summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorStephen Rothwell <sfr@canb.auug.org.au>2009-07-13 17:29:44 +1000
committerStephen Rothwell <sfr@canb.auug.org.au>2009-07-13 17:29:44 +1000
commitb7271709219ba70760ae324dd0accb3f5839a14e (patch)
tree62ab14e1f08c20a29585f3b5abb8b50b217e196d
parent271a8472fb7a3597ac069db78c8187be4c30cc1c (diff)
parentb2bcd06c57cfb4a38bb040939ec633f538804026 (diff)
Merge branch 'quilt/staging'
-rw-r--r--drivers/staging/Kconfig6
-rw-r--r--drivers/staging/Makefile3
-rw-r--r--drivers/staging/android/binder.c709
-rw-r--r--drivers/staging/android/lowmemorykiller.c35
-rw-r--r--drivers/staging/android/lowmemorykiller.txt16
-rw-r--r--drivers/staging/at76_usb/at76_usb.c131
-rw-r--r--drivers/staging/comedi/comedi.h1002
-rw-r--r--drivers/staging/comedi/comedi_compat32.c115
-rw-r--r--drivers/staging/comedi/comedi_compat32.h4
-rw-r--r--drivers/staging/comedi/comedi_fops.c278
-rw-r--r--drivers/staging/comedi/comedi_ksyms.c3
-rw-r--r--drivers/staging/comedi/comedidev.h85
-rw-r--r--drivers/staging/comedi/comedilib.h77
-rw-r--r--drivers/staging/comedi/drivers.c184
-rw-r--r--drivers/staging/comedi/drivers/8253.h69
-rw-r--r--drivers/staging/comedi/drivers/8255.c54
-rw-r--r--drivers/staging/comedi/drivers/8255.h16
-rw-r--r--drivers/staging/comedi/drivers/acl7225b.c22
-rw-r--r--drivers/staging/comedi/drivers/adl_pci6208.c93
-rw-r--r--drivers/staging/comedi/drivers/adl_pci7296.c39
-rw-r--r--drivers/staging/comedi/drivers/adl_pci7432.c57
-rw-r--r--drivers/staging/comedi/drivers/adl_pci8164.c126
-rw-r--r--drivers/staging/comedi/drivers/adl_pci9111.c361
-rw-r--r--drivers/staging/comedi/drivers/adl_pci9118.c532
-rw-r--r--drivers/staging/comedi/drivers/adq12b.c371
-rw-r--r--drivers/staging/comedi/drivers/adv_pci1710.c417
-rw-r--r--drivers/staging/comedi/drivers/adv_pci1723.c73
-rw-r--r--drivers/staging/comedi/drivers/adv_pci_dio.c306
-rw-r--r--drivers/staging/comedi/drivers/aio_aio12_8.c36
-rw-r--r--drivers/staging/comedi/drivers/aio_iiro_16.c30
-rw-r--r--drivers/staging/comedi/drivers/amplc_dio200.c314
-rw-r--r--drivers/staging/comedi/drivers/amplc_pc236.c118
-rw-r--r--drivers/staging/comedi/drivers/amplc_pc263.c101
-rw-r--r--drivers/staging/comedi/drivers/amplc_pci224.c260
-rw-r--r--drivers/staging/comedi/drivers/amplc_pci230.c495
-rw-r--r--drivers/staging/comedi/drivers/c6xdigio.c42
-rw-r--r--drivers/staging/comedi/drivers/cb_das16_cs.c166
-rw-r--r--drivers/staging/comedi/drivers/cb_pcidas.c671
-rw-r--r--drivers/staging/comedi/drivers/cb_pcidas64.c1788
-rw-r--r--drivers/staging/comedi/drivers/cb_pcidda.c218
-rw-r--r--drivers/staging/comedi/drivers/cb_pcidio.c74
-rw-r--r--drivers/staging/comedi/drivers/cb_pcimdas.c89
-rw-r--r--drivers/staging/comedi/drivers/cb_pcimdda.c61
-rw-r--r--drivers/staging/comedi/drivers/comedi_bond.c56
-rw-r--r--drivers/staging/comedi/drivers/comedi_fc.c14
-rw-r--r--drivers/staging/comedi/drivers/comedi_fc.h4
-rw-r--r--drivers/staging/comedi/drivers/comedi_parport.c29
-rw-r--r--drivers/staging/comedi/drivers/comedi_test.c143
-rw-r--r--drivers/staging/comedi/drivers/contec_pci_dio.c48
-rw-r--r--drivers/staging/comedi/drivers/daqboard2000.c119
-rw-r--r--drivers/staging/comedi/drivers/das08.c622
-rw-r--r--drivers/staging/comedi/drivers/das08.h3
-rw-r--r--drivers/staging/comedi/drivers/das08_cs.c24
-rw-r--r--drivers/staging/comedi/drivers/das16.c828
-rw-r--r--drivers/staging/comedi/drivers/das16m1.c132
-rw-r--r--drivers/staging/comedi/drivers/das1800.c658
-rw-r--r--drivers/staging/comedi/drivers/das6402.c23
-rw-r--r--drivers/staging/comedi/drivers/das800.c224
-rw-r--r--drivers/staging/comedi/drivers/dmm32at.c144
-rw-r--r--drivers/staging/comedi/drivers/dt2801.c242
-rw-r--r--drivers/staging/comedi/drivers/dt2811.c178
-rw-r--r--drivers/staging/comedi/drivers/dt2814.c16
-rw-r--r--drivers/staging/comedi/drivers/dt2815.c38
-rw-r--r--drivers/staging/comedi/drivers/dt2817.c19
-rw-r--r--drivers/staging/comedi/drivers/dt282x.c264
-rw-r--r--drivers/staging/comedi/drivers/dt3000.c145
-rw-r--r--drivers/staging/comedi/drivers/dt9812.c85
-rw-r--r--drivers/staging/comedi/drivers/fl512.c37
-rw-r--r--drivers/staging/comedi/drivers/gsc_hpdi.c236
-rw-r--r--drivers/staging/comedi/drivers/icp_multi.c198
-rw-r--r--drivers/staging/comedi/drivers/icp_multi.h74
-rw-r--r--drivers/staging/comedi/drivers/ii_pci20kc.c127
-rw-r--r--drivers/staging/comedi/drivers/jr3_pci.c300
-rw-r--r--drivers/staging/comedi/drivers/jr3_pci.h40
-rw-r--r--drivers/staging/comedi/drivers/ke_counter.c67
-rw-r--r--drivers/staging/comedi/drivers/me4000.c881
-rw-r--r--drivers/staging/comedi/drivers/me_daq.c218
-rw-r--r--drivers/staging/comedi/drivers/mite.c138
-rw-r--r--drivers/staging/comedi/drivers/mite.h144
-rw-r--r--drivers/staging/comedi/drivers/mpc624.c48
-rw-r--r--drivers/staging/comedi/drivers/mpc8260cpm.c26
-rw-r--r--drivers/staging/comedi/drivers/multiq3.c45
-rw-r--r--drivers/staging/comedi/drivers/ni_6527.c107
-rw-r--r--drivers/staging/comedi/drivers/ni_65xx.c400
-rw-r--r--drivers/staging/comedi/drivers/ni_660x.c291
-rw-r--r--drivers/staging/comedi/drivers/ni_670x.c99
-rw-r--r--drivers/staging/comedi/drivers/ni_at_a2150.c93
-rw-r--r--drivers/staging/comedi/drivers/ni_at_ao.c69
-rw-r--r--drivers/staging/comedi/drivers/ni_atmio.c318
-rw-r--r--drivers/staging/comedi/drivers/ni_atmio16d.c126
-rw-r--r--drivers/staging/comedi/drivers/ni_daq_700.c80
-rw-r--r--drivers/staging/comedi/drivers/ni_daq_dio24.c43
-rw-r--r--drivers/staging/comedi/drivers/ni_labpc.c452
-rw-r--r--drivers/staging/comedi/drivers/ni_labpc.h5
-rw-r--r--drivers/staging/comedi/drivers/ni_labpc_cs.c70
-rw-r--r--drivers/staging/comedi/drivers/ni_mio_common.c1662
-rw-r--r--drivers/staging/comedi/drivers/ni_mio_cs.c36
-rw-r--r--drivers/staging/comedi/drivers/ni_pcidio.c341
-rw-r--r--drivers/staging/comedi/drivers/ni_pcimio.c2063
-rw-r--r--drivers/staging/comedi/drivers/ni_stc.h64
-rw-r--r--drivers/staging/comedi/drivers/ni_tio.c475
-rw-r--r--drivers/staging/comedi/drivers/ni_tio.h47
-rw-r--r--drivers/staging/comedi/drivers/ni_tio_internal.h58
-rw-r--r--drivers/staging/comedi/drivers/ni_tiocmd.c105
-rw-r--r--drivers/staging/comedi/drivers/pcl711.c107
-rw-r--r--drivers/staging/comedi/drivers/pcl724.c33
-rw-r--r--drivers/staging/comedi/drivers/pcl725.c7
-rw-r--r--drivers/staging/comedi/drivers/pcl726.c59
-rw-r--r--drivers/staging/comedi/drivers/pcl730.c16
-rw-r--r--drivers/staging/comedi/drivers/pcl812.c480
-rw-r--r--drivers/staging/comedi/drivers/pcl816.c220
-rw-r--r--drivers/staging/comedi/drivers/pcl818.c338
-rw-r--r--drivers/staging/comedi/drivers/pcm3724.c28
-rw-r--r--drivers/staging/comedi/drivers/pcm3730.c16
-rw-r--r--drivers/staging/comedi/drivers/pcmad.c17
-rw-r--r--drivers/staging/comedi/drivers/pcmda12.c25
-rw-r--r--drivers/staging/comedi/drivers/pcmmio.c287
-rw-r--r--drivers/staging/comedi/drivers/pcmuio.c228
-rw-r--r--drivers/staging/comedi/drivers/plx9080.h8
-rw-r--r--drivers/staging/comedi/drivers/poc.c102
-rw-r--r--drivers/staging/comedi/drivers/quatech_daqp_cs.c115
-rw-r--r--drivers/staging/comedi/drivers/rtd520.c487
-rw-r--r--drivers/staging/comedi/drivers/rti800.c83
-rw-r--r--drivers/staging/comedi/drivers/rti802.c21
-rw-r--r--drivers/staging/comedi/drivers/s526.c203
-rw-r--r--drivers/staging/comedi/drivers/s626.c1047
-rw-r--r--drivers/staging/comedi/drivers/s626.h16
-rw-r--r--drivers/staging/comedi/drivers/serial2002.c201
-rw-r--r--drivers/staging/comedi/drivers/skel.c82
-rw-r--r--drivers/staging/comedi/drivers/ssv_dnp.c40
-rw-r--r--drivers/staging/comedi/drivers/unioxx5.c106
-rw-r--r--drivers/staging/comedi/drivers/usbdux.c268
-rw-r--r--drivers/staging/comedi/drivers/usbduxfast.c459
-rw-r--r--drivers/staging/comedi/drivers/vmk80xx.c135
-rw-r--r--drivers/staging/comedi/kcomedilib/data.c12
-rw-r--r--drivers/staging/comedi/kcomedilib/dio.c8
-rw-r--r--drivers/staging/comedi/kcomedilib/get.c55
-rw-r--r--drivers/staging/comedi/kcomedilib/kcomedilib_main.c35
-rw-r--r--drivers/staging/comedi/kcomedilib/ksyms.c4
-rw-r--r--drivers/staging/comedi/proc.c23
-rw-r--r--drivers/staging/comedi/range.c21
-rw-r--r--drivers/staging/cpc-usb/cpc-usb_drv.c1
-rw-r--r--drivers/staging/et131x/et1310_address_map.h2138
-rw-r--r--drivers/staging/et131x/et1310_eeprom.c46
-rw-r--r--drivers/staging/et131x/et1310_eeprom.h6
-rw-r--r--drivers/staging/et131x/et1310_jagcore.c20
-rw-r--r--drivers/staging/et131x/et1310_jagcore.h17
-rw-r--r--drivers/staging/et131x/et1310_mac.c112
-rw-r--r--drivers/staging/et131x/et1310_mac.h8
-rw-r--r--drivers/staging/et131x/et1310_phy.c202
-rw-r--r--drivers/staging/et131x/et1310_phy.h904
-rw-r--r--drivers/staging/et131x/et1310_pm.c19
-rw-r--r--drivers/staging/et131x/et1310_pm.h8
-rw-r--r--drivers/staging/et131x/et1310_rx.c115
-rw-r--r--drivers/staging/et131x/et1310_rx.h194
-rw-r--r--drivers/staging/et131x/et1310_tx.c120
-rw-r--r--drivers/staging/et131x/et1310_tx.h102
-rw-r--r--drivers/staging/et131x/et131x_adapter.h72
-rw-r--r--drivers/staging/et131x/et131x_config.c38
-rw-r--r--drivers/staging/et131x/et131x_debug.c12
-rw-r--r--drivers/staging/et131x/et131x_debug.h24
-rw-r--r--drivers/staging/et131x/et131x_defs.h12
-rw-r--r--drivers/staging/et131x/et131x_initpci.c74
-rw-r--r--drivers/staging/et131x/et131x_initpci.h6
-rw-r--r--drivers/staging/et131x/et131x_isr.c44
-rw-r--r--drivers/staging/et131x/et131x_isr.h6
-rw-r--r--drivers/staging/et131x/et131x_netdev.c123
-rw-r--r--drivers/staging/et131x/et131x_netdev.h6
-rw-r--r--drivers/staging/et131x/et131x_version.h6
-rw-r--r--drivers/staging/meilhaus/TODO2
-rw-r--r--drivers/staging/otus/ioctl.c25
-rw-r--r--drivers/staging/otus/usbdrv.c14
-rw-r--r--drivers/staging/otus/wrap_buf.c3
-rw-r--r--drivers/staging/otus/wrap_dbg.c3
-rw-r--r--drivers/staging/otus/wrap_ev.c7
-rw-r--r--drivers/staging/otus/wrap_mem.c3
-rw-r--r--drivers/staging/otus/wrap_mis.c3
-rw-r--r--drivers/staging/otus/wrap_pkt.c4
-rw-r--r--drivers/staging/otus/wrap_sec.c3
-rw-r--r--drivers/staging/otus/wrap_usb.c3
-rw-r--r--drivers/staging/otus/wwrap.c8
-rw-r--r--drivers/staging/otus/zdcompat.h10
-rw-r--r--drivers/staging/quatech_usb2/Kconfig15
-rw-r--r--drivers/staging/quatech_usb2/Makefile1
-rw-r--r--drivers/staging/quatech_usb2/quatech_usb2.c611
-rw-r--r--drivers/staging/rspiusb/rspiusb.c14
-rw-r--r--drivers/staging/rt2860/rt_linux.h33
-rw-r--r--drivers/staging/rt2860/rt_main_dev.c2
-rw-r--r--drivers/staging/rt2860/sta_ioctl.c7
-rw-r--r--drivers/staging/rt2870/2870_main_dev.c4
-rw-r--r--drivers/staging/rt2870/rt2870.h6
-rw-r--r--drivers/staging/rt3090/Kconfig5
-rw-r--r--drivers/staging/rt3090/Makefile80
-rw-r--r--drivers/staging/rt3090/action.h66
-rw-r--r--drivers/staging/rt3090/ap.h512
-rw-r--r--drivers/staging/rt3090/ap_apcli.h276
-rw-r--r--drivers/staging/rt3090/ap_autoChSel.h79
-rw-r--r--drivers/staging/rt3090/ap_autoChSel_cmm.h66
-rw-r--r--drivers/staging/rt3090/ap_cfg.h118
-rw-r--r--drivers/staging/rt3090/ap_ids.h82
-rw-r--r--drivers/staging/rt3090/ap_mbss.h72
-rw-r--r--drivers/staging/rt3090/ap_uapsd.h636
-rw-r--r--drivers/staging/rt3090/ap_wds.h212
-rw-r--r--drivers/staging/rt3090/chips/rt3090.c123
-rw-r--r--drivers/staging/rt3090/chips/rt30xx.c525
-rw-r--r--drivers/staging/rt3090/chips/rt3370.c121
-rw-r--r--drivers/staging/rt3090/chips/rt3390.c122
-rw-r--r--drivers/staging/rt3090/chips/rt33xx.c536
-rw-r--r--drivers/staging/rt3090/chlist.h130
-rw-r--r--drivers/staging/rt3090/common/action.c1057
-rw-r--r--drivers/staging/rt3090/common/ba_action.c1779
-rw-r--r--drivers/staging/rt3090/common/cmm_aes.c1560
-rw-r--r--drivers/staging/rt3090/common/cmm_asic.c2753
-rw-r--r--drivers/staging/rt3090/common/cmm_cfg.c295
-rw-r--r--drivers/staging/rt3090/common/cmm_data.c2763
-rw-r--r--drivers/staging/rt3090/common/cmm_data_pci.c1576
-rw-r--r--drivers/staging/rt3090/common/cmm_info.c3717
-rw-r--r--drivers/staging/rt3090/common/cmm_mac_pci.c1757
-rw-r--r--drivers/staging/rt3090/common/cmm_profile.c2321
-rw-r--r--drivers/staging/rt3090/common/cmm_sanity.c1718
-rw-r--r--drivers/staging/rt3090/common/cmm_sync.c734
-rw-r--r--drivers/staging/rt3090/common/cmm_tkip.c966
-rw-r--r--drivers/staging/rt3090/common/cmm_wep.c500
-rw-r--r--drivers/staging/rt3090/common/cmm_wpa.c3149
-rw-r--r--drivers/staging/rt3090/common/crypt_aes.c1007
-rw-r--r--drivers/staging/rt3090/common/crypt_biginteger.c1119
-rw-r--r--drivers/staging/rt3090/common/crypt_dh.c234
-rw-r--r--drivers/staging/rt3090/common/crypt_hmac.c279
-rw-r--r--drivers/staging/rt3090/common/crypt_md5.c353
-rw-r--r--drivers/staging/rt3090/common/crypt_sha2.c536
-rw-r--r--drivers/staging/rt3090/common/dfs.c481
-rw-r--r--drivers/staging/rt3090/common/ee_efuse.c1548
-rw-r--r--drivers/staging/rt3090/common/ee_prom.c308
-rw-r--r--drivers/staging/rt3090/common/eeprom.c98
-rw-r--r--drivers/staging/rt3090/common/igmp_snoop.c1365
-rw-r--r--drivers/staging/rt3090/common/mlme.c6550
-rw-r--r--drivers/staging/rt3090/common/mlme_ex.c215
-rw-r--r--drivers/staging/rt3090/common/netif_block.c147
-rw-r--r--drivers/staging/rt3090/common/rt_channel.c1287
-rw-r--r--drivers/staging/rt3090/common/rt_rf.c201
-rw-r--r--drivers/staging/rt3090/common/rtmp_init.c3882
-rw-r--r--drivers/staging/rt3090/common/rtmp_mcu.c560
-rw-r--r--drivers/staging/rt3090/common/rtmp_timer.c327
-rw-r--r--drivers/staging/rt3090/common/spectrum.c2221
-rw-r--r--drivers/staging/rt3090/config.mk187
-rw-r--r--drivers/staging/rt3090/crypt_hmac.h81
-rw-r--r--drivers/staging/rt3090/crypt_md5.h78
-rw-r--r--drivers/staging/rt3090/crypt_sha2.h107
-rw-r--r--drivers/staging/rt3090/dfs.h137
-rw-r--r--drivers/staging/rt3090/eeprom.h82
-rw-r--r--drivers/staging/rt3090/firmware.h517
-rw-r--r--drivers/staging/rt3090/igmp_snoop.h152
-rw-r--r--drivers/staging/rt3090/ipv6.h215
-rw-r--r--drivers/staging/rt3090/link_list.h133
-rw-r--r--drivers/staging/rt3090/mac_pci.h454
-rw-r--r--drivers/staging/rt3090/mlme.h1360
-rw-r--r--drivers/staging/rt3090/mlme_ex.h83
-rw-r--r--drivers/staging/rt3090/mlme_ex_def.h53
-rw-r--r--drivers/staging/rt3090/netif_block.h56
-rw-r--r--drivers/staging/rt3090/oid.h1144
-rw-r--r--drivers/staging/rt3090/pci_main_dev.c1194
-rw-r--r--drivers/staging/rt3090/rt3090.h77
-rw-r--r--drivers/staging/rt3090/rt30xx.h (renamed from drivers/staging/rt2860/md4.h)30
-rw-r--r--drivers/staging/rt3090/rt3370.h64
-rw-r--r--drivers/staging/rt3090/rt3390.h77
-rw-r--r--drivers/staging/rt3090/rt33xx.h (renamed from drivers/staging/rt2870/md4.h)30
-rw-r--r--drivers/staging/rt3090/rt_ate.c6089
-rw-r--r--drivers/staging/rt3090/rt_ate.h314
-rw-r--r--drivers/staging/rt3090/rt_config.h126
-rw-r--r--drivers/staging/rt3090/rt_linux.c1623
-rw-r--r--drivers/staging/rt3090/rt_linux.h1034
-rw-r--r--drivers/staging/rt3090/rt_main_dev.c897
-rw-r--r--drivers/staging/rt3090/rt_pci_rbus.c989
-rw-r--r--drivers/staging/rt3090/rt_profile.c101
-rw-r--r--drivers/staging/rt3090/rtmp.h6873
-rw-r--r--drivers/staging/rt3090/rtmp_chip.h355
-rw-r--r--drivers/staging/rt3090/rtmp_def.h1650
-rw-r--r--drivers/staging/rt3090/rtmp_dot11.h146
-rw-r--r--drivers/staging/rt3090/rtmp_iface.h81
-rw-r--r--drivers/staging/rt3090/rtmp_mac.h2304
-rw-r--r--drivers/staging/rt3090/rtmp_mcu.h55
-rw-r--r--drivers/staging/rt3090/rtmp_os.h93
-rw-r--r--drivers/staging/rt3090/rtmp_pci.h110
-rw-r--r--drivers/staging/rt3090/rtmp_phy.h631
-rw-r--r--drivers/staging/rt3090/rtmp_timer.h162
-rw-r--r--drivers/staging/rt3090/rtmp_type.h147
-rw-r--r--drivers/staging/rt3090/spectrum.h234
-rw-r--r--drivers/staging/rt3090/spectrum_def.h257
-rw-r--r--drivers/staging/rt3090/sta/assoc.c1673
-rw-r--r--drivers/staging/rt3090/sta/auth.c491
-rw-r--r--drivers/staging/rt3090/sta/auth_rsp.c151
-rw-r--r--drivers/staging/rt3090/sta/connect.c2759
-rw-r--r--drivers/staging/rt3090/sta/dls.c2207
-rw-r--r--drivers/staging/rt3090/sta/rtmp_ckipmic.c579
-rw-r--r--drivers/staging/rt3090/sta/rtmp_data.c2661
-rw-r--r--drivers/staging/rt3090/sta/sanity.c382
-rw-r--r--drivers/staging/rt3090/sta/sync.c1840
-rw-r--r--drivers/staging/rt3090/sta/wpa.c396
-rw-r--r--drivers/staging/rt3090/sta_ioctl.c7559
-rw-r--r--drivers/staging/rt3090/vr_ikans.h71
-rw-r--r--drivers/staging/rt3090/wpa.h447
-rw-r--r--drivers/staging/rtl8187se/Makefile14
-rw-r--r--drivers/staging/rtl8187se/TODO21
-rw-r--r--drivers/staging/rtl8187se/dot11d.h101
-rw-r--r--drivers/staging/rtl8187se/ieee80211.h1755
-rw-r--r--drivers/staging/rtl8187se/ieee80211/dot11d.c22
-rw-r--r--drivers/staging/rtl8187se/ieee80211/dot11d.h2
-rw-r--r--drivers/staging/rtl8187se/ieee80211/ieee80211.h140
-rw-r--r--drivers/staging/rtl8187se/ieee80211/ieee80211_crypt.c17
-rw-r--r--drivers/staging/rtl8187se/ieee80211/ieee80211_crypt_ccmp.c73
-rw-r--r--drivers/staging/rtl8187se/ieee80211/ieee80211_crypt_tkip.c293
-rw-r--r--drivers/staging/rtl8187se/ieee80211/ieee80211_crypt_wep.c120
-rw-r--r--drivers/staging/rtl8187se/ieee80211/ieee80211_module.c88
-rw-r--r--drivers/staging/rtl8187se/ieee80211/ieee80211_rx.c242
-rw-r--r--drivers/staging/rtl8187se/ieee80211/ieee80211_softmac.c995
-rw-r--r--drivers/staging/rtl8187se/ieee80211/ieee80211_softmac_wx.c42
-rw-r--r--drivers/staging/rtl8187se/ieee80211/ieee80211_tx.c241
-rw-r--r--drivers/staging/rtl8187se/ieee80211/ieee80211_wx.c123
-rw-r--r--drivers/staging/rtl8187se/ieee80211/internal.h115
-rw-r--r--drivers/staging/rtl8187se/ieee80211/rtl_crypto.h399
-rw-r--r--drivers/staging/rtl8187se/ieee80211_crypt.h86
-rw-r--r--drivers/staging/rtl8187se/r8180.h24
-rw-r--r--drivers/staging/rtl8187se/r8180_93cx6.h2
-rw-r--r--drivers/staging/rtl8187se/r8180_core.c2946
-rw-r--r--drivers/staging/rtl8187se/r8180_dm.c58
-rw-r--r--drivers/staging/rtl8187se/r8180_dm.h18
-rw-r--r--drivers/staging/rtl8187se/r8180_gct.c296
-rw-r--r--drivers/staging/rtl8187se/r8180_gct.h25
-rw-r--r--drivers/staging/rtl8187se/r8180_hw.h393
-rw-r--r--drivers/staging/rtl8187se/r8180_max2820.c240
-rw-r--r--drivers/staging/rtl8187se/r8180_max2820.h21
-rw-r--r--drivers/staging/rtl8187se/r8180_pm.c92
-rw-r--r--drivers/staging/rtl8187se/r8180_pm.h28
-rw-r--r--drivers/staging/rtl8187se/r8180_rtl8225.c933
-rw-r--r--drivers/staging/rtl8187se/r8180_rtl8225.h12
-rw-r--r--drivers/staging/rtl8187se/r8180_rtl8225z2.c1552
-rw-r--r--drivers/staging/rtl8187se/r8180_rtl8255.c1838
-rw-r--r--drivers/staging/rtl8187se/r8180_rtl8255.h19
-rw-r--r--drivers/staging/rtl8187se/r8180_sa2400.c233
-rw-r--r--drivers/staging/rtl8187se/r8180_sa2400.h26
-rw-r--r--drivers/staging/rtl8187se/r8180_wx.c51
-rw-r--r--drivers/staging/rtl8187se/r8180_wx.h2
-rw-r--r--drivers/staging/rtl8187se/r8185b_init.c663
-rw-r--r--drivers/staging/rtl8192su/Kconfig2
-rw-r--r--drivers/staging/rtl8192su/Makefile23
-rw-r--r--drivers/staging/rtl8192su/TODO23
-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/Makefile3
-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.c18
-rw-r--r--drivers/staging/rtl8192su/ieee80211/dot11d.h4
-rw-r--r--drivers/staging/rtl8192su/ieee80211/ieee80211.h354
-rw-r--r--drivers/staging/rtl8192su/ieee80211/ieee80211_crypt.c14
-rw-r--r--drivers/staging/rtl8192su/ieee80211/ieee80211_crypt.h7
-rw-r--r--drivers/staging/rtl8192su/ieee80211/ieee80211_crypt_ccmp.c51
-rw-r--r--drivers/staging/rtl8192su/ieee80211/ieee80211_crypt_tkip.c266
-rw-r--r--drivers/staging/rtl8192su/ieee80211/ieee80211_crypt_wep.c113
-rw-r--r--drivers/staging/rtl8192su/ieee80211/ieee80211_module.c65
-rw-r--r--drivers/staging/rtl8192su/ieee80211/ieee80211_rx.c126
-rw-r--r--drivers/staging/rtl8192su/ieee80211/ieee80211_softmac.c338
-rw-r--r--drivers/staging/rtl8192su/ieee80211/ieee80211_softmac_wx.c83
-rw-r--r--drivers/staging/rtl8192su/ieee80211/ieee80211_tx.c22
-rw-r--r--drivers/staging/rtl8192su/ieee80211/ieee80211_wx.c198
-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/rtl819x_BAProc.c43
-rw-r--r--drivers/staging/rtl8192su/ieee80211/rtl819x_HT.h9
-rw-r--r--drivers/staging/rtl8192su/ieee80211/rtl819x_HTProc.c277
-rw-r--r--drivers/staging/rtl8192su/ieee80211/rtl819x_Qos.h168
-rw-r--r--drivers/staging/rtl8192su/ieee80211/rtl819x_TSProc.c34
-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.h5
-rw-r--r--drivers/staging/rtl8192su/r8190_rtl8256.c312
-rw-r--r--drivers/staging/rtl8192su/r8192S_Efuse.c113
-rw-r--r--drivers/staging/rtl8192su/r8192S_firmware.c477
-rw-r--r--drivers/staging/rtl8192su/r8192S_firmware.h5
-rw-r--r--drivers/staging/rtl8192su/r8192S_hw.h184
-rw-r--r--drivers/staging/rtl8192su/r8192S_phy.c923
-rw-r--r--drivers/staging/rtl8192su/r8192S_phy.h5
-rw-r--r--drivers/staging/rtl8192su/r8192S_rtl6052.c104
-rw-r--r--drivers/staging/rtl8192su/r8192S_rtl6052.h47
-rw-r--r--drivers/staging/rtl8192su/r8192U.h528
-rw-r--r--drivers/staging/rtl8192su/r8192U_core.c4835
-rw-r--r--drivers/staging/rtl8192su/r8192U_dm.c549
-rw-r--r--drivers/staging/rtl8192su/r8192U_dm.h55
-rw-r--r--drivers/staging/rtl8192su/r8192U_hw.h746
-rw-r--r--drivers/staging/rtl8192su/r8192U_pm.c19
-rw-r--r--drivers/staging/rtl8192su/r8192U_pm.h2
-rw-r--r--drivers/staging/rtl8192su/r8192U_wx.c128
-rw-r--r--drivers/staging/rtl8192su/r8192U_wx.h1
-rw-r--r--drivers/staging/rtl8192su/r819xU_HTType.h9
-rw-r--r--drivers/staging/rtl8192su/r819xU_cmdpkt.c113
-rw-r--r--drivers/staging/rtl8192su/r819xU_cmdpkt.h20
-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_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_usb2/serqt_usb2.c8
-rw-r--r--drivers/staging/stlc45xx/stlc45xx.c27
-rw-r--r--drivers/staging/vt6655/Kconfig2
-rw-r--r--drivers/staging/vt6655/Makefile2
-rw-r--r--drivers/staging/vt6655/Makefile.arm181
-rw-r--r--drivers/staging/vt6655/Makefile.x86209
-rw-r--r--drivers/staging/vt6655/desc.h9
-rw-r--r--drivers/staging/vt6655/device.h98
-rw-r--r--drivers/staging/vt6655/device_main.c311
-rw-r--r--drivers/staging/vt6655/dpc.c106
-rw-r--r--drivers/staging/vt6655/hostap.c29
-rw-r--r--drivers/staging/vt6655/hostap.h8
-rw-r--r--drivers/staging/vt6655/iwctl.c87
-rw-r--r--drivers/staging/vt6655/iwctl.h87
-rw-r--r--drivers/staging/vt6655/kcompat.h4
-rw-r--r--drivers/staging/vt6655/wctl.c4
-rw-r--r--drivers/staging/vt6656/80211hdr.h358
-rw-r--r--drivers/staging/vt6656/80211mgr.c1050
-rw-r--r--drivers/staging/vt6656/80211mgr.h867
-rw-r--r--drivers/staging/vt6656/Kconfig6
-rw-r--r--drivers/staging/vt6656/Makefile39
-rw-r--r--drivers/staging/vt6656/aes_ccmp.c410
-rw-r--r--drivers/staging/vt6656/aes_ccmp.h48
-rw-r--r--drivers/staging/vt6656/baseband.c2129
-rw-r--r--drivers/staging/vt6656/baseband.h163
-rw-r--r--drivers/staging/vt6656/bssdb.c1768
-rw-r--r--drivers/staging/vt6656/bssdb.h370
-rw-r--r--drivers/staging/vt6656/card.c1147
-rw-r--r--drivers/staging/vt6656/card.h109
-rw-r--r--drivers/staging/vt6656/channel.c535
-rw-r--r--drivers/staging/vt6656/channel.h58
-rw-r--r--drivers/staging/vt6656/control.c116
-rw-r--r--drivers/staging/vt6656/control.h103
-rw-r--r--drivers/staging/vt6656/country.h163
-rw-r--r--drivers/staging/vt6656/datarate.c518
-rw-r--r--drivers/staging/vt6656/datarate.h110
-rw-r--r--drivers/staging/vt6656/desc.h453
-rw-r--r--drivers/staging/vt6656/device.h976
-rw-r--r--drivers/staging/vt6656/device_cfg.h142
-rw-r--r--drivers/staging/vt6656/dpc.c1658
-rw-r--r--drivers/staging/vt6656/dpc.h94
-rw-r--r--drivers/staging/vt6656/firmware.c887
-rw-r--r--drivers/staging/vt6656/firmware.h66
-rw-r--r--drivers/staging/vt6656/hostap.c888
-rw-r--r--drivers/staging/vt6656/hostap.h86
-rw-r--r--drivers/staging/vt6656/int.c214
-rw-r--r--drivers/staging/vt6656/int.h101
-rw-r--r--drivers/staging/vt6656/iocmd.h478
-rw-r--r--drivers/staging/vt6656/ioctl.c724
-rw-r--r--drivers/staging/vt6656/ioctl.h74
-rw-r--r--drivers/staging/vt6656/iowpa.h159
-rw-r--r--drivers/staging/vt6656/iwctl.c2215
-rw-r--r--drivers/staging/vt6656/iwctl.h246
-rw-r--r--drivers/staging/vt6656/kcompat.h83
-rw-r--r--drivers/staging/vt6656/key.c886
-rw-r--r--drivers/staging/vt6656/key.h196
-rw-r--r--drivers/staging/vt6656/mac.c500
-rw-r--r--drivers/staging/vt6656/mac.h458
-rw-r--r--drivers/staging/vt6656/main_usb.c2256
-rw-r--r--drivers/staging/vt6656/mib.c592
-rw-r--r--drivers/staging/vt6656/mib.h445
-rw-r--r--drivers/staging/vt6656/michael.c188
-rw-r--r--drivers/staging/vt6656/michael.h62
-rw-r--r--drivers/staging/vt6656/power.c458
-rw-r--r--drivers/staging/vt6656/power.h84
-rw-r--r--drivers/staging/vt6656/rc4.c89
-rw-r--r--drivers/staging/vt6656/rc4.h51
-rw-r--r--drivers/staging/vt6656/rf.c1163
-rw-r--r--drivers/staging/vt6656/rf.h112
-rw-r--r--drivers/staging/vt6656/rndis.h162
-rw-r--r--drivers/staging/vt6656/rxtx.c3280
-rw-r--r--drivers/staging/vt6656/rxtx.h716
-rw-r--r--drivers/staging/vt6656/srom.h144
-rw-r--r--drivers/staging/vt6656/tbit.h78
-rw-r--r--drivers/staging/vt6656/tcrc.c207
-rw-r--r--drivers/staging/vt6656/tcrc.h71
-rw-r--r--drivers/staging/vt6656/tether.c123
-rw-r--r--drivers/staging/vt6656/tether.h256
-rw-r--r--drivers/staging/vt6656/tkip.c284
-rw-r--r--drivers/staging/vt6656/tkip.h76
-rw-r--r--drivers/staging/vt6656/tmacro.h152
-rw-r--r--drivers/staging/vt6656/tpci.h119
-rw-r--r--drivers/staging/vt6656/ttype.h399
-rw-r--r--drivers/staging/vt6656/umem.h75
-rw-r--r--drivers/staging/vt6656/upc.h171
-rw-r--r--drivers/staging/vt6656/usbpipe.c857
-rw-r--r--drivers/staging/vt6656/usbpipe.h116
-rw-r--r--drivers/staging/vt6656/vntconfiguration.dat6
-rw-r--r--drivers/staging/vt6656/wcmd.c1397
-rw-r--r--drivers/staging/vt6656/wcmd.h156
-rw-r--r--drivers/staging/vt6656/wctl.c263
-rw-r--r--drivers/staging/vt6656/wctl.h127
-rw-r--r--drivers/staging/vt6656/wmgr.c4993
-rw-r--r--drivers/staging/vt6656/wmgr.h519
-rw-r--r--drivers/staging/vt6656/wpa.c339
-rw-r--r--drivers/staging/vt6656/wpa.h98
-rw-r--r--drivers/staging/vt6656/wpa2.c373
-rw-r--r--drivers/staging/vt6656/wpa2.h99
-rw-r--r--drivers/staging/vt6656/wpactl.c1030
-rw-r--r--drivers/staging/vt6656/wpactl.h90
-rw-r--r--drivers/staging/wlan-ng/hfa384x_usb.c205
-rw-r--r--drivers/staging/wlan-ng/p80211conv.c12
-rw-r--r--drivers/staging/wlan-ng/p80211hdr.h15
-rw-r--r--drivers/staging/wlan-ng/p80211meta.h6
-rw-r--r--drivers/staging/wlan-ng/p80211mgmt.h6
-rw-r--r--drivers/staging/wlan-ng/p80211msg.h6
-rw-r--r--drivers/staging/wlan-ng/p80211netdev.c62
-rw-r--r--drivers/staging/wlan-ng/p80211netdev.h3
-rw-r--r--drivers/staging/wlan-ng/p80211req.c12
-rw-r--r--drivers/staging/wlan-ng/p80211types.h4
-rw-r--r--drivers/staging/wlan-ng/p80211wep.c27
-rw-r--r--drivers/staging/wlan-ng/p80211wext.c77
-rw-r--r--drivers/staging/wlan-ng/prism2fw.c46
-rw-r--r--drivers/staging/wlan-ng/prism2mgmt.c23
-rw-r--r--drivers/staging/wlan-ng/prism2mib.c144
-rw-r--r--drivers/staging/wlan-ng/prism2sta.c153
-rw-r--r--drivers/staging/wlan-ng/prism2usb.c10
529 files changed, 168458 insertions, 51384 deletions
diff --git a/drivers/staging/Kconfig b/drivers/staging/Kconfig
index 348bf61a8fec..a0eeb2c6a6dd 100644
--- a/drivers/staging/Kconfig
+++ b/drivers/staging/Kconfig
@@ -75,6 +75,8 @@ source "drivers/staging/rt2870/Kconfig"
source "drivers/staging/rt3070/Kconfig"
+source "drivers/staging/rt3090/Kconfig"
+
source "drivers/staging/comedi/Kconfig"
source "drivers/staging/asus_oled/Kconfig"
@@ -121,8 +123,12 @@ source "drivers/staging/octeon/Kconfig"
source "drivers/staging/serqt_usb2/Kconfig"
+source "drivers/staging/quatech_usb2/Kconfig"
+
source "drivers/staging/vt6655/Kconfig"
+source "drivers/staging/vt6656/Kconfig"
+
source "drivers/staging/cpc-usb/Kconfig"
source "drivers/staging/pata_rdc/Kconfig"
diff --git a/drivers/staging/Makefile b/drivers/staging/Makefile
index 8d61d7b4debf..ea387f568954 100644
--- a/drivers/staging/Makefile
+++ b/drivers/staging/Makefile
@@ -20,6 +20,7 @@ obj-$(CONFIG_OTUS) += otus/
obj-$(CONFIG_RT2860) += rt2860/
obj-$(CONFIG_RT2870) += rt2870/
obj-$(CONFIG_RT3070) += rt3070/
+obj-$(CONFIG_RT3090) += rt3090/
obj-$(CONFIG_COMEDI) += comedi/
obj-$(CONFIG_ASUS_OLED) += asus_oled/
obj-$(CONFIG_PANEL) += panel/
@@ -41,8 +42,10 @@ obj-$(CONFIG_PLAN9AUTH) += p9auth/
obj-$(CONFIG_HECI) += heci/
obj-$(CONFIG_LINE6_USB) += line6/
obj-$(CONFIG_USB_SERIAL_QUATECH2) += serqt_usb2/
+obj-$(CONFIG_USB_SERIAL_QUATECH_USB2) += quatech_usb2/
obj-$(CONFIG_OCTEON_ETHERNET) += octeon/
obj-$(CONFIG_VT6655) += vt6655/
+obj-$(CONFIG_VT6656) += vt6656/
obj-$(CONFIG_USB_CPC) += cpc-usb/
obj-$(CONFIG_RDC_17F3101X) += pata_rdc/
obj-$(CONFIG_FB_UDL) += udlfb/
diff --git a/drivers/staging/android/binder.c b/drivers/staging/android/binder.c
index 17d89a8124ad..c6dc58eee400 100644
--- a/drivers/staging/android/binder.c
+++ b/drivers/staging/android/binder.c
@@ -31,18 +31,21 @@
#include <linux/sched.h>
#include <linux/uaccess.h>
#include <linux/vmalloc.h>
+
#include "binder.h"
static DEFINE_MUTEX(binder_lock);
+static DEFINE_MUTEX(binder_deferred_lock);
+
static HLIST_HEAD(binder_procs);
+static HLIST_HEAD(binder_deferred_list);
+static HLIST_HEAD(binder_dead_nodes);
+
+static struct proc_dir_entry *binder_proc_dir_entry_root;
+static struct proc_dir_entry *binder_proc_dir_entry_proc;
static struct binder_node *binder_context_mgr_node;
static uid_t binder_context_mgr_uid = -1;
static int binder_last_id;
-static struct proc_dir_entry *binder_proc_dir_entry_root;
-static struct proc_dir_entry *binder_proc_dir_entry_proc;
-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);
@@ -100,6 +103,12 @@ static int binder_set_stop_on_user_error(const char *val,
module_param_call(stop_on_user_error, binder_set_stop_on_user_error,
param_get_int, &binder_stop_on_user_error, S_IWUSR | S_IRUGO);
+#define binder_debug(mask, x...) \
+ do { \
+ if (binder_debug_mask & mask) \
+ printk(KERN_INFO x); \
+ } while (0)
+
#define binder_user_error(x...) \
do { \
if (binder_debug_mask & BINDER_DEBUG_USER_ERROR) \
@@ -108,7 +117,7 @@ module_param_call(stop_on_user_error, binder_set_stop_on_user_error,
binder_stop_on_user_error = 2; \
} while (0)
-enum {
+enum binder_stat_types {
BINDER_STAT_PROC,
BINDER_STAT_THREAD,
BINDER_STAT_NODE,
@@ -128,6 +137,16 @@ struct binder_stats {
static struct binder_stats binder_stats;
+static inline void binder_stats_deleted(enum binder_stat_types type)
+{
+ binder_stats.obj_deleted[type]++;
+}
+
+static inline void binder_stats_created(enum binder_stat_types type)
+{
+ binder_stats.obj_created[type]++;
+}
+
struct binder_transaction_log_entry {
int debug_id;
int call_type;
@@ -237,7 +256,7 @@ struct binder_buffer {
uint8_t data[0];
};
-enum {
+enum binder_deferred_state {
BINDER_DEFERRED_PUT_FILES = 0x01,
BINDER_DEFERRED_FLUSH = 0x02,
BINDER_DEFERRED_RELEASE = 0x04,
@@ -320,7 +339,8 @@ struct binder_transaction {
uid_t sender_euid;
};
-static void binder_defer_work(struct binder_proc *proc, int defer);
+static void
+binder_defer_work(struct binder_proc *proc, enum binder_deferred_state defer);
/*
* copied from get_unused_fd_flags
@@ -468,9 +488,9 @@ static void binder_set_nice(long nice)
return;
}
min_nice = 20 - current->signal->rlim[RLIMIT_NICE].rlim_cur;
- if (binder_debug_mask & BINDER_DEBUG_PRIORITY_CAP)
- printk(KERN_INFO "binder: %d: nice value %ld not allowed use "
- "%ld instead\n", current->pid, nice, min_nice);
+ binder_debug(BINDER_DEBUG_PRIORITY_CAP,
+ "binder: %d: nice value %ld not allowed use "
+ "%ld instead\n", current->pid, nice, min_nice);
set_user_nice(current, min_nice);
if (min_nice < 20)
return;
@@ -500,9 +520,9 @@ static void binder_insert_free_buffer(struct binder_proc *proc,
new_buffer_size = binder_buffer_size(proc, new_buffer);
- if (binder_debug_mask & BINDER_DEBUG_BUFFER_ALLOC)
- printk(KERN_INFO "binder: %d: add free buffer, size %zd, "
- "at %p\n", proc->pid, new_buffer_size, new_buffer);
+ binder_debug(BINDER_DEBUG_BUFFER_ALLOC,
+ "binder: %d: add free buffer, size %zd, "
+ "at %p\n", proc->pid, new_buffer_size, new_buffer);
while (*p) {
parent = *p;
@@ -579,9 +599,9 @@ static int binder_update_page_range(struct binder_proc *proc, int allocate,
struct page **page;
struct mm_struct *mm;
- if (binder_debug_mask & BINDER_DEBUG_BUFFER_ALLOC)
- printk(KERN_INFO "binder: %d: %s pages %p-%p\n",
- proc->pid, allocate ? "allocate" : "free", start, end);
+ binder_debug(BINDER_DEBUG_BUFFER_ALLOC,
+ "binder: %d: %s pages %p-%p\n", proc->pid,
+ allocate ? "allocate" : "free", start, end);
if (end <= start)
return 0;
@@ -696,10 +716,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 failed, "
- "no async space left\n", proc->pid, size);
+ binder_debug(BINDER_DEBUG_BUFFER_ALLOC,
+ "binder: %d: binder_alloc_buf size %zd"
+ "failed, no async space left\n", proc->pid, size);
return NULL;
}
@@ -727,9 +746,10 @@ static struct binder_buffer *binder_alloc_buf(struct binder_proc *proc,
buffer = rb_entry(best_fit, struct binder_buffer, rb_node);
buffer_size = binder_buffer_size(proc, buffer);
}
- if (binder_debug_mask & BINDER_DEBUG_BUFFER_ALLOC)
- printk(KERN_INFO "binder: %d: binder_alloc_buf size %zd got buff"
- "er %p size %zd\n", proc->pid, size, buffer, buffer_size);
+
+ binder_debug(BINDER_DEBUG_BUFFER_ALLOC,
+ "binder: %d: binder_alloc_buf size %zd got buff"
+ "er %p size %zd\n", proc->pid, size, buffer, buffer_size);
has_page_addr =
(void *)(((uintptr_t)buffer->data + buffer_size) & PAGE_MASK);
@@ -756,18 +776,18 @@ static struct binder_buffer *binder_alloc_buf(struct binder_proc *proc,
new_buffer->free = 1;
binder_insert_free_buffer(proc, new_buffer);
}
- if (binder_debug_mask & BINDER_DEBUG_BUFFER_ALLOC)
- printk(KERN_INFO "binder: %d: binder_alloc_buf size %zd got "
- "%p\n", proc->pid, size, buffer);
+ binder_debug(BINDER_DEBUG_BUFFER_ALLOC,
+ "binder: %d: binder_alloc_buf size %zd got "
+ "%p\n", proc->pid, size, buffer);
buffer->data_size = data_size;
buffer->offsets_size = offsets_size;
buffer->async_transaction = is_async;
if (is_async) {
proc->free_async_space -= size + sizeof(struct binder_buffer);
- if (binder_debug_mask & BINDER_DEBUG_BUFFER_ALLOC_ASYNC)
- printk(KERN_INFO "binder: %d: binder_alloc_buf size %zd "
- "async free %zd\n", proc->pid, size,
- proc->free_async_space);
+ binder_debug(BINDER_DEBUG_BUFFER_ALLOC_ASYNC,
+ "binder: %d: binder_alloc_buf size %zd "
+ "async free %zd\n", proc->pid, size,
+ proc->free_async_space);
}
return buffer;
@@ -797,9 +817,9 @@ static void binder_delete_free_buffer(struct binder_proc *proc,
free_page_start = 0;
if (buffer_end_page(prev) == buffer_end_page(buffer))
free_page_end = 0;
- if (binder_debug_mask & BINDER_DEBUG_BUFFER_ALLOC)
- printk(KERN_INFO "binder: %d: merge free, buffer %p "
- "share page with %p\n", proc->pid, buffer, prev);
+ binder_debug(BINDER_DEBUG_BUFFER_ALLOC,
+ "binder: %d: merge free, buffer %p "
+ "share page with %p\n", proc->pid, buffer, prev);
}
if (!list_is_last(&buffer->entry, &proc->buffers)) {
@@ -810,19 +830,19 @@ static void binder_delete_free_buffer(struct binder_proc *proc,
if (buffer_start_page(next) ==
buffer_start_page(buffer))
free_page_start = 0;
- if (binder_debug_mask & BINDER_DEBUG_BUFFER_ALLOC)
- printk(KERN_INFO "binder: %d: merge free, "
- "buffer %p share page with %p\n",
- proc->pid, buffer, prev);
+ binder_debug(BINDER_DEBUG_BUFFER_ALLOC,
+ "binder: %d: merge free, buffer"
+ " %p share page with %p\n", proc->pid,
+ buffer, prev);
}
}
list_del(&buffer->entry);
if (free_page_start || free_page_end) {
- if (binder_debug_mask & BINDER_DEBUG_BUFFER_ALLOC)
- printk(KERN_INFO "binder: %d: merge free, buffer %p do "
- "not share page%s%s with with %p or %p\n",
- proc->pid, buffer, free_page_start ? "" : " end",
- free_page_end ? "" : " start", prev, next);
+ binder_debug(BINDER_DEBUG_BUFFER_ALLOC,
+ "binder: %d: merge free, buffer %p do "
+ "not share page%s%s with with %p or %p\n",
+ proc->pid, buffer, free_page_start ? "" : " end",
+ free_page_end ? "" : " start", prev, next);
binder_update_page_range(proc, 0, free_page_start ?
buffer_start_page(buffer) : buffer_end_page(buffer),
(free_page_end ? buffer_end_page(buffer) :
@@ -839,9 +859,10 @@ static void binder_free_buf(struct binder_proc *proc,
size = ALIGN(buffer->data_size, sizeof(void *)) +
ALIGN(buffer->offsets_size, sizeof(void *));
- if (binder_debug_mask & BINDER_DEBUG_BUFFER_ALLOC)
- printk(KERN_INFO "binder: %d: binder_free_buf %p size %zd buffer"
- "_size %zd\n", proc->pid, buffer, size, buffer_size);
+
+ binder_debug(BINDER_DEBUG_BUFFER_ALLOC,
+ "binder: %d: binder_free_buf %p size %zd buffer"
+ "_size %zd\n", proc->pid, buffer, size, buffer_size);
BUG_ON(buffer->free);
BUG_ON(size > buffer_size);
@@ -851,10 +872,11 @@ static void binder_free_buf(struct binder_proc *proc,
if (buffer->async_transaction) {
proc->free_async_space += size + sizeof(struct binder_buffer);
- if (binder_debug_mask & BINDER_DEBUG_BUFFER_ALLOC_ASYNC)
- printk(KERN_INFO "binder: %d: binder_free_buf size %zd "
- "async free %zd\n", proc->pid, size,
- proc->free_async_space);
+
+ binder_debug(BINDER_DEBUG_BUFFER_ALLOC_ASYNC,
+ "binder: %d: binder_free_buf size %zd "
+ "async free %zd\n", proc->pid, size,
+ proc->free_async_space);
}
binder_update_page_range(proc, 0,
@@ -925,7 +947,7 @@ static struct binder_node *binder_new_node(struct binder_proc *proc,
node = kzalloc(sizeof(*node), GFP_KERNEL);
if (node == NULL)
return NULL;
- binder_stats.obj_created[BINDER_STAT_NODE]++;
+ binder_stats_created(BINDER_STAT_NODE);
rb_link_node(&node->rb_node, parent, p);
rb_insert_color(&node->rb_node, &proc->nodes);
node->debug_id = ++binder_last_id;
@@ -935,10 +957,10 @@ static struct binder_node *binder_new_node(struct binder_proc *proc,
node->work.type = BINDER_WORK_NODE;
INIT_LIST_HEAD(&node->work.entry);
INIT_LIST_HEAD(&node->async_todo);
- if (binder_debug_mask & BINDER_DEBUG_INTERNAL_REFS)
- printk(KERN_INFO "binder: %d:%d node %d u%p c%p created\n",
- proc->pid, current->pid, node->debug_id,
- node->ptr, node->cookie);
+ binder_debug(BINDER_DEBUG_INTERNAL_REFS,
+ "binder: %d:%d node %d u%p c%p created\n",
+ proc->pid, current->pid, node->debug_id,
+ node->ptr, node->cookie);
return node;
}
@@ -1003,15 +1025,17 @@ static int binder_dec_node(struct binder_node *node, int strong, int internal)
list_del_init(&node->work.entry);
if (node->proc) {
rb_erase(&node->rb_node, &node->proc->nodes);
- if (binder_debug_mask & BINDER_DEBUG_INTERNAL_REFS)
- printk(KERN_INFO "binder: refless node %d deleted\n", node->debug_id);
+ binder_debug(BINDER_DEBUG_INTERNAL_REFS,
+ "binder: refless node %d deleted\n",
+ node->debug_id);
} else {
hlist_del(&node->dead_node);
- if (binder_debug_mask & BINDER_DEBUG_INTERNAL_REFS)
- printk(KERN_INFO "binder: dead node %d deleted\n", node->debug_id);
+ binder_debug(BINDER_DEBUG_INTERNAL_REFS,
+ "binder: dead node %d deleted\n",
+ node->debug_id);
}
kfree(node);
- binder_stats.obj_deleted[BINDER_STAT_NODE]++;
+ binder_stats_deleted(BINDER_STAT_NODE);
}
}
@@ -1060,7 +1084,7 @@ static struct binder_ref *binder_get_ref_for_node(struct binder_proc *proc,
new_ref = kzalloc(sizeof(*ref), GFP_KERNEL);
if (new_ref == NULL)
return NULL;
- binder_stats.obj_created[BINDER_STAT_REF]++;
+ binder_stats_created(BINDER_STAT_REF);
new_ref->debug_id = ++binder_last_id;
new_ref->proc = proc;
new_ref->node = node;
@@ -1091,25 +1115,27 @@ static struct binder_ref *binder_get_ref_for_node(struct binder_proc *proc,
rb_insert_color(&new_ref->rb_node_desc, &proc->refs_by_desc);
if (node) {
hlist_add_head(&new_ref->node_entry, &node->refs);
- if (binder_debug_mask & BINDER_DEBUG_INTERNAL_REFS)
- printk(KERN_INFO "binder: %d new ref %d desc %d for "
- "node %d\n", proc->pid, new_ref->debug_id,
- new_ref->desc, node->debug_id);
+
+ binder_debug(BINDER_DEBUG_INTERNAL_REFS,
+ "binder: %d new ref %d desc %d for "
+ "node %d\n", proc->pid, new_ref->debug_id,
+ new_ref->desc, node->debug_id);
} else {
- if (binder_debug_mask & BINDER_DEBUG_INTERNAL_REFS)
- printk(KERN_INFO "binder: %d new ref %d desc %d for "
- "dead node\n", proc->pid, new_ref->debug_id,
- new_ref->desc);
+ binder_debug(BINDER_DEBUG_INTERNAL_REFS,
+ "binder: %d new ref %d desc %d for "
+ "dead node\n", proc->pid, new_ref->debug_id,
+ new_ref->desc);
}
return new_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 "
- "node %d\n", ref->proc->pid, ref->debug_id,
- ref->desc, ref->node->debug_id);
+ binder_debug(BINDER_DEBUG_INTERNAL_REFS,
+ "binder: %d delete ref %d desc %d for "
+ "node %d\n", ref->proc->pid, ref->debug_id,
+ ref->desc, ref->node->debug_id);
+
rb_erase(&ref->rb_node_desc, &ref->proc->refs_by_desc);
rb_erase(&ref->rb_node_node, &ref->proc->refs_by_node);
if (ref->strong)
@@ -1117,16 +1143,16 @@ static void binder_delete_ref(struct binder_ref *ref)
hlist_del(&ref->node_entry);
binder_dec_node(ref->node, 0, 1);
if (ref->death) {
- if (binder_debug_mask & BINDER_DEBUG_DEAD_BINDER)
- printk(KERN_INFO "binder: %d delete ref %d desc %d "
- "has death notification\n", ref->proc->pid,
- ref->debug_id, ref->desc);
+ binder_debug(BINDER_DEBUG_DEAD_BINDER,
+ "binder: %d delete ref %d desc %d "
+ "has death notification\n", ref->proc->pid,
+ ref->debug_id, ref->desc);
list_del(&ref->death->work.entry);
kfree(ref->death);
- binder_stats.obj_deleted[BINDER_STAT_DEATH]++;
+ binder_stats_deleted(BINDER_STAT_DEATH);
}
kfree(ref);
- binder_stats.obj_deleted[BINDER_STAT_REF]++;
+ binder_stats_deleted(BINDER_STAT_REF);
}
static int binder_inc_ref(struct binder_ref *ref, int strong,
@@ -1198,7 +1224,7 @@ static void binder_pop_transaction(struct binder_thread *target_thread,
if (t->buffer)
t->buffer->transaction = NULL;
kfree(t);
- binder_stats.obj_deleted[BINDER_STAT_TRANSACTION]++;
+ binder_stats_deleted(BINDER_STAT_TRANSACTION);
}
static void binder_send_failed_reply(struct binder_transaction *t,
@@ -1216,9 +1242,11 @@ static void binder_send_failed_reply(struct binder_transaction *t,
target_thread->return_error = BR_OK;
}
if (target_thread->return_error == BR_OK) {
- if (binder_debug_mask & BINDER_DEBUG_FAILED_TRANSACTION)
- printk(KERN_INFO "binder: send failed reply for transaction %d to %d:%d\n",
- t->debug_id, target_thread->proc->pid, target_thread->pid);
+ binder_debug(BINDER_DEBUG_FAILED_TRANSACTION,
+ "binder: send failed reply for "
+ "transaction %d to %d:%d\n",
+ t->debug_id, target_thread->proc->pid,
+ target_thread->pid);
binder_pop_transaction(target_thread, t);
target_thread->return_error = error_code;
@@ -1234,29 +1262,100 @@ static void binder_send_failed_reply(struct binder_transaction *t,
} else {
struct binder_transaction *next = t->from_parent;
- if (binder_debug_mask & BINDER_DEBUG_FAILED_TRANSACTION)
- printk(KERN_INFO "binder: send failed reply "
- "for transaction %d, target dead\n",
- t->debug_id);
+ binder_debug(BINDER_DEBUG_FAILED_TRANSACTION,
+ "binder: send failed reply "
+ "for transaction %d, target dead\n",
+ t->debug_id);
binder_pop_transaction(target_thread, t);
if (next == NULL) {
- if (binder_debug_mask & BINDER_DEBUG_DEAD_BINDER)
- printk(KERN_INFO "binder: reply failed,"
- " no target thread at root\n");
+ binder_debug(BINDER_DEBUG_DEAD_BINDER,
+ "binder: reply failed,"
+ " no target thread at root\n");
return;
}
t = next;
- if (binder_debug_mask & BINDER_DEBUG_DEAD_BINDER)
- printk(KERN_INFO "binder: reply failed, no targ"
- "et thread -- retry %d\n", t->debug_id);
+ binder_debug(BINDER_DEBUG_DEAD_BINDER,
+ "binder: reply failed, no target "
+ "thread -- retry %d\n", t->debug_id);
}
}
}
static void binder_transaction_buffer_release(struct binder_proc *proc,
struct binder_buffer *buffer,
- size_t *failed_at);
+ size_t *failed_at)
+{
+ size_t *offp, *off_end;
+ int debug_id = buffer->debug_id;
+
+ binder_debug(BINDER_DEBUG_TRANSACTION,
+ "binder: %d buffer release %d, size %zd-%zd, failed at %p\n",
+ proc->pid, buffer->debug_id,
+ buffer->data_size, buffer->offsets_size, failed_at);
+
+ if (buffer->target_node)
+ binder_dec_node(buffer->target_node, 1, 0);
+
+ offp = (size_t *)(buffer->data + ALIGN(buffer->data_size, sizeof(void *)));
+ if (failed_at)
+ off_end = failed_at;
+ else
+ off_end = (void *)offp + buffer->offsets_size;
+ for (; offp < off_end; offp++) {
+ struct flat_binder_object *fp;
+ if (*offp > buffer->data_size - sizeof(*fp) ||
+ buffer->data_size < sizeof(*fp) ||
+ !IS_ALIGNED(*offp, sizeof(void *))) {
+ printk(KERN_ERR "binder: transaction release %d bad"
+ "offset %zd, size %zd\n", debug_id,
+ *offp, buffer->data_size);
+ continue;
+ }
+ fp = (struct flat_binder_object *)(buffer->data + *offp);
+ switch (fp->type) {
+ case BINDER_TYPE_BINDER:
+ case BINDER_TYPE_WEAK_BINDER: {
+ struct binder_node *node = binder_get_node(proc, fp->binder);
+ if (node == NULL) {
+ printk(KERN_ERR "binder: transaction release %d"
+ " bad node %p\n", debug_id, fp->binder);
+ break;
+ }
+ binder_debug(BINDER_DEBUG_TRANSACTION,
+ " node %d u%p\n",
+ node->debug_id, node->ptr);
+ binder_dec_node(node, fp->type == BINDER_TYPE_BINDER, 0);
+ } break;
+ case BINDER_TYPE_HANDLE:
+ case BINDER_TYPE_WEAK_HANDLE: {
+ struct binder_ref *ref = binder_get_ref(proc, fp->handle);
+ if (ref == NULL) {
+ printk(KERN_ERR "binder: transaction release %d"
+ " bad handle %ld\n", debug_id,
+ fp->handle);
+ break;
+ }
+ binder_debug(BINDER_DEBUG_TRANSACTION,
+ " ref %d desc %d (node %d)\n",
+ ref->debug_id, ref->desc, ref->node->debug_id);
+ binder_dec_ref(ref, fp->type == BINDER_TYPE_HANDLE);
+ } break;
+
+ case BINDER_TYPE_FD:
+ binder_debug(BINDER_DEBUG_TRANSACTION,
+ " fd %ld\n", fp->handle);
+ if (failed_at)
+ task_close_fd(proc, fp->handle);
+ break;
+
+ default:
+ printk(KERN_ERR "binder: transaction release %d bad "
+ "object type %lx\n", debug_id, fp->type);
+ break;
+ }
+ }
+}
static void binder_transaction(struct binder_proc *proc,
struct binder_thread *thread,
@@ -1387,34 +1486,34 @@ static void binder_transaction(struct binder_proc *proc,
return_error = BR_FAILED_REPLY;
goto err_alloc_t_failed;
}
- binder_stats.obj_created[BINDER_STAT_TRANSACTION]++;
+ binder_stats_created(BINDER_STAT_TRANSACTION);
tcomplete = kzalloc(sizeof(*tcomplete), GFP_KERNEL);
if (tcomplete == NULL) {
return_error = BR_FAILED_REPLY;
goto err_alloc_tcomplete_failed;
}
- binder_stats.obj_created[BINDER_STAT_TRANSACTION_COMPLETE]++;
+ binder_stats_created(BINDER_STAT_TRANSACTION_COMPLETE);
t->debug_id = ++binder_last_id;
e->debug_id = t->debug_id;
- if (binder_debug_mask & BINDER_DEBUG_TRANSACTION) {
- if (reply)
- printk(KERN_INFO "binder: %d:%d BC_REPLY %d -> %d:%d, "
- "data %p-%p size %zd-%zd\n",
- proc->pid, thread->pid, t->debug_id,
- target_proc->pid, target_thread->pid,
- tr->data.ptr.buffer, tr->data.ptr.offsets,
- tr->data_size, tr->offsets_size);
- else
- printk(KERN_INFO "binder: %d:%d BC_TRANSACTION %d -> "
- "%d - node %d, data %p-%p size %zd-%zd\n",
- proc->pid, thread->pid, t->debug_id,
- target_proc->pid, target_node->debug_id,
- tr->data.ptr.buffer, tr->data.ptr.offsets,
- tr->data_size, tr->offsets_size);
- }
+ if (reply)
+ binder_debug(BINDER_DEBUG_TRANSACTION,
+ "binder: %d:%d BC_REPLY %d -> %d:%d, "
+ "data %p-%p size %zd-%zd\n",
+ proc->pid, thread->pid, t->debug_id,
+ target_proc->pid, target_thread->pid,
+ tr->data.ptr.buffer, tr->data.ptr.offsets,
+ tr->data_size, tr->offsets_size);
+ else
+ binder_debug(BINDER_DEBUG_TRANSACTION,
+ "binder: %d:%d BC_TRANSACTION %d -> "
+ "%d - node %d, data %p-%p size %zd-%zd\n",
+ proc->pid, thread->pid, t->debug_id,
+ target_proc->pid, target_node->debug_id,
+ tr->data.ptr.buffer, tr->data.ptr.offsets,
+ tr->data_size, tr->offsets_size);
if (!reply && !(tr->flags & TF_ONE_WAY))
t->from = thread;
@@ -1505,10 +1604,13 @@ static void binder_transaction(struct binder_proc *proc,
else
fp->type = BINDER_TYPE_WEAK_HANDLE;
fp->handle = ref->desc;
- binder_inc_ref(ref, fp->type == BINDER_TYPE_HANDLE, &thread->todo);
- if (binder_debug_mask & BINDER_DEBUG_TRANSACTION)
- printk(KERN_INFO " node %d u%p -> ref %d desc %d\n",
- node->debug_id, node->ptr, ref->debug_id, ref->desc);
+ binder_inc_ref(ref, fp->type == BINDER_TYPE_HANDLE,
+ &thread->todo);
+
+ binder_debug(BINDER_DEBUG_TRANSACTION,
+ " node %d u%p -> ref %d desc %d\n",
+ node->debug_id, node->ptr, ref->debug_id,
+ ref->desc);
} break;
case BINDER_TYPE_HANDLE:
case BINDER_TYPE_WEAK_HANDLE: {
@@ -1529,9 +1631,10 @@ static void binder_transaction(struct binder_proc *proc,
fp->binder = ref->node->ptr;
fp->cookie = ref->node->cookie;
binder_inc_node(ref->node, fp->type == BINDER_TYPE_BINDER, 0, NULL);
- if (binder_debug_mask & BINDER_DEBUG_TRANSACTION)
- printk(KERN_INFO " ref %d desc %d -> node %d u%p\n",
- ref->debug_id, ref->desc, ref->node->debug_id, ref->node->ptr);
+ binder_debug(BINDER_DEBUG_TRANSACTION,
+ " ref %d desc %d -> node %d u%p\n",
+ ref->debug_id, ref->desc, ref->node->debug_id,
+ ref->node->ptr);
} else {
struct binder_ref *new_ref;
new_ref = binder_get_ref_for_node(target_proc, ref->node);
@@ -1541,9 +1644,10 @@ static void binder_transaction(struct binder_proc *proc,
}
fp->handle = new_ref->desc;
binder_inc_ref(new_ref, fp->type == BINDER_TYPE_HANDLE, NULL);
- if (binder_debug_mask & BINDER_DEBUG_TRANSACTION)
- printk(KERN_INFO " ref %d desc %d -> ref %d desc %d (node %d)\n",
- ref->debug_id, ref->desc, new_ref->debug_id, new_ref->desc, ref->node->debug_id);
+ binder_debug(BINDER_DEBUG_TRANSACTION,
+ " ref %d desc %d -> ref %d desc %d (node %d)\n",
+ ref->debug_id, ref->desc, new_ref->debug_id,
+ new_ref->desc, ref->node->debug_id);
}
} break;
@@ -1579,8 +1683,8 @@ static void binder_transaction(struct binder_proc *proc,
goto err_get_unused_fd_failed;
}
task_fd_install(target_proc, target_fd, file);
- if (binder_debug_mask & BINDER_DEBUG_TRANSACTION)
- printk(KERN_INFO " fd %ld -> %d\n", fp->handle, target_fd);
+ binder_debug(BINDER_DEBUG_TRANSACTION,
+ " fd %ld -> %d\n", fp->handle, target_fd);
/* TODO: fput? */
fp->handle = target_fd;
} break;
@@ -1632,21 +1736,20 @@ err_copy_data_failed:
binder_free_buf(target_proc, t->buffer);
err_binder_alloc_buf_failed:
kfree(tcomplete);
- binder_stats.obj_deleted[BINDER_STAT_TRANSACTION_COMPLETE]++;
+ binder_stats_deleted(BINDER_STAT_TRANSACTION_COMPLETE);
err_alloc_tcomplete_failed:
kfree(t);
- binder_stats.obj_deleted[BINDER_STAT_TRANSACTION]++;
+ binder_stats_deleted(BINDER_STAT_TRANSACTION);
err_alloc_t_failed:
err_bad_call_stack:
err_empty_call_stack:
err_dead_binder:
err_invalid_target_handle:
err_no_context_mgr_node:
- if (binder_debug_mask & BINDER_DEBUG_FAILED_TRANSACTION)
- printk(KERN_INFO "binder: %d:%d transaction failed %d, size"
- "%zd-%zd\n",
- proc->pid, thread->pid, return_error,
- tr->data_size, tr->offsets_size);
+ binder_debug(BINDER_DEBUG_FAILED_TRANSACTION,
+ "binder: %d:%d transaction failed %d, size %zd-%zd\n",
+ proc->pid, thread->pid, return_error,
+ tr->data_size, tr->offsets_size);
{
struct binder_transaction_log_entry *fe;
@@ -1662,76 +1765,6 @@ 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)
-{
- size_t *offp, *off_end;
- int debug_id = buffer->debug_id;
-
- if (binder_debug_mask & BINDER_DEBUG_TRANSACTION)
- printk(KERN_INFO "binder: %d buffer release %d, size %zd-%zd, failed at %p\n",
- proc->pid, buffer->debug_id,
- buffer->data_size, buffer->offsets_size, failed_at);
-
- if (buffer->target_node)
- binder_dec_node(buffer->target_node, 1, 0);
-
- offp = (size_t *)(buffer->data + ALIGN(buffer->data_size, sizeof(void *)));
- if (failed_at)
- off_end = failed_at;
- else
- off_end = (void *)offp + buffer->offsets_size;
- for (; offp < off_end; offp++) {
- struct flat_binder_object *fp;
- if (*offp > buffer->data_size - sizeof(*fp) ||
- buffer->data_size < sizeof(*fp) ||
- !IS_ALIGNED(*offp, sizeof(void *))) {
- printk(KERN_ERR "binder: transaction release %d bad"
- "offset %zd, size %zd\n", debug_id, *offp, buffer->data_size);
- continue;
- }
- fp = (struct flat_binder_object *)(buffer->data + *offp);
- switch (fp->type) {
- case BINDER_TYPE_BINDER:
- case BINDER_TYPE_WEAK_BINDER: {
- struct binder_node *node = binder_get_node(proc, fp->binder);
- if (node == NULL) {
- printk(KERN_ERR "binder: transaction release %d bad node %p\n", debug_id, fp->binder);
- break;
- }
- if (binder_debug_mask & BINDER_DEBUG_TRANSACTION)
- printk(KERN_INFO " node %d u%p\n",
- node->debug_id, node->ptr);
- binder_dec_node(node, fp->type == BINDER_TYPE_BINDER, 0);
- } break;
- case BINDER_TYPE_HANDLE:
- case BINDER_TYPE_WEAK_HANDLE: {
- struct binder_ref *ref = binder_get_ref(proc, fp->handle);
- if (ref == NULL) {
- printk(KERN_ERR "binder: transaction release %d bad handle %ld\n", debug_id, fp->handle);
- break;
- }
- if (binder_debug_mask & BINDER_DEBUG_TRANSACTION)
- printk(KERN_INFO " ref %d desc %d (node %d)\n",
- ref->debug_id, ref->desc, ref->node->debug_id);
- binder_dec_ref(ref, fp->type == BINDER_TYPE_HANDLE);
- } break;
-
- case BINDER_TYPE_FD:
- if (binder_debug_mask & BINDER_DEBUG_TRANSACTION)
- printk(KERN_INFO " fd %ld\n", fp->handle);
- if (failed_at)
- task_close_fd(proc, fp->handle);
- break;
-
- default:
- printk(KERN_ERR "binder: transaction release %d bad object type %lx\n", debug_id, fp->type);
- break;
- }
- }
-}
-
int binder_thread_write(struct binder_proc *proc, struct binder_thread *thread,
void __user *buffer, int size, signed long *consumed)
{
@@ -1799,9 +1832,10 @@ int binder_thread_write(struct binder_proc *proc, struct binder_thread *thread,
binder_dec_ref(ref, 0);
break;
}
- if (binder_debug_mask & BINDER_DEBUG_USER_REFS)
- printk(KERN_INFO "binder: %d:%d %s ref %d desc %d s %d w %d for node %d\n",
- proc->pid, thread->pid, debug_string, ref->debug_id, ref->desc, ref->strong, ref->weak, ref->node->debug_id);
+ binder_debug(BINDER_DEBUG_USER_REFS,
+ "binder: %d:%d %s ref %d desc %d s %d w %d for node %d\n",
+ proc->pid, thread->pid, debug_string, ref->debug_id,
+ ref->desc, ref->strong, ref->weak, ref->node->debug_id);
break;
}
case BC_INCREFS_DONE:
@@ -1859,9 +1893,11 @@ int binder_thread_write(struct binder_proc *proc, struct binder_thread *thread,
node->pending_weak_ref = 0;
}
binder_dec_node(node, cmd == BC_ACQUIRE_DONE, 0);
- if (binder_debug_mask & BINDER_DEBUG_USER_REFS)
- printk(KERN_INFO "binder: %d:%d %s node %d ls %d lw %d\n",
- proc->pid, thread->pid, cmd == BC_INCREFS_DONE ? "BC_INCREFS_DONE" : "BC_ACQUIRE_DONE", node->debug_id, node->local_strong_refs, node->local_weak_refs);
+ binder_debug(BINDER_DEBUG_USER_REFS,
+ "binder: %d:%d %s node %d ls %d lw %d\n",
+ proc->pid, thread->pid,
+ cmd == BC_INCREFS_DONE ? "BC_INCREFS_DONE" : "BC_ACQUIRE_DONE",
+ node->debug_id, node->local_strong_refs, node->local_weak_refs);
break;
}
case BC_ATTEMPT_ACQUIRE:
@@ -1893,10 +1929,10 @@ int binder_thread_write(struct binder_proc *proc, struct binder_thread *thread,
proc->pid, thread->pid, data_ptr);
break;
}
- if (binder_debug_mask & BINDER_DEBUG_FREE_BUFFER)
- printk(KERN_INFO "binder: %d:%d BC_FREE_BUFFER u%p found buffer %d for %s transaction\n",
- proc->pid, thread->pid, data_ptr, buffer->debug_id,
- buffer->transaction ? "active" : "finished");
+ binder_debug(BINDER_DEBUG_FREE_BUFFER,
+ "binder: %d:%d BC_FREE_BUFFER u%p found buffer %d for %s transaction\n",
+ proc->pid, thread->pid, data_ptr, buffer->debug_id,
+ buffer->transaction ? "active" : "finished");
if (buffer->transaction) {
buffer->transaction->buffer = NULL;
@@ -1926,9 +1962,9 @@ int binder_thread_write(struct binder_proc *proc, struct binder_thread *thread,
}
case BC_REGISTER_LOOPER:
- if (binder_debug_mask & BINDER_DEBUG_THREADS)
- printk(KERN_INFO "binder: %d:%d BC_REGISTER_LOOPER\n",
- proc->pid, thread->pid);
+ binder_debug(BINDER_DEBUG_THREADS,
+ "binder: %d:%d BC_REGISTER_LOOPER\n",
+ proc->pid, thread->pid);
if (thread->looper & BINDER_LOOPER_STATE_ENTERED) {
thread->looper |= BINDER_LOOPER_STATE_INVALID;
binder_user_error("binder: %d:%d ERROR:"
@@ -1948,9 +1984,9 @@ int binder_thread_write(struct binder_proc *proc, struct binder_thread *thread,
thread->looper |= BINDER_LOOPER_STATE_REGISTERED;
break;
case BC_ENTER_LOOPER:
- if (binder_debug_mask & BINDER_DEBUG_THREADS)
- printk(KERN_INFO "binder: %d:%d BC_ENTER_LOOPER\n",
- proc->pid, thread->pid);
+ binder_debug(BINDER_DEBUG_THREADS,
+ "binder: %d:%d BC_ENTER_LOOPER\n",
+ proc->pid, thread->pid);
if (thread->looper & BINDER_LOOPER_STATE_REGISTERED) {
thread->looper |= BINDER_LOOPER_STATE_INVALID;
binder_user_error("binder: %d:%d ERROR:"
@@ -1961,9 +1997,9 @@ int binder_thread_write(struct binder_proc *proc, struct binder_thread *thread,
thread->looper |= BINDER_LOOPER_STATE_ENTERED;
break;
case BC_EXIT_LOOPER:
- if (binder_debug_mask & BINDER_DEBUG_THREADS)
- printk(KERN_INFO "binder: %d:%d BC_EXIT_LOOPER\n",
- proc->pid, thread->pid);
+ binder_debug(BINDER_DEBUG_THREADS,
+ "binder: %d:%d BC_EXIT_LOOPER\n",
+ proc->pid, thread->pid);
thread->looper |= BINDER_LOOPER_STATE_EXITED;
break;
@@ -1992,14 +2028,14 @@ int binder_thread_write(struct binder_proc *proc, struct binder_thread *thread,
break;
}
- if (binder_debug_mask & BINDER_DEBUG_DEATH_NOTIFICATION)
- printk(KERN_INFO "binder: %d:%d %s %p ref %d desc %d s %d w %d for node %d\n",
- proc->pid, thread->pid,
- cmd == BC_REQUEST_DEATH_NOTIFICATION ?
- "BC_REQUEST_DEATH_NOTIFICATION" :
- "BC_CLEAR_DEATH_NOTIFICATION",
- cookie, ref->debug_id, ref->desc,
- ref->strong, ref->weak, ref->node->debug_id);
+ binder_debug(BINDER_DEBUG_DEATH_NOTIFICATION,
+ "binder: %d:%d %s %p ref %d desc %d s %d w %d for node %d\n",
+ proc->pid, thread->pid,
+ cmd == BC_REQUEST_DEATH_NOTIFICATION ?
+ "BC_REQUEST_DEATH_NOTIFICATION" :
+ "BC_CLEAR_DEATH_NOTIFICATION",
+ cookie, ref->debug_id, ref->desc,
+ ref->strong, ref->weak, ref->node->debug_id);
if (cmd == BC_REQUEST_DEATH_NOTIFICATION) {
if (ref->death) {
@@ -2013,13 +2049,13 @@ int binder_thread_write(struct binder_proc *proc, struct binder_thread *thread,
death = kzalloc(sizeof(*death), GFP_KERNEL);
if (death == NULL) {
thread->return_error = BR_ERROR;
- if (binder_debug_mask & BINDER_DEBUG_FAILED_TRANSACTION)
- printk(KERN_INFO "binder: %d:%d "
- "BC_REQUEST_DEATH_NOTIFICATION failed\n",
- proc->pid, thread->pid);
+ binder_debug(BINDER_DEBUG_FAILED_TRANSACTION,
+ "binder: %d:%d "
+ "BC_REQUEST_DEATH_NOTIFICATION failed\n",
+ proc->pid, thread->pid);
break;
}
- binder_stats.obj_created[BINDER_STAT_DEATH]++;
+ binder_stats_created(BINDER_STAT_DEATH);
INIT_LIST_HEAD(&death->work.entry);
death->cookie = cookie;
ref->death = death;
@@ -2082,9 +2118,9 @@ int binder_thread_write(struct binder_proc *proc, struct binder_thread *thread,
break;
}
}
- if (binder_debug_mask & BINDER_DEBUG_DEAD_BINDER)
- printk(KERN_INFO "binder: %d:%d BC_DEAD_BINDER_DONE %p found %p\n",
- proc->pid, thread->pid, cookie, death);
+ binder_debug(BINDER_DEBUG_DEAD_BINDER,
+ "binder: %d:%d BC_DEAD_BINDER_DONE %p found %p\n",
+ proc->pid, thread->pid, cookie, death);
if (death == NULL) {
binder_user_error("binder: %d:%d BC_DEAD"
"_BINDER_DONE %p not found\n",
@@ -2240,13 +2276,13 @@ retry:
ptr += sizeof(uint32_t);
binder_stat_br(proc, thread, cmd);
- if (binder_debug_mask & BINDER_DEBUG_TRANSACTION_COMPLETE)
- printk(KERN_INFO "binder: %d:%d BR_TRANSACTION_COMPLETE\n",
- proc->pid, thread->pid);
+ binder_debug(BINDER_DEBUG_TRANSACTION_COMPLETE,
+ "binder: %d:%d BR_TRANSACTION_COMPLETE\n",
+ proc->pid, thread->pid);
list_del(&w->entry);
kfree(w);
- binder_stats.obj_deleted[BINDER_STAT_TRANSACTION_COMPLETE]++;
+ binder_stats_deleted(BINDER_STAT_TRANSACTION_COMPLETE);
} break;
case BINDER_WORK_NODE: {
struct binder_node *node = container_of(w, struct binder_node, work);
@@ -2287,22 +2323,24 @@ retry:
ptr += sizeof(void *);
binder_stat_br(proc, thread, cmd);
- if (binder_debug_mask & BINDER_DEBUG_USER_REFS)
- printk(KERN_INFO "binder: %d:%d %s %d u%p c%p\n",
- proc->pid, thread->pid, cmd_name, node->debug_id, node->ptr, node->cookie);
+ binder_debug(BINDER_DEBUG_USER_REFS,
+ "binder: %d:%d %s %d u%p c%p\n",
+ proc->pid, thread->pid, cmd_name, node->debug_id, node->ptr, node->cookie);
} else {
list_del_init(&w->entry);
if (!weak && !strong) {
- if (binder_debug_mask & BINDER_DEBUG_INTERNAL_REFS)
- printk(KERN_INFO "binder: %d:%d node %d u%p c%p deleted\n",
- proc->pid, thread->pid, node->debug_id, node->ptr, node->cookie);
+ binder_debug(BINDER_DEBUG_INTERNAL_REFS,
+ "binder: %d:%d node %d u%p c%p deleted\n",
+ proc->pid, thread->pid, node->debug_id,
+ node->ptr, node->cookie);
rb_erase(&node->rb_node, &proc->nodes);
kfree(node);
- binder_stats.obj_deleted[BINDER_STAT_NODE]++;
+ binder_stats_deleted(BINDER_STAT_NODE);
} else {
- if (binder_debug_mask & BINDER_DEBUG_INTERNAL_REFS)
- printk(KERN_INFO "binder: %d:%d node %d u%p c%p state unchanged\n",
- proc->pid, thread->pid, node->debug_id, node->ptr, node->cookie);
+ binder_debug(BINDER_DEBUG_INTERNAL_REFS,
+ "binder: %d:%d node %d u%p c%p state unchanged\n",
+ proc->pid, thread->pid, node->debug_id, node->ptr,
+ node->cookie);
}
}
} break;
@@ -2323,18 +2361,18 @@ retry:
if (put_user(death->cookie, (void * __user *)ptr))
return -EFAULT;
ptr += sizeof(void *);
- if (binder_debug_mask & BINDER_DEBUG_DEATH_NOTIFICATION)
- printk(KERN_INFO "binder: %d:%d %s %p\n",
- proc->pid, thread->pid,
- cmd == BR_DEAD_BINDER ?
- "BR_DEAD_BINDER" :
- "BR_CLEAR_DEATH_NOTIFICATION_DONE",
- death->cookie);
+ binder_debug(BINDER_DEBUG_DEATH_NOTIFICATION,
+ "binder: %d:%d %s %p\n",
+ proc->pid, thread->pid,
+ cmd == BR_DEAD_BINDER ?
+ "BR_DEAD_BINDER" :
+ "BR_CLEAR_DEATH_NOTIFICATION_DONE",
+ death->cookie);
if (w->type == BINDER_WORK_CLEAR_DEATH_NOTIFICATION) {
list_del(&w->entry);
kfree(death);
- binder_stats.obj_deleted[BINDER_STAT_DEATH]++;
+ binder_stats_deleted(BINDER_STAT_DEATH);
} else
list_move(&w->entry, &proc->delivered_death);
if (cmd == BR_DEAD_BINDER)
@@ -2391,16 +2429,16 @@ retry:
ptr += sizeof(tr);
binder_stat_br(proc, thread, cmd);
- if (binder_debug_mask & BINDER_DEBUG_TRANSACTION)
- 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",
- 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,
- tr.data.ptr.buffer, tr.data.ptr.offsets);
+ binder_debug(BINDER_DEBUG_TRANSACTION,
+ "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",
+ 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,
+ tr.data.ptr.buffer, tr.data.ptr.offsets);
list_del(&t->work.entry);
t->buffer->allow_user_free = 1;
@@ -2411,7 +2449,7 @@ retry:
} else {
t->buffer->transaction = NULL;
kfree(t);
- binder_stats.obj_deleted[BINDER_STAT_TRANSACTION]++;
+ binder_stats_deleted(BINDER_STAT_TRANSACTION);
}
break;
}
@@ -2425,9 +2463,9 @@ done:
BINDER_LOOPER_STATE_ENTERED)) /* the user-space code fails to */
/*spawn a new thread if we leave this out */) {
proc->requested_threads++;
- if (binder_debug_mask & BINDER_DEBUG_THREADS)
- printk(KERN_INFO "binder: %d:%d BR_SPAWN_LOOPER\n",
- proc->pid, thread->pid);
+ binder_debug(BINDER_DEBUG_THREADS,
+ "binder: %d:%d BR_SPAWN_LOOPER\n",
+ proc->pid, thread->pid);
if (put_user(BR_SPAWN_LOOPER, (uint32_t __user *)buffer))
return -EFAULT;
}
@@ -2450,7 +2488,7 @@ static void binder_release_work(struct list_head *list)
} break;
case BINDER_WORK_TRANSACTION_COMPLETE: {
kfree(w);
- binder_stats.obj_deleted[BINDER_STAT_TRANSACTION_COMPLETE]++;
+ binder_stats_deleted(BINDER_STAT_TRANSACTION_COMPLETE);
} break;
default:
break;
@@ -2480,7 +2518,7 @@ static struct binder_thread *binder_get_thread(struct binder_proc *proc)
thread = kzalloc(sizeof(*thread), GFP_KERNEL);
if (thread == NULL)
return NULL;
- binder_stats.obj_created[BINDER_STAT_THREAD]++;
+ binder_stats_created(BINDER_STAT_THREAD);
thread->proc = proc;
thread->pid = current->pid;
init_waitqueue_head(&thread->wait);
@@ -2507,11 +2545,12 @@ static int binder_free_thread(struct binder_proc *proc,
send_reply = t;
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");
+ binder_debug(BINDER_DEBUG_DEAD_TRANSACTION,
+ "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;
@@ -2530,7 +2569,7 @@ static int binder_free_thread(struct binder_proc *proc,
binder_send_failed_reply(send_reply, BR_DEAD_REPLY);
binder_release_work(&thread->todo);
kfree(thread);
- binder_stats.obj_deleted[BINDER_STAT_THREAD]++;
+ binder_stats_deleted(BINDER_STAT_THREAD);
return active_transactions;
}
@@ -2596,9 +2635,11 @@ static long binder_ioctl(struct file *filp, unsigned int cmd, unsigned long arg)
ret = -EFAULT;
goto err;
}
- if (binder_debug_mask & BINDER_DEBUG_READ_WRITE)
- printk(KERN_INFO "binder: %d:%d write %ld at %08lx, read %ld at %08lx\n",
- proc->pid, thread->pid, bwr.write_size, bwr.write_buffer, bwr.read_size, bwr.read_buffer);
+ binder_debug(BINDER_DEBUG_READ_WRITE,
+ "binder: %d:%d write %ld at %08lx, read %ld at %08lx\n",
+ proc->pid, thread->pid, bwr.write_size, bwr.write_buffer,
+ bwr.read_size, bwr.read_buffer);
+
if (bwr.write_size > 0) {
ret = binder_thread_write(proc, thread, (void __user *)bwr.write_buffer, bwr.write_size, &bwr.write_consumed);
if (ret < 0) {
@@ -2618,9 +2659,10 @@ static long binder_ioctl(struct file *filp, unsigned int cmd, unsigned long arg)
goto err;
}
}
- if (binder_debug_mask & BINDER_DEBUG_READ_WRITE)
- printk(KERN_INFO "binder: %d:%d wrote %ld of %ld, read return %ld of %ld\n",
- proc->pid, thread->pid, bwr.write_consumed, bwr.write_size, bwr.read_consumed, bwr.read_size);
+ binder_debug(BINDER_DEBUG_READ_WRITE,
+ "binder: %d:%d wrote %ld of %ld, read return %ld of %ld\n",
+ proc->pid, thread->pid, bwr.write_consumed, bwr.write_size,
+ bwr.read_consumed, bwr.read_size);
if (copy_to_user(ubuf, &bwr, sizeof(bwr))) {
ret = -EFAULT;
goto err;
@@ -2661,9 +2703,8 @@ static long binder_ioctl(struct file *filp, unsigned int cmd, unsigned long arg)
binder_context_mgr_node->has_weak_ref = 1;
break;
case BINDER_THREAD_EXIT:
- if (binder_debug_mask & BINDER_DEBUG_THREADS)
- printk(KERN_INFO "binder: %d:%d exit\n",
- proc->pid, thread->pid);
+ binder_debug(BINDER_DEBUG_THREADS, "binder: %d:%d exit\n",
+ proc->pid, thread->pid);
binder_free_thread(proc, thread);
thread = NULL;
break;
@@ -2695,24 +2736,22 @@ err:
static void binder_vma_open(struct vm_area_struct *vma)
{
struct binder_proc *proc = vma->vm_private_data;
- if (binder_debug_mask & BINDER_DEBUG_OPEN_CLOSE)
- printk(KERN_INFO
- "binder: %d open vm area %lx-%lx (%ld K) vma %lx pagep %lx\n",
- proc->pid, vma->vm_start, vma->vm_end,
- (vma->vm_end - vma->vm_start) / SZ_1K, vma->vm_flags,
- (unsigned long)pgprot_val(vma->vm_page_prot));
+ binder_debug(BINDER_DEBUG_OPEN_CLOSE,
+ "binder: %d open vm area %lx-%lx (%ld K) vma %lx pagep %lx\n",
+ proc->pid, vma->vm_start, vma->vm_end,
+ (vma->vm_end - vma->vm_start) / SZ_1K, vma->vm_flags,
+ (unsigned long)pgprot_val(vma->vm_page_prot));
dump_stack();
}
static void binder_vma_close(struct vm_area_struct *vma)
{
struct binder_proc *proc = vma->vm_private_data;
- if (binder_debug_mask & BINDER_DEBUG_OPEN_CLOSE)
- printk(KERN_INFO
- "binder: %d close vm area %lx-%lx (%ld K) vma %lx pagep %lx\n",
- proc->pid, vma->vm_start, vma->vm_end,
- (vma->vm_end - vma->vm_start) / SZ_1K, vma->vm_flags,
- (unsigned long)pgprot_val(vma->vm_page_prot));
+ binder_debug(BINDER_DEBUG_OPEN_CLOSE,
+ "binder: %d close vm area %lx-%lx (%ld K) vma %lx pagep %lx\n",
+ proc->pid, vma->vm_start, vma->vm_end,
+ (vma->vm_end - vma->vm_start) / SZ_1K, vma->vm_flags,
+ (unsigned long)pgprot_val(vma->vm_page_prot));
proc->vma = NULL;
binder_defer_work(proc, BINDER_DEFERRED_PUT_FILES);
}
@@ -2733,12 +2772,11 @@ static int binder_mmap(struct file *filp, struct vm_area_struct *vma)
if ((vma->vm_end - vma->vm_start) > SZ_4M)
vma->vm_end = vma->vm_start + SZ_4M;
- if (binder_debug_mask & BINDER_DEBUG_OPEN_CLOSE)
- printk(KERN_INFO
- "binder_mmap: %d %lx-%lx (%ld K) vma %lx pagep %lx\n",
- proc->pid, vma->vm_start, vma->vm_end,
- (vma->vm_end - vma->vm_start) / SZ_1K, vma->vm_flags,
- (unsigned long)pgprot_val(vma->vm_page_prot));
+ binder_debug(BINDER_DEBUG_OPEN_CLOSE,
+ "binder_mmap: %d %lx-%lx (%ld K) vma %lx pagep %lx\n",
+ proc->pid, vma->vm_start, vma->vm_end,
+ (vma->vm_end - vma->vm_start) / SZ_1K, vma->vm_flags,
+ (unsigned long)pgprot_val(vma->vm_page_prot));
if (vma->vm_flags & FORBIDDEN_MMAP_FLAGS) {
ret = -EPERM;
@@ -2818,9 +2856,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);
+ binder_debug(BINDER_DEBUG_OPEN_CLOSE, "binder_open: %d:%d\n",
+ current->group_leader->pid, current->pid);
proc = kzalloc(sizeof(*proc), GFP_KERNEL);
if (proc == NULL)
@@ -2831,7 +2868,7 @@ static int binder_open(struct inode *nodp, struct file *filp)
init_waitqueue_head(&proc->wait);
proc->default_priority = task_nice(current);
mutex_lock(&binder_lock);
- binder_stats.obj_created[BINDER_STAT_PROC]++;
+ binder_stats_created(BINDER_STAT_PROC);
hlist_add_head(&proc->proc_node, &binder_procs);
proc->pid = current->group_leader->pid;
INIT_LIST_HEAD(&proc->delivered_death);
@@ -2873,8 +2910,9 @@ static void binder_deferred_flush(struct binder_proc *proc)
}
wake_up_interruptible_all(&proc->wait);
- if (binder_debug_mask & BINDER_DEBUG_OPEN_CLOSE)
- printk(KERN_INFO "binder_flush: %d woke %d threads\n", proc->pid, wake_count);
+ binder_debug(BINDER_DEBUG_OPEN_CLOSE,
+ "binder_flush: %d woke %d threads\n", proc->pid,
+ wake_count);
}
static int binder_release(struct inode *nodp, struct file *filp)
@@ -2903,8 +2941,9 @@ static void binder_deferred_release(struct binder_proc *proc)
hlist_del(&proc->proc_node);
if (binder_context_mgr_node && binder_context_mgr_node->proc == proc) {
- if (binder_debug_mask & BINDER_DEBUG_DEAD_BINDER)
- printk(KERN_INFO "binder_release: %d context_mgr_node gone\n", proc->pid);
+ binder_debug(BINDER_DEBUG_DEAD_BINDER,
+ "binder_release: %d context_mgr_node gone\n",
+ proc->pid);
binder_context_mgr_node = NULL;
}
@@ -2925,7 +2964,7 @@ static void binder_deferred_release(struct binder_proc *proc)
list_del_init(&node->work.entry);
if (hlist_empty(&node->refs)) {
kfree(node);
- binder_stats.obj_deleted[BINDER_STAT_NODE]++;
+ binder_stats_deleted(BINDER_STAT_NODE);
} else {
struct binder_ref *ref;
int death = 0;
@@ -2947,10 +2986,10 @@ static void binder_deferred_release(struct binder_proc *proc)
BUG();
}
}
- 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);
+ binder_debug(BINDER_DEBUG_DEAD_BINDER,
+ "binder: node %d now dead, "
+ "refs %d, death %d\n", node->debug_id,
+ incoming_refs, death);
}
}
outgoing_refs = 0;
@@ -2979,20 +3018,18 @@ static void binder_deferred_release(struct binder_proc *proc)
buffers++;
}
- binder_stats.obj_deleted[BINDER_STAT_PROC]++;
+ binder_stats_deleted(BINDER_STAT_PROC);
page_count = 0;
if (proc->pages) {
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);
+ binder_debug(BINDER_DEBUG_BUFFER_ALLOC,
+ "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++;
}
@@ -3003,13 +3040,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);
+ binder_debug(BINDER_DEBUG_OPEN_CLOSE,
+ "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);
}
@@ -3055,7 +3091,8 @@ static void binder_deferred_func(struct work_struct *work)
}
static DECLARE_WORK(binder_deferred_work, binder_deferred_func);
-static void binder_defer_work(struct binder_proc *proc, int defer)
+static void
+binder_defer_work(struct binder_proc *proc, enum binder_deferred_state defer)
{
mutex_lock(&binder_deferred_lock);
proc->deferred_work |= defer;
diff --git a/drivers/staging/android/lowmemorykiller.c b/drivers/staging/android/lowmemorykiller.c
index fe72240f5a9e..f13c6fc76c44 100644
--- a/drivers/staging/android/lowmemorykiller.c
+++ b/drivers/staging/android/lowmemorykiller.c
@@ -1,5 +1,21 @@
/* drivers/misc/lowmemorykiller.c
*
+ * The lowmemorykiller driver lets user-space specify a set of memory thresholds
+ * where processes with a range of oom_adj values will get killed. Specify the
+ * minimum oom_adj values in /sys/module/lowmemorykiller/parameters/adj and the
+ * number of free pages in /sys/module/lowmemorykiller/parameters/minfree. Both
+ * files take a comma separated list of numbers in ascending order.
+ *
+ * For example, write "0,8" to /sys/module/lowmemorykiller/parameters/adj and
+ * "1024,4096" to /sys/module/lowmemorykiller/parameters/minfree to kill processes
+ * with a oom_adj value of 8 or higher when the free memory drops below 4096 pages
+ * and kill processes with a oom_adj value of 0 or higher when the free memory
+ * drops below 1024 pages.
+ *
+ * The driver considers memory used for caches to be free, but if a large
+ * percentage of the cached memory is locked this can be very inaccurate
+ * and processes may not get killed until the normal oom killer is triggered.
+ *
* Copyright (C) 2007-2008 Google, Inc.
*
* This software is licensed under the terms of the GNU General Public
@@ -19,12 +35,6 @@
#include <linux/oom.h>
#include <linux/sched.h>
-static int lowmem_shrink(int nr_to_scan, gfp_t gfp_mask);
-
-static struct shrinker lowmem_shrinker = {
- .shrink = lowmem_shrink,
- .seeks = DEFAULT_SEEKS * 16
-};
static uint32_t lowmem_debug_level = 2;
static int lowmem_adj[6] = {
0,
@@ -96,19 +106,21 @@ static int lowmem_shrink(int nr_to_scan, gfp_t gfp_mask)
read_lock(&tasklist_lock);
for_each_process(p) {
+ struct mm_struct *mm;
int oom_adj;
task_lock(p);
- if (!p->mm) {
+ mm = p->mm;
+ if (!mm) {
task_unlock(p);
continue;
}
- oom_adj = p->oomkilladj;
+ oom_adj = mm->oom_adj;
if (oom_adj < min_adj) {
task_unlock(p);
continue;
}
- tasksize = get_mm_rss(p->mm);
+ tasksize = get_mm_rss(mm);
task_unlock(p);
if (tasksize <= 0)
continue;
@@ -138,6 +150,11 @@ static int lowmem_shrink(int nr_to_scan, gfp_t gfp_mask)
return rem;
}
+static struct shrinker lowmem_shrinker = {
+ .shrink = lowmem_shrink,
+ .seeks = DEFAULT_SEEKS * 16
+};
+
static int __init lowmem_init(void)
{
register_shrinker(&lowmem_shrinker);
diff --git a/drivers/staging/android/lowmemorykiller.txt b/drivers/staging/android/lowmemorykiller.txt
deleted file mode 100644
index bd5c0c028968..000000000000
--- a/drivers/staging/android/lowmemorykiller.txt
+++ /dev/null
@@ -1,16 +0,0 @@
-The lowmemorykiller driver lets user-space specify a set of memory thresholds
-where processes with a range of oom_adj values will get killed. Specify the
-minimum oom_adj values in /sys/module/lowmemorykiller/parameters/adj and the
-number of free pages in /sys/module/lowmemorykiller/parameters/minfree. Both
-files take a comma separated list of numbers in ascending order.
-
-For example, write "0,8" to /sys/module/lowmemorykiller/parameters/adj and
-"1024,4096" to /sys/module/lowmemorykiller/parameters/minfree to kill processes
-with a oom_adj value of 8 or higher when the free memory drops below 4096 pages
-and kill processes with a oom_adj value of 0 or higher when the free memory
-drops below 1024 pages.
-
-The driver considers memory used for caches to be free, but if a large
-percentage of the cached memory is locked this can be very inaccurate
-and processes may not get killed until the normal oom killer is triggered.
-
diff --git a/drivers/staging/at76_usb/at76_usb.c b/drivers/staging/at76_usb/at76_usb.c
index 7b8aa5edf42f..f05a4cea4359 100644
--- a/drivers/staging/at76_usb/at76_usb.c
+++ b/drivers/staging/at76_usb/at76_usb.c
@@ -558,20 +558,6 @@ static char *hex2str(void *buf, int len)
return ret;
}
-#define MAC2STR_BUFFERS 4
-
-static inline char *mac2str(u8 *mac)
-{
- static atomic_t a = ATOMIC_INIT(0);
- static char bufs[MAC2STR_BUFFERS][6 * 3];
- char *str;
-
- str = bufs[atomic_inc_return(&a) & (MAC2STR_BUFFERS - 1)];
- sprintf(str, "%02x:%02x:%02x:%02x:%02x:%02x",
- mac[0], mac[1], mac[2], mac[3], mac[4], mac[5]);
- return str;
-}
-
/* LED trigger */
static int tx_activity;
static void at76_ledtrig_tx_timerfunc(unsigned long data);
@@ -1071,13 +1057,12 @@ static void at76_dump_mib_mac_addr(struct at76_priv *priv)
goto exit;
}
- at76_dbg(DBG_MIB, "%s: MIB MAC_ADDR: mac_addr %s res 0x%x 0x%x",
- priv->netdev->name,
- mac2str(m->mac_addr), m->res[0], m->res[1]);
+ at76_dbg(DBG_MIB, "%s: MIB MAC_ADDR: mac_addr %pM res 0x%x 0x%x",
+ priv->netdev->name, m->mac_addr, m->res[0], m->res[1]);
for (i = 0; i < ARRAY_SIZE(m->group_addr); i++)
- at76_dbg(DBG_MIB, "%s: MIB MAC_ADDR: group addr %d: %s, "
+ at76_dbg(DBG_MIB, "%s: MIB MAC_ADDR: group addr %d: %pM, "
"status %d", priv->netdev->name, i,
- mac2str(m->group_addr[i]), m->group_addr_status[i]);
+ m->group_addr[i], m->group_addr_status[i]);
exit:
kfree(m);
}
@@ -1140,7 +1125,7 @@ static void at76_dump_mib_mac_mgmt(struct at76_priv *priv)
at76_dbg(DBG_MIB, "%s: MIB MAC_MGMT: beacon_period %d CFP_max_duration "
"%d medium_occupancy_limit %d station_id 0x%x ATIM_window %d "
"CFP_mode %d privacy_opt_impl %d DTIM_period %d CFP_period %d "
- "current_bssid %s current_essid %s current_bss_type %d "
+ "current_bssid %pM scurrent_essid %s current_bss_type %d "
"pm_mode %d ibss_change %d res %d "
"multi_domain_capability_implemented %d "
"international_roaming %d country_string %.3s",
@@ -1149,7 +1134,7 @@ static void at76_dump_mib_mac_mgmt(struct at76_priv *priv)
le16_to_cpu(m->medium_occupancy_limit),
le16_to_cpu(m->station_id), le16_to_cpu(m->ATIM_window),
m->CFP_mode, m->privacy_option_implemented, m->DTIM_period,
- m->CFP_period, mac2str(m->current_bssid),
+ m->CFP_period, m->current_bssid,
hex2str(m->current_essid, IW_ESSID_MAX_SIZE),
m->current_bss_type, m->power_mgmt_mode, m->ibss_change,
m->res, m->multi_domain_capability_implemented,
@@ -1178,7 +1163,7 @@ static void at76_dump_mib_mac(struct at76_priv *priv)
"cwmin %d cwmax %d short_retry_time %d long_retry_time %d "
"scan_type %d scan_channel %d probe_delay %u "
"min_channel_time %d max_channel_time %d listen_int %d "
- "desired_ssid %s desired_bssid %s desired_bsstype %d",
+ "desired_ssid %s desired_bssid %pM desired_bsstype %d",
priv->netdev->name, le32_to_cpu(m->max_tx_msdu_lifetime),
le32_to_cpu(m->max_rx_lifetime),
le16_to_cpu(m->frag_threshold), le16_to_cpu(m->rts_threshold),
@@ -1189,7 +1174,7 @@ static void at76_dump_mib_mac(struct at76_priv *priv)
le16_to_cpu(m->max_channel_time),
le16_to_cpu(m->listen_interval),
hex2str(m->desired_ssid, IW_ESSID_MAX_SIZE),
- mac2str(m->desired_bssid), m->desired_bsstype);
+ m->desired_bssid, m->desired_bsstype);
exit:
kfree(m);
}
@@ -1297,8 +1282,8 @@ static int at76_get_current_bssid(struct at76_priv *priv)
goto error;
}
memcpy(priv->bssid, mac_mgmt->current_bssid, ETH_ALEN);
- printk(KERN_INFO "%s: using BSSID %s\n", priv->netdev->name,
- mac2str(priv->bssid));
+ printk(KERN_INFO "%s: using BSSID %pM\n", priv->netdev->name,
+ priv->bssid);
error:
kfree(mac_mgmt);
exit:
@@ -1468,8 +1453,8 @@ static int at76_join_bss(struct at76_priv *priv, struct bss_info *ptr)
join.timeout = cpu_to_le16(2000);
at76_dbg(DBG_PROGRESS,
- "%s join addr %s ssid %s type %d ch %d timeout %d",
- priv->netdev->name, mac2str(join.bssid), join.essid,
+ "%s join addr %pM ssid %s stype %d ch %d timeout %d",
+ priv->netdev->name, join.bssid, join.essid,
join.bss_type, join.channel, le16_to_cpu(join.timeout));
return at76_set_card_command(priv->udev, CMD_JOIN, &join,
sizeof(struct at76_req_join));
@@ -1670,8 +1655,8 @@ static int at76_auth_req(struct at76_priv *priv, struct bss_info *bss,
/* init. at76_priv tx header */
tx_buffer->wlength = cpu_to_le16(buf_len - AT76_TX_HDRLEN);
- at76_dbg(DBG_TX_MGMT, "%s: AuthReq bssid %s alg %d seq_nr %d",
- priv->netdev->name, mac2str(mgmt->addr3),
+ at76_dbg(DBG_TX_MGMT, "%s: AuthReq bssid %pM alg %d seq_nr %d",
+ priv->netdev->name, mgmt->addr3,
le16_to_cpu(req->algorithm), le16_to_cpu(req->transaction));
if (seq_nr == 3)
at76_dbg(DBG_TX_MGMT, "%s: AuthReq challenge: %s ...",
@@ -1746,8 +1731,8 @@ static int at76_assoc_req(struct at76_priv *priv, struct bss_info *bss)
next_ie(&ie); /* points to IE of rates now */
at76_dbg(DBG_TX_MGMT,
- "%s: AssocReq bssid %s capa 0x%04x ssid %.*s rates %s",
- priv->netdev->name, mac2str(mgmt->addr3),
+ "%s: AssocReq bssid %pM capa 0x%04x ssid %.*s rates %s",
+ priv->netdev->name, mgmt->addr3,
le16_to_cpu(req->capability), essid_len, essid,
hex2str(ie->data, ie->len));
@@ -1773,8 +1758,8 @@ static void at76_bss_list_timeout(unsigned long par)
if (ptr != priv->curr_bss
&& time_after(jiffies, ptr->last_rx + BSS_LIST_TIMEOUT)) {
at76_dbg(DBG_BSS_TABLE_RM,
- "%s: bss_list: removing old BSS %s ch %d",
- priv->netdev->name, mac2str(ptr->bssid),
+ "%s: bss_list: removing old BSS %pM ch %d",
+ priv->netdev->name, ptr->bssid,
ptr->channel);
list_del(&ptr->list);
kfree(ptr);
@@ -1806,9 +1791,9 @@ static void at76_dump_bss_table(struct at76_priv *priv)
list_for_each(lptr, &priv->bss_list) {
ptr = list_entry(lptr, struct bss_info, list);
- at76_dbg(DBG_BSS_TABLE, "0x%p: bssid %s channel %d ssid %.*s "
+ at76_dbg(DBG_BSS_TABLE, "0x%p: bssid %pM channel %d ssid %.*s "
"(%s) capa 0x%04x rates %s rssi %d link %d noise %d",
- ptr, mac2str(ptr->bssid), ptr->channel, ptr->ssid_len,
+ ptr, ptr->bssid, ptr->channel, ptr->ssid_len,
ptr->ssid, hex2str(ptr->ssid, ptr->ssid_len),
ptr->capa, hex2str(ptr->rates, ptr->rates_len),
ptr->rssi, ptr->link_qual, ptr->noise_level);
@@ -1855,8 +1840,8 @@ static void at76_work_assoc_done(struct work_struct *work)
netif_wake_queue(priv->netdev);
at76_set_mac_state(priv, MAC_CONNECTED);
at76_iwevent_bss_connect(priv->netdev, priv->curr_bss->bssid);
- at76_dbg(DBG_PROGRESS, "%s: connected to BSSID %s",
- priv->netdev->name, mac2str(priv->curr_bss->bssid));
+ at76_dbg(DBG_PROGRESS, "%s: connected to BSSID %pM",
+ priv->netdev->name, priv->curr_bss->bssid);
exit:
mutex_unlock(&priv->mtx);
@@ -2218,8 +2203,8 @@ static int at76_iw_handler_set_wap(struct net_device *netdev,
{
struct at76_priv *priv = netdev_priv(netdev);
- at76_dbg(DBG_IOCTL, "%s: SIOCSIWAP - wap/bssid %s", netdev->name,
- mac2str(ap_addr->sa_data));
+ at76_dbg(DBG_IOCTL, "%s: SIOCSIWAP - wap/bssid %pM", netdev->name,
+ ap_addr->sa_data);
/* if the incoming address == ff:ff:ff:ff:ff:ff, the user has
chosen any or auto AP preference */
@@ -2244,8 +2229,8 @@ static int at76_iw_handler_get_wap(struct net_device *netdev,
ap_addr->sa_family = ARPHRD_ETHER;
memcpy(ap_addr->sa_data, priv->bssid, ETH_ALEN);
- at76_dbg(DBG_IOCTL, "%s: SIOCGIWAP - wap/bssid %s", netdev->name,
- mac2str(ap_addr->sa_data));
+ at76_dbg(DBG_IOCTL, "%s: SIOCGIWAP - wap/bssid %pM", netdev->name,
+ ap_addr->sa_data);
return 0;
}
@@ -3323,8 +3308,8 @@ static int at76_open(struct net_device *netdev)
set the mac address in the device ! */
if (compare_ether_addr(netdev->dev_addr, priv->mac_addr)) {
if (at76_add_mac_address(priv, netdev->dev_addr) >= 0)
- at76_dbg(DBG_PROGRESS, "%s: set new MAC addr %s",
- netdev->name, mac2str(netdev->dev_addr));
+ at76_dbg(DBG_PROGRESS, "%s: set new MAC addr %pM",
+ netdev->name, netdev->dev_addr);
}
priv->scan_state = SCAN_IDLE;
@@ -3581,11 +3566,11 @@ static inline int at76_match_bssid(struct at76_priv *priv, struct bss_info *ptr)
return 1;
at76_dbg(DBG_BSS_MATCH,
- "%s: requested bssid - %s does not match",
- priv->netdev->name, mac2str(priv->wanted_bssid));
+ "%s: requested bssid - %pM does not match",
+ priv->netdev->name, priv->wanted_bssid);
at76_dbg(DBG_BSS_MATCH,
- " AP bssid - %s of bss table entry %p",
- mac2str(ptr->bssid), ptr);
+ " AP bssid - %pM of bss table entry %p",
+ ptr->bssid, ptr);
return 0;
}
@@ -3668,9 +3653,9 @@ static void at76_work_join(struct work_struct *work)
printk(KERN_ERR "%s: join_bss completed with %d\n",
priv->netdev->name, ret);
else
- printk(KERN_INFO "%s: join_bss ssid %s timed out\n",
+ printk(KERN_INFO "%s: join_bss ssid %pM timed out\n",
priv->netdev->name,
- mac2str(priv->curr_bss->bssid));
+ priv->curr_bss->bssid);
/* retry next BSS immediately */
schedule_work(&priv->work_join);
@@ -3788,8 +3773,8 @@ static void at76_dwork_beacon(struct work_struct *work)
goto exit;
/* We haven't received any beacons from out AP for BEACON_TIMEOUT */
- printk(KERN_INFO "%s: lost beacon bssid %s\n",
- priv->netdev->name, mac2str(priv->curr_bss->bssid));
+ printk(KERN_INFO "%s: lost beacon bssid %pM\n",
+ priv->netdev->name, priv->curr_bss->bssid);
netif_carrier_off(priv->netdev);
netif_stop_queue(priv->netdev);
@@ -3879,7 +3864,7 @@ static void at76_work_new_bss(struct work_struct *work)
at76_dbg(DBG_PROGRESS, "ibss_change = 0x%2x", mac_mgmt.ibss_change);
memcpy(priv->bssid, mac_mgmt.current_bssid, ETH_ALEN);
- at76_dbg(DBG_PROGRESS, "using BSSID %s", mac2str(priv->bssid));
+ at76_dbg(DBG_PROGRESS, "using BSSID %pM", priv->bssid);
at76_iwevent_bss_connect(priv->netdev, priv->bssid);
@@ -4116,9 +4101,9 @@ static void at76_rx_mgmt_assoc(struct at76_priv *priv,
u16 assoc_id = le16_to_cpu(resp->aid);
u16 status = le16_to_cpu(resp->status);
- at76_dbg(DBG_RX_MGMT, "%s: rx AssocResp bssid %s capa 0x%04x status "
+ at76_dbg(DBG_RX_MGMT, "%s: rx AssocResp bssid %pM capa 0x%04x status "
"0x%04x assoc_id 0x%04x rates %s", priv->netdev->name,
- mac2str(resp->header.addr3), le16_to_cpu(resp->capability),
+ resp->header.addr3, le16_to_cpu(resp->capability),
status, assoc_id, hex2str(resp->info_element->data,
resp->info_element->len));
@@ -4155,9 +4140,9 @@ static void at76_rx_mgmt_disassoc(struct at76_priv *priv,
struct ieee80211_hdr_3addr *mgmt = &resp->header;
at76_dbg(DBG_RX_MGMT,
- "%s: rx DisAssoc bssid %s reason 0x%04x destination %s",
- priv->netdev->name, mac2str(mgmt->addr3),
- le16_to_cpu(resp->reason), mac2str(mgmt->addr1));
+ "%s: rx DisAssoc bssid %pM reason 0x%04x destination %pM",
+ priv->netdev->name, mgmt->addr3,
+ le16_to_cpu(resp->reason), mgmt->addr1);
/* We are not connected, ignore */
if (priv->mac_state == MAC_SCANNING || priv->mac_state == MAC_INIT
@@ -4203,9 +4188,9 @@ static void at76_rx_mgmt_auth(struct at76_priv *priv,
int status = le16_to_cpu(resp->status);
at76_dbg(DBG_RX_MGMT,
- "%s: rx AuthFrame bssid %s alg %d seq_nr %d status %d "
- "destination %s", priv->netdev->name, mac2str(mgmt->addr3),
- alg, seq_nr, status, mac2str(mgmt->addr1));
+ "%s: rx AuthFrame bssid %pM alg %d seq_nr %d status %d "
+ "destination %pM", priv->netdev->name, mgmt->addr3,
+ alg, seq_nr, status, mgmt->addr1);
if (alg == WLAN_AUTH_SHARED_KEY && seq_nr == 2)
at76_dbg(DBG_RX_MGMT, "%s: AuthFrame challenge %s ...",
@@ -4262,9 +4247,9 @@ static void at76_rx_mgmt_deauth(struct at76_priv *priv,
struct ieee80211_hdr_3addr *mgmt = &resp->header;
at76_dbg(DBG_RX_MGMT | DBG_PROGRESS,
- "%s: rx DeAuth bssid %s reason 0x%04x destination %s",
- priv->netdev->name, mac2str(mgmt->addr3),
- le16_to_cpu(resp->reason), mac2str(mgmt->addr1));
+ "%s: rx DeAuth bssid %pM reason 0x%04x destination %pM",
+ priv->netdev->name, mgmt->addr3,
+ le16_to_cpu(resp->reason), mgmt->addr1);
if (priv->mac_state != MAC_AUTH && priv->mac_state != MAC_ASSOC
&& priv->mac_state != MAC_CONNECTED) {
@@ -4366,8 +4351,8 @@ static void at76_rx_mgmt_beacon(struct at76_priv *priv,
match->link_qual = buf->link_quality;
match->noise_level = buf->noise_level;
memcpy(match->bssid, mgmt->addr3, ETH_ALEN);
- at76_dbg(DBG_RX_BEACON, "%s: bssid %s", priv->netdev->name,
- mac2str(match->bssid));
+ at76_dbg(DBG_RX_BEACON, "%s: bssid %pM", priv->netdev->name,
+ match->bssid);
ie = bdata->info_element;
@@ -4677,9 +4662,9 @@ static struct sk_buff *at76_check_for_rx_frags(struct at76_priv *priv)
unsigned long oldest = ~0UL;
at76_dbg(DBG_RX_FRAGS,
- "%s: rx data frame_ctl %04x addr2 %s seq/frag %d/%d "
+ "%s: rx data frame_ctl %04x addr2 %pM seq/frag %d/%d "
"length %d data %d: %s ...", priv->netdev->name, frame_ctl,
- mac2str(i802_11_hdr->addr2), seqnr, fragnr, length, data_len,
+ i802_11_hdr->addr2, seqnr, fragnr, length, data_len,
hex2str(data, 32));
at76_dbg(DBG_RX_FRAGS_SKB, "%s: incoming skb: head %p data %p "
@@ -4838,8 +4823,8 @@ static struct sk_buff *at76_check_for_rx_frags(struct at76_priv *priv)
priv->rx_skb = skb;
at76_dbg(DBG_RX_FRAGS,
- "%s: free old contents: sender %s seq/frag %d/%d",
- priv->netdev->name, mac2str(optr->sender),
+ "%s: free old contents: sender %pM seq/frag %d/%d",
+ priv->netdev->name, optr->sender,
optr->seqnr, optr->fragnr);
} else {
@@ -5319,10 +5304,12 @@ static int at76_init_new_device(struct at76_priv *priv,
/* Add pointers to enable iwspy support. */
priv->wireless_data.spy_data = &priv->spy_data;
+#ifdef CONFIG_WIRELESS_EXT
netdev->wireless_data = &priv->wireless_data;
+ netdev->wireless_handlers = &at76_handler_def;
+#endif
netdev->watchdog_timeo = 2 * HZ;
- netdev->wireless_handlers = &at76_handler_def;
dev_alloc_name(netdev, "wlan%d");
ret = register_netdev(priv->netdev);
@@ -5333,8 +5320,8 @@ static int at76_init_new_device(struct at76_priv *priv,
}
priv->netdev_registered = 1;
- printk(KERN_INFO "%s: USB %s, MAC %s, firmware %d.%d.%d-%d\n",
- netdev->name, dev_name(&interface->dev), mac2str(priv->mac_addr),
+ printk(KERN_INFO "%s: USB %s, MAC %pM, firmware %d.%d.%d-%d\n",
+ netdev->name, dev_name(&interface->dev), priv->mac_addr,
priv->fw_version.major, priv->fw_version.minor,
priv->fw_version.patch, priv->fw_version.build);
printk(KERN_INFO "%s: regulatory domain 0x%02x: %s\n", netdev->name,
diff --git a/drivers/staging/comedi/comedi.h b/drivers/staging/comedi/comedi.h
index 8101cea84528..957b6405dfa7 100644
--- a/drivers/staging/comedi/comedi.h
+++ b/drivers/staging/comedi/comedi.h
@@ -121,10 +121,10 @@ extern "C" {
#define TRIG_BOGUS 0x0001 /* do the motions */
#define TRIG_DITHER 0x0002 /* enable dithering */
#define TRIG_DEGLITCH 0x0004 /* enable deglitching */
-/*#define TRIG_RT 0x0008 */ /* perform op in real time */
+ /*#define TRIG_RT 0x0008 *//* perform op in real time */
#define TRIG_CONFIG 0x0010 /* perform configuration, not triggering */
#define TRIG_WAKE_EOS 0x0020 /* wake up on end-of-scan events */
-/*#define TRIG_WRITE 0x0040*/ /* write to bidirectional devices */
+ /*#define TRIG_WRITE 0x0040*//* write to bidirectional devices */
/* command flags */
/* These flags are used in comedi_cmd structures */
@@ -199,93 +199,91 @@ extern "C" {
#define SDF_LSAMPL 0x10000000 /* subdevice uses 32-bit samples */
#define SDF_PACKED 0x20000000 /* subdevice can do packed DIO */
/* re recyle these flags for PWM */
-#define SDF_PWM_COUNTER SDF_MODE0 /* PWM can automatically switch off */
-#define SDF_PWM_HBRIDGE SDF_MODE1 /* PWM is signed (H-bridge) */
-
-
+#define SDF_PWM_COUNTER SDF_MODE0 /* PWM can automatically switch off */
+#define SDF_PWM_HBRIDGE SDF_MODE1 /* PWM is signed (H-bridge) */
/* subdevice types */
-enum comedi_subdevice_type {
- COMEDI_SUBD_UNUSED, /* unused by driver */
- COMEDI_SUBD_AI, /* analog input */
- COMEDI_SUBD_AO, /* analog output */
- COMEDI_SUBD_DI, /* digital input */
- COMEDI_SUBD_DO, /* digital output */
- COMEDI_SUBD_DIO, /* digital input/output */
- COMEDI_SUBD_COUNTER, /* counter */
- COMEDI_SUBD_TIMER, /* timer */
- COMEDI_SUBD_MEMORY, /* memory, EEPROM, DPRAM */
- COMEDI_SUBD_CALIB, /* calibration DACs */
- COMEDI_SUBD_PROC, /* processor, DSP */
- COMEDI_SUBD_SERIAL, /* serial IO */
- COMEDI_SUBD_PWM /* PWM */
-};
+ enum comedi_subdevice_type {
+ COMEDI_SUBD_UNUSED, /* unused by driver */
+ COMEDI_SUBD_AI, /* analog input */
+ COMEDI_SUBD_AO, /* analog output */
+ COMEDI_SUBD_DI, /* digital input */
+ COMEDI_SUBD_DO, /* digital output */
+ COMEDI_SUBD_DIO, /* digital input/output */
+ COMEDI_SUBD_COUNTER, /* counter */
+ COMEDI_SUBD_TIMER, /* timer */
+ COMEDI_SUBD_MEMORY, /* memory, EEPROM, DPRAM */
+ COMEDI_SUBD_CALIB, /* calibration DACs */
+ COMEDI_SUBD_PROC, /* processor, DSP */
+ COMEDI_SUBD_SERIAL, /* serial IO */
+ COMEDI_SUBD_PWM /* PWM */
+ };
/* configuration instructions */
-enum configuration_ids {
- INSN_CONFIG_DIO_INPUT = 0,
- INSN_CONFIG_DIO_OUTPUT = 1,
- INSN_CONFIG_DIO_OPENDRAIN = 2,
- INSN_CONFIG_ANALOG_TRIG = 16,
+ enum configuration_ids {
+ INSN_CONFIG_DIO_INPUT = 0,
+ INSN_CONFIG_DIO_OUTPUT = 1,
+ INSN_CONFIG_DIO_OPENDRAIN = 2,
+ INSN_CONFIG_ANALOG_TRIG = 16,
/* INSN_CONFIG_WAVEFORM = 17, */
/* INSN_CONFIG_TRIG = 18, */
/* INSN_CONFIG_COUNTER = 19, */
- INSN_CONFIG_ALT_SOURCE = 20,
- INSN_CONFIG_DIGITAL_TRIG = 21,
- INSN_CONFIG_BLOCK_SIZE = 22,
- INSN_CONFIG_TIMER_1 = 23,
- INSN_CONFIG_FILTER = 24,
- INSN_CONFIG_CHANGE_NOTIFY = 25,
-
- /*ALPHA*/ INSN_CONFIG_SERIAL_CLOCK = 26,
- INSN_CONFIG_BIDIRECTIONAL_DATA = 27,
- INSN_CONFIG_DIO_QUERY = 28,
- INSN_CONFIG_PWM_OUTPUT = 29,
- INSN_CONFIG_GET_PWM_OUTPUT = 30,
- INSN_CONFIG_ARM = 31,
- INSN_CONFIG_DISARM = 32,
- INSN_CONFIG_GET_COUNTER_STATUS = 33,
- INSN_CONFIG_RESET = 34,
- INSN_CONFIG_GPCT_SINGLE_PULSE_GENERATOR = 1001, /* Use CTR as single pulsegenerator */
- INSN_CONFIG_GPCT_PULSE_TRAIN_GENERATOR = 1002, /* Use CTR as pulsetraingenerator */
- INSN_CONFIG_GPCT_QUADRATURE_ENCODER = 1003, /* Use the counter as encoder */
- INSN_CONFIG_SET_GATE_SRC = 2001, /* Set gate source */
- INSN_CONFIG_GET_GATE_SRC = 2002, /* Get gate source */
- INSN_CONFIG_SET_CLOCK_SRC = 2003, /* Set master clock source */
- INSN_CONFIG_GET_CLOCK_SRC = 2004, /* Get master clock source */
- INSN_CONFIG_SET_OTHER_SRC = 2005, /* Set other source */
-/* INSN_CONFIG_GET_OTHER_SRC = 2006,*/ /* Get other source */
- INSN_CONFIG_GET_HARDWARE_BUFFER_SIZE = 2006, /* Get size in bytes of
- subdevice's on-board
- fifos used during
- streaming
- input/output */
- INSN_CONFIG_SET_COUNTER_MODE = 4097,
- INSN_CONFIG_8254_SET_MODE = INSN_CONFIG_SET_COUNTER_MODE, /* deprecated */
- INSN_CONFIG_8254_READ_STATUS = 4098,
- INSN_CONFIG_SET_ROUTING = 4099,
- INSN_CONFIG_GET_ROUTING = 4109,
+ INSN_CONFIG_ALT_SOURCE = 20,
+ INSN_CONFIG_DIGITAL_TRIG = 21,
+ INSN_CONFIG_BLOCK_SIZE = 22,
+ INSN_CONFIG_TIMER_1 = 23,
+ INSN_CONFIG_FILTER = 24,
+ INSN_CONFIG_CHANGE_NOTIFY = 25,
+
+ /*ALPHA*/ INSN_CONFIG_SERIAL_CLOCK = 26,
+ INSN_CONFIG_BIDIRECTIONAL_DATA = 27,
+ INSN_CONFIG_DIO_QUERY = 28,
+ INSN_CONFIG_PWM_OUTPUT = 29,
+ INSN_CONFIG_GET_PWM_OUTPUT = 30,
+ INSN_CONFIG_ARM = 31,
+ INSN_CONFIG_DISARM = 32,
+ INSN_CONFIG_GET_COUNTER_STATUS = 33,
+ INSN_CONFIG_RESET = 34,
+ INSN_CONFIG_GPCT_SINGLE_PULSE_GENERATOR = 1001, /* Use CTR as single pulsegenerator */
+ INSN_CONFIG_GPCT_PULSE_TRAIN_GENERATOR = 1002, /* Use CTR as pulsetraingenerator */
+ INSN_CONFIG_GPCT_QUADRATURE_ENCODER = 1003, /* Use the counter as encoder */
+ INSN_CONFIG_SET_GATE_SRC = 2001, /* Set gate source */
+ INSN_CONFIG_GET_GATE_SRC = 2002, /* Get gate source */
+ INSN_CONFIG_SET_CLOCK_SRC = 2003, /* Set master clock source */
+ INSN_CONFIG_GET_CLOCK_SRC = 2004, /* Get master clock source */
+ INSN_CONFIG_SET_OTHER_SRC = 2005, /* Set other source */
+ /* INSN_CONFIG_GET_OTHER_SRC = 2006,*//* Get other source */
+ INSN_CONFIG_GET_HARDWARE_BUFFER_SIZE = 2006, /* Get size in bytes of
+ subdevice's on-board
+ fifos used during
+ streaming
+ input/output */
+ INSN_CONFIG_SET_COUNTER_MODE = 4097,
+ INSN_CONFIG_8254_SET_MODE = INSN_CONFIG_SET_COUNTER_MODE, /* deprecated */
+ INSN_CONFIG_8254_READ_STATUS = 4098,
+ INSN_CONFIG_SET_ROUTING = 4099,
+ INSN_CONFIG_GET_ROUTING = 4109,
/* PWM */
- INSN_CONFIG_PWM_SET_PERIOD = 5000, /* sets frequency */
- INSN_CONFIG_PWM_GET_PERIOD = 5001, /* gets frequency */
- INSN_CONFIG_GET_PWM_STATUS = 5002, /* is it running? */
- INSN_CONFIG_PWM_SET_H_BRIDGE = 5003, /* sets H bridge: duty cycle and sign bit for a relay at the same time*/
- INSN_CONFIG_PWM_GET_H_BRIDGE = 5004 /* gets H bridge data: duty cycle and the sign bit */
-};
-
-enum comedi_io_direction {
- COMEDI_INPUT = 0,
- COMEDI_OUTPUT = 1,
- COMEDI_OPENDRAIN = 2
-};
-
-enum comedi_support_level {
- COMEDI_UNKNOWN_SUPPORT = 0,
- COMEDI_SUPPORTED,
- COMEDI_UNSUPPORTED
-};
+ INSN_CONFIG_PWM_SET_PERIOD = 5000, /* sets frequency */
+ INSN_CONFIG_PWM_GET_PERIOD = 5001, /* gets frequency */
+ INSN_CONFIG_GET_PWM_STATUS = 5002, /* is it running? */
+ INSN_CONFIG_PWM_SET_H_BRIDGE = 5003, /* sets H bridge: duty cycle and sign bit for a relay at the same time */
+ INSN_CONFIG_PWM_GET_H_BRIDGE = 5004 /* gets H bridge data: duty cycle and the sign bit */
+ };
+
+ enum comedi_io_direction {
+ COMEDI_INPUT = 0,
+ COMEDI_OUTPUT = 1,
+ COMEDI_OPENDRAIN = 2
+ };
+
+ enum comedi_support_level {
+ COMEDI_UNKNOWN_SUPPORT = 0,
+ COMEDI_SUPPORTED,
+ COMEDI_UNSUPPORTED
+ };
/* ioctls */
@@ -309,133 +307,132 @@ enum comedi_support_level {
/* structures */
-struct comedi_trig {
- unsigned int subdev; /* subdevice */
- unsigned int mode; /* mode */
- unsigned int flags;
- unsigned int n_chan; /* number of channels */
- unsigned int *chanlist; /* channel/range list */
- short *data; /* data list, size depends on subd flags */
- unsigned int n; /* number of scans */
- unsigned int trigsrc;
- unsigned int trigvar;
- unsigned int trigvar1;
- unsigned int data_len;
- unsigned int unused[3];
-};
-
-struct comedi_insn {
- unsigned int insn;
- unsigned int n;
- unsigned int *data;
- unsigned int subdev;
- unsigned int chanspec;
- unsigned int unused[3];
-};
-
-struct comedi_insnlist {
- unsigned int n_insns;
- struct comedi_insn *insns;
-};
-
-struct comedi_cmd {
- unsigned int subdev;
- unsigned int flags;
-
- unsigned int start_src;
- unsigned int start_arg;
-
- unsigned int scan_begin_src;
- unsigned int scan_begin_arg;
-
- unsigned int convert_src;
- unsigned int convert_arg;
-
- unsigned int scan_end_src;
- unsigned int scan_end_arg;
-
- unsigned int stop_src;
- unsigned int stop_arg;
-
- unsigned int *chanlist; /* channel/range list */
- unsigned int chanlist_len;
-
- short *data; /* data list, size depends on subd flags */
- unsigned int data_len;
-};
-
-struct comedi_chaninfo {
- unsigned int subdev;
- unsigned int *maxdata_list;
- unsigned int *flaglist;
- unsigned int *rangelist;
- unsigned int unused[4];
-};
-
-struct comedi_rangeinfo {
- unsigned int range_type;
- void *range_ptr;
-};
-
-struct comedi_krange {
- int min; /* fixed point, multiply by 1e-6 */
- int max; /* fixed point, multiply by 1e-6 */
- unsigned int flags;
-};
-
-
-struct comedi_subdinfo {
- unsigned int type;
- unsigned int n_chan;
- unsigned int subd_flags;
- unsigned int timer_type;
- unsigned int len_chanlist;
- unsigned int maxdata;
- unsigned int flags; /* channel flags */
- unsigned int range_type; /* lookup in kernel */
- unsigned int settling_time_0;
- unsigned insn_bits_support; /* see support_level enum for values*/
- unsigned int unused[8];
-};
-
-struct comedi_devinfo {
- unsigned int version_code;
- unsigned int n_subdevs;
- char driver_name[COMEDI_NAMELEN];
- char board_name[COMEDI_NAMELEN];
- int read_subdevice;
- int write_subdevice;
- int unused[30];
-};
-
-struct comedi_devconfig {
- char board_name[COMEDI_NAMELEN];
- int options[COMEDI_NDEVCONFOPTS];
-};
-
-struct comedi_bufconfig {
- unsigned int subdevice;
- unsigned int flags;
-
- unsigned int maximum_size;
- unsigned int size;
-
- unsigned int unused[4];
-};
-
-struct comedi_bufinfo {
- unsigned int subdevice;
- unsigned int bytes_read;
-
- unsigned int buf_write_ptr;
- unsigned int buf_read_ptr;
- unsigned int buf_write_count;
- unsigned int buf_read_count;
-
- unsigned int bytes_written;
-
- unsigned int unused[4];
-};
+ struct comedi_trig {
+ unsigned int subdev; /* subdevice */
+ unsigned int mode; /* mode */
+ unsigned int flags;
+ unsigned int n_chan; /* number of channels */
+ unsigned int *chanlist; /* channel/range list */
+ short *data; /* data list, size depends on subd flags */
+ unsigned int n; /* number of scans */
+ unsigned int trigsrc;
+ unsigned int trigvar;
+ unsigned int trigvar1;
+ unsigned int data_len;
+ unsigned int unused[3];
+ };
+
+ struct comedi_insn {
+ unsigned int insn;
+ unsigned int n;
+ unsigned int *data;
+ unsigned int subdev;
+ unsigned int chanspec;
+ unsigned int unused[3];
+ };
+
+ struct comedi_insnlist {
+ unsigned int n_insns;
+ struct comedi_insn *insns;
+ };
+
+ struct comedi_cmd {
+ unsigned int subdev;
+ unsigned int flags;
+
+ unsigned int start_src;
+ unsigned int start_arg;
+
+ unsigned int scan_begin_src;
+ unsigned int scan_begin_arg;
+
+ unsigned int convert_src;
+ unsigned int convert_arg;
+
+ unsigned int scan_end_src;
+ unsigned int scan_end_arg;
+
+ unsigned int stop_src;
+ unsigned int stop_arg;
+
+ unsigned int *chanlist; /* channel/range list */
+ unsigned int chanlist_len;
+
+ short *data; /* data list, size depends on subd flags */
+ unsigned int data_len;
+ };
+
+ struct comedi_chaninfo {
+ unsigned int subdev;
+ unsigned int *maxdata_list;
+ unsigned int *flaglist;
+ unsigned int *rangelist;
+ unsigned int unused[4];
+ };
+
+ struct comedi_rangeinfo {
+ unsigned int range_type;
+ void *range_ptr;
+ };
+
+ struct comedi_krange {
+ int min; /* fixed point, multiply by 1e-6 */
+ int max; /* fixed point, multiply by 1e-6 */
+ unsigned int flags;
+ };
+
+ struct comedi_subdinfo {
+ unsigned int type;
+ unsigned int n_chan;
+ unsigned int subd_flags;
+ unsigned int timer_type;
+ unsigned int len_chanlist;
+ unsigned int maxdata;
+ unsigned int flags; /* channel flags */
+ unsigned int range_type; /* lookup in kernel */
+ unsigned int settling_time_0;
+ unsigned insn_bits_support; /* see support_level enum for values */
+ unsigned int unused[8];
+ };
+
+ struct comedi_devinfo {
+ unsigned int version_code;
+ unsigned int n_subdevs;
+ char driver_name[COMEDI_NAMELEN];
+ char board_name[COMEDI_NAMELEN];
+ int read_subdevice;
+ int write_subdevice;
+ int unused[30];
+ };
+
+ struct comedi_devconfig {
+ char board_name[COMEDI_NAMELEN];
+ int options[COMEDI_NDEVCONFOPTS];
+ };
+
+ struct comedi_bufconfig {
+ unsigned int subdevice;
+ unsigned int flags;
+
+ unsigned int maximum_size;
+ unsigned int size;
+
+ unsigned int unused[4];
+ };
+
+ struct comedi_bufinfo {
+ unsigned int subdevice;
+ unsigned int bytes_read;
+
+ unsigned int buf_write_ptr;
+ unsigned int buf_read_ptr;
+ unsigned int buf_write_count;
+ unsigned int buf_read_count;
+
+ unsigned int bytes_written;
+
+ unsigned int unused[4];
+ };
/* range stuff */
@@ -486,298 +483,284 @@ struct comedi_bufinfo {
*/
-enum i8254_mode {
- I8254_MODE0 = (0 << 1), /* Interrupt on terminal count */
- I8254_MODE1 = (1 << 1), /* Hardware retriggerable one-shot */
- I8254_MODE2 = (2 << 1), /* Rate generator */
- I8254_MODE3 = (3 << 1), /* Square wave mode */
- I8254_MODE4 = (4 << 1), /* Software triggered strobe */
- I8254_MODE5 = (5 << 1), /* Hardware triggered strobe (retriggerable) */
- I8254_BCD = 1, /* use binary-coded decimal instead of binary (pretty useless) */
- I8254_BINARY = 0
-};
-
-static inline unsigned NI_USUAL_PFI_SELECT(unsigned pfi_channel)
-{
- if (pfi_channel < 10)
- return 0x1 + pfi_channel;
- else
- return 0xb + pfi_channel;
-}
-static inline unsigned NI_USUAL_RTSI_SELECT(unsigned rtsi_channel)
-{
- if (rtsi_channel < 7)
- return 0xb + rtsi_channel;
- else
- return 0x1b;
-}
+ enum i8254_mode {
+ I8254_MODE0 = (0 << 1), /* Interrupt on terminal count */
+ I8254_MODE1 = (1 << 1), /* Hardware retriggerable one-shot */
+ I8254_MODE2 = (2 << 1), /* Rate generator */
+ I8254_MODE3 = (3 << 1), /* Square wave mode */
+ I8254_MODE4 = (4 << 1), /* Software triggered strobe */
+ I8254_MODE5 = (5 << 1), /* Hardware triggered strobe (retriggerable) */
+ I8254_BCD = 1, /* use binary-coded decimal instead of binary (pretty useless) */
+ I8254_BINARY = 0
+ };
+
+ static inline unsigned NI_USUAL_PFI_SELECT(unsigned pfi_channel) {
+ if (pfi_channel < 10)
+ return 0x1 + pfi_channel;
+ else
+ return 0xb + pfi_channel;
+ } static inline unsigned NI_USUAL_RTSI_SELECT(unsigned rtsi_channel) {
+ if (rtsi_channel < 7)
+ return 0xb + rtsi_channel;
+ else
+ return 0x1b;
+ }
/* mode bits for NI general-purpose counters, set with
* INSN_CONFIG_SET_COUNTER_MODE */
#define NI_GPCT_COUNTING_MODE_SHIFT 16
#define NI_GPCT_INDEX_PHASE_BITSHIFT 20
#define NI_GPCT_COUNTING_DIRECTION_SHIFT 24
-enum ni_gpct_mode_bits {
- NI_GPCT_GATE_ON_BOTH_EDGES_BIT = 0x4,
- NI_GPCT_EDGE_GATE_MODE_MASK = 0x18,
- NI_GPCT_EDGE_GATE_STARTS_STOPS_BITS = 0x0,
- NI_GPCT_EDGE_GATE_STOPS_STARTS_BITS = 0x8,
- NI_GPCT_EDGE_GATE_STARTS_BITS = 0x10,
- NI_GPCT_EDGE_GATE_NO_STARTS_NO_STOPS_BITS = 0x18,
- NI_GPCT_STOP_MODE_MASK = 0x60,
- NI_GPCT_STOP_ON_GATE_BITS = 0x00,
- NI_GPCT_STOP_ON_GATE_OR_TC_BITS = 0x20,
- NI_GPCT_STOP_ON_GATE_OR_SECOND_TC_BITS = 0x40,
- NI_GPCT_LOAD_B_SELECT_BIT = 0x80,
- NI_GPCT_OUTPUT_MODE_MASK = 0x300,
- NI_GPCT_OUTPUT_TC_PULSE_BITS = 0x100,
- NI_GPCT_OUTPUT_TC_TOGGLE_BITS = 0x200,
- NI_GPCT_OUTPUT_TC_OR_GATE_TOGGLE_BITS = 0x300,
- NI_GPCT_HARDWARE_DISARM_MASK = 0xc00,
- NI_GPCT_NO_HARDWARE_DISARM_BITS = 0x000,
- NI_GPCT_DISARM_AT_TC_BITS = 0x400,
- NI_GPCT_DISARM_AT_GATE_BITS = 0x800,
- NI_GPCT_DISARM_AT_TC_OR_GATE_BITS = 0xc00,
- NI_GPCT_LOADING_ON_TC_BIT = 0x1000,
- NI_GPCT_LOADING_ON_GATE_BIT = 0x4000,
- NI_GPCT_COUNTING_MODE_MASK = 0x7 << NI_GPCT_COUNTING_MODE_SHIFT,
- NI_GPCT_COUNTING_MODE_NORMAL_BITS =
- 0x0 << NI_GPCT_COUNTING_MODE_SHIFT,
- NI_GPCT_COUNTING_MODE_QUADRATURE_X1_BITS =
- 0x1 << NI_GPCT_COUNTING_MODE_SHIFT,
- NI_GPCT_COUNTING_MODE_QUADRATURE_X2_BITS =
- 0x2 << NI_GPCT_COUNTING_MODE_SHIFT,
- NI_GPCT_COUNTING_MODE_QUADRATURE_X4_BITS =
- 0x3 << NI_GPCT_COUNTING_MODE_SHIFT,
- NI_GPCT_COUNTING_MODE_TWO_PULSE_BITS =
- 0x4 << NI_GPCT_COUNTING_MODE_SHIFT,
- NI_GPCT_COUNTING_MODE_SYNC_SOURCE_BITS =
- 0x6 << NI_GPCT_COUNTING_MODE_SHIFT,
- NI_GPCT_INDEX_PHASE_MASK = 0x3 << NI_GPCT_INDEX_PHASE_BITSHIFT,
- NI_GPCT_INDEX_PHASE_LOW_A_LOW_B_BITS =
- 0x0 << NI_GPCT_INDEX_PHASE_BITSHIFT,
- NI_GPCT_INDEX_PHASE_LOW_A_HIGH_B_BITS =
- 0x1 << NI_GPCT_INDEX_PHASE_BITSHIFT,
- NI_GPCT_INDEX_PHASE_HIGH_A_LOW_B_BITS =
- 0x2 << NI_GPCT_INDEX_PHASE_BITSHIFT,
- NI_GPCT_INDEX_PHASE_HIGH_A_HIGH_B_BITS =
- 0x3 << NI_GPCT_INDEX_PHASE_BITSHIFT,
- NI_GPCT_INDEX_ENABLE_BIT = 0x400000,
- NI_GPCT_COUNTING_DIRECTION_MASK =
- 0x3 << NI_GPCT_COUNTING_DIRECTION_SHIFT,
- NI_GPCT_COUNTING_DIRECTION_DOWN_BITS =
- 0x00 << NI_GPCT_COUNTING_DIRECTION_SHIFT,
- NI_GPCT_COUNTING_DIRECTION_UP_BITS =
- 0x1 << NI_GPCT_COUNTING_DIRECTION_SHIFT,
- NI_GPCT_COUNTING_DIRECTION_HW_UP_DOWN_BITS =
- 0x2 << NI_GPCT_COUNTING_DIRECTION_SHIFT,
- NI_GPCT_COUNTING_DIRECTION_HW_GATE_BITS =
- 0x3 << NI_GPCT_COUNTING_DIRECTION_SHIFT,
- NI_GPCT_RELOAD_SOURCE_MASK = 0xc000000,
- NI_GPCT_RELOAD_SOURCE_FIXED_BITS = 0x0,
- NI_GPCT_RELOAD_SOURCE_SWITCHING_BITS = 0x4000000,
- NI_GPCT_RELOAD_SOURCE_GATE_SELECT_BITS = 0x8000000,
- NI_GPCT_OR_GATE_BIT = 0x10000000,
- NI_GPCT_INVERT_OUTPUT_BIT = 0x20000000
-};
+ enum ni_gpct_mode_bits {
+ NI_GPCT_GATE_ON_BOTH_EDGES_BIT = 0x4,
+ NI_GPCT_EDGE_GATE_MODE_MASK = 0x18,
+ NI_GPCT_EDGE_GATE_STARTS_STOPS_BITS = 0x0,
+ NI_GPCT_EDGE_GATE_STOPS_STARTS_BITS = 0x8,
+ NI_GPCT_EDGE_GATE_STARTS_BITS = 0x10,
+ NI_GPCT_EDGE_GATE_NO_STARTS_NO_STOPS_BITS = 0x18,
+ NI_GPCT_STOP_MODE_MASK = 0x60,
+ NI_GPCT_STOP_ON_GATE_BITS = 0x00,
+ NI_GPCT_STOP_ON_GATE_OR_TC_BITS = 0x20,
+ NI_GPCT_STOP_ON_GATE_OR_SECOND_TC_BITS = 0x40,
+ NI_GPCT_LOAD_B_SELECT_BIT = 0x80,
+ NI_GPCT_OUTPUT_MODE_MASK = 0x300,
+ NI_GPCT_OUTPUT_TC_PULSE_BITS = 0x100,
+ NI_GPCT_OUTPUT_TC_TOGGLE_BITS = 0x200,
+ NI_GPCT_OUTPUT_TC_OR_GATE_TOGGLE_BITS = 0x300,
+ NI_GPCT_HARDWARE_DISARM_MASK = 0xc00,
+ NI_GPCT_NO_HARDWARE_DISARM_BITS = 0x000,
+ NI_GPCT_DISARM_AT_TC_BITS = 0x400,
+ NI_GPCT_DISARM_AT_GATE_BITS = 0x800,
+ NI_GPCT_DISARM_AT_TC_OR_GATE_BITS = 0xc00,
+ NI_GPCT_LOADING_ON_TC_BIT = 0x1000,
+ NI_GPCT_LOADING_ON_GATE_BIT = 0x4000,
+ NI_GPCT_COUNTING_MODE_MASK = 0x7 << NI_GPCT_COUNTING_MODE_SHIFT,
+ NI_GPCT_COUNTING_MODE_NORMAL_BITS =
+ 0x0 << NI_GPCT_COUNTING_MODE_SHIFT,
+ NI_GPCT_COUNTING_MODE_QUADRATURE_X1_BITS =
+ 0x1 << NI_GPCT_COUNTING_MODE_SHIFT,
+ NI_GPCT_COUNTING_MODE_QUADRATURE_X2_BITS =
+ 0x2 << NI_GPCT_COUNTING_MODE_SHIFT,
+ NI_GPCT_COUNTING_MODE_QUADRATURE_X4_BITS =
+ 0x3 << NI_GPCT_COUNTING_MODE_SHIFT,
+ NI_GPCT_COUNTING_MODE_TWO_PULSE_BITS =
+ 0x4 << NI_GPCT_COUNTING_MODE_SHIFT,
+ NI_GPCT_COUNTING_MODE_SYNC_SOURCE_BITS =
+ 0x6 << NI_GPCT_COUNTING_MODE_SHIFT,
+ NI_GPCT_INDEX_PHASE_MASK = 0x3 << NI_GPCT_INDEX_PHASE_BITSHIFT,
+ NI_GPCT_INDEX_PHASE_LOW_A_LOW_B_BITS =
+ 0x0 << NI_GPCT_INDEX_PHASE_BITSHIFT,
+ NI_GPCT_INDEX_PHASE_LOW_A_HIGH_B_BITS =
+ 0x1 << NI_GPCT_INDEX_PHASE_BITSHIFT,
+ NI_GPCT_INDEX_PHASE_HIGH_A_LOW_B_BITS =
+ 0x2 << NI_GPCT_INDEX_PHASE_BITSHIFT,
+ NI_GPCT_INDEX_PHASE_HIGH_A_HIGH_B_BITS =
+ 0x3 << NI_GPCT_INDEX_PHASE_BITSHIFT,
+ NI_GPCT_INDEX_ENABLE_BIT = 0x400000,
+ NI_GPCT_COUNTING_DIRECTION_MASK =
+ 0x3 << NI_GPCT_COUNTING_DIRECTION_SHIFT,
+ NI_GPCT_COUNTING_DIRECTION_DOWN_BITS =
+ 0x00 << NI_GPCT_COUNTING_DIRECTION_SHIFT,
+ NI_GPCT_COUNTING_DIRECTION_UP_BITS =
+ 0x1 << NI_GPCT_COUNTING_DIRECTION_SHIFT,
+ NI_GPCT_COUNTING_DIRECTION_HW_UP_DOWN_BITS =
+ 0x2 << NI_GPCT_COUNTING_DIRECTION_SHIFT,
+ NI_GPCT_COUNTING_DIRECTION_HW_GATE_BITS =
+ 0x3 << NI_GPCT_COUNTING_DIRECTION_SHIFT,
+ NI_GPCT_RELOAD_SOURCE_MASK = 0xc000000,
+ NI_GPCT_RELOAD_SOURCE_FIXED_BITS = 0x0,
+ NI_GPCT_RELOAD_SOURCE_SWITCHING_BITS = 0x4000000,
+ NI_GPCT_RELOAD_SOURCE_GATE_SELECT_BITS = 0x8000000,
+ NI_GPCT_OR_GATE_BIT = 0x10000000,
+ NI_GPCT_INVERT_OUTPUT_BIT = 0x20000000
+ };
/* Bits for setting a clock source with
* INSN_CONFIG_SET_CLOCK_SRC when using NI general-purpose counters. */
-enum ni_gpct_clock_source_bits {
- NI_GPCT_CLOCK_SRC_SELECT_MASK = 0x3f,
- NI_GPCT_TIMEBASE_1_CLOCK_SRC_BITS = 0x0,
- NI_GPCT_TIMEBASE_2_CLOCK_SRC_BITS = 0x1,
- NI_GPCT_TIMEBASE_3_CLOCK_SRC_BITS = 0x2,
- NI_GPCT_LOGIC_LOW_CLOCK_SRC_BITS = 0x3,
- NI_GPCT_NEXT_GATE_CLOCK_SRC_BITS = 0x4,
- NI_GPCT_NEXT_TC_CLOCK_SRC_BITS = 0x5,
- NI_GPCT_SOURCE_PIN_i_CLOCK_SRC_BITS = 0x6, /* NI 660x-specific */
- NI_GPCT_PXI10_CLOCK_SRC_BITS = 0x7,
- NI_GPCT_PXI_STAR_TRIGGER_CLOCK_SRC_BITS = 0x8,
- NI_GPCT_ANALOG_TRIGGER_OUT_CLOCK_SRC_BITS = 0x9,
- NI_GPCT_PRESCALE_MODE_CLOCK_SRC_MASK = 0x30000000,
- NI_GPCT_NO_PRESCALE_CLOCK_SRC_BITS = 0x0,
- NI_GPCT_PRESCALE_X2_CLOCK_SRC_BITS = 0x10000000, /* divide source by 2 */
- NI_GPCT_PRESCALE_X8_CLOCK_SRC_BITS = 0x20000000, /* divide source by 8 */
- NI_GPCT_INVERT_CLOCK_SRC_BIT = 0x80000000
-};
-static inline unsigned NI_GPCT_SOURCE_PIN_CLOCK_SRC_BITS(unsigned n)
-{
- /* NI 660x-specific */
- return 0x10 + n;
-}
-static inline unsigned NI_GPCT_RTSI_CLOCK_SRC_BITS(unsigned n)
-{
- return 0x18 + n;
-}
-static inline unsigned NI_GPCT_PFI_CLOCK_SRC_BITS(unsigned n)
-{
- /* no pfi on NI 660x */
- return 0x20 + n;
-}
+ enum ni_gpct_clock_source_bits {
+ NI_GPCT_CLOCK_SRC_SELECT_MASK = 0x3f,
+ NI_GPCT_TIMEBASE_1_CLOCK_SRC_BITS = 0x0,
+ NI_GPCT_TIMEBASE_2_CLOCK_SRC_BITS = 0x1,
+ NI_GPCT_TIMEBASE_3_CLOCK_SRC_BITS = 0x2,
+ NI_GPCT_LOGIC_LOW_CLOCK_SRC_BITS = 0x3,
+ NI_GPCT_NEXT_GATE_CLOCK_SRC_BITS = 0x4,
+ NI_GPCT_NEXT_TC_CLOCK_SRC_BITS = 0x5,
+ NI_GPCT_SOURCE_PIN_i_CLOCK_SRC_BITS = 0x6, /* NI 660x-specific */
+ NI_GPCT_PXI10_CLOCK_SRC_BITS = 0x7,
+ NI_GPCT_PXI_STAR_TRIGGER_CLOCK_SRC_BITS = 0x8,
+ NI_GPCT_ANALOG_TRIGGER_OUT_CLOCK_SRC_BITS = 0x9,
+ NI_GPCT_PRESCALE_MODE_CLOCK_SRC_MASK = 0x30000000,
+ NI_GPCT_NO_PRESCALE_CLOCK_SRC_BITS = 0x0,
+ NI_GPCT_PRESCALE_X2_CLOCK_SRC_BITS = 0x10000000, /* divide source by 2 */
+ NI_GPCT_PRESCALE_X8_CLOCK_SRC_BITS = 0x20000000, /* divide source by 8 */
+ NI_GPCT_INVERT_CLOCK_SRC_BIT = 0x80000000
+ };
+ static inline unsigned NI_GPCT_SOURCE_PIN_CLOCK_SRC_BITS(unsigned n) {
+ /* NI 660x-specific */
+ return 0x10 + n;
+ }
+ static inline unsigned NI_GPCT_RTSI_CLOCK_SRC_BITS(unsigned n) {
+ return 0x18 + n;
+ }
+ static inline unsigned NI_GPCT_PFI_CLOCK_SRC_BITS(unsigned n) {
+ /* no pfi on NI 660x */
+ return 0x20 + n;
+ }
/* Possibilities for setting a gate source with
INSN_CONFIG_SET_GATE_SRC when using NI general-purpose counters.
May be bitwise-or'd with CR_EDGE or CR_INVERT. */
-enum ni_gpct_gate_select {
- /* m-series gates */
- NI_GPCT_TIMESTAMP_MUX_GATE_SELECT = 0x0,
- NI_GPCT_AI_START2_GATE_SELECT = 0x12,
- NI_GPCT_PXI_STAR_TRIGGER_GATE_SELECT = 0x13,
- NI_GPCT_NEXT_OUT_GATE_SELECT = 0x14,
- NI_GPCT_AI_START1_GATE_SELECT = 0x1c,
- NI_GPCT_NEXT_SOURCE_GATE_SELECT = 0x1d,
- NI_GPCT_ANALOG_TRIGGER_OUT_GATE_SELECT = 0x1e,
- NI_GPCT_LOGIC_LOW_GATE_SELECT = 0x1f,
- /* more gates for 660x */
- NI_GPCT_SOURCE_PIN_i_GATE_SELECT = 0x100,
- NI_GPCT_GATE_PIN_i_GATE_SELECT = 0x101,
- /* more gates for 660x "second gate" */
- NI_GPCT_UP_DOWN_PIN_i_GATE_SELECT = 0x201,
- NI_GPCT_SELECTED_GATE_GATE_SELECT = 0x21e,
- /* m-series "second gate" sources are unknown,
- we should add them here with an offset of 0x300 when known. */
- NI_GPCT_DISABLED_GATE_SELECT = 0x8000,
-};
-static inline unsigned NI_GPCT_GATE_PIN_GATE_SELECT(unsigned n)
-{
- return 0x102 + n;
-}
-static inline unsigned NI_GPCT_RTSI_GATE_SELECT(unsigned n)
-{
- return NI_USUAL_RTSI_SELECT(n);
-}
-static inline unsigned NI_GPCT_PFI_GATE_SELECT(unsigned n)
-{
- return NI_USUAL_PFI_SELECT(n);
-}
-static inline unsigned NI_GPCT_UP_DOWN_PIN_GATE_SELECT(unsigned n)
-{
- return 0x202 + n;
-}
+ enum ni_gpct_gate_select {
+ /* m-series gates */
+ NI_GPCT_TIMESTAMP_MUX_GATE_SELECT = 0x0,
+ NI_GPCT_AI_START2_GATE_SELECT = 0x12,
+ NI_GPCT_PXI_STAR_TRIGGER_GATE_SELECT = 0x13,
+ NI_GPCT_NEXT_OUT_GATE_SELECT = 0x14,
+ NI_GPCT_AI_START1_GATE_SELECT = 0x1c,
+ NI_GPCT_NEXT_SOURCE_GATE_SELECT = 0x1d,
+ NI_GPCT_ANALOG_TRIGGER_OUT_GATE_SELECT = 0x1e,
+ NI_GPCT_LOGIC_LOW_GATE_SELECT = 0x1f,
+ /* more gates for 660x */
+ NI_GPCT_SOURCE_PIN_i_GATE_SELECT = 0x100,
+ NI_GPCT_GATE_PIN_i_GATE_SELECT = 0x101,
+ /* more gates for 660x "second gate" */
+ NI_GPCT_UP_DOWN_PIN_i_GATE_SELECT = 0x201,
+ NI_GPCT_SELECTED_GATE_GATE_SELECT = 0x21e,
+ /* m-series "second gate" sources are unknown,
+ we should add them here with an offset of 0x300 when known. */
+ NI_GPCT_DISABLED_GATE_SELECT = 0x8000,
+ };
+ static inline unsigned NI_GPCT_GATE_PIN_GATE_SELECT(unsigned n) {
+ return 0x102 + n;
+ }
+ static inline unsigned NI_GPCT_RTSI_GATE_SELECT(unsigned n) {
+ return NI_USUAL_RTSI_SELECT(n);
+ }
+ static inline unsigned NI_GPCT_PFI_GATE_SELECT(unsigned n) {
+ return NI_USUAL_PFI_SELECT(n);
+ }
+ static inline unsigned NI_GPCT_UP_DOWN_PIN_GATE_SELECT(unsigned n) {
+ return 0x202 + n;
+ }
/* Possibilities for setting a source with
INSN_CONFIG_SET_OTHER_SRC when using NI general-purpose counters. */
-enum ni_gpct_other_index {
- NI_GPCT_SOURCE_ENCODER_A,
- NI_GPCT_SOURCE_ENCODER_B,
- NI_GPCT_SOURCE_ENCODER_Z
-};
-enum ni_gpct_other_select {
- /* m-series gates */
- /* Still unknown, probably only need NI_GPCT_PFI_OTHER_SELECT */
- NI_GPCT_DISABLED_OTHER_SELECT = 0x8000,
-};
-static inline unsigned NI_GPCT_PFI_OTHER_SELECT(unsigned n)
-{
- return NI_USUAL_PFI_SELECT(n);
-}
+ enum ni_gpct_other_index {
+ NI_GPCT_SOURCE_ENCODER_A,
+ NI_GPCT_SOURCE_ENCODER_B,
+ NI_GPCT_SOURCE_ENCODER_Z
+ };
+ enum ni_gpct_other_select {
+ /* m-series gates */
+ /* Still unknown, probably only need NI_GPCT_PFI_OTHER_SELECT */
+ NI_GPCT_DISABLED_OTHER_SELECT = 0x8000,
+ };
+ static inline unsigned NI_GPCT_PFI_OTHER_SELECT(unsigned n) {
+ return NI_USUAL_PFI_SELECT(n);
+ }
/* start sources for ni general-purpose counters for use with
INSN_CONFIG_ARM */
-enum ni_gpct_arm_source {
- NI_GPCT_ARM_IMMEDIATE = 0x0,
- NI_GPCT_ARM_PAIRED_IMMEDIATE = 0x1, /* Start both the counter and
- the adjacent paired counter
- simultaneously */
- /* NI doesn't document bits for selecting hardware arm triggers. If
- * the NI_GPCT_ARM_UNKNOWN bit is set, we will pass the least
- * significant bits (3 bits for 660x or 5 bits for m-series) through to
- * the hardware. This will at least allow someone to figure out what
- * the bits do later. */
- NI_GPCT_ARM_UNKNOWN = 0x1000,
-};
+ enum ni_gpct_arm_source {
+ NI_GPCT_ARM_IMMEDIATE = 0x0,
+ NI_GPCT_ARM_PAIRED_IMMEDIATE = 0x1, /* Start both the counter and
+ the adjacent paired counter
+ simultaneously */
+ /* NI doesn't document bits for selecting hardware arm triggers. If
+ * the NI_GPCT_ARM_UNKNOWN bit is set, we will pass the least
+ * significant bits (3 bits for 660x or 5 bits for m-series) through to
+ * the hardware. This will at least allow someone to figure out what
+ * the bits do later. */
+ NI_GPCT_ARM_UNKNOWN = 0x1000,
+ };
/* digital filtering options for ni 660x for use with INSN_CONFIG_FILTER. */
-enum ni_gpct_filter_select {
- NI_GPCT_FILTER_OFF = 0x0,
- NI_GPCT_FILTER_TIMEBASE_3_SYNC = 0x1,
- NI_GPCT_FILTER_100x_TIMEBASE_1 = 0x2,
- NI_GPCT_FILTER_20x_TIMEBASE_1 = 0x3,
- NI_GPCT_FILTER_10x_TIMEBASE_1 = 0x4,
- NI_GPCT_FILTER_2x_TIMEBASE_1 = 0x5,
- NI_GPCT_FILTER_2x_TIMEBASE_3 = 0x6
-};
+ enum ni_gpct_filter_select {
+ NI_GPCT_FILTER_OFF = 0x0,
+ NI_GPCT_FILTER_TIMEBASE_3_SYNC = 0x1,
+ NI_GPCT_FILTER_100x_TIMEBASE_1 = 0x2,
+ NI_GPCT_FILTER_20x_TIMEBASE_1 = 0x3,
+ NI_GPCT_FILTER_10x_TIMEBASE_1 = 0x4,
+ NI_GPCT_FILTER_2x_TIMEBASE_1 = 0x5,
+ NI_GPCT_FILTER_2x_TIMEBASE_3 = 0x6
+ };
/* PFI digital filtering options for ni m-series for use with
* INSN_CONFIG_FILTER. */
-enum ni_pfi_filter_select {
- NI_PFI_FILTER_OFF = 0x0,
- NI_PFI_FILTER_125ns = 0x1,
- NI_PFI_FILTER_6425ns = 0x2,
- NI_PFI_FILTER_2550us = 0x3
-};
+ enum ni_pfi_filter_select {
+ NI_PFI_FILTER_OFF = 0x0,
+ NI_PFI_FILTER_125ns = 0x1,
+ NI_PFI_FILTER_6425ns = 0x2,
+ NI_PFI_FILTER_2550us = 0x3
+ };
/* master clock sources for ni mio boards and INSN_CONFIG_SET_CLOCK_SRC */
-enum ni_mio_clock_source {
- NI_MIO_INTERNAL_CLOCK = 0,
- NI_MIO_RTSI_CLOCK = 1, /* doesn't work for m-series, use
- NI_MIO_PLL_RTSI_CLOCK() */
- /* the NI_MIO_PLL_* sources are m-series only */
- NI_MIO_PLL_PXI_STAR_TRIGGER_CLOCK = 2,
- NI_MIO_PLL_PXI10_CLOCK = 3,
- NI_MIO_PLL_RTSI0_CLOCK = 4
-};
-static inline unsigned NI_MIO_PLL_RTSI_CLOCK(unsigned rtsi_channel)
-{
- return NI_MIO_PLL_RTSI0_CLOCK + rtsi_channel;
-}
+ enum ni_mio_clock_source {
+ NI_MIO_INTERNAL_CLOCK = 0,
+ NI_MIO_RTSI_CLOCK = 1, /* doesn't work for m-series, use
+ NI_MIO_PLL_RTSI_CLOCK() */
+ /* the NI_MIO_PLL_* sources are m-series only */
+ NI_MIO_PLL_PXI_STAR_TRIGGER_CLOCK = 2,
+ NI_MIO_PLL_PXI10_CLOCK = 3,
+ NI_MIO_PLL_RTSI0_CLOCK = 4
+ };
+ static inline unsigned NI_MIO_PLL_RTSI_CLOCK(unsigned rtsi_channel) {
+ return NI_MIO_PLL_RTSI0_CLOCK + rtsi_channel;
+ }
/* Signals which can be routed to an NI RTSI pin with INSN_CONFIG_SET_ROUTING.
The numbers assigned are not arbitrary, they correspond to the bits required
to program the board. */
-enum ni_rtsi_routing {
- NI_RTSI_OUTPUT_ADR_START1 = 0,
- NI_RTSI_OUTPUT_ADR_START2 = 1,
- NI_RTSI_OUTPUT_SCLKG = 2,
- NI_RTSI_OUTPUT_DACUPDN = 3,
- NI_RTSI_OUTPUT_DA_START1 = 4,
- NI_RTSI_OUTPUT_G_SRC0 = 5,
- NI_RTSI_OUTPUT_G_GATE0 = 6,
- NI_RTSI_OUTPUT_RGOUT0 = 7,
- NI_RTSI_OUTPUT_RTSI_BRD_0 = 8,
- NI_RTSI_OUTPUT_RTSI_OSC = 12 /* pre-m-series always have RTSI clock
- on line 7 */
-};
-static inline unsigned NI_RTSI_OUTPUT_RTSI_BRD(unsigned n)
-{
- return NI_RTSI_OUTPUT_RTSI_BRD_0 + n;
-}
+ enum ni_rtsi_routing {
+ NI_RTSI_OUTPUT_ADR_START1 = 0,
+ NI_RTSI_OUTPUT_ADR_START2 = 1,
+ NI_RTSI_OUTPUT_SCLKG = 2,
+ NI_RTSI_OUTPUT_DACUPDN = 3,
+ NI_RTSI_OUTPUT_DA_START1 = 4,
+ NI_RTSI_OUTPUT_G_SRC0 = 5,
+ NI_RTSI_OUTPUT_G_GATE0 = 6,
+ NI_RTSI_OUTPUT_RGOUT0 = 7,
+ NI_RTSI_OUTPUT_RTSI_BRD_0 = 8,
+ NI_RTSI_OUTPUT_RTSI_OSC = 12 /* pre-m-series always have RTSI clock
+ on line 7 */
+ };
+ static inline unsigned NI_RTSI_OUTPUT_RTSI_BRD(unsigned n) {
+ return NI_RTSI_OUTPUT_RTSI_BRD_0 + n;
+ }
/* Signals which can be routed to an NI PFI pin on an m-series board with
* INSN_CONFIG_SET_ROUTING. These numbers are also returned by
* INSN_CONFIG_GET_ROUTING on pre-m-series boards, even though their routing
* cannot be changed. The numbers assigned are not arbitrary, they correspond
* to the bits required to program the board. */
-enum ni_pfi_routing {
- NI_PFI_OUTPUT_PFI_DEFAULT = 0,
- NI_PFI_OUTPUT_AI_START1 = 1,
- NI_PFI_OUTPUT_AI_START2 = 2,
- NI_PFI_OUTPUT_AI_CONVERT = 3,
- NI_PFI_OUTPUT_G_SRC1 = 4,
- NI_PFI_OUTPUT_G_GATE1 = 5,
- NI_PFI_OUTPUT_AO_UPDATE_N = 6,
- NI_PFI_OUTPUT_AO_START1 = 7,
- NI_PFI_OUTPUT_AI_START_PULSE = 8,
- NI_PFI_OUTPUT_G_SRC0 = 9,
- NI_PFI_OUTPUT_G_GATE0 = 10,
- NI_PFI_OUTPUT_EXT_STROBE = 11,
- NI_PFI_OUTPUT_AI_EXT_MUX_CLK = 12,
- NI_PFI_OUTPUT_GOUT0 = 13,
- NI_PFI_OUTPUT_GOUT1 = 14,
- NI_PFI_OUTPUT_FREQ_OUT = 15,
- NI_PFI_OUTPUT_PFI_DO = 16,
- NI_PFI_OUTPUT_I_ATRIG = 17,
- NI_PFI_OUTPUT_RTSI0 = 18,
- NI_PFI_OUTPUT_PXI_STAR_TRIGGER_IN = 26,
- NI_PFI_OUTPUT_SCXI_TRIG1 = 27,
- NI_PFI_OUTPUT_DIO_CHANGE_DETECT_RTSI = 28,
- NI_PFI_OUTPUT_CDI_SAMPLE = 29,
- NI_PFI_OUTPUT_CDO_UPDATE = 30
-};
-static inline unsigned NI_PFI_OUTPUT_RTSI(unsigned rtsi_channel)
-{
- return NI_PFI_OUTPUT_RTSI0 + rtsi_channel;
-}
+ enum ni_pfi_routing {
+ NI_PFI_OUTPUT_PFI_DEFAULT = 0,
+ NI_PFI_OUTPUT_AI_START1 = 1,
+ NI_PFI_OUTPUT_AI_START2 = 2,
+ NI_PFI_OUTPUT_AI_CONVERT = 3,
+ NI_PFI_OUTPUT_G_SRC1 = 4,
+ NI_PFI_OUTPUT_G_GATE1 = 5,
+ NI_PFI_OUTPUT_AO_UPDATE_N = 6,
+ NI_PFI_OUTPUT_AO_START1 = 7,
+ NI_PFI_OUTPUT_AI_START_PULSE = 8,
+ NI_PFI_OUTPUT_G_SRC0 = 9,
+ NI_PFI_OUTPUT_G_GATE0 = 10,
+ NI_PFI_OUTPUT_EXT_STROBE = 11,
+ NI_PFI_OUTPUT_AI_EXT_MUX_CLK = 12,
+ NI_PFI_OUTPUT_GOUT0 = 13,
+ NI_PFI_OUTPUT_GOUT1 = 14,
+ NI_PFI_OUTPUT_FREQ_OUT = 15,
+ NI_PFI_OUTPUT_PFI_DO = 16,
+ NI_PFI_OUTPUT_I_ATRIG = 17,
+ NI_PFI_OUTPUT_RTSI0 = 18,
+ NI_PFI_OUTPUT_PXI_STAR_TRIGGER_IN = 26,
+ NI_PFI_OUTPUT_SCXI_TRIG1 = 27,
+ NI_PFI_OUTPUT_DIO_CHANGE_DETECT_RTSI = 28,
+ NI_PFI_OUTPUT_CDI_SAMPLE = 29,
+ NI_PFI_OUTPUT_CDO_UPDATE = 30
+ };
+ static inline unsigned NI_PFI_OUTPUT_RTSI(unsigned rtsi_channel) {
+ return NI_PFI_OUTPUT_RTSI0 + rtsi_channel;
+ }
/* Signals which can be routed to output on a NI PFI pin on a 660x board
with INSN_CONFIG_SET_ROUTING. The numbers assigned are
@@ -785,72 +768,67 @@ static inline unsigned NI_PFI_OUTPUT_RTSI(unsigned rtsi_channel)
to program the board. Lines 0 to 7 can only be set to
NI_660X_PFI_OUTPUT_DIO. Lines 32 to 39 can only be set to
NI_660X_PFI_OUTPUT_COUNTER. */
-enum ni_660x_pfi_routing {
- NI_660X_PFI_OUTPUT_COUNTER = 1, /* counter */
- NI_660X_PFI_OUTPUT_DIO = 2, /* static digital output */
-};
+ enum ni_660x_pfi_routing {
+ NI_660X_PFI_OUTPUT_COUNTER = 1, /* counter */
+ NI_660X_PFI_OUTPUT_DIO = 2, /* static digital output */
+ };
/* NI External Trigger lines. These values are not arbitrary, but are related
* to the bits required to program the board (offset by 1 for historical
* reasons). */
-static inline unsigned NI_EXT_PFI(unsigned pfi_channel)
-{
- return NI_USUAL_PFI_SELECT(pfi_channel) - 1;
-}
-static inline unsigned NI_EXT_RTSI(unsigned rtsi_channel)
-{
- return NI_USUAL_RTSI_SELECT(rtsi_channel) - 1;
-}
+ static inline unsigned NI_EXT_PFI(unsigned pfi_channel) {
+ return NI_USUAL_PFI_SELECT(pfi_channel) - 1;
+ }
+ static inline unsigned NI_EXT_RTSI(unsigned rtsi_channel) {
+ return NI_USUAL_RTSI_SELECT(rtsi_channel) - 1;
+ }
/* status bits for INSN_CONFIG_GET_COUNTER_STATUS */
-enum comedi_counter_status_flags {
- COMEDI_COUNTER_ARMED = 0x1,
- COMEDI_COUNTER_COUNTING = 0x2,
- COMEDI_COUNTER_TERMINAL_COUNT = 0x4,
-};
+ enum comedi_counter_status_flags {
+ COMEDI_COUNTER_ARMED = 0x1,
+ COMEDI_COUNTER_COUNTING = 0x2,
+ COMEDI_COUNTER_TERMINAL_COUNT = 0x4,
+ };
/* Clock sources for CDIO subdevice on NI m-series boards. Used as the
* scan_begin_arg for a comedi_command. These sources may also be bitwise-or'd
* with CR_INVERT to change polarity. */
-enum ni_m_series_cdio_scan_begin_src {
- NI_CDIO_SCAN_BEGIN_SRC_GROUND = 0,
- NI_CDIO_SCAN_BEGIN_SRC_AI_START = 18,
- NI_CDIO_SCAN_BEGIN_SRC_AI_CONVERT = 19,
- NI_CDIO_SCAN_BEGIN_SRC_PXI_STAR_TRIGGER = 20,
- NI_CDIO_SCAN_BEGIN_SRC_G0_OUT = 28,
- NI_CDIO_SCAN_BEGIN_SRC_G1_OUT = 29,
- NI_CDIO_SCAN_BEGIN_SRC_ANALOG_TRIGGER = 30,
- NI_CDIO_SCAN_BEGIN_SRC_AO_UPDATE = 31,
- NI_CDIO_SCAN_BEGIN_SRC_FREQ_OUT = 32,
- NI_CDIO_SCAN_BEGIN_SRC_DIO_CHANGE_DETECT_IRQ = 33
-};
-static inline unsigned NI_CDIO_SCAN_BEGIN_SRC_PFI(unsigned pfi_channel)
-{
- return NI_USUAL_PFI_SELECT(pfi_channel);
-}
-static inline unsigned NI_CDIO_SCAN_BEGIN_SRC_RTSI(unsigned rtsi_channel)
-{
- return NI_USUAL_RTSI_SELECT(rtsi_channel);
-}
+ enum ni_m_series_cdio_scan_begin_src {
+ NI_CDIO_SCAN_BEGIN_SRC_GROUND = 0,
+ NI_CDIO_SCAN_BEGIN_SRC_AI_START = 18,
+ NI_CDIO_SCAN_BEGIN_SRC_AI_CONVERT = 19,
+ NI_CDIO_SCAN_BEGIN_SRC_PXI_STAR_TRIGGER = 20,
+ NI_CDIO_SCAN_BEGIN_SRC_G0_OUT = 28,
+ NI_CDIO_SCAN_BEGIN_SRC_G1_OUT = 29,
+ NI_CDIO_SCAN_BEGIN_SRC_ANALOG_TRIGGER = 30,
+ NI_CDIO_SCAN_BEGIN_SRC_AO_UPDATE = 31,
+ NI_CDIO_SCAN_BEGIN_SRC_FREQ_OUT = 32,
+ NI_CDIO_SCAN_BEGIN_SRC_DIO_CHANGE_DETECT_IRQ = 33
+ };
+ static inline unsigned NI_CDIO_SCAN_BEGIN_SRC_PFI(unsigned pfi_channel) {
+ return NI_USUAL_PFI_SELECT(pfi_channel);
+ }
+ static inline unsigned NI_CDIO_SCAN_BEGIN_SRC_RTSI(unsigned
+ rtsi_channel) {
+ return NI_USUAL_RTSI_SELECT(rtsi_channel);
+ }
/* scan_begin_src for scan_begin_arg==TRIG_EXT with analog output command on NI
* boards. These scan begin sources can also be bitwise-or'd with CR_INVERT to
* change polarity. */
-static inline unsigned NI_AO_SCAN_BEGIN_SRC_PFI(unsigned pfi_channel)
-{
- return NI_USUAL_PFI_SELECT(pfi_channel);
-}
-static inline unsigned NI_AO_SCAN_BEGIN_SRC_RTSI(unsigned rtsi_channel)
-{
- return NI_USUAL_RTSI_SELECT(rtsi_channel);
-}
+ static inline unsigned NI_AO_SCAN_BEGIN_SRC_PFI(unsigned pfi_channel) {
+ return NI_USUAL_PFI_SELECT(pfi_channel);
+ }
+ static inline unsigned NI_AO_SCAN_BEGIN_SRC_RTSI(unsigned rtsi_channel) {
+ return NI_USUAL_RTSI_SELECT(rtsi_channel);
+ }
/* Bits for setting a clock source with
* INSN_CONFIG_SET_CLOCK_SRC when using NI frequency output subdevice. */
-enum ni_freq_out_clock_source_bits {
- NI_FREQ_OUT_TIMEBASE_1_DIV_2_CLOCK_SRC, /* 10 MHz */
- NI_FREQ_OUT_TIMEBASE_2_CLOCK_SRC /* 100 KHz */
-};
+ enum ni_freq_out_clock_source_bits {
+ NI_FREQ_OUT_TIMEBASE_1_DIV_2_CLOCK_SRC, /* 10 MHz */
+ NI_FREQ_OUT_TIMEBASE_2_CLOCK_SRC /* 100 KHz */
+ };
/* Values for setting a clock source with INSN_CONFIG_SET_CLOCK_SRC for
* 8254 counter subdevices on Amplicon DIO boards (amplc_dio200 driver). */
diff --git a/drivers/staging/comedi/comedi_compat32.c b/drivers/staging/comedi/comedi_compat32.c
index 1b9c2a7c824f..9810e37845c7 100644
--- a/drivers/staging/comedi/comedi_compat32.c
+++ b/drivers/staging/comedi/comedi_compat32.c
@@ -51,7 +51,7 @@
struct comedi32_chaninfo_struct {
unsigned int subdev;
compat_uptr_t maxdata_list; /* 32-bit 'unsigned int *' */
- compat_uptr_t flaglist; /* 32-bit 'unsigned int *' */
+ compat_uptr_t flaglist; /* 32-bit 'unsigned int *' */
compat_uptr_t rangelist; /* 32-bit 'unsigned int *' */
unsigned int unused[4];
};
@@ -74,16 +74,16 @@ struct comedi32_cmd_struct {
unsigned int scan_end_arg;
unsigned int stop_src;
unsigned int stop_arg;
- compat_uptr_t chanlist; /* 32-bit 'unsigned int *' */
+ compat_uptr_t chanlist; /* 32-bit 'unsigned int *' */
unsigned int chanlist_len;
- compat_uptr_t data; /* 32-bit 'short *' */
+ compat_uptr_t data; /* 32-bit 'short *' */
unsigned int data_len;
};
struct comedi32_insn_struct {
unsigned int insn;
unsigned int n;
- compat_uptr_t data; /* 32-bit 'unsigned int *' */
+ compat_uptr_t data; /* 32-bit 'unsigned int *' */
unsigned int subdev;
unsigned int chanspec;
unsigned int unused[3];
@@ -91,19 +91,19 @@ struct comedi32_insn_struct {
struct comedi32_insnlist_struct {
unsigned int n_insns;
- compat_uptr_t insns; /* 32-bit 'struct comedi_insn *' */
+ compat_uptr_t insns; /* 32-bit 'struct comedi_insn *' */
};
/* Handle translated ioctl. */
static int translated_ioctl(struct file *file, unsigned int cmd,
- unsigned long arg)
+ unsigned long arg)
{
if (!file->f_op)
return -ENOTTY;
#ifdef HAVE_UNLOCKED_IOCTL
if (file->f_op->unlocked_ioctl) {
- int rc = (int)(*file->f_op->unlocked_ioctl)(file, cmd, arg);
+ int rc = (int)(*file->f_op->unlocked_ioctl) (file, cmd, arg);
if (rc == -ENOIOCTLCMD)
rc = -ENOTTY;
return rc;
@@ -112,8 +112,8 @@ static int translated_ioctl(struct file *file, unsigned int cmd,
if (file->f_op->ioctl) {
int rc;
lock_kernel();
- rc = (*file->f_op->ioctl)(file->f_dentry->d_inode,
- file, cmd, arg);
+ rc = (*file->f_op->ioctl) (file->f_dentry->d_inode,
+ file, cmd, arg);
unlock_kernel();
return rc;
}
@@ -136,8 +136,7 @@ static int compat_chaninfo(struct file *file, unsigned long arg)
/* Copy chaninfo structure. Ignore unused members. */
if (!access_ok(VERIFY_READ, chaninfo32, sizeof(*chaninfo32))
- || !access_ok(VERIFY_WRITE, chaninfo,
- sizeof(*chaninfo))) {
+ || !access_ok(VERIFY_WRITE, chaninfo, sizeof(*chaninfo))) {
return -EFAULT;
}
err = 0;
@@ -171,8 +170,7 @@ static int compat_rangeinfo(struct file *file, unsigned long arg)
/* Copy rangeinfo structure. */
if (!access_ok(VERIFY_READ, rangeinfo32, sizeof(*rangeinfo32))
- || !access_ok(VERIFY_WRITE, rangeinfo,
- sizeof(*rangeinfo))) {
+ || !access_ok(VERIFY_WRITE, rangeinfo, sizeof(*rangeinfo))) {
return -EFAULT;
}
err = 0;
@@ -184,12 +182,12 @@ static int compat_rangeinfo(struct file *file, unsigned long arg)
return -EFAULT;
return translated_ioctl(file, COMEDI_RANGEINFO,
- (unsigned long)rangeinfo);
+ (unsigned long)rangeinfo);
}
/* Copy 32-bit cmd structure to native cmd structure. */
-static int get_compat_cmd(struct comedi_cmd __user *cmd,
- struct comedi32_cmd_struct __user *cmd32)
+static int get_compat_cmd(struct comedi_cmd __user * cmd,
+ struct comedi32_cmd_struct __user * cmd32)
{
int err;
union {
@@ -199,7 +197,7 @@ static int get_compat_cmd(struct comedi_cmd __user *cmd,
/* Copy cmd structure. */
if (!access_ok(VERIFY_READ, cmd32, sizeof(*cmd32))
- || !access_ok(VERIFY_WRITE, cmd, sizeof(*cmd))) {
+ || !access_ok(VERIFY_WRITE, cmd, sizeof(*cmd))) {
return -EFAULT;
}
err = 0;
@@ -239,7 +237,8 @@ static int get_compat_cmd(struct comedi_cmd __user *cmd,
}
/* Copy native cmd structure to 32-bit cmd structure. */
-static int put_compat_cmd(struct comedi32_cmd_struct __user *cmd32, struct comedi_cmd __user *cmd)
+static int put_compat_cmd(struct comedi32_cmd_struct __user * cmd32,
+ struct comedi_cmd __user * cmd)
{
int err;
unsigned int temp;
@@ -249,7 +248,7 @@ static int put_compat_cmd(struct comedi32_cmd_struct __user *cmd32, struct comed
/* (Could use ptr_to_compat() to set them, but that wasn't implemented
* until kernel version 2.6.11.) */
if (!access_ok(VERIFY_READ, cmd, sizeof(*cmd))
- || !access_ok(VERIFY_WRITE, cmd32, sizeof(*cmd32))) {
+ || !access_ok(VERIFY_WRITE, cmd32, sizeof(*cmd32))) {
return -EFAULT;
}
err = 0;
@@ -329,8 +328,8 @@ static int compat_cmdtest(struct file *file, unsigned long arg)
}
/* Copy 32-bit insn structure to native insn structure. */
-static int get_compat_insn(struct comedi_insn __user *insn,
- struct comedi32_insn_struct __user *insn32)
+static int get_compat_insn(struct comedi_insn __user * insn,
+ struct comedi32_insn_struct __user * insn32)
{
int err;
union {
@@ -341,7 +340,7 @@ static int get_compat_insn(struct comedi_insn __user *insn,
/* Copy insn structure. Ignore the unused members. */
err = 0;
if (!access_ok(VERIFY_READ, insn32, sizeof(*insn32))
- || !access_ok(VERIFY_WRITE, insn, sizeof(*insn)))
+ || !access_ok(VERIFY_WRITE, insn, sizeof(*insn)))
return -EFAULT;
err |= __get_user(temp.uint, &insn32->insn);
@@ -385,7 +384,7 @@ static int compat_insnlist(struct file *file, unsigned long arg)
/* Allocate user memory to copy insnlist and insns into. */
s = compat_alloc_user_space(offsetof(struct combined_insnlist,
- insn[n_insns]));
+ insn[n_insns]));
/* Set native insnlist structure. */
if (!access_ok(VERIFY_WRITE, &s->insnlist, sizeof(s->insnlist))) {
@@ -404,7 +403,7 @@ static int compat_insnlist(struct file *file, unsigned long arg)
}
return translated_ioctl(file, COMEDI_INSNLIST,
- (unsigned long)&s->insnlist);
+ (unsigned long)&s->insnlist);
}
/* Handle 32-bit COMEDI_INSN ioctl. */
@@ -427,7 +426,7 @@ static int compat_insn(struct file *file, unsigned long arg)
/* Process untranslated ioctl. */
/* Returns -ENOIOCTLCMD for unrecognised ioctl codes. */
static inline int raw_ioctl(struct file *file, unsigned int cmd,
- unsigned long arg)
+ unsigned long arg)
{
int rc;
@@ -477,8 +476,7 @@ static inline int raw_ioctl(struct file *file, unsigned int cmd,
/* compat_ioctl file operation. */
/* Returns -ENOIOCTLCMD for unrecognised ioctl codes. */
-long comedi_compat_ioctl(struct file *file, unsigned int cmd,
- unsigned long arg)
+long comedi_compat_ioctl(struct file *file, unsigned int cmd, unsigned long arg)
{
return raw_ioctl(file, cmd, arg);
}
@@ -497,7 +495,7 @@ long comedi_compat_ioctl(struct file *file, unsigned int cmd,
/* Handler for all 32-bit ioctl codes registered by this driver. */
static int mapped_ioctl(unsigned int fd, unsigned int cmd, unsigned long arg,
- struct file *file)
+ struct file *file)
{
int rc;
@@ -515,27 +513,27 @@ static int mapped_ioctl(unsigned int fd, unsigned int cmd, unsigned long arg,
struct ioctl32_map {
unsigned int cmd;
- int (*handler)(unsigned int, unsigned int, unsigned long,
+ int (*handler) (unsigned int, unsigned int, unsigned long,
struct file *);
int registered;
};
static struct ioctl32_map comedi_ioctl32_map[] = {
- { COMEDI_DEVCONFIG, mapped_ioctl, 0 },
- { COMEDI_DEVINFO, mapped_ioctl, 0 },
- { COMEDI_SUBDINFO, mapped_ioctl, 0 },
- { COMEDI_BUFCONFIG, mapped_ioctl, 0 },
- { COMEDI_BUFINFO, mapped_ioctl, 0 },
- { COMEDI_LOCK, mapped_ioctl, 0 },
- { COMEDI_UNLOCK, mapped_ioctl, 0 },
- { COMEDI_CANCEL, mapped_ioctl, 0 },
- { COMEDI_POLL, mapped_ioctl, 0 },
- { COMEDI32_CHANINFO, mapped_ioctl, 0 },
- { COMEDI32_RANGEINFO, mapped_ioctl, 0 },
- { COMEDI32_CMD, mapped_ioctl, 0 },
- { COMEDI32_CMDTEST, mapped_ioctl, 0 },
- { COMEDI32_INSNLIST, mapped_ioctl, 0 },
- { COMEDI32_INSN, mapped_ioctl, 0 },
+ {COMEDI_DEVCONFIG, mapped_ioctl, 0},
+ {COMEDI_DEVINFO, mapped_ioctl, 0},
+ {COMEDI_SUBDINFO, mapped_ioctl, 0},
+ {COMEDI_BUFCONFIG, mapped_ioctl, 0},
+ {COMEDI_BUFINFO, mapped_ioctl, 0},
+ {COMEDI_LOCK, mapped_ioctl, 0},
+ {COMEDI_UNLOCK, mapped_ioctl, 0},
+ {COMEDI_CANCEL, mapped_ioctl, 0},
+ {COMEDI_POLL, mapped_ioctl, 0},
+ {COMEDI32_CHANINFO, mapped_ioctl, 0},
+ {COMEDI32_RANGEINFO, mapped_ioctl, 0},
+ {COMEDI32_CMD, mapped_ioctl, 0},
+ {COMEDI32_CMDTEST, mapped_ioctl, 0},
+ {COMEDI32_INSNLIST, mapped_ioctl, 0},
+ {COMEDI32_INSN, mapped_ioctl, 0},
};
#define NUM_IOCTL32_MAPS ARRAY_SIZE(comedi_ioctl32_map)
@@ -547,13 +545,13 @@ void comedi_register_ioctl32(void)
for (n = 0; n < NUM_IOCTL32_MAPS; n++) {
rc = register_ioctl32_conversion(comedi_ioctl32_map[n].cmd,
- comedi_ioctl32_map[n].handler);
+ comedi_ioctl32_map[n].handler);
if (rc) {
printk(KERN_WARNING
- "comedi: failed to register 32-bit "
- "compatible ioctl handler for 0x%X - "
- "expect bad things to happen!\n",
- comedi_ioctl32_map[n].cmd);
+ "comedi: failed to register 32-bit "
+ "compatible ioctl handler for 0x%X - "
+ "expect bad things to happen!\n",
+ comedi_ioctl32_map[n].cmd);
}
comedi_ioctl32_map[n].registered = !rc;
}
@@ -566,15 +564,16 @@ void comedi_unregister_ioctl32(void)
for (n = 0; n < NUM_IOCTL32_MAPS; n++) {
if (comedi_ioctl32_map[n].registered) {
- rc = unregister_ioctl32_conversion(
- comedi_ioctl32_map[n].cmd,
- comedi_ioctl32_map[n].handler);
+ rc = unregister_ioctl32_conversion(comedi_ioctl32_map
+ [n].cmd,
+ comedi_ioctl32_map
+ [n].handler);
if (rc) {
printk(KERN_ERR
- "comedi: failed to unregister 32-bit "
- "compatible ioctl handler for 0x%X - "
- "expect kernel Oops!\n",
- comedi_ioctl32_map[n].cmd);
+ "comedi: failed to unregister 32-bit "
+ "compatible ioctl handler for 0x%X - "
+ "expect kernel Oops!\n",
+ comedi_ioctl32_map[n].cmd);
} else {
comedi_ioctl32_map[n].registered = 0;
}
@@ -582,6 +581,6 @@ void comedi_unregister_ioctl32(void)
}
}
-#endif /* HAVE_COMPAT_IOCTL */
+#endif /* HAVE_COMPAT_IOCTL */
-#endif /* CONFIG_COMPAT */
+#endif /* CONFIG_COMPAT */
diff --git a/drivers/staging/comedi/comedi_compat32.h b/drivers/staging/comedi/comedi_compat32.h
index 0ca01642c165..fd0f8a3125a1 100644
--- a/drivers/staging/comedi/comedi_compat32.h
+++ b/drivers/staging/comedi/comedi_compat32.h
@@ -28,14 +28,14 @@
#define _COMEDI_COMPAT32_H
#include <linux/compat.h>
-#include <linux/fs.h> /* For HAVE_COMPAT_IOCTL and HAVE_UNLOCKED_IOCTL */
+#include <linux/fs.h> /* For HAVE_COMPAT_IOCTL and HAVE_UNLOCKED_IOCTL */
#ifdef CONFIG_COMPAT
#ifdef HAVE_COMPAT_IOCTL
extern long comedi_compat_ioctl(struct file *file, unsigned int cmd,
- unsigned long arg);
+ unsigned long arg);
#define comedi_register_ioctl32() do {} while (0)
#define comedi_unregister_ioctl32() do {} while (0)
diff --git a/drivers/staging/comedi/comedi_fops.c b/drivers/staging/comedi/comedi_fops.c
index 9d7c99394ec6..42e4bc49cbbe 100644
--- a/drivers/staging/comedi/comedi_fops.c
+++ b/drivers/staging/comedi/comedi_fops.c
@@ -68,26 +68,33 @@ module_param(comedi_num_legacy_minors, int, 0444);
static DEFINE_SPINLOCK(comedi_file_info_table_lock);
static struct comedi_device_file_info
- *comedi_file_info_table[COMEDI_NUM_MINORS];
+*comedi_file_info_table[COMEDI_NUM_MINORS];
-static int do_devconfig_ioctl(struct comedi_device *dev, struct comedi_devconfig *arg);
+static int do_devconfig_ioctl(struct comedi_device *dev,
+ struct comedi_devconfig *arg);
static int do_bufconfig_ioctl(struct comedi_device *dev, void *arg);
-static int do_devinfo_ioctl(struct comedi_device *dev, struct comedi_devinfo *arg,
- struct file *file);
-static int do_subdinfo_ioctl(struct comedi_device *dev, struct comedi_subdinfo *arg,
- void *file);
-static int do_chaninfo_ioctl(struct comedi_device *dev, struct comedi_chaninfo *arg);
+static int do_devinfo_ioctl(struct comedi_device *dev,
+ struct comedi_devinfo *arg, struct file *file);
+static int do_subdinfo_ioctl(struct comedi_device *dev,
+ struct comedi_subdinfo *arg, void *file);
+static int do_chaninfo_ioctl(struct comedi_device *dev,
+ struct comedi_chaninfo *arg);
static int do_bufinfo_ioctl(struct comedi_device *dev, void *arg);
static int do_cmd_ioctl(struct comedi_device *dev, void *arg, void *file);
-static int do_lock_ioctl(struct comedi_device *dev, unsigned int arg, void *file);
-static int do_unlock_ioctl(struct comedi_device *dev, unsigned int arg, void *file);
-static int do_cancel_ioctl(struct comedi_device *dev, unsigned int arg, void *file);
+static int do_lock_ioctl(struct comedi_device *dev, unsigned int arg,
+ void *file);
+static int do_unlock_ioctl(struct comedi_device *dev, unsigned int arg,
+ void *file);
+static int do_cancel_ioctl(struct comedi_device *dev, unsigned int arg,
+ void *file);
static int do_cmdtest_ioctl(struct comedi_device *dev, void *arg, void *file);
static int do_insnlist_ioctl(struct comedi_device *dev, void *arg, void *file);
static int do_insn_ioctl(struct comedi_device *dev, void *arg, void *file);
-static int do_poll_ioctl(struct comedi_device *dev, unsigned int subd, void *file);
+static int do_poll_ioctl(struct comedi_device *dev, unsigned int subd,
+ void *file);
-extern void do_become_nonbusy(struct comedi_device *dev, struct comedi_subdevice *s);
+extern void do_become_nonbusy(struct comedi_device *dev,
+ struct comedi_subdevice *s);
static int do_cancel(struct comedi_device *dev, struct comedi_subdevice *s);
static int comedi_fasync(int fd, struct file *file, int on);
@@ -202,7 +209,8 @@ done:
writes:
none
*/
-static int do_devconfig_ioctl(struct comedi_device *dev, struct comedi_devconfig *arg)
+static int do_devconfig_ioctl(struct comedi_device *dev,
+ struct comedi_devconfig *arg)
{
struct comedi_devconfig it;
int ret;
@@ -342,8 +350,8 @@ copyback:
devinfo structure
*/
-static int do_devinfo_ioctl(struct comedi_device *dev, struct comedi_devinfo *arg,
- struct file *file)
+static int do_devinfo_ioctl(struct comedi_device *dev,
+ struct comedi_devinfo *arg, struct file *file)
{
struct comedi_devinfo devinfo;
const unsigned minor = iminor(file->f_dentry->d_inode);
@@ -392,14 +400,16 @@ static int do_devinfo_ioctl(struct comedi_device *dev, struct comedi_devinfo *ar
array of subdevice info structures at arg
*/
-static int do_subdinfo_ioctl(struct comedi_device *dev, struct comedi_subdinfo *arg,
- void *file)
+static int do_subdinfo_ioctl(struct comedi_device *dev,
+ struct comedi_subdinfo *arg, void *file)
{
int ret, i;
struct comedi_subdinfo *tmp, *us;
struct comedi_subdevice *s;
- tmp = kcalloc(dev->n_subdevices, sizeof(struct comedi_subdinfo), GFP_KERNEL);
+ tmp =
+ kcalloc(dev->n_subdevices, sizeof(struct comedi_subdinfo),
+ GFP_KERNEL);
if (!tmp)
return -ENOMEM;
@@ -472,7 +482,8 @@ static int do_subdinfo_ioctl(struct comedi_device *dev, struct comedi_subdinfo *
arrays at elements of chaninfo structure
*/
-static int do_chaninfo_ioctl(struct comedi_device *dev, struct comedi_chaninfo *arg)
+static int do_chaninfo_ioctl(struct comedi_device *dev,
+ struct comedi_chaninfo *arg)
{
struct comedi_subdevice *s;
struct comedi_chaninfo it;
@@ -514,7 +525,7 @@ static int do_chaninfo_ioctl(struct comedi_device *dev, struct comedi_chaninfo *
}
#if 0
if (copy_to_user(it.rangelist, s->range_type_list,
- s->n_chan*sizeof(unsigned int)))
+ s->n_chan * sizeof(unsigned int)))
return -EFAULT;
#endif
}
@@ -589,8 +600,8 @@ copyback:
return 0;
}
-static int parse_insn(struct comedi_device *dev, struct comedi_insn *insn, unsigned int *data,
- void *file);
+static int parse_insn(struct comedi_device *dev, struct comedi_insn *insn,
+ unsigned int *data, void *file);
/*
* COMEDI_INSNLIST
* synchronous instructions
@@ -626,7 +637,8 @@ static int do_insnlist_ioctl(struct comedi_device *dev, void *arg, void *file)
goto error;
}
- insns = kmalloc(sizeof(struct comedi_insn) * insnlist.n_insns, GFP_KERNEL);
+ insns =
+ kmalloc(sizeof(struct comedi_insn) * insnlist.n_insns, GFP_KERNEL);
if (!insns) {
DPRINTK("kmalloc failed\n");
ret = -ENOMEM;
@@ -678,7 +690,8 @@ error:
return i;
}
-static int check_insn_config_length(struct comedi_insn *insn, unsigned int *data)
+static int check_insn_config_length(struct comedi_insn *insn,
+ unsigned int *data)
{
if (insn->n < 1)
return -EINVAL;
@@ -725,22 +738,22 @@ static int check_insn_config_length(struct comedi_insn *insn, unsigned int *data
if (insn->n == 5)
return 0;
break;
- /* by default we allow the insn since we don't have checks for
- * all possible cases yet */
+ /* by default we allow the insn since we don't have checks for
+ * all possible cases yet */
default:
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__,
- __FILE__, insn->n);
+ "%i is implemented.\n"
+ " Add a check to %s in %s.\n"
+ " Assuming n=%i is correct.\n", data[0], __func__,
+ __FILE__, insn->n);
return 0;
break;
}
return -EINVAL;
}
-static int parse_insn(struct comedi_device *dev, struct comedi_insn *insn, unsigned int *data,
- void *file)
+static int parse_insn(struct comedi_device *dev, struct comedi_insn *insn,
+ unsigned int *data, void *file)
{
struct comedi_subdevice *s;
int ret = 0;
@@ -920,7 +933,8 @@ static int do_insn_ioctl(struct comedi_device *dev, void *arg, void *file)
if (insn.n > MAX_SAMPLES)
insn.n = MAX_SAMPLES;
if (insn.insn & INSN_MASK_WRITE) {
- if (copy_from_user(data, insn.data, insn.n * sizeof(unsigned int))) {
+ if (copy_from_user
+ (data, insn.data, insn.n * sizeof(unsigned int))) {
ret = -EFAULT;
goto error;
}
@@ -929,7 +943,8 @@ static int do_insn_ioctl(struct comedi_device *dev, void *arg, void *file)
if (ret < 0)
goto error;
if (insn.insn & INSN_MASK_READ) {
- if (copy_to_user(insn.data, data, insn.n * sizeof(unsigned int))) {
+ if (copy_to_user
+ (insn.data, data, insn.n * sizeof(unsigned int))) {
ret = -EFAULT;
goto error;
}
@@ -1202,7 +1217,8 @@ cleanup:
*/
-static int do_lock_ioctl(struct comedi_device *dev, unsigned int arg, void *file)
+static int do_lock_ioctl(struct comedi_device *dev, unsigned int arg,
+ void *file)
{
int ret = 0;
unsigned long flags;
@@ -1246,7 +1262,8 @@ static int do_lock_ioctl(struct comedi_device *dev, unsigned int arg, void *file
This function isn't protected by the semaphore, since
we already own the lock.
*/
-static int do_unlock_ioctl(struct comedi_device *dev, unsigned int arg, void *file)
+static int do_unlock_ioctl(struct comedi_device *dev, unsigned int arg,
+ void *file)
{
struct comedi_subdevice *s;
@@ -1286,7 +1303,8 @@ static int do_unlock_ioctl(struct comedi_device *dev, unsigned int arg, void *fi
nothing
*/
-static int do_cancel_ioctl(struct comedi_device *dev, unsigned int arg, void *file)
+static int do_cancel_ioctl(struct comedi_device *dev, unsigned int arg,
+ void *file)
{
struct comedi_subdevice *s;
@@ -1322,7 +1340,8 @@ static int do_cancel_ioctl(struct comedi_device *dev, unsigned int arg, void *fi
nothing
*/
-static int do_poll_ioctl(struct comedi_device *dev, unsigned int arg, void *file)
+static int do_poll_ioctl(struct comedi_device *dev, unsigned int arg,
+ void *file)
{
struct comedi_subdevice *s;
@@ -1371,7 +1390,7 @@ void comedi_unmap(struct vm_area_struct *area)
}
static struct vm_operations_struct comedi_vm_ops = {
- .close = comedi_unmap,
+ .close = comedi_unmap,
};
static int comedi_mmap(struct file *file, struct vm_area_struct *vma)
@@ -1428,10 +1447,10 @@ static int comedi_mmap(struct file *file, struct vm_area_struct *vma)
n_pages = size >> PAGE_SHIFT;
for (i = 0; i < n_pages; ++i) {
if (remap_pfn_range(vma, start,
- page_to_pfn(virt_to_page(async->
- buf_page_list[i].
- virt_addr)),
- PAGE_SIZE, PAGE_SHARED)) {
+ page_to_pfn(virt_to_page
+ (async->buf_page_list
+ [i].virt_addr)), PAGE_SIZE,
+ PAGE_SHARED)) {
retval = -EAGAIN;
goto done;
}
@@ -1449,7 +1468,7 @@ done:
return retval;
}
-static unsigned int comedi_poll(struct file *file, poll_table *wait)
+static unsigned int comedi_poll(struct file *file, poll_table * wait)
{
unsigned int mask = 0;
const unsigned minor = iminor(file->f_dentry->d_inode);
@@ -1496,7 +1515,7 @@ static unsigned int comedi_poll(struct file *file, poll_table *wait)
}
static ssize_t comedi_write(struct file *file, const char *buf, size_t nbytes,
- loff_t *offset)
+ loff_t * offset)
{
struct comedi_subdevice *s;
struct comedi_async *async;
@@ -1598,7 +1617,7 @@ done:
}
static ssize_t comedi_read(struct file *file, char *buf, size_t nbytes,
- loff_t *offset)
+ loff_t * offset)
{
struct comedi_subdevice *s;
struct comedi_async *async;
@@ -1729,7 +1748,8 @@ static int comedi_open(struct inode *inode, struct file *file)
const unsigned minor = iminor(inode);
struct comedi_device_file_info *dev_file_info =
comedi_get_device_file_info(minor);
- struct comedi_device *dev = dev_file_info ? dev_file_info->device : NULL;
+ struct comedi_device *dev =
+ dev_file_info ? dev_file_info->device : NULL;
if (dev == NULL) {
DPRINTK("invalid minor number\n");
@@ -1846,22 +1866,22 @@ static int comedi_fasync(int fd, struct file *file, int on)
}
const struct file_operations comedi_fops = {
- .owner = THIS_MODULE,
+ .owner = THIS_MODULE,
#ifdef HAVE_UNLOCKED_IOCTL
- .unlocked_ioctl = comedi_unlocked_ioctl,
+ .unlocked_ioctl = comedi_unlocked_ioctl,
#else
- .ioctl = comedi_ioctl,
+ .ioctl = comedi_ioctl,
#endif
#ifdef HAVE_COMPAT_IOCTL
- .compat_ioctl = comedi_compat_ioctl,
+ .compat_ioctl = comedi_compat_ioctl,
#endif
- .open = comedi_open,
- .release = comedi_close,
- .read = comedi_read,
- .write = comedi_write,
- .mmap = comedi_mmap,
- .poll = comedi_poll,
- .fasync = comedi_fasync,
+ .open = comedi_open,
+ .release = comedi_close,
+ .read = comedi_read,
+ .write = comedi_write,
+ .mmap = comedi_mmap,
+ .poll = comedi_poll,
+ .fasync = comedi_fasync,
};
struct class *comedi_class;
@@ -1952,7 +1972,6 @@ static void __exit comedi_cleanup(void)
for (i = 0; i < COMEDI_NUM_MINORS; ++i)
BUG_ON(comedi_file_info_table[i]);
-
class_destroy(comedi_class);
cdev_del(&comedi_cdev);
unregister_chrdev_region(MKDEV(COMEDI_MAJOR, 0), COMEDI_NUM_MINORS);
@@ -1981,8 +2000,9 @@ void comedi_event(struct comedi_device *dev, struct comedi_subdevice *s)
if ((comedi_get_subdevice_runflags(s) & SRF_RUNNING) == 0)
return;
- if (s->async->
- events & (COMEDI_CB_EOA | COMEDI_CB_ERROR | COMEDI_CB_OVERFLOW)) {
+ if (s->
+ async->events & (COMEDI_CB_EOA | COMEDI_CB_ERROR |
+ COMEDI_CB_OVERFLOW)) {
runflags_mask |= SRF_RUNNING;
}
/* remember if an error event has occured, so an error
@@ -2000,12 +2020,10 @@ void comedi_event(struct comedi_device *dev, struct comedi_subdevice *s)
if (comedi_get_subdevice_runflags(s) & SRF_USER) {
wake_up_interruptible(&async->wait_head);
if (s->subdev_flags & SDF_CMD_READ) {
- kill_fasync(&dev->async_queue, SIGIO,
- POLL_IN);
+ kill_fasync(&dev->async_queue, SIGIO, POLL_IN);
}
if (s->subdev_flags & SDF_CMD_WRITE) {
- kill_fasync(&dev->async_queue, SIGIO,
- POLL_OUT);
+ kill_fasync(&dev->async_queue, SIGIO, POLL_OUT);
}
} else {
if (async->cb_func)
@@ -2103,7 +2121,8 @@ int comedi_alloc_board_minor(struct device *hardware_device)
comedi_device_cleanup(info->device);
kfree(info->device);
kfree(info);
- printk(KERN_ERR "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;
@@ -2115,29 +2134,33 @@ int comedi_alloc_board_minor(struct device *hardware_device)
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);
+ 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);
+ 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);
+ 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);
+ 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;
}
@@ -2194,7 +2217,8 @@ int comedi_alloc_subdevice_minor(struct comedi_device *dev,
spin_unlock_irqrestore(&comedi_file_info_table_lock, flags);
if (i == COMEDI_NUM_MINORS) {
kfree(info);
- printk(KERN_ERR "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;
@@ -2207,29 +2231,33 @@ int comedi_alloc_subdevice_minor(struct comedi_device *dev,
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);
+ 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);
+ 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);
+ 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);
+ 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;
}
@@ -2295,7 +2323,7 @@ static int resize_async_buffer(struct comedi_device *dev,
return -EINVAL;
/* make sure buffer is an integral number of pages
- * (we round up) */
+ * (we round up) */
new_size = (new_size + PAGE_SIZE - 1) & PAGE_MASK;
retval = comedi_buf_alloc(dev, s, new_size);
@@ -2324,16 +2352,16 @@ static ssize_t show_max_read_buffer_kb(struct device *dev,
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);
+ 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;
+ bytes_per_kibi;
}
- retval = snprintf(buf, PAGE_SIZE, "%i\n", max_buffer_size_kb);
+ retval = snprintf(buf, PAGE_SIZE, "%i\n", max_buffer_size_kb);
mutex_unlock(&info->device->mutex);
return retval;
@@ -2347,14 +2375,14 @@ static ssize_t store_max_read_buffer_kb(struct device *dev,
unsigned long new_max_size_kb;
uint64_t new_max_size;
struct comedi_subdevice *const read_subdevice =
- comedi_get_read_subdevice(info);
+ 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)
+ 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)
+ 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);
@@ -2372,9 +2400,8 @@ static ssize_t store_max_read_buffer_kb(struct device *dev,
static struct device_attribute dev_attr_max_read_buffer_kb = {
.attr = {
- .name = "max_read_buffer_kb",
- .mode = S_IRUGO | S_IWUSR
- },
+ .name = "max_read_buffer_kb",
+ .mode = S_IRUGO | S_IWUSR},
.show = &show_max_read_buffer_kb,
.store = &store_max_read_buffer_kb
};
@@ -2386,16 +2413,16 @@ static ssize_t show_read_buffer_kb(struct device *dev,
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);
+ comedi_get_read_subdevice(info);
mutex_lock(&info->device->mutex);
if (read_subdevice &&
- (read_subdevice->subdev_flags & SDF_CMD_READ) &&
- read_subdevice->async) {
+ (read_subdevice->subdev_flags & SDF_CMD_READ) &&
+ read_subdevice->async) {
buffer_size_kb = read_subdevice->async->prealloc_bufsz /
- bytes_per_kibi;
+ bytes_per_kibi;
}
- retval = snprintf(buf, PAGE_SIZE, "%i\n", buffer_size_kb);
+ retval = snprintf(buf, PAGE_SIZE, "%i\n", buffer_size_kb);
mutex_unlock(&info->device->mutex);
return retval;
@@ -2410,14 +2437,14 @@ static ssize_t store_read_buffer_kb(struct device *dev,
uint64_t new_size;
int retval;
struct comedi_subdevice *const read_subdevice =
- comedi_get_read_subdevice(info);
+ comedi_get_read_subdevice(info);
if (strict_strtoul(buf, 10, &new_size_kb))
return -EINVAL;
- if (new_size_kb != (uint32_t)new_size_kb)
+ 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)
+ new_size = ((uint64_t) new_size_kb) * bytes_per_kibi;
+ if (new_size != (uint32_t) new_size)
return -EINVAL;
mutex_lock(&info->device->mutex);
@@ -2438,9 +2465,8 @@ static ssize_t store_read_buffer_kb(struct device *dev,
static struct device_attribute dev_attr_read_buffer_kb = {
.attr = {
- .name = "read_buffer_kb",
- .mode = S_IRUGO | S_IWUSR | S_IWGRP
- },
+ .name = "read_buffer_kb",
+ .mode = S_IRUGO | S_IWUSR | S_IWGRP},
.show = &show_read_buffer_kb,
.store = &store_read_buffer_kb
};
@@ -2453,16 +2479,16 @@ static ssize_t show_max_write_buffer_kb(struct device *dev,
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);
+ 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;
+ bytes_per_kibi;
}
- retval = snprintf(buf, PAGE_SIZE, "%i\n", max_buffer_size_kb);
+ retval = snprintf(buf, PAGE_SIZE, "%i\n", max_buffer_size_kb);
mutex_unlock(&info->device->mutex);
return retval;
@@ -2476,14 +2502,14 @@ static ssize_t store_max_write_buffer_kb(struct device *dev,
unsigned long new_max_size_kb;
uint64_t new_max_size;
struct comedi_subdevice *const write_subdevice =
- comedi_get_write_subdevice(info);
+ 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)
+ 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)
+ 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);
@@ -2501,9 +2527,8 @@ static ssize_t store_max_write_buffer_kb(struct device *dev,
static struct device_attribute dev_attr_max_write_buffer_kb = {
.attr = {
- .name = "max_write_buffer_kb",
- .mode = S_IRUGO | S_IWUSR
- },
+ .name = "max_write_buffer_kb",
+ .mode = S_IRUGO | S_IWUSR},
.show = &show_max_write_buffer_kb,
.store = &store_max_write_buffer_kb
};
@@ -2515,16 +2540,16 @@ static ssize_t show_write_buffer_kb(struct device *dev,
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);
+ 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;
+ bytes_per_kibi;
}
- retval = snprintf(buf, PAGE_SIZE, "%i\n", buffer_size_kb);
+ retval = snprintf(buf, PAGE_SIZE, "%i\n", buffer_size_kb);
mutex_unlock(&info->device->mutex);
return retval;
@@ -2539,14 +2564,14 @@ static ssize_t store_write_buffer_kb(struct device *dev,
uint64_t new_size;
int retval;
struct comedi_subdevice *const write_subdevice =
- comedi_get_write_subdevice(info);
+ comedi_get_write_subdevice(info);
if (strict_strtoul(buf, 10, &new_size_kb))
return -EINVAL;
- if (new_size_kb != (uint32_t)new_size_kb)
+ 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)
+ new_size = ((uint64_t) new_size_kb) * bytes_per_kibi;
+ if (new_size != (uint32_t) new_size)
return -EINVAL;
mutex_lock(&info->device->mutex);
@@ -2557,7 +2582,7 @@ static ssize_t store_write_buffer_kb(struct device *dev,
return -EINVAL;
}
retval = resize_async_buffer(info->device, write_subdevice,
- write_subdevice->async, new_size);
+ write_subdevice->async, new_size);
mutex_unlock(&info->device->mutex);
if (retval < 0)
@@ -2567,9 +2592,8 @@ static ssize_t store_write_buffer_kb(struct device *dev,
static struct device_attribute dev_attr_write_buffer_kb = {
.attr = {
- .name = "write_buffer_kb",
- .mode = S_IRUGO | S_IWUSR | S_IWGRP
- },
+ .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 a732e342dcd2..87803e69a149 100644
--- a/drivers/staging/comedi/comedi_ksyms.c
+++ b/drivers/staging/comedi/comedi_ksyms.c
@@ -22,9 +22,6 @@
*/
#define __NO_VERSION__
-#ifndef EXPORT_SYMTAB
-#define EXPORT_SYMTAB
-#endif
#include "comedidev.h"
diff --git a/drivers/staging/comedi/comedidev.h b/drivers/staging/comedi/comedidev.h
index 89af44a788df..e8a5f7d33e7a 100644
--- a/drivers/staging/comedi/comedidev.h
+++ b/drivers/staging/comedi/comedidev.h
@@ -156,28 +156,30 @@ struct comedi_subdevice {
unsigned int *chanlist; /* driver-owned chanlist (not used) */
- int (*insn_read) (struct comedi_device *, struct comedi_subdevice *, struct comedi_insn *,
- unsigned int *);
- int (*insn_write) (struct comedi_device *, struct comedi_subdevice *, struct comedi_insn *,
- unsigned int *);
- int (*insn_bits) (struct comedi_device *, struct comedi_subdevice *, struct comedi_insn *,
- unsigned int *);
- int (*insn_config) (struct comedi_device *, struct comedi_subdevice *, struct comedi_insn *,
- unsigned int *);
+ int (*insn_read) (struct comedi_device *, struct comedi_subdevice *,
+ struct comedi_insn *, unsigned int *);
+ int (*insn_write) (struct comedi_device *, struct comedi_subdevice *,
+ struct comedi_insn *, unsigned int *);
+ int (*insn_bits) (struct comedi_device *, struct comedi_subdevice *,
+ struct comedi_insn *, unsigned int *);
+ int (*insn_config) (struct comedi_device *, struct comedi_subdevice *,
+ struct comedi_insn *, unsigned int *);
int (*do_cmd) (struct comedi_device *, struct comedi_subdevice *);
- int (*do_cmdtest) (struct comedi_device *, struct comedi_subdevice *, struct comedi_cmd *);
+ int (*do_cmdtest) (struct comedi_device *, struct comedi_subdevice *,
+ struct comedi_cmd *);
int (*poll) (struct comedi_device *, struct comedi_subdevice *);
int (*cancel) (struct comedi_device *, struct comedi_subdevice *);
/* int (*do_lock)(struct comedi_device *,struct comedi_subdevice *); */
/* int (*do_unlock)(struct comedi_device *,struct comedi_subdevice *); */
/* called when the buffer changes */
- int (*buf_change) (struct comedi_device *dev, struct comedi_subdevice *s,
- unsigned long new_size);
+ int (*buf_change) (struct comedi_device * dev,
+ struct comedi_subdevice * s, unsigned long new_size);
- void (*munge) (struct comedi_device *dev, struct comedi_subdevice *s, void *data,
- unsigned int num_bytes, unsigned int start_chan_index);
+ void (*munge) (struct comedi_device * dev, struct comedi_subdevice * s,
+ void *data, unsigned int num_bytes,
+ unsigned int start_chan_index);
enum dma_data_direction async_dma_dir;
unsigned int state;
@@ -231,7 +233,7 @@ struct comedi_async {
int (*cb_func) (unsigned int flags, void *);
void *cb_arg;
- int (*inttrig) (struct comedi_device *dev, struct comedi_subdevice *s,
+ int (*inttrig) (struct comedi_device * dev, struct comedi_subdevice * s,
unsigned int x);
};
@@ -281,8 +283,8 @@ struct comedi_device {
struct fasync_struct *async_queue;
- void (*open) (struct comedi_device *dev);
- void (*close) (struct comedi_device *dev);
+ void (*open) (struct comedi_device * dev);
+ void (*close) (struct comedi_device * dev);
};
struct comedi_device_file_info {
@@ -316,8 +318,9 @@ static const unsigned COMEDI_SUBDEVICE_MINOR_OFFSET = 1;
struct comedi_device_file_info *comedi_get_device_file_info(unsigned minor);
-static inline struct comedi_subdevice *comedi_get_read_subdevice(
- const struct comedi_device_file_info *info)
+static inline struct comedi_subdevice *comedi_get_read_subdevice(const struct
+ comedi_device_file_info
+ *info)
{
if (info->read_subdevice)
return info->read_subdevice;
@@ -326,8 +329,9 @@ static inline struct comedi_subdevice *comedi_get_read_subdevice(
return info->device->read_subdev;
}
-static inline struct comedi_subdevice *comedi_get_write_subdevice(
- const struct comedi_device_file_info *info)
+static inline struct comedi_subdevice *comedi_get_write_subdevice(const struct
+ comedi_device_file_info
+ *info)
{
if (info->write_subdevice)
return info->write_subdevice;
@@ -337,7 +341,8 @@ static inline struct comedi_subdevice *comedi_get_write_subdevice(
}
void comedi_device_detach(struct comedi_device *dev);
-int comedi_device_attach(struct comedi_device *dev, struct comedi_devconfig *it);
+int comedi_device_attach(struct comedi_device *dev,
+ struct comedi_devconfig *it);
int comedi_driver_register(struct comedi_driver *);
int comedi_driver_unregister(struct comedi_driver *);
@@ -346,8 +351,8 @@ void cleanup_polling(void);
void start_polling(struct comedi_device *);
void stop_polling(struct comedi_device *);
-int comedi_buf_alloc(struct comedi_device *dev, struct comedi_subdevice *s, unsigned long
- new_size);
+int comedi_buf_alloc(struct comedi_device *dev, struct comedi_subdevice *s,
+ unsigned long new_size);
#ifdef CONFIG_PROC_FS
void comedi_proc_init(void);
@@ -356,6 +361,7 @@ void comedi_proc_cleanup(void);
static inline void comedi_proc_init(void)
{
}
+
static inline void comedi_proc_cleanup(void)
{
}
@@ -378,10 +384,10 @@ enum subdevice_runflags {
int do_rangeinfo_ioctl(struct comedi_device *dev, struct comedi_rangeinfo *arg);
int check_chanlist(struct comedi_subdevice *s, int n, unsigned int *chanlist);
void comedi_set_subdevice_runflags(struct comedi_subdevice *s, unsigned mask,
- unsigned bits);
+ unsigned bits);
unsigned comedi_get_subdevice_runflags(struct comedi_subdevice *s);
int insn_inval(struct comedi_device *dev, struct comedi_subdevice *s,
- struct comedi_insn *insn, unsigned int *data);
+ struct comedi_insn *insn, unsigned int *data);
/* range stuff */
@@ -421,7 +427,8 @@ static inline int alloc_subdevices(struct comedi_device *dev,
dev->n_subdevices = num_subdevices;
dev->subdevices =
- kcalloc(num_subdevices, sizeof(struct comedi_subdevice), GFP_KERNEL);
+ kcalloc(num_subdevices, sizeof(struct comedi_subdevice),
+ GFP_KERNEL);
if (!dev->subdevices)
return -ENOMEM;
for (i = 0; i < num_subdevices; ++i) {
@@ -451,7 +458,8 @@ static inline unsigned int bytes_per_sample(const struct comedi_subdevice *subd)
/* must be used in attach to set dev->hw_dev if you wish to dma directly
into comedi's buffer */
-static inline void comedi_set_hw_dev(struct comedi_device *dev, struct device *hw_dev)
+static inline void comedi_set_hw_dev(struct comedi_device *dev,
+ struct device *hw_dev)
{
if (dev->hw_dev)
put_device(dev->hw_dev);
@@ -467,21 +475,23 @@ int comedi_buf_put(struct comedi_async *async, short x);
int comedi_buf_get(struct comedi_async *async, short *x);
unsigned int comedi_buf_write_n_available(struct comedi_async *async);
-unsigned int comedi_buf_write_alloc(struct comedi_async *async, unsigned int nbytes);
+unsigned int comedi_buf_write_alloc(struct comedi_async *async,
+ unsigned int nbytes);
unsigned int comedi_buf_write_alloc_strict(struct comedi_async *async,
- unsigned int nbytes);
+ unsigned int nbytes);
unsigned comedi_buf_write_free(struct comedi_async *async, unsigned int nbytes);
unsigned comedi_buf_read_alloc(struct comedi_async *async, unsigned nbytes);
unsigned comedi_buf_read_free(struct comedi_async *async, unsigned int nbytes);
unsigned int comedi_buf_read_n_available(struct comedi_async *async);
void comedi_buf_memcpy_to(struct comedi_async *async, unsigned int offset,
- const void *source, unsigned int num_bytes);
+ const void *source, unsigned int num_bytes);
void comedi_buf_memcpy_from(struct comedi_async *async, unsigned int offset,
- void *destination, unsigned int num_bytes);
+ void *destination, unsigned int num_bytes);
static inline unsigned comedi_buf_write_n_allocated(struct comedi_async *async)
{
return async->buf_write_alloc_count - async->buf_write_count;
}
+
static inline unsigned comedi_buf_read_n_allocated(struct comedi_async *async)
{
return async->buf_read_alloc_count - async->buf_read_count;
@@ -516,25 +526,26 @@ static inline void *comedi_aux_data(int options[], int n)
int comedi_alloc_board_minor(struct device *hardware_device);
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);
void comedi_free_subdevice_minor(struct comedi_subdevice *s);
int comedi_pci_auto_config(struct pci_dev *pcidev, const char *board_name);
void comedi_pci_auto_unconfig(struct pci_dev *pcidev);
-struct usb_device; /* forward declaration */
+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);
#ifdef CONFIG_COMEDI_PCI_DRIVERS
- #define CONFIG_COMEDI_PCI
+#define CONFIG_COMEDI_PCI
#endif
#ifdef CONFIG_COMEDI_PCI_DRIVERS_MODULE
- #define CONFIG_COMEDI_PCI
+#define CONFIG_COMEDI_PCI
#endif
#ifdef CONFIG_COMEDI_PCMCIA_DRIVERS
- #define CONFIG_COMEDI_PCMCIA
+#define CONFIG_COMEDI_PCMCIA
#endif
#ifdef CONFIG_COMEDI_PCMCIA_DRIVERS_MODULE
- #define CONFIG_COMEDI_PCMCIA
+#define CONFIG_COMEDI_PCMCIA
#endif
#endif /* _COMEDIDEV_H */
diff --git a/drivers/staging/comedi/comedilib.h b/drivers/staging/comedi/comedilib.h
index c2729312d57e..3918d53b3040 100644
--- a/drivers/staging/comedi/comedilib.h
+++ b/drivers/staging/comedi/comedilib.h
@@ -58,29 +58,31 @@ int comedi_fileno(void *dev);
int comedi_cancel(void *dev, unsigned int subdev);
int comedi_register_callback(void *dev, unsigned int subdev,
- unsigned int mask, int (*cb) (unsigned int, void *), void *arg);
+ unsigned int mask, int (*cb) (unsigned int,
+ void *), void *arg);
int comedi_command(void *dev, struct comedi_cmd *cmd);
int comedi_command_test(void *dev, struct comedi_cmd *cmd);
int comedi_trigger(void *dev, unsigned int subdev, struct comedi_trig *it);
int __comedi_trigger(void *dev, unsigned int subdev, struct comedi_trig *it);
int comedi_data_write(void *dev, unsigned int subdev, unsigned int chan,
- unsigned int range, unsigned int aref, unsigned int data);
+ unsigned int range, unsigned int aref, unsigned int data);
int comedi_data_read(void *dev, unsigned int subdev, unsigned int chan,
- unsigned int range, unsigned int aref, unsigned int *data);
+ unsigned int range, unsigned int aref, unsigned int *data);
int comedi_data_read_hint(void *dev, unsigned int subdev,
- unsigned int chan, unsigned int range, unsigned int aref);
-int comedi_data_read_delayed(void *dev, unsigned int subdev,
- unsigned int chan, unsigned int range, unsigned int aref,
- unsigned int *data, unsigned int nano_sec);
+ unsigned int chan, unsigned int range,
+ unsigned int aref);
+int comedi_data_read_delayed(void *dev, unsigned int subdev, unsigned int chan,
+ unsigned int range, unsigned int aref,
+ unsigned int *data, unsigned int nano_sec);
int comedi_dio_config(void *dev, unsigned int subdev, unsigned int chan,
- unsigned int io);
+ unsigned int io);
int comedi_dio_read(void *dev, unsigned int subdev, unsigned int chan,
- unsigned int *val);
+ unsigned int *val);
int comedi_dio_write(void *dev, unsigned int subdev, unsigned int chan,
- unsigned int val);
+ unsigned int val);
int comedi_dio_bitfield(void *dev, unsigned int subdev, unsigned int mask,
- unsigned int *bits);
+ unsigned int *bits);
int comedi_get_n_subdevices(void *dev);
int comedi_get_version_code(void *dev);
const char *comedi_get_driver_name(void *dev);
@@ -89,31 +91,29 @@ int comedi_get_subdevice_type(void *dev, unsigned int subdevice);
int comedi_find_subdevice_by_type(void *dev, int type, unsigned int subd);
int comedi_get_n_channels(void *dev, unsigned int subdevice);
unsigned int comedi_get_maxdata(void *dev, unsigned int subdevice, unsigned
- int chan);
-int comedi_get_n_ranges(void *dev, unsigned int subdevice, unsigned int
- chan);
+ int chan);
+int comedi_get_n_ranges(void *dev, unsigned int subdevice, unsigned int chan);
int comedi_do_insn(void *dev, struct comedi_insn *insn);
int comedi_poll(void *dev, unsigned int subdev);
/* DEPRECATED functions */
-int comedi_get_rangetype(void *dev, unsigned int subdevice,
- unsigned int chan);
+int comedi_get_rangetype(void *dev, unsigned int subdevice, unsigned int chan);
/* ALPHA functions */
unsigned int comedi_get_subdevice_flags(void *dev, unsigned int subdevice);
int comedi_get_len_chanlist(void *dev, unsigned int subdevice);
int comedi_get_krange(void *dev, unsigned int subdevice, unsigned int
- chan, unsigned int range, struct comedi_krange *krange);
+ chan, unsigned int range, struct comedi_krange *krange);
unsigned int comedi_get_buf_head_pos(void *dev, unsigned int subdevice);
int comedi_set_user_int_count(void *dev, unsigned int subdevice,
- unsigned int buf_user_count);
+ unsigned int buf_user_count);
int comedi_map(void *dev, unsigned int subdev, void *ptr);
int comedi_unmap(void *dev, unsigned int subdev);
int comedi_get_buffer_size(void *dev, unsigned int subdev);
int comedi_mark_buffer_read(void *dev, unsigned int subdevice,
- unsigned int num_bytes);
+ unsigned int num_bytes);
int comedi_mark_buffer_written(void *d, unsigned int subdevice,
- unsigned int num_bytes);
+ unsigned int num_bytes);
int comedi_get_buffer_contents(void *dev, unsigned int subdevice);
int comedi_get_buffer_offset(void *dev, unsigned int subdevice);
@@ -135,53 +135,56 @@ int comedi_unlock(unsigned int minor, unsigned int subdev);
int comedi_cancel(unsigned int minor, unsigned int subdev);
int comedi_register_callback(unsigned int minor, unsigned int subdev,
- unsigned int mask, int (*cb) (unsigned int, void *), void *arg);
+ unsigned int mask, int (*cb) (unsigned int,
+ void *), void *arg);
int comedi_command(unsigned int minor, struct comedi_cmd *cmd);
int comedi_command_test(unsigned int minor, struct comedi_cmd *cmd);
-int comedi_trigger(unsigned int minor, unsigned int subdev, struct comedi_trig *it);
-int __comedi_trigger(unsigned int minor, unsigned int subdev, struct comedi_trig *it);
+int comedi_trigger(unsigned int minor, unsigned int subdev,
+ struct comedi_trig *it);
+int __comedi_trigger(unsigned int minor, unsigned int subdev,
+ struct comedi_trig *it);
int comedi_data_write(unsigned int dev, unsigned int subdev, unsigned int chan,
- unsigned int range, unsigned int aref, unsigned int data);
+ unsigned int range, unsigned int aref, unsigned int data);
int comedi_data_read(unsigned int dev, unsigned int subdev, unsigned int chan,
- unsigned int range, unsigned int aref, unsigned int *data);
+ unsigned int range, unsigned int aref, unsigned int *data);
int comedi_dio_config(unsigned int dev, unsigned int subdev, unsigned int chan,
- unsigned int io);
+ unsigned int io);
int comedi_dio_read(unsigned int dev, unsigned int subdev, unsigned int chan,
- unsigned int *val);
+ unsigned int *val);
int comedi_dio_write(unsigned int dev, unsigned int subdev, unsigned int chan,
- unsigned int val);
+ unsigned int val);
int comedi_dio_bitfield(unsigned int dev, unsigned int subdev,
- unsigned int mask, unsigned int *bits);
+ unsigned int mask, unsigned int *bits);
int comedi_get_n_subdevices(unsigned int dev);
int comedi_get_version_code(unsigned int dev);
char *comedi_get_driver_name(unsigned int dev);
char *comedi_get_board_name(unsigned int minor);
int comedi_get_subdevice_type(unsigned int minor, unsigned int subdevice);
int comedi_find_subdevice_by_type(unsigned int minor, int type,
- unsigned int subd);
+ unsigned int subd);
int comedi_get_n_channels(unsigned int minor, unsigned int subdevice);
unsigned int comedi_get_maxdata(unsigned int minor, unsigned int subdevice, unsigned
- int chan);
+ int chan);
int comedi_get_n_ranges(unsigned int minor, unsigned int subdevice, unsigned int
- chan);
+ chan);
int comedi_do_insn(unsigned int minor, struct comedi_insn *insn);
int comedi_poll(unsigned int minor, unsigned int subdev);
/* DEPRECATED functions */
int comedi_get_rangetype(unsigned int minor, unsigned int subdevice,
- unsigned int chan);
+ unsigned int chan);
/* ALPHA functions */
unsigned int comedi_get_subdevice_flags(unsigned int minor, unsigned int
- subdevice);
+ subdevice);
int comedi_get_len_chanlist(unsigned int minor, unsigned int subdevice);
int comedi_get_krange(unsigned int minor, unsigned int subdevice, unsigned int
- chan, unsigned int range, struct comedi_krange *krange);
+ chan, unsigned int range, struct comedi_krange *krange);
unsigned int comedi_get_buf_head_pos(unsigned int minor, unsigned int
- subdevice);
+ subdevice);
int comedi_set_user_int_count(unsigned int minor, unsigned int subdevice,
- unsigned int buf_user_count);
+ unsigned int buf_user_count);
int comedi_map(unsigned int minor, unsigned int subdev, void **ptr);
int comedi_unmap(unsigned int minor, unsigned int subdev);
diff --git a/drivers/staging/comedi/drivers.c b/drivers/staging/comedi/drivers.c
index 42a02571ff1b..dc53aeeac68f 100644
--- a/drivers/staging/comedi/drivers.c
+++ b/drivers/staging/comedi/drivers.c
@@ -48,13 +48,14 @@
#include <asm/system.h>
static int postconfig(struct comedi_device *dev);
-static int insn_rw_emulate_bits(struct comedi_device *dev, struct comedi_subdevice *s,
- struct comedi_insn *insn, unsigned int *data);
-static void *comedi_recognize(struct comedi_driver * driv, const char *name);
+static int insn_rw_emulate_bits(struct comedi_device *dev,
+ struct comedi_subdevice *s,
+ struct comedi_insn *insn, unsigned int *data);
+static void *comedi_recognize(struct comedi_driver *driv, const char *name);
static void comedi_report_boards(struct comedi_driver *driv);
static int poll_invalid(struct comedi_device *dev, struct comedi_subdevice *s);
int comedi_buf_alloc(struct comedi_device *dev, struct comedi_subdevice *s,
- unsigned long new_size);
+ unsigned long new_size);
struct comedi_driver *comedi_drivers;
@@ -123,7 +124,8 @@ int comedi_device_attach(struct comedi_device *dev, struct comedi_devconfig *it)
for (driv = comedi_drivers; driv; driv = driv->next) {
if (!try_module_get(driv->module)) {
- printk("comedi: failed to increment module count, skipping\n");
+ printk
+ ("comedi: failed to increment module count, skipping\n");
continue;
}
if (driv->num_names) {
@@ -195,16 +197,20 @@ int comedi_driver_unregister(struct comedi_driver *driver)
/* check for devices using this driver */
for (i = 0; i < COMEDI_NUM_BOARD_MINORS; i++) {
- struct comedi_device_file_info *dev_file_info = comedi_get_device_file_info(i);
+ 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);
if (dev->attached && dev->driver == driver) {
if (dev->use_count)
- printk("BUG! detaching device with use_count=%d\n", dev->use_count);
+ printk
+ ("BUG! detaching device with use_count=%d\n",
+ dev->use_count);
comedi_device_detach(dev);
}
mutex_unlock(&dev->mutex);
@@ -242,10 +248,11 @@ static int postconfig(struct comedi_device *dev)
if (s->do_cmd) {
BUG_ON((s->subdev_flags & (SDF_CMD_READ |
- SDF_CMD_WRITE)) == 0);
+ SDF_CMD_WRITE)) == 0);
BUG_ON(!s->do_cmdtest);
- async = kzalloc(sizeof(struct comedi_async), GFP_KERNEL);
+ async =
+ kzalloc(sizeof(struct comedi_async), GFP_KERNEL);
if (async == NULL) {
printk("failed to allocate async struct\n");
return -ENOMEM;
@@ -298,7 +305,7 @@ static int postconfig(struct comedi_device *dev)
}
/* generic recognize function for drivers that register their supported board names */
-void *comedi_recognize(struct comedi_driver * driv, const char *name)
+void *comedi_recognize(struct comedi_driver *driv, const char *name)
{
unsigned i;
const char *const *name_ptr = driv->board_name;
@@ -306,8 +313,8 @@ void *comedi_recognize(struct comedi_driver * driv, const char *name)
if (strcmp(*name_ptr, name) == 0)
return (void *)name_ptr;
name_ptr =
- (const char *const *)((const char *)name_ptr +
- driv->offset);
+ (const char *const *)((const char *)name_ptr +
+ driv->offset);
}
return NULL;
@@ -319,7 +326,7 @@ void comedi_report_boards(struct comedi_driver *driv)
const char *const *name_ptr;
printk("comedi: valid board names for %s driver are:\n",
- driv->driver_name);
+ driv->driver_name);
name_ptr = driv->board_name;
for (i = 0; i < driv->num_names; i++) {
@@ -337,13 +344,14 @@ static int poll_invalid(struct comedi_device *dev, struct comedi_subdevice *s)
}
int insn_inval(struct comedi_device *dev, struct comedi_subdevice *s,
- struct comedi_insn *insn, unsigned int *data)
+ struct comedi_insn *insn, unsigned int *data)
{
return -EINVAL;
}
-static int insn_rw_emulate_bits(struct comedi_device *dev, struct comedi_subdevice *s,
- struct comedi_insn *insn, unsigned int *data)
+static int insn_rw_emulate_bits(struct comedi_device *dev,
+ struct comedi_subdevice *s,
+ struct comedi_insn *insn, unsigned int *data)
{
struct comedi_insn new_insn;
int ret;
@@ -351,7 +359,7 @@ static int insn_rw_emulate_bits(struct comedi_device *dev, struct comedi_subdevi
unsigned chan = CR_CHAN(insn->chanspec);
const unsigned base_bitfield_channel =
- (chan < channels_per_bitfield) ? 0 : chan;
+ (chan < channels_per_bitfield) ? 0 : chan;
unsigned int new_data[2];
memset(new_data, 0, sizeof(new_data));
memset(&new_insn, 0, sizeof(new_insn));
@@ -379,7 +387,7 @@ static int insn_rw_emulate_bits(struct comedi_device *dev, struct comedi_subdevi
return 1;
}
-static inline unsigned long uvirt_to_kva(pgd_t *pgd, unsigned long adr)
+static inline unsigned long uvirt_to_kva(pgd_t * pgd, unsigned long adr)
{
unsigned long ret = 0UL;
pmd_t *pmd;
@@ -394,7 +402,7 @@ static inline unsigned long uvirt_to_kva(pgd_t *pgd, unsigned long adr)
pte = *ptep;
if (pte_present(pte)) {
ret = (unsigned long)
- page_address(pte_page(pte));
+ page_address(pte_page(pte));
ret |= (adr & (PAGE_SIZE - 1));
}
}
@@ -413,7 +421,7 @@ static inline unsigned long kvirt_to_kva(unsigned long adr)
}
int comedi_buf_alloc(struct comedi_device *dev, struct comedi_subdevice *s,
- unsigned long new_size)
+ unsigned long new_size)
{
struct comedi_async *async = s->async;
@@ -434,18 +442,22 @@ int comedi_buf_alloc(struct comedi_device *dev, struct comedi_subdevice *s,
unsigned i;
for (i = 0; i < async->n_buf_pages; ++i) {
if (async->buf_page_list[i].virt_addr) {
- mem_map_unreserve(virt_to_page(async->
- buf_page_list[i].virt_addr));
+ mem_map_unreserve(virt_to_page
+ (async->buf_page_list[i].
+ virt_addr));
if (s->async_dma_dir != DMA_NONE) {
dma_free_coherent(dev->hw_dev,
- PAGE_SIZE,
- async->buf_page_list[i].
- virt_addr,
- async->buf_page_list[i].
- dma_addr);
+ PAGE_SIZE,
+ async->
+ buf_page_list
+ [i].virt_addr,
+ async->
+ buf_page_list
+ [i].dma_addr);
} else {
- free_page((unsigned long)async->
- buf_page_list[i].virt_addr);
+ free_page((unsigned long)
+ async->buf_page_list[i].
+ virt_addr);
}
}
}
@@ -460,66 +472,69 @@ int comedi_buf_alloc(struct comedi_device *dev, struct comedi_subdevice *s,
struct page **pages = NULL;
async->buf_page_list =
- vmalloc(sizeof(struct comedi_buf_page) * n_pages);
+ vmalloc(sizeof(struct comedi_buf_page) * n_pages);
if (async->buf_page_list) {
memset(async->buf_page_list, 0,
- sizeof(struct comedi_buf_page) * n_pages);
+ sizeof(struct comedi_buf_page) * n_pages);
pages = vmalloc(sizeof(struct page *) * n_pages);
}
if (pages) {
for (i = 0; i < n_pages; i++) {
if (s->async_dma_dir != DMA_NONE) {
async->buf_page_list[i].virt_addr =
- dma_alloc_coherent(dev->hw_dev,
- PAGE_SIZE,
- &async->buf_page_list[i].
- dma_addr,
- GFP_KERNEL | __GFP_COMP);
+ dma_alloc_coherent(dev->hw_dev,
+ PAGE_SIZE,
+ &async->
+ buf_page_list
+ [i].dma_addr,
+ GFP_KERNEL |
+ __GFP_COMP);
} else {
async->buf_page_list[i].virt_addr =
- (void *)
- get_zeroed_page(GFP_KERNEL);
+ (void *)
+ get_zeroed_page(GFP_KERNEL);
}
if (async->buf_page_list[i].virt_addr == NULL) {
break;
}
- mem_map_reserve(virt_to_page(async->
- buf_page_list[i].virt_addr));
+ mem_map_reserve(virt_to_page
+ (async->buf_page_list[i].
+ virt_addr));
pages[i] =
- virt_to_page(async->buf_page_list[i].
- virt_addr);
+ virt_to_page(async->
+ buf_page_list[i].virt_addr);
}
}
if (i == n_pages) {
async->prealloc_buf =
- vmap(pages, n_pages, VM_MAP,
- PAGE_KERNEL_NOCACHE);
- }
- if (pages) {
- vfree(pages);
+ vmap(pages, n_pages, VM_MAP, PAGE_KERNEL_NOCACHE);
}
+ vfree(pages);
+
if (async->prealloc_buf == NULL) {
/* Some allocation failed above. */
if (async->buf_page_list) {
for (i = 0; i < n_pages; i++) {
if (async->buf_page_list[i].virt_addr ==
- NULL) {
+ NULL) {
break;
}
- mem_map_unreserve(virt_to_page(async->
- buf_page_list[i].
- virt_addr));
+ mem_map_unreserve(virt_to_page
+ (async->buf_page_list
+ [i].virt_addr));
if (s->async_dma_dir != DMA_NONE) {
dma_free_coherent(dev->hw_dev,
- PAGE_SIZE,
- async->buf_page_list[i].
- virt_addr,
- async->buf_page_list[i].
- dma_addr);
+ PAGE_SIZE,
+ async->
+ buf_page_list
+ [i].virt_addr,
+ async->
+ buf_page_list
+ [i].dma_addr);
} else {
- free_page((unsigned long)async->
- buf_page_list[i].
- virt_addr);
+ free_page((unsigned long)
+ async->buf_page_list
+ [i].virt_addr);
}
}
vfree(async->buf_page_list);
@@ -536,7 +551,8 @@ int comedi_buf_alloc(struct comedi_device *dev, struct comedi_subdevice *s,
/* munging is applied to data by core as it passes between user
* and kernel space */
-unsigned int comedi_buf_munge(struct comedi_async *async, unsigned int num_bytes)
+unsigned int comedi_buf_munge(struct comedi_async *async,
+ unsigned int num_bytes)
{
struct comedi_subdevice *s = async->subdevice;
unsigned int count = 0;
@@ -555,15 +571,15 @@ unsigned int comedi_buf_munge(struct comedi_async *async, unsigned int num_bytes
block_size = num_bytes - count;
if (block_size < 0) {
printk("%s: %s: bug! block_size is negative\n",
- __FILE__, __func__);
+ __FILE__, __func__);
break;
}
if ((int)(async->munge_ptr + block_size -
- async->prealloc_bufsz) > 0)
+ async->prealloc_bufsz) > 0)
block_size = async->prealloc_bufsz - async->munge_ptr;
s->munge(s->device, s, async->prealloc_buf + async->munge_ptr,
- block_size, async->munge_chan);
+ block_size, async->munge_chan);
smp_wmb(); /* barrier insures data is munged in buffer before munge_count is incremented */
@@ -598,7 +614,8 @@ unsigned int comedi_buf_write_n_available(struct comedi_async *async)
}
/* allocates chunk for the writer from free buffer space */
-unsigned int comedi_buf_write_alloc(struct comedi_async *async, unsigned int nbytes)
+unsigned int comedi_buf_write_alloc(struct comedi_async *async,
+ unsigned int nbytes)
{
unsigned int free_end = async->buf_read_count + async->prealloc_bufsz;
@@ -614,7 +631,7 @@ unsigned int comedi_buf_write_alloc(struct comedi_async *async, unsigned int nby
/* allocates nothing unless it can completely fulfill the request */
unsigned int comedi_buf_write_alloc_strict(struct comedi_async *async,
- unsigned int nbytes)
+ unsigned int nbytes)
{
unsigned int free_end = async->buf_read_count + async->prealloc_bufsz;
@@ -632,8 +649,9 @@ unsigned int comedi_buf_write_alloc_strict(struct comedi_async *async,
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) {
- printk("comedi: attempted to write-free more bytes than have been write-allocated.\n");
+ async->buf_write_alloc_count) > 0) {
+ 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;
@@ -649,7 +667,7 @@ unsigned comedi_buf_write_free(struct comedi_async *async, unsigned int nbytes)
unsigned comedi_buf_read_alloc(struct comedi_async *async, unsigned nbytes)
{
if ((int)(async->buf_read_alloc_count + nbytes - async->munge_count) >
- 0) {
+ 0) {
nbytes = async->munge_count - async->buf_read_alloc_count;
}
async->buf_read_alloc_count += nbytes;
@@ -665,8 +683,9 @@ unsigned comedi_buf_read_free(struct comedi_async *async, unsigned int nbytes)
/* barrier insures data has been read out of buffer before read count is incremented */
smp_mb();
if ((int)(async->buf_read_count + nbytes -
- async->buf_read_alloc_count) > 0) {
- printk("comedi: attempted to read-free more bytes than have been read-allocated.\n");
+ async->buf_read_alloc_count) > 0) {
+ 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;
@@ -676,7 +695,7 @@ unsigned comedi_buf_read_free(struct comedi_async *async, unsigned int nbytes)
}
void comedi_buf_memcpy_to(struct comedi_async *async, unsigned int offset,
- const void *data, unsigned int num_bytes)
+ const void *data, unsigned int num_bytes)
{
unsigned int write_ptr = async->buf_write_ptr + offset;
@@ -701,7 +720,7 @@ void comedi_buf_memcpy_to(struct comedi_async *async, unsigned int offset,
}
void comedi_buf_memcpy_from(struct comedi_async *async, unsigned int offset,
- void *dest, unsigned int nbytes)
+ void *dest, unsigned int nbytes)
{
void *src;
unsigned int read_ptr = async->buf_read_ptr + offset;
@@ -748,7 +767,7 @@ int comedi_buf_get(struct comedi_async *async, short *x)
if (n < sizeof(short))
return 0;
comedi_buf_read_alloc(async, sizeof(short));
- *x = *(short *) (async->prealloc_buf + async->buf_read_ptr);
+ *x = *(short *)(async->prealloc_buf + async->buf_read_ptr);
comedi_buf_read_free(async, sizeof(short));
return 1;
}
@@ -761,7 +780,7 @@ int comedi_buf_put(struct comedi_async *async, short x)
async->events |= COMEDI_CB_ERROR;
return 0;
}
- *(short *) (async->prealloc_buf + async->buf_write_ptr) = x;
+ *(short *)(async->prealloc_buf + async->buf_write_ptr) = x;
comedi_buf_write_free(async, sizeof(short));
return 1;
}
@@ -785,7 +804,8 @@ void comedi_reset_async_buf(struct comedi_async *async)
async->events = 0;
}
-int comedi_auto_config(struct device *hardware_device, const char *board_name, const int *options, unsigned num_options)
+int comedi_auto_config(struct device *hardware_device, const char *board_name,
+ const int *options, unsigned num_options)
{
struct comedi_devconfig it;
int minor;
@@ -799,7 +819,8 @@ 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) {
@@ -822,8 +843,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);
}
@@ -833,7 +853,8 @@ 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);
@@ -860,8 +881,7 @@ void comedi_pci_auto_unconfig(struct pci_dev *pcidev)
comedi_auto_unconfig(&pcidev->dev);
}
-int comedi_usb_auto_config(struct usb_device *usbdev,
- const char *board_name)
+int comedi_usb_auto_config(struct usb_device *usbdev, const char *board_name)
{
BUG_ON(usbdev == NULL);
return comedi_auto_config(&usbdev->dev, board_name, NULL, 0);
diff --git a/drivers/staging/comedi/drivers/8253.h b/drivers/staging/comedi/drivers/8253.h
index ad467ac290a3..c2ea2d96f1cc 100644
--- a/drivers/staging/comedi/drivers/8253.h
+++ b/drivers/staging/comedi/drivers/8253.h
@@ -29,8 +29,10 @@
#define i8253_cascade_ns_to_timer i8253_cascade_ns_to_timer_2div
static inline void i8253_cascade_ns_to_timer_2div_old(int i8253_osc_base,
- unsigned int *d1, unsigned int *d2, unsigned int *nanosec,
- int round_mode)
+ unsigned int *d1,
+ unsigned int *d2,
+ unsigned int *nanosec,
+ int round_mode)
{
int divider;
int div1, div2;
@@ -78,8 +80,10 @@ static inline void i8253_cascade_ns_to_timer_2div_old(int i8253_osc_base,
}
static inline void i8253_cascade_ns_to_timer_power(int i8253_osc_base,
- unsigned int *d1, unsigned int *d2, unsigned int *nanosec,
- int round_mode)
+ unsigned int *d1,
+ unsigned int *d2,
+ unsigned int *nanosec,
+ int round_mode)
{
int div1, div2;
int base;
@@ -118,8 +122,10 @@ static inline void i8253_cascade_ns_to_timer_power(int i8253_osc_base,
}
static inline void i8253_cascade_ns_to_timer_2div(int i8253_osc_base,
- unsigned int *d1, unsigned int *d2, unsigned int *nanosec,
- int round_mode)
+ unsigned int *d1,
+ unsigned int *d2,
+ unsigned int *nanosec,
+ int round_mode)
{
unsigned int divider;
unsigned int div1, div2;
@@ -136,12 +142,11 @@ static inline void i8253_cascade_ns_to_timer_2div(int i8253_osc_base,
div2 = *d2 ? *d2 : max_count;
divider = div1 * div2;
if (div1 * div2 * i8253_osc_base == *nanosec &&
- div1 > 1 && div1 <= max_count &&
- div2 > 1 && div2 <= max_count &&
- /* check for overflow */
- divider > div1 && divider > div2 &&
- divider * i8253_osc_base > divider &&
- divider * i8253_osc_base > i8253_osc_base) {
+ div1 > 1 && div1 <= max_count && div2 > 1 && div2 <= max_count &&
+ /* check for overflow */
+ divider > div1 && divider > div2 &&
+ divider * i8253_osc_base > divider &&
+ divider * i8253_osc_base > i8253_osc_base) {
return;
}
@@ -158,10 +163,10 @@ static inline void i8253_cascade_ns_to_timer_2div(int i8253_osc_base,
if (start < 2)
start = 2;
for (div1 = start; div1 <= divider / div1 + 1 && div1 <= max_count;
- div1++) {
+ div1++) {
for (div2 = divider / div1;
- div1 * div2 <= divider + div1 + 1 && div2 <= max_count;
- div2++) {
+ div1 * div2 <= divider + div1 + 1 && div2 <= max_count;
+ div2++) {
ns = i8253_osc_base * div1 * div2;
if (ns <= *nanosec && ns > ns_glb) {
ns_glb = ns;
@@ -229,7 +234,8 @@ static inline void i8253_cascade_ns_to_timer_2div(int i8253_osc_base,
#define i8254_control_reg 3
static inline int i8254_load(unsigned long base_address, unsigned int regshift,
- unsigned int counter_number, unsigned int count, unsigned int mode)
+ unsigned int counter_number, unsigned int count,
+ unsigned int mode)
{
unsigned int byte;
@@ -255,7 +261,8 @@ static inline int i8254_load(unsigned long base_address, unsigned int regshift,
}
static inline int i8254_mm_load(void *base_address, unsigned int regshift,
- unsigned int counter_number, unsigned int count, unsigned int mode)
+ unsigned int counter_number, unsigned int count,
+ unsigned int mode)
{
unsigned int byte;
@@ -282,7 +289,7 @@ static inline int i8254_mm_load(void *base_address, unsigned int regshift,
/* Returns 16 bit counter value, should work for 8253 also.*/
static inline int i8254_read(unsigned long base_address, unsigned int regshift,
- unsigned int counter_number)
+ unsigned int counter_number)
{
unsigned int byte;
int ret;
@@ -303,7 +310,7 @@ static inline int i8254_read(unsigned long base_address, unsigned int regshift,
}
static inline int i8254_mm_read(void *base_address, unsigned int regshift,
- unsigned int counter_number)
+ unsigned int counter_number)
{
unsigned int byte;
int ret;
@@ -325,7 +332,8 @@ static inline int i8254_mm_read(void *base_address, unsigned int regshift,
/* Loads 16 bit initial counter value, should work for 8253 also. */
static inline void i8254_write(unsigned long base_address,
- unsigned int regshift, unsigned int counter_number, unsigned int count)
+ unsigned int regshift,
+ unsigned int counter_number, unsigned int count)
{
unsigned int byte;
@@ -339,7 +347,9 @@ static inline void i8254_write(unsigned long base_address,
}
static inline void i8254_mm_write(void *base_address,
- unsigned int regshift, unsigned int counter_number, unsigned int count)
+ unsigned int regshift,
+ unsigned int counter_number,
+ unsigned int count)
{
unsigned int byte;
@@ -360,7 +370,8 @@ static inline void i8254_mm_write(void *base_address,
* I8254_BCD, I8254_BINARY
*/
static inline int i8254_set_mode(unsigned long base_address,
- unsigned int regshift, unsigned int counter_number, unsigned int mode)
+ unsigned int regshift,
+ unsigned int counter_number, unsigned int mode)
{
unsigned int byte;
@@ -378,7 +389,9 @@ static inline int i8254_set_mode(unsigned long base_address,
}
static inline int i8254_mm_set_mode(void *base_address,
- unsigned int regshift, unsigned int counter_number, unsigned int mode)
+ unsigned int regshift,
+ unsigned int counter_number,
+ unsigned int mode)
{
unsigned int byte;
@@ -396,18 +409,20 @@ static inline int i8254_mm_set_mode(void *base_address,
}
static inline int i8254_status(unsigned long base_address,
- unsigned int regshift, unsigned int counter_number)
+ unsigned int regshift,
+ unsigned int counter_number)
{
outb(0xE0 | (2 << counter_number),
- base_address + (i8254_control_reg << regshift));
+ base_address + (i8254_control_reg << regshift));
return inb(base_address + (counter_number << regshift));
}
static inline int i8254_mm_status(void *base_address,
- unsigned int regshift, unsigned int counter_number)
+ unsigned int regshift,
+ unsigned int counter_number)
{
writeb(0xE0 | (2 << counter_number),
- base_address + (i8254_control_reg << regshift));
+ base_address + (i8254_control_reg << regshift));
return readb(base_address + (counter_number << regshift));
}
diff --git a/drivers/staging/comedi/drivers/8255.c b/drivers/staging/comedi/drivers/8255.c
index bdc3957bceb8..0a50864767e4 100644
--- a/drivers/staging/comedi/drivers/8255.c
+++ b/drivers/staging/comedi/drivers/8255.c
@@ -105,7 +105,8 @@ struct subdev_8255_struct {
#define CALLBACK_FUNC (((struct subdev_8255_struct *)s->private)->cb_func)
#define subdevpriv ((struct subdev_8255_struct *)s->private)
-static int dev_8255_attach(struct comedi_device *dev, struct comedi_devconfig * it);
+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",
@@ -116,9 +117,10 @@ static struct comedi_driver driver_8255 = {
COMEDI_INITCLEANUP(driver_8255);
-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_8255_interrupt(struct comedi_device *dev, struct comedi_subdevice * s)
+void subdev_8255_interrupt(struct comedi_device *dev,
+ struct comedi_subdevice *s)
{
short d;
@@ -143,8 +145,9 @@ 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)
+static int subdev_8255_insn(struct comedi_device *dev,
+ struct comedi_subdevice *s,
+ struct comedi_insn *insn, unsigned int *data)
{
if (data[0]) {
s->state &= ~data[0];
@@ -152,13 +155,13 @@ static int subdev_8255_insn(struct comedi_device *dev, struct comedi_subdevice *
if (data[0] & 0xff)
CALLBACK_FUNC(1, _8255_DATA, s->state & 0xff,
- CALLBACK_ARG);
+ CALLBACK_ARG);
if (data[0] & 0xff00)
CALLBACK_FUNC(1, _8255_DATA + 1, (s->state >> 8) & 0xff,
- CALLBACK_ARG);
+ CALLBACK_ARG);
if (data[0] & 0xff0000)
CALLBACK_FUNC(1, _8255_DATA + 2,
- (s->state >> 16) & 0xff, CALLBACK_ARG);
+ (s->state >> 16) & 0xff, CALLBACK_ARG);
}
data[1] = CALLBACK_FUNC(0, _8255_DATA, 0, CALLBACK_ARG);
@@ -168,8 +171,9 @@ static int subdev_8255_insn(struct comedi_device *dev, struct comedi_subdevice *
return 2;
}
-static int subdev_8255_insn_config(struct comedi_device *dev, struct comedi_subdevice * s,
- struct comedi_insn *insn, unsigned int *data)
+static int subdev_8255_insn_config(struct comedi_device *dev,
+ struct comedi_subdevice *s,
+ struct comedi_insn *insn, unsigned int *data)
{
unsigned int mask;
unsigned int bits;
@@ -205,7 +209,7 @@ static int subdev_8255_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)
{
int config;
@@ -222,8 +226,9 @@ static void do_config(struct comedi_device *dev, struct comedi_subdevice * s)
CALLBACK_FUNC(1, _8255_CR, config, CALLBACK_ARG);
}
-static int subdev_8255_cmdtest(struct comedi_device *dev, struct comedi_subdevice * s,
- struct comedi_cmd *cmd)
+static int subdev_8255_cmdtest(struct comedi_device *dev,
+ struct comedi_subdevice *s,
+ struct comedi_cmd *cmd)
{
int err = 0;
unsigned int tmp;
@@ -297,22 +302,25 @@ static int subdev_8255_cmdtest(struct comedi_device *dev, struct comedi_subdevic
return 0;
}
-static int subdev_8255_cmd(struct comedi_device *dev, struct comedi_subdevice * s)
+static int subdev_8255_cmd(struct comedi_device *dev,
+ struct comedi_subdevice *s)
{
/* FIXME */
return 0;
}
-static int subdev_8255_cancel(struct comedi_device *dev, struct comedi_subdevice * s)
+static int subdev_8255_cancel(struct comedi_device *dev,
+ struct comedi_subdevice *s)
{
/* FIXME */
return 0;
}
-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(struct comedi_device *dev, struct comedi_subdevice *s,
+ int (*cb) (int, int, int, unsigned long),
+ unsigned long arg)
{
s->type = COMEDI_SUBD_DIO;
s->subdev_flags = SDF_READABLE | SDF_WRITABLE;
@@ -340,8 +348,9 @@ int subdev_8255_init(struct comedi_device *dev, struct comedi_subdevice * s, int
return 0;
}
-int subdev_8255_init_irq(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 (*cb) (int, int, int, unsigned long),
+ unsigned long arg)
{
int ret;
@@ -358,7 +367,7 @@ int subdev_8255_init_irq(struct comedi_device *dev, struct comedi_subdevice * s,
return 0;
}
-void subdev_8255_cleanup(struct comedi_device *dev, struct comedi_subdevice * s)
+void subdev_8255_cleanup(struct comedi_device *dev, struct comedi_subdevice *s)
{
if (s->private) {
/* this test does nothing, so comment it out
@@ -376,7 +385,8 @@ void subdev_8255_cleanup(struct comedi_device *dev, struct comedi_subdevice * s)
*/
-static int dev_8255_attach(struct comedi_device *dev, struct comedi_devconfig * it)
+static int dev_8255_attach(struct comedi_device *dev,
+ struct comedi_devconfig *it)
{
int ret;
unsigned long iobase;
@@ -410,7 +420,7 @@ static int dev_8255_attach(struct comedi_device *dev, struct comedi_devconfig *
dev->subdevices[i].type = COMEDI_SUBD_UNUSED;
} else {
subdev_8255_init(dev, dev->subdevices + i, NULL,
- iobase);
+ iobase);
}
}
diff --git a/drivers/staging/comedi/drivers/8255.h b/drivers/staging/comedi/drivers/8255.h
index 5457c6b2d22e..02c5a361b1ab 100644
--- a/drivers/staging/comedi/drivers/8255.h
+++ b/drivers/staging/comedi/drivers/8255.h
@@ -29,16 +29,20 @@
#if defined(CONFIG_COMEDI_8255) || defined(CONFIG_COMEDI_8255_MODULE)
int subdev_8255_init(struct comedi_device *dev, struct comedi_subdevice *s,
- int (*cb) (int, int, int, unsigned long), unsigned long arg);
+ int (*cb) (int, int, int, unsigned long),
+ unsigned long arg);
int subdev_8255_init_irq(struct comedi_device *dev, struct comedi_subdevice *s,
- int (*cb) (int, int, int, unsigned long), unsigned long arg);
+ 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_interrupt(struct comedi_device *dev,
+ struct comedi_subdevice *s);
#else
-static inline int subdev_8255_init(struct comedi_device *dev, struct comedi_subdevice *s,
- void *x, unsigned long y)
+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");
@@ -48,7 +52,7 @@ static inline int subdev_8255_init(struct comedi_device *dev, struct comedi_subd
}
static inline void subdev_8255_cleanup(struct comedi_device *dev,
- struct comedi_subdevice *s)
+ struct comedi_subdevice *s)
{
}
diff --git a/drivers/staging/comedi/drivers/acl7225b.c b/drivers/staging/comedi/drivers/acl7225b.c
index 5b986aa7398b..c3652ef19a5f 100644
--- a/drivers/staging/comedi/drivers/acl7225b.c
+++ b/drivers/staging/comedi/drivers/acl7225b.c
@@ -22,7 +22,8 @@ Devices: [Adlink] ACL-7225b (acl7225b), [ICP] P16R16DIO (p16r16dio)
#define ACL7225_DI_LO 2 /* Digital input low byte (DI0-DI7) */
#define ACL7225_DI_HI 3 /* Digital input high byte (DI8-DI15) */
-static int acl7225b_attach(struct comedi_device *dev, struct comedi_devconfig * it);
+static int acl7225b_attach(struct comedi_device *dev,
+ struct comedi_devconfig *it);
static int acl7225b_detach(struct comedi_device *dev);
struct boardtype {
@@ -50,8 +51,9 @@ static struct comedi_driver driver_acl7225b = {
COMEDI_INITCLEANUP(driver_acl7225b);
-static int acl7225b_do_insn(struct comedi_device *dev, struct comedi_subdevice * s,
- struct comedi_insn *insn, unsigned int *data)
+static int acl7225b_do_insn(struct comedi_device *dev,
+ struct comedi_subdevice *s,
+ struct comedi_insn *insn, unsigned int *data)
{
if (insn->n != 2)
return -EINVAL;
@@ -64,26 +66,28 @@ static int acl7225b_do_insn(struct comedi_device *dev, struct comedi_subdevice *
outb(s->state & 0xff, dev->iobase + (unsigned long)s->private);
if (data[0] & 0xff00)
outb((s->state >> 8),
- dev->iobase + (unsigned long)s->private + 1);
+ dev->iobase + (unsigned long)s->private + 1);
data[1] = s->state;
return 2;
}
-static int acl7225b_di_insn(struct comedi_device *dev, struct comedi_subdevice * s,
- struct comedi_insn *insn, unsigned int *data)
+static int acl7225b_di_insn(struct comedi_device *dev,
+ struct comedi_subdevice *s,
+ struct comedi_insn *insn, unsigned int *data)
{
if (insn->n != 2)
return -EINVAL;
data[1] = inb(dev->iobase + (unsigned long)s->private) |
- (inb(dev->iobase + (unsigned long)s->private + 1) << 8);
+ (inb(dev->iobase + (unsigned long)s->private + 1) << 8);
return 2;
}
-static int acl7225b_attach(struct comedi_device *dev, struct comedi_devconfig * it)
+static int acl7225b_attach(struct comedi_device *dev,
+ struct comedi_devconfig *it)
{
struct comedi_subdevice *s;
int iobase, iorange;
@@ -91,7 +95,7 @@ static int acl7225b_attach(struct comedi_device *dev, struct comedi_devconfig *
iobase = it->options[0];
iorange = this_board->io_range;
printk("comedi%d: acl7225b: board=%s 0x%04x ", dev->minor,
- this_board->name, iobase);
+ this_board->name, iobase);
if (!request_region(iobase, iorange, "acl7225b")) {
printk("I/O port conflict\n");
return -EIO;
diff --git a/drivers/staging/comedi/drivers/adl_pci6208.c b/drivers/staging/comedi/drivers/adl_pci6208.c
index b4807fc7eb01..8e1befc448a3 100644
--- a/drivers/staging/comedi/drivers/adl_pci6208.c
+++ b/drivers/staging/comedi/drivers/adl_pci6208.c
@@ -66,23 +66,23 @@ struct pci6208_board {
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
@@ -90,8 +90,9 @@ static const struct pci6208_board pci6208_boards[] = {
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},
- {0}
+ {
+ PCI_VENDOR_ID_ADLINK, 0x6208, PCI_ANY_ID, PCI_ANY_ID, 0, 0, 0}, {
+ 0}
};
MODULE_DEVICE_TABLE(pci, pci6208_pci_table);
@@ -107,7 +108,8 @@ 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_attach(struct comedi_device *dev,
+ struct comedi_devconfig *it);
static int pci6208_detach(struct comedi_device *dev);
static struct comedi_driver driver_pci6208 = {
@@ -122,13 +124,15 @@ COMEDI_PCI_INITCLEANUP(driver_pci6208, pci6208_pci_table);
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);
+ 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_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, */
@@ -140,7 +144,8 @@ 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;
@@ -217,8 +222,9 @@ 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);
@@ -242,8 +248,9 @@ 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);
@@ -309,8 +316,8 @@ static int pci6208_find_device(struct comedi_device *dev, int bus, int slot)
int i;
for (pci_dev = pci_get_device(PCI_ANY_ID, PCI_ANY_ID, NULL);
- pci_dev != NULL;
- pci_dev = pci_get_device(PCI_ANY_ID, PCI_ANY_ID, pci_dev)) {
+ 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 < ARRAY_SIZE(pci6208_boards); i++) {
if (pci6208_boards[i].dev_id == pci_dev->device) {
@@ -318,9 +325,9 @@ static int pci6208_find_device(struct comedi_device *dev, int bus, int slot)
if ((bus != 0) || (slot != 0)) {
/* are we on the wrong bus/slot? */
if (pci_dev->bus->number
- != bus ||
- PCI_SLOT(pci_dev->devfn)
- != slot) {
+ != bus ||
+ PCI_SLOT(pci_dev->devfn)
+ != slot) {
continue;
}
}
@@ -332,16 +339,16 @@ static int pci6208_find_device(struct comedi_device *dev, int bus, int slot)
}
printk("comedi%d: no supported board found! (req. bus/slot : %d/%d)\n",
- dev->minor, bus, slot);
+ dev->minor, bus, slot);
return -EIO;
- found:
+found:
printk("comedi%d: found %s (b:s:f=%d:%d:%d) , irq=%d\n",
- dev->minor,
- pci6208_boards[i].name,
- pci_dev->bus->number,
- PCI_SLOT(pci_dev->devfn),
- PCI_FUNC(pci_dev->devfn), pci_dev->irq);
+ dev->minor,
+ pci6208_boards[i].name,
+ pci_dev->bus->number,
+ PCI_SLOT(pci_dev->devfn),
+ PCI_FUNC(pci_dev->devfn), pci_dev->irq);
/* TODO: Warn about non-tested boards. */
/* switch(board->device_id) */
@@ -355,13 +362,15 @@ 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)
+ int dev_minor)
{
unsigned long io_base, io_range, lcr_io_base, lcr_io_range;
/* 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);
+ 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]. */
@@ -369,14 +378,14 @@ pci6208_pci_setup(struct pci_dev *pci_dev, unsigned long *io_base_ptr,
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);
+ dev_minor, lcr_io_base, lcr_io_range);
/* 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;
printk("comedi%d: 6208 registers at address 0x%4lx [0x%4lx]\n",
- dev_minor, io_base, io_range);
+ dev_minor, io_base, io_range);
*io_base_ptr = io_base;
/* devpriv->io_range = io_range; */
diff --git a/drivers/staging/comedi/drivers/adl_pci7296.c b/drivers/staging/comedi/drivers/adl_pci7296.c
index d2f23a88608d..4de6fadec78b 100644
--- a/drivers/staging/comedi/drivers/adl_pci7296.c
+++ b/drivers/staging/comedi/drivers/adl_pci7296.c
@@ -49,9 +49,10 @@ Configuration Options:
#define PCI_DEVICE_ID_PCI7296 0x7296
static DEFINE_PCI_DEVICE_TABLE(adl_pci7296_pci_table) = {
- {PCI_VENDOR_ID_ADLINK, PCI_DEVICE_ID_PCI7296, PCI_ANY_ID, PCI_ANY_ID, 0,
- 0, 0},
- {0}
+ {
+ PCI_VENDOR_ID_ADLINK, PCI_DEVICE_ID_PCI7296, PCI_ANY_ID,
+ PCI_ANY_ID, 0, 0, 0}, {
+ 0}
};
MODULE_DEVICE_TABLE(pci, adl_pci7296_pci_table);
@@ -61,10 +62,10 @@ struct adl_pci7296_private {
struct pci_dev *pci_dev;
};
-
#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_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",
@@ -73,7 +74,8 @@ static struct comedi_driver driver_adl_pci7296 = {
.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;
@@ -94,21 +96,23 @@ static int adl_pci7296_attach(struct comedi_device *dev, struct comedi_devconfig
return -ENOMEM;
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)) {
+ pcidev != NULL;
+ pcidev = pci_get_device(PCI_ANY_ID, PCI_ANY_ID, pcidev)) {
if (pcidev->vendor == PCI_VENDOR_ID_ADLINK &&
- pcidev->device == PCI_DEVICE_ID_PCI7296) {
+ pcidev->device == PCI_DEVICE_ID_PCI7296) {
if (bus || slot) {
/* requested particular bus/slot */
if (pcidev->bus->number != bus
- || PCI_SLOT(pcidev->devfn) != slot) {
+ || PCI_SLOT(pcidev->devfn) != slot) {
continue;
}
}
devpriv->pci_dev = pcidev;
if (comedi_pci_enable(pcidev, "adl_pci7296") < 0) {
- printk("comedi%d: Failed to enable PCI device and request regions\n", dev->minor);
+ printk
+ ("comedi%d: Failed to enable PCI device and request regions\n",
+ dev->minor);
return -EIO;
}
@@ -118,23 +122,26 @@ static int adl_pci7296_attach(struct comedi_device *dev, struct comedi_devconfig
/* four 8255 digital io subdevices */
s = dev->subdevices + 0;
subdev_8255_init(dev, s, NULL,
- (unsigned long)(dev->iobase));
+ (unsigned long)(dev->iobase));
s = dev->subdevices + 1;
ret = subdev_8255_init(dev, s, NULL,
- (unsigned long)(dev->iobase + PORT2A));
+ (unsigned long)(dev->iobase +
+ PORT2A));
if (ret < 0)
return ret;
s = dev->subdevices + 2;
ret = subdev_8255_init(dev, s, NULL,
- (unsigned long)(dev->iobase + PORT3A));
+ (unsigned long)(dev->iobase +
+ PORT3A));
if (ret < 0)
return ret;
s = dev->subdevices + 3;
ret = subdev_8255_init(dev, s, NULL,
- (unsigned long)(dev->iobase + PORT4A));
+ (unsigned long)(dev->iobase +
+ PORT4A));
if (ret < 0)
return ret;
@@ -145,7 +152,7 @@ static int adl_pci7296_attach(struct comedi_device *dev, struct comedi_devconfig
}
printk("comedi%d: no supported board found! (req. bus/slot : %d/%d)\n",
- dev->minor, bus, slot);
+ dev->minor, bus, slot);
return -EIO;
}
diff --git a/drivers/staging/comedi/drivers/adl_pci7432.c b/drivers/staging/comedi/drivers/adl_pci7432.c
index 78becbdd17a8..e0844c69be77 100644
--- a/drivers/staging/comedi/drivers/adl_pci7432.c
+++ b/drivers/staging/comedi/drivers/adl_pci7432.c
@@ -44,9 +44,10 @@ Configuration Options:
#define PCI_DEVICE_ID_PCI7432 0x7432
static DEFINE_PCI_DEVICE_TABLE(adl_pci7432_pci_table) = {
- {PCI_VENDOR_ID_ADLINK, PCI_DEVICE_ID_PCI7432, PCI_ANY_ID, PCI_ANY_ID, 0,
- 0, 0},
- {0}
+ {
+ PCI_VENDOR_ID_ADLINK, PCI_DEVICE_ID_PCI7432, PCI_ANY_ID,
+ PCI_ANY_ID, 0, 0, 0}, {
+ 0}
};
MODULE_DEVICE_TABLE(pci, adl_pci7432_pci_table);
@@ -58,7 +59,8 @@ 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_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",
@@ -69,15 +71,20 @@ static struct comedi_driver driver_adl_pci7432 = {
/* 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;
@@ -97,21 +104,23 @@ static int adl_pci7432_attach(struct comedi_device *dev, struct comedi_devconfig
return -ENOMEM;
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)) {
+ pcidev != NULL;
+ pcidev = pci_get_device(PCI_ANY_ID, PCI_ANY_ID, pcidev)) {
if (pcidev->vendor == PCI_VENDOR_ID_ADLINK &&
- pcidev->device == PCI_DEVICE_ID_PCI7432) {
+ pcidev->device == PCI_DEVICE_ID_PCI7432) {
if (bus || slot) {
/* requested particular bus/slot */
if (pcidev->bus->number != bus
- || PCI_SLOT(pcidev->devfn) != slot) {
+ || PCI_SLOT(pcidev->devfn) != slot) {
continue;
}
}
devpriv->pci_dev = pcidev;
if (comedi_pci_enable(pcidev, "adl_pci7432") < 0) {
- printk("comedi%d: Failed to enable PCI device and request regions\n", dev->minor);
+ printk
+ ("comedi%d: Failed to enable PCI device and request regions\n",
+ dev->minor);
return -EIO;
}
dev->iobase = pci_resource_start(pcidev, 2);
@@ -120,7 +129,7 @@ static int adl_pci7432_attach(struct comedi_device *dev, struct comedi_devconfig
s = dev->subdevices + 0;
s->type = COMEDI_SUBD_DI;
s->subdev_flags =
- SDF_READABLE | SDF_GROUND | SDF_COMMON;
+ SDF_READABLE | SDF_GROUND | SDF_COMMON;
s->n_chan = 32;
s->maxdata = 1;
s->len_chanlist = 32;
@@ -131,7 +140,7 @@ static int adl_pci7432_attach(struct comedi_device *dev, struct comedi_devconfig
s = dev->subdevices + 1;
s->type = COMEDI_SUBD_DO;
s->subdev_flags =
- SDF_WRITABLE | SDF_GROUND | SDF_COMMON;
+ SDF_WRITABLE | SDF_GROUND | SDF_COMMON;
s->n_chan = 32;
s->maxdata = 1;
s->len_chanlist = 32;
@@ -146,7 +155,7 @@ static int adl_pci7432_attach(struct comedi_device *dev, struct comedi_devconfig
}
printk("comedi%d: no supported board found! (req. bus/slot : %d/%d)\n",
- dev->minor, bus, slot);
+ dev->minor, bus, slot);
return -EIO;
}
@@ -164,8 +173,10 @@ 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]);
@@ -178,14 +189,16 @@ static int adl_pci7432_do_insn_bits(struct comedi_device *dev, struct comedi_sub
s->state |= (data[0] & data[1]);
printk("comedi: out: %8x on iobase %4lx\n", s->state,
- dev->iobase + PCI7432_DO);
+ dev->iobase + PCI7432_DO);
outl(s->state & 0xffffffff, dev->iobase + PCI7432_DO);
}
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 2d7d68af6b1e..43745ec94ab5 100644
--- a/drivers/staging/comedi/drivers/adl_pci8164.c
+++ b/drivers/staging/comedi/drivers/adl_pci8164.c
@@ -56,9 +56,10 @@ Configuration Options:
#define PCI_DEVICE_ID_PCI8164 0x8164
static DEFINE_PCI_DEVICE_TABLE(adl_pci8164_pci_table) = {
- {PCI_VENDOR_ID_ADLINK, PCI_DEVICE_ID_PCI8164, PCI_ANY_ID, PCI_ANY_ID, 0,
- 0, 0},
- {0}
+ {
+ PCI_VENDOR_ID_ADLINK, PCI_DEVICE_ID_PCI8164, PCI_ANY_ID,
+ PCI_ANY_ID, 0, 0, 0}, {
+ 0}
};
MODULE_DEVICE_TABLE(pci, adl_pci8164_pci_table);
@@ -70,7 +71,8 @@ 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_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",
@@ -79,31 +81,48 @@ static struct comedi_driver driver_adl_pci8164 = {
.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);
+ 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);
+ 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;
@@ -123,21 +142,23 @@ static int adl_pci8164_attach(struct comedi_device *dev, struct comedi_devconfig
return -ENOMEM;
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)) {
+ pcidev != NULL;
+ pcidev = pci_get_device(PCI_ANY_ID, PCI_ANY_ID, pcidev)) {
if (pcidev->vendor == PCI_VENDOR_ID_ADLINK &&
- pcidev->device == PCI_DEVICE_ID_PCI8164) {
+ pcidev->device == PCI_DEVICE_ID_PCI8164) {
if (bus || slot) {
/* requested particular bus/slot */
if (pcidev->bus->number != bus
- || PCI_SLOT(pcidev->devfn) != slot) {
+ || PCI_SLOT(pcidev->devfn) != slot) {
continue;
}
}
devpriv->pci_dev = pcidev;
if (comedi_pci_enable(pcidev, "adl_pci8164") < 0) {
- printk("comedi%d: Failed to enable PCI device and request regions\n", dev->minor);
+ printk
+ ("comedi%d: Failed to enable PCI device and request regions\n",
+ dev->minor);
return -EIO;
}
dev->iobase = pci_resource_start(pcidev, 2);
@@ -190,7 +211,7 @@ static int adl_pci8164_attach(struct comedi_device *dev, struct comedi_devconfig
}
printk("comedi%d: no supported board found! (req. bus/slot : %d/%d)\n",
- dev->minor, bus, slot);
+ dev->minor, bus, slot);
return -EIO;
}
@@ -216,8 +237,7 @@ 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)
+ char *action, unsigned short offset)
{
int axis, axis_reg;
char *axisname;
@@ -247,8 +267,8 @@ static void adl_pci8164_insn_read(struct comedi_device *dev,
}
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);
+ 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,
@@ -260,22 +280,28 @@ static int adl_pci8164_insn_read_msts(struct comedi_device *dev,
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)
{
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)
{
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)
{
adl_pci8164_insn_read(dev, s, insn, data, "BUF1", PCI8164_BUF1);
return 2;
@@ -286,11 +312,10 @@ static int adl_pci8164_insn_read_buf1(struct comedi_device *dev, struct comedi_s
* 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)
+ struct comedi_subdevice *s,
+ struct comedi_insn *insn,
+ unsigned int *data,
+ char *action, unsigned short offset)
{
unsigned int axis, axis_reg;
@@ -327,30 +352,37 @@ static void adl_pci8164_insn_out(struct comedi_device *dev,
}
-
-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)
{
adl_pci8164_insn_out(dev, s, insn, data, "CMD", PCI8164_CMD);
return 2;
}
-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)
{
adl_pci8164_insn_out(dev, s, insn, data, "OTP", PCI8164_OTP);
return 2;
}
static int adl_pci8164_insn_write_buf0(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)
{
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)
+ 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 0ac722e6f37a..da172a553d15 100644
--- a/drivers/staging/comedi/drivers/adl_pci9111.c
+++ b/drivers/staging/comedi/drivers/adl_pci9111.c
@@ -264,27 +264,32 @@ TODO:
/* Function prototypes */
-static int pci9111_attach(struct comedi_device *dev, struct comedi_devconfig *it);
+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 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 = {
5,
{
- BIP_RANGE(10),
- BIP_RANGE(5),
- BIP_RANGE(2.5),
- BIP_RANGE(1.25),
- BIP_RANGE(0.625)
- }
+ BIP_RANGE(10),
+ BIP_RANGE(5),
+ BIP_RANGE(2.5),
+ BIP_RANGE(1.25),
+ BIP_RANGE(0.625)
+ }
};
static DEFINE_PCI_DEVICE_TABLE(pci9111_pci_table) = {
- {PCI_VENDOR_ID_ADLINK, PCI9111_HR_DEVICE_ID, PCI_ANY_ID, PCI_ANY_ID, 0,
- 0, 0},
- /* { PCI_VENDOR_ID_ADLINK, PCI9111_HG_DEVICE_ID, PCI_ANY_ID, PCI_ANY_ID, 0, 0, 0 }, */
- {0}
+ {
+ PCI_VENDOR_ID_ADLINK, PCI9111_HR_DEVICE_ID, PCI_ANY_ID,
+ PCI_ANY_ID, 0, 0, 0},
+ /* { PCI_VENDOR_ID_ADLINK, PCI9111_HG_DEVICE_ID, PCI_ANY_ID, PCI_ANY_ID, 0, 0, 0 }, */
+ {
+ 0}
};
MODULE_DEVICE_TABLE(pci, pci9111_pci_table);
@@ -309,17 +314,17 @@ 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 \
@@ -379,9 +384,11 @@ struct pci9111_private_data {
#define PLX9050_SOFTWARE_INTERRUPT (1 << 7)
static void plx9050_interrupt_control(unsigned long io_base,
- bool LINTi1_enable,
- bool LINTi1_active_high,
- bool LINTi2_enable, bool LINTi2_active_high, bool interrupt_enable)
+ bool LINTi1_enable,
+ bool LINTi1_active_high,
+ bool LINTi2_enable,
+ bool LINTi2_active_high,
+ bool interrupt_enable)
{
int flags = 0;
@@ -409,16 +416,19 @@ static void plx9050_interrupt_control(unsigned long io_base,
static void pci9111_timer_set(struct comedi_device *dev)
{
pci9111_8254_control_set(PCI9111_8254_COUNTER_0 |
- PCI9111_8254_READ_LOAD_LSB_MSB |
- PCI9111_8254_MODE_0 | PCI9111_8254_BINARY_COUNTER);
+ PCI9111_8254_READ_LOAD_LSB_MSB |
+ PCI9111_8254_MODE_0 |
+ PCI9111_8254_BINARY_COUNTER);
pci9111_8254_control_set(PCI9111_8254_COUNTER_1 |
- PCI9111_8254_READ_LOAD_LSB_MSB |
- PCI9111_8254_MODE_2 | PCI9111_8254_BINARY_COUNTER);
+ PCI9111_8254_READ_LOAD_LSB_MSB |
+ PCI9111_8254_MODE_2 |
+ PCI9111_8254_BINARY_COUNTER);
pci9111_8254_control_set(PCI9111_8254_COUNTER_2 |
- PCI9111_8254_READ_LOAD_LSB_MSB |
- PCI9111_8254_MODE_2 | PCI9111_8254_BINARY_COUNTER);
+ PCI9111_8254_READ_LOAD_LSB_MSB |
+ PCI9111_8254_MODE_2 |
+ PCI9111_8254_BINARY_COUNTER);
udelay(1);
@@ -433,7 +443,7 @@ enum pci9111_trigger_sources {
};
static void pci9111_trigger_source_set(struct comedi_device *dev,
- enum pci9111_trigger_sources source)
+ enum pci9111_trigger_sources source)
{
int flags;
@@ -491,7 +501,8 @@ enum pci9111_ISC1_sources {
};
static void pci9111_interrupt_source_set(struct comedi_device *dev,
- enum pci9111_ISC0_sources irq_0_source, enum pci9111_ISC1_sources irq_1_source)
+ enum pci9111_ISC0_sources irq_0_source,
+ enum pci9111_ISC1_sources irq_1_source)
{
int flags;
@@ -514,12 +525,13 @@ 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 */
plx9050_interrupt_control(dev_private->lcr_io_base, true, true, true,
- true, false);
+ true, false);
pci9111_trigger_source_set(dev, software);
@@ -543,19 +555,19 @@ static int pci9111_ai_cancel(struct comedi_device *dev, struct comedi_subdevice
static int
pci9111_ai_do_cmd_test(struct comedi_device *dev,
- struct comedi_subdevice *s, struct comedi_cmd *cmd)
+ struct comedi_subdevice *s, struct comedi_cmd *cmd)
{
int tmp;
int error = 0;
int range, reference;
int i;
- struct pci9111_board *board = (struct pci9111_board *) dev->board_ptr;
+ struct pci9111_board *board = (struct pci9111_board *)dev->board_ptr;
/* Step 1 : check if trigger are trivialy valid */
pci9111_check_trigger_src(cmd->start_src, TRIG_NOW);
pci9111_check_trigger_src(cmd->scan_begin_src,
- TRIG_TIMER | TRIG_FOLLOW | TRIG_EXT);
+ TRIG_TIMER | TRIG_FOLLOW | TRIG_EXT);
pci9111_check_trigger_src(cmd->convert_src, TRIG_TIMER | TRIG_EXT);
pci9111_check_trigger_src(cmd->scan_end_src, TRIG_COUNT);
pci9111_check_trigger_src(cmd->stop_src, TRIG_COUNT | TRIG_NONE);
@@ -569,21 +581,21 @@ pci9111_ai_do_cmd_test(struct comedi_device *dev,
error++;
if ((cmd->scan_begin_src != TRIG_TIMER) &&
- (cmd->scan_begin_src != TRIG_FOLLOW) &&
- (cmd->scan_begin_src != TRIG_EXT))
+ (cmd->scan_begin_src != TRIG_FOLLOW) &&
+ (cmd->scan_begin_src != TRIG_EXT))
error++;
if ((cmd->convert_src != TRIG_TIMER) && (cmd->convert_src != TRIG_EXT)) {
error++;
}
if ((cmd->convert_src == TRIG_TIMER) &&
- !((cmd->scan_begin_src == TRIG_TIMER) ||
- (cmd->scan_begin_src == TRIG_FOLLOW))) {
+ !((cmd->scan_begin_src == TRIG_TIMER) ||
+ (cmd->scan_begin_src == TRIG_FOLLOW))) {
error++;
}
if ((cmd->convert_src == TRIG_EXT) &&
- !((cmd->scan_begin_src == TRIG_EXT) ||
- (cmd->scan_begin_src == TRIG_FOLLOW))) {
+ !((cmd->scan_begin_src == TRIG_EXT) ||
+ (cmd->scan_begin_src == TRIG_FOLLOW))) {
error++;
}
@@ -613,7 +625,7 @@ pci9111_ai_do_cmd_test(struct comedi_device *dev,
}
if ((cmd->convert_src == TRIG_TIMER) &&
- (cmd->convert_arg < board->ai_acquisition_period_min_ns)) {
+ (cmd->convert_arg < board->ai_acquisition_period_min_ns)) {
cmd->convert_arg = board->ai_acquisition_period_min_ns;
error++;
}
@@ -623,7 +635,7 @@ pci9111_ai_do_cmd_test(struct comedi_device *dev,
}
if ((cmd->scan_begin_src == TRIG_TIMER) &&
- (cmd->scan_begin_arg < board->ai_acquisition_period_min_ns)) {
+ (cmd->scan_begin_arg < board->ai_acquisition_period_min_ns)) {
cmd->scan_begin_arg = board->ai_acquisition_period_min_ns;
error++;
}
@@ -637,7 +649,7 @@ pci9111_ai_do_cmd_test(struct comedi_device *dev,
}
if ((cmd->scan_end_src == TRIG_COUNT) &&
- (cmd->scan_end_arg != cmd->chanlist_len)) {
+ (cmd->scan_end_arg != cmd->chanlist_len)) {
cmd->scan_end_arg = cmd->chanlist_len;
error++;
}
@@ -659,9 +671,10 @@ pci9111_ai_do_cmd_test(struct comedi_device *dev,
if (cmd->convert_src == TRIG_TIMER) {
tmp = cmd->convert_arg;
i8253_cascade_ns_to_timer_2div(PCI9111_8254_CLOCK_PERIOD_NS,
- &(dev_private->timer_divisor_1),
- &(dev_private->timer_divisor_2),
- &(cmd->convert_arg), cmd->flags & TRIG_ROUND_MASK);
+ &(dev_private->timer_divisor_1),
+ &(dev_private->timer_divisor_2),
+ &(cmd->convert_arg),
+ cmd->flags & TRIG_ROUND_MASK);
if (tmp != cmd->convert_arg)
error++;
}
@@ -679,7 +692,7 @@ pci9111_ai_do_cmd_test(struct comedi_device *dev,
if (cmd->scan_begin_arg != scan_begin_min) {
if (scan_begin_min < cmd->scan_begin_arg) {
scan_factor =
- cmd->scan_begin_arg / scan_begin_min;
+ cmd->scan_begin_arg / scan_begin_min;
scan_begin_arg = scan_factor * scan_begin_min;
if (cmd->scan_begin_arg != scan_begin_arg) {
cmd->scan_begin_arg = scan_begin_arg;
@@ -706,27 +719,27 @@ pci9111_ai_do_cmd_test(struct comedi_device *dev,
for (i = 0; i < cmd->chanlist_len; i++) {
if (CR_CHAN(cmd->chanlist[i]) != i) {
comedi_error(dev,
- "entries in chanlist must be consecutive "
- "channels,counting upwards from 0\n");
+ "entries in chanlist must be consecutive "
+ "channels,counting upwards from 0\n");
error++;
}
if (CR_RANGE(cmd->chanlist[i]) != range) {
comedi_error(dev,
- "entries in chanlist must all have the same gain\n");
+ "entries in chanlist must all have the same gain\n");
error++;
}
if (CR_AREF(cmd->chanlist[i]) != reference) {
comedi_error(dev,
- "entries in chanlist must all have the same reference\n");
+ "entries in chanlist must all have the same reference\n");
error++;
}
}
} else {
if ((CR_CHAN(cmd->chanlist[0]) >
- (board->ai_channel_nbr - 1))
- || (CR_CHAN(cmd->chanlist[0]) < 0)) {
+ (board->ai_channel_nbr - 1))
+ || (CR_CHAN(cmd->chanlist[0]) < 0)) {
comedi_error(dev,
- "channel number is out of limits\n");
+ "channel number is out of limits\n");
error++;
}
}
@@ -741,13 +754,14 @@ 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;
if (!dev->irq) {
comedi_error(dev,
- "no irq assigned for PCI9111, cannot do hardware conversion");
+ "no irq assigned for PCI9111, cannot do hardware conversion");
return -1;
}
/* Set channel scan limit */
@@ -772,7 +786,7 @@ static int pci9111_ai_do_cmd(struct comedi_device *dev, struct comedi_subdevice
switch (async_cmd->stop_src) {
case TRIG_COUNT:
dev_private->stop_counter =
- async_cmd->stop_arg * async_cmd->chanlist_len;
+ async_cmd->stop_arg * async_cmd->chanlist_len;
dev_private->stop_is_none = 0;
break;
@@ -792,28 +806,29 @@ static int pci9111_ai_do_cmd(struct comedi_device *dev, struct comedi_subdevice
switch (async_cmd->convert_src) {
case TRIG_TIMER:
i8253_cascade_ns_to_timer_2div(PCI9111_8254_CLOCK_PERIOD_NS,
- &(dev_private->timer_divisor_1),
- &(dev_private->timer_divisor_2),
- &(async_cmd->convert_arg),
- async_cmd->flags & TRIG_ROUND_MASK);
+ &(dev_private->timer_divisor_1),
+ &(dev_private->timer_divisor_2),
+ &(async_cmd->convert_arg),
+ async_cmd->
+ flags & TRIG_ROUND_MASK);
#ifdef AI_DO_CMD_DEBUG
printk(PCI9111_DRIVER_NAME ": divisors = %d, %d\n",
- dev_private->timer_divisor_1,
- dev_private->timer_divisor_2);
+ dev_private->timer_divisor_1,
+ dev_private->timer_divisor_2);
#endif
pci9111_trigger_source_set(dev, software);
pci9111_timer_set(dev);
pci9111_fifo_reset();
pci9111_interrupt_source_set(dev, irq_on_fifo_half_full,
- irq_on_timer_tick);
+ irq_on_timer_tick);
pci9111_trigger_source_set(dev, timer_pacer);
plx9050_interrupt_control(dev_private->lcr_io_base, true, true,
- false, true, true);
+ false, true, true);
dev_private->scan_delay =
- (async_cmd->scan_begin_arg / (async_cmd->convert_arg *
- async_cmd->chanlist_len)) - 1;
+ (async_cmd->scan_begin_arg / (async_cmd->convert_arg *
+ async_cmd->chanlist_len)) - 1;
break;
@@ -822,9 +837,9 @@ static int pci9111_ai_do_cmd(struct comedi_device *dev, struct comedi_subdevice
pci9111_trigger_source_set(dev, external);
pci9111_fifo_reset();
pci9111_interrupt_source_set(dev, irq_on_fifo_half_full,
- irq_on_timer_tick);
+ irq_on_timer_tick);
plx9050_interrupt_control(dev_private->lcr_io_base, true, true,
- false, true, true);
+ false, true, true);
break;
@@ -837,45 +852,47 @@ static int pci9111_ai_do_cmd(struct comedi_device *dev, struct comedi_subdevice
dev_private->chanlist_len = async_cmd->chanlist_len;
dev_private->chunk_counter = 0;
dev_private->chunk_num_samples =
- dev_private->chanlist_len * (1 + dev_private->scan_delay);
+ dev_private->chanlist_len * (1 + dev_private->scan_delay);
#ifdef AI_DO_CMD_DEBUG
printk(PCI9111_DRIVER_NAME ": start interruptions!\n");
printk(PCI9111_DRIVER_NAME ": trigger source = %2x\n",
- pci9111_trigger_and_autoscan_get());
+ pci9111_trigger_and_autoscan_get());
printk(PCI9111_DRIVER_NAME ": irq source = %2x\n",
- pci9111_interrupt_and_fifo_get());
+ pci9111_interrupt_and_fifo_get());
printk(PCI9111_DRIVER_NAME ": ai_do_cmd\n");
printk(PCI9111_DRIVER_NAME ": stop counter = %d\n",
- dev_private->stop_counter);
+ dev_private->stop_counter);
printk(PCI9111_DRIVER_NAME ": scan delay = %d\n",
- dev_private->scan_delay);
+ dev_private->scan_delay);
printk(PCI9111_DRIVER_NAME ": chanlist_len = %d\n",
- dev_private->chanlist_len);
+ dev_private->chanlist_len);
printk(PCI9111_DRIVER_NAME ": chunk num samples = %d\n",
- dev_private->chunk_num_samples);
+ dev_private->chunk_num_samples);
#endif
return 0;
}
-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 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);
short *array = data;
int resolution =
- ((struct pci9111_board *) dev->board_ptr)->ai_resolution;
+ ((struct pci9111_board *)dev->board_ptr)->ai_resolution;
for (i = 0; i < num_samples; i++) {
if (resolution == PCI9111_HR_AI_RESOLUTION)
array[i] =
- (array[i] & PCI9111_HR_AI_RESOLUTION_MASK) ^
- PCI9111_HR_AI_RESOLUTION_2_CMP_BIT;
+ (array[i] & PCI9111_HR_AI_RESOLUTION_MASK) ^
+ PCI9111_HR_AI_RESOLUTION_2_CMP_BIT;
else
array[i] =
- ((array[i] >> 4) & PCI9111_AI_RESOLUTION_MASK) ^
- PCI9111_AI_RESOLUTION_2_CMP_BIT;
+ ((array[i] >> 4) & PCI9111_AI_RESOLUTION_MASK) ^
+ PCI9111_AI_RESOLUTION_2_CMP_BIT;
}
}
@@ -905,18 +922,12 @@ static irqreturn_t pci9111_interrupt(int irq, void *p_device)
/* Check if we are source of interrupt */
intcsr = inb(dev_private->lcr_io_base +
- PLX9050_REGISTER_INTERRUPT_CONTROL);
+ PLX9050_REGISTER_INTERRUPT_CONTROL);
if (!(((intcsr & PLX9050_PCI_INTERRUPT_ENABLE) != 0)
- && (((intcsr & (PLX9050_LINTI1_ENABLE |
- PLX9050_LINTI1_STATUS))
- ==
- (PLX9050_LINTI1_ENABLE |
- PLX9050_LINTI1_STATUS))
- || ((intcsr & (PLX9050_LINTI2_ENABLE |
- PLX9050_LINTI2_STATUS))
- ==
- (PLX9050_LINTI2_ENABLE |
- PLX9050_LINTI2_STATUS))))) {
+ && (((intcsr & (PLX9050_LINTI1_ENABLE | PLX9050_LINTI1_STATUS))
+ == (PLX9050_LINTI1_ENABLE | PLX9050_LINTI1_STATUS))
+ || ((intcsr & (PLX9050_LINTI2_ENABLE | PLX9050_LINTI2_STATUS))
+ == (PLX9050_LINTI2_ENABLE | PLX9050_LINTI2_STATUS))))) {
/* Not the source of the interrupt. */
/* (N.B. not using PLX9050_SOFTWARE_INTERRUPT) */
spin_unlock_irqrestore(&dev->spinlock, irq_flags);
@@ -924,12 +935,11 @@ static irqreturn_t pci9111_interrupt(int irq, void *p_device)
}
if ((intcsr & (PLX9050_LINTI1_ENABLE | PLX9050_LINTI1_STATUS)) ==
- (PLX9050_LINTI1_ENABLE | PLX9050_LINTI1_STATUS)) {
+ (PLX9050_LINTI1_ENABLE | PLX9050_LINTI1_STATUS)) {
/* Interrupt comes from fifo_half-full signal */
if (pci9111_is_fifo_full()) {
- spin_unlock_irqrestore(&dev->spinlock,
- irq_flags);
+ spin_unlock_irqrestore(&dev->spinlock, irq_flags);
comedi_error(dev, PCI9111_DRIVER_NAME " fifo overflow");
pci9111_interrupt_clear();
pci9111_ai_cancel(dev, subdevice);
@@ -948,73 +958,70 @@ static irqreturn_t pci9111_interrupt(int irq, void *p_device)
#endif
num_samples =
- PCI9111_FIFO_HALF_SIZE >
- dev_private->stop_counter
- && !dev_private->stop_is_none ? dev_private->
- stop_counter : PCI9111_FIFO_HALF_SIZE;
+ PCI9111_FIFO_HALF_SIZE >
+ dev_private->stop_counter
+ && !dev_private->
+ stop_is_none ? dev_private->stop_counter :
+ PCI9111_FIFO_HALF_SIZE;
insw(PCI9111_IO_BASE + PCI9111_REGISTER_AD_FIFO_VALUE,
- dev_private->ai_bounce_buffer, num_samples);
+ dev_private->ai_bounce_buffer, num_samples);
if (dev_private->scan_delay < 1) {
bytes_written =
- cfc_write_array_to_buffer(subdevice,
- dev_private->ai_bounce_buffer,
- num_samples * sizeof(short));
+ cfc_write_array_to_buffer(subdevice,
+ dev_private->
+ ai_bounce_buffer,
+ num_samples *
+ sizeof(short));
} else {
int position = 0;
int to_read;
while (position < num_samples) {
if (dev_private->chunk_counter <
- dev_private->chanlist_len) {
+ dev_private->chanlist_len) {
to_read =
- dev_private->
- chanlist_len -
- dev_private->
- chunk_counter;
+ dev_private->chanlist_len -
+ dev_private->chunk_counter;
if (to_read >
- num_samples - position)
+ num_samples - position)
to_read =
- num_samples -
- position;
+ num_samples -
+ position;
bytes_written +=
- cfc_write_array_to_buffer
- (subdevice,
- dev_private->
- ai_bounce_buffer +
- position,
- to_read *
- sizeof(short));
+ cfc_write_array_to_buffer
+ (subdevice,
+ dev_private->ai_bounce_buffer
+ + position,
+ to_read * sizeof(short));
} else {
to_read =
- dev_private->
- chunk_num_samples -
- dev_private->
- chunk_counter;
+ dev_private->chunk_num_samples
+ -
+ dev_private->chunk_counter;
if (to_read >
- num_samples - position)
+ num_samples - position)
to_read =
- num_samples -
- position;
+ num_samples -
+ position;
bytes_written +=
- sizeof(short) *
- to_read;
+ sizeof(short) * to_read;
}
position += to_read;
dev_private->chunk_counter += to_read;
if (dev_private->chunk_counter >=
- dev_private->chunk_num_samples)
+ dev_private->chunk_num_samples)
dev_private->chunk_counter = 0;
}
}
dev_private->stop_counter -=
- bytes_written / sizeof(short);
+ bytes_written / sizeof(short);
}
}
@@ -1044,17 +1051,18 @@ static irqreturn_t pci9111_interrupt(int irq, void *p_device)
#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)
+ struct comedi_subdevice *subdevice,
+ struct comedi_insn *insn, unsigned int *data)
{
int resolution =
- ((struct pci9111_board *) dev->board_ptr)->ai_resolution;
+ ((struct pci9111_board *)dev->board_ptr)->ai_resolution;
int timeout, i;
#ifdef AI_INSN_DEBUG
printk(PCI9111_DRIVER_NAME ": ai_insn set c/r/n = %2x/%2x/%2x\n",
- CR_CHAN((&insn->chanspec)[0]),
- CR_RANGE((&insn->chanspec)[0]), insn->n);
+ CR_CHAN((&insn->chanspec)[0]),
+ CR_RANGE((&insn->chanspec)[0]), insn->n);
#endif
pci9111_ai_channel_set(CR_CHAN((&insn->chanspec)[0]));
@@ -1080,7 +1088,7 @@ static int pci9111_ai_insn_read(struct comedi_device *dev,
pci9111_fifo_reset();
return -ETIME;
- conversion_done:
+conversion_done:
if (resolution == PCI9111_HR_AI_RESOLUTION) {
data[i] = pci9111_hr_ai_get_data();
@@ -1091,8 +1099,8 @@ static int pci9111_ai_insn_read(struct comedi_device *dev,
#ifdef AI_INSN_DEBUG
printk(PCI9111_DRIVER_NAME ": ai_insn get c/r/t = %2x/%2x/%2x\n",
- pci9111_ai_channel_get(),
- pci9111_ai_range_get(), pci9111_trigger_and_autoscan_get());
+ pci9111_ai_channel_get(),
+ pci9111_ai_range_get(), pci9111_trigger_and_autoscan_get());
#endif
return i;
@@ -1102,7 +1110,8 @@ static int pci9111_ai_insn_read(struct comedi_device *dev,
static int
pci9111_ao_insn_write(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)
{
int i;
@@ -1117,7 +1126,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)
+ struct comedi_subdevice *s,
+ struct comedi_insn *insn, unsigned int *data)
{
int i;
@@ -1135,7 +1145,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)
+ struct comedi_subdevice *subdevice,
+ struct comedi_insn *insn, unsigned int *data)
{
unsigned int bits;
@@ -1148,7 +1159,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)
+ struct comedi_subdevice *subdevice,
+ struct comedi_insn *insn, unsigned int *data)
{
unsigned int bits;
@@ -1181,7 +1193,7 @@ static int pci9111_reset(struct comedi_device *dev)
/* Set trigger source to software */
plx9050_interrupt_control(dev_private->lcr_io_base, true, true, true,
- true, false);
+ true, false);
pci9111_trigger_source_set(dev, software);
pci9111_pretrigger_set(dev, false);
@@ -1201,7 +1213,8 @@ 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;
@@ -1217,29 +1230,29 @@ static int pci9111_attach(struct comedi_device *dev, struct comedi_devconfig *it
printk("comedi%d: " PCI9111_DRIVER_NAME " driver\n", dev->minor);
for (pci_device = pci_get_device(PCI_ANY_ID, PCI_ANY_ID, NULL);
- pci_device != NULL;
- pci_device =
- pci_get_device(PCI_ANY_ID, PCI_ANY_ID, pci_device)) {
+ pci_device != NULL;
+ pci_device = pci_get_device(PCI_ANY_ID, PCI_ANY_ID, pci_device)) {
if (pci_device->vendor == PCI_VENDOR_ID_ADLINK) {
for (i = 0; i < pci9111_board_nbr; i++) {
if (pci9111_boards[i].device_id ==
- pci_device->device) {
+ pci_device->device) {
/* was a particular bus/slot requested? */
if ((it->options[0] != 0)
- || (it->options[1] != 0)) {
+ || (it->options[1] != 0)) {
/* are we on the wrong bus/slot? */
if (pci_device->bus->number !=
- it->options[0]
- || PCI_SLOT(pci_device->
- devfn) !=
- it->options[1]) {
+ it->options[0]
+ ||
+ PCI_SLOT(pci_device->devfn)
+ != it->options[1]) {
continue;
}
}
dev->board_ptr = pci9111_boards + i;
- board = (struct pci9111_board *) dev->
- board_ptr;
+ board =
+ (struct pci9111_board *)
+ dev->board_ptr;
dev_private->pci_device = pci_device;
goto found;
}
@@ -1248,17 +1261,17 @@ static int pci9111_attach(struct comedi_device *dev, struct comedi_devconfig *it
}
printk("comedi%d: no supported board found! (req. bus/slot : %d/%d)\n",
- dev->minor, it->options[0], it->options[1]);
+ dev->minor, it->options[0], it->options[1]);
return -EIO;
- found:
+found:
printk("comedi%d: found %s (b:s:f=%d:%d:%d) , irq=%d\n",
- dev->minor,
- pci9111_boards[i].name,
- pci_device->bus->number,
- PCI_SLOT(pci_device->devfn),
- PCI_FUNC(pci_device->devfn), pci_device->irq);
+ dev->minor,
+ pci9111_boards[i].name,
+ pci_device->bus->number,
+ PCI_SLOT(pci_device->devfn),
+ PCI_FUNC(pci_device->devfn), pci_device->irq);
/* TODO: Warn about non-tested boards. */
@@ -1270,11 +1283,15 @@ static int pci9111_attach(struct comedi_device *dev, struct comedi_devconfig *it
lcr_io_base = pci_resource_start(pci_device, 1);
lcr_io_range = pci_resource_len(pci_device, 1);
- printk("comedi%d: local configuration registers at address 0x%4lx [0x%4lx]\n", dev->minor, lcr_io_base, lcr_io_range);
+ printk
+ ("comedi%d: local configuration registers at address 0x%4lx [0x%4lx]\n",
+ dev->minor, lcr_io_base, lcr_io_range);
/* Enable PCI device and request regions */
if (comedi_pci_enable(pci_device, PCI9111_DRIVER_NAME) < 0) {
- printk("comedi%d: Failed to enable PCI device and request regions\n", dev->minor);
+ printk
+ ("comedi%d: Failed to enable PCI device and request regions\n",
+ dev->minor);
return -EIO;
}
/* Read PCI6308 register base address [PCI_BASE_ADDRESS #2]. */
@@ -1283,7 +1300,7 @@ static int pci9111_attach(struct comedi_device *dev, struct comedi_devconfig *it
io_range = pci_resource_len(pci_device, 2);
printk("comedi%d: 6503 registers at address 0x%4lx [0x%4lx]\n",
- dev->minor, io_base, io_range);
+ dev->minor, io_base, io_range);
dev->iobase = io_base;
dev->board_name = board->name;
@@ -1301,7 +1318,7 @@ static int pci9111_attach(struct comedi_device *dev, struct comedi_devconfig *it
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);
+ dev->minor, pci_device->irq);
return -EINVAL;
}
}
diff --git a/drivers/staging/comedi/drivers/adl_pci9118.c b/drivers/staging/comedi/drivers/adl_pci9118.c
index 65f522be9124..1ee4b6a91c1f 100644
--- a/drivers/staging/comedi/drivers/adl_pci9118.c
+++ b/drivers/staging/comedi/drivers/adl_pci9118.c
@@ -154,32 +154,33 @@ Configuration options:
#define EXTTRG_AI 0 /* ext trg is used by AI */
static const struct comedi_lrange range_pci9118dg_hr = { 8, {
- BIP_RANGE(5),
- BIP_RANGE(2.5),
- BIP_RANGE(1.25),
- BIP_RANGE(0.625),
- UNI_RANGE(10),
- UNI_RANGE(5),
- UNI_RANGE(2.5),
- UNI_RANGE(1.25)
- }
+ BIP_RANGE(5),
+ BIP_RANGE(2.5),
+ BIP_RANGE(1.25),
+ BIP_RANGE(0.625),
+ UNI_RANGE(10),
+ UNI_RANGE(5),
+ UNI_RANGE(2.5),
+ UNI_RANGE(1.25)
+ }
};
static const struct comedi_lrange range_pci9118hg = { 8, {
- BIP_RANGE(5),
- BIP_RANGE(0.5),
- BIP_RANGE(0.05),
- BIP_RANGE(0.005),
- UNI_RANGE(10),
- UNI_RANGE(1),
- UNI_RANGE(0.1),
- UNI_RANGE(0.01)
- }
+ BIP_RANGE(5),
+ BIP_RANGE(0.5),
+ BIP_RANGE(0.05),
+ BIP_RANGE(0.005),
+ UNI_RANGE(10),
+ UNI_RANGE(1),
+ UNI_RANGE(0.1),
+ UNI_RANGE(0.01)
+ }
};
#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_attach(struct comedi_device *dev,
+ struct comedi_devconfig *it);
static int pci9118_detach(struct comedi_device *dev);
struct boardtype {
@@ -204,28 +205,29 @@ struct boardtype {
};
static DEFINE_PCI_DEVICE_TABLE(pci9118_pci_table) = {
- {PCI_VENDOR_ID_AMCC, 0x80d9, PCI_ANY_ID, PCI_ANY_ID, 0, 0, 0},
- {0}
+ {
+ PCI_VENDOR_ID_AMCC, 0x80d9, PCI_ANY_ID, PCI_ANY_ID, 0, 0, 0}, {
+ 0}
};
MODULE_DEVICE_TABLE(pci, pci9118_pci_table);
static const struct boardtype boardtypes[] = {
{"pci9118dg", PCI_VENDOR_ID_AMCC, 0x80d9,
- AMCC_OP_REG_SIZE, IORANGE_9118,
- 16, 8, 256, PCI9118_CHANLEN, 2, 0x0fff, 0x0fff,
- &range_pci9118dg_hr, &range_bipolar10,
- 3000, 12, 512},
+ AMCC_OP_REG_SIZE, IORANGE_9118,
+ 16, 8, 256, PCI9118_CHANLEN, 2, 0x0fff, 0x0fff,
+ &range_pci9118dg_hr, &range_bipolar10,
+ 3000, 12, 512},
{"pci9118hg", PCI_VENDOR_ID_AMCC, 0x80d9,
- AMCC_OP_REG_SIZE, IORANGE_9118,
- 16, 8, 256, PCI9118_CHANLEN, 2, 0x0fff, 0x0fff,
- &range_pci9118hg, &range_bipolar10,
- 3000, 12, 512},
+ AMCC_OP_REG_SIZE, IORANGE_9118,
+ 16, 8, 256, PCI9118_CHANLEN, 2, 0x0fff, 0x0fff,
+ &range_pci9118hg, &range_bipolar10,
+ 3000, 12, 512},
{"pci9118hr", PCI_VENDOR_ID_AMCC, 0x80d9,
- AMCC_OP_REG_SIZE, IORANGE_9118,
- 16, 8, 256, PCI9118_CHANLEN, 2, 0xffff, 0x0fff,
- &range_pci9118dg_hr, &range_bipolar10,
- 10000, 40, 512},
+ AMCC_OP_REG_SIZE, IORANGE_9118,
+ 16, 8, 256, PCI9118_CHANLEN, 2, 0xffff, 0x0fff,
+ &range_pci9118dg_hr, &range_bipolar10,
+ 10000, 40, 512},
};
#define n_boardtypes (sizeof(boardtypes)/sizeof(struct boardtype))
@@ -309,27 +311,34 @@ struct pci9118_private {
==============================================================================
*/
-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,
- 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,
- unsigned int divisor2);
+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, 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, 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 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);
+ 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;
@@ -358,15 +367,14 @@ static int pci9118_insn_read_ai(struct comedi_device *dev, struct comedi_subdevi
outl(0, dev->iobase + PCI9118_DELFIFO); /* flush FIFO */
return -ETIME;
- conv_finish:
+conv_finish:
if (devpriv->ai16bits) {
data[n] =
- (inl(dev->iobase +
- PCI9118_AD_DATA) & 0xffff) ^ 0x8000;
+ (inl(dev->iobase +
+ PCI9118_AD_DATA) & 0xffff) ^ 0x8000;
} else {
data[n] =
- (inw(dev->iobase +
- PCI9118_AD_DATA) >> 4) & 0xfff;
+ (inw(dev->iobase + PCI9118_AD_DATA) >> 4) & 0xfff;
}
}
@@ -378,8 +386,9 @@ static int pci9118_insn_read_ai(struct comedi_device *dev, struct comedi_subdevi
/*
==============================================================================
*/
-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;
@@ -401,8 +410,9 @@ static int pci9118_insn_write_ao(struct comedi_device *dev, struct comedi_subdev
/*
==============================================================================
*/
-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;
@@ -416,8 +426,9 @@ static int pci9118_insn_read_ao(struct comedi_device *dev, struct comedi_subdevi
/*
==============================================================================
*/
-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;
@@ -427,8 +438,9 @@ static int pci9118_insn_bits_di(struct comedi_device *dev, struct comedi_subdevi
/*
==============================================================================
*/
-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];
@@ -446,29 +458,31 @@ static int pci9118_insn_bits_do(struct comedi_device *dev, struct comedi_subdevi
static void interrupt_pci9118_ai_mode4_switch(struct comedi_device *dev)
{
devpriv->AdFunctionReg =
- AdFunction_PDTrg | AdFunction_PETrg | AdFunction_AM;
+ AdFunction_PDTrg | AdFunction_PETrg | AdFunction_AM;
outl(devpriv->AdFunctionReg, dev->iobase + PCI9118_ADFUNC);
outl(0x30, dev->iobase + PCI9118_CNTCTRL);
outl((devpriv->dmabuf_hw[1 - devpriv->dma_actbuf] >> 1) & 0xff,
- dev->iobase + PCI9118_CNT0);
+ dev->iobase + PCI9118_CNT0);
outl((devpriv->dmabuf_hw[1 - devpriv->dma_actbuf] >> 9) & 0xff,
- dev->iobase + PCI9118_CNT0);
+ dev->iobase + PCI9118_CNT0);
devpriv->AdFunctionReg |= AdFunction_Start;
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)
+ 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,
- stop_pos = devpriv->ai_add_front + devpriv->ai_n_chan;
+ stop_pos = devpriv->ai_add_front + devpriv->ai_n_chan;
unsigned int raw_scanlen = devpriv->ai_add_front + devpriv->ai_n_chan +
- devpriv->ai_add_back;
+ devpriv->ai_add_back;
for (i = 0; i < num_samples; i++) {
if (devpriv->ai_act_dmapos >= start_pos &&
- devpriv->ai_act_dmapos < stop_pos) {
+ devpriv->ai_act_dmapos < stop_pos) {
dma_buffer[j++] = dma_buffer[i];
}
devpriv->ai_act_dmapos++;
@@ -482,18 +496,20 @@ 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)
+ struct comedi_subdevice *s,
+ short *dma_buffer,
+ unsigned int num_samples)
{
unsigned int num_bytes;
num_samples = defragment_dma_buffer(dev, s, dma_buffer, num_samples);
devpriv->ai_act_scan +=
- (s->async->cur_chan + num_samples) / devpriv->ai_n_scanlen;
+ (s->async->cur_chan + num_samples) / devpriv->ai_n_scanlen;
s->async->cur_chan += num_samples;
s->async->cur_chan %= devpriv->ai_n_scanlen;
num_bytes =
- cfc_write_array_to_buffer(s, dma_buffer,
- num_samples * sizeof(short));
+ cfc_write_array_to_buffer(s, dma_buffer,
+ num_samples * sizeof(short));
if (num_bytes < num_samples * sizeof(short))
return -1;
return 0;
@@ -503,7 +519,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)
+ struct comedi_subdevice *s,
+ unsigned char m)
{
if (m & 0x100) {
comedi_error(dev, "A/D FIFO Full status (Fatal Error!)");
@@ -511,7 +528,7 @@ static char pci9118_decode_error_status(struct comedi_device *dev,
}
if (m & 0x008) {
comedi_error(dev,
- "A/D Burst Mode Overrun Status (Fatal Error!)");
+ "A/D Burst Mode Overrun Status (Fatal Error!)");
devpriv->ai_maskerr &= ~0x008L;
}
if (m & 0x004) {
@@ -532,8 +549,10 @@ 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,
- void *data, unsigned int num_bytes, unsigned int start_chan_index)
+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);
short *array = data;
@@ -553,8 +572,10 @@ 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,
- unsigned short int_daq)
+ struct comedi_subdevice *s,
+ unsigned short int_adstat,
+ unsigned int int_amcc,
+ unsigned short int_daq)
{
register short sampl;
@@ -570,9 +591,9 @@ static void interrupt_pci9118_ai_onesample(struct comedi_device *dev,
if (devpriv->ai16bits == 0) {
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]);
+ ("comedi: A/D SAMPL - data dropout: received channel %d, expected %d!\n",
+ sampl & 0x000f,
+ devpriv->chanlist[s->async->cur_chan]);
s->async->events |= COMEDI_CB_ERROR | COMEDI_CB_EOA;
pci9118_ai_cancel(dev, s);
comedi_event(dev, s);
@@ -599,9 +620,11 @@ static void interrupt_pci9118_ai_onesample(struct comedi_device *dev,
/*
==============================================================================
*/
-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)
+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)
{
unsigned int next_dma_buf, samplesinbuf, sampls, m;
@@ -632,11 +655,11 @@ static void interrupt_pci9118_ai_dma(struct comedi_device *dev, struct comedi_su
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);
+ devpriv->iobase_a + AMCC_OP_REG_MWAR);
outl(devpriv->dmabuf_use_size[next_dma_buf],
- devpriv->iobase_a + AMCC_OP_REG_MWTC);
+ devpriv->iobase_a + AMCC_OP_REG_MWTC);
devpriv->dmabuf_used_size[next_dma_buf] =
- devpriv->dmabuf_use_size[next_dma_buf];
+ devpriv->dmabuf_use_size[next_dma_buf];
if (devpriv->ai_do == 4)
interrupt_pci9118_ai_mode4_switch(dev);
}
@@ -646,8 +669,8 @@ static void interrupt_pci9118_ai_dma(struct comedi_device *dev, struct comedi_su
/* 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);
+ devpriv->dmabuf_virt[devpriv->dma_actbuf],
+ samplesinbuf);
m = m - sampls; /* m= how many samples was transfered */
}
/* DPRINTK("YYY\n"); */
@@ -662,9 +685,9 @@ static void interrupt_pci9118_ai_dma(struct comedi_device *dev, struct comedi_su
devpriv->dma_actbuf = 1 - devpriv->dma_actbuf;
} else { /* restart DMA if is not used double buffering */
outl(devpriv->dmabuf_hw[0],
- devpriv->iobase_a + AMCC_OP_REG_MWAR);
+ devpriv->iobase_a + AMCC_OP_REG_MWAR);
outl(devpriv->dmabuf_use_size[0],
- devpriv->iobase_a + AMCC_OP_REG_MWTC);
+ devpriv->iobase_a + AMCC_OP_REG_MWTC);
if (devpriv->ai_do == 4)
interrupt_pci9118_ai_mode4_switch(dev);
}
@@ -700,18 +723,18 @@ static irqreturn_t interrupt_pci9118(int irq, void *d)
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;
+ ~START_AI_EXT;
if (!(devpriv->ai12_startstop &
- STOP_AI_EXT))
+ 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 */
outl(devpriv->AdControlReg,
- dev->iobase + PCI9118_ADCNTRL);
+ dev->iobase + PCI9118_ADCNTRL);
} else {
- if (devpriv->
- ai12_startstop & STOP_AI_EXT) {
+ if (devpriv->ai12_startstop &
+ STOP_AI_EXT) {
devpriv->ai12_startstop &=
- ~STOP_AI_EXT;
+ ~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 */
}
@@ -719,7 +742,7 @@ static irqreturn_t interrupt_pci9118(int irq, void *d)
}
(devpriv->int_ai_func) (dev, dev->subdevices + 0, int_adstat,
- int_amcc, int_daq);
+ int_amcc, int_daq);
}
return IRQ_HANDLED;
@@ -728,8 +751,8 @@ static irqreturn_t interrupt_pci9118(int irq, void *d)
/*
==============================================================================
*/
-static int pci9118_ai_inttrig(struct comedi_device *dev, struct comedi_subdevice *s,
- unsigned int trignum)
+static int pci9118_ai_inttrig(struct comedi_device *dev,
+ struct comedi_subdevice *s, unsigned int trignum)
{
if (trignum != devpriv->ai_inttrig_start)
return -EINVAL;
@@ -741,7 +764,7 @@ static int pci9118_ai_inttrig(struct comedi_device *dev, struct comedi_subdevice
outl(devpriv->AdFunctionReg, dev->iobase + PCI9118_ADFUNC);
if (devpriv->ai_do != 3) {
start_pacer(dev, devpriv->ai_do, devpriv->ai_divisor1,
- devpriv->ai_divisor2);
+ devpriv->ai_divisor2);
devpriv->AdControlReg |= AdControl_SoftG;
}
outl(devpriv->AdControlReg, dev->iobase + PCI9118_ADCNTRL);
@@ -752,8 +775,9 @@ static int pci9118_ai_inttrig(struct comedi_device *dev, struct comedi_subdevice
/*
==============================================================================
*/
-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;
@@ -799,21 +823,21 @@ static int pci9118_ai_cmdtest(struct comedi_device *dev, struct comedi_subdevice
/* step 2: make sure trigger sources are unique and mutually compatible */
if (cmd->start_src != TRIG_NOW &&
- cmd->start_src != TRIG_INT && cmd->start_src != TRIG_EXT) {
+ cmd->start_src != TRIG_INT && cmd->start_src != TRIG_EXT) {
cmd->start_src = TRIG_NOW;
err++;
}
if (cmd->scan_begin_src != TRIG_TIMER &&
- cmd->scan_begin_src != TRIG_EXT &&
- cmd->scan_begin_src != TRIG_INT &&
- cmd->scan_begin_src != TRIG_FOLLOW) {
+ cmd->scan_begin_src != TRIG_EXT &&
+ cmd->scan_begin_src != TRIG_INT &&
+ cmd->scan_begin_src != TRIG_FOLLOW) {
cmd->scan_begin_src = TRIG_FOLLOW;
err++;
}
if (cmd->convert_src != TRIG_TIMER &&
- cmd->convert_src != TRIG_EXT && cmd->convert_src != TRIG_NOW) {
+ cmd->convert_src != TRIG_EXT && cmd->convert_src != TRIG_NOW) {
cmd->convert_src = TRIG_TIMER;
err++;
}
@@ -824,8 +848,8 @@ static int pci9118_ai_cmdtest(struct comedi_device *dev, struct comedi_subdevice
}
if (cmd->stop_src != TRIG_NONE &&
- cmd->stop_src != TRIG_COUNT &&
- cmd->stop_src != TRIG_INT && cmd->stop_src != TRIG_EXT) {
+ cmd->stop_src != TRIG_COUNT &&
+ cmd->stop_src != TRIG_INT && cmd->stop_src != TRIG_EXT) {
cmd->stop_src = TRIG_COUNT;
err++;
}
@@ -841,13 +865,13 @@ static int pci9118_ai_cmdtest(struct comedi_device *dev, struct comedi_subdevice
}
if ((cmd->scan_begin_src & (TRIG_TIMER | TRIG_EXT)) &&
- (!(cmd->convert_src & (TRIG_TIMER | TRIG_NOW)))) {
+ (!(cmd->convert_src & (TRIG_TIMER | TRIG_NOW)))) {
cmd->convert_src = TRIG_TIMER;
err++;
}
if ((cmd->scan_begin_src == TRIG_FOLLOW) &&
- (!(cmd->convert_src & (TRIG_TIMER | TRIG_EXT)))) {
+ (!(cmd->convert_src & (TRIG_TIMER | TRIG_EXT)))) {
cmd->convert_src = TRIG_TIMER;
err++;
}
@@ -875,7 +899,7 @@ static int pci9118_ai_cmdtest(struct comedi_device *dev, struct comedi_subdevice
}
if ((cmd->scan_begin_src == TRIG_TIMER) &&
- (cmd->convert_src == TRIG_TIMER) && (cmd->scan_end_arg == 1)) {
+ (cmd->convert_src == TRIG_TIMER) && (cmd->scan_end_arg == 1)) {
cmd->scan_begin_src = TRIG_FOLLOW;
cmd->convert_arg = cmd->scan_begin_arg;
cmd->scan_begin_arg = 0;
@@ -938,8 +962,7 @@ static int pci9118_ai_cmdtest(struct comedi_device *dev, struct comedi_subdevice
if ((cmd->scan_end_arg % cmd->chanlist_len)) {
cmd->scan_end_arg =
- cmd->chanlist_len * (cmd->scan_end_arg /
- cmd->chanlist_len);
+ cmd->chanlist_len * (cmd->scan_end_arg / cmd->chanlist_len);
err++;
}
@@ -952,8 +975,8 @@ static int pci9118_ai_cmdtest(struct comedi_device *dev, struct comedi_subdevice
tmp = cmd->scan_begin_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);
+ &divisor2, &cmd->scan_begin_arg,
+ cmd->flags & TRIG_ROUND_MASK);
/* 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;
@@ -964,31 +987,31 @@ static int pci9118_ai_cmdtest(struct comedi_device *dev, struct comedi_subdevice
if (cmd->convert_src & (TRIG_TIMER | TRIG_NOW)) {
tmp = cmd->convert_arg;
i8253_cascade_ns_to_timer(devpriv->i8254_osc_base, &divisor1,
- &divisor2, &cmd->convert_arg,
- cmd->flags & TRIG_ROUND_MASK);
+ &divisor2, &cmd->convert_arg,
+ cmd->flags & TRIG_ROUND_MASK);
/* 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)
err++;
if (cmd->scan_begin_src == TRIG_TIMER
- && cmd->convert_src == TRIG_NOW) {
+ && cmd->convert_src == TRIG_NOW) {
if (cmd->convert_arg == 0) {
if (cmd->scan_begin_arg <
- this_board->ai_ns_min *
- (cmd->scan_end_arg + 2)) {
+ this_board->ai_ns_min *
+ (cmd->scan_end_arg + 2)) {
cmd->scan_begin_arg =
- this_board->ai_ns_min *
- (cmd->scan_end_arg + 2);
+ this_board->ai_ns_min *
+ (cmd->scan_end_arg + 2);
/* printk("s2 timer1=%u timer2=%u\n",cmd->scan_begin_arg,cmd->convert_arg); */
err++;
}
} else {
if (cmd->scan_begin_arg <
- cmd->convert_arg * cmd->chanlist_len) {
+ cmd->convert_arg * cmd->chanlist_len) {
cmd->scan_begin_arg =
- cmd->convert_arg *
- cmd->chanlist_len;
+ cmd->convert_arg *
+ cmd->chanlist_len;
/* printk("s3 timer1=%u timer2=%u\n",cmd->scan_begin_arg,cmd->convert_arg); */
err++;
}
@@ -1001,7 +1024,7 @@ static int pci9118_ai_cmdtest(struct comedi_device *dev, struct comedi_subdevice
if (cmd->chanlist)
if (!check_channel_list(dev, s, cmd->chanlist_len,
- cmd->chanlist, 0, 0))
+ cmd->chanlist, 0, 0))
return 5; /* incorrect channels list */
return 0;
@@ -1034,19 +1057,22 @@ static int Compute_and_setup_dma(struct comedi_device *dev)
/* uff, too short DMA buffer, disable EOS support! */
devpriv->ai_flags &= (~TRIG_WAKE_EOS);
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);
+ ("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 */
dmalen0 = devpriv->ai_n_realscanlen << 1;
- DPRINTK("21 dmalen0=%d ai_n_realscanlen=%d useeoshandle=%d\n", dmalen0, devpriv->ai_n_realscanlen, devpriv->useeoshandle);
+ 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) {
printk
- ("comedi%d: ERR: DMA0 buf len bug? (%d<4)\n",
- dev->minor, dmalen0);
+ ("comedi%d: ERR: DMA0 buf len bug? (%d<4)\n",
+ dev->minor, dmalen0);
dmalen0 = 4;
}
}
@@ -1056,19 +1082,22 @@ static int Compute_and_setup_dma(struct comedi_device *dev)
/* uff, too short DMA buffer, disable EOS support! */
devpriv->ai_flags &= (~TRIG_WAKE_EOS);
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);
+ ("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 */
dmalen1 = devpriv->ai_n_realscanlen << 1;
- DPRINTK("22 dmalen1=%d ai_n_realscanlen=%d useeoshandle=%d\n", dmalen1, devpriv->ai_n_realscanlen, devpriv->useeoshandle);
+ 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) {
printk
- ("comedi%d: ERR: DMA1 buf len bug? (%d<4)\n",
- dev->minor, dmalen1);
+ ("comedi%d: ERR: DMA1 buf len bug? (%d<4)\n",
+ dev->minor, dmalen1);
dmalen1 = 4;
}
}
@@ -1080,15 +1109,15 @@ static int Compute_and_setup_dma(struct comedi_device *dev)
/* 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 / (devpriv->ai_n_realscanlen << 1)) *
+ (devpriv->ai_n_realscanlen << 1);
dmalen0 &= ~3L;
if (!dmalen0)
dmalen0 = i; /* uff. very long scan? */
i = dmalen1;
dmalen1 =
- (dmalen1 / (devpriv->ai_n_realscanlen << 1)) *
- (devpriv->ai_n_realscanlen << 1);
+ (dmalen1 / (devpriv->ai_n_realscanlen << 1)) *
+ (devpriv->ai_n_realscanlen << 1);
dmalen1 &= ~3L;
if (!dmalen1)
dmalen1 = i; /* uff. very long scan? */
@@ -1096,23 +1125,25 @@ static int Compute_and_setup_dma(struct comedi_device *dev)
if (!devpriv->ai_neverending) {
/* fits whole measure into one DMA buffer? */
if (dmalen0 >
- ((devpriv->ai_n_realscanlen << 1) *
- devpriv->ai_scans)) {
- DPRINTK("3.0 ai_n_realscanlen=%d ai_scans=%d \n", devpriv->ai_n_realscanlen, devpriv->ai_scans);
+ ((devpriv->ai_n_realscanlen << 1) *
+ devpriv->ai_scans)) {
+ DPRINTK
+ ("3.0 ai_n_realscanlen=%d ai_scans=%d \n",
+ devpriv->ai_n_realscanlen,
+ devpriv->ai_scans);
dmalen0 =
- (devpriv->ai_n_realscanlen << 1) *
- devpriv->ai_scans;
+ (devpriv->ai_n_realscanlen << 1) *
+ devpriv->ai_scans;
DPRINTK("3.1 dmalen0=%d dmalen1=%d \n", dmalen0,
dmalen1);
dmalen0 &= ~3L;
} else { /* fits whole measure into two DMA buffer? */
if (dmalen1 >
- ((devpriv->ai_n_realscanlen << 1) *
- devpriv->ai_scans - dmalen0))
+ ((devpriv->ai_n_realscanlen << 1) *
+ devpriv->ai_scans - dmalen0))
dmalen1 =
- (devpriv->
- ai_n_realscanlen << 1) *
- devpriv->ai_scans - dmalen0;
+ (devpriv->ai_n_realscanlen << 1) *
+ devpriv->ai_scans - dmalen0;
DPRINTK("3.2 dmalen0=%d dmalen1=%d \n", dmalen0,
dmalen1);
dmalen1 &= ~3L;
@@ -1131,16 +1162,16 @@ static int Compute_and_setup_dma(struct comedi_device *dev)
#if 0
if (devpriv->ai_n_scanlen < this_board->half_fifo_size) {
devpriv->dmabuf_panic_size[0] =
- (this_board->half_fifo_size / devpriv->ai_n_scanlen +
- 1) * devpriv->ai_n_scanlen * sizeof(short);
+ (this_board->half_fifo_size / devpriv->ai_n_scanlen +
+ 1) * devpriv->ai_n_scanlen * sizeof(short);
devpriv->dmabuf_panic_size[1] =
- (this_board->half_fifo_size / devpriv->ai_n_scanlen +
- 1) * devpriv->ai_n_scanlen * sizeof(short);
+ (this_board->half_fifo_size / devpriv->ai_n_scanlen +
+ 1) * devpriv->ai_n_scanlen * sizeof(short);
} else {
devpriv->dmabuf_panic_size[0] =
- (devpriv->ai_n_scanlen << 1) % devpriv->dmabuf_size[0];
+ (devpriv->ai_n_scanlen << 1) % devpriv->dmabuf_size[0];
devpriv->dmabuf_panic_size[1] =
- (devpriv->ai_n_scanlen << 1) % devpriv->dmabuf_size[1];
+ (devpriv->ai_n_scanlen << 1) % devpriv->dmabuf_size[1];
}
#endif
@@ -1149,12 +1180,12 @@ static int Compute_and_setup_dma(struct comedi_device *dev)
outl(devpriv->dmabuf_use_size[0], devpriv->iobase_a + AMCC_OP_REG_MWTC);
/* init DMA transfer */
outl(0x00000000 | AINT_WRITE_COMPL,
- devpriv->iobase_a + AMCC_OP_REG_INTCSR);
+ 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);
+ 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 */
DPRINTK("adl_pci9118 EDBG: END: Compute_and_setup_dma()\n");
@@ -1164,7 +1195,8 @@ 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);
@@ -1183,7 +1215,7 @@ static int pci9118_ai_docmd_sampl(struct comedi_device *dev, struct comedi_subde
return -EIO;
default:
comedi_error(dev,
- "pci9118_ai_docmd_sampl() mode number bug!\n");
+ "pci9118_ai_docmd_sampl() mode number bug!\n");
return -EIO;
};
@@ -1204,7 +1236,7 @@ static int pci9118_ai_docmd_sampl(struct comedi_device *dev, struct comedi_subde
outl(devpriv->AdFunctionReg, dev->iobase + PCI9118_ADFUNC);
if (devpriv->ai_do != 3) {
start_pacer(dev, devpriv->ai_do, devpriv->ai_divisor1,
- devpriv->ai_divisor2);
+ devpriv->ai_divisor2);
devpriv->AdControlReg |= AdControl_SoftG;
}
outl(devpriv->IntControlReg, dev->iobase + PCI9118_INTCTRL);
@@ -1217,7 +1249,8 @@ static int pci9118_ai_docmd_sampl(struct comedi_device *dev, struct comedi_subde
/*
==============================================================================
*/
-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);
@@ -1226,34 +1259,34 @@ static int pci9118_ai_docmd_dma(struct comedi_device *dev, struct comedi_subdevi
switch (devpriv->ai_do) {
case 1:
devpriv->AdControlReg |=
- ((AdControl_TmrTr | AdControl_Dma) & 0xff);
+ ((AdControl_TmrTr | AdControl_Dma) & 0xff);
break;
case 2:
devpriv->AdControlReg |=
- ((AdControl_TmrTr | AdControl_Dma) & 0xff);
+ ((AdControl_TmrTr | AdControl_Dma) & 0xff);
devpriv->AdFunctionReg =
- AdFunction_PDTrg | AdFunction_PETrg | AdFunction_BM |
- AdFunction_BS;
+ AdFunction_PDTrg | AdFunction_PETrg | AdFunction_BM |
+ AdFunction_BS;
if (devpriv->usessh && (!devpriv->softsshdelay))
devpriv->AdFunctionReg |= AdFunction_BSSH;
outl(devpriv->ai_n_realscanlen, dev->iobase + PCI9118_BURST);
break;
case 3:
devpriv->AdControlReg |=
- ((AdControl_ExtM | AdControl_Dma) & 0xff);
+ ((AdControl_ExtM | AdControl_Dma) & 0xff);
devpriv->AdFunctionReg = AdFunction_PDTrg | AdFunction_PETrg;
break;
case 4:
devpriv->AdControlReg |=
- ((AdControl_TmrTr | AdControl_Dma) & 0xff);
+ ((AdControl_TmrTr | AdControl_Dma) & 0xff);
devpriv->AdFunctionReg =
- AdFunction_PDTrg | AdFunction_PETrg | AdFunction_AM;
+ AdFunction_PDTrg | AdFunction_PETrg | AdFunction_AM;
outl(devpriv->AdFunctionReg, dev->iobase + PCI9118_ADFUNC);
outl(0x30, dev->iobase + PCI9118_CNTCTRL);
outl((devpriv->dmabuf_hw[0] >> 1) & 0xff,
- dev->iobase + PCI9118_CNT0);
+ dev->iobase + PCI9118_CNT0);
outl((devpriv->dmabuf_hw[0] >> 9) & 0xff,
- dev->iobase + PCI9118_CNT0);
+ dev->iobase + PCI9118_CNT0);
devpriv->AdFunctionReg |= AdFunction_Start;
break;
default:
@@ -1268,14 +1301,14 @@ static int pci9118_ai_docmd_dma(struct comedi_device *dev, struct comedi_subdevi
devpriv->int_ai_func = interrupt_pci9118_ai_dma; /* transfer function */
outl(0x02000000 | AINT_WRITE_COMPL,
- devpriv->iobase_a + AMCC_OP_REG_INTCSR);
+ devpriv->iobase_a + AMCC_OP_REG_INTCSR);
if (!(devpriv->ai12_startstop & (START_AI_EXT | START_AI_INT))) {
outl(devpriv->AdFunctionReg, dev->iobase + PCI9118_ADFUNC);
outl(devpriv->IntControlReg, dev->iobase + PCI9118_INTCTRL);
if (devpriv->ai_do != 3) {
start_pacer(dev, devpriv->ai_do, devpriv->ai_divisor1,
- devpriv->ai_divisor2);
+ devpriv->ai_divisor2);
devpriv->AdControlReg |= AdControl_SoftG;
}
outl(devpriv->AdControlReg, dev->iobase + PCI9118_ADCNTRL);
@@ -1338,7 +1371,7 @@ static int pci9118_ai_cmd(struct comedi_device *dev, struct comedi_subdevice *s)
/* use sample&hold signal? */
if (cmd->convert_src == TRIG_NOW) {
devpriv->usessh = 1;
- } /* yes */
+ } /* yes */
else {
devpriv->usessh = 0;
} /* no */
@@ -1354,7 +1387,7 @@ static int pci9118_ai_cmd(struct comedi_device *dev, struct comedi_subdevice *s)
if (devpriv->master) {
devpriv->usedma = 1;
if ((cmd->flags & TRIG_WAKE_EOS) &&
- (devpriv->ai_n_scanlen == 1)) {
+ (devpriv->ai_n_scanlen == 1)) {
if (cmd->convert_src == TRIG_NOW) {
devpriv->ai_add_back = 1;
}
@@ -1363,8 +1396,8 @@ static int pci9118_ai_cmd(struct comedi_device *dev, struct comedi_subdevice *s)
}
}
if ((cmd->flags & TRIG_WAKE_EOS) &&
- (devpriv->ai_n_scanlen & 1) &&
- (devpriv->ai_n_scanlen > 1)) {
+ (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 */
@@ -1392,16 +1425,16 @@ static int pci9118_ai_cmd(struct comedi_device *dev, struct comedi_subdevice *s)
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_n_chan +
+ devpriv->ai_add_back) & 1)
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_add_front + devpriv->ai_n_chan +
- devpriv->ai_add_back) * (devpriv->ai_n_scanlen /
- devpriv->ai_n_chan);
+ (devpriv->ai_add_front + devpriv->ai_n_chan +
+ devpriv->ai_add_back) * (devpriv->ai_n_scanlen /
+ devpriv->ai_n_chan);
DPRINTK("2 usedma=%d realscan=%d af=%u n_chan=%d ab=%d n_scanlen=%d\n",
devpriv->usedma,
@@ -1411,13 +1444,13 @@ static int pci9118_ai_cmd(struct comedi_device *dev, struct comedi_subdevice *s)
/* 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))
+ devpriv->ai_chanlist, devpriv->ai_add_front,
+ devpriv->ai_add_back))
return -EINVAL;
if (!setup_channel_list(dev, s, devpriv->ai_n_chan,
- devpriv->ai_chanlist, 0, devpriv->ai_add_front,
- devpriv->ai_add_back, devpriv->usedma,
- devpriv->useeoshandle))
+ devpriv->ai_chanlist, 0, devpriv->ai_add_front,
+ devpriv->ai_add_back, devpriv->usedma,
+ devpriv->useeoshandle))
return -EINVAL;
/* compute timers settings */
@@ -1429,32 +1462,36 @@ static int pci9118_ai_cmd(struct comedi_device *dev, struct comedi_subdevice *s)
devpriv->ai_do = 1;
}
pci9118_calc_divisors(devpriv->ai_do, dev, s,
- &cmd->scan_begin_arg, &cmd->convert_arg,
- devpriv->ai_flags, devpriv->ai_n_realscanlen,
- &devpriv->ai_divisor1, &devpriv->ai_divisor2,
- devpriv->usessh, devpriv->ai_add_front);
+ &cmd->scan_begin_arg, &cmd->convert_arg,
+ devpriv->ai_flags,
+ devpriv->ai_n_realscanlen,
+ &devpriv->ai_divisor1,
+ &devpriv->ai_divisor2, devpriv->usessh,
+ devpriv->ai_add_front);
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 (!devpriv->usedma) {
comedi_error(dev,
- "cmd->scan_begin_src=TRIG_TIMER works only with bus mastering!");
+ "cmd->scan_begin_src=TRIG_TIMER works only with bus mastering!");
return -EIO;
}
devpriv->ai_do = 2;
pci9118_calc_divisors(devpriv->ai_do, dev, s,
- &cmd->scan_begin_arg, &cmd->convert_arg,
- devpriv->ai_flags, devpriv->ai_n_realscanlen,
- &devpriv->ai_divisor1, &devpriv->ai_divisor2,
- devpriv->usessh, devpriv->ai_add_front);
+ &cmd->scan_begin_arg, &cmd->convert_arg,
+ devpriv->ai_flags,
+ devpriv->ai_n_realscanlen,
+ &devpriv->ai_divisor1,
+ &devpriv->ai_divisor2, devpriv->usessh,
+ devpriv->ai_add_front);
devpriv->ai_timer1 = cmd->scan_begin_arg;
devpriv->ai_timer2 = cmd->convert_arg;
}
if ((cmd->scan_begin_src == TRIG_FOLLOW)
- && (cmd->convert_src == TRIG_EXT)) {
+ && (cmd->convert_src == TRIG_EXT)) {
devpriv->ai_do = 3;
}
@@ -1486,8 +1523,9 @@ static int pci9118_ai_cmd(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 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;
@@ -1498,9 +1536,8 @@ static int check_channel_list(struct comedi_device *dev, struct comedi_subdevice
}
if ((frontadd + n_chan + backadd) > s->len_chanlist) {
printk
- ("comedi%d: range/channel list is too long for actual configuration (%d>%d)!",
- dev->minor, n_chan,
- s->len_chanlist - frontadd - backadd);
+ ("comedi%d: range/channel list is too long for actual configuration (%d>%d)!",
+ dev->minor, n_chan, s->len_chanlist - frontadd - backadd);
return 0;
}
@@ -1511,22 +1548,21 @@ static int check_channel_list(struct comedi_device *dev, struct comedi_subdevice
if (n_chan > 1)
for (i = 1; i < n_chan; i++) { /* check S.E/diff */
if ((CR_AREF(chanlist[i]) == AREF_DIFF) !=
- (differencial)) {
+ (differencial)) {
comedi_error(dev,
- "Differencial and single ended inputs cann't be mixtured!");
+ "Differencial and single ended inputs cann't be mixtured!");
return 0;
}
if ((CR_RANGE(chanlist[i]) < PCI9118_BIPOLAR_RANGES) !=
- (bipolar)) {
+ (bipolar)) {
comedi_error(dev,
- "Bipolar and unipolar ranges cann't be mixtured!");
+ "Bipolar and unipolar ranges cann't be mixtured!");
return 0;
}
if ((!devpriv->usemux) & (differencial) &
- (CR_CHAN(chanlist[i]) >=
- this_board->n_aichand)) {
+ (CR_CHAN(chanlist[i]) >= this_board->n_aichand)) {
comedi_error(dev,
- "If AREF_DIFF is used then is available only first 8 channels!");
+ "If AREF_DIFF is used then is available only first 8 channels!");
return 0;
}
}
@@ -1537,14 +1573,17 @@ static int check_channel_list(struct comedi_device *dev, struct comedi_subdevice
/*
==============================================================================
*/
-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)
+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)
{
unsigned int i, differencial = 0, bipolar = 0;
unsigned int scanquad, gain, ssh = 0x00;
- DPRINTK("adl_pci9118 EDBG: BGN: setup_channel_list(%d,.,%d,.,%d,%d,%d,%d)\n", dev->minor, n_chan, rot, frontadd, backadd, usedma);
+ DPRINTK
+ ("adl_pci9118 EDBG: BGN: setup_channel_list(%d,.,%d,.,%d,%d,%d,%d)\n",
+ dev->minor, n_chan, rot, frontadd, backadd, usedma);
if (usedma == 1) {
rot = 8;
@@ -1625,7 +1664,7 @@ static int setup_channel_list(struct comedi_device *dev, struct comedi_subdevice
if (useeos) {
for (i = 1; i < n_chan; i++) { /* store range list to card */
devpriv->chanlist[(n_chan + i) ^ usedma] =
- (CR_CHAN(chanlist[i]) & 0xf) << rot;
+ (CR_CHAN(chanlist[i]) & 0xf) << rot;
}
devpriv->chanlist[(2 * n_chan) ^ usedma] = devpriv->chanlist[0 ^ usedma]; /* for 32bit oerations */
useeos = 2;
@@ -1652,18 +1691,22 @@ static int setup_channel_list(struct comedi_device *dev, struct comedi_subdevice
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,
- unsigned int flags, int chans, unsigned int *div1, unsigned int *div2,
- char usessh, unsigned int chnsshfront)
+ 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)
{
- DPRINTK("adl_pci9118 EDBG: BGN: pci9118_calc_divisors(%d,%d,.,%u,%u,%u,%d,.,.,,%u,%u)\n", mode, dev->minor, *tim1, *tim2, flags, chans, usessh, chnsshfront);
+ DPRINTK
+ ("adl_pci9118 EDBG: BGN: pci9118_calc_divisors(%d,%d,.,%u,%u,%u,%d,.,.,,%u,%u)\n",
+ mode, dev->minor, *tim1, *tim2, flags, chans, usessh, chnsshfront);
switch (mode) {
case 1:
case 4:
if (*tim2 < this_board->ai_ns_min)
*tim2 = this_board->ai_ns_min;
i8253_cascade_ns_to_timer(devpriv->i8254_osc_base, div1, div2,
- tim2, flags & TRIG_ROUND_NEAREST);
+ tim2, flags & TRIG_ROUND_NEAREST);
DPRINTK("OSC base=%u div1=%u div2=%u timer1=%u\n",
devpriv->i8254_osc_base, *div1, *div2, *tim1);
break;
@@ -1710,8 +1753,8 @@ static void pci9118_calc_divisors(char mode, struct comedi_device *dev,
/*
==============================================================================
*/
-static void start_pacer(struct comedi_device *dev, int mode, unsigned int divisor1,
- unsigned int divisor2)
+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);
@@ -1760,7 +1803,8 @@ 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 */
@@ -1835,7 +1879,8 @@ 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,8 +1893,7 @@ static int pci9118_attach(struct comedi_device *dev, struct comedi_devconfig *it
unsigned char pci_bus, pci_slot, pci_func;
u16 u16w;
- printk("comedi%d: adl_pci9118: board=%s", dev->minor,
- this_board->name);
+ printk("comedi%d: adl_pci9118: board=%s", dev->minor, this_board->name);
opt_bus = it->options[0];
opt_slot = it->options[1];
@@ -1869,12 +1913,13 @@ static int pci9118_attach(struct comedi_device *dev, struct comedi_devconfig *it
errstr = "not found!";
pcidev = NULL;
while (NULL != (pcidev = pci_get_device(PCI_VENDOR_ID_AMCC,
- this_board->device_id, pcidev))) {
+ this_board->device_id,
+ pcidev))) {
/* Found matching vendor/device. */
if (opt_bus || opt_slot) {
/* Check bus/slot. */
if (opt_bus != pcidev->bus->number
- || opt_slot != PCI_SLOT(pcidev->devfn))
+ || opt_slot != PCI_SLOT(pcidev->devfn))
continue; /* no match */
}
/*
@@ -1882,7 +1927,8 @@ static int pci9118_attach(struct comedi_device *dev, struct comedi_devconfig *it
* Enable PCI device and request regions.
*/
if (comedi_pci_enable(pcidev, "adl_pci9118")) {
- errstr = "failed to enable PCI device and request regions!";
+ errstr =
+ "failed to enable PCI device and request regions!";
continue;
}
break;
@@ -1891,7 +1937,7 @@ static int pci9118_attach(struct comedi_device *dev, struct comedi_devconfig *it
if (!pcidev) {
if (opt_bus || opt_slot) {
printk(" - Card at b:s %d:%d %s\n",
- opt_bus, opt_slot, errstr);
+ opt_bus, opt_slot, errstr);
} else {
printk(" - Card %s\n", errstr);
}
@@ -1910,7 +1956,7 @@ static int pci9118_attach(struct comedi_device *dev, struct comedi_devconfig *it
iobase_9 = pci_resource_start(pcidev, 2);
printk(", b:s:f=%d:%d:%d, io=0x%4lx, 0x%4lx", pci_bus, pci_slot,
- pci_func, iobase_9, iobase_a);
+ pci_func, iobase_9, iobase_a);
dev->iobase = iobase_9;
dev->board_name = this_board->name;
@@ -1926,7 +1972,7 @@ static int pci9118_attach(struct comedi_device *dev, struct comedi_devconfig *it
if (request_irq(irq, interrupt_pci9118, IRQF_SHARED,
"ADLink PCI-9118", dev)) {
printk(", unable to allocate IRQ %d, DISABLING IT",
- irq);
+ irq);
irq = 0; /* Can't use IRQ */
} else {
printk(", irq=%u", irq);
@@ -1942,8 +1988,8 @@ static int pci9118_attach(struct comedi_device *dev, struct comedi_devconfig *it
for (i = 0; i < 2; i++) {
for (pages = 4; pages >= 0; pages--) {
devpriv->dmabuf_virt[i] =
- (short *) __get_free_pages(GFP_KERNEL,
- pages);
+ (short *)__get_free_pages(GFP_KERNEL,
+ pages);
if (devpriv->dmabuf_virt[i])
break;
}
@@ -1951,10 +1997,10 @@ static int pci9118_attach(struct comedi_device *dev, struct comedi_devconfig *it
devpriv->dmabuf_pages[i] = pages;
devpriv->dmabuf_size[i] = PAGE_SIZE * pages;
devpriv->dmabuf_samples[i] =
- devpriv->dmabuf_size[i] >> 1;
+ devpriv->dmabuf_size[i] >> 1;
devpriv->dmabuf_hw[i] =
- virt_to_bus((void *)devpriv->
- dmabuf_virt[i]);
+ virt_to_bus((void *)
+ devpriv->dmabuf_virt[i]);
}
}
if (!devpriv->dmabuf_virt[0]) {
@@ -2090,10 +2136,10 @@ static int pci9118_detach(struct comedi_device *dev)
}
if (devpriv->dmabuf_virt[0])
free_pages((unsigned long)devpriv->dmabuf_virt[0],
- devpriv->dmabuf_pages[0]);
+ devpriv->dmabuf_pages[0]);
if (devpriv->dmabuf_virt[1])
free_pages((unsigned long)devpriv->dmabuf_virt[1],
- devpriv->dmabuf_pages[1]);
+ devpriv->dmabuf_pages[1]);
}
return 0;
diff --git a/drivers/staging/comedi/drivers/adq12b.c b/drivers/staging/comedi/drivers/adq12b.c
index d09d1493a8b7..c5ed8bb97602 100644
--- a/drivers/staging/comedi/drivers/adq12b.c
+++ b/drivers/staging/comedi/drivers/adq12b.c
@@ -62,7 +62,6 @@ If you do not specify any options, they will default to
single-ended 0 1-2 1-2 (factory default)
differential 1 2-3 2-3
-
written by jeremy theler <thelerg@ib.cnea.gov.ar>
instituto balseiro
@@ -101,39 +100,39 @@ If you do not specify any options, they will default to
/* 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)
+ }
+};
struct adq12b_board {
- const char *name;
- int ai_se_chans;
- int ai_diff_chans;
- int ai_bits;
- int di_chans;
- int do_chans;
+ const char *name;
+ int ai_se_chans;
+ int ai_diff_chans;
+ int ai_bits;
+ int di_chans;
+ int do_chans;
};
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 */
/*,
.name = "adq12b",
@@ -147,11 +146,11 @@ static const struct adq12b_board adq12b_boards[] = {
#define thisboard ((const struct adq12b_board *)dev->board_ptr)
struct adq12b_private {
- int unipolar; /* option 2 of comedi_config (1 is iobase) */
- int differential; /* option 3 of comedi_config */
- int last_channel;
- int last_range;
- unsigned int digital_state;
+ int unipolar; /* option 2 of comedi_config (1 is iobase) */
+ int differential; /* option 3 of comedi_config */
+ int last_channel;
+ int last_range;
+ unsigned int digital_state;
};
#define devpriv ((struct adq12b_private *)dev->private)
@@ -162,21 +161,28 @@ 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",
- module: THIS_MODULE,
- attach: adq12b_attach,
- detach: adq12b_detach,
- board_name: &adq12b_boards[0].name,
- offset: sizeof(struct adq12b_board),
- num_names: ARRAY_SIZE(adq12b_boards),
+static struct comedi_driver driver_adq12b = {
+driver_name:"adq12b",
+module:THIS_MODULE,
+attach:adq12b_attach,
+detach:adq12b_detach,
+board_name:&adq12b_boards[0].name,
+offset: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
@@ -186,109 +192,108 @@ static int adq12b_do_insn_bits(struct comedi_device *dev, struct comedi_subdevic
*/
static int adq12b_attach(struct comedi_device *dev, struct comedi_devconfig *it)
{
- struct comedi_subdevice *s;
- unsigned long iobase;
- int unipolar, differential;
-
- iobase = it->options[0];
- 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");
-
- /* if no address was specified, try the default 0x300 */
- if (iobase == 0) {
- printk("comedi%d: adq12b warning: I/O base address not specified. Trying the default 0x300.\n", dev->minor);
- iobase = 0x300;
- }
-
- printk("comedi%d: adq12b: 0x%04lx ", dev->minor, iobase);
- if (!request_region(iobase, ADQ12B_SIZE, "adq12b")) {
- printk("I/O port conflict\n");
- return -EIO;
- }
- dev->iobase = iobase;
+ struct comedi_subdevice *s;
+ unsigned long iobase;
+ int unipolar, differential;
+
+ iobase = it->options[0];
+ 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");
+
+ /* if no address was specified, try the default 0x300 */
+ if (iobase == 0) {
+ printk
+ ("comedi%d: adq12b warning: I/O base address not specified. Trying the default 0x300.\n",
+ dev->minor);
+ iobase = 0x300;
+ }
+
+ printk("comedi%d: adq12b: 0x%04lx ", dev->minor, iobase);
+ if (!request_region(iobase, ADQ12B_SIZE, "adq12b")) {
+ printk("I/O port conflict\n");
+ return -EIO;
+ }
+ dev->iobase = iobase;
/*
* Initialize dev->board_name. Note that we can use the "thisboard"
* macro now, since we just initialized it in the last line.
*/
- dev->board_name = thisboard->name;
+ dev->board_name = thisboard->name;
/*
* Allocate the private structure area. alloc_private() is a
* convenient macro defined in comedidev.h.
*/
- if (alloc_private (dev, sizeof (struct adq12b_private)) < 0)
- return -ENOMEM;
+ if (alloc_private(dev, sizeof(struct adq12b_private)) < 0)
+ return -ENOMEM;
/* fill in devpriv structure */
- devpriv->unipolar = unipolar;
- devpriv->differential = differential;
+ devpriv->unipolar = unipolar;
+ devpriv->differential = differential;
devpriv->digital_state = 0;
/* initialize channel and range to -1 so we make sure we always write
at least once to the CTREG in the instruction */
- devpriv->last_channel = -1;
- devpriv->last_range = -1;
-
+ devpriv->last_channel = -1;
+ devpriv->last_range = -1;
/*
* Allocate the subdevice structures. alloc_subdevice() is a
* convenient macro defined in comedidev.h.
*/
- if (alloc_subdevices (dev, 3)<0)
- return -ENOMEM;
-
- s = dev->subdevices+0;
- /* analog input subdevice */
- s->type = COMEDI_SUBD_AI;
- if (differential) {
- s->subdev_flags = SDF_READABLE|SDF_GROUND|SDF_DIFF;
- s->n_chan = thisboard->ai_diff_chans;
- } else {
- s->subdev_flags = SDF_READABLE|SDF_GROUND;
- s->n_chan = thisboard->ai_se_chans;
- }
-
- if (unipolar) {
- s->range_table = &range_adq12b_ai_unipolar;
- } else {
- s->range_table = &range_adq12b_ai_bipolar;
- }
-
- s->maxdata = (1 << thisboard->ai_bits)-1;
-
-
- s->len_chanlist = 4; /* This is the maximum chanlist length that
- the board can handle */
- s->insn_read = adq12b_ai_rinsn;
-
-
- s = dev->subdevices+1;
- /* digital input subdevice */
- s->type = COMEDI_SUBD_DI;
- s->subdev_flags = SDF_READABLE;
- s->n_chan=thisboard->di_chans;
- s->maxdata = 1;
- s->range_table = &range_digital;
- s->insn_bits = adq12b_di_insn_bits;
-
- s = dev->subdevices+2;
- /* digital output subdevice */
- s->type = COMEDI_SUBD_DO;
- s->subdev_flags = SDF_WRITABLE;
- s->n_chan = thisboard->do_chans;
- s->maxdata = 1;
- s->range_table = &range_digital;
- s->insn_bits = adq12b_do_insn_bits;
-
-
- printk("attached\n");
-
- return 0;
+ if (alloc_subdevices(dev, 3) < 0)
+ return -ENOMEM;
+
+ s = dev->subdevices + 0;
+ /* analog input subdevice */
+ s->type = COMEDI_SUBD_AI;
+ if (differential) {
+ s->subdev_flags = SDF_READABLE | SDF_GROUND | SDF_DIFF;
+ s->n_chan = thisboard->ai_diff_chans;
+ } else {
+ s->subdev_flags = SDF_READABLE | SDF_GROUND;
+ s->n_chan = thisboard->ai_se_chans;
+ }
+
+ if (unipolar) {
+ s->range_table = &range_adq12b_ai_unipolar;
+ } else {
+ s->range_table = &range_adq12b_ai_bipolar;
+ }
+
+ s->maxdata = (1 << thisboard->ai_bits) - 1;
+
+ s->len_chanlist = 4; /* This is the maximum chanlist length that
+ the board can handle */
+ s->insn_read = adq12b_ai_rinsn;
+
+ s = dev->subdevices + 1;
+ /* digital input subdevice */
+ s->type = COMEDI_SUBD_DI;
+ s->subdev_flags = SDF_READABLE;
+ s->n_chan = thisboard->di_chans;
+ s->maxdata = 1;
+ s->range_table = &range_digital;
+ s->insn_bits = adq12b_di_insn_bits;
+
+ s = dev->subdevices + 2;
+ /* digital output subdevice */
+ s->type = COMEDI_SUBD_DO;
+ s->subdev_flags = SDF_WRITABLE;
+ s->n_chan = thisboard->do_chans;
+ s->maxdata = 1;
+ s->range_table = &range_digital;
+ s->insn_bits = adq12b_do_insn_bits;
+
+ printk("attached\n");
+
+ return 0;
}
-
/*
* _detach is called to deconfigure a device. It should deallocate
* resources.
@@ -299,14 +304,14 @@ static int adq12b_attach(struct comedi_device *dev, struct comedi_devconfig *it)
*/
static int adq12b_detach(struct comedi_device *dev)
{
- if (dev->iobase)
- release_region(dev->iobase, ADQ12B_SIZE);
+ if (dev->iobase)
+ release_region(dev->iobase, ADQ12B_SIZE);
- kfree(devpriv);
+ kfree(devpriv);
- printk("comedi%d: adq12b: removed\n", dev->minor);
+ printk("comedi%d: adq12b: removed\n", dev->minor);
- return 0;
+ return 0;
}
/*
@@ -314,79 +319,83 @@ 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;
- unsigned char hi, lo, status;
-
- /* change channel and range only if it is different from the previous */
- range = CR_RANGE(insn->chanspec);
- channel = CR_CHAN(insn->chanspec);
- if (channel != devpriv->last_channel || range != devpriv->last_range) {
- outb((range << 4) | channel, dev->iobase + ADQ12B_CTREG);
- 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++){
-
- /* wait for end of convertion */
- i = 0;
- do {
+ int n, i;
+ int range, channel;
+ unsigned char hi, lo, status;
+
+ /* change channel and range only if it is different from the previous */
+ range = CR_RANGE(insn->chanspec);
+ channel = CR_CHAN(insn->chanspec);
+ if (channel != devpriv->last_channel || range != devpriv->last_range) {
+ outb((range << 4) | channel, dev->iobase + ADQ12B_CTREG);
+ 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++) {
+
+ /* wait for end of convertion */
+ i = 0;
+ do {
/* udelay(1); */
- status = inb(dev->iobase + ADQ12B_STINR);
- status = status & ADQ12B_EOC;
- } while (status == 0 && ++i < TIMEOUT);
+ status = inb(dev->iobase + ADQ12B_STINR);
+ status = status & ADQ12B_EOC;
+ } while (status == 0 && ++i < TIMEOUT);
/* } while (++i < 10); */
- /* read data */
- hi = inb(dev->iobase + ADQ12B_ADHIG);
- lo = inb(dev->iobase + ADQ12B_ADLOW);
+ /* read data */
+ hi = inb(dev->iobase + ADQ12B_ADHIG);
+ lo = inb(dev->iobase + ADQ12B_ADLOW);
- /* printk("debug: chan=%d range=%d status=%d hi=%d lo=%d\n", channel, range, status, hi, lo); */
- data[n] = (hi << 8) | lo;
+ /* printk("debug: chan=%d range=%d status=%d hi=%d lo=%d\n", channel, range, status, hi, lo); */
+ data[n] = (hi << 8) | lo;
- }
+ }
- /* return the number of samples read/written */
- return n;
+ /* return the number of samples read/written */
+ return n;
}
-
-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 */
- data[1] = (inb(dev->iobase+ADQ12B_STINR) & (0x1f));
+ /* only bits 0-4 have information about digital inputs */
+ data[1] = (inb(dev->iobase + ADQ12B_STINR) & (0x1f));
- return 2;
+ return 2;
}
-
-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;
+ int channel;
for (channel = 0; channel < 8; channel++)
- if (((data[0]>>channel) & 0x01) != 0)
- outb((((data[1]>>channel)&0x01)<<3) | channel, dev->iobase + ADQ12B_OUTBR);
+ if (((data[0] >> channel) & 0x01) != 0)
+ outb((((data[1] >> channel) & 0x01) << 3) | channel,
+ dev->iobase + ADQ12B_OUTBR);
- /* store information to retrieve when asked for reading */
- if (data[0]) {
- devpriv->digital_state &= ~data[0];
- devpriv->digital_state |= (data[0]&data[1]);
- }
+ /* store information to retrieve when asked for reading */
+ if (data[0]) {
+ devpriv->digital_state &= ~data[0];
+ devpriv->digital_state |= (data[0] & data[1]);
+ }
- data[1] = devpriv->digital_state;
+ data[1] = devpriv->digital_state;
- return 2;
+ return 2;
}
-
/*
* A convenient macro that defines init_module() and cleanup_module(),
* as necessary.
diff --git a/drivers/staging/comedi/drivers/adv_pci1710.c b/drivers/staging/comedi/drivers/adv_pci1710.c
index 0b56c14e2d59..f0ae4c06fe95 100644
--- a/drivers/staging/comedi/drivers/adv_pci1710.c
+++ b/drivers/staging/comedi/drivers/adv_pci1710.c
@@ -124,67 +124,69 @@ Configuration options:
#define Syncont_SC0 1 /* set synchronous output mode */
static const struct comedi_lrange range_pci1710_3 = { 9, {
- BIP_RANGE(5),
- BIP_RANGE(2.5),
- BIP_RANGE(1.25),
- BIP_RANGE(0.625),
- BIP_RANGE(10),
- UNI_RANGE(10),
- UNI_RANGE(5),
- UNI_RANGE(2.5),
- UNI_RANGE(1.25)
- }
+ BIP_RANGE(5),
+ BIP_RANGE(2.5),
+ BIP_RANGE(1.25),
+ BIP_RANGE(0.625),
+ BIP_RANGE(10),
+ UNI_RANGE(10),
+ UNI_RANGE(5),
+ UNI_RANGE(2.5),
+ UNI_RANGE(1.25)
+ }
};
static const char range_codes_pci1710_3[] =
- { 0x00, 0x01, 0x02, 0x03, 0x04, 0x10, 0x11, 0x12, 0x13 };
+ { 0x00, 0x01, 0x02, 0x03, 0x04, 0x10, 0x11, 0x12, 0x13 };
static const struct comedi_lrange range_pci1710hg = { 12, {
- BIP_RANGE(5),
- BIP_RANGE(0.5),
- BIP_RANGE(0.05),
- BIP_RANGE(0.005),
- BIP_RANGE(10),
- BIP_RANGE(1),
- BIP_RANGE(0.1),
- BIP_RANGE(0.01),
- UNI_RANGE(10),
- UNI_RANGE(1),
- UNI_RANGE(0.1),
- UNI_RANGE(0.01)
- }
+ BIP_RANGE(5),
+ BIP_RANGE(0.5),
+ BIP_RANGE(0.05),
+ BIP_RANGE(0.005),
+ BIP_RANGE(10),
+ BIP_RANGE(1),
+ BIP_RANGE(0.1),
+ BIP_RANGE(0.01),
+ UNI_RANGE(10),
+ UNI_RANGE(1),
+ UNI_RANGE(0.1),
+ UNI_RANGE(0.01)
+ }
};
static const char range_codes_pci1710hg[] =
- { 0x00, 0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07, 0x10, 0x11, 0x12,
- 0x13 };
+ { 0x00, 0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07, 0x10, 0x11, 0x12,
+ 0x13
+};
static const struct comedi_lrange range_pci17x1 = { 5, {
- BIP_RANGE(10),
- BIP_RANGE(5),
- BIP_RANGE(2.5),
- BIP_RANGE(1.25),
- BIP_RANGE(0.625)
- }
+ BIP_RANGE(10),
+ BIP_RANGE(5),
+ BIP_RANGE(2.5),
+ BIP_RANGE(1.25),
+ BIP_RANGE(0.625)
+ }
};
static const char range_codes_pci17x1[] = { 0x00, 0x01, 0x02, 0x03, 0x04 };
static const struct comedi_lrange range_pci1720 = { 4, {
- UNI_RANGE(5),
- UNI_RANGE(10),
- BIP_RANGE(5),
- BIP_RANGE(10)
- }
+ UNI_RANGE(5),
+ UNI_RANGE(10),
+ BIP_RANGE(5),
+ BIP_RANGE(10)
+ }
};
static const struct comedi_lrange range_pci171x_da = { 2, {
- UNI_RANGE(5),
- UNI_RANGE(10),
- }
+ UNI_RANGE(5),
+ UNI_RANGE(10),
+ }
};
-static int pci1710_attach(struct comedi_device *dev, struct comedi_devconfig *it);
+static int pci1710_attach(struct comedi_device *dev,
+ struct comedi_devconfig *it);
static int pci1710_detach(struct comedi_device *dev);
struct boardtype {
@@ -209,49 +211,50 @@ struct boardtype {
};
static DEFINE_PCI_DEVICE_TABLE(pci1710_pci_table) = {
- {PCI_VENDOR_ID_ADVANTECH, 0x1710, PCI_ANY_ID, PCI_ANY_ID, 0, 0, 0},
- {PCI_VENDOR_ID_ADVANTECH, 0x1711, PCI_ANY_ID, PCI_ANY_ID, 0, 0, 0},
- {PCI_VENDOR_ID_ADVANTECH, 0x1713, PCI_ANY_ID, PCI_ANY_ID, 0, 0, 0},
- {PCI_VENDOR_ID_ADVANTECH, 0x1720, PCI_ANY_ID, PCI_ANY_ID, 0, 0, 0},
- {PCI_VENDOR_ID_ADVANTECH, 0x1731, PCI_ANY_ID, PCI_ANY_ID, 0, 0, 0},
- {0}
+ {
+ PCI_VENDOR_ID_ADVANTECH, 0x1710, PCI_ANY_ID, PCI_ANY_ID, 0, 0, 0}, {
+ PCI_VENDOR_ID_ADVANTECH, 0x1711, PCI_ANY_ID, PCI_ANY_ID, 0, 0, 0}, {
+ PCI_VENDOR_ID_ADVANTECH, 0x1713, PCI_ANY_ID, PCI_ANY_ID, 0, 0, 0}, {
+ PCI_VENDOR_ID_ADVANTECH, 0x1720, PCI_ANY_ID, PCI_ANY_ID, 0, 0, 0}, {
+ PCI_VENDOR_ID_ADVANTECH, 0x1731, PCI_ANY_ID, PCI_ANY_ID, 0, 0, 0}, {
+ 0}
};
MODULE_DEVICE_TABLE(pci, pci1710_pci_table);
static const struct boardtype boardtypes[] = {
{"pci1710", 0x1710,
- IORANGE_171x, 1, TYPE_PCI171X,
- 16, 8, 2, 16, 16, 1, 0x0fff, 0x0fff,
- &range_pci1710_3, range_codes_pci1710_3,
- &range_pci171x_da,
- 10000, 2048},
+ IORANGE_171x, 1, TYPE_PCI171X,
+ 16, 8, 2, 16, 16, 1, 0x0fff, 0x0fff,
+ &range_pci1710_3, range_codes_pci1710_3,
+ &range_pci171x_da,
+ 10000, 2048},
{"pci1710hg", 0x1710,
- IORANGE_171x, 1, TYPE_PCI171X,
- 16, 8, 2, 16, 16, 1, 0x0fff, 0x0fff,
- &range_pci1710hg, range_codes_pci1710hg,
- &range_pci171x_da,
- 10000, 2048},
+ IORANGE_171x, 1, TYPE_PCI171X,
+ 16, 8, 2, 16, 16, 1, 0x0fff, 0x0fff,
+ &range_pci1710hg, range_codes_pci1710hg,
+ &range_pci171x_da,
+ 10000, 2048},
{"pci1711", 0x1711,
- IORANGE_171x, 1, TYPE_PCI171X,
- 16, 0, 2, 16, 16, 1, 0x0fff, 0x0fff,
- &range_pci17x1, range_codes_pci17x1, &range_pci171x_da,
- 10000, 512},
+ IORANGE_171x, 1, TYPE_PCI171X,
+ 16, 0, 2, 16, 16, 1, 0x0fff, 0x0fff,
+ &range_pci17x1, range_codes_pci17x1, &range_pci171x_da,
+ 10000, 512},
{"pci1713", 0x1713,
- IORANGE_171x, 1, TYPE_PCI1713,
- 32, 16, 0, 0, 0, 0, 0x0fff, 0x0000,
- &range_pci1710_3, range_codes_pci1710_3, NULL,
- 10000, 2048},
+ IORANGE_171x, 1, TYPE_PCI1713,
+ 32, 16, 0, 0, 0, 0, 0x0fff, 0x0000,
+ &range_pci1710_3, range_codes_pci1710_3, NULL,
+ 10000, 2048},
{"pci1720", 0x1720,
- IORANGE_1720, 0, TYPE_PCI1720,
- 0, 0, 4, 0, 0, 0, 0x0000, 0x0fff,
- NULL, NULL, &range_pci1720,
- 0, 0},
+ IORANGE_1720, 0, TYPE_PCI1720,
+ 0, 0, 4, 0, 0, 0, 0x0000, 0x0fff,
+ NULL, NULL, &range_pci1720,
+ 0, 0},
{"pci1731", 0x1731,
- IORANGE_171x, 1, TYPE_PCI171X,
- 16, 0, 0, 16, 16, 0, 0x0fff, 0x0000,
- &range_pci17x1, range_codes_pci17x1, NULL,
- 10000, 512},
+ IORANGE_171x, 1, TYPE_PCI171X,
+ 16, 0, 0, 16, 16, 0, 0x0fff, 0x0000,
+ &range_pci17x1, range_codes_pci17x1, NULL,
+ 10000, 512},
/* dummy entry corresponding to driver name */
{.name = DRV_NAME},
};
@@ -292,7 +295,7 @@ struct pci1710_private {
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 */
+ short *ai_data; /* data buffer */
unsigned int ai_timer1; /* timers */
unsigned int ai_timer2;
short ao_data[4]; /* data output buffer */
@@ -306,14 +309,18 @@ struct pci1710_private {
==============================================================================
*/
-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,
- unsigned int *chanlist, unsigned int n_chan, unsigned int seglen);
-static void start_pacer(struct comedi_device *dev, int mode, unsigned int divisor1,
- unsigned int divisor2);
+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,
+ unsigned int *chanlist, unsigned int n_chan,
+ unsigned int seglen);
+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 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 */
0x0808, 0x0909, 0x0a0a, 0x0b0b, 0x0c0c, 0x0d0d, 0x0e0e, 0x0f0f,
@@ -324,8 +331,9 @@ 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
@@ -364,10 +372,12 @@ static int pci171x_insn_read_ai(struct comedi_device *dev, struct comedi_subdevi
outb(0, dev->iobase + PCI171x_CLRFIFO);
outb(0, dev->iobase + PCI171x_CLRINT);
data[n] = 0;
- DPRINTK("adv_pci1710 EDBG: END: pci171x_insn_read_ai(...) n=%d\n", n);
+ DPRINTK
+ ("adv_pci1710 EDBG: END: pci171x_insn_read_ai(...) n=%d\n",
+ n);
return -ETIME;
- conv_finish:
+conv_finish:
#ifdef PCI171x_PARANOIDCHECK
idata = inw(dev->iobase + PCI171x_AD_DATA);
if (this_board->cardtype != TYPE_PCI1713)
@@ -392,8 +402,9 @@ static int pci171x_insn_read_ai(struct comedi_device *dev, struct comedi_subdevi
/*
==============================================================================
*/
-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;
@@ -423,8 +434,9 @@ static int pci171x_insn_write_ao(struct comedi_device *dev, struct comedi_subdev
/*
==============================================================================
*/
-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;
@@ -438,8 +450,9 @@ static int pci171x_insn_read_ao(struct comedi_device *dev, struct comedi_subdevi
/*
==============================================================================
*/
-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);
@@ -449,8 +462,9 @@ static int pci171x_insn_bits_di(struct comedi_device *dev, struct comedi_subdevi
/*
==============================================================================
*/
-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];
@@ -465,8 +479,10 @@ static int pci171x_insn_bits_do(struct comedi_device *dev, struct comedi_subdevi
/*
==============================================================================
*/
-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;
@@ -487,8 +503,10 @@ static int pci171x_insn_counter_read(struct comedi_device *dev, struct comedi_su
/*
==============================================================================
*/
-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;
@@ -515,7 +533,9 @@ static int pci171x_insn_counter_write(struct comedi_device *dev, struct comedi_s
==============================================================================
*/
static int pci171x_insn_counter_config(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)
{
#ifdef unused
/* This doesn't work like a normal Comedi counter config */
@@ -550,8 +570,9 @@ 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;
@@ -596,8 +617,8 @@ static void interrupt_pci1710_every_sample(void *d)
}
if (m & Status_FF) {
printk
- ("comedi%d: A/D FIFO Full status (Fatal Error!) (%4x)\n",
- dev->minor, m);
+ ("comedi%d: A/D FIFO Full status (Fatal Error!) (%4x)\n",
+ dev->minor, m);
pci171x_ai_cancel(dev, s);
s->async->events |= COMEDI_CB_EOA | COMEDI_CB_ERROR;
comedi_event(dev, s);
@@ -613,16 +634,17 @@ static void interrupt_pci1710_every_sample(void *d)
DPRINTK("%04x:", sampl);
if (this_board->cardtype != TYPE_PCI1713)
if ((sampl & 0xf000) !=
- devpriv->act_chanlist[s->async->cur_chan]) {
+ devpriv->act_chanlist[s->async->cur_chan]) {
printk
- ("comedi: A/D data dropout: received data from channel %d, expected %d!\n",
- (sampl & 0xf000) >> 12,
- (devpriv->act_chanlist[s->async->
- cur_chan] & 0xf000) >>
- 12);
+ ("comedi: A/D data dropout: received data from channel %d, expected %d!\n",
+ (sampl & 0xf000) >> 12,
+ (devpriv->
+ act_chanlist[s->
+ async->cur_chan] & 0xf000) >>
+ 12);
pci171x_ai_cancel(dev, s);
s->async->events |=
- COMEDI_CB_EOA | COMEDI_CB_ERROR;
+ COMEDI_CB_EOA | COMEDI_CB_ERROR;
comedi_event(dev, s);
return;
}
@@ -631,7 +653,7 @@ static void interrupt_pci1710_every_sample(void *d)
comedi_buf_put(s->async, sampl & 0x0fff);
#else
comedi_buf_put(s->async,
- inw(dev->iobase + PCI171x_AD_DATA) & 0x0fff);
+ inw(dev->iobase + PCI171x_AD_DATA) & 0x0fff);
#endif
++s->async->cur_chan;
@@ -641,7 +663,10 @@ static void interrupt_pci1710_every_sample(void *d)
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: 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 */
pci171x_ai_cancel(dev, s);
@@ -661,8 +686,8 @@ static void interrupt_pci1710_every_sample(void *d)
/*
==============================================================================
*/
-static int move_block_from_fifo(struct comedi_device *dev, struct comedi_subdevice *s,
- int n, int turn)
+static int move_block_from_fifo(struct comedi_device *dev,
+ struct comedi_subdevice *s, int n, int turn)
{
int i, j;
#ifdef PCI171x_PARANOIDCHECK
@@ -677,22 +702,21 @@ static int move_block_from_fifo(struct comedi_device *dev, struct comedi_subdevi
if (this_board->cardtype != TYPE_PCI1713)
if ((sampl & 0xf000) != devpriv->act_chanlist[j]) {
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->
- act_chanlist[j] & 0xf000) >> 12,
- i, j, devpriv->ai_act_scan, n, turn,
- sampl);
+ ("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->act_chanlist[j] & 0xf000) >> 12,
+ i, j, devpriv->ai_act_scan, n, turn,
+ sampl);
pci171x_ai_cancel(dev, s);
s->async->events |=
- COMEDI_CB_EOA | COMEDI_CB_ERROR;
+ COMEDI_CB_EOA | COMEDI_CB_ERROR;
comedi_event(dev, s);
return 1;
}
comedi_buf_put(s->async, sampl & 0x0fff);
#else
comedi_buf_put(s->async,
- inw(dev->iobase + PCI171x_AD_DATA) & 0x0fff);
+ inw(dev->iobase + PCI171x_AD_DATA) & 0x0fff);
#endif
j++;
if (j >= devpriv->ai_n_chan) {
@@ -717,7 +741,7 @@ static void interrupt_pci1710_half_fifo(void *d)
m = inw(dev->iobase + PCI171x_STATUS);
if (!(m & Status_FH)) {
printk("comedi%d: A/D FIFO not half full! (%4x)\n",
- dev->minor, m);
+ dev->minor, m);
pci171x_ai_cancel(dev, s);
s->async->events |= COMEDI_CB_EOA | COMEDI_CB_ERROR;
comedi_event(dev, s);
@@ -725,8 +749,8 @@ static void interrupt_pci1710_half_fifo(void *d)
}
if (m & Status_FF) {
printk
- ("comedi%d: A/D FIFO Full status (Fatal Error!) (%4x)\n",
- dev->minor, m);
+ ("comedi%d: A/D FIFO Full status (Fatal Error!) (%4x)\n",
+ dev->minor, m);
pci171x_ai_cancel(dev, s);
s->async->events |= COMEDI_CB_EOA | COMEDI_CB_ERROR;
comedi_event(dev, s);
@@ -804,7 +828,7 @@ static irqreturn_t interrupt_service_pci1710(int irq, void *d)
==============================================================================
*/
static int pci171x_ai_docmd_and_mode(int mode, struct comedi_device *dev,
- struct comedi_subdevice *s)
+ struct comedi_subdevice *s)
{
unsigned int divisor1, divisor2;
unsigned int seglen;
@@ -814,11 +838,11 @@ static int pci171x_ai_docmd_and_mode(int mode, struct comedi_device *dev,
start_pacer(dev, -1, 0, 0); /* stop pacer */
seglen = check_channel_list(dev, s, devpriv->ai_chanlist,
- devpriv->ai_n_chan);
+ devpriv->ai_n_chan);
if (seglen < 1)
return -EINVAL;
setup_channel_list(dev, s, devpriv->ai_chanlist,
- devpriv->ai_n_chan, seglen);
+ devpriv->ai_n_chan, seglen);
outb(0, dev->iobase + PCI171x_CLRFIFO);
outb(0, dev->iobase + PCI171x_CLRINT);
@@ -840,7 +864,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;
}
@@ -853,16 +877,19 @@ static int pci171x_ai_docmd_and_mode(int mode, struct comedi_device *dev,
if (mode == 2) {
devpriv->ai_et_CntrlReg = devpriv->CntrlReg;
devpriv->CntrlReg &=
- ~(Control_PACER | Control_ONEFH | Control_GATE);
+ ~(Control_PACER | Control_ONEFH | Control_GATE);
devpriv->CntrlReg |= Control_EXT;
devpriv->ai_et = 1;
} else {
devpriv->ai_et = 0;
}
i8253_cascade_ns_to_timer(devpriv->i8254_osc_base, &divisor1,
- &divisor2, &devpriv->ai_timer1,
- devpriv->ai_flags & TRIG_ROUND_MASK);
- DPRINTK("adv_pci1710 EDBG: OSC base=%u div1=%u div2=%u timer=%u\n", devpriv->i8254_osc_base, divisor1, divisor2, devpriv->ai_timer1);
+ &divisor2, &devpriv->ai_timer1,
+ devpriv->ai_flags & TRIG_ROUND_MASK);
+ 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 */
@@ -889,21 +916,22 @@ static int pci171x_ai_docmd_and_mode(int mode, struct comedi_device *dev,
static void pci171x_cmdtest_out(int e, struct comedi_cmd *cmd)
{
printk("adv_pci1710 e=%d startsrc=%x scansrc=%x convsrc=%x\n", e,
- cmd->start_src, cmd->scan_begin_src, cmd->convert_src);
+ cmd->start_src, cmd->scan_begin_src, cmd->convert_src);
printk("adv_pci1710 e=%d startarg=%d scanarg=%d convarg=%d\n", e,
- cmd->start_arg, cmd->scan_begin_arg, cmd->convert_arg);
+ cmd->start_arg, cmd->scan_begin_arg, cmd->convert_arg);
printk("adv_pci1710 e=%d stopsrc=%x scanend=%x\n", e, cmd->stop_src,
- cmd->scan_end_src);
+ cmd->scan_end_src);
printk("adv_pci1710 e=%d stoparg=%d scanendarg=%d chanlistlen=%d\n",
- e, cmd->stop_arg, cmd->scan_end_arg, cmd->chanlist_len);
+ e, cmd->stop_arg, cmd->scan_end_arg, cmd->chanlist_len);
}
#endif
/*
==============================================================================
*/
-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;
@@ -943,7 +971,9 @@ static int pci171x_ai_cmdtest(struct comedi_device *dev, struct comedi_subdevice
#ifdef PCI171X_EXTDEBUG
pci171x_cmdtest_out(1, cmd);
#endif
- DPRINTK("adv_pci1710 EDBG: BGN: pci171x_ai_cmdtest(...) err=%d ret=1\n", err);
+ DPRINTK
+ ("adv_pci1710 EDBG: BGN: pci171x_ai_cmdtest(...) err=%d ret=1\n",
+ err);
return 1;
}
@@ -974,7 +1004,9 @@ static int pci171x_ai_cmdtest(struct comedi_device *dev, struct comedi_subdevice
#ifdef PCI171X_EXTDEBUG
pci171x_cmdtest_out(2, cmd);
#endif
- DPRINTK("adv_pci1710 EDBG: BGN: pci171x_ai_cmdtest(...) err=%d ret=2\n", err);
+ DPRINTK
+ ("adv_pci1710 EDBG: BGN: pci171x_ai_cmdtest(...) err=%d ret=2\n",
+ err);
return 2;
}
@@ -1030,7 +1062,9 @@ static int pci171x_ai_cmdtest(struct comedi_device *dev, struct comedi_subdevice
#ifdef PCI171X_EXTDEBUG
pci171x_cmdtest_out(3, cmd);
#endif
- DPRINTK("adv_pci1710 EDBG: BGN: pci171x_ai_cmdtest(...) err=%d ret=3\n", err);
+ DPRINTK
+ ("adv_pci1710 EDBG: BGN: pci171x_ai_cmdtest(...) err=%d ret=3\n",
+ err);
return 3;
}
@@ -1039,8 +1073,8 @@ static int pci171x_ai_cmdtest(struct comedi_device *dev, struct comedi_subdevice
if (cmd->convert_src == TRIG_TIMER) {
tmp = cmd->convert_arg;
i8253_cascade_ns_to_timer(devpriv->i8254_osc_base, &divisor1,
- &divisor2, &cmd->convert_arg,
- cmd->flags & TRIG_ROUND_MASK);
+ &divisor2, &cmd->convert_arg,
+ cmd->flags & TRIG_ROUND_MASK);
if (cmd->convert_arg < this_board->ai_ns_min)
cmd->convert_arg = this_board->ai_ns_min;
if (tmp != cmd->convert_arg)
@@ -1048,7 +1082,9 @@ static int pci171x_ai_cmdtest(struct comedi_device *dev, struct comedi_subdevice
}
if (err) {
- DPRINTK("adv_pci1710 EDBG: BGN: pci171x_ai_cmdtest(...) err=%d ret=4\n", err);
+ DPRINTK
+ ("adv_pci1710 EDBG: BGN: pci171x_ai_cmdtest(...) err=%d ret=4\n",
+ err);
return 4;
}
@@ -1056,7 +1092,7 @@ static int pci171x_ai_cmdtest(struct comedi_device *dev, struct comedi_subdevice
if (cmd->chanlist) {
if (!check_channel_list(dev, s, cmd->chanlist,
- cmd->chanlist_len))
+ cmd->chanlist_len))
return 5; /* incorrect channels list */
}
@@ -1090,7 +1126,8 @@ static int pci171x_ai_cmd(struct comedi_device *dev, struct comedi_subdevice *s)
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);
+ TRIG_EXT ? 2 : 1, dev,
+ s);
}
if (cmd->convert_src == TRIG_EXT) { /* mode 3 */
return pci171x_ai_docmd_and_mode(3, dev, s);
@@ -1106,8 +1143,9 @@ static int pci171x_ai_cmd(struct comedi_device *dev, struct comedi_subdevice *s)
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,
- unsigned int *chanlist, unsigned int n_chan)
+static int check_channel_list(struct comedi_device *dev,
+ struct comedi_subdevice *s,
+ unsigned int *chanlist, unsigned int n_chan)
{
unsigned int chansegment[32];
unsigned int i, nowmustbechan, seglen, segpos;
@@ -1128,18 +1166,18 @@ static int check_channel_list(struct comedi_device *dev, struct comedi_subdevice
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");
+ "Odd channel can't be differential input!\n");
return 0;
}
nowmustbechan =
- (CR_CHAN(chansegment[i - 1]) + 1) % s->n_chan;
+ (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 :-( */
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]));
+ ("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 */
@@ -1149,13 +1187,13 @@ static int check_channel_list(struct comedi_device *dev, struct comedi_subdevice
/* 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]) {
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]),
- CR_AREF(chansegment[i]),
- CR_CHAN(chanlist[i % seglen]),
- CR_RANGE(chanlist[i % seglen]),
- CR_AREF(chansegment[i % seglen]));
+ ("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]),
+ CR_AREF(chansegment[i]),
+ CR_CHAN(chanlist[i % seglen]),
+ CR_RANGE(chanlist[i % seglen]),
+ CR_AREF(chansegment[i % seglen]));
return 0; /* chan/gain list is strange */
}
}
@@ -1165,8 +1203,10 @@ static int check_channel_list(struct comedi_device *dev, struct comedi_subdevice
return seglen;
}
-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 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;
@@ -1185,14 +1225,14 @@ static void setup_channel_list(struct comedi_device *dev, struct comedi_subdevic
outw(range, dev->iobase + PCI171x_RANGE); /* select gain */
#ifdef PCI171x_PARANOIDCHECK
devpriv->act_chanlist[i] =
- (CR_CHAN(chanlist[i]) << 12) & 0xf000;
+ (CR_CHAN(chanlist[i]) << 12) & 0xf000;
#endif
DPRINTK("GS: %2d. [%4x]=%4x %4x\n", i, chanprog, range,
devpriv->act_chanlist[i]);
}
devpriv->ai_et_MuxVal =
- CR_CHAN(chanlist[0]) | (CR_CHAN(chanlist[seglen - 1]) << 8);
+ CR_CHAN(chanlist[0]) | (CR_CHAN(chanlist[seglen - 1]) << 8);
outw(devpriv->ai_et_MuxVal, dev->iobase + PCI171x_MUX); /* select channel interval to scan */
DPRINTK("MUX: %4x L%4x.H%4x\n",
CR_CHAN(chanlist[0]) | (CR_CHAN(chanlist[seglen - 1]) << 8),
@@ -1202,8 +1242,8 @@ static void setup_channel_list(struct comedi_device *dev, struct comedi_subdevic
/*
==============================================================================
*/
-static void start_pacer(struct comedi_device *dev, int mode, unsigned int divisor1,
- unsigned int divisor2)
+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,
divisor1, divisor2);
@@ -1222,7 +1262,8 @@ static void start_pacer(struct comedi_device *dev, int mode, unsigned int diviso
/*
==============================================================================
*/
-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");
@@ -1318,7 +1359,8 @@ 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;
@@ -1347,36 +1389,35 @@ static int pci1710_attach(struct comedi_device *dev, struct comedi_devconfig *it
pcidev = NULL;
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)
- {
- for (i = 0; i < n_boardtypes; ++i)
- {
- if (pcidev->device == boardtypes[i].device_id)
- {
+ PCI_ANY_ID, pcidev))) {
+ if (strcmp(this_board->name, DRV_NAME) == 0) {
+ for (i = 0; i < n_boardtypes; ++i) {
+ if (pcidev->device == boardtypes[i].device_id) {
board_index = i;
break;
}
}
- if (i == n_boardtypes) continue;
- }else
- {
- if (pcidev->device != boardtypes[board_index].device_id) continue;
+ if (i == n_boardtypes)
+ continue;
+ } else {
+ if (pcidev->device != boardtypes[board_index].device_id)
+ continue;
}
/* Found matching vendor/device. */
if (opt_bus || opt_slot) {
/* Check bus/slot. */
if (opt_bus != pcidev->bus->number
- || opt_slot != PCI_SLOT(pcidev->devfn))
+ || opt_slot != PCI_SLOT(pcidev->devfn))
continue; /* no match */
}
/*
- * Look for device that isn't in use.
- * Enable PCI device and request regions.
- */
+ * Look for device that isn't in use.
+ * Enable PCI device and request regions.
+ */
if (comedi_pci_enable(pcidev, DRV_NAME)) {
- errstr = "failed to enable PCI device and request regions!";
+ 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 */
@@ -1387,7 +1428,7 @@ static int pci1710_attach(struct comedi_device *dev, struct comedi_devconfig *it
if (!pcidev) {
if (opt_bus || opt_slot) {
printk(" - Card at b:s %d:%d %s\n",
- opt_bus, opt_slot, errstr);
+ opt_bus, opt_slot, errstr);
} else {
printk(" - Card %s\n", errstr);
}
@@ -1401,7 +1442,7 @@ static int pci1710_attach(struct comedi_device *dev, struct comedi_devconfig *it
iobase = pci_resource_start(pcidev, 2);
printk(", b:s:f=%d:%d:%d, io=0x%4lx", pci_bus, pci_slot, pci_func,
- iobase);
+ iobase);
dev->iobase = iobase;
@@ -1434,8 +1475,8 @@ static int pci1710_attach(struct comedi_device *dev, struct comedi_devconfig *it
IRQF_SHARED, "Advantech PCI-1710",
dev)) {
printk
- (", unable to allocate IRQ %d, DISABLING IT",
- irq);
+ (", unable to allocate IRQ %d, DISABLING IT",
+ irq);
irq = 0; /* Can't use IRQ */
} else {
printk(", irq=%u", irq);
diff --git a/drivers/staging/comedi/drivers/adv_pci1723.c b/drivers/staging/comedi/drivers/adv_pci1723.c
index e1994a5290bd..6b0b7eda3be8 100644
--- a/drivers/staging/comedi/drivers/adv_pci1723.c
+++ b/drivers/staging/comedi/drivers/adv_pci1723.c
@@ -95,8 +95,8 @@ TODO:
/* static unsigned short pci_list_builded=0; =1 list of card is know */
static const struct comedi_lrange range_pci1723 = { 1, {
- BIP_RANGE(10)
- }
+ BIP_RANGE(10)
+ }
};
/*
@@ -116,23 +116,24 @@ struct pci1723_board {
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,
+ },
};
/* 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(pci1723_pci_table) = {
- {PCI_VENDOR_ID_ADVANTECH, 0x1723, PCI_ANY_ID, PCI_ANY_ID, 0, 0, 0},
- {0}
+ {
+ PCI_VENDOR_ID_ADVANTECH, 0x1723, PCI_ANY_ID, PCI_ANY_ID, 0, 0, 0}, {
+ 0}
};
MODULE_DEVICE_TABLE(pci, pci1723_pci_table);
@@ -143,7 +144,8 @@ 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_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))
@@ -189,7 +191,7 @@ static int pci1723_reset(struct comedi_device *dev)
/* set all ranges to +/- 10V */
devpriv->da_range[i] = 0;
outw(((devpriv->da_range[i] << 4) | i),
- PCI1723_RANGE_CALIBRATION_MODE);
+ PCI1723_RANGE_CALIBRATION_MODE);
}
outw(0, dev->iobase + PCI1723_CHANGE_CHA_OUTPUT_TYPE_STROBE); /* update ranges */
@@ -202,8 +204,9 @@ static int pci1723_reset(struct comedi_device *dev)
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 +221,9 @@ static int pci1723_insn_read_ao(struct comedi_device *dev, struct comedi_subdevi
/*
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 +242,9 @@ static int pci1723_ao_write_winsn(struct comedi_device *dev, struct comedi_subde
/*
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;
@@ -278,8 +283,9 @@ static int pci1723_dio_insn_config(struct comedi_device *dev, struct comedi_subd
/*
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 +300,8 @@ static int pci1723_dio_insn_bits(struct comedi_device *dev, struct comedi_subdev
* 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,8 +311,7 @@ static int pci1723_attach(struct comedi_device *dev, struct comedi_devconfig *it
int opt_bus, opt_slot;
const char *errstr;
- printk("comedi%d: adv_pci1723: board=%s", dev->minor,
- this_board->name);
+ printk("comedi%d: adv_pci1723: board=%s", dev->minor, this_board->name);
opt_bus = it->options[0];
opt_slot = it->options[1];
@@ -321,12 +327,12 @@ static int pci1723_attach(struct comedi_device *dev, struct comedi_devconfig *it
pcidev = NULL;
while (NULL != (pcidev =
pci_get_device(PCI_VENDOR_ID_ADVANTECH,
- this_board->device_id, pcidev))) {
+ this_board->device_id, pcidev))) {
/* Found matching vendor/device. */
if (opt_bus || opt_slot) {
/* Check bus/slot. */
if (opt_bus != pcidev->bus->number
- || opt_slot != PCI_SLOT(pcidev->devfn))
+ || opt_slot != PCI_SLOT(pcidev->devfn))
continue; /* no match */
}
/*
@@ -334,7 +340,8 @@ static int pci1723_attach(struct comedi_device *dev, struct comedi_devconfig *it
* Enable PCI device and request regions.
*/
if (comedi_pci_enable(pcidev, "adv_pci1723")) {
- errstr = "failed to enable PCI device and request regions!";
+ errstr =
+ "failed to enable PCI device and request regions!";
continue;
}
break;
@@ -343,7 +350,7 @@ static int pci1723_attach(struct comedi_device *dev, struct comedi_devconfig *it
if (!pcidev) {
if (opt_bus || opt_slot) {
printk(" - Card at b:s %d:%d %s\n",
- opt_bus, opt_slot, errstr);
+ opt_bus, opt_slot, errstr);
} else {
printk(" - Card %s\n", errstr);
}
@@ -356,7 +363,7 @@ static int pci1723_attach(struct comedi_device *dev, struct comedi_devconfig *it
iobase = pci_resource_start(pcidev, 2);
printk(", b:s:f=%d:%d:%d, io=0x%4x", pci_bus, pci_slot, pci_func,
- iobase);
+ iobase);
dev->iobase = iobase;
@@ -416,7 +423,7 @@ static int pci1723_attach(struct comedi_device *dev, struct comedi_devconfig *it
s = dev->subdevices + subdev;
s->type = COMEDI_SUBD_DIO;
s->subdev_flags =
- SDF_READABLE | SDF_WRITABLE | SDF_GROUND | SDF_COMMON;
+ SDF_READABLE | SDF_WRITABLE | SDF_GROUND | SDF_COMMON;
s->n_chan = this_board->n_diochan;
s->maxdata = 1;
s->len_chanlist = this_board->n_diochan;
diff --git a/drivers/staging/comedi/drivers/adv_pci_dio.c b/drivers/staging/comedi/drivers/adv_pci_dio.c
index 5a8c0a3bb2f8..61d35fe64350 100644
--- a/drivers/staging/comedi/drivers/adv_pci_dio.c
+++ b/drivers/staging/comedi/drivers/adv_pci_dio.c
@@ -84,13 +84,13 @@ enum hw_io_access {
#define PCI173x_BOARDID 4 /* R: Board I/D switch for 1730/3/4 */
/* Advantech PCI-1736UP */
-#define PCI1736_IDI 0 /* R: Isolated digital input 0-15 */
-#define PCI1736_IDO 0 /* W: Isolated digital output 0-15 */
-#define PCI1736_3_INT_EN 0x08 /* R/W: enable/disable interrupts */
-#define PCI1736_3_INT_RF 0x0c /* R/W: set falling/raising edge for interrupts */
-#define PCI1736_3_INT_CLR 0x10 /* R/W: clear interrupts */
-#define PCI1736_BOARDID 4 /* R: Board I/D switch for 1736UP */
-#define PCI1736_MAINREG 0 /* Normal register (2) doesn't work */
+#define PCI1736_IDI 0 /* R: Isolated digital input 0-15 */
+#define PCI1736_IDO 0 /* W: Isolated digital output 0-15 */
+#define PCI1736_3_INT_EN 0x08 /* R/W: enable/disable interrupts */
+#define PCI1736_3_INT_RF 0x0c /* R/W: set falling/raising edge for interrupts */
+#define PCI1736_3_INT_CLR 0x10 /* R/W: clear interrupts */
+#define PCI1736_BOARDID 4 /* R: Board I/D switch for 1736UP */
+#define PCI1736_MAINREG 0 /* Normal register (2) doesn't work */
/* Advantech PCI-1750 */
#define PCI1750_IDI 0 /* R: Isolated digital input 0-15 */
@@ -183,7 +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_attach(struct comedi_device *dev,
+ struct comedi_devconfig *it);
static int pci_dio_detach(struct comedi_device *dev);
struct diosubd_data {
@@ -207,117 +208,118 @@ struct dio_boardtype {
};
static DEFINE_PCI_DEVICE_TABLE(pci_dio_pci_table) = {
- {PCI_VENDOR_ID_ADVANTECH, 0x1730, PCI_ANY_ID, PCI_ANY_ID, 0, 0, 0},
- {PCI_VENDOR_ID_ADVANTECH, 0x1733, PCI_ANY_ID, PCI_ANY_ID, 0, 0, 0},
- {PCI_VENDOR_ID_ADVANTECH, 0x1734, PCI_ANY_ID, PCI_ANY_ID, 0, 0, 0},
- {PCI_VENDOR_ID_ADVANTECH, 0x1736, PCI_ANY_ID, PCI_ANY_ID, 0, 0, 0},
- {PCI_VENDOR_ID_ADVANTECH, 0x1750, PCI_ANY_ID, PCI_ANY_ID, 0, 0, 0},
- {PCI_VENDOR_ID_ADVANTECH, 0x1751, PCI_ANY_ID, PCI_ANY_ID, 0, 0, 0},
- {PCI_VENDOR_ID_ADVANTECH, 0x1752, PCI_ANY_ID, PCI_ANY_ID, 0, 0, 0},
- {PCI_VENDOR_ID_ADVANTECH, 0x1753, PCI_ANY_ID, PCI_ANY_ID, 0, 0, 0},
- {PCI_VENDOR_ID_ADVANTECH, 0x1754, PCI_ANY_ID, PCI_ANY_ID, 0, 0, 0},
- {PCI_VENDOR_ID_ADVANTECH, 0x1756, PCI_ANY_ID, PCI_ANY_ID, 0, 0, 0},
- {PCI_VENDOR_ID_ADVANTECH, 0x1760, PCI_ANY_ID, PCI_ANY_ID, 0, 0, 0},
- {PCI_VENDOR_ID_ADVANTECH, 0x1762, PCI_ANY_ID, PCI_ANY_ID, 0, 0, 0},
- {0}
+ {
+ PCI_VENDOR_ID_ADVANTECH, 0x1730, PCI_ANY_ID, PCI_ANY_ID, 0, 0, 0}, {
+ PCI_VENDOR_ID_ADVANTECH, 0x1733, PCI_ANY_ID, PCI_ANY_ID, 0, 0, 0}, {
+ PCI_VENDOR_ID_ADVANTECH, 0x1734, PCI_ANY_ID, PCI_ANY_ID, 0, 0, 0}, {
+ PCI_VENDOR_ID_ADVANTECH, 0x1736, PCI_ANY_ID, PCI_ANY_ID, 0, 0, 0}, {
+ PCI_VENDOR_ID_ADVANTECH, 0x1750, PCI_ANY_ID, PCI_ANY_ID, 0, 0, 0}, {
+ PCI_VENDOR_ID_ADVANTECH, 0x1751, PCI_ANY_ID, PCI_ANY_ID, 0, 0, 0}, {
+ PCI_VENDOR_ID_ADVANTECH, 0x1752, PCI_ANY_ID, PCI_ANY_ID, 0, 0, 0}, {
+ PCI_VENDOR_ID_ADVANTECH, 0x1753, PCI_ANY_ID, PCI_ANY_ID, 0, 0, 0}, {
+ PCI_VENDOR_ID_ADVANTECH, 0x1754, PCI_ANY_ID, PCI_ANY_ID, 0, 0, 0}, {
+ PCI_VENDOR_ID_ADVANTECH, 0x1756, PCI_ANY_ID, PCI_ANY_ID, 0, 0, 0}, {
+ PCI_VENDOR_ID_ADVANTECH, 0x1760, PCI_ANY_ID, PCI_ANY_ID, 0, 0, 0}, {
+ PCI_VENDOR_ID_ADVANTECH, 0x1762, PCI_ANY_ID, PCI_ANY_ID, 0, 0, 0}, {
+ 0}
};
MODULE_DEVICE_TABLE(pci, pci_dio_pci_table);
static const struct dio_boardtype boardtypes[] = {
{"pci1730", PCI_VENDOR_ID_ADVANTECH, 0x1730, PCIDIO_MAINREG,
- TYPE_PCI1730,
- {{16, PCI1730_DI, 2, 0}, {16, PCI1730_IDI, 2, 0}},
- {{16, PCI1730_DO, 2, 0}, {16, PCI1730_IDO, 2, 0}},
- {{0, 0, 0, 0}, {0, 0, 0, 0}},
- {4, PCI173x_BOARDID, 1, SDF_INTERNAL},
- IO_8b,
- },
+ TYPE_PCI1730,
+ {{16, PCI1730_DI, 2, 0}, {16, PCI1730_IDI, 2, 0}},
+ {{16, PCI1730_DO, 2, 0}, {16, PCI1730_IDO, 2, 0}},
+ {{0, 0, 0, 0}, {0, 0, 0, 0}},
+ {4, PCI173x_BOARDID, 1, SDF_INTERNAL},
+ IO_8b,
+ },
{"pci1733", PCI_VENDOR_ID_ADVANTECH, 0x1733, PCIDIO_MAINREG,
- TYPE_PCI1733,
- {{0, 0, 0, 0}, {32, PCI1733_IDI, 4, 0}},
- {{0, 0, 0, 0}, {0, 0, 0, 0}},
- {{0, 0, 0, 0}, {0, 0, 0, 0}},
- {4, PCI173x_BOARDID, 1, SDF_INTERNAL},
- IO_8b},
+ TYPE_PCI1733,
+ {{0, 0, 0, 0}, {32, PCI1733_IDI, 4, 0}},
+ {{0, 0, 0, 0}, {0, 0, 0, 0}},
+ {{0, 0, 0, 0}, {0, 0, 0, 0}},
+ {4, PCI173x_BOARDID, 1, SDF_INTERNAL},
+ IO_8b},
{"pci1734", PCI_VENDOR_ID_ADVANTECH, 0x1734, PCIDIO_MAINREG,
- TYPE_PCI1734,
- {{0, 0, 0, 0}, {0, 0, 0, 0}},
- {{0, 0, 0, 0}, {32, PCI1734_IDO, 4, 0}},
- {{0, 0, 0, 0}, {0, 0, 0, 0}},
- {4, PCI173x_BOARDID, 1, SDF_INTERNAL},
- IO_8b},
+ TYPE_PCI1734,
+ {{0, 0, 0, 0}, {0, 0, 0, 0}},
+ {{0, 0, 0, 0}, {32, PCI1734_IDO, 4, 0}},
+ {{0, 0, 0, 0}, {0, 0, 0, 0}},
+ {4, PCI173x_BOARDID, 1, SDF_INTERNAL},
+ IO_8b},
{"pci1736", PCI_VENDOR_ID_ADVANTECH, 0x1736, PCI1736_MAINREG,
- TYPE_PCI1736,
- {{0, 0, 0, 0}, {16, PCI1736_IDI, 2, 0}},
- {{0, 0, 0, 0}, {16, PCI1736_IDO, 2, 0}},
- {{ 0, 0, 0, 0}, { 0, 0, 0, 0}},
- { 4, PCI1736_BOARDID, 1, SDF_INTERNAL},
- IO_8b,
- },
+ TYPE_PCI1736,
+ {{0, 0, 0, 0}, {16, PCI1736_IDI, 2, 0}},
+ {{0, 0, 0, 0}, {16, PCI1736_IDO, 2, 0}},
+ {{0, 0, 0, 0}, {0, 0, 0, 0}},
+ {4, PCI1736_BOARDID, 1, SDF_INTERNAL},
+ IO_8b,
+ },
{"pci1750", PCI_VENDOR_ID_ADVANTECH, 0x1750, PCIDIO_MAINREG,
- TYPE_PCI1750,
- {{0, 0, 0, 0}, {16, PCI1750_IDI, 2, 0}},
- {{0, 0, 0, 0}, {16, PCI1750_IDO, 2, 0}},
- {{0, 0, 0, 0}, {0, 0, 0, 0}},
- {0, 0, 0, 0},
- IO_8b},
+ TYPE_PCI1750,
+ {{0, 0, 0, 0}, {16, PCI1750_IDI, 2, 0}},
+ {{0, 0, 0, 0}, {16, PCI1750_IDO, 2, 0}},
+ {{0, 0, 0, 0}, {0, 0, 0, 0}},
+ {0, 0, 0, 0},
+ IO_8b},
{"pci1751", PCI_VENDOR_ID_ADVANTECH, 0x1751, PCIDIO_MAINREG,
- TYPE_PCI1751,
- {{0, 0, 0, 0}, {0, 0, 0, 0}},
- {{0, 0, 0, 0}, {0, 0, 0, 0}},
- {{48, PCI1751_DIO, 2, 0}, {0, 0, 0, 0}},
- {0, 0, 0, 0},
- IO_8b},
+ TYPE_PCI1751,
+ {{0, 0, 0, 0}, {0, 0, 0, 0}},
+ {{0, 0, 0, 0}, {0, 0, 0, 0}},
+ {{48, PCI1751_DIO, 2, 0}, {0, 0, 0, 0}},
+ {0, 0, 0, 0},
+ IO_8b},
{"pci1752", PCI_VENDOR_ID_ADVANTECH, 0x1752, PCIDIO_MAINREG,
- TYPE_PCI1752,
- {{0, 0, 0, 0}, {0, 0, 0, 0}},
- {{32, PCI1752_IDO, 2, 0}, {32, PCI1752_IDO2, 2, 0}},
- {{0, 0, 0, 0}, {0, 0, 0, 0}},
- {4, PCI175x_BOARDID, 1, SDF_INTERNAL},
- IO_16b},
+ TYPE_PCI1752,
+ {{0, 0, 0, 0}, {0, 0, 0, 0}},
+ {{32, PCI1752_IDO, 2, 0}, {32, PCI1752_IDO2, 2, 0}},
+ {{0, 0, 0, 0}, {0, 0, 0, 0}},
+ {4, PCI175x_BOARDID, 1, SDF_INTERNAL},
+ IO_16b},
{"pci1753", PCI_VENDOR_ID_ADVANTECH, 0x1753, PCIDIO_MAINREG,
- TYPE_PCI1753,
- {{0, 0, 0, 0}, {0, 0, 0, 0}},
- {{0, 0, 0, 0}, {0, 0, 0, 0}},
- {{96, PCI1753_DIO, 4, 0}, {0, 0, 0, 0}},
- {0, 0, 0, 0},
- IO_8b},
+ TYPE_PCI1753,
+ {{0, 0, 0, 0}, {0, 0, 0, 0}},
+ {{0, 0, 0, 0}, {0, 0, 0, 0}},
+ {{96, PCI1753_DIO, 4, 0}, {0, 0, 0, 0}},
+ {0, 0, 0, 0},
+ IO_8b},
{"pci1753e", PCI_VENDOR_ID_ADVANTECH, 0x1753, PCIDIO_MAINREG,
- TYPE_PCI1753E,
- {{0, 0, 0, 0}, {0, 0, 0, 0}},
- {{0, 0, 0, 0}, {0, 0, 0, 0}},
- {{96, PCI1753_DIO, 4, 0}, {96, PCI1753E_DIO, 4, 0}},
- {0, 0, 0, 0},
- IO_8b},
+ TYPE_PCI1753E,
+ {{0, 0, 0, 0}, {0, 0, 0, 0}},
+ {{0, 0, 0, 0}, {0, 0, 0, 0}},
+ {{96, PCI1753_DIO, 4, 0}, {96, PCI1753E_DIO, 4, 0}},
+ {0, 0, 0, 0},
+ IO_8b},
{"pci1754", PCI_VENDOR_ID_ADVANTECH, 0x1754, PCIDIO_MAINREG,
- TYPE_PCI1754,
- {{32, PCI1754_IDI, 2, 0}, {32, PCI1754_IDI2, 2, 0}},
- {{0, 0, 0, 0}, {0, 0, 0, 0}},
- {{0, 0, 0, 0}, {0, 0, 0, 0}},
- {4, PCI175x_BOARDID, 1, SDF_INTERNAL},
- IO_16b},
+ TYPE_PCI1754,
+ {{32, PCI1754_IDI, 2, 0}, {32, PCI1754_IDI2, 2, 0}},
+ {{0, 0, 0, 0}, {0, 0, 0, 0}},
+ {{0, 0, 0, 0}, {0, 0, 0, 0}},
+ {4, PCI175x_BOARDID, 1, SDF_INTERNAL},
+ IO_16b},
{"pci1756", PCI_VENDOR_ID_ADVANTECH, 0x1756, PCIDIO_MAINREG,
- TYPE_PCI1756,
- {{0, 0, 0, 0}, {32, PCI1756_IDI, 2, 0}},
- {{0, 0, 0, 0}, {32, PCI1756_IDO, 2, 0}},
- {{0, 0, 0, 0}, {0, 0, 0, 0}},
- {4, PCI175x_BOARDID, 1, SDF_INTERNAL},
- IO_16b},
+ TYPE_PCI1756,
+ {{0, 0, 0, 0}, {32, PCI1756_IDI, 2, 0}},
+ {{0, 0, 0, 0}, {32, PCI1756_IDO, 2, 0}},
+ {{0, 0, 0, 0}, {0, 0, 0, 0}},
+ {4, PCI175x_BOARDID, 1, SDF_INTERNAL},
+ IO_16b},
{"pci1760", PCI_VENDOR_ID_ADVANTECH, 0x1760, 0,
- TYPE_PCI1760,
- {{0, 0, 0, 0}, {0, 0, 0, 0}}, /* This card have own setup work */
- {{0, 0, 0, 0}, {0, 0, 0, 0}},
- {{0, 0, 0, 0}, {0, 0, 0, 0}},
- {0, 0, 0, 0},
- IO_8b},
+ TYPE_PCI1760,
+ {{0, 0, 0, 0}, {0, 0, 0, 0}}, /* This card have own setup work */
+ {{0, 0, 0, 0}, {0, 0, 0, 0}},
+ {{0, 0, 0, 0}, {0, 0, 0, 0}},
+ {0, 0, 0, 0},
+ IO_8b},
{"pci1762", PCI_VENDOR_ID_ADVANTECH, 0x1762, PCIDIO_MAINREG,
- TYPE_PCI1762,
- {{0, 0, 0, 0}, {16, PCI1762_IDI, 1, 0}},
- {{0, 0, 0, 0}, {16, PCI1762_RO, 1, 0}},
- {{0, 0, 0, 0}, {0, 0, 0, 0}},
- {4, PCI1762_BOARDID, 1, SDF_INTERNAL},
- IO_16b}
+ TYPE_PCI1762,
+ {{0, 0, 0, 0}, {16, PCI1762_IDI, 1, 0}},
+ {{0, 0, 0, 0}, {16, PCI1762_RO, 1, 0}},
+ {{0, 0, 0, 0}, {0, 0, 0, 0}},
+ {4, PCI1762_BOARDID, 1, SDF_INTERNAL},
+ IO_16b}
};
#define n_boardtypes (sizeof(boardtypes)/sizeof(struct dio_boardtype))
@@ -357,8 +359,9 @@ 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 +377,9 @@ static int pci_dio_insn_bits_di_b(struct comedi_device *dev, struct comedi_subde
/*
==============================================================================
*/
-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 +394,9 @@ static int pci_dio_insn_bits_di_w(struct comedi_device *dev, struct comedi_subde
/*
==============================================================================
*/
-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;
@@ -401,7 +406,7 @@ static int pci_dio_insn_bits_do_b(struct comedi_device *dev, struct comedi_subde
s->state |= (data[0] & data[1]);
for (i = 0; i < d->regs; i++)
outb((s->state >> (8 * i)) & 0xff,
- dev->iobase + d->addr + i);
+ dev->iobase + d->addr + i);
}
data[1] = s->state;
@@ -411,8 +416,9 @@ static int pci_dio_insn_bits_do_b(struct comedi_device *dev, struct comedi_subde
/*
==============================================================================
*/
-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;
@@ -422,7 +428,7 @@ static int pci_dio_insn_bits_do_w(struct comedi_device *dev, struct comedi_subde
s->state |= (data[0] & data[1]);
for (i = 0; i < d->regs; i++)
outw((s->state >> (16 * i)) & 0xffff,
- dev->iobase + d->addr + 2 * i);
+ dev->iobase + d->addr + 2 * i);
}
data[1] = s->state;
@@ -433,7 +439,8 @@ static int pci_dio_insn_bits_do_w(struct comedi_device *dev, struct comedi_subde
==============================================================================
*/
static int pci1760_unchecked_mbxrequest(struct comedi_device *dev,
- unsigned char *omb, unsigned char *imb, int repeats)
+ unsigned char *omb, unsigned char *imb,
+ int repeats)
{
int cnt, tout, ok = 0;
@@ -472,11 +479,11 @@ static int pci1760_clear_imb2(struct comedi_device *dev)
}
static int pci1760_mbxrequest(struct comedi_device *dev,
- unsigned char *omb, unsigned char *imb)
+ unsigned char *omb, unsigned char *imb)
{
if (omb[2] == CMD_ClearIMB2) {
comedi_error(dev,
- "bug! this function should not be used for CMD_ClearIMB2 command");
+ "bug! this function should not be used for CMD_ClearIMB2 command");
return -EINVAL;
}
if (inb(dev->iobase + IMB2) == omb[2]) {
@@ -491,8 +498,9 @@ 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);
@@ -502,8 +510,9 @@ static int pci1760_insn_bits_di(struct comedi_device *dev, struct comedi_subdevi
/*
==============================================================================
*/
-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] = {
@@ -530,8 +539,9 @@ static int pci1760_insn_bits_do(struct comedi_device *dev, struct comedi_subdevi
/*
==============================================================================
*/
-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] = {
@@ -555,8 +565,9 @@ static int pci1760_insn_cnt_read(struct comedi_device *dev, struct comedi_subdev
/*
==============================================================================
*/
-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;
@@ -570,7 +581,7 @@ static int pci1760_insn_cnt_write(struct comedi_device *dev, struct comedi_subde
unsigned char imb[4];
if (devpriv->CntResValue[chan] != (data[0] & 0xffff)) { /* Set reset value if different */
- ret = pci1760_mbxrequest(dev, omb, imb);
+ ret = pci1760_mbxrequest(dev, omb, imb);
if (!ret)
return ret;
devpriv->CntResValue[chan] = data[0] & 0xffff;
@@ -697,11 +708,11 @@ static int pci_dio_reset(struct comedi_device *dev)
break;
case TYPE_PCI1736:
- outb(0, dev->iobase+PCI1736_IDO);
- outb(0, dev->iobase+PCI1736_IDO+1);
- outb(0, dev->iobase+PCI1736_3_INT_EN); /* disable interrupts */
- outb(0x0f, dev->iobase+PCI1736_3_INT_CLR);/* clear interrupts */
- outb(0, dev->iobase+PCI1736_3_INT_RF); /* set rising edge trigger */
+ outb(0, dev->iobase + PCI1736_IDO);
+ outb(0, dev->iobase + PCI1736_IDO + 1);
+ outb(0, dev->iobase + PCI1736_3_INT_EN); /* disable interrupts */
+ outb(0x0f, dev->iobase + PCI1736_3_INT_CLR); /* clear interrupts */
+ outb(0, dev->iobase + PCI1736_3_INT_RF); /* set rising edge trigger */
break;
case TYPE_PCI1750:
@@ -756,7 +767,8 @@ 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;
@@ -809,7 +821,7 @@ static int pci1760_attach(struct comedi_device *dev, struct comedi_devconfig *it
==============================================================================
*/
static int pci_dio_add_di(struct comedi_device *dev, struct comedi_subdevice *s,
- const struct diosubd_data *d, int subdev)
+ const struct diosubd_data *d, int subdev)
{
s->type = COMEDI_SUBD_DI;
s->subdev_flags = SDF_READABLE | SDF_GROUND | SDF_COMMON | d->specflags;
@@ -836,7 +848,7 @@ static int pci_dio_add_di(struct comedi_device *dev, struct comedi_subdevice *s,
==============================================================================
*/
static int pci_dio_add_do(struct comedi_device *dev, struct comedi_subdevice *s,
- const struct diosubd_data *d, int subdev)
+ const struct diosubd_data *d, int subdev)
{
s->type = COMEDI_SUBD_DO;
s->subdev_flags = SDF_WRITABLE | SDF_GROUND | SDF_COMMON;
@@ -863,8 +875,9 @@ static int pci_dio_add_do(struct comedi_device *dev, struct comedi_subdevice *s,
/*
==============================================================================
*/
-static int CheckAndAllocCard(struct comedi_device *dev, struct comedi_devconfig *it,
- struct pci_dev *pcidev)
+static int CheckAndAllocCard(struct comedi_device *dev,
+ struct comedi_devconfig *it,
+ struct pci_dev *pcidev)
{
struct pci_dio_private *pr, *prev;
@@ -889,7 +902,8 @@ 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;
@@ -905,8 +919,8 @@ static int pci_dio_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)) {
+ pcidev != NULL;
+ pcidev = pci_get_device(PCI_ANY_ID, PCI_ANY_ID, pcidev)) {
/* loop through cards supported by this driver */
for (i = 0; i < n_boardtypes; ++i) {
if (boardtypes[i].vendor_id != pcidev->vendor)
@@ -917,13 +931,13 @@ static int pci_dio_attach(struct comedi_device *dev, struct comedi_devconfig *it
if (it->options[0] || it->options[1]) {
/* are we on the wrong bus/slot? */
if (pcidev->bus->number != it->options[0] ||
- PCI_SLOT(pcidev->devfn) !=
- it->options[1]) {
+ PCI_SLOT(pcidev->devfn) != it->options[1]) {
continue;
}
}
ret = CheckAndAllocCard(dev, it, pcidev);
- if (ret != 1) continue;
+ if (ret != 1)
+ continue;
dev->board_ptr = boardtypes + i;
break;
}
@@ -932,20 +946,19 @@ static int pci_dio_attach(struct comedi_device *dev, struct comedi_devconfig *it
}
if (!dev->board_ptr) {
- printk
- (", Error: Requested type of the card was not found!\n");
+ printk(", Error: Requested type of the card was not found!\n");
return -EIO;
}
if (comedi_pci_enable(pcidev, driver_pci_dio.driver_name)) {
printk
- (", Error: Can't enable PCI device and request regions!\n");
+ (", Error: Can't enable PCI device and request regions!\n");
return -EIO;
}
iobase = pci_resource_start(pcidev, this_board->main_pci_region);
printk(", b:s:f=%d:%d:%d, io=0x%4lx",
- pcidev->bus->number, PCI_SLOT(pcidev->devfn),
- PCI_FUNC(pcidev->devfn), iobase);
+ pcidev->bus->number, PCI_SLOT(pcidev->devfn),
+ PCI_FUNC(pcidev->devfn), iobase);
dev->iobase = iobase;
dev->board_name = this_board->name;
@@ -994,8 +1007,9 @@ static int pci_dio_attach(struct comedi_device *dev, struct comedi_devconfig *it
for (j = 0; j < this_board->sdio[i].regs; j++) {
s = dev->subdevices + subdev;
subdev_8255_init(dev, s, NULL,
- dev->iobase + this_board->sdio[i].addr +
- SIZE_8255 * j);
+ dev->iobase +
+ this_board->sdio[i].addr +
+ SIZE_8255 * j);
subdev++;
}
diff --git a/drivers/staging/comedi/drivers/aio_aio12_8.c b/drivers/staging/comedi/drivers/aio_aio12_8.c
index 72283ae81368..c4cac66db12e 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,13 +88,14 @@ 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);
+ ADC_MODE_NORMAL |
+ (CR_RANGE(insn->chanspec) << 3) | CR_CHAN(insn->chanspec);
/* read status to clear EOC latch */
inb(dev->iobase + AIO12_8_STATUS);
@@ -107,7 +108,7 @@ static int aio_aio12_8_ai_read(struct comedi_device *dev, struct comedi_subdevic
/* Wait for conversion to complete */
while (timeout &&
- !(inb(dev->iobase + AIO12_8_STATUS) & STATUS_ADC_EOC)) {
+ !(inb(dev->iobase + AIO12_8_STATUS) & STATUS_ADC_EOC)) {
timeout--;
printk("timeout %d\n", timeout);
udelay(1);
@@ -122,8 +123,9 @@ static int aio_aio12_8_ai_read(struct comedi_device *dev, struct comedi_subdevic
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,8 +135,9 @@ static int aio_aio12_8_ao_read(struct comedi_device *dev, struct comedi_subdevic
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);
@@ -154,14 +157,15 @@ static int aio_aio12_8_ao_write(struct comedi_device *dev, struct comedi_subdevi
static const struct comedi_lrange range_aio_aio12_8 = {
4,
{
- UNI_RANGE(5),
- BIP_RANGE(5),
- UNI_RANGE(10),
- BIP_RANGE(10),
- }
+ UNI_RANGE(5),
+ BIP_RANGE(5),
+ UNI_RANGE(10),
+ BIP_RANGE(10),
+ }
};
-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;
diff --git a/drivers/staging/comedi/drivers/aio_iiro_16.c b/drivers/staging/comedi/drivers/aio_iiro_16.c
index d062f8619b6e..3857fd566d21 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,7 +67,8 @@ 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);
@@ -82,12 +83,17 @@ static struct comedi_driver driver_aio_iiro_16 = {
};
static int aio_iiro_16_dio_insn_bits_read(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);
static int aio_iiro_16_dio_insn_bits_write(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);
-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;
@@ -143,7 +149,9 @@ static int aio_iiro_16_detach(struct comedi_device *dev)
}
static int aio_iiro_16_dio_insn_bits_write(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)
{
if (insn->n != 2)
return -EINVAL;
@@ -153,7 +161,7 @@ static int aio_iiro_16_dio_insn_bits_write(struct comedi_device *dev,
s->state |= data[0] & data[1];
outb(s->state & 0xff, dev->iobase + AIO_IIRO_16_RELAY_0_7);
outb((s->state >> 8) & 0xff,
- dev->iobase + AIO_IIRO_16_RELAY_8_15);
+ dev->iobase + AIO_IIRO_16_RELAY_8_15);
}
data[1] = s->state;
@@ -162,7 +170,9 @@ static int aio_iiro_16_dio_insn_bits_write(struct comedi_device *dev,
}
static int aio_iiro_16_dio_insn_bits_read(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)
{
if (insn->n != 2)
return -EINVAL;
diff --git a/drivers/staging/comedi/drivers/amplc_dio200.c b/drivers/staging/comedi/drivers/amplc_dio200.c
index 744680059faf..69ab2813dd2e 100644
--- a/drivers/staging/comedi/drivers/amplc_dio200.c
+++ b/drivers/staging/comedi/drivers/amplc_dio200.c
@@ -290,60 +290,60 @@ 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
};
@@ -367,51 +367,51 @@ 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,
- sd_8254,
- sd_intr},
- .sdinfo = {0x00, 0x08, 0x0C, 0x10, 0x14,
- 0x3F},
- .has_int_sce = 1,
- .has_clk_gat_sce = 1,
- },
+ .n_subdevs = 6,
+ .sdtype = {sd_8255, sd_8254, sd_8254, sd_8254,
+ sd_8254,
+ sd_intr},
+ .sdinfo = {0x00, 0x08, 0x0C, 0x10, 0x14,
+ 0x3F},
+ .has_int_sce = 1,
+ .has_clk_gat_sce = 1,
+ },
[pc214_layout] = {
- .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,
- },
+ .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,
+ },
[pc215_layout] = {
- .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,
- },
+ .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,
+ },
[pc218_layout] = {
- .n_subdevs = 7,
- .sdtype = {sd_8254, sd_8254, sd_8255, sd_8254,
- sd_8254,
- sd_intr},
- .sdinfo = {0x00, 0x04, 0x08, 0x0C, 0x10,
- 0x14,
- 0x3F},
- .has_int_sce = 1,
- .has_clk_gat_sce = 1,
- },
+ .n_subdevs = 7,
+ .sdtype = {sd_8254, sd_8254, sd_8255, sd_8254,
+ sd_8254,
+ sd_intr},
+ .sdinfo = {0x00, 0x04, 0x08, 0x0C, 0x10,
+ 0x14,
+ 0x3F},
+ .has_int_sce = 1,
+ .has_clk_gat_sce = 1,
+ },
[pc272_layout] = {
- .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,
- },
+ .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,
+ },
};
/*
@@ -420,11 +420,12 @@ static const struct dio200_layout_struct dio200_layouts[] = {
#ifdef CONFIG_COMEDI_PCI
static DEFINE_PCI_DEVICE_TABLE(dio200_pci_table) = {
- {PCI_VENDOR_ID_AMPLICON, PCI_DEVICE_ID_AMPLICON_PCI215,
- PCI_ANY_ID, PCI_ANY_ID, 0, 0, 0},
- {PCI_VENDOR_ID_AMPLICON, PCI_DEVICE_ID_AMPLICON_PCI272,
- PCI_ANY_ID, PCI_ANY_ID, 0, 0, 0},
- {0}
+ {
+ PCI_VENDOR_ID_AMPLICON, PCI_DEVICE_ID_AMPLICON_PCI215,
+ PCI_ANY_ID, PCI_ANY_ID, 0, 0, 0}, {
+ PCI_VENDOR_ID_AMPLICON, PCI_DEVICE_ID_AMPLICON_PCI272,
+ PCI_ANY_ID, PCI_ANY_ID, 0, 0, 0}, {
+ 0}
};
MODULE_DEVICE_TABLE(pci, dio200_pci_table);
@@ -475,7 +476,8 @@ 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_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,
@@ -500,7 +502,7 @@ COMEDI_INITCLEANUP(driver_amplc_dio200);
#ifdef CONFIG_COMEDI_PCI
static int
dio200_find_pci(struct comedi_device *dev, int bus, int slot,
- struct pci_dev **pci_dev_p)
+ struct pci_dev **pci_dev_p)
{
struct pci_dev *pci_dev = NULL;
@@ -508,13 +510,13 @@ dio200_find_pci(struct comedi_device *dev, int bus, int slot,
/* Look for matching PCI device. */
for (pci_dev = pci_get_device(PCI_VENDOR_ID_AMPLICON, PCI_ANY_ID, NULL);
- pci_dev != NULL;
- pci_dev = pci_get_device(PCI_VENDOR_ID_AMPLICON,
- PCI_ANY_ID, pci_dev)) {
+ pci_dev != NULL;
+ pci_dev = pci_get_device(PCI_VENDOR_ID_AMPLICON,
+ PCI_ANY_ID, pci_dev)) {
/* If bus/slot specified, check them. */
if (bus || slot) {
if (bus != pci_dev->bus->number
- || slot != PCI_SLOT(pci_dev->devfn))
+ || slot != PCI_SLOT(pci_dev->devfn))
continue;
}
if (thisboard->model == anypci_model) {
@@ -545,11 +547,11 @@ dio200_find_pci(struct comedi_device *dev, int bus, int slot,
/* No match found. */
if (bus || slot) {
printk(KERN_ERR
- "comedi%d: error! no %s found at pci %02x:%02x!\n",
- dev->minor, thisboard->name, bus, slot);
+ "comedi%d: error! no %s found at pci %02x:%02x!\n",
+ dev->minor, thisboard->name, bus, slot);
} else {
printk(KERN_ERR "comedi%d: error! no %s found!\n",
- dev->minor, thisboard->name);
+ dev->minor, thisboard->name);
}
return -EIO;
}
@@ -564,7 +566,7 @@ dio200_request_region(unsigned minor, unsigned long from, unsigned long extent)
{
if (!from || !request_region(from, extent, DIO200_DRIVER_NAME)) {
printk(KERN_ERR "comedi%d: I/O port conflict (%#lx,%lu)!\n",
- minor, from, extent);
+ minor, from, extent);
return -EIO;
}
return 0;
@@ -574,8 +576,9 @@ 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;
@@ -593,7 +596,8 @@ 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;
@@ -607,7 +611,8 @@ 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;
@@ -644,7 +649,7 @@ static int dio200_start_intr(struct comedi_device *dev, struct comedi_subdevice
*/
static int
dio200_inttrig_start_intr(struct comedi_device *dev, struct comedi_subdevice *s,
- unsigned int trignum)
+ unsigned int trignum)
{
struct dio200_subdev_intr *subpriv;
unsigned long flags;
@@ -673,7 +678,8 @@ dio200_inttrig_start_intr(struct comedi_device *dev, struct comedi_subdevice *s,
* 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;
@@ -699,7 +705,7 @@ static int dio200_handle_read_intr(struct comedi_device *dev, struct comedi_subd
*/
cur_enabled = subpriv->enabled_isns;
while ((intstat = (inb(subpriv->iobase) & subpriv->valid_isns
- & ~triggered)) != 0) {
+ & ~triggered)) != 0) {
triggered |= intstat;
cur_enabled &= ~triggered;
outb(cur_enabled, subpriv->iobase);
@@ -748,12 +754,12 @@ static int dio200_handle_read_intr(struct comedi_device *dev, struct comedi_subd
/* Write the scan to the buffer. */
if (comedi_buf_put(s->async, val)) {
s->async->events |= (COMEDI_CB_BLOCK |
- COMEDI_CB_EOS);
+ COMEDI_CB_EOS);
} else {
/* Error! Stop acquisition. */
dio200_stop_intr(dev, s);
s->async->events |= COMEDI_CB_ERROR
- | COMEDI_CB_OVERFLOW;
+ | COMEDI_CB_OVERFLOW;
comedi_error(dev, "buffer overflow");
}
@@ -764,9 +770,9 @@ static int dio200_handle_read_intr(struct comedi_device *dev, struct comedi_subd
subpriv->stopcount--;
if (subpriv->stopcount == 0) {
s->async->events |=
- COMEDI_CB_EOA;
+ COMEDI_CB_EOA;
dio200_stop_intr(dev,
- s);
+ s);
}
}
}
@@ -785,7 +791,8 @@ static int dio200_handle_read_intr(struct comedi_device *dev, struct comedi_subd
/*
* '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;
@@ -803,8 +810,8 @@ static int dio200_subdev_intr_cancel(struct comedi_device *dev, struct comedi_su
* '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;
@@ -909,7 +916,8 @@ dio200_subdev_intr_cmdtest(struct comedi_device *dev, struct comedi_subdevice *s
/*
* '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;
@@ -956,14 +964,15 @@ static int dio200_subdev_intr_cmd(struct comedi_device *dev, struct comedi_subde
*/
static int
dio200_subdev_intr_init(struct comedi_device *dev, struct comedi_subdevice *s,
- unsigned long iobase, unsigned valid_isns, int has_int_sce)
+ unsigned long iobase, unsigned valid_isns,
+ int has_int_sce)
{
struct dio200_subdev_intr *subpriv;
subpriv = kzalloc(sizeof(*subpriv), GFP_KERNEL);
if (!subpriv) {
printk(KERN_ERR "comedi%d: error! out of memory!\n",
- dev->minor);
+ dev->minor);
return -ENOMEM;
}
subpriv->iobase = iobase;
@@ -1000,7 +1009,8 @@ 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;
@@ -1023,7 +1033,8 @@ static irqreturn_t dio200_interrupt(int irq, void *d)
if (devpriv->intr_sd >= 0) {
handled = dio200_handle_read_intr(dev,
- dev->subdevices + devpriv->intr_sd);
+ dev->subdevices +
+ devpriv->intr_sd);
} else {
handled = 0;
}
@@ -1036,7 +1047,7 @@ static irqreturn_t dio200_interrupt(int irq, void *d)
*/
static int
dio200_subdev_8254_read(struct comedi_device *dev, struct comedi_subdevice *s,
- struct comedi_insn *insn, unsigned int *data)
+ struct comedi_insn *insn, unsigned int *data)
{
struct dio200_subdev_8254 *subpriv = s->private;
int chan = CR_CHAN(insn->chanspec);
@@ -1051,7 +1062,7 @@ dio200_subdev_8254_read(struct comedi_device *dev, struct comedi_subdevice *s,
*/
static int
dio200_subdev_8254_write(struct comedi_device *dev, struct comedi_subdevice *s,
- struct comedi_insn *insn, unsigned int *data)
+ struct comedi_insn *insn, unsigned int *data)
{
struct dio200_subdev_8254 *subpriv = s->private;
int chan = CR_CHAN(insn->chanspec);
@@ -1065,8 +1076,8 @@ 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,
- unsigned int gate_src)
+dio200_set_gate_src(struct dio200_subdev_8254 *subpriv,
+ unsigned int counter_number, unsigned int gate_src)
{
unsigned char byte;
@@ -1088,7 +1099,8 @@ dio200_set_gate_src(struct dio200_subdev_8254 *subpriv, unsigned int counter_num
* 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;
@@ -1102,8 +1114,8 @@ dio200_get_gate_src(struct dio200_subdev_8254 *subpriv, unsigned int counter_num
* Set clock source for an '8254' counter subdevice channel.
*/
static int
-dio200_set_clock_src(struct dio200_subdev_8254 *subpriv, unsigned int counter_number,
- unsigned int clock_src)
+dio200_set_clock_src(struct dio200_subdev_8254 *subpriv,
+ unsigned int counter_number, unsigned int clock_src)
{
unsigned char byte;
@@ -1125,8 +1137,8 @@ dio200_set_clock_src(struct dio200_subdev_8254 *subpriv, unsigned int counter_nu
* 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;
@@ -1145,7 +1157,7 @@ dio200_get_clock_src(struct dio200_subdev_8254 *subpriv, unsigned int counter_nu
*/
static int
dio200_subdev_8254_config(struct comedi_device *dev, struct comedi_subdevice *s,
- struct comedi_insn *insn, unsigned int *data)
+ struct comedi_insn *insn, unsigned int *data)
{
struct dio200_subdev_8254 *subpriv = s->private;
int ret;
@@ -1197,7 +1209,8 @@ dio200_subdev_8254_config(struct comedi_device *dev, struct comedi_subdevice *s,
*/
static int
dio200_subdev_8254_init(struct comedi_device *dev, struct comedi_subdevice *s,
- unsigned long iobase, unsigned offset, int has_clk_gat_sce)
+ unsigned long iobase, unsigned offset,
+ int has_clk_gat_sce)
{
struct dio200_subdev_8254 *subpriv;
unsigned int chan;
@@ -1205,7 +1218,7 @@ dio200_subdev_8254_init(struct comedi_device *dev, struct comedi_subdevice *s,
subpriv = kzalloc(sizeof(*subpriv), GFP_KERNEL);
if (!subpriv) {
printk(KERN_ERR "comedi%d: error! out of memory!\n",
- dev->minor);
+ dev->minor);
return -ENOMEM;
}
@@ -1224,16 +1237,16 @@ dio200_subdev_8254_init(struct comedi_device *dev, struct comedi_subdevice *s,
/* Derive CLK_SCE and GAT_SCE register offsets from
* 8254 offset. */
subpriv->clk_sce_iobase =
- DIO200_XCLK_SCE + (offset >> 3) + iobase;
+ DIO200_XCLK_SCE + (offset >> 3) + iobase;
subpriv->gat_sce_iobase =
- DIO200_XGAT_SCE + (offset >> 3) + iobase;
+ DIO200_XGAT_SCE + (offset >> 3) + iobase;
subpriv->which = (offset >> 2) & 1;
}
/* Initialize channels. */
for (chan = 0; chan < 3; chan++) {
i8254_set_mode(subpriv->iobase, 0, chan,
- I8254_MODE0 | I8254_BINARY);
+ I8254_MODE0 | I8254_BINARY);
if (subpriv->has_clk_gat_sce) {
/* Gate source 0 is VCC (logic 1). */
dio200_set_gate_src(subpriv, chan, 0);
@@ -1249,7 +1262,8 @@ 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;
@@ -1280,12 +1294,12 @@ static int dio200_attach(struct comedi_device *dev, struct comedi_devconfig *it)
int ret;
printk(KERN_DEBUG "comedi%d: %s: attach\n", dev->minor,
- DIO200_DRIVER_NAME);
+ DIO200_DRIVER_NAME);
ret = alloc_private(dev, sizeof(struct dio200_private));
if (ret < 0) {
printk(KERN_ERR "comedi%d: error! out of memory!\n",
- dev->minor);
+ dev->minor);
return ret;
}
@@ -1310,8 +1324,8 @@ static int dio200_attach(struct comedi_device *dev, struct comedi_devconfig *it)
#endif
default:
printk(KERN_ERR
- "comedi%d: %s: BUG! cannot determine board type!\n",
- dev->minor, DIO200_DRIVER_NAME);
+ "comedi%d: %s: BUG! cannot determine board type!\n",
+ dev->minor, DIO200_DRIVER_NAME);
return -EINVAL;
break;
}
@@ -1324,8 +1338,8 @@ static int dio200_attach(struct comedi_device *dev, struct comedi_devconfig *it)
ret = comedi_pci_enable(pci_dev, DIO200_DRIVER_NAME);
if (ret < 0) {
printk(KERN_ERR
- "comedi%d: error! cannot enable PCI device and request regions!\n",
- dev->minor);
+ "comedi%d: error! cannot enable PCI device and request regions!\n",
+ dev->minor);
return ret;
}
iobase = pci_resource_start(pci_dev, 2);
@@ -1345,7 +1359,7 @@ static int dio200_attach(struct comedi_device *dev, struct comedi_devconfig *it)
ret = alloc_subdevices(dev, layout->n_subdevs);
if (ret < 0) {
printk(KERN_ERR "comedi%d: error! out of memory!\n",
- dev->minor);
+ dev->minor);
return ret;
}
@@ -1355,7 +1369,8 @@ static int dio200_attach(struct comedi_device *dev, struct comedi_devconfig *it)
case sd_8254:
/* counter subdevice (8254) */
ret = dio200_subdev_8254_init(dev, s, iobase,
- layout->sdinfo[n], layout->has_clk_gat_sce);
+ layout->sdinfo[n],
+ layout->has_clk_gat_sce);
if (ret < 0) {
return ret;
}
@@ -1363,7 +1378,7 @@ static int dio200_attach(struct comedi_device *dev, struct comedi_devconfig *it)
case sd_8255:
/* digital i/o subdevice (8255) */
ret = subdev_8255_init(dev, s, 0,
- iobase + layout->sdinfo[n]);
+ iobase + layout->sdinfo[n]);
if (ret < 0) {
return ret;
}
@@ -1372,8 +1387,11 @@ static int dio200_attach(struct comedi_device *dev, struct comedi_devconfig *it)
/* 'INTERRUPT' subdevice */
if (irq) {
ret = dio200_subdev_intr_init(dev, s,
- iobase + DIO200_INT_SCE,
- layout->sdinfo[n], layout->has_int_sce);
+ iobase +
+ DIO200_INT_SCE,
+ layout->sdinfo[n],
+ layout->
+ has_int_sce);
if (ret < 0) {
return ret;
}
@@ -1403,8 +1421,8 @@ static int dio200_attach(struct comedi_device *dev, struct comedi_devconfig *it)
dev->irq = irq;
} else {
printk(KERN_WARNING
- "comedi%d: warning! irq %u unavailable!\n",
- dev->minor, irq);
+ "comedi%d: warning! irq %u unavailable!\n",
+ dev->minor, irq);
}
}
@@ -1441,7 +1459,7 @@ static int dio200_detach(struct comedi_device *dev)
unsigned n;
printk(KERN_DEBUG "comedi%d: %s: detach\n", dev->minor,
- DIO200_DRIVER_NAME);
+ DIO200_DRIVER_NAME);
if (dev->irq) {
free_irq(dev->irq, dev);
@@ -1482,7 +1500,7 @@ static int dio200_detach(struct comedi_device *dev)
}
if (dev->board_name) {
printk(KERN_INFO "comedi%d: %s removed\n",
- dev->minor, dev->board_name);
+ dev->minor, dev->board_name);
}
return 0;
diff --git a/drivers/staging/comedi/drivers/amplc_pc236.c b/drivers/staging/comedi/drivers/amplc_pc236.c
index 48d7ccb4a3fe..1032a8110d6e 100644
--- a/drivers/staging/comedi/drivers/amplc_pc236.c
+++ b/drivers/staging/comedi/drivers/amplc_pc236.c
@@ -107,36 +107,37 @@ 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
};
#ifdef CONFIG_COMEDI_PCI
static DEFINE_PCI_DEVICE_TABLE(pc236_pci_table) = {
- {PCI_VENDOR_ID_AMPLICON, PCI_DEVICE_ID_AMPLICON_PCI236, PCI_ANY_ID,
- PCI_ANY_ID, 0, 0, 0},
- {0}
+ {
+ PCI_VENDOR_ID_AMPLICON, PCI_DEVICE_ID_AMPLICON_PCI236,
+ PCI_ANY_ID, PCI_ANY_ID, 0, 0, 0}, {
+ 0}
};
MODULE_DEVICE_TABLE(pci, pc236_pci_table);
@@ -186,16 +187,20 @@ COMEDI_INITCLEANUP(driver_amplc_pc236);
#endif
static int pc236_request_region(unsigned minor, unsigned long from,
- unsigned long extent);
+ 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 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);
/*
@@ -205,7 +210,7 @@ static irqreturn_t pc236_interrupt(int irq, void *d);
#ifdef CONFIG_COMEDI_PCI
static int
pc236_find_pci(struct comedi_device *dev, int bus, int slot,
- struct pci_dev **pci_dev_p)
+ struct pci_dev **pci_dev_p)
{
struct pci_dev *pci_dev = NULL;
@@ -213,13 +218,13 @@ pc236_find_pci(struct comedi_device *dev, int bus, int slot,
/* Look for matching PCI device. */
for (pci_dev = pci_get_device(PCI_VENDOR_ID_AMPLICON, PCI_ANY_ID, NULL);
- pci_dev != NULL;
- pci_dev = pci_get_device(PCI_VENDOR_ID_AMPLICON,
- PCI_ANY_ID, pci_dev)) {
+ pci_dev != NULL;
+ pci_dev = pci_get_device(PCI_VENDOR_ID_AMPLICON,
+ PCI_ANY_ID, pci_dev)) {
/* If bus/slot specified, check them. */
if (bus || slot) {
if (bus != pci_dev->bus->number
- || slot != PCI_SLOT(pci_dev->devfn))
+ || slot != PCI_SLOT(pci_dev->devfn))
continue;
}
if (thisboard->model == anypci_model) {
@@ -250,11 +255,11 @@ pc236_find_pci(struct comedi_device *dev, int bus, int slot,
/* No match found. */
if (bus || slot) {
printk(KERN_ERR
- "comedi%d: error! no %s found at pci %02x:%02x!\n",
- dev->minor, thisboard->name, bus, slot);
+ "comedi%d: error! no %s found at pci %02x:%02x!\n",
+ dev->minor, thisboard->name, bus, slot);
} else {
printk(KERN_ERR "comedi%d: error! no %s found!\n",
- dev->minor, thisboard->name);
+ dev->minor, thisboard->name);
}
return -EIO;
}
@@ -279,7 +284,7 @@ static int pc236_attach(struct comedi_device *dev, struct comedi_devconfig *it)
int ret;
printk(KERN_DEBUG "comedi%d: %s: attach\n", dev->minor,
- PC236_DRIVER_NAME);
+ PC236_DRIVER_NAME);
/*
* Allocate the private structure area. alloc_private() is a
* convenient macro defined in comedidev.h.
@@ -287,7 +292,7 @@ static int pc236_attach(struct comedi_device *dev, struct comedi_devconfig *it)
ret = alloc_private(dev, sizeof(struct pc236_private));
if (ret < 0) {
printk(KERN_ERR "comedi%d: error! out of memory!\n",
- dev->minor);
+ dev->minor);
return ret;
}
/* Process options. */
@@ -311,8 +316,8 @@ static int pc236_attach(struct comedi_device *dev, struct comedi_devconfig *it)
#endif /* CONFIG_COMEDI_PCI */
default:
printk(KERN_ERR
- "comedi%d: %s: BUG! cannot determine board type!\n",
- dev->minor, PC236_DRIVER_NAME);
+ "comedi%d: %s: BUG! cannot determine board type!\n",
+ dev->minor, PC236_DRIVER_NAME);
return -EINVAL;
break;
}
@@ -329,8 +334,8 @@ static int pc236_attach(struct comedi_device *dev, struct comedi_devconfig *it)
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);
+ "comedi%d: error! cannot enable PCI device and request regions!\n",
+ dev->minor);
return ret;
}
devpriv->lcr_iobase = pci_resource_start(pci_dev, 1);
@@ -353,7 +358,7 @@ static int pc236_attach(struct comedi_device *dev, struct comedi_devconfig *it)
ret = alloc_subdevices(dev, 2);
if (ret < 0) {
printk(KERN_ERR "comedi%d: error! out of memory!\n",
- dev->minor);
+ dev->minor);
return ret;
}
@@ -362,7 +367,7 @@ static int pc236_attach(struct comedi_device *dev, struct comedi_devconfig *it)
ret = subdev_8255_init(dev, s, NULL, iobase);
if (ret < 0) {
printk(KERN_ERR "comedi%d: error! out of memory!\n",
- dev->minor);
+ dev->minor);
return ret;
}
s = dev->subdevices + 1;
@@ -416,7 +421,7 @@ static int pc236_attach(struct comedi_device *dev, struct comedi_devconfig *it)
static int pc236_detach(struct comedi_device *dev)
{
printk(KERN_DEBUG "comedi%d: %s: detach\n", dev->minor,
- PC236_DRIVER_NAME);
+ PC236_DRIVER_NAME);
if (devpriv) {
pc236_intr_disable(dev);
}
@@ -442,7 +447,7 @@ static int pc236_detach(struct comedi_device *dev)
}
if (dev->board_name) {
printk(KERN_INFO "comedi%d: %s removed\n",
- dev->minor, dev->board_name);
+ dev->minor, dev->board_name);
}
return 0;
}
@@ -452,11 +457,11 @@ static int pc236_detach(struct comedi_device *dev)
* if there is a conflict.
*/
static int pc236_request_region(unsigned minor, unsigned long from,
- unsigned long extent)
+ unsigned long extent)
{
if (!from || !request_region(from, extent, PC236_DRIVER_NAME)) {
printk(KERN_ERR "comedi%d: I/O port conflict (%#lx,%lu)!\n",
- minor, from, extent);
+ minor, from, extent);
return -EIO;
}
return 0;
@@ -516,13 +521,13 @@ static int pc236_intr_check(struct comedi_device *dev)
#ifdef CONFIG_COMEDI_PCI
if (devpriv->lcr_iobase) {
if ((inl(devpriv->lcr_iobase + PLX9052_INTCSR)
- & PLX9052_INTCSR_LI1STAT_MASK)
- == PLX9052_INTCSR_LI1STAT_INACTIVE) {
+ & PLX9052_INTCSR_LI1STAT_MASK)
+ == PLX9052_INTCSR_LI1STAT_INACTIVE) {
retval = 0;
} else {
/* Clear interrupt and keep it enabled. */
outl(PCI236_INTR_ENABLE,
- devpriv->lcr_iobase + PLX9052_INTCSR);
+ devpriv->lcr_iobase + PLX9052_INTCSR);
}
}
#endif
@@ -536,8 +541,9 @@ 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;
@@ -547,8 +553,9 @@ static int pc236_intr_insn(struct comedi_device *dev, struct comedi_subdevice *s
* 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;
@@ -635,7 +642,8 @@ static int pc236_intr_cmd(struct comedi_device *dev, struct comedi_subdevice *s)
/*
* 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);
diff --git a/drivers/staging/comedi/drivers/amplc_pc263.c b/drivers/staging/comedi/drivers/amplc_pc263.c
index 730b67743f0e..c62a7e1f81bd 100644
--- a/drivers/staging/comedi/drivers/amplc_pc263.c
+++ b/drivers/staging/comedi/drivers/amplc_pc263.c
@@ -74,36 +74,37 @@ 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
};
#ifdef CONFIG_COMEDI_PCI
static DEFINE_PCI_DEVICE_TABLE(pc263_pci_table) = {
- {PCI_VENDOR_ID_AMPLICON, PCI_DEVICE_ID_AMPLICON_PCI263, PCI_ANY_ID,
- PCI_ANY_ID, 0, 0, 0},
- {0}
+ {
+ PCI_VENDOR_ID_AMPLICON, PCI_DEVICE_ID_AMPLICON_PCI263,
+ PCI_ANY_ID, PCI_ANY_ID, 0, 0, 0}, {
+ 0}
};
MODULE_DEVICE_TABLE(pci, pc263_pci_table);
@@ -145,11 +146,13 @@ static struct comedi_driver driver_amplc_pc263 = {
};
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);
+ 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);
/*
* This function looks for a PCI device matching the requested board name,
@@ -158,7 +161,7 @@ static int pc263_dio_insn_config(struct comedi_device *dev, struct comedi_subdev
#ifdef CONFIG_COMEDI_PCI
static int
pc263_find_pci(struct comedi_device *dev, int bus, int slot,
- struct pci_dev **pci_dev_p)
+ struct pci_dev **pci_dev_p)
{
struct pci_dev *pci_dev = NULL;
@@ -166,13 +169,13 @@ pc263_find_pci(struct comedi_device *dev, int bus, int slot,
/* Look for matching PCI device. */
for (pci_dev = pci_get_device(PCI_VENDOR_ID_AMPLICON, PCI_ANY_ID, NULL);
- pci_dev != NULL;
- pci_dev = pci_get_device(PCI_VENDOR_ID_AMPLICON,
- PCI_ANY_ID, pci_dev)) {
+ pci_dev != NULL;
+ pci_dev = pci_get_device(PCI_VENDOR_ID_AMPLICON,
+ PCI_ANY_ID, pci_dev)) {
/* If bus/slot specified, check them. */
if (bus || slot) {
if (bus != pci_dev->bus->number
- || slot != PCI_SLOT(pci_dev->devfn))
+ || slot != PCI_SLOT(pci_dev->devfn))
continue;
}
if (thisboard->model == anypci_model) {
@@ -203,11 +206,11 @@ pc263_find_pci(struct comedi_device *dev, int bus, int slot,
/* No match found. */
if (bus || slot) {
printk(KERN_ERR
- "comedi%d: error! no %s found at pci %02x:%02x!\n",
- dev->minor, thisboard->name, bus, slot);
+ "comedi%d: error! no %s found at pci %02x:%02x!\n",
+ dev->minor, thisboard->name, bus, slot);
} else {
printk(KERN_ERR "comedi%d: error! no %s found!\n",
- dev->minor, thisboard->name);
+ dev->minor, thisboard->name);
}
return -EIO;
}
@@ -230,7 +233,7 @@ static int pc263_attach(struct comedi_device *dev, struct comedi_devconfig *it)
int ret;
printk(KERN_DEBUG "comedi%d: %s: attach\n", dev->minor,
- PC263_DRIVER_NAME);
+ PC263_DRIVER_NAME);
/*
* Allocate the private structure area. alloc_private() is a
* convenient macro defined in comedidev.h.
@@ -239,7 +242,7 @@ static int pc263_attach(struct comedi_device *dev, struct comedi_devconfig *it)
ret = alloc_private(dev, sizeof(struct pc263_private));
if (ret < 0) {
printk(KERN_ERR "comedi%d: error! out of memory!\n",
- dev->minor);
+ dev->minor);
return ret;
}
#endif
@@ -261,8 +264,8 @@ static int pc263_attach(struct comedi_device *dev, struct comedi_devconfig *it)
#endif /* CONFIG_COMEDI_PCI */
default:
printk(KERN_ERR
- "comedi%d: %s: BUG! cannot determine board type!\n",
- dev->minor, PC263_DRIVER_NAME);
+ "comedi%d: %s: BUG! cannot determine board type!\n",
+ dev->minor, PC263_DRIVER_NAME);
return -EINVAL;
break;
}
@@ -278,8 +281,8 @@ static int pc263_attach(struct comedi_device *dev, struct comedi_devconfig *it)
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);
+ "comedi%d: error! cannot enable PCI device and request regions!\n",
+ dev->minor);
return ret;
}
iobase = pci_resource_start(pci_dev, 2);
@@ -300,7 +303,7 @@ static int pc263_attach(struct comedi_device *dev, struct comedi_devconfig *it)
ret = alloc_subdevices(dev, 1);
if (ret < 0) {
printk(KERN_ERR "comedi%d: error! out of memory!\n",
- dev->minor);
+ dev->minor);
return ret;
}
@@ -344,7 +347,7 @@ static int pc263_attach(struct comedi_device *dev, struct comedi_devconfig *it)
static int pc263_detach(struct comedi_device *dev)
{
printk(KERN_DEBUG "comedi%d: %s: detach\n", dev->minor,
- PC263_DRIVER_NAME);
+ PC263_DRIVER_NAME);
#ifdef CONFIG_COMEDI_PCI
if (devpriv)
@@ -366,7 +369,7 @@ static int pc263_detach(struct comedi_device *dev)
}
if (dev->board_name) {
printk(KERN_INFO "comedi%d: %s removed\n",
- dev->minor, dev->board_name);
+ dev->minor, dev->board_name);
}
return 0;
}
@@ -376,11 +379,11 @@ static int pc263_detach(struct comedi_device *dev)
* if there is a conflict.
*/
static int pc263_request_region(unsigned minor, unsigned long from,
- unsigned long extent)
+ unsigned long extent)
{
if (!from || !request_region(from, extent, PC263_DRIVER_NAME)) {
printk(KERN_ERR "comedi%d: I/O port conflict (%#lx,%lu)!\n",
- minor, from, extent);
+ minor, from, extent);
return -EIO;
}
return 0;
@@ -391,8 +394,9 @@ 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;
@@ -416,8 +420,9 @@ static int pc263_dio_insn_bits(struct comedi_device *dev, struct comedi_subdevic
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 d1a64e80cddb..d9836879355e 100644
--- a/drivers/staging/comedi/drivers/amplc_pci224.c
+++ b/drivers/staging/comedi/drivers/amplc_pci224.c
@@ -283,15 +283,15 @@ Caveats:
static const struct comedi_lrange range_pci224_internal = {
8,
{
- BIP_RANGE(10),
- BIP_RANGE(5),
- BIP_RANGE(2.5),
- BIP_RANGE(1.25),
- UNI_RANGE(10),
- UNI_RANGE(5),
- UNI_RANGE(2.5),
- UNI_RANGE(1.25),
- }
+ BIP_RANGE(10),
+ BIP_RANGE(5),
+ BIP_RANGE(2.5),
+ BIP_RANGE(1.25),
+ UNI_RANGE(10),
+ UNI_RANGE(5),
+ UNI_RANGE(2.5),
+ UNI_RANGE(1.25),
+ }
};
static const unsigned short hwrange_pci224_internal[8] = {
@@ -309,9 +309,9 @@ static const unsigned short hwrange_pci224_internal[8] = {
static const struct comedi_lrange range_pci224_external = {
2,
{
- RANGE_ext(-1, 1), /* bipolar [-Vref,+Vref] */
- RANGE_ext(0, 1), /* unipolar [0,+Vref] */
- }
+ RANGE_ext(-1, 1), /* bipolar [-Vref,+Vref] */
+ RANGE_ext(0, 1), /* unipolar [0,+Vref] */
+ }
};
static const unsigned short hwrange_pci224_external[2] = {
@@ -324,8 +324,8 @@ static const unsigned short hwrange_pci224_external[2] = {
static const struct comedi_lrange range_pci234_ext2 = {
1,
{
- RANGE_ext(-2, 2),
- }
+ RANGE_ext(-2, 2),
+ }
};
/* The hardware selectable Vref external range for PCI234
@@ -333,8 +333,8 @@ static const struct comedi_lrange range_pci234_ext2 = {
static const struct comedi_lrange range_pci234_ext = {
1,
{
- RANGE_ext(-1, 1),
- }
+ RANGE_ext(-1, 1),
+ }
};
/* This serves for all the PCI234 ranges. */
@@ -358,24 +358,24 @@ 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 */
+ },
};
/*
@@ -383,11 +383,12 @@ static const struct pci224_board pci224_boards[] = {
*/
static DEFINE_PCI_DEVICE_TABLE(pci224_pci_table) = {
- {PCI_VENDOR_ID_AMPLICON, PCI_DEVICE_ID_AMPLICON_PCI224,
- PCI_ANY_ID, PCI_ANY_ID, 0, 0, 0},
- {PCI_VENDOR_ID_AMPLICON, PCI_DEVICE_ID_AMPLICON_PCI234,
- PCI_ANY_ID, PCI_ANY_ID, 0, 0, 0},
- {0}
+ {
+ PCI_VENDOR_ID_AMPLICON, PCI_DEVICE_ID_AMPLICON_PCI224,
+ PCI_ANY_ID, PCI_ANY_ID, 0, 0, 0}, {
+ PCI_VENDOR_ID_AMPLICON, PCI_DEVICE_ID_AMPLICON_PCI234,
+ PCI_ANY_ID, PCI_ANY_ID, 0, 0, 0}, {
+ 0}
};
MODULE_DEVICE_TABLE(pci, pci224_pci_table);
@@ -428,7 +429,8 @@ 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_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,
@@ -446,7 +448,8 @@ 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;
@@ -456,9 +459,10 @@ pci224_ao_set_data(struct comedi_device *dev, int chan, int range, unsigned int
outw(1 << chan, dev->iobase + PCI224_DACCEN);
/* Set range and reset FIFO. */
devpriv->daccon = COMBINE(devpriv->daccon, devpriv->hwrange[range],
- (PCI224_DACCON_POLAR_MASK | PCI224_DACCON_VREF_MASK));
+ (PCI224_DACCON_POLAR_MASK |
+ PCI224_DACCON_VREF_MASK));
outw(devpriv->daccon | PCI224_DACCON_FIFORESET,
- dev->iobase + PCI224_DACCON);
+ dev->iobase + PCI224_DACCON);
/*
* Mangle the data. The hardware expects:
* - bipolar: 16-bit 2's complement
@@ -466,7 +470,7 @@ pci224_ao_set_data(struct comedi_device *dev, int chan, int range, unsigned int
*/
mangled = (unsigned short)data << (16 - thisboard->ao_bits);
if ((devpriv->daccon & PCI224_DACCON_POLAR_MASK) ==
- PCI224_DACCON_POLAR_BI) {
+ PCI224_DACCON_POLAR_BI) {
mangled ^= 0x8000;
}
/* Write mangled data to the FIFO. */
@@ -480,7 +484,7 @@ pci224_ao_set_data(struct comedi_device *dev, int chan, int range, unsigned int
*/
static int
pci224_ao_insn_write(struct comedi_device *dev, struct comedi_subdevice *s,
- struct comedi_insn *insn, unsigned int *data)
+ struct comedi_insn *insn, unsigned int *data)
{
int i;
int chan, range;
@@ -507,7 +511,7 @@ pci224_ao_insn_write(struct comedi_device *dev, struct comedi_subdevice *s,
*/
static int
pci224_ao_insn_read(struct comedi_device *dev, struct comedi_subdevice *s,
- struct comedi_insn *insn, unsigned int *data)
+ struct comedi_insn *insn, unsigned int *data)
{
int i;
int chan;
@@ -526,7 +530,7 @@ pci224_ao_insn_read(struct comedi_device *dev, struct comedi_subdevice *s,
*/
static void
pci224_cascade_ns_to_timer(int osc_base, unsigned int *d1, unsigned int *d2,
- unsigned int *nanosec, int round_mode)
+ unsigned int *nanosec, int round_mode)
{
i8253_cascade_ns_to_timer(osc_base, d1, d2, nanosec, round_mode);
}
@@ -534,7 +538,8 @@ 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;
@@ -565,16 +570,19 @@ static void pci224_ao_stop(struct comedi_device *dev, struct comedi_subdevice *s
/* Reconfigure DAC for insn_write usage. */
outw(0, dev->iobase + PCI224_DACCEN); /* Disable channels. */
devpriv->daccon = COMBINE(devpriv->daccon,
- PCI224_DACCON_TRIG_SW | PCI224_DACCON_FIFOINTR_EMPTY,
- PCI224_DACCON_TRIG_MASK | PCI224_DACCON_FIFOINTR_MASK);
+ PCI224_DACCON_TRIG_SW |
+ PCI224_DACCON_FIFOINTR_EMPTY,
+ PCI224_DACCON_TRIG_MASK |
+ PCI224_DACCON_FIFOINTR_MASK);
outw(devpriv->daccon | PCI224_DACCON_FIFORESET,
- dev->iobase + PCI224_DACCON);
+ dev->iobase + PCI224_DACCON);
}
/*
* 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;
@@ -601,7 +609,8 @@ static void pci224_ao_start(struct comedi_device *dev, struct comedi_subdevice *
/*
* 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;
@@ -630,8 +639,7 @@ static void pci224_ao_handle_fifo(struct comedi_device *dev, struct comedi_subde
switch (dacstat & PCI224_DACCON_FIFOFL_MASK) {
case PCI224_DACCON_FIFOFL_EMPTY:
room = PCI224_FIFO_ROOM_EMPTY;
- if (!devpriv->ao_stop_continuous
- && devpriv->ao_stop_count == 0) {
+ if (!devpriv->ao_stop_continuous && devpriv->ao_stop_count == 0) {
/* FIFO empty at end of counted acquisition. */
pci224_ao_stop(dev, s);
s->async->events |= COMEDI_CB_EOA;
@@ -656,7 +664,7 @@ static void pci224_ao_handle_fifo(struct comedi_device *dev, struct comedi_subde
pci224_ao_stop(dev, s);
s->async->events |= COMEDI_CB_OVERFLOW;
printk(KERN_ERR "comedi%d: "
- "AO buffer underrun\n", dev->minor);
+ "AO buffer underrun\n", dev->minor);
}
}
/* Determine how many new scans can be put in the FIFO. */
@@ -670,11 +678,10 @@ static void pci224_ao_handle_fifo(struct comedi_device *dev, struct comedi_subde
/* Process scans. */
for (n = 0; n < num_scans; n++) {
cfc_read_array_from_buffer(s, &devpriv->ao_scan_vals[0],
- bytes_per_scan);
+ bytes_per_scan);
for (i = 0; i < cmd->chanlist_len; i++) {
- outw(devpriv->ao_scan_vals[devpriv->
- ao_scan_order[i]],
- dev->iobase + PCI224_DACDATA);
+ outw(devpriv->ao_scan_vals[devpriv->ao_scan_order[i]],
+ dev->iobase + PCI224_DACDATA);
}
}
if (!devpriv->ao_stop_continuous) {
@@ -685,14 +692,13 @@ static void pci224_ao_handle_fifo(struct comedi_device *dev, struct comedi_subde
* until FIFO is empty.
*/
devpriv->daccon = COMBINE(devpriv->daccon,
- PCI224_DACCON_FIFOINTR_EMPTY,
- PCI224_DACCON_FIFOINTR_MASK);
- outw(devpriv->daccon,
- dev->iobase + PCI224_DACCON);
+ PCI224_DACCON_FIFOINTR_EMPTY,
+ PCI224_DACCON_FIFOINTR_MASK);
+ outw(devpriv->daccon, dev->iobase + PCI224_DACCON);
}
}
if ((devpriv->daccon & PCI224_DACCON_TRIG_MASK) ==
- PCI224_DACCON_TRIG_NONE) {
+ PCI224_DACCON_TRIG_NONE) {
unsigned short trig;
/*
@@ -718,7 +724,7 @@ static void pci224_ao_handle_fifo(struct comedi_device *dev, struct comedi_subde
}
}
devpriv->daccon = COMBINE(devpriv->daccon, trig,
- PCI224_DACCON_TRIG_MASK);
+ PCI224_DACCON_TRIG_MASK);
outw(devpriv->daccon, dev->iobase + PCI224_DACCON);
}
if (s->async->events) {
@@ -731,7 +737,7 @@ static void pci224_ao_handle_fifo(struct comedi_device *dev, struct comedi_subde
*/
static int
pci224_ao_inttrig_start(struct comedi_device *dev, struct comedi_subdevice *s,
- unsigned int trignum)
+ unsigned int trignum)
{
if (trignum != 0)
return -EINVAL;
@@ -750,7 +756,8 @@ 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;
@@ -828,13 +835,13 @@ pci224_ao_cmdtest(struct comedi_device *dev, struct comedi_subdevice *s, struct
/* Force to external trigger 0. */
if ((cmd->start_arg & ~CR_FLAGS_MASK) != 0) {
cmd->start_arg = COMBINE(cmd->start_arg, 0,
- ~CR_FLAGS_MASK);
+ ~CR_FLAGS_MASK);
err++;
}
/* The only flag allowed is CR_EDGE, which is ignored. */
if ((cmd->start_arg & CR_FLAGS_MASK & ~CR_EDGE) != 0) {
cmd->start_arg = COMBINE(cmd->start_arg, 0,
- CR_FLAGS_MASK & ~CR_EDGE);
+ CR_FLAGS_MASK & ~CR_EDGE);
err++;
}
break;
@@ -859,14 +866,16 @@ pci224_ao_cmdtest(struct comedi_device *dev, struct comedi_subdevice *s, struct
/* Force to external trigger 0. */
if ((cmd->scan_begin_arg & ~CR_FLAGS_MASK) != 0) {
cmd->scan_begin_arg = COMBINE(cmd->scan_begin_arg, 0,
- ~CR_FLAGS_MASK);
+ ~CR_FLAGS_MASK);
err++;
}
/* Only allow flags CR_EDGE and CR_INVERT. Ignore CR_EDGE. */
if ((cmd->scan_begin_arg & CR_FLAGS_MASK &
- ~(CR_EDGE | CR_INVERT)) != 0) {
+ ~(CR_EDGE | CR_INVERT)) != 0) {
cmd->scan_begin_arg = COMBINE(cmd->scan_begin_arg, 0,
- CR_FLAGS_MASK & ~(CR_EDGE | CR_INVERT));
+ CR_FLAGS_MASK & ~(CR_EDGE
+ |
+ CR_INVERT));
err++;
}
break;
@@ -892,13 +901,13 @@ pci224_ao_cmdtest(struct comedi_device *dev, struct comedi_subdevice *s, struct
/* Force to external trigger 0. */
if ((cmd->stop_arg & ~CR_FLAGS_MASK) != 0) {
cmd->stop_arg = COMBINE(cmd->stop_arg, 0,
- ~CR_FLAGS_MASK);
+ ~CR_FLAGS_MASK);
err++;
}
/* The only flag allowed is CR_EDGE, which is ignored. */
if ((cmd->stop_arg & CR_FLAGS_MASK & ~CR_EDGE) != 0) {
cmd->stop_arg = COMBINE(cmd->stop_arg, 0,
- CR_FLAGS_MASK & ~CR_EDGE);
+ CR_FLAGS_MASK & ~CR_EDGE);
}
break;
case TRIG_NONE:
@@ -935,14 +944,14 @@ pci224_ao_cmdtest(struct comedi_device *dev, struct comedi_subdevice *s, struct
/* Be careful to avoid overflow! */
div2 = cmd->scan_begin_arg / TIMEBASE_10MHZ;
div2 += (round + cmd->scan_begin_arg % TIMEBASE_10MHZ) /
- TIMEBASE_10MHZ;
+ TIMEBASE_10MHZ;
if (div2 <= 0x10000) {
/* A single timer will suffice. */
if (div2 < 2)
div2 = 2;
cmd->scan_begin_arg = div2 * TIMEBASE_10MHZ;
if (cmd->scan_begin_arg < div2 ||
- cmd->scan_begin_arg < TIMEBASE_10MHZ) {
+ cmd->scan_begin_arg < TIMEBASE_10MHZ) {
/* Overflow! */
cmd->scan_begin_arg = MAX_SCAN_PERIOD;
}
@@ -951,7 +960,8 @@ pci224_ao_cmdtest(struct comedi_device *dev, struct comedi_subdevice *s, struct
div1 = devpriv->cached_div1;
div2 = devpriv->cached_div2;
pci224_cascade_ns_to_timer(TIMEBASE_10MHZ, &div1, &div2,
- &cmd->scan_begin_arg, round_mode);
+ &cmd->scan_begin_arg,
+ round_mode);
devpriv->cached_div1 = div1;
devpriv->cached_div2 = div2;
}
@@ -1061,12 +1071,15 @@ static int pci224_ao_cmd(struct comedi_device *dev, struct comedi_subdevice *s)
* N.B. DAC FIFO interrupts are currently disabled.
*/
devpriv->daccon = COMBINE(devpriv->daccon,
- (devpriv->hwrange[range] | PCI224_DACCON_TRIG_NONE |
- PCI224_DACCON_FIFOINTR_NHALF),
- (PCI224_DACCON_POLAR_MASK | PCI224_DACCON_VREF_MASK |
- PCI224_DACCON_TRIG_MASK | PCI224_DACCON_FIFOINTR_MASK));
+ (devpriv->
+ hwrange[range] | PCI224_DACCON_TRIG_NONE |
+ PCI224_DACCON_FIFOINTR_NHALF),
+ (PCI224_DACCON_POLAR_MASK |
+ PCI224_DACCON_VREF_MASK |
+ PCI224_DACCON_TRIG_MASK |
+ PCI224_DACCON_FIFOINTR_MASK));
outw(devpriv->daccon | PCI224_DACCON_FIFORESET,
- dev->iobase + PCI224_DACCON);
+ dev->iobase + PCI224_DACCON);
if (cmd->scan_begin_src == TRIG_TIMER) {
unsigned int div1, div2, round;
@@ -1089,7 +1102,7 @@ static int pci224_ao_cmd(struct comedi_device *dev, struct comedi_subdevice *s)
/* Be careful to avoid overflow! */
div2 = cmd->scan_begin_arg / TIMEBASE_10MHZ;
div2 += (round + cmd->scan_begin_arg % TIMEBASE_10MHZ) /
- TIMEBASE_10MHZ;
+ TIMEBASE_10MHZ;
if (div2 <= 0x10000) {
/* A single timer will suffice. */
if (div2 < 2)
@@ -1101,7 +1114,7 @@ static int pci224_ao_cmd(struct comedi_device *dev, struct comedi_subdevice *s)
div1 = devpriv->cached_div1;
div2 = devpriv->cached_div2;
pci224_cascade_ns_to_timer(TIMEBASE_10MHZ, &div1, &div2,
- &ns, round_mode);
+ &ns, round_mode);
}
/*
@@ -1110,25 +1123,25 @@ static int pci224_ao_cmd(struct comedi_device *dev, struct comedi_subdevice *s)
*/
/* Make sure Z2-0 is gated on. */
outb(GAT_CONFIG(0, GAT_VCC),
- devpriv->iobase1 + PCI224_ZGAT_SCE);
+ devpriv->iobase1 + PCI224_ZGAT_SCE);
if (div1 == 1) {
/* Not cascading. Z2-0 needs 10 MHz clock. */
outb(CLK_CONFIG(0, CLK_10MHZ),
- devpriv->iobase1 + PCI224_ZCLK_SCE);
+ devpriv->iobase1 + PCI224_ZCLK_SCE);
} else {
/* Cascading with Z2-2. */
/* Make sure Z2-2 is gated on. */
outb(GAT_CONFIG(2, GAT_VCC),
- devpriv->iobase1 + PCI224_ZGAT_SCE);
+ devpriv->iobase1 + PCI224_ZGAT_SCE);
/* Z2-2 needs 10 MHz clock. */
outb(CLK_CONFIG(2, CLK_10MHZ),
- devpriv->iobase1 + PCI224_ZCLK_SCE);
+ devpriv->iobase1 + PCI224_ZCLK_SCE);
/* Load Z2-2 mode (2) and counter (div1). */
i8254_load(devpriv->iobase1 + PCI224_Z2_CT0, 0,
- 2, div1, 2);
+ 2, div1, 2);
/* Z2-0 is clocked from Z2-2's output. */
outb(CLK_CONFIG(0, CLK_OUTNM1),
- devpriv->iobase1 + PCI224_ZCLK_SCE);
+ devpriv->iobase1 + PCI224_ZCLK_SCE);
}
/* Load Z2-0 mode (2) and counter (div2). */
i8254_load(devpriv->iobase1 + PCI224_Z2_CT0, 0, 0, div2, 2);
@@ -1174,7 +1187,8 @@ 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;
@@ -1184,8 +1198,8 @@ 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,
- unsigned int num_bytes, unsigned int chan_index)
+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;
short *array = data;
@@ -1198,7 +1212,7 @@ pci224_ao_munge(struct comedi_device *dev, struct comedi_subdevice *s, void *dat
shift = 16 - thisboard->ao_bits;
/* Channels will be all bipolar or all unipolar. */
if ((devpriv->hwrange[CR_RANGE(async->cmd.chanlist[0])] &
- PCI224_DACCON_POLAR_MASK) == PCI224_DACCON_POLAR_UNI) {
+ PCI224_DACCON_POLAR_MASK) == PCI224_DACCON_POLAR_UNI) {
/* Unipolar */
offset = 0;
} else {
@@ -1253,7 +1267,7 @@ static irqreturn_t pci224_interrupt(int irq, void *d)
spin_lock_irqsave(&devpriv->ao_spinlock, flags);
if (curenab != devpriv->intsce) {
outb(devpriv->intsce,
- devpriv->iobase1 + PCI224_INT_SCE);
+ devpriv->iobase1 + PCI224_INT_SCE);
}
devpriv->intr_running = 0;
spin_unlock_irqrestore(&devpriv->ao_spinlock, flags);
@@ -1267,7 +1281,7 @@ static irqreturn_t pci224_interrupt(int irq, void *d)
*/
static int
pci224_find_pci(struct comedi_device *dev, int bus, int slot,
- struct pci_dev **pci_dev_p)
+ struct pci_dev **pci_dev_p)
{
struct pci_dev *pci_dev = NULL;
@@ -1275,13 +1289,13 @@ pci224_find_pci(struct comedi_device *dev, int bus, int slot,
/* Look for matching PCI device. */
for (pci_dev = pci_get_device(PCI_VENDOR_ID_AMPLICON, PCI_ANY_ID, NULL);
- pci_dev != NULL;
- pci_dev = pci_get_device(PCI_VENDOR_ID_AMPLICON, PCI_ANY_ID,
- pci_dev)) {
+ pci_dev != NULL;
+ pci_dev = pci_get_device(PCI_VENDOR_ID_AMPLICON, PCI_ANY_ID,
+ pci_dev)) {
/* If bus/slot specified, check them. */
if (bus || slot) {
if (bus != pci_dev->bus->number
- || slot != PCI_SLOT(pci_dev->devfn))
+ || slot != PCI_SLOT(pci_dev->devfn))
continue;
}
if (thisboard->model == any_model) {
@@ -1310,11 +1324,11 @@ pci224_find_pci(struct comedi_device *dev, int bus, int slot,
/* No match found. */
if (bus || slot) {
printk(KERN_ERR "comedi%d: error! "
- "no %s found at pci %02x:%02x!\n",
- dev->minor, thisboard->name, bus, slot);
+ "no %s found at pci %02x:%02x!\n",
+ dev->minor, thisboard->name, bus, slot);
} else {
printk(KERN_ERR "comedi%d: error! no %s found!\n",
- dev->minor, thisboard->name);
+ dev->minor, thisboard->name);
}
return -EIO;
}
@@ -1341,7 +1355,7 @@ static int pci224_attach(struct comedi_device *dev, struct comedi_devconfig *it)
ret = alloc_private(dev, sizeof(struct pci224_private));
if (ret < 0) {
printk(KERN_ERR "comedi%d: error! out of memory!\n",
- dev->minor);
+ dev->minor);
return ret;
}
@@ -1353,8 +1367,8 @@ static int pci224_attach(struct comedi_device *dev, struct comedi_devconfig *it)
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);
+ "comedi%d: error! cannot enable PCI device "
+ "and request regions!\n", dev->minor);
return ret;
}
spin_lock_init(&devpriv->ao_spinlock);
@@ -1365,21 +1379,21 @@ static int pci224_attach(struct comedi_device *dev, struct comedi_devconfig *it)
/* Allocate readback buffer for AO channels. */
devpriv->ao_readback = kmalloc(sizeof(devpriv->ao_readback[0]) *
- thisboard->ao_chans, GFP_KERNEL);
+ thisboard->ao_chans, GFP_KERNEL);
if (!devpriv->ao_readback) {
return -ENOMEM;
}
/* Allocate buffer to hold values for AO channel scan. */
devpriv->ao_scan_vals = kmalloc(sizeof(devpriv->ao_scan_vals[0]) *
- thisboard->ao_chans, GFP_KERNEL);
+ thisboard->ao_chans, GFP_KERNEL);
if (!devpriv->ao_scan_vals) {
return -ENOMEM;
}
/* Allocate buffer to hold AO channel scan order. */
devpriv->ao_scan_order = kmalloc(sizeof(devpriv->ao_scan_order[0]) *
- thisboard->ao_chans, GFP_KERNEL);
+ thisboard->ao_chans, GFP_KERNEL);
if (!devpriv->ao_scan_order) {
return -ENOMEM;
}
@@ -1393,15 +1407,16 @@ static int pci224_attach(struct comedi_device *dev, struct comedi_devconfig *it)
outw(0, dev->iobase + PCI224_DACCEN);
outw(0, dev->iobase + PCI224_FIFOSIZ);
devpriv->daccon = (PCI224_DACCON_TRIG_SW | PCI224_DACCON_POLAR_BI |
- PCI224_DACCON_FIFOENAB | PCI224_DACCON_FIFOINTR_EMPTY);
+ PCI224_DACCON_FIFOENAB |
+ PCI224_DACCON_FIFOINTR_EMPTY);
outw(devpriv->daccon | PCI224_DACCON_FIFORESET,
- dev->iobase + PCI224_DACCON);
+ dev->iobase + PCI224_DACCON);
/* Allocate subdevices. There is only one! */
ret = alloc_subdevices(dev, 1);
if (ret < 0) {
printk(KERN_ERR "comedi%d: error! out of memory!\n",
- dev->minor);
+ dev->minor);
return ret;
}
@@ -1427,22 +1442,22 @@ static int pci224_attach(struct comedi_device *dev, struct comedi_devconfig *it)
const struct comedi_lrange **range_table_list;
s->range_table_list = range_table_list =
- kmalloc(sizeof(struct comedi_lrange *) * s->n_chan,
- GFP_KERNEL);
+ kmalloc(sizeof(struct comedi_lrange *) * s->n_chan,
+ GFP_KERNEL);
if (!s->range_table_list) {
return -ENOMEM;
}
for (n = 2; n < 3 + s->n_chan; n++) {
if (it->options[n] < 0 || it->options[n] > 1) {
printk(KERN_WARNING "comedi%d: %s: warning! "
- "bad options[%u]=%d\n",
- dev->minor, DRIVER_NAME, n,
- it->options[n]);
+ "bad options[%u]=%d\n",
+ dev->minor, DRIVER_NAME, n,
+ it->options[n]);
}
}
for (n = 0; n < s->n_chan; n++) {
if (n < COMEDI_NDEVCONFOPTS - 3 &&
- it->options[3 + n] == 1) {
+ it->options[3 + n] == 1) {
if (it->options[2] == 1) {
range_table_list[n] = &range_pci234_ext;
} else {
@@ -1451,7 +1466,7 @@ static int pci224_attach(struct comedi_device *dev, struct comedi_devconfig *it)
} else {
if (it->options[2] == 1) {
range_table_list[n] =
- &range_pci234_ext2;
+ &range_pci234_ext2;
} else {
range_table_list[n] = &range_bipolar10;
}
@@ -1466,9 +1481,8 @@ static int pci224_attach(struct comedi_device *dev, struct comedi_devconfig *it)
} else {
if (it->options[2] != 0) {
printk(KERN_WARNING "comedi%d: %s: warning! "
- "bad options[2]=%d\n",
- dev->minor, DRIVER_NAME,
- it->options[2]);
+ "bad options[2]=%d\n",
+ dev->minor, DRIVER_NAME, it->options[2]);
}
s->range_table = &range_pci224_internal;
devpriv->hwrange = hwrange_pci224_internal;
@@ -1482,7 +1496,7 @@ static int pci224_attach(struct comedi_device *dev, struct comedi_devconfig *it)
DRIVER_NAME, dev);
if (ret < 0) {
printk(KERN_ERR "comedi%d: error! "
- "unable to allocate irq %u\n", dev->minor, irq);
+ "unable to allocate irq %u\n", dev->minor, irq);
return ret;
} else {
dev->irq = irq;
@@ -1545,7 +1559,7 @@ static int pci224_detach(struct comedi_device *dev)
}
if (dev->board_name) {
printk(KERN_INFO "comedi%d: %s removed\n",
- dev->minor, dev->board_name);
+ dev->minor, dev->board_name);
}
return 0;
diff --git a/drivers/staging/comedi/drivers/amplc_pci230.c b/drivers/staging/comedi/drivers/amplc_pci230.c
index 21133f068bf3..c4d8c4cae4a5 100644
--- a/drivers/staging/comedi/drivers/amplc_pci230.c
+++ b/drivers/staging/comedi/drivers/amplc_pci230.c
@@ -457,55 +457,56 @@ 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,
+ },
};
static DEFINE_PCI_DEVICE_TABLE(pci230_pci_table) = {
- {PCI_VENDOR_ID_AMPLICON, PCI_DEVICE_ID_PCI230, PCI_ANY_ID, PCI_ANY_ID,
- 0, 0, 0},
- {PCI_VENDOR_ID_AMPLICON, PCI_DEVICE_ID_PCI260, PCI_ANY_ID, PCI_ANY_ID,
- 0, 0, 0},
- {0}
+ {
+ PCI_VENDOR_ID_AMPLICON, PCI_DEVICE_ID_PCI230, PCI_ANY_ID,
+ PCI_ANY_ID, 0, 0, 0}, {
+ PCI_VENDOR_ID_AMPLICON, PCI_DEVICE_ID_PCI260, PCI_ANY_ID,
+ PCI_ANY_ID, 0, 0, 0}, {
+ 0}
};
MODULE_DEVICE_TABLE(pci, pci230_pci_table);
@@ -571,14 +572,14 @@ static const unsigned int pci230_timebase[8] = {
/* PCI230 analogue input range table */
static const struct comedi_lrange pci230_ai_range = { 7, {
- BIP_RANGE(10),
- BIP_RANGE(5),
- BIP_RANGE(2.5),
- BIP_RANGE(1.25),
- UNI_RANGE(10),
- UNI_RANGE(5),
- UNI_RANGE(2.5)
- }
+ BIP_RANGE(10),
+ BIP_RANGE(5),
+ BIP_RANGE(2.5),
+ BIP_RANGE(1.25),
+ UNI_RANGE(10),
+ UNI_RANGE(5),
+ UNI_RANGE(2.5)
+ }
};
/* PCI230 analogue gain bits for each input range. */
@@ -589,9 +590,9 @@ static const unsigned char pci230_ai_bipolar[7] = { 1, 1, 1, 1, 0, 0, 0 };
/* PCI230 analogue output range table */
static const struct comedi_lrange pci230_ao_range = { 2, {
- UNI_RANGE(10),
- BIP_RANGE(10)
- }
+ UNI_RANGE(10),
+ BIP_RANGE(10)
+ }
};
/* PCI230 daccon bipolar flag for each analogue output range. */
@@ -603,7 +604,8 @@ 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_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",
@@ -617,35 +619,48 @@ static struct comedi_driver driver_amplc_pci230 = {
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 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);
+ 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);
-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);
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_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 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);
+ short data = (short)inw(dev->iobase + PCI230_ADCDATA);
/* PCI230 is 12 bit - stored in upper bits of 16 bit register (lower
* four bits reserved for expansion). */
@@ -661,7 +676,7 @@ static short pci230_ai_read(struct comedi_device *dev)
}
static inline unsigned short pci230_ao_mangle_datum(struct comedi_device *dev,
- short datum)
+ short datum)
{
/* If a bipolar range was specified, mangle it (straight binary->twos
* complement). */
@@ -676,26 +691,28 @@ 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,
- unsigned int chan)
+static inline void pci230_ao_write_nofifo(struct comedi_device *dev,
+ short datum, unsigned int chan)
{
/* Store unmangled datum to be read back later. */
devpriv->ao_readback[chan] = datum;
/* Write mangled datum to appropriate DACOUT register. */
outw(pci230_ao_mangle_datum(dev, datum), dev->iobase + (((chan) == 0)
- ? PCI230_DACOUT1 : PCI230_DACOUT2));
+ ? PCI230_DACOUT1
+ :
+ PCI230_DACOUT2));
}
static inline void pci230_ao_write_fifo(struct comedi_device *dev, short datum,
- unsigned int chan)
+ unsigned int chan)
{
/* Store unmangled datum to be read back later. */
devpriv->ao_readback[chan] = datum;
/* Write mangled datum to appropriate DACDATA register. */
outw(pci230_ao_mangle_datum(dev, datum),
- dev->iobase + PCI230P2_DACDATA);
+ dev->iobase + PCI230P2_DACDATA);
}
/*
@@ -713,7 +730,7 @@ static int pci230_attach(struct comedi_device *dev, struct comedi_devconfig *it)
int i = 0, irq_hdl, rc;
printk("comedi%d: amplc_pci230: attach %s %d,%d\n", dev->minor,
- thisboard->name, it->options[0], it->options[1]);
+ thisboard->name, it->options[0], it->options[1]);
/* Allocate the private structure area using alloc_private().
* Macro defined in comedidev.h - memsets struct fields to 0. */
@@ -726,12 +743,12 @@ static int pci230_attach(struct comedi_device *dev, struct comedi_devconfig *it)
spin_lock_init(&devpriv->ao_stop_spinlock);
/* Find card */
for (pci_dev = pci_get_device(PCI_ANY_ID, PCI_ANY_ID, NULL);
- pci_dev != NULL;
- pci_dev = pci_get_device(PCI_ANY_ID, PCI_ANY_ID, pci_dev)) {
+ pci_dev != NULL;
+ pci_dev = pci_get_device(PCI_ANY_ID, PCI_ANY_ID, pci_dev)) {
if (it->options[0] || it->options[1]) {
/* Match against bus/slot options. */
if (it->options[0] != pci_dev->bus->number ||
- it->options[1] != PCI_SLOT(pci_dev->devfn))
+ it->options[1] != PCI_SLOT(pci_dev->devfn))
continue;
}
if (pci_dev->vendor != PCI_VENDOR_ID_AMPLICON)
@@ -748,7 +765,7 @@ static int pci230_attach(struct comedi_device *dev, struct comedi_devconfig *it)
* First check length of
* registers. */
if (pci_resource_len(pci_dev, 3)
- < 32) {
+ < 32) {
/* Not a '+' model. */
continue;
}
@@ -790,7 +807,7 @@ static int pci230_attach(struct comedi_device *dev, struct comedi_devconfig *it)
}
if (!pci_dev) {
printk("comedi%d: No %s card found\n", dev->minor,
- thisboard->name);
+ thisboard->name);
return -EIO;
}
devpriv->pci_dev = pci_dev;
@@ -803,7 +820,7 @@ static int pci230_attach(struct comedi_device *dev, struct comedi_devconfig *it)
/* Enable PCI device and reserve I/O spaces. */
if (comedi_pci_enable(pci_dev, "amplc_pci230") < 0) {
printk("comedi%d: failed to enable PCI device "
- "and request regions\n", dev->minor);
+ "and request regions\n", dev->minor);
return -EIO;
}
@@ -813,7 +830,7 @@ static int pci230_attach(struct comedi_device *dev, struct comedi_devconfig *it)
iobase2 = pci_resource_start(pci_dev, 3);
printk("comedi%d: %s I/O region 1 0x%04lx I/O region 2 0x%04lx\n",
- dev->minor, dev->board_name, iobase1, iobase2);
+ dev->minor, dev->board_name, iobase1, iobase2);
devpriv->iobase1 = iobase1;
dev->iobase = iobase2;
@@ -829,9 +846,9 @@ static int pci230_attach(struct comedi_device *dev, struct comedi_devconfig *it)
devpriv->hwver = inw(dev->iobase + PCI230P_HWVER);
if (devpriv->hwver < thisboard->min_hwver) {
printk("comedi%d: %s - bad hardware version "
- "- got %u, need %u\n", dev->minor,
- dev->board_name, devpriv->hwver,
- thisboard->min_hwver);
+ "- got %u, need %u\n", dev->minor,
+ dev->board_name, devpriv->hwver,
+ thisboard->min_hwver);
return -EIO;
}
if (devpriv->hwver > 0) {
@@ -844,7 +861,7 @@ static int pci230_attach(struct comedi_device *dev, struct comedi_devconfig *it)
extfunc |= PCI230P_EXTFUNC_GAT_EXTTRIG;
}
if ((thisboard->ao_chans > 0)
- && (devpriv->hwver >= 2)) {
+ && (devpriv->hwver >= 2)) {
/* Enable DAC FIFO functionality. */
extfunc |= PCI230P2_EXTFUNC_DACFIFO;
}
@@ -854,8 +871,8 @@ static int pci230_attach(struct comedi_device *dev, struct comedi_devconfig *it)
/* Temporarily enable DAC FIFO, reset it and disable
* FIFO wraparound. */
outw(devpriv->daccon | PCI230P2_DAC_FIFO_EN
- | PCI230P2_DAC_FIFO_RESET,
- dev->iobase + PCI230_DACCON);
+ | PCI230P2_DAC_FIFO_RESET,
+ dev->iobase + PCI230_DACCON);
/* Clear DAC FIFO channel enable register. */
outw(0, dev->iobase + PCI230P2_DACEN);
/* Disable DAC FIFO. */
@@ -869,23 +886,23 @@ static int pci230_attach(struct comedi_device *dev, struct comedi_devconfig *it)
/* Set ADC to a reasonable state. */
devpriv->adcg = 0;
devpriv->adccon = PCI230_ADC_TRIG_NONE | PCI230_ADC_IM_SE
- | PCI230_ADC_IR_BIP;
+ | PCI230_ADC_IR_BIP;
outw(1 << 0, dev->iobase + PCI230_ADCEN);
outw(devpriv->adcg, dev->iobase + PCI230_ADCG);
outw(devpriv->adccon | PCI230_ADC_FIFO_RESET,
- dev->iobase + PCI230_ADCCON);
+ dev->iobase + PCI230_ADCCON);
/* Register the interrupt handler. */
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,
- devpriv->pci_dev->irq);
+ "commands will not be available %d\n", dev->minor,
+ devpriv->pci_dev->irq);
} else {
dev->irq = devpriv->pci_dev->irq;
printk("comedi%d: registered irq %u\n", dev->minor,
- devpriv->pci_dev->irq);
+ devpriv->pci_dev->irq);
}
/*
@@ -941,7 +958,7 @@ static int pci230_attach(struct comedi_device *dev, struct comedi_devconfig *it)
/* digital i/o subdevice */
if (thisboard->have_dio) {
rc = subdev_8255_init(dev, s, NULL,
- (devpriv->iobase1 + PCI230_PPI_X_BASE));
+ (devpriv->iobase1 + PCI230_PPI_X_BASE));
if (rc < 0)
return rc;
} else {
@@ -985,7 +1002,7 @@ static int pci230_detach(struct comedi_device *dev)
}
static int get_resources(struct comedi_device *dev, unsigned int res_mask,
- unsigned char owner)
+ unsigned char owner)
{
int ok;
unsigned int i;
@@ -997,7 +1014,7 @@ static int get_resources(struct comedi_device *dev, unsigned int res_mask,
claimed = 0;
spin_lock_irqsave(&devpriv->res_spinlock, irqflags);
for (b = 1, i = 0; (i < NUM_RESOURCES)
- && (res_mask != 0); b <<= 1, i++) {
+ && (res_mask != 0); b <<= 1, i++) {
if ((res_mask & b) != 0) {
res_mask &= ~b;
if (devpriv->res_owner[i] == OWNER_NONE) {
@@ -1007,7 +1024,7 @@ static int get_resources(struct comedi_device *dev, unsigned int res_mask,
for (b = 1, i = 0; claimed != 0; b <<= 1, i++) {
if ((claimed & b) != 0) {
devpriv->res_owner[i]
- = OWNER_NONE;
+ = OWNER_NONE;
claimed &= ~b;
}
}
@@ -1020,14 +1037,14 @@ static int get_resources(struct comedi_device *dev, unsigned int res_mask,
return ok;
}
-static inline int get_one_resource(struct comedi_device *dev, unsigned int resource,
- unsigned char owner)
+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,
- unsigned char owner)
+ unsigned char owner)
{
unsigned int i;
unsigned int b;
@@ -1035,7 +1052,7 @@ static void put_resources(struct comedi_device *dev, unsigned int res_mask,
spin_lock_irqsave(&devpriv->res_spinlock, irqflags);
for (b = 1, i = 0; (i < NUM_RESOURCES)
- && (res_mask != 0); b <<= 1, i++) {
+ && (res_mask != 0); b <<= 1, i++) {
if ((res_mask & b) != 0) {
res_mask &= ~b;
if (devpriv->res_owner[i] == owner) {
@@ -1046,13 +1063,14 @@ static void put_resources(struct comedi_device *dev, unsigned int res_mask,
spin_unlock_irqrestore(&devpriv->res_spinlock, irqflags);
}
-static inline void put_one_resource(struct comedi_device *dev, unsigned int resource,
- unsigned char owner)
+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);
}
@@ -1060,8 +1078,9 @@ static inline void put_all_resources(struct comedi_device *dev, unsigned char ow
/*
* 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;
@@ -1112,7 +1131,7 @@ static int pci230_ai_rinsn(struct comedi_device *dev, struct comedi_subdevice *s
adccon |= PCI230_ADC_IM_SE;
}
devpriv->adcg = (devpriv->adcg & ~(3 << gainshift))
- | (pci230_ai_gain[range] << gainshift);
+ | (pci230_ai_gain[range] << gainshift);
if (devpriv->ai_bipolar) {
adccon |= PCI230_ADC_IR_BIP;
} else {
@@ -1135,9 +1154,9 @@ static int pci230_ai_rinsn(struct comedi_device *dev, struct comedi_subdevice *s
/* Trigger conversion by toggling Z2-CT2 output (finish with
* output high). */
i8254_set_mode(devpriv->iobase1 + PCI230_Z2_CT_BASE, 0, 2,
- I8254_MODE0);
+ I8254_MODE0);
i8254_set_mode(devpriv->iobase1 + PCI230_Z2_CT_BASE, 0, 2,
- I8254_MODE1);
+ I8254_MODE1);
#define TIMEOUT 100
/* wait for conversion to end */
@@ -1165,8 +1184,9 @@ static int pci230_ai_rinsn(struct comedi_device *dev, struct comedi_subdevice *s
/*
* 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;
@@ -1193,8 +1213,9 @@ static int pci230_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 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);
@@ -1205,8 +1226,8 @@ static int pci230_ao_rinsn(struct comedi_device *dev, struct comedi_subdevice *s
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;
@@ -1317,17 +1338,16 @@ static int pci230_ao_cmdtest(struct comedi_device *dev, struct comedi_subdevice
/* Trigger number must be 0. */
if ((cmd->scan_begin_arg & ~CR_FLAGS_MASK) != 0) {
cmd->scan_begin_arg = COMBINE(cmd->scan_begin_arg, 0,
- ~CR_FLAGS_MASK);
+ ~CR_FLAGS_MASK);
err++;
}
/* The only flags allowed are CR_EDGE and CR_INVERT. The
* CR_EDGE flag is ignored. */
if ((cmd->scan_begin_arg
- & (CR_FLAGS_MASK & ~(CR_EDGE | CR_INVERT))) !=
- 0) {
+ & (CR_FLAGS_MASK & ~(CR_EDGE | CR_INVERT))) != 0) {
cmd->scan_begin_arg =
- COMBINE(cmd->scan_begin_arg, 0,
- CR_FLAGS_MASK & ~(CR_EDGE | CR_INVERT));
+ COMBINE(cmd->scan_begin_arg, 0,
+ CR_FLAGS_MASK & ~(CR_EDGE | CR_INVERT));
err++;
}
break;
@@ -1361,7 +1381,7 @@ static int pci230_ao_cmdtest(struct comedi_device *dev, struct comedi_subdevice
if (cmd->scan_begin_src == TRIG_TIMER) {
tmp = cmd->scan_begin_arg;
pci230_ns_to_single_timer(&cmd->scan_begin_arg,
- cmd->flags & TRIG_ROUND_MASK);
+ cmd->flags & TRIG_ROUND_MASK);
if (tmp != cmd->scan_begin_arg)
err++;
}
@@ -1419,7 +1439,8 @@ static int pci230_ao_cmdtest(struct comedi_device *dev, struct comedi_subdevice
}
static int pci230_ao_inttrig_scan_begin(struct comedi_device *dev,
- struct comedi_subdevice *s, unsigned int trig_num)
+ struct comedi_subdevice *s,
+ unsigned int trig_num)
{
unsigned long irqflags;
@@ -1431,16 +1452,16 @@ static int pci230_ao_inttrig_scan_begin(struct comedi_device *dev,
/* Perform scan. */
if (devpriv->hwver < 2) {
/* Not using DAC FIFO. */
- spin_unlock_irqrestore(&devpriv->
- ao_stop_spinlock, irqflags);
+ spin_unlock_irqrestore(&devpriv->ao_stop_spinlock,
+ irqflags);
pci230_handle_ao_nofifo(dev, s);
comedi_event(dev, s);
} else {
/* Using DAC FIFO. */
/* Read DACSWTRIG register to trigger conversion. */
inw(dev->iobase + PCI230P2_DACSWTRIG);
- spin_unlock_irqrestore(&devpriv->
- ao_stop_spinlock, irqflags);
+ 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. */
@@ -1450,7 +1471,8 @@ static int pci230_ao_inttrig_scan_begin(struct comedi_device *dev,
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;
@@ -1499,7 +1521,8 @@ static void pci230_ao_start(struct comedi_device *dev, struct comedi_subdevice *
break;
}
devpriv->daccon = (devpriv->daccon
- & ~PCI230P2_DAC_TRIG_MASK) | scantrig;
+ & ~PCI230P2_DAC_TRIG_MASK) |
+ scantrig;
outw(devpriv->daccon, dev->iobase + PCI230_DACCON);
}
@@ -1509,17 +1532,17 @@ static void pci230_ao_start(struct comedi_device *dev, struct comedi_subdevice *
/* Not using DAC FIFO. */
/* Enable CT1 timer interrupt. */
spin_lock_irqsave(&devpriv->isr_spinlock,
- irqflags);
+ irqflags);
devpriv->int_en |= PCI230_INT_ZCLK_CT1;
devpriv->ier |= PCI230_INT_ZCLK_CT1;
outb(devpriv->ier,
- devpriv->iobase1 + PCI230_INT_SCE);
- spin_unlock_irqrestore(&devpriv->
- isr_spinlock, irqflags);
+ devpriv->iobase1 + PCI230_INT_SCE);
+ spin_unlock_irqrestore(&devpriv->isr_spinlock,
+ irqflags);
}
/* Set CT1 gate high to start counting. */
outb(GAT_CONFIG(1, GAT_VCC),
- devpriv->iobase1 + PCI230_ZGAT_SCE);
+ devpriv->iobase1 + PCI230_ZGAT_SCE);
break;
case TRIG_INT:
async->inttrig = pci230_ao_inttrig_scan_begin;
@@ -1527,19 +1550,19 @@ static void pci230_ao_start(struct comedi_device *dev, struct comedi_subdevice *
}
if (devpriv->hwver >= 2) {
/* Using DAC FIFO. Enable DAC FIFO interrupt. */
- spin_lock_irqsave(&devpriv->isr_spinlock,
- irqflags);
+ 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);
spin_unlock_irqrestore(&devpriv->isr_spinlock,
- irqflags);
+ irqflags);
}
}
}
-static int pci230_ao_inttrig_start(struct comedi_device *dev, struct comedi_subdevice *s,
- unsigned int trig_num)
+static int pci230_ao_inttrig_start(struct comedi_device *dev,
+ struct comedi_subdevice *s,
+ unsigned int trig_num)
{
if (trig_num != 0)
return -EINVAL;
@@ -1600,24 +1623,25 @@ static int pci230_ao_cmd(struct comedi_device *dev, struct comedi_subdevice *s)
* N.B. DAC FIFO interrupts are currently disabled.
*/
daccon |= PCI230P2_DAC_FIFO_EN | PCI230P2_DAC_FIFO_RESET
- | PCI230P2_DAC_FIFO_UNDERRUN_CLEAR
- | PCI230P2_DAC_TRIG_NONE | PCI230P2_DAC_INT_FIFO_NHALF;
+ | PCI230P2_DAC_FIFO_UNDERRUN_CLEAR
+ | PCI230P2_DAC_TRIG_NONE | PCI230P2_DAC_INT_FIFO_NHALF;
}
/* Set DACCON. */
outw(daccon, dev->iobase + PCI230_DACCON);
/* Preserve most of DACCON apart from write-only, transient bits. */
devpriv->daccon = daccon
- & ~(PCI230P2_DAC_FIFO_RESET | PCI230P2_DAC_FIFO_UNDERRUN_CLEAR);
+ & ~(PCI230P2_DAC_FIFO_RESET | PCI230P2_DAC_FIFO_UNDERRUN_CLEAR);
if (cmd->scan_begin_src == TRIG_TIMER) {
/* Set the counter timer 1 to the specified scan frequency. */
/* cmd->scan_begin_arg is sampling period in ns */
/* gate it off for now. */
outb(GAT_CONFIG(1, GAT_GND),
- devpriv->iobase1 + PCI230_ZGAT_SCE);
+ devpriv->iobase1 + PCI230_ZGAT_SCE);
pci230_ct_setup_ns_mode(dev, 1, I8254_MODE3,
- cmd->scan_begin_arg, cmd->flags & TRIG_ROUND_MASK);
+ cmd->scan_begin_arg,
+ cmd->flags & TRIG_ROUND_MASK);
}
/* N.B. cmd->start_src == TRIG_INT */
@@ -1637,7 +1661,7 @@ static int pci230_ai_check_scan_period(struct comedi_cmd *cmd)
}
min_scan_period = chanlist_len * cmd->convert_arg;
if ((min_scan_period < chanlist_len)
- || (min_scan_period < cmd->convert_arg)) {
+ || (min_scan_period < cmd->convert_arg)) {
/* Arithmetic overflow. */
min_scan_period = UINT_MAX;
err++;
@@ -1650,8 +1674,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;
@@ -1679,7 +1703,7 @@ static int pci230_ai_cmdtest(struct comedi_device *dev, struct comedi_subdevice
* EXTTRIG/EXTCONVCLK input on pin 17 instead. */
if ((thisboard->have_dio) || (thisboard->min_hwver > 0)) {
cmd->scan_begin_src &= TRIG_FOLLOW | TRIG_TIMER | TRIG_INT
- | TRIG_EXT;
+ | TRIG_EXT;
} else {
cmd->scan_begin_src &= TRIG_FOLLOW | TRIG_TIMER | TRIG_INT;
}
@@ -1723,7 +1747,7 @@ static int pci230_ai_cmdtest(struct comedi_device *dev, struct comedi_subdevice
/* If scan_begin_src is not TRIG_FOLLOW, then a monostable will be
* set up to generate a fixed number of timed conversion pulses. */
if ((cmd->scan_begin_src != TRIG_FOLLOW)
- && (cmd->convert_src != TRIG_TIMER))
+ && (cmd->convert_src != TRIG_TIMER))
err++;
if (err)
@@ -1788,17 +1812,17 @@ static int pci230_ai_cmdtest(struct comedi_device *dev, struct comedi_subdevice
/* Trigger number must be 0. */
if ((cmd->convert_arg & ~CR_FLAGS_MASK) != 0) {
cmd->convert_arg = COMBINE(cmd->convert_arg, 0,
- ~CR_FLAGS_MASK);
+ ~CR_FLAGS_MASK);
err++;
}
/* The only flags allowed are CR_INVERT and CR_EDGE.
* CR_EDGE is required. */
if ((cmd->convert_arg & (CR_FLAGS_MASK & ~CR_INVERT))
- != CR_EDGE) {
+ != CR_EDGE) {
/* Set CR_EDGE, preserve CR_INVERT. */
cmd->convert_arg =
- COMBINE(cmd->start_arg, (CR_EDGE | 0),
- CR_FLAGS_MASK & ~CR_INVERT);
+ COMBINE(cmd->start_arg, (CR_EDGE | 0),
+ CR_FLAGS_MASK & ~CR_INVERT);
err++;
}
} else {
@@ -1836,13 +1860,13 @@ static int pci230_ai_cmdtest(struct comedi_device *dev, struct comedi_subdevice
* of CT2 (sample convert trigger is CT2) */
if ((cmd->scan_begin_arg & ~CR_FLAGS_MASK) != 0) {
cmd->scan_begin_arg = COMBINE(cmd->scan_begin_arg, 0,
- ~CR_FLAGS_MASK);
+ ~CR_FLAGS_MASK);
err++;
}
/* The only flag allowed is CR_EDGE, which is ignored. */
if ((cmd->scan_begin_arg & CR_FLAGS_MASK & ~CR_EDGE) != 0) {
cmd->scan_begin_arg = COMBINE(cmd->scan_begin_arg, 0,
- CR_FLAGS_MASK & ~CR_EDGE);
+ CR_FLAGS_MASK & ~CR_EDGE);
err++;
}
} else if (cmd->scan_begin_src == TRIG_TIMER) {
@@ -1867,7 +1891,7 @@ static int pci230_ai_cmdtest(struct comedi_device *dev, struct comedi_subdevice
if (cmd->convert_src == TRIG_TIMER) {
tmp = cmd->convert_arg;
pci230_ns_to_single_timer(&cmd->convert_arg,
- cmd->flags & TRIG_ROUND_MASK);
+ cmd->flags & TRIG_ROUND_MASK);
if (tmp != cmd->convert_arg)
err++;
}
@@ -1876,11 +1900,11 @@ static int pci230_ai_cmdtest(struct comedi_device *dev, struct comedi_subdevice
/* N.B. cmd->convert_arg is also TRIG_TIMER */
tmp = cmd->scan_begin_arg;
pci230_ns_to_single_timer(&cmd->scan_begin_arg,
- cmd->flags & TRIG_ROUND_MASK);
+ cmd->flags & TRIG_ROUND_MASK);
if (!pci230_ai_check_scan_period(cmd)) {
/* Was below minimum required. Round up. */
pci230_ns_to_single_timer(&cmd->scan_begin_arg,
- TRIG_ROUND_UP);
+ TRIG_ROUND_UP);
pci230_ai_check_scan_period(cmd);
}
if (tmp != cmd->scan_begin_arg)
@@ -1921,20 +1945,19 @@ static int pci230_ai_cmdtest(struct comedi_device *dev, struct comedi_subdevice
* differential. (These are remapped in software. In
* hardware, only the even channels are available.) */
if ((aref == AREF_DIFF)
- && (chan >= (s->n_chan / 2))) {
+ && (chan >= (s->n_chan / 2))) {
errors |= diffchan_err;
}
if (n > 0) {
/* Channel numbers must strictly increase or
* subsequence must repeat exactly. */
if ((chan <= prev_chan)
- && (subseq_len == 0)) {
+ && (subseq_len == 0)) {
subseq_len = n;
}
if ((subseq_len > 0)
- && (cmd->chanlist[n] !=
- cmd->chanlist[n %
- subseq_len])) {
+ && (cmd->chanlist[n] !=
+ cmd->chanlist[n % subseq_len])) {
errors |= seq_err;
}
/* Channels must have same AREF. */
@@ -1948,8 +1971,8 @@ static int pci230_ai_cmdtest(struct comedi_device *dev, struct comedi_subdevice
/* Single-ended channel pairs must have same
* range. */
if ((aref != AREF_DIFF)
- && (((chan ^ prev_chan) & ~1) == 0)
- && (range != prev_range)) {
+ && (((chan ^ prev_chan) & ~1) == 0)
+ && (range != prev_range)) {
errors |= rangepair_err;
}
}
@@ -1983,7 +2006,7 @@ static int pci230_ai_cmdtest(struct comedi_device *dev, struct comedi_subdevice
* does, and we can't tell them apart!
*/
if ((subseq_len > 1)
- && (CR_CHAN(cmd->chanlist[0]) != 0)) {
+ && (CR_CHAN(cmd->chanlist[0]) != 0)) {
errors |= buggy_chan0_err;
}
}
@@ -2021,11 +2044,11 @@ static int pci230_ai_cmdtest(struct comedi_device *dev, struct comedi_subdevice
if ((errors & buggy_chan0_err) != 0) {
/* Use printk instead of DPRINTK here. */
printk("comedi: comedi%d: amplc_pci230: "
- "ai_cmdtest: Buggy PCI230+/260+ "
- "h/w version %u requires first channel "
- "of multi-channel sequence to be 0 "
- "(corrected in h/w version 4)\n",
- dev->minor, devpriv->hwver);
+ "ai_cmdtest: Buggy PCI230+/260+ "
+ "h/w version %u requires first channel "
+ "of multi-channel sequence to be 0 "
+ "(corrected in h/w version 4)\n",
+ dev->minor, devpriv->hwver);
}
}
}
@@ -2037,7 +2060,7 @@ static int pci230_ai_cmdtest(struct comedi_device *dev, struct comedi_subdevice
}
static void pci230_ai_update_fifo_trigger_level(struct comedi_device *dev,
- struct comedi_subdevice *s)
+ struct comedi_subdevice *s)
{
struct comedi_cmd *cmd = &s->async->cmd;
unsigned int scanlen = cmd->scan_end_arg;
@@ -2050,13 +2073,12 @@ static void pci230_ai_update_fifo_trigger_level(struct comedi_device *dev,
wake = scanlen - devpriv->ai_scan_pos;
} else {
if (devpriv->ai_continuous
- || (devpriv->ai_scan_count
- >= PCI230_ADC_FIFOLEVEL_HALFFULL)
- || (scanlen >= PCI230_ADC_FIFOLEVEL_HALFFULL)) {
+ || (devpriv->ai_scan_count >= PCI230_ADC_FIFOLEVEL_HALFFULL)
+ || (scanlen >= PCI230_ADC_FIFOLEVEL_HALFFULL)) {
wake = PCI230_ADC_FIFOLEVEL_HALFFULL;
} else {
wake = (devpriv->ai_scan_count * scanlen)
- - devpriv->ai_scan_pos;
+ - devpriv->ai_scan_pos;
}
}
if (wake >= PCI230_ADC_FIFOLEVEL_HALFFULL) {
@@ -2080,8 +2102,9 @@ 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,
- unsigned int trig_num)
+static int pci230_ai_inttrig_convert(struct comedi_device *dev,
+ struct comedi_subdevice *s,
+ unsigned int trig_num)
{
unsigned long irqflags;
@@ -2095,36 +2118,35 @@ static int pci230_ai_inttrig_convert(struct comedi_device *dev, struct comedi_su
/* Trigger conversion by toggling Z2-CT2 output. Finish
* with output high. */
i8254_set_mode(devpriv->iobase1 + PCI230_Z2_CT_BASE, 0, 2,
- I8254_MODE0);
+ I8254_MODE0);
i8254_set_mode(devpriv->iobase1 + PCI230_Z2_CT_BASE, 0, 2,
- I8254_MODE1);
+ I8254_MODE1);
/* Delay. Should driver be responsible for this? An
* alternative would be to wait until conversion is complete,
* but we can't tell when it's complete because the ADC busy
* bit has a different meaning when FIFO enabled (and when
* FIFO not enabled, it only works for software triggers). */
if (((devpriv->adccon & PCI230_ADC_IM_MASK)
- == PCI230_ADC_IM_DIF)
- && (devpriv->hwver == 0)) {
+ == PCI230_ADC_IM_DIF)
+ && (devpriv->hwver == 0)) {
/* PCI230/260 in differential mode */
delayus = 8;
} else {
/* single-ended or PCI230+/260+ */
delayus = 4;
}
- spin_unlock_irqrestore(&devpriv->ai_stop_spinlock,
- irqflags);
+ spin_unlock_irqrestore(&devpriv->ai_stop_spinlock, irqflags);
udelay(delayus);
} else {
- spin_unlock_irqrestore(&devpriv->ai_stop_spinlock,
- irqflags);
+ 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)
+ struct comedi_subdevice *s,
+ unsigned int trig_num)
{
unsigned long irqflags;
unsigned char zgat;
@@ -2145,7 +2167,8 @@ static int pci230_ai_inttrig_scan_begin(struct comedi_device *dev,
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;
@@ -2203,7 +2226,7 @@ static void pci230_ai_start(struct comedi_device *dev, struct comedi_subdevice *
break;
}
devpriv->adccon = (devpriv->adccon & ~PCI230_ADC_TRIG_MASK)
- | conv;
+ | conv;
outw(devpriv->adccon, dev->iobase + PCI230_ADCCON);
if (cmd->convert_src == TRIG_INT) {
async->inttrig = pci230_ai_inttrig_convert;
@@ -2267,11 +2290,11 @@ static void pci230_ai_start(struct comedi_device *dev, struct comedi_subdevice *
* gated on to start counting. */
zgat = GAT_CONFIG(1, GAT_VCC);
outb(zgat, devpriv->iobase1
- + PCI230_ZGAT_SCE);
+ + PCI230_ZGAT_SCE);
break;
case TRIG_INT:
async->inttrig =
- pci230_ai_inttrig_scan_begin;
+ pci230_ai_inttrig_scan_begin;
break;
}
}
@@ -2282,8 +2305,9 @@ 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,
- unsigned int trig_num)
+static int pci230_ai_inttrig_start(struct comedi_device *dev,
+ struct comedi_subdevice *s,
+ unsigned int trig_num)
{
if (trig_num != 0)
return -EINVAL;
@@ -2394,7 +2418,7 @@ static int pci230_ai_cmd(struct comedi_device *dev, struct comedi_subdevice *s)
adcen |= 1 << chan;
}
devpriv->adcg = (devpriv->adcg & ~(3 << gainshift))
- | (pci230_ai_gain[range] << gainshift);
+ | (pci230_ai_gain[range] << gainshift);
}
/* Set channel scan list. */
@@ -2439,7 +2463,7 @@ static int pci230_ai_cmd(struct comedi_device *dev, struct comedi_subdevice *s)
outb(zgat, devpriv->iobase1 + PCI230_ZGAT_SCE);
/* Set counter/timer 2 to the specified conversion period. */
pci230_ct_setup_ns_mode(dev, 2, I8254_MODE3, cmd->convert_arg,
- cmd->flags & TRIG_ROUND_MASK);
+ cmd->flags & TRIG_ROUND_MASK);
if (cmd->scan_begin_src != TRIG_FOLLOW) {
/*
* Set up monostable on CT0 output for scan timing. A
@@ -2456,8 +2480,9 @@ static int pci230_ai_cmd(struct comedi_device *dev, struct comedi_subdevice *s)
zgat = GAT_CONFIG(0, GAT_VCC);
outb(zgat, devpriv->iobase1 + PCI230_ZGAT_SCE);
pci230_ct_setup_ns_mode(dev, 0, I8254_MODE1,
- ((uint64_t) cmd->convert_arg
- * cmd->scan_end_arg), TRIG_ROUND_UP);
+ ((uint64_t) cmd->convert_arg
+ * cmd->scan_end_arg),
+ TRIG_ROUND_UP);
if (cmd->scan_begin_src == TRIG_TIMER) {
/*
* Monostable on CT0 will be triggered by
@@ -2468,8 +2493,10 @@ static int pci230_ai_cmd(struct comedi_device *dev, struct comedi_subdevice *s)
zgat = GAT_CONFIG(1, GAT_GND);
outb(zgat, devpriv->iobase1 + PCI230_ZGAT_SCE);
pci230_ct_setup_ns_mode(dev, 1, I8254_MODE3,
- cmd->scan_begin_arg,
- cmd->flags & TRIG_ROUND_MASK);
+ cmd->scan_begin_arg,
+ cmd->
+ flags &
+ TRIG_ROUND_MASK);
}
}
}
@@ -2485,7 +2512,7 @@ static int pci230_ai_cmd(struct comedi_device *dev, struct comedi_subdevice *s)
}
static unsigned int divide_ns(uint64_t ns, unsigned int timebase,
- unsigned int round_mode)
+ unsigned int round_mode)
{
uint64_t div;
unsigned int rem;
@@ -2510,7 +2537,7 @@ static unsigned int divide_ns(uint64_t ns, unsigned int timebase,
/* Given desired period in ns, returns the required internal clock source
* and gets the initial count. */
static unsigned int pci230_choose_clk_count(uint64_t ns, unsigned int *count,
- unsigned int round_mode)
+ unsigned int round_mode)
{
unsigned int clk_src, cnt;
@@ -2535,7 +2562,8 @@ static void pci230_ns_to_single_timer(unsigned int *ns, unsigned int round)
}
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 mode, uint64_t ns,
+ unsigned int round)
{
unsigned int clk_src;
unsigned int count;
@@ -2556,7 +2584,7 @@ static void pci230_ct_setup_ns_mode(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);
+ I8254_MODE1);
/* Counter ct, 8254 mode 1, initial count not written. */
}
@@ -2564,7 +2592,7 @@ static void pci230_cancel_ct(struct comedi_device *dev, unsigned int ct)
static irqreturn_t pci230_interrupt(int irq, void *d)
{
unsigned char status_int, valid_status_int;
- struct comedi_device *dev = (struct comedi_device *) d;
+ struct comedi_device *dev = (struct comedi_device *)d;
struct comedi_subdevice *s;
unsigned long irqflags;
@@ -2624,7 +2652,8 @@ static irqreturn_t pci230_interrupt(int irq, void *d)
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;
@@ -2661,7 +2690,8 @@ static void pci230_handle_ao_nofifo(struct comedi_device *dev, struct comedi_sub
/* 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;
@@ -2699,7 +2729,7 @@ static int pci230_handle_ao_fifo(struct comedi_device *dev, struct comedi_subdev
* (otherwise there will be loads of "DAC FIFO not half full"
* interrupts). */
if ((num_scans == 0)
- && ((dacstat & PCI230P2_DAC_FIFO_HALF) == 0)) {
+ && ((dacstat & PCI230P2_DAC_FIFO_HALF) == 0)) {
comedi_error(dev, "AO buffer underrun");
events |= COMEDI_CB_OVERFLOW | COMEDI_CB_ERROR;
}
@@ -2728,7 +2758,7 @@ static int pci230_handle_ao_fifo(struct comedi_device *dev, struct comedi_subdev
comedi_buf_get(async, &datum);
pci230_ao_write_fifo(dev, datum,
- CR_CHAN(cmd->chanlist[i]));
+ CR_CHAN(cmd->chanlist[i]));
}
}
events |= COMEDI_CB_EOS | COMEDI_CB_BLOCK;
@@ -2739,10 +2769,11 @@ static int pci230_handle_ao_fifo(struct comedi_device *dev, struct comedi_subdev
* to FIFO. Set FIFO interrupt trigger level
* to 'empty'. */
devpriv->daccon = (devpriv->daccon
- & ~PCI230P2_DAC_INT_FIFO_MASK)
- | PCI230P2_DAC_INT_FIFO_EMPTY;
+ &
+ ~PCI230P2_DAC_INT_FIFO_MASK)
+ | PCI230P2_DAC_INT_FIFO_EMPTY;
outw(devpriv->daccon,
- dev->iobase + PCI230_DACCON);
+ dev->iobase + PCI230_DACCON);
}
}
/* Check if FIFO underrun occurred while writing to FIFO. */
@@ -2753,7 +2784,7 @@ static int pci230_handle_ao_fifo(struct comedi_device *dev, struct comedi_subdev
}
}
if ((events & (COMEDI_CB_EOA | COMEDI_CB_ERROR | COMEDI_CB_OVERFLOW))
- != 0) {
+ != 0) {
/* Stopping AO due to completion or error. */
pci230_ao_stop(dev, s);
running = 0;
@@ -2764,7 +2795,8 @@ static int pci230_handle_ao_fifo(struct comedi_device *dev, struct comedi_subdev
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;
@@ -2780,11 +2812,11 @@ static void pci230_handle_ai(struct comedi_device *dev, struct comedi_subdevice
} else if (devpriv->ai_scan_count == 0) {
todo = 0;
} else if ((devpriv->ai_scan_count > PCI230_ADC_FIFOLEVEL_HALFFULL)
- || (scanlen > PCI230_ADC_FIFOLEVEL_HALFFULL)) {
+ || (scanlen > PCI230_ADC_FIFOLEVEL_HALFFULL)) {
todo = PCI230_ADC_FIFOLEVEL_HALFFULL;
} else {
todo = (devpriv->ai_scan_count * scanlen)
- - devpriv->ai_scan_pos;
+ - devpriv->ai_scan_pos;
if (todo > PCI230_ADC_FIFOLEVEL_HALFFULL) {
todo = PCI230_ADC_FIFOLEVEL_HALFFULL;
}
@@ -2817,7 +2849,7 @@ static void pci230_handle_ai(struct comedi_device *dev, struct comedi_subdevice
if (devpriv->hwver > 0) {
/* Read PCI230+/260+ ADC FIFO level. */
fifoamount = inw(dev->iobase
- + PCI230P_ADCFFLEV);
+ + PCI230P_ADCFFLEV);
if (fifoamount == 0) {
/* Shouldn't happen. */
break;
@@ -2854,7 +2886,7 @@ static void pci230_handle_ai(struct comedi_device *dev, struct comedi_subdevice
async->events |= events;
if ((async->events & (COMEDI_CB_EOA | COMEDI_CB_ERROR |
- COMEDI_CB_OVERFLOW)) != 0) {
+ COMEDI_CB_OVERFLOW)) != 0) {
/* disable hardware conversions */
pci230_ai_stop(dev, s);
} else {
@@ -2863,7 +2895,8 @@ 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;
@@ -2910,21 +2943,23 @@ static void pci230_ao_stop(struct comedi_device *dev, struct comedi_subdevice *s
* disable FIFO. */
devpriv->daccon &= PCI230_DAC_OR_MASK;
outw(devpriv->daccon | PCI230P2_DAC_FIFO_RESET
- | PCI230P2_DAC_FIFO_UNDERRUN_CLEAR,
- dev->iobase + PCI230_DACCON);
+ | PCI230P2_DAC_FIFO_UNDERRUN_CLEAR,
+ dev->iobase + PCI230_DACCON);
}
/* Release resources. */
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;
@@ -2964,15 +2999,17 @@ static void pci230_ai_stop(struct comedi_device *dev, struct comedi_subdevice *s
/* Reset FIFO, disable FIFO and set start conversion source to none.
* Keep se/diff and bip/uni settings */
devpriv->adccon = (devpriv->adccon & (PCI230_ADC_IR_MASK
- | PCI230_ADC_IM_MASK)) | PCI230_ADC_TRIG_NONE;
+ | PCI230_ADC_IM_MASK)) |
+ PCI230_ADC_TRIG_NONE;
outw(devpriv->adccon | PCI230_ADC_FIFO_RESET,
- dev->iobase + PCI230_ADCCON);
+ dev->iobase + PCI230_ADCCON);
/* Release resources. */
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 b204793040e2..abb0532182ba 100644
--- a/drivers/staging/comedi/drivers/c6xdigio.c
+++ b/drivers/staging/comedi/drivers/c6xdigio.c
@@ -97,7 +97,8 @@ union encvaluetype {
#define C6XDIGIO_TIME_OUT 20
-static int c6xdigio_attach(struct comedi_device *dev, struct comedi_devconfig *it);
+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",
@@ -114,28 +115,28 @@ static void C6X_pwmInit(unsigned long baseAddr)
WriteByteToHwPort(baseAddr, 0x70);
while (((ReadByteFromHwPort(baseAddr + 1) & 0x80) == 0)
- && (timeout < C6XDIGIO_TIME_OUT)) {
+ && (timeout < C6XDIGIO_TIME_OUT)) {
timeout++;
}
WriteByteToHwPort(baseAddr, 0x74);
timeout = 0;
while (((ReadByteFromHwPort(baseAddr + 1) & 0x80) == 0x80)
- && (timeout < C6XDIGIO_TIME_OUT)) {
+ && (timeout < C6XDIGIO_TIME_OUT)) {
timeout++;
}
WriteByteToHwPort(baseAddr, 0x70);
timeout = 0;
while (((ReadByteFromHwPort(baseAddr + 1) & 0x80) == 0x0)
- && (timeout < C6XDIGIO_TIME_OUT)) {
+ && (timeout < C6XDIGIO_TIME_OUT)) {
timeout++;
}
WriteByteToHwPort(baseAddr, 0x0);
timeout = 0;
while (((ReadByteFromHwPort(baseAddr + 1) & 0x80) == 0x80)
- && (timeout < C6XDIGIO_TIME_OUT)) {
+ && (timeout < C6XDIGIO_TIME_OUT)) {
timeout++;
}
@@ -315,38 +316,41 @@ static void C6X_encResetAll(unsigned long baseAddr)
WriteByteToHwPort(baseAddr, 0x68);
while (((ReadByteFromHwPort(baseAddr + 1) & 0x80) == 0)
- && (timeout < C6XDIGIO_TIME_OUT)) {
+ && (timeout < C6XDIGIO_TIME_OUT)) {
timeout++;
}
WriteByteToHwPort(baseAddr, 0x6C);
timeout = 0;
while (((ReadByteFromHwPort(baseAddr + 1) & 0x80) == 0x80)
- && (timeout < C6XDIGIO_TIME_OUT)) {
+ && (timeout < C6XDIGIO_TIME_OUT)) {
timeout++;
}
WriteByteToHwPort(baseAddr, 0x68);
timeout = 0;
while (((ReadByteFromHwPort(baseAddr + 1) & 0x80) == 0x0)
- && (timeout < C6XDIGIO_TIME_OUT)) {
+ && (timeout < C6XDIGIO_TIME_OUT)) {
timeout++;
}
WriteByteToHwPort(baseAddr, 0x0);
timeout = 0;
while (((ReadByteFromHwPort(baseAddr + 1) & 0x80) == 0x80)
- && (timeout < C6XDIGIO_TIME_OUT)) {
+ && (timeout < C6XDIGIO_TIME_OUT)) {
timeout++;
}
}
static int c6xdigio_pwmo_insn_read(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)
{
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)
+ struct comedi_subdevice *s,
+ struct comedi_insn *insn,
+ unsigned int *data)
{
int i;
int chan = CR_CHAN(insn->chanspec);
@@ -375,12 +379,13 @@ static int c6xdigio_pwmo_insn_write(struct comedi_device *dev,
/* { */
/* int i; */
/* int chan = CR_CHAN(insn->chanspec); */
-/* *//* C6X_encResetAll( dev->iobase ); */
-/* *//* return insn->n; */
+ /* *//* 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)
+ struct comedi_subdevice *s,
+ struct comedi_insn *insn, unsigned int *data)
{
/* printk("c6xdigio_ei__insn_read %x\n", insn->n); */
int n;
@@ -415,9 +420,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},
{}
};
@@ -426,7 +431,8 @@ 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;
@@ -478,7 +484,7 @@ static int c6xdigio_attach(struct comedi_device *dev, struct comedi_devconfig *i
s->range_table = &range_unknown;
/* s = dev->subdevices + 2; */
- /* pwm output subdevice */
+ /* pwm output subdevice */
/* s->type = COMEDI_SUBD_COUNTER; // Not sure what to put here */
/* s->subdev_flags = SDF_WRITEABLE; */
/* s->n_chan = 1; */
diff --git a/drivers/staging/comedi/drivers/cb_das16_cs.c b/drivers/staging/comedi/drivers/cb_das16_cs.c
index 7af245b42e51..2f7aa3b5ef8e 100644
--- a/drivers/staging/comedi/drivers/cb_das16_cs.c
+++ b/drivers/staging/comedi/drivers/cb_das16_cs.c
@@ -62,20 +62,20 @@ 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,
+ },
};
#define n_boards (sizeof(das16cs_boards)/sizeof(das16cs_boards[0]))
@@ -90,7 +90,8 @@ 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_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",
@@ -102,31 +103,43 @@ static struct comedi_driver driver_das16cs = {
static struct pcmcia_device *cur_dev = NULL;
static const struct comedi_lrange das16cs_ai_range = { 4, {
- RANGE(-10, 10),
- RANGE(-5, 5),
- RANGE(-2.5, 2.5),
- RANGE(-1.25, 1.25),
- }
+ RANGE(-10, 10),
+ RANGE(-5, 5),
+ RANGE(-2.5, 2.5),
+ RANGE(-1.25, 1.25),
+ }
};
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 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)
{
@@ -140,15 +153,15 @@ static int get_prodid(struct comedi_device *dev, struct pcmcia_device *link)
tuple.DesiredTuple = CISTPL_MANFID;
tuple.Attributes = TUPLE_RETURN_COMMON;
if ((pcmcia_get_first_tuple(link, &tuple) == 0) &&
- (pcmcia_get_tuple_data(link, &tuple) == 0)) {
+ (pcmcia_get_tuple_data(link, &tuple) == 0)) {
prodid = le16_to_cpu(buf[1]);
}
return prodid;
}
-static const struct das16cs_board *das16cs_probe(struct comedi_device * dev,
- struct pcmcia_device *link)
+static const struct das16cs_board *das16cs_probe(struct comedi_device *dev,
+ struct pcmcia_device *link)
{
int id;
int i;
@@ -166,7 +179,8 @@ 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;
@@ -287,8 +301,9 @@ static irqreturn_t das16cs_interrupt(int irq, void *d)
* "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;
@@ -334,8 +349,9 @@ 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;
@@ -381,7 +397,7 @@ static int das16cs_ai_cmdtest(struct comedi_device *dev, struct comedi_subdevice
/* note that mutual compatiblity is not an issue here */
if (cmd->scan_begin_src != TRIG_TIMER &&
- cmd->scan_begin_src != TRIG_EXT)
+ cmd->scan_begin_src != TRIG_EXT)
err++;
if (cmd->convert_src != TRIG_TIMER && cmd->convert_src != TRIG_EXT)
err++;
@@ -463,7 +479,8 @@ static int das16cs_ai_cmdtest(struct comedi_device *dev, struct comedi_subdevice
tmp = cmd->scan_begin_arg;
i8253_cascade_ns_to_timer(100, &div1, &div2,
- &cmd->scan_begin_arg, cmd->flags & TRIG_ROUND_MASK);
+ &cmd->scan_begin_arg,
+ cmd->flags & TRIG_ROUND_MASK);
if (tmp != cmd->scan_begin_arg)
err++;
}
@@ -472,14 +489,15 @@ static int das16cs_ai_cmdtest(struct comedi_device *dev, struct comedi_subdevice
tmp = cmd->convert_arg;
i8253_cascade_ns_to_timer(100, &div1, &div2,
- &cmd->scan_begin_arg, cmd->flags & TRIG_ROUND_MASK);
+ &cmd->scan_begin_arg,
+ cmd->flags & TRIG_ROUND_MASK);
if (tmp != cmd->convert_arg)
err++;
if (cmd->scan_begin_src == TRIG_TIMER &&
- cmd->scan_begin_arg <
- cmd->convert_arg * cmd->scan_end_arg) {
+ cmd->scan_begin_arg <
+ cmd->convert_arg * cmd->scan_end_arg) {
cmd->scan_begin_arg =
- cmd->convert_arg * cmd->scan_end_arg;
+ cmd->convert_arg * cmd->scan_end_arg;
err++;
}
}
@@ -490,8 +508,9 @@ static int das16cs_ai_cmdtest(struct comedi_device *dev, struct comedi_subdevice
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);
@@ -536,8 +555,9 @@ 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);
@@ -553,8 +573,9 @@ 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;
@@ -573,8 +594,9 @@ static int das16cs_dio_insn_bits(struct comedi_device *dev, struct comedi_subdev
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;
@@ -593,8 +615,7 @@ static int das16cs_dio_insn_config(struct comedi_device *dev, struct comedi_subd
break;
case INSN_CONFIG_DIO_QUERY:
data[1] =
- (s->
- io_bits & (1 << chan)) ? COMEDI_OUTPUT : COMEDI_INPUT;
+ (s->io_bits & (1 << chan)) ? COMEDI_OUTPUT : COMEDI_INPUT;
return insn->n;
break;
default:
@@ -611,14 +632,17 @@ static int das16cs_dio_insn_config(struct comedi_device *dev, struct comedi_subd
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;
}
@@ -650,7 +674,7 @@ static int pc_debug = PCMCIA_DEBUG;
module_param(pc_debug, int, 0644);
#define DEBUG(n, args...) if (pc_debug>(n)) printk(KERN_DEBUG args)
static char *version =
- "cb_das16_cs.c pcmcia code (David Schleef), modified from dummy_cs.c 1.31 2001/08/24 12:13:13 (David Hinds)";
+ "cb_das16_cs.c pcmcia code (David Schleef), modified from dummy_cs.c 1.31 2001/08/24 12:13:13 (David Hinds)";
#else
#define DEBUG(n, args...)
#endif
@@ -739,7 +763,7 @@ static void das16cs_pcmcia_detach(struct pcmcia_device *link)
DEBUG(0, "das16cs_pcmcia_detach(0x%p)\n", link);
if (link->dev_node) {
- ((struct local_info_t *) link->priv)->stop = 1;
+ ((struct local_info_t *)link->priv)->stop = 1;
das16cs_pcmcia_release(link);
}
/* This points to the parent struct local_info_t struct */
@@ -853,7 +877,7 @@ static void das16cs_pcmcia_config(struct pcmcia_device *link)
/* If we got this far, we're cool! */
break;
- next_entry:
+next_entry:
last_fn = GetNextTuple;
last_ret = pcmcia_get_next_tuple(link, &tuple);
@@ -893,20 +917,20 @@ static void das16cs_pcmcia_config(struct pcmcia_device *link)
/* Finally, report what we've done */
printk(KERN_INFO "%s: index 0x%02x",
- dev->node.dev_name, link->conf.ConfigIndex);
+ dev->node.dev_name, link->conf.ConfigIndex);
if (link->conf.Attributes & CONF_ENABLE_IRQ)
printk(", irq %u", link->irq.AssignedIRQ);
if (link->io.NumPorts1)
printk(", io 0x%04x-0x%04x", link->io.BasePort1,
- link->io.BasePort1 + link->io.NumPorts1 - 1);
+ link->io.BasePort1 + link->io.NumPorts1 - 1);
if (link->io.NumPorts2)
printk(" & 0x%04x-0x%04x", link->io.BasePort2,
- link->io.BasePort2 + link->io.NumPorts2 - 1);
+ link->io.BasePort2 + link->io.NumPorts2 - 1);
printk("\n");
return;
- cs_failed:
+cs_failed:
cs_error(link, last_fn, last_ret);
das16cs_pcmcia_release(link);
} /* das16cs_pcmcia_config */
@@ -953,7 +977,7 @@ struct pcmcia_driver das16cs_driver = {
.id_table = das16cs_id_table,
.owner = THIS_MODULE,
.drv = {
- .name = dev_info,
+ .name = dev_info,
},
};
diff --git a/drivers/staging/comedi/drivers/cb_pcidas.c b/drivers/staging/comedi/drivers/cb_pcidas.c
index 702de1571223..f3e66c440a38 100644
--- a/drivers/staging/comedi/drivers/cb_pcidas.c
+++ b/drivers/staging/comedi/drivers/cb_pcidas.c
@@ -156,6 +156,7 @@ static inline unsigned int DAC_RANGE(unsigned int channel, unsigned int range)
{
return (range & 0x3) << (8 + 2 * (channel & 0x1));
}
+
static inline unsigned int DAC_RANGE_MASK(unsigned int channel)
{
return 0x3 << (8 + 2 * (channel & 0x1));
@@ -200,41 +201,41 @@ static inline unsigned int DAC_DATA_REG(unsigned int channel)
static const struct comedi_lrange cb_pcidas_ranges = {
8,
{
- BIP_RANGE(10),
- BIP_RANGE(5),
- BIP_RANGE(2.5),
- BIP_RANGE(1.25),
- UNI_RANGE(10),
- UNI_RANGE(5),
- UNI_RANGE(2.5),
- UNI_RANGE(1.25)
- }
+ BIP_RANGE(10),
+ BIP_RANGE(5),
+ BIP_RANGE(2.5),
+ BIP_RANGE(1.25),
+ UNI_RANGE(10),
+ UNI_RANGE(5),
+ UNI_RANGE(2.5),
+ UNI_RANGE(1.25)
+ }
};
/* pci-das1001 input ranges */
static const struct comedi_lrange cb_pcidas_alt_ranges = {
8,
{
- BIP_RANGE(10),
- BIP_RANGE(1),
- BIP_RANGE(0.1),
- BIP_RANGE(0.01),
- UNI_RANGE(10),
- UNI_RANGE(1),
- UNI_RANGE(0.1),
- UNI_RANGE(0.01)
- }
+ BIP_RANGE(10),
+ BIP_RANGE(1),
+ BIP_RANGE(0.1),
+ BIP_RANGE(0.01),
+ UNI_RANGE(10),
+ UNI_RANGE(1),
+ UNI_RANGE(0.1),
+ UNI_RANGE(0.01)
+ }
};
/* analog output ranges */
static const struct comedi_lrange cb_pcidas_ao_ranges = {
4,
{
- BIP_RANGE(5),
- BIP_RANGE(10),
- UNI_RANGE(5),
- UNI_RANGE(10),
- }
+ BIP_RANGE(5),
+ BIP_RANGE(10),
+ UNI_RANGE(5),
+ UNI_RANGE(10),
+ }
};
enum trimpot_model {
@@ -260,131 +261,132 @@ 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,
+ },
};
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},
- {PCI_VENDOR_ID_CB, 0x0010, PCI_ANY_ID, PCI_ANY_ID, 0, 0, 0},
- {PCI_VENDOR_ID_CB, 0x0019, PCI_ANY_ID, PCI_ANY_ID, 0, 0, 0},
- {PCI_VENDOR_ID_CB, 0x001c, PCI_ANY_ID, PCI_ANY_ID, 0, 0, 0},
- {PCI_VENDOR_ID_CB, 0x004c, PCI_ANY_ID, PCI_ANY_ID, 0, 0, 0},
- {PCI_VENDOR_ID_CB, 0x001a, PCI_ANY_ID, PCI_ANY_ID, 0, 0, 0},
- {PCI_VENDOR_ID_CB, 0x001b, PCI_ANY_ID, PCI_ANY_ID, 0, 0, 0},
- {0}
+ {
+ 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}, {
+ PCI_VENDOR_ID_CB, 0x0010, PCI_ANY_ID, PCI_ANY_ID, 0, 0, 0}, {
+ PCI_VENDOR_ID_CB, 0x0019, PCI_ANY_ID, PCI_ANY_ID, 0, 0, 0}, {
+ PCI_VENDOR_ID_CB, 0x001c, PCI_ANY_ID, PCI_ANY_ID, 0, 0, 0}, {
+ PCI_VENDOR_ID_CB, 0x004c, PCI_ANY_ID, PCI_ANY_ID, 0, 0, 0}, {
+ PCI_VENDOR_ID_CB, 0x001a, PCI_ANY_ID, PCI_ANY_ID, 0, 0, 0}, {
+ PCI_VENDOR_ID_CB, 0x001b, PCI_ANY_ID, PCI_ANY_ID, 0, 0, 0}, {
+ 0}
};
MODULE_DEVICE_TABLE(pci, cb_pcidas_pci_table);
@@ -438,7 +440,8 @@ 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_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",
@@ -447,55 +450,75 @@ static struct comedi_driver driver_cb_pcidas = {
.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 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 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 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 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,
- 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);
+ 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, 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 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);
+ 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,
- uint8_t value);
+ uint8_t value);
static int nvram_read(struct comedi_device *dev, unsigned int address,
- uint8_t *data);
+ uint8_t * data);
static inline unsigned int cal_enable_bits(struct comedi_device *dev)
{
@@ -506,7 +529,8 @@ 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;
@@ -527,8 +551,8 @@ static int cb_pcidas_attach(struct comedi_device *dev, struct comedi_devconfig *
printk("\n");
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)) {
+ pcidev != NULL;
+ pcidev = pci_get_device(PCI_ANY_ID, PCI_ANY_ID, pcidev)) {
/* is it not a computer boards card? */
if (pcidev->vendor != PCI_VENDOR_ID_CB)
continue;
@@ -540,8 +564,7 @@ static int cb_pcidas_attach(struct comedi_device *dev, struct comedi_devconfig *
if (it->options[0] || it->options[1]) {
/* are we on the wrong bus/slot? */
if (pcidev->bus->number != it->options[0] ||
- PCI_SLOT(pcidev->devfn) !=
- it->options[1]) {
+ PCI_SLOT(pcidev->devfn) != it->options[1]) {
continue;
}
}
@@ -552,13 +575,13 @@ static int cb_pcidas_attach(struct comedi_device *dev, struct comedi_devconfig *
}
printk("No supported ComputerBoards/MeasurementComputing card found on "
- "requested position\n");
+ "requested position\n");
return -EIO;
- found:
+found:
printk("Found %s on bus %i, slot %i\n", cb_pcidas_boards[index].name,
- pcidev->bus->number, PCI_SLOT(pcidev->devfn));
+ pcidev->bus->number, PCI_SLOT(pcidev->devfn));
/*
* Enable PCI device and reserve I/O ports.
@@ -572,20 +595,20 @@ static int cb_pcidas_attach(struct comedi_device *dev, struct comedi_devconfig *
* their base address.
*/
devpriv->s5933_config =
- pci_resource_start(devpriv->pci_dev, S5933_BADRINDEX);
+ pci_resource_start(devpriv->pci_dev, S5933_BADRINDEX);
devpriv->control_status =
- pci_resource_start(devpriv->pci_dev, CONT_STAT_BADRINDEX);
+ pci_resource_start(devpriv->pci_dev, CONT_STAT_BADRINDEX);
devpriv->adc_fifo =
- pci_resource_start(devpriv->pci_dev, ADC_FIFO_BADRINDEX);
+ pci_resource_start(devpriv->pci_dev, ADC_FIFO_BADRINDEX);
devpriv->pacer_counter_dio =
- pci_resource_start(devpriv->pci_dev, PACER_BADRINDEX);
+ pci_resource_start(devpriv->pci_dev, PACER_BADRINDEX);
if (thisboard->ao_nchan) {
devpriv->ao_registers =
- pci_resource_start(devpriv->pci_dev, AO_BADRINDEX);
+ pci_resource_start(devpriv->pci_dev, AO_BADRINDEX);
}
/* disable and clear interrupts on amcc s5933 */
outl(INTCSR_INBOX_INTR_STATUS,
- devpriv->s5933_config + AMCC_OP_REG_INTCSR);
+ devpriv->s5933_config + AMCC_OP_REG_INTCSR);
/* get irq */
if (request_irq(devpriv->pci_dev->irq, cb_pcidas_interrupt,
@@ -700,11 +723,11 @@ static int cb_pcidas_attach(struct comedi_device *dev, struct comedi_devconfig *
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;
+ INTCSR_INBOX_BYTE(3) | INTCSR_INBOX_SELECT(3) |
+ INTCSR_INBOX_FULL_INT;
/* clear and enable interrupt on amcc s5933 */
outl(devpriv->s5933_intcsr_bits | INTCSR_INBOX_INTR_STATUS,
- devpriv->s5933_config + AMCC_OP_REG_INTCSR);
+ devpriv->s5933_config + AMCC_OP_REG_INTCSR);
return 1;
}
@@ -725,11 +748,10 @@ static int cb_pcidas_detach(struct comedi_device *dev)
if (devpriv->s5933_config) {
/* disable and clear interrupts on amcc s5933 */
outl(INTCSR_INBOX_INTR_STATUS,
- devpriv->s5933_config + AMCC_OP_REG_INTCSR);
+ devpriv->s5933_config + AMCC_OP_REG_INTCSR);
#ifdef CB_PCIDAS_DEBUG
printk("detaching, incsr is 0x%x\n",
- inl(devpriv->s5933_config +
- AMCC_OP_REG_INTCSR));
+ inl(devpriv->s5933_config + AMCC_OP_REG_INTCSR));
#endif
}
}
@@ -751,8 +773,9 @@ 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;
@@ -761,7 +784,7 @@ static int cb_pcidas_ai_rinsn(struct comedi_device *dev, struct comedi_subdevice
/* enable calibration input if appropriate */
if (insn->chanspec & CR_ALT_SOURCE) {
outw(cal_enable_bits(dev),
- devpriv->control_status + CALIBRATION_REG);
+ devpriv->control_status + CALIBRATION_REG);
channel = 0;
} else {
outw(0, devpriv->control_status + CALIBRATION_REG);
@@ -769,7 +792,7 @@ static int cb_pcidas_ai_rinsn(struct comedi_device *dev, struct comedi_subdevice
}
/* set mux limits and gain */
bits = BEGIN_SCAN(channel) |
- END_SCAN(channel) | GAIN_BITS(CR_RANGE(insn->chanspec));
+ END_SCAN(channel) | GAIN_BITS(CR_RANGE(insn->chanspec));
/* set unipolar/bipolar */
if (CR_RANGE(insn->chanspec) & IS_UNIPOLAR)
bits |= UNIP;
@@ -803,7 +826,8 @@ static int cb_pcidas_ai_rinsn(struct comedi_device *dev, struct comedi_subdevice
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];
@@ -819,7 +843,7 @@ static int ai_config_calibration_source(struct comedi_device *dev, unsigned int
}
static int ai_config_insn(struct comedi_device *dev, struct comedi_subdevice *s,
- struct comedi_insn *insn, unsigned int *data)
+ struct comedi_insn *insn, unsigned int *data)
{
int id = data[0];
@@ -835,8 +859,10 @@ static int ai_config_insn(struct comedi_device *dev, struct comedi_subdevice *s,
}
/* 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)
+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;
@@ -845,9 +871,9 @@ static int cb_pcidas_ao_nofifo_winsn(struct comedi_device *dev, struct comedi_su
channel = CR_CHAN(insn->chanspec);
spin_lock_irqsave(&dev->spinlock, flags);
devpriv->ao_control_bits &=
- ~DAC_MODE_UPDATE_BOTH & ~DAC_RANGE_MASK(channel);
+ ~DAC_MODE_UPDATE_BOTH & ~DAC_RANGE_MASK(channel);
devpriv->ao_control_bits |=
- DACEN | DAC_RANGE(channel, CR_RANGE(insn->chanspec));
+ DACEN | DAC_RANGE(channel, CR_RANGE(insn->chanspec));
outw(devpriv->ao_control_bits, devpriv->control_status + DAC_CSR);
spin_unlock_irqrestore(&dev->spinlock, flags);
@@ -860,8 +886,9 @@ static int cb_pcidas_ao_nofifo_winsn(struct comedi_device *dev, struct comedi_su
}
/* 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)
+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;
@@ -873,11 +900,13 @@ static int cb_pcidas_ao_fifo_winsn(struct comedi_device *dev, struct comedi_subd
channel = CR_CHAN(insn->chanspec);
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;
+ ~DAC_CHAN_EN(0) & ~DAC_CHAN_EN(1) & ~DAC_RANGE_MASK(channel) &
+ ~DAC_PACER_MASK;
devpriv->ao_control_bits |=
- DACEN | DAC_RANGE(channel,
- CR_RANGE(insn->chanspec)) | DAC_CHAN_EN(channel) | DAC_START;
+ DACEN | DAC_RANGE(channel,
+ CR_RANGE(insn->
+ chanspec)) | DAC_CHAN_EN(channel) |
+ DAC_START;
outw(devpriv->ao_control_bits, devpriv->control_status + DAC_CSR);
spin_unlock_irqrestore(&dev->spinlock, flags);
@@ -891,16 +920,19 @@ static int cb_pcidas_ao_fifo_winsn(struct comedi_device *dev, struct comedi_subd
/* 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)
+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;
@@ -914,16 +946,18 @@ 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)];
@@ -939,26 +973,28 @@ static int dac08_write(struct comedi_device *dev, unsigned int value)
devpriv->dac08_value = value;
outw(cal_enable_bits(dev) | (value & 0xff),
- devpriv->control_status + CALIBRATION_REG);
+ devpriv->control_status + CALIBRATION_REG);
udelay(1);
outw(cal_enable_bits(dev) | SELECT_DAC08_BIT | (value & 0xff),
- devpriv->control_status + CALIBRATION_REG);
+ devpriv->control_status + CALIBRATION_REG);
udelay(1);
outw(cal_enable_bits(dev) | (value & 0xff),
- devpriv->control_status + CALIBRATION_REG);
+ devpriv->control_status + CALIBRATION_REG);
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;
@@ -966,7 +1002,7 @@ static int dac08_read_insn(struct comedi_device *dev, struct comedi_subdevice *s
}
static int cb_pcidas_trimpot_write(struct comedi_device *dev,
- unsigned int channel, unsigned int value)
+ unsigned int channel, unsigned int value)
{
if (devpriv->trimpot_value[channel] == value)
return 1;
@@ -988,16 +1024,18 @@ 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);
@@ -1006,8 +1044,9 @@ 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;
@@ -1055,11 +1094,11 @@ static int cb_pcidas_ai_cmdtest(struct comedi_device *dev, struct comedi_subdevi
if (cmd->start_src != TRIG_NOW && cmd->start_src != TRIG_EXT)
err++;
if (cmd->scan_begin_src != TRIG_FOLLOW &&
- cmd->scan_begin_src != TRIG_TIMER &&
- cmd->scan_begin_src != TRIG_EXT)
+ cmd->scan_begin_src != TRIG_TIMER &&
+ cmd->scan_begin_src != TRIG_EXT)
err++;
if (cmd->convert_src != TRIG_TIMER &&
- cmd->convert_src != TRIG_EXT && cmd->convert_src != TRIG_NOW)
+ cmd->convert_src != TRIG_EXT && cmd->convert_src != TRIG_NOW)
err++;
if (cmd->stop_src != TRIG_COUNT && cmd->stop_src != TRIG_NONE)
err++;
@@ -1070,8 +1109,7 @@ static int cb_pcidas_ai_cmdtest(struct comedi_device *dev, struct comedi_subdevi
if (cmd->scan_begin_src != TRIG_FOLLOW && cmd->convert_src != TRIG_NOW)
err++;
if (cmd->start_src == TRIG_EXT &&
- (cmd->convert_src == TRIG_EXT
- || cmd->scan_begin_src == TRIG_EXT))
+ (cmd->convert_src == TRIG_EXT || cmd->scan_begin_src == TRIG_EXT))
err++;
if (err)
@@ -1086,9 +1124,9 @@ static int cb_pcidas_ai_cmdtest(struct comedi_device *dev, struct comedi_subdevi
if (cmd->scan_begin_src == TRIG_TIMER) {
if (cmd->scan_begin_arg <
- thisboard->ai_speed * cmd->chanlist_len) {
+ thisboard->ai_speed * cmd->chanlist_len) {
cmd->scan_begin_arg =
- thisboard->ai_speed * cmd->chanlist_len;
+ thisboard->ai_speed * cmd->chanlist_len;
err++;
}
}
@@ -1119,16 +1157,20 @@ static int cb_pcidas_ai_cmdtest(struct comedi_device *dev, struct comedi_subdevi
if (cmd->scan_begin_src == TRIG_TIMER) {
tmp = cmd->scan_begin_arg;
i8253_cascade_ns_to_timer_2div(TIMER_BASE,
- &(devpriv->divisor1), &(devpriv->divisor2),
- &(cmd->scan_begin_arg), cmd->flags & TRIG_ROUND_MASK);
+ &(devpriv->divisor1),
+ &(devpriv->divisor2),
+ &(cmd->scan_begin_arg),
+ cmd->flags & TRIG_ROUND_MASK);
if (tmp != cmd->scan_begin_arg)
err++;
}
if (cmd->convert_src == TRIG_TIMER) {
tmp = cmd->convert_arg;
i8253_cascade_ns_to_timer_2div(TIMER_BASE,
- &(devpriv->divisor1), &(devpriv->divisor2),
- &(cmd->convert_arg), cmd->flags & TRIG_ROUND_MASK);
+ &(devpriv->divisor1),
+ &(devpriv->divisor2),
+ &(cmd->convert_arg),
+ cmd->flags & TRIG_ROUND_MASK);
if (tmp != cmd->convert_arg)
err++;
}
@@ -1142,14 +1184,14 @@ static int cb_pcidas_ai_cmdtest(struct comedi_device *dev, struct comedi_subdevi
start_chan = CR_CHAN(cmd->chanlist[0]);
for (i = 1; i < cmd->chanlist_len; i++) {
if (CR_CHAN(cmd->chanlist[i]) !=
- (start_chan + i) % s->n_chan) {
+ (start_chan + i) % s->n_chan) {
comedi_error(dev,
- "entries in chanlist must be consecutive channels, counting upwards\n");
+ "entries in chanlist must be consecutive channels, counting upwards\n");
err++;
}
if (CR_RANGE(cmd->chanlist[i]) != gain) {
comedi_error(dev,
- "entries in chanlist must all have the same gain\n");
+ "entries in chanlist must all have the same gain\n");
err++;
}
}
@@ -1161,7 +1203,8 @@ static int cb_pcidas_ai_cmdtest(struct comedi_device *dev, struct comedi_subdevi
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;
@@ -1177,8 +1220,8 @@ static int cb_pcidas_ai_cmd(struct comedi_device *dev, struct comedi_subdevice *
/* 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]));
+ END_SCAN(CR_CHAN(cmd->chanlist[cmd->chanlist_len - 1])) |
+ GAIN_BITS(CR_RANGE(cmd->chanlist[0]));
/* set unipolar/bipolar */
if (CR_RANGE(cmd->chanlist[0]) & IS_UNIPOLAR)
bits |= UNIP;
@@ -1199,10 +1242,10 @@ static int cb_pcidas_ai_cmd(struct comedi_device *dev, struct comedi_subdevice *
/* load counters */
if (cmd->convert_src == TRIG_TIMER)
cb_pcidas_load_counters(dev, &cmd->convert_arg,
- cmd->flags & TRIG_ROUND_MASK);
+ cmd->flags & TRIG_ROUND_MASK);
else if (cmd->scan_begin_src == TRIG_TIMER)
cb_pcidas_load_counters(dev, &cmd->scan_begin_arg,
- cmd->flags & TRIG_ROUND_MASK);
+ cmd->flags & TRIG_ROUND_MASK);
/* set number of conversions */
if (cmd->stop_src == TRIG_COUNT) {
@@ -1225,7 +1268,7 @@ static int cb_pcidas_ai_cmd(struct comedi_device *dev, struct comedi_subdevice *
#endif
/* enable (and clear) interrupts */
outw(devpriv->adc_fifo_bits | EOAI | INT | LADFUL,
- devpriv->control_status + INT_ADCFIFO);
+ devpriv->control_status + INT_ADCFIFO);
spin_unlock_irqrestore(&dev->spinlock, flags);
/* set start trigger and burst mode */
@@ -1248,8 +1291,9 @@ static int cb_pcidas_ai_cmd(struct comedi_device *dev, struct comedi_subdevice *
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;
@@ -1294,7 +1338,7 @@ static int cb_pcidas_ao_cmdtest(struct comedi_device *dev, struct comedi_subdevi
/* step 2: make sure trigger sources are unique and mutually compatible */
if (cmd->scan_begin_src != TRIG_TIMER &&
- cmd->scan_begin_src != TRIG_EXT)
+ cmd->scan_begin_src != TRIG_EXT)
err++;
if (cmd->stop_src != TRIG_COUNT && cmd->stop_src != TRIG_NONE)
err++;
@@ -1336,8 +1380,10 @@ static int cb_pcidas_ao_cmdtest(struct comedi_device *dev, struct comedi_subdevi
if (cmd->scan_begin_src == TRIG_TIMER) {
tmp = cmd->scan_begin_arg;
i8253_cascade_ns_to_timer_2div(TIMER_BASE,
- &(devpriv->ao_divisor1), &(devpriv->ao_divisor2),
- &(cmd->scan_begin_arg), cmd->flags & TRIG_ROUND_MASK);
+ &(devpriv->ao_divisor1),
+ &(devpriv->ao_divisor2),
+ &(cmd->scan_begin_arg),
+ cmd->flags & TRIG_ROUND_MASK);
if (tmp != cmd->scan_begin_arg)
err++;
}
@@ -1348,9 +1394,9 @@ static int cb_pcidas_ao_cmdtest(struct comedi_device *dev, struct comedi_subdevi
/* 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) {
+ CR_CHAN(cmd->chanlist[1]) != 1) {
comedi_error(dev,
- "channels must be ordered channel 0, channel 1 in chanlist\n");
+ "channels must be ordered channel 0, channel 1 in chanlist\n");
err++;
}
}
@@ -1361,7 +1407,8 @@ static int cb_pcidas_ao_cmdtest(struct comedi_device *dev, struct comedi_subdevi
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;
@@ -1373,10 +1420,11 @@ static int cb_pcidas_ao_cmd(struct comedi_device *dev, struct comedi_subdevice *
for (i = 0; i < cmd->chanlist_len; i++) {
/* enable channel */
devpriv->ao_control_bits |=
- DAC_CHAN_EN(CR_CHAN(cmd->chanlist[i]));
+ DAC_CHAN_EN(CR_CHAN(cmd->chanlist[i]));
/* set range */
devpriv->ao_control_bits |= DAC_RANGE(CR_CHAN(cmd->chanlist[i]),
- CR_RANGE(cmd->chanlist[i]));
+ CR_RANGE(cmd->
+ chanlist[i]));
}
/* disable analog out before settings pacer source and count values */
@@ -1389,14 +1437,16 @@ static int cb_pcidas_ao_cmd(struct comedi_device *dev, struct comedi_subdevice *
/* load counters */
if (cmd->scan_begin_src == TRIG_TIMER) {
i8253_cascade_ns_to_timer_2div(TIMER_BASE,
- &(devpriv->ao_divisor1), &(devpriv->ao_divisor2),
- &(cmd->scan_begin_arg), cmd->flags);
+ &(devpriv->ao_divisor1),
+ &(devpriv->ao_divisor2),
+ &(cmd->scan_begin_arg),
+ cmd->flags);
/* Write the values of ctr1 and ctr2 into counters 1 and 2 */
i8254_load(devpriv->pacer_counter_dio + DAC8254, 0, 1,
- devpriv->ao_divisor1, 2);
+ devpriv->ao_divisor1, 2);
i8254_load(devpriv->pacer_counter_dio + DAC8254, 0, 2,
- devpriv->ao_divisor2, 2);
+ devpriv->ao_divisor2, 2);
}
/* set number of conversions */
if (cmd->stop_src == TRIG_COUNT) {
@@ -1441,7 +1491,7 @@ static int cb_pcidas_ao_inttrig(struct comedi_device *dev,
num_points = devpriv->ao_count;
num_bytes = cfc_read_array_from_buffer(s, devpriv->ao_buffer,
- num_points * sizeof(short));
+ num_points * sizeof(short));
num_points = num_bytes / sizeof(short);
if (cmd->stop_src == TRIG_COUNT) {
@@ -1458,14 +1508,13 @@ static int cb_pcidas_ao_inttrig(struct comedi_device *dev,
#endif
/* enable and clear interrupts */
outw(devpriv->adc_fifo_bits | DAEMI | DAHFI,
- devpriv->control_status + INT_ADCFIFO);
+ devpriv->control_status + INT_ADCFIFO);
/* 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
- printk("comedi: sent 0x%x to dac control\n",
- devpriv->ao_control_bits);
+ printk("comedi: sent 0x%x to dac control\n", devpriv->ao_control_bits);
#endif
spin_unlock_irqrestore(&dev->spinlock, flags);
@@ -1476,7 +1525,7 @@ static int cb_pcidas_ao_inttrig(struct comedi_device *dev,
static irqreturn_t cb_pcidas_interrupt(int irq, void *d)
{
- struct comedi_device *dev = (struct comedi_device *) d;
+ struct comedi_device *dev = (struct comedi_device *)d;
struct comedi_subdevice *s = dev->read_subdev;
struct comedi_async *async;
int status, s5933_status;
@@ -1505,7 +1554,7 @@ static irqreturn_t cb_pcidas_interrupt(int irq, void *d)
inl_p(devpriv->s5933_config + AMCC_OP_REG_IMB4);
/* clear interrupt on amcc s5933 */
outl(devpriv->s5933_intcsr_bits | INTCSR_INBOX_INTR_STATUS,
- devpriv->s5933_config + AMCC_OP_REG_INTCSR);
+ devpriv->s5933_config + AMCC_OP_REG_INTCSR);
status = inw(devpriv->control_status + INT_ADCFIFO);
#ifdef CB_PCIDAS_DEBUG
@@ -1524,13 +1573,13 @@ static irqreturn_t cb_pcidas_interrupt(int irq, void *d)
/* read data */
num_samples = half_fifo;
if (async->cmd.stop_src == TRIG_COUNT &&
- num_samples > devpriv->count) {
+ num_samples > devpriv->count) {
num_samples = devpriv->count;
}
insw(devpriv->adc_fifo + ADCDATA, devpriv->ai_buffer,
- num_samples);
+ num_samples);
cfc_write_array_to_buffer(s, devpriv->ai_buffer,
- num_samples * sizeof(short));
+ num_samples * sizeof(short));
devpriv->count -= num_samples;
if (async->cmd.stop_src == TRIG_COUNT && devpriv->count == 0) {
async->events |= COMEDI_CB_EOA;
@@ -1539,14 +1588,14 @@ static irqreturn_t cb_pcidas_interrupt(int irq, void *d)
/* clear half-full interrupt latch */
spin_lock_irqsave(&dev->spinlock, flags);
outw(devpriv->adc_fifo_bits | INT,
- devpriv->control_status + INT_ADCFIFO);
+ devpriv->control_status + INT_ADCFIFO);
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 */
if ((ADNE & inw(devpriv->control_status +
- INT_ADCFIFO)) == 0)
+ INT_ADCFIFO)) == 0)
break;
cfc_write_to_buffer(s, inw(devpriv->adc_fifo));
if (async->cmd.stop_src == TRIG_COUNT && --devpriv->count == 0) { /* end of acquisition */
@@ -1558,15 +1607,15 @@ static irqreturn_t cb_pcidas_interrupt(int irq, void *d)
/* clear not-empty interrupt latch */
spin_lock_irqsave(&dev->spinlock, flags);
outw(devpriv->adc_fifo_bits | INT,
- devpriv->control_status + INT_ADCFIFO);
+ devpriv->control_status + INT_ADCFIFO);
spin_unlock_irqrestore(&dev->spinlock, flags);
} else if (status & EOAI) {
comedi_error(dev,
- "bug! encountered end of aquisition interrupt?");
+ "bug! encountered end of aquisition interrupt?");
/* clear EOA interrupt latch */
spin_lock_irqsave(&dev->spinlock, flags);
outw(devpriv->adc_fifo_bits | EOAI,
- devpriv->control_status + INT_ADCFIFO);
+ devpriv->control_status + INT_ADCFIFO);
spin_unlock_irqrestore(&dev->spinlock, flags);
}
/* check for fifo overflow */
@@ -1575,7 +1624,7 @@ static irqreturn_t cb_pcidas_interrupt(int irq, void *d)
/* clear overflow interrupt latch */
spin_lock_irqsave(&dev->spinlock, flags);
outw(devpriv->adc_fifo_bits | LADFUL,
- devpriv->control_status + INT_ADCFIFO);
+ devpriv->control_status + INT_ADCFIFO);
spin_unlock_irqrestore(&dev->spinlock, flags);
cb_pcidas_cancel(dev, s);
async->events |= COMEDI_CB_EOA | COMEDI_CB_ERROR;
@@ -1601,12 +1650,12 @@ static void handle_ao_interrupt(struct comedi_device *dev, unsigned int status)
/* clear dac empty interrupt latch */
spin_lock_irqsave(&dev->spinlock, flags);
outw(devpriv->adc_fifo_bits | DAEMI,
- devpriv->control_status + INT_ADCFIFO);
+ devpriv->control_status + INT_ADCFIFO);
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
- && devpriv->ao_count)) {
+ (cmd->stop_src == TRIG_COUNT
+ && devpriv->ao_count)) {
comedi_error(dev, "dac fifo underflow");
cb_pcidas_ao_cancel(dev, s);
async->events |= COMEDI_CB_ERROR;
@@ -1619,11 +1668,11 @@ static void handle_ao_interrupt(struct comedi_device *dev, unsigned int status)
/* 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)
+ devpriv->ao_count < num_points)
num_points = devpriv->ao_count;
num_bytes =
- cfc_read_array_from_buffer(s, devpriv->ao_buffer,
- num_points * sizeof(short));
+ cfc_read_array_from_buffer(s, devpriv->ao_buffer,
+ num_points * sizeof(short));
num_points = num_bytes / sizeof(short);
if (async->cmd.stop_src == TRIG_COUNT) {
@@ -1631,11 +1680,11 @@ static void handle_ao_interrupt(struct comedi_device *dev, unsigned int status)
}
/* write data to board's fifo */
outsw(devpriv->ao_registers + DACDATA, devpriv->ao_buffer,
- num_points);
+ num_points);
/* clear half-full interrupt latch */
spin_lock_irqsave(&dev->spinlock, flags);
outw(devpriv->adc_fifo_bits | DAHFI,
- devpriv->control_status + INT_ADCFIFO);
+ devpriv->control_status + INT_ADCFIFO);
spin_unlock_irqrestore(&dev->spinlock, flags);
}
@@ -1643,7 +1692,8 @@ static void handle_ao_interrupt(struct comedi_device *dev, unsigned int status)
}
/* 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;
@@ -1681,21 +1731,23 @@ static int cb_pcidas_ao_cancel(struct comedi_device *dev,
}
static void cb_pcidas_load_counters(struct comedi_device *dev, unsigned int *ns,
- int rounding_flags)
+ int rounding_flags)
{
i8253_cascade_ns_to_timer_2div(TIMER_BASE, &(devpriv->divisor1),
- &(devpriv->divisor2), ns, rounding_flags & TRIG_ROUND_MASK);
+ &(devpriv->divisor2), ns,
+ rounding_flags & TRIG_ROUND_MASK);
/* Write the values of ctr1 and ctr2 into counters 1 and 2 */
i8254_load(devpriv->pacer_counter_dio + ADC8254, 0, 1,
- devpriv->divisor1, 2);
+ devpriv->divisor1, 2);
i8254_load(devpriv->pacer_counter_dio + ADC8254, 0, 2,
- devpriv->divisor2, 2);
+ devpriv->divisor2, 2);
}
static void write_calibration_bitstream(struct comedi_device *dev,
- unsigned int register_bits, unsigned int bitstream,
- unsigned int bitstream_length)
+ unsigned int register_bits,
+ unsigned int bitstream,
+ unsigned int bitstream_length)
{
static const int write_delay = 1;
unsigned int bit;
@@ -1711,7 +1763,7 @@ static void write_calibration_bitstream(struct comedi_device *dev,
}
static int caldac_8800_write(struct comedi_device *dev, unsigned int address,
- uint8_t value)
+ uint8_t value)
{
static const int num_caldac_channels = 8;
static const int bitstream_length = 11;
@@ -1729,11 +1781,11 @@ static int caldac_8800_write(struct comedi_device *dev, unsigned int address,
devpriv->caldac_value[address] = value;
write_calibration_bitstream(dev, cal_enable_bits(dev), bitstream,
- bitstream_length);
+ bitstream_length);
udelay(caldac_8800_udelay);
outw(cal_enable_bits(dev) | SELECT_8800_BIT,
- devpriv->control_status + CALIBRATION_REG);
+ devpriv->control_status + CALIBRATION_REG);
udelay(caldac_8800_udelay);
outw(cal_enable_bits(dev), devpriv->control_status + CALIBRATION_REG);
@@ -1752,7 +1804,7 @@ static int trimpot_7376_write(struct comedi_device *dev, uint8_t value)
outw(register_bits, devpriv->control_status + CALIBRATION_REG);
write_calibration_bitstream(dev, register_bits, bitstream,
- bitstream_length);
+ bitstream_length);
udelay(ad7376_udelay);
outw(cal_enable_bits(dev), devpriv->control_status + CALIBRATION_REG);
@@ -1764,7 +1816,7 @@ static int trimpot_7376_write(struct comedi_device *dev, uint8_t value)
* ch 0 : adc gain
* ch 1 : adc postgain offset */
static int trimpot_8402_write(struct comedi_device *dev, unsigned int channel,
- uint8_t value)
+ uint8_t value)
{
static const int bitstream_length = 10;
unsigned int bitstream = ((channel & 0x3) << 8) | (value & 0xff);
@@ -1776,7 +1828,7 @@ static int trimpot_8402_write(struct comedi_device *dev, unsigned int channel,
outw(register_bits, devpriv->control_status + CALIBRATION_REG);
write_calibration_bitstream(dev, register_bits, bitstream,
- bitstream_length);
+ bitstream_length);
udelay(ad8402_udelay);
outw(cal_enable_bits(dev), devpriv->control_status + CALIBRATION_REG);
@@ -1791,15 +1843,16 @@ static int wait_for_nvram_ready(unsigned long s5933_base_addr)
for (i = 0; i < timeout; i++) {
if ((inb(s5933_base_addr +
- AMCC_OP_REG_MCSR_NVCMD) & MCSR_NV_BUSY)
- == 0)
+ AMCC_OP_REG_MCSR_NVCMD) & MCSR_NV_BUSY)
+ == 0)
return 0;
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;
@@ -1807,10 +1860,10 @@ static int nvram_read(struct comedi_device *dev, unsigned int address, uint8_t *
return -ETIMEDOUT;
outb(MCSR_NV_ENABLE | MCSR_NV_LOAD_LOW_ADDR,
- iobase + AMCC_OP_REG_MCSR_NVCMD);
+ iobase + AMCC_OP_REG_MCSR_NVCMD);
outb(address & 0xff, iobase + AMCC_OP_REG_MCSR_NVDATA);
outb(MCSR_NV_ENABLE | MCSR_NV_LOAD_HIGH_ADDR,
- iobase + AMCC_OP_REG_MCSR_NVCMD);
+ iobase + AMCC_OP_REG_MCSR_NVCMD);
outb((address >> 8) & 0xff, iobase + AMCC_OP_REG_MCSR_NVDATA);
outb(MCSR_NV_ENABLE | MCSR_NV_READ, iobase + AMCC_OP_REG_MCSR_NVCMD);
diff --git a/drivers/staging/comedi/drivers/cb_pcidas64.c b/drivers/staging/comedi/drivers/cb_pcidas64.c
index 210b462868b7..82295e0f07f9 100644
--- a/drivers/staging/comedi/drivers/cb_pcidas64.c
+++ b/drivers/staging/comedi/drivers/cb_pcidas64.c
@@ -152,10 +152,12 @@ static inline unsigned int dac_convert_reg(unsigned int channel)
{
return 0x70 + (2 * (channel & 0x1));
}
+
static inline unsigned int dac_lsb_4020_reg(unsigned int channel)
{
return 0x70 + (4 * (channel & 0x1));
}
+
static inline unsigned int dac_msb_4020_reg(unsigned int channel)
{
return 0x72 + (4 * (channel & 0x1));
@@ -269,10 +271,12 @@ static inline uint16_t adc_lo_chan_4020_bits(unsigned int channel)
{
return (channel & 0x3) << 8;
};
+
static inline uint16_t adc_hi_chan_4020_bits(unsigned int channel)
{
return (channel & 0x3) << 10;
};
+
static inline uint16_t adc_mode_bits(unsigned int mode)
{
return (mode & 0xf) << 12;
@@ -370,10 +374,12 @@ static inline unsigned int dma_chain_flag_bits(uint16_t prepost_bits)
{
return (prepost_bits >> 6) & 0x3;
}
+
static inline unsigned int adc_upper_read_ptr_code(uint16_t prepost_bits)
{
return (prepost_bits >> 12) & 0x3;
}
+
static inline unsigned int adc_upper_write_ptr_code(uint16_t prepost_bits)
{
return (prepost_bits >> 14) & 0x3;
@@ -394,6 +400,7 @@ static inline uint8_t adc_src_4020_bits(unsigned int source)
{
return (source << 4) & ADC_SRC_4020_MASK;
};
+
static inline uint8_t attenuate_bit(unsigned int channel)
{
/* attenuate channel (+-5V input range) */
@@ -404,90 +411,91 @@ static inline uint8_t attenuate_bit(unsigned int channel)
static const struct comedi_lrange ai_ranges_64xx = {
8,
{
- BIP_RANGE(10),
- BIP_RANGE(5),
- BIP_RANGE(2.5),
- BIP_RANGE(1.25),
- UNI_RANGE(10),
- UNI_RANGE(5),
- UNI_RANGE(2.5),
- UNI_RANGE(1.25)
- }
+ BIP_RANGE(10),
+ BIP_RANGE(5),
+ BIP_RANGE(2.5),
+ BIP_RANGE(1.25),
+ UNI_RANGE(10),
+ UNI_RANGE(5),
+ UNI_RANGE(2.5),
+ UNI_RANGE(1.25)
+ }
};
/* analog input ranges for 60xx boards */
static const struct comedi_lrange ai_ranges_60xx = {
4,
{
- BIP_RANGE(10),
- BIP_RANGE(5),
- BIP_RANGE(0.5),
- BIP_RANGE(0.05),
- }
+ BIP_RANGE(10),
+ BIP_RANGE(5),
+ BIP_RANGE(0.5),
+ BIP_RANGE(0.05),
+ }
};
/* analog input ranges for 6030, etc boards */
static const struct comedi_lrange ai_ranges_6030 = {
14,
{
- BIP_RANGE(10),
- BIP_RANGE(5),
- BIP_RANGE(2),
- BIP_RANGE(1),
- BIP_RANGE(0.5),
- BIP_RANGE(0.2),
- BIP_RANGE(0.1),
- UNI_RANGE(10),
- UNI_RANGE(5),
- UNI_RANGE(2),
- UNI_RANGE(1),
- UNI_RANGE(0.5),
- UNI_RANGE(0.2),
- UNI_RANGE(0.1),
- }
+ BIP_RANGE(10),
+ BIP_RANGE(5),
+ BIP_RANGE(2),
+ BIP_RANGE(1),
+ BIP_RANGE(0.5),
+ BIP_RANGE(0.2),
+ BIP_RANGE(0.1),
+ UNI_RANGE(10),
+ UNI_RANGE(5),
+ UNI_RANGE(2),
+ UNI_RANGE(1),
+ UNI_RANGE(0.5),
+ UNI_RANGE(0.2),
+ UNI_RANGE(0.1),
+ }
};
/* analog input ranges for 6052, etc boards */
static const struct comedi_lrange ai_ranges_6052 = {
15,
{
- BIP_RANGE(10),
- BIP_RANGE(5),
- BIP_RANGE(2.5),
- BIP_RANGE(1),
- BIP_RANGE(0.5),
- BIP_RANGE(0.25),
- BIP_RANGE(0.1),
- BIP_RANGE(0.05),
- UNI_RANGE(10),
- UNI_RANGE(5),
- UNI_RANGE(2),
- UNI_RANGE(1),
- UNI_RANGE(0.5),
- UNI_RANGE(0.2),
- UNI_RANGE(0.1),
- }
+ BIP_RANGE(10),
+ BIP_RANGE(5),
+ BIP_RANGE(2.5),
+ BIP_RANGE(1),
+ BIP_RANGE(0.5),
+ BIP_RANGE(0.25),
+ BIP_RANGE(0.1),
+ BIP_RANGE(0.05),
+ UNI_RANGE(10),
+ UNI_RANGE(5),
+ UNI_RANGE(2),
+ UNI_RANGE(1),
+ UNI_RANGE(0.5),
+ UNI_RANGE(0.2),
+ UNI_RANGE(0.1),
+ }
};
/* analog input ranges for 4020 board */
static const struct comedi_lrange ai_ranges_4020 = {
2,
{
- BIP_RANGE(5),
- BIP_RANGE(1),
- }
+ BIP_RANGE(5),
+ BIP_RANGE(1),
+ }
};
/* analog output ranges */
static const struct comedi_lrange ao_ranges_64xx = {
4,
{
- BIP_RANGE(5),
- BIP_RANGE(10),
- UNI_RANGE(5),
- UNI_RANGE(10),
- }
+ BIP_RANGE(5),
+ BIP_RANGE(10),
+ UNI_RANGE(5),
+ UNI_RANGE(10),
+ }
};
+
static const int ao_range_code_64xx[] = {
0x0,
0x1,
@@ -498,9 +506,10 @@ static const int ao_range_code_64xx[] = {
static const struct comedi_lrange ao_ranges_60xx = {
1,
{
- BIP_RANGE(10),
- }
+ BIP_RANGE(10),
+ }
};
+
static const int ao_range_code_60xx[] = {
0x0,
};
@@ -508,10 +517,11 @@ static const int ao_range_code_60xx[] = {
static const struct comedi_lrange ao_ranges_6030 = {
2,
{
- BIP_RANGE(10),
- UNI_RANGE(10),
- }
+ BIP_RANGE(10),
+ UNI_RANGE(10),
+ }
};
+
static const int ao_range_code_6030[] = {
0x0,
0x2,
@@ -520,10 +530,11 @@ static const int ao_range_code_6030[] = {
static const struct comedi_lrange ao_ranges_4020 = {
2,
{
- BIP_RANGE(5),
- BIP_RANGE(10),
- }
+ BIP_RANGE(5),
+ BIP_RANGE(10),
+ }
};
+
static const int ao_range_code_4020[] = {
0x1,
0x0,
@@ -597,458 +608,478 @@ 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",
- .device_id = 0x78,
- .ai_se_chans = 16,
- .ai_bits = 16,
- .ai_speed = 5000,
- .ao_nchan = 0,
- .ao_bits = 16,
- .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-das6013",
+ .device_id = 0x78,
+ .ai_se_chans = 16,
+ .ai_bits = 16,
+ .ai_speed = 5000,
+ .ao_nchan = 0,
+ .ao_bits = 16,
+ .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-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
};
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},
- {PCI_VENDOR_ID_COMPUTERBOARDS, 0x0035, PCI_ANY_ID, PCI_ANY_ID, 0, 0, 0},
- {PCI_VENDOR_ID_COMPUTERBOARDS, 0x0036, PCI_ANY_ID, PCI_ANY_ID, 0, 0, 0},
- {PCI_VENDOR_ID_COMPUTERBOARDS, 0x0037, PCI_ANY_ID, PCI_ANY_ID, 0, 0, 0},
- {PCI_VENDOR_ID_COMPUTERBOARDS, 0x0052, PCI_ANY_ID, PCI_ANY_ID, 0, 0, 0},
- {PCI_VENDOR_ID_COMPUTERBOARDS, 0x005d, PCI_ANY_ID, PCI_ANY_ID, 0, 0, 0},
- {PCI_VENDOR_ID_COMPUTERBOARDS, 0x005e, PCI_ANY_ID, PCI_ANY_ID, 0, 0, 0},
- {PCI_VENDOR_ID_COMPUTERBOARDS, 0x005f, PCI_ANY_ID, PCI_ANY_ID, 0, 0, 0},
- {PCI_VENDOR_ID_COMPUTERBOARDS, 0x0061, PCI_ANY_ID, PCI_ANY_ID, 0, 0, 0},
- {PCI_VENDOR_ID_COMPUTERBOARDS, 0x0062, PCI_ANY_ID, PCI_ANY_ID, 0, 0, 0},
- {PCI_VENDOR_ID_COMPUTERBOARDS, 0x0063, PCI_ANY_ID, PCI_ANY_ID, 0, 0, 0},
- {PCI_VENDOR_ID_COMPUTERBOARDS, 0x0064, PCI_ANY_ID, PCI_ANY_ID, 0, 0, 0},
- {PCI_VENDOR_ID_COMPUTERBOARDS, 0x0066, PCI_ANY_ID, PCI_ANY_ID, 0, 0, 0},
- {PCI_VENDOR_ID_COMPUTERBOARDS, 0x0067, PCI_ANY_ID, PCI_ANY_ID, 0, 0, 0},
- {PCI_VENDOR_ID_COMPUTERBOARDS, 0x0068, PCI_ANY_ID, PCI_ANY_ID, 0, 0, 0},
- {PCI_VENDOR_ID_COMPUTERBOARDS, 0x006f, PCI_ANY_ID, PCI_ANY_ID, 0, 0, 0},
- {PCI_VENDOR_ID_COMPUTERBOARDS, 0x0078, PCI_ANY_ID, PCI_ANY_ID, 0, 0, 0},
- {PCI_VENDOR_ID_COMPUTERBOARDS, 0x0079, PCI_ANY_ID, PCI_ANY_ID, 0, 0, 0},
- {0}
+ {
+ 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},
+ {
+ PCI_VENDOR_ID_COMPUTERBOARDS, 0x0035, PCI_ANY_ID, PCI_ANY_ID, 0, 0, 0},
+ {
+ PCI_VENDOR_ID_COMPUTERBOARDS, 0x0036, PCI_ANY_ID, PCI_ANY_ID, 0, 0, 0},
+ {
+ PCI_VENDOR_ID_COMPUTERBOARDS, 0x0037, PCI_ANY_ID, PCI_ANY_ID, 0, 0, 0},
+ {
+ PCI_VENDOR_ID_COMPUTERBOARDS, 0x0052, PCI_ANY_ID, PCI_ANY_ID, 0, 0, 0},
+ {
+ PCI_VENDOR_ID_COMPUTERBOARDS, 0x005d, PCI_ANY_ID, PCI_ANY_ID, 0, 0, 0},
+ {
+ PCI_VENDOR_ID_COMPUTERBOARDS, 0x005e, PCI_ANY_ID, PCI_ANY_ID, 0, 0, 0},
+ {
+ PCI_VENDOR_ID_COMPUTERBOARDS, 0x005f, PCI_ANY_ID, PCI_ANY_ID, 0, 0, 0},
+ {
+ PCI_VENDOR_ID_COMPUTERBOARDS, 0x0061, PCI_ANY_ID, PCI_ANY_ID, 0, 0, 0},
+ {
+ PCI_VENDOR_ID_COMPUTERBOARDS, 0x0062, PCI_ANY_ID, PCI_ANY_ID, 0, 0, 0},
+ {
+ PCI_VENDOR_ID_COMPUTERBOARDS, 0x0063, PCI_ANY_ID, PCI_ANY_ID, 0, 0, 0},
+ {
+ PCI_VENDOR_ID_COMPUTERBOARDS, 0x0064, PCI_ANY_ID, PCI_ANY_ID, 0, 0, 0},
+ {
+ PCI_VENDOR_ID_COMPUTERBOARDS, 0x0066, PCI_ANY_ID, PCI_ANY_ID, 0, 0, 0},
+ {
+ PCI_VENDOR_ID_COMPUTERBOARDS, 0x0067, PCI_ANY_ID, PCI_ANY_ID, 0, 0, 0},
+ {
+ PCI_VENDOR_ID_COMPUTERBOARDS, 0x0068, PCI_ANY_ID, PCI_ANY_ID, 0, 0, 0},
+ {
+ PCI_VENDOR_ID_COMPUTERBOARDS, 0x006f, PCI_ANY_ID, PCI_ANY_ID, 0, 0, 0},
+ {
+ PCI_VENDOR_ID_COMPUTERBOARDS, 0x0078, PCI_ANY_ID, PCI_ANY_ID, 0, 0, 0},
+ {
+ PCI_VENDOR_ID_COMPUTERBOARDS, 0x0079, PCI_ANY_ID, PCI_ANY_ID, 0, 0, 0},
+ {
+ 0}
};
MODULE_DEVICE_TABLE(pci, pcidas64_pci_table);
-static inline struct pcidas64_board *board(const struct comedi_device * dev)
+static inline struct pcidas64_board *board(const struct comedi_device *dev)
{
- return (struct pcidas64_board *) dev->board_ptr;
+ return (struct pcidas64_board *)dev->board_ptr;
}
static inline unsigned short se_diff_bit_6xxx(struct comedi_device *dev,
- int use_differential)
+ int use_differential)
{
if ((board(dev)->layout == LAYOUT_64XX && !use_differential) ||
- (board(dev)->layout == LAYOUT_60XX && use_differential))
+ (board(dev)->layout == LAYOUT_60XX && use_differential))
return ADC_SE_DIFF_BIT;
else
return 0;
@@ -1107,11 +1138,10 @@ struct pcidas64_private {
short ao_bounce_buffer[DAC_FIFO_SIZE];
};
-
/* inline function that makes it easier to
* access the private structure.
*/
-static inline struct pcidas64_private *priv(struct comedi_device * dev)
+static inline struct pcidas64_private *priv(struct comedi_device *dev)
{
return dev->private;
}
@@ -1132,76 +1162,86 @@ static struct comedi_driver driver_cb_pcidas = {
};
static int ai_rinsn(struct comedi_device *dev, struct comedi_subdevice *s,
- struct comedi_insn *insn, unsigned int *data);
+ 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);
+ 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);
+ 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);
+ 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_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);
+ 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);
+ 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);
+ 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);
+ 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);
+ 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 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);
+ const uint8_t * data, unsigned int length);
static void caldac_write(struct comedi_device *dev, unsigned int channel,
- unsigned int value);
+ unsigned int value);
static int caldac_8800_write(struct comedi_device *dev, unsigned int address,
- uint8_t value);
+ 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,
- unsigned int value);
+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 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);
+ 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 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,
- unsigned int range_index)
+ unsigned int range_index)
{
const struct comedi_krange *range =
- &board(dev)->ai_range_table->range[range_index];
+ &board(dev)->ai_range_table->range[range_index];
unsigned int bits = 0;
switch (range->max) {
@@ -1242,7 +1282,7 @@ static unsigned int ai_range_bits_6xxx(const struct comedi_device *dev,
}
static unsigned int hw_revision(const struct comedi_device *dev,
- uint16_t hw_status_bits)
+ uint16_t hw_status_bits)
{
if (board(dev)->layout == LAYOUT_4020)
return (hw_status_bits >> 13) & 0x7;
@@ -1250,8 +1290,9 @@ 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,
- unsigned int channel, unsigned int range)
+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];
@@ -1276,38 +1317,38 @@ static void init_plx9080(struct comedi_device *dev)
void *plx_iobase = priv(dev)->plx9080_iobase;
priv(dev)->plx_control_bits =
- readl(priv(dev)->plx9080_iobase + PLX_CONTROL_REG);
+ readl(priv(dev)->plx9080_iobase + PLX_CONTROL_REG);
/* plx9080 dump */
DEBUG_PRINT(" plx interrupt status 0x%x\n",
- readl(plx_iobase + PLX_INTRCS_REG));
+ readl(plx_iobase + PLX_INTRCS_REG));
DEBUG_PRINT(" plx id bits 0x%x\n", readl(plx_iobase + PLX_ID_REG));
DEBUG_PRINT(" plx control reg 0x%x\n", priv(dev)->plx_control_bits);
DEBUG_PRINT(" plx mode/arbitration reg 0x%x\n",
- readl(plx_iobase + PLX_MARB_REG));
+ readl(plx_iobase + PLX_MARB_REG));
DEBUG_PRINT(" plx region0 reg 0x%x\n",
- readl(plx_iobase + PLX_REGION0_REG));
+ readl(plx_iobase + PLX_REGION0_REG));
DEBUG_PRINT(" plx region1 reg 0x%x\n",
- readl(plx_iobase + PLX_REGION1_REG));
+ readl(plx_iobase + PLX_REGION1_REG));
DEBUG_PRINT(" plx revision 0x%x\n",
- readl(plx_iobase + PLX_REVISION_REG));
+ readl(plx_iobase + PLX_REVISION_REG));
DEBUG_PRINT(" plx dma channel 0 mode 0x%x\n",
- readl(plx_iobase + PLX_DMA0_MODE_REG));
+ readl(plx_iobase + PLX_DMA0_MODE_REG));
DEBUG_PRINT(" plx dma channel 1 mode 0x%x\n",
- readl(plx_iobase + PLX_DMA1_MODE_REG));
+ readl(plx_iobase + PLX_DMA1_MODE_REG));
DEBUG_PRINT(" plx dma channel 0 pci address 0x%x\n",
- readl(plx_iobase + PLX_DMA0_PCI_ADDRESS_REG));
+ readl(plx_iobase + PLX_DMA0_PCI_ADDRESS_REG));
DEBUG_PRINT(" plx dma channel 0 local address 0x%x\n",
- readl(plx_iobase + PLX_DMA0_LOCAL_ADDRESS_REG));
+ readl(plx_iobase + PLX_DMA0_LOCAL_ADDRESS_REG));
DEBUG_PRINT(" plx dma channel 0 transfer size 0x%x\n",
- readl(plx_iobase + PLX_DMA0_TRANSFER_SIZE_REG));
+ readl(plx_iobase + PLX_DMA0_TRANSFER_SIZE_REG));
DEBUG_PRINT(" plx dma channel 0 descriptor 0x%x\n",
- readl(plx_iobase + PLX_DMA0_DESCRIPTOR_REG));
+ readl(plx_iobase + PLX_DMA0_DESCRIPTOR_REG));
DEBUG_PRINT(" plx dma channel 0 command status 0x%x\n",
- readb(plx_iobase + PLX_DMA0_CS_REG));
+ readb(plx_iobase + PLX_DMA0_CS_REG));
DEBUG_PRINT(" plx dma channel 0 threshold 0x%x\n",
- readl(plx_iobase + PLX_DMA0_THRESHOLD_REG));
+ readl(plx_iobase + PLX_DMA0_THRESHOLD_REG));
DEBUG_PRINT(" plx bigend 0x%x\n", readl(plx_iobase + PLX_BIGEND_REG));
#ifdef __BIG_ENDIAN
@@ -1352,10 +1393,10 @@ static void init_plx9080(struct comedi_device *dev)
/* 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;
+ ICS_AERR | ICS_PERR | ICS_PIE | ICS_PLIE | ICS_PAIE | ICS_LIE |
+ ICS_DMA0_E | ICS_DMA1_E;
writel(priv(dev)->plx_intcsr_bits,
- priv(dev)->plx9080_iobase + PLX_INTRCS_REG);
+ priv(dev)->plx9080_iobase + PLX_INTRCS_REG);
}
/* Allocate and initialize the subdevice structures.
@@ -1405,8 +1446,7 @@ static int setup_subdevices(struct comedi_device *dev)
if (board(dev)->ao_nchan) {
s->type = COMEDI_SUBD_AO;
s->subdev_flags =
- SDF_READABLE | SDF_WRITABLE | SDF_GROUND |
- SDF_CMD_WRITE;
+ SDF_READABLE | SDF_WRITABLE | SDF_GROUND | SDF_CMD_WRITE;
s->n_chan = board(dev)->ao_nchan;
s->maxdata = (1 << board(dev)->ao_bits) - 1;
s->range_table = board(dev)->ao_range_table;
@@ -1452,14 +1492,14 @@ static int setup_subdevices(struct comedi_device *dev)
if (board(dev)->has_8255) {
if (board(dev)->layout == LAYOUT_4020) {
dio_8255_iobase =
- priv(dev)->main_iobase + I8255_4020_REG;
+ priv(dev)->main_iobase + I8255_4020_REG;
subdev_8255_init(dev, s, dio_callback_4020,
- (unsigned long)dio_8255_iobase);
+ (unsigned long)dio_8255_iobase);
} else {
dio_8255_iobase =
- priv(dev)->dio_counter_iobase + DIO_8255_OFFSET;
+ priv(dev)->dio_counter_iobase + DIO_8255_OFFSET;
subdev_8255_init(dev, s, dio_callback,
- (unsigned long)dio_8255_iobase);
+ (unsigned long)dio_8255_iobase);
}
} else
s->type = COMEDI_SUBD_UNUSED;
@@ -1527,7 +1567,7 @@ 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);
+ priv(dev)->plx9080_iobase + PLX_INTRCS_REG);
}
static void init_stc_registers(struct comedi_device *dev)
@@ -1541,7 +1581,7 @@ static void init_stc_registers(struct comedi_device *dev)
if (1)
priv(dev)->adc_control1_bits |= ADC_QUEUE_CONFIG_BIT;
writew(priv(dev)->adc_control1_bits,
- priv(dev)->main_iobase + ADC_CONTROL1_REG);
+ priv(dev)->main_iobase + ADC_CONTROL1_REG);
/* 6402/16 manual says this register must be initialized to 0xff? */
writew(0xff, priv(dev)->main_iobase + ADC_SAMPLE_INTERVAL_UPPER_REG);
@@ -1551,7 +1591,7 @@ static void init_stc_registers(struct comedi_device *dev)
bits |= INTERNAL_CLOCK_4020_BITS;
priv(dev)->hw_config_bits |= bits;
writew(priv(dev)->hw_config_bits,
- priv(dev)->main_iobase + HW_CONFIG_REG);
+ priv(dev)->main_iobase + HW_CONFIG_REG);
writew(0, priv(dev)->main_iobase + DAQ_SYNC_REG);
writew(0, priv(dev)->main_iobase + CALIBRATION_REG);
@@ -1561,13 +1601,13 @@ static void init_stc_registers(struct comedi_device *dev)
/* 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);
+ board(dev)->ai_fifo->max_segment_length);
priv(dev)->dac_control1_bits = DAC_OUTPUT_ENABLE_BIT;
priv(dev)->intr_enable_bits = /* EN_DAC_INTR_SRC_BIT | DAC_INTR_QEMPTY_BITS | */
- EN_DAC_DONE_INTR_BIT | EN_DAC_UNDERRUN_BIT;
+ EN_DAC_DONE_INTR_BIT | EN_DAC_UNDERRUN_BIT;
writew(priv(dev)->intr_enable_bits,
- priv(dev)->main_iobase + INTR_ENABLE_REG);
+ priv(dev)->main_iobase + INTR_ENABLE_REG);
disable_ai_pacing(dev);
};
@@ -1579,8 +1619,8 @@ int alloc_and_init_dma_members(struct comedi_device *dev)
/* 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,
- &priv(dev)->ai_buffer_bus_addr[i]);
+ pci_alloc_consistent(priv(dev)->hw_dev, DMA_BUFFER_SIZE,
+ &priv(dev)->ai_buffer_bus_addr[i]);
if (priv(dev)->ai_buffer[i] == NULL) {
return -ENOMEM;
}
@@ -1588,9 +1628,10 @@ int alloc_and_init_dma_members(struct comedi_device *dev)
for (i = 0; i < AO_DMA_RING_COUNT; i++) {
if (ao_cmd_is_supported(board(dev))) {
priv(dev)->ao_buffer[i] =
- pci_alloc_consistent(priv(dev)->hw_dev,
- DMA_BUFFER_SIZE,
- &priv(dev)->ao_buffer_bus_addr[i]);
+ pci_alloc_consistent(priv(dev)->hw_dev,
+ DMA_BUFFER_SIZE,
+ &priv(dev)->
+ ao_buffer_bus_addr[i]);
if (priv(dev)->ao_buffer[i] == NULL) {
return -ENOMEM;
}
@@ -1598,61 +1639,65 @@ int alloc_and_init_dma_members(struct comedi_device *dev)
}
/* 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)),
- &priv(dev)->ai_dma_desc_bus_addr);
+ pci_alloc_consistent(priv(dev)->hw_dev,
+ sizeof(struct plx_dma_desc) *
+ ai_dma_ring_count(board(dev)),
+ &priv(dev)->ai_dma_desc_bus_addr);
if (priv(dev)->ai_dma_desc == NULL) {
return -ENOMEM;
}
DEBUG_PRINT("ai dma descriptors start at bus addr 0x%x\n",
- priv(dev)->ai_dma_desc_bus_addr);
+ priv(dev)->ai_dma_desc_bus_addr);
if (ao_cmd_is_supported(board(dev))) {
priv(dev)->ao_dma_desc =
- pci_alloc_consistent(priv(dev)->hw_dev,
- sizeof(struct plx_dma_desc) * AO_DMA_RING_COUNT,
- &priv(dev)->ao_dma_desc_bus_addr);
+ pci_alloc_consistent(priv(dev)->hw_dev,
+ sizeof(struct plx_dma_desc) *
+ AO_DMA_RING_COUNT,
+ &priv(dev)->ao_dma_desc_bus_addr);
if (priv(dev)->ao_dma_desc == NULL) {
return -ENOMEM;
}
DEBUG_PRINT("ao dma descriptors start at bus addr 0x%x\n",
- priv(dev)->ao_dma_desc_bus_addr);
+ priv(dev)->ao_dma_desc_bus_addr);
}
/* 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]);
+ cpu_to_le32(priv(dev)->ai_buffer_bus_addr[i]);
if (board(dev)->layout == LAYOUT_4020)
priv(dev)->ai_dma_desc[i].local_start_addr =
- cpu_to_le32(priv(dev)->local1_iobase +
- ADC_FIFO_REG);
+ cpu_to_le32(priv(dev)->local1_iobase +
+ ADC_FIFO_REG);
else
priv(dev)->ai_dma_desc[i].local_start_addr =
- cpu_to_le32(priv(dev)->local0_iobase +
- ADC_FIFO_REG);
+ cpu_to_le32(priv(dev)->local0_iobase +
+ ADC_FIFO_REG);
priv(dev)->ai_dma_desc[i].transfer_size = cpu_to_le32(0);
priv(dev)->ai_dma_desc[i].next =
- cpu_to_le32((priv(dev)->ai_dma_desc_bus_addr + ((i +
- 1) %
- ai_dma_ring_count(board(dev))) *
- sizeof(priv(dev)->
- ai_dma_desc[0])) | PLX_DESC_IN_PCI_BIT |
- PLX_INTR_TERM_COUNT | PLX_XFER_LOCAL_TO_PCI);
+ cpu_to_le32((priv(dev)->ai_dma_desc_bus_addr + ((i +
+ 1) %
+ ai_dma_ring_count
+ (board
+ (dev))) *
+ sizeof(priv(dev)->ai_dma_desc[0])) |
+ PLX_DESC_IN_PCI_BIT | PLX_INTR_TERM_COUNT |
+ PLX_XFER_LOCAL_TO_PCI);
}
if (ao_cmd_is_supported(board(dev))) {
for (i = 0; i < AO_DMA_RING_COUNT; i++) {
priv(dev)->ao_dma_desc[i].pci_start_addr =
- cpu_to_le32(priv(dev)->ao_buffer_bus_addr[i]);
+ cpu_to_le32(priv(dev)->ao_buffer_bus_addr[i]);
priv(dev)->ao_dma_desc[i].local_start_addr =
- cpu_to_le32(priv(dev)->local0_iobase +
- DAC_FIFO_REG);
+ cpu_to_le32(priv(dev)->local0_iobase +
+ DAC_FIFO_REG);
priv(dev)->ao_dma_desc[i].transfer_size =
- cpu_to_le32(0);
+ cpu_to_le32(0);
priv(dev)->ao_dma_desc[i].next =
- cpu_to_le32((priv(dev)->ao_dma_desc_bus_addr +
- ((i + 1) % (AO_DMA_RING_COUNT)) *
- sizeof(priv(dev)->
- ao_dma_desc[0])) |
- PLX_DESC_IN_PCI_BIT | PLX_INTR_TERM_COUNT);
+ cpu_to_le32((priv(dev)->ao_dma_desc_bus_addr +
+ ((i + 1) % (AO_DMA_RING_COUNT)) *
+ sizeof(priv(dev)->ao_dma_desc[0])) |
+ PLX_DESC_IN_PCI_BIT |
+ PLX_INTR_TERM_COUNT);
}
}
return 0;
@@ -1661,9 +1706,9 @@ int alloc_and_init_dma_members(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.");
+ "AO command and AI external channel queue cannot be used simultaneously.");
comedi_error(dev,
- "Use internal AI channel queue (channels must be consecutive and use same range/aref)");
+ "Use internal AI channel queue (channels must be consecutive and use same range/aref)");
}
/*
@@ -1690,8 +1735,8 @@ 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)) {
+ pcidev != NULL;
+ pcidev = pci_get_device(PCI_ANY_ID, PCI_ANY_ID, pcidev)) {
/* is it not a computer boards card? */
if (pcidev->vendor != PCI_VENDOR_ID_COMPUTERBOARDS)
continue;
@@ -1703,8 +1748,7 @@ static int attach(struct comedi_device *dev, struct comedi_devconfig *it)
if (it->options[0] || it->options[1]) {
/* are we on the wrong bus/slot? */
if (pcidev->bus->number != it->options[0] ||
- PCI_SLOT(pcidev->devfn) !=
- it->options[1]) {
+ PCI_SLOT(pcidev->devfn) != it->options[1]) {
continue;
}
}
@@ -1717,16 +1761,17 @@ static int attach(struct comedi_device *dev, struct comedi_devconfig *it)
}
if (dev->board_ptr == NULL) {
- printk("No supported ComputerBoards/MeasurementComputing card found\n");
+ printk
+ ("No supported ComputerBoards/MeasurementComputing card found\n");
return -EIO;
}
printk("Found %s on bus %i, slot %i\n", board(dev)->name,
- pcidev->bus->number, PCI_SLOT(pcidev->devfn));
+ pcidev->bus->number, PCI_SLOT(pcidev->devfn));
if (comedi_pci_enable(pcidev, driver_cb_pcidas.driver_name)) {
printk(KERN_WARNING
- " failed to enable PCI device and request regions\n");
+ " failed to enable PCI device and request regions\n");
return -EIO;
}
pci_set_master(pcidev);
@@ -1735,23 +1780,25 @@ static int attach(struct comedi_device *dev, struct comedi_devconfig *it)
dev->board_name = board(dev)->name;
priv(dev)->plx9080_phys_iobase =
- pci_resource_start(pcidev, PLX9080_BADDRINDEX);
+ pci_resource_start(pcidev, PLX9080_BADDRINDEX);
priv(dev)->main_phys_iobase =
- pci_resource_start(pcidev, MAIN_BADDRINDEX);
+ pci_resource_start(pcidev, MAIN_BADDRINDEX);
priv(dev)->dio_counter_phys_iobase =
- pci_resource_start(pcidev, DIO_COUNTER_BADDRINDEX);
+ pci_resource_start(pcidev, DIO_COUNTER_BADDRINDEX);
/* 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,
- pci_resource_len(pcidev, MAIN_BADDRINDEX));
+ pci_resource_len(pcidev,
+ PLX9080_BADDRINDEX));
+ priv(dev)->main_iobase =
+ ioremap(priv(dev)->main_phys_iobase,
+ pci_resource_len(pcidev, MAIN_BADDRINDEX));
priv(dev)->dio_counter_iobase =
- ioremap(priv(dev)->dio_counter_phys_iobase,
- pci_resource_len(pcidev, DIO_COUNTER_BADDRINDEX));
+ ioremap(priv(dev)->dio_counter_phys_iobase,
+ pci_resource_len(pcidev, DIO_COUNTER_BADDRINDEX));
if (!priv(dev)->plx9080_iobase || !priv(dev)->main_iobase
- || !priv(dev)->dio_counter_iobase) {
+ || !priv(dev)->dio_counter_iobase) {
printk(" failed to remap io memory\n");
return -ENOMEM;
}
@@ -1759,27 +1806,25 @@ static int attach(struct comedi_device *dev, struct comedi_devconfig *it)
DEBUG_PRINT(" plx9080 remapped to 0x%p\n", priv(dev)->plx9080_iobase);
DEBUG_PRINT(" main remapped to 0x%p\n", priv(dev)->main_iobase);
DEBUG_PRINT(" diocounter remapped to 0x%p\n",
- priv(dev)->dio_counter_iobase);
+ priv(dev)->dio_counter_iobase);
/* figure out what local addresses are */
local_range =
- readl(priv(dev)->plx9080_iobase +
- PLX_LAS0RNG_REG) & LRNG_MEM_MASK;
+ readl(priv(dev)->plx9080_iobase + PLX_LAS0RNG_REG) & LRNG_MEM_MASK;
local_decode =
- readl(priv(dev)->plx9080_iobase +
- PLX_LAS0MAP_REG) & local_range & LMAP_MEM_MASK;
+ readl(priv(dev)->plx9080_iobase +
+ PLX_LAS0MAP_REG) & local_range & LMAP_MEM_MASK;
priv(dev)->local0_iobase =
- ((uint32_t) priv(dev)->
- main_phys_iobase & ~local_range) | local_decode;
+ ((uint32_t) priv(dev)->main_phys_iobase & ~local_range) |
+ local_decode;
local_range =
- readl(priv(dev)->plx9080_iobase +
- PLX_LAS1RNG_REG) & LRNG_MEM_MASK;
+ readl(priv(dev)->plx9080_iobase + PLX_LAS1RNG_REG) & LRNG_MEM_MASK;
local_decode =
- readl(priv(dev)->plx9080_iobase +
- PLX_LAS1MAP_REG) & local_range & LMAP_MEM_MASK;
+ readl(priv(dev)->plx9080_iobase +
+ PLX_LAS1MAP_REG) & local_range & LMAP_MEM_MASK;
priv(dev)->local1_iobase =
- ((uint32_t) priv(dev)->
- dio_counter_phys_iobase & ~local_range) | local_decode;
+ ((uint32_t) priv(dev)->dio_counter_phys_iobase & ~local_range) |
+ local_decode;
DEBUG_PRINT(" local 0 io addr 0x%x\n", priv(dev)->local0_iobase);
DEBUG_PRINT(" local 1 io addr 0x%x\n", priv(dev)->local1_iobase);
@@ -1789,7 +1834,7 @@ static int attach(struct comedi_device *dev, struct comedi_devconfig *it)
return retval;
priv(dev)->hw_revision =
- hw_revision(dev, readw(priv(dev)->main_iobase + HW_STATUS_REG));
+ hw_revision(dev, readw(priv(dev)->main_iobase + HW_STATUS_REG));
printk(" stc hardware revision %i\n", priv(dev)->hw_revision);
init_plx9080(dev);
init_stc_registers(dev);
@@ -1840,32 +1885,40 @@ static int detach(struct comedi_device *dev)
for (i = 0; i < ai_dma_ring_count(board(dev)); i++) {
if (priv(dev)->ai_buffer[i])
pci_free_consistent(priv(dev)->hw_dev,
- DMA_BUFFER_SIZE,
- priv(dev)->ai_buffer[i],
- priv(dev)->
- ai_buffer_bus_addr[i]);
+ DMA_BUFFER_SIZE,
+ priv(dev)->
+ ai_buffer[i],
+ priv
+ (dev)->ai_buffer_bus_addr
+ [i]);
}
for (i = 0; i < AO_DMA_RING_COUNT; i++) {
if (priv(dev)->ao_buffer[i])
pci_free_consistent(priv(dev)->hw_dev,
- DMA_BUFFER_SIZE,
- priv(dev)->ao_buffer[i],
- priv(dev)->
- ao_buffer_bus_addr[i]);
+ DMA_BUFFER_SIZE,
+ priv(dev)->
+ ao_buffer[i],
+ priv
+ (dev)->ao_buffer_bus_addr
+ [i]);
}
/* free dma descriptors */
if (priv(dev)->ai_dma_desc)
pci_free_consistent(priv(dev)->hw_dev,
- sizeof(struct plx_dma_desc) *
- ai_dma_ring_count(board(dev)),
- priv(dev)->ai_dma_desc,
- priv(dev)->ai_dma_desc_bus_addr);
+ sizeof(struct plx_dma_desc)
+ *
+ ai_dma_ring_count(board
+ (dev)),
+ priv(dev)->ai_dma_desc,
+ priv(dev)->
+ ai_dma_desc_bus_addr);
if (priv(dev)->ao_dma_desc)
pci_free_consistent(priv(dev)->hw_dev,
- sizeof(struct plx_dma_desc) *
- AO_DMA_RING_COUNT,
- priv(dev)->ao_dma_desc,
- priv(dev)->ao_dma_desc_bus_addr);
+ sizeof(struct plx_dma_desc)
+ * AO_DMA_RING_COUNT,
+ priv(dev)->ao_dma_desc,
+ priv(dev)->
+ ao_dma_desc_bus_addr);
if (priv(dev)->main_phys_iobase) {
comedi_pci_disable(priv(dev)->hw_dev);
}
@@ -1879,7 +1932,7 @@ static int detach(struct comedi_device *dev)
}
static int ai_rinsn(struct comedi_device *dev, struct comedi_subdevice *s,
- struct comedi_insn *insn, unsigned int *data)
+ struct comedi_insn *insn, unsigned int *data)
{
unsigned int bits = 0, n, i;
unsigned int channel, range, aref;
@@ -1901,14 +1954,14 @@ static int ai_rinsn(struct comedi_device *dev, struct comedi_subdevice *s,
else
priv(dev)->adc_control1_bits &= ~ADC_DITHER_BIT;
writew(priv(dev)->adc_control1_bits,
- priv(dev)->main_iobase + ADC_CONTROL1_REG);
+ priv(dev)->main_iobase + ADC_CONTROL1_REG);
spin_unlock_irqrestore(&dev->spinlock, flags);
if (board(dev)->layout != LAYOUT_4020) {
/* use internal queue */
priv(dev)->hw_config_bits &= ~EXT_QUEUE_BIT;
writew(priv(dev)->hw_config_bits,
- priv(dev)->main_iobase + HW_CONFIG_REG);
+ priv(dev)->main_iobase + HW_CONFIG_REG);
/* ALT_SOURCE is internal calibration reference */
if (insn->chanspec & CR_ALT_SOURCE) {
@@ -1920,9 +1973,9 @@ static int ai_rinsn(struct comedi_device *dev, struct comedi_subdevice *s,
else
cal_en_bit = CAL_EN_64XX_BIT;
/* 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);
+ 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 */
writew(0, priv(dev)->main_iobase + CALIBRATION_REG);
@@ -1938,7 +1991,7 @@ static int ai_rinsn(struct comedi_device *dev, struct comedi_subdevice *s,
bits |= adc_chan_bits(channel);
/* set stop channel */
writew(adc_chan_bits(channel),
- priv(dev)->main_iobase + ADC_QUEUE_HIGH_REG);
+ priv(dev)->main_iobase + ADC_QUEUE_HIGH_REG);
/* set start channel, and rest of settings */
writew(bits, priv(dev)->main_iobase + ADC_QUEUE_LOAD_REG);
} else {
@@ -1948,8 +2001,7 @@ static int ai_rinsn(struct comedi_device *dev, struct comedi_subdevice *s,
if (insn->chanspec & CR_ALT_SOURCE) {
DEBUG_PRINT("reading calibration source\n");
priv(dev)->i2c_cal_range_bits |=
- adc_src_4020_bits(priv(dev)->
- calibration_source);
+ adc_src_4020_bits(priv(dev)->calibration_source);
} else { /* select BNC inputs */
priv(dev)->i2c_cal_range_bits |= adc_src_4020_bits(4);
}
@@ -1958,20 +2010,20 @@ static int ai_rinsn(struct comedi_device *dev, struct comedi_subdevice *s,
priv(dev)->i2c_cal_range_bits |= attenuate_bit(channel);
else
priv(dev)->i2c_cal_range_bits &=
- ~attenuate_bit(channel);
+ ~attenuate_bit(channel);
/* 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,
- sizeof(i2c_data));
+ sizeof(i2c_data));
}
/* 4020 manual asks that sample interval register to be set before writing to convert register.
* Using somewhat arbitrary setting of 4 master clock ticks = 0.1 usec */
writew(0,
- priv(dev)->main_iobase + ADC_SAMPLE_INTERVAL_UPPER_REG);
+ priv(dev)->main_iobase + ADC_SAMPLE_INTERVAL_UPPER_REG);
writew(2,
- priv(dev)->main_iobase + ADC_SAMPLE_INTERVAL_LOWER_REG);
+ priv(dev)->main_iobase + ADC_SAMPLE_INTERVAL_LOWER_REG);
}
for (n = 0; n < insn->n; n++) {
@@ -1981,7 +2033,7 @@ static int ai_rinsn(struct comedi_device *dev, struct comedi_subdevice *s,
/* 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);
+ priv(dev)->main_iobase + ADC_CONVERT_REG);
/* wait for data */
for (i = 0; i < timeout; i++) {
@@ -1989,7 +2041,7 @@ static int ai_rinsn(struct comedi_device *dev, struct comedi_subdevice *s,
DEBUG_PRINT(" pipe bits 0x%x\n", pipe_full_bits(bits));
if (board(dev)->layout == LAYOUT_4020) {
if (readw(priv(dev)->main_iobase +
- ADC_WRITE_PNTR_REG))
+ ADC_WRITE_PNTR_REG))
break;
} else {
if (pipe_full_bits(bits))
@@ -2005,17 +2057,18 @@ static int ai_rinsn(struct comedi_device *dev, struct comedi_subdevice *s,
}
if (board(dev)->layout == LAYOUT_4020)
data[n] =
- readl(priv(dev)->dio_counter_iobase +
- ADC_FIFO_REG) & 0xffff;
+ readl(priv(dev)->dio_counter_iobase +
+ ADC_FIFO_REG) & 0xffff;
else
data[n] =
- readw(priv(dev)->main_iobase + PIPE1_READ_REG);
+ readw(priv(dev)->main_iobase + PIPE1_READ_REG);
}
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;
@@ -2046,8 +2099,7 @@ static int ai_config_block_size(struct comedi_device *dev, unsigned int *data)
if (requested_block_size) {
fifo_size =
- requested_block_size * fifo->num_segments /
- bytes_in_sample;
+ requested_block_size * fifo->num_segments / bytes_in_sample;
retval = set_ai_fifo_size(dev, fifo_size);
if (retval < 0)
@@ -2062,7 +2114,8 @@ 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;
@@ -2104,7 +2157,7 @@ static int ai_config_master_clock(struct comedi_device *dev, unsigned int *data)
}
static int ai_config_insn(struct comedi_device *dev, struct comedi_subdevice *s,
- struct comedi_insn *insn, unsigned int *data)
+ struct comedi_insn *insn, unsigned int *data)
{
int id = data[0];
@@ -2126,7 +2179,7 @@ static int ai_config_insn(struct comedi_device *dev, struct comedi_subdevice *s,
}
static int ai_cmdtest(struct comedi_device *dev, struct comedi_subdevice *s,
- struct comedi_cmd *cmd)
+ struct comedi_cmd *cmd)
{
int err = 0;
int tmp;
@@ -2181,21 +2234,21 @@ static int ai_cmdtest(struct comedi_device *dev, struct comedi_subdevice *s,
if (cmd->start_src != TRIG_NOW && cmd->start_src != TRIG_EXT)
err++;
if (cmd->scan_begin_src != TRIG_TIMER &&
- cmd->scan_begin_src != TRIG_OTHER &&
- cmd->scan_begin_src != TRIG_FOLLOW)
+ cmd->scan_begin_src != TRIG_OTHER &&
+ cmd->scan_begin_src != TRIG_FOLLOW)
err++;
if (cmd->convert_src != TRIG_TIMER &&
- cmd->convert_src != TRIG_EXT && cmd->convert_src != TRIG_NOW)
+ cmd->convert_src != TRIG_EXT && cmd->convert_src != TRIG_NOW)
err++;
if (cmd->stop_src != TRIG_COUNT &&
- cmd->stop_src != TRIG_NONE && cmd->stop_src != TRIG_EXT)
+ cmd->stop_src != TRIG_NONE && cmd->stop_src != TRIG_EXT)
err++;
/* compatibility check */
if (cmd->convert_src == TRIG_EXT && cmd->scan_begin_src == TRIG_TIMER)
err++;
if (cmd->stop_src != TRIG_COUNT &&
- cmd->stop_src != TRIG_NONE && cmd->stop_src != TRIG_EXT)
+ cmd->stop_src != TRIG_NONE && cmd->stop_src != TRIG_EXT)
err++;
if (err)
@@ -2217,10 +2270,10 @@ static int ai_cmdtest(struct comedi_device *dev, struct comedi_subdevice *s,
if (cmd->scan_begin_src == TRIG_TIMER) {
/* if scans are timed faster than conversion rate allows */
if (cmd->convert_arg * cmd->chanlist_len >
- cmd->scan_begin_arg) {
+ cmd->scan_begin_arg) {
cmd->scan_begin_arg =
- cmd->convert_arg *
- cmd->chanlist_len;
+ cmd->convert_arg *
+ cmd->chanlist_len;
err++;
}
}
@@ -2279,7 +2332,7 @@ static int ai_cmdtest(struct comedi_device *dev, struct comedi_subdevice *s,
for (i = 1; i < cmd->chanlist_len; i++) {
if (aref != CR_AREF(cmd->chanlist[i])) {
comedi_error(dev,
- "all elements in chanlist must use the same analog reference");
+ "all elements in chanlist must use the same analog reference");
err++;
break;
}
@@ -2289,16 +2342,16 @@ static int ai_cmdtest(struct comedi_device *dev, struct comedi_subdevice *s,
unsigned int first_channel = CR_CHAN(cmd->chanlist[0]);
for (i = 1; i < cmd->chanlist_len; i++) {
if (CR_CHAN(cmd->chanlist[i]) !=
- first_channel + i) {
+ first_channel + i) {
comedi_error(dev,
- "chanlist must use consecutive channels");
+ "chanlist must use consecutive channels");
err++;
break;
}
}
if (cmd->chanlist_len == 3) {
comedi_error(dev,
- "chanlist cannot be 3 channels long, use 1, 2, or 4 channels");
+ "chanlist cannot be 3 channels long, use 1, 2, or 4 channels");
err++;
}
}
@@ -2321,7 +2374,8 @@ 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 */
@@ -2330,9 +2384,9 @@ static void setup_sample_counters(struct comedi_device *dev, struct comedi_cmd *
/* load hardware conversion counter */
if (use_hw_sample_counter(cmd)) {
writew(cmd->stop_arg & 0xffff,
- priv(dev)->main_iobase + ADC_COUNT_LOWER_REG);
+ priv(dev)->main_iobase + ADC_COUNT_LOWER_REG);
writew((cmd->stop_arg >> 16) & 0xff,
- priv(dev)->main_iobase + ADC_COUNT_UPPER_REG);
+ priv(dev)->main_iobase + ADC_COUNT_UPPER_REG);
} else {
writew(1, priv(dev)->main_iobase + ADC_COUNT_LOWER_REG);
}
@@ -2343,8 +2397,8 @@ static inline unsigned int dma_transfer_size(struct comedi_device *dev)
unsigned int num_samples;
num_samples =
- priv(dev)->ai_fifo_segment_length *
- board(dev)->ai_fifo->sample_packing_ratio;
+ priv(dev)->ai_fifo_segment_length *
+ board(dev)->ai_fifo->sample_packing_ratio;
if (num_samples > DMA_BUFFER_SIZE / sizeof(uint16_t))
num_samples = DMA_BUFFER_SIZE / sizeof(uint16_t);
@@ -2360,12 +2414,12 @@ static void disable_ai_pacing(struct comedi_device *dev)
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);
+ priv(dev)->main_iobase + ADC_CONTROL1_REG);
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);
+ priv(dev)->main_iobase + ADC_CONTROL0_REG);
}
static void disable_ai_interrupts(struct comedi_device *dev)
@@ -2374,23 +2428,24 @@ static void disable_ai_interrupts(struct comedi_device *dev)
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;
+ ~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);
+ priv(dev)->main_iobase + INTR_ENABLE_REG);
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;
+ 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. */
if (cmd->flags & TRIG_WAKE_EOS) {
/* 4020 doesn't support pio transfers except for fifo dregs */
@@ -2400,27 +2455,28 @@ static void enable_ai_interrupts(struct comedi_device *dev, const struct comedi_
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);
+ priv(dev)->main_iobase + INTR_ENABLE_REG);
DEBUG_PRINT("intr enable bits 0x%x\n", priv(dev)->intr_enable_bits);
spin_unlock_irqrestore(&dev->spinlock, flags);
}
static uint32_t ai_convert_counter_6xxx(const struct comedi_device *dev,
- const struct comedi_cmd *cmd)
+ const struct comedi_cmd *cmd)
{
/* 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 */
switch (cmd->scan_begin_src) {
case TRIG_TIMER:
count = (cmd->scan_begin_arg -
- (cmd->convert_arg * (cmd->chanlist_len - 1)))
- / TIMER_BASE;
+ (cmd->convert_arg * (cmd->chanlist_len - 1)))
+ / TIMER_BASE;
break;
case TRIG_FOLLOW:
count = cmd->convert_arg / TIMER_BASE;
@@ -2432,7 +2488,8 @@ static uint32_t ai_scan_counter_6xxx(struct comedi_device *dev, struct comedi_cm
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;
@@ -2454,7 +2511,7 @@ static uint32_t ai_convert_counter_4020(struct comedi_device *dev, struct comedi
}
static void select_master_clock_4020(struct comedi_device *dev,
- const struct comedi_cmd *cmd)
+ const struct comedi_cmd *cmd)
{
/* select internal/external master clock */
priv(dev)->hw_config_bits &= ~MASTER_CLOCK_4020_MASK;
@@ -2469,10 +2526,11 @@ static void select_master_clock_4020(struct comedi_device *dev,
priv(dev)->hw_config_bits |= INTERNAL_CLOCK_4020_BITS;
}
writew(priv(dev)->hw_config_bits,
- priv(dev)->main_iobase + HW_CONFIG_REG);
+ 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:
@@ -2483,7 +2541,8 @@ static void select_master_clock(struct comedi_device *dev, const struct comedi_c
}
}
-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;
@@ -2491,12 +2550,12 @@ static inline void dma_start_sync(struct comedi_device *dev, unsigned int channe
spin_lock_irqsave(&dev->spinlock, flags);
if (channel)
writeb(PLX_DMA_EN_BIT | PLX_DMA_START_BIT |
- PLX_CLEAR_DMA_INTR_BIT,
- priv(dev)->plx9080_iobase + PLX_DMA1_CS_REG);
+ PLX_CLEAR_DMA_INTR_BIT,
+ priv(dev)->plx9080_iobase + PLX_DMA1_CS_REG);
else
writeb(PLX_DMA_EN_BIT | PLX_DMA_START_BIT |
- PLX_CLEAR_DMA_INTR_BIT,
- priv(dev)->plx9080_iobase + PLX_DMA0_CS_REG);
+ PLX_CLEAR_DMA_INTR_BIT,
+ priv(dev)->plx9080_iobase + PLX_DMA0_CS_REG);
spin_unlock_irqrestore(&dev->spinlock, flags);
}
@@ -2517,17 +2576,17 @@ static void set_ai_pacing(struct comedi_device *dev, struct comedi_cmd *cmd)
/* load lower 16 bits of convert interval */
writew(convert_counter & 0xffff,
- priv(dev)->main_iobase + ADC_SAMPLE_INTERVAL_LOWER_REG);
+ 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 */
writew((convert_counter >> 16) & 0xff,
- priv(dev)->main_iobase + ADC_SAMPLE_INTERVAL_UPPER_REG);
+ priv(dev)->main_iobase + ADC_SAMPLE_INTERVAL_UPPER_REG);
/* load lower 16 bits of scan delay */
writew(scan_counter & 0xffff,
- priv(dev)->main_iobase + ADC_DELAY_INTERVAL_LOWER_REG);
+ priv(dev)->main_iobase + ADC_DELAY_INTERVAL_LOWER_REG);
/* load upper 8 bits of scan delay */
writew((scan_counter >> 16) & 0xff,
- priv(dev)->main_iobase + ADC_DELAY_INTERVAL_UPPER_REG);
+ priv(dev)->main_iobase + ADC_DELAY_INTERVAL_UPPER_REG);
DEBUG_PRINT("scan counter 0x%x\n", scan_counter);
}
@@ -2536,10 +2595,10 @@ static int use_internal_queue_6xxx(const struct comedi_cmd *cmd)
int i;
for (i = 0; i + 1 < cmd->chanlist_len; i++) {
if (CR_CHAN(cmd->chanlist[i + 1]) !=
- CR_CHAN(cmd->chanlist[i]) + 1)
+ CR_CHAN(cmd->chanlist[i]) + 1)
return 0;
if (CR_RANGE(cmd->chanlist[i + 1]) !=
- CR_RANGE(cmd->chanlist[i]))
+ CR_RANGE(cmd->chanlist[i]))
return 0;
if (CR_AREF(cmd->chanlist[i + 1]) != CR_AREF(cmd->chanlist[i]))
return 0;
@@ -2547,7 +2606,8 @@ 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;
@@ -2556,25 +2616,26 @@ static int setup_channel_queue(struct comedi_device *dev, const struct comedi_cm
if (use_internal_queue_6xxx(cmd)) {
priv(dev)->hw_config_bits &= ~EXT_QUEUE_BIT;
writew(priv(dev)->hw_config_bits,
- priv(dev)->main_iobase + HW_CONFIG_REG);
+ priv(dev)->main_iobase + HW_CONFIG_REG);
bits = 0;
/* set channel */
bits |= adc_chan_bits(CR_CHAN(cmd->chanlist[0]));
/* set gain */
bits |= ai_range_bits_6xxx(dev,
- CR_RANGE(cmd->chanlist[0]));
+ CR_RANGE(cmd->chanlist[0]));
/* set single-ended / differential */
bits |= se_diff_bit_6xxx(dev,
- CR_AREF(cmd->chanlist[0]) == AREF_DIFF);
+ CR_AREF(cmd->chanlist[0]) ==
+ AREF_DIFF);
if (CR_AREF(cmd->chanlist[0]) == AREF_COMMON)
bits |= ADC_COMMON_BIT;
/* set stop channel */
- writew(adc_chan_bits(CR_CHAN(cmd->chanlist[cmd->
- chanlist_len - 1])),
- priv(dev)->main_iobase + ADC_QUEUE_HIGH_REG);
+ 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 */
writew(bits,
- priv(dev)->main_iobase + ADC_QUEUE_LOAD_REG);
+ priv(dev)->main_iobase + ADC_QUEUE_LOAD_REG);
} else {
/* use external queue */
if (dev->write_subdev && dev->write_subdev->busy) {
@@ -2583,36 +2644,40 @@ static int setup_channel_queue(struct comedi_device *dev, const struct comedi_cm
}
priv(dev)->hw_config_bits |= EXT_QUEUE_BIT;
writew(priv(dev)->hw_config_bits,
- priv(dev)->main_iobase + HW_CONFIG_REG);
+ priv(dev)->main_iobase + HW_CONFIG_REG);
/* clear DAC buffer to prevent weird interactions */
writew(0,
- priv(dev)->main_iobase + DAC_BUFFER_CLEAR_REG);
+ priv(dev)->main_iobase + DAC_BUFFER_CLEAR_REG);
/* clear queue pointer */
writew(0, priv(dev)->main_iobase + ADC_QUEUE_CLEAR_REG);
/* load external queue */
for (i = 0; i < cmd->chanlist_len; i++) {
bits = 0;
/* set channel */
- bits |= adc_chan_bits(CR_CHAN(cmd->
- chanlist[i]));
+ bits |=
+ adc_chan_bits(CR_CHAN(cmd->chanlist[i]));
/* set gain */
bits |= ai_range_bits_6xxx(dev,
- CR_RANGE(cmd->chanlist[i]));
+ CR_RANGE(cmd->
+ chanlist
+ [i]));
/* set single-ended / differential */
bits |= se_diff_bit_6xxx(dev,
- CR_AREF(cmd->chanlist[i]) == AREF_DIFF);
+ CR_AREF(cmd->
+ chanlist[i]) ==
+ AREF_DIFF);
if (CR_AREF(cmd->chanlist[i]) == AREF_COMMON)
bits |= ADC_COMMON_BIT;
/* mark end of queue */
if (i == cmd->chanlist_len - 1)
bits |= QUEUE_EOSCAN_BIT |
- QUEUE_EOSEQ_BIT;
+ QUEUE_EOSEQ_BIT;
writew(bits,
- priv(dev)->main_iobase +
- ADC_QUEUE_FIFO_REG);
+ priv(dev)->main_iobase +
+ ADC_QUEUE_FIFO_REG);
DEBUG_PRINT
- ("wrote 0x%x to external channel queue\n",
- bits);
+ ("wrote 0x%x to external channel queue\n",
+ bits);
}
/* doing a queue clear is not specified in board docs,
* but required for reliable operation */
@@ -2622,7 +2687,7 @@ static int setup_channel_queue(struct comedi_device *dev, const struct comedi_cm
}
} else {
unsigned short old_cal_range_bits =
- priv(dev)->i2c_cal_range_bits;
+ priv(dev)->i2c_cal_range_bits;
priv(dev)->i2c_cal_range_bits &= ~ADC_SRC_4020_MASK;
/* select BNC inputs */
@@ -2634,23 +2699,24 @@ static int setup_channel_queue(struct comedi_device *dev, const struct comedi_cm
if (range == 0)
priv(dev)->i2c_cal_range_bits |=
- attenuate_bit(channel);
+ attenuate_bit(channel);
else
priv(dev)->i2c_cal_range_bits &=
- ~attenuate_bit(channel);
+ ~attenuate_bit(channel);
}
/* 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,
- sizeof(i2c_data));
+ sizeof(i2c_data));
}
}
return 0;
}
static inline void load_first_dma_descriptor(struct comedi_device *dev,
- unsigned int dma_channel, unsigned int descriptor_bits)
+ unsigned int dma_channel,
+ unsigned int descriptor_bits)
{
/* The transfer size, pci address, and local address registers
* are supposedly unused during chained dma,
@@ -2659,20 +2725,20 @@ static inline void load_first_dma_descriptor(struct comedi_device *dev,
* block. Initializing them to zero seems to fix the problem. */
if (dma_channel) {
writel(0,
- priv(dev)->plx9080_iobase + PLX_DMA1_TRANSFER_SIZE_REG);
+ priv(dev)->plx9080_iobase + PLX_DMA1_TRANSFER_SIZE_REG);
writel(0, priv(dev)->plx9080_iobase + PLX_DMA1_PCI_ADDRESS_REG);
writel(0,
- priv(dev)->plx9080_iobase + PLX_DMA1_LOCAL_ADDRESS_REG);
+ priv(dev)->plx9080_iobase + PLX_DMA1_LOCAL_ADDRESS_REG);
writel(descriptor_bits,
- priv(dev)->plx9080_iobase + PLX_DMA1_DESCRIPTOR_REG);
+ priv(dev)->plx9080_iobase + PLX_DMA1_DESCRIPTOR_REG);
} else {
writel(0,
- priv(dev)->plx9080_iobase + PLX_DMA0_TRANSFER_SIZE_REG);
+ 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);
+ priv(dev)->plx9080_iobase + PLX_DMA0_LOCAL_ADDRESS_REG);
writel(descriptor_bits,
- priv(dev)->plx9080_iobase + PLX_DMA0_DESCRIPTOR_REG);
+ priv(dev)->plx9080_iobase + PLX_DMA0_DESCRIPTOR_REG);
}
}
@@ -2719,14 +2785,15 @@ static int ai_cmd(struct comedi_device *dev, struct comedi_subdevice *s)
priv(dev)->adc_control1_bits |= TWO_CHANNEL_4020_BITS;
priv(dev)->adc_control1_bits &= ~ADC_LO_CHANNEL_4020_MASK;
priv(dev)->adc_control1_bits |=
- adc_lo_chan_4020_bits(CR_CHAN(cmd->chanlist[0]));
+ adc_lo_chan_4020_bits(CR_CHAN(cmd->chanlist[0]));
priv(dev)->adc_control1_bits &= ~ADC_HI_CHANNEL_4020_MASK;
priv(dev)->adc_control1_bits |=
- adc_hi_chan_4020_bits(CR_CHAN(cmd->chanlist[cmd->
- chanlist_len - 1]));
+ adc_hi_chan_4020_bits(CR_CHAN
+ (cmd->
+ chanlist[cmd->chanlist_len - 1]));
}
writew(priv(dev)->adc_control1_bits,
- priv(dev)->main_iobase + ADC_CONTROL1_REG);
+ priv(dev)->main_iobase + ADC_CONTROL1_REG);
DEBUG_PRINT("control1 bits 0x%x\n", priv(dev)->adc_control1_bits);
spin_unlock_irqrestore(&dev->spinlock, flags);
@@ -2734,20 +2801,21 @@ static int ai_cmd(struct comedi_device *dev, struct comedi_subdevice *s)
writew(0, priv(dev)->main_iobase + ADC_BUFFER_CLEAR_REG);
if ((cmd->flags & TRIG_WAKE_EOS) == 0 ||
- board(dev)->layout == LAYOUT_4020) {
+ board(dev)->layout == LAYOUT_4020) {
priv(dev)->ai_dma_index = 0;
/* 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));
+ cpu_to_le32(dma_transfer_size(dev) *
+ sizeof(uint16_t));
/* give location of first dma descriptor */
load_first_dma_descriptor(dev, 1,
- priv(dev)->
- ai_dma_desc_bus_addr | PLX_DESC_IN_PCI_BIT |
- PLX_INTR_TERM_COUNT | PLX_XFER_LOCAL_TO_PCI);
+ priv(dev)->ai_dma_desc_bus_addr |
+ PLX_DESC_IN_PCI_BIT |
+ PLX_INTR_TERM_COUNT |
+ PLX_XFER_LOCAL_TO_PCI);
dma_start_sync(dev, 1);
}
@@ -2807,11 +2875,9 @@ static void pio_drain_ai_fifo_16(struct comedi_device *dev)
do {
/* get least significant 15 bits */
read_index =
- readw(priv(dev)->main_iobase +
- ADC_READ_PNTR_REG) & 0x7fff;
+ readw(priv(dev)->main_iobase + ADC_READ_PNTR_REG) & 0x7fff;
write_index =
- readw(priv(dev)->main_iobase +
- ADC_WRITE_PNTR_REG) & 0x7fff;
+ readw(priv(dev)->main_iobase + ADC_WRITE_PNTR_REG) & 0x7fff;
/* Get most significant bits (grey code). Different boards use different code
* so use a scheme that doesn't depend on encoding. This read must
* occur after reading least significant 15 bits to avoid race
@@ -2824,11 +2890,12 @@ static void pio_drain_ai_fifo_16(struct comedi_device *dev)
write_segment = adc_upper_write_ptr_code(prepost_bits);
DEBUG_PRINT(" rd seg %i, wrt seg %i, rd idx %i, wrt idx %i\n",
- read_segment, write_segment, read_index, write_index);
+ read_segment, write_segment, read_index,
+ write_index);
if (read_segment != write_segment)
num_samples =
- priv(dev)->ai_fifo_segment_length - read_index;
+ priv(dev)->ai_fifo_segment_length - read_index;
else
num_samples = write_index - read_index;
@@ -2850,7 +2917,8 @@ static void pio_drain_ai_fifo_16(struct comedi_device *dev)
for (i = 0; i < num_samples; i++) {
cfc_write_to_buffer(s,
- readw(priv(dev)->main_iobase + ADC_FIFO_REG));
+ readw(priv(dev)->main_iobase +
+ ADC_FIFO_REG));
}
} while (read_segment != write_segment);
@@ -2870,9 +2938,9 @@ static void pio_drain_ai_fifo_32(struct comedi_device *dev)
unsigned int max_transfer = 100000;
uint32_t fifo_data;
int write_code =
- readw(priv(dev)->main_iobase + ADC_WRITE_PNTR_REG) & 0x7fff;
+ readw(priv(dev)->main_iobase + ADC_WRITE_PNTR_REG) & 0x7fff;
int read_code =
- readw(priv(dev)->main_iobase + ADC_READ_PNTR_REG) & 0x7fff;
+ readw(priv(dev)->main_iobase + ADC_READ_PNTR_REG) & 0x7fff;
if (cmd->stop_src == TRIG_COUNT) {
if (max_transfer > priv(dev)->ai_count) {
@@ -2888,8 +2956,7 @@ static void pio_drain_ai_fifo_32(struct comedi_device *dev)
i++;
}
read_code =
- readw(priv(dev)->main_iobase +
- ADC_READ_PNTR_REG) & 0x7fff;
+ readw(priv(dev)->main_iobase + ADC_READ_PNTR_REG) & 0x7fff;
}
priv(dev)->ai_count -= i;
}
@@ -2913,19 +2980,18 @@ static void drain_dma_buffers(struct comedi_device *dev, unsigned int channel)
if (channel)
pci_addr_reg =
- priv(dev)->plx9080_iobase + PLX_DMA1_PCI_ADDRESS_REG;
+ priv(dev)->plx9080_iobase + PLX_DMA1_PCI_ADDRESS_REG;
else
pci_addr_reg =
- priv(dev)->plx9080_iobase + PLX_DMA0_PCI_ADDRESS_REG;
+ priv(dev)->plx9080_iobase + PLX_DMA0_PCI_ADDRESS_REG;
/* 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]
- || next_transfer_addr >=
- priv(dev)->ai_buffer_bus_addr[priv(dev)->ai_dma_index] +
- DMA_BUFFER_SIZE) && j < ai_dma_ring_count(board(dev));
- j++) {
+ (next_transfer_addr <
+ priv(dev)->ai_buffer_bus_addr[priv(dev)->ai_dma_index]
+ || next_transfer_addr >=
+ 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 */
num_samples = dma_transfer_size(dev);
if (async->cmd.stop_src == TRIG_COUNT) {
@@ -2934,15 +3000,16 @@ static void drain_dma_buffers(struct comedi_device *dev, unsigned int channel)
priv(dev)->ai_count -= num_samples;
}
cfc_write_array_to_buffer(dev->read_subdev,
- priv(dev)->ai_buffer[priv(dev)->ai_dma_index],
- num_samples * sizeof(uint16_t));
+ priv(dev)->ai_buffer[priv(dev)->
+ ai_dma_index],
+ num_samples * sizeof(uint16_t));
priv(dev)->ai_dma_index =
- (priv(dev)->ai_dma_index +
- 1) % ai_dma_ring_count(board(dev));
+ (priv(dev)->ai_dma_index +
+ 1) % ai_dma_ring_count(board(dev));
DEBUG_PRINT("next buffer addr 0x%lx\n",
- (unsigned long)priv(dev)->ai_buffer_bus_addr[priv(dev)->
- ai_dma_index]);
+ (unsigned long)priv(dev)->
+ ai_buffer_bus_addr[priv(dev)->ai_dma_index]);
DEBUG_PRINT("pci addr reg 0x%x\n", next_transfer_addr);
}
/* XXX check for dma ring buffer overrun (use end-of-chain bit to mark last
@@ -2950,7 +3017,7 @@ static void drain_dma_buffers(struct comedi_device *dev, unsigned int channel)
}
void handle_ai_interrupt(struct comedi_device *dev, unsigned short status,
- unsigned int plx_status)
+ unsigned int plx_status)
{
struct comedi_subdevice *s = dev->read_subdev;
struct comedi_async *async = s->async;
@@ -2968,7 +3035,7 @@ void handle_ai_interrupt(struct comedi_device *dev, unsigned short status,
dma1_status = readb(priv(dev)->plx9080_iobase + PLX_DMA1_CS_REG);
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);
+ priv(dev)->plx9080_iobase + PLX_DMA1_CS_REG);
DEBUG_PRINT("dma1 status 0x%x\n", dma1_status);
if (dma1_status & PLX_DMA_EN_BIT) {
@@ -2983,9 +3050,9 @@ void handle_ai_interrupt(struct comedi_device *dev, unsigned short status,
/* drain fifo with pio */
if ((status & ADC_DONE_BIT) ||
- ((cmd->flags & TRIG_WAKE_EOS) &&
- (status & ADC_INTR_PENDING_BIT) &&
- (board(dev)->layout != LAYOUT_4020))) {
+ ((cmd->flags & TRIG_WAKE_EOS) &&
+ (status & ADC_INTR_PENDING_BIT) &&
+ (board(dev)->layout != LAYOUT_4020))) {
DEBUG_PRINT("pio fifo drain\n");
spin_lock_irqsave(&dev->spinlock, flags);
if (priv(dev)->ai_cmd_running) {
@@ -2996,7 +3063,7 @@ void handle_ai_interrupt(struct comedi_device *dev, unsigned short status,
}
/* 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))) {
+ (cmd->stop_src == TRIG_EXT && (status & ADC_STOP_BIT))) {
async->events |= COMEDI_CB_EOA;
}
@@ -3026,14 +3093,15 @@ static int last_ao_dma_load_completed(struct comedi_device *dev)
return 0;
transfer_address =
- readl(priv(dev)->plx9080_iobase + PLX_DMA0_PCI_ADDRESS_REG);
+ readl(priv(dev)->plx9080_iobase + PLX_DMA0_PCI_ADDRESS_REG);
if (transfer_address != priv(dev)->ao_buffer_bus_addr[buffer_index])
return 0;
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;
@@ -3047,10 +3115,10 @@ static int ao_stopped_by_error(struct comedi_device *dev, const struct comedi_cm
}
static inline int ao_dma_needs_restart(struct comedi_device *dev,
- unsigned short dma_status)
+ unsigned short dma_status)
{
if ((dma_status & PLX_DMA_DONE_BIT) == 0 ||
- (dma_status & PLX_DMA_EN_BIT) == 0)
+ (dma_status & PLX_DMA_EN_BIT) == 0)
return 0;
if (last_ao_dma_load_completed(dev))
return 0;
@@ -3063,7 +3131,7 @@ static void restart_ao_dma(struct comedi_device *dev)
unsigned int dma_desc_bits;
dma_desc_bits =
- readl(priv(dev)->plx9080_iobase + PLX_DMA0_DESCRIPTOR_REG);
+ readl(priv(dev)->plx9080_iobase + PLX_DMA0_DESCRIPTOR_REG);
dma_desc_bits &= ~PLX_END_OF_CHAIN_BIT;
DEBUG_PRINT("restarting ao dma, descriptor reg 0x%x\n", dma_desc_bits);
load_first_dma_descriptor(dev, 0, dma_desc_bits);
@@ -3071,8 +3139,8 @@ 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,
- unsigned int plx_status)
+static void handle_ao_interrupt(struct comedi_device *dev,
+ unsigned short status, unsigned int plx_status)
{
struct comedi_subdevice *s = dev->write_subdev;
struct comedi_async *async;
@@ -3091,12 +3159,12 @@ static void handle_ao_interrupt(struct comedi_device *dev, unsigned short status
dma0_status = readb(priv(dev)->plx9080_iobase + PLX_DMA0_CS_REG);
if (plx_status & ICS_DMA0_A) { /* dma chan 0 interrupt */
if ((dma0_status & PLX_DMA_EN_BIT)
- && !(dma0_status & PLX_DMA_DONE_BIT))
+ && !(dma0_status & PLX_DMA_DONE_BIT))
writeb(PLX_DMA_EN_BIT | PLX_CLEAR_DMA_INTR_BIT,
- priv(dev)->plx9080_iobase + PLX_DMA0_CS_REG);
+ priv(dev)->plx9080_iobase + PLX_DMA0_CS_REG);
else
writeb(PLX_CLEAR_DMA_INTR_BIT,
- priv(dev)->plx9080_iobase + PLX_DMA0_CS_REG);
+ priv(dev)->plx9080_iobase + PLX_DMA0_CS_REG);
spin_unlock_irqrestore(&dev->spinlock, flags);
DEBUG_PRINT("dma0 status 0x%x\n", dma0_status);
if (dma0_status & PLX_DMA_EN_BIT) {
@@ -3114,11 +3182,11 @@ static void handle_ao_interrupt(struct comedi_device *dev, unsigned short status
if (ao_stopped_by_error(dev, cmd))
async->events |= COMEDI_CB_ERROR;
DEBUG_PRINT("plx dma0 desc reg 0x%x\n",
- readl(priv(dev)->plx9080_iobase +
- PLX_DMA0_DESCRIPTOR_REG));
+ readl(priv(dev)->plx9080_iobase +
+ PLX_DMA0_DESCRIPTOR_REG));
DEBUG_PRINT("plx dma0 address reg 0x%x\n",
- readl(priv(dev)->plx9080_iobase +
- PLX_DMA0_PCI_ADDRESS_REG));
+ readl(priv(dev)->plx9080_iobase +
+ PLX_DMA0_PCI_ADDRESS_REG));
}
cfc_handle_events(dev, s);
}
@@ -3141,7 +3209,7 @@ static irqreturn_t handle_interrupt(int irq, void *d)
* interrupt handler */
if (dev->attached == 0) {
DEBUG_PRINT("cb_pcidas64: premature interrupt, ignoring",
- status);
+ status);
return IRQ_HANDLED;
}
handle_ai_interrupt(dev, status, plx_status);
@@ -3192,7 +3260,7 @@ static int ai_cancel(struct comedi_device *dev, struct comedi_subdevice *s)
}
static int ao_winsn(struct comedi_device *dev, struct comedi_subdevice *s,
- struct comedi_insn *insn, unsigned int *data)
+ struct comedi_insn *insn, unsigned int *data)
{
int chan = CR_CHAN(insn->chanspec);
int range = CR_RANGE(insn->chanspec);
@@ -3203,14 +3271,14 @@ static int ao_winsn(struct comedi_device *dev, struct comedi_subdevice *s,
/* 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);
+ priv(dev)->main_iobase + DAC_CONTROL1_REG);
/* write to channel */
if (board(dev)->layout == LAYOUT_4020) {
writew(data[0] & 0xff,
- priv(dev)->main_iobase + dac_lsb_4020_reg(chan));
+ priv(dev)->main_iobase + dac_lsb_4020_reg(chan));
writew((data[0] >> 8) & 0xf,
- priv(dev)->main_iobase + dac_msb_4020_reg(chan));
+ priv(dev)->main_iobase + dac_msb_4020_reg(chan));
} else {
writew(data[0], priv(dev)->main_iobase + dac_convert_reg(chan));
}
@@ -3221,18 +3289,20 @@ static int ao_winsn(struct comedi_device *dev, struct comedi_subdevice *s,
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;
+ WAVEFORM_GATE_ENABLE_BIT | WAVEFORM_GATE_SELECT_BIT;
if (cmd->start_src == TRIG_EXT) {
bits |= WAVEFORM_TRIG_EXT_BITS;
@@ -3249,7 +3319,8 @@ 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;
@@ -3259,14 +3330,15 @@ static void set_dac_control1_reg(struct comedi_device *dev, const struct comedi_
channel = CR_CHAN(cmd->chanlist[i]);
range = CR_RANGE(cmd->chanlist[i]);
set_dac_range_bits(dev, &priv(dev)->dac_control1_bits, channel,
- range);
+ range);
}
priv(dev)->dac_control1_bits |= DAC_SW_GATE_BIT;
writew(priv(dev)->dac_control1_bits,
- priv(dev)->main_iobase + DAC_CONTROL1_REG);
+ 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;
@@ -3281,7 +3353,8 @@ static void set_dac_select_reg(struct comedi_device *dev, const struct comedi_cm
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;
@@ -3294,13 +3367,13 @@ static void set_dac_interval_regs(struct comedi_device *dev, const struct comedi
divisor = max_counter_value;
}
writew(divisor & 0xffff,
- priv(dev)->main_iobase + DAC_SAMPLE_INTERVAL_LOWER_REG);
+ priv(dev)->main_iobase + DAC_SAMPLE_INTERVAL_LOWER_REG);
writew((divisor >> 16) & 0xff,
- priv(dev)->main_iobase + DAC_SAMPLE_INTERVAL_UPPER_REG);
+ 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)
+ const struct comedi_cmd *cmd)
{
unsigned int num_bytes, buffer_index, prev_buffer_index;
unsigned int next_bits;
@@ -3309,7 +3382,7 @@ static unsigned int load_ao_dma_buffer(struct comedi_device *dev,
prev_buffer_index = prev_ao_dma_index(dev);
DEBUG_PRINT("attempting to load ao buffer %i (0x%x)\n", buffer_index,
- priv(dev)->ao_buffer_bus_addr[buffer_index]);
+ priv(dev)->ao_buffer_bus_addr[buffer_index]);
num_bytes = comedi_buf_read_n_available(dev->write_subdev->async);
if (num_bytes > DMA_BUFFER_SIZE)
@@ -3324,9 +3397,11 @@ static unsigned int load_ao_dma_buffer(struct comedi_device *dev,
DEBUG_PRINT("loading %i bytes\n", num_bytes);
num_bytes = cfc_read_array_from_buffer(dev->write_subdev,
- priv(dev)->ao_buffer[buffer_index], num_bytes);
+ priv(dev)->
+ ao_buffer[buffer_index],
+ num_bytes);
priv(dev)->ao_dma_desc[buffer_index].transfer_size =
- cpu_to_le32(num_bytes);
+ cpu_to_le32(num_bytes);
/* set end of chain bit so we catch underruns */
next_bits = le32_to_cpu(priv(dev)->ao_dma_desc[buffer_index].next);
next_bits |= PLX_END_OF_CHAIN_BIT;
@@ -3348,7 +3423,7 @@ static void load_ao_dma(struct comedi_device *dev, const struct comedi_cmd *cmd)
unsigned int num_bytes;
unsigned int next_transfer_addr;
void *pci_addr_reg =
- priv(dev)->plx9080_iobase + PLX_DMA0_PCI_ADDRESS_REG;
+ priv(dev)->plx9080_iobase + PLX_DMA0_PCI_ADDRESS_REG;
unsigned int buffer_index;
do {
@@ -3356,10 +3431,10 @@ static void load_ao_dma(struct comedi_device *dev, const struct comedi_cmd *cmd)
/* don't overwrite data that hasn't been transferred yet */
next_transfer_addr = readl(pci_addr_reg);
if (next_transfer_addr >=
- priv(dev)->ao_buffer_bus_addr[buffer_index]
- && next_transfer_addr <
- priv(dev)->ao_buffer_bus_addr[buffer_index] +
- DMA_BUFFER_SIZE)
+ priv(dev)->ao_buffer_bus_addr[buffer_index]
+ && next_transfer_addr <
+ priv(dev)->ao_buffer_bus_addr[buffer_index] +
+ DMA_BUFFER_SIZE)
return;
num_bytes = load_ao_dma_buffer(dev, cmd);
} while (num_bytes >= DMA_BUFFER_SIZE);
@@ -3377,13 +3452,14 @@ static int prep_ao_dma(struct comedi_device *dev, const struct comedi_cmd *cmd)
num_bytes = (DAC_FIFO_SIZE / 2) * bytes_in_sample;
if (cmd->stop_src == TRIG_COUNT &&
- num_bytes / bytes_in_sample > priv(dev)->ao_count)
+ num_bytes / bytes_in_sample > priv(dev)->ao_count)
num_bytes = priv(dev)->ao_count * bytes_in_sample;
num_bytes = cfc_read_array_from_buffer(dev->write_subdev,
- priv(dev)->ao_bounce_buffer, num_bytes);
+ priv(dev)->ao_bounce_buffer,
+ num_bytes);
for (i = 0; i < num_bytes / bytes_in_sample; i++) {
writew(priv(dev)->ao_bounce_buffer[i],
- priv(dev)->main_iobase + DAC_FIFO_REG);
+ priv(dev)->main_iobase + DAC_FIFO_REG);
}
priv(dev)->ao_count -= num_bytes / bytes_in_sample;
if (cmd->stop_src == TRIG_COUNT && priv(dev)->ao_count == 0)
@@ -3427,7 +3503,7 @@ static int ao_cmd(struct comedi_device *dev, struct comedi_subdevice *s)
set_dac_select_reg(dev, cmd);
set_dac_interval_regs(dev, cmd);
load_first_dma_descriptor(dev, 0, priv(dev)->ao_dma_desc_bus_addr |
- PLX_DESC_IN_PCI_BIT | PLX_INTR_TERM_COUNT);
+ PLX_DESC_IN_PCI_BIT | PLX_INTR_TERM_COUNT);
set_dac_control1_reg(dev, cmd);
s->async->inttrig = ao_inttrig;
@@ -3436,7 +3512,7 @@ static int ao_cmd(struct comedi_device *dev, struct comedi_subdevice *s)
}
static int ao_inttrig(struct comedi_device *dev, struct comedi_subdevice *s,
- unsigned int trig_num)
+ unsigned int trig_num)
{
struct comedi_cmd *cmd = &s->async->cmd;
int retval;
@@ -3459,7 +3535,7 @@ static int ao_inttrig(struct comedi_device *dev, struct comedi_subdevice *s,
}
static int ao_cmdtest(struct comedi_device *dev, struct comedi_subdevice *s,
- struct comedi_cmd *cmd)
+ struct comedi_cmd *cmd)
{
int err = 0;
int tmp;
@@ -3502,14 +3578,14 @@ static int ao_cmdtest(struct comedi_device *dev, struct comedi_subdevice *s,
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)
+ cmd->scan_begin_src != TRIG_EXT)
err++;
/* compatibility check */
if (cmd->convert_src == TRIG_EXT && cmd->scan_begin_src == TRIG_TIMER)
err++;
if (cmd->stop_src != TRIG_COUNT &&
- cmd->stop_src != TRIG_NONE && cmd->stop_src != TRIG_EXT)
+ cmd->stop_src != TRIG_NONE && cmd->stop_src != TRIG_EXT)
err++;
if (err)
@@ -3523,9 +3599,9 @@ static int ao_cmdtest(struct comedi_device *dev, struct comedi_subdevice *s,
err++;
}
if (get_ao_divisor(cmd->scan_begin_arg,
- cmd->flags) > max_counter_value) {
+ cmd->flags) > max_counter_value) {
cmd->scan_begin_arg =
- (max_counter_value + 2) * TIMER_BASE;
+ (max_counter_value + 2) * TIMER_BASE;
err++;
}
}
@@ -3547,8 +3623,7 @@ static int ao_cmdtest(struct comedi_device *dev, struct comedi_subdevice *s,
if (cmd->scan_begin_src == TRIG_TIMER) {
tmp_arg = cmd->scan_begin_arg;
cmd->scan_begin_arg =
- get_divisor(cmd->scan_begin_arg,
- cmd->flags) * TIMER_BASE;
+ get_divisor(cmd->scan_begin_arg, cmd->flags) * TIMER_BASE;
if (tmp_arg != cmd->scan_begin_arg)
err++;
}
@@ -3561,7 +3636,7 @@ static int ao_cmdtest(struct comedi_device *dev, struct comedi_subdevice *s,
for (i = 1; i < cmd->chanlist_len; i++) {
if (CR_CHAN(cmd->chanlist[i]) != first_channel + i) {
comedi_error(dev,
- "chanlist must use consecutive channels");
+ "chanlist must use consecutive channels");
err++;
break;
}
@@ -3603,7 +3678,7 @@ 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)
+ struct comedi_insn *insn, unsigned int *data)
{
unsigned int bits;
@@ -3616,7 +3691,7 @@ static int di_rbits(struct comedi_device *dev, struct comedi_subdevice *s,
}
static int do_wbits(struct comedi_device *dev, struct comedi_subdevice *s,
- struct comedi_insn *insn, unsigned int *data)
+ struct comedi_insn *insn, unsigned int *data)
{
data[0] &= 0xf;
/* zero bits we are going to change */
@@ -3631,8 +3706,9 @@ 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;
@@ -3653,19 +3729,19 @@ static int dio_60xx_config_insn(struct comedi_device *dev, struct comedi_subdevi
}
writeb(s->io_bits,
- priv(dev)->dio_counter_iobase + DIO_DIRECTION_60XX_REG);
+ priv(dev)->dio_counter_iobase + DIO_DIRECTION_60XX_REG);
return 1;
}
static int dio_60xx_wbits(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];
s->state |= (data[0] & data[1]);
writeb(s->state,
- priv(dev)->dio_counter_iobase + DIO_DATA_60XX_REG);
+ priv(dev)->dio_counter_iobase + DIO_DATA_60XX_REG);
}
data[1] = readb(priv(dev)->dio_counter_iobase + DIO_DATA_60XX_REG);
@@ -3674,7 +3750,7 @@ static int dio_60xx_wbits(struct comedi_device *dev, struct comedi_subdevice *s,
}
static void caldac_write(struct comedi_device *dev, unsigned int channel,
- unsigned int value)
+ unsigned int value)
{
priv(dev)->caldac_state[channel] = value;
@@ -3691,8 +3767,9 @@ 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);
@@ -3706,8 +3783,9 @@ 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);
@@ -3717,7 +3795,7 @@ static int calib_read_insn(struct comedi_device *dev, struct comedi_subdevice *s
}
static void ad8402_write(struct comedi_device *dev, unsigned int channel,
- unsigned int value)
+ unsigned int value)
{
static const int bitstream_length = 10;
unsigned int bit, register_bits;
@@ -3739,7 +3817,7 @@ static void ad8402_write(struct comedi_device *dev, unsigned int channel,
writew(register_bits, priv(dev)->main_iobase + CALIBRATION_REG);
udelay(ad8402_udelay);
writew(register_bits | SERIAL_CLOCK_BIT,
- priv(dev)->main_iobase + CALIBRATION_REG);
+ priv(dev)->main_iobase + CALIBRATION_REG);
}
udelay(ad8402_udelay);
@@ -3747,8 +3825,9 @@ static void ad8402_write(struct comedi_device *dev, unsigned int channel,
}
/* 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);
@@ -3764,8 +3843,9 @@ 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);
@@ -3781,7 +3861,7 @@ static uint16_t read_eeprom(struct comedi_device *dev, uint8_t address)
unsigned int bitstream = (read_command << 8) | address;
unsigned int bit;
void *const plx_control_addr =
- priv(dev)->plx9080_iobase + PLX_CONTROL_REG;
+ priv(dev)->plx9080_iobase + PLX_CONTROL_REG;
uint16_t value;
static const int value_length = 16;
static const int eeprom_udelay = 1;
@@ -3836,8 +3916,9 @@ static uint16_t read_eeprom(struct comedi_device *dev, uint8_t address)
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));
@@ -3853,7 +3934,7 @@ static void check_adc_timing(struct comedi_device *dev, struct comedi_cmd *cmd)
unsigned int convert_divisor = 0, scan_divisor;
static const int min_convert_divisor = 3;
static const int max_convert_divisor =
- max_counter_value + min_convert_divisor;
+ max_counter_value + min_convert_divisor;
static const int min_scan_divisor_4020 = 2;
unsigned long long max_scan_divisor, min_scan_divisor;
@@ -3862,7 +3943,7 @@ static void check_adc_timing(struct comedi_device *dev, struct comedi_cmd *cmd)
cmd->convert_arg = 0;
} else {
convert_divisor =
- get_divisor(cmd->convert_arg, cmd->flags);
+ get_divisor(cmd->convert_arg, cmd->flags);
if (convert_divisor > max_convert_divisor)
convert_divisor = max_convert_divisor;
if (convert_divisor < min_convert_divisor)
@@ -3878,8 +3959,8 @@ static void check_adc_timing(struct comedi_device *dev, struct comedi_cmd *cmd)
/* XXX check for integer overflows */
min_scan_divisor = convert_divisor * cmd->chanlist_len;
max_scan_divisor =
- (convert_divisor * cmd->chanlist_len - 1) +
- max_counter_value;
+ (convert_divisor * cmd->chanlist_len - 1) +
+ max_counter_value;
} else {
min_scan_divisor = min_scan_divisor_4020;
max_scan_divisor = max_counter_value + min_scan_divisor;
@@ -3931,7 +4012,8 @@ static int set_ai_fifo_size(struct comedi_device *dev, unsigned int num_samples)
num_fifo_entries = num_samples / fifo->sample_packing_ratio;
retval = set_ai_fifo_segment_length(dev,
- num_fifo_entries / fifo->num_segments);
+ num_fifo_entries /
+ fifo->num_segments);
if (retval < 0)
return retval;
@@ -3946,12 +4028,12 @@ static int set_ai_fifo_size(struct comedi_device *dev, unsigned int num_samples)
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;
+ board(dev)->ai_fifo->num_segments *
+ board(dev)->ai_fifo->sample_packing_ratio;
}
static int set_ai_fifo_segment_length(struct comedi_device *dev,
- unsigned int num_entries)
+ unsigned int num_entries)
{
static const int increment_size = 0x100;
const struct hw_fifo_info *const fifo = board(dev)->ai_fifo;
@@ -3970,12 +4052,12 @@ static int set_ai_fifo_segment_length(struct comedi_device *dev,
priv(dev)->fifo_size_bits &= ~fifo->fifo_size_reg_mask;
priv(dev)->fifo_size_bits |= bits;
writew(priv(dev)->fifo_size_bits,
- priv(dev)->main_iobase + FIFO_SIZE_REG);
+ priv(dev)->main_iobase + FIFO_SIZE_REG);
priv(dev)->ai_fifo_segment_length = num_increments * increment_size;
DEBUG_PRINT("set hardware fifo segment length to %i\n",
- priv(dev)->ai_fifo_segment_length);
+ priv(dev)->ai_fifo_segment_length);
return priv(dev)->ai_fifo_segment_length;
}
@@ -4002,7 +4084,7 @@ static int set_ai_fifo_segment_length(struct comedi_device *dev,
*/
static int caldac_8800_write(struct comedi_device *dev, unsigned int address,
- uint8_t value)
+ uint8_t value)
{
static const int num_caldac_channels = 8;
static const int bitstream_length = 11;
@@ -4033,8 +4115,8 @@ static int caldac_8800_write(struct comedi_device *dev, unsigned int address,
}
/* 4020 caldacs */
-static int caldac_i2c_write(struct comedi_device *dev, unsigned int caldac_channel,
- unsigned int value)
+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;
@@ -4108,8 +4190,8 @@ static void i2c_set_sda(struct comedi_device *dev, int state)
priv(dev)->plx_control_bits &= ~data_bit;
writel(priv(dev)->plx_control_bits, plx_control_addr);
udelay(i2c_high_udelay);
- } else /* set data line low */
- {
+ } else { /* set data line low */
+
priv(dev)->plx_control_bits |= data_bit;
writel(priv(dev)->plx_control_bits, plx_control_addr);
udelay(i2c_low_udelay);
@@ -4127,8 +4209,8 @@ static void i2c_set_scl(struct comedi_device *dev, int state)
priv(dev)->plx_control_bits &= ~clock_bit;
writel(priv(dev)->plx_control_bits, plx_control_addr);
udelay(i2c_high_udelay);
- } else /* set clock line low */
- {
+ } else { /* set clock line low */
+
priv(dev)->plx_control_bits |= clock_bit;
writel(priv(dev)->plx_control_bits, plx_control_addr);
udelay(i2c_low_udelay);
@@ -4180,7 +4262,7 @@ static void i2c_stop(struct comedi_device *dev)
}
static void i2c_write(struct comedi_device *dev, unsigned int address,
- const uint8_t *data, unsigned int length)
+ const uint8_t * data, unsigned int length)
{
unsigned int i;
uint8_t bitstream;
diff --git a/drivers/staging/comedi/drivers/cb_pcidda.c b/drivers/staging/comedi/drivers/cb_pcidda.c
index 8f3629416188..7a5d46ef1b77 100644
--- a/drivers/staging/comedi/drivers/cb_pcidda.c
+++ b/drivers/staging/comedi/drivers/cb_pcidda.c
@@ -115,13 +115,13 @@ Please report success/failure with other different cards to
static const struct comedi_lrange cb_pcidda_ranges = {
6,
{
- BIP_RANGE(10),
- BIP_RANGE(5),
- BIP_RANGE(2.5),
- UNI_RANGE(10),
- UNI_RANGE(5),
- UNI_RANGE(2.5),
- }
+ BIP_RANGE(10),
+ BIP_RANGE(5),
+ BIP_RANGE(2.5),
+ UNI_RANGE(10),
+ UNI_RANGE(5),
+ UNI_RANGE(2.5),
+ }
};
/*
@@ -147,63 +147,64 @@ struct cb_pcidda_board {
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,
+ },
};
static DEFINE_PCI_DEVICE_TABLE(cb_pcidda_pci_table) = {
- {PCI_VENDOR_ID_CB, 0x0020, PCI_ANY_ID, PCI_ANY_ID, 0, 0, 0},
- {PCI_VENDOR_ID_CB, 0x0021, PCI_ANY_ID, PCI_ANY_ID, 0, 0, 0},
- {PCI_VENDOR_ID_CB, 0x0022, PCI_ANY_ID, PCI_ANY_ID, 0, 0, 0},
- {PCI_VENDOR_ID_CB, 0x0023, PCI_ANY_ID, PCI_ANY_ID, 0, 0, 0},
- {PCI_VENDOR_ID_CB, 0x0024, PCI_ANY_ID, PCI_ANY_ID, 0, 0, 0},
- {PCI_VENDOR_ID_CB, 0x0025, PCI_ANY_ID, PCI_ANY_ID, 0, 0, 0},
- {0}
+ {
+ PCI_VENDOR_ID_CB, 0x0020, PCI_ANY_ID, PCI_ANY_ID, 0, 0, 0}, {
+ PCI_VENDOR_ID_CB, 0x0021, PCI_ANY_ID, PCI_ANY_ID, 0, 0, 0}, {
+ PCI_VENDOR_ID_CB, 0x0022, PCI_ANY_ID, PCI_ANY_ID, 0, 0, 0}, {
+ PCI_VENDOR_ID_CB, 0x0023, PCI_ANY_ID, PCI_ANY_ID, 0, 0, 0}, {
+ PCI_VENDOR_ID_CB, 0x0024, PCI_ANY_ID, PCI_ANY_ID, 0, 0, 0}, {
+ PCI_VENDOR_ID_CB, 0x0025, PCI_ANY_ID, PCI_ANY_ID, 0, 0, 0}, {
+ 0}
};
MODULE_DEVICE_TABLE(pci, cb_pcidda_pci_table);
@@ -239,11 +240,13 @@ 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_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_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); */
@@ -251,11 +254,11 @@ static int cb_pcidda_ao_winsn(struct comedi_device *dev, struct comedi_subdevice
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);
+ unsigned int num_bits);
static unsigned int cb_pcidda_read_eeprom(struct comedi_device *dev,
- unsigned int address);
+ unsigned int address);
static void cb_pcidda_calibrate(struct comedi_device *dev, unsigned int channel,
- unsigned int range);
+ unsigned int range);
/*
* The struct comedi_driver structure tells the Comedi core module
@@ -274,7 +277,8 @@ static struct comedi_driver driver_cb_pcidda = {
* 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;
@@ -294,29 +298,29 @@ static int cb_pcidda_attach(struct comedi_device *dev, struct comedi_devconfig *
printk("\n");
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)) {
+ pcidev != NULL;
+ pcidev = pci_get_device(PCI_ANY_ID, PCI_ANY_ID, pcidev)) {
if (pcidev->vendor == PCI_VENDOR_ID_CB) {
if (it->options[0] || it->options[1]) {
if (pcidev->bus->number != it->options[0] ||
- PCI_SLOT(pcidev->devfn) !=
- it->options[1]) {
+ PCI_SLOT(pcidev->devfn) != it->options[1]) {
continue;
}
}
for (index = 0; index < N_BOARDS; index++) {
if (cb_pcidda_boards[index].device_id ==
- pcidev->device) {
+ pcidev->device) {
goto found;
}
}
}
}
if (!pcidev) {
- printk("Not a ComputerBoards/MeasurementComputing card on requested position\n");
+ printk
+ ("Not a ComputerBoards/MeasurementComputing card on requested position\n");
return -EIO;
}
- found:
+found:
devpriv->pci_dev = pcidev;
dev->board_ptr = cb_pcidda_boards + index;
/* "thisboard" macro can be used from here. */
@@ -326,7 +330,8 @@ static int cb_pcidda_attach(struct comedi_device *dev, struct comedi_devconfig *
* Enable PCI device and request regions.
*/
if (comedi_pci_enable(pcidev, thisboard->name)) {
- printk("cb_pcidda: failed to enable PCI device and request regions\n");
+ printk
+ ("cb_pcidda: failed to enable PCI device and request regions\n");
return -EIO;
}
@@ -334,14 +339,17 @@ static int cb_pcidda_attach(struct comedi_device *dev, struct comedi_devconfig *
* Allocate the I/O ports.
*/
devpriv->digitalio =
- pci_resource_start(devpriv->pci_dev, DIGITALIO_BADRINDEX);
+ pci_resource_start(devpriv->pci_dev, DIGITALIO_BADRINDEX);
devpriv->dac = pci_resource_start(devpriv->pci_dev, DAC_BADRINDEX);
/*
* Warn about the status of the driver.
*/
if (thisboard->status == 2)
- printk("WARNING: DRIVER FOR THIS BOARD NOT CHECKED WITH MANUAL. " "WORKS ASSUMING FULL COMPATIBILITY WITH PCI-DDA08/12. " "PLEASE REPORT USAGE TO <ivanmr@altavista.com>.\n");
+ printk
+ ("WARNING: DRIVER FOR THIS BOARD NOT CHECKED WITH MANUAL. "
+ "WORKS ASSUMING FULL COMPATIBILITY WITH PCI-DDA08/12. "
+ "PLEASE REPORT USAGE TO <ivanmr@altavista.com>.\n");
/*
* Initialize dev->board_name.
@@ -423,7 +431,8 @@ 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);
@@ -442,8 +451,9 @@ 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;
@@ -489,7 +499,7 @@ static int cb_pcidda_ai_cmdtest(struct comedi_device *dev, struct comedi_subdevi
/* note that mutual compatiblity is not an issue here */
if (cmd->scan_begin_src != TRIG_TIMER
- && cmd->scan_begin_src != TRIG_EXT)
+ && cmd->scan_begin_src != TRIG_EXT)
err++;
if (cmd->convert_src != TRIG_TIMER && cmd->convert_src != TRIG_EXT)
err++;
@@ -569,21 +579,21 @@ static int cb_pcidda_ai_cmdtest(struct comedi_device *dev, struct comedi_subdevi
if (cmd->scan_begin_src == TRIG_TIMER) {
tmp = cmd->scan_begin_arg;
cb_pcidda_ns_to_timer(&cmd->scan_begin_arg,
- cmd->flags & TRIG_ROUND_MASK);
+ cmd->flags & TRIG_ROUND_MASK);
if (tmp != cmd->scan_begin_arg)
err++;
}
if (cmd->convert_src == TRIG_TIMER) {
tmp = cmd->convert_arg;
cb_pcidda_ns_to_timer(&cmd->convert_arg,
- cmd->flags & TRIG_ROUND_MASK);
+ cmd->flags & TRIG_ROUND_MASK);
if (tmp != cmd->convert_arg)
err++;
if (cmd->scan_begin_src == TRIG_TIMER &&
- cmd->scan_begin_arg <
- cmd->convert_arg * cmd->scan_end_arg) {
+ cmd->scan_begin_arg <
+ cmd->convert_arg * cmd->scan_end_arg) {
cmd->scan_begin_arg =
- cmd->convert_arg * cmd->scan_end_arg;
+ cmd->convert_arg * cmd->scan_end_arg;
err++;
}
}
@@ -608,8 +618,9 @@ 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;
@@ -676,7 +687,7 @@ static unsigned int cb_pcidda_serial_in(struct comedi_device *dev)
/* lowlevel write to eeprom/dac */
static void cb_pcidda_serial_out(struct comedi_device *dev, unsigned int value,
- unsigned int num_bits)
+ unsigned int num_bits)
{
int i;
@@ -692,7 +703,7 @@ 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,
- unsigned int address)
+ unsigned int address)
{
unsigned int i;
unsigned int cal2_bits;
@@ -725,8 +736,9 @@ static unsigned int cb_pcidda_read_eeprom(struct comedi_device *dev,
}
/* 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)
+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;
@@ -787,14 +799,14 @@ static unsigned int fine_offset_channel(unsigned int ao_channel)
/* 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)
+ unsigned int range)
{
return 0x7 + 2 * range + 12 * ao_channel;
}
/* 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)
+ unsigned int range)
{
return 0x8 + 2 * range + 12 * ao_channel;
}
@@ -813,7 +825,7 @@ static unsigned int eeprom_fine_byte(unsigned int word)
/* 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 range)
{
unsigned int coarse_offset, fine_offset, coarse_gain, fine_gain;
@@ -822,27 +834,27 @@ static void cb_pcidda_calibrate(struct comedi_device *dev, unsigned int channel,
/* get values from eeprom data */
coarse_offset =
- eeprom_coarse_byte(devpriv->
- eeprom_data[offset_eeprom_address(channel, range)]);
+ eeprom_coarse_byte(devpriv->eeprom_data
+ [offset_eeprom_address(channel, range)]);
fine_offset =
- eeprom_fine_byte(devpriv->
- eeprom_data[offset_eeprom_address(channel, range)]);
+ eeprom_fine_byte(devpriv->eeprom_data
+ [offset_eeprom_address(channel, range)]);
coarse_gain =
- eeprom_coarse_byte(devpriv->
- eeprom_data[gain_eeprom_address(channel, range)]);
+ eeprom_coarse_byte(devpriv->eeprom_data
+ [gain_eeprom_address(channel, range)]);
fine_gain =
- eeprom_fine_byte(devpriv->
- eeprom_data[gain_eeprom_address(channel, range)]);
+ eeprom_fine_byte(devpriv->eeprom_data
+ [gain_eeprom_address(channel, range)]);
/* set caldacs */
cb_pcidda_write_caldac(dev, caldac_number(channel),
- coarse_offset_channel(channel), coarse_offset);
+ coarse_offset_channel(channel), coarse_offset);
cb_pcidda_write_caldac(dev, caldac_number(channel),
- fine_offset_channel(channel), fine_offset);
+ fine_offset_channel(channel), fine_offset);
cb_pcidda_write_caldac(dev, caldac_number(channel),
- coarse_gain_channel(channel), coarse_gain);
+ coarse_gain_channel(channel), coarse_gain);
cb_pcidda_write_caldac(dev, caldac_number(channel),
- fine_gain_channel(channel), fine_gain);
+ fine_gain_channel(channel), fine_gain);
}
/*
diff --git a/drivers/staging/comedi/drivers/cb_pcidio.c b/drivers/staging/comedi/drivers/cb_pcidio.c
index dc701273167c..4d10bc31d461 100644
--- a/drivers/staging/comedi/drivers/cb_pcidio.c
+++ b/drivers/staging/comedi/drivers/cb_pcidio.c
@@ -63,23 +63,23 @@ struct pcidio_board {
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,
+ },
};
/* This is used by modprobe to translate PCI IDs to drivers. Should
@@ -87,10 +87,11 @@ static const struct pcidio_board pcidio_boards[] = {
/* Please add your PCI vendor ID to comedidev.h, and it will be forwarded
* upstream. */
static DEFINE_PCI_DEVICE_TABLE(pcidio_pci_table) = {
- {PCI_VENDOR_ID_CB, 0x0028, PCI_ANY_ID, PCI_ANY_ID, 0, 0, 0},
- {PCI_VENDOR_ID_CB, 0x0014, PCI_ANY_ID, PCI_ANY_ID, 0, 0, 0},
- {PCI_VENDOR_ID_CB, 0x000b, PCI_ANY_ID, PCI_ANY_ID, 0, 0, 0},
- {0}
+ {
+ PCI_VENDOR_ID_CB, 0x0028, PCI_ANY_ID, PCI_ANY_ID, 0, 0, 0}, {
+ PCI_VENDOR_ID_CB, 0x0014, PCI_ANY_ID, PCI_ANY_ID, 0, 0, 0}, {
+ PCI_VENDOR_ID_CB, 0x000b, PCI_ANY_ID, PCI_ANY_ID, 0, 0, 0}, {
+ 0}
};
MODULE_DEVICE_TABLE(pci, pcidio_pci_table);
@@ -127,7 +128,8 @@ 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_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",
@@ -197,15 +199,13 @@ static int pcidio_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)) {
+ pcidev != NULL;
+ pcidev = pci_get_device(PCI_ANY_ID, PCI_ANY_ID, pcidev)) {
/* 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 < ARRAY_SIZE(pcidio_boards);
- index++) {
+ for (index = 0; index < ARRAY_SIZE(pcidio_boards); index++) {
if (pcidio_pci_table[index].device != pcidev->device)
continue;
@@ -213,8 +213,7 @@ static int pcidio_attach(struct comedi_device *dev, struct comedi_devconfig *it)
if (it->options[0] || it->options[1]) {
/* are we on the wrong bus/slot? */
if (pcidev->bus->number != it->options[0] ||
- PCI_SLOT(pcidev->devfn) !=
- it->options[1]) {
+ PCI_SLOT(pcidev->devfn) != it->options[1]) {
continue;
}
}
@@ -224,10 +223,10 @@ static int pcidio_attach(struct comedi_device *dev, struct comedi_devconfig *it)
}
printk("No supported ComputerBoards/MeasurementComputing card found on "
- "requested position\n");
+ "requested position\n");
return -EIO;
- found:
+found:
/*
* Initialize dev->board_name. Note that we can use the "thisboard"
@@ -237,16 +236,17 @@ static int pcidio_attach(struct comedi_device *dev, struct comedi_devconfig *it)
devpriv->pci_dev = pcidev;
printk("Found %s on bus %i, slot %i\n", thisboard->name,
- devpriv->pci_dev->bus->number,
- PCI_SLOT(devpriv->pci_dev->devfn));
+ devpriv->pci_dev->bus->number,
+ PCI_SLOT(devpriv->pci_dev->devfn));
if (comedi_pci_enable(pcidev, thisboard->name)) {
- printk("cb_pcidio: failed to enable PCI device and request regions\n");
+ printk
+ ("cb_pcidio: failed to enable PCI device and request regions\n");
return -EIO;
}
devpriv->dio_reg_base
- =
- pci_resource_start(devpriv->pci_dev,
- pcidio_boards[index].dioregs_badrindex);
+ =
+ pci_resource_start(devpriv->pci_dev,
+ pcidio_boards[index].dioregs_badrindex);
/*
* Allocate the subdevice structures. alloc_subdevice() is a
@@ -257,9 +257,9 @@ static int pcidio_attach(struct comedi_device *dev, struct comedi_devconfig *it)
for (i = 0; i < thisboard->n_8255; i++) {
subdev_8255_init(dev, dev->subdevices + i,
- NULL, devpriv->dio_reg_base + i * 4);
+ NULL, devpriv->dio_reg_base + i * 4);
printk(" subdev %d: base = 0x%lx\n", i,
- devpriv->dio_reg_base + i * 4);
+ devpriv->dio_reg_base + i * 4);
}
printk("attached\n");
diff --git a/drivers/staging/comedi/drivers/cb_pcimdas.c b/drivers/staging/comedi/drivers/cb_pcimdas.c
index 57d250c73abc..cbbca05acb96 100644
--- a/drivers/staging/comedi/drivers/cb_pcimdas.c
+++ b/drivers/staging/comedi/drivers/cb_pcimdas.c
@@ -103,29 +103,31 @@ struct cb_pcimdas_board {
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,
+ .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, */
- },
+ },
};
/* 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(cb_pcimdas_pci_table) = {
- {PCI_VENDOR_ID_COMPUTERBOARDS, 0x0056, PCI_ANY_ID, PCI_ANY_ID, 0, 0, 0},
- {0}
+ {
+ PCI_VENDOR_ID_COMPUTERBOARDS, 0x0056, PCI_ANY_ID, PCI_ANY_ID, 0, 0, 0},
+ {
+ 0}
};
MODULE_DEVICE_TABLE(pci, cb_pcimdas_pci_table);
@@ -176,7 +178,8 @@ 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_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",
@@ -185,12 +188,15 @@ static struct comedi_driver driver_cb_pcimdas = {
.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
@@ -198,7 +204,8 @@ static int cb_pcimdas_ao_rinsn(struct comedi_device *dev, struct comedi_subdevic
* 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;
@@ -219,22 +226,21 @@ static int cb_pcimdas_attach(struct comedi_device *dev, struct comedi_devconfig
printk("\n");
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)) {
+ pcidev != NULL;
+ pcidev = pci_get_device(PCI_ANY_ID, PCI_ANY_ID, pcidev)) {
/* 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++) {
if (cb_pcimdas_boards[index].device_id !=
- pcidev->device)
+ pcidev->device)
continue;
/* was a particular bus/slot requested? */
if (it->options[0] || it->options[1]) {
/* are we on the wrong bus/slot? */
if (pcidev->bus->number != it->options[0] ||
- PCI_SLOT(pcidev->devfn) !=
- it->options[1]) {
+ PCI_SLOT(pcidev->devfn) != it->options[1]) {
continue;
}
}
@@ -245,13 +251,13 @@ static int cb_pcimdas_attach(struct comedi_device *dev, struct comedi_devconfig
}
printk("No supported ComputerBoards/MeasurementComputing card found on "
- "requested position\n");
+ "requested position\n");
return -EIO;
- found:
+found:
printk("Found %s on bus %i, slot %i\n", cb_pcimdas_boards[index].name,
- pcidev->bus->number, PCI_SLOT(pcidev->devfn));
+ pcidev->bus->number, PCI_SLOT(pcidev->devfn));
/* Warn about non-tested features */
switch (thisboard->device_id) {
@@ -259,7 +265,7 @@ static int cb_pcimdas_attach(struct comedi_device *dev, struct comedi_devconfig
break;
default:
printk("THIS CARD IS UNSUPPORTED.\n"
- "PLEASE REPORT USAGE TO <mocelet@sucs.org>\n");
+ "PLEASE REPORT USAGE TO <mocelet@sucs.org>\n");
};
if (comedi_pci_enable(pcidev, "cb_pcimdas")) {
@@ -373,8 +379,9 @@ 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;
@@ -438,8 +445,9 @@ static int cb_pcimdas_ai_rinsn(struct comedi_device *dev, struct comedi_subdevic
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);
@@ -466,8 +474,9 @@ static int cb_pcimdas_ao_winsn(struct comedi_device *dev, struct comedi_subdevic
/* 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 57bb1182480d..980fa0aacf92 100644
--- a/drivers/staging/comedi/drivers/cb_pcimdda.c
+++ b/drivers/staging/comedi/drivers/cb_pcimdda.c
@@ -118,16 +118,16 @@ 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,
+ }
};
/*
@@ -143,9 +143,10 @@ static const struct board_struct boards[] = {
/* Please add your PCI vendor ID to comedidev.h, and it will be forwarded
* upstream. */
static DEFINE_PCI_DEVICE_TABLE(pci_table) = {
- {PCI_VENDOR_ID_COMPUTERBOARDS, PCI_ID_PCIM_DDA06_16, PCI_ANY_ID,
- PCI_ANY_ID, 0, 0, 0},
- {0}
+ {
+ PCI_VENDOR_ID_COMPUTERBOARDS, PCI_ID_PCIM_DDA06_16, PCI_ANY_ID,
+ PCI_ANY_ID, 0, 0, 0}, {
+ 0}
};
MODULE_DEVICE_TABLE(pci, pci_table);
@@ -190,15 +191,15 @@ static struct comedi_driver cb_pcimdda_driver = {
MODULE_AUTHOR("Calin A. Culianu <calin@rtlab.org>");
MODULE_DESCRIPTION("Comedi low-level driver for the Computerboards PCIM-DDA "
- "series. Currently only supports PCIM-DDA06-16 (which "
- "also happens to be the only board in this series. :) ) ");
+ "series. Currently only supports PCIM-DDA06-16 (which "
+ "also happens to be the only board in this series. :) ) ");
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);
+ 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);
+ struct comedi_insn *insn, unsigned int *data);
/*---------------------------------------------------------------------------
HELPER FUNCTION DECLARATIONS
@@ -207,7 +208,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;
}
/*
@@ -344,7 +345,7 @@ static int detach(struct comedi_device *dev)
if (devpriv->attached_successfully && thisboard)
printk("comedi%d: %s: detached\n", dev->minor,
- thisboard->name);
+ thisboard->name);
}
@@ -352,7 +353,7 @@ static int detach(struct comedi_device *dev)
}
static int ao_winsn(struct comedi_device *dev, struct comedi_subdevice *s,
- struct comedi_insn *insn, unsigned int *data)
+ struct comedi_insn *insn, unsigned int *data)
{
int i;
int chan = CR_CHAN(insn->chanspec);
@@ -391,7 +392,7 @@ static int ao_winsn(struct comedi_device *dev, struct comedi_subdevice *s,
applications, I would imagine.
*/
static int ao_rinsn(struct comedi_device *dev, struct comedi_subdevice *s,
- struct comedi_insn *insn, unsigned int *data)
+ struct comedi_insn *insn, unsigned int *data)
{
int i;
int chan = CR_CHAN(insn->chanspec);
@@ -431,8 +432,8 @@ static int probe(struct comedi_device *dev, const struct comedi_devconfig *it)
unsigned long registers;
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)) {
+ pcidev != NULL;
+ pcidev = pci_get_device(PCI_ANY_ID, PCI_ANY_ID, pcidev)) {
/* is it not a computer boards card? */
if (pcidev->vendor != PCI_VENDOR_ID_COMPUTERBOARDS)
continue;
@@ -444,8 +445,7 @@ static int probe(struct comedi_device *dev, const struct comedi_devconfig *it)
if (it->options[0] || it->options[1]) {
/* are we on the wrong bus/slot? */
if (pcidev->bus->number != it->options[0] ||
- PCI_SLOT(pcidev->devfn) !=
- it->options[1]) {
+ PCI_SLOT(pcidev->devfn) != it->options[1]) {
continue;
}
}
@@ -454,20 +454,21 @@ static int probe(struct comedi_device *dev, const struct comedi_devconfig *it)
devpriv->pci_dev = pcidev;
dev->board_ptr = boards + index;
if (comedi_pci_enable(pcidev, thisboard->name)) {
- printk("cb_pcimdda: Failed to enable PCI device and request regions\n");
+ printk
+ ("cb_pcimdda: Failed to enable PCI device and request regions\n");
return -EIO;
}
registers =
- pci_resource_start(devpriv->pci_dev,
- REGS_BADRINDEX);
+ pci_resource_start(devpriv->pci_dev,
+ REGS_BADRINDEX);
devpriv->registers = registers;
devpriv->dio_registers
- = devpriv->registers + thisboard->dio_offset;
+ = devpriv->registers + thisboard->dio_offset;
return 0;
}
}
printk("cb_pcimdda: No supported ComputerBoards/MeasurementComputing "
- "card found at the requested position\n");
+ "card found at the requested position\n");
return -ENODEV;
}
diff --git a/drivers/staging/comedi/drivers/comedi_bond.c b/drivers/staging/comedi/drivers/comedi_bond.c
index 45cd41f7fd29..cf39a24ddd4c 100644
--- a/drivers/staging/comedi/drivers/comedi_bond.c
+++ b/drivers/staging/comedi/drivers/comedi_bond.c
@@ -132,8 +132,8 @@ struct BondingBoard {
static const struct BondingBoard bondingBoards[] = {
{
- .name = MODULE_NAME,
- },
+ .name = MODULE_NAME,
+ },
};
/*
@@ -176,7 +176,8 @@ struct Private {
* the board, and also about the kernel module that contains
* the device code.
*/
-static int bonding_attach(struct comedi_device *dev, struct comedi_devconfig *it);
+static int bonding_attach(struct comedi_device *dev,
+ struct comedi_devconfig *it);
static int bonding_detach(struct comedi_device *dev);
/** Build Private array of all devices.. */
static int doDevConfig(struct comedi_device *dev, struct comedi_devconfig *it);
@@ -186,10 +187,10 @@ static void doDevUnconfig(struct comedi_device *dev);
static void *Realloc(const void *ptr, size_t len, size_t old_len);
static struct comedi_driver driver_bonding = {
- .driver_name = MODULE_NAME,
- .module = THIS_MODULE,
- .attach = bonding_attach,
- .detach = bonding_detach,
+ .driver_name = MODULE_NAME,
+ .module = THIS_MODULE,
+ .attach = bonding_attach,
+ .detach = bonding_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
@@ -208,15 +209,18 @@ static struct comedi_driver driver_bonding = {
* the type of board in software. ISA PnP, PCI, and PCMCIA
* devices are such boards.
*/
- .board_name = &bondingBoards[0].name,
- .offset = sizeof(struct BondingBoard),
- .num_names = ARRAY_SIZE(bondingBoards),
+ .board_name = &bondingBoards[0].name,
+ .offset = sizeof(struct BondingBoard),
+ .num_names = ARRAY_SIZE(bondingBoards),
};
-static int bonding_dio_insn_bits(struct comedi_device *dev, struct comedi_subdevice *s,
+static int bonding_dio_insn_bits(struct comedi_device *dev,
+ struct comedi_subdevice *s,
struct comedi_insn *insn, unsigned int *data);
-static int bonding_dio_insn_config(struct comedi_device *dev, struct comedi_subdevice *s,
- struct comedi_insn *insn, unsigned int *data);
+static int bonding_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
@@ -224,7 +228,8 @@ static int bonding_dio_insn_config(struct comedi_device *dev, struct comedi_subd
* in the driver structure, dev->board_ptr contains that
* address.
*/
-static int bonding_attach(struct comedi_device *dev, struct comedi_devconfig *it)
+static int bonding_attach(struct comedi_device *dev,
+ struct comedi_devconfig *it)
{
struct comedi_subdevice *s;
@@ -293,7 +298,8 @@ static int bonding_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 bonding_dio_insn_bits(struct comedi_device *dev, struct comedi_subdevice *s,
+static int bonding_dio_insn_bits(struct comedi_device *dev,
+ struct comedi_subdevice *s,
struct comedi_insn *insn, unsigned int *data)
{
#define LSAMPL_BITS (sizeof(unsigned int)*8)
@@ -317,14 +323,14 @@ static int bonding_dio_insn_bits(struct comedi_device *dev, struct comedi_subdev
/* Argh, we have >= LSAMPL_BITS chans.. take all bits */
if (bdev->nchans >= LSAMPL_BITS)
- subdevMask = (unsigned int) (-1);
+ subdevMask = (unsigned int)(-1);
writeMask = (data[0] >> num_done) & subdevMask;
dataBits = (data[1] >> num_done) & subdevMask;
/* Read/Write the new digital lines */
if (comedi_dio_bitfield(bdev->dev, bdev->subdev, writeMask,
- &dataBits) != 2)
+ &dataBits) != 2)
return -EINVAL;
/* Make room for the new bits in data[1], the return value */
@@ -340,7 +346,8 @@ static int bonding_dio_insn_bits(struct comedi_device *dev, struct comedi_subdev
return insn->n;
}
-static int bonding_dio_insn_config(struct comedi_device *dev, struct comedi_subdevice *s,
+static int bonding_dio_insn_config(struct comedi_device *dev,
+ struct comedi_subdevice *s,
struct comedi_insn *insn, unsigned int *data)
{
int chan = CR_CHAN(insn->chanspec), ret, io_bits = s->io_bits;
@@ -366,7 +373,7 @@ static int bonding_dio_insn_config(struct comedi_device *dev, struct comedi_subd
break;
case INSN_CONFIG_DIO_QUERY:
data[1] =
- (io_bits & (1 << chan)) ? COMEDI_OUTPUT : COMEDI_INPUT;
+ (io_bits & (1 << chan)) ? COMEDI_OUTPUT : COMEDI_INPUT;
return insn->n;
break;
default:
@@ -435,7 +442,7 @@ static int doDevConfig(struct comedi_device *dev, struct comedi_devconfig *it)
/* Do DIO, as that's all we support now.. */
while ((sdev = comedi_find_subdevice_by_type(d, COMEDI_SUBD_DIO,
- sdev + 1)) > -1) {
+ sdev + 1)) > -1) {
nchans = comedi_get_n_channels(d, sdev);
if (nchans <= 0) {
ERROR("comedi_get_n_channels() returned %d "
@@ -465,8 +472,8 @@ static int doDevConfig(struct comedi_device *dev, struct comedi_devconfig *it)
/* ergh.. ugly.. we need to realloc :( */
tmp = devpriv->ndevs * sizeof(bdev);
devpriv->devs =
- Realloc(devpriv->devs,
- ++devpriv->ndevs * sizeof(bdev), tmp);
+ Realloc(devpriv->devs,
+ ++devpriv->ndevs * sizeof(bdev), tmp);
if (!devpriv->devs) {
ERROR("Could not allocate memory. "
"Out of memory?");
@@ -478,10 +485,9 @@ static int doDevConfig(struct comedi_device *dev, struct comedi_devconfig *it)
/** Append dev:subdev to devpriv->name */
char buf[20];
int left =
- MAX_BOARD_NAME - strlen(devpriv->name) -
- 1;
+ MAX_BOARD_NAME - strlen(devpriv->name) - 1;
snprintf(buf, sizeof(buf), "%d:%d ", dev->minor,
- bdev->subdev);
+ bdev->subdev);
buf[sizeof(buf) - 1] = 0;
strncat(devpriv->name, buf, left);
}
diff --git a/drivers/staging/comedi/drivers/comedi_fc.c b/drivers/staging/comedi/drivers/comedi_fc.c
index 8ab8e733afb6..f781154734ad 100644
--- a/drivers/staging/comedi/drivers/comedi_fc.c
+++ b/drivers/staging/comedi/drivers/comedi_fc.c
@@ -42,8 +42,8 @@ static void increment_scan_progress(struct comedi_subdevice *subd,
}
/* Writes an array of data points to comedi's buffer */
-unsigned int cfc_write_array_to_buffer(struct comedi_subdevice *subd, void *data,
- unsigned int num_bytes)
+unsigned int cfc_write_array_to_buffer(struct comedi_subdevice *subd,
+ void *data, unsigned int num_bytes)
{
struct comedi_async *async = subd->async;
unsigned int retval;
@@ -65,10 +65,11 @@ unsigned int cfc_write_array_to_buffer(struct comedi_subdevice *subd, void *data
return num_bytes;
}
+
EXPORT_SYMBOL(cfc_write_array_to_buffer);
-unsigned int cfc_read_array_from_buffer(struct comedi_subdevice *subd, void *data,
- unsigned int num_bytes)
+unsigned int cfc_read_array_from_buffer(struct comedi_subdevice *subd,
+ void *data, unsigned int num_bytes)
{
struct comedi_async *async = subd->async;
@@ -83,9 +84,11 @@ unsigned int cfc_read_array_from_buffer(struct comedi_subdevice *subd, void *dat
return num_bytes;
}
+
EXPORT_SYMBOL(cfc_read_array_from_buffer);
-unsigned int cfc_handle_events(struct comedi_device *dev, struct comedi_subdevice *subd)
+unsigned int cfc_handle_events(struct comedi_device *dev,
+ struct comedi_subdevice *subd)
{
unsigned int events = subd->async->events;
@@ -99,6 +102,7 @@ unsigned int cfc_handle_events(struct comedi_device *dev, struct comedi_subdevic
return events;
}
+
EXPORT_SYMBOL(cfc_handle_events);
MODULE_AUTHOR("Frank Mori Hess <fmhess@users.sourceforge.net>");
diff --git a/drivers/staging/comedi/drivers/comedi_fc.h b/drivers/staging/comedi/drivers/comedi_fc.h
index 494ae3f2aff6..4b2cfd327995 100644
--- a/drivers/staging/comedi/drivers/comedi_fc.h
+++ b/drivers/staging/comedi/drivers/comedi_fc.h
@@ -40,8 +40,8 @@ static inline unsigned int cfc_write_to_buffer(struct comedi_subdevice *subd,
return cfc_write_array_to_buffer(subd, &data, sizeof(data));
};
-static inline unsigned int cfc_write_long_to_buffer(struct comedi_subdevice *subd,
- unsigned int data)
+static inline unsigned int cfc_write_long_to_buffer(struct comedi_subdevice
+ *subd, unsigned int data)
{
return cfc_write_array_to_buffer(subd, &data, sizeof(data));
};
diff --git a/drivers/staging/comedi/drivers/comedi_parport.c b/drivers/staging/comedi/drivers/comedi_parport.c
index f42897de640e..043afe4439c7 100644
--- a/drivers/staging/comedi/drivers/comedi_parport.c
+++ b/drivers/staging/comedi/drivers/comedi_parport.c
@@ -91,13 +91,14 @@ pin, which can be used to wake up tasks.
#define PARPORT_B 1
#define PARPORT_C 2
-static int parport_attach(struct comedi_device *dev, struct comedi_devconfig *it);
+static int parport_attach(struct comedi_device *dev,
+ struct comedi_devconfig *it);
static int parport_detach(struct comedi_device *dev);
static struct comedi_driver driver_parport = {
- .driver_name = "comedi_parport",
- .module = THIS_MODULE,
- .attach = parport_attach,
- .detach = parport_detach,
+ .driver_name = "comedi_parport",
+ .module = THIS_MODULE,
+ .attach = parport_attach,
+ .detach = parport_detach,
};
COMEDI_INITCLEANUP(driver_parport);
@@ -124,7 +125,8 @@ static int parport_insn_a(struct comedi_device *dev, struct comedi_subdevice *s,
return 2;
}
-static int parport_insn_config_a(struct comedi_device *dev, struct comedi_subdevice *s,
+static int parport_insn_config_a(struct comedi_device *dev,
+ struct comedi_subdevice *s,
struct comedi_insn *insn, unsigned int *data)
{
if (data[0]) {
@@ -168,7 +170,8 @@ static int parport_insn_c(struct comedi_device *dev, struct comedi_subdevice *s,
return 2;
}
-static int parport_intr_insn(struct comedi_device *dev, struct comedi_subdevice *s,
+static int parport_intr_insn(struct comedi_device *dev,
+ struct comedi_subdevice *s,
struct comedi_insn *insn, unsigned int *data)
{
if (insn->n < 1)
@@ -178,7 +181,8 @@ static int parport_intr_insn(struct comedi_device *dev, struct comedi_subdevice
return 2;
}
-static int parport_intr_cmdtest(struct comedi_device *dev, struct comedi_subdevice *s,
+static int parport_intr_cmdtest(struct comedi_device *dev,
+ struct comedi_subdevice *s,
struct comedi_cmd *cmd)
{
int err = 0;
@@ -253,7 +257,8 @@ static int parport_intr_cmdtest(struct comedi_device *dev, struct comedi_subdevi
return 0;
}
-static int parport_intr_cmd(struct comedi_device *dev, struct comedi_subdevice *s)
+static int parport_intr_cmd(struct comedi_device *dev,
+ struct comedi_subdevice *s)
{
devpriv->c_data |= 0x10;
outb(devpriv->c_data, dev->iobase + PARPORT_C);
@@ -263,7 +268,8 @@ static int parport_intr_cmd(struct comedi_device *dev, struct comedi_subdevice *
return 0;
}
-static int parport_intr_cancel(struct comedi_device *dev, struct comedi_subdevice *s)
+static int parport_intr_cancel(struct comedi_device *dev,
+ struct comedi_subdevice *s)
{
printk(KERN_DEBUG "parport_intr_cancel()\n");
@@ -292,7 +298,8 @@ static irqreturn_t parport_interrupt(int irq, void *d)
return IRQ_HANDLED;
}
-static int parport_attach(struct comedi_device *dev, struct comedi_devconfig *it)
+static int parport_attach(struct comedi_device *dev,
+ struct comedi_devconfig *it)
{
int ret;
unsigned int irq;
diff --git a/drivers/staging/comedi/drivers/comedi_test.c b/drivers/staging/comedi/drivers/comedi_test.c
index 9b8cf62973be..ef83a1a445ba 100644
--- a/drivers/staging/comedi/drivers/comedi_test.c
+++ b/drivers/staging/comedi/drivers/comedi_test.c
@@ -69,11 +69,11 @@ struct waveform_board {
static const struct waveform_board waveform_boards[] = {
{
- .name = "comedi_test",
- .ai_chans = N_CHANS,
- .ai_bits = 16,
- .have_dio = 0,
- },
+ .name = "comedi_test",
+ .ai_chans = N_CHANS,
+ .ai_bits = 16,
+ .have_dio = 0,
+ },
};
#define thisboard ((const struct waveform_board *)dev->board_ptr)
@@ -84,7 +84,7 @@ struct waveform_private {
struct timeval last; /* time at which last timer interrupt occured */
unsigned int uvolt_amplitude; /* waveform amplitude in microvolts */
unsigned long usec_period; /* waveform period in microseconds */
- unsigned long usec_current; /* current time (modulo waveform period) */
+ unsigned long usec_current; /* current time (modulo waveform period) */
unsigned long usec_remainder; /* usec since last scan; */
unsigned long ai_count; /* number of conversions remaining */
unsigned int scan_period; /* scan period in usec */
@@ -94,36 +94,42 @@ struct waveform_private {
};
#define devpriv ((struct waveform_private *)dev->private)
-static int waveform_attach(struct comedi_device *dev, struct comedi_devconfig *it);
+static int waveform_attach(struct comedi_device *dev,
+ struct comedi_devconfig *it);
static int waveform_detach(struct comedi_device *dev);
static struct comedi_driver driver_waveform = {
- .driver_name = "comedi_test",
- .module = THIS_MODULE,
- .attach = waveform_attach,
- .detach = waveform_detach,
- .board_name = &waveform_boards[0].name,
- .offset = sizeof(struct waveform_board),
- .num_names = ARRAY_SIZE(waveform_boards),
+ .driver_name = "comedi_test",
+ .module = THIS_MODULE,
+ .attach = waveform_attach,
+ .detach = waveform_detach,
+ .board_name = &waveform_boards[0].name,
+ .offset = sizeof(struct waveform_board),
+ .num_names = ARRAY_SIZE(waveform_boards),
};
COMEDI_INITCLEANUP(driver_waveform);
-static int waveform_ai_cmdtest(struct comedi_device *dev, struct comedi_subdevice *s,
+static int waveform_ai_cmdtest(struct comedi_device *dev,
+ struct comedi_subdevice *s,
struct comedi_cmd *cmd);
-static int waveform_ai_cmd(struct comedi_device *dev, struct comedi_subdevice *s);
-static int waveform_ai_cancel(struct comedi_device *dev, struct comedi_subdevice *s);
-static int waveform_ai_insn_read(struct comedi_device *dev, struct comedi_subdevice *s,
+static int waveform_ai_cmd(struct comedi_device *dev,
+ struct comedi_subdevice *s);
+static int waveform_ai_cancel(struct comedi_device *dev,
+ struct comedi_subdevice *s);
+static int waveform_ai_insn_read(struct comedi_device *dev,
+ struct comedi_subdevice *s,
struct comedi_insn *insn, unsigned int *data);
-static int waveform_ao_insn_write(struct comedi_device *dev, struct comedi_subdevice *s,
+static int waveform_ao_insn_write(struct comedi_device *dev,
+ struct comedi_subdevice *s,
struct comedi_insn *insn, unsigned int *data);
static short fake_sawtooth(struct comedi_device *dev, unsigned int range,
- unsigned long current_time);
+ unsigned long current_time);
static short fake_squarewave(struct comedi_device *dev, unsigned int range,
- unsigned long current_time);
-static short fake_flatline(struct comedi_device *dev, unsigned int range,
unsigned long current_time);
+static short fake_flatline(struct comedi_device *dev, unsigned int range,
+ unsigned long current_time);
static short fake_waveform(struct comedi_device *dev, unsigned int channel,
- unsigned int range, unsigned long current_time);
+ unsigned int range, unsigned long current_time);
/* 1000 nanosec in a microsec */
static const int nano_per_micro = 1000;
@@ -132,9 +138,9 @@ static const int nano_per_micro = 1000;
static const struct comedi_lrange waveform_ai_ranges = {
2,
{
- BIP_RANGE(10),
- BIP_RANGE(5),
- }
+ BIP_RANGE(10),
+ BIP_RANGE(5),
+ }
};
/*
@@ -144,7 +150,7 @@ static const struct comedi_lrange waveform_ai_ranges = {
*/
static void waveform_ai_interrupt(unsigned long arg)
{
- struct comedi_device *dev = (struct comedi_device *) arg;
+ struct comedi_device *dev = (struct comedi_device *)arg;
struct comedi_async *async = dev->read_subdev->async;
struct comedi_cmd *cmd = &async->cmd;
unsigned int i, j;
@@ -156,27 +162,34 @@ static void waveform_ai_interrupt(unsigned long arg)
do_gettimeofday(&now);
elapsed_time =
- 1000000 * (now.tv_sec - devpriv->last.tv_sec) + now.tv_usec -
- devpriv->last.tv_usec;
+ 1000000 * (now.tv_sec - devpriv->last.tv_sec) + now.tv_usec -
+ devpriv->last.tv_usec;
devpriv->last = now;
num_scans =
- (devpriv->usec_remainder + elapsed_time) / devpriv->scan_period;
+ (devpriv->usec_remainder + elapsed_time) / devpriv->scan_period;
devpriv->usec_remainder =
- (devpriv->usec_remainder + elapsed_time) % devpriv->scan_period;
+ (devpriv->usec_remainder + elapsed_time) % devpriv->scan_period;
async->events = 0;
for (i = 0; i < num_scans; i++) {
for (j = 0; j < cmd->chanlist_len; j++) {
cfc_write_to_buffer(dev->read_subdev,
- fake_waveform(dev, CR_CHAN(cmd->chanlist[j]),
- CR_RANGE(cmd->chanlist[j]),
- devpriv->usec_current +
- i * devpriv->scan_period +
- j * devpriv->convert_period));
+ fake_waveform(dev,
+ CR_CHAN(cmd->
+ chanlist[j]),
+ CR_RANGE(cmd->
+ chanlist[j]),
+ devpriv->
+ usec_current +
+ i *
+ devpriv->scan_period +
+ j *
+ devpriv->
+ convert_period));
}
devpriv->ai_count++;
if (cmd->stop_src == TRIG_COUNT
- && devpriv->ai_count >= cmd->stop_arg) {
+ && devpriv->ai_count >= cmd->stop_arg) {
async->events |= COMEDI_CB_EOA;
break;
}
@@ -193,7 +206,8 @@ static void waveform_ai_interrupt(unsigned long arg)
comedi_event(dev, dev->read_subdev);
}
-static int waveform_attach(struct comedi_device *dev, struct comedi_devconfig *it)
+static int waveform_attach(struct comedi_device *dev,
+ struct comedi_devconfig *it)
{
struct comedi_subdevice *s;
int amplitude = it->options[0];
@@ -255,8 +269,8 @@ static int waveform_attach(struct comedi_device *dev, struct comedi_devconfig *i
devpriv->timer.data = (unsigned long)dev;
printk(KERN_INFO "comedi%d: comedi_test: "
- "%i microvolt, %li microsecond waveform attached\n", dev->minor,
- devpriv->uvolt_amplitude, devpriv->usec_period);
+ "%i microvolt, %li microsecond waveform attached\n", dev->minor,
+ devpriv->uvolt_amplitude, devpriv->usec_period);
return 1;
}
@@ -270,7 +284,8 @@ static int waveform_detach(struct comedi_device *dev)
return 0;
}
-static int waveform_ai_cmdtest(struct comedi_device *dev, struct comedi_subdevice *s,
+static int waveform_ai_cmdtest(struct comedi_device *dev,
+ struct comedi_subdevice *s,
struct comedi_cmd *cmd)
{
int err = 0;
@@ -336,10 +351,10 @@ static int waveform_ai_cmdtest(struct comedi_device *dev, struct comedi_subdevic
err++;
}
if (cmd->convert_src == TRIG_TIMER &&
- cmd->scan_begin_arg <
- cmd->convert_arg * cmd->chanlist_len) {
+ cmd->scan_begin_arg <
+ cmd->convert_arg * cmd->chanlist_len) {
cmd->scan_begin_arg =
- cmd->convert_arg * cmd->chanlist_len;
+ cmd->convert_arg * cmd->chanlist_len;
err++;
}
}
@@ -377,8 +392,8 @@ static int waveform_ai_cmdtest(struct comedi_device *dev, struct comedi_subdevic
tmp = cmd->scan_begin_arg;
/* round to nearest microsec */
cmd->scan_begin_arg =
- nano_per_micro * ((tmp +
- (nano_per_micro / 2)) / nano_per_micro);
+ nano_per_micro * ((tmp +
+ (nano_per_micro / 2)) / nano_per_micro);
if (tmp != cmd->scan_begin_arg)
err++;
}
@@ -386,8 +401,8 @@ static int waveform_ai_cmdtest(struct comedi_device *dev, struct comedi_subdevic
tmp = cmd->convert_arg;
/* round to nearest microsec */
cmd->convert_arg =
- nano_per_micro * ((tmp +
- (nano_per_micro / 2)) / nano_per_micro);
+ nano_per_micro * ((tmp +
+ (nano_per_micro / 2)) / nano_per_micro);
if (tmp != cmd->convert_arg)
err++;
}
@@ -398,13 +413,14 @@ static int waveform_ai_cmdtest(struct comedi_device *dev, struct comedi_subdevic
return 0;
}
-static int waveform_ai_cmd(struct comedi_device *dev, struct comedi_subdevice *s)
+static int waveform_ai_cmd(struct comedi_device *dev,
+ struct comedi_subdevice *s)
{
struct comedi_cmd *cmd = &s->async->cmd;
if (cmd->flags & TRIG_RT) {
comedi_error(dev,
- "commands at RT priority not supported in this driver");
+ "commands at RT priority not supported in this driver");
return -1;
}
@@ -430,7 +446,8 @@ static int waveform_ai_cmd(struct comedi_device *dev, struct comedi_subdevice *s
return 0;
}
-static int waveform_ai_cancel(struct comedi_device *dev, struct comedi_subdevice *s)
+static int waveform_ai_cancel(struct comedi_device *dev,
+ struct comedi_subdevice *s)
{
devpriv->timer_running = 0;
del_timer(&devpriv->timer);
@@ -438,12 +455,13 @@ static int waveform_ai_cancel(struct comedi_device *dev, struct comedi_subdevice
}
static short fake_sawtooth(struct comedi_device *dev, unsigned int range_index,
- unsigned long current_time)
+ unsigned long current_time)
{
struct comedi_subdevice *s = dev->read_subdev;
unsigned int offset = s->maxdata / 2;
u64 value;
- const struct comedi_krange *krange = &s->range_table->range[range_index];
+ const struct comedi_krange *krange =
+ &s->range_table->range[range_index];
u64 binary_amplitude;
binary_amplitude = s->maxdata;
@@ -458,13 +476,16 @@ static short fake_sawtooth(struct comedi_device *dev, unsigned int range_index,
return offset + value;
}
-static short fake_squarewave(struct comedi_device *dev, unsigned int range_index,
- unsigned long current_time)
+
+static short fake_squarewave(struct comedi_device *dev,
+ unsigned int range_index,
+ unsigned long current_time)
{
struct comedi_subdevice *s = dev->read_subdev;
unsigned int offset = s->maxdata / 2;
u64 value;
- const struct comedi_krange *krange = &s->range_table->range[range_index];
+ const struct comedi_krange *krange =
+ &s->range_table->range[range_index];
current_time %= devpriv->usec_period;
value = s->maxdata;
@@ -478,14 +499,14 @@ static short fake_squarewave(struct comedi_device *dev, unsigned int range_index
}
static short fake_flatline(struct comedi_device *dev, unsigned int range_index,
- unsigned long current_time)
+ unsigned long current_time)
{
return dev->read_subdev->maxdata / 2;
}
/* generates a different waveform depending on what channel is read */
static short fake_waveform(struct comedi_device *dev, unsigned int channel,
- unsigned int range, unsigned long current_time)
+ unsigned int range, unsigned long current_time)
{
enum {
SAWTOOTH_CHAN,
@@ -505,7 +526,8 @@ static short fake_waveform(struct comedi_device *dev, unsigned int channel,
return fake_flatline(dev, range, current_time);
}
-static int waveform_ai_insn_read(struct comedi_device *dev, struct comedi_subdevice *s,
+static int waveform_ai_insn_read(struct comedi_device *dev,
+ struct comedi_subdevice *s,
struct comedi_insn *insn, unsigned int *data)
{
int i, chan = CR_CHAN(insn->chanspec);
@@ -516,7 +538,8 @@ static int waveform_ai_insn_read(struct comedi_device *dev, struct comedi_subdev
return insn->n;
}
-static int waveform_ao_insn_write(struct comedi_device *dev, struct comedi_subdevice *s,
+static int waveform_ao_insn_write(struct comedi_device *dev,
+ struct comedi_subdevice *s,
struct comedi_insn *insn, unsigned int *data)
{
int i, chan = CR_CHAN(insn->chanspec);
diff --git a/drivers/staging/comedi/drivers/contec_pci_dio.c b/drivers/staging/comedi/drivers/contec_pci_dio.c
index 6c58e9990323..b16d652f7763 100644
--- a/drivers/staging/comedi/drivers/contec_pci_dio.c
+++ b/drivers/staging/comedi/drivers/contec_pci_dio.c
@@ -57,9 +57,10 @@ static const struct contec_board contec_boards[] = {
#define PCI_DEVICE_ID_PIO1616L 0x8172
static DEFINE_PCI_DEVICE_TABLE(contec_pci_table) = {
- {PCI_VENDOR_ID_CONTEC, PCI_DEVICE_ID_PIO1616L, PCI_ANY_ID, PCI_ANY_ID,
- 0, 0, PIO1616L},
- {0}
+ {
+ PCI_VENDOR_ID_CONTEC, PCI_DEVICE_ID_PIO1616L, PCI_ANY_ID,
+ PCI_ANY_ID, 0, 0, PIO1616L}, {
+ 0}
};
MODULE_DEVICE_TABLE(pci, contec_pci_table);
@@ -75,7 +76,8 @@ 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_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",
@@ -85,14 +87,16 @@ static struct comedi_driver driver_contec = {
};
/* 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);
+ struct comedi_cmd *cmd);
static int contec_ns_to_timer(unsigned int *ns, int round);
#endif
@@ -113,22 +117,22 @@ static int contec_attach(struct comedi_device *dev, struct comedi_devconfig *it)
return -ENOMEM;
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)) {
+ pcidev != NULL;
+ pcidev = pci_get_device(PCI_ANY_ID, PCI_ANY_ID, pcidev)) {
if (pcidev->vendor == PCI_VENDOR_ID_CONTEC &&
- pcidev->device == PCI_DEVICE_ID_PIO1616L) {
+ pcidev->device == PCI_DEVICE_ID_PIO1616L) {
if (it->options[0] || it->options[1]) {
/* Check bus and slot. */
if (it->options[0] != pcidev->bus->number ||
- it->options[1] !=
- PCI_SLOT(pcidev->devfn)) {
+ it->options[1] != PCI_SLOT(pcidev->devfn)) {
continue;
}
}
devpriv->pci_dev = pcidev;
if (comedi_pci_enable(pcidev, "contec_pci_dio")) {
- printk("error enabling PCI device and request regions!\n");
+ printk
+ ("error enabling PCI device and request regions!\n");
return -EIO;
}
dev->iobase = pci_resource_start(pcidev, 0);
@@ -180,7 +184,7 @@ 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)
+ struct comedi_cmd *cmd)
{
printk("contec_cmdtest called\n");
return 0;
@@ -192,8 +196,9 @@ 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");
@@ -206,14 +211,15 @@ static int contec_do_insn_bits(struct comedi_device *dev, struct comedi_subdevic
s->state &= ~data[0];
s->state |= data[0] & data[1];
printk(" out: %d on %lx\n", s->state,
- dev->iobase + thisboard->out_offs);
+ 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)
{
printk("contec_di_insn_bits called\n");
diff --git a/drivers/staging/comedi/drivers/daqboard2000.c b/drivers/staging/comedi/drivers/daqboard2000.c
index d4526c616a99..078ec273b277 100644
--- a/drivers/staging/comedi/drivers/daqboard2000.c
+++ b/drivers/staging/comedi/drivers/daqboard2000.c
@@ -107,13 +107,10 @@ Configuration options:
| +---------------- Unipolar
+------------------------- Correction gain high
-
-
999. The card seems to have an incredible amount of capabilities, but
trying to reverse engineer them from the Windows source is beyond my
patience.
-
*/
#include "../comedidev.h"
@@ -147,25 +144,32 @@ Configuration options:
/* Available ranges */
static const struct comedi_lrange range_daqboard2000_ai = { 13, {
- RANGE(-10, 10),
- RANGE(-5, 5),
- RANGE(-2.5, 2.5),
- RANGE(-1.25, 1.25),
- RANGE(-0.625, 0.625),
- RANGE(-0.3125, 0.3125),
- RANGE(-0.156, 0.156),
- RANGE(0, 10),
- RANGE(0, 5),
- RANGE(0, 2.5),
- RANGE(0, 1.25),
- RANGE(0, 0.625),
- RANGE(0, 0.3125)
- }
+ RANGE(-10, 10),
+ RANGE(-5, 5),
+ RANGE(-2.5,
+ 2.5),
+ RANGE(-1.25,
+ 1.25),
+ RANGE(-0.625,
+ 0.625),
+ RANGE(-0.3125,
+ 0.3125),
+ RANGE(-0.156,
+ 0.156),
+ RANGE(0, 10),
+ RANGE(0, 5),
+ RANGE(0, 2.5),
+ RANGE(0, 1.25),
+ RANGE(0,
+ 0.625),
+ RANGE(0,
+ 0.3125)
+ }
};
static const struct comedi_lrange range_daqboard2000_ao = { 1, {
- RANGE(-10, 10)
- }
+ RANGE(-10, 10)
+ }
};
struct daqboard2000_hw {
@@ -297,7 +301,8 @@ struct daqboard2000_hw {
#define DAQBOARD2000_PosRefDacSelect 0x0100
#define DAQBOARD2000_NegRefDacSelect 0x0000
-static int daqboard2000_attach(struct comedi_device *dev, struct comedi_devconfig *it);
+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 = {
@@ -320,8 +325,9 @@ static const struct daq200_boardtype boardtypes[] = {
#define this_board ((const struct daq200_boardtype *)dev->board_ptr)
static DEFINE_PCI_DEVICE_TABLE(daqboard2000_pci_table) = {
- {0x1616, 0x0409, PCI_ANY_ID, PCI_ANY_ID, 0, 0, 0},
- {0}
+ {
+ 0x1616, 0x0409, PCI_ANY_ID, PCI_ANY_ID, 0, 0, 0}, {
+ 0}
};
MODULE_DEVICE_TABLE(pci, daqboard2000_pci_table);
@@ -394,17 +400,18 @@ 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;
int gain, chan, timeout;
fpga->acqControl =
- DAQBOARD2000_AcqResetScanListFifo |
- DAQBOARD2000_AcqResetResultsFifo |
- DAQBOARD2000_AcqResetConfigPipe;
+ DAQBOARD2000_AcqResetScanListFifo |
+ DAQBOARD2000_AcqResetResultsFifo | DAQBOARD2000_AcqResetConfigPipe;
/* If pacer clock is not set to some high value (> 10 us), we
risk multiple samples to be put into the result FIFO. */
@@ -436,9 +443,8 @@ static int daqboard2000_ai_insn_read(struct comedi_device *dev, struct comedi_su
/* udelay(2); */
}
for (timeout = 0; timeout < 20; timeout++) {
- if (fpga->
- acqControl &
- DAQBOARD2000_AcqResultsFIFOHasValidData) {
+ if (fpga->acqControl &
+ DAQBOARD2000_AcqResultsFIFOHasValidData) {
break;
}
/* udelay(2); */
@@ -451,8 +457,10 @@ static int daqboard2000_ai_insn_read(struct comedi_device *dev, struct comedi_su
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);
@@ -464,8 +472,10 @@ static int daqboard2000_ao_insn_read(struct comedi_device *dev, struct comedi_su
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);
@@ -521,7 +531,7 @@ static void daqboard2000_pulseProgPin(struct comedi_device *dev)
writel(DAQBOARD2000_SECRProgPinHi, devpriv->plx + 0x6c);
udelay(10000);
writel(DAQBOARD2000_SECRProgPinLo, devpriv->plx + 0x6c);
- 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)
@@ -550,14 +560,14 @@ static int daqboard2000_writeCPLD(struct comedi_device *dev, int data)
udelay(10);
writew(data, devpriv->daq + 0x1000);
if ((readw(devpriv->daq + 0x1000) & DAQBOARD2000_CPLD_INIT) ==
- DAQBOARD2000_CPLD_INIT) {
+ DAQBOARD2000_CPLD_INIT) {
result = 1;
}
return result;
}
static int initialize_daqboard2000(struct comedi_device *dev,
- unsigned char *cpld_array, int len)
+ unsigned char *cpld_array, int len)
{
int result = -EIO;
/* Read the serial EEPROM control register */
@@ -585,7 +595,7 @@ static int initialize_daqboard2000(struct comedi_device *dev,
if (daqboard2000_pollCPLD(dev, DAQBOARD2000_CPLD_INIT)) {
for (i = 0; i < len; i++) {
if (cpld_array[i] == 0xff
- && cpld_array[i + 1] == 0x20) {
+ && cpld_array[i + 1] == 0x20) {
#ifdef DEBUG_EEPROM
printk("Preamble found at %d\n", i);
#endif
@@ -594,8 +604,7 @@ static int initialize_daqboard2000(struct comedi_device *dev,
}
for (; i < len; i += 2) {
int data =
- (cpld_array[i] << 8) + cpld_array[i +
- 1];
+ (cpld_array[i] << 8) + cpld_array[i + 1];
if (!daqboard2000_writeCPLD(dev, data)) {
break;
}
@@ -702,7 +711,7 @@ rmmod daqboard2000 ; rmmod comedi; make install ; modprobe daqboard2000; /usr/sb
*/
static int daqboard2000_8255_cb(int dir, int port, int data,
- unsigned long ioaddr)
+ unsigned long ioaddr)
{
int result = 0;
if (dir) {
@@ -718,7 +727,8 @@ 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;
@@ -737,21 +747,20 @@ static int daqboard2000_attach(struct comedi_device *dev, struct comedi_devconfi
return -ENOMEM;
}
for (card = pci_get_device(0x1616, 0x0409, NULL);
- card != NULL;
- card = pci_get_device(0x1616, 0x0409, card)) {
+ card != NULL; card = pci_get_device(0x1616, 0x0409, card)) {
if (bus || slot) {
/* requested particular bus/slot */
if (card->bus->number != bus ||
- PCI_SLOT(card->devfn) != slot) {
+ PCI_SLOT(card->devfn) != slot) {
continue;
}
}
- break; /* found one */
+ break; /* found one */
}
if (!card) {
if (bus || slot)
printk(" no daqboard2000 found at bus/slot: %d/%d\n",
- bus, slot);
+ bus, slot);
else
printk(" no daqboard2000 found\n");
return -EIO;
@@ -759,8 +768,8 @@ static int daqboard2000_attach(struct comedi_device *dev, struct comedi_devconfi
u32 id;
int i;
devpriv->pci_dev = card;
- id = ((u32) card->subsystem_device << 16) | card->
- subsystem_vendor;
+ id = ((u32) card->
+ subsystem_device << 16) | card->subsystem_vendor;
for (i = 0; i < n_boardtypes; i++) {
if (boardtypes[i].id == id) {
printk(" %s", boardtypes[i].name);
@@ -768,7 +777,9 @@ static int daqboard2000_attach(struct comedi_device *dev, struct comedi_devconfi
}
}
if (!dev->board_ptr) {
- printk(" unknown subsystem id %08x (pretend it is an ids2)", id);
+ printk
+ (" unknown subsystem id %08x (pretend it is an ids2)",
+ id);
dev->board_ptr = boardtypes;
}
}
@@ -780,9 +791,9 @@ static int daqboard2000_attach(struct comedi_device *dev, struct comedi_devconfi
}
devpriv->got_regions = 1;
devpriv->plx =
- ioremap(pci_resource_start(card, 0), DAQBOARD2000_PLX_SIZE);
+ ioremap(pci_resource_start(card, 0), DAQBOARD2000_PLX_SIZE);
devpriv->daq =
- ioremap(pci_resource_start(card, 2), DAQBOARD2000_DAQ_SIZE);
+ ioremap(pci_resource_start(card, 2), DAQBOARD2000_DAQ_SIZE);
if (!devpriv->plx || !devpriv->daq) {
return -ENOMEM;
}
@@ -844,10 +855,10 @@ static int daqboard2000_attach(struct comedi_device *dev, struct comedi_devconfi
s = dev->subdevices + 2;
result = subdev_8255_init(dev, s, daqboard2000_8255_cb,
- (unsigned long)(dev->iobase + 0x40));
+ (unsigned long)(dev->iobase + 0x40));
printk("\n");
- out:
+out:
return result;
}
diff --git a/drivers/staging/comedi/drivers/das08.c b/drivers/staging/comedi/drivers/das08.c
index c20cd8feb13d..f4258334532c 100644
--- a/drivers/staging/comedi/drivers/das08.c
+++ b/drivers/staging/comedi/drivers/das08.c
@@ -155,60 +155,66 @@ 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);
+ 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);
+ 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);
+ 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);
+ unsigned int mode);
static const struct comedi_lrange range_das08_pgl = { 9, {
- BIP_RANGE(10),
- BIP_RANGE(5),
- BIP_RANGE(2.5),
- BIP_RANGE(1.25),
- BIP_RANGE(0.625),
- UNI_RANGE(10),
- UNI_RANGE(5),
- UNI_RANGE(2.5),
- UNI_RANGE(1.25)
- }
+ BIP_RANGE(10),
+ BIP_RANGE(5),
+ BIP_RANGE(2.5),
+ BIP_RANGE(1.25),
+ BIP_RANGE(0.625),
+ UNI_RANGE(10),
+ UNI_RANGE(5),
+ UNI_RANGE(2.5),
+ UNI_RANGE(1.25)
+ }
};
+
static const struct comedi_lrange range_das08_pgh = { 12, {
- BIP_RANGE(10),
- BIP_RANGE(5),
- BIP_RANGE(1),
- BIP_RANGE(0.5),
- BIP_RANGE(0.1),
- BIP_RANGE(0.05),
- BIP_RANGE(0.01),
- BIP_RANGE(0.005),
- UNI_RANGE(10),
- UNI_RANGE(1),
- UNI_RANGE(0.1),
- UNI_RANGE(0.01),
- }
+ BIP_RANGE(10),
+ BIP_RANGE(5),
+ BIP_RANGE(1),
+ BIP_RANGE(0.5),
+ BIP_RANGE(0.1),
+ BIP_RANGE(0.05),
+ BIP_RANGE(0.01),
+ BIP_RANGE(0.005),
+ UNI_RANGE(10),
+ UNI_RANGE(1),
+ UNI_RANGE(0.1),
+ UNI_RANGE(0.01),
+ }
};
+
static const struct comedi_lrange range_das08_pgm = { 9, {
- BIP_RANGE(10),
- BIP_RANGE(5),
- BIP_RANGE(0.5),
- BIP_RANGE(0.05),
- BIP_RANGE(0.01),
- UNI_RANGE(10),
- UNI_RANGE(1),
- UNI_RANGE(0.1),
- UNI_RANGE(0.01)
- }
+ BIP_RANGE(10),
+ BIP_RANGE(5),
+ BIP_RANGE(0.5),
+ BIP_RANGE(0.05),
+ BIP_RANGE(0.01),
+ UNI_RANGE(10),
+ UNI_RANGE(1),
+ UNI_RANGE(0.1),
+ UNI_RANGE(0.01)
+ }
}; /*
cio-das08jr.pdf
@@ -234,7 +240,7 @@ static const struct comedi_lrange *const das08_ai_lranges[] = {
};
static const int das08_pgh_gainlist[] =
- { 8, 0, 10, 2, 12, 4, 14, 6, 1, 3, 5, 7 };
+ { 8, 0, 10, 2, 12, 4, 14, 6, 1, 3, 5, 7 };
static const int das08_pgl_gainlist[] = { 8, 0, 2, 4, 6, 1, 3, 5, 7 };
static const int das08_pgm_gainlist[] = { 8, 0, 10, 12, 14, 9, 11, 13, 15 };
@@ -248,260 +254,261 @@ 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
};
#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 */
{
- .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
#ifdef CONFIG_COMEDI_PCI
static DEFINE_PCI_DEVICE_TABLE(das08_pci_table) = {
- {PCI_VENDOR_ID_COMPUTERBOARDS, PCI_DEVICE_ID_PCIDAS08, PCI_ANY_ID,
- PCI_ANY_ID, 0, 0, 0},
- {0}
+ {
+ PCI_VENDOR_ID_COMPUTERBOARDS, PCI_DEVICE_ID_PCIDAS08,
+ PCI_ANY_ID, PCI_ANY_ID, 0, 0, 0}, {
+ 0}
};
MODULE_DEVICE_TABLE(pci, das08_pci_table);
@@ -513,7 +520,7 @@ 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)
+ struct comedi_insn *insn, unsigned int *data)
{
int i, n;
int chan;
@@ -538,7 +545,7 @@ static int das08_ai_rinsn(struct comedi_device *dev, struct comedi_subdevice *s,
/* set gain/range */
range = CR_RANGE(insn->chanspec);
outb(devpriv->pg_gainlist[range],
- dev->iobase + DAS08AO_GAIN_CONTROL);
+ dev->iobase + DAS08AO_GAIN_CONTROL);
}
for (n = 0; n < insn->n; n++) {
@@ -580,7 +587,7 @@ static int das08_ai_rinsn(struct comedi_device *dev, struct comedi_subdevice *s,
}
static int das08_di_rbits(struct comedi_device *dev, struct comedi_subdevice *s,
- struct comedi_insn *insn, unsigned int *data)
+ struct comedi_insn *insn, unsigned int *data)
{
data[0] = 0;
data[1] = DAS08_IP(inb(dev->iobase + DAS08_STATUS));
@@ -589,7 +596,7 @@ static int das08_di_rbits(struct comedi_device *dev, struct comedi_subdevice *s,
}
static int das08_do_wbits(struct comedi_device *dev, struct comedi_subdevice *s,
- struct comedi_insn *insn, unsigned int *data)
+ struct comedi_insn *insn, unsigned int *data)
{
int wbits;
@@ -611,8 +618,9 @@ static int das08_do_wbits(struct comedi_device *dev, struct comedi_subdevice *s,
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,8 +628,9 @@ 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 */
devpriv->do_bits &= ~data[0];
@@ -634,8 +643,9 @@ 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 +678,9 @@ 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;
@@ -716,7 +727,7 @@ static unsigned int i8254_read_channel_low(unsigned int base, int chan)
}
static void i8254_write_channel_low(unsigned int base, int chan,
- unsigned int value)
+ unsigned int value)
{
unsigned int msb, lsb;
@@ -740,7 +751,7 @@ static unsigned int i8254_read_channel(struct i8254_struct *st, int channel)
}
static void i8254_write_channel(struct i8254_struct *st, int channel,
- unsigned int value)
+ unsigned int value)
{
int chan = st->logic2phys[channel];
@@ -755,13 +766,13 @@ static void i8254_initialize(struct i8254_struct *st)
}
static void i8254_set_mode_low(unsigned int base, int channel,
- unsigned int mode)
+ unsigned int mode)
{
outb((channel << 6) | 0x30 | (mode & 0x0F), base + I8254_CTRL);
}
static void i8254_set_mode(struct i8254_struct *st, int channel,
- unsigned int mode)
+ unsigned int mode)
{
int chan = st->logic2phys[channel];
@@ -782,8 +793,9 @@ 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;
@@ -794,8 +806,9 @@ static int das08_counter_read(struct comedi_device *dev, struct comedi_subdevice
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;
@@ -805,8 +818,9 @@ static int das08_counter_write(struct comedi_device *dev, struct comedi_subdevic
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;
@@ -835,8 +849,7 @@ static struct comedi_driver driver_das08 = {
.attach = das08_attach,
.detach = das08_common_detach,
.board_name = &das08_boards[0].name,
- .num_names = sizeof(das08_boards) /
- sizeof(struct das08_board_struct),
+ .num_names = sizeof(das08_boards) / sizeof(struct das08_board_struct),
.offset = sizeof(struct das08_board_struct),
};
@@ -921,7 +934,8 @@ int das08_common_attach(struct comedi_device *dev, unsigned long iobase)
/* 8255 */
if (thisboard->i8255_offset != 0) {
subdev_8255_init(dev, s, NULL, (unsigned long)(dev->iobase +
- thisboard->i8255_offset));
+ thisboard->
+ i8255_offset));
} else {
s->type = COMEDI_SUBD_UNUSED;
}
@@ -943,8 +957,8 @@ int das08_common_attach(struct comedi_device *dev, unsigned long iobase)
devpriv->i8254.logic2phys[2] = 2;
devpriv->i8254.iobase = iobase + thisboard->i8254_offset;
devpriv->i8254.mode[0] =
- devpriv->i8254.mode[1] =
- devpriv->i8254.mode[2] = I8254_MODE0 | I8254_BINARY;
+ devpriv->i8254.mode[1] =
+ devpriv->i8254.mode[2] = I8254_MODE0 | I8254_BINARY;
i8254_initialize(&devpriv->i8254);
} else {
s->type = COMEDI_SUBD_UNUSED;
@@ -972,19 +986,19 @@ static int das08_attach(struct comedi_device *dev, struct comedi_devconfig *it)
#ifdef CONFIG_COMEDI_PCI
if (it->options[0] || it->options[1]) {
printk("bus %i slot %i ",
- it->options[0], it->options[1]);
+ it->options[0], it->options[1]);
}
printk("\n");
/* 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)) {
+ pdev != NULL;
+ pdev = pci_get_device(PCI_ANY_ID, PCI_ANY_ID, pdev)) {
if (pdev->vendor == PCI_VENDOR_ID_COMPUTERBOARDS
- && pdev->device == PCI_DEVICE_ID_PCIDAS08) {
+ && pdev->device == PCI_DEVICE_ID_PCIDAS08) {
if (it->options[0] || it->options[1]) {
if (pdev->bus->number == it->options[0]
- && PCI_SLOT(pdev->devfn) ==
- it->options[1]) {
+ && PCI_SLOT(pdev->devfn) ==
+ it->options[1]) {
break;
}
} else {
@@ -999,7 +1013,8 @@ static int das08_attach(struct comedi_device *dev, struct comedi_devconfig *it)
devpriv->pdev = pdev;
/* enable PCI device and reserve I/O spaces */
if (comedi_pci_enable(pdev, DRV_NAME)) {
- printk(" Error enabling PCI device and requesting regions\n");
+ printk
+ (" Error enabling PCI device and requesting regions\n");
return -EIO;
}
/* read base addresses */
@@ -1018,10 +1033,10 @@ static int das08_attach(struct comedi_device *dev, struct comedi_devconfig *it)
/* Enable local interrupt 1 and pci interrupt */
outw(INTR1_ENABLE | PCI_INTR_ENABLE, pci_iobase + INTCSR);
#endif
-#else /* CONFIG_COMEDI_PCI */
+#else /* CONFIG_COMEDI_PCI */
printk("this driver has not been built with PCI support.\n");
return -EINVAL;
-#endif /* CONFIG_COMEDI_PCI */
+#endif /* CONFIG_COMEDI_PCI */
} else {
iobase = it->options[0];
}
@@ -1042,7 +1057,6 @@ int das08_common_detach(struct comedi_device *dev)
if (dev->iobase)
release_region(dev->iobase, thisboard->iosize);
}
-
#ifdef CONFIG_COMEDI_PCI
if (devpriv) {
if (devpriv->pdev) {
diff --git a/drivers/staging/comedi/drivers/das08.h b/drivers/staging/comedi/drivers/das08.h
index 7cdb3fc4daee..35d2660cf93b 100644
--- a/drivers/staging/comedi/drivers/das08.h
+++ b/drivers/staging/comedi/drivers/das08.h
@@ -28,7 +28,8 @@ enum das08_bustype { isa, pci, pcmcia, pc104 };
/* 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 };
+ das08_pgm
+};
struct das08_board_struct {
const char *name;
diff --git a/drivers/staging/comedi/drivers/das08_cs.c b/drivers/staging/comedi/drivers/das08_cs.c
index 8e4464100e1e..74fcc1086c51 100644
--- a/drivers/staging/comedi/drivers/das08_cs.c
+++ b/drivers/staging/comedi/drivers/das08_cs.c
@@ -56,7 +56,8 @@ 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",
@@ -65,11 +66,12 @@ static struct comedi_driver driver_das08_cs = {
.detach = das08_common_detach,
.board_name = &das08_cs_boards[0].name,
.num_names = sizeof(das08_cs_boards) /
- sizeof(struct das08_board_struct),
+ 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;
@@ -122,7 +124,7 @@ static int pc_debug = PCMCIA_DEBUG;
module_param(pc_debug, int, 0644);
#define DEBUG(n, args...) if (pc_debug>(n)) printk(KERN_DEBUG args)
static const char *version =
- "das08.c pcmcia code (Frank Hess), modified from dummy_cs.c 1.31 2001/08/24 12:13:13 (David Hinds)";
+ "das08.c pcmcia code (Frank Hess), modified from dummy_cs.c 1.31 2001/08/24 12:13:13 (David Hinds)";
#else
#define DEBUG(n, args...)
#endif
@@ -226,7 +228,7 @@ static void das08_pcmcia_detach(struct pcmcia_device *link)
DEBUG(0, "das08_pcmcia_detach(0x%p)\n", link);
if (link->dev_node) {
- ((struct local_info_t *) link->priv)->stop = 1;
+ ((struct local_info_t *)link->priv)->stop = 1;
das08_pcmcia_release(link);
}
@@ -356,7 +358,7 @@ static void das08_pcmcia_config(struct pcmcia_device *link)
/* If we got this far, we're cool! */
break;
- next_entry:
+next_entry:
last_fn = GetNextTuple;
last_ret = pcmcia_get_next_tuple(link, &tuple);
@@ -391,20 +393,20 @@ static void das08_pcmcia_config(struct pcmcia_device *link)
/* Finally, report what we've done */
printk(KERN_INFO "%s: index 0x%02x",
- dev->node.dev_name, link->conf.ConfigIndex);
+ dev->node.dev_name, link->conf.ConfigIndex);
if (link->conf.Attributes & CONF_ENABLE_IRQ)
printk(", irq %u", link->irq.AssignedIRQ);
if (link->io.NumPorts1)
printk(", io 0x%04x-0x%04x", link->io.BasePort1,
- link->io.BasePort1 + link->io.NumPorts1 - 1);
+ link->io.BasePort1 + link->io.NumPorts1 - 1);
if (link->io.NumPorts2)
printk(" & 0x%04x-0x%04x", link->io.BasePort2,
- link->io.BasePort2 + link->io.NumPorts2 - 1);
+ link->io.BasePort2 + link->io.NumPorts2 - 1);
printk("\n");
return;
- cs_failed:
+cs_failed:
cs_error(link, last_fn, last_ret);
das08_pcmcia_release(link);
@@ -470,7 +472,7 @@ struct pcmcia_driver das08_cs_driver = {
.id_table = das08_cs_id_table,
.owner = THIS_MODULE,
.drv = {
- .name = dev_info,
+ .name = dev_info,
},
};
diff --git a/drivers/staging/comedi/drivers/das16.c b/drivers/staging/comedi/drivers/das16.c
index 59af86a8bbfb..10a87e6a8095 100644
--- a/drivers/staging/comedi/drivers/das16.c
+++ b/drivers/staging/comedi/drivers/das16.c
@@ -238,61 +238,67 @@ static const int sample_size = 2; /* size in bytes of a sample from board */
#define DAS1600_CLK_10MHZ 0x01
static const struct comedi_lrange range_das1x01_bip = { 4, {
- BIP_RANGE(10),
- BIP_RANGE(1),
- BIP_RANGE(0.1),
- BIP_RANGE(0.01),
- }
+ BIP_RANGE(10),
+ BIP_RANGE(1),
+ BIP_RANGE(0.1),
+ BIP_RANGE(0.01),
+ }
};
+
static const struct comedi_lrange range_das1x01_unip = { 4, {
- UNI_RANGE(10),
- UNI_RANGE(1),
- UNI_RANGE(0.1),
- UNI_RANGE(0.01),
- }
+ UNI_RANGE(10),
+ UNI_RANGE(1),
+ UNI_RANGE(0.1),
+ UNI_RANGE(0.01),
+ }
};
+
static const struct comedi_lrange range_das1x02_bip = { 4, {
- BIP_RANGE(10),
- BIP_RANGE(5),
- BIP_RANGE(2.5),
- BIP_RANGE(1.25),
- }
+ BIP_RANGE(10),
+ BIP_RANGE(5),
+ BIP_RANGE(2.5),
+ BIP_RANGE(1.25),
+ }
};
+
static const struct comedi_lrange range_das1x02_unip = { 4, {
- UNI_RANGE(10),
- UNI_RANGE(5),
- UNI_RANGE(2.5),
- UNI_RANGE(1.25),
- }
+ UNI_RANGE(10),
+ UNI_RANGE(5),
+ UNI_RANGE(2.5),
+ UNI_RANGE(1.25),
+ }
};
+
static const struct comedi_lrange range_das16jr = { 9, {
- /* also used by 16/330 */
- BIP_RANGE(10),
- BIP_RANGE(5),
- BIP_RANGE(2.5),
- BIP_RANGE(1.25),
- BIP_RANGE(0.625),
- UNI_RANGE(10),
- UNI_RANGE(5),
- UNI_RANGE(2.5),
- UNI_RANGE(1.25),
- }
+ /* also used by 16/330 */
+ BIP_RANGE(10),
+ BIP_RANGE(5),
+ BIP_RANGE(2.5),
+ BIP_RANGE(1.25),
+ BIP_RANGE(0.625),
+ UNI_RANGE(10),
+ UNI_RANGE(5),
+ UNI_RANGE(2.5),
+ UNI_RANGE(1.25),
+ }
};
+
static const struct comedi_lrange range_das16jr_16 = { 8, {
- BIP_RANGE(10),
- BIP_RANGE(5),
- BIP_RANGE(2.5),
- BIP_RANGE(1.25),
- UNI_RANGE(10),
- UNI_RANGE(5),
- UNI_RANGE(2.5),
- UNI_RANGE(1.25),
- }
+ BIP_RANGE(10),
+ BIP_RANGE(5),
+ BIP_RANGE(2.5),
+ BIP_RANGE(1.25),
+ UNI_RANGE(10),
+ UNI_RANGE(5),
+ UNI_RANGE(2.5),
+ UNI_RANGE(1.25),
+ }
};
static const int das16jr_gainlist[] = { 8, 0, 1, 2, 3, 4, 5, 6, 7 };
static const int das16jr_16_gainlist[] = { 0, 1, 2, 3, 4, 5, 6, 7 };
static const int das1600_gainlist[] = { 0, 1, 2, 3 };
+
enum {
das16_pg_none = 0,
das16_pg_16jr,
@@ -307,6 +313,7 @@ static const int *const das16_gainlists[] = {
das1600_gainlist,
das1600_gainlist,
};
+
static const struct comedi_lrange *const das16_ai_uni_lranges[] = {
&range_unknown,
&range_das16jr,
@@ -314,6 +321,7 @@ static const struct comedi_lrange *const das16_ai_uni_lranges[] = {
&range_das1x01_unip,
&range_das1x02_unip,
};
+
static const struct comedi_lrange *const das16_ai_bip_lranges[] = {
&range_unknown,
&range_das16jr,
@@ -328,20 +336,23 @@ struct munge_info {
};
static int das16_ao_winsn(struct comedi_device *dev, struct comedi_subdevice *s,
- struct comedi_insn *insn, unsigned int *data);
+ 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);
+ 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);
+ 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);
+ 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);
+ 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_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);
@@ -349,10 +360,10 @@ static void das16_timer_interrupt(unsigned long arg);
static void das16_interrupt(struct comedi_device *dev);
static unsigned int das16_set_pacer(struct comedi_device *dev, unsigned int ns,
- int flags);
+ int flags);
static int das1600_mode_detect(struct comedi_device *dev);
static unsigned int das16_suggest_transfer_size(struct comedi_device *dev,
- struct comedi_cmd cmd);
+ struct comedi_cmd cmd);
static void reg_dump(struct comedi_device *dev);
@@ -376,324 +387,324 @@ 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
};
@@ -717,6 +728,7 @@ 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 */
@@ -742,7 +754,7 @@ struct das16_private_struct {
#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)
+ struct comedi_cmd *cmd)
{
int err = 0, tmp;
int gain, start_chan, i;
@@ -787,11 +799,11 @@ static int das16_cmd_test(struct comedi_device *dev, struct comedi_subdevice *s,
/* step 2: make sure trigger sources are unique and mutually compatible */
if (cmd->scan_begin_src != TRIG_TIMER &&
- cmd->scan_begin_src != TRIG_EXT &&
- cmd->scan_begin_src != TRIG_FOLLOW)
+ cmd->scan_begin_src != TRIG_EXT &&
+ cmd->scan_begin_src != TRIG_FOLLOW)
err++;
if (cmd->convert_src != TRIG_TIMER &&
- cmd->convert_src != TRIG_EXT && cmd->convert_src != TRIG_NOW)
+ cmd->convert_src != TRIG_EXT && cmd->convert_src != TRIG_NOW)
err++;
if (cmd->stop_src != TRIG_NONE && cmd->stop_src != TRIG_COUNT)
err++;
@@ -826,9 +838,9 @@ static int das16_cmd_test(struct comedi_device *dev, struct comedi_subdevice *s,
/* check against maximum frequency */
if (cmd->scan_begin_src == TRIG_TIMER) {
if (cmd->scan_begin_arg <
- thisboard->ai_speed * cmd->chanlist_len) {
+ thisboard->ai_speed * cmd->chanlist_len) {
cmd->scan_begin_arg =
- thisboard->ai_speed * cmd->chanlist_len;
+ thisboard->ai_speed * cmd->chanlist_len;
err++;
}
}
@@ -853,16 +865,20 @@ static int das16_cmd_test(struct comedi_device *dev, struct comedi_subdevice *s,
unsigned int tmp = cmd->scan_begin_arg;
/* 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);
+ &(devpriv->divisor1),
+ &(devpriv->divisor2),
+ &(cmd->scan_begin_arg),
+ cmd->flags & TRIG_ROUND_MASK);
err += (tmp != cmd->scan_begin_arg);
}
if (cmd->convert_src == TRIG_TIMER) {
unsigned int tmp = cmd->convert_arg;
/* 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);
+ &(devpriv->divisor1),
+ &(devpriv->divisor2),
+ &(cmd->convert_arg),
+ cmd->flags & TRIG_ROUND_MASK);
err += (tmp != cmd->convert_arg);
}
if (err)
@@ -874,14 +890,14 @@ static int das16_cmd_test(struct comedi_device *dev, struct comedi_subdevice *s,
start_chan = CR_CHAN(cmd->chanlist[0]);
for (i = 1; i < cmd->chanlist_len; i++) {
if (CR_CHAN(cmd->chanlist[i]) !=
- (start_chan + i) % s->n_chan) {
+ (start_chan + i) % s->n_chan) {
comedi_error(dev,
- "entries in chanlist must be consecutive channels, counting upwards\n");
+ "entries in chanlist must be consecutive channels, counting upwards\n");
err++;
}
if (CR_RANGE(cmd->chanlist[i]) != gain) {
comedi_error(dev,
- "entries in chanlist must all have the same gain\n");
+ "entries in chanlist must all have the same gain\n");
err++;
}
}
@@ -901,19 +917,19 @@ static int das16_cmd_exec(struct comedi_device *dev, struct comedi_subdevice *s)
int range;
if (devpriv->dma_chan == 0 || (dev->irq == 0
- && devpriv->timer_mode == 0)) {
+ && devpriv->timer_mode == 0)) {
comedi_error(dev,
- "irq (or use of 'timer mode') dma required to execute comedi_cmd");
+ "irq (or use of 'timer mode') dma required to execute comedi_cmd");
return -1;
}
if (cmd->flags & TRIG_RT) {
comedi_error(dev,
- "isa dma transfers cannot be performed with TRIG_RT, aborting");
+ "isa dma transfers cannot be performed with TRIG_RT, aborting");
return -1;
}
devpriv->adc_byte_count =
- cmd->stop_arg * cmd->chanlist_len * sizeof(uint16_t);
+ cmd->stop_arg * cmd->chanlist_len * sizeof(uint16_t);
/* disable conversions for das1600 mode */
if (thisboard->size > 0x400) {
@@ -929,13 +945,13 @@ static int das16_cmd_exec(struct comedi_device *dev, struct comedi_subdevice *s)
if (thisboard->ai_pg != das16_pg_none) {
range = CR_RANGE(cmd->chanlist[0]);
outb((das16_gainlists[thisboard->ai_pg])[range],
- dev->iobase + DAS16_GAIN);
+ dev->iobase + DAS16_GAIN);
}
/* set counter mode and counts */
cmd->convert_arg =
- das16_set_pacer(dev, cmd->convert_arg,
- cmd->flags & TRIG_ROUND_MASK);
+ das16_set_pacer(dev, cmd->convert_arg,
+ cmd->flags & TRIG_ROUND_MASK);
DEBUG_PRINT("pacer period: %d ns\n", cmd->convert_arg);
/* enable counters */
@@ -960,7 +976,7 @@ static int das16_cmd_exec(struct comedi_device *dev, struct comedi_subdevice *s)
clear_dma_ff(devpriv->dma_chan);
devpriv->current_buffer = 0;
set_dma_addr(devpriv->dma_chan,
- devpriv->dma_buffer_addr[devpriv->current_buffer]);
+ devpriv->dma_buffer_addr[devpriv->current_buffer]);
/* 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);
@@ -1031,7 +1047,7 @@ static void das16_reset(struct comedi_device *dev)
}
static int das16_ai_rinsn(struct comedi_device *dev, struct comedi_subdevice *s,
- struct comedi_insn *insn, unsigned int *data)
+ struct comedi_insn *insn, unsigned int *data)
{
int i, n;
int range;
@@ -1051,7 +1067,7 @@ static int das16_ai_rinsn(struct comedi_device *dev, struct comedi_subdevice *s,
if (thisboard->ai_pg != das16_pg_none) {
range = CR_RANGE(insn->chanspec);
outb((das16_gainlists[thisboard->ai_pg])[range],
- dev->iobase + DAS16_GAIN);
+ dev->iobase + DAS16_GAIN);
}
for (n = 0; n < insn->n; n++) {
@@ -1079,7 +1095,7 @@ static int das16_ai_rinsn(struct comedi_device *dev, struct comedi_subdevice *s,
}
static int das16_di_rbits(struct comedi_device *dev, struct comedi_subdevice *s,
- struct comedi_insn *insn, unsigned int *data)
+ struct comedi_insn *insn, unsigned int *data)
{
unsigned int bits;
@@ -1091,7 +1107,7 @@ static int das16_di_rbits(struct comedi_device *dev, struct comedi_subdevice *s,
}
static int das16_do_wbits(struct comedi_device *dev, struct comedi_subdevice *s,
- struct comedi_insn *insn, unsigned int *data)
+ struct comedi_insn *insn, unsigned int *data)
{
unsigned int wbits;
@@ -1111,7 +1127,7 @@ static int das16_do_wbits(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)
+ struct comedi_insn *insn, unsigned int *data)
{
int i;
int lsb, msb;
@@ -1154,7 +1170,7 @@ static irqreturn_t das16_dma_interrupt(int irq, void *d)
static void das16_timer_interrupt(unsigned long arg)
{
- struct comedi_device *dev = (struct comedi_device *) arg;
+ struct comedi_device *dev = (struct comedi_device *)arg;
das16_interrupt(dev);
@@ -1191,7 +1207,7 @@ static int disable_dma_on_even(struct comedi_device *dev)
}
if (i == disable_limit) {
comedi_error(dev,
- "failed to get an even dma transfer, could be trouble.");
+ "failed to get an even dma transfer, could be trouble.");
}
return residue;
}
@@ -1248,13 +1264,13 @@ static void das16_interrupt(struct comedi_device *dev)
/* 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)
devpriv->dma_transfer_size = devpriv->adc_byte_count;
/* re-enable dma */
if ((async->events & COMEDI_CB_EOA) == 0) {
set_dma_addr(devpriv->dma_chan,
- devpriv->dma_buffer_addr[devpriv->current_buffer]);
+ devpriv->dma_buffer_addr[devpriv->current_buffer]);
set_dma_count(devpriv->dma_chan, devpriv->dma_transfer_size);
enable_dma(devpriv->dma_chan);
/* reenable conversions for das1600 mode, (stupid hardware) */
@@ -1267,16 +1283,17 @@ static void das16_interrupt(struct comedi_device *dev)
spin_unlock_irqrestore(&dev->spinlock, spin_flags);
cfc_write_array_to_buffer(s,
- devpriv->dma_buffer[buffer_index], num_bytes);
+ devpriv->dma_buffer[buffer_index], num_bytes);
cfc_handle_events(dev, s);
}
static unsigned int das16_set_pacer(struct comedi_device *dev, unsigned int ns,
- int rounding_flags)
+ int rounding_flags)
{
i8253_cascade_ns_to_timer_2div(devpriv->clockbase, &(devpriv->divisor1),
- &(devpriv->divisor2), &ns, rounding_flags & TRIG_ROUND_MASK);
+ &(devpriv->divisor2), &ns,
+ rounding_flags & TRIG_ROUND_MASK);
/* Write the values of ctr1 and ctr2 into counters 1 and 2 */
i8254_load(dev->iobase + DAS16_CNTR0_DATA, 0, 1, devpriv->divisor1, 2);
@@ -1295,12 +1312,12 @@ static void reg_dump(struct comedi_device *dev)
DEBUG_PRINT("DAS16_PACER: %x\n", inb(dev->iobase + DAS16_PACER));
DEBUG_PRINT("DAS16_GAIN: %x\n", inb(dev->iobase + DAS16_GAIN));
DEBUG_PRINT("DAS16_CNTR_CONTROL: %x\n",
- inb(dev->iobase + DAS16_CNTR_CONTROL));
+ inb(dev->iobase + DAS16_CNTR_CONTROL));
DEBUG_PRINT("DAS1600_CONV: %x\n", inb(dev->iobase + DAS1600_CONV));
DEBUG_PRINT("DAS1600_BURST: %x\n", inb(dev->iobase + DAS1600_BURST));
DEBUG_PRINT("DAS1600_ENABLE: %x\n", inb(dev->iobase + DAS1600_ENABLE));
DEBUG_PRINT("DAS1600_STATUS_B: %x\n",
- inb(dev->iobase + DAS1600_STATUS_B));
+ inb(dev->iobase + DAS1600_STATUS_B));
}
static int das16_probe(struct comedi_device *dev, struct comedi_devconfig *it)
@@ -1331,7 +1348,7 @@ static int das16_probe(struct comedi_device *dev, struct comedi_devconfig *it)
printk(" id bits are 0x%02x\n", diobits);
if (thisboard->id != diobits) {
printk(" requested board's id bits are 0x%x (ignore)\n",
- thisboard->id);
+ thisboard->id);
}
return 0;
@@ -1393,8 +1410,9 @@ static int das16_attach(struct comedi_device *dev, struct comedi_devconfig *it)
/* check that clock setting is valid */
if (it->options[3]) {
if (it->options[3] != 0 &&
- it->options[3] != 1 && it->options[3] != 10) {
- printk("\n Invalid option. Master clock must be set to 1 or 10 (MHz)\n");
+ it->options[3] != 1 && it->options[3] != 10) {
+ printk
+ ("\n Invalid option. Master clock must be set to 1 or 10 (MHz)\n");
return -EINVAL;
}
}
@@ -1411,20 +1429,20 @@ static int das16_attach(struct comedi_device *dev, struct comedi_devconfig *it)
}
} else {
printk(" 0x%04lx-0x%04lx 0x%04lx-0x%04lx\n",
- iobase, iobase + 0x0f,
- iobase + 0x400,
- iobase + 0x400 + (thisboard->size & 0x3ff));
+ iobase, iobase + 0x0f,
+ iobase + 0x400,
+ iobase + 0x400 + (thisboard->size & 0x3ff));
if (!request_region(iobase, 0x10, "das16")) {
printk(" I/O port conflict: 0x%04lx-0x%04lx\n",
- iobase, iobase + 0x0f);
+ iobase, iobase + 0x0f);
return -EIO;
}
if (!request_region(iobase + 0x400, thisboard->size & 0x3ff,
- "das16")) {
+ "das16")) {
release_region(iobase, 0x10);
printk(" I/O port conflict: 0x%04lx-0x%04lx\n",
- iobase + 0x400,
- iobase + 0x400 + (thisboard->size & 0x3ff));
+ iobase + 0x400,
+ iobase + 0x400 + (thisboard->size & 0x3ff));
return -EIO;
}
}
@@ -1470,13 +1488,16 @@ static int das16_attach(struct comedi_device *dev, struct comedi_devconfig *it)
int i;
for (i = 0; i < 2; i++) {
devpriv->dma_buffer[i] = pci_alloc_consistent(NULL,
- DAS16_DMA_SIZE, &devpriv->dma_buffer_addr[i]);
+ DAS16_DMA_SIZE,
+ &devpriv->
+ dma_buffer_addr
+ [i]);
if (devpriv->dma_buffer[i] == NULL)
return -ENOMEM;
}
if (request_dma(dma_chan, "das16")) {
printk(" failed to allocate dma channel %i\n",
- dma_chan);
+ dma_chan);
return -EINVAL;
}
devpriv->dma_chan = dma_chan;
@@ -1494,11 +1515,11 @@ static int das16_attach(struct comedi_device *dev, struct comedi_devconfig *it)
/* get any user-defined input range */
if (thisboard->ai_pg == das16_pg_none &&
- (it->options[4] || it->options[5])) {
+ (it->options[4] || it->options[5])) {
/* allocate single-range range table */
devpriv->user_ai_range_table =
- kmalloc(sizeof(struct comedi_lrange) + sizeof(struct comedi_krange),
- GFP_KERNEL);
+ kmalloc(sizeof(struct comedi_lrange) +
+ sizeof(struct comedi_krange), GFP_KERNEL);
/* initialize ai range */
devpriv->user_ai_range_table->length = 1;
user_ai_range = devpriv->user_ai_range_table->range;
@@ -1510,8 +1531,8 @@ static int das16_attach(struct comedi_device *dev, struct comedi_devconfig *it)
if (it->options[6] || it->options[7]) {
/* allocate single-range range table */
devpriv->user_ao_range_table =
- kmalloc(sizeof(struct comedi_lrange) + sizeof(struct comedi_krange),
- GFP_KERNEL);
+ kmalloc(sizeof(struct comedi_lrange) +
+ sizeof(struct comedi_krange), GFP_KERNEL);
/* initialize ao range */
devpriv->user_ao_range_table->length = 1;
user_ao_range = devpriv->user_ao_range_table->range;
@@ -1612,7 +1633,7 @@ static int das16_attach(struct comedi_device *dev, struct comedi_devconfig *it)
/* 8255 */
if (thisboard->i8255_offset != 0) {
subdev_8255_init(dev, s, NULL, (dev->iobase +
- thisboard->i8255_offset));
+ thisboard->i8255_offset));
} else {
s->type = COMEDI_SUBD_UNUSED;
}
@@ -1646,8 +1667,9 @@ static int das16_detach(struct comedi_device *dev)
for (i = 0; i < 2; i++) {
if (devpriv->dma_buffer[i])
pci_free_consistent(NULL, DAS16_DMA_SIZE,
- devpriv->dma_buffer[i],
- devpriv->dma_buffer_addr[i]);
+ devpriv->dma_buffer[i],
+ devpriv->
+ dma_buffer_addr[i]);
}
if (devpriv->dma_chan)
free_dma(devpriv->dma_chan);
@@ -1666,7 +1688,7 @@ static int das16_detach(struct comedi_device *dev)
} else {
release_region(dev->iobase, 0x10);
release_region(dev->iobase + 0x400,
- thisboard->size & 0x3ff);
+ thisboard->size & 0x3ff);
}
}
@@ -1677,7 +1699,7 @@ 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,
- struct comedi_cmd cmd)
+ struct comedi_cmd cmd)
{
unsigned int size;
unsigned int freq;
@@ -1717,8 +1739,10 @@ 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,
- void *array, unsigned int num_bytes, unsigned int start_chan_index)
+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);
short *data = array;
diff --git a/drivers/staging/comedi/drivers/das16m1.c b/drivers/staging/comedi/drivers/das16m1.c
index 3da8bf47cbf6..c403d8827434 100644
--- a/drivers/staging/comedi/drivers/das16m1.c
+++ b/drivers/staging/comedi/drivers/das16m1.c
@@ -120,36 +120,41 @@ irq can be omitted, although the cmd interface will not work without it.
static const struct comedi_lrange range_das16m1 = { 9,
{
- BIP_RANGE(5),
- BIP_RANGE(2.5),
- BIP_RANGE(1.25),
- BIP_RANGE(0.625),
- UNI_RANGE(10),
- UNI_RANGE(5),
- UNI_RANGE(2.5),
- UNI_RANGE(1.25),
- BIP_RANGE(10),
- }
+ BIP_RANGE(5),
+ BIP_RANGE(2.5),
+ BIP_RANGE(1.25),
+ BIP_RANGE(0.625),
+ UNI_RANGE(10),
+ UNI_RANGE(5),
+ UNI_RANGE(2.5),
+ UNI_RANGE(1.25),
+ BIP_RANGE(10),
+ }
};
-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_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_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,
- int round_flag);
+static unsigned int das16m1_set_pacer(struct comedi_device *dev,
+ unsigned int ns, int round_flag);
static int das16m1_irq_bits(unsigned int irq);
@@ -160,12 +165,13 @@ 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 */
+ },
};
-static int das16m1_attach(struct comedi_device *dev, struct comedi_devconfig *it);
+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",
@@ -199,8 +205,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;
@@ -289,8 +295,10 @@ static int das16m1_cmd_test(struct comedi_device *dev, struct comedi_subdevice *
tmp = cmd->convert_arg;
/* calculate counter values that give desired timing */
i8253_cascade_ns_to_timer_2div(DAS16M1_XTAL,
- &(devpriv->divisor1), &(devpriv->divisor2),
- &(cmd->convert_arg), cmd->flags & TRIG_ROUND_MASK);
+ &(devpriv->divisor1),
+ &(devpriv->divisor2),
+ &(cmd->convert_arg),
+ cmd->flags & TRIG_ROUND_MASK);
if (tmp != cmd->convert_arg)
err++;
}
@@ -304,13 +312,13 @@ static int das16m1_cmd_test(struct comedi_device *dev, struct comedi_subdevice *
/* 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");
+ " even/odd channels must go have even/odd chanlist indices");
err++;
}
}
if ((cmd->chanlist_len % 2) != 0) {
comedi_error(dev,
- "chanlist must be of even length or length 1");
+ "chanlist must be of even length or length 1");
err++;
}
}
@@ -321,7 +329,8 @@ 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;
@@ -345,20 +354,20 @@ static int das16m1_cmd_exec(struct comedi_device *dev, struct comedi_subdevice *
/* remember current reading of counter so we know when counter has
* actually been loaded */
devpriv->initial_hw_count =
- i8254_read(dev->iobase + DAS16M1_8254_FIRST, 0, 1);
+ i8254_read(dev->iobase + DAS16M1_8254_FIRST, 0, 1);
/* setup channel/gain queue */
for (i = 0; i < cmd->chanlist_len; i++) {
outb(i, dev->iobase + DAS16M1_QUEUE_ADDR);
- byte = Q_CHAN(CR_CHAN(cmd->
- chanlist[i])) | Q_RANGE(CR_RANGE(cmd->
- chanlist[i]));
+ byte =
+ Q_CHAN(CR_CHAN(cmd->chanlist[i])) |
+ Q_RANGE(CR_RANGE(cmd->chanlist[i]));
outb(byte, dev->iobase + DAS16M1_QUEUE_DATA);
}
/* set counter mode and counts */
cmd->convert_arg =
- das16m1_set_pacer(dev, cmd->convert_arg,
- cmd->flags & TRIG_ROUND_MASK);
+ das16m1_set_pacer(dev, cmd->convert_arg,
+ cmd->flags & TRIG_ROUND_MASK);
/* set control & status register */
byte = 0;
@@ -392,8 +401,9 @@ static int das16m1_cancel(struct comedi_device *dev, struct comedi_subdevice *s)
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;
@@ -405,8 +415,8 @@ static int das16m1_ai_rinsn(struct comedi_device *dev, struct comedi_subdevice *
/* setup channel/gain queue */
outb(0, dev->iobase + DAS16M1_QUEUE_ADDR);
- byte = Q_CHAN(CR_CHAN(insn->chanspec)) | Q_RANGE(CR_RANGE(insn->
- chanspec));
+ byte =
+ Q_CHAN(CR_CHAN(insn->chanspec)) | Q_RANGE(CR_RANGE(insn->chanspec));
outb(byte, dev->iobase + DAS16M1_QUEUE_DATA);
for (n = 0; n < insn->n; n++) {
@@ -429,8 +439,9 @@ 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;
@@ -441,8 +452,9 @@ 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;
@@ -552,7 +564,7 @@ static void das16m1_handler(struct comedi_device *dev, unsigned int status)
insw(dev->iobase, devpriv->ai_buffer, num_samples);
munge_sample_array(devpriv->ai_buffer, num_samples);
cfc_write_array_to_buffer(s, devpriv->ai_buffer,
- num_samples * sizeof(short));
+ num_samples * sizeof(short));
devpriv->adc_count += num_samples;
if (cmd->stop_src == TRIG_COUNT) {
@@ -577,17 +589,18 @@ 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,
- int rounding_flags)
+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),
- &(devpriv->divisor2), &ns, rounding_flags & TRIG_ROUND_MASK);
+ &(devpriv->divisor2), &ns,
+ rounding_flags & TRIG_ROUND_MASK);
/* Write the values of ctr1 and ctr2 into counters 1 and 2 */
i8254_load(dev->iobase + DAS16M1_8254_SECOND, 0, 1, devpriv->divisor1,
- 2);
+ 2);
i8254_load(dev->iobase + DAS16M1_8254_SECOND, 0, 2, devpriv->divisor2,
- 2);
+ 2);
return ns;
}
@@ -634,7 +647,8 @@ 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;
@@ -652,14 +666,14 @@ static int das16m1_attach(struct comedi_device *dev, struct comedi_devconfig *it
dev->board_name = thisboard->name;
printk(" io 0x%lx-0x%lx 0x%lx-0x%lx",
- iobase, iobase + DAS16M1_SIZE,
- iobase + DAS16M1_82C55, iobase + DAS16M1_82C55 + DAS16M1_SIZE2);
+ iobase, iobase + DAS16M1_SIZE,
+ iobase + DAS16M1_82C55, iobase + DAS16M1_82C55 + DAS16M1_SIZE2);
if (!request_region(iobase, DAS16M1_SIZE, driver_das16m1.driver_name)) {
printk(" I/O port conflict\n");
return -EIO;
}
if (!request_region(iobase + DAS16M1_82C55, DAS16M1_SIZE2,
- driver_das16m1.driver_name)) {
+ driver_das16m1.driver_name)) {
release_region(iobase, DAS16M1_SIZE);
printk(" I/O port conflict\n");
return -EIO;
@@ -682,7 +696,7 @@ static int das16m1_attach(struct comedi_device *dev, struct comedi_devconfig *it
printk(", no irq\n");
} else {
printk(", invalid irq\n"
- " valid irqs are 2, 3, 5, 7, 10, 11, 12, or 15\n");
+ " valid irqs are 2, 3, 5, 7, 10, 11, 12, or 15\n");
return -EINVAL;
}
diff --git a/drivers/staging/comedi/drivers/das1800.c b/drivers/staging/comedi/drivers/das1800.c
index a3434088c9e6..6ea59cc6b2bb 100644
--- a/drivers/staging/comedi/drivers/das1800.c
+++ b/drivers/staging/comedi/drivers/das1800.c
@@ -181,33 +181,44 @@ enum {
das1802hr, das1802hr_da, das1801hc, das1802hc, das1801ao, das1802ao
};
-static int das1800_attach(struct comedi_device *dev, struct comedi_devconfig *it);
+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 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 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_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);
+ 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);
+ 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);
@@ -217,29 +228,29 @@ static unsigned int suggest_transfer_size(struct comedi_cmd *cmd);
static const struct comedi_lrange range_ai_das1801 = {
8,
{
- RANGE(-5, 5),
- RANGE(-1, 1),
- RANGE(-0.1, 0.1),
- RANGE(-0.02, 0.02),
- RANGE(0, 5),
- RANGE(0, 1),
- RANGE(0, 0.1),
- RANGE(0, 0.02),
- }
+ RANGE(-5, 5),
+ RANGE(-1, 1),
+ RANGE(-0.1, 0.1),
+ RANGE(-0.02, 0.02),
+ RANGE(0, 5),
+ RANGE(0, 1),
+ RANGE(0, 0.1),
+ RANGE(0, 0.02),
+ }
};
static const struct comedi_lrange range_ai_das1802 = {
8,
{
- RANGE(-10, 10),
- RANGE(-5, 5),
- RANGE(-2.5, 2.5),
- RANGE(-1.25, 1.25),
- RANGE(0, 10),
- RANGE(0, 5),
- RANGE(0, 2.5),
- RANGE(0, 1.25),
- }
+ RANGE(-10, 10),
+ RANGE(-5, 5),
+ RANGE(-2.5, 2.5),
+ RANGE(-1.25, 1.25),
+ RANGE(0, 10),
+ RANGE(0, 5),
+ RANGE(0, 2.5),
+ RANGE(0, 1.25),
+ }
};
struct das1800_board {
@@ -260,203 +271,203 @@ 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,
+ },
};
/*
@@ -490,8 +501,8 @@ struct das1800_private {
static const struct comedi_lrange range_ao_1 = {
1,
{
- RANGE(-10, 10),
- }
+ RANGE(-10, 10),
+ }
};
/* analog out range for 'ao' boards */
@@ -522,7 +533,7 @@ static struct comedi_driver driver_das1800 = {
COMEDI_INITCLEANUP(driver_das1800);
static int das1800_init_dma(struct comedi_device *dev, unsigned int dma0,
- unsigned int dma1)
+ unsigned int dma1)
{
unsigned long flags;
@@ -550,8 +561,8 @@ static int das1800_init_dma(struct comedi_device *dev, unsigned int dma0,
break;
default:
printk(" only supports dma channels 5 through 7\n"
- " Dual dma only allows the following combinations:\n"
- " dma 5,6 / 6,7 / or 7,5\n");
+ " Dual dma only allows the following combinations:\n"
+ " dma 5,6 / 6,7 / or 7,5\n");
return -EINVAL;
break;
}
@@ -564,7 +575,7 @@ static int das1800_init_dma(struct comedi_device *dev, unsigned int dma0,
if (dma1) {
if (request_dma(dma1, driver_das1800.driver_name)) {
printk(" failed to allocate dma channel %i\n",
- dma1);
+ dma1);
return -EINVAL;
}
devpriv->dma1 = dma1;
@@ -575,7 +586,7 @@ static int das1800_init_dma(struct comedi_device *dev, unsigned int dma0,
devpriv->dma_current_buf = devpriv->ai_buf0;
if (dma1) {
devpriv->ai_buf1 =
- kmalloc(DMA_BUF_SIZE, GFP_KERNEL | GFP_DMA);
+ kmalloc(DMA_BUF_SIZE, GFP_KERNEL | GFP_DMA);
if (devpriv->ai_buf1 == NULL)
return -ENOMEM;
}
@@ -591,7 +602,8 @@ 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];
@@ -607,7 +619,7 @@ static int das1800_attach(struct comedi_device *dev, struct comedi_devconfig *it
return -ENOMEM;
printk("comedi%d: %s: io 0x%lx", dev->minor, driver_das1800.driver_name,
- iobase);
+ iobase);
if (irq) {
printk(", irq %u", irq);
if (dma0) {
@@ -625,7 +637,9 @@ static int das1800_attach(struct comedi_device *dev, struct comedi_devconfig *it
/* check if io addresses are available */
if (!request_region(iobase, DAS1800_SIZE, driver_das1800.driver_name)) {
- printk(" I/O port conflict: failed to allocate ports 0x%lx to 0x%lx\n", iobase, iobase + DAS1800_SIZE - 1);
+ printk
+ (" I/O port conflict: failed to allocate ports 0x%lx to 0x%lx\n",
+ iobase, iobase + DAS1800_SIZE - 1);
return -EIO;
}
dev->iobase = iobase;
@@ -643,8 +657,10 @@ static int das1800_attach(struct comedi_device *dev, struct comedi_devconfig *it
if (thisboard->ao_ability == 2) {
iobase2 = iobase + IOBASE2;
if (!request_region(iobase2, DAS1800_SIZE,
- driver_das1800.driver_name)) {
- printk(" I/O port conflict: failed to allocate ports 0x%lx to 0x%lx\n", iobase2, iobase2 + DAS1800_SIZE - 1);
+ driver_das1800.driver_name)) {
+ printk
+ (" I/O port conflict: failed to allocate ports 0x%lx to 0x%lx\n",
+ iobase2, iobase2 + DAS1800_SIZE - 1);
return -EIO;
}
devpriv->iobase2 = iobase2;
@@ -694,7 +710,7 @@ static int das1800_attach(struct comedi_device *dev, struct comedi_devconfig *it
if (devpriv->ai_buf0 == NULL) {
devpriv->ai_buf0 =
- kmalloc(FIFO_SIZE * sizeof(uint16_t), GFP_KERNEL);
+ kmalloc(FIFO_SIZE * sizeof(uint16_t), GFP_KERNEL);
if (devpriv->ai_buf0 == NULL)
return -ENOMEM;
}
@@ -759,7 +775,7 @@ static int das1800_attach(struct comedi_device *dev, struct comedi_devconfig *it
if (thisboard->ao_ability == 1) {
/* select 'update' dac channel for baseAddress + 0x0 */
outb(DAC(thisboard->ao_n_chan - 1),
- dev->iobase + DAS1800_SELECT);
+ dev->iobase + DAS1800_SELECT);
outw(devpriv->ao_update_bits, dev->iobase + DAS1800_DAC);
}
@@ -787,7 +803,7 @@ static int das1800_detach(struct comedi_device *dev)
}
printk("comedi%d: %s: remove\n", dev->minor,
- driver_das1800.driver_name);
+ driver_das1800.driver_name);
return 0;
};
@@ -800,42 +816,45 @@ static int das1800_probe(struct comedi_device *dev)
int board;
id = (inb(dev->iobase + DAS1800_DIGITAL) >> 4) & 0xf; /* get id bits */
- board = ((struct das1800_board *) dev->board_ptr) - das1800_boards;
+ board = ((struct das1800_board *)dev->board_ptr) - das1800_boards;
switch (id) {
case 0x3:
if (board == das1801st_da || board == das1802st_da ||
- board == das1701st_da || board == das1702st_da) {
+ board == das1701st_da || board == das1702st_da) {
printk(" Board model: %s\n",
- das1800_boards[board].name);
+ das1800_boards[board].name);
return board;
}
- printk(" Board model (probed, not recommended): das-1800st-da series\n");
+ printk
+ (" Board model (probed, not recommended): das-1800st-da series\n");
return das1801st;
break;
case 0x4:
if (board == das1802hr_da || board == das1702hr_da) {
printk(" Board model: %s\n",
- das1800_boards[board].name);
+ das1800_boards[board].name);
return board;
}
- printk(" Board model (probed, not recommended): das-1802hr-da\n");
+ printk
+ (" Board model (probed, not recommended): das-1802hr-da\n");
return das1802hr;
break;
case 0x5:
if (board == das1801ao || board == das1802ao ||
- board == das1701ao || board == das1702ao) {
+ board == das1701ao || board == das1702ao) {
printk(" Board model: %s\n",
- das1800_boards[board].name);
+ das1800_boards[board].name);
return board;
}
- printk(" Board model (probed, not recommended): das-1800ao series\n");
+ printk
+ (" Board model (probed, not recommended): das-1800ao series\n");
return das1801ao;
break;
case 0x6:
if (board == das1802hr || board == das1702hr) {
printk(" Board model: %s\n",
- das1800_boards[board].name);
+ das1800_boards[board].name);
return board;
}
printk(" Board model (probed, not recommended): das-1802hr\n");
@@ -843,32 +862,37 @@ static int das1800_probe(struct comedi_device *dev)
break;
case 0x7:
if (board == das1801st || board == das1802st ||
- board == das1701st || board == das1702st) {
+ board == das1701st || board == das1702st) {
printk(" Board model: %s\n",
- das1800_boards[board].name);
+ das1800_boards[board].name);
return board;
}
- printk(" Board model (probed, not recommended): das-1800st series\n");
+ printk
+ (" Board model (probed, not recommended): das-1800st series\n");
return das1801st;
break;
case 0x8:
if (board == das1801hc || board == das1802hc) {
printk(" Board model: %s\n",
- das1800_boards[board].name);
+ das1800_boards[board].name);
return board;
}
- printk(" Board model (probed, not recommended): das-1800hc series\n");
+ printk
+ (" Board model (probed, not recommended): das-1800hc series\n");
return das1801hc;
break;
default:
- printk(" Board model: probe returned 0x%x (unknown, please report)\n", id);
+ printk
+ (" Board model: probe returned 0x%x (unknown, please report)\n",
+ id);
return board;
break;
}
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;
@@ -963,18 +987,18 @@ static void das1800_ai_handler(struct comedi_device *dev)
return;
}
-static void das1800_handle_dma(struct comedi_device *dev, struct comedi_subdevice *s,
- unsigned int status)
+static void das1800_handle_dma(struct comedi_device *dev,
+ struct comedi_subdevice *s, unsigned int status)
{
unsigned long flags;
const int dual_dma = devpriv->irq_dma_bits & DMA_DUAL;
flags = claim_dma_lock();
das1800_flush_dma_channel(dev, s, devpriv->dma_current,
- devpriv->dma_current_buf);
+ devpriv->dma_current_buf);
/* re-enable dma channel */
set_dma_addr(devpriv->dma_current,
- virt_to_bus(devpriv->dma_current_buf));
+ virt_to_bus(devpriv->dma_current_buf));
set_dma_count(devpriv->dma_current, devpriv->dma_transfer_size);
enable_dma(devpriv->dma_current);
release_dma_lock(flags);
@@ -999,14 +1023,14 @@ static void das1800_handle_dma(struct comedi_device *dev, struct comedi_subdevic
}
static inline uint16_t munge_bipolar_sample(const struct comedi_device *dev,
- uint16_t sample)
+ uint16_t sample)
{
sample += 1 << (thisboard->resolution - 1);
return sample;
}
-static void munge_data(struct comedi_device *dev, uint16_t *array,
- unsigned int num_elements)
+static void munge_data(struct comedi_device *dev, uint16_t * array,
+ unsigned int num_elements)
{
unsigned int i;
int unipolar;
@@ -1024,8 +1048,9 @@ 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;
@@ -1054,14 +1079,15 @@ static void das1800_flush_dma_channel(struct comedi_device *dev, struct comedi_s
/* 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;
flags = claim_dma_lock();
das1800_flush_dma_channel(dev, s, devpriv->dma_current,
- devpriv->dma_current_buf);
+ devpriv->dma_current_buf);
if (dual_dma) {
/* switch to other channel and flush it */
@@ -1073,7 +1099,7 @@ static void das1800_flush_dma(struct comedi_device *dev, struct comedi_subdevice
devpriv->dma_current_buf = devpriv->ai_buf0;
}
das1800_flush_dma_channel(dev, s, devpriv->dma_current,
- devpriv->dma_current_buf);
+ devpriv->dma_current_buf);
}
release_dma_lock(flags);
@@ -1085,7 +1111,7 @@ static void das1800_flush_dma(struct comedi_device *dev, struct comedi_subdevice
}
static void das1800_handle_fifo_half_full(struct comedi_device *dev,
- struct comedi_subdevice *s)
+ struct comedi_subdevice *s)
{
int numPoints = 0; /* number of points to read */
struct comedi_cmd *cmd = &s->async->cmd;
@@ -1097,14 +1123,14 @@ static void das1800_handle_fifo_half_full(struct comedi_device *dev,
insw(dev->iobase + DAS1800_FIFO, devpriv->ai_buf0, numPoints);
munge_data(dev, devpriv->ai_buf0, numPoints);
cfc_write_array_to_buffer(s, devpriv->ai_buf0,
- numPoints * sizeof(devpriv->ai_buf0[0]));
+ numPoints * sizeof(devpriv->ai_buf0[0]));
if (cmd->stop_src == TRIG_COUNT)
devpriv->count -= numPoints;
return;
}
static void das1800_handle_fifo_not_empty(struct comedi_device *dev,
- struct comedi_subdevice *s)
+ struct comedi_subdevice *s)
{
short dpnt;
int unipolar;
@@ -1140,8 +1166,9 @@ static int das1800_cancel(struct comedi_device *dev, struct comedi_subdevice *s)
}
/* 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;
@@ -1185,17 +1212,17 @@ static int das1800_ai_do_cmdtest(struct comedi_device *dev, struct comedi_subdev
if (cmd->start_src != TRIG_NOW && cmd->start_src != TRIG_EXT)
err++;
if (cmd->scan_begin_src != TRIG_FOLLOW &&
- cmd->scan_begin_src != TRIG_TIMER &&
- cmd->scan_begin_src != TRIG_EXT)
+ cmd->scan_begin_src != TRIG_TIMER &&
+ cmd->scan_begin_src != TRIG_EXT)
err++;
if (cmd->convert_src != TRIG_TIMER && cmd->convert_src != TRIG_EXT)
err++;
if (cmd->stop_src != TRIG_COUNT &&
- cmd->stop_src != TRIG_NONE && cmd->stop_src != TRIG_EXT)
+ cmd->stop_src != TRIG_NONE && cmd->stop_src != TRIG_EXT)
err++;
/* compatibility check */
if (cmd->scan_begin_src != TRIG_FOLLOW &&
- cmd->convert_src != TRIG_TIMER)
+ cmd->convert_src != TRIG_TIMER)
err++;
if (err)
@@ -1250,9 +1277,11 @@ static int das1800_ai_do_cmdtest(struct comedi_device *dev, struct comedi_subdev
tmp_arg = cmd->convert_arg;
/* calculate counter values that give desired timing */
i8253_cascade_ns_to_timer_2div(TIMER_BASE,
- &(devpriv->divisor1), &(devpriv->divisor2),
- &(cmd->convert_arg),
- cmd->flags & TRIG_ROUND_MASK);
+ &(devpriv->divisor1),
+ &(devpriv->divisor2),
+ &(cmd->convert_arg),
+ cmd->
+ flags & TRIG_ROUND_MASK);
if (tmp_arg != cmd->convert_arg)
err++;
}
@@ -1261,27 +1290,32 @@ static int das1800_ai_do_cmdtest(struct comedi_device *dev, struct comedi_subdev
/* check that convert_arg is compatible */
tmp_arg = cmd->convert_arg;
cmd->convert_arg =
- burst_convert_arg(cmd->convert_arg,
- cmd->flags & TRIG_ROUND_MASK);
+ burst_convert_arg(cmd->convert_arg,
+ cmd->flags & TRIG_ROUND_MASK);
if (tmp_arg != cmd->convert_arg)
err++;
if (cmd->scan_begin_src == TRIG_TIMER) {
/* if scans are timed faster than conversion rate allows */
if (cmd->convert_arg * cmd->chanlist_len >
- cmd->scan_begin_arg) {
+ cmd->scan_begin_arg) {
cmd->scan_begin_arg =
- cmd->convert_arg *
- cmd->chanlist_len;
+ cmd->convert_arg *
+ cmd->chanlist_len;
err++;
}
tmp_arg = cmd->scan_begin_arg;
/* calculate counter values that give desired timing */
i8253_cascade_ns_to_timer_2div(TIMER_BASE,
- &(devpriv->divisor1),
- &(devpriv->divisor2),
- &(cmd->scan_begin_arg),
- cmd->flags & TRIG_ROUND_MASK);
+ &(devpriv->
+ divisor1),
+ &(devpriv->
+ divisor2),
+ &(cmd->
+ scan_begin_arg),
+ cmd->
+ flags &
+ TRIG_ROUND_MASK);
if (tmp_arg != cmd->scan_begin_arg)
err++;
}
@@ -1297,7 +1331,7 @@ static int das1800_ai_do_cmdtest(struct comedi_device *dev, struct comedi_subdev
for (i = 1; i < cmd->chanlist_len; i++) {
if (unipolar != (CR_RANGE(cmd->chanlist[i]) & UNIPOLAR)) {
comedi_error(dev,
- "unipolar and bipolar ranges cannot be mixed in the chanlist");
+ "unipolar and bipolar ranges cannot be mixed in the chanlist");
err++;
break;
}
@@ -1394,9 +1428,11 @@ static int setup_counters(struct comedi_device *dev, struct comedi_cmd cmd)
if (cmd.convert_src == TRIG_TIMER) {
/* set conversion frequency */
i8253_cascade_ns_to_timer_2div(TIMER_BASE,
- &(devpriv->divisor1), &(devpriv->divisor2),
- &(cmd.convert_arg),
- cmd.flags & TRIG_ROUND_MASK);
+ &(devpriv->divisor1),
+ &(devpriv->divisor2),
+ &(cmd.convert_arg),
+ cmd.
+ flags & TRIG_ROUND_MASK);
if (das1800_set_frequency(dev) < 0) {
return -1;
}
@@ -1405,8 +1441,9 @@ static int setup_counters(struct comedi_device *dev, struct comedi_cmd cmd)
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),
- cmd.flags & TRIG_ROUND_MASK);
+ &(devpriv->divisor2),
+ &(cmd.scan_begin_arg),
+ cmd.flags & TRIG_ROUND_MASK);
if (das1800_set_frequency(dev) < 0) {
return -1;
}
@@ -1478,9 +1515,9 @@ static void program_chanlist(struct comedi_device *dev, struct comedi_cmd cmd)
/* make channel / gain list */
for (i = 0; i < n; i++) {
chan_range =
- CR_CHAN(cmd.chanlist[i]) | ((CR_RANGE(cmd.
- chanlist[i]) & range_mask) <<
- range_bitshift);
+ CR_CHAN(cmd.
+ chanlist[i]) | ((CR_RANGE(cmd.chanlist[i]) &
+ range_mask) << range_bitshift);
outw(chan_range, dev->iobase + DAS1800_QRAM);
}
outb(n - 1, dev->iobase + DAS1800_QRAM_ADDRESS); /*finish write to QRAM */
@@ -1490,7 +1527,8 @@ static void program_chanlist(struct comedi_device *dev, struct comedi_cmd cmd)
}
/* analog input do_cmd */
-static int das1800_ai_do_cmd(struct comedi_device *dev, struct comedi_subdevice *s)
+static int das1800_ai_do_cmd(struct comedi_device *dev,
+ struct comedi_subdevice *s)
{
int ret;
int control_a, control_c;
@@ -1499,7 +1537,7 @@ static int das1800_ai_do_cmd(struct comedi_device *dev, struct comedi_subdevice
if (!dev->irq) {
comedi_error(dev,
- "no irq assigned for das-1800, cannot do hardware conversions");
+ "no irq assigned for das-1800, cannot do hardware conversions");
return -1;
}
@@ -1542,7 +1580,7 @@ static int das1800_ai_do_cmd(struct comedi_device *dev, struct comedi_subdevice
if (control_c & BMDE) {
/* program conversion period with number of microseconds minus 1 */
outb(cmd.convert_arg / 1000 - 1,
- dev->iobase + DAS1800_BURST_RATE);
+ 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 */
@@ -1553,8 +1591,9 @@ 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;
@@ -1613,8 +1652,9 @@ static int das1800_ai_rinsn(struct comedi_device *dev, struct comedi_subdevice *
}
/* 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); */
@@ -1642,8 +1682,9 @@ static int das1800_ao_winsn(struct comedi_device *dev, struct comedi_subdevice *
}
/* 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;
@@ -1653,8 +1694,9 @@ 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;
@@ -1679,11 +1721,11 @@ static int das1800_set_frequency(struct comedi_device *dev)
/* counter 1, mode 2 */
if (i8254_load(dev->iobase + DAS1800_COUNTER, 0, 1, devpriv->divisor1,
- 2))
+ 2))
err++;
/* counter 2, mode 2 */
if (i8254_load(dev->iobase + DAS1800_COUNTER, 0, 2, devpriv->divisor2,
- 2))
+ 2))
err++;
if (err)
return -1;
@@ -1736,7 +1778,7 @@ static unsigned int suggest_transfer_size(struct comedi_cmd *cmd)
break;
case TRIG_TIMER:
size = (fill_time / (cmd->scan_begin_arg * cmd->chanlist_len)) *
- sample_size;
+ sample_size;
break;
default:
size = DMA_BUF_SIZE;
@@ -1747,7 +1789,7 @@ static unsigned int suggest_transfer_size(struct comedi_cmd *cmd)
max_size = DMA_BUF_SIZE;
/* 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)
+ cmd->stop_arg * cmd->chanlist_len * sample_size < max_size)
max_size = cmd->stop_arg * cmd->chanlist_len * sample_size;
if (size > max_size)
diff --git a/drivers/staging/comedi/drivers/das6402.c b/drivers/staging/comedi/drivers/das6402.c
index 0114eb935305..92487f58fd8b 100644
--- a/drivers/staging/comedi/drivers/das6402.c
+++ b/drivers/staging/comedi/drivers/das6402.c
@@ -99,7 +99,8 @@ 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_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",
@@ -117,7 +118,8 @@ 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)
{
@@ -163,7 +165,7 @@ static irqreturn_t intr_handler(int irq, void *d)
}
#ifdef DEBUG
printk("das6402: interrupt! das6402_irqcount=%i\n",
- devpriv->das6402_irqcount);
+ devpriv->das6402_irqcount);
printk("das6402: iobase+2=%i\n", inw_p(dev->iobase + 2));
#endif
@@ -174,7 +176,7 @@ static irqreturn_t intr_handler(int irq, void *d)
outb(0x07, dev->iobase + 8); /* clears all flip-flops */
#ifdef DEBUG
printk("das6402: Got %i samples\n\n",
- devpriv->das6402_wordsread - diff);
+ devpriv->das6402_wordsread - diff);
#endif
s->async->events |= COMEDI_CB_EOA;
comedi_event(dev, s);
@@ -196,7 +198,8 @@ 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))
@@ -205,7 +208,8 @@ static void das6402_ai_fifo_dregs(struct comedi_device *dev, struct comedi_subde
}
}
-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
@@ -227,8 +231,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;
@@ -300,7 +304,8 @@ static int das6402_detach(struct comedi_device *dev)
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;
diff --git a/drivers/staging/comedi/drivers/das800.c b/drivers/staging/comedi/drivers/das800.c
index 70e9d699c7a3..ecb97cdbce26 100644
--- a/drivers/staging/comedi/drivers/das800.c
+++ b/drivers/staging/comedi/drivers/das800.c
@@ -118,114 +118,114 @@ struct das800_board {
static const struct comedi_lrange range_das800_ai = {
1,
{
- RANGE(-5, 5),
- }
+ RANGE(-5, 5),
+ }
};
static const struct comedi_lrange range_das801_ai = {
9,
{
- RANGE(-5, 5),
- RANGE(-10, 10),
- RANGE(0, 10),
- RANGE(-0.5, 0.5),
- RANGE(0, 1),
- RANGE(-0.05, 0.05),
- RANGE(0, 0.1),
- RANGE(-0.01, 0.01),
- RANGE(0, 0.02),
- }
+ RANGE(-5, 5),
+ RANGE(-10, 10),
+ RANGE(0, 10),
+ RANGE(-0.5, 0.5),
+ RANGE(0, 1),
+ RANGE(-0.05, 0.05),
+ RANGE(0, 0.1),
+ RANGE(-0.01, 0.01),
+ RANGE(0, 0.02),
+ }
};
static const struct comedi_lrange range_cio_das801_ai = {
9,
{
- RANGE(-5, 5),
- RANGE(-10, 10),
- RANGE(0, 10),
- RANGE(-0.5, 0.5),
- RANGE(0, 1),
- RANGE(-0.05, 0.05),
- RANGE(0, 0.1),
- RANGE(-0.005, 0.005),
- RANGE(0, 0.01),
- }
+ RANGE(-5, 5),
+ RANGE(-10, 10),
+ RANGE(0, 10),
+ RANGE(-0.5, 0.5),
+ RANGE(0, 1),
+ RANGE(-0.05, 0.05),
+ RANGE(0, 0.1),
+ RANGE(-0.005, 0.005),
+ RANGE(0, 0.01),
+ }
};
static const struct comedi_lrange range_das802_ai = {
9,
{
- RANGE(-5, 5),
- RANGE(-10, 10),
- RANGE(0, 10),
- RANGE(-2.5, 2.5),
- RANGE(0, 5),
- RANGE(-1.25, 1.25),
- RANGE(0, 2.5),
- RANGE(-0.625, 0.625),
- RANGE(0, 1.25),
- }
+ RANGE(-5, 5),
+ RANGE(-10, 10),
+ RANGE(0, 10),
+ RANGE(-2.5, 2.5),
+ RANGE(0, 5),
+ RANGE(-1.25, 1.25),
+ RANGE(0, 2.5),
+ RANGE(-0.625, 0.625),
+ RANGE(0, 1.25),
+ }
};
static const struct comedi_lrange range_das80216_ai = {
8,
{
- RANGE(-10, 10),
- RANGE(0, 10),
- RANGE(-5, 5),
- RANGE(0, 5),
- RANGE(-2.5, 2.5),
- RANGE(0, 2.5),
- RANGE(-1.25, 1.25),
- RANGE(0, 1.25),
- }
+ RANGE(-10, 10),
+ RANGE(0, 10),
+ RANGE(-5, 5),
+ RANGE(0, 5),
+ RANGE(-2.5, 2.5),
+ RANGE(0, 2.5),
+ RANGE(-1.25, 1.25),
+ RANGE(0, 1.25),
+ }
};
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,
+ },
};
/*
@@ -243,7 +243,8 @@ 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_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);
@@ -260,15 +261,20 @@ static struct comedi_driver driver_das800 = {
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_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);
@@ -330,7 +336,7 @@ static int das800_probe(struct comedi_device *dev)
break;
default:
printk(" Board model: probe returned 0x%x (unknown)\n",
- id_bits);
+ id_bits);
return board;
break;
}
@@ -429,7 +435,7 @@ static irqreturn_t das800_interrupt(int irq, void *d)
* We already have spinlock, so indirect addressing is safe */
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);
+ dev->iobase + DAS800_CONTROL1);
spin_unlock_irqrestore(&dev->spinlock, irq_flags);
/* otherwise, stop taking data */
} else {
@@ -585,8 +591,9 @@ static void disable_das800(struct comedi_device *dev)
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;
@@ -676,8 +683,9 @@ static int das800_ai_do_cmdtest(struct comedi_device *dev, struct comedi_subdevi
tmp = cmd->convert_arg;
/* calculate counter values that give desired timing */
i8253_cascade_ns_to_timer_2div(TIMER_BASE, &(devpriv->divisor1),
- &(devpriv->divisor2), &(cmd->convert_arg),
- cmd->flags & TRIG_ROUND_MASK);
+ &(devpriv->divisor2),
+ &(cmd->convert_arg),
+ cmd->flags & TRIG_ROUND_MASK);
if (tmp != cmd->convert_arg)
err++;
}
@@ -691,14 +699,14 @@ static int das800_ai_do_cmdtest(struct comedi_device *dev, struct comedi_subdevi
startChan = CR_CHAN(cmd->chanlist[0]);
for (i = 1; i < cmd->chanlist_len; i++) {
if (CR_CHAN(cmd->chanlist[i]) !=
- (startChan + i) % N_CHAN_AI) {
+ (startChan + i) % N_CHAN_AI) {
comedi_error(dev,
- "entries in chanlist must be consecutive channels, counting upwards\n");
+ "entries in chanlist must be consecutive channels, counting upwards\n");
err++;
}
if (CR_RANGE(cmd->chanlist[i]) != gain) {
comedi_error(dev,
- "entries in chanlist must all have the same gain\n");
+ "entries in chanlist must all have the same gain\n");
err++;
}
}
@@ -710,7 +718,8 @@ static int das800_ai_do_cmdtest(struct comedi_device *dev, struct comedi_subdevi
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;
@@ -719,7 +728,7 @@ static int das800_ai_do_cmd(struct comedi_device *dev, struct comedi_subdevice *
if (!dev->irq) {
comedi_error(dev,
- "no irq assigned for das-800, cannot do hardware conversions");
+ "no irq assigned for das-800, cannot do hardware conversions");
return -1;
}
@@ -767,8 +776,10 @@ static int das800_ai_do_cmd(struct comedi_device *dev, struct comedi_subdevice *
conv_bits |= CASC | ITE;
/* set conversion frequency */
i8253_cascade_ns_to_timer_2div(TIMER_BASE, &(devpriv->divisor1),
- &(devpriv->divisor2), &(async->cmd.convert_arg),
- async->cmd.flags & TRIG_ROUND_MASK);
+ &(devpriv->divisor2),
+ &(async->cmd.convert_arg),
+ async->cmd.
+ flags & TRIG_ROUND_MASK);
if (das800_set_frequency(dev) < 0) {
comedi_error(dev, "Error setting up counters");
return -1;
@@ -789,8 +800,9 @@ static int das800_ai_do_cmd(struct comedi_device *dev, struct comedi_subdevice *
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;
@@ -843,8 +855,9 @@ static int das800_ai_rinsn(struct comedi_device *dev, struct comedi_subdevice *s
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;
@@ -856,8 +869,9 @@ static int das800_di_rbits(struct comedi_device *dev, struct comedi_subdevice *s
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;
diff --git a/drivers/staging/comedi/drivers/dmm32at.c b/drivers/staging/comedi/drivers/dmm32at.c
index 573cbe72b20b..aeec1ee9ad6b 100644
--- a/drivers/staging/comedi/drivers/dmm32at.c
+++ b/drivers/staging/comedi/drivers/dmm32at.c
@@ -168,11 +168,11 @@ Configuration Options:
static const struct comedi_lrange dmm32at_airanges = {
4,
{
- UNI_RANGE(10),
- UNI_RANGE(5),
- BIP_RANGE(10),
- BIP_RANGE(5),
- }
+ UNI_RANGE(10),
+ UNI_RANGE(5),
+ BIP_RANGE(10),
+ BIP_RANGE(5),
+ }
};
/* register values for above ranges */
@@ -189,11 +189,11 @@ static const unsigned char dmm32at_rangebits[] = {
static const struct comedi_lrange dmm32at_aoranges = {
4,
{
- UNI_RANGE(10),
- UNI_RANGE(5),
- BIP_RANGE(10),
- BIP_RANGE(5),
- }
+ UNI_RANGE(10),
+ UNI_RANGE(5),
+ BIP_RANGE(10),
+ BIP_RANGE(5),
+ }
};
/*
@@ -214,16 +214,16 @@ 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,
+ },
};
/*
@@ -259,7 +259,8 @@ 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_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",
@@ -290,20 +291,29 @@ static struct comedi_driver driver_dmm32at = {
};
/* 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);
void dmm32at_setaitimer(struct comedi_device *dev, unsigned int nansec);
@@ -314,7 +324,8 @@ 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;
@@ -369,12 +380,12 @@ static int dmm32at_attach(struct comedi_device *dev, struct comedi_devconfig *it
airback = dmm_inb(dev, DMM32AT_AIRBACK);
printk("dmm32at: lo=0x%02x hi=0x%02x fifostat=0x%02x\n",
- ailo, aihi, fifostat);
+ ailo, aihi, fifostat);
printk("dmm32at: aistat=0x%02x intstat=0x%02x airback=0x%02x\n",
- aistat, intstat, airback);
+ aistat, intstat, airback);
if ((ailo != 0x00) || (aihi != 0x1f) || (fifostat != 0x80) ||
- (aistat != 0x60 || (intstat != 0x00) || airback != 0x0c)) {
+ (aistat != 0x60 || (intstat != 0x00) || airback != 0x0c)) {
printk("dmmat32: board detection failed\n");
return -EIO;
}
@@ -450,7 +461,7 @@ static int dmm32at_attach(struct comedi_device *dev, struct comedi_devconfig *it
dmm_outb(dev, DMM32AT_CNTRL, DMM32AT_DIOACC);
/* set the DIO's to the defualt input setting */
devpriv->dio_config = DMM32AT_DIRA | DMM32AT_DIRB |
- DMM32AT_DIRCL | DMM32AT_DIRCH | DMM32AT_DIENABLE;
+ DMM32AT_DIRCL | DMM32AT_DIRCH | DMM32AT_DIENABLE;
dmm_outb(dev, DMM32AT_DIOCONF, devpriv->dio_config);
/* set up the subdevice */
@@ -497,8 +508,9 @@ 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;
@@ -568,8 +580,9 @@ 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;
@@ -618,7 +631,7 @@ static int dmm32at_ai_cmdtest(struct comedi_device *dev, struct comedi_subdevice
/* note that mutual compatiblity is not an issue here */
if (cmd->scan_begin_src != TRIG_TIMER &&
- cmd->scan_begin_src != TRIG_EXT)
+ cmd->scan_begin_src != TRIG_EXT)
err++;
if (cmd->convert_src != TRIG_TIMER && cmd->convert_src != TRIG_EXT)
err++;
@@ -703,21 +716,21 @@ static int dmm32at_ai_cmdtest(struct comedi_device *dev, struct comedi_subdevice
if (cmd->scan_begin_src == TRIG_TIMER) {
tmp = cmd->scan_begin_arg;
dmm32at_ns_to_timer(&cmd->scan_begin_arg,
- cmd->flags & TRIG_ROUND_MASK);
+ cmd->flags & TRIG_ROUND_MASK);
if (tmp != cmd->scan_begin_arg)
err++;
}
if (cmd->convert_src == TRIG_TIMER) {
tmp = cmd->convert_arg;
dmm32at_ns_to_timer(&cmd->convert_arg,
- cmd->flags & TRIG_ROUND_MASK);
+ cmd->flags & TRIG_ROUND_MASK);
if (tmp != cmd->convert_arg)
err++;
if (cmd->scan_begin_src == TRIG_TIMER &&
- cmd->scan_begin_arg <
- cmd->convert_arg * cmd->scan_end_arg) {
+ cmd->scan_begin_arg <
+ cmd->convert_arg * cmd->scan_end_arg) {
cmd->scan_begin_arg =
- cmd->convert_arg * cmd->scan_end_arg;
+ cmd->convert_arg * cmd->scan_end_arg;
err++;
}
}
@@ -733,14 +746,14 @@ static int dmm32at_ai_cmdtest(struct comedi_device *dev, struct comedi_subdevice
start_chan = CR_CHAN(cmd->chanlist[0]);
for (i = 1; i < cmd->chanlist_len; i++) {
if (CR_CHAN(cmd->chanlist[i]) !=
- (start_chan + i) % s->n_chan) {
+ (start_chan + i) % s->n_chan) {
comedi_error(dev,
- "entries in chanlist must be consecutive channels, counting upwards\n");
+ "entries in chanlist must be consecutive channels, counting upwards\n");
err++;
}
if (CR_RANGE(cmd->chanlist[i]) != gain) {
comedi_error(dev,
- "entries in chanlist must all have the same gain\n");
+ "entries in chanlist must all have the same gain\n");
err++;
}
}
@@ -822,7 +835,8 @@ 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_cancel(struct comedi_device *dev,
+ struct comedi_subdevice *s)
{
devpriv->ai_scans_left = 1;
return 0;
@@ -893,8 +907,9 @@ 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);
@@ -936,8 +951,9 @@ 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 +969,9 @@ 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;
@@ -975,7 +992,7 @@ static int dmm32at_dio_insn_bits(struct comedi_device *dev, struct comedi_subdev
/* if either part of dio is set for output */
if (((devpriv->dio_config & DMM32AT_DIRCL) == 0) ||
- ((devpriv->dio_config & DMM32AT_DIRCH) == 0)) {
+ ((devpriv->dio_config & DMM32AT_DIRCH) == 0)) {
diobits = (s->state & 0x00ff0000) >> 16;
dmm_outb(dev, DMM32AT_DIOC, diobits);
}
@@ -1006,8 +1023,9 @@ static int dmm32at_dio_insn_bits(struct comedi_device *dev, struct comedi_subdev
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);
diff --git a/drivers/staging/comedi/drivers/dt2801.c b/drivers/staging/comedi/drivers/dt2801.c
index 25a9b213b6f1..7b9af5d755e0 100644
--- a/drivers/staging/comedi/drivers/dt2801.c
+++ b/drivers/staging/comedi/drivers/dt2801.c
@@ -88,7 +88,8 @@ 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_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",
@@ -102,37 +103,57 @@ COMEDI_INITCLEANUP(driver_dt2801);
#if 0
/* ignore 'defined but not used' warning */
static const struct comedi_lrange range_dt2801_ai_pgh_bipolar = { 4, {
- RANGE(-10, 10),
- RANGE(-5, 5),
- RANGE(-2.5, 2.5),
- RANGE(-1.25, 1.25),
- }
+ RANGE(-10,
+ 10),
+ RANGE(-5,
+ 5),
+ RANGE
+ (-2.5,
+ 2.5),
+ RANGE
+ (-1.25,
+ 1.25),
+ }
};
#endif
static const struct comedi_lrange range_dt2801_ai_pgl_bipolar = { 4, {
- RANGE(-10, 10),
- RANGE(-1, 1),
- RANGE(-0.1, 0.1),
- RANGE(-0.02, 0.02),
- }
+ RANGE(-10,
+ 10),
+ RANGE(-1,
+ 1),
+ RANGE
+ (-0.1,
+ 0.1),
+ RANGE
+ (-0.02,
+ 0.02),
+ }
};
#if 0
/* ignore 'defined but not used' warning */
static const struct comedi_lrange range_dt2801_ai_pgh_unipolar = { 4, {
- RANGE(0, 10),
- RANGE(0, 5),
- RANGE(0, 2.5),
- RANGE(0, 1.25),
- }
+ RANGE(0,
+ 10),
+ RANGE(0,
+ 5),
+ RANGE(0,
+ 2.5),
+ RANGE(0,
+ 1.25),
+ }
};
#endif
static const struct comedi_lrange range_dt2801_ai_pgl_unipolar = { 4, {
- RANGE(0, 10),
- RANGE(0, 1),
- RANGE(0, 0.1),
- RANGE(0, 0.02),
- }
+ RANGE(0,
+ 10),
+ RANGE(0,
+ 1),
+ RANGE(0,
+ 0.1),
+ RANGE(0,
+ 0.02),
+ }
};
struct dt2801_board {
@@ -146,75 +167,74 @@ struct dt2801_board {
int dabits;
};
-
/* Typeid's for the different boards of the DT2801-series
(taken from the test-software, that comes with the 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 boardtype (*(const struct dt2801_board *)dev->board_ptr)
@@ -227,16 +247,21 @@ 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
@@ -299,7 +324,8 @@ static int dt2801_writedata(struct comedi_device *dev, unsigned int data)
}
#if 0
if (stat & DT_S_READY) {
- printk("dt2801: ready flag set (bad!) in dt2801_writedata()\n");
+ printk
+ ("dt2801: ready flag set (bad!) in dt2801_writedata()\n");
return -EIO;
}
#endif
@@ -353,7 +379,8 @@ static int dt2801_writecmd(struct comedi_device *dev, int command)
stat = inb_p(dev->iobase + DT2801_STATUS);
if (stat & DT_S_COMPOSITE_ERROR) {
- printk("dt2801: composite-error in dt2801_writecmd(), ignoring\n");
+ printk
+ ("dt2801: composite-error in dt2801_writecmd(), ignoring\n");
}
if (!(stat & DT_S_READY)) {
printk("dt2801: !ready in dt2801_writecmd(), ignoring\n");
@@ -463,8 +490,8 @@ static const struct comedi_lrange *ai_range_lkup(int type, int opt)
switch (type) {
case 0:
return (opt) ?
- &range_dt2801_ai_pgl_unipolar :
- &range_dt2801_ai_pgl_bipolar;
+ &range_dt2801_ai_pgl_unipolar :
+ &range_dt2801_ai_pgl_bipolar;
case 1:
return (opt) ? &range_unipolar10 : &range_bipolar10;
case 2:
@@ -510,10 +537,10 @@ static int dt2801_attach(struct comedi_device *dev, struct comedi_devconfig *it)
goto havetype;
}
printk("dt2801: unrecognized board code=0x%02x, contact author\n",
- board_code);
+ board_code);
type = 0;
- havetype:
+havetype:
dev->board_ptr = boardtypes + type;
printk("dt2801: %s at port 0x%lx", boardtype.name, iobase);
@@ -579,7 +606,7 @@ static int dt2801_attach(struct comedi_device *dev, struct comedi_devconfig *it)
s->insn_config = dt2801_dio_insn_config;
ret = 0;
- out:
+out:
printk("\n");
return ret;
@@ -611,8 +638,9 @@ 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;
@@ -633,16 +661,18 @@ static int dt2801_ai_insn_read(struct comedi_device *dev, struct comedi_subdevic
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));
@@ -653,8 +683,9 @@ static int dt2801_ao_insn_write(struct comedi_device *dev, struct comedi_subdevi
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;
@@ -677,8 +708,9 @@ static int dt2801_dio_insn_bits(struct comedi_device *dev, struct comedi_subdevi
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 7853902be621..51ef695698a3 100644
--- a/drivers/staging/comedi/drivers/dt2811.c
+++ b/drivers/staging/comedi/drivers/dt2811.c
@@ -53,46 +53,95 @@ Configuration options:
static const char *driver_name = "dt2811";
static const struct comedi_lrange range_dt2811_pgh_ai_5_unipolar = { 4, {
- RANGE(0, 5),
- RANGE(0, 2.5),
- RANGE(0, 1.25),
- RANGE(0, 0.625)
- }
+ RANGE
+ (0, 5),
+ RANGE
+ (0,
+ 2.5),
+ RANGE
+ (0,
+ 1.25),
+ RANGE
+ (0,
+ 0.625)
+ }
};
+
static const struct comedi_lrange range_dt2811_pgh_ai_2_5_bipolar = { 4, {
- RANGE(-2.5, 2.5),
- RANGE(-1.25, 1.25),
- RANGE(-0.625, 0.625),
- RANGE(-0.3125, 0.3125)
- }
+ RANGE
+ (-2.5,
+ 2.5),
+ RANGE
+ (-1.25,
+ 1.25),
+ RANGE
+ (-0.625,
+ 0.625),
+ RANGE
+ (-0.3125,
+ 0.3125)
+ }
};
+
static const struct comedi_lrange range_dt2811_pgh_ai_5_bipolar = { 4, {
- RANGE(-5, 5),
- RANGE(-2.5, 2.5),
- RANGE(-1.25, 1.25),
- RANGE(-0.625, 0.625)
- }
+ RANGE
+ (-5, 5),
+ RANGE
+ (-2.5,
+ 2.5),
+ RANGE
+ (-1.25,
+ 1.25),
+ RANGE
+ (-0.625,
+ 0.625)
+ }
};
+
static const struct comedi_lrange range_dt2811_pgl_ai_5_unipolar = { 4, {
- RANGE(0, 5),
- RANGE(0, 0.5),
- RANGE(0, 0.05),
- RANGE(0, 0.01)
- }
+ RANGE
+ (0, 5),
+ RANGE
+ (0,
+ 0.5),
+ RANGE
+ (0,
+ 0.05),
+ RANGE
+ (0,
+ 0.01)
+ }
};
+
static const struct comedi_lrange range_dt2811_pgl_ai_2_5_bipolar = { 4, {
- RANGE(-2.5, 2.5),
- RANGE(-0.25, 0.25),
- RANGE(-0.025, 0.025),
- RANGE(-0.005, 0.005)
- }
+ RANGE
+ (-2.5,
+ 2.5),
+ RANGE
+ (-0.25,
+ 0.25),
+ RANGE
+ (-0.025,
+ 0.025),
+ RANGE
+ (-0.005,
+ 0.005)
+ }
};
+
static const struct comedi_lrange range_dt2811_pgl_ai_5_bipolar = { 4, {
- RANGE(-5, 5),
- RANGE(-0.5, 0.5),
- RANGE(-0.05, 0.05),
- RANGE(-0.01, 0.01)
- }
+ RANGE
+ (-5, 5),
+ RANGE
+ (-0.5,
+ 0.5),
+ RANGE
+ (-0.05,
+ 0.05),
+ RANGE
+ (-0.01,
+ 0.01)
+ }
};
/*
@@ -202,20 +251,21 @@ struct dt2811_board {
static const struct dt2811_board boardtypes[] = {
{"dt2811-pgh",
- &range_dt2811_pgh_ai_5_bipolar,
- &range_dt2811_pgh_ai_2_5_bipolar,
- &range_dt2811_pgh_ai_5_unipolar,
- },
+ &range_dt2811_pgh_ai_5_bipolar,
+ &range_dt2811_pgh_ai_2_5_bipolar,
+ &range_dt2811_pgh_ai_5_unipolar,
+ },
{"dt2811-pgl",
- &range_dt2811_pgl_ai_5_bipolar,
- &range_dt2811_pgl_ai_2_5_bipolar,
- &range_dt2811_pgl_ai_5_unipolar,
- },
+ &range_dt2811_pgl_ai_5_bipolar,
+ &range_dt2811_pgl_ai_2_5_bipolar,
+ &range_dt2811_pgl_ai_5_unipolar,
+ },
};
#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_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",
@@ -230,15 +280,18 @@ static struct comedi_driver driver_dt2811 = {
COMEDI_INITCLEANUP(driver_dt2811);
static int dt2811_ai_insn(struct comedi_device *dev, struct comedi_subdevice *s,
- struct comedi_insn *insn, unsigned int *data);
+ 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);
+ 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 };
@@ -349,7 +402,7 @@ static int dt2811_attach(struct comedi_device *dev, struct comedi_devconfig *it)
irqs = probe_irq_on();
outb(DT2811_CLRERROR | DT2811_INTENB,
- dev->iobase + DT2811_ADCSR);
+ dev->iobase + DT2811_ADCSR);
outb(0, dev->iobase + DT2811_ADGCR);
udelay(100);
@@ -368,7 +421,7 @@ static int dt2811_attach(struct comedi_device *dev, struct comedi_devconfig *it)
i = inb(dev->iobase + DT2811_ADDATHI);
printk("(irq = %d)\n", irq);
ret = request_irq(irq, dt2811_interrupt, 0,
- driver_name, dev);
+ driver_name, dev);
if (ret < 0)
return -EIO;
dev->irq = irq;
@@ -500,7 +553,7 @@ static int dt2811_detach(struct comedi_device *dev)
}
static int dt2811_ai_insn(struct comedi_device *dev, struct comedi_subdevice *s,
- struct comedi_insn *insn, unsigned int *data)
+ struct comedi_insn *insn, unsigned int *data)
{
int chan = CR_CHAN(insn->chanspec);
int timeout = DT2811_TIMEOUT;
@@ -510,7 +563,7 @@ static int dt2811_ai_insn(struct comedi_device *dev, struct comedi_subdevice *s,
outb(chan, dev->iobase + DT2811_ADGCR);
while (timeout
- && inb(dev->iobase + DT2811_ADCSR) & DT2811_ADBUSY)
+ && inb(dev->iobase + DT2811_ADCSR) & DT2811_ADBUSY)
timeout--;
if (!timeout)
return -ETIME;
@@ -526,7 +579,7 @@ static int dt2811_ai_insn(struct comedi_device *dev, struct comedi_subdevice *s,
#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;
@@ -537,7 +590,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;
@@ -551,7 +604,7 @@ 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)
+ struct comedi_insn *insn, unsigned int *data)
{
int i;
int chan;
@@ -561,15 +614,16 @@ static int dt2811_ao_insn(struct comedi_device *dev, struct comedi_subdevice *s,
for (i = 0; i < insn->n; i++) {
outb(data[i] & 0xff, dev->iobase + DT2811_DADAT0LO + 2 * chan);
outb((data[i] >> 8) & 0xff,
- dev->iobase + DT2811_DADAT0HI + 2 * chan);
+ dev->iobase + DT2811_DADAT0HI + 2 * chan);
devpriv->ao_readback[chan] = data[i];
}
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;
@@ -583,8 +637,9 @@ static int dt2811_ao_insn_read(struct comedi_device *dev, struct comedi_subdevic
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;
@@ -594,8 +649,9 @@ static int dt2811_di_insn_bits(struct comedi_device *dev, struct comedi_subdevic
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 5906ddddf65c..0364bbf178e1 100644
--- a/drivers/staging/comedi/drivers/dt2814.c
+++ b/drivers/staging/comedi/drivers/dt2814.c
@@ -60,7 +60,8 @@ 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_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",
@@ -84,8 +85,9 @@ 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;
@@ -135,8 +137,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;
@@ -234,8 +236,8 @@ static int dt2814_ai_cmd(struct comedi_device *dev, struct comedi_subdevice *s)
int trigvar;
trigvar =
- dt2814_ns_to_timer(&cmd->scan_begin_arg,
- cmd->flags & TRIG_ROUND_MASK);
+ dt2814_ns_to_timer(&cmd->scan_begin_arg,
+ cmd->flags & TRIG_ROUND_MASK);
chan = CR_CHAN(cmd->chanlist[0]);
diff --git a/drivers/staging/comedi/drivers/dt2815.c b/drivers/staging/comedi/drivers/dt2815.c
index b42dec60e1b7..d1db93c043a8 100644
--- a/drivers/staging/comedi/drivers/dt2815.c
+++ b/drivers/staging/comedi/drivers/dt2815.c
@@ -62,12 +62,15 @@ Configuration options:
#include <linux/delay.h>
static const struct comedi_lrange range_dt2815_ao_32_current = { 1, {
- RANGE_mA(0, 32)
- }
+ RANGE_mA(0,
+ 32)
+ }
};
+
static const struct comedi_lrange range_dt2815_ao_20_current = { 1, {
- RANGE_mA(4, 20)
- }
+ RANGE_mA(4,
+ 20)
+ }
};
#define DT2815_SIZE 2
@@ -75,7 +78,8 @@ 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_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",
@@ -94,7 +98,6 @@ struct dt2815_private {
unsigned int ao_readback[8];
};
-
#define devpriv ((struct dt2815_private *)dev->private)
static int dt2815_wait_for_status(struct comedi_device *dev, int status)
@@ -108,8 +111,9 @@ 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);
@@ -122,7 +126,7 @@ static int dt2815_ao_insn_read(struct comedi_device *dev, struct comedi_subdevic
}
static int dt2815_ao_insn(struct comedi_device *dev, struct comedi_subdevice *s,
- struct comedi_insn *insn, unsigned int *data)
+ struct comedi_insn *insn, unsigned int *data)
{
int i;
int chan = CR_CHAN(insn->chanspec);
@@ -136,8 +140,8 @@ static int dt2815_ao_insn(struct comedi_device *dev, struct comedi_subdevice *s,
status = dt2815_wait_for_status(dev, 0x00);
if (status != 0) {
printk
- ("dt2815: failed to write low byte on %d reason %x\n",
- chan, status);
+ ("dt2815: failed to write low byte on %d reason %x\n",
+ chan, status);
return -EBUSY;
}
@@ -146,8 +150,8 @@ static int dt2815_ao_insn(struct comedi_device *dev, struct comedi_subdevice *s,
status = dt2815_wait_for_status(dev, 0x10);
if (status != 0x10) {
printk
- ("dt2815: failed to write high byte on %d reason %x\n",
- chan, status);
+ ("dt2815: failed to write high byte on %d reason %x\n",
+ chan, status);
return -EBUSY;
}
devpriv->ao_readback[chan] = data[i];
@@ -212,12 +216,12 @@ static int dt2815_attach(struct comedi_device *dev, struct comedi_devconfig *it)
s->range_table_list = devpriv->range_type_list;
current_range_type = (it->options[3])
- ? &range_dt2815_ao_20_current : &range_dt2815_ao_32_current;
+ ? &range_dt2815_ao_20_current : &range_dt2815_ao_32_current;
voltage_range_type = (it->options[2])
- ? &range_bipolar5 : &range_unipolar5;
+ ? &range_bipolar5 : &range_unipolar5;
for (i = 0; i < 8; i++) {
devpriv->range_type_list[i] = (it->options[5 + i])
- ? current_range_type : voltage_range_type;
+ ? current_range_type : voltage_range_type;
}
/* Init the 2815 */
@@ -236,7 +240,7 @@ static int dt2815_attach(struct comedi_device *dev, struct comedi_devconfig *it)
break;
} else if (status != 0x00) {
printk("dt2815: unexpected status 0x%x (@t=%d)\n",
- status, i);
+ status, i);
if (status & 0x60) {
outb(0x00, dev->iobase + DT2815_STATUS);
}
diff --git a/drivers/staging/comedi/drivers/dt2817.c b/drivers/staging/comedi/drivers/dt2817.c
index b36f85632f87..54e0dea0fc59 100644
--- a/drivers/staging/comedi/drivers/dt2817.c
+++ b/drivers/staging/comedi/drivers/dt2817.c
@@ -47,7 +47,8 @@ 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_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",
@@ -58,8 +59,9 @@ static struct comedi_driver driver_dt2817 = {
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 +98,9 @@ static int dt2817_dio_insn_config(struct comedi_device *dev, struct comedi_subde
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;
@@ -115,13 +118,13 @@ static int dt2817_dio_insn_bits(struct comedi_device *dev, struct comedi_subdevi
outb(s->state & 0xff, dev->iobase + DT2817_DATA + 0);
if (changed & 0x0000ff00)
outb((s->state >> 8) & 0xff,
- dev->iobase + DT2817_DATA + 1);
+ dev->iobase + DT2817_DATA + 1);
if (changed & 0x00ff0000)
outb((s->state >> 16) & 0xff,
- dev->iobase + DT2817_DATA + 2);
+ dev->iobase + DT2817_DATA + 2);
if (changed & 0xff000000)
outb((s->state >> 24) & 0xff,
- dev->iobase + DT2817_DATA + 3);
+ dev->iobase + DT2817_DATA + 3);
}
data[1] = inb(dev->iobase + DT2817_DATA + 0);
data[1] |= (inb(dev->iobase + DT2817_DATA + 1) << 8);
diff --git a/drivers/staging/comedi/drivers/dt282x.c b/drivers/staging/comedi/drivers/dt282x.c
index 22b7304af396..a4c96c02fa2b 100644
--- a/drivers/staging/comedi/drivers/dt282x.c
+++ b/drivers/staging/comedi/drivers/dt282x.c
@@ -155,46 +155,78 @@ Notes:
#define DT2821_BDINIT 0x0001 /* (W) initialize board */
static const struct comedi_lrange range_dt282x_ai_lo_bipolar = { 4, {
- RANGE(-10, 10),
- RANGE(-5, 5),
- RANGE(-2.5, 2.5),
- RANGE(-1.25, 1.25)
- }
+ RANGE(-10,
+ 10),
+ RANGE(-5,
+ 5),
+ RANGE(-2.5,
+ 2.5),
+ RANGE
+ (-1.25,
+ 1.25)
+ }
};
+
static const struct comedi_lrange range_dt282x_ai_lo_unipolar = { 4, {
- RANGE(0, 10),
- RANGE(0, 5),
- RANGE(0, 2.5),
- RANGE(0, 1.25)
- }
+ RANGE(0,
+ 10),
+ RANGE(0,
+ 5),
+ RANGE(0,
+ 2.5),
+ RANGE(0,
+ 1.25)
+ }
};
+
static const struct comedi_lrange range_dt282x_ai_5_bipolar = { 4, {
- RANGE(-5, 5),
- RANGE(-2.5, 2.5),
- RANGE(-1.25, 1.25),
- RANGE(-0.625, 0.625),
- }
+ RANGE(-5,
+ 5),
+ RANGE(-2.5,
+ 2.5),
+ RANGE(-1.25,
+ 1.25),
+ RANGE
+ (-0.625,
+ 0.625),
+ }
};
+
static const struct comedi_lrange range_dt282x_ai_5_unipolar = { 4, {
- RANGE(0, 5),
- RANGE(0, 2.5),
- RANGE(0, 1.25),
- RANGE(0, 0.625),
- }
+ RANGE(0,
+ 5),
+ RANGE(0,
+ 2.5),
+ RANGE(0,
+ 1.25),
+ RANGE(0,
+ 0.625),
+ }
};
+
static const struct comedi_lrange range_dt282x_ai_hi_bipolar = { 4, {
- RANGE(-10, 10),
- RANGE(-1, 1),
- RANGE(-0.1, 0.1),
- RANGE(-0.02, 0.02)
- }
+ RANGE(-10,
+ 10),
+ RANGE(-1,
+ 1),
+ RANGE(-0.1,
+ 0.1),
+ RANGE
+ (-0.02,
+ 0.02)
+ }
};
+
static const struct comedi_lrange range_dt282x_ai_hi_unipolar = { 4, {
- RANGE(0, 10),
- RANGE(0, 1),
- RANGE(0, 0.1),
- RANGE(0, 0.02)
- }
+ RANGE(0,
+ 10),
+ RANGE(0,
+ 1),
+ RANGE(0,
+ 0.1),
+ RANGE(0,
+ 0.02)
+ }
};
struct dt282x_board {
@@ -217,7 +249,7 @@ static const struct dt282x_board boardtypes[] = {
.ispgl = 0,
.dachan = 2,
.dabits = 12,
- },
+ },
{.name = "dt2821-f",
.adbits = 12,
.adchan_se = 16,
@@ -226,7 +258,7 @@ static const struct dt282x_board boardtypes[] = {
.ispgl = 0,
.dachan = 2,
.dabits = 12,
- },
+ },
{.name = "dt2821-g",
.adbits = 12,
.adchan_se = 16,
@@ -235,7 +267,7 @@ static const struct dt282x_board boardtypes[] = {
.ispgl = 0,
.dachan = 2,
.dabits = 12,
- },
+ },
{.name = "dt2823",
.adbits = 16,
.adchan_se = 0,
@@ -244,16 +276,16 @@ static const struct dt282x_board boardtypes[] = {
.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,
- },
+ .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,
@@ -262,7 +294,7 @@ static const struct dt282x_board boardtypes[] = {
.ispgl = 1,
.dachan = 0,
.dabits = 0,
- },
+ },
{.name = "dt2825",
.adbits = 12,
.adchan_se = 16,
@@ -271,7 +303,7 @@ static const struct dt282x_board boardtypes[] = {
.ispgl = 1,
.dachan = 2,
.dabits = 12,
- },
+ },
{.name = "dt2827",
.adbits = 16,
.adchan_se = 0,
@@ -280,7 +312,7 @@ static const struct dt282x_board boardtypes[] = {
.ispgl = 0,
.dachan = 2,
.dabits = 12,
- },
+ },
{.name = "dt2828",
.adbits = 12,
.adchan_se = 4,
@@ -289,7 +321,7 @@ static const struct dt282x_board boardtypes[] = {
.ispgl = 0,
.dachan = 2,
.dabits = 12,
- },
+ },
{.name = "dt2829",
.adbits = 16,
.adchan_se = 8,
@@ -298,7 +330,7 @@ static const struct dt282x_board boardtypes[] = {
.ispgl = 0,
.dachan = 2,
.dabits = 16,
- },
+ },
{.name = "dt21-ez",
.adbits = 12,
.adchan_se = 16,
@@ -307,7 +339,7 @@ static const struct dt282x_board boardtypes[] = {
.ispgl = 0,
.dachan = 2,
.dabits = 12,
- },
+ },
{.name = "dt23-ez",
.adbits = 16,
.adchan_se = 16,
@@ -316,7 +348,7 @@ static const struct dt282x_board boardtypes[] = {
.ispgl = 0,
.dachan = 0,
.dabits = 0,
- },
+ },
{.name = "dt24-ez",
.adbits = 12,
.adchan_se = 16,
@@ -325,7 +357,7 @@ static const struct dt282x_board boardtypes[] = {
.ispgl = 0,
.dachan = 0,
.dabits = 0,
- },
+ },
{.name = "dt24-ez-pgl",
.adbits = 12,
.adchan_se = 16,
@@ -334,7 +366,7 @@ static const struct dt282x_board boardtypes[] = {
.ispgl = 1,
.dachan = 0,
.dabits = 0,
- },
+ },
};
#define n_boardtypes sizeof(boardtypes)/sizeof(struct dt282x_board)
@@ -394,7 +426,8 @@ struct dt282x_private {
if (_i){b} \
}while (0)
-static int dt282x_attach(struct comedi_device *dev, struct comedi_devconfig *it);
+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",
@@ -411,15 +444,17 @@ 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 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 int dt282x_grab_dma(struct comedi_device *dev, int dma1, int dma2);
static void dt282x_munge(struct comedi_device *dev, short *buf,
- unsigned int nbytes)
+ unsigned int nbytes)
{
unsigned int i;
unsigned short mask = (1 << boardtype.adbits) - 1;
@@ -628,7 +663,7 @@ static irqreturn_t dt282x_interrupt(int irq, void *d)
int ret;
short data;
- data = (short) inw(dev->iobase + DT2821_ADDAT);
+ data = (short)inw(dev->iobase + DT2821_ADDAT);
data &= (1 << boardtype.adbits) - 1;
if (devpriv->ad_2scomp) {
data ^= 1 << (boardtype.adbits - 1);
@@ -654,7 +689,7 @@ static irqreturn_t dt282x_interrupt(int irq, void *d)
}
static void dt282x_load_changain(struct comedi_device *dev, int n,
- unsigned int *chanlist)
+ unsigned int *chanlist)
{
unsigned int i;
unsigned int chan, range;
@@ -674,8 +709,9 @@ 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;
@@ -686,18 +722,15 @@ static int dt282x_ai_insn_read(struct comedi_device *dev, struct comedi_subdevic
dt282x_load_changain(dev, 1, &insn->chanspec);
update_supcsr(DT2821_PRLD);
- wait_for(!mux_busy(), comedi_error(dev, "timeout\n");
- return -ETIME;
- );
+ wait_for(!mux_busy(), comedi_error(dev, "timeout\n"); return -ETIME;);
for (i = 0; i < insn->n; i++) {
update_supcsr(DT2821_STRIG);
wait_for(ad_done(), comedi_error(dev, "timeout\n");
- return -ETIME;
- );
+ return -ETIME;);
data[i] =
- inw(dev->iobase +
+ inw(dev->iobase +
DT2821_ADDAT) & ((1 << boardtype.adbits) - 1);
if (devpriv->ad_2scomp)
data[i] ^= (1 << (boardtype.adbits - 1));
@@ -706,8 +739,8 @@ static int dt282x_ai_insn_read(struct comedi_device *dev, struct comedi_subdevic
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;
@@ -746,7 +779,7 @@ static int dt282x_ai_cmdtest(struct comedi_device *dev, struct comedi_subdevice
/* note that mutual compatiblity is not an issue here */
if (cmd->scan_begin_src != TRIG_FOLLOW &&
- cmd->scan_begin_src != TRIG_EXT)
+ cmd->scan_begin_src != TRIG_EXT)
err++;
if (cmd->stop_src != TRIG_COUNT && cmd->stop_src != TRIG_NONE)
err++;
@@ -825,7 +858,7 @@ static int dt282x_ai_cmd(struct comedi_device *dev, struct comedi_subdevice *s)
if (devpriv->usedma == 0) {
comedi_error(dev,
- "driver requires 2 dma channels to execute command");
+ "driver requires 2 dma channels to execute command");
return -EIO;
}
@@ -865,9 +898,7 @@ static int dt282x_ai_cmd(struct comedi_device *dev, struct comedi_subdevice *s)
update_adcsr(0);
update_supcsr(DT2821_PRLD);
- wait_for(!mux_busy(), comedi_error(dev, "timeout\n");
- return -ETIME;
- );
+ wait_for(!mux_busy(), comedi_error(dev, "timeout\n"); return -ETIME;);
if (cmd->scan_begin_src == TRIG_FOLLOW) {
update_supcsr(DT2821_STRIG);
@@ -887,7 +918,8 @@ 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 +969,18 @@ 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 +1012,8 @@ static int dt282x_ao_insn_write(struct comedi_device *dev, struct comedi_subdevi
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 +1063,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,8 +1103,8 @@ 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,
- unsigned int x)
+static int dt282x_ao_inttrig(struct comedi_device *dev,
+ struct comedi_subdevice *s, unsigned int x)
{
int size;
@@ -1078,7 +1112,7 @@ static int dt282x_ao_inttrig(struct comedi_device *dev, struct comedi_subdevice
return -EINVAL;
size = cfc_read_array_from_buffer(s, devpriv->dma[0].buf,
- devpriv->dma_maxsize);
+ devpriv->dma_maxsize);
if (size == 0) {
printk("dt282x: AO underrun\n");
return -EPIPE;
@@ -1086,7 +1120,7 @@ static int dt282x_ao_inttrig(struct comedi_device *dev, struct comedi_subdevice
prep_ao_dma(dev, 0, size);
size = cfc_read_array_from_buffer(s, devpriv->dma[1].buf,
- devpriv->dma_maxsize);
+ devpriv->dma_maxsize);
if (size == 0) {
printk("dt282x: AO underrun\n");
return -EPIPE;
@@ -1106,7 +1140,7 @@ static int dt282x_ao_cmd(struct comedi_device *dev, struct comedi_subdevice *s)
if (devpriv->usedma == 0) {
comedi_error(dev,
- "driver requires 2 dma channels to execute command");
+ "driver requires 2 dma channels to execute command");
return -EIO;
}
@@ -1132,7 +1166,8 @@ 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 +1180,9 @@ 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 +1195,9 @@ static int dt282x_dio_insn_bits(struct comedi_device *dev, struct comedi_subdevi
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;
@@ -1190,10 +1227,12 @@ static const struct comedi_lrange *const ai_range_table[] = {
&range_dt282x_ai_5_bipolar,
&range_dt282x_ai_5_unipolar
};
+
static const struct comedi_lrange *const ai_range_pgl_table[] = {
&range_dt282x_ai_hi_bipolar,
&range_dt282x_ai_hi_unipolar
};
+
static const struct comedi_lrange *opt_ai_range_lkup(int ispgl, int x)
{
if (ispgl) {
@@ -1206,6 +1245,7 @@ static const struct comedi_lrange *opt_ai_range_lkup(int ispgl, int x)
return ai_range_table[x];
}
}
+
static const struct comedi_lrange *const ao_range_table[] = {
&range_bipolar10,
&range_unipolar10,
@@ -1213,6 +1253,7 @@ static const struct comedi_lrange *const ao_range_table[] = {
&range_unipolar5,
&range_bipolar2_5
};
+
static const struct comedi_lrange *opt_ao_range_lkup(int x)
{
if (x < 0 || x >= 5)
@@ -1264,23 +1305,23 @@ static int dt282x_attach(struct comedi_device *dev, struct comedi_devconfig *it)
i = inw(dev->iobase + DT2821_ADCSR);
#ifdef DEBUG
printk(" fingerprint=%x,%x,%x,%x,%x",
- inw(dev->iobase + DT2821_ADCSR),
- inw(dev->iobase + DT2821_CHANCSR),
- inw(dev->iobase + DT2821_DACSR),
- inw(dev->iobase + DT2821_SUPCSR),
- inw(dev->iobase + DT2821_TMRCTR));
+ inw(dev->iobase + DT2821_ADCSR),
+ inw(dev->iobase + DT2821_CHANCSR),
+ inw(dev->iobase + DT2821_DACSR),
+ inw(dev->iobase + DT2821_SUPCSR),
+ inw(dev->iobase + DT2821_TMRCTR));
#endif
if (((inw(dev->iobase + DT2821_ADCSR) & DT2821_ADCSR_MASK)
- != DT2821_ADCSR_VAL) ||
- ((inw(dev->iobase + DT2821_CHANCSR) & DT2821_CHANCSR_MASK)
- != DT2821_CHANCSR_VAL) ||
- ((inw(dev->iobase + DT2821_DACSR) & DT2821_DACSR_MASK)
- != DT2821_DACSR_VAL) ||
- ((inw(dev->iobase + DT2821_SUPCSR) & DT2821_SUPCSR_MASK)
- != DT2821_SUPCSR_VAL) ||
- ((inw(dev->iobase + DT2821_TMRCTR) & DT2821_TMRCTR_MASK)
- != DT2821_TMRCTR_VAL)) {
+ != DT2821_ADCSR_VAL) ||
+ ((inw(dev->iobase + DT2821_CHANCSR) & DT2821_CHANCSR_MASK)
+ != DT2821_CHANCSR_VAL) ||
+ ((inw(dev->iobase + DT2821_DACSR) & DT2821_DACSR_MASK)
+ != DT2821_DACSR_VAL) ||
+ ((inw(dev->iobase + DT2821_SUPCSR) & DT2821_SUPCSR_MASK)
+ != DT2821_SUPCSR_VAL) ||
+ ((inw(dev->iobase + DT2821_TMRCTR) & DT2821_TMRCTR_MASK)
+ != DT2821_TMRCTR_VAL)) {
printk(" board not found");
return -EIO;
}
@@ -1302,7 +1343,7 @@ static int dt282x_attach(struct comedi_device *dev, struct comedi_devconfig *it)
irq = probe_irq_off(irqs);
restore_flags(flags);
- if (0 /* error */) {
+ if (0 /* error */ ) {
printk(" error probing irq (bad)");
}
}
@@ -1330,7 +1371,7 @@ static int dt282x_attach(struct comedi_device *dev, struct comedi_devconfig *it)
return ret;
ret = dt282x_grab_dma(dev, it->options[opt_dma1],
- it->options[opt_dma2]);
+ it->options[opt_dma2]);
if (ret < 0)
return ret;
@@ -1344,10 +1385,9 @@ static int dt282x_attach(struct comedi_device *dev, struct comedi_devconfig *it)
/* ai subdevice */
s->type = COMEDI_SUBD_AI;
s->subdev_flags = SDF_READABLE | SDF_CMD_READ |
- ((it->options[opt_diff]) ? SDF_DIFF : SDF_COMMON);
+ ((it->options[opt_diff]) ? SDF_DIFF : SDF_COMMON);
s->n_chan =
- (it->options[opt_diff]) ? boardtype.adchan_di : boardtype.
- adchan_se;
+ (it->options[opt_diff]) ? boardtype.adchan_di : boardtype.adchan_se;
s->insn_read = dt282x_ai_insn_read;
s->do_cmdtest = dt282x_ai_cmdtest;
s->do_cmd = dt282x_ai_cmd;
@@ -1355,7 +1395,7 @@ static int dt282x_attach(struct comedi_device *dev, struct comedi_devconfig *it)
s->maxdata = (1 << boardtype.adbits) - 1;
s->len_chanlist = 16;
s->range_table =
- opt_ai_range_lkup(boardtype.ispgl, it->options[opt_ai_range]);
+ opt_ai_range_lkup(boardtype.ispgl, it->options[opt_ai_range]);
devpriv->ad_2scomp = it->options[opt_ai_twos];
s++;
@@ -1375,9 +1415,9 @@ static int dt282x_attach(struct comedi_device *dev, struct comedi_devconfig *it)
s->len_chanlist = 2;
s->range_table_list = devpriv->darangelist;
devpriv->darangelist[0] =
- opt_ao_range_lkup(it->options[opt_ao0_range]);
+ opt_ao_range_lkup(it->options[opt_ao0_range]);
devpriv->darangelist[1] =
- opt_ao_range_lkup(it->options[opt_ao1_range]);
+ opt_ao_range_lkup(it->options[opt_ao1_range]);
devpriv->da0_2scomp = it->options[opt_ao0_twos];
devpriv->da1_2scomp = it->options[opt_ao1_twos];
} else {
diff --git a/drivers/staging/comedi/drivers/dt3000.c b/drivers/staging/comedi/drivers/dt3000.c
index 2af8b59f9061..bbbef790c8f6 100644
--- a/drivers/staging/comedi/drivers/dt3000.c
+++ b/drivers/staging/comedi/drivers/dt3000.c
@@ -68,18 +68,19 @@ AO commands are not supported.
#define PCI_VENDOR_ID_DT 0x1116
static const struct comedi_lrange range_dt3000_ai = { 4, {
- RANGE(-10, 10),
- RANGE(-5, 5),
- RANGE(-2.5, 2.5),
- RANGE(-1.25, 1.25)
- }
+ RANGE(-10, 10),
+ RANGE(-5, 5),
+ RANGE(-2.5, 2.5),
+ RANGE(-1.25, 1.25)
+ }
};
+
static const struct comedi_lrange range_dt3000_ai_pgl = { 4, {
- RANGE(-10, 10),
- RANGE(-1, 1),
- RANGE(-0.1, 0.1),
- RANGE(-0.02, 0.02)
- }
+ RANGE(-10, 10),
+ RANGE(-1, 1),
+ RANGE(-0.1, 0.1),
+ RANGE(-0.02, 0.02)
+ }
};
struct dt3k_boardtype {
@@ -94,7 +95,6 @@ struct dt3k_boardtype {
int dabits;
};
-
static const struct dt3k_boardtype dt3k_boardtypes[] = {
{.name = "dt3001",
.device_id = 0x22,
@@ -104,7 +104,7 @@ static const struct dt3k_boardtype dt3k_boardtypes[] = {
.ai_speed = 3000,
.dachan = 2,
.dabits = 12,
- },
+ },
{.name = "dt3001-pgl",
.device_id = 0x27,
.adchan = 16,
@@ -113,7 +113,7 @@ static const struct dt3k_boardtype dt3k_boardtypes[] = {
.ai_speed = 3000,
.dachan = 2,
.dabits = 12,
- },
+ },
{.name = "dt3002",
.device_id = 0x23,
.adchan = 32,
@@ -122,7 +122,7 @@ static const struct dt3k_boardtype dt3k_boardtypes[] = {
.ai_speed = 3000,
.dachan = 0,
.dabits = 0,
- },
+ },
{.name = "dt3003",
.device_id = 0x24,
.adchan = 64,
@@ -131,7 +131,7 @@ static const struct dt3k_boardtype dt3k_boardtypes[] = {
.ai_speed = 3000,
.dachan = 2,
.dabits = 12,
- },
+ },
{.name = "dt3003-pgl",
.device_id = 0x28,
.adchan = 64,
@@ -140,7 +140,7 @@ static const struct dt3k_boardtype dt3k_boardtypes[] = {
.ai_speed = 3000,
.dachan = 2,
.dabits = 12,
- },
+ },
{.name = "dt3004",
.device_id = 0x25,
.adchan = 16,
@@ -149,8 +149,8 @@ static const struct dt3k_boardtype dt3k_boardtypes[] = {
.ai_speed = 10000,
.dachan = 2,
.dabits = 12,
- },
- {.name = "dt3005", /* a.k.a. 3004-200 */
+ },
+ {.name = "dt3005", /* a.k.a. 3004-200 */
.device_id = 0x26,
.adchan = 16,
.adbits = 16,
@@ -158,21 +158,22 @@ static const struct dt3k_boardtype dt3k_boardtypes[] = {
.ai_speed = 5000,
.dachan = 2,
.dabits = 12,
- },
+ },
};
#define n_dt3k_boards sizeof(dt3k_boardtypes)/sizeof(struct dt3k_boardtype)
#define this_board ((const struct dt3k_boardtype *)dev->board_ptr)
static DEFINE_PCI_DEVICE_TABLE(dt3k_pci_table) = {
- {PCI_VENDOR_ID_DT, 0x0022, PCI_ANY_ID, PCI_ANY_ID, 0, 0, 0},
- {PCI_VENDOR_ID_DT, 0x0027, PCI_ANY_ID, PCI_ANY_ID, 0, 0, 0},
- {PCI_VENDOR_ID_DT, 0x0023, PCI_ANY_ID, PCI_ANY_ID, 0, 0, 0},
- {PCI_VENDOR_ID_DT, 0x0024, PCI_ANY_ID, PCI_ANY_ID, 0, 0, 0},
- {PCI_VENDOR_ID_DT, 0x0028, PCI_ANY_ID, PCI_ANY_ID, 0, 0, 0},
- {PCI_VENDOR_ID_DT, 0x0025, PCI_ANY_ID, PCI_ANY_ID, 0, 0, 0},
- {PCI_VENDOR_ID_DT, 0x0026, PCI_ANY_ID, PCI_ANY_ID, 0, 0, 0},
- {0}
+ {
+ PCI_VENDOR_ID_DT, 0x0022, PCI_ANY_ID, PCI_ANY_ID, 0, 0, 0}, {
+ PCI_VENDOR_ID_DT, 0x0027, PCI_ANY_ID, PCI_ANY_ID, 0, 0, 0}, {
+ PCI_VENDOR_ID_DT, 0x0023, PCI_ANY_ID, PCI_ANY_ID, 0, 0, 0}, {
+ PCI_VENDOR_ID_DT, 0x0024, PCI_ANY_ID, PCI_ANY_ID, 0, 0, 0}, {
+ PCI_VENDOR_ID_DT, 0x0028, PCI_ANY_ID, PCI_ANY_ID, 0, 0, 0}, {
+ PCI_VENDOR_ID_DT, 0x0025, PCI_ANY_ID, PCI_ANY_ID, 0, 0, 0}, {
+ PCI_VENDOR_ID_DT, 0x0026, PCI_ANY_ID, PCI_ANY_ID, 0, 0, 0}, {
+ 0}
};
MODULE_DEVICE_TABLE(pci, dt3k_pci_table);
@@ -276,7 +277,8 @@ 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_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",
@@ -287,10 +289,12 @@ static struct comedi_driver driver_dt3000 = {
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);
+ unsigned int round_mode);
+static int dt3k_ai_cancel(struct comedi_device *dev,
+ struct comedi_subdevice *s);
#ifdef DEBUG
static void debug_intr_flags(unsigned int flags);
#endif
@@ -319,8 +323,9 @@ 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,
- unsigned int chan, unsigned int gain)
+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);
@@ -333,7 +338,7 @@ static unsigned int dt3k_readsingle(struct comedi_device *dev, unsigned int subs
}
static void dt3k_writesingle(struct comedi_device *dev, unsigned int subsys,
- unsigned int chan, unsigned int data)
+ unsigned int chan, unsigned int data)
{
writew(subsys, devpriv->io_addr + DPR_SubSys);
@@ -388,6 +393,7 @@ static char *intr_flags[] = {
"AdFull", "AdSwError", "AdHwError", "DaEmpty",
"DaSwError", "DaHwError", "CtDone", "CmDone",
};
+
static void debug_intr_flags(unsigned int flags)
{
int i;
@@ -401,7 +407,8 @@ 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;
@@ -430,8 +437,8 @@ static void dt3k_ai_empty_fifo(struct comedi_device *dev, struct comedi_subdevic
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;
@@ -528,7 +535,7 @@ static int dt3k_ai_cmdtest(struct comedi_device *dev, struct comedi_subdevice *s
if (cmd->scan_begin_src == TRIG_TIMER) {
tmp = cmd->scan_begin_arg;
dt3k_ns_to_timer(100, &cmd->scan_begin_arg,
- cmd->flags & TRIG_ROUND_MASK);
+ cmd->flags & TRIG_ROUND_MASK);
if (tmp != cmd->scan_begin_arg)
err++;
} else {
@@ -537,14 +544,14 @@ static int dt3k_ai_cmdtest(struct comedi_device *dev, struct comedi_subdevice *s
if (cmd->convert_src == TRIG_TIMER) {
tmp = cmd->convert_arg;
dt3k_ns_to_timer(50, &cmd->convert_arg,
- cmd->flags & TRIG_ROUND_MASK);
+ cmd->flags & TRIG_ROUND_MASK);
if (tmp != cmd->convert_arg)
err++;
if (cmd->scan_begin_src == TRIG_TIMER &&
- cmd->scan_begin_arg <
- cmd->convert_arg * cmd->scan_end_arg) {
+ cmd->scan_begin_arg <
+ cmd->convert_arg * cmd->scan_end_arg) {
cmd->scan_begin_arg =
- cmd->convert_arg * cmd->scan_end_arg;
+ cmd->convert_arg * cmd->scan_end_arg;
err++;
}
} else {
@@ -558,7 +565,7 @@ static int dt3k_ai_cmdtest(struct comedi_device *dev, struct comedi_subdevice *s
}
static int dt3k_ns_to_timer(unsigned int timer_base, unsigned int *nanosec,
- unsigned int round_mode)
+ unsigned int round_mode)
{
int divider, base, prescale;
@@ -608,7 +615,7 @@ static int dt3k_ai_cmd(struct comedi_device *dev, struct comedi_subdevice *s)
range = CR_RANGE(cmd->chanlist[i]);
writew((range << 6) | chan,
- devpriv->io_addr + DPR_ADC_buffer + i);
+ devpriv->io_addr + DPR_ADC_buffer + i);
}
aref = CR_AREF(cmd->chanlist[0]);
@@ -617,7 +624,7 @@ static int dt3k_ai_cmd(struct comedi_device *dev, struct comedi_subdevice *s)
if (cmd->convert_src == TRIG_TIMER) {
divider = dt3k_ns_to_timer(50, &cmd->convert_arg,
- cmd->flags & TRIG_ROUND_MASK);
+ cmd->flags & TRIG_ROUND_MASK);
writew((divider >> 16), devpriv->io_addr + DPR_Params(1));
printk("param[1]=0x%04x\n", divider >> 16);
writew((divider & 0xffff), devpriv->io_addr + DPR_Params(2));
@@ -628,7 +635,7 @@ static int dt3k_ai_cmd(struct comedi_device *dev, struct comedi_subdevice *s)
if (cmd->scan_begin_src == TRIG_TIMER) {
tscandiv = dt3k_ns_to_timer(100, &cmd->scan_begin_arg,
- cmd->flags & TRIG_ROUND_MASK);
+ cmd->flags & TRIG_ROUND_MASK);
writew((tscandiv >> 16), devpriv->io_addr + DPR_Params(3));
printk("param[3]=0x%04x\n", tscandiv >> 16);
writew((tscandiv & 0xffff), devpriv->io_addr + DPR_Params(4));
@@ -650,7 +657,7 @@ static int dt3k_ai_cmd(struct comedi_device *dev, struct comedi_subdevice *s)
ret = dt3k_send_cmd(dev, CMD_CONFIG);
writew(DT3000_ADFULL | DT3000_ADSWERR | DT3000_ADHWERR,
- devpriv->io_addr + DPR_Int_Mask);
+ devpriv->io_addr + DPR_Int_Mask);
debug_n_ints = 0;
@@ -673,7 +680,7 @@ static int dt3k_ai_cancel(struct comedi_device *dev, struct comedi_subdevice *s)
}
static int dt3k_ai_insn(struct comedi_device *dev, struct comedi_subdevice *s,
- struct comedi_insn *insn, unsigned int *data)
+ struct comedi_insn *insn, unsigned int *data)
{
int i;
unsigned int chan, gain, aref;
@@ -691,7 +698,7 @@ static int dt3k_ai_insn(struct comedi_device *dev, struct comedi_subdevice *s,
}
static int dt3k_ao_insn(struct comedi_device *dev, struct comedi_subdevice *s,
- struct comedi_insn *insn, unsigned int *data)
+ struct comedi_insn *insn, unsigned int *data)
{
int i;
unsigned int chan;
@@ -705,8 +712,9 @@ 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;
@@ -734,8 +742,9 @@ 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;
@@ -750,9 +759,9 @@ static int dt3k_dio_insn_config(struct comedi_device *dev, struct comedi_subdevi
break;
case INSN_CONFIG_DIO_QUERY:
data[1] =
- (s->io_bits & (1 << CR_CHAN(insn->
- chanspec))) ? COMEDI_OUTPUT :
- COMEDI_INPUT;
+ (s->
+ io_bits & (1 << CR_CHAN(insn->chanspec))) ? COMEDI_OUTPUT :
+ COMEDI_INPUT;
return insn->n;
break;
default:
@@ -765,8 +774,9 @@ static int dt3k_dio_insn_config(struct comedi_device *dev, struct comedi_subdevi
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;
@@ -781,8 +791,9 @@ static int dt3k_dio_insn_bits(struct comedi_device *dev, struct comedi_subdevice
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;
@@ -925,8 +936,8 @@ static int dt_pci_probe(struct comedi_device *dev, int bus, int slot)
pcidev = NULL;
while ((pcidev = dt_pci_find_device(pcidev, &board)) != NULL) {
if ((bus == 0 && slot == 0) ||
- (pcidev->bus->number == bus &&
- PCI_SLOT(pcidev->devfn) == slot)) {
+ (pcidev->bus->number == bus &&
+ PCI_SLOT(pcidev->devfn) == slot)) {
break;
}
}
@@ -961,7 +972,7 @@ static int setup_pci(struct comedi_device *dev)
return -ENOMEM;
#if DEBUG
printk("0x%08llx mapped to %p, ",
- (unsigned long long)devpriv->phys_addr, devpriv->io_addr);
+ (unsigned long long)devpriv->phys_addr, devpriv->io_addr);
#endif
return 0;
@@ -972,15 +983,17 @@ static struct pci_dev *dt_pci_find_device(struct pci_dev *from, int *board)
int i;
for (from = pci_get_device(PCI_VENDOR_ID_DT, PCI_ANY_ID, from);
- from != NULL;
- from = pci_get_device(PCI_VENDOR_ID_DT, PCI_ANY_ID, from)) {
+ from != NULL;
+ from = pci_get_device(PCI_VENDOR_ID_DT, PCI_ANY_ID, from)) {
for (i = 0; i < n_dt3k_boards; i++) {
if (from->device == dt3k_boardtypes[i].device_id) {
*board = i;
return from;
}
}
- printk("unknown Data Translation PCI device found with device_id=0x%04x\n", from->device);
+ printk
+ ("unknown Data Translation PCI device found with device_id=0x%04x\n",
+ from->device);
}
*board = -1;
return from;
diff --git a/drivers/staging/comedi/drivers/dt9812.c b/drivers/staging/comedi/drivers/dt9812.c
index cc4c04630086..312f4f282bd7 100644
--- a/drivers/staging/comedi/drivers/dt9812.c
+++ b/drivers/staging/comedi/drivers/dt9812.c
@@ -89,9 +89,9 @@ for my needs.
#define F020_MASK_DACxCN_DACxEN 0x80
enum {
- /* A/D D/A DI DO CT */
+ /* A/D D/A DI DO CT */
DT9812_DEVID_DT9812_10, /* 8 2 8 8 1 +/- 10V */
- DT9812_DEVID_DT9812_2PT5,/* 8 2 8 8 1 0-2.44V */
+ DT9812_DEVID_DT9812_2PT5, /* 8 2 8 8 1 0-2.44V */
#if 0
DT9812_DEVID_DT9813, /* 16 2 4 4 1 +/- 10V */
DT9812_DEVID_DT9814 /* 24 2 0 0 1 +/- 10V */
@@ -266,7 +266,7 @@ static DECLARE_MUTEX(dt9812_mutex);
static struct usb_device_id dt9812_table[] = {
{USB_DEVICE(0x0867, 0x9812)},
- { } /* Terminating entry */
+ {} /* Terminating entry */
};
MODULE_DEVICE_TABLE(usb, dt9812_table);
@@ -301,23 +301,23 @@ struct slot_dt9812 {
};
static const struct comedi_lrange dt9812_10_ain_range = { 1, {
- BIP_RANGE(10),
- }
+ BIP_RANGE(10),
+ }
};
static const struct comedi_lrange dt9812_2pt5_ain_range = { 1, {
- UNI_RANGE(2.5),
- }
+ UNI_RANGE(2.5),
+ }
};
static const struct comedi_lrange dt9812_10_aout_range = { 1, {
- BIP_RANGE(10),
- }
+ BIP_RANGE(10),
+ }
};
static const struct comedi_lrange dt9812_2pt5_aout_range = { 1, {
- UNI_RANGE(2.5),
- }
+ UNI_RANGE(2.5),
+ }
};
static struct slot_dt9812 dt9812[DT9812_NUM_SLOTS];
@@ -346,7 +346,7 @@ static int dt9812_read_info(struct usb_dt9812 *dev, int offset, void *buf,
cmd.cmd = cpu_to_le32(DT9812_R_FLASH_DATA);
cmd.u.flash_data_info.address =
- cpu_to_le16(DT9812_DIAGS_BOARD_INFO_ADDR + offset);
+ cpu_to_le16(DT9812_DIAGS_BOARD_INFO_ADDR + offset);
cmd.u.flash_data_info.numbytes = cpu_to_le16(buf_size);
/* DT9812 only responds to 32 byte writes!! */
@@ -365,7 +365,7 @@ static int dt9812_read_info(struct usb_dt9812 *dev, int offset, void *buf,
}
static int dt9812_read_multiple_registers(struct usb_dt9812 *dev, int reg_count,
- u8 *address, u8 *value)
+ u8 * address, u8 * value)
{
struct dt9812_usb_cmd cmd;
int i, count, retval;
@@ -391,8 +391,8 @@ static int dt9812_read_multiple_registers(struct usb_dt9812 *dev, int reg_count,
}
static int dt9812_write_multiple_registers(struct usb_dt9812 *dev,
- int reg_count, u8 *address,
- u8 *value)
+ int reg_count, u8 * address,
+ u8 * value)
{
struct dt9812_usb_cmd cmd;
int i, count, retval;
@@ -430,7 +430,7 @@ static int dt9812_rmw_multiple_registers(struct usb_dt9812 *dev, int reg_count,
return retval;
}
-static int dt9812_digital_in(struct slot_dt9812 *slot, u8 *bits)
+static int dt9812_digital_in(struct slot_dt9812 *slot, u8 * bits)
{
int result = -ENODEV;
@@ -449,7 +449,7 @@ static int dt9812_digital_in(struct slot_dt9812 *slot, u8 *bits)
*/
*bits = (value[0] & 0x7f) | ((value[1] & 0x08) << 4);
/* printk("%2.2x, %2.2x -> %2.2x\n",
- value[0], value[1], *bits); */
+ value[0], value[1], *bits); */
}
}
up(&slot->mutex);
@@ -476,7 +476,7 @@ static int dt9812_digital_out(struct slot_dt9812 *slot, u8 bits)
return result;
}
-static int dt9812_digital_out_shadow(struct slot_dt9812 *slot, u8 *bits)
+static int dt9812_digital_out_shadow(struct slot_dt9812 *slot, u8 * bits)
{
int result = -ENODEV;
@@ -516,8 +516,7 @@ static void dt9812_configure_gain(struct usb_dt9812 *dev,
rmw->address = F020_SFR_ADC0CF;
rmw->and_mask = F020_MASK_ADC0CF_AMP0GN2 |
- F020_MASK_ADC0CF_AMP0GN1 |
- F020_MASK_ADC0CF_AMP0GN0;
+ F020_MASK_ADC0CF_AMP0GN1 | F020_MASK_ADC0CF_AMP0GN0;
switch (gain) {
/*
* 000 -> Gain = 1
@@ -529,7 +528,7 @@ static void dt9812_configure_gain(struct usb_dt9812 *dev,
*/
case DT9812_GAIN_0PT5:
rmw->or_value = F020_MASK_ADC0CF_AMP0GN2 ||
- F020_MASK_ADC0CF_AMP0GN1;
+ F020_MASK_ADC0CF_AMP0GN1;
break;
case DT9812_GAIN_1:
rmw->or_value = 0x00;
@@ -542,7 +541,7 @@ static void dt9812_configure_gain(struct usb_dt9812 *dev,
break;
case DT9812_GAIN_8:
rmw->or_value = F020_MASK_ADC0CF_AMP0GN1 ||
- F020_MASK_ADC0CF_AMP0GN0;
+ F020_MASK_ADC0CF_AMP0GN0;
break;
case DT9812_GAIN_16:
rmw->or_value = F020_MASK_ADC0CF_AMP0GN2;
@@ -553,7 +552,7 @@ static void dt9812_configure_gain(struct usb_dt9812 *dev,
}
}
-static int dt9812_analog_in(struct slot_dt9812 *slot, int channel, u16 *value,
+static int dt9812_analog_in(struct slot_dt9812 *slot, int channel, u16 * value,
enum dt9812_gain gain)
{
struct dt9812_rmw_byte rmw[3];
@@ -620,7 +619,7 @@ exit:
}
static int dt9812_analog_out_shadow(struct slot_dt9812 *slot, int channel,
- u16 *value)
+ u16 * value)
{
int result = -ENODEV;
@@ -729,32 +728,32 @@ static int dt9812_probe(struct usb_interface *interface,
direction = USB_DIR_IN;
dev->message_pipe.addr = endpoint->bEndpointAddress;
dev->message_pipe.size =
- le16_to_cpu(endpoint->wMaxPacketSize);
+ le16_to_cpu(endpoint->wMaxPacketSize);
break;
case 1:
direction = USB_DIR_OUT;
dev->command_write.addr = endpoint->bEndpointAddress;
dev->command_write.size =
- le16_to_cpu(endpoint->wMaxPacketSize);
+ le16_to_cpu(endpoint->wMaxPacketSize);
break;
case 2:
direction = USB_DIR_IN;
dev->command_read.addr = endpoint->bEndpointAddress;
dev->command_read.size =
- le16_to_cpu(endpoint->wMaxPacketSize);
+ le16_to_cpu(endpoint->wMaxPacketSize);
break;
case 3:
direction = USB_DIR_OUT;
dev->write_stream.addr = endpoint->bEndpointAddress;
dev->write_stream.size =
- le16_to_cpu(endpoint->wMaxPacketSize);
+ le16_to_cpu(endpoint->wMaxPacketSize);
break;
case 4:
direction = USB_DIR_IN;
dev->read_stream.addr = endpoint->bEndpointAddress;
dev->read_stream.size =
- le16_to_cpu(endpoint->wMaxPacketSize);
+ le16_to_cpu(endpoint->wMaxPacketSize);
break;
}
if ((endpoint->bEndpointAddress & USB_DIR_IN) != direction) {
@@ -786,8 +785,7 @@ static int dt9812_probe(struct usb_interface *interface,
retval = -ENODEV;
goto error;
}
- if (dt9812_read_info(dev, 3, &dev->product,
- sizeof(dev->product)) != 0) {
+ if (dt9812_read_info(dev, 3, &dev->product, sizeof(dev->product)) != 0) {
err("Failed to read product.");
retval = -ENODEV;
goto error;
@@ -940,8 +938,9 @@ static void dt9812_comedi_open(struct comedi_device *dev)
up(&devpriv->slot->mutex);
}
-static int dt9812_di_rinsn(struct comedi_device *dev, struct comedi_subdevice *s,
- struct comedi_insn *insn, unsigned int *data)
+static int dt9812_di_rinsn(struct comedi_device *dev,
+ struct comedi_subdevice *s, struct comedi_insn *insn,
+ unsigned int *data)
{
int n;
u8 bits = 0;
@@ -952,8 +951,9 @@ static int dt9812_di_rinsn(struct comedi_device *dev, struct comedi_subdevice *s
return n;
}
-static int dt9812_do_winsn(struct comedi_device *dev, struct comedi_subdevice *s,
- struct comedi_insn *insn, unsigned int *data)
+static int dt9812_do_winsn(struct comedi_device *dev,
+ struct comedi_subdevice *s, struct comedi_insn *insn,
+ unsigned int *data)
{
int n;
u8 bits = 0;
@@ -970,8 +970,9 @@ static int dt9812_do_winsn(struct comedi_device *dev, struct comedi_subdevice *s
return n;
}
-static int dt9812_ai_rinsn(struct comedi_device *dev, struct comedi_subdevice *s,
- struct comedi_insn *insn, unsigned int *data)
+static int dt9812_ai_rinsn(struct comedi_device *dev,
+ struct comedi_subdevice *s, struct comedi_insn *insn,
+ unsigned int *data)
{
int n;
@@ -985,8 +986,9 @@ static int dt9812_ai_rinsn(struct comedi_device *dev, struct comedi_subdevice *s
return n;
}
-static int dt9812_ao_rinsn(struct comedi_device *dev, struct comedi_subdevice *s,
- struct comedi_insn *insn, unsigned int *data)
+static int dt9812_ao_rinsn(struct comedi_device *dev,
+ struct comedi_subdevice *s, struct comedi_insn *insn,
+ unsigned int *data)
{
int n;
u16 value;
@@ -999,8 +1001,9 @@ static int dt9812_ao_rinsn(struct comedi_device *dev, struct comedi_subdevice *s
return n;
}
-static int dt9812_ao_winsn(struct comedi_device *dev, struct comedi_subdevice *s,
- struct comedi_insn *insn, unsigned int *data)
+static int dt9812_ao_winsn(struct comedi_device *dev,
+ struct comedi_subdevice *s, struct comedi_insn *insn,
+ unsigned int *data)
{
int n;
diff --git a/drivers/staging/comedi/drivers/fl512.c b/drivers/staging/comedi/drivers/fl512.c
index b8657c47d4cc..8fca18043357 100644
--- a/drivers/staging/comedi/drivers/fl512.c
+++ b/drivers/staging/comedi/drivers/fl512.c
@@ -32,14 +32,14 @@ struct fl512_private {
#define devpriv ((struct fl512_private *) dev->private)
static const struct comedi_lrange range_fl512 = { 4, {
- BIP_RANGE(0.5),
- BIP_RANGE(1),
- BIP_RANGE(5),
- BIP_RANGE(10),
- UNI_RANGE(1),
- UNI_RANGE(5),
- UNI_RANGE(10),
- }
+ BIP_RANGE(0.5),
+ BIP_RANGE(1),
+ BIP_RANGE(5),
+ BIP_RANGE(10),
+ UNI_RANGE(1),
+ UNI_RANGE(5),
+ UNI_RANGE(10),
+ }
};
static int fl512_attach(struct comedi_device *dev, struct comedi_devconfig *it);
@@ -55,17 +55,20 @@ static struct comedi_driver driver_fl512 = {
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);
+ 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);
+ 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)
+ struct comedi_subdevice *s, struct comedi_insn *insn,
+ unsigned int *data)
{
int n;
unsigned int lo_byte, hi_byte;
@@ -90,7 +93,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)
+ struct comedi_subdevice *s, struct comedi_insn *insn,
+ unsigned int *data)
{
int n;
int chan = CR_CHAN(insn->chanspec); /* get chan to write */
@@ -111,7 +115,8 @@ static int fl512_ao_insn(struct comedi_device *dev,
* DA port
*/
static int fl512_ao_insn_readback(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)
{
int n;
int chan = CR_CHAN(insn->chanspec);
@@ -130,7 +135,7 @@ static int fl512_attach(struct comedi_device *dev, struct comedi_devconfig *it)
{
unsigned long iobase;
struct comedi_subdevice *s; /* pointer to the subdevice:
- Analog in, Analog out, ( not made ->and Digital IO) */
+ Analog in, Analog out, ( not made ->and Digital IO) */
iobase = it->options[0];
printk("comedi:%d fl512: 0x%04lx", dev->minor, iobase);
diff --git a/drivers/staging/comedi/drivers/gsc_hpdi.c b/drivers/staging/comedi/drivers/gsc_hpdi.c
index b156ae717ae4..0bb30162e92c 100644
--- a/drivers/staging/comedi/drivers/gsc_hpdi.c
+++ b/drivers/staging/comedi/drivers/gsc_hpdi.c
@@ -58,7 +58,7 @@ 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);
+ 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);
@@ -149,7 +149,7 @@ enum board_control_bits {
TEST_MODE_ENABLE_BIT = 0x80000000,
};
uint32_t command_discrete_output_bits(unsigned int channel, int output,
- int output_value)
+ int output_value)
{
uint32_t bits = 0;
@@ -193,11 +193,13 @@ uint32_t almost_empty_bits(unsigned int num_words)
{
return num_words & 0xffff;
}
+
unsigned int almost_full_num_words(uint32_t bits)
{
/* XXX need to add or subtract one? */
return (bits >> 16) & 0xffff;
}
+
unsigned int almost_empty_num_words(uint32_t bits)
{
return bits & 0xffff;
@@ -268,33 +270,33 @@ struct hpdi_board {
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 DEFINE_PCI_DEVICE_TABLE(hpdi_pci_table) = {
- {PCI_VENDOR_ID_PLX, PCI_DEVICE_ID_PLX_9080, PCI_VENDOR_ID_PLX, 0x2400,
- 0, 0, 0},
- {0}
+ {
+ PCI_VENDOR_ID_PLX, PCI_DEVICE_ID_PLX_9080, PCI_VENDOR_ID_PLX,
+ 0x2400, 0, 0, 0}, {
+ 0}
};
MODULE_DEVICE_TABLE(pci, hpdi_pci_table);
-static inline struct hpdi_board *board(const struct comedi_device * dev)
+static inline struct hpdi_board *board(const struct comedi_device *dev)
{
- return (struct hpdi_board *) dev->board_ptr;
+ return (struct hpdi_board *)dev->board_ptr;
}
struct hpdi_private {
@@ -321,8 +323,7 @@ struct hpdi_private {
unsigned dio_config_output:1;
};
-
-static inline struct hpdi_private *priv(struct comedi_device * dev)
+static inline struct hpdi_private *priv(struct comedi_device *dev)
{
return dev->private;
}
@@ -336,8 +337,9 @@ static struct comedi_driver driver_hpdi = {
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:
@@ -350,8 +352,7 @@ static int dio_config_insn(struct comedi_device *dev, struct comedi_subdevice *s
break;
case INSN_CONFIG_DIO_QUERY:
data[1] =
- priv(dev)->
- dio_config_output ? COMEDI_OUTPUT : COMEDI_INPUT;
+ priv(dev)->dio_config_output ? COMEDI_OUTPUT : COMEDI_INPUT;
return insn->n;
break;
case INSN_CONFIG_BLOCK_SIZE:
@@ -377,29 +378,29 @@ static void init_plx9080(struct comedi_device *dev)
/* plx9080 dump */
DEBUG_PRINT(" plx interrupt status 0x%x\n",
- readl(plx_iobase + PLX_INTRCS_REG));
+ readl(plx_iobase + PLX_INTRCS_REG));
DEBUG_PRINT(" plx id bits 0x%x\n", readl(plx_iobase + PLX_ID_REG));
DEBUG_PRINT(" plx control reg 0x%x\n",
- readl(priv(dev)->plx9080_iobase + PLX_CONTROL_REG));
+ readl(priv(dev)->plx9080_iobase + PLX_CONTROL_REG));
DEBUG_PRINT(" plx revision 0x%x\n",
- readl(plx_iobase + PLX_REVISION_REG));
+ readl(plx_iobase + PLX_REVISION_REG));
DEBUG_PRINT(" plx dma channel 0 mode 0x%x\n",
- readl(plx_iobase + PLX_DMA0_MODE_REG));
+ readl(plx_iobase + PLX_DMA0_MODE_REG));
DEBUG_PRINT(" plx dma channel 1 mode 0x%x\n",
- readl(plx_iobase + PLX_DMA1_MODE_REG));
+ readl(plx_iobase + PLX_DMA1_MODE_REG));
DEBUG_PRINT(" plx dma channel 0 pci address 0x%x\n",
- readl(plx_iobase + PLX_DMA0_PCI_ADDRESS_REG));
+ readl(plx_iobase + PLX_DMA0_PCI_ADDRESS_REG));
DEBUG_PRINT(" plx dma channel 0 local address 0x%x\n",
- readl(plx_iobase + PLX_DMA0_LOCAL_ADDRESS_REG));
+ readl(plx_iobase + PLX_DMA0_LOCAL_ADDRESS_REG));
DEBUG_PRINT(" plx dma channel 0 transfer size 0x%x\n",
- readl(plx_iobase + PLX_DMA0_TRANSFER_SIZE_REG));
+ readl(plx_iobase + PLX_DMA0_TRANSFER_SIZE_REG));
DEBUG_PRINT(" plx dma channel 0 descriptor 0x%x\n",
- readl(plx_iobase + PLX_DMA0_DESCRIPTOR_REG));
+ readl(plx_iobase + PLX_DMA0_DESCRIPTOR_REG));
DEBUG_PRINT(" plx dma channel 0 command status 0x%x\n",
- readb(plx_iobase + PLX_DMA0_CS_REG));
+ readb(plx_iobase + PLX_DMA0_CS_REG));
DEBUG_PRINT(" plx dma channel 0 threshold 0x%x\n",
- readl(plx_iobase + PLX_DMA0_THRESHOLD_REG));
+ readl(plx_iobase + PLX_DMA0_THRESHOLD_REG));
DEBUG_PRINT(" plx bigend 0x%x\n", readl(plx_iobase + PLX_BIGEND_REG));
#ifdef __BIG_ENDIAN
bits = BIGEND_DMA0 | BIGEND_DMA1;
@@ -448,7 +449,7 @@ static int setup_subdevices(struct comedi_device *dev)
/* dev->write_subdev = s; */
s->type = COMEDI_SUBD_DIO;
s->subdev_flags =
- SDF_READABLE | SDF_WRITEABLE | SDF_LSAMPL | SDF_CMD_READ;
+ SDF_READABLE | SDF_WRITEABLE | SDF_LSAMPL | SDF_CMD_READ;
s->n_chan = 32;
s->len_chanlist = 32;
s->maxdata = 1;
@@ -469,21 +470,21 @@ static int init_hpdi(struct comedi_device *dev)
udelay(10);
writel(almost_empty_bits(32) | almost_full_bits(32),
- priv(dev)->hpdi_iobase + RX_PROG_ALMOST_REG);
+ priv(dev)->hpdi_iobase + RX_PROG_ALMOST_REG);
writel(almost_empty_bits(32) | almost_full_bits(32),
- priv(dev)->hpdi_iobase + TX_PROG_ALMOST_REG);
+ priv(dev)->hpdi_iobase + TX_PROG_ALMOST_REG);
priv(dev)->tx_fifo_size = fifo_size(readl(priv(dev)->hpdi_iobase +
- TX_FIFO_SIZE_REG));
+ TX_FIFO_SIZE_REG));
priv(dev)->rx_fifo_size = fifo_size(readl(priv(dev)->hpdi_iobase +
- RX_FIFO_SIZE_REG));
+ RX_FIFO_SIZE_REG));
writel(0, priv(dev)->hpdi_iobase + INTERRUPT_CONTROL_REG);
/* enable interrupts */
plx_intcsr_bits =
- ICS_AERR | ICS_PERR | ICS_PIE | ICS_PLIE | ICS_PAIE | ICS_LIE |
- ICS_DMA0_E;
+ ICS_AERR | ICS_PERR | ICS_PIE | ICS_PLIE | ICS_PAIE | ICS_LIE |
+ ICS_DMA0_E;
writel(plx_intcsr_bits, priv(dev)->plx9080_iobase + PLX_INTRCS_REG);
return 0;
@@ -491,11 +492,11 @@ static int init_hpdi(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 transfer_size)
{
unsigned int buffer_index, buffer_offset;
uint32_t next_bits = PLX_DESC_IN_PCI_BIT | PLX_INTR_TERM_COUNT |
- PLX_XFER_LOCAL_TO_PCI;
+ PLX_XFER_LOCAL_TO_PCI;
unsigned int i;
if (transfer_size > DMA_BUFFER_SIZE)
@@ -506,26 +507,26 @@ static int setup_dma_descriptors(struct comedi_device *dev,
DEBUG_PRINT(" transfer_size %i\n", transfer_size);
DEBUG_PRINT(" descriptors at 0x%lx\n",
- (unsigned long)priv(dev)->dma_desc_phys_addr);
+ (unsigned long)priv(dev)->dma_desc_phys_addr);
buffer_offset = 0;
buffer_index = 0;
for (i = 0; i < NUM_DMA_DESCRIPTORS &&
- buffer_index < NUM_DMA_BUFFERS; i++) {
+ buffer_index < NUM_DMA_BUFFERS; i++) {
priv(dev)->dma_desc[i].pci_start_addr =
- cpu_to_le32(priv(dev)->
- dio_buffer_phys_addr[buffer_index] + buffer_offset);
+ cpu_to_le32(priv(dev)->dio_buffer_phys_addr[buffer_index] +
+ buffer_offset);
priv(dev)->dma_desc[i].local_start_addr = cpu_to_le32(FIFO_REG);
priv(dev)->dma_desc[i].transfer_size =
- cpu_to_le32(transfer_size);
+ cpu_to_le32(transfer_size);
priv(dev)->dma_desc[i].next =
- cpu_to_le32((priv(dev)->dma_desc_phys_addr + (i +
- 1) *
- sizeof(priv(dev)->dma_desc[0])) | next_bits);
+ cpu_to_le32((priv(dev)->dma_desc_phys_addr + (i +
+ 1) *
+ sizeof(priv(dev)->dma_desc[0])) | next_bits);
priv(dev)->desc_dio_buffer[i] =
- priv(dev)->dio_buffer[buffer_index] +
- (buffer_offset / sizeof(uint32_t));
+ priv(dev)->dio_buffer[buffer_index] +
+ (buffer_offset / sizeof(uint32_t));
buffer_offset += transfer_size;
if (transfer_size + buffer_offset > DMA_BUFFER_SIZE) {
@@ -535,17 +536,18 @@ static int setup_dma_descriptors(struct comedi_device *dev,
DEBUG_PRINT(" desc %i\n", i);
DEBUG_PRINT(" start addr virt 0x%p, phys 0x%lx\n",
- priv(dev)->desc_dio_buffer[i],
- (unsigned long)priv(dev)->dma_desc[i].pci_start_addr);
+ priv(dev)->desc_dio_buffer[i],
+ (unsigned long)priv(dev)->dma_desc[i].
+ pci_start_addr);
DEBUG_PRINT(" next 0x%lx\n",
- (unsigned long)priv(dev)->dma_desc[i].next);
+ (unsigned long)priv(dev)->dma_desc[i].next);
}
priv(dev)->num_dma_descriptors = i;
/* 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);
+ cpu_to_le32(priv(dev)->dma_desc_phys_addr | next_bits);
DEBUG_PRINT(" desc %i next fixup 0x%lx\n", i - 1,
- (unsigned long)priv(dev)->dma_desc[i - 1].next);
+ (unsigned long)priv(dev)->dma_desc[i - 1].next);
priv(dev)->block_size = transfer_size;
@@ -567,14 +569,15 @@ static int hpdi_attach(struct comedi_device *dev, struct comedi_devconfig *it)
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);
+ hpdi_boards[i].device_id,
+ PCI_VENDOR_ID_PLX,
+ hpdi_boards[i].subdevice_id,
+ pcidev);
/* was a particular bus/slot requested? */
if (it->options[0] || it->options[1]) {
/* are we on the wrong bus/slot? */
if (pcidev->bus->number != it->options[0] ||
- PCI_SLOT(pcidev->devfn) !=
- it->options[1])
+ PCI_SLOT(pcidev->devfn) != it->options[1])
continue;
}
if (pcidev) {
@@ -590,11 +593,11 @@ static int hpdi_attach(struct comedi_device *dev, struct comedi_devconfig *it)
}
printk("gsc_hpdi: found %s on bus %i, slot %i\n", board(dev)->name,
- pcidev->bus->number, PCI_SLOT(pcidev->devfn));
+ pcidev->bus->number, PCI_SLOT(pcidev->devfn));
if (comedi_pci_enable(pcidev, driver_hpdi.driver_name)) {
printk(KERN_WARNING
- " failed enable PCI device and request regions\n");
+ " failed enable PCI device and request regions\n");
return -EIO;
}
pci_set_master(pcidev);
@@ -603,15 +606,17 @@ static int hpdi_attach(struct comedi_device *dev, struct comedi_devconfig *it)
dev->board_name = board(dev)->name;
priv(dev)->plx9080_phys_iobase =
- pci_resource_start(pcidev, PLX9080_BADDRINDEX);
+ pci_resource_start(pcidev, PLX9080_BADDRINDEX);
priv(dev)->hpdi_phys_iobase =
- pci_resource_start(pcidev, HPDI_BADDRINDEX);
+ pci_resource_start(pcidev, HPDI_BADDRINDEX);
/* 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,
- pci_resource_len(pcidev, HPDI_BADDRINDEX));
+ pci_resource_len(pcidev,
+ PLX9080_BADDRINDEX));
+ priv(dev)->hpdi_iobase =
+ ioremap(priv(dev)->hpdi_phys_iobase,
+ pci_resource_len(pcidev, HPDI_BADDRINDEX));
if (!priv(dev)->plx9080_iobase || !priv(dev)->hpdi_iobase) {
printk(" failed to remap io memory\n");
return -ENOMEM;
@@ -635,16 +640,18 @@ static int hpdi_attach(struct comedi_device *dev, struct comedi_devconfig *it)
/* 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,
- &priv(dev)->dio_buffer_phys_addr[i]);
+ pci_alloc_consistent(priv(dev)->hw_dev, DMA_BUFFER_SIZE,
+ &priv(dev)->dio_buffer_phys_addr[i]);
DEBUG_PRINT("dio_buffer at virt 0x%p, phys 0x%lx\n",
- priv(dev)->dio_buffer[i],
- (unsigned long)priv(dev)->dio_buffer_phys_addr[i]);
+ priv(dev)->dio_buffer[i],
+ (unsigned long)priv(dev)->dio_buffer_phys_addr[i]);
}
/* 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);
+ sizeof(struct plx_dma_desc) *
+ NUM_DMA_DESCRIPTORS,
+ &priv(dev)->
+ dma_desc_phys_addr);
if (priv(dev)->dma_desc_phys_addr & 0xf) {
printk(" dma descriptors not quad-word aligned (bug)\n");
return -EIO;
@@ -681,18 +688,21 @@ static int hpdi_detach(struct comedi_device *dev)
for (i = 0; i < NUM_DMA_BUFFERS; i++) {
if (priv(dev)->dio_buffer[i])
pci_free_consistent(priv(dev)->hw_dev,
- DMA_BUFFER_SIZE,
- priv(dev)->dio_buffer[i],
- priv(dev)->
- dio_buffer_phys_addr[i]);
+ DMA_BUFFER_SIZE,
+ priv(dev)->
+ dio_buffer[i],
+ priv
+ (dev)->dio_buffer_phys_addr
+ [i]);
}
/* free dma descriptors */
if (priv(dev)->dma_desc)
pci_free_consistent(priv(dev)->hw_dev,
- sizeof(struct plx_dma_desc) *
- NUM_DMA_DESCRIPTORS,
- priv(dev)->dma_desc,
- priv(dev)->dma_desc_phys_addr);
+ sizeof(struct plx_dma_desc)
+ * NUM_DMA_DESCRIPTORS,
+ priv(dev)->dma_desc,
+ priv(dev)->
+ dma_desc_phys_addr);
if (priv(dev)->hpdi_phys_iobase) {
comedi_pci_disable(priv(dev)->hw_dev);
}
@@ -719,7 +729,7 @@ static int dio_config_block_size(struct comedi_device *dev, unsigned int *data)
}
static int di_cmd_test(struct comedi_device *dev, struct comedi_subdevice *s,
- struct comedi_cmd *cmd)
+ struct comedi_cmd *cmd)
{
int err = 0;
int tmp;
@@ -805,7 +815,7 @@ static int di_cmd_test(struct comedi_device *dev, struct comedi_subdevice *s,
if (CR_CHAN(cmd->chanlist[i]) != i) {
/* XXX could support 8 channels or 16 channels */
comedi_error(dev,
- "chanlist must be channels 0 to 31 in order");
+ "chanlist must be channels 0 to 31 in order");
err++;
break;
}
@@ -819,7 +829,7 @@ static int di_cmd_test(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)
+ struct comedi_cmd *cmd)
{
if (priv(dev)->dio_config_output) {
return -EINVAL;
@@ -828,10 +838,10 @@ static int hpdi_cmd_test(struct comedi_device *dev, struct comedi_subdevice *s,
}
static inline void hpdi_writel(struct comedi_device *dev, uint32_t bits,
- unsigned int offset)
+ unsigned int offset)
{
writel(bits | priv(dev)->bits[offset / sizeof(uint32_t)],
- priv(dev)->hpdi_iobase + offset);
+ priv(dev)->hpdi_iobase + offset);
}
static int di_cmd(struct comedi_device *dev, struct comedi_subdevice *s)
@@ -857,16 +867,16 @@ static int di_cmd(struct comedi_device *dev, struct comedi_subdevice *s)
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 */
- bits = priv(dev)->
- dma_desc_phys_addr | PLX_DESC_IN_PCI_BIT | PLX_INTR_TERM_COUNT |
- PLX_XFER_LOCAL_TO_PCI;
+ 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 */
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);
+ priv(dev)->plx9080_iobase + PLX_DMA0_CS_REG);
spin_unlock_irqrestore(&dev->spinlock, flags);
if (cmd->stop_src == TRIG_COUNT)
@@ -876,10 +886,10 @@ static int di_cmd(struct comedi_device *dev, struct comedi_subdevice *s)
/* clear over/under run status flags */
writel(RX_UNDERRUN_BIT | RX_OVERRUN_BIT,
- priv(dev)->hpdi_iobase + BOARD_STATUS_REG);
+ priv(dev)->hpdi_iobase + BOARD_STATUS_REG);
/* enable interrupts */
writel(intr_bit(RX_FULL_INTR),
- priv(dev)->hpdi_iobase + INTERRUPT_CONTROL_REG);
+ priv(dev)->hpdi_iobase + INTERRUPT_CONTROL_REG);
DEBUG_PRINT("hpdi: starting rx\n");
hpdi_writel(dev, RX_ENABLE_BIT, BOARD_CONTROL_REG);
@@ -905,22 +915,21 @@ static void drain_dma_buffers(struct comedi_device *dev, unsigned int channel)
if (channel)
pci_addr_reg =
- priv(dev)->plx9080_iobase + PLX_DMA1_PCI_ADDRESS_REG;
+ priv(dev)->plx9080_iobase + PLX_DMA1_PCI_ADDRESS_REG;
else
pci_addr_reg =
- priv(dev)->plx9080_iobase + PLX_DMA0_PCI_ADDRESS_REG;
+ priv(dev)->plx9080_iobase + PLX_DMA0_PCI_ADDRESS_REG;
/* loop until we have read all the full buffers */
j = 0;
for (next_transfer_addr = readl(pci_addr_reg);
- (next_transfer_addr <
- le32_to_cpu(priv(dev)->dma_desc[priv(dev)->
- dma_desc_index].pci_start_addr)
- || next_transfer_addr >=
- le32_to_cpu(priv(dev)->dma_desc[priv(dev)->
- dma_desc_index].pci_start_addr) +
- priv(dev)->block_size)
- && j < priv(dev)->num_dma_descriptors; j++) {
+ (next_transfer_addr <
+ le32_to_cpu(priv(dev)->dma_desc[priv(dev)->dma_desc_index].
+ pci_start_addr)
+ || next_transfer_addr >=
+ le32_to_cpu(priv(dev)->dma_desc[priv(dev)->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 */
num_samples = priv(dev)->block_size / sizeof(uint32_t);
if (async->cmd.stop_src == TRIG_COUNT) {
@@ -929,13 +938,15 @@ static void drain_dma_buffers(struct comedi_device *dev, unsigned int channel)
priv(dev)->dio_count -= num_samples;
}
cfc_write_array_to_buffer(dev->read_subdev,
- priv(dev)->desc_dio_buffer[priv(dev)->dma_desc_index],
- num_samples * sizeof(uint32_t));
+ priv(dev)->desc_dio_buffer[priv(dev)->
+ dma_desc_index],
+ num_samples * sizeof(uint32_t));
priv(dev)->dma_desc_index++;
priv(dev)->dma_desc_index %= priv(dev)->num_dma_descriptors;
DEBUG_PRINT("next desc addr 0x%lx\n", (unsigned long)
- priv(dev)->dma_desc[priv(dev)->dma_desc_index].next);
+ 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 */
@@ -969,14 +980,14 @@ static irqreturn_t handle_interrupt(int irq, void *d)
if (hpdi_intr_status) {
DEBUG_PRINT("hpdi: intr status 0x%x, ", hpdi_intr_status);
writel(hpdi_intr_status,
- priv(dev)->hpdi_iobase + INTERRUPT_STATUS_REG);
+ priv(dev)->hpdi_iobase + INTERRUPT_STATUS_REG);
}
/* 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 */
writeb((dma0_status & PLX_DMA_EN_BIT) | PLX_CLEAR_DMA_INTR_BIT,
- priv(dev)->plx9080_iobase + PLX_DMA0_CS_REG);
+ priv(dev)->plx9080_iobase + PLX_DMA0_CS_REG);
DEBUG_PRINT("dma0 status 0x%x\n", dma0_status);
if (dma0_status & PLX_DMA_EN_BIT) {
@@ -989,10 +1000,9 @@ static irqreturn_t handle_interrupt(int irq, void *d)
/* 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);
+ priv(dev)->plx9080_iobase + PLX_DMA1_CS_REG);
DEBUG_PRINT("dma1 status 0x%x\n", dma1_status);
DEBUG_PRINT(" cleared dma ch1 interrupt\n");
@@ -1010,8 +1020,8 @@ static irqreturn_t handle_interrupt(int irq, void *d)
comedi_error(dev, "rx fifo overrun");
async->events |= COMEDI_CB_EOA | COMEDI_CB_ERROR;
DEBUG_PRINT("dma0_status 0x%x\n",
- (int)readb(priv(dev)->plx9080_iobase +
- PLX_DMA0_CS_REG));
+ (int)readb(priv(dev)->plx9080_iobase +
+ PLX_DMA0_CS_REG));
}
if (hpdi_board_status & RX_UNDERRUN_BIT) {
diff --git a/drivers/staging/comedi/drivers/icp_multi.c b/drivers/staging/comedi/drivers/icp_multi.c
index 984f995149b6..7a67fff42358 100644
--- a/drivers/staging/comedi/drivers/icp_multi.c
+++ b/drivers/staging/comedi/drivers/icp_multi.c
@@ -110,11 +110,11 @@ Options:
/* Define analogue range */
static const struct comedi_lrange range_analog = { 4, {
- UNI_RANGE(5),
- UNI_RANGE(10),
- BIP_RANGE(5),
- BIP_RANGE(10)
- }
+ UNI_RANGE(5),
+ UNI_RANGE(10),
+ BIP_RANGE(5),
+ BIP_RANGE(10)
+ }
};
static const char range_codes_analog[] = { 0x00, 0x20, 0x10, 0x30 };
@@ -124,7 +124,8 @@ static const char range_codes_analog[] = { 0x00, 0x20, 0x10, 0x30 };
Forward declarations
==============================================================================
*/
-static int icp_multi_attach(struct comedi_device *dev, struct comedi_devconfig *it);
+static int icp_multi_attach(struct comedi_device *dev,
+ struct comedi_devconfig *it);
static int icp_multi_detach(struct comedi_device *dev);
/*
@@ -155,33 +156,33 @@ struct boardtype {
static const struct boardtype boardtypes[] = {
{"icp_multi", /* Driver name */
- DEVICE_ID, /* PCI device ID */
- IORANGE_ICP_MULTI, /* I/O range length */
- 1, /* 1=Card supports interrupts */
- TYPE_ICP_MULTI, /* Card type = ICP MULTI */
- 16, /* Num of A/D channels */
- 8, /* Num of A/D channels in diff mode */
- 4, /* Num of D/A channels */
- 16, /* Num of digital inputs */
- 8, /* Num of digital outputs */
- 4, /* Num of counters */
- 0x0fff, /* Resolution of A/D */
- 0x0fff, /* Resolution of D/A */
- &range_analog, /* Rangelist for A/D */
- range_codes_analog, /* Range codes for programming */
- &range_analog}, /* Rangelist for D/A */
+ DEVICE_ID, /* PCI device ID */
+ IORANGE_ICP_MULTI, /* I/O range length */
+ 1, /* 1=Card supports interrupts */
+ TYPE_ICP_MULTI, /* Card type = ICP MULTI */
+ 16, /* Num of A/D channels */
+ 8, /* Num of A/D channels in diff mode */
+ 4, /* Num of D/A channels */
+ 16, /* Num of digital inputs */
+ 8, /* Num of digital outputs */
+ 4, /* Num of counters */
+ 0x0fff, /* Resolution of A/D */
+ 0x0fff, /* Resolution of D/A */
+ &range_analog, /* Rangelist for A/D */
+ range_codes_analog, /* Range codes for programming */
+ &range_analog}, /* Rangelist for D/A */
};
#define n_boardtypes (sizeof(boardtypes)/sizeof(struct boardtype))
static struct comedi_driver driver_icp_multi = {
- driver_name:"icp_multi",
- module : THIS_MODULE,
- attach : icp_multi_attach,
- detach : icp_multi_detach,
- num_names : n_boardtypes,
- board_name : &boardtypes[0].name,
- offset : sizeof(struct boardtype),
+driver_name:"icp_multi",
+module:THIS_MODULE,
+attach:icp_multi_attach,
+detach:icp_multi_detach,
+num_names:n_boardtypes,
+board_name:&boardtypes[0].name,
+offset:sizeof(struct boardtype),
};
COMEDI_INITCLEANUP(driver_icp_multi);
@@ -199,9 +200,9 @@ struct icp_multi_private {
unsigned char act_chanlist_len; /* len of scanlist */
unsigned char act_chanlist_pos; /* actual position in MUX list */
unsigned int *ai_chanlist; /* actaul chanlist */
- short *ai_data; /* data buffer */
+ short *ai_data; /* data buffer */
short ao_data[4]; /* data output buffer */
- short di_data; /* Digital input data */
+ short di_data; /* Digital input data */
unsigned int do_data; /* Remember digital output data */
};
@@ -215,11 +216,13 @@ struct icp_multi_private {
*/
#if 0
-static int check_channel_list(struct comedi_device *dev, struct comedi_subdevice *s,
- unsigned int *chanlist, unsigned int n_chan);
+static int check_channel_list(struct comedi_device *dev,
+ struct comedi_subdevice *s,
+ unsigned int *chanlist, unsigned int n_chan);
#endif
-static void setup_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,
+ unsigned int *chanlist, unsigned int n_chan);
static int icp_multi_reset(struct comedi_device *dev);
/*
@@ -246,8 +249,9 @@ static int icp_multi_reset(struct comedi_device *dev);
==============================================================================
*/
-static int icp_multi_insn_read_ai(struct comedi_device *dev, struct comedi_subdevice *s,
- struct comedi_insn *insn, unsigned int *data)
+static int icp_multi_insn_read_ai(struct comedi_device *dev,
+ struct comedi_subdevice *s,
+ struct comedi_insn *insn, unsigned int *data)
{
int n, timeout;
@@ -267,42 +271,42 @@ static int icp_multi_insn_read_ai(struct comedi_device *dev, struct comedi_subde
#ifdef ICP_MULTI_EXTDEBUG
printk("icp_multi A ST=%4x IO=%p\n",
- readw(devpriv->io_addr + ICP_MULTI_ADC_CSR),
- devpriv->io_addr + ICP_MULTI_ADC_CSR);
+ readw(devpriv->io_addr + ICP_MULTI_ADC_CSR),
+ devpriv->io_addr + ICP_MULTI_ADC_CSR);
#endif
for (n = 0; n < insn->n; n++) {
/* Set start ADC bit */
devpriv->AdcCmdStatus |= ADC_ST;
writew(devpriv->AdcCmdStatus,
- devpriv->io_addr + ICP_MULTI_ADC_CSR);
+ devpriv->io_addr + ICP_MULTI_ADC_CSR);
devpriv->AdcCmdStatus &= ~ADC_ST;
#ifdef ICP_MULTI_EXTDEBUG
printk("icp multi B n=%d ST=%4x\n", n,
- readw(devpriv->io_addr + ICP_MULTI_ADC_CSR));
+ readw(devpriv->io_addr + ICP_MULTI_ADC_CSR));
#endif
udelay(1);
#ifdef ICP_MULTI_EXTDEBUG
printk("icp multi C n=%d ST=%4x\n", n,
- readw(devpriv->io_addr + ICP_MULTI_ADC_CSR));
+ readw(devpriv->io_addr + ICP_MULTI_ADC_CSR));
#endif
/* Wait for conversion to complete, or get fed up waiting */
timeout = 100;
while (timeout--) {
if (!(readw(devpriv->io_addr +
- ICP_MULTI_ADC_CSR) & ADC_BSY))
+ ICP_MULTI_ADC_CSR) & ADC_BSY))
goto conv_finish;
#ifdef ICP_MULTI_EXTDEBUG
if (!(timeout % 10))
printk("icp multi D n=%d tm=%d ST=%4x\n", n,
- timeout,
- readw(devpriv->io_addr +
- ICP_MULTI_ADC_CSR));
+ timeout,
+ readw(devpriv->io_addr +
+ ICP_MULTI_ADC_CSR));
#endif
udelay(1);
@@ -318,19 +322,21 @@ static int icp_multi_insn_read_ai(struct comedi_device *dev, struct comedi_subde
/* Clear interrupt status */
devpriv->IntStatus |= ADC_READY;
writew(devpriv->IntStatus,
- devpriv->io_addr + ICP_MULTI_INT_STAT);
+ devpriv->io_addr + ICP_MULTI_INT_STAT);
/* Clear data received */
data[n] = 0;
#ifdef ICP_MULTI_EXTDEBUG
- printk("icp multi EDBG: END: icp_multi_insn_read_ai(...) n=%d\n", n);
+ printk
+ ("icp multi EDBG: END: icp_multi_insn_read_ai(...) n=%d\n",
+ n);
#endif
return -ETIME;
- conv_finish:
+conv_finish:
data[n] =
- (readw(devpriv->io_addr + ICP_MULTI_AI) >> 4) & 0x0fff;
+ (readw(devpriv->io_addr + ICP_MULTI_AI) >> 4) & 0x0fff;
}
/* Disable interrupt */
@@ -365,8 +371,9 @@ static int icp_multi_insn_read_ai(struct comedi_device *dev, struct comedi_subde
==============================================================================
*/
-static int icp_multi_insn_write_ao(struct comedi_device *dev, struct comedi_subdevice *s,
- struct comedi_insn *insn, unsigned int *data)
+static int icp_multi_insn_write_ao(struct comedi_device *dev,
+ struct comedi_subdevice *s,
+ struct comedi_insn *insn, unsigned int *data)
{
int n, chan, range, timeout;
@@ -401,15 +408,15 @@ static int icp_multi_insn_write_ao(struct comedi_device *dev, struct comedi_subd
timeout = 100;
while (timeout--) {
if (!(readw(devpriv->io_addr +
- ICP_MULTI_DAC_CSR) & DAC_BSY))
+ ICP_MULTI_DAC_CSR) & DAC_BSY))
goto dac_ready;
#ifdef ICP_MULTI_EXTDEBUG
if (!(timeout % 10))
printk("icp multi A n=%d tm=%d ST=%4x\n", n,
- timeout,
- readw(devpriv->io_addr +
- ICP_MULTI_DAC_CSR));
+ timeout,
+ readw(devpriv->io_addr +
+ ICP_MULTI_DAC_CSR));
#endif
udelay(1);
@@ -425,24 +432,26 @@ static int icp_multi_insn_write_ao(struct comedi_device *dev, struct comedi_subd
/* Clear interrupt status */
devpriv->IntStatus |= DAC_READY;
writew(devpriv->IntStatus,
- devpriv->io_addr + ICP_MULTI_INT_STAT);
+ devpriv->io_addr + ICP_MULTI_INT_STAT);
/* Clear data received */
devpriv->ao_data[chan] = 0;
#ifdef ICP_MULTI_EXTDEBUG
- printk("icp multi EDBG: END: icp_multi_insn_write_ao(...) n=%d\n", n);
+ printk
+ ("icp multi EDBG: END: icp_multi_insn_write_ao(...) n=%d\n",
+ n);
#endif
return -ETIME;
- dac_ready:
+dac_ready:
/* Write data to analogue output data register */
writew(data[n], devpriv->io_addr + ICP_MULTI_AO);
/* Set DAC_ST bit to write the data to selected channel */
devpriv->DacCmdStatus |= DAC_ST;
writew(devpriv->DacCmdStatus,
- devpriv->io_addr + ICP_MULTI_DAC_CSR);
+ devpriv->io_addr + ICP_MULTI_DAC_CSR);
devpriv->DacCmdStatus &= ~DAC_ST;
/* Save analogue output data */
@@ -473,8 +482,9 @@ static int icp_multi_insn_write_ao(struct comedi_device *dev, struct comedi_subd
==============================================================================
*/
-static int icp_multi_insn_read_ao(struct comedi_device *dev, struct comedi_subdevice *s,
- struct comedi_insn *insn, unsigned int *data)
+static int icp_multi_insn_read_ao(struct comedi_device *dev,
+ struct comedi_subdevice *s,
+ struct comedi_insn *insn, unsigned int *data)
{
int n, chan;
@@ -506,8 +516,9 @@ static int icp_multi_insn_read_ao(struct comedi_device *dev, struct comedi_subde
==============================================================================
*/
-static int icp_multi_insn_bits_di(struct comedi_device *dev, struct comedi_subdevice *s,
- struct comedi_insn *insn, unsigned int *data)
+static int icp_multi_insn_bits_di(struct comedi_device *dev,
+ struct comedi_subdevice *s,
+ struct comedi_insn *insn, unsigned int *data)
{
data[1] = readw(devpriv->io_addr + ICP_MULTI_DI);
@@ -532,8 +543,9 @@ static int icp_multi_insn_bits_di(struct comedi_device *dev, struct comedi_subde
==============================================================================
*/
-static int icp_multi_insn_bits_do(struct comedi_device *dev, struct comedi_subdevice *s,
- struct comedi_insn *insn, unsigned int *data)
+static int icp_multi_insn_bits_do(struct comedi_device *dev,
+ struct comedi_subdevice *s,
+ struct comedi_insn *insn, unsigned int *data)
{
#ifdef ICP_MULTI_EXTDEBUG
printk("icp multi EDBG: BGN: icp_multi_insn_bits_do(...)\n");
@@ -574,8 +586,9 @@ static int icp_multi_insn_bits_do(struct comedi_device *dev, struct comedi_subde
==============================================================================
*/
-static int icp_multi_insn_read_ctr(struct comedi_device *dev, struct comedi_subdevice *s,
- struct comedi_insn *insn, unsigned int *data)
+static int icp_multi_insn_read_ctr(struct comedi_device *dev,
+ struct comedi_subdevice *s,
+ struct comedi_insn *insn, unsigned int *data)
{
return 0;
}
@@ -598,8 +611,10 @@ static int icp_multi_insn_read_ctr(struct comedi_device *dev, struct comedi_subd
==============================================================================
*/
-static int icp_multi_insn_write_ctr(struct comedi_device *dev, struct comedi_subdevice *s,
- struct comedi_insn *insn, unsigned int *data)
+static int icp_multi_insn_write_ctr(struct comedi_device *dev,
+ struct comedi_subdevice *s,
+ struct comedi_insn *insn,
+ unsigned int *data)
{
return 0;
}
@@ -626,7 +641,7 @@ static irqreturn_t interrupt_service_icp_multi(int irq, void *d)
#ifdef ICP_MULTI_EXTDEBUG
printk("icp multi EDBG: BGN: interrupt_service_icp_multi(%d,...)\n",
- irq);
+ irq);
#endif
/* Is this interrupt from our board? */
@@ -637,7 +652,7 @@ static irqreturn_t interrupt_service_icp_multi(int irq, void *d)
#ifdef ICP_MULTI_EXTDEBUG
printk("icp multi EDBG: interrupt_service_icp_multi() ST: %4x\n",
- readw(devpriv->io_addr + ICP_MULTI_INT_STAT));
+ readw(devpriv->io_addr + ICP_MULTI_INT_STAT));
#endif
/* Determine which interrupt is active & handle it */
@@ -690,8 +705,9 @@ static irqreturn_t interrupt_service_icp_multi(int irq, void *d)
==============================================================================
*/
-static int check_channel_list(struct comedi_device *dev, struct comedi_subdevice *s,
- unsigned int *chanlist, unsigned int n_chan)
+static int check_channel_list(struct comedi_device *dev,
+ struct comedi_subdevice *s,
+ unsigned int *chanlist, unsigned int n_chan)
{
unsigned int i;
@@ -709,13 +725,13 @@ static int check_channel_list(struct comedi_device *dev, struct comedi_subdevice
if (CR_AREF(chanlist[i]) == AREF_DIFF) {
if (CR_CHAN(chanlist[i]) > this_board->n_aichand) {
comedi_error(dev,
- "Incorrect differential ai channel number");
+ "Incorrect differential ai channel number");
return 0;
}
} else {
if (CR_CHAN(chanlist[i]) > this_board->n_aichan) {
comedi_error(dev,
- "Incorrect ai channel number");
+ "Incorrect ai channel number");
return 0;
}
}
@@ -744,8 +760,9 @@ static int check_channel_list(struct comedi_device *dev, struct comedi_subdevice
==============================================================================
*/
-static void setup_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,
+ unsigned int *chanlist, unsigned int n_chan)
{
unsigned int i, range, chanprog;
unsigned int diff;
@@ -788,11 +805,11 @@ static void setup_channel_list(struct comedi_device *dev, struct comedi_subdevic
/* Output channel, range, mode to ICP Multi */
writew(devpriv->AdcCmdStatus,
- devpriv->io_addr + ICP_MULTI_ADC_CSR);
+ devpriv->io_addr + ICP_MULTI_ADC_CSR);
#ifdef ICP_MULTI_EXTDEBUG
printk("GS: %2d. [%4x]=%4x %4x\n", i, chanprog, range,
- devpriv->act_chanlist[i]);
+ devpriv->act_chanlist[i]);
#endif
}
@@ -840,7 +857,7 @@ static int icp_multi_reset(struct comedi_device *dev)
/* Output to command / status register */
writew(devpriv->DacCmdStatus,
- devpriv->io_addr + ICP_MULTI_DAC_CSR);
+ devpriv->io_addr + ICP_MULTI_DAC_CSR);
/* Delay to allow DAC time to recover */
udelay(1);
@@ -871,7 +888,8 @@ static int icp_multi_reset(struct comedi_device *dev)
==============================================================================
*/
-static int icp_multi_attach(struct comedi_device *dev, struct comedi_devconfig *it)
+static int icp_multi_attach(struct comedi_device *dev,
+ struct comedi_devconfig *it)
{
struct comedi_subdevice *s;
int ret, subdev, n_subdevices;
@@ -891,15 +909,15 @@ static int icp_multi_attach(struct comedi_device *dev, struct comedi_devconfig *
if (pci_list_builded++ == 0) {
pci_card_list_init(PCI_VENDOR_ID_ICP,
#ifdef ICP_MULTI_EXTDEBUG
- 1
+ 1
#else
- 0
+ 0
#endif
- );
+ );
}
printk("Anne's comedi%d: icp_multi: board=%s", dev->minor,
- this_board->name);
+ this_board->name);
card = select_and_alloc_pci_card(PCI_VENDOR_ID_ICP,
this_board->device_id, it->options[0],
@@ -911,7 +929,7 @@ static int icp_multi_attach(struct comedi_device *dev, struct comedi_devconfig *
devpriv->card = card;
if ((pci_card_data(card, &pci_bus, &pci_slot, &pci_func, &io_addr[0],
- &irq)) < 0) {
+ &irq)) < 0) {
printk(" - Can't get configuration data!\n");
return -EIO;
}
@@ -920,7 +938,7 @@ static int icp_multi_attach(struct comedi_device *dev, struct comedi_devconfig *
devpriv->phys_iobase = iobase;
printk(", b:s:f=%d:%d:%d, io=0x%8llx \n", pci_bus, pci_slot, pci_func,
- (unsigned long long)iobase);
+ (unsigned long long)iobase);
devpriv->io_addr = ioremap(iobase, ICP_MULTI_SIZE);
@@ -930,7 +948,7 @@ static int icp_multi_attach(struct comedi_device *dev, struct comedi_devconfig *
}
#ifdef ICP_MULTI_EXTDEBUG
printk("0x%08llx mapped to %p, ", (unsigned long long)iobase,
- devpriv->io_addr);
+ devpriv->io_addr);
#endif
dev->board_name = this_board->name;
@@ -957,7 +975,9 @@ static int icp_multi_attach(struct comedi_device *dev, struct comedi_devconfig *
if (irq) {
if (request_irq(irq, interrupt_service_icp_multi,
IRQF_SHARED, "Inova Icp Multi", dev)) {
- printk(", unable to allocate IRQ %u, DISABLING IT", irq);
+ printk
+ (", unable to allocate IRQ %u, DISABLING IT",
+ irq);
irq = 0; /* Can't use IRQ */
} else
printk(", irq=%u", irq);
diff --git a/drivers/staging/comedi/drivers/icp_multi.h b/drivers/staging/comedi/drivers/icp_multi.h
index 354ba8f14f81..8caadc630ed5 100644
--- a/drivers/staging/comedi/drivers/icp_multi.h
+++ b/drivers/staging/comedi/drivers/icp_multi.h
@@ -36,20 +36,26 @@ struct pcilst_struct *inova_devices;
static void pci_card_list_init(unsigned short pci_vendor, char display);
static void pci_card_list_cleanup(unsigned short pci_vendor);
static struct pcilst_struct *find_free_pci_card_by_device(unsigned short
- vendor_id, unsigned short device_id);
+ vendor_id,
+ unsigned short
+ device_id);
static int find_free_pci_card_by_position(unsigned short vendor_id,
- unsigned short device_id, unsigned short pci_bus,
- unsigned short pci_slot, struct pcilst_struct **card);
+ unsigned short device_id,
+ unsigned short pci_bus,
+ unsigned short pci_slot,
+ struct pcilst_struct **card);
static struct pcilst_struct *select_and_alloc_pci_card(unsigned short vendor_id,
- unsigned short device_id, unsigned short pci_bus,
- unsigned short pci_slot);
+ unsigned short device_id,
+ unsigned short pci_bus,
+ unsigned short pci_slot);
static int pci_card_alloc(struct pcilst_struct *amcc);
static int pci_card_free(struct pcilst_struct *amcc);
static void pci_card_list_display(void);
static int pci_card_data(struct pcilst_struct *amcc,
- unsigned char *pci_bus, unsigned char *pci_slot,
- unsigned char *pci_func, resource_size_t * io_addr, unsigned int *irq);
+ unsigned char *pci_bus, unsigned char *pci_slot,
+ unsigned char *pci_func, resource_size_t * io_addr,
+ unsigned int *irq);
/****************************************************************************/
@@ -64,12 +70,13 @@ static void pci_card_list_init(unsigned short pci_vendor, char display)
last = NULL;
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)) {
+ pcidev != NULL;
+ pcidev = pci_get_device(PCI_ANY_ID, PCI_ANY_ID, pcidev)) {
if (pcidev->vendor == pci_vendor) {
inova = kmalloc(sizeof(*inova), GFP_KERNEL);
if (!inova) {
- printk("icp_multi: pci_card_list_init: allocation failed\n");
+ printk
+ ("icp_multi: pci_card_list_init: allocation failed\n");
pci_dev_put(pcidev);
break;
}
@@ -93,7 +100,7 @@ static void pci_card_list_init(unsigned short pci_vendor, char display)
* pci_card_alloc. */
for (i = 0; i < 5; i++)
inova->io_addr[i] =
- pci_resource_start(pcidev, i);
+ pci_resource_start(pcidev, i);
inova->irq = pcidev->irq;
}
}
@@ -120,14 +127,16 @@ static void pci_card_list_cleanup(unsigned short pci_vendor)
/****************************************************************************/
/* find first unused card with this device_id */
static struct pcilst_struct *find_free_pci_card_by_device(unsigned short
- vendor_id, unsigned short device_id)
+ vendor_id,
+ unsigned short
+ device_id)
{
struct pcilst_struct *inova, *next;
for (inova = inova_devices; inova; inova = next) {
next = inova->next;
if ((!inova->used) && (inova->device == device_id)
- && (inova->vendor == vendor_id))
+ && (inova->vendor == vendor_id))
return inova;
}
@@ -138,8 +147,10 @@ static struct pcilst_struct *find_free_pci_card_by_device(unsigned short
/****************************************************************************/
/* find card on requested position */
static int find_free_pci_card_by_position(unsigned short vendor_id,
- unsigned short device_id, unsigned short pci_bus,
- unsigned short pci_slot, struct pcilst_struct **card)
+ unsigned short device_id,
+ unsigned short pci_bus,
+ unsigned short pci_slot,
+ struct pcilst_struct **card)
{
struct pcilst_struct *inova, *next;
@@ -147,8 +158,8 @@ static int find_free_pci_card_by_position(unsigned short vendor_id,
for (inova = inova_devices; inova; inova = next) {
next = inova->next;
if ((inova->vendor == vendor_id) && (inova->device == device_id)
- && (inova->pci_bus == pci_bus)
- && (inova->pci_slot == pci_slot)) {
+ && (inova->pci_bus == pci_bus)
+ && (inova->pci_slot == pci_slot)) {
if (!(inova->used)) {
*card = inova;
return 0; /* ok, card is found */
@@ -211,7 +222,13 @@ static void pci_card_list_display(void)
for (inova = inova_devices; inova; inova = next) {
next = inova->next;
- printk("%2d %2d %2d 0x%4x 0x%4x 0x%8llx 0x%8llx %2u %2d\n", inova->pci_bus, inova->pci_slot, inova->pci_func, inova->vendor, inova->device, (unsigned long long)inova->io_addr[0], (unsigned long long)inova->io_addr[2], inova->irq, inova->used);
+ printk
+ ("%2d %2d %2d 0x%4x 0x%4x 0x%8llx 0x%8llx %2u %2d\n",
+ inova->pci_bus, inova->pci_slot, inova->pci_func,
+ inova->vendor, inova->device,
+ (unsigned long long)inova->io_addr[0],
+ (unsigned long long)inova->io_addr[2], inova->irq,
+ inova->used);
}
}
@@ -219,8 +236,9 @@ static void pci_card_list_display(void)
/****************************************************************************/
/* return all card information for driver */
static int pci_card_data(struct pcilst_struct *inova,
- unsigned char *pci_bus, unsigned char *pci_slot,
- unsigned char *pci_func, resource_size_t * io_addr, unsigned int *irq)
+ unsigned char *pci_bus, unsigned char *pci_slot,
+ unsigned char *pci_func, resource_size_t * io_addr,
+ unsigned int *irq)
{
int i;
@@ -238,8 +256,9 @@ static int pci_card_data(struct pcilst_struct *inova,
/****************************************************************************/
/* select and alloc card */
static struct pcilst_struct *select_and_alloc_pci_card(unsigned short vendor_id,
- unsigned short device_id, unsigned short pci_bus,
- unsigned short pci_slot)
+ unsigned short device_id,
+ unsigned short pci_bus,
+ unsigned short pci_slot)
{
struct pcilst_struct *card;
int err;
@@ -253,16 +272,17 @@ static struct pcilst_struct *select_and_alloc_pci_card(unsigned short vendor_id,
}
} else {
switch (find_free_pci_card_by_position(vendor_id, device_id,
- pci_bus, pci_slot, &card)) {
+ pci_bus, pci_slot,
+ &card)) {
case 1:
printk
- (" - Card not found on requested position b:s %d:%d!\n",
- pci_bus, pci_slot);
+ (" - Card not found on requested position b:s %d:%d!\n",
+ pci_bus, pci_slot);
return NULL;
case 2:
printk
- (" - Card on requested position is used b:s %d:%d!\n",
- pci_bus, pci_slot);
+ (" - Card on requested position is used b:s %d:%d!\n",
+ pci_bus, pci_slot);
return NULL;
}
}
diff --git a/drivers/staging/comedi/drivers/ii_pci20kc.c b/drivers/staging/comedi/drivers/ii_pci20kc.c
index a90d65fde31e..24df2453e683 100644
--- a/drivers/staging/comedi/drivers/ii_pci20kc.c
+++ b/drivers/staging/comedi/drivers/ii_pci20kc.c
@@ -154,11 +154,11 @@ struct pci20xxx_private {
union pci20xxx_subdev_private subdev_private[PCI20000_MODULES];
};
-
#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_attach(struct comedi_device *dev,
+ struct comedi_devconfig *it);
static int pci20xxx_detach(struct comedi_device *dev);
static struct comedi_driver driver_pci20xxx = {
@@ -169,10 +169,11 @@ static struct comedi_driver driver_pci20xxx = {
};
static int pci20006_init(struct comedi_device *dev, struct comedi_subdevice *s,
- int opt0, int opt1);
+ int opt0, int opt1);
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);
+ int opt0, int opt1);
+static int pci20xxx_dio_init(struct comedi_device *dev,
+ struct comedi_subdevice *s);
/*
options[0] Board base address
@@ -201,7 +202,8 @@ 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;
@@ -223,7 +225,9 @@ static int pci20xxx_attach(struct comedi_device *dev, struct comedi_devconfig *i
/* Check PCI-20001 C-2A Carrier Board ID */
if ((readb(devpriv->ioaddr) & PCI20000_ID) != PCI20000_ID) {
printk("comedi%d: ii_pci20kc", dev->minor);
- printk(" PCI-20001 C-2A Carrier Board at base=0x%p not found !\n", devpriv->ioaddr);
+ printk
+ (" PCI-20001 C-2A Carrier Board at base=0x%p not found !\n",
+ devpriv->ioaddr);
return -EINVAL;
}
printk("comedi%d:\n", dev->minor);
@@ -237,22 +241,24 @@ static int pci20xxx_attach(struct comedi_device *dev, struct comedi_devconfig *i
switch (id) {
case PCI20006_ID:
sdp->pci20006.iobase =
- devpriv->ioaddr + (i + 1) * PCI20000_OFFSET;
+ devpriv->ioaddr + (i + 1) * PCI20000_OFFSET;
pci20006_init(dev, s, it->options[2 * i + 2],
- it->options[2 * i + 3]);
+ it->options[2 * i + 3]);
printk("comedi%d: ii_pci20kc", dev->minor);
printk(" PCI-20006 module in slot %d \n", i + 1);
break;
case PCI20341_ID:
sdp->pci20341.iobase =
- devpriv->ioaddr + (i + 1) * PCI20000_OFFSET;
+ devpriv->ioaddr + (i + 1) * PCI20000_OFFSET;
pci20341_init(dev, s, it->options[2 * i + 2],
- it->options[2 * i + 3]);
+ it->options[2 * i + 3]);
printk("comedi%d: ii_pci20kc", dev->minor);
printk(" PCI-20341 module in slot %d \n", i + 1);
break;
default:
- printk("ii_pci20kc: unknown module code 0x%02x in slot %d: module disabled\n", id, i);
+ printk
+ ("ii_pci20kc: unknown module code 0x%02x in slot %d: module disabled\n",
+ id, i);
/* fall through */
case PCI20xxx_EMPTY_ID:
s->type = COMEDI_SUBD_UNUSED;
@@ -275,10 +281,12 @@ 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,
@@ -287,7 +295,7 @@ static const struct comedi_lrange *pci20006_range_list[] = {
};
static int pci20006_init(struct comedi_device *dev, struct comedi_subdevice *s,
- int opt0, int opt1)
+ int opt0, int opt1)
{
union pci20xxx_subdev_private *sdp = s->private;
@@ -311,8 +319,9 @@ 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;
@@ -321,8 +330,9 @@ static int pci20006_insn_read(struct comedi_device *dev, struct comedi_subdevice
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;
@@ -354,15 +364,17 @@ static int pci20006_insn_write(struct comedi_device *dev, struct comedi_subdevic
/* 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 };
static const struct comedi_lrange range_bipolar0_5 = { 1, {BIP_RANGE(0.5)} };
static const struct comedi_lrange range_bipolar0_05 = { 1, {BIP_RANGE(0.05)} };
-static const struct comedi_lrange range_bipolar0_025 = { 1, {BIP_RANGE(0.025)} };
+static const struct comedi_lrange range_bipolar0_025 =
+ { 1, {BIP_RANGE(0.025)} };
static const struct comedi_lrange *const pci20341_ranges[] = {
&range_bipolar5,
@@ -372,7 +384,7 @@ static const struct comedi_lrange *const pci20341_ranges[] = {
};
static int pci20341_init(struct comedi_device *dev, struct comedi_subdevice *s,
- int opt0, int opt1)
+ int opt0, int opt1)
{
union pci20xxx_subdev_private *sdp = s->private;
int option;
@@ -402,10 +414,11 @@ 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;
+ union pci20xxx_subdev_private *sdp = s->private;
unsigned int i = 0, j = 0;
int lo, hi;
unsigned char eoc; /* end of conversion */
@@ -414,7 +427,7 @@ static int pci20341_insn_read(struct comedi_device *dev, struct comedi_subdevice
writeb(1, sdp->iobase + PCI20341_LCHAN_ADDR_REG); /* write number of input channels */
clb = PCI20341_DAISY_CHAIN | PCI20341_MUX | (sdp->pci20341.ai_gain << 3)
- | CR_CHAN(insn->chanspec);
+ | CR_CHAN(insn->chanspec);
writeb(clb, sdp->iobase + PCI20341_CHAN_LIST);
writeb(0x00, sdp->iobase + PCI20341_CC_RESET); /* reset settling time counter and trigger delay counter */
writeb(0x00, sdp->iobase + PCI20341_CHAN_RESET);
@@ -434,13 +447,15 @@ static int pci20341_insn_read(struct comedi_device *dev, struct comedi_subdevice
eoc = readb(sdp->iobase + PCI20341_STATUS_REG);
}
if (j >= 100) {
- printk("comedi%d: pci20xxx: AI interrupt channel %i polling exit !\n", dev->minor, i);
+ printk
+ ("comedi%d: pci20xxx: AI interrupt channel %i polling exit !\n",
+ dev->minor, i);
return -EINVAL;
}
lo = readb(sdp->iobase + PCI20341_LDATA);
hi = readb(sdp->iobase + PCI20341_LDATA + 1);
boarddata = lo + 0x100 * hi;
- data[i] = (short) ((boarddata + 0x8000) & 0xffff); /* board-data -> comedi-data */
+ data[i] = (short)((boarddata + 0x8000) & 0xffff); /* board-data -> comedi-data */
}
return i;
@@ -448,14 +463,19 @@ static int pci20341_insn_read(struct comedi_device *dev, struct comedi_subdevice
/* 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;
@@ -474,8 +494,10 @@ 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;
@@ -499,8 +521,9 @@ static int pci20xxx_dio_insn_config(struct comedi_device *dev, struct comedi_sub
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];
@@ -510,16 +533,16 @@ static int pci20xxx_dio_insn_bits(struct comedi_device *dev, struct comedi_subde
mask &= s->io_bits;
if (mask & 0x000000ff)
writeb((s->state >> 0) & 0xff,
- devpriv->ioaddr + PCI20000_DIO_0);
+ devpriv->ioaddr + PCI20000_DIO_0);
if (mask & 0x0000ff00)
writeb((s->state >> 8) & 0xff,
- devpriv->ioaddr + PCI20000_DIO_1);
+ devpriv->ioaddr + PCI20000_DIO_1);
if (mask & 0x00ff0000)
writeb((s->state >> 16) & 0xff,
- devpriv->ioaddr + PCI20000_DIO_2);
+ devpriv->ioaddr + PCI20000_DIO_2);
if (mask & 0xff000000)
writeb((s->state >> 24) & 0xff,
- devpriv->ioaddr + PCI20000_DIO_3);
+ devpriv->ioaddr + PCI20000_DIO_3);
data[1] = readb(devpriv->ioaddr + PCI20000_DIO_0);
data[1] |= readb(devpriv->ioaddr + PCI20000_DIO_1) << 8;
@@ -529,7 +552,8 @@ static int pci20xxx_dio_insn_bits(struct comedi_device *dev, struct comedi_subde
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;
@@ -543,7 +567,7 @@ static void pci20xxx_dio_config(struct comedi_device *dev, struct comedi_subdevi
/* output port 0 */
control_01 &= PCI20000_DIO_EOC;
buffer = (buffer & (~(DIO_BE << DIO_PS_0))) | (DIO_BO <<
- DIO_PS_0);
+ DIO_PS_0);
} else {
/* input port 0 */
control_01 = (control_01 & DIO_CAND) | PCI20000_DIO_EIC;
@@ -553,7 +577,7 @@ static void pci20xxx_dio_config(struct comedi_device *dev, struct comedi_subdevi
/* output port 1 */
control_01 &= PCI20000_DIO_OOC;
buffer = (buffer & (~(DIO_BE << DIO_PS_1))) | (DIO_BO <<
- DIO_PS_1);
+ DIO_PS_1);
} else {
/* input port 1 */
control_01 = (control_01 & DIO_CAND) | PCI20000_DIO_OIC;
@@ -563,7 +587,7 @@ static void pci20xxx_dio_config(struct comedi_device *dev, struct comedi_subdevi
/* output port 2 */
control_23 &= PCI20000_DIO_EOC;
buffer = (buffer & (~(DIO_BE << DIO_PS_2))) | (DIO_BO <<
- DIO_PS_2);
+ DIO_PS_2);
} else {
/* input port 2 */
control_23 = (control_23 & DIO_CAND) | PCI20000_DIO_EIC;
@@ -573,7 +597,7 @@ static void pci20xxx_dio_config(struct comedi_device *dev, struct comedi_subdevi
/* output port 3 */
control_23 &= PCI20000_DIO_OOC;
buffer = (buffer & (~(DIO_BE << DIO_PS_3))) | (DIO_BO <<
- DIO_PS_3);
+ DIO_PS_3);
} else {
/* input port 3 */
control_23 = (control_23 & DIO_CAND) | PCI20000_DIO_OIC;
@@ -598,7 +622,8 @@ 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 baf83c6a9412..14bf29bf5781 100644
--- a/drivers/staging/comedi/drivers/jr3_pci.c
+++ b/drivers/staging/comedi/drivers/jr3_pci.c
@@ -45,6 +45,8 @@ Devices: [JR3] PCI force sensor board (jr3_pci)
#include <linux/delay.h>
#include <linux/ctype.h>
#include <linux/firmware.h>
+#include <linux/jiffies.h>
+#include <linux/timer.h>
#include "comedi_pci.h"
#include "jr3_pci.h"
@@ -54,7 +56,8 @@ Devices: [JR3] PCI force sensor board (jr3_pci)
#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_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 = {
@@ -65,15 +68,16 @@ static struct comedi_driver driver_jr3_pci = {
};
static DEFINE_PCI_DEVICE_TABLE(jr3_pci_pci_table) = {
- {PCI_VENDOR_ID_JR3, PCI_DEVICE_ID_JR3_1_CHANNEL,
- PCI_ANY_ID, PCI_ANY_ID, 0, 0, 0},
- {PCI_VENDOR_ID_JR3, PCI_DEVICE_ID_JR3_2_CHANNEL,
- PCI_ANY_ID, PCI_ANY_ID, 0, 0, 0},
- {PCI_VENDOR_ID_JR3, PCI_DEVICE_ID_JR3_3_CHANNEL,
- PCI_ANY_ID, PCI_ANY_ID, 0, 0, 0},
- {PCI_VENDOR_ID_JR3, PCI_DEVICE_ID_JR3_4_CHANNEL,
- PCI_ANY_ID, PCI_ANY_ID, 0, 0, 0},
- {0}
+ {
+ PCI_VENDOR_ID_JR3, PCI_DEVICE_ID_JR3_1_CHANNEL,
+ PCI_ANY_ID, PCI_ANY_ID, 0, 0, 0}, {
+ PCI_VENDOR_ID_JR3, PCI_DEVICE_ID_JR3_2_CHANNEL,
+ PCI_ANY_ID, PCI_ANY_ID, 0, 0, 0}, {
+ PCI_VENDOR_ID_JR3, PCI_DEVICE_ID_JR3_3_CHANNEL,
+ PCI_ANY_ID, PCI_ANY_ID, 0, 0, 0}, {
+ PCI_VENDOR_ID_JR3, PCI_DEVICE_ID_JR3_4_CHANNEL,
+ PCI_ANY_ID, PCI_ANY_ID, 0, 0, 0}, {
+ 0}
};
MODULE_DEVICE_TABLE(pci, jr3_pci_pci_table);
@@ -87,14 +91,12 @@ struct jr3_pci_dev_private {
struct timer_list timer;
};
-
struct poll_delay_t {
int min;
int max;
};
-
struct jr3_pci_subdev_private {
volatile struct jr3_channel *channel;
unsigned long next_time_min;
@@ -122,7 +124,7 @@ struct jr3_pci_subdev_private {
/* Hotplug firmware loading stuff */
typedef int comedi_firmware_callback(struct comedi_device *dev,
- const u8 *data, size_t size);
+ const u8 * data, size_t size);
static int comedi_load_firmware(struct comedi_device *dev, char *name,
comedi_firmware_callback cb)
@@ -141,7 +143,7 @@ static int comedi_load_firmware(struct comedi_device *dev, char *name,
strcat(firmware_path, prefix);
strcat(firmware_path, name);
result = request_firmware(&fw, firmware_path,
- &devpriv->pci_dev->dev);
+ &devpriv->pci_dev->dev);
if (result == 0) {
if (!cb)
result = -EINVAL;
@@ -176,7 +178,7 @@ struct transform_t {
};
static void set_transforms(volatile struct jr3_channel *channel,
- struct transform_t transf, short num)
+ struct transform_t transf, short num)
{
int i;
@@ -195,7 +197,8 @@ static void set_transforms(volatile struct jr3_channel *channel,
}
}
-static void use_transform(volatile struct jr3_channel *channel, short transf_num)
+static void use_transform(volatile struct jr3_channel *channel,
+ short transf_num)
{
set_s16(&channel->command_word0, 0x0500 + (transf_num & 0x000f));
}
@@ -220,12 +223,12 @@ struct six_axis_t {
};
static void set_full_scales(volatile struct jr3_channel *channel,
- struct six_axis_t full_scale)
+ struct six_axis_t full_scale)
{
printk("%d %d %d %d %d %d\n",
- full_scale.fx,
- full_scale.fy,
- full_scale.fz, full_scale.mx, full_scale.my, full_scale.mz);
+ full_scale.fx,
+ full_scale.fy,
+ full_scale.fz, full_scale.mx, full_scale.my, full_scale.mz);
set_s16(&channel->full_scale.fx, full_scale.fx);
set_s16(&channel->full_scale.fy, full_scale.fy);
set_s16(&channel->full_scale.fz, full_scale.fz);
@@ -235,7 +238,8 @@ static void set_full_scales(volatile struct jr3_channel *channel,
set_s16(&channel->command_word0, 0x0a00);
}
-static struct six_axis_t get_min_full_scales(volatile struct jr3_channel *channel)
+static struct six_axis_t get_min_full_scales(volatile struct jr3_channel
+ *channel)
{
struct six_axis_t result;
result.fx = get_s16(&channel->min_full_scale.fx);
@@ -247,7 +251,8 @@ static struct six_axis_t get_min_full_scales(volatile struct jr3_channel *channe
return result;
}
-static struct six_axis_t get_max_full_scales(volatile struct jr3_channel *channel)
+static struct six_axis_t get_max_full_scales(volatile struct jr3_channel
+ *channel)
{
struct six_axis_t result;
result.fx = get_s16(&channel->max_full_scale.fx);
@@ -259,8 +264,9 @@ 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;
@@ -275,9 +281,8 @@ static int jr3_pci_ai_insn_read(struct comedi_device *dev, struct comedi_subdevi
result = insn->n;
if (p->state != state_jr3_done ||
- (get_u16(&p->channel->
- errors) & (watch_dog | watch_dog2 |
- sensor_change))) {
+ (get_u16(&p->channel->errors) & (watch_dog | watch_dog2 |
+ sensor_change))) {
/* No sensor or sensor changed */
if (p->state == state_jr3_done) {
/* Restart polling */
@@ -297,59 +302,51 @@ static int jr3_pci_ai_insn_read(struct comedi_device *dev, struct comedi_subdevi
int F = 0;
switch (axis) {
case 0:{
- F = get_s16(&p->
- channel->
- filter[filter].
- fx);
+ F = get_s16
+ (&p->channel->filter
+ [filter].fx);
}
break;
case 1:{
- F = get_s16(&p->
- channel->
- filter[filter].
- fy);
+ F = get_s16
+ (&p->channel->filter
+ [filter].fy);
}
break;
case 2:{
- F = get_s16(&p->
- channel->
- filter[filter].
- fz);
+ F = get_s16
+ (&p->channel->filter
+ [filter].fz);
}
break;
case 3:{
- F = get_s16(&p->
- channel->
- filter[filter].
- mx);
+ F = get_s16
+ (&p->channel->filter
+ [filter].mx);
}
break;
case 4:{
- F = get_s16(&p->
- channel->
- filter[filter].
- my);
+ F = get_s16
+ (&p->channel->filter
+ [filter].my);
}
break;
case 5:{
- F = get_s16(&p->
- channel->
- filter[filter].
- mz);
+ F = get_s16
+ (&p->channel->filter
+ [filter].mz);
}
break;
case 6:{
- F = get_s16(&p->
- channel->
- filter[filter].
- v1);
+ F = get_s16
+ (&p->channel->filter
+ [filter].v1);
}
break;
case 7:{
- F = get_s16(&p->
- channel->
- filter[filter].
- v2);
+ F = get_s16
+ (&p->channel->filter
+ [filter].v2);
}
break;
}
@@ -360,14 +357,14 @@ static int jr3_pci_ai_insn_read(struct comedi_device *dev, struct comedi_subdevi
data[i] = 0;
} else {
data[i] =
- get_u16(&p->channel->model_no);
+ get_u16(&p->channel->model_no);
}
} else if (channel == 57) {
if (p->state != state_jr3_done) {
data[i] = 0;
} else {
data[i] =
- get_u16(&p->channel->serial_no);
+ get_u16(&p->channel->serial_no);
}
}
}
@@ -387,12 +384,12 @@ static void jr3_pci_open(struct comedi_device *dev)
p = dev->subdevices[i].private;
if (p) {
printk("serial: %p %d (%d)\n", p, p->serial_no,
- p->channel_no);
+ p->channel_no);
}
}
}
-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) {
@@ -414,8 +411,8 @@ 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,
- size_t size)
+static int jr3_download_firmware(struct comedi_device *dev, const u8 * data,
+ size_t size)
{
/*
* IDM file format is:
@@ -459,24 +456,23 @@ static int jr3_download_firmware(struct comedi_device *dev, const u8 *data,
while (more) {
unsigned int count, addr;
more = more
- && read_idm_word(data, size, &pos,
- &count);
+ && read_idm_word(data, size, &pos, &count);
if (more && count == 0xffff) {
break;
}
more = more
- && read_idm_word(data, size, &pos,
- &addr);
+ && read_idm_word(data, size, &pos, &addr);
printk("Loading#%d %4.4x bytes at %4.4x\n", i,
- count, addr);
+ count, addr);
while (more && count > 0) {
if (addr & 0x4000) {
/* 16 bit data, never seen in real life!! */
unsigned int data1;
more = more
- && read_idm_word(data,
- size, &pos, &data1);
+ && read_idm_word(data,
+ size, &pos,
+ &data1);
count--;
/* printk("jr3_data, not tested\n"); */
/* jr3[addr + 0x20000 * pnum] = data1; */
@@ -485,21 +481,23 @@ static int jr3_download_firmware(struct comedi_device *dev, const u8 *data,
unsigned int data1, data2;
more = more
- && read_idm_word(data,
- size, &pos, &data1);
+ && read_idm_word(data,
+ size, &pos,
+ &data1);
more = more
- && read_idm_word(data,
- size, &pos, &data2);
+ && read_idm_word(data, size,
+ &pos,
+ &data2);
count -= 2;
if (more) {
- set_u16(&p->iobase->
- channel[i].
- program_low
+ set_u16(&p->
+ iobase->channel
+ [i].program_low
[addr], data1);
udelay(1);
- set_u16(&p->iobase->
- channel[i].
- program_high
+ set_u16(&p->
+ iobase->channel
+ [i].program_high
[addr], data2);
udelay(1);
@@ -536,7 +534,7 @@ static struct poll_delay_t jr3_pci_poll_subdevice(struct comedi_subdevice *s)
u16 model_no = get_u16(&channel->model_no);
u16 serial_no = get_u16(&channel->serial_no);
if ((errors & (watch_dog | watch_dog2)) ||
- model_no == 0 || serial_no == 0) {
+ 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.
@@ -545,7 +543,7 @@ static struct poll_delay_t jr3_pci_poll_subdevice(struct comedi_subdevice *s)
} else {
p->retries = 0;
p->state =
- state_jr3_init_wait_for_offset;
+ state_jr3_init_wait_for_offset;
result = poll_delay_min_max(1000, 2000);
}
}
@@ -559,40 +557,44 @@ static struct poll_delay_t jr3_pci_poll_subdevice(struct comedi_subdevice *s)
struct transform_t transf;
p->model_no =
- get_u16(&channel->model_no);
+ get_u16(&channel->model_no);
p->serial_no =
- get_u16(&channel->serial_no);
+ get_u16(&channel->serial_no);
- printk("Setting transform for channel %d\n", p->channel_no);
+ printk
+ ("Setting transform for channel %d\n",
+ p->channel_no);
printk("Sensor Model = %i\n",
- p->model_no);
+ p->model_no);
printk("Sensor Serial = %i\n",
- p->serial_no);
+ p->serial_no);
/* Transformation all zeros */
transf.link[0].link_type =
- (enum link_types)0;
+ (enum link_types)0;
transf.link[0].link_amount = 0;
transf.link[1].link_type =
- (enum link_types)0;
+ (enum link_types)0;
transf.link[1].link_amount = 0;
transf.link[2].link_type =
- (enum link_types)0;
+ (enum link_types)0;
transf.link[2].link_amount = 0;
transf.link[3].link_type =
- (enum link_types)0;
+ (enum link_types)0;
transf.link[3].link_amount = 0;
set_transforms(channel, transf, 0);
use_transform(channel, 0);
p->state =
- state_jr3_init_transform_complete;
+ state_jr3_init_transform_complete;
result = poll_delay_min_max(20, 100); /* Allow 20 ms for completion */
}
} break;
case state_jr3_init_transform_complete:{
if (!is_complete(channel)) {
- printk("state_jr3_init_transform_complete complete = %d\n", is_complete(channel));
+ printk
+ ("state_jr3_init_transform_complete complete = %d\n",
+ is_complete(channel));
result = poll_delay_min_max(20, 100);
} else {
/* Set full scale */
@@ -600,7 +602,7 @@ static struct poll_delay_t jr3_pci_poll_subdevice(struct comedi_subdevice *s)
struct six_axis_t max_full_scale;
min_full_scale =
- get_min_full_scales(channel);
+ get_min_full_scales(channel);
printk("Obtained Min. Full Scales:\n");
printk("%i ", (min_full_scale).fx);
printk("%i ", (min_full_scale).fy);
@@ -611,7 +613,7 @@ static struct poll_delay_t jr3_pci_poll_subdevice(struct comedi_subdevice *s)
printk("\n");
max_full_scale =
- get_max_full_scales(channel);
+ get_max_full_scales(channel);
printk("Obtained Max. Full Scales:\n");
printk("%i ", (max_full_scale).fx);
printk("%i ", (max_full_scale).fy);
@@ -622,17 +624,19 @@ static struct poll_delay_t jr3_pci_poll_subdevice(struct comedi_subdevice *s)
printk("\n");
set_full_scales(channel,
- max_full_scale);
+ max_full_scale);
p->state =
- state_jr3_init_set_full_scale_complete;
+ state_jr3_init_set_full_scale_complete;
result = poll_delay_min_max(20, 100); /* Allow 20 ms for completion */
}
}
break;
case state_jr3_init_set_full_scale_complete:{
if (!is_complete(channel)) {
- printk("state_jr3_init_set_full_scale_complete complete = %d\n", is_complete(channel));
+ printk
+ ("state_jr3_init_set_full_scale_complete complete = %d\n",
+ is_complete(channel));
result = poll_delay_min_max(20, 100);
} else {
volatile struct force_array *full_scale;
@@ -640,32 +644,29 @@ static struct poll_delay_t jr3_pci_poll_subdevice(struct comedi_subdevice *s)
/* 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) *
- 1000;
+ -get_s16(&full_scale->fx) * 1000;
p->range[0].range.max =
- get_s16(&full_scale->fx) * 1000;
+ get_s16(&full_scale->fx) * 1000;
p->range[1].range.min =
- -get_s16(&full_scale->fy) *
- 1000;
+ -get_s16(&full_scale->fy) * 1000;
p->range[1].range.max =
- get_s16(&full_scale->fy) * 1000;
+ get_s16(&full_scale->fy) * 1000;
p->range[2].range.min =
- -get_s16(&full_scale->fz) *
- 1000;
+ -get_s16(&full_scale->fz) * 1000;
p->range[2].range.max =
- get_s16(&full_scale->fz) * 1000;
+ get_s16(&full_scale->fz) * 1000;
p->range[3].range.min =
- -get_s16(&full_scale->mx) * 100;
+ -get_s16(&full_scale->mx) * 100;
p->range[3].range.max =
- get_s16(&full_scale->mx) * 100;
+ get_s16(&full_scale->mx) * 100;
p->range[4].range.min =
- -get_s16(&full_scale->my) * 100;
+ -get_s16(&full_scale->my) * 100;
p->range[4].range.max =
- get_s16(&full_scale->my) * 100;
+ get_s16(&full_scale->my) * 100;
p->range[5].range.min =
- -get_s16(&full_scale->mz) * 100;
+ -get_s16(&full_scale->mz) * 100;
p->range[5].range.max =
- get_s16(&full_scale->mz) * 100;
+ 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; /* ?? */
@@ -677,27 +678,38 @@ static struct poll_delay_t jr3_pci_poll_subdevice(struct comedi_subdevice *s)
int i;
for (i = 0; i < 9; i++) {
printk("%d %d - %d\n",
- i,
- p->range[i].
- range.min,
- p->range[i].
- range.max);
+ i,
+ p->
+ range[i].range.
+ min,
+ p->
+ range[i].range.
+ max);
}
}
use_offset(channel, 0);
p->state =
- state_jr3_init_use_offset_complete;
+ state_jr3_init_use_offset_complete;
result = poll_delay_min_max(40, 100); /* Allow 40 ms for completion */
}
}
break;
case state_jr3_init_use_offset_complete:{
if (!is_complete(channel)) {
- printk("state_jr3_init_use_offset_complete complete = %d\n", is_complete(channel));
+ printk
+ ("state_jr3_init_use_offset_complete complete = %d\n",
+ is_complete(channel));
result = poll_delay_min_max(20, 100);
} else {
- printk("Default offsets %d %d %d %d %d %d\n", get_s16(&channel->offsets.fx), get_s16(&channel->offsets.fy), get_s16(&channel->offsets.fz), get_s16(&channel->offsets.mx), get_s16(&channel->offsets.my), get_s16(&channel->offsets.mz));
+ printk
+ ("Default offsets %d %d %d %d %d %d\n",
+ get_s16(&channel->offsets.fx),
+ get_s16(&channel->offsets.fy),
+ get_s16(&channel->offsets.fz),
+ get_s16(&channel->offsets.mx),
+ get_s16(&channel->offsets.my),
+ get_s16(&channel->offsets.mz));
set_s16(&channel->offsets.fx, 0);
set_s16(&channel->offsets.fy, 0);
@@ -728,7 +740,7 @@ static struct poll_delay_t jr3_pci_poll_subdevice(struct comedi_subdevice *s)
static void jr3_pci_poll_dev(unsigned long data)
{
unsigned long flags;
- struct comedi_device *dev = (struct comedi_device *) data;
+ struct comedi_device *dev = (struct comedi_device *)data;
struct jr3_pci_dev_private *devpriv = dev->private;
unsigned long now;
int delay;
@@ -739,15 +751,16 @@ static void jr3_pci_poll_dev(unsigned long data)
now = jiffies;
/* 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;
+ struct jr3_pci_subdev_private *subdevpriv =
+ dev->subdevices[i].private;
if (now > subdevpriv->next_time_min) {
struct poll_delay_t sub_delay;
sub_delay = jr3_pci_poll_subdevice(&dev->subdevices[i]);
subdevpriv->next_time_min =
- jiffies + msecs_to_jiffies(sub_delay.min);
+ jiffies + msecs_to_jiffies(sub_delay.min);
subdevpriv->next_time_max =
- jiffies + msecs_to_jiffies(sub_delay.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
@@ -763,7 +776,8 @@ static void jr3_pci_poll_dev(unsigned long data)
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;
@@ -777,7 +791,7 @@ static int jr3_pci_attach(struct comedi_device *dev, struct comedi_devconfig *it
if (sizeof(struct jr3_channel) != 0xc00) {
printk("sizeof(struct jr3_channel) = %x [expected %x]\n",
- (unsigned)sizeof(struct jr3_channel), 0xc00);
+ (unsigned)sizeof(struct jr3_channel), 0xc00);
return -EINVAL;
}
@@ -820,7 +834,7 @@ static int jr3_pci_attach(struct comedi_device *dev, struct comedi_devconfig *it
/* Take first available card */
break;
} else if (opt_bus == card->bus->number &&
- opt_slot == PCI_SLOT(card->devfn)) {
+ opt_slot == PCI_SLOT(card->devfn)) {
/* Take requested card */
break;
}
@@ -841,7 +855,8 @@ static int jr3_pci_attach(struct comedi_device *dev, struct comedi_devconfig *it
}
devpriv->pci_enabled = 1;
- devpriv->iobase = ioremap(pci_resource_start(card, 0), sizeof(struct jr3_t));
+ devpriv->iobase =
+ ioremap(pci_resource_start(card, 0), sizeof(struct jr3_t));
result = alloc_subdevices(dev, devpriv->n_channels);
if (result < 0)
goto out;
@@ -853,7 +868,7 @@ static int jr3_pci_attach(struct comedi_device *dev, struct comedi_devconfig *it
dev->subdevices[i].n_chan = 8 * 7 + 2;
dev->subdevices[i].insn_read = jr3_pci_ai_insn_read;
dev->subdevices[i].private =
- kzalloc(sizeof(struct jr3_pci_subdev_private), GFP_KERNEL);
+ kzalloc(sizeof(struct jr3_pci_subdev_private), GFP_KERNEL);
if (dev->subdevices[i].private) {
struct jr3_pci_subdev_private *p;
int j;
@@ -861,9 +876,9 @@ static int jr3_pci_attach(struct comedi_device *dev, struct comedi_devconfig *it
p = dev->subdevices[i].private;
p->channel = &devpriv->iobase->channel[i].data;
printk("p->channel %p %p (%tx)\n",
- p->channel, devpriv->iobase,
- ((char *)(p->channel) -
- (char *)(devpriv->iobase)));
+ p->channel, devpriv->iobase,
+ ((char *)(p->channel) -
+ (char *)(devpriv->iobase)));
p->channel_no = i;
for (j = 0; j < 8; j++) {
int k;
@@ -873,7 +888,8 @@ static int jr3_pci_attach(struct comedi_device *dev, struct comedi_devconfig *it
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;
}
}
@@ -882,15 +898,15 @@ static int jr3_pci_attach(struct comedi_device *dev, struct comedi_devconfig *it
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 */
dev->subdevices[i].range_table = 0;
dev->subdevices[i].range_table_list =
- p->range_table_list;
+ p->range_table_list;
dev->subdevices[i].maxdata = 0;
dev->subdevices[i].maxdata_list = p->maxdata_list;
}
@@ -920,8 +936,8 @@ static int jr3_pci_attach(struct comedi_device *dev, struct comedi_devconfig *it
msleep_interruptible(25);
for (i = 0; i < 0x18; i++) {
printk("%c",
- get_u16(&devpriv->iobase->channel[0].data.
- copyright[i]) >> 8);
+ get_u16(&devpriv->iobase->channel[0].
+ data.copyright[i]) >> 8);
}
/* Start card timer */
@@ -937,7 +953,7 @@ static int jr3_pci_attach(struct comedi_device *dev, struct comedi_devconfig *it
devpriv->timer.expires = jiffies + msecs_to_jiffies(1000);
add_timer(&devpriv->timer);
- out:
+out:
return result;
}
diff --git a/drivers/staging/comedi/drivers/jr3_pci.h b/drivers/staging/comedi/drivers/jr3_pci.h
index 4f4bfb24c6d6..a1469611d84e 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);
}
@@ -304,7 +304,7 @@ struct jr3_channel {
/* not set a full scale. */
struct six_axis_array default_FS; /* offset 0x0068 */
- s32 reserved3; /* offset 0x006e */
+ s32 reserved3; /* offset 0x006e */
/* Load_envelope_num is the load envelope number that is currently
* in use. This value is set by the user after one of the load
@@ -341,7 +341,7 @@ struct jr3_channel {
*/
struct six_axis_array min_full_scale; /* offset 0x0070 */
- s32 reserved4; /* offset 0x0076 */
+ s32 reserved4; /* offset 0x0076 */
/* Transform_num is the transform number that is currently in use.
* This value is set by the JR3 DSP after the user has used command
@@ -354,7 +354,7 @@ struct jr3_channel {
/* min_full_scale (pg. 9) for more details. */
struct six_axis_array max_full_scale; /* offset 0x0078 */
- s32 reserved5; /* offset 0x007e */
+ s32 reserved5; /* offset 0x007e */
/* Peak_address is the address of the data which will be monitored
* by the peak routine. This value is set by the user. The peak
@@ -398,14 +398,14 @@ struct jr3_channel {
* offset # command (pg. 34). It can vary between 0 and 15.
*/
- s32 offset_num; /* offset 0x008e */
+ s32 offset_num; /* offset 0x008e */
/* Vect_axes is a bit map showing which of the axes are being used
* in the vector calculations. This value is set by the JR3 DSP
* after the user has executed the set vector axes command (pg. 37).
*/
- u32 vect_axes; /* offset 0x008f */
+ u32 vect_axes; /* offset 0x008f */
/* Filter0 is the decoupled, unfiltered data from the JR3 sensor.
* This data has had the offsets removed.
@@ -465,7 +465,7 @@ struct jr3_channel {
*/
s32 near_sat_value; /* offset 0x00e0 */
- s32 sat_value; /* offset 0x00e1 */
+ s32 sat_value; /* offset 0x00e1 */
/* Rate_address, rate_divisor & rate_count contain the data used to
* control the calculations of the rates. Rate_address is the
@@ -486,7 +486,7 @@ struct jr3_channel {
s32 rate_address; /* offset 0x00e2 */
u32 rate_divisor; /* offset 0x00e3 */
- u32 rate_count; /* offset 0x00e4 */
+ u32 rate_count; /* offset 0x00e4 */
/* Command_word2 through command_word0 are the locations used to
* send commands to the JR3 DSP. Their usage varies with the command
@@ -543,14 +543,14 @@ struct jr3_channel {
* Issues section on pg. 49 for more details.
*/
- u32 count_x; /* offset 0x00ef */
+ u32 count_x; /* offset 0x00ef */
/* Warnings & errors contain the warning and error bits
* respectively. The format of these two words is discussed on page
* 21 under the headings warnings_bits and error_bits.
*/
- u32 warnings; /* offset 0x00f0 */
+ u32 warnings; /* offset 0x00f0 */
u32 errors; /* offset 0x00f1 */
/* Threshold_bits is a word containing the bits that are set by the
@@ -565,7 +565,7 @@ struct jr3_channel {
* description for cal_crc_bad (pg. 21) for more information.
*/
- s32 last_CRC; /* offset 0x00f3 */
+ s32 last_CRC; /* offset 0x00f3 */
/* EEProm_ver_no contains the version number of the sensor EEProm.
* EEProm version numbers can vary between 0 and 255.
@@ -591,16 +591,16 @@ struct jr3_channel {
* different sensor configurations.
*/
- u32 serial_no; /* offset 0x00f8 */
- u32 model_no; /* offset 0x00f9 */
+ u32 serial_no; /* offset 0x00f8 */
+ u32 model_no; /* offset 0x00f9 */
/* Cal_day & cal_year are the sensor calibration date. Day is the
* day of the year, with January 1 being 1, and December 31, being
* 366 for leap years.
*/
- s32 cal_day; /* offset 0x00fa */
- s32 cal_year; /* offset 0x00fb */
+ s32 cal_day; /* offset 0x00fa */
+ s32 cal_year; /* offset 0x00fb */
/* Units is an enumerated read only value defining the engineering
* units used in the sensor full scale. The meanings of particular
@@ -627,7 +627,7 @@ struct jr3_channel {
u32 units; /* offset 0x00fc */
s32 bits; /* offset 0x00fd */
- s32 channels; /* offset 0x00fe */
+ s32 channels; /* offset 0x00fe */
/* Thickness specifies the overall thickness of the sensor from
* flange to flange. The engineering units for this value are
@@ -636,7 +636,7 @@ struct jr3_channel {
* transformation from the center of the sensor to either flange.
*/
- s32 thickness; /* offset 0x00ff */
+ s32 thickness; /* offset 0x00ff */
/* Load_envelopes is a table containing the load envelope
* descriptions. There are 16 possible load envelope slots in the
diff --git a/drivers/staging/comedi/drivers/ke_counter.c b/drivers/staging/comedi/drivers/ke_counter.c
index b49aed5c4a02..c145e829108f 100644
--- a/drivers/staging/comedi/drivers/ke_counter.c
+++ b/drivers/staging/comedi/drivers/ke_counter.c
@@ -52,9 +52,10 @@ 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,
- 0},
- {0}
+ {
+ PCI_VENDOR_ID_KOLTER, CNT_CARD_DEVICE_ID, PCI_ANY_ID,
+ PCI_ANY_ID, 0, 0, 0}, {
+ 0}
};
MODULE_DEVICE_TABLE(pci, cnt_pci_table);
@@ -69,13 +70,12 @@ struct cnt_board_struct {
int cnt_bits;
};
-
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))
@@ -87,7 +87,6 @@ struct cnt_device_private {
struct pci_dev *pcidev;
};
-
#define devpriv ((struct cnt_device_private *)dev->private)
static struct comedi_driver cnt_driver = {
@@ -104,18 +103,19 @@ 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)
+ struct comedi_subdevice *s, struct comedi_insn *insn,
+ unsigned int *data)
{
int chan = CR_CHAN(insn->chanspec);
outb((unsigned char)((data[0] >> 24) & 0xff),
- dev->iobase + chan * 0x20 + 0x10);
+ dev->iobase + chan * 0x20 + 0x10);
outb((unsigned char)((data[0] >> 16) & 0xff),
- dev->iobase + chan * 0x20 + 0x0c);
+ dev->iobase + chan * 0x20 + 0x0c);
outb((unsigned char)((data[0] >> 8) & 0xff),
- dev->iobase + chan * 0x20 + 0x08);
+ dev->iobase + chan * 0x20 + 0x08);
outb((unsigned char)((data[0] >> 0) & 0xff),
- dev->iobase + chan * 0x20 + 0x04);
+ dev->iobase + chan * 0x20 + 0x04);
/* return the number of samples written */
return 1;
@@ -124,7 +124,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)
+ struct comedi_subdevice *s, struct comedi_insn *insn,
+ unsigned int *data)
{
unsigned char a0, a1, a2, a3, a4;
int chan = CR_CHAN(insn->chanspec);
@@ -140,7 +141,7 @@ static int cnt_rinsn(struct comedi_device *dev,
if (a4 > 0)
result = result - s->maxdata;
- *data = (unsigned int) result;
+ *data = (unsigned int)result;
/* return the number of samples read */
return 1;
@@ -163,49 +164,51 @@ static int cnt_attach(struct comedi_device *dev, struct comedi_devconfig *it)
/* 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);
- pci_device != NULL;
- pci_device =
- pci_get_device(PCI_ANY_ID, PCI_ANY_ID, pci_device)) {
+ pci_device != NULL;
+ pci_device = pci_get_device(PCI_ANY_ID, PCI_ANY_ID, pci_device)) {
if (pci_device->vendor == PCI_VENDOR_ID_KOLTER) {
for (i = 0; i < cnt_board_nbr; i++) {
if (cnt_boards[i].device_id ==
- pci_device->device) {
+ pci_device->device) {
/* was a particular bus/slot requested? */
if ((it->options[0] != 0)
- || (it->options[1] != 0)) {
+ || (it->options[1] != 0)) {
/* are we on the wrong bus/slot? */
if (pci_device->bus->number !=
- it->options[0]
- || PCI_SLOT(pci_device->
- devfn) !=
- it->options[1]) {
+ it->options[0]
+ ||
+ PCI_SLOT(pci_device->devfn)
+ != it->options[1]) {
continue;
}
}
dev->board_ptr = cnt_boards + i;
- board = (struct cnt_board_struct *) dev->
- board_ptr;
+ board =
+ (struct cnt_board_struct *)
+ dev->board_ptr;
goto found;
}
}
}
}
printk("comedi%d: no supported board found! (req. bus/slot: %d/%d)\n",
- dev->minor, it->options[0], it->options[1]);
+ dev->minor, it->options[0], it->options[1]);
return -EIO;
- found:
+found:
printk("comedi%d: found %s at PCI bus %d, slot %d\n", dev->minor,
- board->name, pci_device->bus->number,
- PCI_SLOT(pci_device->devfn));
+ board->name, pci_device->bus->number,
+ PCI_SLOT(pci_device->devfn));
devpriv->pcidev = pci_device;
dev->board_name = board->name;
/* enable PCI device and request regions */
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);
+ printk
+ ("comedi%d: failed to enable PCI device and request regions!\n",
+ dev->minor);
return error;
}
diff --git a/drivers/staging/comedi/drivers/me4000.c b/drivers/staging/comedi/drivers/me4000.c
index 236845871735..6079913d14b0 100644
--- a/drivers/staging/comedi/drivers/me4000.c
+++ b/drivers/staging/comedi/drivers/me4000.c
@@ -71,24 +71,21 @@ broken.
===========================================================================*/
static DEFINE_PCI_DEVICE_TABLE(me4000_pci_table) = {
- {PCI_VENDOR_ID_MEILHAUS, 0x4650, PCI_ANY_ID, PCI_ANY_ID, 0, 0, 0},
-
- {PCI_VENDOR_ID_MEILHAUS, 0x4660, PCI_ANY_ID, PCI_ANY_ID, 0, 0, 0},
- {PCI_VENDOR_ID_MEILHAUS, 0x4661, PCI_ANY_ID, PCI_ANY_ID, 0, 0, 0},
- {PCI_VENDOR_ID_MEILHAUS, 0x4662, PCI_ANY_ID, PCI_ANY_ID, 0, 0, 0},
- {PCI_VENDOR_ID_MEILHAUS, 0x4663, PCI_ANY_ID, PCI_ANY_ID, 0, 0, 0},
-
- {PCI_VENDOR_ID_MEILHAUS, 0x4670, PCI_ANY_ID, PCI_ANY_ID, 0, 0, 0},
- {PCI_VENDOR_ID_MEILHAUS, 0x4671, PCI_ANY_ID, PCI_ANY_ID, 0, 0, 0},
- {PCI_VENDOR_ID_MEILHAUS, 0x4672, PCI_ANY_ID, PCI_ANY_ID, 0, 0, 0},
- {PCI_VENDOR_ID_MEILHAUS, 0x4673, PCI_ANY_ID, PCI_ANY_ID, 0, 0, 0},
-
- {PCI_VENDOR_ID_MEILHAUS, 0x4680, PCI_ANY_ID, PCI_ANY_ID, 0, 0, 0},
- {PCI_VENDOR_ID_MEILHAUS, 0x4681, PCI_ANY_ID, PCI_ANY_ID, 0, 0, 0},
- {PCI_VENDOR_ID_MEILHAUS, 0x4682, PCI_ANY_ID, PCI_ANY_ID, 0, 0, 0},
- {PCI_VENDOR_ID_MEILHAUS, 0x4683, PCI_ANY_ID, PCI_ANY_ID, 0, 0, 0},
-
- {0}
+ {
+ PCI_VENDOR_ID_MEILHAUS, 0x4650, PCI_ANY_ID, PCI_ANY_ID, 0, 0, 0}, {
+ PCI_VENDOR_ID_MEILHAUS, 0x4660, PCI_ANY_ID, PCI_ANY_ID, 0, 0, 0}, {
+ PCI_VENDOR_ID_MEILHAUS, 0x4661, PCI_ANY_ID, PCI_ANY_ID, 0, 0, 0}, {
+ PCI_VENDOR_ID_MEILHAUS, 0x4662, PCI_ANY_ID, PCI_ANY_ID, 0, 0, 0}, {
+ PCI_VENDOR_ID_MEILHAUS, 0x4663, PCI_ANY_ID, PCI_ANY_ID, 0, 0, 0}, {
+ PCI_VENDOR_ID_MEILHAUS, 0x4670, PCI_ANY_ID, PCI_ANY_ID, 0, 0, 0}, {
+ PCI_VENDOR_ID_MEILHAUS, 0x4671, PCI_ANY_ID, PCI_ANY_ID, 0, 0, 0}, {
+ PCI_VENDOR_ID_MEILHAUS, 0x4672, PCI_ANY_ID, PCI_ANY_ID, 0, 0, 0}, {
+ PCI_VENDOR_ID_MEILHAUS, 0x4673, PCI_ANY_ID, PCI_ANY_ID, 0, 0, 0}, {
+ PCI_VENDOR_ID_MEILHAUS, 0x4680, PCI_ANY_ID, PCI_ANY_ID, 0, 0, 0}, {
+ PCI_VENDOR_ID_MEILHAUS, 0x4681, PCI_ANY_ID, PCI_ANY_ID, 0, 0, 0}, {
+ PCI_VENDOR_ID_MEILHAUS, 0x4682, PCI_ANY_ID, PCI_ANY_ID, 0, 0, 0}, {
+ PCI_VENDOR_ID_MEILHAUS, 0x4683, PCI_ANY_ID, PCI_ANY_ID, 0, 0, 0}, {
+ 0}
};
MODULE_DEVICE_TABLE(pci, me4000_pci_table);
@@ -119,13 +116,14 @@ static const struct me4000_board me4000_boards[] = {
/*-----------------------------------------------------------------------------
Comedi function prototypes
---------------------------------------------------------------------------*/
-static int me4000_attach(struct comedi_device *dev, struct comedi_devconfig *it);
+static int me4000_attach(struct comedi_device *dev,
+ struct comedi_devconfig *it);
static int me4000_detach(struct comedi_device *dev);
static struct comedi_driver driver_me4000 = {
- driver_name:"me4000",
- module : THIS_MODULE,
- attach : me4000_attach,
- detach : me4000_detach,
+driver_name:"me4000",
+module:THIS_MODULE,
+attach:me4000_attach,
+detach:me4000_detach,
};
/*-----------------------------------------------------------------------------
@@ -133,7 +131,8 @@ static struct comedi_driver driver_me4000 = {
---------------------------------------------------------------------------*/
static int me4000_probe(struct comedi_device *dev, struct comedi_devconfig *it);
static int get_registers(struct comedi_device *dev, struct pci_dev *pci_dev_p);
-static int init_board_info(struct comedi_device *dev, struct pci_dev *pci_dev_p);
+static int init_board_info(struct comedi_device *dev,
+ struct pci_dev *pci_dev_p);
static int init_ao_context(struct comedi_device *dev);
static int init_ai_context(struct comedi_device *dev);
static int init_dio_context(struct comedi_device *dev);
@@ -142,80 +141,95 @@ static int xilinx_download(struct comedi_device *dev);
static int reset_board(struct comedi_device *dev);
static int me4000_dio_insn_bits(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);
static int me4000_dio_insn_config(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);
static int cnt_reset(struct comedi_device *dev, unsigned int channel);
static int cnt_config(struct comedi_device *dev,
- unsigned int channel, unsigned int mode);
+ unsigned int channel, unsigned int mode);
static int me4000_cnt_insn_config(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);
static int me4000_cnt_insn_write(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);
static int me4000_cnt_insn_read(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);
static int me4000_ai_insn_read(struct comedi_device *dev,
- struct comedi_subdevice *subdevice, struct comedi_insn *insn, unsigned int *data);
+ struct comedi_subdevice *subdevice,
+ struct comedi_insn *insn, unsigned int *data);
-static int me4000_ai_cancel(struct comedi_device *dev, struct comedi_subdevice *s);
+static int me4000_ai_cancel(struct comedi_device *dev,
+ struct comedi_subdevice *s);
static int ai_check_chanlist(struct comedi_device *dev,
- struct comedi_subdevice *s, struct comedi_cmd *cmd);
+ struct comedi_subdevice *s,
+ struct comedi_cmd *cmd);
static int ai_round_cmd_args(struct comedi_device *dev,
- struct comedi_subdevice *s,
- struct comedi_cmd *cmd,
- unsigned int *init_ticks,
- unsigned int *scan_ticks, unsigned int *chan_ticks);
+ struct comedi_subdevice *s,
+ struct comedi_cmd *cmd,
+ unsigned int *init_ticks,
+ unsigned int *scan_ticks,
+ unsigned int *chan_ticks);
static int ai_prepare(struct comedi_device *dev,
- struct comedi_subdevice *s,
- struct comedi_cmd *cmd,
- unsigned int init_ticks,
- unsigned int scan_ticks, unsigned int chan_ticks);
+ struct comedi_subdevice *s,
+ struct comedi_cmd *cmd,
+ unsigned int init_ticks,
+ unsigned int scan_ticks, unsigned int chan_ticks);
static int ai_write_chanlist(struct comedi_device *dev,
- struct comedi_subdevice *s, struct comedi_cmd *cmd);
+ struct comedi_subdevice *s,
+ struct comedi_cmd *cmd);
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);
+ struct comedi_subdevice *s,
+ struct comedi_cmd *cmd);
-static int me4000_ai_do_cmd(struct comedi_device *dev, struct comedi_subdevice *s);
+static int me4000_ai_do_cmd(struct comedi_device *dev,
+ struct comedi_subdevice *s);
static int me4000_ao_insn_write(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);
static int me4000_ao_insn_read(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);
/*-----------------------------------------------------------------------------
Meilhaus inline functions
---------------------------------------------------------------------------*/
static inline void me4000_outb(struct comedi_device *dev, unsigned char value,
- unsigned long port)
+ unsigned long port)
{
PORT_PDEBUG("--> 0x%02X port 0x%04lX\n", value, port);
outb(value, port);
}
static inline void me4000_outl(struct comedi_device *dev, unsigned long value,
- unsigned long port)
+ unsigned long port)
{
PORT_PDEBUG("--> 0x%08lX port 0x%04lX\n", value, port);
outl(value, port);
}
-static inline unsigned long me4000_inl(struct comedi_device *dev, unsigned long port)
+static inline unsigned long me4000_inl(struct comedi_device *dev,
+ unsigned long port)
{
unsigned long value;
value = inl(port);
@@ -223,7 +237,8 @@ static inline unsigned long me4000_inl(struct comedi_device *dev, unsigned long
return value;
}
-static inline unsigned char me4000_inb(struct comedi_device *dev, unsigned long port)
+static inline unsigned char me4000_inb(struct comedi_device *dev,
+ unsigned long port)
{
unsigned char value;
value = inb(port);
@@ -234,18 +249,18 @@ static inline unsigned char me4000_inb(struct comedi_device *dev, unsigned long
static const struct comedi_lrange me4000_ai_range = {
4,
{
- UNI_RANGE(2.5),
- UNI_RANGE(10),
- BIP_RANGE(2.5),
- BIP_RANGE(10),
- }
+ UNI_RANGE(2.5),
+ UNI_RANGE(10),
+ BIP_RANGE(2.5),
+ BIP_RANGE(10),
+ }
};
static const struct comedi_lrange me4000_ao_range = {
1,
{
- BIP_RANGE(10),
- }
+ BIP_RANGE(10),
+ }
};
static int me4000_attach(struct comedi_device *dev, struct comedi_devconfig *it)
@@ -276,7 +291,7 @@ static int me4000_attach(struct comedi_device *dev, struct comedi_devconfig *it)
if (thisboard->ai.count) {
s->type = COMEDI_SUBD_AI;
s->subdev_flags =
- SDF_READABLE | SDF_COMMON | SDF_GROUND | SDF_DIFF;
+ SDF_READABLE | SDF_COMMON | SDF_GROUND | SDF_DIFF;
s->n_chan = thisboard->ai.count;
s->maxdata = 0xFFFF; /* 16 bit ADC */
s->len_chanlist = ME4000_AI_CHANNEL_LIST_COUNT;
@@ -286,7 +301,9 @@ static int me4000_attach(struct comedi_device *dev, struct comedi_devconfig *it)
if (info->irq > 0) {
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);
+ printk
+ ("comedi%d: me4000: me4000_attach(): Unable to allocate irq\n",
+ dev->minor);
} else {
dev->read_subdev = s;
s->subdev_flags |= SDF_CMD_READ;
@@ -296,8 +313,8 @@ static int me4000_attach(struct comedi_device *dev, struct comedi_devconfig *it)
}
} else {
printk(KERN_WARNING
- "comedi%d: me4000: me4000_attach(): No interrupt available\n",
- dev->minor);
+ "comedi%d: me4000: me4000_attach(): No interrupt available\n",
+ dev->minor);
}
} else {
s->type = COMEDI_SUBD_UNUSED;
@@ -346,7 +363,7 @@ static int me4000_attach(struct comedi_device *dev, struct comedi_devconfig *it)
if (!me4000_inl(dev, info->dio_context.dir_reg)) {
s->io_bits |= 0xFF;
me4000_outl(dev, ME4000_DIO_CTRL_BIT_MODE_0,
- info->dio_context.dir_reg);
+ info->dio_context.dir_reg);
}
/*=========================================================================
@@ -386,28 +403,28 @@ static int me4000_probe(struct comedi_device *dev, struct comedi_devconfig *it)
* 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);
- pci_device != NULL;
- pci_device =
- pci_get_device(PCI_ANY_ID, PCI_ANY_ID, pci_device)) {
+ pci_device != NULL;
+ pci_device = pci_get_device(PCI_ANY_ID, PCI_ANY_ID, pci_device)) {
if (pci_device->vendor == PCI_VENDOR_ID_MEILHAUS) {
for (i = 0; i < ME4000_BOARD_VERSIONS; i++) {
if (me4000_boards[i].device_id ==
- pci_device->device) {
+ pci_device->device) {
/* Was a particular bus/slot requested? */
if ((it->options[0] != 0)
- || (it->options[1] != 0)) {
+ || (it->options[1] != 0)) {
/* Are we on the wrong bus/slot? */
if (pci_device->bus->number !=
- it->options[0]
- || PCI_SLOT(pci_device->
- devfn) !=
- it->options[1]) {
+ it->options[0]
+ ||
+ PCI_SLOT(pci_device->devfn)
+ != it->options[1]) {
continue;
}
}
dev->board_ptr = me4000_boards + i;
- board = (struct me4000_board *) dev->
- board_ptr;
+ board =
+ (struct me4000_board *)
+ dev->board_ptr;
info->pci_dev_p = pci_device;
goto found;
}
@@ -416,16 +433,16 @@ static int me4000_probe(struct comedi_device *dev, struct comedi_devconfig *it)
}
printk(KERN_ERR
- "comedi%d: me4000: me4000_probe(): No supported board found (req. bus/slot : %d/%d)\n",
- dev->minor, it->options[0], it->options[1]);
+ "comedi%d: me4000: me4000_probe(): No supported board found (req. bus/slot : %d/%d)\n",
+ dev->minor, it->options[0], it->options[1]);
return -ENODEV;
- found:
+found:
printk(KERN_INFO
- "comedi%d: me4000: me4000_probe(): Found %s at PCI bus %d, slot %d\n",
- dev->minor, me4000_boards[i].name, pci_device->bus->number,
- PCI_SLOT(pci_device->devfn));
+ "comedi%d: me4000: me4000_probe(): Found %s at PCI bus %d, slot %d\n",
+ dev->minor, me4000_boards[i].name, pci_device->bus->number,
+ PCI_SLOT(pci_device->devfn));
/* Set data in device structure */
dev->board_name = board->name;
@@ -434,8 +451,8 @@ static int me4000_probe(struct comedi_device *dev, struct comedi_devconfig *it)
result = comedi_pci_enable(pci_device, dev->board_name);
if (result) {
printk(KERN_ERR
- "comedi%d: me4000: me4000_probe(): Cannot enable PCI device and request I/O regions\n",
- dev->minor);
+ "comedi%d: me4000: me4000_probe(): Cannot enable PCI device and request I/O regions\n",
+ dev->minor);
return result;
}
@@ -443,16 +460,16 @@ static int me4000_probe(struct comedi_device *dev, struct comedi_devconfig *it)
result = get_registers(dev, pci_device);
if (result) {
printk(KERN_ERR
- "comedi%d: me4000: me4000_probe(): Cannot get registers\n",
- dev->minor);
+ "comedi%d: me4000: me4000_probe(): Cannot get registers\n",
+ dev->minor);
return result;
}
/* Initialize board info */
result = init_board_info(dev, pci_device);
if (result) {
printk(KERN_ERR
- "comedi%d: me4000: me4000_probe(): Cannot init baord info\n",
- dev->minor);
+ "comedi%d: me4000: me4000_probe(): Cannot init baord info\n",
+ dev->minor);
return result;
}
@@ -460,8 +477,8 @@ static int me4000_probe(struct comedi_device *dev, struct comedi_devconfig *it)
result = init_ao_context(dev);
if (result) {
printk(KERN_ERR
- "comedi%d: me4000: me4000_probe(): Cannot init ao context\n",
- dev->minor);
+ "comedi%d: me4000: me4000_probe(): Cannot init ao context\n",
+ dev->minor);
return result;
}
@@ -469,8 +486,8 @@ static int me4000_probe(struct comedi_device *dev, struct comedi_devconfig *it)
result = init_ai_context(dev);
if (result) {
printk(KERN_ERR
- "comedi%d: me4000: me4000_probe(): Cannot init ai context\n",
- dev->minor);
+ "comedi%d: me4000: me4000_probe(): Cannot init ai context\n",
+ dev->minor);
return result;
}
@@ -478,8 +495,8 @@ static int me4000_probe(struct comedi_device *dev, struct comedi_devconfig *it)
result = init_dio_context(dev);
if (result) {
printk(KERN_ERR
- "comedi%d: me4000: me4000_probe(): Cannot init dio context\n",
- dev->minor);
+ "comedi%d: me4000: me4000_probe(): Cannot init dio context\n",
+ dev->minor);
return result;
}
@@ -487,8 +504,8 @@ static int me4000_probe(struct comedi_device *dev, struct comedi_devconfig *it)
result = init_cnt_context(dev);
if (result) {
printk(KERN_ERR
- "comedi%d: me4000: me4000_probe(): Cannot init cnt context\n",
- dev->minor);
+ "comedi%d: me4000: me4000_probe(): Cannot init cnt context\n",
+ dev->minor);
return result;
}
@@ -496,8 +513,8 @@ static int me4000_probe(struct comedi_device *dev, struct comedi_devconfig *it)
result = xilinx_download(dev);
if (result) {
printk(KERN_ERR
- "comedi%d: me4000: me4000_probe(): Can't download firmware\n",
- dev->minor);
+ "comedi%d: me4000: me4000_probe(): Can't download firmware\n",
+ dev->minor);
return result;
}
@@ -505,8 +522,8 @@ static int me4000_probe(struct comedi_device *dev, struct comedi_devconfig *it)
result = reset_board(dev);
if (result) {
printk(KERN_ERR
- "comedi%d: me4000: me4000_probe(): Can't reset board\n",
- dev->minor);
+ "comedi%d: me4000: me4000_probe(): Can't reset board\n",
+ dev->minor);
return result;
}
@@ -523,8 +540,8 @@ static int get_registers(struct comedi_device *dev, struct pci_dev *pci_dev_p)
info->plx_regbase = pci_resource_start(pci_dev_p, 1);
if (info->plx_regbase == 0) {
printk(KERN_ERR
- "comedi%d: me4000: get_registers(): PCI base address 1 is not available\n",
- dev->minor);
+ "comedi%d: me4000: get_registers(): PCI base address 1 is not available\n",
+ dev->minor);
return -ENODEV;
}
info->plx_regbase_size = pci_resource_len(pci_dev_p, 1);
@@ -534,8 +551,8 @@ static int get_registers(struct comedi_device *dev, struct pci_dev *pci_dev_p)
info->me4000_regbase = pci_resource_start(pci_dev_p, 2);
if (info->me4000_regbase == 0) {
printk(KERN_ERR
- "comedi%d: me4000: get_registers(): PCI base address 2 is not available\n",
- dev->minor);
+ "comedi%d: me4000: get_registers(): PCI base address 2 is not available\n",
+ dev->minor);
return -ENODEV;
}
info->me4000_regbase_size = pci_resource_len(pci_dev_p, 2);
@@ -545,8 +562,8 @@ static int get_registers(struct comedi_device *dev, struct pci_dev *pci_dev_p)
info->timer_regbase = pci_resource_start(pci_dev_p, 3);
if (info->timer_regbase == 0) {
printk(KERN_ERR
- "comedi%d: me4000: get_registers(): PCI base address 3 is not available\n",
- dev->minor);
+ "comedi%d: me4000: get_registers(): PCI base address 3 is not available\n",
+ dev->minor);
return -ENODEV;
}
info->timer_regbase_size = pci_resource_len(pci_dev_p, 3);
@@ -556,8 +573,8 @@ static int get_registers(struct comedi_device *dev, struct pci_dev *pci_dev_p)
info->program_regbase = pci_resource_start(pci_dev_p, 5);
if (info->program_regbase == 0) {
printk(KERN_ERR
- "comedi%d: me4000: get_registers(): PCI base address 5 is not available\n",
- dev->minor);
+ "comedi%d: me4000: get_registers(): PCI base address 5 is not available\n",
+ dev->minor);
return -ENODEV;
}
info->program_regbase_size = pci_resource_len(pci_dev_p, 5);
@@ -610,67 +627,67 @@ static int init_ao_context(struct comedi_device *dev)
switch (i) {
case 0:
info->ao_context[i].ctrl_reg =
- info->me4000_regbase + ME4000_AO_00_CTRL_REG;
+ info->me4000_regbase + ME4000_AO_00_CTRL_REG;
info->ao_context[i].status_reg =
- info->me4000_regbase + ME4000_AO_00_STATUS_REG;
+ info->me4000_regbase + ME4000_AO_00_STATUS_REG;
info->ao_context[i].fifo_reg =
- info->me4000_regbase + ME4000_AO_00_FIFO_REG;
+ info->me4000_regbase + ME4000_AO_00_FIFO_REG;
info->ao_context[i].single_reg =
- info->me4000_regbase + ME4000_AO_00_SINGLE_REG;
+ info->me4000_regbase + ME4000_AO_00_SINGLE_REG;
info->ao_context[i].timer_reg =
- info->me4000_regbase + ME4000_AO_00_TIMER_REG;
+ info->me4000_regbase + ME4000_AO_00_TIMER_REG;
info->ao_context[i].irq_status_reg =
- info->me4000_regbase + ME4000_IRQ_STATUS_REG;
+ info->me4000_regbase + ME4000_IRQ_STATUS_REG;
info->ao_context[i].preload_reg =
- info->me4000_regbase + ME4000_AO_LOADSETREG_XX;
+ info->me4000_regbase + ME4000_AO_LOADSETREG_XX;
break;
case 1:
info->ao_context[i].ctrl_reg =
- info->me4000_regbase + ME4000_AO_01_CTRL_REG;
+ info->me4000_regbase + ME4000_AO_01_CTRL_REG;
info->ao_context[i].status_reg =
- info->me4000_regbase + ME4000_AO_01_STATUS_REG;
+ info->me4000_regbase + ME4000_AO_01_STATUS_REG;
info->ao_context[i].fifo_reg =
- info->me4000_regbase + ME4000_AO_01_FIFO_REG;
+ info->me4000_regbase + ME4000_AO_01_FIFO_REG;
info->ao_context[i].single_reg =
- info->me4000_regbase + ME4000_AO_01_SINGLE_REG;
+ info->me4000_regbase + ME4000_AO_01_SINGLE_REG;
info->ao_context[i].timer_reg =
- info->me4000_regbase + ME4000_AO_01_TIMER_REG;
+ info->me4000_regbase + ME4000_AO_01_TIMER_REG;
info->ao_context[i].irq_status_reg =
- info->me4000_regbase + ME4000_IRQ_STATUS_REG;
+ info->me4000_regbase + ME4000_IRQ_STATUS_REG;
info->ao_context[i].preload_reg =
- info->me4000_regbase + ME4000_AO_LOADSETREG_XX;
+ info->me4000_regbase + ME4000_AO_LOADSETREG_XX;
break;
case 2:
info->ao_context[i].ctrl_reg =
- info->me4000_regbase + ME4000_AO_02_CTRL_REG;
+ info->me4000_regbase + ME4000_AO_02_CTRL_REG;
info->ao_context[i].status_reg =
- info->me4000_regbase + ME4000_AO_02_STATUS_REG;
+ info->me4000_regbase + ME4000_AO_02_STATUS_REG;
info->ao_context[i].fifo_reg =
- info->me4000_regbase + ME4000_AO_02_FIFO_REG;
+ info->me4000_regbase + ME4000_AO_02_FIFO_REG;
info->ao_context[i].single_reg =
- info->me4000_regbase + ME4000_AO_02_SINGLE_REG;
+ info->me4000_regbase + ME4000_AO_02_SINGLE_REG;
info->ao_context[i].timer_reg =
- info->me4000_regbase + ME4000_AO_02_TIMER_REG;
+ info->me4000_regbase + ME4000_AO_02_TIMER_REG;
info->ao_context[i].irq_status_reg =
- info->me4000_regbase + ME4000_IRQ_STATUS_REG;
+ info->me4000_regbase + ME4000_IRQ_STATUS_REG;
info->ao_context[i].preload_reg =
- info->me4000_regbase + ME4000_AO_LOADSETREG_XX;
+ info->me4000_regbase + ME4000_AO_LOADSETREG_XX;
break;
case 3:
info->ao_context[i].ctrl_reg =
- info->me4000_regbase + ME4000_AO_03_CTRL_REG;
+ info->me4000_regbase + ME4000_AO_03_CTRL_REG;
info->ao_context[i].status_reg =
- info->me4000_regbase + ME4000_AO_03_STATUS_REG;
+ info->me4000_regbase + ME4000_AO_03_STATUS_REG;
info->ao_context[i].fifo_reg =
- info->me4000_regbase + ME4000_AO_03_FIFO_REG;
+ info->me4000_regbase + ME4000_AO_03_FIFO_REG;
info->ao_context[i].single_reg =
- info->me4000_regbase + ME4000_AO_03_SINGLE_REG;
+ info->me4000_regbase + ME4000_AO_03_SINGLE_REG;
info->ao_context[i].timer_reg =
- info->me4000_regbase + ME4000_AO_03_TIMER_REG;
+ info->me4000_regbase + ME4000_AO_03_TIMER_REG;
info->ao_context[i].irq_status_reg =
- info->me4000_regbase + ME4000_IRQ_STATUS_REG;
+ info->me4000_regbase + ME4000_IRQ_STATUS_REG;
info->ao_context[i].preload_reg =
- info->me4000_regbase + ME4000_AO_LOADSETREG_XX;
+ info->me4000_regbase + ME4000_AO_LOADSETREG_XX;
break;
default:
break;
@@ -689,27 +706,27 @@ static int init_ai_context(struct comedi_device *dev)
info->ai_context.ctrl_reg = info->me4000_regbase + ME4000_AI_CTRL_REG;
info->ai_context.status_reg =
- info->me4000_regbase + ME4000_AI_STATUS_REG;
+ info->me4000_regbase + ME4000_AI_STATUS_REG;
info->ai_context.channel_list_reg =
- info->me4000_regbase + ME4000_AI_CHANNEL_LIST_REG;
+ info->me4000_regbase + ME4000_AI_CHANNEL_LIST_REG;
info->ai_context.data_reg = info->me4000_regbase + ME4000_AI_DATA_REG;
info->ai_context.chan_timer_reg =
- info->me4000_regbase + ME4000_AI_CHAN_TIMER_REG;
+ info->me4000_regbase + ME4000_AI_CHAN_TIMER_REG;
info->ai_context.chan_pre_timer_reg =
- info->me4000_regbase + ME4000_AI_CHAN_PRE_TIMER_REG;
+ info->me4000_regbase + ME4000_AI_CHAN_PRE_TIMER_REG;
info->ai_context.scan_timer_low_reg =
- info->me4000_regbase + ME4000_AI_SCAN_TIMER_LOW_REG;
+ info->me4000_regbase + ME4000_AI_SCAN_TIMER_LOW_REG;
info->ai_context.scan_timer_high_reg =
- info->me4000_regbase + ME4000_AI_SCAN_TIMER_HIGH_REG;
+ info->me4000_regbase + ME4000_AI_SCAN_TIMER_HIGH_REG;
info->ai_context.scan_pre_timer_low_reg =
- info->me4000_regbase + ME4000_AI_SCAN_PRE_TIMER_LOW_REG;
+ info->me4000_regbase + ME4000_AI_SCAN_PRE_TIMER_LOW_REG;
info->ai_context.scan_pre_timer_high_reg =
- info->me4000_regbase + ME4000_AI_SCAN_PRE_TIMER_HIGH_REG;
+ info->me4000_regbase + ME4000_AI_SCAN_PRE_TIMER_HIGH_REG;
info->ai_context.start_reg = info->me4000_regbase + ME4000_AI_START_REG;
info->ai_context.irq_status_reg =
- info->me4000_regbase + ME4000_IRQ_STATUS_REG;
+ info->me4000_regbase + ME4000_IRQ_STATUS_REG;
info->ai_context.sample_counter_reg =
- info->me4000_regbase + ME4000_AI_SAMPLE_COUNTER_REG;
+ info->me4000_regbase + ME4000_AI_SAMPLE_COUNTER_REG;
return 0;
}
@@ -722,13 +739,13 @@ static int init_dio_context(struct comedi_device *dev)
info->dio_context.dir_reg = info->me4000_regbase + ME4000_DIO_DIR_REG;
info->dio_context.ctrl_reg = info->me4000_regbase + ME4000_DIO_CTRL_REG;
info->dio_context.port_0_reg =
- info->me4000_regbase + ME4000_DIO_PORT_0_REG;
+ info->me4000_regbase + ME4000_DIO_PORT_0_REG;
info->dio_context.port_1_reg =
- info->me4000_regbase + ME4000_DIO_PORT_1_REG;
+ info->me4000_regbase + ME4000_DIO_PORT_1_REG;
info->dio_context.port_2_reg =
- info->me4000_regbase + ME4000_DIO_PORT_2_REG;
+ info->me4000_regbase + ME4000_DIO_PORT_2_REG;
info->dio_context.port_3_reg =
- info->me4000_regbase + ME4000_DIO_PORT_3_REG;
+ info->me4000_regbase + ME4000_DIO_PORT_3_REG;
return 0;
}
@@ -740,11 +757,11 @@ static int init_cnt_context(struct comedi_device *dev)
info->cnt_context.ctrl_reg = info->timer_regbase + ME4000_CNT_CTRL_REG;
info->cnt_context.counter_0_reg =
- info->timer_regbase + ME4000_CNT_COUNTER_0_REG;
+ info->timer_regbase + ME4000_CNT_COUNTER_0_REG;
info->cnt_context.counter_1_reg =
- info->timer_regbase + ME4000_CNT_COUNTER_1_REG;
+ info->timer_regbase + ME4000_CNT_COUNTER_1_REG;
info->cnt_context.counter_2_reg =
- info->timer_regbase + ME4000_CNT_COUNTER_2_REG;
+ info->timer_regbase + ME4000_CNT_COUNTER_2_REG;
return 0;
}
@@ -783,8 +800,8 @@ static int xilinx_download(struct comedi_device *dev)
udelay(20);
if (!(inl(info->plx_regbase + PLX_INTCSR) & 0x20)) {
printk(KERN_ERR
- "comedi%d: me4000: xilinx_download(): Can't init Xilinx\n",
- dev->minor);
+ "comedi%d: me4000: xilinx_download(): Can't init Xilinx\n",
+ dev->minor);
return -EIO;
}
@@ -794,12 +811,12 @@ static int xilinx_download(struct comedi_device *dev)
outl(value, info->plx_regbase + PLX_ICR);
if (FIRMWARE_NOT_AVAILABLE) {
comedi_error(dev,
- "xilinx firmware unavailable due to licensing, aborting");
+ "xilinx firmware unavailable due to licensing, aborting");
return -EIO;
} else {
/* Download Xilinx firmware */
size = (xilinx_firm[0] << 24) + (xilinx_firm[1] << 16) +
- (xilinx_firm[2] << 8) + xilinx_firm[3];
+ (xilinx_firm[2] << 8) + xilinx_firm[3];
udelay(10);
for (idx = 0; idx < size; idx++) {
@@ -809,8 +826,8 @@ static int xilinx_download(struct comedi_device *dev)
/* Check if BUSY flag is low */
if (inl(info->plx_regbase + PLX_ICR) & 0x20) {
printk(KERN_ERR
- "comedi%d: me4000: xilinx_download(): Xilinx is still busy (idx = %d)\n",
- dev->minor, idx);
+ "comedi%d: me4000: xilinx_download(): Xilinx is still busy (idx = %d)\n",
+ dev->minor, idx);
return -EIO;
}
}
@@ -820,11 +837,11 @@ static int xilinx_download(struct comedi_device *dev)
if (inl(info->plx_regbase + PLX_ICR) & 0x4) {
} else {
printk(KERN_ERR
- "comedi%d: me4000: xilinx_download(): DONE flag is not set\n",
- dev->minor);
+ "comedi%d: me4000: xilinx_download(): DONE flag is not set\n",
+ dev->minor);
printk(KERN_ERR
- "comedi%d: me4000: xilinx_download(): Download not succesful\n",
- dev->minor);
+ "comedi%d: me4000: xilinx_download(): Download not succesful\n",
+ dev->minor);
return -EIO;
}
@@ -851,44 +868,44 @@ static int reset_board(struct comedi_device *dev)
/* 0x8000 to the DACs means an output voltage of 0V */
me4000_outl(dev, 0x8000,
- info->me4000_regbase + ME4000_AO_00_SINGLE_REG);
+ info->me4000_regbase + ME4000_AO_00_SINGLE_REG);
me4000_outl(dev, 0x8000,
- info->me4000_regbase + ME4000_AO_01_SINGLE_REG);
+ info->me4000_regbase + ME4000_AO_01_SINGLE_REG);
me4000_outl(dev, 0x8000,
- info->me4000_regbase + ME4000_AO_02_SINGLE_REG);
+ info->me4000_regbase + ME4000_AO_02_SINGLE_REG);
me4000_outl(dev, 0x8000,
- info->me4000_regbase + ME4000_AO_03_SINGLE_REG);
+ info->me4000_regbase + ME4000_AO_03_SINGLE_REG);
/* Set both stop bits in the analog input control register */
me4000_outl(dev,
- ME4000_AI_CTRL_BIT_IMMEDIATE_STOP | ME4000_AI_CTRL_BIT_STOP,
- info->me4000_regbase + ME4000_AI_CTRL_REG);
+ ME4000_AI_CTRL_BIT_IMMEDIATE_STOP | ME4000_AI_CTRL_BIT_STOP,
+ info->me4000_regbase + ME4000_AI_CTRL_REG);
/* Set both stop bits in the analog output control register */
me4000_outl(dev,
- ME4000_AO_CTRL_BIT_IMMEDIATE_STOP | ME4000_AO_CTRL_BIT_STOP,
- info->me4000_regbase + ME4000_AO_00_CTRL_REG);
+ ME4000_AO_CTRL_BIT_IMMEDIATE_STOP | ME4000_AO_CTRL_BIT_STOP,
+ info->me4000_regbase + ME4000_AO_00_CTRL_REG);
me4000_outl(dev,
- ME4000_AO_CTRL_BIT_IMMEDIATE_STOP | ME4000_AO_CTRL_BIT_STOP,
- info->me4000_regbase + ME4000_AO_01_CTRL_REG);
+ ME4000_AO_CTRL_BIT_IMMEDIATE_STOP | ME4000_AO_CTRL_BIT_STOP,
+ info->me4000_regbase + ME4000_AO_01_CTRL_REG);
me4000_outl(dev,
- ME4000_AO_CTRL_BIT_IMMEDIATE_STOP | ME4000_AO_CTRL_BIT_STOP,
- info->me4000_regbase + ME4000_AO_02_CTRL_REG);
+ ME4000_AO_CTRL_BIT_IMMEDIATE_STOP | ME4000_AO_CTRL_BIT_STOP,
+ info->me4000_regbase + ME4000_AO_02_CTRL_REG);
me4000_outl(dev,
- ME4000_AO_CTRL_BIT_IMMEDIATE_STOP | ME4000_AO_CTRL_BIT_STOP,
- info->me4000_regbase + ME4000_AO_03_CTRL_REG);
+ ME4000_AO_CTRL_BIT_IMMEDIATE_STOP | ME4000_AO_CTRL_BIT_STOP,
+ info->me4000_regbase + ME4000_AO_03_CTRL_REG);
/* Enable interrupts on the PLX */
me4000_outl(dev, 0x43, info->plx_regbase + PLX_INTCSR);
/* Set the adustment register for AO demux */
me4000_outl(dev, ME4000_AO_DEMUX_ADJUST_VALUE,
- info->me4000_regbase + ME4000_AO_DEMUX_ADJUST_REG);
+ info->me4000_regbase + ME4000_AO_DEMUX_ADJUST_REG);
/* Set digital I/O direction for port 0 to output on isolated versions */
if (!(me4000_inl(dev, info->me4000_regbase + ME4000_DIO_DIR_REG) & 0x1)) {
me4000_outl(dev, 0x1,
- info->me4000_regbase + ME4000_DIO_CTRL_REG);
+ info->me4000_regbase + ME4000_DIO_CTRL_REG);
}
return 0;
@@ -915,7 +932,8 @@ static int me4000_detach(struct comedi_device *dev)
===========================================================================*/
static int me4000_ai_insn_read(struct comedi_device *dev,
- struct comedi_subdevice *subdevice, struct comedi_insn *insn, unsigned int *data)
+ struct comedi_subdevice *subdevice,
+ struct comedi_insn *insn, unsigned int *data)
{
int chan = CR_CHAN(insn->chanspec);
@@ -932,8 +950,8 @@ static int me4000_ai_insn_read(struct comedi_device *dev,
return 0;
} else if (insn->n > 1) {
printk(KERN_ERR
- "comedi%d: me4000: me4000_ai_insn_read(): Invalid instruction length %d\n",
- dev->minor, insn->n);
+ "comedi%d: me4000: me4000_ai_insn_read(): Invalid instruction length %d\n",
+ dev->minor, insn->n);
return -EINVAL;
}
@@ -952,8 +970,8 @@ static int me4000_ai_insn_read(struct comedi_device *dev,
break;
default:
printk(KERN_ERR
- "comedi%d: me4000: me4000_ai_insn_read(): Invalid range specified\n",
- dev->minor);
+ "comedi%d: me4000: me4000_ai_insn_read(): Invalid range specified\n",
+ dev->minor);
return -EINVAL;
}
@@ -962,8 +980,8 @@ static int me4000_ai_insn_read(struct comedi_device *dev,
case AREF_COMMON:
if (chan >= thisboard->ai.count) {
printk(KERN_ERR
- "comedi%d: me4000: me4000_ai_insn_read(): Analog input is not available\n",
- dev->minor);
+ "comedi%d: me4000: me4000_ai_insn_read(): Analog input is not available\n",
+ dev->minor);
return -EINVAL;
}
entry |= ME4000_AI_LIST_INPUT_SINGLE_ENDED | chan;
@@ -972,23 +990,23 @@ static int me4000_ai_insn_read(struct comedi_device *dev,
case AREF_DIFF:
if (rang == 0 || rang == 1) {
printk(KERN_ERR
- "comedi%d: me4000: me4000_ai_insn_read(): Range must be bipolar when aref = diff\n",
- dev->minor);
+ "comedi%d: me4000: me4000_ai_insn_read(): Range must be bipolar when aref = diff\n",
+ dev->minor);
return -EINVAL;
}
if (chan >= thisboard->ai.diff_count) {
printk(KERN_ERR
- "comedi%d: me4000: me4000_ai_insn_read(): Analog input is not available\n",
- dev->minor);
+ "comedi%d: me4000: me4000_ai_insn_read(): Analog input is not available\n",
+ dev->minor);
return -EINVAL;
}
entry |= ME4000_AI_LIST_INPUT_DIFFERENTIAL | chan;
break;
default:
printk(KERN_ERR
- "comedi%d: me4000: me4000_ai_insn_read(): Invalid aref specified\n",
- dev->minor);
+ "comedi%d: me4000: me4000_ai_insn_read(): Invalid aref specified\n",
+ dev->minor);
return -EINVAL;
}
@@ -997,13 +1015,13 @@ static int me4000_ai_insn_read(struct comedi_device *dev,
/* Clear channel list, data fifo and both stop bits */
tmp = me4000_inl(dev, info->ai_context.ctrl_reg);
tmp &= ~(ME4000_AI_CTRL_BIT_CHANNEL_FIFO |
- ME4000_AI_CTRL_BIT_DATA_FIFO |
- ME4000_AI_CTRL_BIT_STOP | ME4000_AI_CTRL_BIT_IMMEDIATE_STOP);
+ ME4000_AI_CTRL_BIT_DATA_FIFO |
+ ME4000_AI_CTRL_BIT_STOP | ME4000_AI_CTRL_BIT_IMMEDIATE_STOP);
me4000_outl(dev, tmp, info->ai_context.ctrl_reg);
/* Set the acquisition mode to single */
tmp &= ~(ME4000_AI_CTRL_BIT_MODE_0 | ME4000_AI_CTRL_BIT_MODE_1 |
- ME4000_AI_CTRL_BIT_MODE_2);
+ ME4000_AI_CTRL_BIT_MODE_2);
me4000_outl(dev, tmp, info->ai_context.ctrl_reg);
/* Enable channel list and data fifo */
@@ -1016,18 +1034,19 @@ static int me4000_ai_insn_read(struct comedi_device *dev,
/* Set the timer to maximum sample rate */
me4000_outl(dev, ME4000_AI_MIN_TICKS, info->ai_context.chan_timer_reg);
me4000_outl(dev, ME4000_AI_MIN_TICKS,
- info->ai_context.chan_pre_timer_reg);
+ info->ai_context.chan_pre_timer_reg);
/* Start conversion by dummy read */
me4000_inl(dev, info->ai_context.start_reg);
/* Wait until ready */
udelay(10);
- if (!(me4000_inl(dev, info->ai_context.
- status_reg) & ME4000_AI_STATUS_BIT_EF_DATA)) {
+ if (!
+ (me4000_inl(dev, info->ai_context.status_reg) &
+ ME4000_AI_STATUS_BIT_EF_DATA)) {
printk(KERN_ERR
- "comedi%d: me4000: me4000_ai_insn_read(): Value not available after wait\n",
- dev->minor);
+ "comedi%d: me4000: me4000_ai_insn_read(): Value not available after wait\n",
+ dev->minor);
return -EIO;
}
@@ -1038,7 +1057,8 @@ static int me4000_ai_insn_read(struct comedi_device *dev,
return 1;
}
-static int me4000_ai_cancel(struct comedi_device *dev, struct comedi_subdevice *s)
+static int me4000_ai_cancel(struct comedi_device *dev,
+ struct comedi_subdevice *s)
{
unsigned long tmp;
@@ -1056,7 +1076,7 @@ static int me4000_ai_cancel(struct comedi_device *dev, struct comedi_subdevice *
}
static int ai_check_chanlist(struct comedi_device *dev,
- struct comedi_subdevice *s, struct comedi_cmd *cmd)
+ struct comedi_subdevice *s, struct comedi_cmd *cmd)
{
int aref;
int i;
@@ -1066,24 +1086,24 @@ static int ai_check_chanlist(struct comedi_device *dev,
/* Check whether a channel list is available */
if (!cmd->chanlist_len) {
printk(KERN_ERR
- "comedi%d: me4000: ai_check_chanlist(): No channel list available\n",
- dev->minor);
+ "comedi%d: me4000: ai_check_chanlist(): No channel list available\n",
+ dev->minor);
return -EINVAL;
}
/* Check the channel list size */
if (cmd->chanlist_len > ME4000_AI_CHANNEL_LIST_COUNT) {
printk(KERN_ERR
- "comedi%d: me4000: ai_check_chanlist(): Channel list is to large\n",
- dev->minor);
+ "comedi%d: me4000: ai_check_chanlist(): Channel list is to large\n",
+ dev->minor);
return -EINVAL;
}
/* Check the pointer */
if (!cmd->chanlist) {
printk(KERN_ERR
- "comedi%d: me4000: ai_check_chanlist(): NULL pointer to channel list\n",
- dev->minor);
+ "comedi%d: me4000: ai_check_chanlist(): NULL pointer to channel list\n",
+ dev->minor);
return -EFAULT;
}
@@ -1092,8 +1112,8 @@ static int ai_check_chanlist(struct comedi_device *dev,
for (i = 0; i < cmd->chanlist_len; i++) {
if (CR_AREF(cmd->chanlist[i]) != aref) {
printk(KERN_ERR
- "comedi%d: me4000: ai_check_chanlist(): Mode is not equal for all entries\n",
- dev->minor);
+ "comedi%d: me4000: ai_check_chanlist(): Mode is not equal for all entries\n",
+ dev->minor);
return -EINVAL;
}
}
@@ -1102,10 +1122,10 @@ static int ai_check_chanlist(struct comedi_device *dev,
if (aref == SDF_DIFF) {
for (i = 0; i < cmd->chanlist_len; i++) {
if (CR_CHAN(cmd->chanlist[i]) >=
- thisboard->ai.diff_count) {
+ thisboard->ai.diff_count) {
printk(KERN_ERR
- "comedi%d: me4000: ai_check_chanlist(): Channel number to high\n",
- dev->minor);
+ "comedi%d: me4000: ai_check_chanlist(): Channel number to high\n",
+ dev->minor);
return -EINVAL;
}
}
@@ -1113,8 +1133,8 @@ static int ai_check_chanlist(struct comedi_device *dev,
for (i = 0; i < cmd->chanlist_len; i++) {
if (CR_CHAN(cmd->chanlist[i]) >= thisboard->ai.count) {
printk(KERN_ERR
- "comedi%d: me4000: ai_check_chanlist(): Channel number to high\n",
- dev->minor);
+ "comedi%d: me4000: ai_check_chanlist(): Channel number to high\n",
+ dev->minor);
return -EINVAL;
}
}
@@ -1124,10 +1144,10 @@ static int ai_check_chanlist(struct comedi_device *dev,
if (aref == SDF_DIFF) {
for (i = 0; i < cmd->chanlist_len; i++) {
if (CR_RANGE(cmd->chanlist[i]) != 1 &&
- CR_RANGE(cmd->chanlist[i]) != 2) {
+ CR_RANGE(cmd->chanlist[i]) != 2) {
printk(KERN_ERR
- "comedi%d: me4000: ai_check_chanlist(): Bipolar is not selected in differential mode\n",
- dev->minor);
+ "comedi%d: me4000: ai_check_chanlist(): Bipolar is not selected in differential mode\n",
+ dev->minor);
return -EINVAL;
}
}
@@ -1137,10 +1157,10 @@ static int ai_check_chanlist(struct comedi_device *dev,
}
static int ai_round_cmd_args(struct comedi_device *dev,
- struct comedi_subdevice *s,
- struct comedi_cmd *cmd,
- unsigned int *init_ticks,
- unsigned int *scan_ticks, unsigned int *chan_ticks)
+ struct comedi_subdevice *s,
+ struct comedi_cmd *cmd,
+ unsigned int *init_ticks,
+ unsigned int *scan_ticks, unsigned int *chan_ticks)
{
int rest;
@@ -1153,7 +1173,7 @@ static int ai_round_cmd_args(struct comedi_device *dev,
PDEBUG("ai_round_cmd_arg(): start_arg = %d\n", cmd->start_arg);
PDEBUG("ai_round_cmd_arg(): scan_begin_arg = %d\n",
- cmd->scan_begin_arg);
+ cmd->scan_begin_arg);
PDEBUG("ai_round_cmd_arg(): convert_arg = %d\n", cmd->convert_arg);
if (cmd->start_arg) {
@@ -1203,19 +1223,19 @@ static int ai_round_cmd_args(struct comedi_device *dev,
}
static void ai_write_timer(struct comedi_device *dev,
- unsigned int init_ticks,
- unsigned int scan_ticks, unsigned int chan_ticks)
+ unsigned int init_ticks,
+ unsigned int scan_ticks, unsigned int chan_ticks)
{
CALL_PDEBUG("In ai_write_timer()\n");
me4000_outl(dev, init_ticks - 1,
- info->ai_context.scan_pre_timer_low_reg);
+ info->ai_context.scan_pre_timer_low_reg);
me4000_outl(dev, 0x0, info->ai_context.scan_pre_timer_high_reg);
if (scan_ticks) {
me4000_outl(dev, scan_ticks - 1,
- info->ai_context.scan_timer_low_reg);
+ info->ai_context.scan_timer_low_reg);
me4000_outl(dev, 0x0, info->ai_context.scan_timer_high_reg);
}
@@ -1224,10 +1244,10 @@ static void ai_write_timer(struct comedi_device *dev,
}
static int ai_prepare(struct comedi_device *dev,
- struct comedi_subdevice *s,
- struct comedi_cmd *cmd,
- unsigned int init_ticks,
- unsigned int scan_ticks, unsigned int chan_ticks)
+ struct comedi_subdevice *s,
+ struct comedi_cmd *cmd,
+ unsigned int init_ticks,
+ unsigned int scan_ticks, unsigned int chan_ticks)
{
unsigned long tmp = 0;
@@ -1242,42 +1262,42 @@ static int ai_prepare(struct comedi_device *dev,
/* Start sources */
if ((cmd->start_src == TRIG_EXT &&
- cmd->scan_begin_src == TRIG_TIMER &&
- cmd->convert_src == TRIG_TIMER) ||
- (cmd->start_src == TRIG_EXT &&
- cmd->scan_begin_src == TRIG_FOLLOW &&
- cmd->convert_src == TRIG_TIMER)) {
+ cmd->scan_begin_src == TRIG_TIMER &&
+ cmd->convert_src == TRIG_TIMER) ||
+ (cmd->start_src == TRIG_EXT &&
+ cmd->scan_begin_src == TRIG_FOLLOW &&
+ cmd->convert_src == TRIG_TIMER)) {
tmp = ME4000_AI_CTRL_BIT_MODE_1 |
- ME4000_AI_CTRL_BIT_CHANNEL_FIFO |
- ME4000_AI_CTRL_BIT_DATA_FIFO;
+ ME4000_AI_CTRL_BIT_CHANNEL_FIFO |
+ ME4000_AI_CTRL_BIT_DATA_FIFO;
} else if (cmd->start_src == TRIG_EXT &&
- cmd->scan_begin_src == TRIG_EXT &&
- cmd->convert_src == TRIG_TIMER) {
+ cmd->scan_begin_src == TRIG_EXT &&
+ cmd->convert_src == TRIG_TIMER) {
tmp = ME4000_AI_CTRL_BIT_MODE_2 |
- ME4000_AI_CTRL_BIT_CHANNEL_FIFO |
- ME4000_AI_CTRL_BIT_DATA_FIFO;
+ ME4000_AI_CTRL_BIT_CHANNEL_FIFO |
+ ME4000_AI_CTRL_BIT_DATA_FIFO;
} else if (cmd->start_src == TRIG_EXT &&
- cmd->scan_begin_src == TRIG_EXT &&
- cmd->convert_src == TRIG_EXT) {
+ cmd->scan_begin_src == TRIG_EXT &&
+ cmd->convert_src == TRIG_EXT) {
tmp = ME4000_AI_CTRL_BIT_MODE_0 |
- ME4000_AI_CTRL_BIT_MODE_1 |
- ME4000_AI_CTRL_BIT_CHANNEL_FIFO |
- ME4000_AI_CTRL_BIT_DATA_FIFO;
+ ME4000_AI_CTRL_BIT_MODE_1 |
+ ME4000_AI_CTRL_BIT_CHANNEL_FIFO |
+ ME4000_AI_CTRL_BIT_DATA_FIFO;
} else {
tmp = ME4000_AI_CTRL_BIT_MODE_0 |
- ME4000_AI_CTRL_BIT_CHANNEL_FIFO |
- ME4000_AI_CTRL_BIT_DATA_FIFO;
+ ME4000_AI_CTRL_BIT_CHANNEL_FIFO |
+ ME4000_AI_CTRL_BIT_DATA_FIFO;
}
/* Stop triggers */
if (cmd->stop_src == TRIG_COUNT) {
me4000_outl(dev, cmd->chanlist_len * cmd->stop_arg,
- info->ai_context.sample_counter_reg);
+ info->ai_context.sample_counter_reg);
tmp |= ME4000_AI_CTRL_BIT_HF_IRQ | ME4000_AI_CTRL_BIT_SC_IRQ;
} else if (cmd->stop_src == TRIG_NONE &&
- cmd->scan_end_src == TRIG_COUNT) {
+ cmd->scan_end_src == TRIG_COUNT) {
me4000_outl(dev, cmd->scan_end_arg,
- info->ai_context.sample_counter_reg);
+ info->ai_context.sample_counter_reg);
tmp |= ME4000_AI_CTRL_BIT_HF_IRQ | ME4000_AI_CTRL_BIT_SC_IRQ;
} else {
tmp |= ME4000_AI_CTRL_BIT_HF_IRQ;
@@ -1293,7 +1313,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)
+ struct comedi_subdevice *s, struct comedi_cmd *cmd)
{
unsigned int entry;
unsigned int chan;
@@ -1332,7 +1352,8 @@ static int ai_write_chanlist(struct comedi_device *dev,
return 0;
}
-static int me4000_ai_do_cmd(struct comedi_device *dev, struct comedi_subdevice *s)
+static int me4000_ai_do_cmd(struct comedi_device *dev,
+ struct comedi_subdevice *s)
{
int err;
unsigned int init_ticks = 0;
@@ -1349,7 +1370,7 @@ static int me4000_ai_do_cmd(struct comedi_device *dev, struct comedi_subdevice *
/* Round the timer arguments */
err = ai_round_cmd_args(dev,
- s, cmd, &init_ticks, &scan_ticks, &chan_ticks);
+ s, cmd, &init_ticks, &scan_ticks, &chan_ticks);
if (err)
return err;
@@ -1377,7 +1398,8 @@ static int me4000_ai_do_cmd(struct comedi_device *dev, struct comedi_subdevice *
* So I tried to adopt this scheme.
*/
static int me4000_ai_do_cmd_test(struct comedi_device *dev,
- struct comedi_subdevice *s, struct comedi_cmd *cmd)
+ struct comedi_subdevice *s,
+ struct comedi_cmd *cmd)
{
unsigned int init_ticks;
@@ -1390,28 +1412,28 @@ static int me4000_ai_do_cmd_test(struct comedi_device *dev,
PDEBUG("me4000_ai_do_cmd_test(): subdev = %d\n", cmd->subdev);
PDEBUG("me4000_ai_do_cmd_test(): flags = %08X\n", cmd->flags);
PDEBUG("me4000_ai_do_cmd_test(): start_src = %08X\n",
- cmd->start_src);
+ cmd->start_src);
PDEBUG("me4000_ai_do_cmd_test(): start_arg = %d\n",
- cmd->start_arg);
+ cmd->start_arg);
PDEBUG("me4000_ai_do_cmd_test(): scan_begin_src = %08X\n",
- cmd->scan_begin_src);
+ cmd->scan_begin_src);
PDEBUG("me4000_ai_do_cmd_test(): scan_begin_arg = %d\n",
- cmd->scan_begin_arg);
+ cmd->scan_begin_arg);
PDEBUG("me4000_ai_do_cmd_test(): convert_src = %08X\n",
- cmd->convert_src);
+ cmd->convert_src);
PDEBUG("me4000_ai_do_cmd_test(): convert_arg = %d\n",
- cmd->convert_arg);
+ cmd->convert_arg);
PDEBUG("me4000_ai_do_cmd_test(): scan_end_src = %08X\n",
- cmd->scan_end_src);
+ cmd->scan_end_src);
PDEBUG("me4000_ai_do_cmd_test(): scan_end_arg = %d\n",
- cmd->scan_end_arg);
+ cmd->scan_end_arg);
PDEBUG("me4000_ai_do_cmd_test(): stop_src = %08X\n",
- cmd->stop_src);
+ cmd->stop_src);
PDEBUG("me4000_ai_do_cmd_test(): stop_arg = %d\n", cmd->stop_arg);
PDEBUG("me4000_ai_do_cmd_test(): chanlist = %d\n",
- (unsigned int)cmd->chanlist);
+ (unsigned int)cmd->chanlist);
PDEBUG("me4000_ai_do_cmd_test(): chanlist_len = %d\n",
- cmd->chanlist_len);
+ cmd->chanlist_len);
/* Only rounding flags are implemented */
cmd->flags &= TRIG_ROUND_NEAREST | TRIG_ROUND_UP | TRIG_ROUND_DOWN;
@@ -1432,8 +1454,8 @@ static int me4000_ai_do_cmd_test(struct comedi_device *dev,
break;
default:
printk(KERN_ERR
- "comedi%d: me4000: me4000_ai_do_cmd_test(): Invalid start source\n",
- dev->minor);
+ "comedi%d: me4000: me4000_ai_do_cmd_test(): Invalid start source\n",
+ dev->minor);
cmd->start_src = TRIG_NOW;
err++;
}
@@ -1448,8 +1470,8 @@ static int me4000_ai_do_cmd_test(struct comedi_device *dev,
break;
default:
printk(KERN_ERR
- "comedi%d: me4000: me4000_ai_do_cmd_test(): Invalid scan begin source\n",
- dev->minor);
+ "comedi%d: me4000: me4000_ai_do_cmd_test(): Invalid scan begin source\n",
+ dev->minor);
cmd->scan_begin_src = TRIG_FOLLOW;
err++;
}
@@ -1463,8 +1485,8 @@ static int me4000_ai_do_cmd_test(struct comedi_device *dev,
break;
default:
printk(KERN_ERR
- "comedi%d: me4000: me4000_ai_do_cmd_test(): Invalid convert source\n",
- dev->minor);
+ "comedi%d: me4000: me4000_ai_do_cmd_test(): Invalid convert source\n",
+ dev->minor);
cmd->convert_src = TRIG_TIMER;
err++;
}
@@ -1478,8 +1500,8 @@ static int me4000_ai_do_cmd_test(struct comedi_device *dev,
break;
default:
printk(KERN_ERR
- "comedi%d: me4000: me4000_ai_do_cmd_test(): Invalid scan end source\n",
- dev->minor);
+ "comedi%d: me4000: me4000_ai_do_cmd_test(): Invalid scan end source\n",
+ dev->minor);
cmd->scan_end_src = TRIG_NONE;
err++;
}
@@ -1493,8 +1515,8 @@ static int me4000_ai_do_cmd_test(struct comedi_device *dev,
break;
default:
printk(KERN_ERR
- "comedi%d: me4000: me4000_ai_do_cmd_test(): Invalid stop source\n",
- dev->minor);
+ "comedi%d: me4000: me4000_ai_do_cmd_test(): Invalid stop source\n",
+ dev->minor);
cmd->stop_src = TRIG_NONE;
err++;
}
@@ -1505,27 +1527,27 @@ static int me4000_ai_do_cmd_test(struct comedi_device *dev,
* Stage 2. Check for trigger source conflicts.
*/
if (cmd->start_src == TRIG_NOW &&
- cmd->scan_begin_src == TRIG_TIMER &&
- cmd->convert_src == TRIG_TIMER) {
+ cmd->scan_begin_src == TRIG_TIMER &&
+ cmd->convert_src == TRIG_TIMER) {
} else if (cmd->start_src == TRIG_NOW &&
- cmd->scan_begin_src == TRIG_FOLLOW &&
- cmd->convert_src == TRIG_TIMER) {
+ cmd->scan_begin_src == TRIG_FOLLOW &&
+ cmd->convert_src == TRIG_TIMER) {
} else if (cmd->start_src == TRIG_EXT &&
- cmd->scan_begin_src == TRIG_TIMER &&
- cmd->convert_src == TRIG_TIMER) {
+ cmd->scan_begin_src == TRIG_TIMER &&
+ cmd->convert_src == TRIG_TIMER) {
} else if (cmd->start_src == TRIG_EXT &&
- cmd->scan_begin_src == TRIG_FOLLOW &&
- cmd->convert_src == TRIG_TIMER) {
+ cmd->scan_begin_src == TRIG_FOLLOW &&
+ cmd->convert_src == TRIG_TIMER) {
} else if (cmd->start_src == TRIG_EXT &&
- cmd->scan_begin_src == TRIG_EXT &&
- cmd->convert_src == TRIG_TIMER) {
+ cmd->scan_begin_src == TRIG_EXT &&
+ cmd->convert_src == TRIG_TIMER) {
} else if (cmd->start_src == TRIG_EXT &&
- cmd->scan_begin_src == TRIG_EXT &&
- cmd->convert_src == TRIG_EXT) {
+ cmd->scan_begin_src == TRIG_EXT &&
+ cmd->convert_src == TRIG_EXT) {
} else {
printk(KERN_ERR
- "comedi%d: me4000: me4000_ai_do_cmd_test(): Invalid start trigger combination\n",
- dev->minor);
+ "comedi%d: me4000: me4000_ai_do_cmd_test(): Invalid start trigger combination\n",
+ dev->minor);
cmd->start_src = TRIG_NOW;
cmd->scan_begin_src = TRIG_FOLLOW;
cmd->convert_src = TRIG_TIMER;
@@ -1534,15 +1556,15 @@ static int me4000_ai_do_cmd_test(struct comedi_device *dev,
if (cmd->stop_src == TRIG_NONE && cmd->scan_end_src == TRIG_NONE) {
} else if (cmd->stop_src == TRIG_COUNT &&
- cmd->scan_end_src == TRIG_NONE) {
+ cmd->scan_end_src == TRIG_NONE) {
} else if (cmd->stop_src == TRIG_NONE &&
- cmd->scan_end_src == TRIG_COUNT) {
+ cmd->scan_end_src == TRIG_COUNT) {
} else if (cmd->stop_src == TRIG_COUNT &&
- cmd->scan_end_src == TRIG_COUNT) {
+ cmd->scan_end_src == TRIG_COUNT) {
} else {
printk(KERN_ERR
- "comedi%d: me4000: me4000_ai_do_cmd_test(): Invalid stop trigger combination\n",
- dev->minor);
+ "comedi%d: me4000: me4000_ai_do_cmd_test(): Invalid stop trigger combination\n",
+ dev->minor);
cmd->stop_src = TRIG_NONE;
cmd->scan_end_src = TRIG_NONE;
err++;
@@ -1555,29 +1577,29 @@ static int me4000_ai_do_cmd_test(struct comedi_device *dev,
*/
if (cmd->chanlist_len < 1) {
printk(KERN_ERR
- "comedi%d: me4000: me4000_ai_do_cmd_test(): No channel list\n",
- dev->minor);
+ "comedi%d: me4000: me4000_ai_do_cmd_test(): No channel list\n",
+ dev->minor);
cmd->chanlist_len = 1;
err++;
}
if (init_ticks < 66) {
printk(KERN_ERR
- "comedi%d: me4000: me4000_ai_do_cmd_test(): Start arg to low\n",
- dev->minor);
+ "comedi%d: me4000: me4000_ai_do_cmd_test(): Start arg to low\n",
+ dev->minor);
cmd->start_arg = 2000;
err++;
}
if (scan_ticks && scan_ticks < 67) {
printk(KERN_ERR
- "comedi%d: me4000: me4000_ai_do_cmd_test(): Scan begin arg to low\n",
- dev->minor);
+ "comedi%d: me4000: me4000_ai_do_cmd_test(): Scan begin arg to low\n",
+ dev->minor);
cmd->scan_begin_arg = 2031;
err++;
}
if (chan_ticks < 66) {
printk(KERN_ERR
- "comedi%d: me4000: me4000_ai_do_cmd_test(): Convert arg to low\n",
- dev->minor);
+ "comedi%d: me4000: me4000_ai_do_cmd_test(): Convert arg to low\n",
+ dev->minor);
cmd->convert_arg = 2000;
err++;
}
@@ -1589,123 +1611,123 @@ static int me4000_ai_do_cmd_test(struct comedi_device *dev,
* Stage 4. Check for argument conflicts.
*/
if (cmd->start_src == TRIG_NOW &&
- cmd->scan_begin_src == TRIG_TIMER &&
- cmd->convert_src == TRIG_TIMER) {
+ cmd->scan_begin_src == TRIG_TIMER &&
+ cmd->convert_src == TRIG_TIMER) {
/* Check timer arguments */
if (init_ticks < ME4000_AI_MIN_TICKS) {
printk(KERN_ERR
- "comedi%d: me4000: me4000_ai_do_cmd_test(): Invalid start arg\n",
- dev->minor);
+ "comedi%d: me4000: me4000_ai_do_cmd_test(): Invalid start arg\n",
+ dev->minor);
cmd->start_arg = 2000; /* 66 ticks at least */
err++;
}
if (chan_ticks < ME4000_AI_MIN_TICKS) {
printk(KERN_ERR
- "comedi%d: me4000: me4000_ai_do_cmd_test(): Invalid convert arg\n",
- dev->minor);
+ "comedi%d: me4000: me4000_ai_do_cmd_test(): Invalid convert arg\n",
+ dev->minor);
cmd->convert_arg = 2000; /* 66 ticks at least */
err++;
}
if (scan_ticks <= cmd->chanlist_len * chan_ticks) {
printk(KERN_ERR
- "comedi%d: me4000: me4000_ai_do_cmd_test(): Invalid scan end arg\n",
- dev->minor);
+ "comedi%d: me4000: me4000_ai_do_cmd_test(): Invalid scan end arg\n",
+ dev->minor);
cmd->scan_end_arg = 2000 * cmd->chanlist_len + 31; /* At least one tick more */
err++;
}
} else if (cmd->start_src == TRIG_NOW &&
- cmd->scan_begin_src == TRIG_FOLLOW &&
- cmd->convert_src == TRIG_TIMER) {
+ cmd->scan_begin_src == TRIG_FOLLOW &&
+ cmd->convert_src == TRIG_TIMER) {
/* Check timer arguments */
if (init_ticks < ME4000_AI_MIN_TICKS) {
printk(KERN_ERR
- "comedi%d: me4000: me4000_ai_do_cmd_test(): Invalid start arg\n",
- dev->minor);
+ "comedi%d: me4000: me4000_ai_do_cmd_test(): Invalid start arg\n",
+ dev->minor);
cmd->start_arg = 2000; /* 66 ticks at least */
err++;
}
if (chan_ticks < ME4000_AI_MIN_TICKS) {
printk(KERN_ERR
- "comedi%d: me4000: me4000_ai_do_cmd_test(): Invalid convert arg\n",
- dev->minor);
+ "comedi%d: me4000: me4000_ai_do_cmd_test(): Invalid convert arg\n",
+ dev->minor);
cmd->convert_arg = 2000; /* 66 ticks at least */
err++;
}
} else if (cmd->start_src == TRIG_EXT &&
- cmd->scan_begin_src == TRIG_TIMER &&
- cmd->convert_src == TRIG_TIMER) {
+ cmd->scan_begin_src == TRIG_TIMER &&
+ cmd->convert_src == TRIG_TIMER) {
/* Check timer arguments */
if (init_ticks < ME4000_AI_MIN_TICKS) {
printk(KERN_ERR
- "comedi%d: me4000: me4000_ai_do_cmd_test(): Invalid start arg\n",
- dev->minor);
+ "comedi%d: me4000: me4000_ai_do_cmd_test(): Invalid start arg\n",
+ dev->minor);
cmd->start_arg = 2000; /* 66 ticks at least */
err++;
}
if (chan_ticks < ME4000_AI_MIN_TICKS) {
printk(KERN_ERR
- "comedi%d: me4000: me4000_ai_do_cmd_test(): Invalid convert arg\n",
- dev->minor);
+ "comedi%d: me4000: me4000_ai_do_cmd_test(): Invalid convert arg\n",
+ dev->minor);
cmd->convert_arg = 2000; /* 66 ticks at least */
err++;
}
if (scan_ticks <= cmd->chanlist_len * chan_ticks) {
printk(KERN_ERR
- "comedi%d: me4000: me4000_ai_do_cmd_test(): Invalid scan end arg\n",
- dev->minor);
+ "comedi%d: me4000: me4000_ai_do_cmd_test(): Invalid scan end arg\n",
+ dev->minor);
cmd->scan_end_arg = 2000 * cmd->chanlist_len + 31; /* At least one tick more */
err++;
}
} else if (cmd->start_src == TRIG_EXT &&
- cmd->scan_begin_src == TRIG_FOLLOW &&
- cmd->convert_src == TRIG_TIMER) {
+ cmd->scan_begin_src == TRIG_FOLLOW &&
+ cmd->convert_src == TRIG_TIMER) {
/* Check timer arguments */
if (init_ticks < ME4000_AI_MIN_TICKS) {
printk(KERN_ERR
- "comedi%d: me4000: me4000_ai_do_cmd_test(): Invalid start arg\n",
- dev->minor);
+ "comedi%d: me4000: me4000_ai_do_cmd_test(): Invalid start arg\n",
+ dev->minor);
cmd->start_arg = 2000; /* 66 ticks at least */
err++;
}
if (chan_ticks < ME4000_AI_MIN_TICKS) {
printk(KERN_ERR
- "comedi%d: me4000: me4000_ai_do_cmd_test(): Invalid convert arg\n",
- dev->minor);
+ "comedi%d: me4000: me4000_ai_do_cmd_test(): Invalid convert arg\n",
+ dev->minor);
cmd->convert_arg = 2000; /* 66 ticks at least */
err++;
}
} else if (cmd->start_src == TRIG_EXT &&
- cmd->scan_begin_src == TRIG_EXT &&
- cmd->convert_src == TRIG_TIMER) {
+ cmd->scan_begin_src == TRIG_EXT &&
+ cmd->convert_src == TRIG_TIMER) {
/* Check timer arguments */
if (init_ticks < ME4000_AI_MIN_TICKS) {
printk(KERN_ERR
- "comedi%d: me4000: me4000_ai_do_cmd_test(): Invalid start arg\n",
- dev->minor);
+ "comedi%d: me4000: me4000_ai_do_cmd_test(): Invalid start arg\n",
+ dev->minor);
cmd->start_arg = 2000; /* 66 ticks at least */
err++;
}
if (chan_ticks < ME4000_AI_MIN_TICKS) {
printk(KERN_ERR
- "comedi%d: me4000: me4000_ai_do_cmd_test(): Invalid convert arg\n",
- dev->minor);
+ "comedi%d: me4000: me4000_ai_do_cmd_test(): Invalid convert arg\n",
+ dev->minor);
cmd->convert_arg = 2000; /* 66 ticks at least */
err++;
}
} else if (cmd->start_src == TRIG_EXT &&
- cmd->scan_begin_src == TRIG_EXT &&
- cmd->convert_src == TRIG_EXT) {
+ cmd->scan_begin_src == TRIG_EXT &&
+ cmd->convert_src == TRIG_EXT) {
/* Check timer arguments */
if (init_ticks < ME4000_AI_MIN_TICKS) {
printk(KERN_ERR
- "comedi%d: me4000: me4000_ai_do_cmd_test(): Invalid start arg\n",
- dev->minor);
+ "comedi%d: me4000: me4000_ai_do_cmd_test(): Invalid start arg\n",
+ dev->minor);
cmd->start_arg = 2000; /* 66 ticks at least */
err++;
}
@@ -1713,8 +1735,8 @@ static int me4000_ai_do_cmd_test(struct comedi_device *dev,
if (cmd->stop_src == TRIG_COUNT) {
if (cmd->stop_arg == 0) {
printk(KERN_ERR
- "comedi%d: me4000: me4000_ai_do_cmd_test(): Invalid stop arg\n",
- dev->minor);
+ "comedi%d: me4000: me4000_ai_do_cmd_test(): Invalid stop arg\n",
+ dev->minor);
cmd->stop_arg = 1;
err++;
}
@@ -1722,8 +1744,8 @@ static int me4000_ai_do_cmd_test(struct comedi_device *dev,
if (cmd->scan_end_src == TRIG_COUNT) {
if (cmd->scan_end_arg == 0) {
printk(KERN_ERR
- "comedi%d: me4000: me4000_ai_do_cmd_test(): Invalid scan end arg\n",
- dev->minor);
+ "comedi%d: me4000: me4000_ai_do_cmd_test(): Invalid scan end arg\n",
+ dev->minor);
cmd->scan_end_arg = 1;
err++;
}
@@ -1764,40 +1786,40 @@ static irqreturn_t me4000_ai_isr(int irq, void *dev_id)
/* Check if irq number is right */
if (irq != ai_context->irq) {
printk(KERN_ERR
- "comedi%d: me4000: me4000_ai_isr(): Incorrect interrupt num: %d\n",
- dev->minor, irq);
+ "comedi%d: me4000: me4000_ai_isr(): Incorrect interrupt num: %d\n",
+ dev->minor, irq);
return IRQ_HANDLED;
}
if (me4000_inl(dev,
- ai_context->
- irq_status_reg) & ME4000_IRQ_STATUS_BIT_AI_HF) {
+ ai_context->irq_status_reg) &
+ ME4000_IRQ_STATUS_BIT_AI_HF) {
ISR_PDEBUG
- ("me4000_ai_isr(): Fifo half full interrupt occured\n");
+ ("me4000_ai_isr(): Fifo half full interrupt occured\n");
/* Read status register to find out what happened */
tmp = me4000_inl(dev, ai_context->ctrl_reg);
if (!(tmp & ME4000_AI_STATUS_BIT_FF_DATA) &&
- !(tmp & ME4000_AI_STATUS_BIT_HF_DATA) &&
- (tmp & ME4000_AI_STATUS_BIT_EF_DATA)) {
+ !(tmp & ME4000_AI_STATUS_BIT_HF_DATA) &&
+ (tmp & ME4000_AI_STATUS_BIT_EF_DATA)) {
ISR_PDEBUG("me4000_ai_isr(): Fifo full\n");
c = ME4000_AI_FIFO_COUNT;
/* FIFO overflow, so stop conversion and disable all interrupts */
tmp |= ME4000_AI_CTRL_BIT_IMMEDIATE_STOP;
tmp &= ~(ME4000_AI_CTRL_BIT_HF_IRQ |
- ME4000_AI_CTRL_BIT_SC_IRQ);
+ ME4000_AI_CTRL_BIT_SC_IRQ);
me4000_outl(dev, tmp, ai_context->ctrl_reg);
s->async->events |= COMEDI_CB_ERROR | COMEDI_CB_EOA;
printk(KERN_ERR
- "comedi%d: me4000: me4000_ai_isr(): FIFO overflow\n",
- dev->minor);
+ "comedi%d: me4000: me4000_ai_isr(): FIFO overflow\n",
+ dev->minor);
} else if ((tmp & ME4000_AI_STATUS_BIT_FF_DATA)
- && !(tmp & ME4000_AI_STATUS_BIT_HF_DATA)
- && (tmp & ME4000_AI_STATUS_BIT_EF_DATA)) {
+ && !(tmp & ME4000_AI_STATUS_BIT_HF_DATA)
+ && (tmp & ME4000_AI_STATUS_BIT_EF_DATA)) {
ISR_PDEBUG("me4000_ai_isr(): Fifo half full\n");
s->async->events |= COMEDI_CB_BLOCK;
@@ -1805,21 +1827,21 @@ static irqreturn_t me4000_ai_isr(int irq, void *dev_id)
c = ME4000_AI_FIFO_COUNT / 2;
} else {
printk(KERN_ERR
- "comedi%d: me4000: me4000_ai_isr(): Can't determine state of fifo\n",
- dev->minor);
+ "comedi%d: me4000: me4000_ai_isr(): Can't determine state of fifo\n",
+ dev->minor);
c = 0;
/* Undefined state, so stop conversion and disable all interrupts */
tmp |= ME4000_AI_CTRL_BIT_IMMEDIATE_STOP;
tmp &= ~(ME4000_AI_CTRL_BIT_HF_IRQ |
- ME4000_AI_CTRL_BIT_SC_IRQ);
+ ME4000_AI_CTRL_BIT_SC_IRQ);
me4000_outl(dev, tmp, ai_context->ctrl_reg);
s->async->events |= COMEDI_CB_ERROR | COMEDI_CB_EOA;
printk(KERN_ERR
- "comedi%d: me4000: me4000_ai_isr(): Undefined FIFO state\n",
- dev->minor);
+ "comedi%d: me4000: me4000_ai_isr(): Undefined FIFO state\n",
+ dev->minor);
}
ISR_PDEBUG("me4000_ai_isr(): Try to read %d values\n", c);
@@ -1833,14 +1855,14 @@ static irqreturn_t me4000_ai_isr(int irq, void *dev_id)
/* Buffer overflow, so stop conversion and disable all interrupts */
tmp |= ME4000_AI_CTRL_BIT_IMMEDIATE_STOP;
tmp &= ~(ME4000_AI_CTRL_BIT_HF_IRQ |
- ME4000_AI_CTRL_BIT_SC_IRQ);
+ ME4000_AI_CTRL_BIT_SC_IRQ);
me4000_outl(dev, tmp, ai_context->ctrl_reg);
s->async->events |= COMEDI_CB_OVERFLOW;
printk(KERN_ERR
- "comedi%d: me4000: me4000_ai_isr(): Buffer overflow\n",
- dev->minor);
+ "comedi%d: me4000: me4000_ai_isr(): Buffer overflow\n",
+ dev->minor);
break;
}
@@ -1855,10 +1877,9 @@ static irqreturn_t me4000_ai_isr(int irq, void *dev_id)
}
if (me4000_inl(dev,
- ai_context->
- irq_status_reg) & ME4000_IRQ_STATUS_BIT_SC) {
+ ai_context->irq_status_reg) & ME4000_IRQ_STATUS_BIT_SC) {
ISR_PDEBUG
- ("me4000_ai_isr(): Sample counter interrupt occured\n");
+ ("me4000_ai_isr(): Sample counter interrupt occured\n");
s->async->events |= COMEDI_CB_BLOCK | COMEDI_CB_EOA;
@@ -1876,8 +1897,8 @@ static irqreturn_t me4000_ai_isr(int irq, void *dev_id)
if (!comedi_buf_put(s->async, lval)) {
printk(KERN_ERR
- "comedi%d: me4000: me4000_ai_isr(): Buffer overflow\n",
- dev->minor);
+ "comedi%d: me4000: me4000_ai_isr(): Buffer overflow\n",
+ dev->minor);
s->async->events |= COMEDI_CB_OVERFLOW;
break;
}
@@ -1885,7 +1906,7 @@ static irqreturn_t me4000_ai_isr(int irq, void *dev_id)
/* Work is done, so reset the interrupt */
ISR_PDEBUG
- ("me4000_ai_isr(): Reset interrupt from sample counter\n");
+ ("me4000_ai_isr(): Reset interrupt from sample counter\n");
tmp |= ME4000_AI_CTRL_BIT_SC_IRQ_RESET;
me4000_outl(dev, tmp, ai_context->ctrl_reg);
tmp &= ~ME4000_AI_CTRL_BIT_SC_IRQ_RESET;
@@ -1905,7 +1926,8 @@ static irqreturn_t me4000_ai_isr(int irq, void *dev_id)
===========================================================================*/
static int me4000_ao_insn_write(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)
{
int chan = CR_CHAN(insn->chanspec);
@@ -1919,29 +1941,29 @@ static int me4000_ao_insn_write(struct comedi_device *dev,
return 0;
} else if (insn->n > 1) {
printk(KERN_ERR
- "comedi%d: me4000: me4000_ao_insn_write(): Invalid instruction length %d\n",
- dev->minor, insn->n);
+ "comedi%d: me4000: me4000_ao_insn_write(): Invalid instruction length %d\n",
+ dev->minor, insn->n);
return -EINVAL;
}
if (chan >= thisboard->ao.count) {
printk(KERN_ERR
- "comedi%d: me4000: me4000_ao_insn_write(): Invalid channel %d\n",
- dev->minor, insn->n);
+ "comedi%d: me4000: me4000_ao_insn_write(): Invalid channel %d\n",
+ dev->minor, insn->n);
return -EINVAL;
}
if (rang != 0) {
printk(KERN_ERR
- "comedi%d: me4000: me4000_ao_insn_write(): Invalid range %d\n",
- dev->minor, insn->n);
+ "comedi%d: me4000: me4000_ao_insn_write(): Invalid range %d\n",
+ dev->minor, insn->n);
return -EINVAL;
}
if (aref != AREF_GROUND && aref != AREF_COMMON) {
printk(KERN_ERR
- "comedi%d: me4000: me4000_ao_insn_write(): Invalid aref %d\n",
- dev->minor, insn->n);
+ "comedi%d: me4000: me4000_ao_insn_write(): Invalid aref %d\n",
+ dev->minor, insn->n);
return -EINVAL;
}
@@ -1963,14 +1985,17 @@ static int me4000_ao_insn_write(struct comedi_device *dev,
}
static int me4000_ao_insn_read(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)
{
int chan = CR_CHAN(insn->chanspec);
if (insn->n == 0) {
return 0;
} else if (insn->n > 1) {
- printk("comedi%d: me4000: me4000_ao_insn_read(): Invalid instruction length\n", dev->minor);
+ printk
+ ("comedi%d: me4000: me4000_ao_insn_read(): Invalid instruction length\n",
+ dev->minor);
return -EINVAL;
}
@@ -1984,7 +2009,8 @@ static int me4000_ao_insn_read(struct comedi_device *dev,
===========================================================================*/
static int me4000_dio_insn_bits(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)
{
CALL_PDEBUG("In me4000_dio_insn_bits()\n");
@@ -1994,7 +2020,9 @@ static int me4000_dio_insn_bits(struct comedi_device *dev,
return 0;
if (insn->n != 2) {
- printk("comedi%d: me4000: me4000_dio_insn_bits(): Invalid instruction length\n", dev->minor);
+ printk
+ ("comedi%d: me4000: me4000_dio_insn_bits(): Invalid instruction length\n",
+ dev->minor);
return -EINVAL;
}
@@ -2014,28 +2042,29 @@ static int me4000_dio_insn_bits(struct comedi_device *dev,
/* Write out the new digital output lines */
me4000_outl(dev, (s->state >> 0) & 0xFF,
- info->dio_context.port_0_reg);
+ info->dio_context.port_0_reg);
me4000_outl(dev, (s->state >> 8) & 0xFF,
- info->dio_context.port_1_reg);
+ info->dio_context.port_1_reg);
me4000_outl(dev, (s->state >> 16) & 0xFF,
- info->dio_context.port_2_reg);
+ info->dio_context.port_2_reg);
me4000_outl(dev, (s->state >> 24) & 0xFF,
- info->dio_context.port_3_reg);
+ info->dio_context.port_3_reg);
}
/* On return, data[1] contains the value of
the digital input and output lines. */
data[1] =
- ((me4000_inl(dev, info->dio_context.port_0_reg) & 0xFF) << 0) |
- ((me4000_inl(dev, info->dio_context.port_1_reg) & 0xFF) << 8) |
- ((me4000_inl(dev, info->dio_context.port_2_reg) & 0xFF) << 16) |
- ((me4000_inl(dev, info->dio_context.port_3_reg) & 0xFF) << 24);
+ ((me4000_inl(dev, info->dio_context.port_0_reg) & 0xFF) << 0) |
+ ((me4000_inl(dev, info->dio_context.port_1_reg) & 0xFF) << 8) |
+ ((me4000_inl(dev, info->dio_context.port_2_reg) & 0xFF) << 16) |
+ ((me4000_inl(dev, info->dio_context.port_3_reg) & 0xFF) << 24);
return 2;
}
static int me4000_dio_insn_config(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)
{
unsigned long tmp;
int chan = CR_CHAN(insn->chanspec);
@@ -2044,8 +2073,7 @@ static int me4000_dio_insn_config(struct comedi_device *dev,
if (data[0] == INSN_CONFIG_DIO_QUERY) {
data[1] =
- (s->
- io_bits & (1 << chan)) ? COMEDI_OUTPUT : COMEDI_INPUT;
+ (s->io_bits & (1 << chan)) ? COMEDI_OUTPUT : COMEDI_INPUT;
return insn->n;
}
@@ -2063,7 +2091,7 @@ static int me4000_dio_insn_config(struct comedi_device *dev,
if (chan < 8) {
s->io_bits |= 0xFF;
tmp &= ~(ME4000_DIO_CTRL_BIT_MODE_0 |
- ME4000_DIO_CTRL_BIT_MODE_1);
+ ME4000_DIO_CTRL_BIT_MODE_1);
tmp |= ME4000_DIO_CTRL_BIT_MODE_0;
} else if (chan < 16) {
/*
@@ -2075,17 +2103,17 @@ static int me4000_dio_insn_config(struct comedi_device *dev,
s->io_bits |= 0xFF00;
tmp &= ~(ME4000_DIO_CTRL_BIT_MODE_2 |
- ME4000_DIO_CTRL_BIT_MODE_3);
+ ME4000_DIO_CTRL_BIT_MODE_3);
tmp |= ME4000_DIO_CTRL_BIT_MODE_2;
} else if (chan < 24) {
s->io_bits |= 0xFF0000;
tmp &= ~(ME4000_DIO_CTRL_BIT_MODE_4 |
- ME4000_DIO_CTRL_BIT_MODE_5);
+ ME4000_DIO_CTRL_BIT_MODE_5);
tmp |= ME4000_DIO_CTRL_BIT_MODE_4;
} else if (chan < 32) {
s->io_bits |= 0xFF000000;
tmp &= ~(ME4000_DIO_CTRL_BIT_MODE_6 |
- ME4000_DIO_CTRL_BIT_MODE_7);
+ ME4000_DIO_CTRL_BIT_MODE_7);
tmp |= ME4000_DIO_CTRL_BIT_MODE_6;
} else {
return -EINVAL;
@@ -2101,19 +2129,19 @@ static int me4000_dio_insn_config(struct comedi_device *dev,
s->io_bits &= ~0xFF;
tmp &= ~(ME4000_DIO_CTRL_BIT_MODE_0 |
- ME4000_DIO_CTRL_BIT_MODE_1);
+ ME4000_DIO_CTRL_BIT_MODE_1);
} else if (chan < 16) {
s->io_bits &= ~0xFF00;
tmp &= ~(ME4000_DIO_CTRL_BIT_MODE_2 |
- ME4000_DIO_CTRL_BIT_MODE_3);
+ ME4000_DIO_CTRL_BIT_MODE_3);
} else if (chan < 24) {
s->io_bits &= ~0xFF0000;
tmp &= ~(ME4000_DIO_CTRL_BIT_MODE_4 |
- ME4000_DIO_CTRL_BIT_MODE_5);
+ ME4000_DIO_CTRL_BIT_MODE_5);
} else if (chan < 32) {
s->io_bits &= ~0xFF000000;
tmp &= ~(ME4000_DIO_CTRL_BIT_MODE_6 |
- ME4000_DIO_CTRL_BIT_MODE_7);
+ ME4000_DIO_CTRL_BIT_MODE_7);
} else {
return -EINVAL;
}
@@ -2151,8 +2179,8 @@ static int cnt_reset(struct comedi_device *dev, unsigned int channel)
break;
default:
printk(KERN_ERR
- "comedi%d: me4000: cnt_reset(): Invalid channel\n",
- dev->minor);
+ "comedi%d: me4000: cnt_reset(): Invalid channel\n",
+ dev->minor);
return -EINVAL;
}
@@ -2160,7 +2188,7 @@ static int cnt_reset(struct comedi_device *dev, unsigned int channel)
}
static int cnt_config(struct comedi_device *dev, unsigned int channel,
- unsigned int mode)
+ unsigned int mode)
{
int tmp = 0;
@@ -2178,8 +2206,8 @@ static int cnt_config(struct comedi_device *dev, unsigned int channel,
break;
default:
printk(KERN_ERR
- "comedi%d: me4000: cnt_config(): Invalid channel\n",
- dev->minor);
+ "comedi%d: me4000: cnt_config(): Invalid channel\n",
+ dev->minor);
return -EINVAL;
}
@@ -2204,8 +2232,8 @@ static int cnt_config(struct comedi_device *dev, unsigned int channel,
break;
default:
printk(KERN_ERR
- "comedi%d: me4000: cnt_config(): Invalid counter mode\n",
- dev->minor);
+ "comedi%d: me4000: cnt_config(): Invalid counter mode\n",
+ dev->minor);
return -EINVAL;
}
@@ -2217,7 +2245,8 @@ static int cnt_config(struct comedi_device *dev, unsigned int channel,
}
static int me4000_cnt_insn_config(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)
{
int err;
@@ -2228,8 +2257,8 @@ static int me4000_cnt_insn_config(struct comedi_device *dev,
case GPCT_RESET:
if (insn->n != 1) {
printk(KERN_ERR
- "comedi%d: me4000: me4000_cnt_insn_config(): Invalid instruction length%d\n",
- dev->minor, insn->n);
+ "comedi%d: me4000: me4000_cnt_insn_config(): Invalid instruction length%d\n",
+ dev->minor, insn->n);
return -EINVAL;
}
@@ -2240,8 +2269,8 @@ static int me4000_cnt_insn_config(struct comedi_device *dev,
case GPCT_SET_OPERATION:
if (insn->n != 2) {
printk(KERN_ERR
- "comedi%d: me4000: me4000_cnt_insn_config(): Invalid instruction length%d\n",
- dev->minor, insn->n);
+ "comedi%d: me4000: me4000_cnt_insn_config(): Invalid instruction length%d\n",
+ dev->minor, insn->n);
return -EINVAL;
}
@@ -2251,8 +2280,8 @@ static int me4000_cnt_insn_config(struct comedi_device *dev,
break;
default:
printk(KERN_ERR
- "comedi%d: me4000: me4000_cnt_insn_config(): Invalid instruction\n",
- dev->minor);
+ "comedi%d: me4000: me4000_cnt_insn_config(): Invalid instruction\n",
+ dev->minor);
return -EINVAL;
}
@@ -2260,7 +2289,8 @@ static int me4000_cnt_insn_config(struct comedi_device *dev,
}
static int me4000_cnt_insn_read(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)
{
unsigned short tmp;
@@ -2272,8 +2302,8 @@ static int me4000_cnt_insn_read(struct comedi_device *dev,
if (insn->n > 1) {
printk(KERN_ERR
- "comedi%d: me4000: me4000_cnt_insn_read(): Invalid instruction length %d\n",
- dev->minor, insn->n);
+ "comedi%d: me4000: me4000_cnt_insn_read(): Invalid instruction length %d\n",
+ dev->minor, insn->n);
return -EINVAL;
}
@@ -2298,8 +2328,8 @@ static int me4000_cnt_insn_read(struct comedi_device *dev,
break;
default:
printk(KERN_ERR
- "comedi%d: me4000: me4000_cnt_insn_read(): Invalid channel %d\n",
- dev->minor, insn->chanspec);
+ "comedi%d: me4000: me4000_cnt_insn_read(): Invalid channel %d\n",
+ dev->minor, insn->chanspec);
return -EINVAL;
}
@@ -2307,7 +2337,8 @@ static int me4000_cnt_insn_read(struct comedi_device *dev,
}
static int me4000_cnt_insn_write(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)
{
unsigned short tmp;
@@ -2318,8 +2349,8 @@ static int me4000_cnt_insn_write(struct comedi_device *dev,
return 0;
} else if (insn->n > 1) {
printk(KERN_ERR
- "comedi%d: me4000: me4000_cnt_insn_write(): Invalid instruction length %d\n",
- dev->minor, insn->n);
+ "comedi%d: me4000: me4000_cnt_insn_write(): Invalid instruction length %d\n",
+ dev->minor, insn->n);
return -EINVAL;
}
@@ -2344,8 +2375,8 @@ static int me4000_cnt_insn_write(struct comedi_device *dev,
break;
default:
printk(KERN_ERR
- "comedi%d: me4000: me4000_cnt_insn_write(): Invalid channel %d\n",
- dev->minor, insn->chanspec);
+ "comedi%d: me4000: me4000_cnt_insn_write(): Invalid channel %d\n",
+ dev->minor, insn->chanspec);
return -EINVAL;
}
diff --git a/drivers/staging/comedi/drivers/me_daq.c b/drivers/staging/comedi/drivers/me_daq.c
index f21cecaa2e09..2cda7ad1d32f 100644
--- a/drivers/staging/comedi/drivers/me_daq.c
+++ b/drivers/staging/comedi/drivers/me_daq.c
@@ -151,46 +151,47 @@ static int me_detach(struct comedi_device *dev);
static const struct comedi_lrange me2000_ai_range = {
8,
{
- BIP_RANGE(10),
- BIP_RANGE(5),
- BIP_RANGE(2.5),
- BIP_RANGE(1.25),
- UNI_RANGE(10),
- UNI_RANGE(5),
- UNI_RANGE(2.5),
- UNI_RANGE(1.25)
- }
+ BIP_RANGE(10),
+ BIP_RANGE(5),
+ BIP_RANGE(2.5),
+ BIP_RANGE(1.25),
+ UNI_RANGE(10),
+ UNI_RANGE(5),
+ UNI_RANGE(2.5),
+ UNI_RANGE(1.25)
+ }
};
static const struct comedi_lrange me2600_ai_range = {
8,
{
- BIP_RANGE(10),
- BIP_RANGE(5),
- BIP_RANGE(2.5),
- BIP_RANGE(1.25),
- UNI_RANGE(10),
- UNI_RANGE(5),
- UNI_RANGE(2.5),
- UNI_RANGE(1.25)
- }
+ BIP_RANGE(10),
+ BIP_RANGE(5),
+ BIP_RANGE(2.5),
+ BIP_RANGE(1.25),
+ UNI_RANGE(10),
+ UNI_RANGE(5),
+ UNI_RANGE(2.5),
+ UNI_RANGE(1.25)
+ }
};
static const struct comedi_lrange me2600_ao_range = {
3,
{
- BIP_RANGE(10),
- BIP_RANGE(5),
- UNI_RANGE(10)
- }
+ BIP_RANGE(10),
+ BIP_RANGE(5),
+ UNI_RANGE(10)
+ }
};
static DEFINE_PCI_DEVICE_TABLE(me_pci_table) = {
- {PCI_VENDOR_ID_MEILHAUS, ME2600_DEVICE_ID, PCI_ANY_ID, PCI_ANY_ID, 0, 0,
- 0},
- {PCI_VENDOR_ID_MEILHAUS, ME2000_DEVICE_ID, PCI_ANY_ID, PCI_ANY_ID, 0, 0,
- 0},
- {0}
+ {
+ PCI_VENDOR_ID_MEILHAUS, ME2600_DEVICE_ID, PCI_ANY_ID,
+ PCI_ANY_ID, 0, 0, 0}, {
+ PCI_VENDOR_ID_MEILHAUS, ME2000_DEVICE_ID, PCI_ANY_ID,
+ PCI_ANY_ID, 0, 0, 0}, {
+ 0}
};
MODULE_DEVICE_TABLE(pci, me_pci_table);
@@ -212,48 +213,48 @@ struct me_board {
static const struct me_board me_boards[] = {
{
- /* -- ME-2600i -- */
- .name = ME_DRIVER_NAME,
- .device_id = ME2600_DEVICE_ID,
- /* Analog Output */
- .ao_channel_nbr = 4,
- .ao_resolution = 12,
- .ao_resolution_mask = 0x0fff,
- .ao_range_list = &me2600_ao_range,
- .ai_channel_nbr = 16,
- /* Analog Input */
- .ai_resolution = 12,
- .ai_resolution_mask = 0x0fff,
- .ai_range_list = &me2600_ai_range,
- .dio_channel_nbr = 32,
- },
+ /* -- ME-2600i -- */
+ .name = ME_DRIVER_NAME,
+ .device_id = ME2600_DEVICE_ID,
+ /* Analog Output */
+ .ao_channel_nbr = 4,
+ .ao_resolution = 12,
+ .ao_resolution_mask = 0x0fff,
+ .ao_range_list = &me2600_ao_range,
+ .ai_channel_nbr = 16,
+ /* Analog Input */
+ .ai_resolution = 12,
+ .ai_resolution_mask = 0x0fff,
+ .ai_range_list = &me2600_ai_range,
+ .dio_channel_nbr = 32,
+ },
{
- /* -- ME-2000i -- */
- .name = ME_DRIVER_NAME,
- .device_id = ME2000_DEVICE_ID,
- /* Analog Output */
- .ao_channel_nbr = 0,
- .ao_resolution = 0,
- .ao_resolution_mask = 0,
- .ao_range_list = NULL,
- .ai_channel_nbr = 16,
- /* Analog Input */
- .ai_resolution = 12,
- .ai_resolution_mask = 0x0fff,
- .ai_range_list = &me2000_ai_range,
- .dio_channel_nbr = 32,
- }
+ /* -- ME-2000i -- */
+ .name = ME_DRIVER_NAME,
+ .device_id = ME2000_DEVICE_ID,
+ /* Analog Output */
+ .ao_channel_nbr = 0,
+ .ao_resolution = 0,
+ .ao_resolution_mask = 0,
+ .ao_range_list = NULL,
+ .ai_channel_nbr = 16,
+ /* Analog Input */
+ .ai_resolution = 12,
+ .ai_resolution_mask = 0x0fff,
+ .ai_range_list = &me2000_ai_range,
+ .dio_channel_nbr = 32,
+ }
};
#define me_board_nbr (sizeof(me_boards)/sizeof(struct me_board))
-
static struct comedi_driver me_driver = {
- .driver_name = ME_DRIVER_NAME,
- .module = THIS_MODULE,
- .attach = me_attach,
- .detach = me_detach,
+ .driver_name = ME_DRIVER_NAME,
+ .module = THIS_MODULE,
+ .attach = me_attach,
+ .detach = me_detach,
};
+
COMEDI_PCI_INITCLEANUP(me_driver, me_pci_table);
/* Private data structure */
@@ -292,7 +293,8 @@ static inline void sleep(unsigned sec)
*
* ------------------------------------------------------------------
*/
-static int me_dio_insn_config(struct comedi_device *dev, struct comedi_subdevice *s,
+static int me_dio_insn_config(struct comedi_device *dev,
+ struct comedi_subdevice *s,
struct comedi_insn *insn, unsigned int *data)
{
int bits;
@@ -305,7 +307,7 @@ static int me_dio_insn_config(struct comedi_device *dev, struct comedi_subdevice
/* Enable Port A */
dev_private->control_2 |= ENABLE_PORT_A;
writew(dev_private->control_2,
- dev_private->me_regbase + ME_CONTROL_2);
+ dev_private->me_regbase + ME_CONTROL_2);
} else { /* Port B in use */
bits = 0xffff0000;
@@ -313,7 +315,7 @@ static int me_dio_insn_config(struct comedi_device *dev, struct comedi_subdevice
/* Enable Port B */
dev_private->control_2 |= ENABLE_PORT_B;
writew(dev_private->control_2,
- dev_private->me_regbase + ME_CONTROL_2);
+ dev_private->me_regbase + ME_CONTROL_2);
}
if (data[0]) {
@@ -328,7 +330,8 @@ static int me_dio_insn_config(struct comedi_device *dev, struct comedi_subdevice
}
/* Digital instant input/outputs */
-static int me_dio_insn_bits(struct comedi_device *dev, struct comedi_subdevice *s,
+static int me_dio_insn_bits(struct comedi_device *dev,
+ struct comedi_subdevice *s,
struct comedi_insn *insn, unsigned int *data)
{
unsigned int mask = data[0];
@@ -338,7 +341,7 @@ static int me_dio_insn_bits(struct comedi_device *dev, struct comedi_subdevice *
mask &= s->io_bits;
if (mask & 0x0000ffff) { /* Port A */
writew((s->state & 0xffff),
- dev_private->me_regbase + ME_DIO_PORT_A);
+ dev_private->me_regbase + ME_DIO_PORT_A);
} else {
data[1] &= ~0x0000ffff;
data[1] |= readw(dev_private->me_regbase + ME_DIO_PORT_A);
@@ -346,7 +349,7 @@ static int me_dio_insn_bits(struct comedi_device *dev, struct comedi_subdevice *
if (mask & 0xffff0000) { /* Port B */
writew(((s->state >> 16) & 0xffff),
- dev_private->me_regbase + ME_DIO_PORT_B);
+ dev_private->me_regbase + ME_DIO_PORT_B);
} else {
data[1] &= ~0xffff0000;
data[1] |= readw(dev_private->me_regbase + ME_DIO_PORT_B) << 16;
@@ -364,7 +367,8 @@ static int me_dio_insn_bits(struct comedi_device *dev, struct comedi_subdevice *
*/
/* Analog instant input */
-static int me_ai_insn_read(struct comedi_device *dev, struct comedi_subdevice *subdevice,
+static int me_ai_insn_read(struct comedi_device *dev,
+ struct comedi_subdevice *subdevice,
struct comedi_insn *insn, unsigned int *data)
{
unsigned short value;
@@ -414,8 +418,8 @@ static int me_ai_insn_read(struct comedi_device *dev, struct comedi_subdevice *s
/* get value from ADC fifo */
if (i) {
data[0] =
- (readw(dev_private->me_regbase +
- ME_READ_AD_FIFO) ^ 0x800) & 0x0FFF;
+ (readw(dev_private->me_regbase +
+ ME_READ_AD_FIFO) ^ 0x800) & 0x0FFF;
} else {
printk(KERN_ERR "comedi%d: Cannot get single value\n",
dev->minor);
@@ -450,14 +454,15 @@ static int me_ai_cancel(struct comedi_device *dev, struct comedi_subdevice *s)
}
/* Test analog input command */
-static int me_ai_do_cmd_test(struct comedi_device *dev, struct comedi_subdevice *s,
- struct comedi_cmd *cmd)
+static int me_ai_do_cmd_test(struct comedi_device *dev,
+ struct comedi_subdevice *s, struct comedi_cmd *cmd)
{
return 0;
}
/* Analog input command */
-static int me_ai_do_cmd(struct comedi_device *dev, struct comedi_subdevice *subdevice)
+static int me_ai_do_cmd(struct comedi_device *dev,
+ struct comedi_subdevice *subdevice)
{
return 0;
}
@@ -471,7 +476,8 @@ static int me_ai_do_cmd(struct comedi_device *dev, struct comedi_subdevice *subd
*/
/* Analog instant output */
-static int me_ao_insn_write(struct comedi_device *dev, struct comedi_subdevice *s,
+static int me_ao_insn_write(struct comedi_device *dev,
+ struct comedi_subdevice *s,
struct comedi_insn *insn, unsigned int *data)
{
int chan;
@@ -495,13 +501,13 @@ static int me_ao_insn_write(struct comedi_device *dev, struct comedi_subdevice *
dev_private->dac_control &= ~(0x0880 >> chan);
if (rang == 0)
dev_private->dac_control |=
- ((DAC_BIPOLAR_A | DAC_GAIN_1_A) >> chan);
+ ((DAC_BIPOLAR_A | DAC_GAIN_1_A) >> chan);
else if (rang == 1)
dev_private->dac_control |=
- ((DAC_BIPOLAR_A | DAC_GAIN_0_A) >> chan);
+ ((DAC_BIPOLAR_A | DAC_GAIN_0_A) >> chan);
}
writew(dev_private->dac_control,
- dev_private->me_regbase + ME_DAC_CONTROL);
+ dev_private->me_regbase + ME_DAC_CONTROL);
/* Update dac-control register */
readw(dev_private->me_regbase + ME_DAC_CONTROL_UPDATE);
@@ -510,7 +516,7 @@ static int me_ao_insn_write(struct comedi_device *dev, struct comedi_subdevice *
for (i = 0; i < insn->n; i++) {
chan = CR_CHAN((&insn->chanspec)[i]);
writew((data[0] & s->maxdata),
- dev_private->me_regbase + ME_DAC_DATA_A + (chan << 1));
+ dev_private->me_regbase + ME_DAC_DATA_A + (chan << 1));
dev_private->ao_readback[chan] = (data[0] & s->maxdata);
}
@@ -521,14 +527,15 @@ static int me_ao_insn_write(struct comedi_device *dev, struct comedi_subdevice *
}
/* Analog output readback */
-static int me_ao_insn_read(struct comedi_device *dev, struct comedi_subdevice *s,
- struct comedi_insn *insn, unsigned int *data)
+static int me_ao_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++) {
data[i] =
- dev_private->ao_readback[CR_CHAN((&insn->chanspec)[i])];
+ dev_private->ao_readback[CR_CHAN((&insn->chanspec)[i])];
}
return 1;
@@ -575,9 +582,9 @@ static int me2600_xilinx_download(struct comedi_device *dev,
if (length < 16)
return -EINVAL;
file_length = (((unsigned int)me2600_firmware[0] & 0xff) << 24) +
- (((unsigned int)me2600_firmware[1] & 0xff) << 16) +
- (((unsigned int)me2600_firmware[2] & 0xff) << 8) +
- ((unsigned int)me2600_firmware[3] & 0xff);
+ (((unsigned int)me2600_firmware[1] & 0xff) << 16) +
+ (((unsigned int)me2600_firmware[2] & 0xff) << 8) +
+ ((unsigned int)me2600_firmware[3] & 0xff);
/*
* Loop for writing firmware byte by byte to xilinx
@@ -585,7 +592,7 @@ static int me2600_xilinx_download(struct comedi_device *dev,
*/
for (i = 0; i < file_length; i++)
writeb((me2600_firmware[16 + i] & 0xff),
- dev_private->me_regbase + 0x0);
+ dev_private->me_regbase + 0x0);
/* Write 5 dummy values to xilinx */
for (i = 0; i < 5; i++)
@@ -653,33 +660,32 @@ static int me_attach(struct comedi_device *dev, struct comedi_devconfig *it)
/* 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);
- pci_device != NULL;
- pci_device =
- pci_get_device(PCI_ANY_ID, PCI_ANY_ID, pci_device)) {
+ pci_device != NULL;
+ pci_device = pci_get_device(PCI_ANY_ID, PCI_ANY_ID, pci_device)) {
if (pci_device->vendor == PCI_VENDOR_ID_MEILHAUS) {
for (i = 0; i < me_board_nbr; i++) {
if (me_boards[i].device_id ==
- pci_device->device) {
+ pci_device->device) {
/*
* was a particular bus/slot requested?
*/
if ((it->options[0] != 0)
- || (it->options[1] != 0)) {
+ || (it->options[1] != 0)) {
/*
* are we on the wrong bus/slot?
*/
if (pci_device->bus->number !=
- it->options[0]
- || PCI_SLOT(pci_device->
- devfn) !=
- it->options[1]) {
+ it->options[0]
+ ||
+ PCI_SLOT(pci_device->devfn)
+ != it->options[1]) {
continue;
}
}
dev->board_ptr = me_boards + i;
- board = (struct me_board *) dev->
- board_ptr;
+ board =
+ (struct me_board *)dev->board_ptr;
dev_private->pci_device = pci_device;
goto found;
}
@@ -694,8 +700,8 @@ static int me_attach(struct comedi_device *dev, struct comedi_devconfig *it)
found:
printk(KERN_INFO "comedi%d: found %s at PCI bus %d, slot %d\n",
- dev->minor, me_boards[i].name,
- pci_device->bus->number, PCI_SLOT(pci_device->devfn));
+ dev->minor, me_boards[i].name,
+ pci_device->bus->number, PCI_SLOT(pci_device->devfn));
/* Enable PCI device and request PCI regions */
if (comedi_pci_enable(pci_device, ME_DRIVER_NAME) < 0) {
@@ -711,7 +717,7 @@ found:
plx_regbase_tmp = pci_resource_start(pci_device, 0);
plx_regbase_size_tmp = pci_resource_len(pci_device, 0);
dev_private->plx_regbase =
- ioremap(plx_regbase_tmp, plx_regbase_size_tmp);
+ ioremap(plx_regbase_tmp, plx_regbase_size_tmp);
dev_private->plx_regbase_size = plx_regbase_size_tmp;
if (!dev_private->plx_regbase) {
printk("comedi%d: Failed to remap I/O memory\n", dev->minor);
@@ -736,18 +742,21 @@ found:
swap_regbase_tmp = regbase_tmp;
result = pci_write_config_dword(pci_device,
- PCI_BASE_ADDRESS_0, plx_regbase_tmp);
+ PCI_BASE_ADDRESS_0,
+ plx_regbase_tmp);
if (result != PCIBIOS_SUCCESSFUL)
return -EIO;
result = pci_write_config_dword(pci_device,
- PCI_BASE_ADDRESS_5, swap_regbase_tmp);
+ PCI_BASE_ADDRESS_5,
+ swap_regbase_tmp);
if (result != PCIBIOS_SUCCESSFUL)
return -EIO;
} else {
plx_regbase_tmp -= 0x80;
result = pci_write_config_dword(pci_device,
- PCI_BASE_ADDRESS_0, plx_regbase_tmp);
+ PCI_BASE_ADDRESS_0,
+ plx_regbase_tmp);
if (result != PCIBIOS_SUCCESSFUL)
return -EIO;
}
@@ -822,7 +831,8 @@ found:
subdevice->insn_config = me_dio_insn_config;
subdevice->io_bits = 0;
- printk(KERN_INFO "comedi%d: "ME_DRIVER_NAME" attached.\n", dev->minor);
+ printk(KERN_INFO "comedi%d: " ME_DRIVER_NAME " attached.\n",
+ dev->minor);
return 0;
}
diff --git a/drivers/staging/comedi/drivers/mite.c b/drivers/staging/comedi/drivers/mite.c
index 22a4029c30b5..e652f3b270b1 100644
--- a/drivers/staging/comedi/drivers/mite.c
+++ b/drivers/staging/comedi/drivers/mite.c
@@ -73,8 +73,8 @@ void mite_init(void)
struct mite_struct *mite;
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)) {
+ pcidev != NULL;
+ pcidev = pci_get_device(PCI_ANY_ID, PCI_ANY_ID, pcidev)) {
if (pcidev->vendor == PCI_VENDOR_ID_NATINST) {
unsigned i;
@@ -99,14 +99,19 @@ void mite_init(void)
static void dump_chip_signature(u32 csigr_bits)
{
- printk("mite: version = %i, type = %i, mite mode = %i, interface mode = %i\n", mite_csigr_version(csigr_bits), mite_csigr_type(csigr_bits), mite_csigr_mmode(csigr_bits), mite_csigr_imode(csigr_bits));
- printk("mite: num channels = %i, write post fifo depth = %i, wins = %i, iowins = %i\n", mite_csigr_dmac(csigr_bits), mite_csigr_wpdep(csigr_bits), mite_csigr_wins(csigr_bits), mite_csigr_iowins(csigr_bits));
+ printk
+ ("mite: version = %i, type = %i, mite mode = %i, interface mode = %i\n",
+ mite_csigr_version(csigr_bits), mite_csigr_type(csigr_bits),
+ mite_csigr_mmode(csigr_bits), mite_csigr_imode(csigr_bits));
+ printk
+ ("mite: num channels = %i, write post fifo depth = %i, wins = %i, iowins = %i\n",
+ mite_csigr_dmac(csigr_bits), mite_csigr_wpdep(csigr_bits),
+ mite_csigr_wins(csigr_bits), mite_csigr_iowins(csigr_bits));
}
unsigned mite_fifo_size(struct mite_struct *mite, unsigned channel)
{
- unsigned fcr_bits = readl(mite->mite_io_addr +
- MITE_FCR(channel));
+ unsigned fcr_bits = readl(mite->mite_io_addr + MITE_FCR(channel));
unsigned empty_count = (fcr_bits >> 16) & 0xff;
unsigned full_count = fcr_bits & 0xff;
return empty_count + full_count;
@@ -134,7 +139,7 @@ int mite_setup2(struct mite_struct *mite, unsigned use_iodwbsr_1)
return -ENOMEM;
}
printk("MITE:0x%08llx mapped to %p ",
- (unsigned long long)mite->mite_phys_addr, mite->mite_io_addr);
+ (unsigned long long)mite->mite_phys_addr, mite->mite_io_addr);
addr = pci_resource_start(mite->pcidev, 1);
mite->daq_phys_addr = addr;
@@ -146,19 +151,18 @@ int mite_setup2(struct mite_struct *mite, unsigned use_iodwbsr_1)
return -ENOMEM;
}
printk("DAQ:0x%08llx mapped to %p\n",
- (unsigned long long)mite->daq_phys_addr, mite->daq_io_addr);
+ (unsigned long long)mite->daq_phys_addr, mite->daq_io_addr);
if (use_iodwbsr_1) {
writel(0, mite->mite_io_addr + MITE_IODWBSR);
printk("mite: using I/O Window Base Size register 1\n");
- writel(mite->
- daq_phys_addr | WENAB |
- MITE_IODWBSR_1_WSIZE_bits(length),
- mite->mite_io_addr + MITE_IODWBSR_1);
+ writel(mite->daq_phys_addr | WENAB |
+ MITE_IODWBSR_1_WSIZE_bits(length),
+ mite->mite_io_addr + MITE_IODWBSR_1);
writel(0, mite->mite_io_addr + MITE_IODWCR_1);
} else {
writel(mite->daq_phys_addr | WENAB,
- mite->mite_io_addr + MITE_IODWBSR);
+ mite->mite_io_addr + MITE_IODWBSR);
}
/* make sure dma bursts work. I got this from running a bus analyzer
on a pxi-6281 and a pxi-6713. 6713 powered up with register value
@@ -167,15 +171,17 @@ int mite_setup2(struct mite_struct *mite, unsigned use_iodwbsr_1)
then does a bitwise-or of 0x600 with it and writes it back.
*/
unknown_dma_burst_bits =
- readl(mite->mite_io_addr + MITE_UNKNOWN_DMA_BURST_REG);
+ readl(mite->mite_io_addr + MITE_UNKNOWN_DMA_BURST_REG);
unknown_dma_burst_bits |= UNKNOWN_DMA_BURST_ENABLE_BITS;
writel(unknown_dma_burst_bits,
- mite->mite_io_addr + MITE_UNKNOWN_DMA_BURST_REG);
+ mite->mite_io_addr + MITE_UNKNOWN_DMA_BURST_REG);
csigr_bits = readl(mite->mite_io_addr + MITE_CSIGR);
mite->num_channels = mite_csigr_dmac(csigr_bits);
if (mite->num_channels > MAX_MITE_DMA_CHANNELS) {
- printk("mite: bug? chip claims to have %i dma channels. Setting to %i.\n", mite->num_channels, MAX_MITE_DMA_CHANNELS);
+ printk
+ ("mite: bug? chip claims to have %i dma channels. Setting to %i.\n",
+ mite->num_channels, MAX_MITE_DMA_CHANNELS);
mite->num_channels = MAX_MITE_DMA_CHANNELS;
}
dump_chip_signature(csigr_bits);
@@ -183,9 +189,9 @@ int mite_setup2(struct mite_struct *mite, unsigned use_iodwbsr_1)
writel(CHOR_DMARESET, mite->mite_io_addr + MITE_CHOR(i));
/* disable interrupts */
writel(CHCR_CLR_DMA_IE | CHCR_CLR_LINKP_IE | CHCR_CLR_SAR_IE |
- CHCR_CLR_DONE_IE | CHCR_CLR_MRDY_IE | CHCR_CLR_DRDY_IE |
- CHCR_CLR_LC_IE | CHCR_CLR_CONT_RB_IE,
- mite->mite_io_addr + MITE_CHCR(i));
+ CHCR_CLR_DONE_IE | CHCR_CLR_MRDY_IE | CHCR_CLR_DRDY_IE |
+ CHCR_CLR_LC_IE | CHCR_CLR_CONT_RB_IE,
+ mite->mite_io_addr + MITE_CHCR(i));
}
mite->fifo_size = mite_fifo_size(mite, 0);
printk("mite: fifo size is %i.\n", mite->fifo_size);
@@ -250,8 +256,10 @@ void mite_list_devices(void)
}
struct mite_channel *mite_request_channel_in_range(struct mite_struct *mite,
- struct mite_dma_descriptor_ring *ring, unsigned min_channel,
- unsigned max_channel)
+ struct
+ mite_dma_descriptor_ring
+ *ring, unsigned min_channel,
+ unsigned max_channel)
{
int i;
unsigned long flags;
@@ -284,10 +292,10 @@ void mite_release_channel(struct mite_channel *mite_chan)
/* disable all channel's interrupts (do it after disarm/reset so
MITE_CHCR reg isn't changed while dma is still active!) */
writel(CHCR_CLR_DMA_IE | CHCR_CLR_LINKP_IE |
- CHCR_CLR_SAR_IE | CHCR_CLR_DONE_IE |
- CHCR_CLR_MRDY_IE | CHCR_CLR_DRDY_IE |
- CHCR_CLR_LC_IE | CHCR_CLR_CONT_RB_IE,
- mite->mite_io_addr + MITE_CHCR(mite_chan->channel));
+ CHCR_CLR_SAR_IE | CHCR_CLR_DONE_IE |
+ CHCR_CLR_MRDY_IE | CHCR_CLR_DRDY_IE |
+ CHCR_CLR_LC_IE | CHCR_CLR_CONT_RB_IE,
+ mite->mite_io_addr + MITE_CHCR(mite_chan->channel));
mite->channel_allocated[mite_chan->channel] = 0;
mite_chan->ring = NULL;
mmiowb();
@@ -317,15 +325,18 @@ void mite_dma_arm(struct mite_channel *mite_chan)
/**************************************/
-int mite_buf_change(struct mite_dma_descriptor_ring *ring, struct comedi_async * async)
+int mite_buf_change(struct mite_dma_descriptor_ring *ring,
+ struct comedi_async *async)
{
unsigned int n_links;
int i;
if (ring->descriptors) {
dma_free_coherent(ring->hw_dev,
- ring->n_links * sizeof(struct mite_dma_descriptor),
- ring->descriptors, ring->descriptors_dma_addr);
+ ring->n_links *
+ sizeof(struct mite_dma_descriptor),
+ ring->descriptors,
+ ring->descriptors_dma_addr);
}
ring->descriptors = NULL;
ring->descriptors_dma_addr = 0;
@@ -339,9 +350,9 @@ int mite_buf_change(struct mite_dma_descriptor_ring *ring, struct comedi_async *
MDPRINTK("ring->hw_dev=%p, n_links=0x%04x\n", ring->hw_dev, n_links);
ring->descriptors =
- dma_alloc_coherent(ring->hw_dev,
- n_links * sizeof(struct mite_dma_descriptor),
- &ring->descriptors_dma_addr, GFP_KERNEL);
+ dma_alloc_coherent(ring->hw_dev,
+ n_links * sizeof(struct mite_dma_descriptor),
+ &ring->descriptors_dma_addr, GFP_KERNEL);
if (!ring->descriptors) {
printk("mite: ring buffer allocation failed\n");
return -ENOMEM;
@@ -351,13 +362,14 @@ int mite_buf_change(struct mite_dma_descriptor_ring *ring, struct comedi_async *
for (i = 0; i < n_links; i++) {
ring->descriptors[i].count = cpu_to_le32(PAGE_SIZE);
ring->descriptors[i].addr =
- cpu_to_le32(async->buf_page_list[i].dma_addr);
+ cpu_to_le32(async->buf_page_list[i].dma_addr);
ring->descriptors[i].next =
- cpu_to_le32(ring->descriptors_dma_addr + (i +
- 1) * sizeof(struct mite_dma_descriptor));
+ cpu_to_le32(ring->descriptors_dma_addr + (i +
+ 1) *
+ sizeof(struct mite_dma_descriptor));
}
ring->descriptors[n_links - 1].next =
- cpu_to_le32(ring->descriptors_dma_addr);
+ cpu_to_le32(ring->descriptors_dma_addr);
/* barrier is meant to insure that all the writes to the dma descriptors
have completed before the dma controller is commanded to read them */
smp_wmb();
@@ -365,7 +377,7 @@ int mite_buf_change(struct mite_dma_descriptor_ring *ring, struct comedi_async *
}
void mite_prep_dma(struct mite_channel *mite_chan,
- unsigned int num_device_bits, unsigned int num_memory_bits)
+ unsigned int num_device_bits, unsigned int num_memory_bits)
{
unsigned int chor, chcr, mcr, dcr, lkcr;
struct mite_struct *mite = mite_chan->mite;
@@ -378,7 +390,7 @@ void mite_prep_dma(struct mite_channel *mite_chan,
/* short link chaining mode */
chcr = CHCR_SET_DMA_IE | CHCR_LINKSHORT | CHCR_SET_DONE_IE |
- CHCR_BURSTEN;
+ CHCR_BURSTEN;
/*
* Link Complete Interrupt: interrupt every time a link
* in MITE_RING is completed. This can generate a lot of
@@ -413,8 +425,7 @@ void mite_prep_dma(struct mite_channel *mite_chan,
mcr |= CR_PSIZE32;
break;
default:
- printk
- ("mite: bug! invalid mem bit width for dma transfer\n");
+ printk("mite: bug! invalid mem bit width for dma transfer\n");
break;
}
writel(mcr, mite->mite_io_addr + MITE_MCR(mite_chan->channel));
@@ -433,8 +444,7 @@ void mite_prep_dma(struct mite_channel *mite_chan,
dcr |= CR_PSIZE32;
break;
default:
- printk
- ("mite: bug! invalid dev bit width for dma transfer\n");
+ printk("mite: bug! invalid dev bit width for dma transfer\n");
break;
}
writel(dcr, mite->mite_io_addr + MITE_DCR(mite_chan->channel));
@@ -448,7 +458,7 @@ void mite_prep_dma(struct mite_channel *mite_chan,
/* starting address for link chaining */
writel(mite_chan->ring->descriptors_dma_addr,
- mite->mite_io_addr + MITE_LKAR(mite_chan->channel));
+ mite->mite_io_addr + MITE_LKAR(mite_chan->channel));
MDPRINTK("exit mite_prep_dma\n");
}
@@ -459,15 +469,15 @@ u32 mite_device_bytes_transferred(struct mite_channel *mite_chan)
return readl(mite->mite_io_addr + MITE_DAR(mite_chan->channel));
}
-u32 mite_bytes_in_transit(struct mite_channel *mite_chan)
+u32 mite_bytes_in_transit(struct mite_channel * mite_chan)
{
struct mite_struct *mite = mite_chan->mite;
return readl(mite->mite_io_addr +
- MITE_FCR(mite_chan->channel)) & 0x000000FF;
+ MITE_FCR(mite_chan->channel)) & 0x000000FF;
}
/* returns lower bound for number of bytes transferred from device to memory */
-u32 mite_bytes_written_to_memory_lb(struct mite_channel *mite_chan)
+u32 mite_bytes_written_to_memory_lb(struct mite_channel * mite_chan)
{
u32 device_byte_count;
@@ -476,7 +486,7 @@ u32 mite_bytes_written_to_memory_lb(struct mite_channel *mite_chan)
}
/* returns upper bound for number of bytes transferred from device to memory */
-u32 mite_bytes_written_to_memory_ub(struct mite_channel *mite_chan)
+u32 mite_bytes_written_to_memory_ub(struct mite_channel * mite_chan)
{
u32 in_transit_count;
@@ -485,7 +495,7 @@ u32 mite_bytes_written_to_memory_ub(struct mite_channel *mite_chan)
}
/* returns lower bound for number of bytes read from memory for transfer to device */
-u32 mite_bytes_read_from_memory_lb(struct mite_channel *mite_chan)
+u32 mite_bytes_read_from_memory_lb(struct mite_channel * mite_chan)
{
u32 device_byte_count;
@@ -494,7 +504,7 @@ u32 mite_bytes_read_from_memory_lb(struct mite_channel *mite_chan)
}
/* returns upper bound for number of bytes read from memory for transfer to device */
-u32 mite_bytes_read_from_memory_ub(struct mite_channel *mite_chan)
+u32 mite_bytes_read_from_memory_ub(struct mite_channel * mite_chan)
{
u32 in_transit_count;
@@ -511,7 +521,7 @@ unsigned mite_dma_tcr(struct mite_channel *mite_chan)
lkar = readl(mite->mite_io_addr + MITE_LKAR(mite_chan->channel));
tcr = readl(mite->mite_io_addr + MITE_TCR(mite_chan->channel));
MDPRINTK("mite_dma_tcr ch%i, lkar=0x%08x tcr=%d\n", mite_chan->channel,
- lkar, tcr);
+ lkar, tcr);
return tcr;
}
@@ -526,7 +536,8 @@ void mite_dma_disarm(struct mite_channel *mite_chan)
writel(chor, mite->mite_io_addr + MITE_CHOR(mite_chan->channel));
}
-int mite_sync_input_dma(struct mite_channel *mite_chan, struct comedi_async * async)
+int mite_sync_input_dma(struct mite_channel *mite_chan,
+ struct comedi_async *async)
{
int count;
unsigned int nbytes, old_alloc_count;
@@ -538,7 +549,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) {
+ old_alloc_count) > 0) {
printk("mite: DMA overwrite of free area\n");
async->events |= COMEDI_CB_OVERFLOW;
return -1;
@@ -561,24 +572,25 @@ int mite_sync_input_dma(struct mite_channel *mite_chan, struct comedi_async * as
return 0;
}
-int mite_sync_output_dma(struct mite_channel *mite_chan, struct comedi_async * async)
+int mite_sync_output_dma(struct mite_channel *mite_chan,
+ struct comedi_async *async)
{
int count;
u32 nbytes_ub, nbytes_lb;
unsigned int old_alloc_count;
u32 stop_count =
- async->cmd.stop_arg * cfc_bytes_per_scan(async->subdevice);
+ async->cmd.stop_arg * cfc_bytes_per_scan(async->subdevice);
old_alloc_count = async->buf_read_alloc_count;
/* read alloc as much as we can */
comedi_buf_read_alloc(async, async->prealloc_bufsz);
nbytes_lb = mite_bytes_read_from_memory_lb(mite_chan);
if (async->cmd.stop_src == TRIG_COUNT &&
- (int)(nbytes_lb - stop_count) > 0)
+ (int)(nbytes_lb - stop_count) > 0)
nbytes_lb = stop_count;
nbytes_ub = mite_bytes_read_from_memory_ub(mite_chan);
if (async->cmd.stop_src == TRIG_COUNT &&
- (int)(nbytes_ub - stop_count) > 0)
+ (int)(nbytes_ub - stop_count) > 0)
nbytes_ub = stop_count;
if ((int)(nbytes_ub - old_alloc_count) > 0) {
printk("mite: DMA underrun\n");
@@ -607,7 +619,7 @@ unsigned mite_get_status(struct mite_channel *mite_chan)
if (status & CHSR_DONE) {
mite_chan->done = 1;
writel(CHOR_CLRDONE,
- mite->mite_io_addr + MITE_CHOR(mite_chan->channel));
+ mite->mite_io_addr + MITE_CHOR(mite_chan->channel));
}
mmiowb();
spin_unlock_irqrestore(&mite->lock, flags);
@@ -703,7 +715,7 @@ static const char *const mite_CHSR_strings[] = {
void mite_dump_regs(struct mite_channel *mite_chan)
{
unsigned long mite_io_addr =
- (unsigned long)mite_chan->mite->mite_io_addr;
+ (unsigned long)mite_chan->mite->mite_io_addr;
unsigned long addr = 0;
unsigned long temp = 0;
@@ -712,37 +724,37 @@ void mite_dump_regs(struct mite_channel *mite_chan)
addr = mite_io_addr + MITE_CHOR(channel);
printk("mite status[CHOR]at 0x%08lx =0x%08lx\n", addr, temp =
- readl(addr));
+ readl(addr));
mite_decode(mite_CHOR_strings, temp);
addr = mite_io_addr + MITE_CHCR(channel);
printk("mite status[CHCR]at 0x%08lx =0x%08lx\n", addr, temp =
- readl(addr));
+ readl(addr));
mite_decode(mite_CHCR_strings, temp);
addr = mite_io_addr + MITE_TCR(channel);
printk("mite status[TCR] at 0x%08lx =0x%08x\n", addr, readl(addr));
addr = mite_io_addr + MITE_MCR(channel);
printk("mite status[MCR] at 0x%08lx =0x%08lx\n", addr, temp =
- readl(addr));
+ readl(addr));
mite_decode(mite_MCR_strings, temp);
addr = mite_io_addr + MITE_MAR(channel);
printk("mite status[MAR] at 0x%08lx =0x%08x\n", addr, readl(addr));
addr = mite_io_addr + MITE_DCR(channel);
printk("mite status[DCR] at 0x%08lx =0x%08lx\n", addr, temp =
- readl(addr));
+ readl(addr));
mite_decode(mite_DCR_strings, temp);
addr = mite_io_addr + MITE_DAR(channel);
printk("mite status[DAR] at 0x%08lx =0x%08x\n", addr, readl(addr));
addr = mite_io_addr + MITE_LKCR(channel);
printk("mite status[LKCR]at 0x%08lx =0x%08lx\n", addr, temp =
- readl(addr));
+ readl(addr));
mite_decode(mite_LKCR_strings, temp);
addr = mite_io_addr + MITE_LKAR(channel);
printk("mite status[LKAR]at 0x%08lx =0x%08x\n", addr, readl(addr));
addr = mite_io_addr + MITE_CHSR(channel);
printk("mite status[CHSR]at 0x%08lx =0x%08lx\n", addr, temp =
- readl(addr));
+ readl(addr));
mite_decode(mite_CHSR_strings, temp);
addr = mite_io_addr + MITE_FCR(channel);
printk("mite status[FCR] at 0x%08lx =0x%08x\n\n", addr, readl(addr));
diff --git a/drivers/staging/comedi/drivers/mite.h b/drivers/staging/comedi/drivers/mite.h
index 31942319aa38..0518fadc4daa 100644
--- a/drivers/staging/comedi/drivers/mite.h
+++ b/drivers/staging/comedi/drivers/mite.h
@@ -80,10 +80,11 @@ struct mite_struct {
};
static inline struct mite_dma_descriptor_ring *mite_alloc_ring(struct
- mite_struct *mite)
+ mite_struct
+ *mite)
{
struct mite_dma_descriptor_ring *ring =
- kmalloc(sizeof(struct mite_dma_descriptor_ring), GFP_KERNEL);
+ kmalloc(sizeof(struct mite_dma_descriptor_ring), GFP_KERNEL);
if (ring == NULL)
return ring;
ring->hw_dev = get_device(&mite->pcidev->dev);
@@ -102,9 +103,10 @@ static inline void mite_free_ring(struct mite_dma_descriptor_ring *ring)
if (ring) {
if (ring->descriptors) {
dma_free_coherent(ring->hw_dev,
- ring->n_links *
- sizeof(struct mite_dma_descriptor),
- ring->descriptors, ring->descriptors_dma_addr);
+ ring->n_links *
+ sizeof(struct mite_dma_descriptor),
+ ring->descriptors,
+ ring->descriptors_dma_addr);
}
put_device(ring->hw_dev);
kfree(ring);
@@ -117,6 +119,7 @@ static inline unsigned int mite_irq(struct mite_struct *mite)
{
return mite->pcidev->irq;
};
+
static inline unsigned int mite_device_id(struct mite_struct *mite)
{
return mite->pcidev->device;
@@ -129,21 +132,29 @@ int mite_setup2(struct mite_struct *mite, unsigned use_iodwbsr_1);
void mite_unsetup(struct mite_struct *mite);
void mite_list_devices(void);
struct mite_channel *mite_request_channel_in_range(struct mite_struct *mite,
- struct mite_dma_descriptor_ring *ring, unsigned min_channel,
- unsigned max_channel);
+ struct
+ mite_dma_descriptor_ring
+ *ring, unsigned min_channel,
+ unsigned max_channel);
static inline struct mite_channel *mite_request_channel(struct mite_struct
- *mite, struct mite_dma_descriptor_ring *ring)
+ *mite,
+ struct
+ mite_dma_descriptor_ring
+ *ring)
{
return mite_request_channel_in_range(mite, ring, 0,
- mite->num_channels - 1);
+ mite->num_channels - 1);
}
+
void mite_release_channel(struct mite_channel *mite_chan);
unsigned mite_dma_tcr(struct mite_channel *mite_chan);
void mite_dma_arm(struct mite_channel *mite_chan);
void mite_dma_disarm(struct mite_channel *mite_chan);
-int mite_sync_input_dma(struct mite_channel *mite_chan, struct comedi_async * async);
-int mite_sync_output_dma(struct mite_channel *mite_chan, struct comedi_async * async);
+int mite_sync_input_dma(struct mite_channel *mite_chan,
+ struct comedi_async *async);
+int mite_sync_output_dma(struct mite_channel *mite_chan,
+ struct comedi_async *async);
u32 mite_bytes_written_to_memory_lb(struct mite_channel *mite_chan);
u32 mite_bytes_written_to_memory_ub(struct mite_channel *mite_chan);
u32 mite_bytes_read_from_memory_lb(struct mite_channel *mite_chan);
@@ -153,16 +164,16 @@ unsigned mite_get_status(struct mite_channel *mite_chan);
int mite_done(struct mite_channel *mite_chan);
#if 0
-unsigned long mite_ll_from_kvmem(struct mite_struct *mite, struct comedi_async * async,
- int len);
+unsigned long mite_ll_from_kvmem(struct mite_struct *mite,
+ struct comedi_async *async, int len);
void mite_setregs(struct mite_struct *mite, unsigned long ll_start, int chan,
- int dir);
+ int dir);
#endif
void mite_prep_dma(struct mite_channel *mite_chan,
- unsigned int num_device_bits, unsigned int num_memory_bits);
+ unsigned int num_device_bits, unsigned int num_memory_bits);
int mite_buf_change(struct mite_dma_descriptor_ring *ring,
- struct comedi_async *async);
+ struct comedi_async *async);
#ifdef DEBUG_MITE
void mite_print_chsr(unsigned int chsr);
@@ -185,72 +196,88 @@ enum mite_registers {
MITE_PCI_CONFIG_OFFSET = 0x300,
MITE_CSIGR = 0x460 /* chip signature */
};
-static inline int MITE_CHOR(int channel) /* channel operation */
-{
+static inline int MITE_CHOR(int channel)
+{ /* channel operation */
return CHAN_OFFSET(channel) + 0x0;
};
-static inline int MITE_CHCR(int channel) /* channel control */
-{
+
+static inline int MITE_CHCR(int channel)
+{ /* channel control */
return CHAN_OFFSET(channel) + 0x4;
};
-static inline int MITE_TCR(int channel) /* transfer count */
-{
+
+static inline int MITE_TCR(int channel)
+{ /* transfer count */
return CHAN_OFFSET(channel) + 0x8;
};
-static inline int MITE_MCR(int channel) /* memory configuration */
-{
+
+static inline int MITE_MCR(int channel)
+{ /* memory configuration */
return CHAN_OFFSET(channel) + 0xc;
};
-static inline int MITE_MAR(int channel) /* memory address */
-{
+
+static inline int MITE_MAR(int channel)
+{ /* memory address */
return CHAN_OFFSET(channel) + 0x10;
};
-static inline int MITE_DCR(int channel) /* device configuration */
-{
+
+static inline int MITE_DCR(int channel)
+{ /* device configuration */
return CHAN_OFFSET(channel) + 0x14;
};
-static inline int MITE_DAR(int channel) /* device address */
-{
+
+static inline int MITE_DAR(int channel)
+{ /* device address */
return CHAN_OFFSET(channel) + 0x18;
};
-static inline int MITE_LKCR(int channel) /* link configuration */
-{
+
+static inline int MITE_LKCR(int channel)
+{ /* link configuration */
return CHAN_OFFSET(channel) + 0x1c;
};
-static inline int MITE_LKAR(int channel) /* link address */
-{
+
+static inline int MITE_LKAR(int channel)
+{ /* link address */
return CHAN_OFFSET(channel) + 0x20;
};
-static inline int MITE_LLKAR(int channel) /* see mite section of tnt5002 manual */
-{
+
+static inline int MITE_LLKAR(int channel)
+{ /* see mite section of tnt5002 manual */
return CHAN_OFFSET(channel) + 0x24;
};
-static inline int MITE_BAR(int channel) /* base address */
-{
+
+static inline int MITE_BAR(int channel)
+{ /* base address */
return CHAN_OFFSET(channel) + 0x28;
};
-static inline int MITE_BCR(int channel) /* base count */
-{
+
+static inline int MITE_BCR(int channel)
+{ /* base count */
return CHAN_OFFSET(channel) + 0x2c;
};
-static inline int MITE_SAR(int channel) /* ? address */
-{
+
+static inline int MITE_SAR(int channel)
+{ /* ? address */
return CHAN_OFFSET(channel) + 0x30;
};
-static inline int MITE_WSCR(int channel) /* ? */
-{
+
+static inline int MITE_WSCR(int channel)
+{ /* ? */
return CHAN_OFFSET(channel) + 0x34;
};
-static inline int MITE_WSER(int channel) /* ? */
-{
+
+static inline int MITE_WSER(int channel)
+{ /* ? */
return CHAN_OFFSET(channel) + 0x38;
};
-static inline int MITE_CHSR(int channel) /* channel status */
-{
+
+static inline int MITE_CHSR(int channel)
+{ /* channel status */
return CHAN_OFFSET(channel) + 0x3c;
};
-static inline int MITE_FCR(int channel) /* fifo count */
-{
+
+static inline int MITE_FCR(int channel)
+{ /* fifo count */
return CHAN_OFFSET(channel) + 0x40;
};
@@ -275,22 +302,27 @@ static inline int mite_csigr_version(u32 csigr_bits)
{
return csigr_bits & 0xf;
};
+
static inline int mite_csigr_type(u32 csigr_bits)
{ /* original mite = 0, minimite = 1 */
return (csigr_bits >> 4) & 0xf;
};
+
static inline int mite_csigr_mmode(u32 csigr_bits)
{ /* mite mode, minimite = 1 */
return (csigr_bits >> 8) & 0x3;
};
+
static inline int mite_csigr_imode(u32 csigr_bits)
{ /* cpu port interface mode, pci = 0x3 */
return (csigr_bits >> 12) & 0x3;
};
+
static inline int mite_csigr_dmac(u32 csigr_bits)
{ /* number of dma channels */
return (csigr_bits >> 16) & 0xf;
};
+
static inline int mite_csigr_wpdep(u32 csigr_bits)
{ /* write post fifo depth */
unsigned int wpdep_bits = (csigr_bits >> 20) & 0x7;
@@ -299,10 +331,12 @@ static inline int mite_csigr_wpdep(u32 csigr_bits)
else
return 1 << (wpdep_bits - 1);
};
+
static inline int mite_csigr_wins(u32 csigr_bits)
{
return (csigr_bits >> 24) & 0x1f;
};
+
static inline int mite_csigr_iowins(u32 csigr_bits)
{ /* number of io windows */
return (csigr_bits >> 29) & 0x7;
@@ -366,9 +400,9 @@ enum MITE_CHCR_bits {
CHCR_LINKSHORT = (4 << 0),
CHCR_LINKLONG = (5 << 0),
CHCRPON =
- (CHCR_CLR_DMA_IE | CHCR_CLR_LINKP_IE | CHCR_CLR_SAR_IE |
- CHCR_CLR_DONE_IE | CHCR_CLR_MRDY_IE | CHCR_CLR_DRDY_IE |
- CHCR_CLR_LC_IE | CHCR_CLR_CONT_RB_IE),
+ (CHCR_CLR_DMA_IE | CHCR_CLR_LINKP_IE | CHCR_CLR_SAR_IE |
+ CHCR_CLR_DONE_IE | CHCR_CLR_MRDY_IE | CHCR_CLR_DRDY_IE |
+ CHCR_CLR_LC_IE | CHCR_CLR_CONT_RB_IE),
};
enum ConfigRegister_bits {
@@ -390,12 +424,14 @@ static inline int CR_REQS(int source)
{
return (source & 0x7) << 16;
};
+
static inline int CR_REQSDRQ(unsigned drq_line)
{
/* This also works on m-series when
using channels (drq_line) 4 or 5. */
return CR_REQS((drq_line & 0x3) | 0x4);
}
+
static inline int CR_RL(unsigned int retry_limit)
{
int value = 0;
@@ -447,7 +483,7 @@ enum CHSR_bits {
static inline void mite_dma_reset(struct mite_channel *mite_chan)
{
writel(CHOR_DMARESET | CHOR_FRESET,
- mite_chan->mite->mite_io_addr + MITE_CHOR(mite_chan->channel));
+ mite_chan->mite->mite_io_addr + MITE_CHOR(mite_chan->channel));
};
#endif
diff --git a/drivers/staging/comedi/drivers/mpc624.c b/drivers/staging/comedi/drivers/mpc624.c
index 4a0e647f631a..cb4da2ae8429 100644
--- a/drivers/staging/comedi/drivers/mpc624.c
+++ b/drivers/staging/comedi/drivers/mpc624.c
@@ -125,28 +125,29 @@ struct skel_private {
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(2.02)
- }
+ /* 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(20.2)
- }
+ /* 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_attach(struct comedi_device *dev,
+ struct comedi_devconfig *it);
static int mpc624_detach(struct comedi_device *dev);
/* ---------------------------------------------------------------------------- */
static struct comedi_driver driver_mpc624 = {
@@ -157,8 +158,9 @@ static struct comedi_driver driver_mpc624 = {
};
/* ---------------------------------------------------------------------------- */
-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);
/* ---------------------------------------------------------------------------- */
static int mpc624_attach(struct comedi_device *dev, struct comedi_devconfig *it)
{
@@ -222,7 +224,7 @@ static int mpc624_attach(struct comedi_device *dev, struct comedi_devconfig *it)
break;
default:
printk
- ("illegal convertion rate setting! Valid numbers are 0..9. Using 9 => 6.875 Hz, ");
+ ("illegal convertion rate setting! Valid numbers are 0..9. Using 9 => 6.875 Hz, ");
devpriv->ulConvertionRate = MPC624_SPEED_3_52_kHz;
}
@@ -270,8 +272,9 @@ static int mpc624_detach(struct comedi_device *dev)
/* 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;
@@ -316,16 +319,15 @@ static int mpc624_ai_rinsn(struct comedi_device *dev, struct comedi_subdevice *s
outb(0, dev->iobase + MPC624_ADC);
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) */
outb(MPC624_ADSDI, dev->iobase + MPC624_ADC);
udelay(1);
/* Set the clock high */
outb(MPC624_ADSCK | MPC624_ADSDI,
- dev->iobase + MPC624_ADC);
- } else /* the next bit is a 0 */
- {
+ dev->iobase + MPC624_ADC);
+ } else { /* the next bit is a 0 */
+
/* Set the ADSDI line (send to MPC624) */
outb(0, dev->iobase + MPC624_ADC);
udelay(1);
@@ -336,8 +338,7 @@ static int mpc624_ai_rinsn(struct comedi_device *dev, struct comedi_subdevice *s
udelay(1);
data_in <<= 1;
data_in |=
- (inb(dev->iobase +
- MPC624_ADC) & MPC624_ADSDO) >> 4;
+ (inb(dev->iobase + MPC624_ADC) & MPC624_ADSDO) >> 4;
udelay(1);
data_out <<= 1;
@@ -358,12 +359,11 @@ static int mpc624_ai_rinsn(struct comedi_device *dev, struct comedi_subdevice *s
if (data_in & MPC624_EOC_BIT)
printk("MPC624: EOC bit is set (data_in=%lu)!",
- data_in);
+ data_in);
if (data_in & MPC624_DMY_BIT)
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);
+ 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. */
diff --git a/drivers/staging/comedi/drivers/mpc8260cpm.c b/drivers/staging/comedi/drivers/mpc8260cpm.c
index c7ee3ef10130..440a144a037e 100644
--- a/drivers/staging/comedi/drivers/mpc8260cpm.c
+++ b/drivers/staging/comedi/drivers/mpc8260cpm.c
@@ -46,7 +46,8 @@ 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_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",
@@ -57,12 +58,15 @@ static struct comedi_driver driver_mpc8260cpm = {
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;
@@ -114,8 +118,9 @@ 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 +162,9 @@ static int mpc8260cpm_dio_config(struct comedi_device *dev, struct comedi_subdev
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 f7cce6cc7766..5d6af9c459db 100644
--- a/drivers/staging/comedi/drivers/multiq3.c
+++ b/drivers/staging/comedi/drivers/multiq3.c
@@ -83,7 +83,8 @@ 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_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",
@@ -99,8 +100,9 @@ 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;
@@ -108,7 +110,7 @@ static int multiq3_ai_insn_read(struct comedi_device *dev, struct comedi_subdevi
chan = CR_CHAN(insn->chanspec);
outw(MULTIQ3_CONTROL_MUST | MULTIQ3_AD_MUX_EN | (chan << 3),
- dev->iobase + MULTIQ3_CONTROL);
+ dev->iobase + MULTIQ3_CONTROL);
for (i = 0; i < MULTIQ3_TIMEOUT; i++) {
if (inw(dev->iobase + MULTIQ3_STATUS) & MULTIQ3_STATUS_EOC)
@@ -121,7 +123,7 @@ static int multiq3_ai_insn_read(struct comedi_device *dev, struct comedi_subdevi
outw(0, dev->iobase + MULTIQ3_AD_CS);
for (i = 0; i < MULTIQ3_TIMEOUT; i++) {
if (inw(dev->iobase +
- MULTIQ3_STATUS) & MULTIQ3_STATUS_EOC_I)
+ MULTIQ3_STATUS) & MULTIQ3_STATUS_EOC_I)
break;
}
if (i == MULTIQ3_TIMEOUT)
@@ -135,8 +137,9 @@ static int multiq3_ai_insn_read(struct comedi_device *dev, struct comedi_subdevi
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);
@@ -148,15 +151,16 @@ static int multiq3_ao_insn_read(struct comedi_device *dev, struct comedi_subdevi
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);
for (i = 0; i < insn->n; i++) {
outw(MULTIQ3_CONTROL_MUST | MULTIQ3_DA_LOAD | chan,
- dev->iobase + MULTIQ3_CONTROL);
+ dev->iobase + MULTIQ3_CONTROL);
outw(data[i], dev->iobase + MULTIQ3_DAC_DATA);
outw(MULTIQ3_CONTROL_MUST, dev->iobase + MULTIQ3_CONTROL);
@@ -166,8 +170,9 @@ static int multiq3_ao_insn_write(struct comedi_device *dev, struct comedi_subdev
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;
@@ -177,8 +182,9 @@ static int multiq3_di_insn_bits(struct comedi_device *dev, struct comedi_subdevi
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;
@@ -192,8 +198,10 @@ static int multiq3_do_insn_bits(struct comedi_device *dev, struct comedi_subdevi
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);
@@ -218,7 +226,7 @@ static void encoder_reset(struct comedi_device *dev)
int chan;
for (chan = 0; chan < dev->subdevices[4].n_chan; chan++) {
int control =
- MULTIQ3_CONTROL_MUST | MULTIQ3_AD_MUX_EN | (chan << 3);
+ MULTIQ3_CONTROL_MUST | MULTIQ3_AD_MUX_EN | (chan << 3);
outw(control, dev->iobase + MULTIQ3_CONTROL);
outb(MULTIQ3_EFLAG_RESET, dev->iobase + MULTIQ3_ENC_CONTROL);
outb(MULTIQ3_BP_RESET, dev->iobase + MULTIQ3_ENC_CONTROL);
@@ -236,7 +244,8 @@ 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;
diff --git a/drivers/staging/comedi/drivers/ni_6527.c b/drivers/staging/comedi/drivers/ni_6527.c
index 67adc97265bd..7a49dfce67be 100644
--- a/drivers/staging/comedi/drivers/ni_6527.c
+++ b/drivers/staging/comedi/drivers/ni_6527.c
@@ -76,7 +76,8 @@ 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_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",
@@ -93,22 +94,23 @@ 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",
+ },
};
#define n_ni6527_boards (sizeof(ni6527_boards)/sizeof(ni6527_boards[0]))
#define this_board ((const struct ni6527_board *)dev->board_ptr)
static DEFINE_PCI_DEVICE_TABLE(ni6527_pci_table) = {
- {PCI_VENDOR_ID_NATINST, 0x2b10, PCI_ANY_ID, PCI_ANY_ID, 0, 0, 0},
- {PCI_VENDOR_ID_NATINST, 0x2b20, PCI_ANY_ID, PCI_ANY_ID, 0, 0, 0},
- {0}
+ {
+ PCI_VENDOR_ID_NATINST, 0x2b10, PCI_ANY_ID, PCI_ANY_ID, 0, 0, 0}, {
+ PCI_VENDOR_ID_NATINST, 0x2b20, PCI_ANY_ID, PCI_ANY_ID, 0, 0, 0}, {
+ 0}
};
MODULE_DEVICE_TABLE(pci, ni6527_pci_table);
@@ -123,8 +125,9 @@ struct ni6527_private {
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;
@@ -141,17 +144,14 @@ static int ni6527_di_insn_config(struct comedi_device *dev, struct comedi_subdev
if (interval != devpriv->filter_interval) {
writeb(interval & 0xff,
- devpriv->mite->daq_io_addr +
- Filter_Interval(0));
+ devpriv->mite->daq_io_addr + Filter_Interval(0));
writeb((interval >> 8) & 0xff,
- devpriv->mite->daq_io_addr +
- Filter_Interval(1));
+ devpriv->mite->daq_io_addr + Filter_Interval(1));
writeb((interval >> 16) & 0x0f,
- devpriv->mite->daq_io_addr +
- Filter_Interval(2));
+ devpriv->mite->daq_io_addr + Filter_Interval(2));
writeb(ClrInterval,
- devpriv->mite->daq_io_addr + Clear_Register);
+ devpriv->mite->daq_io_addr + Clear_Register);
devpriv->filter_interval = interval;
}
@@ -162,17 +162,18 @@ static int ni6527_di_insn_config(struct comedi_device *dev, struct comedi_subdev
}
writeb(devpriv->filter_enable,
- devpriv->mite->daq_io_addr + Filter_Enable(0));
+ devpriv->mite->daq_io_addr + Filter_Enable(0));
writeb(devpriv->filter_enable >> 8,
- devpriv->mite->daq_io_addr + Filter_Enable(1));
+ devpriv->mite->daq_io_addr + Filter_Enable(1));
writeb(devpriv->filter_enable >> 16,
- devpriv->mite->daq_io_addr + Filter_Enable(2));
+ devpriv->mite->daq_io_addr + Filter_Enable(2));
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;
@@ -184,8 +185,9 @@ static int ni6527_di_insn_bits(struct comedi_device *dev, struct comedi_subdevic
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;
@@ -197,15 +199,15 @@ static int ni6527_do_insn_bits(struct comedi_device *dev, struct comedi_subdevic
* but in Comedi, it is represented by 0. */
if (data[0] & 0x0000ff) {
writeb((s->state ^ 0xff),
- devpriv->mite->daq_io_addr + Port_Register(3));
+ devpriv->mite->daq_io_addr + Port_Register(3));
}
if (data[0] & 0x00ff00) {
writeb((s->state >> 8) ^ 0xff,
- devpriv->mite->daq_io_addr + Port_Register(4));
+ devpriv->mite->daq_io_addr + Port_Register(4));
}
if (data[0] & 0xff0000) {
writeb((s->state >> 16) ^ 0xff,
- devpriv->mite->daq_io_addr + Port_Register(5));
+ devpriv->mite->daq_io_addr + Port_Register(5));
}
}
data[1] = s->state;
@@ -226,7 +228,7 @@ static irqreturn_t ni6527_interrupt(int irq, void *d)
return IRQ_NONE;
writeb(ClrEdge | ClrOverflow,
- devpriv->mite->daq_io_addr + Clear_Register);
+ devpriv->mite->daq_io_addr + Clear_Register);
comedi_buf_put(s->async, 0);
s->async->events |= COMEDI_CB_EOS;
@@ -234,8 +236,9 @@ static irqreturn_t ni6527_interrupt(int irq, void *d)
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;
@@ -310,28 +313,31 @@ static int ni6527_intr_cmdtest(struct comedi_device *dev, struct comedi_subdevic
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; */
writeb(ClrEdge | ClrOverflow,
- devpriv->mite->daq_io_addr + Clear_Register);
+ devpriv->mite->daq_io_addr + Clear_Register);
writeb(FallingEdgeIntEnable | RisingEdgeIntEnable |
- MasterInterruptEnable | EdgeIntEnable,
- devpriv->mite->daq_io_addr + Master_Interrupt_Control);
+ MasterInterruptEnable | EdgeIntEnable,
+ devpriv->mite->daq_io_addr + Master_Interrupt_Control);
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;
@@ -340,8 +346,9 @@ static int ni6527_intr_insn_bits(struct comedi_device *dev, struct comedi_subdev
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;
@@ -349,18 +356,18 @@ static int ni6527_intr_insn_config(struct comedi_device *dev, struct comedi_subd
return -EINVAL;
writeb(data[1],
- devpriv->mite->daq_io_addr + Rising_Edge_Detection_Enable(0));
+ devpriv->mite->daq_io_addr + Rising_Edge_Detection_Enable(0));
writeb(data[1] >> 8,
- devpriv->mite->daq_io_addr + Rising_Edge_Detection_Enable(1));
+ devpriv->mite->daq_io_addr + Rising_Edge_Detection_Enable(1));
writeb(data[1] >> 16,
- devpriv->mite->daq_io_addr + Rising_Edge_Detection_Enable(2));
+ devpriv->mite->daq_io_addr + Rising_Edge_Detection_Enable(2));
writeb(data[2],
- devpriv->mite->daq_io_addr + Falling_Edge_Detection_Enable(0));
+ devpriv->mite->daq_io_addr + Falling_Edge_Detection_Enable(0));
writeb(data[2] >> 8,
- devpriv->mite->daq_io_addr + Falling_Edge_Detection_Enable(1));
+ devpriv->mite->daq_io_addr + Falling_Edge_Detection_Enable(1));
writeb(data[2] >> 16,
- devpriv->mite->daq_io_addr + Falling_Edge_Detection_Enable(2));
+ devpriv->mite->daq_io_addr + Falling_Edge_Detection_Enable(2));
return 2;
}
@@ -430,7 +437,7 @@ static int ni6527_attach(struct comedi_device *dev, struct comedi_devconfig *it)
writeb(0x00, devpriv->mite->daq_io_addr + Filter_Enable(2));
writeb(ClrEdge | ClrOverflow | ClrFilter | ClrInterval,
- devpriv->mite->daq_io_addr + Clear_Register);
+ devpriv->mite->daq_io_addr + Clear_Register);
writeb(0x00, devpriv->mite->daq_io_addr + Master_Interrupt_Control);
ret = request_irq(mite_irq(devpriv->mite), ni6527_interrupt,
@@ -449,7 +456,7 @@ static int ni6527_detach(struct comedi_device *dev)
{
if (devpriv && devpriv->mite && devpriv->mite->daq_io_addr) {
writeb(0x00,
- devpriv->mite->daq_io_addr + Master_Interrupt_Control);
+ devpriv->mite->daq_io_addr + Master_Interrupt_Control);
}
if (dev->irq) {
@@ -473,7 +480,7 @@ static int ni6527_find_device(struct comedi_device *dev, int bus, int slot)
continue;
if (bus || slot) {
if (bus != mite->pcidev->bus->number ||
- slot != PCI_SLOT(mite->pcidev->devfn))
+ slot != PCI_SLOT(mite->pcidev->devfn))
continue;
}
for (i = 0; i < n_ni6527_boards; i++) {
diff --git a/drivers/staging/comedi/drivers/ni_65xx.c b/drivers/staging/comedi/drivers/ni_65xx.c
index 35708503dec3..8079c41b7338 100644
--- a/drivers/staging/comedi/drivers/ni_65xx.c
+++ b/drivers/staging/comedi/drivers/ni_65xx.c
@@ -66,18 +66,22 @@ static inline unsigned Port_Data(unsigned port)
{
return 0x40 + port * ni_65xx_port_offset;
}
+
static inline unsigned Port_Select(unsigned port)
{
return 0x41 + port * ni_65xx_port_offset;
}
+
static inline unsigned Rising_Edge_Detection_Enable(unsigned port)
{
return 0x42 + port * ni_65xx_port_offset;
}
+
static inline unsigned Falling_Edge_Detection_Enable(unsigned port)
{
return 0x43 + port * ni_65xx_port_offset;
}
+
static inline unsigned Filter_Enable(unsigned port)
{
return 0x44 + port * ni_65xx_port_offset;
@@ -103,7 +107,8 @@ 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_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",
@@ -124,161 +129,165 @@ 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,
+ },
};
#define n_ni_65xx_boards (sizeof(ni_65xx_boards)/sizeof(ni_65xx_boards[0]))
-static inline const struct ni_65xx_board *board(struct comedi_device * dev)
+static inline const struct ni_65xx_board *board(struct comedi_device *dev)
{
return dev->board_ptr;
}
+
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;
}
static DEFINE_PCI_DEVICE_TABLE(ni_65xx_pci_table) = {
- {PCI_VENDOR_ID_NATINST, 0x1710, PCI_ANY_ID, PCI_ANY_ID, 0, 0, 0},
- {PCI_VENDOR_ID_NATINST, 0x7085, PCI_ANY_ID, PCI_ANY_ID, 0, 0, 0},
- {PCI_VENDOR_ID_NATINST, 0x7086, PCI_ANY_ID, PCI_ANY_ID, 0, 0, 0},
- {PCI_VENDOR_ID_NATINST, 0x7087, PCI_ANY_ID, PCI_ANY_ID, 0, 0, 0},
- {PCI_VENDOR_ID_NATINST, 0x7088, PCI_ANY_ID, PCI_ANY_ID, 0, 0, 0},
- {PCI_VENDOR_ID_NATINST, 0x70a9, PCI_ANY_ID, PCI_ANY_ID, 0, 0, 0},
- {PCI_VENDOR_ID_NATINST, 0x70c3, PCI_ANY_ID, PCI_ANY_ID, 0, 0, 0},
- {PCI_VENDOR_ID_NATINST, 0x70c8, PCI_ANY_ID, PCI_ANY_ID, 0, 0, 0},
- {PCI_VENDOR_ID_NATINST, 0x70c9, PCI_ANY_ID, PCI_ANY_ID, 0, 0, 0},
- {PCI_VENDOR_ID_NATINST, 0x70cc, PCI_ANY_ID, PCI_ANY_ID, 0, 0, 0},
- {PCI_VENDOR_ID_NATINST, 0x70CD, PCI_ANY_ID, PCI_ANY_ID, 0, 0, 0},
- {PCI_VENDOR_ID_NATINST, 0x70d1, PCI_ANY_ID, PCI_ANY_ID, 0, 0, 0},
- {PCI_VENDOR_ID_NATINST, 0x70d2, PCI_ANY_ID, PCI_ANY_ID, 0, 0, 0},
- {PCI_VENDOR_ID_NATINST, 0x70d3, PCI_ANY_ID, PCI_ANY_ID, 0, 0, 0},
- {PCI_VENDOR_ID_NATINST, 0x7124, PCI_ANY_ID, PCI_ANY_ID, 0, 0, 0},
- {PCI_VENDOR_ID_NATINST, 0x7125, PCI_ANY_ID, PCI_ANY_ID, 0, 0, 0},
- {PCI_VENDOR_ID_NATINST, 0x7126, PCI_ANY_ID, PCI_ANY_ID, 0, 0, 0},
- {PCI_VENDOR_ID_NATINST, 0x7127, PCI_ANY_ID, PCI_ANY_ID, 0, 0, 0},
- {PCI_VENDOR_ID_NATINST, 0x7128, PCI_ANY_ID, PCI_ANY_ID, 0, 0, 0},
- {PCI_VENDOR_ID_NATINST, 0x718b, PCI_ANY_ID, PCI_ANY_ID, 0, 0, 0},
- {PCI_VENDOR_ID_NATINST, 0x718c, PCI_ANY_ID, PCI_ANY_ID, 0, 0, 0},
- {PCI_VENDOR_ID_NATINST, 0x71c5, PCI_ANY_ID, PCI_ANY_ID, 0, 0, 0},
- {0}
+ {
+ PCI_VENDOR_ID_NATINST, 0x1710, PCI_ANY_ID, PCI_ANY_ID, 0, 0, 0}, {
+ PCI_VENDOR_ID_NATINST, 0x7085, PCI_ANY_ID, PCI_ANY_ID, 0, 0, 0}, {
+ PCI_VENDOR_ID_NATINST, 0x7086, PCI_ANY_ID, PCI_ANY_ID, 0, 0, 0}, {
+ PCI_VENDOR_ID_NATINST, 0x7087, PCI_ANY_ID, PCI_ANY_ID, 0, 0, 0}, {
+ PCI_VENDOR_ID_NATINST, 0x7088, PCI_ANY_ID, PCI_ANY_ID, 0, 0, 0}, {
+ PCI_VENDOR_ID_NATINST, 0x70a9, PCI_ANY_ID, PCI_ANY_ID, 0, 0, 0}, {
+ PCI_VENDOR_ID_NATINST, 0x70c3, PCI_ANY_ID, PCI_ANY_ID, 0, 0, 0}, {
+ PCI_VENDOR_ID_NATINST, 0x70c8, PCI_ANY_ID, PCI_ANY_ID, 0, 0, 0}, {
+ PCI_VENDOR_ID_NATINST, 0x70c9, PCI_ANY_ID, PCI_ANY_ID, 0, 0, 0}, {
+ PCI_VENDOR_ID_NATINST, 0x70cc, PCI_ANY_ID, PCI_ANY_ID, 0, 0, 0}, {
+ PCI_VENDOR_ID_NATINST, 0x70CD, PCI_ANY_ID, PCI_ANY_ID, 0, 0, 0}, {
+ PCI_VENDOR_ID_NATINST, 0x70d1, PCI_ANY_ID, PCI_ANY_ID, 0, 0, 0}, {
+ PCI_VENDOR_ID_NATINST, 0x70d2, PCI_ANY_ID, PCI_ANY_ID, 0, 0, 0}, {
+ PCI_VENDOR_ID_NATINST, 0x70d3, PCI_ANY_ID, PCI_ANY_ID, 0, 0, 0}, {
+ PCI_VENDOR_ID_NATINST, 0x7124, PCI_ANY_ID, PCI_ANY_ID, 0, 0, 0}, {
+ PCI_VENDOR_ID_NATINST, 0x7125, PCI_ANY_ID, PCI_ANY_ID, 0, 0, 0}, {
+ PCI_VENDOR_ID_NATINST, 0x7126, PCI_ANY_ID, PCI_ANY_ID, 0, 0, 0}, {
+ PCI_VENDOR_ID_NATINST, 0x7127, PCI_ANY_ID, PCI_ANY_ID, 0, 0, 0}, {
+ PCI_VENDOR_ID_NATINST, 0x7128, PCI_ANY_ID, PCI_ANY_ID, 0, 0, 0}, {
+ PCI_VENDOR_ID_NATINST, 0x718b, PCI_ANY_ID, PCI_ANY_ID, 0, 0, 0}, {
+ PCI_VENDOR_ID_NATINST, 0x718c, PCI_ANY_ID, PCI_ANY_ID, 0, 0, 0}, {
+ PCI_VENDOR_ID_NATINST, 0x71c5, PCI_ANY_ID, PCI_ANY_ID, 0, 0, 0}, {
+ 0}
};
MODULE_DEVICE_TABLE(pci, ni_65xx_pci_table);
@@ -291,7 +300,7 @@ struct ni_65xx_private {
unsigned short dio_direction[NI_65XX_MAX_NUM_PORTS];
};
-static inline struct ni_65xx_private *private(struct comedi_device * dev)
+static inline struct ni_65xx_private *private(struct comedi_device *dev)
{
return dev->private;
}
@@ -300,14 +309,16 @@ struct ni_65xx_subdevice_private {
unsigned base_port;
};
-static inline struct ni_65xx_subdevice_private *sprivate(struct comedi_subdevice * subdev)
+static inline struct ni_65xx_subdevice_private *sprivate(struct comedi_subdevice
+ *subdev)
{
return subdev->private;
}
+
static struct ni_65xx_subdevice_private *ni_65xx_alloc_subdevice_private(void)
{
struct ni_65xx_subdevice_private *subdev_private =
- kzalloc(sizeof(struct ni_65xx_subdevice_private), GFP_KERNEL);
+ kzalloc(sizeof(struct ni_65xx_subdevice_private), GFP_KERNEL);
if (subdev_private == NULL)
return NULL;
return subdev_private;
@@ -315,12 +326,13 @@ static struct ni_65xx_subdevice_private *ni_65xx_alloc_subdevice_private(void)
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 =
- sprivate(s)->base_port + ni_65xx_port_by_channel(chan);
+ sprivate(s)->base_port + ni_65xx_port_by_channel(chan);
if (data[0] != INSN_CONFIG_FILTER)
return -EINVAL;
@@ -328,41 +340,42 @@ static int ni_65xx_config_filter(struct comedi_device *dev, struct comedi_subdev
static const unsigned filter_resolution_ns = 200;
static const unsigned max_filter_interval = 0xfffff;
unsigned interval =
- (data[1] +
- (filter_resolution_ns / 2)) / filter_resolution_ns;
+ (data[1] +
+ (filter_resolution_ns / 2)) / filter_resolution_ns;
if (interval > max_filter_interval)
interval = max_filter_interval;
data[1] = interval * filter_resolution_ns;
if (interval != private(dev)->filter_interval) {
writeb(interval,
- private(dev)->mite->daq_io_addr +
- Filter_Interval);
+ private(dev)->mite->daq_io_addr +
+ Filter_Interval);
private(dev)->filter_interval = interval;
}
private(dev)->filter_enable[port] |=
- 1 << (chan % ni_65xx_channels_per_port);
+ 1 << (chan % ni_65xx_channels_per_port);
} else {
private(dev)->filter_enable[port] &=
- ~(1 << (chan % ni_65xx_channels_per_port));
+ ~(1 << (chan % ni_65xx_channels_per_port));
}
writeb(private(dev)->filter_enable[port],
- private(dev)->mite->daq_io_addr + Filter_Enable(port));
+ private(dev)->mite->daq_io_addr + Filter_Enable(port));
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;
if (insn->n < 1)
return -EINVAL;
port = sprivate(s)->base_port +
- ni_65xx_port_by_channel(CR_CHAN(insn->chanspec));
+ ni_65xx_port_by_channel(CR_CHAN(insn->chanspec));
switch (data[0]) {
case INSN_CONFIG_FILTER:
return ni_65xx_config_filter(dev, s, insn, data);
@@ -393,8 +406,9 @@ static int ni_65xx_dio_insn_config(struct comedi_device *dev, struct comedi_subd
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;
@@ -405,8 +419,8 @@ static int ni_65xx_dio_insn_bits(struct comedi_device *dev, struct comedi_subdev
base_bitfield_channel = CR_CHAN(insn->chanspec);
for (j = 0; j < max_ports_per_bitfield; ++j) {
const unsigned port =
- sprivate(s)->base_port +
- ni_65xx_port_by_channel(base_bitfield_channel) + j;
+ sprivate(s)->base_port +
+ ni_65xx_port_by_channel(base_bitfield_channel) + j;
unsigned base_port_channel;
unsigned port_mask, port_data, port_read_bits;
int bitshift;
@@ -431,18 +445,17 @@ static int ni_65xx_dio_insn_bits(struct comedi_device *dev, struct comedi_subdev
unsigned bits;
private(dev)->output_bits[port] &= ~port_mask;
private(dev)->output_bits[port] |=
- port_data & port_mask;
+ port_data & port_mask;
bits = private(dev)->output_bits[port];
if (board(dev)->invert_outputs)
bits = ~bits;
writeb(bits,
- private(dev)->mite->daq_io_addr +
- Port_Data(port));
+ private(dev)->mite->daq_io_addr +
+ Port_Data(port));
/* printk("wrote 0x%x to port %i\n", bits, port); */
}
port_read_bits =
- readb(private(dev)->mite->daq_io_addr +
- Port_Data(port));
+ readb(private(dev)->mite->daq_io_addr + Port_Data(port));
/* printk("read 0x%x from port %i\n", port_read_bits, port); */
if (bitshift > 0) {
port_read_bits <<= bitshift;
@@ -468,7 +481,7 @@ static irqreturn_t ni_65xx_interrupt(int irq, void *d)
return IRQ_NONE;
writeb(ClrEdge | ClrOverflow,
- private(dev)->mite->daq_io_addr + Clear_Register);
+ private(dev)->mite->daq_io_addr + Clear_Register);
comedi_buf_put(s->async, 0);
s->async->events |= COMEDI_CB_EOS;
@@ -476,8 +489,9 @@ static irqreturn_t ni_65xx_interrupt(int irq, void *d)
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;
@@ -552,29 +566,32 @@ static int ni_65xx_intr_cmdtest(struct comedi_device *dev, struct comedi_subdevi
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; */
writeb(ClrEdge | ClrOverflow,
- private(dev)->mite->daq_io_addr + Clear_Register);
+ private(dev)->mite->daq_io_addr + Clear_Register);
writeb(FallingEdgeIntEnable | RisingEdgeIntEnable |
- MasterInterruptEnable | EdgeIntEnable,
- private(dev)->mite->daq_io_addr + Master_Interrupt_Control);
+ MasterInterruptEnable | EdgeIntEnable,
+ private(dev)->mite->daq_io_addr + Master_Interrupt_Control);
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);
+ private(dev)->mite->daq_io_addr + Master_Interrupt_Control);
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;
@@ -583,8 +600,10 @@ static int ni_65xx_intr_insn_bits(struct comedi_device *dev, struct comedi_subde
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;
@@ -592,35 +611,36 @@ static int ni_65xx_intr_insn_config(struct comedi_device *dev, struct comedi_sub
return -EINVAL;
writeb(data[1],
- private(dev)->mite->daq_io_addr +
- Rising_Edge_Detection_Enable(0));
+ private(dev)->mite->daq_io_addr +
+ Rising_Edge_Detection_Enable(0));
writeb(data[1] >> 8,
- private(dev)->mite->daq_io_addr +
- Rising_Edge_Detection_Enable(0x10));
+ private(dev)->mite->daq_io_addr +
+ Rising_Edge_Detection_Enable(0x10));
writeb(data[1] >> 16,
- private(dev)->mite->daq_io_addr +
- Rising_Edge_Detection_Enable(0x20));
+ private(dev)->mite->daq_io_addr +
+ Rising_Edge_Detection_Enable(0x20));
writeb(data[1] >> 24,
- private(dev)->mite->daq_io_addr +
- Rising_Edge_Detection_Enable(0x30));
+ private(dev)->mite->daq_io_addr +
+ Rising_Edge_Detection_Enable(0x30));
writeb(data[2],
- private(dev)->mite->daq_io_addr +
- Falling_Edge_Detection_Enable(0));
+ private(dev)->mite->daq_io_addr +
+ Falling_Edge_Detection_Enable(0));
writeb(data[2] >> 8,
- private(dev)->mite->daq_io_addr +
- Falling_Edge_Detection_Enable(0x10));
+ private(dev)->mite->daq_io_addr +
+ Falling_Edge_Detection_Enable(0x10));
writeb(data[2] >> 16,
- private(dev)->mite->daq_io_addr +
- Falling_Edge_Detection_Enable(0x20));
+ private(dev)->mite->daq_io_addr +
+ Falling_Edge_Detection_Enable(0x20));
writeb(data[2] >> 24,
- private(dev)->mite->daq_io_addr +
- Falling_Edge_Detection_Enable(0x30));
+ private(dev)->mite->daq_io_addr +
+ Falling_Edge_Detection_Enable(0x30));
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;
@@ -647,7 +667,7 @@ static int ni_65xx_attach(struct comedi_device *dev, struct comedi_devconfig *it
printk(" %s", dev->board_name);
printk(" ID=0x%02x",
- readb(private(dev)->mite->daq_io_addr + ID_Register));
+ readb(private(dev)->mite->daq_io_addr + ID_Register));
ret = alloc_subdevices(dev, 4);
if (ret < 0)
@@ -658,7 +678,7 @@ static int ni_65xx_attach(struct comedi_device *dev, struct comedi_devconfig *it
s->type = COMEDI_SUBD_DI;
s->subdev_flags = SDF_READABLE;
s->n_chan =
- board(dev)->num_di_ports * ni_65xx_channels_per_port;
+ board(dev)->num_di_ports * ni_65xx_channels_per_port;
s->range_table = &range_digital;
s->maxdata = 1;
s->insn_config = ni_65xx_dio_insn_config;
@@ -676,7 +696,7 @@ static int ni_65xx_attach(struct comedi_device *dev, struct comedi_devconfig *it
s->type = COMEDI_SUBD_DO;
s->subdev_flags = SDF_READABLE | SDF_WRITABLE;
s->n_chan =
- board(dev)->num_do_ports * ni_65xx_channels_per_port;
+ board(dev)->num_do_ports * ni_65xx_channels_per_port;
s->range_table = &range_digital;
s->maxdata = 1;
s->insn_bits = ni_65xx_dio_insn_bits;
@@ -693,7 +713,7 @@ static int ni_65xx_attach(struct comedi_device *dev, struct comedi_devconfig *it
s->type = COMEDI_SUBD_DIO;
s->subdev_flags = SDF_READABLE | SDF_WRITABLE;
s->n_chan =
- board(dev)->num_dio_ports * ni_65xx_channels_per_port;
+ board(dev)->num_dio_ports * ni_65xx_channels_per_port;
s->range_table = &range_digital;
s->maxdata = 1;
s->insn_config = ni_65xx_dio_insn_config;
@@ -705,8 +725,8 @@ static int ni_65xx_attach(struct comedi_device *dev, struct comedi_devconfig *it
for (i = 0; i < board(dev)->num_dio_ports; ++i) {
/* configure all ports for input */
writeb(0x1,
- private(dev)->mite->daq_io_addr +
- Port_Select(i));
+ private(dev)->mite->daq_io_addr +
+ Port_Select(i));
}
} else {
s->type = COMEDI_SUBD_UNUSED;
@@ -727,18 +747,18 @@ static int ni_65xx_attach(struct comedi_device *dev, struct comedi_devconfig *it
for (i = 0; i < ni_65xx_total_num_ports(board(dev)); ++i) {
writeb(0x00,
- private(dev)->mite->daq_io_addr + Filter_Enable(i));
+ private(dev)->mite->daq_io_addr + Filter_Enable(i));
if (board(dev)->invert_outputs)
writeb(0x01,
- private(dev)->mite->daq_io_addr + Port_Data(i));
+ private(dev)->mite->daq_io_addr + Port_Data(i));
else
writeb(0x00,
- private(dev)->mite->daq_io_addr + Port_Data(i));
+ private(dev)->mite->daq_io_addr + Port_Data(i));
}
writeb(ClrEdge | ClrOverflow,
- private(dev)->mite->daq_io_addr + Clear_Register);
+ private(dev)->mite->daq_io_addr + Clear_Register);
writeb(0x00,
- private(dev)->mite->daq_io_addr + Master_Interrupt_Control);
+ private(dev)->mite->daq_io_addr + Master_Interrupt_Control);
/* Set filter interval to 0 (32bit reg) */
writeb(0x00000000, private(dev)->mite->daq_io_addr + Filter_Interval);
@@ -758,10 +778,10 @@ static int ni_65xx_attach(struct comedi_device *dev, struct comedi_devconfig *it
static int ni_65xx_detach(struct comedi_device *dev)
{
if (private(dev) && private(dev)->mite
- && private(dev)->mite->daq_io_addr) {
+ && private(dev)->mite->daq_io_addr) {
writeb(0x00,
- private(dev)->mite->daq_io_addr +
- Master_Interrupt_Control);
+ private(dev)->mite->daq_io_addr +
+ Master_Interrupt_Control);
}
if (dev->irq) {
@@ -793,7 +813,7 @@ static int ni_65xx_find_device(struct comedi_device *dev, int bus, int slot)
continue;
if (bus || slot) {
if (bus != mite->pcidev->bus->number ||
- slot != PCI_SLOT(mite->pcidev->devfn))
+ slot != PCI_SLOT(mite->pcidev->devfn))
continue;
}
for (i = 0; i < n_ni_65xx_boards; i++) {
diff --git a/drivers/staging/comedi/drivers/ni_660x.c b/drivers/staging/comedi/drivers/ni_660x.c
index 11e9b0411805..772c9372e435 100644
--- a/drivers/staging/comedi/drivers/ni_660x.c
+++ b/drivers/staging/comedi/drivers/ni_660x.c
@@ -201,7 +201,6 @@ struct NI_660xRegisterData {
enum ni_660x_register_width size; /* 1 byte, 2 bytes, or 4 bytes */
};
-
static const struct NI_660xRegisterData registerData[NumRegisters] = {
{"G0 Interrupt Acknowledge", 0x004, NI_660x_WRITE, DATA_2B},
{"G0 Status Register", 0x004, NI_660x_READ, DATA_2B},
@@ -316,21 +315,25 @@ static inline unsigned ioconfig_bitshift(unsigned pfi_channel)
else
return 8;
}
+
static inline unsigned pfi_output_select_mask(unsigned pfi_channel)
{
return 0x3 << ioconfig_bitshift(pfi_channel);
}
+
static inline unsigned pfi_output_select_bits(unsigned pfi_channel,
- unsigned output_select)
+ unsigned output_select)
{
return (output_select & 0x3) << ioconfig_bitshift(pfi_channel);
}
+
static inline unsigned pfi_input_select_mask(unsigned pfi_channel)
{
return 0x7 << (4 + ioconfig_bitshift(pfi_channel));
}
+
static inline unsigned pfi_input_select_bits(unsigned pfi_channel,
- unsigned input_select)
+ unsigned input_select)
{
return (input_select & 0x7) << (4 + ioconfig_bitshift(pfi_channel));
}
@@ -341,6 +344,7 @@ static inline unsigned dma_select_mask(unsigned dma_channel)
BUG_ON(dma_channel >= MAX_DMA_CHANNEL);
return 0x1f << (8 * dma_channel);
}
+
enum dma_selection {
dma_selection_none = 0x1f,
};
@@ -349,11 +353,13 @@ static inline unsigned dma_selection_counter(unsigned counter_index)
BUG_ON(counter_index >= counters_per_chip);
return counter_index;
}
+
static inline unsigned dma_select_bits(unsigned dma_channel, unsigned selection)
{
BUG_ON(dma_channel >= MAX_DMA_CHANNEL);
return (selection << (8 * dma_channel)) & dma_select_mask(dma_channel);
}
+
static inline unsigned dma_reset_bit(unsigned dma_channel)
{
BUG_ON(dma_channel >= MAX_DMA_CHANNEL);
@@ -388,36 +394,37 @@ 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,
+ },
};
#define NI_660X_MAX_NUM_CHIPS 2
#define NI_660X_MAX_NUM_COUNTERS (NI_660X_MAX_NUM_CHIPS * counters_per_chip)
static DEFINE_PCI_DEVICE_TABLE(ni_660x_pci_table) = {
- {PCI_VENDOR_ID_NATINST, 0x2c60, PCI_ANY_ID, PCI_ANY_ID, 0, 0, 0},
- {PCI_VENDOR_ID_NATINST, 0x1310, PCI_ANY_ID, PCI_ANY_ID, 0, 0, 0},
- {PCI_VENDOR_ID_NATINST, 0x1360, PCI_ANY_ID, PCI_ANY_ID, 0, 0, 0},
- {PCI_VENDOR_ID_NATINST, 0x2cc0, PCI_ANY_ID, PCI_ANY_ID, 0, 0, 0},
- {0}
+ {
+ PCI_VENDOR_ID_NATINST, 0x2c60, PCI_ANY_ID, PCI_ANY_ID, 0, 0, 0}, {
+ PCI_VENDOR_ID_NATINST, 0x1310, PCI_ANY_ID, PCI_ANY_ID, 0, 0, 0}, {
+ PCI_VENDOR_ID_NATINST, 0x1360, PCI_ANY_ID, PCI_ANY_ID, 0, 0, 0}, {
+ PCI_VENDOR_ID_NATINST, 0x2cc0, PCI_ANY_ID, PCI_ANY_ID, 0, 0, 0}, {
+ 0}
};
MODULE_DEVICE_TABLE(pci, ni_660x_pci_table);
@@ -436,24 +443,26 @@ struct ni_660x_private {
unsigned short pfi_output_selects[NUM_PFI_CHANNELS];
};
-static inline struct ni_660x_private *private(struct comedi_device * dev)
+static inline struct ni_660x_private *private(struct comedi_device *dev)
{
return dev->private;
}
/* initialized in ni_660x_find_device() */
-static inline const struct ni_660x_board *board(struct comedi_device * dev)
+static inline const struct ni_660x_board *board(struct comedi_device *dev)
{
return dev->board_ptr;
}
#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_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 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",
@@ -466,21 +475,28 @@ 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,
- unsigned source);
+ 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);
+ 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);
+ 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);
+ 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);
+ 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);
+ struct comedi_subdevice *s,
+ struct comedi_insn *insn, unsigned int *data);
static inline unsigned ni_660x_num_counters(struct comedi_device *dev)
{
@@ -697,7 +713,7 @@ static enum NI_660x_Register ni_gpct_to_660x_register(enum ni_gpct_register reg)
break;
default:
printk("%s: unhandled register 0x%x in switch.\n",
- __func__, reg);
+ __func__, reg);
BUG();
return 0;
break;
@@ -706,11 +722,12 @@ static enum NI_660x_Register ni_gpct_to_660x_register(enum ni_gpct_register reg)
}
static inline void ni_660x_write_register(struct comedi_device *dev,
- unsigned chip_index, unsigned bits, enum NI_660x_Register reg)
+ unsigned chip_index, unsigned bits,
+ enum NI_660x_Register reg)
{
void *const write_address =
- private(dev)->mite->daq_io_addr + GPCT_OFFSET[chip_index] +
- registerData[reg].offset;
+ private(dev)->mite->daq_io_addr + GPCT_OFFSET[chip_index] +
+ registerData[reg].offset;
switch (registerData[reg].size) {
case DATA_2B:
@@ -721,18 +738,19 @@ static inline void ni_660x_write_register(struct comedi_device *dev,
break;
default:
printk("%s: %s: bug! unhandled case (reg=0x%x) in switch.\n",
- __FILE__, __func__, reg);
+ __FILE__, __func__, reg);
BUG();
break;
}
}
static inline unsigned ni_660x_read_register(struct comedi_device *dev,
- unsigned chip_index, enum NI_660x_Register reg)
+ unsigned chip_index,
+ enum NI_660x_Register reg)
{
void *const read_address =
- private(dev)->mite->daq_io_addr + GPCT_OFFSET[chip_index] +
- registerData[reg].offset;
+ private(dev)->mite->daq_io_addr + GPCT_OFFSET[chip_index] +
+ registerData[reg].offset;
switch (registerData[reg].size) {
case DATA_2B:
@@ -743,7 +761,7 @@ static inline unsigned ni_660x_read_register(struct comedi_device *dev,
break;
default:
printk("%s: %s: bug! unhandled case (reg=0x%x) in switch.\n",
- __FILE__, __func__, reg);
+ __FILE__, __func__, reg);
BUG();
break;
}
@@ -751,65 +769,72 @@ static inline unsigned ni_660x_read_register(struct comedi_device *dev,
}
static void ni_gpct_write_register(struct ni_gpct *counter, unsigned bits,
- enum ni_gpct_register reg)
+ enum ni_gpct_register reg)
{
struct comedi_device *dev = counter->counter_dev->dev;
enum NI_660x_Register ni_660x_register = ni_gpct_to_660x_register(reg);
ni_660x_write_register(dev, counter->chip_index, bits,
- ni_660x_register);
+ ni_660x_register);
}
static unsigned ni_gpct_read_register(struct ni_gpct *counter,
- enum ni_gpct_register reg)
+ enum ni_gpct_register reg)
{
struct comedi_device *dev = counter->counter_dev->dev;
enum NI_660x_Register ni_660x_register = ni_gpct_to_660x_register(reg);
return ni_660x_read_register(dev, counter->chip_index,
- ni_660x_register);
+ ni_660x_register);
}
-static inline struct mite_dma_descriptor_ring *mite_ring(struct ni_660x_private * priv,
- struct ni_gpct *counter)
+static inline struct mite_dma_descriptor_ring *mite_ring(struct ni_660x_private
+ *priv,
+ struct ni_gpct
+ *counter)
{
return priv->mite_rings[counter->chip_index][counter->counter_index];
}
static inline void ni_660x_set_dma_channel(struct comedi_device *dev,
- unsigned mite_channel, struct ni_gpct *counter)
+ unsigned mite_channel,
+ struct ni_gpct *counter)
{
unsigned long 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);
+ ~dma_select_mask(mite_channel);
private(dev)->dma_configuration_soft_copies[counter->chip_index] |=
- dma_select_bits(mite_channel,
- dma_selection_counter(counter->counter_index));
+ dma_select_bits(mite_channel,
+ dma_selection_counter(counter->counter_index));
ni_660x_write_register(dev, counter->chip_index,
- private(dev)->dma_configuration_soft_copies[counter->
- chip_index] | dma_reset_bit(mite_channel),
- DMAConfigRegister);
+ private(dev)->
+ dma_configuration_soft_copies
+ [counter->chip_index] |
+ dma_reset_bit(mite_channel), DMAConfigRegister);
mmiowb();
spin_unlock_irqrestore(&private(dev)->soft_reg_copy_lock, flags);
}
static inline void ni_660x_unset_dma_channel(struct comedi_device *dev,
- unsigned mite_channel, struct ni_gpct *counter)
+ unsigned mite_channel,
+ struct ni_gpct *counter)
{
unsigned long 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);
+ ~dma_select_mask(mite_channel);
private(dev)->dma_configuration_soft_copies[counter->chip_index] |=
- dma_select_bits(mite_channel, dma_selection_none);
+ dma_select_bits(mite_channel, dma_selection_none);
ni_660x_write_register(dev, counter->chip_index,
- private(dev)->dma_configuration_soft_copies[counter->
- chip_index], DMAConfigRegister);
+ private(dev)->
+ dma_configuration_soft_copies
+ [counter->chip_index], DMAConfigRegister);
mmiowb();
spin_unlock_irqrestore(&private(dev)->soft_reg_copy_lock, flags);
}
static int ni_660x_request_mite_channel(struct comedi_device *dev,
- struct ni_gpct *counter, enum comedi_io_direction direction)
+ struct ni_gpct *counter,
+ enum comedi_io_direction direction)
{
unsigned long flags;
struct mite_channel *mite_chan;
@@ -817,13 +842,12 @@ static int ni_660x_request_mite_channel(struct comedi_device *dev,
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));
+ mite_request_channel(private(dev)->mite, mite_ring(private(dev),
+ counter));
if (mite_chan == NULL) {
- spin_unlock_irqrestore(&private(dev)->mite_channel_lock,
- flags);
+ spin_unlock_irqrestore(&private(dev)->mite_channel_lock, flags);
comedi_error(dev,
- "failed to reserve mite dma channel for counter.");
+ "failed to reserve mite dma channel for counter.");
return -EBUSY;
}
mite_chan->dir = direction;
@@ -833,7 +857,8 @@ static int ni_660x_request_mite_channel(struct comedi_device *dev,
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;
@@ -858,7 +883,7 @@ static int ni_660x_cmd(struct comedi_device *dev, struct comedi_subdevice *s)
retval = ni_660x_request_mite_channel(dev, counter, COMEDI_INPUT);
if (retval) {
comedi_error(dev,
- "no dma channel available for use by counter");
+ "no dma channel available for use by counter");
return retval;
}
ni_tio_acknowledge_and_confirm(counter, NULL, NULL, NULL, NULL);
@@ -867,8 +892,8 @@ 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);
@@ -893,19 +918,18 @@ static void set_tio_counterswap(struct comedi_device *dev, int chipset)
*/
if (chipset)
ni_660x_write_register(dev, chipset, CounterSwap,
- ClockConfigRegister);
+ ClockConfigRegister);
else
ni_660x_write_register(dev, chipset, 0, ClockConfigRegister);
}
static void ni_660x_handle_gpct_interrupt(struct comedi_device *dev,
- struct comedi_subdevice *s)
+ struct comedi_subdevice *s)
{
ni_tio_handle_interrupt(subdev_to_counter(s), s);
if (s->async->events) {
- if (s->async->
- events & (COMEDI_CB_EOA | COMEDI_CB_ERROR |
- COMEDI_CB_OVERFLOW)) {
+ if (s->async->events & (COMEDI_CB_EOA | COMEDI_CB_ERROR |
+ COMEDI_CB_OVERFLOW)) {
ni_660x_cancel(dev, s);
}
comedi_event(dev, s);
@@ -943,13 +967,14 @@ static int ni_660x_input_poll(struct comedi_device *dev,
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)
+static int ni_660x_buf_change(struct comedi_device *dev,
+ struct comedi_subdevice *s,
+ unsigned long new_size)
{
int ret;
ret = mite_buf_change(mite_ring(private(dev), subdev_to_counter(s)),
- s->async);
+ s->async);
if (ret < 0)
return ret;
@@ -982,7 +1007,7 @@ static int ni_660x_alloc_mite_rings(struct comedi_device *dev)
for (i = 0; i < board(dev)->n_chips; ++i) {
for (j = 0; j < counters_per_chip; ++j) {
private(dev)->mite_rings[i][j] =
- mite_alloc_ring(private(dev)->mite);
+ mite_alloc_ring(private(dev)->mite);
if (private(dev)->mite_rings[i][j] == NULL) {
return -ENOMEM;
}
@@ -1003,7 +1028,8 @@ 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;
@@ -1056,8 +1082,11 @@ static int ni_660x_attach(struct comedi_device *dev, struct comedi_devconfig *it
ni_660x_write_register(dev, 0, 0, STCDIOControl);
private(dev)->counter_dev = ni_gpct_device_construct(dev,
- &ni_gpct_write_register, &ni_gpct_read_register,
- ni_gpct_variant_660x, ni_660x_num_counters(dev));
+ &ni_gpct_write_register,
+ &ni_gpct_read_register,
+ ni_gpct_variant_660x,
+ ni_660x_num_counters
+ (dev));
if (private(dev)->counter_dev == NULL)
return -ENOMEM;
for (i = 0; i < NI_660X_MAX_NUM_COUNTERS; ++i) {
@@ -1065,8 +1094,8 @@ static int ni_660x_attach(struct comedi_device *dev, struct comedi_devconfig *it
if (i < ni_660x_num_counters(dev)) {
s->type = COMEDI_SUBD_COUNTER;
s->subdev_flags =
- SDF_READABLE | SDF_WRITABLE | SDF_LSAMPL |
- SDF_CMD_READ /* | SDF_CMD_WRITE */ ;
+ SDF_READABLE | SDF_WRITABLE | SDF_LSAMPL |
+ SDF_CMD_READ /* | SDF_CMD_WRITE */ ;
s->n_chan = 3;
s->maxdata = 0xffffffff;
s->insn_read = ni_660x_GPCT_rinsn;
@@ -1082,9 +1111,9 @@ static int ni_660x_attach(struct comedi_device *dev, struct comedi_devconfig *it
s->private = &private(dev)->counter_dev->counters[i];
private(dev)->counter_dev->counters[i].chip_index =
- i / counters_per_chip;
+ i / counters_per_chip;
private(dev)->counter_dev->counters[i].counter_index =
- i % counters_per_chip;
+ i % counters_per_chip;
} else {
s->type = COMEDI_SUBD_UNUSED;
}
@@ -1100,7 +1129,7 @@ static int ni_660x_attach(struct comedi_device *dev, struct comedi_devconfig *it
ni_660x_set_pfi_routing(dev, i, pfi_output_select_do);
else
ni_660x_set_pfi_routing(dev, i,
- pfi_output_select_counter);
+ pfi_output_select_counter);
ni_660x_select_pfi_output(dev, i, pfi_output_select_high_Z);
}
/* to be safe, set counterswap bits on tio chips after all the counter
@@ -1119,7 +1148,7 @@ static int ni_660x_attach(struct comedi_device *dev, struct comedi_devconfig *it
if (board(dev)->n_chips > 1)
global_interrupt_config_bits |= Cascade_Int_Enable_Bit;
ni_660x_write_register(dev, 0, global_interrupt_config_bits,
- GlobalInterruptConfigRegister);
+ GlobalInterruptConfigRegister);
printk("attached\n");
return 0;
}
@@ -1145,7 +1174,7 @@ 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)
+ struct comedi_insn *insn, unsigned int *data)
{
return ni_tio_rinsn(subdev_to_counter(s), insn, data);
}
@@ -1158,27 +1187,27 @@ static void init_tio_chip(struct comedi_device *dev, int chipset)
private(dev)->dma_configuration_soft_copies[chipset] = 0;
for (i = 0; i < MAX_DMA_CHANNEL; ++i) {
private(dev)->dma_configuration_soft_copies[chipset] |=
- dma_select_bits(i,
- dma_selection_none) & dma_select_mask(i);
+ dma_select_bits(i, dma_selection_none) & dma_select_mask(i);
}
ni_660x_write_register(dev, chipset,
- private(dev)->dma_configuration_soft_copies[chipset],
- DMAConfigRegister);
- for (i = 0; i < NUM_PFI_CHANNELS; ++i)
- {
+ private(dev)->
+ dma_configuration_soft_copies[chipset],
+ DMAConfigRegister);
+ 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)
+ 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)
+ struct comedi_subdevice *s,
+ struct comedi_insn *insn, unsigned int *data)
{
return ni_tio_winsn(subdev_to_counter(s), insn, data);
}
@@ -1193,7 +1222,7 @@ static int ni_660x_find_device(struct comedi_device *dev, int bus, int slot)
continue;
if (bus || slot) {
if (bus != mite->pcidev->bus->number ||
- slot != PCI_SLOT(mite->pcidev->devfn))
+ slot != PCI_SLOT(mite->pcidev->devfn))
continue;
}
@@ -1211,7 +1240,8 @@ static int ni_660x_find_device(struct comedi_device *dev, int bus, int slot)
}
static int ni_660x_dio_insn_bits(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)
{
unsigned base_bitfield_channel = CR_CHAN(insn->chanspec);
@@ -1225,13 +1255,14 @@ static int ni_660x_dio_insn_bits(struct comedi_device *dev,
/* on return, data[1] contains the value of the digital
* input and output lines. */
data[1] =
- (ni_660x_read_register(dev, 0,
- DIO32Input) >> base_bitfield_channel);
+ (ni_660x_read_register(dev, 0,
+ DIO32Input) >> base_bitfield_channel);
return 2;
}
-static void ni_660x_select_pfi_output(struct comedi_device *dev, unsigned pfi_channel,
- unsigned output_select)
+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;
static const unsigned counter_4_7_last_pfi = 23;
@@ -1240,33 +1271,41 @@ static void ni_660x_select_pfi_output(struct comedi_device *dev, unsigned pfi_ch
unsigned active_bits;
unsigned idle_bits;
- if (board (dev)->n_chips > 1) {
+ 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) {
+ pfi_channel >= counter_4_7_first_pfi &&
+ pfi_channel <= counter_4_7_last_pfi) {
active_chipset = 1;
idle_chipset = 0;
- }else {
+ } else {
active_chipset = 0;
idle_chipset = 1;
}
}
if (idle_chipset != active_chipset) {
- idle_bits = ni_660x_read_register(dev, idle_chipset, IOConfigReg(pfi_channel));
+ 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);
- ni_660x_write_register(dev, idle_chipset, idle_bits, IOConfigReg(pfi_channel));
+ idle_bits |=
+ pfi_output_select_bits(pfi_channel,
+ pfi_output_select_high_Z);
+ ni_660x_write_register(dev, idle_chipset, idle_bits,
+ IOConfigReg(pfi_channel));
}
- active_bits = ni_660x_read_register(dev, active_chipset, IOConfigReg(pfi_channel));
+ active_bits =
+ ni_660x_read_register(dev, active_chipset,
+ IOConfigReg(pfi_channel));
active_bits &= ~pfi_output_select_mask(pfi_channel);
active_bits |= pfi_output_select_bits(pfi_channel, output_select);
- ni_660x_write_register(dev, active_chipset, active_bits, IOConfigReg(pfi_channel));
+ 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,
- unsigned source)
+ unsigned source)
{
if (source > num_pfi_output_selects)
return -EINVAL;
@@ -1284,18 +1323,21 @@ static int ni_660x_set_pfi_routing(struct comedi_device *dev, unsigned chan,
private(dev)->pfi_output_selects[chan] = source;
if (private(dev)->pfi_direction_bits & (((uint64_t) 1) << chan))
ni_660x_select_pfi_output(dev, chan,
- private(dev)->pfi_output_selects[chan]);
+ private(dev)->
+ pfi_output_selects[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,
- enum ni_gpct_filter_select filter)
+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));
bits &= ~pfi_input_select_mask(pfi_channel);
@@ -1304,7 +1346,8 @@ static void ni660x_config_filter(struct comedi_device *dev, unsigned pfi_channel
}
static int ni_660x_dio_insn_config(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)
{
int chan = CR_CHAN(insn->chanspec);
@@ -1317,7 +1360,8 @@ static int ni_660x_dio_insn_config(struct comedi_device *dev,
case INSN_CONFIG_DIO_OUTPUT:
private(dev)->pfi_direction_bits |= ((uint64_t) 1) << chan;
ni_660x_select_pfi_output(dev, chan,
- private(dev)->pfi_output_selects[chan]);
+ private(dev)->
+ pfi_output_selects[chan]);
break;
case INSN_CONFIG_DIO_INPUT:
private(dev)->pfi_direction_bits &= ~(((uint64_t) 1) << chan);
@@ -1325,9 +1369,8 @@ static int ni_660x_dio_insn_config(struct comedi_device *dev,
break;
case INSN_CONFIG_DIO_QUERY:
data[1] =
- (private(dev)->
- pfi_direction_bits & (((uint64_t) 1) << chan)) ?
- COMEDI_OUTPUT : COMEDI_INPUT;
+ (private(dev)->pfi_direction_bits &
+ (((uint64_t) 1) << chan)) ? COMEDI_OUTPUT : COMEDI_INPUT;
return 0;
case INSN_CONFIG_SET_ROUTING:
return ni_660x_set_pfi_routing(dev, chan, data[1]);
diff --git a/drivers/staging/comedi/drivers/ni_670x.c b/drivers/staging/comedi/drivers/ni_670x.c
index 71f7d3ab3aa1..89ce5b873ffe 100644
--- a/drivers/staging/comedi/drivers/ni_670x.c
+++ b/drivers/staging/comedi/drivers/ni_670x.c
@@ -70,30 +70,32 @@ 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 }, */
- {0}
+ {
+ 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 }, */
+ {
+ 0}
};
MODULE_DEVICE_TABLE(pci, ni_670x_pci_table);
@@ -108,11 +110,11 @@ struct ni_670x_private {
unsigned int ao_readback[32];
};
-
#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_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 = {
@@ -128,16 +130,22 @@ 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_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_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)
{
struct comedi_subdevice *s;
int ret;
@@ -175,7 +183,7 @@ static int ni_670x_attach(struct comedi_device *dev, struct comedi_devconfig *it
const struct comedi_lrange **range_table_list;
range_table_list = kmalloc(sizeof(struct comedi_lrange *) * 32,
- GFP_KERNEL);
+ GFP_KERNEL);
if (!range_table_list)
return -ENOMEM;
s->range_table_list = range_table_list;
@@ -223,8 +231,9 @@ static int ni_670x_detach(struct comedi_device *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);
@@ -249,8 +258,9 @@ 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);
@@ -261,8 +271,9 @@ 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;
@@ -273,7 +284,7 @@ static int ni_670x_dio_insn_bits(struct comedi_device *dev, struct comedi_subdev
s->state &= ~data[0];
s->state |= data[0] & data[1];
writel(s->state,
- devpriv->mite->daq_io_addr + DIO_PORT0_DATA_OFFSET);
+ devpriv->mite->daq_io_addr + DIO_PORT0_DATA_OFFSET);
}
/* on return, data[1] contains the value of the digital
@@ -283,8 +294,9 @@ static int ni_670x_dio_insn_bits(struct comedi_device *dev, struct comedi_subdev
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);
@@ -297,8 +309,7 @@ static int ni_670x_dio_insn_config(struct comedi_device *dev, struct comedi_subd
break;
case INSN_CONFIG_DIO_QUERY:
data[1] =
- (s->
- io_bits & (1 << chan)) ? COMEDI_OUTPUT : COMEDI_INPUT;
+ (s->io_bits & (1 << chan)) ? COMEDI_OUTPUT : COMEDI_INPUT;
return insn->n;
break;
default:
@@ -320,7 +331,7 @@ static int ni_670x_find_device(struct comedi_device *dev, int bus, int slot)
continue;
if (bus || slot) {
if (bus != mite->pcidev->bus->number
- || slot != PCI_SLOT(mite->pcidev->devfn))
+ || slot != PCI_SLOT(mite->pcidev->devfn))
continue;
}
diff --git a/drivers/staging/comedi/drivers/ni_at_a2150.c b/drivers/staging/comedi/drivers/ni_at_a2150.c
index 45c6809031db..dd75dfb34309 100644
--- a/drivers/staging/comedi/drivers/ni_at_a2150.c
+++ b/drivers/staging/comedi/drivers/ni_at_a2150.c
@@ -131,25 +131,25 @@ struct a2150_board {
static const struct comedi_lrange range_a2150 = {
1,
{
- RANGE(-2.828, 2.828),
- }
+ RANGE(-2.828, 2.828),
+ }
};
/* 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,
+ },
};
/*
@@ -167,7 +167,6 @@ struct a2150_private {
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);
@@ -182,16 +181,17 @@ static struct comedi_driver driver_a2150 = {
};
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_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);
+ struct comedi_insn *insn, unsigned int *data);
static int a2150_get_timing(struct comedi_device *dev, unsigned int *period,
- int flags);
+ int flags);
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);
+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(),
* as necessary.
@@ -335,7 +335,7 @@ static int a2150_attach(struct comedi_device *dev, struct comedi_devconfig *it)
int i;
printk("comedi%d: %s: io 0x%lx", dev->minor, driver_a2150.driver_name,
- iobase);
+ iobase);
if (irq) {
printk(", irq %u", irq);
} else {
@@ -391,7 +391,7 @@ static int a2150_attach(struct comedi_device *dev, struct comedi_devconfig *it)
}
devpriv->dma = dma;
devpriv->dma_buffer =
- kmalloc(A2150_DMA_BUFFER_SIZE, GFP_KERNEL | GFP_DMA);
+ kmalloc(A2150_DMA_BUFFER_SIZE, GFP_KERNEL | GFP_DMA);
if (devpriv->dma_buffer == NULL)
return -ENOMEM;
@@ -441,7 +441,8 @@ static int a2150_attach(struct comedi_device *dev, struct comedi_devconfig *it)
udelay(1000);
}
if (i == timeout) {
- printk(" timed out waiting for offset calibration to complete\n");
+ printk
+ (" timed out waiting for offset calibration to complete\n");
return -ETIME;
}
devpriv->config_bits |= ENABLE0_BIT | ENABLE1_BIT;
@@ -488,8 +489,8 @@ static int a2150_cancel(struct comedi_device *dev, struct comedi_subdevice *s)
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;
@@ -589,25 +590,24 @@ static int a2150_ai_cmdtest(struct comedi_device *dev, struct comedi_subdevice *
for (i = 1; i < cmd->chanlist_len; i++) {
if (CR_CHAN(cmd->chanlist[i]) != (startChan + i)) {
comedi_error(dev,
- "entries in chanlist must be consecutive channels, counting upwards\n");
+ "entries in chanlist must be consecutive channels, counting upwards\n");
err++;
}
}
if (cmd->chanlist_len == 2 && CR_CHAN(cmd->chanlist[0]) == 1) {
comedi_error(dev,
- "length 2 chanlist must be channels 0,1 or channels 2,3");
+ "length 2 chanlist must be channels 0,1 or channels 2,3");
err++;
}
if (cmd->chanlist_len == 3) {
comedi_error(dev,
- "chanlist must have 1,2 or 4 channels");
+ "chanlist must have 1,2 or 4 channels");
err++;
}
if (CR_AREF(cmd->chanlist[0]) != CR_AREF(cmd->chanlist[1]) ||
- CR_AREF(cmd->chanlist[2]) != CR_AREF(cmd->chanlist[3]))
- {
+ CR_AREF(cmd->chanlist[2]) != CR_AREF(cmd->chanlist[3])) {
comedi_error(dev,
- "channels 0/1 and 2/3 must have the same analog reference");
+ "channels 0/1 and 2/3 must have the same analog reference");
err++;
}
}
@@ -628,12 +628,12 @@ static int a2150_ai_cmd(struct comedi_device *dev, struct comedi_subdevice *s)
if (!dev->irq || !devpriv->dma) {
comedi_error(dev,
- " irq and dma required, cannot do hardware conversions");
+ " irq and dma required, cannot do hardware conversions");
return -1;
}
if (cmd->flags & TRIG_RT) {
comedi_error(dev,
- " dma incompatible with hard real-time interrupt (TRIG_RT), aborting");
+ " dma incompatible with hard real-time interrupt (TRIG_RT), aborting");
return -1;
}
/* clear fifo and reset triggering circuitry */
@@ -641,7 +641,7 @@ static int a2150_ai_cmd(struct comedi_device *dev, struct comedi_subdevice *s)
/* setup chanlist */
if (a2150_set_chanlist(dev, CR_CHAN(cmd->chanlist[0]),
- cmd->chanlist_len) < 0)
+ cmd->chanlist_len) < 0)
return -1;
/* setup ac/dc coupling */
@@ -673,14 +673,14 @@ static int a2150_ai_cmd(struct comedi_device *dev, struct comedi_subdevice *s)
/* 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 *
- ONE_THIRD_SECOND / cmd->scan_begin_arg;
+ sizeof(devpriv->dma_buffer[0]) * cmd->chanlist_len *
+ ONE_THIRD_SECOND / cmd->scan_begin_arg;
if (devpriv->dma_transfer_size > A2150_DMA_BUFFER_SIZE)
devpriv->dma_transfer_size = A2150_DMA_BUFFER_SIZE;
if (devpriv->dma_transfer_size < sizeof(devpriv->dma_buffer[0]))
devpriv->dma_transfer_size = sizeof(devpriv->dma_buffer[0]);
devpriv->dma_transfer_size -=
- devpriv->dma_transfer_size % sizeof(devpriv->dma_buffer[0]);
+ devpriv->dma_transfer_size % sizeof(devpriv->dma_buffer[0]);
set_dma_count(devpriv->dma, devpriv->dma_transfer_size);
enable_dma(devpriv->dma);
release_dma_lock(lock_flags);
@@ -700,8 +700,8 @@ static int a2150_ai_cmd(struct comedi_device *dev, struct comedi_subdevice *s)
trigger_bits = 0;
/* 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)) {
+ (old_config_bits & CLOCK_MASK) !=
+ (devpriv->config_bits & CLOCK_MASK)) {
/* set trigger source to delay trigger */
trigger_bits |= DELAY_TRIGGER_BITS;
} else {
@@ -730,7 +730,7 @@ 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)
+ struct comedi_insn *insn, unsigned int *data)
{
unsigned int i, n;
static const int timeout = 100000;
@@ -804,7 +804,7 @@ static int a2150_ai_rinsn(struct comedi_device *dev, struct comedi_subdevice *s,
/* 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,
- int flags)
+ int flags)
{
int lub, glb, temp;
int lub_divisor_shift, lub_index, glb_divisor_shift, glb_index;
@@ -866,19 +866,20 @@ static int a2150_get_timing(struct comedi_device *dev, unsigned int *period,
devpriv->config_bits &= ~CLOCK_MASK;
if (*period == lub) {
devpriv->config_bits |=
- CLOCK_SELECT_BITS(lub_index) |
- CLOCK_DIVISOR_BITS(lub_divisor_shift);
+ CLOCK_SELECT_BITS(lub_index) |
+ CLOCK_DIVISOR_BITS(lub_divisor_shift);
} else {
devpriv->config_bits |=
- CLOCK_SELECT_BITS(glb_index) |
- CLOCK_DIVISOR_BITS(glb_divisor_shift);
+ CLOCK_SELECT_BITS(glb_index) |
+ CLOCK_DIVISOR_BITS(glb_divisor_shift);
}
return 0;
}
-static int a2150_set_chanlist(struct comedi_device *dev, unsigned int start_channel,
- unsigned int num_channels)
+static int a2150_set_chanlist(struct comedi_device *dev,
+ unsigned int start_channel,
+ unsigned int num_channels)
{
if (start_channel + num_channels > 4)
return -1;
diff --git a/drivers/staging/comedi/drivers/ni_at_ao.c b/drivers/staging/comedi/drivers/ni_at_ao.c
index 4e8bf9ed167c..8adb23739846 100644
--- a/drivers/staging/comedi/drivers/ni_at_ao.c
+++ b/drivers/staging/comedi/drivers/ni_at_ao.c
@@ -158,13 +158,13 @@ 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,
+ },
};
#define thisboard ((struct atao_board *)dev->board_ptr)
@@ -198,17 +198,21 @@ 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);
+ 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);
+ 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)
{
@@ -324,7 +328,7 @@ 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)
+ struct comedi_insn *insn, unsigned int *data)
{
int i;
int chan = CR_CHAN(insn->chanspec);
@@ -348,7 +352,7 @@ static int atao_ao_winsn(struct comedi_device *dev, struct comedi_subdevice *s,
}
static int atao_ao_rinsn(struct comedi_device *dev, struct comedi_subdevice *s,
- struct comedi_insn *insn, unsigned int *data)
+ struct comedi_insn *insn, unsigned int *data)
{
int i;
int chan = CR_CHAN(insn->chanspec);
@@ -359,8 +363,9 @@ 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 +381,9 @@ static int atao_dio_insn_bits(struct comedi_device *dev, struct comedi_subdevice
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;
@@ -401,8 +407,7 @@ static int atao_dio_insn_config(struct comedi_device *dev, struct comedi_subdevi
break;
case INSN_CONFIG_DIO_QUERY:
data[1] =
- (s->
- io_bits & (1 << chan)) ? COMEDI_OUTPUT : COMEDI_INPUT;
+ (s->io_bits & (1 << chan)) ? COMEDI_OUTPUT : COMEDI_INPUT;
return insn->n;
break;
default:
@@ -421,8 +426,9 @@ static int atao_dio_insn_config(struct comedi_device *dev, struct comedi_subdevi
* 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 +437,9 @@ static int atao_calib_insn_read(struct comedi_device *dev, struct comedi_subdevi
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);
@@ -441,13 +448,13 @@ static int atao_calib_insn_write(struct comedi_device *dev, struct comedi_subdev
for (bit = 1 << (11 - 1); bit; bit >>= 1) {
outw(devpriv->cfg2 | ((bit & bitstring) ? SDATA : 0),
- dev->iobase + ATAO_CFG2);
+ dev->iobase + ATAO_CFG2);
outw(devpriv->cfg2 | SCLK | ((bit & bitstring) ? SDATA : 0),
- dev->iobase + ATAO_CFG2);
+ dev->iobase + ATAO_CFG2);
}
/* strobe the appropriate caldac */
outw(devpriv->cfg2 | (((chan >> 3) + 1) << 14),
- dev->iobase + ATAO_CFG2);
+ dev->iobase + ATAO_CFG2);
outw(devpriv->cfg2, dev->iobase + ATAO_CFG2);
return insn->n;
diff --git a/drivers/staging/comedi/drivers/ni_atmio.c b/drivers/staging/comedi/drivers/ni_atmio.c
index 8839447538f2..8ead31164d5c 100644
--- a/drivers/staging/comedi/drivers/ni_atmio.c
+++ b/drivers/staging/comedi/drivers/ni_atmio.c
@@ -117,159 +117,159 @@ are not supported.
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,
- .num_p0_dio_channels = 8,
- .caldac = {mb88341},
- },
+ .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,
+ .num_p0_dio_channels = 8,
+ .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,
- .ao_range_table = &range_ni_E_ao_ext,
- .ao_unipolar = 1,
- .ao_speed = 1000,
- .has_8255 = 0,
- .num_p0_dio_channels = 8,
- .caldac = {mb88341},
- },
+ .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,
+ .num_p0_dio_channels = 8,
+ .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,
- .ao_range_table = &range_ni_E_ao_ext,
- .ao_unipolar = 1,
- .ao_speed = 10000,
- .num_p0_dio_channels = 8,
- .caldac = {ad8804_debug},
- .has_8255 = 0,
- },
+ .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,
+ .num_p0_dio_channels = 8,
+ .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,
- .ao_range_table = &range_ni_E_ao_ext,
- .ao_unipolar = 1,
- .ao_speed = 10000,
- .num_p0_dio_channels = 8,
- .caldac = {ad8804_debug},
- .has_8255 = 1,
- },
+ .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,
+ .num_p0_dio_channels = 8,
+ .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,
- .ao_range_table = &range_ni_E_ao_ext,
- .ao_unipolar = 1,
- .ao_speed = 1000,
- .has_8255 = 0,
- .num_p0_dio_channels = 8,
- .caldac = {ad8804_debug},
- },
+ .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,
+ .num_p0_dio_channels = 8,
+ .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,
- .ao_range_table = &range_bipolar10,
- .ao_unipolar = 0,
- .ao_speed = 50000,
- .num_p0_dio_channels = 8,
- .caldac = {dac8800, dac8043},
- .has_8255 = 0,
- },
+ .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,
+ .num_p0_dio_channels = 8,
+ .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,
- .ao_range_table = &range_ni_E_ao_ext,
- .ao_unipolar = 1,
- .ao_speed = 1000,
- .num_p0_dio_channels = 8,
- .caldac = {dac8800, dac8043, ad8522},
- .has_8255 = 0,
- },
+ .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,
+ .num_p0_dio_channels = 8,
+ .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,
- .num_p0_dio_channels = 8,
- .caldac = {dac8800, dac8043, ad8522},
- .has_8255 = 0,
- }
+ .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,
+ }
};
static const int ni_irqpin[] =
- { -1, -1, -1, 0, 1, 2, -1, 3, -1, -1, 4, 5, 6, -1, -1, 7 };
+ { -1, -1, -1, 0, 1, 2, -1, 3, -1, -1, 4, 5, 6, -1, -1, 7 };
#define interrupt_pin(a) (ni_irqpin[(a)])
@@ -279,8 +279,7 @@ static const int ni_irqpin[] =
struct ni_private {
struct pnp_dev *isapnp_dev;
- NI_PRIVATE_COMMON
-};
+ NI_PRIVATE_COMMON};
#define devpriv ((struct ni_private *)dev->private)
/* How we access registers */
@@ -330,17 +329,18 @@ static uint16_t ni_atmio_win_in(struct comedi_device *dev, int addr)
}
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_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",
@@ -378,14 +378,17 @@ static int ni_isapnp_find_board(struct pnp_dev **dev)
for (i = 0; i < n_ni_boards; i++) {
isapnp_dev = pnp_find_dev(NULL,
- ISAPNP_VENDOR('N', 'I', 'C'),
- ISAPNP_FUNCTION(ni_boards[i].isapnp_id), NULL);
+ ISAPNP_VENDOR('N', 'I', 'C'),
+ ISAPNP_FUNCTION(ni_boards[i].
+ isapnp_id), NULL);
if (isapnp_dev == NULL || isapnp_dev->card == NULL)
continue;
if (pnp_device_attach(isapnp_dev) < 0) {
- printk("ni_atmio: %s found but already active, skipping.\n", ni_boards[i].name);
+ printk
+ ("ni_atmio: %s found but already active, skipping.\n",
+ ni_boards[i].name);
continue;
}
if (pnp_activate_dev(isapnp_dev) < 0) {
@@ -393,7 +396,7 @@ static int ni_isapnp_find_board(struct pnp_dev **dev)
return -EAGAIN;
}
if (!pnp_port_valid(isapnp_dev, 0)
- || !pnp_irq_valid(isapnp_dev, 0)) {
+ || !pnp_irq_valid(isapnp_dev, 0)) {
pnp_device_detach(isapnp_dev);
printk("ni_atmio: pnp invalid port or irq, aborting\n");
return -ENOMEM;
@@ -406,7 +409,8 @@ 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;
@@ -455,7 +459,7 @@ static int ni_atmio_attach(struct comedi_device *dev, struct comedi_devconfig *i
printk(" board fingerprint:");
for (i = 0; i < 16; i += 2) {
printk(" %04x %02x", inw(dev->iobase + i),
- inb(dev->iobase + i + 1));
+ inb(dev->iobase + i + 1));
}
}
#endif
diff --git a/drivers/staging/comedi/drivers/ni_atmio16d.c b/drivers/staging/comedi/drivers/ni_atmio16d.c
index 1a8c2ab20d3d..cde30b77a15f 100644
--- a/drivers/staging/comedi/drivers/ni_atmio16d.c
+++ b/drivers/staging/comedi/drivers/ni_atmio16d.c
@@ -112,13 +112,13 @@ 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,
+ },
};
#define n_atmio16_boards sizeof(atmio16_boards)/sizeof(atmio16_boards[0])
@@ -126,13 +126,17 @@ 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_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 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);
@@ -151,27 +155,39 @@ COMEDI_INITCLEANUP(driver_atmio16d);
/* range structs */
static const struct comedi_lrange range_atmio16d_ai_10_bipolar = { 4, {
- BIP_RANGE(10),
- BIP_RANGE(1),
- BIP_RANGE(0.1),
- BIP_RANGE(0.02)
- }
+ BIP_RANGE
+ (10),
+ BIP_RANGE
+ (1),
+ BIP_RANGE
+ (0.1),
+ BIP_RANGE
+ (0.02)
+ }
};
static const struct comedi_lrange range_atmio16d_ai_5_bipolar = { 4, {
- BIP_RANGE(5),
- BIP_RANGE(0.5),
- BIP_RANGE(0.05),
- BIP_RANGE(0.01)
- }
+ BIP_RANGE
+ (5),
+ BIP_RANGE
+ (0.5),
+ BIP_RANGE
+ (0.05),
+ BIP_RANGE
+ (0.01)
+ }
};
static const struct comedi_lrange range_atmio16d_ai_unipolar = { 4, {
- UNI_RANGE(10),
- UNI_RANGE(1),
- UNI_RANGE(0.1),
- UNI_RANGE(0.02)
- }
+ UNI_RANGE
+ (10),
+ UNI_RANGE
+ (1),
+ UNI_RANGE
+ (0.1),
+ UNI_RANGE
+ (0.02)
+ }
};
/* private data struct */
@@ -271,8 +287,9 @@ static irqreturn_t atmio16d_interrupt(int irq, void *d)
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
@@ -310,8 +327,8 @@ static int atmio16d_ai_cmdtest(struct comedi_device *dev, struct comedi_subdevic
/* step 2: make sure trigger sources are unique and mutually compatible */
/* note that mutual compatiblity is not an issue here */
if (cmd->scan_begin_src != TRIG_FOLLOW &&
- cmd->scan_begin_src != TRIG_EXT &&
- cmd->scan_begin_src != TRIG_TIMER)
+ cmd->scan_begin_src != TRIG_EXT &&
+ cmd->scan_begin_src != TRIG_TIMER)
err++;
if (cmd->stop_src != TRIG_COUNT && cmd->stop_src != TRIG_NONE)
err++;
@@ -372,7 +389,8 @@ static int atmio16d_ai_cmdtest(struct comedi_device *dev, struct comedi_subdevic
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;
@@ -418,10 +436,10 @@ static int atmio16d_ai_cmd(struct comedi_device *dev, struct comedi_subdevice *s
} 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;
}
@@ -466,10 +484,10 @@ static int atmio16d_ai_cmd(struct comedi_device *dev, struct comedi_subdevice *s
tmp = sample_count & 0xFFFF;
if ((tmp == 0) || (tmp == 1)) {
outw((sample_count >> 16) & 0xFFFF,
- dev->iobase + AM9513A_DATA_REG);
+ dev->iobase + AM9513A_DATA_REG);
} else {
outw(((sample_count >> 16) & 0xFFFF) + 1,
- dev->iobase + AM9513A_DATA_REG);
+ dev->iobase + AM9513A_DATA_REG);
}
outw(0xFF70, dev->iobase + AM9513A_COM_REG);
devpriv->com_reg_1_state |= COMREG1_1632CNT;
@@ -486,10 +504,10 @@ static int atmio16d_ai_cmd(struct comedi_device *dev, struct comedi_subdevice *s
} 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;
}
@@ -522,7 +540,8 @@ static int atmio16d_ai_cmd(struct comedi_device *dev, struct comedi_subdevice *s
}
/* 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);
@@ -530,8 +549,9 @@ static int atmio16d_ai_cancel(struct comedi_device *dev, struct comedi_subdevice
}
/* 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;
@@ -589,8 +609,9 @@ static int atmio16d_ai_insn_read(struct comedi_device *dev, struct comedi_subdev
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
@@ -604,8 +625,9 @@ static int atmio16d_ao_insn_read(struct comedi_device *dev, struct comedi_subdev
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;
@@ -639,8 +661,9 @@ static int atmio16d_ao_insn_write(struct comedi_device *dev, struct comedi_subde
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;
@@ -655,8 +678,10 @@ static int atmio16d_dio_insn_bits(struct comedi_device *dev, struct comedi_subde
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;
@@ -709,7 +734,8 @@ static int atmio16d_dio_insn_config(struct comedi_device *dev, struct comedi_sub
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;
@@ -843,7 +869,7 @@ static int atmio16d_attach(struct comedi_device *dev, struct comedi_devconfig *i
s->n_chan = 0;
s->maxdata = 0
#endif
- printk("\n");
+ printk("\n");
return 0;
}
diff --git a/drivers/staging/comedi/drivers/ni_daq_700.c b/drivers/staging/comedi/drivers/ni_daq_700.c
index e34948205320..6a7797604c97 100644
--- a/drivers/staging/comedi/drivers/ni_daq_700.c
+++ b/drivers/staging/comedi/drivers/ni_daq_700.c
@@ -56,7 +56,8 @@ static struct pcmcia_device *pcmcia_cur_dev = NULL;
#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_attach(struct comedi_device *dev,
+ struct comedi_devconfig *it);
static int dio700_detach(struct comedi_device *dev);
enum dio700_bustype { pcmcia_bustype };
@@ -74,17 +75,17 @@ struct dio700_board {
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,
+ },
};
/*
@@ -97,7 +98,6 @@ struct dio700_private {
int data; /* number of data points left to be taken */
};
-
#define devpriv ((struct dio700_private *)dev->private)
static struct comedi_driver driver_dio700 = {
@@ -156,8 +156,9 @@ 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];
@@ -165,7 +166,7 @@ static int subdev_700_insn(struct comedi_device *dev, struct comedi_subdevice *s
if (data[0] & 0xff)
CALLBACK_FUNC(1, _700_DATA, s->state & 0xff,
- CALLBACK_ARG);
+ CALLBACK_ARG);
}
data[1] = s->state & 0xff;
@@ -174,8 +175,9 @@ static int subdev_700_insn(struct comedi_device *dev, struct comedi_subdevice *s
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]) {
@@ -185,9 +187,9 @@ static int subdev_700_insn_config(struct comedi_device *dev, struct comedi_subde
break;
case INSN_CONFIG_DIO_QUERY:
data[1] =
- (s->io_bits & (1 << CR_CHAN(insn->
- chanspec))) ? COMEDI_OUTPUT :
- COMEDI_INPUT;
+ (s->
+ io_bits & (1 << CR_CHAN(insn->chanspec))) ? COMEDI_OUTPUT :
+ COMEDI_INPUT;
return insn->n;
break;
default:
@@ -202,8 +204,9 @@ static void do_config(struct comedi_device *dev, struct comedi_subdevice *s)
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;
@@ -284,15 +287,16 @@ static int subdev_700_cmd(struct comedi_device *dev, struct comedi_subdevice *s)
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, int, unsigned long), unsigned long arg)
+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;
s->subdev_flags = SDF_READABLE | SDF_WRITABLE;
@@ -321,7 +325,8 @@ int subdev_700_init(struct comedi_device *dev, struct comedi_subdevice *s, int (
}
int subdev_700_init_irq(struct comedi_device *dev, struct comedi_subdevice *s,
- int (*cb) (int, int, int, unsigned long), unsigned long arg)
+ int (*cb) (int, int, int, unsigned long),
+ unsigned long arg)
{
int ret;
@@ -383,7 +388,7 @@ static int dio700_attach(struct comedi_device *dev, struct comedi_devconfig *it)
break;
}
printk("comedi%d: ni_daq_700: %s, io 0x%lx", dev->minor,
- thisboard->name, iobase);
+ thisboard->name, iobase);
#ifdef incomplete
if (irq) {
printk(", irq %u", irq);
@@ -553,7 +558,7 @@ static void dio700_cs_detach(struct pcmcia_device *link)
DEBUG(0, "dio700_cs_detach(0x%p)\n", link);
if (link->dev_node) {
- ((struct local_info_t *) link->priv)->stop = 1;
+ ((struct local_info_t *)link->priv)->stop = 1;
dio700_release(link);
}
@@ -609,7 +614,7 @@ static void dio700_config(struct pcmcia_device *link)
}
last_ret = pcmcia_parse_tuple(&tuple, &parse);
- if (last_ret) {
+ if (last_ret) {
cs_error(link, ParseTuple, last_ret);
goto cs_failed;
}
@@ -681,7 +686,7 @@ static void dio700_config(struct pcmcia_device *link)
if ((cfg->mem.nwin > 0) || (dflt.mem.nwin > 0)) {
cistpl_mem_t *mem =
- (cfg->mem.nwin) ? &cfg->mem : &dflt.mem;
+ (cfg->mem.nwin) ? &cfg->mem : &dflt.mem;
req.Attributes = WIN_DATA_WIDTH_16 | WIN_MEMORY_TYPE_CM;
req.Attributes |= WIN_ENABLE;
req.Base = mem->win[0].host_addr;
@@ -699,7 +704,7 @@ static void dio700_config(struct pcmcia_device *link)
/* If we got this far, we're cool! */
break;
- next_entry:
+next_entry:
last_ret = pcmcia_get_next_tuple(link, &tuple);
if (last_ret) {
@@ -742,23 +747,23 @@ static void dio700_config(struct pcmcia_device *link)
/* Finally, report what we've done */
printk(KERN_INFO "%s: index 0x%02x",
- dev->node.dev_name, link->conf.ConfigIndex);
+ dev->node.dev_name, link->conf.ConfigIndex);
if (link->conf.Attributes & CONF_ENABLE_IRQ)
printk(", irq %d", link->irq.AssignedIRQ);
if (link->io.NumPorts1)
printk(", io 0x%04x-0x%04x", link->io.BasePort1,
- link->io.BasePort1 + link->io.NumPorts1 - 1);
+ link->io.BasePort1 + link->io.NumPorts1 - 1);
if (link->io.NumPorts2)
printk(" & 0x%04x-0x%04x", link->io.BasePort2,
- link->io.BasePort2 + link->io.NumPorts2 - 1);
+ link->io.BasePort2 + link->io.NumPorts2 - 1);
if (link->win)
printk(", mem 0x%06lx-0x%06lx", req.Base,
- req.Base + req.Size - 1);
+ req.Base + req.Size - 1);
printk("\n");
return;
- cs_failed:
+cs_failed:
printk(KERN_INFO "ni_daq_700 cs failed");
dio700_release(link);
@@ -819,7 +824,7 @@ struct pcmcia_driver dio700_cs_driver = {
.id_table = dio700_cs_ids,
.owner = THIS_MODULE,
.drv = {
- .name = dev_info,
+ .name = dev_info,
},
};
@@ -836,6 +841,7 @@ static void __exit exit_dio700_cs(void)
DEBUG(0, "ni_daq_700: unloading\n");
pcmcia_unregister_driver(&dio700_cs_driver);
}
+
int __init init_module(void)
{
int ret;
diff --git a/drivers/staging/comedi/drivers/ni_daq_dio24.c b/drivers/staging/comedi/drivers/ni_daq_dio24.c
index a8ac02febc66..b06e81c526e8 100644
--- a/drivers/staging/comedi/drivers/ni_daq_dio24.c
+++ b/drivers/staging/comedi/drivers/ni_daq_dio24.c
@@ -37,7 +37,7 @@ 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>
@@ -74,17 +74,17 @@ struct dio24_board_struct {
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,
+ },
};
/*
@@ -97,7 +97,6 @@ struct dio24_private {
int data; /* number of data points left to be taken */
};
-
#define devpriv ((struct dio24_private *)dev->private)
static struct comedi_driver driver_dio24 = {
@@ -140,7 +139,7 @@ static int dio24_attach(struct comedi_device *dev, struct comedi_devconfig *it)
break;
}
printk("comedi%d: ni_daq_dio24: %s, io 0x%lx", dev->minor,
- thisboard->name, iobase);
+ thisboard->name, iobase);
#ifdef incomplete
if (irq) {
printk(", irq %u", irq);
@@ -310,7 +309,7 @@ static void dio24_cs_detach(struct pcmcia_device *link)
DEBUG(0, "dio24_cs_detach(0x%p)\n", link);
if (link->dev_node) {
- ((struct local_info_t *) link->priv)->stop = 1;
+ ((struct local_info_t *)link->priv)->stop = 1;
dio24_release(link);
}
@@ -439,7 +438,7 @@ static void dio24_config(struct pcmcia_device *link)
if ((cfg->mem.nwin > 0) || (dflt.mem.nwin > 0)) {
cistpl_mem_t *mem =
- (cfg->mem.nwin) ? &cfg->mem : &dflt.mem;
+ (cfg->mem.nwin) ? &cfg->mem : &dflt.mem;
req.Attributes = WIN_DATA_WIDTH_16 | WIN_MEMORY_TYPE_CM;
req.Attributes |= WIN_ENABLE;
req.Base = mem->win[0].host_addr;
@@ -457,7 +456,7 @@ static void dio24_config(struct pcmcia_device *link)
/* If we got this far, we're cool! */
break;
- next_entry:
+next_entry:
last_ret = pcmcia_get_next_tuple(link, &tuple);
if (last_ret) {
@@ -500,23 +499,23 @@ static void dio24_config(struct pcmcia_device *link)
/* Finally, report what we've done */
printk(KERN_INFO "%s: index 0x%02x",
- dev->node.dev_name, link->conf.ConfigIndex);
+ dev->node.dev_name, link->conf.ConfigIndex);
if (link->conf.Attributes & CONF_ENABLE_IRQ)
printk(", irq %d", link->irq.AssignedIRQ);
if (link->io.NumPorts1)
printk(", io 0x%04x-0x%04x", link->io.BasePort1,
- link->io.BasePort1 + link->io.NumPorts1 - 1);
+ link->io.BasePort1 + link->io.NumPorts1 - 1);
if (link->io.NumPorts2)
printk(" & 0x%04x-0x%04x", link->io.BasePort2,
- link->io.BasePort2 + link->io.NumPorts2 - 1);
+ link->io.BasePort2 + link->io.NumPorts2 - 1);
if (link->win)
printk(", mem 0x%06lx-0x%06lx", req.Base,
- req.Base + req.Size - 1);
+ req.Base + req.Size - 1);
printk("\n");
return;
- cs_failed:
+cs_failed:
printk(KERN_INFO "Fallo");
dio24_release(link);
@@ -576,7 +575,7 @@ struct pcmcia_driver dio24_cs_driver = {
.id_table = dio24_cs_ids,
.owner = THIS_MODULE,
.drv = {
- .name = dev_info,
+ .name = dev_info,
},
};
diff --git a/drivers/staging/comedi/drivers/ni_labpc.c b/drivers/staging/comedi/drivers/ni_labpc.c
index 30e11f46a640..dc3f398cb3ed 100644
--- a/drivers/staging/comedi/drivers/ni_labpc.c
+++ b/drivers/staging/comedi/drivers/ni_labpc.c
@@ -171,40 +171,46 @@ 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_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);
+ 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);
+ 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);
+ 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);
#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);
+ unsigned long arg);
static void labpc_serial_out(struct comedi_device *dev, unsigned int value,
- unsigned int num_bits);
+ unsigned int num_bits);
static unsigned int labpc_serial_in(struct comedi_device *dev);
static unsigned int labpc_eeprom_read(struct comedi_device *dev,
- unsigned int address);
+ unsigned int address);
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);
+ unsigned int address,
+ unsigned int value);
static void write_caldac(struct comedi_device *dev, unsigned int channel,
- unsigned int value);
+ unsigned int value);
enum scan_mode {
MODE_SINGLE_CHAN,
@@ -254,26 +260,27 @@ static const int labpc_plus_ai_gain_bits[NUM_LABPC_PLUS_AI_RANGES] = {
0x60,
0x70,
};
+
static const struct comedi_lrange range_labpc_plus_ai = {
NUM_LABPC_PLUS_AI_RANGES,
{
- BIP_RANGE(5),
- BIP_RANGE(4),
- BIP_RANGE(2.5),
- BIP_RANGE(1),
- BIP_RANGE(0.5),
- BIP_RANGE(0.25),
- BIP_RANGE(0.1),
- BIP_RANGE(0.05),
- UNI_RANGE(10),
- UNI_RANGE(8),
- UNI_RANGE(5),
- UNI_RANGE(2),
- UNI_RANGE(1),
- UNI_RANGE(0.5),
- UNI_RANGE(0.2),
- UNI_RANGE(0.1),
- }
+ BIP_RANGE(5),
+ BIP_RANGE(4),
+ BIP_RANGE(2.5),
+ BIP_RANGE(1),
+ BIP_RANGE(0.5),
+ BIP_RANGE(0.25),
+ BIP_RANGE(0.1),
+ BIP_RANGE(0.05),
+ UNI_RANGE(10),
+ UNI_RANGE(8),
+ UNI_RANGE(5),
+ UNI_RANGE(2),
+ UNI_RANGE(1),
+ UNI_RANGE(0.5),
+ UNI_RANGE(0.2),
+ UNI_RANGE(0.1),
+ }
};
#define NUM_LABPC_1200_AI_RANGES 14
@@ -312,24 +319,25 @@ const int labpc_1200_ai_gain_bits[NUM_LABPC_1200_AI_RANGES] = {
0x60,
0x70,
};
+
const struct comedi_lrange range_labpc_1200_ai = {
NUM_LABPC_1200_AI_RANGES,
{
- BIP_RANGE(5),
- BIP_RANGE(2.5),
- BIP_RANGE(1),
- BIP_RANGE(0.5),
- BIP_RANGE(0.25),
- BIP_RANGE(0.1),
- BIP_RANGE(0.05),
- UNI_RANGE(10),
- UNI_RANGE(5),
- UNI_RANGE(2),
- UNI_RANGE(1),
- UNI_RANGE(0.5),
- UNI_RANGE(0.2),
- UNI_RANGE(0.1),
- }
+ BIP_RANGE(5),
+ BIP_RANGE(2.5),
+ BIP_RANGE(1),
+ BIP_RANGE(0.5),
+ BIP_RANGE(0.25),
+ BIP_RANGE(0.1),
+ BIP_RANGE(0.05),
+ UNI_RANGE(10),
+ UNI_RANGE(5),
+ UNI_RANGE(2),
+ UNI_RANGE(1),
+ UNI_RANGE(0.5),
+ UNI_RANGE(0.2),
+ UNI_RANGE(0.1),
+ }
};
/* analog output ranges */
@@ -337,9 +345,9 @@ const struct comedi_lrange range_labpc_1200_ai = {
static const struct comedi_lrange range_labpc_ao = {
2,
{
- BIP_RANGE(5),
- UNI_RANGE(10),
- }
+ BIP_RANGE(5),
+ UNI_RANGE(10),
+ }
};
/* functions that do inb/outb and readb/writeb so we can use
@@ -348,14 +356,17 @@ static inline unsigned int labpc_inb(unsigned long address)
{
return inb(address);
}
+
static inline void labpc_outb(unsigned int byte, unsigned long address)
{
outb(byte, address);
}
+
static inline unsigned int labpc_readb(unsigned long address)
{
return readb((void *)address);
}
+
static inline void labpc_writeb(unsigned int byte, unsigned long address)
{
writeb(byte, (void *)address);
@@ -363,60 +374,60 @@ static inline void labpc_writeb(unsigned int byte, unsigned long address)
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 */
{
- .name = DRV_NAME,
- .bustype = pci_bustype,
- },
+ .name = DRV_NAME,
+ .bustype = pci_bustype,
+ },
#endif
};
@@ -442,26 +453,28 @@ static struct comedi_driver driver_labpc = {
#ifdef CONFIG_COMEDI_PCI
static DEFINE_PCI_DEVICE_TABLE(labpc_pci_table) = {
- {PCI_VENDOR_ID_NATINST, 0x161, PCI_ANY_ID, PCI_ANY_ID, 0, 0, 0},
- {0}
+ {
+ PCI_VENDOR_ID_NATINST, 0x161, PCI_ANY_ID, PCI_ANY_ID, 0, 0, 0}, {
+ 0}
};
MODULE_DEVICE_TABLE(pci, labpc_pci_table);
#endif /* CONFIG_COMEDI_PCI */
static inline int labpc_counter_load(struct comedi_device *dev,
- unsigned long base_address, unsigned int counter_number,
- unsigned int count, unsigned int mode)
+ unsigned long base_address,
+ unsigned int counter_number,
+ unsigned int count, unsigned int mode)
{
if (thisboard->memory_mapped_io)
return i8254_mm_load((void *)base_address, 0, counter_number,
- count, mode);
+ count, mode);
else
return i8254_load(base_address, 0, counter_number, count, mode);
}
int labpc_common_attach(struct comedi_device *dev, unsigned long iobase,
- unsigned int irq, unsigned int dma_chan)
+ unsigned int irq, unsigned int dma_chan)
{
struct comedi_subdevice *s;
int i;
@@ -469,7 +482,7 @@ int labpc_common_attach(struct comedi_device *dev, unsigned long iobase,
short lsb, msb;
printk("comedi%d: ni_labpc: %s, io 0x%lx", dev->minor, thisboard->name,
- iobase);
+ iobase);
if (irq) {
printk(", irq %u", irq);
}
@@ -486,7 +499,7 @@ int labpc_common_attach(struct comedi_device *dev, unsigned long iobase,
if (thisboard->bustype == isa_bustype) {
/* check if io addresses are available */
if (!request_region(iobase, LABPC_SIZE,
- driver_labpc.driver_name)) {
+ driver_labpc.driver_name)) {
printk("I/O port conflict\n");
return -EIO;
}
@@ -507,9 +520,9 @@ int labpc_common_attach(struct comedi_device *dev, unsigned long iobase,
devpriv->write_byte(devpriv->command4_bits, dev->iobase + COMMAND4_REG);
if (thisboard->register_layout == labpc_1200_layout) {
devpriv->write_byte(devpriv->command5_bits,
- dev->iobase + COMMAND5_REG);
+ dev->iobase + COMMAND5_REG);
devpriv->write_byte(devpriv->command6_bits,
- dev->iobase + COMMAND6_REG);
+ dev->iobase + COMMAND6_REG);
}
/* grab our IRQ */
@@ -532,14 +545,14 @@ int labpc_common_attach(struct comedi_device *dev, unsigned long iobase,
} else if (dma_chan) {
/* allocate dma buffer */
devpriv->dma_buffer =
- kmalloc(dma_buffer_size, GFP_KERNEL | GFP_DMA);
+ kmalloc(dma_buffer_size, GFP_KERNEL | GFP_DMA);
if (devpriv->dma_buffer == NULL) {
printk(" failed to allocate dma buffer\n");
return -ENOMEM;
}
if (request_dma(dma_chan, driver_labpc.driver_name)) {
printk(" failed to allocate dma channel %u\n",
- dma_chan);
+ dma_chan);
return -EINVAL;
}
devpriv->dma_chan = dma_chan;
@@ -559,8 +572,7 @@ int labpc_common_attach(struct comedi_device *dev, unsigned long iobase,
dev->read_subdev = s;
s->type = COMEDI_SUBD_AI;
s->subdev_flags =
- SDF_READABLE | SDF_GROUND | SDF_COMMON | SDF_DIFF |
- SDF_CMD_READ;
+ SDF_READABLE | SDF_GROUND | SDF_COMMON | SDF_DIFF | SDF_CMD_READ;
s->n_chan = 8;
s->len_chanlist = 8;
s->maxdata = (1 << 12) - 1; /* 12 bit resolution */
@@ -599,7 +611,7 @@ int labpc_common_attach(struct comedi_device *dev, unsigned long iobase,
/* 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));
+ (unsigned long)(dev->iobase + DIO_BASE_REG));
else
subdev_8255_init(dev, s, NULL, dev->iobase + DIO_BASE_REG);
@@ -681,7 +693,8 @@ static int labpc_attach(struct comedi_device *dev, struct comedi_devconfig *it)
#endif
break;
case pcmcia_bustype:
- printk(" this driver does not support pcmcia cards, use ni_labpc_cs.o\n");
+ printk
+ (" this driver does not support pcmcia cards, use ni_labpc_cs.o\n");
return -EINVAL;
break;
default:
@@ -705,7 +718,7 @@ static int labpc_find_device(struct comedi_device *dev, int bus, int 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))
+ || slot != PCI_SLOT(mite->pcidev->devfn))
continue;
}
for (i = 0; i < driver_labpc.num_names; i++) {
@@ -795,7 +808,7 @@ static enum scan_mode labpc_ai_scan_mode(const struct comedi_cmd *cmd)
}
static int labpc_ai_chanlist_invalid(const struct comedi_device *dev,
- const struct comedi_cmd *cmd)
+ const struct comedi_cmd *cmd)
{
int mode, channel, range, aref, i;
@@ -810,7 +823,7 @@ static int labpc_ai_chanlist_invalid(const struct comedi_device *dev,
if (mode == MODE_SINGLE_CHAN_INTERVAL) {
if (cmd->chanlist_len > 0xff) {
comedi_error(dev,
- "ni_labpc: chanlist too long for single channel interval mode\n");
+ "ni_labpc: chanlist too long for single channel interval mode\n");
return 1;
}
}
@@ -825,22 +838,22 @@ static int labpc_ai_chanlist_invalid(const struct comedi_device *dev,
case MODE_SINGLE_CHAN_INTERVAL:
if (CR_CHAN(cmd->chanlist[i]) != channel) {
comedi_error(dev,
- "channel scanning order specified in chanlist is not supported by hardware.\n");
+ "channel scanning order specified in chanlist is not supported by hardware.\n");
return 1;
}
break;
case MODE_MULT_CHAN_UP:
if (CR_CHAN(cmd->chanlist[i]) != i) {
comedi_error(dev,
- "channel scanning order specified in chanlist is not supported by hardware.\n");
+ "channel scanning order specified in chanlist is not supported by hardware.\n");
return 1;
}
break;
case MODE_MULT_CHAN_DOWN:
if (CR_CHAN(cmd->chanlist[i]) !=
- cmd->chanlist_len - i - 1) {
+ cmd->chanlist_len - i - 1) {
comedi_error(dev,
- "channel scanning order specified in chanlist is not supported by hardware.\n");
+ "channel scanning order specified in chanlist is not supported by hardware.\n");
return 1;
}
break;
@@ -852,13 +865,13 @@ static int labpc_ai_chanlist_invalid(const struct comedi_device *dev,
if (CR_RANGE(cmd->chanlist[i]) != range) {
comedi_error(dev,
- "entries in chanlist must all have the same range\n");
+ "entries in chanlist must all have the same range\n");
return 1;
}
if (CR_AREF(cmd->chanlist[i]) != aref) {
comedi_error(dev,
- "entries in chanlist must all have the same reference\n");
+ "entries in chanlist must all have the same reference\n");
return 1;
}
}
@@ -883,7 +896,7 @@ static unsigned int labpc_ai_convert_period(const struct comedi_cmd *cmd)
return 0;
if (labpc_ai_scan_mode(cmd) == MODE_SINGLE_CHAN &&
- cmd->scan_begin_src == TRIG_TIMER)
+ cmd->scan_begin_src == TRIG_TIMER)
return cmd->scan_begin_arg;
return cmd->convert_arg;
@@ -895,7 +908,7 @@ static void labpc_set_ai_convert_period(struct comedi_cmd *cmd, unsigned int ns)
return;
if (labpc_ai_scan_mode(cmd) == MODE_SINGLE_CHAN &&
- cmd->scan_begin_src == TRIG_TIMER) {
+ cmd->scan_begin_src == TRIG_TIMER) {
cmd->scan_begin_arg = ns;
if (cmd->convert_arg > cmd->scan_begin_arg)
cmd->convert_arg = cmd->scan_begin_arg;
@@ -909,7 +922,7 @@ static unsigned int labpc_ai_scan_period(const struct comedi_cmd *cmd)
return 0;
if (labpc_ai_scan_mode(cmd) == MODE_SINGLE_CHAN &&
- cmd->convert_src == TRIG_TIMER)
+ cmd->convert_src == TRIG_TIMER)
return 0;
return cmd->scan_begin_arg;
@@ -921,14 +934,14 @@ static void labpc_set_ai_scan_period(struct comedi_cmd *cmd, unsigned int ns)
return;
if (labpc_ai_scan_mode(cmd) == MODE_SINGLE_CHAN &&
- cmd->convert_src == TRIG_TIMER)
+ cmd->convert_src == TRIG_TIMER)
return;
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;
@@ -972,13 +985,13 @@ static int labpc_ai_cmdtest(struct comedi_device *dev, struct comedi_subdevice *
if (cmd->start_src != TRIG_NOW && cmd->start_src != TRIG_EXT)
err++;
if (cmd->scan_begin_src != TRIG_TIMER &&
- cmd->scan_begin_src != TRIG_FOLLOW &&
- cmd->scan_begin_src != TRIG_EXT)
+ cmd->scan_begin_src != TRIG_FOLLOW &&
+ cmd->scan_begin_src != TRIG_EXT)
err++;
if (cmd->convert_src != TRIG_TIMER && cmd->convert_src != TRIG_EXT)
err++;
if (cmd->stop_src != TRIG_COUNT &&
- cmd->stop_src != TRIG_EXT && cmd->stop_src != TRIG_NONE)
+ cmd->stop_src != TRIG_EXT && cmd->stop_src != TRIG_NONE)
err++;
/* can't have external stop and start triggers at once */
@@ -1012,16 +1025,16 @@ static int labpc_ai_cmdtest(struct comedi_device *dev, struct comedi_subdevice *
/* 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 <
- cmd->convert_arg * cmd->chanlist_len) {
+ cmd->scan_begin_arg <
+ cmd->convert_arg * cmd->chanlist_len) {
cmd->scan_begin_arg =
- cmd->convert_arg * cmd->chanlist_len;
+ cmd->convert_arg * cmd->chanlist_len;
err++;
}
if (cmd->scan_begin_arg <
- thisboard->ai_speed * cmd->chanlist_len) {
+ thisboard->ai_speed * cmd->chanlist_len) {
cmd->scan_begin_arg =
- thisboard->ai_speed * cmd->chanlist_len;
+ thisboard->ai_speed * cmd->chanlist_len;
err++;
}
}
@@ -1099,27 +1112,27 @@ static int labpc_ai_cmd(struct comedi_device *dev, struct comedi_subdevice *s)
if (cmd->stop_src == TRIG_EXT) {
/* 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);
+ 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 */
devpriv->write_byte(INIT_A1_BITS,
- dev->iobase + COUNTER_A_CONTROL_REG);
+ 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 */
- (cmd->flags & (TRIG_WAKE_EOS | TRIG_RT)) == 0 &&
- /* only available on the isa boards */
- thisboard->bustype == isa_bustype) {
+ /* 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 */
+ 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 */
- (cmd->flags & TRIG_WAKE_EOS) == 0 &&
- /* make sure we are taking more than just a few points */
- (cmd->stop_src != TRIG_COUNT || devpriv->count > 256)) {
+ /* 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 */
+ (cmd->stop_src != TRIG_COUNT || devpriv->count > 256)) {
xfer = fifo_half_full_transfer;
} else
xfer = fifo_not_empty_transfer;
@@ -1154,7 +1167,7 @@ static int labpc_ai_cmd(struct comedi_device *dev, struct comedi_subdevice *s)
devpriv->command6_bits &= ~ADC_SCAN_UP_BIT;
/* write to register */
devpriv->write_byte(devpriv->command6_bits,
- dev->iobase + COMMAND6_REG);
+ dev->iobase + COMMAND6_REG);
}
/* setup channel list, etc (command1 register) */
@@ -1171,13 +1184,13 @@ static int labpc_ai_cmd(struct comedi_device *dev, struct comedi_subdevice *s)
devpriv->write_byte(devpriv->command1_bits, dev->iobase + COMMAND1_REG);
/* 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) {
+ 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 */
udelay(1);
devpriv->write_byte(devpriv->command1_bits,
- dev->iobase + COMMAND1_REG);
+ dev->iobase + COMMAND1_REG);
}
/* setup any external triggering/pacing (command4 register) */
devpriv->command4_bits = 0;
@@ -1196,17 +1209,17 @@ static int labpc_ai_cmd(struct comedi_device *dev, struct comedi_subdevice *s)
devpriv->write_byte(devpriv->command4_bits, dev->iobase + COMMAND4_REG);
devpriv->write_byte(cmd->chanlist_len,
- dev->iobase + INTERVAL_COUNT_REG);
+ dev->iobase + INTERVAL_COUNT_REG);
/* load count */
devpriv->write_byte(INTERVAL_LOAD_BITS,
- dev->iobase + INTERVAL_LOAD_REG);
+ dev->iobase + INTERVAL_LOAD_REG);
if (cmd->convert_src == TRIG_TIMER || cmd->scan_begin_src == TRIG_TIMER) {
/* set up pacing */
labpc_adc_timing(dev, cmd);
/* load counter b0 in mode 3 */
ret = labpc_counter_load(dev, dev->iobase + COUNTER_B_BASE_REG,
- 0, devpriv->divisor_b0, 3);
+ 0, devpriv->divisor_b0, 3);
if (ret < 0) {
comedi_error(dev, "error loading counter b0");
return -1;
@@ -1216,20 +1229,20 @@ static int labpc_ai_cmd(struct comedi_device *dev, struct comedi_subdevice *s)
if (labpc_ai_convert_period(cmd)) {
/* load counter a0 in mode 2 */
ret = labpc_counter_load(dev, dev->iobase + COUNTER_A_BASE_REG,
- 0, devpriv->divisor_a0, 2);
+ 0, devpriv->divisor_a0, 2);
if (ret < 0) {
comedi_error(dev, "error loading counter a0");
return -1;
}
} else
devpriv->write_byte(INIT_A0_BITS,
- dev->iobase + COUNTER_A_CONTROL_REG);
+ dev->iobase + COUNTER_A_CONTROL_REG);
/* set up scan pacing */
if (labpc_ai_scan_period(cmd)) {
/* load counter b1 in mode 2 */
ret = labpc_counter_load(dev, dev->iobase + COUNTER_B_BASE_REG,
- 1, devpriv->divisor_b1, 2);
+ 1, devpriv->divisor_b1, 2);
if (ret < 0) {
comedi_error(dev, "error loading counter b1");
return -1;
@@ -1246,14 +1259,13 @@ static int labpc_ai_cmd(struct comedi_device *dev, struct comedi_subdevice *s)
* count and address get set correctly */
clear_dma_ff(devpriv->dma_chan);
set_dma_addr(devpriv->dma_chan,
- virt_to_bus(devpriv->dma_buffer));
+ virt_to_bus(devpriv->dma_buffer));
/* set appropriate size of transfer */
devpriv->dma_transfer_size = labpc_suggest_transfer_size(*cmd);
if (cmd->stop_src == TRIG_COUNT &&
- devpriv->count * sample_size <
- devpriv->dma_transfer_size) {
+ devpriv->count * sample_size < devpriv->dma_transfer_size) {
devpriv->dma_transfer_size =
- devpriv->count * sample_size;
+ devpriv->count * sample_size;
}
set_dma_count(devpriv->dma_chan, devpriv->dma_transfer_size);
enable_dma(devpriv->dma_chan);
@@ -1330,12 +1342,12 @@ static irqreturn_t labpc_interrupt(int irq, void *d)
devpriv->status1_bits = devpriv->read_byte(dev->iobase + STATUS1_REG);
if (thisboard->register_layout == labpc_1200_layout)
devpriv->status2_bits =
- devpriv->read_byte(dev->iobase + STATUS2_REG);
+ devpriv->read_byte(dev->iobase + STATUS2_REG);
if ((devpriv->status1_bits & (DMATC_BIT | TIMER_BIT | OVERFLOW_BIT |
- OVERRUN_BIT | DATA_AVAIL_BIT)) == 0
- && (devpriv->status2_bits & A1_TC_BIT) == 0
- && (devpriv->status2_bits & FNHF_BIT)) {
+ OVERRUN_BIT | DATA_AVAIL_BIT)) == 0
+ && (devpriv->status2_bits & A1_TC_BIT) == 0
+ && (devpriv->status2_bits & FNHF_BIT)) {
return IRQ_NONE;
}
@@ -1351,8 +1363,8 @@ static irqreturn_t labpc_interrupt(int irq, void *d)
if (devpriv->current_transfer == isa_dma_transfer) {
/* 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)) {
+ (thisboard->register_layout == labpc_1200_layout
+ && devpriv->status2_bits & A1_TC_BIT)) {
handle_isa_dma(dev);
}
} else
@@ -1405,7 +1417,7 @@ static int labpc_drain_fifo(struct comedi_device *dev)
devpriv->status1_bits = devpriv->read_byte(dev->iobase + STATUS1_REG);
for (i = 0; (devpriv->status1_bits & DATA_AVAIL_BIT) && i < timeout;
- i++) {
+ i++) {
/* quit if we have all the data we want */
if (async->cmd.stop_src == TRIG_COUNT) {
if (devpriv->count == 0)
@@ -1417,7 +1429,7 @@ static int labpc_drain_fifo(struct comedi_device *dev)
data = (msb << 8) | lsb;
cfc_write_to_buffer(dev->read_subdev, data);
devpriv->status1_bits =
- devpriv->read_byte(dev->iobase + STATUS1_REG);
+ devpriv->read_byte(dev->iobase + STATUS1_REG);
}
if (i == timeout) {
comedi_error(dev, "ai timeout, fifo never empties");
@@ -1502,7 +1514,7 @@ static void labpc_drain_dregs(struct comedi_device *dev)
}
static int labpc_ai_rinsn(struct comedi_device *dev, struct comedi_subdevice *s,
- struct comedi_insn *insn, unsigned int *data)
+ struct comedi_insn *insn, unsigned int *data)
{
int i, n;
int chan, range;
@@ -1549,7 +1561,7 @@ static int labpc_ai_rinsn(struct comedi_device *dev, struct comedi_subdevice *s,
devpriv->command6_bits &= ~A1_INTR_EN_BIT;
/* write to register */
devpriv->write_byte(devpriv->command6_bits,
- dev->iobase + COMMAND6_REG);
+ dev->iobase + COMMAND6_REG);
}
/* setup command4 register */
devpriv->command4_bits = 0;
@@ -1570,7 +1582,7 @@ static int labpc_ai_rinsn(struct comedi_device *dev, struct comedi_subdevice *s,
for (i = 0; i < timeout; i++) {
if (devpriv->read_byte(dev->iobase +
- STATUS1_REG) & DATA_AVAIL_BIT)
+ STATUS1_REG) & DATA_AVAIL_BIT)
break;
udelay(1);
}
@@ -1588,7 +1600,7 @@ static int labpc_ai_rinsn(struct comedi_device *dev, struct comedi_subdevice *s,
/* analog output insn */
static int labpc_ao_winsn(struct comedi_device *dev, struct comedi_subdevice *s,
- struct comedi_insn *insn, unsigned int *data)
+ struct comedi_insn *insn, unsigned int *data)
{
int channel, range;
unsigned long flags;
@@ -1613,7 +1625,7 @@ static int labpc_ao_winsn(struct comedi_device *dev, struct comedi_subdevice *s,
devpriv->command6_bits &= ~DAC_UNIP_BIT(channel);
/* write to register */
devpriv->write_byte(devpriv->command6_bits,
- dev->iobase + COMMAND6_REG);
+ dev->iobase + COMMAND6_REG);
}
/* send data */
lsb = data[0] & 0xff;
@@ -1629,23 +1641,25 @@ static int labpc_ao_winsn(struct comedi_device *dev, struct comedi_subdevice *s,
/* analog output readback insn */
static int labpc_ao_rinsn(struct comedi_device *dev, struct comedi_subdevice *s,
- struct comedi_insn *insn, unsigned int *data)
+ 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);
@@ -1653,23 +1667,26 @@ static int labpc_calib_write_insn(struct comedi_device *dev, struct comedi_subde
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 */
if (channel < 16 || channel > 127) {
- printk("eeprom writes are only allowed to channels 16 through 127 (the pointer and user areas)");
+ printk
+ ("eeprom writes are only allowed to channels 16 through 127 (the pointer and user areas)");
return -EINVAL;
}
@@ -1715,7 +1732,7 @@ static void labpc_adc_timing(struct comedi_device *dev, struct comedi_cmd *cmd)
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) */
devpriv->divisor_b0 = (labpc_ai_scan_period(cmd) - 1) /
- (LABPC_TIMER_BASE * max_counter_value) + 1;
+ (LABPC_TIMER_BASE * max_counter_value) + 1;
if (devpriv->divisor_b0 < min_counter_value)
devpriv->divisor_b0 = min_counter_value;
if (devpriv->divisor_b0 > max_counter_value)
@@ -1728,25 +1745,25 @@ static void labpc_adc_timing(struct comedi_device *dev, struct comedi_cmd *cmd)
default:
case TRIG_ROUND_NEAREST:
devpriv->divisor_a0 =
- (labpc_ai_convert_period(cmd) +
- (base_period / 2)) / base_period;
+ (labpc_ai_convert_period(cmd) +
+ (base_period / 2)) / base_period;
devpriv->divisor_b1 =
- (labpc_ai_scan_period(cmd) +
- (base_period / 2)) / base_period;
+ (labpc_ai_scan_period(cmd) +
+ (base_period / 2)) / base_period;
break;
case TRIG_ROUND_UP:
devpriv->divisor_a0 =
- (labpc_ai_convert_period(cmd) + (base_period -
- 1)) / base_period;
+ (labpc_ai_convert_period(cmd) + (base_period -
+ 1)) / base_period;
devpriv->divisor_b1 =
- (labpc_ai_scan_period(cmd) + (base_period -
- 1)) / base_period;
+ (labpc_ai_scan_period(cmd) + (base_period -
+ 1)) / base_period;
break;
case TRIG_ROUND_DOWN:
devpriv->divisor_a0 =
- labpc_ai_convert_period(cmd) / base_period;
+ labpc_ai_convert_period(cmd) / base_period;
devpriv->divisor_b1 =
- labpc_ai_scan_period(cmd) / base_period;
+ labpc_ai_scan_period(cmd) / base_period;
break;
}
/* make sure a0 and b1 values are acceptable */
@@ -1760,9 +1777,9 @@ static void labpc_adc_timing(struct comedi_device *dev, struct comedi_cmd *cmd)
devpriv->divisor_b1 = max_counter_value;
/* write corrected timings to command */
labpc_set_ai_convert_period(cmd,
- base_period * devpriv->divisor_a0);
+ base_period * devpriv->divisor_a0);
labpc_set_ai_scan_period(cmd,
- base_period * devpriv->divisor_b1);
+ base_period * devpriv->divisor_b1);
/* 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;
@@ -1770,8 +1787,10 @@ static void labpc_adc_timing(struct comedi_device *dev, struct comedi_cmd *cmd)
scan_period = labpc_ai_scan_period(cmd);
/* calculate cascaded counter values that give desired scan timing */
i8253_cascade_ns_to_timer_2div(LABPC_TIMER_BASE,
- &(devpriv->divisor_b1), &(devpriv->divisor_b0),
- &scan_period, cmd->flags & TRIG_ROUND_MASK);
+ &(devpriv->divisor_b1),
+ &(devpriv->divisor_b0),
+ &scan_period,
+ cmd->flags & TRIG_ROUND_MASK);
labpc_set_ai_scan_period(cmd, scan_period);
} else if (labpc_ai_convert_period(cmd)) {
unsigned int convert_period;
@@ -1779,14 +1798,16 @@ static void labpc_adc_timing(struct comedi_device *dev, struct comedi_cmd *cmd)
convert_period = labpc_ai_convert_period(cmd);
/* calculate cascaded counter values that give desired conversion timing */
i8253_cascade_ns_to_timer_2div(LABPC_TIMER_BASE,
- &(devpriv->divisor_a0), &(devpriv->divisor_b0),
- &convert_period, cmd->flags & TRIG_ROUND_MASK);
+ &(devpriv->divisor_a0),
+ &(devpriv->divisor_b0),
+ &convert_period,
+ cmd->flags & TRIG_ROUND_MASK);
labpc_set_ai_convert_period(cmd, convert_period);
}
}
static int labpc_dio_mem_callback(int dir, int port, int data,
- unsigned long iobase)
+ unsigned long iobase)
{
if (dir) {
writeb(data, (void *)(iobase + port));
@@ -1798,7 +1819,7 @@ 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,
- unsigned int value_width)
+ unsigned int value_width)
{
int i;
@@ -1812,12 +1833,12 @@ static void labpc_serial_out(struct comedi_device *dev, unsigned int value,
devpriv->command5_bits &= ~SDATA_BIT;
udelay(1);
devpriv->write_byte(devpriv->command5_bits,
- dev->iobase + COMMAND5_REG);
+ dev->iobase + COMMAND5_REG);
/* set clock to load bit */
devpriv->command5_bits |= SCLOCK_BIT;
udelay(1);
devpriv->write_byte(devpriv->command5_bits,
- dev->iobase + COMMAND5_REG);
+ dev->iobase + COMMAND5_REG);
}
}
@@ -1833,16 +1854,16 @@ static unsigned int labpc_serial_in(struct comedi_device *dev)
devpriv->command5_bits |= SCLOCK_BIT;
udelay(1);
devpriv->write_byte(devpriv->command5_bits,
- dev->iobase + COMMAND5_REG);
+ dev->iobase + COMMAND5_REG);
/* clear clock bit */
devpriv->command5_bits &= ~SCLOCK_BIT;
udelay(1);
devpriv->write_byte(devpriv->command5_bits,
- dev->iobase + COMMAND5_REG);
+ dev->iobase + COMMAND5_REG);
/* read bits most significant bit first */
udelay(1);
devpriv->status2_bits =
- devpriv->read_byte(dev->iobase + STATUS2_REG);
+ devpriv->read_byte(dev->iobase + STATUS2_REG);
if (devpriv->status2_bits & EEPROM_OUT_BIT) {
value |= 1 << (value_width - i);
}
@@ -1851,7 +1872,8 @@ 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 */
@@ -1881,7 +1903,7 @@ static unsigned int labpc_eeprom_read(struct comedi_device *dev, unsigned int ad
}
static unsigned int labpc_eeprom_write(struct comedi_device *dev,
- unsigned int address, unsigned int value)
+ unsigned int address, unsigned int value)
{
const int write_enable_instruction = 0x6;
const int write_instruction = 0x2;
@@ -1893,7 +1915,7 @@ static unsigned int labpc_eeprom_write(struct comedi_device *dev,
/* 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)
+ 0)
break;
}
if (i == timeout) {
@@ -1967,7 +1989,7 @@ static unsigned int labpc_eeprom_read_status(struct comedi_device *dev)
/* writes to 8 bit calibration dacs */
static void write_caldac(struct comedi_device *dev, unsigned int channel,
- unsigned int value)
+ unsigned int value)
{
if (value == devpriv->caldac[channel])
return;
@@ -1975,7 +1997,7 @@ static void write_caldac(struct comedi_device *dev, unsigned int channel,
/* 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;
+ ~CALDAC_LOAD_BIT & ~EEPROM_EN_BIT & ~EEPROM_WRITE_UNPROTECT_BIT;
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 c5d2d212612c..82596345dcf4 100644
--- a/drivers/staging/comedi/drivers/ni_labpc.h
+++ b/drivers/staging/comedi/drivers/ni_labpc.h
@@ -30,7 +30,8 @@
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 };
+ isa_dma_transfer
+};
struct labpc_board_struct {
const char *name;
@@ -75,7 +76,7 @@ struct labpc_private {
};
int labpc_common_attach(struct comedi_device *dev, unsigned long iobase,
- unsigned int irq, unsigned int dma);
+ unsigned int irq, unsigned int dma);
int labpc_common_detach(struct comedi_device *dev);
extern const int labpc_1200_is_unipolar[];
diff --git a/drivers/staging/comedi/drivers/ni_labpc_cs.c b/drivers/staging/comedi/drivers/ni_labpc_cs.c
index fb56c03a1b9f..57aecfa883c7 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"
@@ -83,32 +83,32 @@ static int labpc_attach(struct comedi_device *dev, struct comedi_devconfig *it);
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,
+ },
};
/*
@@ -165,7 +165,7 @@ static int pc_debug = PCMCIA_DEBUG;
module_param(pc_debug, int, 0644);
#define DEBUG(n, args...) if (pc_debug>(n)) printk(KERN_DEBUG args)
static const char *version =
- "ni_labpc.c, based on dummy_cs.c 1.31 2001/08/24 12:13:13";
+ "ni_labpc.c, based on dummy_cs.c 1.31 2001/08/24 12:13:13";
#else
#define DEBUG(n, args...)
#endif
@@ -287,7 +287,7 @@ static void labpc_cs_detach(struct pcmcia_device *link)
detach().
*/
if (link->dev_node) {
- ((struct local_info_t *) link->priv)->stop = 1;
+ ((struct local_info_t *)link->priv)->stop = 1;
labpc_release(link);
}
@@ -409,7 +409,7 @@ static void labpc_config(struct pcmcia_device *link)
if ((cfg->mem.nwin > 0) || (dflt.mem.nwin > 0)) {
cistpl_mem_t *mem =
- (cfg->mem.nwin) ? &cfg->mem : &dflt.mem;
+ (cfg->mem.nwin) ? &cfg->mem : &dflt.mem;
req.Attributes = WIN_DATA_WIDTH_16 | WIN_MEMORY_TYPE_CM;
req.Attributes |= WIN_ENABLE;
req.Base = mem->win[0].host_addr;
@@ -428,7 +428,7 @@ static void labpc_config(struct pcmcia_device *link)
/* If we got this far, we're cool! */
break;
- next_entry:
+next_entry:
last_ret = pcmcia_get_next_tuple(link, &tuple);
if (last_ret) {
cs_error(link, GetNextTuple, last_ret);
@@ -470,23 +470,23 @@ static void labpc_config(struct pcmcia_device *link)
/* Finally, report what we've done */
printk(KERN_INFO "%s: index 0x%02x",
- dev->node.dev_name, link->conf.ConfigIndex);
+ dev->node.dev_name, link->conf.ConfigIndex);
if (link->conf.Attributes & CONF_ENABLE_IRQ)
printk(", irq %d", link->irq.AssignedIRQ);
if (link->io.NumPorts1)
printk(", io 0x%04x-0x%04x", link->io.BasePort1,
- link->io.BasePort1 + link->io.NumPorts1 - 1);
+ link->io.BasePort1 + link->io.NumPorts1 - 1);
if (link->io.NumPorts2)
printk(" & 0x%04x-0x%04x", link->io.BasePort2,
- link->io.BasePort2 + link->io.NumPorts2 - 1);
+ link->io.BasePort2 + link->io.NumPorts2 - 1);
if (link->win)
printk(", mem 0x%06lx-0x%06lx", req.Base,
- req.Base + req.Size - 1);
+ req.Base + req.Size - 1);
printk("\n");
return;
- cs_failed:
+cs_failed:
labpc_release(link);
} /* labpc_config */
@@ -545,7 +545,7 @@ struct pcmcia_driver labpc_cs_driver = {
.id_table = labpc_cs_ids,
.owner = THIS_MODULE,
.drv = {
- .name = dev_info,
+ .name = dev_info,
},
};
diff --git a/drivers/staging/comedi/drivers/ni_mio_common.c b/drivers/staging/comedi/drivers/ni_mio_common.c
index d727d7533fc8..e3ffb067ead1 100644
--- a/drivers/staging/comedi/drivers/ni_mio_common.c
+++ b/drivers/staging/comedi/drivers/ni_mio_common.c
@@ -77,110 +77,128 @@ static const unsigned old_RTSI_clock_channel = 7;
/* Note: this table must match the ai_gain_* definitions */
static const short ni_gainlkup[][16] = {
[ai_gain_16] = {0, 1, 2, 3, 4, 5, 6, 7,
- 0x100, 0x101, 0x102, 0x103, 0x104, 0x105, 0x106, 0x107},
+ 0x100, 0x101, 0x102, 0x103, 0x104, 0x105, 0x106, 0x107},
[ai_gain_8] = {1, 2, 4, 7, 0x101, 0x102, 0x104, 0x107},
[ai_gain_14] = {1, 2, 3, 4, 5, 6, 7,
- 0x101, 0x102, 0x103, 0x104, 0x105, 0x106, 0x107},
+ 0x101, 0x102, 0x103, 0x104, 0x105, 0x106, 0x107},
[ai_gain_4] = {0, 1, 4, 7},
[ai_gain_611x] = {0x00a, 0x00b, 0x001, 0x002,
- 0x003, 0x004, 0x005, 0x006},
+ 0x003, 0x004, 0x005, 0x006},
[ai_gain_622x] = {0, 1, 4, 5},
[ai_gain_628x] = {1, 2, 3, 4, 5, 6, 7},
[ai_gain_6143] = {0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00},
};
static const struct comedi_lrange range_ni_E_ai = { 16, {
- RANGE(-10, 10),
- RANGE(-5, 5),
- RANGE(-2.5, 2.5),
- RANGE(-1, 1),
- RANGE(-0.5, 0.5),
- RANGE(-0.25, 0.25),
- RANGE(-0.1, 0.1),
- RANGE(-0.05, 0.05),
- RANGE(0, 20),
- RANGE(0, 10),
- RANGE(0, 5),
- RANGE(0, 2),
- RANGE(0, 1),
- RANGE(0, 0.5),
- RANGE(0, 0.2),
- RANGE(0, 0.1),
- }
+ RANGE(-10, 10),
+ RANGE(-5, 5),
+ RANGE(-2.5, 2.5),
+ RANGE(-1, 1),
+ RANGE(-0.5, 0.5),
+ RANGE(-0.25, 0.25),
+ RANGE(-0.1, 0.1),
+ RANGE(-0.05, 0.05),
+ RANGE(0, 20),
+ RANGE(0, 10),
+ RANGE(0, 5),
+ RANGE(0, 2),
+ RANGE(0, 1),
+ RANGE(0, 0.5),
+ RANGE(0, 0.2),
+ RANGE(0, 0.1),
+ }
};
+
static const struct comedi_lrange range_ni_E_ai_limited = { 8, {
- RANGE(-10, 10),
- RANGE(-5, 5),
- RANGE(-1, 1),
- RANGE(-0.1, 0.1),
- RANGE(0, 10),
- RANGE(0, 5),
- RANGE(0, 1),
- RANGE(0, 0.1),
- }
+ RANGE(-10, 10),
+ RANGE(-5, 5),
+ RANGE(-1, 1),
+ RANGE(-0.1,
+ 0.1),
+ RANGE(0, 10),
+ RANGE(0, 5),
+ RANGE(0, 1),
+ RANGE(0, 0.1),
+ }
};
+
static const struct comedi_lrange range_ni_E_ai_limited14 = { 14, {
- RANGE(-10, 10),
- RANGE(-5, 5),
- RANGE(-2, 2),
- RANGE(-1, 1),
- RANGE(-0.5, 0.5),
- RANGE(-0.2, 0.2),
- RANGE(-0.1, 0.1),
- RANGE(0, 10),
- RANGE(0, 5),
- RANGE(0, 2),
- RANGE(0, 1),
- RANGE(0, 0.5),
- RANGE(0, 0.2),
- RANGE(0, 0.1),
- }
+ RANGE(-10,
+ 10),
+ RANGE(-5, 5),
+ RANGE(-2, 2),
+ RANGE(-1, 1),
+ RANGE(-0.5,
+ 0.5),
+ RANGE(-0.2,
+ 0.2),
+ RANGE(-0.1,
+ 0.1),
+ RANGE(0, 10),
+ RANGE(0, 5),
+ RANGE(0, 2),
+ RANGE(0, 1),
+ RANGE(0,
+ 0.5),
+ RANGE(0,
+ 0.2),
+ RANGE(0,
+ 0.1),
+ }
};
+
static const struct comedi_lrange range_ni_E_ai_bipolar4 = { 4, {
- RANGE(-10, 10),
- RANGE(-5, 5),
- RANGE(-0.5, 0.5),
- RANGE(-0.05, 0.05),
- }
+ RANGE(-10, 10),
+ RANGE(-5, 5),
+ RANGE(-0.5,
+ 0.5),
+ RANGE(-0.05,
+ 0.05),
+ }
};
+
static const struct comedi_lrange range_ni_E_ai_611x = { 8, {
- RANGE(-50, 50),
- RANGE(-20, 20),
- RANGE(-10, 10),
- RANGE(-5, 5),
- RANGE(-2, 2),
- RANGE(-1, 1),
- RANGE(-0.5, 0.5),
- RANGE(-0.2, 0.2),
- }
+ RANGE(-50, 50),
+ RANGE(-20, 20),
+ RANGE(-10, 10),
+ RANGE(-5, 5),
+ RANGE(-2, 2),
+ RANGE(-1, 1),
+ RANGE(-0.5, 0.5),
+ RANGE(-0.2, 0.2),
+ }
};
+
static const struct comedi_lrange range_ni_M_ai_622x = { 4, {
- RANGE(-10, 10),
- RANGE(-5, 5),
- RANGE(-1, 1),
- RANGE(-0.2, 0.2),
- }
+ RANGE(-10, 10),
+ RANGE(-5, 5),
+ RANGE(-1, 1),
+ RANGE(-0.2, 0.2),
+ }
};
+
static const struct comedi_lrange range_ni_M_ai_628x = { 7, {
- RANGE(-10, 10),
- RANGE(-5, 5),
- RANGE(-2, 2),
- RANGE(-1, 1),
- RANGE(-0.5, 0.5),
- RANGE(-0.2, 0.2),
- RANGE(-0.1, 0.1),
- }
+ RANGE(-10, 10),
+ RANGE(-5, 5),
+ RANGE(-2, 2),
+ RANGE(-1, 1),
+ RANGE(-0.5, 0.5),
+ RANGE(-0.2, 0.2),
+ RANGE(-0.1, 0.1),
+ }
};
+
static const struct comedi_lrange range_ni_S_ai_6143 = { 1, {
- RANGE(-5, +5),
- }
+ RANGE(-5, +5),
+ }
};
+
static const struct comedi_lrange range_ni_E_ao_ext = { 4, {
- RANGE(-10, 10),
- RANGE(0, 10),
- RANGE_ext(-1, 1),
- RANGE_ext(0, 1),
- }
+ RANGE(-10, 10),
+ RANGE(0, 10),
+ RANGE_ext(-1, 1),
+ RANGE_ext(0, 1),
+ }
};
static const struct comedi_lrange *const ni_range_lkup[] = {
@@ -194,46 +212,64 @@ 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_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 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,
- unsigned char data_out, unsigned char *data_in);
-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_eeprom_insn_read(struct comedi_device *dev, struct comedi_subdevice *s,
- struct comedi_insn *insn, unsigned int *data);
+ 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,
+ unsigned char data_out,
+ unsigned char *data_in);
+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_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);
+ 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 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 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);
@@ -252,53 +288,62 @@ static void ni_mio_print_status_b(int status);
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 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,
- unsigned int trignum);
-static void ni_load_channelgain_list(struct comedi_device *dev, unsigned int n_chan,
- unsigned int *list);
+ unsigned int trignum);
+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 int ni_ao_inttrig(struct comedi_device *dev, struct comedi_subdevice *s,
- unsigned int trignum);
+ unsigned int trignum);
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_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 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);
+ 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 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,
- unsigned int reg_select_bits);
+ unsigned int reg_select_bits);
#endif
static void cs5529_config_write(struct comedi_device *dev, unsigned int value,
- unsigned int reg_select_bits);
+ 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,
- unsigned period_ns);
+ 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);
@@ -355,14 +400,14 @@ enum timebase_nanoseconds {
static const int num_adc_stages_611x = 3;
static void handle_a_interrupt(struct comedi_device *dev, unsigned short status,
- unsigned ai_mite_status);
+ unsigned ai_mite_status);
static void handle_b_interrupt(struct comedi_device *dev, unsigned short status,
- unsigned ao_mite_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 inline void ni_set_bitfield(struct comedi_device *dev, int reg,
- unsigned bit_mask, unsigned bit_values)
+ unsigned bit_mask, unsigned bit_values)
{
unsigned long flags;
@@ -372,19 +417,19 @@ static inline void ni_set_bitfield(struct comedi_device *dev, int reg,
devpriv->int_a_enable_reg &= ~bit_mask;
devpriv->int_a_enable_reg |= bit_values & bit_mask;
devpriv->stc_writew(dev, devpriv->int_a_enable_reg,
- Interrupt_A_Enable_Register);
+ Interrupt_A_Enable_Register);
break;
case Interrupt_B_Enable_Register:
devpriv->int_b_enable_reg &= ~bit_mask;
devpriv->int_b_enable_reg |= bit_values & bit_mask;
devpriv->stc_writew(dev, devpriv->int_b_enable_reg,
- Interrupt_B_Enable_Register);
+ Interrupt_B_Enable_Register);
break;
case IO_Bidirection_Pin_Register:
devpriv->io_bidirection_pin_reg &= ~bit_mask;
devpriv->io_bidirection_pin_reg |= bit_values & bit_mask;
devpriv->stc_writew(dev, devpriv->io_bidirection_pin_reg,
- IO_Bidirection_Pin_Register);
+ IO_Bidirection_Pin_Register);
break;
case AI_AO_Select:
devpriv->ai_ao_select_reg &= ~bit_mask;
@@ -397,8 +442,7 @@ static inline void ni_set_bitfield(struct comedi_device *dev, int reg,
ni_writeb(devpriv->g0_g1_select_reg, G0_G1_Select);
break;
default:
- printk("Warning %s() called with invalid register\n",
- __func__);
+ printk("Warning %s() called with invalid register\n", __func__);
printk("reg is %d\n", reg);
break;
}
@@ -418,8 +462,8 @@ static inline void ni_set_ai_dma_channel(struct comedi_device *dev, int channel)
if (channel >= 0) {
bitfield =
- (ni_stc_dma_channel_select_bitfield(channel) <<
- AI_DMA_Select_Shift) & AI_DMA_Select_Mask;
+ (ni_stc_dma_channel_select_bitfield(channel) <<
+ AI_DMA_Select_Shift) & AI_DMA_Select_Mask;
} else {
bitfield = 0;
}
@@ -433,8 +477,8 @@ static inline void ni_set_ao_dma_channel(struct comedi_device *dev, int channel)
if (channel >= 0) {
bitfield =
- (ni_stc_dma_channel_select_bitfield(channel) <<
- AO_DMA_Select_Shift) & AO_DMA_Select_Mask;
+ (ni_stc_dma_channel_select_bitfield(channel) <<
+ AO_DMA_Select_Shift) & AO_DMA_Select_Mask;
} else {
bitfield = 0;
}
@@ -443,7 +487,8 @@ static inline void ni_set_ao_dma_channel(struct comedi_device *dev, int channel)
/* 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 gpct_index,
+ int mite_channel)
{
unsigned bitfield;
@@ -453,11 +498,12 @@ static inline void ni_set_gpct_dma_channel(struct comedi_device *dev,
bitfield = 0;
}
ni_set_bitfield(dev, G0_G1_Select, GPCT_DMA_Select_Mask(gpct_index),
- bitfield);
+ bitfield);
}
/* negative mite_channel means no channel */
-static inline void ni_set_cdo_dma_channel(struct comedi_device *dev, int mite_channel)
+static inline void ni_set_cdo_dma_channel(struct comedi_device *dev,
+ int mite_channel)
{
unsigned long flags;
@@ -468,8 +514,8 @@ static inline void ni_set_cdo_dma_channel(struct comedi_device *dev, int mite_ch
under the assumption the cdio dma selection works just like ai/ao/gpct.
Definitely works for dma channels 0 and 1. */
devpriv->cdio_dma_select_reg |=
- (ni_stc_dma_channel_select_bitfield(mite_channel) <<
- CDO_DMA_Select_Shift) & CDO_DMA_Select_Mask;
+ (ni_stc_dma_channel_select_bitfield(mite_channel) <<
+ CDO_DMA_Select_Shift) & CDO_DMA_Select_Mask;
}
ni_writeb(devpriv->cdio_dma_select_reg, M_Offset_CDIO_DMA_Select);
mmiowb();
@@ -483,12 +529,11 @@ static int ni_request_ai_mite_channel(struct comedi_device *dev)
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);
+ mite_request_channel(devpriv->mite, devpriv->ai_mite_ring);
if (devpriv->ai_mite_chan == NULL) {
- 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 for analog input.");
+ "failed to reserve mite dma channel for analog input.");
return -EBUSY;
}
devpriv->ai_mite_chan->dir = COMEDI_INPUT;
@@ -504,12 +549,11 @@ static int ni_request_ao_mite_channel(struct comedi_device *dev)
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);
+ mite_request_channel(devpriv->mite, devpriv->ao_mite_ring);
if (devpriv->ao_mite_chan == NULL) {
- 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 for analog outut.");
+ "failed to reserve mite dma channel for analog outut.");
return -EBUSY;
}
devpriv->ao_mite_chan->dir = COMEDI_OUTPUT;
@@ -519,7 +563,8 @@ static int ni_request_ao_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 gpct_index,
+ enum comedi_io_direction direction)
{
unsigned long flags;
struct mite_channel *mite_chan;
@@ -528,18 +573,17 @@ static int ni_request_gpct_mite_channel(struct comedi_device *dev,
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]);
+ mite_request_channel(devpriv->mite,
+ devpriv->gpct_mite_ring[gpct_index]);
if (mite_chan == NULL) {
- 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 for counter.");
+ "failed to reserve mite dma channel for counter.");
return -EBUSY;
}
mite_chan->dir = direction;
ni_tio_set_mite_channel(&devpriv->counter_dev->counters[gpct_index],
- mite_chan);
+ mite_chan);
ni_set_gpct_dma_channel(dev, gpct_index, mite_chan->channel);
spin_unlock_irqrestore(&devpriv->mite_channel_lock, flags);
return 0;
@@ -555,12 +599,11 @@ static int ni_request_cdo_mite_channel(struct comedi_device *dev)
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);
+ mite_request_channel(devpriv->mite, devpriv->cdo_mite_ring);
if (devpriv->cdo_mite_chan == NULL) {
- 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 for correlated digital outut.");
+ "failed to reserve mite dma channel for correlated digital outut.");
return -EBUSY;
}
devpriv->cdo_mite_chan->dir = COMEDI_OUTPUT;
@@ -600,7 +643,8 @@ static void ni_release_ao_mite_channel(struct comedi_device *dev)
#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;
@@ -609,11 +653,12 @@ void ni_release_gpct_mite_channel(struct comedi_device *dev, unsigned gpct_index
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;
+ devpriv->counter_dev->counters[gpct_index].mite_chan;
ni_set_gpct_dma_channel(dev, gpct_index, -1);
- ni_tio_set_mite_channel(&devpriv->counter_dev->
- counters[gpct_index], NULL);
+ ni_tio_set_mite_channel(&devpriv->
+ counter_dev->counters[gpct_index],
+ NULL);
mite_release_channel(mite_chan);
}
spin_unlock_irqrestore(&devpriv->mite_channel_lock, flags);
@@ -638,7 +683,7 @@ static void ni_release_cdo_mite_channel(struct comedi_device *dev)
/* 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,
- unsigned gpct_index, short enable)
+ unsigned gpct_index, short enable)
{
if (boardtype.reg_type & ni_reg_m_series_mask)
return;
@@ -646,19 +691,19 @@ static void ni_e_series_enable_second_irq(struct comedi_device *dev,
case 0:
if (enable) {
devpriv->stc_writew(dev, G0_Gate_Second_Irq_Enable,
- Second_IRQ_A_Enable_Register);
+ Second_IRQ_A_Enable_Register);
} else {
devpriv->stc_writew(dev, 0,
- Second_IRQ_A_Enable_Register);
+ Second_IRQ_A_Enable_Register);
}
break;
case 1:
if (enable) {
devpriv->stc_writew(dev, G1_Gate_Second_Irq_Enable,
- Second_IRQ_B_Enable_Register);
+ Second_IRQ_B_Enable_Register);
} else {
devpriv->stc_writew(dev, 0,
- Second_IRQ_B_Enable_Register);
+ Second_IRQ_B_Enable_Register);
}
break;
default:
@@ -684,11 +729,11 @@ static void ni_clear_ai_fifo(struct comedi_device *dev)
/* the NI example code does 3 convert pulses for 625x boards,
but that appears to be wrong in practice. */
devpriv->stc_writew(dev, AI_CONVERT_Pulse,
- AI_Command_1_Register);
+ AI_Command_1_Register);
devpriv->stc_writew(dev, AI_CONVERT_Pulse,
- AI_Command_1_Register);
+ AI_Command_1_Register);
devpriv->stc_writew(dev, AI_CONVERT_Pulse,
- AI_Command_1_Register);
+ AI_Command_1_Register);
#endif
}
}
@@ -709,7 +754,8 @@ static uint32_t win_in2(struct comedi_device *dev, int reg)
}
#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)
+static inline void ni_ao_win_outw(struct comedi_device *dev, uint16_t data,
+ int addr)
{
unsigned long flags;
@@ -719,7 +765,8 @@ static inline void ni_ao_win_outw(struct comedi_device *dev, uint16_t data, int
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;
@@ -751,8 +798,8 @@ 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,
- unsigned value)
+static inline void ni_set_bits(struct comedi_device *dev, int reg,
+ unsigned bits, unsigned value)
{
unsigned bit_values;
@@ -792,17 +839,17 @@ static irqreturn_t ni_E_interrupt(int irq, void *d)
ai_mite_status = mite_get_status(devpriv->ai_mite_chan);
if (ai_mite_status & CHSR_LINKC)
writel(CHOR_CLRLC,
- devpriv->mite->mite_io_addr +
- MITE_CHOR(devpriv->ai_mite_chan->
- channel));
+ devpriv->mite->mite_io_addr +
+ MITE_CHOR(devpriv->
+ ai_mite_chan->channel));
}
if (devpriv->ao_mite_chan) {
ao_mite_status = mite_get_status(devpriv->ao_mite_chan);
if (ao_mite_status & CHSR_LINKC)
writel(CHOR_CLRLC,
- mite->mite_io_addr +
- MITE_CHOR(devpriv->ao_mite_chan->
- channel));
+ mite->mite_io_addr +
+ MITE_CHOR(devpriv->
+ ao_mite_chan->channel));
}
spin_unlock_irqrestore(&devpriv->mite_channel_lock, flags_too);
}
@@ -833,7 +880,8 @@ static void ni_sync_ai_dma(struct comedi_device *dev)
spin_unlock_irqrestore(&devpriv->mite_channel_lock, flags);
}
-static void mite_handle_b_linkc(struct mite_struct *mite, struct comedi_device * dev)
+static void mite_handle_b_linkc(struct mite_struct *mite,
+ struct comedi_device *dev)
{
struct comedi_subdevice *s = dev->subdevices + NI_AO_SUBDEV;
unsigned long flags;
@@ -907,9 +955,9 @@ static void shutdown_ai_command(struct comedi_device *dev)
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))
- {
+ if (s->
+ async->events & (COMEDI_CB_ERROR | COMEDI_CB_OVERFLOW |
+ COMEDI_CB_EOA)) {
switch (s - dev->subdevices) {
case NI_AI_SUBDEV:
ni_ai_reset(dev, s);
@@ -932,13 +980,14 @@ static void ni_event(struct comedi_device *dev, struct comedi_subdevice *s)
}
static void handle_gpct_interrupt(struct comedi_device *dev,
- unsigned short counter_index)
+ unsigned short counter_index)
{
#ifdef PCIDMA
- struct comedi_subdevice *s = dev->subdevices + NI_GPCT_SUBDEV(counter_index);
+ struct comedi_subdevice *s =
+ dev->subdevices + NI_GPCT_SUBDEV(counter_index);
ni_tio_handle_interrupt(&devpriv->counter_dev->counters[counter_index],
- s);
+ s);
if (s->async->events)
ni_event(dev, s);
#endif
@@ -966,7 +1015,7 @@ static void ack_a_interrupt(struct comedi_device *dev, unsigned short a_status)
}
static void handle_a_interrupt(struct comedi_device *dev, unsigned short status,
- unsigned ai_mite_status)
+ unsigned ai_mite_status)
{
struct comedi_subdevice *s = dev->subdevices + NI_AI_SUBDEV;
@@ -976,8 +1025,8 @@ static void handle_a_interrupt(struct comedi_device *dev, unsigned short status,
#ifdef DEBUG_INTERRUPT
printk
- ("ni_mio_common: interrupt: a_status=%04x ai_mite_status=%08x\n",
- status, ai_mite_status);
+ ("ni_mio_common: interrupt: a_status=%04x ai_mite_status=%08x\n",
+ status, ai_mite_status);
ni_mio_print_status_a(status);
#endif
#ifdef PCIDMA
@@ -986,11 +1035,11 @@ 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)) {
+ CHSR_DRDY | CHSR_DRQ1 | CHSR_DRQ0 | CHSR_ERROR |
+ CHSR_SABORT | CHSR_XFERR | CHSR_LxERR_mask)) {
printk
- ("unknown mite interrupt, ack! (ai_mite_status=%08x)\n",
- ai_mite_status);
+ ("unknown mite interrupt, ack! (ai_mite_status=%08x)\n",
+ ai_mite_status);
/* mite_print_chsr(ai_mite_status); */
s->async->events |= COMEDI_CB_ERROR | COMEDI_CB_EOA;
/* disable_irq(dev->irq); */
@@ -999,23 +1048,23 @@ static void handle_a_interrupt(struct comedi_device *dev, unsigned short status,
/* test for all uncommon interrupt events at the same time */
if (status & (AI_Overrun_St | AI_Overflow_St | AI_SC_TC_Error_St |
- AI_SC_TC_St | AI_START1_St)) {
+ AI_SC_TC_St | AI_START1_St)) {
if (status == 0xffff) {
printk
- ("ni_mio_common: a_status=0xffff. Card removed?\n");
+ ("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. */
if (comedi_get_subdevice_runflags(s) & SRF_RUNNING) {
s->async->events |=
- COMEDI_CB_ERROR | COMEDI_CB_EOA;
+ COMEDI_CB_ERROR | COMEDI_CB_EOA;
ni_event(dev, s);
}
return;
}
if (status & (AI_Overrun_St | AI_Overflow_St |
- AI_SC_TC_Error_St)) {
+ AI_SC_TC_Error_St)) {
printk("ni_mio_common: ai error a_status=%04x\n",
- status);
+ status);
ni_mio_print_status_a(status);
shutdown_ai_command(dev);
@@ -1047,7 +1096,7 @@ static void handle_a_interrupt(struct comedi_device *dev, unsigned short status,
ni_handle_fifo_half_full(dev);
if ((devpriv->stc_readw(dev,
AI_Status_1_Register) &
- AI_FIFO_Half_Full_St) == 0)
+ AI_FIFO_Half_Full_St) == 0)
break;
}
}
@@ -1063,8 +1112,8 @@ static void handle_a_interrupt(struct comedi_device *dev, unsigned short status,
status = devpriv->stc_readw(dev, AI_Status_1_Register);
if (status & Interrupt_A_St) {
printk
- ("handle_a_interrupt: didn't clear interrupt? status=0x%x\n",
- status);
+ ("handle_a_interrupt: didn't clear interrupt? status=0x%x\n",
+ status);
}
#endif
}
@@ -1097,14 +1146,14 @@ 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,
- unsigned ao_mite_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; */
#ifdef DEBUG_INTERRUPT
printk("ni_mio_common: interrupt: b_status=%04x m1_status=%08x\n",
- b_status, ao_mite_status);
+ b_status, ao_mite_status);
ni_mio_print_status_b(b_status);
#endif
@@ -1115,11 +1164,11 @@ static void handle_b_interrupt(struct comedi_device *dev, unsigned short b_statu
}
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)) {
+ CHSR_DRDY | CHSR_DRQ1 | CHSR_DRQ0 | CHSR_ERROR |
+ CHSR_SABORT | CHSR_XFERR | CHSR_LxERR_mask)) {
printk
- ("unknown mite interrupt, ack! (ao_mite_status=%08x)\n",
- ao_mite_status);
+ ("unknown mite interrupt, ack! (ao_mite_status=%08x)\n",
+ ao_mite_status);
/* mite_print_chsr(ao_mite_status); */
s->async->events |= COMEDI_CB_EOA | COMEDI_CB_ERROR;
}
@@ -1129,14 +1178,15 @@ static void handle_b_interrupt(struct comedi_device *dev, unsigned short b_statu
return;
if (b_status & AO_Overrun_St) {
printk
- ("ni_mio_common: AO FIFO underrun status=0x%04x status2=0x%04x\n",
- b_status, devpriv->stc_readw(dev,
- AO_Status_2_Register));
+ ("ni_mio_common: AO FIFO underrun status=0x%04x status2=0x%04x\n",
+ b_status, devpriv->stc_readw(dev, AO_Status_2_Register));
s->async->events |= COMEDI_CB_OVERFLOW;
}
if (b_status & AO_BC_TC_St) {
- MDPRINTK("ni_mio_common: AO BC_TC status=0x%04x status2=0x%04x\n", b_status, devpriv->stc_readw(dev, AO_Status_2_Register));
+ MDPRINTK
+ ("ni_mio_common: AO BC_TC status=0x%04x status2=0x%04x\n",
+ b_status, devpriv->stc_readw(dev, AO_Status_2_Register));
s->async->events |= COMEDI_CB_EOA;
}
#ifndef PCIDMA
@@ -1147,8 +1197,8 @@ static void handle_b_interrupt(struct comedi_device *dev, unsigned short b_statu
if (!ret) {
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);
+ AO_FIFO_Interrupt_Enable |
+ AO_Error_Interrupt_Enable, 0);
s->async->events |= COMEDI_CB_OVERFLOW;
}
}
@@ -1203,7 +1253,8 @@ static void ni_mio_print_status_b(int status)
#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;
@@ -1262,7 +1313,8 @@ 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;
@@ -1283,7 +1335,8 @@ static int ni_ao_fifo_half_empty(struct comedi_device *dev, struct comedi_subdev
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;
@@ -1306,7 +1359,8 @@ static int ni_ao_prep_fifo(struct comedi_device *dev, struct comedi_subdevice *s
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;
@@ -1349,17 +1403,18 @@ static void ni_ai_fifo_read(struct comedi_device *dev, struct comedi_subdevice *
}
} else {
if (n > sizeof(devpriv->ai_fifo_buffer) /
- sizeof(devpriv->ai_fifo_buffer[0])) {
+ sizeof(devpriv->ai_fifo_buffer[0])) {
comedi_error(dev, "bug! ai_fifo_buffer too small");
async->events |= COMEDI_CB_ERROR;
return;
}
for (i = 0; i < n; i++) {
devpriv->ai_fifo_buffer[i] =
- ni_readw(ADC_FIFO_Data_Register);
+ ni_readw(ADC_FIFO_Data_Register);
}
cfc_write_array_to_buffer(s, devpriv->ai_fifo_buffer,
- n * sizeof(devpriv->ai_fifo_buffer[0]));
+ n *
+ sizeof(devpriv->ai_fifo_buffer[0]));
}
}
@@ -1387,19 +1442,18 @@ static int ni_ai_drain_dma(struct comedi_device *dev)
for (i = 0; i < timeout; i++) {
if ((devpriv->stc_readw(dev,
AI_Status_1_Register) &
- AI_FIFO_Empty_St)
- && mite_bytes_in_transit(devpriv->
- ai_mite_chan) == 0)
+ AI_FIFO_Empty_St)
+ && mite_bytes_in_transit(devpriv->ai_mite_chan) ==
+ 0)
break;
udelay(5);
}
if (i == timeout) {
+ printk("ni_mio_common: wait for dma drain timed out\n");
printk
- ("ni_mio_common: wait for dma drain timed out\n");
- 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));
+ ("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;
}
}
@@ -1423,8 +1477,8 @@ static void ni_handle_fifo_dregs(struct comedi_device *dev)
if (boardtype.reg_type == ni_reg_611x) {
while ((devpriv->stc_readw(dev,
- AI_Status_1_Register) &
- AI_FIFO_Empty_St) == 0) {
+ AI_Status_1_Register) &
+ AI_FIFO_Empty_St) == 0) {
dl = ni_readl(ADC_FIFO_Data_611x);
/* This may get the hi/lo data in the wrong order */
@@ -1453,24 +1507,26 @@ static void ni_handle_fifo_dregs(struct comedi_device *dev)
} else {
fifo_empty =
- devpriv->stc_readw(dev,
- AI_Status_1_Register) & AI_FIFO_Empty_St;
+ devpriv->stc_readw(dev,
+ AI_Status_1_Register) & AI_FIFO_Empty_St;
while (fifo_empty == 0) {
for (i = 0;
- i <
- sizeof(devpriv->ai_fifo_buffer) /
- sizeof(devpriv->ai_fifo_buffer[0]); i++) {
+ i <
+ sizeof(devpriv->ai_fifo_buffer) /
+ sizeof(devpriv->ai_fifo_buffer[0]); i++) {
fifo_empty =
- devpriv->stc_readw(dev,
- AI_Status_1_Register) &
- AI_FIFO_Empty_St;
+ devpriv->stc_readw(dev,
+ AI_Status_1_Register) &
+ AI_FIFO_Empty_St;
if (fifo_empty)
break;
devpriv->ai_fifo_buffer[i] =
- ni_readw(ADC_FIFO_Data_Register);
+ ni_readw(ADC_FIFO_Data_Register);
}
cfc_write_array_to_buffer(s, devpriv->ai_fifo_buffer,
- i * sizeof(devpriv->ai_fifo_buffer[0]));
+ i *
+ sizeof(devpriv->
+ ai_fifo_buffer[0]));
}
}
}
@@ -1513,7 +1569,8 @@ static void get_last_sample_6143(struct comedi_device *dev)
}
static void ni_ai_munge(struct comedi_device *dev, struct comedi_subdevice *s,
- void *data, unsigned int num_bytes, unsigned int chan_index)
+ void *data, unsigned int num_bytes,
+ unsigned int chan_index)
{
struct comedi_async *async = s->async;
unsigned int i;
@@ -1620,13 +1677,13 @@ static int ni_ai_reset(struct comedi_device *dev, struct comedi_subdevice *s)
ni_release_ai_mite_channel(dev);
/* ai configuration */
devpriv->stc_writew(dev, AI_Configuration_Start | AI_Reset,
- Joint_Reset_Register);
+ Joint_Reset_Register);
ni_set_bits(dev, Interrupt_A_Enable_Register,
- AI_SC_TC_Interrupt_Enable | AI_START1_Interrupt_Enable |
- AI_START2_Interrupt_Enable | AI_START_Interrupt_Enable |
- AI_STOP_Interrupt_Enable | AI_Error_Interrupt_Enable |
- AI_FIFO_Interrupt_Enable, 0);
+ AI_SC_TC_Interrupt_Enable | AI_START1_Interrupt_Enable |
+ AI_START2_Interrupt_Enable | AI_START_Interrupt_Enable |
+ AI_STOP_Interrupt_Enable | AI_Error_Interrupt_Enable |
+ AI_FIFO_Interrupt_Enable, 0);
ni_clear_ai_fifo(dev);
@@ -1635,51 +1692,60 @@ static int ni_ai_reset(struct comedi_device *dev, struct comedi_subdevice *s)
devpriv->stc_writew(dev, AI_Disarm, AI_Command_1_Register); /* reset pulses */
devpriv->stc_writew(dev,
- AI_Start_Stop | AI_Mode_1_Reserved /*| AI_Trigger_Once */ ,
- AI_Mode_1_Register);
+ AI_Start_Stop | AI_Mode_1_Reserved
+ /*| AI_Trigger_Once */ ,
+ AI_Mode_1_Register);
devpriv->stc_writew(dev, 0x0000, AI_Mode_2_Register);
/* generate FIFO interrupts on non-empty */
devpriv->stc_writew(dev, (0 << 6) | 0x0000, AI_Mode_3_Register);
if (boardtype.reg_type == ni_reg_611x) {
devpriv->stc_writew(dev, AI_SHIFTIN_Pulse_Width |
- AI_SOC_Polarity |
- AI_LOCALMUX_CLK_Pulse_Width, AI_Personal_Register);
- devpriv->stc_writew(dev, AI_SCAN_IN_PROG_Output_Select(3) |
- AI_EXTMUX_CLK_Output_Select(0) |
- AI_LOCALMUX_CLK_Output_Select(2) |
- AI_SC_TC_Output_Select(3) |
- AI_CONVERT_Output_Select(AI_CONVERT_Output_Enable_High),
- AI_Output_Control_Register);
+ AI_SOC_Polarity |
+ AI_LOCALMUX_CLK_Pulse_Width,
+ AI_Personal_Register);
+ devpriv->stc_writew(dev,
+ AI_SCAN_IN_PROG_Output_Select(3) |
+ AI_EXTMUX_CLK_Output_Select(0) |
+ AI_LOCALMUX_CLK_Output_Select(2) |
+ AI_SC_TC_Output_Select(3) |
+ AI_CONVERT_Output_Select
+ (AI_CONVERT_Output_Enable_High),
+ AI_Output_Control_Register);
} else if (boardtype.reg_type == ni_reg_6143) {
devpriv->stc_writew(dev, AI_SHIFTIN_Pulse_Width |
- AI_SOC_Polarity |
- AI_LOCALMUX_CLK_Pulse_Width, AI_Personal_Register);
- devpriv->stc_writew(dev, AI_SCAN_IN_PROG_Output_Select(3) |
- AI_EXTMUX_CLK_Output_Select(0) |
- AI_LOCALMUX_CLK_Output_Select(2) |
- AI_SC_TC_Output_Select(3) |
- AI_CONVERT_Output_Select(AI_CONVERT_Output_Enable_Low),
- AI_Output_Control_Register);
+ AI_SOC_Polarity |
+ AI_LOCALMUX_CLK_Pulse_Width,
+ AI_Personal_Register);
+ devpriv->stc_writew(dev,
+ AI_SCAN_IN_PROG_Output_Select(3) |
+ AI_EXTMUX_CLK_Output_Select(0) |
+ AI_LOCALMUX_CLK_Output_Select(2) |
+ AI_SC_TC_Output_Select(3) |
+ AI_CONVERT_Output_Select
+ (AI_CONVERT_Output_Enable_Low),
+ AI_Output_Control_Register);
} else {
unsigned ai_output_control_bits;
devpriv->stc_writew(dev, AI_SHIFTIN_Pulse_Width |
- AI_SOC_Polarity |
- AI_CONVERT_Pulse_Width |
- AI_LOCALMUX_CLK_Pulse_Width, AI_Personal_Register);
- ai_output_control_bits = AI_SCAN_IN_PROG_Output_Select(3) |
- AI_EXTMUX_CLK_Output_Select(0) |
- AI_LOCALMUX_CLK_Output_Select(2) |
- AI_SC_TC_Output_Select(3);
+ AI_SOC_Polarity |
+ AI_CONVERT_Pulse_Width |
+ AI_LOCALMUX_CLK_Pulse_Width,
+ AI_Personal_Register);
+ ai_output_control_bits =
+ AI_SCAN_IN_PROG_Output_Select(3) |
+ AI_EXTMUX_CLK_Output_Select(0) |
+ AI_LOCALMUX_CLK_Output_Select(2) |
+ AI_SC_TC_Output_Select(3);
if (boardtype.reg_type == ni_reg_622x)
ai_output_control_bits |=
- AI_CONVERT_Output_Select
- (AI_CONVERT_Output_Enable_High);
+ AI_CONVERT_Output_Select
+ (AI_CONVERT_Output_Enable_High);
else
ai_output_control_bits |=
- AI_CONVERT_Output_Select
- (AI_CONVERT_Output_Enable_Low);
+ AI_CONVERT_Output_Select
+ (AI_CONVERT_Output_Enable_Low);
devpriv->stc_writew(dev, ai_output_control_bits,
- AI_Output_Control_Register);
+ AI_Output_Control_Register);
}
/* the following registers should not be changed, because there
* are no backup registers in devpriv. If you want to change
@@ -1716,8 +1782,9 @@ static int ni_ai_poll(struct comedi_device *dev, struct comedi_subdevice *s)
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;
@@ -1733,31 +1800,31 @@ static int ni_ai_insn_read(struct comedi_device *dev, struct comedi_subdevice *s
if (boardtype.reg_type == ni_reg_611x) {
for (n = 0; n < num_adc_stages_611x; n++) {
devpriv->stc_writew(dev, AI_CONVERT_Pulse,
- AI_Command_1_Register);
+ AI_Command_1_Register);
udelay(1);
}
for (n = 0; n < insn->n; n++) {
devpriv->stc_writew(dev, AI_CONVERT_Pulse,
- AI_Command_1_Register);
+ AI_Command_1_Register);
/* The 611x has screwy 32-bit FIFOs. */
d = 0;
for (i = 0; i < NI_TIMEOUT; i++) {
if (ni_readb(XXX_Status) & 0x80) {
d = (ni_readl(ADC_FIFO_Data_611x) >> 16)
- & 0xffff;
+ & 0xffff;
break;
}
if (!(devpriv->stc_readw(dev,
- AI_Status_1_Register) &
- AI_FIFO_Empty_St)) {
+ AI_Status_1_Register) &
+ AI_FIFO_Empty_St)) {
d = ni_readl(ADC_FIFO_Data_611x) &
- 0xffff;
+ 0xffff;
break;
}
}
if (i == NI_TIMEOUT) {
printk
- ("ni_mio_common: timeout in 611x ni_ai_insn_read\n");
+ ("ni_mio_common: timeout in 611x ni_ai_insn_read\n");
return -ETIME;
}
d += signbits;
@@ -1766,7 +1833,7 @@ static int ni_ai_insn_read(struct comedi_device *dev, struct comedi_subdevice *s
} else if (boardtype.reg_type == ni_reg_6143) {
for (n = 0; n < insn->n; n++) {
devpriv->stc_writew(dev, AI_CONVERT_Pulse,
- AI_Command_1_Register);
+ AI_Command_1_Register);
/* The 6143 has 32-bit FIFOs. You need to strobe a bit to move a single 16bit stranded sample into the FIFO */
dl = 0;
@@ -1779,7 +1846,7 @@ static int ni_ai_insn_read(struct comedi_device *dev, struct comedi_subdevice *s
}
if (i == NI_TIMEOUT) {
printk
- ("ni_mio_common: timeout in 6143 ni_ai_insn_read\n");
+ ("ni_mio_common: timeout in 6143 ni_ai_insn_read\n");
return -ETIME;
}
data[n] = (((dl >> 16) & 0xFFFF) + signbits) & 0xFFFF;
@@ -1787,21 +1854,21 @@ static int ni_ai_insn_read(struct comedi_device *dev, struct comedi_subdevice *s
} else {
for (n = 0; n < insn->n; n++) {
devpriv->stc_writew(dev, AI_CONVERT_Pulse,
- AI_Command_1_Register);
+ AI_Command_1_Register);
for (i = 0; i < NI_TIMEOUT; i++) {
if (!(devpriv->stc_readw(dev,
- AI_Status_1_Register) &
- AI_FIFO_Empty_St))
+ AI_Status_1_Register) &
+ AI_FIFO_Empty_St))
break;
}
if (i == NI_TIMEOUT) {
printk
- ("ni_mio_common: timeout in ni_ai_insn_read\n");
+ ("ni_mio_common: timeout in ni_ai_insn_read\n");
return -ETIME;
}
if (boardtype.reg_type & ni_reg_m_series_mask) {
data[n] =
- ni_readl(M_Offset_AI_FIFO_Data) & mask;
+ ni_readl(M_Offset_AI_FIFO_Data) & mask;
} else {
d = ni_readw(ADC_FIFO_Data_Register);
d += signbits; /* subtle: needs to be short addition */
@@ -1818,8 +1885,8 @@ void ni_prime_channelgain_list(struct comedi_device *dev)
devpriv->stc_writew(dev, AI_CONVERT_Pulse, AI_Command_1_Register);
for (i = 0; i < NI_TIMEOUT; ++i) {
if (!(devpriv->stc_readw(dev,
- AI_Status_1_Register) &
- AI_FIFO_Empty_St)) {
+ AI_Status_1_Register) &
+ AI_FIFO_Empty_St)) {
devpriv->stc_writew(dev, 1, ADC_FIFO_Clear);
return;
}
@@ -1829,7 +1896,8 @@ void ni_prime_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 n_chan,
+ unsigned int *list)
{
unsigned int chan, range, aref;
unsigned int i;
@@ -1849,11 +1917,11 @@ static void ni_m_series_load_channelgain_list(struct comedi_device *dev,
bypass_bits = MSeries_AI_Bypass_Config_FIFO_Bit;
bypass_bits |= chan;
bypass_bits |=
- (devpriv->
- ai_calib_source) & (MSeries_AI_Bypass_Cal_Sel_Pos_Mask |
- MSeries_AI_Bypass_Cal_Sel_Neg_Mask |
- MSeries_AI_Bypass_Mode_Mux_Mask |
- MSeries_AO_Bypass_AO_Cal_Sel_Mask);
+ (devpriv->ai_calib_source) &
+ (MSeries_AI_Bypass_Cal_Sel_Pos_Mask |
+ MSeries_AI_Bypass_Cal_Sel_Neg_Mask |
+ MSeries_AI_Bypass_Mode_Mux_Mask |
+ MSeries_AO_Bypass_AO_Cal_Sel_Mask);
bypass_bits |= MSeries_AI_Bypass_Gain_Bits(range_code);
if (dither)
bypass_bits |= MSeries_AI_Bypass_Dither_Bit;
@@ -1876,22 +1944,22 @@ static void ni_m_series_load_channelgain_list(struct comedi_device *dev,
switch (aref) {
case AREF_DIFF:
config_bits |=
- MSeries_AI_Config_Channel_Type_Differential_Bits;
+ MSeries_AI_Config_Channel_Type_Differential_Bits;
break;
case AREF_COMMON:
config_bits |=
- MSeries_AI_Config_Channel_Type_Common_Ref_Bits;
+ MSeries_AI_Config_Channel_Type_Common_Ref_Bits;
break;
case AREF_GROUND:
config_bits |=
- MSeries_AI_Config_Channel_Type_Ground_Ref_Bits;
+ MSeries_AI_Config_Channel_Type_Ground_Ref_Bits;
break;
case AREF_OTHER:
break;
}
config_bits |= MSeries_AI_Config_Channel_Bits(chan);
config_bits |=
- MSeries_AI_Config_Bank_Bits(boardtype.reg_type, chan);
+ MSeries_AI_Config_Bank_Bits(boardtype.reg_type, chan);
config_bits |= MSeries_AI_Config_Gain_Bits(range_code);
if (i == n_chan - 1)
config_bits |= MSeries_AI_Config_Last_Channel_Bit;
@@ -1933,8 +2001,8 @@ 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,
- unsigned int *list)
+static void ni_load_channelgain_list(struct comedi_device *dev,
+ unsigned int n_chan, unsigned int *list)
{
unsigned int chan, range, aref;
unsigned int i;
@@ -1947,9 +2015,9 @@ static void ni_load_channelgain_list(struct comedi_device *dev, unsigned int n_c
return;
}
if (n_chan == 1 && (boardtype.reg_type != ni_reg_611x)
- && (boardtype.reg_type != ni_reg_6143)) {
+ && (boardtype.reg_type != ni_reg_6143)) {
if (devpriv->changain_state
- && devpriv->changain_spec == list[0]) {
+ && devpriv->changain_spec == list[0]) {
/* ready to go. */
return;
}
@@ -1964,25 +2032,23 @@ static void ni_load_channelgain_list(struct comedi_device *dev, unsigned int n_c
/* Set up Calibration mode if required */
if (boardtype.reg_type == ni_reg_6143) {
if ((list[0] & CR_ALT_SOURCE)
- && !devpriv->ai_calib_source_enabled) {
+ && !devpriv->ai_calib_source_enabled) {
/* Strobe Relay enable bit */
- ni_writew(devpriv->
- ai_calib_source |
- Calibration_Channel_6143_RelayOn,
- Calibration_Channel_6143);
+ ni_writew(devpriv->ai_calib_source |
+ Calibration_Channel_6143_RelayOn,
+ Calibration_Channel_6143);
ni_writew(devpriv->ai_calib_source,
- Calibration_Channel_6143);
+ Calibration_Channel_6143);
devpriv->ai_calib_source_enabled = 1;
msleep_interruptible(100); /* Allow relays to change */
} else if (!(list[0] & CR_ALT_SOURCE)
- && devpriv->ai_calib_source_enabled) {
+ && devpriv->ai_calib_source_enabled) {
/* Strobe Relay disable bit */
- ni_writew(devpriv->
- ai_calib_source |
- Calibration_Channel_6143_RelayOff,
- Calibration_Channel_6143);
+ ni_writew(devpriv->ai_calib_source |
+ Calibration_Channel_6143_RelayOff,
+ Calibration_Channel_6143);
ni_writew(devpriv->ai_calib_source,
- Calibration_Channel_6143);
+ Calibration_Channel_6143);
devpriv->ai_calib_source_enabled = 0;
msleep_interruptible(100); /* Allow relays to change */
}
@@ -1991,7 +2057,7 @@ static void ni_load_channelgain_list(struct comedi_device *dev, unsigned int n_c
offset = 1 << (boardtype.adbits - 1);
for (i = 0; i < n_chan; i++) {
if ((boardtype.reg_type != ni_reg_6143)
- && (list[i] & CR_ALT_SOURCE)) {
+ && (list[i] & CR_ALT_SOURCE)) {
chan = devpriv->ai_calib_source;
} else {
chan = CR_CHAN(list[i]);
@@ -2011,7 +2077,7 @@ static void ni_load_channelgain_list(struct comedi_device *dev, unsigned int n_c
if ((list[i] & CR_ALT_SOURCE)) {
if (boardtype.reg_type == ni_reg_611x)
ni_writew(CR_CHAN(list[i]) & 0x0003,
- Calibration_Channel_Select_611x);
+ Calibration_Channel_Select_611x);
} else {
if (boardtype.reg_type == ni_reg_611x)
aref = AREF_DIFF;
@@ -2048,13 +2114,13 @@ static void ni_load_channelgain_list(struct comedi_device *dev, unsigned int n_c
/* prime the channel/gain list */
if ((boardtype.reg_type != ni_reg_611x)
- && (boardtype.reg_type != ni_reg_6143)) {
+ && (boardtype.reg_type != ni_reg_6143)) {
ni_prime_channelgain_list(dev);
}
}
static int ni_ns_to_timer(const struct comedi_device *dev, unsigned nanosec,
- int round_mode)
+ int round_mode)
{
int divider;
switch (round_mode) {
@@ -2078,7 +2144,7 @@ static unsigned ni_timer_to_ns(const struct comedi_device *dev, int timer)
}
static unsigned ni_min_ai_scan_period_ns(struct comedi_device *dev,
- unsigned num_channels)
+ unsigned num_channels)
{
switch (boardtype.reg_type) {
case ni_reg_611x:
@@ -2094,7 +2160,7 @@ static unsigned ni_min_ai_scan_period_ns(struct comedi_device *dev,
}
static int ni_ai_cmdtest(struct comedi_device *dev, struct comedi_subdevice *s,
- struct comedi_cmd *cmd)
+ struct comedi_cmd *cmd)
{
int err = 0;
int tmp;
@@ -2119,7 +2185,7 @@ static int ni_ai_cmdtest(struct comedi_device *dev, struct comedi_subdevice *s,
tmp = cmd->convert_src;
sources = TRIG_TIMER | TRIG_EXT;
if ((boardtype.reg_type == ni_reg_611x)
- || (boardtype.reg_type == ni_reg_6143))
+ || (boardtype.reg_type == ni_reg_6143))
sources |= TRIG_NOW;
cmd->convert_src &= sources;
if (!cmd->convert_src || tmp != cmd->convert_src)
@@ -2142,14 +2208,14 @@ static int ni_ai_cmdtest(struct comedi_device *dev, struct comedi_subdevice *s,
/* note that mutual compatiblity is not an issue here */
if (cmd->start_src != TRIG_NOW &&
- cmd->start_src != TRIG_INT && cmd->start_src != TRIG_EXT)
+ cmd->start_src != TRIG_INT && cmd->start_src != TRIG_EXT)
err++;
if (cmd->scan_begin_src != TRIG_TIMER &&
- cmd->scan_begin_src != TRIG_EXT &&
- cmd->scan_begin_src != TRIG_OTHER)
+ cmd->scan_begin_src != TRIG_EXT &&
+ cmd->scan_begin_src != TRIG_OTHER)
err++;
if (cmd->convert_src != TRIG_TIMER &&
- cmd->convert_src != TRIG_EXT && cmd->convert_src != TRIG_NOW)
+ cmd->convert_src != TRIG_EXT && cmd->convert_src != TRIG_NOW)
err++;
if (cmd->stop_src != TRIG_COUNT && cmd->stop_src != TRIG_NONE)
err++;
@@ -2179,10 +2245,11 @@ static int ni_ai_cmdtest(struct comedi_device *dev, struct comedi_subdevice *s,
}
if (cmd->scan_begin_src == TRIG_TIMER) {
if (cmd->scan_begin_arg < ni_min_ai_scan_period_ns(dev,
- cmd->chanlist_len)) {
+ cmd->
+ chanlist_len))
+ {
cmd->scan_begin_arg =
- ni_min_ai_scan_period_ns(dev,
- cmd->chanlist_len);
+ ni_min_ai_scan_period_ns(dev, cmd->chanlist_len);
err++;
}
if (cmd->scan_begin_arg > devpriv->clock_ns * 0xffffff) {
@@ -2208,7 +2275,7 @@ static int ni_ai_cmdtest(struct comedi_device *dev, struct comedi_subdevice *s,
}
if (cmd->convert_src == TRIG_TIMER) {
if ((boardtype.reg_type == ni_reg_611x)
- || (boardtype.reg_type == ni_reg_6143)) {
+ || (boardtype.reg_type == ni_reg_6143)) {
if (cmd->convert_arg != 0) {
cmd->convert_arg = 0;
err++;
@@ -2274,27 +2341,31 @@ static int ni_ai_cmdtest(struct comedi_device *dev, struct comedi_subdevice *s,
if (cmd->scan_begin_src == TRIG_TIMER) {
tmp = cmd->scan_begin_arg;
cmd->scan_begin_arg =
- ni_timer_to_ns(dev, ni_ns_to_timer(dev,
- cmd->scan_begin_arg,
- cmd->flags & TRIG_ROUND_MASK));
+ ni_timer_to_ns(dev, ni_ns_to_timer(dev,
+ cmd->scan_begin_arg,
+ cmd->
+ flags &
+ TRIG_ROUND_MASK));
if (tmp != cmd->scan_begin_arg)
err++;
}
if (cmd->convert_src == TRIG_TIMER) {
if ((boardtype.reg_type != ni_reg_611x)
- && (boardtype.reg_type != ni_reg_6143)) {
+ && (boardtype.reg_type != ni_reg_6143)) {
tmp = cmd->convert_arg;
cmd->convert_arg =
- ni_timer_to_ns(dev, ni_ns_to_timer(dev,
- cmd->convert_arg,
- cmd->flags & TRIG_ROUND_MASK));
+ ni_timer_to_ns(dev, ni_ns_to_timer(dev,
+ cmd->convert_arg,
+ cmd->
+ flags &
+ TRIG_ROUND_MASK));
if (tmp != cmd->convert_arg)
err++;
if (cmd->scan_begin_src == TRIG_TIMER &&
- cmd->scan_begin_arg <
- cmd->convert_arg * cmd->scan_end_arg) {
+ cmd->scan_begin_arg <
+ cmd->convert_arg * cmd->scan_end_arg) {
cmd->scan_begin_arg =
- cmd->convert_arg * cmd->scan_end_arg;
+ cmd->convert_arg * cmd->scan_end_arg;
err++;
}
}
@@ -2332,27 +2403,28 @@ static int ni_ai_cmd(struct comedi_device *dev, struct comedi_subdevice *s)
* interferes with the use of pfi0 */
devpriv->an_trig_etc_reg &= ~Analog_Trigger_Enable;
devpriv->stc_writew(dev, devpriv->an_trig_etc_reg,
- Analog_Trigger_Etc_Register);
+ Analog_Trigger_Etc_Register);
switch (cmd->start_src) {
case TRIG_INT:
case TRIG_NOW:
devpriv->stc_writew(dev, AI_START2_Select(0) |
- AI_START1_Sync | AI_START1_Edge | AI_START1_Select(0),
- AI_Trigger_Select_Register);
+ AI_START1_Sync | AI_START1_Edge |
+ AI_START1_Select(0),
+ AI_Trigger_Select_Register);
break;
case TRIG_EXT:
{
int chan = CR_CHAN(cmd->start_arg);
unsigned int bits = AI_START2_Select(0) |
- AI_START1_Sync | AI_START1_Select(chan + 1);
+ AI_START1_Sync | AI_START1_Select(chan + 1);
if (cmd->start_arg & CR_INVERT)
bits |= AI_START1_Polarity;
if (cmd->start_arg & CR_EDGE)
bits |= AI_START1_Edge;
devpriv->stc_writew(dev, bits,
- AI_Trigger_Select_Register);
+ AI_Trigger_Select_Register);
break;
}
}
@@ -2363,7 +2435,7 @@ static int ni_ai_cmd(struct comedi_device *dev, struct comedi_subdevice *s)
devpriv->stc_writew(dev, mode2, AI_Mode_2_Register);
if (cmd->chanlist_len == 1 || (boardtype.reg_type == ni_reg_611x)
- || (boardtype.reg_type == ni_reg_6143)) {
+ || (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_Sync;
@@ -2371,7 +2443,7 @@ static int ni_ai_cmd(struct comedi_device *dev, struct comedi_subdevice *s)
start_stop_select |= AI_STOP_Select(19); /* ai configuration memory */
}
devpriv->stc_writew(dev, start_stop_select,
- AI_START_STOP_Select_Register);
+ AI_START_STOP_Select_Register);
devpriv->ai_cmd2 = 0;
switch (cmd->stop_src) {
@@ -2397,7 +2469,7 @@ static int ni_ai_cmd(struct comedi_device *dev, struct comedi_subdevice *s)
/* 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;
+ AI_STOP_Polarity | AI_STOP_Edge;
}
break;
case TRIG_NONE:
@@ -2433,7 +2505,7 @@ static int ni_ai_cmd(struct comedi_device *dev, struct comedi_subdevice *s)
*/
start_stop_select |= AI_START_Edge | AI_START_Sync;
devpriv->stc_writew(dev, start_stop_select,
- AI_START_STOP_Select_Register);
+ AI_START_STOP_Select_Register);
mode2 |= AI_SI_Reload_Mode(0);
/* AI_SI_Initial_Load_Source=A */
@@ -2443,7 +2515,7 @@ static int ni_ai_cmd(struct comedi_device *dev, struct comedi_subdevice *s)
/* load SI */
timer = ni_ns_to_timer(dev, cmd->scan_begin_arg,
- TRIG_ROUND_NEAREST);
+ TRIG_ROUND_NEAREST);
devpriv->stc_writel(dev, timer, AI_SI_Load_A_Registers);
devpriv->stc_writew(dev, AI_SI_Load, AI_Command_1_Register);
break;
@@ -2454,13 +2526,13 @@ static int ni_ai_cmd(struct comedi_device *dev, struct comedi_subdevice *s)
if (cmd->scan_begin_arg & CR_INVERT)
start_stop_select |= AI_START_Polarity;
if (cmd->scan_begin_src != cmd->convert_src ||
- (cmd->scan_begin_arg & ~CR_EDGE) !=
- (cmd->convert_arg & ~CR_EDGE))
+ (cmd->scan_begin_arg & ~CR_EDGE) !=
+ (cmd->convert_arg & ~CR_EDGE))
start_stop_select |= AI_START_Sync;
start_stop_select |=
- AI_START_Select(1 + CR_CHAN(cmd->scan_begin_arg));
+ AI_START_Select(1 + CR_CHAN(cmd->scan_begin_arg));
devpriv->stc_writew(dev, start_stop_select,
- AI_START_STOP_Select_Register);
+ AI_START_STOP_Select_Register);
break;
}
@@ -2471,7 +2543,7 @@ static int ni_ai_cmd(struct comedi_device *dev, struct comedi_subdevice *s)
timer = 1;
else
timer = ni_ns_to_timer(dev, cmd->convert_arg,
- TRIG_ROUND_NEAREST);
+ TRIG_ROUND_NEAREST);
devpriv->stc_writew(dev, 1, AI_SI2_Load_A_Register); /* 0,0 does not work. */
devpriv->stc_writew(dev, timer, AI_SI2_Load_B_Register);
@@ -2505,14 +2577,14 @@ static int ni_ai_cmd(struct comedi_device *dev, struct comedi_subdevice *s)
/* interrupt on FIFO, errors, SC_TC */
interrupt_a_enable |= AI_Error_Interrupt_Enable |
- AI_SC_TC_Interrupt_Enable;
+ AI_SC_TC_Interrupt_Enable;
#ifndef PCIDMA
interrupt_a_enable |= AI_FIFO_Interrupt_Enable;
#endif
if (cmd->flags & TRIG_WAKE_EOS
- || (devpriv->ai_cmd2 & AI_End_On_End_Of_Scan)) {
+ || (devpriv->ai_cmd2 & AI_End_On_End_Of_Scan)) {
/* wake on end-of-scan */
devpriv->aimode = AIMODE_SCAN;
} else {
@@ -2524,24 +2596,24 @@ static int ni_ai_cmd(struct comedi_device *dev, struct comedi_subdevice *s)
/*generate FIFO interrupts and DMA requests on half-full */
#ifdef PCIDMA
devpriv->stc_writew(dev, AI_FIFO_Mode_HF_to_E,
- AI_Mode_3_Register);
+ AI_Mode_3_Register);
#else
devpriv->stc_writew(dev, AI_FIFO_Mode_HF,
- AI_Mode_3_Register);
+ AI_Mode_3_Register);
#endif
break;
case AIMODE_SAMPLE:
/*generate FIFO interrupts on non-empty */
devpriv->stc_writew(dev, AI_FIFO_Mode_NE,
- AI_Mode_3_Register);
+ AI_Mode_3_Register);
break;
case AIMODE_SCAN:
#ifdef PCIDMA
devpriv->stc_writew(dev, AI_FIFO_Mode_NE,
- AI_Mode_3_Register);
+ AI_Mode_3_Register);
#else
devpriv->stc_writew(dev, AI_FIFO_Mode_HF,
- AI_Mode_3_Register);
+ AI_Mode_3_Register);
#endif
interrupt_a_enable |= AI_STOP_Interrupt_Enable;
break;
@@ -2552,10 +2624,10 @@ static int ni_ai_cmd(struct comedi_device *dev, struct comedi_subdevice *s)
devpriv->stc_writew(dev, AI_Error_Interrupt_Ack | AI_STOP_Interrupt_Ack | AI_START_Interrupt_Ack | AI_START2_Interrupt_Ack | AI_START1_Interrupt_Ack | AI_SC_TC_Interrupt_Ack | AI_SC_TC_Error_Confirm, Interrupt_A_Ack_Register); /* clear interrupts */
ni_set_bits(dev, Interrupt_A_Enable_Register,
- interrupt_a_enable, 1);
+ interrupt_a_enable, 1);
MDPRINTK("Interrupt_A_Enable_Register = 0x%04x\n",
- devpriv->int_a_enable_reg);
+ devpriv->int_a_enable_reg);
} else {
/* interrupt on nothing */
ni_set_bits(dev, Interrupt_A_Enable_Register, ~0, 0);
@@ -2570,14 +2642,14 @@ static int ni_ai_cmd(struct comedi_device *dev, struct comedi_subdevice *s)
switch (cmd->scan_begin_src) {
case TRIG_TIMER:
devpriv->stc_writew(dev,
- AI_SI2_Arm | AI_SI_Arm | AI_DIV_Arm | AI_SC_Arm,
- AI_Command_1_Register);
+ AI_SI2_Arm | AI_SI_Arm | AI_DIV_Arm |
+ AI_SC_Arm, AI_Command_1_Register);
break;
case TRIG_EXT:
/* XXX AI_SI_Arm? */
devpriv->stc_writew(dev,
- AI_SI2_Arm | AI_SI_Arm | AI_DIV_Arm | AI_SC_Arm,
- AI_Command_1_Register);
+ AI_SI2_Arm | AI_SI_Arm | AI_DIV_Arm |
+ AI_SC_Arm, AI_Command_1_Register);
break;
}
@@ -2594,7 +2666,7 @@ static int ni_ai_cmd(struct comedi_device *dev, struct comedi_subdevice *s)
case TRIG_NOW:
/* AI_START1_Pulse */
devpriv->stc_writew(dev, AI_START1_Pulse | devpriv->ai_cmd2,
- AI_Command_2_Register);
+ AI_Command_2_Register);
s->async->inttrig = NULL;
break;
case TRIG_EXT:
@@ -2611,23 +2683,26 @@ static int ni_ai_cmd(struct comedi_device *dev, struct comedi_subdevice *s)
}
static int ni_ai_inttrig(struct comedi_device *dev, struct comedi_subdevice *s,
- unsigned int trignum)
+ unsigned int trignum)
{
if (trignum != 0)
return -EINVAL;
devpriv->stc_writew(dev, AI_START1_Pulse | devpriv->ai_cmd2,
- AI_Command_2_Register);
+ AI_Command_2_Register);
s->async->inttrig = NULL;
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;
@@ -2666,7 +2741,7 @@ static int ni_ai_insn_config(struct comedi_device *dev, struct comedi_subdevice
devpriv->ai_calib_source = calib_source;
if (boardtype.reg_type == ni_reg_611x) {
ni_writeb(calib_source_adjust,
- Cal_Gain_Select_611x);
+ Cal_Gain_Select_611x);
}
}
return 2;
@@ -2677,8 +2752,10 @@ 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;
@@ -2730,8 +2807,7 @@ static int ni_ai_config_analog_trig(struct comedi_device *dev, struct comedi_sub
a = data[4];
b = data[3];
modebits =
- ((data[1] & 0xf) << 4) | ((data[1] & 0xf0) >>
- 4);
+ ((data[1] & 0xf) << 4) | ((data[1] & 0xf0) >> 4);
}
devpriv->atrig_low = a;
devpriv->atrig_high = b;
@@ -2776,7 +2852,8 @@ static int ni_ai_config_analog_trig(struct comedi_device *dev, struct comedi_sub
/* 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,
- void *data, unsigned int num_bytes, unsigned int chan_index)
+ void *data, unsigned int num_bytes,
+ unsigned int chan_index)
{
struct comedi_async *async = s->async;
unsigned int range;
@@ -2799,8 +2876,9 @@ 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,
- int timed)
+ struct comedi_subdevice *s,
+ unsigned int chanspec[],
+ unsigned int n_chans, int timed)
{
unsigned int range;
unsigned int chan;
@@ -2811,7 +2889,8 @@ static int ni_m_series_ao_config_chanlist(struct comedi_device *dev,
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));
+ ni_writeb(devpriv->ao_conf[i],
+ M_Offset_AO_Config_Bank(i));
ni_writeb(0xf, M_Offset_AO_Waveform_Order(i));
}
}
@@ -2834,16 +2913,16 @@ static int ni_m_series_ao_config_chanlist(struct comedi_device *dev,
case 4000000:
conf |= MSeries_AO_DAC_Reference_10V_Internal_Bits;
ni_writeb(MSeries_Attenuate_x5_Bit,
- M_Offset_AO_Reference_Attenuation(chan));
+ M_Offset_AO_Reference_Attenuation(chan));
break;
case 2000000:
conf |= MSeries_AO_DAC_Reference_5V_Internal_Bits;
ni_writeb(MSeries_Attenuate_x5_Bit,
- M_Offset_AO_Reference_Attenuation(chan));
+ M_Offset_AO_Reference_Attenuation(chan));
break;
default:
printk("%s: bug! unhandled ao reference voltage\n",
- __func__);
+ __func__);
break;
}
switch (krange->max + krange->min) {
@@ -2855,7 +2934,7 @@ static int ni_m_series_ao_config_chanlist(struct comedi_device *dev,
break;
default:
printk("%s: bug! unhandled ao offset voltage\n",
- __func__);
+ __func__);
break;
}
if (timed)
@@ -2867,8 +2946,10 @@ 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,
- unsigned int chanspec[], unsigned int n_chans)
+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;
unsigned int chan;
@@ -2902,7 +2983,7 @@ static int ni_old_ao_config_chanlist(struct comedi_device *dev, struct comedi_su
/* analog reference */
/* AREF_OTHER connects AO ground to AI ground, i think */
conf |= (CR_AREF(chanspec[i]) ==
- AREF_OTHER) ? AO_Ground_Ref : 0;
+ AREF_OTHER) ? AO_Ground_Ref : 0;
ni_writew(conf, AO_Configuration);
devpriv->ao_conf[chan] = conf;
@@ -2910,25 +2991,30 @@ static int ni_old_ao_config_chanlist(struct comedi_device *dev, struct comedi_su
return invert;
}
-static int ni_ao_config_chanlist(struct comedi_device *dev, struct comedi_subdevice *s,
- unsigned int chanspec[], unsigned int n_chans, int timed)
+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)
return ni_m_series_ao_config_chanlist(dev, s, chanspec, n_chans,
- timed);
+ timed);
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;
@@ -2941,13 +3027,14 @@ static int ni_ao_insn_write(struct comedi_device *dev, struct comedi_subdevice *
ni_writew(data[0], M_Offset_DAC_Direct_Data(chan));
} else
ni_writew(data[0] ^ invert,
- (chan) ? DAC1_Direct_Data : DAC0_Direct_Data);
+ (chan) ? DAC1_Direct_Data : DAC0_Direct_Data);
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;
@@ -2963,16 +3050,17 @@ static int ni_ao_insn_write_671x(struct comedi_device *dev, struct comedi_subdev
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;
@@ -2990,7 +3078,7 @@ static int ni_ao_insn_config(struct comedi_device *dev, struct comedi_subdevice
}
static int ni_ao_inttrig(struct comedi_device *dev, struct comedi_subdevice *s,
- unsigned int trignum)
+ unsigned int trignum)
{
int ret;
int interrupt_b_bits;
@@ -3006,7 +3094,7 @@ static int ni_ao_inttrig(struct comedi_device *dev, struct comedi_subdevice *s,
s->async->inttrig = NULL;
ni_set_bits(dev, Interrupt_B_Enable_Register,
- AO_FIFO_Interrupt_Enable | AO_Error_Interrupt_Enable, 0);
+ AO_FIFO_Interrupt_Enable | AO_Error_Interrupt_Enable, 0);
interrupt_b_bits = AO_Error_Interrupt_Enable;
#ifdef PCIDMA
devpriv->stc_writew(dev, 1, DAC_FIFO_Clear);
@@ -3027,35 +3115,34 @@ static int ni_ao_inttrig(struct comedi_device *dev, struct comedi_subdevice *s,
#endif
devpriv->stc_writew(dev, devpriv->ao_mode3 | AO_Not_An_UPDATE,
- AO_Mode_3_Register);
+ AO_Mode_3_Register);
devpriv->stc_writew(dev, devpriv->ao_mode3, AO_Mode_3_Register);
/* wait for DACs to be loaded */
for (i = 0; i < timeout; i++) {
udelay(1);
if ((devpriv->stc_readw(dev,
Joint_Status_2_Register) &
- AO_TMRDACWRs_In_Progress_St) == 0)
+ AO_TMRDACWRs_In_Progress_St) == 0)
break;
}
if (i == timeout) {
comedi_error(dev,
- "timed out waiting for AO_TMRDACWRs_In_Progress_St to clear");
+ "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 */
devpriv->stc_writew(dev, AO_Error_Interrupt_Ack,
- Interrupt_B_Ack_Register);
+ Interrupt_B_Ack_Register);
ni_set_bits(dev, Interrupt_B_Enable_Register, interrupt_b_bits, 1);
devpriv->stc_writew(dev,
- devpriv->
- ao_cmd1 | AO_UI_Arm | AO_UC_Arm | AO_BC_Arm |
- AO_DAC1_Update_Mode | AO_DAC0_Update_Mode,
- AO_Command_1_Register);
+ devpriv->ao_cmd1 | AO_UI_Arm | AO_UC_Arm | AO_BC_Arm
+ | AO_DAC1_Update_Mode | AO_DAC0_Update_Mode,
+ AO_Command_1_Register);
devpriv->stc_writew(dev, devpriv->ao_cmd2 | AO_START1_Pulse,
- AO_Command_2_Register);
+ AO_Command_2_Register);
return 0;
}
@@ -3104,18 +3191,20 @@ static int ni_ao_cmd(struct comedi_device *dev, struct comedi_subdevice *s)
case TRIG_INT:
case TRIG_NOW:
devpriv->ao_trigger_select &=
- ~(AO_START1_Polarity | AO_START1_Select(-1));
+ ~(AO_START1_Polarity | AO_START1_Select(-1));
devpriv->ao_trigger_select |= AO_START1_Edge | AO_START1_Sync;
devpriv->stc_writew(dev, devpriv->ao_trigger_select,
- AO_Trigger_Select_Register);
+ AO_Trigger_Select_Register);
break;
case TRIG_EXT:
- devpriv->ao_trigger_select = AO_START1_Select(CR_CHAN(cmd->start_arg)+1);
+ 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->stc_writew(dev, devpriv->ao_trigger_select, AO_Trigger_Select_Register);
+ 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:
BUG();
@@ -3137,17 +3226,19 @@ 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 */
- 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
- {
- devpriv->stc_writel(dev, cmd->stop_arg, AO_UC_Load_A_Register);
- devpriv->stc_writew(dev, AO_UC_Load, AO_Command_1_Register);
devpriv->stc_writel(dev, cmd->stop_arg - 1,
- AO_UC_Load_A_Register);
+ AO_UC_Load_A_Register);
+ devpriv->stc_writew(dev, AO_UC_Load,
+ AO_Command_1_Register);
+ } else {
+ devpriv->stc_writel(dev, cmd->stop_arg,
+ AO_UC_Load_A_Register);
+ devpriv->stc_writew(dev, AO_UC_Load,
+ AO_Command_1_Register);
+ devpriv->stc_writel(dev, cmd->stop_arg - 1,
+ AO_UC_Load_A_Register);
}
break;
case TRIG_NONE:
@@ -3162,21 +3253,21 @@ static int ni_ao_cmd(struct comedi_device *dev, struct comedi_subdevice *s)
}
devpriv->ao_mode1 &=
- ~(AO_UI_Source_Select(0x1f) | AO_UI_Source_Polarity |
- AO_UPDATE_Source_Select(0x1f) | AO_UPDATE_Source_Polarity);
+ ~(AO_UI_Source_Select(0x1f) | AO_UI_Source_Polarity |
+ AO_UPDATE_Source_Select(0x1f) | AO_UPDATE_Source_Polarity);
switch (cmd->scan_begin_src) {
case TRIG_TIMER:
devpriv->ao_cmd2 &= ~AO_BC_Gate_Enable;
trigvar =
- ni_ns_to_timer(dev, cmd->scan_begin_arg,
- TRIG_ROUND_NEAREST);
+ ni_ns_to_timer(dev, cmd->scan_begin_arg,
+ TRIG_ROUND_NEAREST);
devpriv->stc_writel(dev, 1, AO_UI_Load_A_Register);
devpriv->stc_writew(dev, AO_UI_Load, AO_Command_1_Register);
devpriv->stc_writel(dev, trigvar, AO_UI_Load_A_Register);
break;
case TRIG_EXT:
devpriv->ao_mode1 |=
- AO_UPDATE_Source_Select(cmd->scan_begin_arg);
+ AO_UPDATE_Source_Select(cmd->scan_begin_arg);
if (cmd->scan_begin_arg & CR_INVERT)
devpriv->ao_mode1 |= AO_UPDATE_Source_Polarity;
devpriv->ao_cmd2 |= AO_BC_Gate_Enable;
@@ -3188,34 +3279,34 @@ static int ni_ao_cmd(struct comedi_device *dev, struct comedi_subdevice *s)
devpriv->stc_writew(dev, devpriv->ao_cmd2, AO_Command_2_Register);
devpriv->stc_writew(dev, devpriv->ao_mode1, AO_Mode_1_Register);
devpriv->ao_mode2 &=
- ~(AO_UI_Reload_Mode(3) | AO_UI_Initial_Load_Source);
+ ~(AO_UI_Reload_Mode(3) | AO_UI_Initial_Load_Source);
devpriv->stc_writew(dev, devpriv->ao_mode2, AO_Mode_2_Register);
if (cmd->scan_end_arg > 1) {
devpriv->ao_mode1 |= AO_Multiple_Channels;
devpriv->stc_writew(dev,
- AO_Number_Of_Channels(cmd->scan_end_arg -
- 1) |
- AO_UPDATE_Output_Select
- (AO_Update_Output_High_Z),
- AO_Output_Control_Register);
+ AO_Number_Of_Channels(cmd->scan_end_arg -
+ 1) |
+ AO_UPDATE_Output_Select
+ (AO_Update_Output_High_Z),
+ AO_Output_Control_Register);
} else {
unsigned bits;
devpriv->ao_mode1 &= ~AO_Multiple_Channels;
bits = AO_UPDATE_Output_Select(AO_Update_Output_High_Z);
- if (boardtype.reg_type & (ni_reg_m_series_mask | ni_reg_6xxx_mask)) {
+ if (boardtype.
+ reg_type & (ni_reg_m_series_mask | ni_reg_6xxx_mask)) {
bits |= AO_Number_Of_Channels(0);
} else {
- bits |= AO_Number_Of_Channels(CR_CHAN(cmd->
- chanlist[0]));
+ bits |=
+ AO_Number_Of_Channels(CR_CHAN(cmd->chanlist[0]));
}
- devpriv->stc_writew(dev, bits,
- AO_Output_Control_Register);
+ devpriv->stc_writew(dev, bits, AO_Output_Control_Register);
}
devpriv->stc_writew(dev, devpriv->ao_mode1, AO_Mode_1_Register);
devpriv->stc_writew(dev, AO_DAC0_Update_Mode | AO_DAC1_Update_Mode,
- AO_Command_1_Register);
+ AO_Command_1_Register);
devpriv->ao_mode3 |= AO_Stop_On_Overrun_Error;
devpriv->stc_writew(dev, devpriv->ao_mode3, AO_Mode_3_Register);
@@ -3230,7 +3321,7 @@ static int ni_ao_cmd(struct comedi_device *dev, struct comedi_subdevice *s)
devpriv->stc_writew(dev, devpriv->ao_mode2, AO_Mode_2_Register);
bits = AO_BC_Source_Select | AO_UPDATE_Pulse_Width |
- AO_TMRDACWR_Pulse_Width;
+ AO_TMRDACWR_Pulse_Width;
if (boardtype.ao_fifo_depth)
bits |= AO_FIFO_Enable;
else
@@ -3249,9 +3340,9 @@ static int ni_ao_cmd(struct comedi_device *dev, struct comedi_subdevice *s)
if (cmd->stop_src == TRIG_COUNT) {
devpriv->stc_writew(dev, AO_BC_TC_Interrupt_Ack,
- Interrupt_B_Ack_Register);
+ Interrupt_B_Ack_Register);
ni_set_bits(dev, Interrupt_B_Enable_Register,
- AO_BC_TC_Interrupt_Enable, 1);
+ AO_BC_TC_Interrupt_Enable, 1);
}
s->async->inttrig = &ni_ao_inttrig;
@@ -3260,7 +3351,7 @@ static int ni_ao_cmd(struct comedi_device *dev, struct comedi_subdevice *s)
}
static int ni_ao_cmdtest(struct comedi_device *dev, struct comedi_subdevice *s,
- struct comedi_cmd *cmd)
+ struct comedi_cmd *cmd)
{
int err = 0;
int tmp;
@@ -3365,9 +3456,11 @@ static int ni_ao_cmdtest(struct comedi_device *dev, struct comedi_subdevice *s,
if (cmd->scan_begin_src == TRIG_TIMER) {
tmp = cmd->scan_begin_arg;
cmd->scan_begin_arg =
- ni_timer_to_ns(dev, ni_ns_to_timer(dev,
- cmd->scan_begin_arg,
- cmd->flags & TRIG_ROUND_MASK));
+ ni_timer_to_ns(dev, ni_ns_to_timer(dev,
+ cmd->scan_begin_arg,
+ cmd->
+ flags &
+ TRIG_ROUND_MASK));
if (tmp != cmd->scan_begin_arg)
err++;
}
@@ -3398,7 +3491,7 @@ static int ni_ao_reset(struct comedi_device *dev, struct comedi_subdevice *s)
devpriv->stc_writew(dev, AO_BC_Source_Select, AO_Personal_Register);
devpriv->stc_writew(dev, 0x3f98, Interrupt_B_Ack_Register);
devpriv->stc_writew(dev, AO_BC_Source_Select | AO_UPDATE_Pulse_Width |
- AO_TMRDACWR_Pulse_Width, AO_Personal_Register);
+ AO_TMRDACWR_Pulse_Width, AO_Personal_Register);
devpriv->stc_writew(dev, 0, AO_Output_Control_Register);
devpriv->stc_writew(dev, 0, AO_Start_Select_Register);
devpriv->ao_cmd1 = 0;
@@ -3416,12 +3509,11 @@ static int ni_ao_reset(struct comedi_device *dev, struct comedi_subdevice *s)
devpriv->stc_writew(dev, devpriv->ao_mode3, AO_Mode_3_Register);
devpriv->ao_trigger_select = 0;
devpriv->stc_writew(dev, devpriv->ao_trigger_select,
- AO_Trigger_Select_Register);
+ AO_Trigger_Select_Register);
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;
}
ao_win_out(immediate_bits, AO_Immediate_671x);
@@ -3434,12 +3526,13 @@ static int ni_ao_reset(struct comedi_device *dev, struct comedi_subdevice *s)
/* 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
printk("ni_dio_insn_config() chan=%d io=%d\n",
- CR_CHAN(insn->chanspec), data[0]);
+ CR_CHAN(insn->chanspec), data[0]);
#endif
switch (data[0]) {
case INSN_CONFIG_DIO_OUTPUT:
@@ -3450,9 +3543,9 @@ static int ni_dio_insn_config(struct comedi_device *dev, struct comedi_subdevice
break;
case INSN_CONFIG_DIO_QUERY:
data[1] =
- (s->io_bits & (1 << CR_CHAN(insn->
- chanspec))) ? COMEDI_OUTPUT :
- COMEDI_INPUT;
+ (s->
+ io_bits & (1 << CR_CHAN(insn->chanspec))) ? COMEDI_OUTPUT :
+ COMEDI_INPUT;
return insn->n;
break;
default:
@@ -3466,8 +3559,9 @@ static int ni_dio_insn_config(struct comedi_device *dev, struct comedi_subdevice
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
printk("ni_dio_insn_bits() mask=0x%x bits=0x%x\n", data[0], data[1]);
@@ -3478,7 +3572,7 @@ static int ni_dio_insn_bits(struct comedi_device *dev, struct comedi_subdevice *
/* Perform check to make sure we're not using the
serial part of the dio */
if ((data[0] & (DIO_SDIN | DIO_SDOUT))
- && devpriv->serial_interval_ns)
+ && devpriv->serial_interval_ns)
return -EBUSY;
s->state &= ~data[0];
@@ -3486,7 +3580,7 @@ static int ni_dio_insn_bits(struct comedi_device *dev, struct comedi_subdevice *
devpriv->dio_output &= ~DIO_Parallel_Data_Mask;
devpriv->dio_output |= DIO_Parallel_Data_Out(s->state);
devpriv->stc_writew(dev, devpriv->dio_output,
- DIO_Output_Register);
+ DIO_Output_Register);
}
data[1] = devpriv->stc_readw(dev, DIO_Parallel_Input_Register);
@@ -3494,11 +3588,13 @@ static int ni_dio_insn_bits(struct comedi_device *dev, struct comedi_subdevice *
}
static int ni_m_series_dio_insn_config(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)
{
#ifdef DEBUG_DIO
printk("ni_m_series_dio_insn_config() chan=%d io=%d\n",
- CR_CHAN(insn->chanspec), data[0]);
+ CR_CHAN(insn->chanspec), data[0]);
#endif
switch (data[0]) {
case INSN_CONFIG_DIO_OUTPUT:
@@ -3509,9 +3605,9 @@ static int ni_m_series_dio_insn_config(struct comedi_device *dev,
break;
case INSN_CONFIG_DIO_QUERY:
data[1] =
- (s->io_bits & (1 << CR_CHAN(insn->
- chanspec))) ? COMEDI_OUTPUT :
- COMEDI_INPUT;
+ (s->
+ io_bits & (1 << CR_CHAN(insn->chanspec))) ? COMEDI_OUTPUT :
+ COMEDI_INPUT;
return insn->n;
break;
default:
@@ -3523,12 +3619,14 @@ 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
printk("ni_m_series_dio_insn_bits() mask=0x%x bits=0x%x\n", data[0],
- data[1]);
+ data[1]);
#endif
if (insn->n != 2)
return -EINVAL;
@@ -3542,8 +3640,8 @@ static int ni_m_series_dio_insn_bits(struct comedi_device *dev, struct comedi_su
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;
@@ -3606,7 +3704,7 @@ static int ni_cdio_cmdtest(struct comedi_device *dev, struct comedi_subdevice *s
if (cmd->scan_begin_src == TRIG_EXT) {
tmp = cmd->scan_begin_arg;
tmp &= CR_PACK_FLAGS(CDO_Sample_Source_Select_Mask, 0, 0,
- CR_INVERT);
+ CR_INVERT);
if (tmp != cmd->scan_begin_arg) {
err++;
}
@@ -3661,8 +3759,8 @@ static int ni_cdio_cmd(struct comedi_device *dev, struct comedi_subdevice *s)
switch (cmd->scan_begin_src) {
case TRIG_EXT:
cdo_mode_bits |=
- CR_CHAN(cmd->
- scan_begin_arg) & CDO_Sample_Source_Select_Mask;
+ CR_CHAN(cmd->scan_begin_arg) &
+ CDO_Sample_Source_Select_Mask;
break;
default:
BUG();
@@ -3677,7 +3775,7 @@ static int ni_cdio_cmd(struct comedi_device *dev, struct comedi_subdevice *s)
ni_writel(s->io_bits, M_Offset_CDO_Mask_Enable);
} else {
comedi_error(dev,
- "attempted to run digital output command with no lines configured as outputs");
+ "attempted to run digital output command with no lines configured as outputs");
return -EIO;
}
retval = ni_request_cdo_mite_channel(dev);
@@ -3689,7 +3787,7 @@ static int ni_cdio_cmd(struct comedi_device *dev, struct comedi_subdevice *s)
}
static int ni_cdo_inttrig(struct comedi_device *dev, struct comedi_subdevice *s,
- unsigned int trignum)
+ unsigned int trignum)
{
#ifdef PCIDMA
unsigned long flags;
@@ -3732,16 +3830,17 @@ static int ni_cdo_inttrig(struct comedi_device *dev, struct comedi_subdevice *s,
return -EIO;
}
ni_writel(CDO_Arm_Bit | CDO_Error_Interrupt_Enable_Set_Bit |
- CDO_Empty_FIFO_Interrupt_Enable_Set_Bit, M_Offset_CDIO_Command);
+ CDO_Empty_FIFO_Interrupt_Enable_Set_Bit,
+ M_Offset_CDIO_Command);
return retval;
}
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);
+ 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);
@@ -3766,11 +3865,11 @@ static void handle_cdio_interrupt(struct comedi_device *dev)
spin_lock_irqsave(&devpriv->mite_channel_lock, flags);
if (devpriv->cdo_mite_chan) {
unsigned cdo_mite_status =
- mite_get_status(devpriv->cdo_mite_chan);
+ mite_get_status(devpriv->cdo_mite_chan);
if (cdo_mite_status & CHSR_LINKC) {
writel(CHOR_CLRLC,
- devpriv->mite->mite_io_addr +
- MITE_CHOR(devpriv->cdo_mite_chan->channel));
+ devpriv->mite->mite_io_addr +
+ MITE_CHOR(devpriv->cdo_mite_chan->channel));
}
mite_sync_output_dma(devpriv->cdo_mite_chan, s->async);
}
@@ -3786,14 +3885,15 @@ static void handle_cdio_interrupt(struct comedi_device *dev)
if (cdio_status & CDO_FIFO_Empty_Bit) {
/* printk("cdio fifo empty\n"); */
ni_writel(CDO_Empty_FIFO_Interrupt_Enable_Clear_Bit,
- M_Offset_CDIO_Command);
+ M_Offset_CDIO_Command);
/* 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;
@@ -3813,7 +3913,7 @@ static int ni_serial_insn_config(struct comedi_device *dev, struct comedi_subdev
if (data[1] == SERIAL_DISABLED) {
devpriv->serial_hw_mode = 0;
devpriv->dio_control &= ~(DIO_HW_Serial_Enable |
- DIO_Software_Serial_Control);
+ DIO_Software_Serial_Control);
data[1] = SERIAL_DISABLED;
devpriv->serial_interval_ns = data[1];
} else if (data[1] <= SERIAL_600NS) {
@@ -3827,13 +3927,13 @@ static int ni_serial_insn_config(struct comedi_device *dev, struct comedi_subdev
} else if (data[1] <= SERIAL_1_2US) {
devpriv->dio_control &= ~DIO_HW_Serial_Timebase;
devpriv->clock_and_fout |= Slow_Internal_Timebase |
- DIO_Serial_Out_Divide_By_2;
+ DIO_Serial_Out_Divide_By_2;
data[1] = SERIAL_1_2US;
devpriv->serial_interval_ns = data[1];
} else if (data[1] <= SERIAL_10US) {
devpriv->dio_control |= DIO_HW_Serial_Timebase;
devpriv->clock_and_fout |= Slow_Internal_Timebase |
- DIO_Serial_Out_Divide_By_2;
+ DIO_Serial_Out_Divide_By_2;
/* Note: DIO_Serial_Out_Divide_By_2 only affects
600ns/1.2us. If you turn divide_by_2 off with the
slow clock, you will still get 10us, except then
@@ -3842,16 +3942,16 @@ static int ni_serial_insn_config(struct comedi_device *dev, struct comedi_subdev
devpriv->serial_interval_ns = data[1];
} else {
devpriv->dio_control &= ~(DIO_HW_Serial_Enable |
- DIO_Software_Serial_Control);
+ DIO_Software_Serial_Control);
devpriv->serial_hw_mode = 0;
data[1] = (data[1] / 1000) * 1000;
devpriv->serial_interval_ns = data[1];
}
devpriv->stc_writew(dev, devpriv->dio_control,
- DIO_Control_Register);
+ DIO_Control_Register);
devpriv->stc_writew(dev, devpriv->clock_and_fout,
- Clock_and_FOUT_Register);
+ Clock_and_FOUT_Register);
return 1;
break;
@@ -3866,10 +3966,10 @@ static int ni_serial_insn_config(struct comedi_device *dev, struct comedi_subdev
if (devpriv->serial_hw_mode) {
err = ni_serial_hw_readwrite8(dev, s, byte_out,
- &byte_in);
+ &byte_in);
} else if (devpriv->serial_interval_ns > 0) {
err = ni_serial_sw_readwrite8(dev, s, byte_out,
- &byte_in);
+ &byte_in);
} else {
printk("ni_serial_insn_config: serial disabled!\n");
return -EINVAL;
@@ -3886,8 +3986,10 @@ static int ni_serial_insn_config(struct comedi_device *dev, struct comedi_subdev
}
-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_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;
@@ -3912,14 +4014,14 @@ static int ni_serial_hw_readwrite8(struct comedi_device *dev, struct comedi_subd
/* Wait until STC says we're done, but don't loop infinitely. */
while ((status1 =
- devpriv->stc_readw(dev,
- Joint_Status_1_Register)) &
- DIO_Serial_IO_In_Progress_St) {
+ devpriv->stc_readw(dev,
+ Joint_Status_1_Register)) &
+ DIO_Serial_IO_In_Progress_St) {
/* Delay one bit per loop */
udelay((devpriv->serial_interval_ns + 999) / 1000);
if (--count < 0) {
printk
- ("ni_serial_hw_readwrite8: SPI serial I/O didn't finish in time!\n");
+ ("ni_serial_hw_readwrite8: SPI serial I/O didn't finish in time!\n");
err = -ETIME;
goto Error;
}
@@ -3936,14 +4038,16 @@ static int ni_serial_hw_readwrite8(struct comedi_device *dev, struct comedi_subd
#endif
}
- Error:
+Error:
devpriv->stc_writew(dev, devpriv->dio_control, DIO_Control_Register);
return err;
}
-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_serial_sw_readwrite8(struct comedi_device *dev,
+ struct comedi_subdevice *s,
+ unsigned char data_out,
+ unsigned char *data_in)
{
unsigned char mask, input = 0;
@@ -3963,25 +4067,26 @@ static int ni_serial_sw_readwrite8(struct comedi_device *dev, struct comedi_subd
devpriv->dio_output |= DIO_SDOUT;
}
devpriv->stc_writew(dev, devpriv->dio_output,
- DIO_Output_Register);
+ DIO_Output_Register);
/* Assert SDCLK (active low, inverted), wait for half of
the delay, deassert SDCLK, and wait for the other half. */
devpriv->dio_control |= DIO_Software_Serial_Control;
devpriv->stc_writew(dev, devpriv->dio_control,
- DIO_Control_Register);
+ DIO_Control_Register);
udelay((devpriv->serial_interval_ns + 999) / 2000);
devpriv->dio_control &= ~DIO_Software_Serial_Control;
devpriv->stc_writew(dev, devpriv->dio_control,
- DIO_Control_Register);
+ DIO_Control_Register);
udelay((devpriv->serial_interval_ns + 999) / 2000);
/* Input current bit */
if (devpriv->stc_readw(dev,
- DIO_Parallel_Input_Register) & DIO_SDIN) {
+ DIO_Parallel_Input_Register) & DIO_SDIN)
+ {
/* printk("DIO_P_I_R: 0x%x\n", devpriv->stc_readw(dev, DIO_Parallel_Input_Register)); */
input |= mask;
}
@@ -4010,10 +4115,9 @@ static void init_ao_67xx(struct comedi_device *dev, struct comedi_subdevice *s)
{
int i;
- for (i = 0; i < s->n_chan; i++)
- {
+ for (i = 0; i < s->n_chan; i++) {
ni_ao_win_outw(dev, AO_Channel(i) | 0x0,
- AO_Configuration_2_67xx);
+ AO_Configuration_2_67xx);
}
ao_win_out(0x0, AO_Later_Single_Point_Updates);
}
@@ -4102,7 +4206,7 @@ static unsigned ni_gpct_to_stc_register(enum ni_gpct_register reg)
break;
default:
printk("%s: unhandled register 0x%x in switch.\n",
- __func__, reg);
+ __func__, reg);
BUG();
return 0;
break;
@@ -4111,16 +4215,16 @@ static unsigned ni_gpct_to_stc_register(enum ni_gpct_register reg)
}
static void ni_gpct_write_register(struct ni_gpct *counter, unsigned bits,
- enum ni_gpct_register reg)
+ enum ni_gpct_register reg)
{
struct comedi_device *dev = counter->counter_dev->dev;
unsigned stc_register;
/* bits in the join reset register which are relevant to counters */
static const unsigned gpct_joint_reset_mask = G0_Reset | G1_Reset;
static const unsigned gpct_interrupt_a_enable_mask =
- G0_Gate_Interrupt_Enable | G0_TC_Interrupt_Enable;
+ G0_Gate_Interrupt_Enable | G0_TC_Interrupt_Enable;
static const unsigned gpct_interrupt_b_enable_mask =
- G1_Gate_Interrupt_Enable | G1_TC_Interrupt_Enable;
+ G1_Gate_Interrupt_Enable | G1_TC_Interrupt_Enable;
switch (reg) {
/* m-series-only registers */
@@ -4162,12 +4266,12 @@ static void ni_gpct_write_register(struct ni_gpct *counter, unsigned bits,
case NITIO_G0_Interrupt_Enable_Reg:
BUG_ON(bits & ~gpct_interrupt_a_enable_mask);
ni_set_bitfield(dev, Interrupt_A_Enable_Register,
- gpct_interrupt_a_enable_mask, bits);
+ gpct_interrupt_a_enable_mask, bits);
break;
case NITIO_G1_Interrupt_Enable_Reg:
BUG_ON(bits & ~gpct_interrupt_b_enable_mask);
ni_set_bitfield(dev, Interrupt_B_Enable_Register,
- gpct_interrupt_b_enable_mask, bits);
+ gpct_interrupt_b_enable_mask, bits);
break;
case NITIO_G01_Joint_Reset_Reg:
BUG_ON(bits & ~gpct_joint_reset_mask);
@@ -4179,7 +4283,7 @@ static void ni_gpct_write_register(struct ni_gpct *counter, unsigned bits,
}
static unsigned ni_gpct_read_register(struct ni_gpct *counter,
- enum ni_gpct_register reg)
+ enum ni_gpct_register reg)
{
struct comedi_device *dev = counter->counter_dev->dev;
unsigned stc_register;
@@ -4211,27 +4315,30 @@ static unsigned ni_gpct_read_register(struct ni_gpct *counter,
}
static int ni_freq_out_insn_read(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)
{
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)
+ 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,
- Clock_and_FOUT_Register);
+ Clock_and_FOUT_Register);
devpriv->clock_and_fout &= ~FOUT_Divider_mask;
devpriv->clock_and_fout |= FOUT_Divider(data[0]);
devpriv->clock_and_fout |= FOUT_Enable;
devpriv->stc_writew(dev, devpriv->clock_and_fout,
- Clock_and_FOUT_Register);
+ Clock_and_FOUT_Register);
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:
@@ -4244,12 +4351,13 @@ static int ni_set_freq_out_clock(struct comedi_device *dev, unsigned int clock_s
return -EINVAL;
}
devpriv->stc_writew(dev, devpriv->clock_and_fout,
- Clock_and_FOUT_Register);
+ Clock_and_FOUT_Register);
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;
@@ -4260,8 +4368,9 @@ static void ni_get_freq_out_clock(struct comedi_device *dev, unsigned int *clock
}
}
-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:
@@ -4312,7 +4421,7 @@ static int ni_E_init(struct comedi_device *dev, struct comedi_devconfig *it)
if (boardtype.n_adchan) {
s->type = COMEDI_SUBD_AI;
s->subdev_flags =
- SDF_READABLE | SDF_DIFF | SDF_DITHER | SDF_CMD_READ;
+ SDF_READABLE | SDF_DIFF | SDF_DITHER | SDF_CMD_READ;
if (boardtype.reg_type != ni_reg_611x)
s->subdev_flags |= SDF_GROUND | SDF_COMMON | SDF_OTHER;
if (boardtype.adbits > 16)
@@ -4387,7 +4496,7 @@ static int ni_E_init(struct comedi_device *dev, struct comedi_devconfig *it)
s->n_chan = boardtype.num_p0_dio_channels;
if (boardtype.reg_type & ni_reg_m_series_mask) {
s->subdev_flags |=
- SDF_LSAMPL | SDF_CMD_WRITE /* | SDF_CMD_READ */ ;
+ SDF_LSAMPL | SDF_CMD_WRITE /* | SDF_CMD_READ */ ;
s->insn_bits = &ni_m_series_dio_insn_bits;
s->insn_config = &ni_m_series_dio_insn_config;
s->do_cmd = &ni_cdio_cmd;
@@ -4463,7 +4572,7 @@ static int ni_E_init(struct comedi_device *dev, struct comedi_devconfig *it)
ni_writew(s->state, M_Offset_PFI_DO);
for (i = 0; i < NUM_PFI_OUTPUT_SELECT_REGS; ++i) {
ni_writew(devpriv->pfi_output_select_reg[i],
- M_Offset_PFI_Output_Select(i + 1));
+ M_Offset_PFI_Output_Select(i + 1));
}
} else {
s->n_chan = 10;
@@ -4517,15 +4626,17 @@ static int ni_E_init(struct comedi_device *dev, struct comedi_devconfig *it)
counter_variant = ni_gpct_variant_e_series;
}
devpriv->counter_dev = ni_gpct_device_construct(dev,
- &ni_gpct_write_register, &ni_gpct_read_register,
- counter_variant, NUM_GPCT);
+ &ni_gpct_write_register,
+ &ni_gpct_read_register,
+ counter_variant,
+ NUM_GPCT);
/* General purpose counters */
for (j = 0; j < NUM_GPCT; ++j) {
s = dev->subdevices + NI_GPCT_SUBDEV(j);
s->type = COMEDI_SUBD_COUNTER;
s->subdev_flags =
- SDF_READABLE | SDF_WRITABLE | SDF_LSAMPL | SDF_CMD_READ
- /* | SDF_CMD_WRITE */ ;
+ SDF_READABLE | SDF_WRITABLE | SDF_LSAMPL | SDF_CMD_READ
+ /* | SDF_CMD_WRITE */ ;
s->n_chan = 3;
if (boardtype.reg_type & ni_reg_m_series_mask)
s->maxdata = 0xffffffff;
@@ -4561,32 +4672,33 @@ static int ni_E_init(struct comedi_device *dev, struct comedi_devconfig *it)
if ((boardtype.reg_type & ni_reg_6xxx_mask) == 0) {
/* BEAM is this needed for PCI-6143 ?? */
devpriv->clock_and_fout =
- Slow_Internal_Time_Divide_By_2 |
- Slow_Internal_Timebase |
- Clock_To_Board_Divide_By_2 |
- Clock_To_Board |
- AI_Output_Divide_By_2 | AO_Output_Divide_By_2;
+ Slow_Internal_Time_Divide_By_2 |
+ Slow_Internal_Timebase |
+ Clock_To_Board_Divide_By_2 |
+ Clock_To_Board |
+ AI_Output_Divide_By_2 | AO_Output_Divide_By_2;
} else {
devpriv->clock_and_fout =
- Slow_Internal_Time_Divide_By_2 |
- Slow_Internal_Timebase |
- Clock_To_Board_Divide_By_2 | Clock_To_Board;
+ Slow_Internal_Time_Divide_By_2 |
+ Slow_Internal_Timebase |
+ Clock_To_Board_Divide_By_2 | Clock_To_Board;
}
devpriv->stc_writew(dev, devpriv->clock_and_fout,
- Clock_and_FOUT_Register);
+ Clock_and_FOUT_Register);
/* analog output configuration */
ni_ao_reset(dev, dev->subdevices + NI_AO_SUBDEV);
if (dev->irq) {
devpriv->stc_writew(dev,
- (IRQ_POLARITY ? Interrupt_Output_Polarity : 0) |
- (Interrupt_Output_On_3_Pins & 0) | Interrupt_A_Enable |
- Interrupt_B_Enable |
- Interrupt_A_Output_Select(interrupt_pin(dev->
- irq)) |
- Interrupt_B_Output_Select(interrupt_pin(dev->irq)),
- Interrupt_Control_Register);
+ (IRQ_POLARITY ? Interrupt_Output_Polarity :
+ 0) | (Interrupt_Output_On_3_Pins & 0) |
+ Interrupt_A_Enable | Interrupt_B_Enable |
+ Interrupt_A_Output_Select(interrupt_pin
+ (dev->irq)) |
+ Interrupt_B_Output_Select(interrupt_pin
+ (dev->irq)),
+ Interrupt_Control_Register);
}
/* DMA setup */
@@ -4600,7 +4712,7 @@ static int ni_E_init(struct comedi_device *dev, struct comedi_devconfig *it)
for (channel = 0; channel < boardtype.n_aochan; ++channel) {
ni_writeb(0xf, M_Offset_AO_Waveform_Order(channel));
ni_writeb(0x0,
- M_Offset_AO_Reference_Attenuation(channel));
+ M_Offset_AO_Reference_Attenuation(channel));
}
ni_writeb(0x0, M_Offset_AO_Calibration);
}
@@ -4611,7 +4723,7 @@ static int ni_E_init(struct comedi_device *dev, struct comedi_devconfig *it)
static int ni_8255_callback(int dir, int port, int data, unsigned long arg)
{
- struct comedi_device *dev = (struct comedi_device *) arg;
+ struct comedi_device *dev = (struct comedi_device *)arg;
if (dir) {
ni_writeb(data, Port_A + 2 * port);
@@ -4625,8 +4737,9 @@ 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));
@@ -4646,9 +4759,9 @@ static int ni_read_eeprom(struct comedi_device *dev, int addr)
ni_writeb(0x04, Serial_Command);
for (bit = 0x8000; bit; bit >>= 1) {
ni_writeb(0x04 | ((bit & bitstring) ? 0x02 : 0),
- Serial_Command);
+ Serial_Command);
ni_writeb(0x05 | ((bit & bitstring) ? 0x02 : 0),
- Serial_Command);
+ Serial_Command);
}
bitstring = 0;
for (bit = 0x80; bit; bit >>= 1) {
@@ -4662,7 +4775,9 @@ static int ni_read_eeprom(struct comedi_device *dev, int addr)
}
static int ni_m_series_eeprom_insn_read(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)
{
data[0] = devpriv->eeprom_buffer[CR_CHAN(insn->chanspec)];
@@ -4676,8 +4791,9 @@ static int ni_get_pwm_config(struct comedi_device *dev, unsigned int *data)
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]) {
@@ -4685,16 +4801,16 @@ static int ni_m_series_pwm_config(struct comedi_device *dev, struct comedi_subde
switch (data[1]) {
case TRIG_ROUND_NEAREST:
up_count =
- (data[2] +
- devpriv->clock_ns / 2) / devpriv->clock_ns;
+ (data[2] +
+ devpriv->clock_ns / 2) / devpriv->clock_ns;
break;
case TRIG_ROUND_DOWN:
up_count = data[2] / devpriv->clock_ns;
break;
case TRIG_ROUND_UP:
up_count =
- (data[2] + devpriv->clock_ns -
- 1) / devpriv->clock_ns;
+ (data[2] + devpriv->clock_ns -
+ 1) / devpriv->clock_ns;
break;
default:
return -EINVAL;
@@ -4703,30 +4819,30 @@ static int ni_m_series_pwm_config(struct comedi_device *dev, struct comedi_subde
switch (data[3]) {
case TRIG_ROUND_NEAREST:
down_count =
- (data[4] +
- devpriv->clock_ns / 2) / devpriv->clock_ns;
+ (data[4] +
+ devpriv->clock_ns / 2) / devpriv->clock_ns;
break;
case TRIG_ROUND_DOWN:
down_count = data[4] / devpriv->clock_ns;
break;
case TRIG_ROUND_UP:
down_count =
- (data[4] + devpriv->clock_ns -
- 1) / devpriv->clock_ns;
+ (data[4] + devpriv->clock_ns -
+ 1) / devpriv->clock_ns;
break;
default:
return -EINVAL;
break;
}
if (up_count * devpriv->clock_ns != data[2] ||
- down_count * devpriv->clock_ns != data[4]) {
+ down_count * devpriv->clock_ns != data[4]) {
data[2] = up_count * devpriv->clock_ns;
data[4] = down_count * devpriv->clock_ns;
return -EAGAIN;
}
ni_writel(MSeries_Cal_PWM_High_Time_Bits(up_count) |
- MSeries_Cal_PWM_Low_Time_Bits(down_count),
- M_Offset_Cal_PWM);
+ MSeries_Cal_PWM_Low_Time_Bits(down_count),
+ M_Offset_Cal_PWM);
devpriv->pwm_up_count = up_count;
devpriv->pwm_down_count = down_count;
return 5;
@@ -4741,8 +4857,9 @@ static int ni_m_series_pwm_config(struct comedi_device *dev, struct comedi_subde
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]) {
@@ -4750,16 +4867,16 @@ static int ni_6143_pwm_config(struct comedi_device *dev, struct comedi_subdevice
switch (data[1]) {
case TRIG_ROUND_NEAREST:
up_count =
- (data[2] +
- devpriv->clock_ns / 2) / devpriv->clock_ns;
+ (data[2] +
+ devpriv->clock_ns / 2) / devpriv->clock_ns;
break;
case TRIG_ROUND_DOWN:
up_count = data[2] / devpriv->clock_ns;
break;
case TRIG_ROUND_UP:
up_count =
- (data[2] + devpriv->clock_ns -
- 1) / devpriv->clock_ns;
+ (data[2] + devpriv->clock_ns -
+ 1) / devpriv->clock_ns;
break;
default:
return -EINVAL;
@@ -4768,23 +4885,23 @@ static int ni_6143_pwm_config(struct comedi_device *dev, struct comedi_subdevice
switch (data[3]) {
case TRIG_ROUND_NEAREST:
down_count =
- (data[4] +
- devpriv->clock_ns / 2) / devpriv->clock_ns;
+ (data[4] +
+ devpriv->clock_ns / 2) / devpriv->clock_ns;
break;
case TRIG_ROUND_DOWN:
down_count = data[4] / devpriv->clock_ns;
break;
case TRIG_ROUND_UP:
down_count =
- (data[4] + devpriv->clock_ns -
- 1) / devpriv->clock_ns;
+ (data[4] + devpriv->clock_ns -
+ 1) / devpriv->clock_ns;
break;
default:
return -EINVAL;
break;
}
if (up_count * devpriv->clock_ns != data[2] ||
- down_count * devpriv->clock_ns != data[4]) {
+ down_count * devpriv->clock_ns != data[4]) {
data[2] = up_count * devpriv->clock_ns;
data[4] = down_count * devpriv->clock_ns;
return -EAGAIN;
@@ -4808,16 +4925,18 @@ 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)];
@@ -4884,7 +5003,7 @@ static void caldac_setup(struct comedi_device *dev, struct comedi_subdevice *s)
type = boardtype.caldac[i];
for (j = 0; j < caldacs[type].n_chans; j++) {
maxdata_list[chan] =
- (1 << caldacs[type].n_bits) - 1;
+ (1 << caldacs[type].n_bits) - 1;
chan++;
}
}
@@ -4948,8 +5067,8 @@ static int pack_mb88341(int addr, int val, int *bitstring)
*/
addr++;
*bitstring = ((addr & 0x1) << 11) |
- ((addr & 0x2) << 9) |
- ((addr & 0x4) << 7) | ((addr & 0x8) << 5) | (val & 0xff);
+ ((addr & 0x2) << 9) |
+ ((addr & 0x4) << 7) | ((addr & 0x8) << 5) | (val & 0xff);
return 12;
}
@@ -4993,11 +5112,11 @@ static int GPCT_G_Watch(struct comedi_device *dev, int chan)
devpriv->gpct_command[chan] &= ~G_Save_Trace;
devpriv->stc_writew(dev, devpriv->gpct_command[chan],
- G_Command_Register(chan));
+ G_Command_Register(chan));
devpriv->gpct_command[chan] |= G_Save_Trace;
devpriv->stc_writew(dev, devpriv->gpct_command[chan],
- G_Command_Register(chan));
+ G_Command_Register(chan));
/* This procedure is used because the two registers cannot
* be read atomically. */
@@ -5021,37 +5140,37 @@ static void GPCT_Reset(struct comedi_device *dev, int chan)
case 0:
devpriv->stc_writew(dev, G0_Reset, Joint_Reset_Register);
ni_set_bits(dev, Interrupt_A_Enable_Register,
- G0_TC_Interrupt_Enable, 0);
+ G0_TC_Interrupt_Enable, 0);
ni_set_bits(dev, Interrupt_A_Enable_Register,
- G0_Gate_Interrupt_Enable, 0);
+ G0_Gate_Interrupt_Enable, 0);
temp_ack_reg |= G0_Gate_Error_Confirm;
temp_ack_reg |= G0_TC_Error_Confirm;
temp_ack_reg |= G0_TC_Interrupt_Ack;
temp_ack_reg |= G0_Gate_Interrupt_Ack;
devpriv->stc_writew(dev, temp_ack_reg,
- Interrupt_A_Ack_Register);
+ Interrupt_A_Ack_Register);
/* 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);
+ Analog_Trigger_Etc_Register);
break;
case 1:
devpriv->stc_writew(dev, G1_Reset, Joint_Reset_Register);
ni_set_bits(dev, Interrupt_B_Enable_Register,
- G1_TC_Interrupt_Enable, 0);
+ G1_TC_Interrupt_Enable, 0);
ni_set_bits(dev, Interrupt_B_Enable_Register,
- G0_Gate_Interrupt_Enable, 0);
+ G0_Gate_Interrupt_Enable, 0);
temp_ack_reg |= G1_Gate_Error_Confirm;
temp_ack_reg |= G1_TC_Error_Confirm;
temp_ack_reg |= G1_TC_Interrupt_Ack;
temp_ack_reg |= G1_Gate_Interrupt_Ack;
devpriv->stc_writew(dev, temp_ack_reg,
- Interrupt_B_Ack_Register);
+ Interrupt_B_Ack_Register);
devpriv->an_trig_etc_reg |= GPFO_1_Output_Enable;
devpriv->stc_writew(dev, devpriv->an_trig_etc_reg,
- Analog_Trigger_Etc_Register);
+ Analog_Trigger_Etc_Register);
break;
};
@@ -5062,9 +5181,9 @@ static void GPCT_Reset(struct comedi_device *dev, int chan)
devpriv->gpct_command[chan] |= G_Synchronized_Gate;
devpriv->stc_writew(dev, devpriv->gpct_mode[chan],
- G_Mode_Register(chan));
+ G_Mode_Register(chan));
devpriv->stc_writew(dev, devpriv->gpct_input_select[chan],
- G_Input_Select_Register(chan));
+ G_Input_Select_Register(chan));
devpriv->stc_writew(dev, 0, G_Autoincrement_Register(chan));
/* printk("exit GPCT_Reset\n"); */
@@ -5072,22 +5191,25 @@ static void GPCT_Reset(struct comedi_device *dev, int chan)
#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);
@@ -5101,10 +5223,10 @@ static int ni_gpct_cmd(struct comedi_device *dev, struct comedi_subdevice *s)
/* const struct comedi_cmd *cmd = &s->async->cmd; */
retval = ni_request_gpct_mite_channel(dev, counter->counter_index,
- COMEDI_INPUT);
+ COMEDI_INPUT);
if (retval) {
comedi_error(dev,
- "no dma channel available for use by counter");
+ "no dma channel available for use by counter");
return retval;
}
ni_tio_acknowledge_and_confirm(counter, NULL, NULL, NULL, NULL);
@@ -5116,8 +5238,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;
@@ -5150,7 +5272,7 @@ static int ni_gpct_cancel(struct comedi_device *dev, struct comedi_subdevice *s)
*/
static int ni_m_series_set_pfi_routing(struct comedi_device *dev, unsigned chan,
- unsigned source)
+ unsigned source)
{
unsigned pfi_reg_index;
unsigned array_offset;
@@ -5159,16 +5281,16 @@ static int ni_m_series_set_pfi_routing(struct comedi_device *dev, unsigned chan,
pfi_reg_index = 1 + chan / 3;
array_offset = pfi_reg_index - 1;
devpriv->pfi_output_select_reg[array_offset] &=
- ~MSeries_PFI_Output_Select_Mask(chan);
+ ~MSeries_PFI_Output_Select_Mask(chan);
devpriv->pfi_output_select_reg[array_offset] |=
- MSeries_PFI_Output_Select_Bits(chan, source);
+ MSeries_PFI_Output_Select_Bits(chan, source);
ni_writew(devpriv->pfi_output_select_reg[array_offset],
- M_Offset_PFI_Output_Select(pfi_reg_index));
+ M_Offset_PFI_Output_Select(pfi_reg_index));
return 2;
}
static int ni_old_set_pfi_routing(struct comedi_device *dev, unsigned chan,
- unsigned source)
+ unsigned source)
{
/* pre-m-series boards have fixed signals on pfi pins */
if (source != ni_old_get_pfi_routing(dev, chan))
@@ -5177,7 +5299,7 @@ static int ni_old_set_pfi_routing(struct comedi_device *dev, unsigned chan,
}
static int ni_set_pfi_routing(struct comedi_device *dev, unsigned chan,
- unsigned source)
+ unsigned source)
{
if (boardtype.reg_type & ni_reg_m_series_mask)
return ni_m_series_set_pfi_routing(dev, chan, source);
@@ -5185,11 +5307,14 @@ 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]);
+ devpriv->
+ pfi_output_select_reg
+ [array_offset]);
}
static unsigned ni_old_get_pfi_routing(struct comedi_device *dev, unsigned chan)
@@ -5242,7 +5367,7 @@ static unsigned ni_get_pfi_routing(struct comedi_device *dev, unsigned chan)
}
static int ni_config_filter(struct comedi_device *dev, unsigned pfi_channel,
- enum ni_pfi_filter_select filter)
+ enum ni_pfi_filter_select filter)
{
unsigned bits;
if ((boardtype.reg_type & ni_reg_m_series_mask) == 0) {
@@ -5255,8 +5380,9 @@ 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;
@@ -5270,8 +5396,9 @@ 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;
@@ -5289,9 +5416,8 @@ static int ni_pfi_insn_config(struct comedi_device *dev, struct comedi_subdevice
break;
case INSN_CONFIG_DIO_QUERY:
data[1] =
- (devpriv->
- io_bidirection_pin_reg & (1 << chan)) ? COMEDI_OUTPUT :
- COMEDI_INPUT;
+ (devpriv->io_bidirection_pin_reg & (1 << chan)) ?
+ COMEDI_OUTPUT : COMEDI_INPUT;
return 0;
break;
case INSN_CONFIG_SET_ROUTING:
@@ -5325,23 +5451,26 @@ static void ni_rtsi_init(struct comedi_device *dev)
}
/* 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,
- NI_RTSI_OUTPUT_ADR_START2) | RTSI_Trig_Output_Bits(2,
- NI_RTSI_OUTPUT_SCLKG) | RTSI_Trig_Output_Bits(3,
- NI_RTSI_OUTPUT_DACUPDN);
+ RTSI_Trig_Output_Bits(0,
+ NI_RTSI_OUTPUT_ADR_START1) |
+ RTSI_Trig_Output_Bits(1,
+ NI_RTSI_OUTPUT_ADR_START2) |
+ RTSI_Trig_Output_Bits(2,
+ NI_RTSI_OUTPUT_SCLKG) |
+ RTSI_Trig_Output_Bits(3, NI_RTSI_OUTPUT_DACUPDN);
devpriv->stc_writew(dev, devpriv->rtsi_trig_a_output_reg,
- RTSI_Trig_A_Output_Register);
+ RTSI_Trig_A_Output_Register);
devpriv->rtsi_trig_b_output_reg =
- RTSI_Trig_Output_Bits(4,
- NI_RTSI_OUTPUT_DA_START1) | RTSI_Trig_Output_Bits(5,
- NI_RTSI_OUTPUT_G_SRC0) | RTSI_Trig_Output_Bits(6,
- NI_RTSI_OUTPUT_G_GATE0);
+ RTSI_Trig_Output_Bits(4,
+ NI_RTSI_OUTPUT_DA_START1) |
+ RTSI_Trig_Output_Bits(5,
+ NI_RTSI_OUTPUT_G_SRC0) |
+ RTSI_Trig_Output_Bits(6, NI_RTSI_OUTPUT_G_GATE0);
if (boardtype.reg_type & ni_reg_m_series_mask)
devpriv->rtsi_trig_b_output_reg |=
- RTSI_Trig_Output_Bits(7, NI_RTSI_OUTPUT_RTSI_OSC);
+ RTSI_Trig_Output_Bits(7, NI_RTSI_OUTPUT_RTSI_OSC);
devpriv->stc_writew(dev, devpriv->rtsi_trig_b_output_reg,
- RTSI_Trig_B_Output_Register);
+ RTSI_Trig_B_Output_Register);
/*
* Sets the source and direction of the 4 on board lines
@@ -5349,8 +5478,9 @@ 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_bits(struct comedi_device *dev,
+ struct comedi_subdevice *s,
+ struct comedi_insn *insn, unsigned int *data)
{
if (insn->n != 2)
return -EINVAL;
@@ -5363,8 +5493,9 @@ static int ni_rtsi_insn_bits(struct comedi_device *dev, struct comedi_subdevice
/* Find best multiplier/divider to try and get the PLL running at 80 MHz
* given an arbitrary frequency input clock */
static int ni_mseries_get_pll_parameters(unsigned reference_period_ns,
- unsigned *freq_divider, unsigned *freq_multiplier,
- unsigned *actual_period_ns)
+ unsigned *freq_divider,
+ unsigned *freq_multiplier,
+ unsigned *actual_period_ns)
{
unsigned div;
unsigned best_div = 1;
@@ -5383,9 +5514,9 @@ static int ni_mseries_get_pll_parameters(unsigned reference_period_ns,
for (div = 1; div <= max_div; ++div) {
for (mult = 1; mult <= max_mult; ++mult) {
unsigned new_period_ps =
- (reference_picosec * div) / mult;
+ (reference_picosec * div) / mult;
if (abs(new_period_ps - target_picosec) <
- abs(best_period_picosec - target_picosec)) {
+ abs(best_period_picosec - target_picosec)) {
best_period_picosec = new_period_ps;
best_div = div;
best_mult = mult;
@@ -5393,15 +5524,14 @@ static int ni_mseries_get_pll_parameters(unsigned reference_period_ns,
}
}
if (best_period_picosec == 0) {
- printk("%s: bug, failed to find pll parameters\n",
- __func__);
+ printk("%s: bug, failed to find pll parameters\n", __func__);
return -EIO;
}
*freq_divider = best_div;
*freq_multiplier = best_mult;
*actual_period_ns =
- (best_period_picosec * fudge_factor_80_to_20Mhz +
- (pico_per_nano / 2)) / pico_per_nano;
+ (best_period_picosec * fudge_factor_80_to_20Mhz +
+ (pico_per_nano / 2)) / pico_per_nano;
return 0;
}
@@ -5413,8 +5543,8 @@ 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,
- unsigned period_ns)
+static int ni_mseries_set_pll_master_clock(struct comedi_device *dev,
+ unsigned source, unsigned period_ns)
{
static const unsigned min_period_ns = 50;
static const unsigned max_period_ns = 1000;
@@ -5429,34 +5559,36 @@ static int ni_mseries_set_pll_master_clock(struct comedi_device *dev, unsigned s
/* 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) {
printk
- ("%s: you must specify an input clock frequency between %i and %i nanosec "
- "for the phased-lock loop.\n", __func__,
- min_period_ns, max_period_ns);
+ ("%s: you must specify an input clock frequency between %i and %i nanosec "
+ "for the phased-lock loop.\n", __func__,
+ min_period_ns, max_period_ns);
return -EINVAL;
}
devpriv->rtsi_trig_direction_reg &= ~Use_RTSI_Clock_Bit;
devpriv->stc_writew(dev, devpriv->rtsi_trig_direction_reg,
- RTSI_Trig_Direction_Register);
+ RTSI_Trig_Direction_Register);
pll_control_bits =
- MSeries_PLL_Enable_Bit | MSeries_PLL_VCO_Mode_75_150MHz_Bits;
+ MSeries_PLL_Enable_Bit | MSeries_PLL_VCO_Mode_75_150MHz_Bits;
devpriv->clock_and_fout2 |=
- MSeries_Timebase1_Select_Bit | MSeries_Timebase3_Select_Bit;
+ MSeries_Timebase1_Select_Bit | MSeries_Timebase3_Select_Bit;
devpriv->clock_and_fout2 &= ~MSeries_PLL_In_Source_Select_Mask;
switch (source) {
case NI_MIO_PLL_PXI_STAR_TRIGGER_CLOCK:
devpriv->clock_and_fout2 |=
- MSeries_PLL_In_Source_Select_Star_Trigger_Bits;
+ MSeries_PLL_In_Source_Select_Star_Trigger_Bits;
retval = ni_mseries_get_pll_parameters(period_ns, &freq_divider,
- &freq_multiplier, &devpriv->clock_ns);
+ &freq_multiplier,
+ &devpriv->clock_ns);
if (retval < 0)
return retval;
break;
case NI_MIO_PLL_PXI10_CLOCK:
/* pxi clock is 10MHz */
devpriv->clock_and_fout2 |=
- MSeries_PLL_In_Source_Select_PXI_Clock10;
+ MSeries_PLL_In_Source_Select_PXI_Clock10;
retval = ni_mseries_get_pll_parameters(period_ns, &freq_divider,
- &freq_multiplier, &devpriv->clock_ns);
+ &freq_multiplier,
+ &devpriv->clock_ns);
if (retval < 0)
return retval;
break;
@@ -5465,20 +5597,22 @@ static int ni_mseries_set_pll_master_clock(struct comedi_device *dev, unsigned s
unsigned rtsi_channel;
static const unsigned max_rtsi_channel = 7;
for (rtsi_channel = 0; rtsi_channel <= max_rtsi_channel;
- ++rtsi_channel) {
+ ++rtsi_channel) {
if (source ==
- NI_MIO_PLL_RTSI_CLOCK(rtsi_channel)) {
+ NI_MIO_PLL_RTSI_CLOCK(rtsi_channel)) {
devpriv->clock_and_fout2 |=
- MSeries_PLL_In_Source_Select_RTSI_Bits
- (rtsi_channel);
+ MSeries_PLL_In_Source_Select_RTSI_Bits
+ (rtsi_channel);
break;
}
}
if (rtsi_channel > max_rtsi_channel)
return -EINVAL;
retval = ni_mseries_get_pll_parameters(period_ns,
- &freq_divider, &freq_multiplier,
- &devpriv->clock_ns);
+ &freq_divider,
+ &freq_multiplier,
+ &devpriv->
+ clock_ns);
if (retval < 0)
return retval;
}
@@ -5486,8 +5620,8 @@ static int ni_mseries_set_pll_master_clock(struct comedi_device *dev, unsigned s
}
ni_writew(devpriv->clock_and_fout2, M_Offset_Clock_and_Fout2);
pll_control_bits |=
- MSeries_PLL_Divisor_Bits(freq_divider) |
- MSeries_PLL_Multiplier_Bits(freq_multiplier);
+ MSeries_PLL_Divisor_Bits(freq_divider) |
+ MSeries_PLL_Multiplier_Bits(freq_multiplier);
/* printk("using divider=%i, multiplier=%i for PLL. pll_control_bits = 0x%x\n",
* freq_divider, freq_multiplier, pll_control_bits); */
@@ -5503,45 +5637,46 @@ static int ni_mseries_set_pll_master_clock(struct comedi_device *dev, unsigned s
}
if (i == timeout) {
printk
- ("%s: timed out waiting for PLL to lock to reference clock source %i with period %i ns.\n",
- __func__, source, period_ns);
+ ("%s: timed out waiting for PLL to lock to reference clock source %i with period %i ns.\n",
+ __func__, source, period_ns);
return -ETIMEDOUT;
}
return 3;
}
static int ni_set_master_clock(struct comedi_device *dev, unsigned source,
- unsigned period_ns)
+ unsigned period_ns)
{
if (source == NI_MIO_INTERNAL_CLOCK) {
devpriv->rtsi_trig_direction_reg &= ~Use_RTSI_Clock_Bit;
devpriv->stc_writew(dev, devpriv->rtsi_trig_direction_reg,
- RTSI_Trig_Direction_Register);
+ RTSI_Trig_Direction_Register);
devpriv->clock_ns = TIMEBASE_1_NS;
if (boardtype.reg_type & ni_reg_m_series_mask) {
devpriv->clock_and_fout2 &=
- ~(MSeries_Timebase1_Select_Bit |
- MSeries_Timebase3_Select_Bit);
+ ~(MSeries_Timebase1_Select_Bit |
+ MSeries_Timebase3_Select_Bit);
ni_writew(devpriv->clock_and_fout2,
- M_Offset_Clock_and_Fout2);
+ M_Offset_Clock_and_Fout2);
ni_writew(0, M_Offset_PLL_Control);
}
devpriv->clock_source = source;
} else {
if (boardtype.reg_type & ni_reg_m_series_mask) {
return ni_mseries_set_pll_master_clock(dev, source,
- period_ns);
+ period_ns);
} else {
if (source == NI_MIO_RTSI_CLOCK) {
devpriv->rtsi_trig_direction_reg |=
- Use_RTSI_Clock_Bit;
+ Use_RTSI_Clock_Bit;
devpriv->stc_writew(dev,
- devpriv->rtsi_trig_direction_reg,
- RTSI_Trig_Direction_Register);
+ devpriv->
+ rtsi_trig_direction_reg,
+ RTSI_Trig_Direction_Register);
if (period_ns == 0) {
printk
- ("%s: we don't handle an unspecified clock period correctly yet, returning error.\n",
- __func__);
+ ("%s: we don't handle an unspecified clock period correctly yet, returning error.\n",
+ __func__);
return -EINVAL;
} else {
devpriv->clock_ns = period_ns;
@@ -5555,7 +5690,7 @@ static int ni_set_master_clock(struct comedi_device *dev, unsigned source,
}
static int ni_valid_rtsi_output_source(struct comedi_device *dev, unsigned chan,
- unsigned source)
+ unsigned source)
{
if (chan >= num_configurable_rtsi_channels(dev)) {
if (chan == old_RTSI_clock_channel) {
@@ -5563,9 +5698,8 @@ static int ni_valid_rtsi_output_source(struct comedi_device *dev, unsigned chan,
return 1;
else {
printk
- ("%s: invalid source for channel=%i, channel %i is always the RTSI clock for pre-m-series boards.\n",
- __func__, chan,
- old_RTSI_clock_channel);
+ ("%s: invalid source for channel=%i, channel %i is always the RTSI clock for pre-m-series boards.\n",
+ __func__, chan, old_RTSI_clock_channel);
return 0;
}
}
@@ -5596,22 +5730,22 @@ 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,
- unsigned source)
+ unsigned source)
{
if (ni_valid_rtsi_output_source(dev, chan, source) == 0)
return -EINVAL;
if (chan < 4) {
devpriv->rtsi_trig_a_output_reg &= ~RTSI_Trig_Output_Mask(chan);
devpriv->rtsi_trig_a_output_reg |=
- RTSI_Trig_Output_Bits(chan, source);
+ RTSI_Trig_Output_Bits(chan, source);
devpriv->stc_writew(dev, devpriv->rtsi_trig_a_output_reg,
- RTSI_Trig_A_Output_Register);
+ RTSI_Trig_A_Output_Register);
} else if (chan < 8) {
devpriv->rtsi_trig_b_output_reg &= ~RTSI_Trig_Output_Mask(chan);
devpriv->rtsi_trig_b_output_reg |=
- RTSI_Trig_Output_Bits(chan, source);
+ RTSI_Trig_Output_Bits(chan, source);
devpriv->stc_writew(dev, devpriv->rtsi_trig_b_output_reg,
- RTSI_Trig_B_Output_Register);
+ RTSI_Trig_B_Output_Register);
}
return 2;
}
@@ -5620,10 +5754,10 @@ static unsigned ni_get_rtsi_routing(struct comedi_device *dev, unsigned chan)
{
if (chan < 4) {
return RTSI_Trig_Output_Source(chan,
- devpriv->rtsi_trig_a_output_reg);
+ devpriv->rtsi_trig_a_output_reg);
} else if (chan < num_configurable_rtsi_channels(dev)) {
return RTSI_Trig_Output_Source(chan,
- devpriv->rtsi_trig_b_output_reg);
+ devpriv->rtsi_trig_b_output_reg);
} else {
if (chan == old_RTSI_clock_channel)
return NI_RTSI_OUTPUT_RTSI_OSC;
@@ -5632,53 +5766,54 @@ static unsigned ni_get_rtsi_routing(struct comedi_device *dev, unsigned chan)
}
}
-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]) {
case INSN_CONFIG_DIO_OUTPUT:
if (chan < num_configurable_rtsi_channels(dev)) {
devpriv->rtsi_trig_direction_reg |=
- RTSI_Output_Bit(chan,
- (boardtype.reg_type & ni_reg_m_series_mask) !=
- 0);
+ RTSI_Output_Bit(chan,
+ (boardtype.
+ reg_type & ni_reg_m_series_mask) !=
+ 0);
} else if (chan == old_RTSI_clock_channel) {
devpriv->rtsi_trig_direction_reg |=
- Drive_RTSI_Clock_Bit;
+ Drive_RTSI_Clock_Bit;
}
devpriv->stc_writew(dev, devpriv->rtsi_trig_direction_reg,
- RTSI_Trig_Direction_Register);
+ RTSI_Trig_Direction_Register);
break;
case INSN_CONFIG_DIO_INPUT:
if (chan < num_configurable_rtsi_channels(dev)) {
devpriv->rtsi_trig_direction_reg &=
- ~RTSI_Output_Bit(chan,
- (boardtype.reg_type & ni_reg_m_series_mask) !=
- 0);
+ ~RTSI_Output_Bit(chan,
+ (boardtype.
+ reg_type & ni_reg_m_series_mask)
+ != 0);
} else if (chan == old_RTSI_clock_channel) {
devpriv->rtsi_trig_direction_reg &=
- ~Drive_RTSI_Clock_Bit;
+ ~Drive_RTSI_Clock_Bit;
}
devpriv->stc_writew(dev, devpriv->rtsi_trig_direction_reg,
- RTSI_Trig_Direction_Register);
+ RTSI_Trig_Direction_Register);
break;
case INSN_CONFIG_DIO_QUERY:
if (chan < num_configurable_rtsi_channels(dev)) {
data[1] =
- (devpriv->
- rtsi_trig_direction_reg & RTSI_Output_Bit(chan,
- (boardtype.
- reg_type & ni_reg_m_series_mask)
- !=
- 0)) ? INSN_CONFIG_DIO_OUTPUT :
- INSN_CONFIG_DIO_INPUT;
+ (devpriv->rtsi_trig_direction_reg &
+ RTSI_Output_Bit(chan,
+ (boardtype.reg_type &
+ ni_reg_m_series_mask)
+ != 0)) ? INSN_CONFIG_DIO_OUTPUT :
+ INSN_CONFIG_DIO_INPUT;
} else if (chan == old_RTSI_clock_channel) {
data[1] =
- (devpriv->
- rtsi_trig_direction_reg & Drive_RTSI_Clock_Bit)
- ? INSN_CONFIG_DIO_OUTPUT :
- INSN_CONFIG_DIO_INPUT;
+ (devpriv->rtsi_trig_direction_reg &
+ Drive_RTSI_Clock_Bit)
+ ? INSN_CONFIG_DIO_OUTPUT : INSN_CONFIG_DIO_INPUT;
}
return 2;
break;
@@ -5751,12 +5886,12 @@ static void cs5529_command(struct comedi_device *dev, unsigned short value)
/* write to cs5529 register */
static void cs5529_config_write(struct comedi_device *dev, unsigned int value,
- unsigned int reg_select_bits)
+ unsigned int reg_select_bits)
{
ni_ao_win_outw(dev, ((value >> 16) & 0xff),
- CAL_ADC_Config_Data_High_Word_67xx);
+ CAL_ADC_Config_Data_High_Word_67xx);
ni_ao_win_outw(dev, (value & 0xffff),
- CAL_ADC_Config_Data_Low_Word_67xx);
+ CAL_ADC_Config_Data_Low_Word_67xx);
reg_select_bits &= CSCMD_REGISTER_SELECT_MASK;
cs5529_command(dev, CSCMD_COMMAND | reg_select_bits);
if (cs5529_wait_for_idle(dev))
@@ -5766,7 +5901,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,
- unsigned int reg_select_bits)
+ unsigned int reg_select_bits)
{
unsigned int value;
@@ -5775,7 +5910,8 @@ static unsigned int cs5529_config_read(struct comedi_device *dev,
if (cs5529_wait_for_idle(dev))
comedi_error(dev, "timeout or signal in cs5529_config_read()");
value = (ni_ao_win_inw(dev,
- CAL_ADC_Config_Data_High_Word_67xx) << 16) & 0xff0000;
+ CAL_ADC_Config_Data_High_Word_67xx) << 16) &
+ 0xff0000;
value |= ni_ao_win_inw(dev, CAL_ADC_Config_Data_Low_Word_67xx) & 0xffff;
return value;
}
@@ -5790,18 +5926,18 @@ static int cs5529_do_conversion(struct comedi_device *dev, unsigned short *data)
retval = cs5529_wait_for_idle(dev);
if (retval) {
comedi_error(dev,
- "timeout or signal in cs5529_do_conversion()");
+ "timeout or signal in cs5529_do_conversion()");
return -ETIME;
}
status = ni_ao_win_inw(dev, CAL_ADC_Status_67xx);
if (status & CSS_OSC_DETECT) {
printk
- ("ni_mio_common: cs5529 conversion error, status CSS_OSC_DETECT\n");
+ ("ni_mio_common: cs5529 conversion error, status CSS_OSC_DETECT\n");
return -EIO;
}
if (status & CSS_OVERRANGE) {
printk
- ("ni_mio_common: cs5529 conversion error, overrange (ignoring)\n");
+ ("ni_mio_common: cs5529 conversion error, overrange (ignoring)\n");
}
if (data) {
*data = ni_ao_win_inw(dev, CAL_ADC_Data_67xx);
@@ -5811,8 +5947,9 @@ 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;
@@ -5840,29 +5977,28 @@ static int cs5529_ai_insn_read(struct comedi_device *dev, struct comedi_subdevic
static int init_cs5529(struct comedi_device *dev)
{
unsigned int config_bits =
- CSCFG_PORT_MODE | CSCFG_WORD_RATE_2180_CYCLES;
+ CSCFG_PORT_MODE | CSCFG_WORD_RATE_2180_CYCLES;
#if 1
/* do self-calibration */
cs5529_config_write(dev, config_bits | CSCFG_SELF_CAL_OFFSET_GAIN,
- CSCMD_CONFIG_REGISTER);
+ CSCMD_CONFIG_REGISTER);
/* need to force a conversion for calibration to run */
cs5529_do_conversion(dev, NULL);
#else
/* force gain calibration to 1 */
cs5529_config_write(dev, 0x400000, CSCMD_GAIN_REGISTER);
cs5529_config_write(dev, config_bits | CSCFG_SELF_CAL_OFFSET,
- CSCMD_CONFIG_REGISTER);
+ CSCMD_CONFIG_REGISTER);
if (cs5529_wait_for_idle(dev))
comedi_error(dev, "timeout or signal in init_cs5529()\n");
#endif
#ifdef NI_CS5529_DEBUG
printk("config: 0x%x\n", cs5529_config_read(dev,
- CSCMD_CONFIG_REGISTER));
- printk("gain: 0x%x\n", cs5529_config_read(dev,
- CSCMD_GAIN_REGISTER));
+ CSCMD_CONFIG_REGISTER));
+ printk("gain: 0x%x\n", cs5529_config_read(dev, CSCMD_GAIN_REGISTER));
printk("offset: 0x%x\n", cs5529_config_read(dev,
- CSCMD_OFFSET_REGISTER));
+ 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 4d408d410c24..b7322963cf78 100644
--- a/drivers/staging/comedi/drivers/ni_mio_cs.c
+++ b/drivers/staging/comedi/drivers/ni_mio_cs.c
@@ -82,7 +82,7 @@ static const struct ni_board_struct ni_boards[] = {
.num_p0_dio_channels = 8,
.has_8255 = 0,
.caldac = {dac8800, dac8043},
- },
+ },
{.device_id = 0x010c,
.name = "DAQCard-ai-16e-4",
.n_adchan = 16,
@@ -98,7 +98,7 @@ static const struct ni_board_struct ni_boards[] = {
.num_p0_dio_channels = 8,
.has_8255 = 0,
.caldac = {mb88341}, /* verified */
- },
+ },
{.device_id = 0x02c4,
.name = "DAQCard-6062E",
.n_adchan = 16,
@@ -116,7 +116,7 @@ static const struct ni_board_struct ni_boards[] = {
.num_p0_dio_channels = 8,
.has_8255 = 0,
.caldac = {ad8804_debug}, /* verified */
- },
+ },
{.device_id = 0x075e,
.name = "DAQCard-6024E", /* specs incorrect! */
.n_adchan = 16,
@@ -134,7 +134,7 @@ static const struct ni_board_struct ni_boards[] = {
.num_p0_dio_channels = 8,
.has_8255 = 0,
.caldac = {ad8804_debug},
- },
+ },
{.device_id = 0x0245,
.name = "DAQCard-6036E", /* specs incorrect! */
.n_adchan = 16,
@@ -152,7 +152,7 @@ static const struct ni_board_struct ni_boards[] = {
.num_p0_dio_channels = 8,
.has_8255 = 0,
.caldac = {ad8804_debug},
- },
+ },
#if 0
{.device_id = 0x0000, /* unknown */
.name = "DAQCard-6715",
@@ -162,7 +162,7 @@ static const struct ni_board_struct ni_boards[] = {
.ao_671x = 8192,
.num_p0_dio_channels = 8,
.caldac = {mb88341, mb88341},
- },
+ },
#endif
/* N.B. Update ni_mio_cs_ids[] when entries added above. */
};
@@ -227,7 +227,8 @@ static uint16_t mio_cs_win_in(struct comedi_device *dev, int addr)
return ret;
}
-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);
static int mio_cs_detach(struct comedi_device *dev);
static struct comedi_driver driver_ni_mio_cs = {
.driver_name = "ni_mio_cs",
@@ -238,7 +239,8 @@ static struct comedi_driver driver_ni_mio_cs = {
#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 */
@@ -266,6 +268,7 @@ static dev_node_t dev_node = {
COMEDI_MAJOR, 0,
NULL
};
+
static int cs_attach(struct pcmcia_device *link)
{
link->io.Attributes1 = IO_DATA_PATH_WIDTH_16;
@@ -340,7 +343,7 @@ static void mio_cs_config(struct pcmcia_device *link)
tuple.DesiredTuple = CISTPL_MANFID;
tuple.Attributes = TUPLE_RETURN_COMMON;
if ((pcmcia_get_first_tuple(link, &tuple) == 0) &&
- (pcmcia_get_tuple_data(link, &tuple) == 0)) {
+ (pcmcia_get_tuple_data(link, &tuple) == 0)) {
manfid = le16_to_cpu(buf[0]);
prodid = le16_to_cpu(buf[1]);
}
@@ -373,7 +376,7 @@ static void mio_cs_config(struct pcmcia_device *link)
#endif
link->io.NumPorts1 = parse.cftable_entry.io.win[0].len;
link->io.IOAddrLines =
- parse.cftable_entry.io.flags & CISTPL_IO_LINES_MASK;
+ parse.cftable_entry.io.flags & CISTPL_IO_LINES_MASK;
link->io.NumPorts2 = 0;
{
@@ -421,7 +424,7 @@ static int mio_cs_attach(struct comedi_device *dev, struct comedi_devconfig *it)
irq = link->irq.AssignedIRQ;
printk("comedi%d: %s: DAQCard: io 0x%04lx, irq %u, ",
- dev->minor, dev->driver->driver_name, dev->iobase, irq);
+ dev->minor, dev->driver->driver_name, dev->iobase, irq);
#if 0
{
@@ -430,7 +433,7 @@ static int mio_cs_attach(struct comedi_device *dev, struct comedi_devconfig *it)
printk(" board fingerprint:");
for (i = 0; i < 32; i += 2) {
printk(" %04x %02x", inw(dev->iobase + i),
- inb(dev->iobase + i + 1));
+ inb(dev->iobase + i + 1));
}
printk("\n");
printk(" board fingerprint (windowed):");
@@ -447,7 +450,7 @@ static int mio_cs_attach(struct comedi_device *dev, struct comedi_devconfig *it)
dev->board_name = boardtype.name;
ret = request_irq(irq, ni_E_interrupt, NI_E_IRQ_FLAGS,
- "ni_mio_cs", dev);
+ "ni_mio_cs", dev);
if (ret < 0) {
printk(" irq not available\n");
return -EINVAL;
@@ -484,14 +487,15 @@ static int get_prodid(struct comedi_device *dev, struct pcmcia_device *link)
tuple.DesiredTuple = CISTPL_MANFID;
tuple.Attributes = TUPLE_RETURN_COMMON;
if ((pcmcia_get_first_tuple(link, &tuple) == 0) &&
- (pcmcia_get_tuple_data(link, &tuple) == 0)) {
+ (pcmcia_get_tuple_data(link, &tuple) == 0)) {
prodid = le16_to_cpu(buf[1]);
}
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;
@@ -532,7 +536,7 @@ struct pcmcia_driver ni_mio_cs_driver = {
.id_table = ni_mio_cs_ids,
.owner = THIS_MODULE,
.drv = {
- .name = dev_info,
+ .name = dev_info,
},
};
diff --git a/drivers/staging/comedi/drivers/ni_pcidio.c b/drivers/staging/comedi/drivers/ni_pcidio.c
index 6b86a39aac5e..15148d1642d4 100644
--- a/drivers/staging/comedi/drivers/ni_pcidio.c
+++ b/drivers/staging/comedi/drivers/ni_pcidio.c
@@ -212,6 +212,7 @@ static inline unsigned primary_DMAChannel_bits(unsigned channel)
{
return channel & 0x3;
}
+
static inline unsigned secondary_DMAChannel_bits(unsigned channel)
{
return (channel << 2) & 0xc;
@@ -290,7 +291,8 @@ enum FPGA_Control_Bits {
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 ni_pcidio_cancel(struct comedi_device *dev,
+ struct comedi_subdevice *s);
static struct comedi_driver driver_pcidio = {
.driver_name = "ni_pcidio",
@@ -310,83 +312,84 @@ 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,
+ },
};
#define n_nidio_boards (sizeof(nidio_boards)/sizeof(nidio_boards[0]))
#define this_board ((const struct nidio_board *)dev->board_ptr)
static DEFINE_PCI_DEVICE_TABLE(ni_pcidio_pci_table) = {
- {PCI_VENDOR_ID_NATINST, 0x1150, PCI_ANY_ID, PCI_ANY_ID, 0, 0, 0},
- {PCI_VENDOR_ID_NATINST, 0x1320, PCI_ANY_ID, PCI_ANY_ID, 0, 0, 0},
- {PCI_VENDOR_ID_NATINST, 0x12b0, PCI_ANY_ID, PCI_ANY_ID, 0, 0, 0},
- {PCI_VENDOR_ID_NATINST, 0x0160, PCI_ANY_ID, PCI_ANY_ID, 0, 0, 0},
- {PCI_VENDOR_ID_NATINST, 0x1630, PCI_ANY_ID, PCI_ANY_ID, 0, 0, 0},
- {PCI_VENDOR_ID_NATINST, 0x13c0, PCI_ANY_ID, PCI_ANY_ID, 0, 0, 0},
- {PCI_VENDOR_ID_NATINST, 0x0400, PCI_ANY_ID, PCI_ANY_ID, 0, 0, 0},
- {PCI_VENDOR_ID_NATINST, 0x1250, PCI_ANY_ID, PCI_ANY_ID, 0, 0, 0},
- {PCI_VENDOR_ID_NATINST, 0x17d0, PCI_ANY_ID, PCI_ANY_ID, 0, 0, 0},
- {PCI_VENDOR_ID_NATINST, 0x1800, PCI_ANY_ID, PCI_ANY_ID, 0, 0, 0},
- {0}
+ {
+ PCI_VENDOR_ID_NATINST, 0x1150, PCI_ANY_ID, PCI_ANY_ID, 0, 0, 0}, {
+ PCI_VENDOR_ID_NATINST, 0x1320, PCI_ANY_ID, PCI_ANY_ID, 0, 0, 0}, {
+ PCI_VENDOR_ID_NATINST, 0x12b0, PCI_ANY_ID, PCI_ANY_ID, 0, 0, 0}, {
+ PCI_VENDOR_ID_NATINST, 0x0160, PCI_ANY_ID, PCI_ANY_ID, 0, 0, 0}, {
+ PCI_VENDOR_ID_NATINST, 0x1630, PCI_ANY_ID, PCI_ANY_ID, 0, 0, 0}, {
+ PCI_VENDOR_ID_NATINST, 0x13c0, PCI_ANY_ID, PCI_ANY_ID, 0, 0, 0}, {
+ PCI_VENDOR_ID_NATINST, 0x0400, PCI_ANY_ID, PCI_ANY_ID, 0, 0, 0}, {
+ PCI_VENDOR_ID_NATINST, 0x1250, PCI_ANY_ID, PCI_ANY_ID, 0, 0, 0}, {
+ PCI_VENDOR_ID_NATINST, 0x17d0, PCI_ANY_ID, PCI_ANY_ID, 0, 0, 0}, {
+ PCI_VENDOR_ID_NATINST, 0x1800, PCI_ANY_ID, PCI_ANY_ID, 0, 0, 0}, {
+ 0}
};
MODULE_DEVICE_TABLE(pci, ni_pcidio_pci_table);
@@ -402,14 +405,16 @@ 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_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 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 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);
@@ -426,16 +431,16 @@ static int ni_pcidio_request_di_mite_channel(struct comedi_device *dev)
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);
+ mite_request_channel_in_range(devpriv->mite,
+ devpriv->di_mite_ring, 1, 2);
if (devpriv->di_mite_chan == NULL) {
spin_unlock_irqrestore(&devpriv->mite_channel_lock, flags);
comedi_error(dev, "failed to reserve mite dma channel.");
return -EBUSY;
}
writeb(primary_DMAChannel_bits(devpriv->di_mite_chan->channel) |
- secondary_DMAChannel_bits(devpriv->di_mite_chan->channel),
- devpriv->mite->daq_io_addr + DMA_Line_Control_Group1);
+ secondary_DMAChannel_bits(devpriv->di_mite_chan->channel),
+ devpriv->mite->daq_io_addr + DMA_Line_Control_Group1);
mmiowb();
spin_unlock_irqrestore(&devpriv->mite_channel_lock, flags);
return 0;
@@ -452,8 +457,8 @@ static void ni_pcidio_release_di_mite_channel(struct comedi_device *dev)
mite_release_channel(devpriv->di_mite_chan);
devpriv->di_mite_chan = NULL;
writeb(primary_DMAChannel_bits(0) |
- secondary_DMAChannel_bits(0),
- devpriv->mite->daq_io_addr + DMA_Line_Control_Group1);
+ secondary_DMAChannel_bits(0),
+ devpriv->mite->daq_io_addr + DMA_Line_Control_Group1);
mmiowb();
}
spin_unlock_irqrestore(&devpriv->mite_channel_lock, flags);
@@ -471,9 +476,9 @@ 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)
{
- if (s->async->
- events & (COMEDI_CB_EOA | COMEDI_CB_ERROR | COMEDI_CB_OVERFLOW))
- {
+ if (s->
+ async->events & (COMEDI_CB_EOA | COMEDI_CB_ERROR |
+ COMEDI_CB_OVERFLOW)) {
ni_pcidio_cancel(dev, s);
}
comedi_event(dev, s);
@@ -503,7 +508,7 @@ static irqreturn_t nidio_interrupt(int irq, void *d)
}
status = readb(devpriv->mite->daq_io_addr +
- Interrupt_And_Window_Status);
+ Interrupt_And_Window_Status);
flags = readb(devpriv->mite->daq_io_addr + Group_1_Flags);
DPRINTK("ni_pcidio_interrupt: status=0x%02x,flags=0x%02x\n",
@@ -525,13 +530,13 @@ static irqreturn_t nidio_interrupt(int irq, void *d)
if (m_status & CHSR_INT) {
if (m_status & CHSR_LINKC) {
writel(CHOR_CLRLC,
- mite->mite_io_addr +
- MITE_CHOR(devpriv->di_mite_chan->channel));
+ mite->mite_io_addr +
+ MITE_CHOR(devpriv->di_mite_chan->channel));
mite_sync_input_dma(devpriv->di_mite_chan, s->async);
/* XXX need to byteswap */
}
if (m_status & ~(CHSR_INT | CHSR_LINKC | CHSR_DONE | CHSR_DRDY |
- CHSR_DRQ1 | CHSR_MRDY)) {
+ CHSR_DRQ1 | CHSR_MRDY)) {
DPRINTK("unknown mite interrupt, disabling IRQ\n");
async->events |= COMEDI_CB_EOA | COMEDI_CB_ERROR;
disable_irq(dev->irq);
@@ -544,8 +549,8 @@ static irqreturn_t nidio_interrupt(int irq, void *d)
if (work > 20) {
DPRINTK("too much work in interrupt\n");
writeb(0x00,
- devpriv->mite->daq_io_addr +
- Master_DMA_And_Interrupt_Control);
+ devpriv->mite->daq_io_addr +
+ Master_DMA_And_Interrupt_Control);
break;
}
@@ -558,20 +563,20 @@ static irqreturn_t nidio_interrupt(int irq, void *d)
if (work > 100) {
DPRINTK("too much work in interrupt\n");
writeb(0x00,
- devpriv->mite->daq_io_addr +
- Master_DMA_And_Interrupt_Control);
+ devpriv->mite->daq_io_addr +
+ Master_DMA_And_Interrupt_Control);
goto out;
}
AuxData =
- readl(devpriv->mite->daq_io_addr +
- Group_1_FIFO);
+ readl(devpriv->mite->daq_io_addr +
+ Group_1_FIFO);
data1 = AuxData & 0xffff;
data2 = (AuxData & 0xffff0000) >> 16;
comedi_buf_put(async, data1);
comedi_buf_put(async, data2);
/* DPRINTK("read:%d, %d\n",data1,data2); */
flags = readb(devpriv->mite->daq_io_addr +
- Group_1_Flags);
+ 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); */
@@ -583,8 +588,8 @@ static irqreturn_t nidio_interrupt(int irq, void *d)
if (flags & CountExpired) {
DPRINTK("CountExpired\n");
writeb(ClearExpired,
- devpriv->mite->daq_io_addr +
- Group_1_Second_Clear);
+ devpriv->mite->daq_io_addr +
+ Group_1_Second_Clear);
async->events |= COMEDI_CB_EOA;
writeb(0x00, devpriv->mite->daq_io_addr + OpMode);
@@ -592,21 +597,21 @@ static irqreturn_t nidio_interrupt(int irq, void *d)
} else if (flags & Waited) {
DPRINTK("Waited\n");
writeb(ClearWaited,
- devpriv->mite->daq_io_addr +
- Group_1_First_Clear);
+ devpriv->mite->daq_io_addr +
+ Group_1_First_Clear);
async->events |= COMEDI_CB_EOA | COMEDI_CB_ERROR;
break;
} else if (flags & PrimaryTC) {
DPRINTK("PrimaryTC\n");
writeb(ClearPrimaryTC,
- devpriv->mite->daq_io_addr +
- Group_1_First_Clear);
+ devpriv->mite->daq_io_addr +
+ Group_1_First_Clear);
async->events |= COMEDI_CB_EOA;
} else if (flags & SecondaryTC) {
DPRINTK("SecondaryTC\n");
writeb(ClearSecondaryTC,
- devpriv->mite->daq_io_addr +
- Group_1_First_Clear);
+ devpriv->mite->daq_io_addr +
+ Group_1_First_Clear);
async->events |= COMEDI_CB_EOA;
}
#if 0
@@ -614,26 +619,26 @@ static irqreturn_t nidio_interrupt(int irq, void *d)
printk("ni_pcidio: unknown interrupt\n");
async->events |= COMEDI_CB_ERROR | COMEDI_CB_EOA;
writeb(0x00,
- devpriv->mite->daq_io_addr +
- Master_DMA_And_Interrupt_Control);
+ devpriv->mite->daq_io_addr +
+ Master_DMA_And_Interrupt_Control);
}
#endif
flags = readb(devpriv->mite->daq_io_addr + Group_1_Flags);
status = readb(devpriv->mite->daq_io_addr +
- Interrupt_And_Window_Status);
+ 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); */
}
- out:
+out:
ni_pcidio_event(dev, s);
#if 0
if (!tag) {
writeb(0x03,
- devpriv->mite->daq_io_addr +
- Master_DMA_And_Interrupt_Control);
+ devpriv->mite->daq_io_addr +
+ Master_DMA_And_Interrupt_Control);
}
#endif
return IRQ_HANDLED;
@@ -644,6 +649,7 @@ static const char *const flags_strings[] = {
"TransferReady", "CountExpired", "2", "3",
"4", "Waited", "PrimaryTC", "SecondaryTC",
};
+
static void ni_pcidio_print_flags(unsigned int flags)
{
int i;
@@ -656,10 +662,12 @@ static void ni_pcidio_print_flags(unsigned int flags)
}
printk("\n");
}
+
static char *status_strings[] = {
"DataLeft1", "Reserved1", "Req1", "StopTrig1",
"DataLeft2", "Reserved2", "Req2", "StopTrig2",
};
+
static void ni_pcidio_print_status(unsigned int flags)
{
int i;
@@ -675,7 +683,7 @@ static void ni_pcidio_print_status(unsigned int flags)
#endif
#ifdef unused
-static void debug_int(struct comedi_device * dev)
+static void debug_int(struct comedi_device *dev)
{
int a, b;
static int n_int = 0;
@@ -704,8 +712,9 @@ static void debug_int(struct comedi_device * dev)
}
#endif
-static int ni_pcidio_insn_config(struct comedi_device * dev, struct comedi_subdevice * s,
- struct comedi_insn * insn, unsigned int * data)
+static int ni_pcidio_insn_config(struct comedi_device *dev,
+ struct comedi_subdevice *s,
+ struct comedi_insn *insn, unsigned int *data)
{
if (insn->n != 1)
return -EINVAL;
@@ -718,9 +727,9 @@ static int ni_pcidio_insn_config(struct comedi_device * dev, struct comedi_subde
break;
case INSN_CONFIG_DIO_QUERY:
data[1] =
- (s->io_bits & (1 << CR_CHAN(insn->
- chanspec))) ? COMEDI_OUTPUT :
- COMEDI_INPUT;
+ (s->
+ io_bits & (1 << CR_CHAN(insn->chanspec))) ? COMEDI_OUTPUT :
+ COMEDI_INPUT;
return insn->n;
break;
default:
@@ -731,8 +740,9 @@ static int ni_pcidio_insn_config(struct comedi_device * dev, struct comedi_subde
return 1;
}
-static int ni_pcidio_insn_bits(struct comedi_device * dev, struct comedi_subdevice * s,
- struct comedi_insn * insn, unsigned int * data)
+static int ni_pcidio_insn_bits(struct comedi_device *dev,
+ struct comedi_subdevice *s,
+ struct comedi_insn *insn, unsigned int *data)
{
if (insn->n != 2)
return -EINVAL;
@@ -746,8 +756,8 @@ static int ni_pcidio_insn_bits(struct comedi_device * dev, struct comedi_subdevi
return 2;
}
-static int ni_pcidio_cmdtest(struct comedi_device * dev, struct comedi_subdevice * s,
- struct comedi_cmd * cmd)
+static int ni_pcidio_cmdtest(struct comedi_device *dev,
+ struct comedi_subdevice *s, struct comedi_cmd *cmd)
{
int err = 0;
int tmp;
@@ -788,7 +798,7 @@ static int ni_pcidio_cmdtest(struct comedi_device * dev, struct comedi_subdevice
if (cmd->start_src != TRIG_NOW && cmd->start_src != TRIG_INT)
err++;
if (cmd->scan_begin_src != TRIG_TIMER &&
- cmd->scan_begin_src != TRIG_EXT)
+ cmd->scan_begin_src != TRIG_EXT)
err++;
if (err)
@@ -844,7 +854,7 @@ static int ni_pcidio_cmdtest(struct comedi_device * dev, struct comedi_subdevice
if (cmd->scan_begin_src == TRIG_TIMER) {
tmp = cmd->scan_begin_arg;
ni_pcidio_ns_to_timer(&cmd->scan_begin_arg,
- cmd->flags & TRIG_ROUND_MASK);
+ cmd->flags & TRIG_ROUND_MASK);
if (tmp != cmd->scan_begin_arg)
err++;
}
@@ -878,7 +888,7 @@ static int ni_pcidio_ns_to_timer(int *nanosec, int round_mode)
return divider;
}
-static int ni_pcidio_cmd(struct comedi_device * dev, struct comedi_subdevice * s)
+static int ni_pcidio_cmd(struct comedi_device *dev, struct comedi_subdevice *s)
{
struct comedi_cmd *cmd = &s->async->cmd;
@@ -891,11 +901,11 @@ static int ni_pcidio_cmd(struct comedi_device * dev, struct comedi_subdevice * s
/* set transfer width a 32 bits */
writeb(TransferWidth(0) | TransferLength(0),
- devpriv->mite->daq_io_addr + Transfer_Size_Control);
+ devpriv->mite->daq_io_addr + Transfer_Size_Control);
} else {
writeb(0x03, devpriv->mite->daq_io_addr + Data_Path);
writeb(TransferWidth(3) | TransferLength(0),
- devpriv->mite->daq_io_addr + Transfer_Size_Control);
+ devpriv->mite->daq_io_addr + Transfer_Size_Control);
}
/* protocol configuration */
@@ -909,8 +919,8 @@ static int ni_pcidio_cmd(struct comedi_device * dev, struct comedi_subdevice * s
writeb(3, devpriv->mite->daq_io_addr + LinePolarities);
writeb(0xc0, devpriv->mite->daq_io_addr + AckSer);
writel(ni_pcidio_ns_to_timer(&cmd->scan_begin_arg,
- TRIG_ROUND_NEAREST),
- devpriv->mite->daq_io_addr + StartDelay);
+ TRIG_ROUND_NEAREST),
+ devpriv->mite->daq_io_addr + StartDelay);
writeb(1, devpriv->mite->daq_io_addr + ReqDelay);
writeb(1, devpriv->mite->daq_io_addr + ReqNotDelay);
writeb(1, devpriv->mite->daq_io_addr + AckDelay);
@@ -942,14 +952,14 @@ static int ni_pcidio_cmd(struct comedi_device * dev, struct comedi_subdevice * s
if (cmd->stop_src == TRIG_COUNT) {
writel(cmd->stop_arg,
- devpriv->mite->daq_io_addr + Transfer_Count);
+ devpriv->mite->daq_io_addr + Transfer_Count);
} else {
/* XXX */
}
#ifdef USE_DMA
writeb(ClearPrimaryTC | ClearSecondaryTC,
- devpriv->mite->daq_io_addr + Group_1_First_Clear);
+ devpriv->mite->daq_io_addr + Group_1_First_Clear);
{
int retval = setup_mite_dma(dev, s);
@@ -967,7 +977,7 @@ static int ni_pcidio_cmd(struct comedi_device * dev, struct comedi_subdevice * s
writeb(IntEn, devpriv->mite->daq_io_addr + Interrupt_Control);
writeb(0x03,
- devpriv->mite->daq_io_addr + Master_DMA_And_Interrupt_Control);
+ devpriv->mite->daq_io_addr + Master_DMA_And_Interrupt_Control);
if (cmd->stop_src == TRIG_NONE) {
devpriv->OpModeBits = DataLatching(0) | RunMode(7);
@@ -977,7 +987,7 @@ static int ni_pcidio_cmd(struct comedi_device * dev, struct comedi_subdevice * s
if (cmd->start_src == TRIG_NOW) {
/* start */
writeb(devpriv->OpModeBits,
- devpriv->mite->daq_io_addr + OpMode);
+ devpriv->mite->daq_io_addr + OpMode);
s->async->inttrig = NULL;
} else {
/* TRIG_INT */
@@ -988,7 +998,7 @@ static int ni_pcidio_cmd(struct comedi_device * dev, struct comedi_subdevice * s
return 0;
}
-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)
{
int retval;
@@ -1004,8 +1014,8 @@ static int setup_mite_dma(struct comedi_device * dev, struct comedi_subdevice *
return 0;
}
-static int ni_pcidio_inttrig(struct comedi_device * dev, struct comedi_subdevice * s,
- unsigned int trignum)
+static int ni_pcidio_inttrig(struct comedi_device *dev,
+ struct comedi_subdevice *s, unsigned int trignum)
{
if (trignum != 0)
return -EINVAL;
@@ -1016,17 +1026,18 @@ static int ni_pcidio_inttrig(struct comedi_device * dev, struct comedi_subdevice
return 1;
}
-static int ni_pcidio_cancel(struct comedi_device * dev, struct comedi_subdevice * s)
+static int ni_pcidio_cancel(struct comedi_device *dev,
+ struct comedi_subdevice *s)
{
writeb(0x00,
- devpriv->mite->daq_io_addr + Master_DMA_And_Interrupt_Control);
+ devpriv->mite->daq_io_addr + Master_DMA_And_Interrupt_Control);
ni_pcidio_release_di_mite_channel(dev);
return 0;
}
-static int ni_pcidio_change(struct comedi_device * dev, struct comedi_subdevice * s,
- unsigned long new_size)
+static int ni_pcidio_change(struct comedi_device *dev,
+ struct comedi_subdevice *s, unsigned long new_size)
{
int ret;
@@ -1039,50 +1050,53 @@ static int ni_pcidio_change(struct comedi_device * dev, struct comedi_subdevice
return 0;
}
-static int pci_6534_load_fpga(struct comedi_device * dev, int fpga_index, u8 * data,
- int data_len)
+static int pci_6534_load_fpga(struct comedi_device *dev, int fpga_index,
+ u8 * data, int data_len)
{
static const int timeout = 1000;
int i, j;
writew(0x80 | fpga_index,
- devpriv->mite->daq_io_addr + Firmware_Control_Register);
+ devpriv->mite->daq_io_addr + Firmware_Control_Register);
writew(0xc0 | fpga_index,
- devpriv->mite->daq_io_addr + Firmware_Control_Register);
+ devpriv->mite->daq_io_addr + Firmware_Control_Register);
for (i = 0;
- (readw(devpriv->mite->daq_io_addr +
- Firmware_Status_Register) & 0x2) == 0
- && i < timeout; ++i) {
+ (readw(devpriv->mite->daq_io_addr +
+ Firmware_Status_Register) & 0x2) == 0 && i < timeout; ++i) {
udelay(1);
}
if (i == timeout) {
- printk("ni_pcidio: failed to load fpga %i, waiting for status 0x2\n", fpga_index);
+ printk
+ ("ni_pcidio: failed to load fpga %i, waiting for status 0x2\n",
+ fpga_index);
return -EIO;
}
writew(0x80 | fpga_index,
- devpriv->mite->daq_io_addr + Firmware_Control_Register);
+ devpriv->mite->daq_io_addr + Firmware_Control_Register);
for (i = 0;
- readw(devpriv->mite->daq_io_addr + Firmware_Status_Register) !=
- 0x3 && i < timeout; ++i) {
+ readw(devpriv->mite->daq_io_addr + Firmware_Status_Register) !=
+ 0x3 && i < timeout; ++i) {
udelay(1);
}
if (i == timeout) {
- printk("ni_pcidio: failed to load fpga %i, waiting for status 0x3\n", fpga_index);
+ printk
+ ("ni_pcidio: failed to load fpga %i, waiting for status 0x3\n",
+ fpga_index);
return -EIO;
}
for (j = 0; j + 1 < data_len;) {
unsigned int value = data[j++];
value |= data[j++] << 8;
writew(value,
- devpriv->mite->daq_io_addr + Firmware_Data_Register);
+ devpriv->mite->daq_io_addr + Firmware_Data_Register);
for (i = 0;
- (readw(devpriv->mite->daq_io_addr +
- Firmware_Status_Register) & 0x2) == 0
- && i < timeout; ++i) {
+ (readw(devpriv->mite->daq_io_addr +
+ Firmware_Status_Register) & 0x2) == 0
+ && i < timeout; ++i) {
udelay(1);
}
if (i == timeout) {
printk("ni_pcidio: failed to load word into fpga %i\n",
- fpga_index);
+ fpga_index);
return -EIO;
}
if (need_resched())
@@ -1092,12 +1106,12 @@ static int pci_6534_load_fpga(struct comedi_device * dev, int fpga_index, u8 * d
return 0;
}
-static int pci_6534_reset_fpga(struct comedi_device * dev, int fpga_index)
+static int pci_6534_reset_fpga(struct comedi_device *dev, int fpga_index)
{
return pci_6534_load_fpga(dev, fpga_index, NULL, 0);
}
-static int pci_6534_reset_fpgas(struct comedi_device * dev)
+static int pci_6534_reset_fpgas(struct comedi_device *dev)
{
int ret;
int i;
@@ -1111,7 +1125,7 @@ static int pci_6534_reset_fpgas(struct comedi_device * dev)
return ret;
}
-static void pci_6534_init_main_fpga(struct comedi_device * dev)
+static void pci_6534_init_main_fpga(struct comedi_device *dev)
{
writel(0, devpriv->mite->daq_io_addr + FPGA_Control1_Register);
writel(0, devpriv->mite->daq_io_addr + FPGA_Control2_Register);
@@ -1121,7 +1135,7 @@ static void pci_6534_init_main_fpga(struct comedi_device * dev)
writel(0, devpriv->mite->daq_io_addr + FPGA_SCBMS_Counter_Register);
}
-static int pci_6534_upload_firmware(struct comedi_device * dev, int options[])
+static int pci_6534_upload_firmware(struct comedi_device *dev, int options[])
{
int ret;
void *main_fpga_data, *scarab_a_data, *scarab_b_data;
@@ -1151,7 +1165,7 @@ static int pci_6534_upload_firmware(struct comedi_device * dev, int options[])
return 0;
}
-static int nidio_attach(struct comedi_device * dev, struct comedi_devconfig * it)
+static int nidio_attach(struct comedi_device *dev, struct comedi_devconfig *it)
{
struct comedi_subdevice *s;
int i;
@@ -1198,22 +1212,23 @@ static int nidio_attach(struct comedi_device * dev, struct comedi_devconfig * it
if (!this_board->is_diodaq) {
for (i = 0; i < this_board->n_8255; i++) {
subdev_8255_init(dev, dev->subdevices + i,
- nidio96_8255_cb,
- (unsigned long)(devpriv->mite->daq_io_addr +
- NIDIO_8255_BASE(i)));
+ nidio96_8255_cb,
+ (unsigned long)(devpriv->mite->
+ daq_io_addr +
+ NIDIO_8255_BASE(i)));
}
} else {
printk(" rev=%d",
- readb(devpriv->mite->daq_io_addr + Chip_Version));
+ readb(devpriv->mite->daq_io_addr + Chip_Version));
s = dev->subdevices + 0;
dev->read_subdev = s;
s->type = COMEDI_SUBD_DIO;
s->subdev_flags =
- SDF_READABLE | SDF_WRITABLE | SDF_LSAMPL | SDF_PACKED |
- SDF_CMD_READ;
+ SDF_READABLE | SDF_WRITABLE | SDF_LSAMPL | SDF_PACKED |
+ SDF_CMD_READ;
s->n_chan = 32;
s->range_table = &range_digital;
s->maxdata = 1;
@@ -1232,8 +1247,8 @@ static int nidio_attach(struct comedi_device * dev, struct comedi_devconfig * it
/* disable interrupts on board */
writeb(0x00,
- devpriv->mite->daq_io_addr +
- Master_DMA_And_Interrupt_Control);
+ devpriv->mite->daq_io_addr +
+ Master_DMA_And_Interrupt_Control);
ret = request_irq(irq, nidio_interrupt, IRQF_SHARED,
"ni_pcidio", dev);
@@ -1248,7 +1263,7 @@ static int nidio_attach(struct comedi_device * dev, struct comedi_devconfig * it
return 0;
}
-static int nidio_detach(struct comedi_device * dev)
+static int nidio_detach(struct comedi_device *dev)
{
int i;
@@ -1272,7 +1287,7 @@ static int nidio_detach(struct comedi_device * dev)
return 0;
}
-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)
{
struct mite_struct *mite;
int i;
@@ -1282,7 +1297,7 @@ static int nidio_find_device(struct comedi_device * dev, int bus, int slot)
continue;
if (bus || slot) {
if (bus != mite->pcidev->bus->number ||
- slot != PCI_SLOT(mite->pcidev->devfn))
+ slot != PCI_SLOT(mite->pcidev->devfn))
continue;
}
for (i = 0; i < n_nidio_boards; i++) {
diff --git a/drivers/staging/comedi/drivers/ni_pcimio.c b/drivers/staging/comedi/drivers/ni_pcimio.c
index 1d04b75dec22..0dc639212ade 100644
--- a/drivers/staging/comedi/drivers/ni_pcimio.c
+++ b/drivers/staging/comedi/drivers/ni_pcimio.c
@@ -130,58 +130,59 @@ Bugs:
/* The following two tables must be in the same order */
static DEFINE_PCI_DEVICE_TABLE(ni_pci_table) = {
- {PCI_VENDOR_ID_NATINST, 0x0162, PCI_ANY_ID, PCI_ANY_ID, 0, 0, 0},
- {PCI_VENDOR_ID_NATINST, 0x1170, PCI_ANY_ID, PCI_ANY_ID, 0, 0, 0},
- {PCI_VENDOR_ID_NATINST, 0x1180, PCI_ANY_ID, PCI_ANY_ID, 0, 0, 0},
- {PCI_VENDOR_ID_NATINST, 0x1190, PCI_ANY_ID, PCI_ANY_ID, 0, 0, 0},
- {PCI_VENDOR_ID_NATINST, 0x11b0, PCI_ANY_ID, PCI_ANY_ID, 0, 0, 0},
- {PCI_VENDOR_ID_NATINST, 0x11c0, PCI_ANY_ID, PCI_ANY_ID, 0, 0, 0},
- {PCI_VENDOR_ID_NATINST, 0x11d0, PCI_ANY_ID, PCI_ANY_ID, 0, 0, 0},
- {PCI_VENDOR_ID_NATINST, 0x1270, PCI_ANY_ID, PCI_ANY_ID, 0, 0, 0},
- {PCI_VENDOR_ID_NATINST, 0x1330, PCI_ANY_ID, PCI_ANY_ID, 0, 0, 0},
- {PCI_VENDOR_ID_NATINST, 0x1340, PCI_ANY_ID, PCI_ANY_ID, 0, 0, 0},
- {PCI_VENDOR_ID_NATINST, 0x1350, PCI_ANY_ID, PCI_ANY_ID, 0, 0, 0},
- {PCI_VENDOR_ID_NATINST, 0x14e0, PCI_ANY_ID, PCI_ANY_ID, 0, 0, 0},
- {PCI_VENDOR_ID_NATINST, 0x14f0, PCI_ANY_ID, PCI_ANY_ID, 0, 0, 0},
- {PCI_VENDOR_ID_NATINST, 0x1580, PCI_ANY_ID, PCI_ANY_ID, 0, 0, 0},
- {PCI_VENDOR_ID_NATINST, 0x15b0, PCI_ANY_ID, PCI_ANY_ID, 0, 0, 0},
- {PCI_VENDOR_ID_NATINST, 0x1880, PCI_ANY_ID, PCI_ANY_ID, 0, 0, 0},
- {PCI_VENDOR_ID_NATINST, 0x1870, PCI_ANY_ID, PCI_ANY_ID, 0, 0, 0},
- {PCI_VENDOR_ID_NATINST, 0x18b0, PCI_ANY_ID, PCI_ANY_ID, 0, 0, 0},
- {PCI_VENDOR_ID_NATINST, 0x18c0, PCI_ANY_ID, PCI_ANY_ID, 0, 0, 0},
- {PCI_VENDOR_ID_NATINST, 0x2410, PCI_ANY_ID, PCI_ANY_ID, 0, 0, 0},
- {PCI_VENDOR_ID_NATINST, 0x2420, PCI_ANY_ID, PCI_ANY_ID, 0, 0, 0},
- {PCI_VENDOR_ID_NATINST, 0x2430, PCI_ANY_ID, PCI_ANY_ID, 0, 0, 0},
- {PCI_VENDOR_ID_NATINST, 0x2890, PCI_ANY_ID, PCI_ANY_ID, 0, 0, 0},
- {PCI_VENDOR_ID_NATINST, 0x28c0, PCI_ANY_ID, PCI_ANY_ID, 0, 0, 0},
- {PCI_VENDOR_ID_NATINST, 0x2a60, PCI_ANY_ID, PCI_ANY_ID, 0, 0, 0},
- {PCI_VENDOR_ID_NATINST, 0x2a70, PCI_ANY_ID, PCI_ANY_ID, 0, 0, 0},
- {PCI_VENDOR_ID_NATINST, 0x2a80, PCI_ANY_ID, PCI_ANY_ID, 0, 0, 0},
- {PCI_VENDOR_ID_NATINST, 0x2ab0, PCI_ANY_ID, PCI_ANY_ID, 0, 0, 0},
- {PCI_VENDOR_ID_NATINST, 0x2b80, PCI_ANY_ID, PCI_ANY_ID, 0, 0, 0},
- {PCI_VENDOR_ID_NATINST, 0x2b90, PCI_ANY_ID, PCI_ANY_ID, 0, 0, 0},
- {PCI_VENDOR_ID_NATINST, 0x2c80, PCI_ANY_ID, PCI_ANY_ID, 0, 0, 0},
- {PCI_VENDOR_ID_NATINST, 0x2ca0, PCI_ANY_ID, PCI_ANY_ID, 0, 0, 0},
- {PCI_VENDOR_ID_NATINST, 0x70aa, PCI_ANY_ID, PCI_ANY_ID, 0, 0, 0},
- {PCI_VENDOR_ID_NATINST, 0x70ab, PCI_ANY_ID, PCI_ANY_ID, 0, 0, 0},
- {PCI_VENDOR_ID_NATINST, 0x70ac, PCI_ANY_ID, PCI_ANY_ID, 0, 0, 0},
- {PCI_VENDOR_ID_NATINST, 0x70af, PCI_ANY_ID, PCI_ANY_ID, 0, 0, 0},
- {PCI_VENDOR_ID_NATINST, 0x70b0, PCI_ANY_ID, PCI_ANY_ID, 0, 0, 0},
- {PCI_VENDOR_ID_NATINST, 0x70b4, PCI_ANY_ID, PCI_ANY_ID, 0, 0, 0},
- {PCI_VENDOR_ID_NATINST, 0x70b6, PCI_ANY_ID, PCI_ANY_ID, 0, 0, 0},
- {PCI_VENDOR_ID_NATINST, 0x70b7, PCI_ANY_ID, PCI_ANY_ID, 0, 0, 0},
- {PCI_VENDOR_ID_NATINST, 0x70b8, PCI_ANY_ID, PCI_ANY_ID, 0, 0, 0},
- {PCI_VENDOR_ID_NATINST, 0x70bc, PCI_ANY_ID, PCI_ANY_ID, 0, 0, 0},
- {PCI_VENDOR_ID_NATINST, 0x70bd, PCI_ANY_ID, PCI_ANY_ID, 0, 0, 0},
- {PCI_VENDOR_ID_NATINST, 0x70bf, PCI_ANY_ID, PCI_ANY_ID, 0, 0, 0},
- {PCI_VENDOR_ID_NATINST, 0x70c0, PCI_ANY_ID, PCI_ANY_ID, 0, 0, 0},
- {PCI_VENDOR_ID_NATINST, 0x70f2, PCI_ANY_ID, PCI_ANY_ID, 0, 0, 0},
- {PCI_VENDOR_ID_NATINST, 0x710d, PCI_ANY_ID, PCI_ANY_ID, 0, 0, 0},
- {PCI_VENDOR_ID_NATINST, 0x716c, PCI_ANY_ID, PCI_ANY_ID, 0, 0, 0},
- {PCI_VENDOR_ID_NATINST, 0x717f, PCI_ANY_ID, PCI_ANY_ID, 0, 0, 0},
- {PCI_VENDOR_ID_NATINST, 0x71bc, PCI_ANY_ID, PCI_ANY_ID, 0, 0, 0},
- {PCI_VENDOR_ID_NATINST, 0x717d, PCI_ANY_ID, PCI_ANY_ID, 0, 0, 0},
- {0}
+ {
+ PCI_VENDOR_ID_NATINST, 0x0162, PCI_ANY_ID, PCI_ANY_ID, 0, 0, 0}, {
+ PCI_VENDOR_ID_NATINST, 0x1170, PCI_ANY_ID, PCI_ANY_ID, 0, 0, 0}, {
+ PCI_VENDOR_ID_NATINST, 0x1180, PCI_ANY_ID, PCI_ANY_ID, 0, 0, 0}, {
+ PCI_VENDOR_ID_NATINST, 0x1190, PCI_ANY_ID, PCI_ANY_ID, 0, 0, 0}, {
+ PCI_VENDOR_ID_NATINST, 0x11b0, PCI_ANY_ID, PCI_ANY_ID, 0, 0, 0}, {
+ PCI_VENDOR_ID_NATINST, 0x11c0, PCI_ANY_ID, PCI_ANY_ID, 0, 0, 0}, {
+ PCI_VENDOR_ID_NATINST, 0x11d0, PCI_ANY_ID, PCI_ANY_ID, 0, 0, 0}, {
+ PCI_VENDOR_ID_NATINST, 0x1270, PCI_ANY_ID, PCI_ANY_ID, 0, 0, 0}, {
+ PCI_VENDOR_ID_NATINST, 0x1330, PCI_ANY_ID, PCI_ANY_ID, 0, 0, 0}, {
+ PCI_VENDOR_ID_NATINST, 0x1340, PCI_ANY_ID, PCI_ANY_ID, 0, 0, 0}, {
+ PCI_VENDOR_ID_NATINST, 0x1350, PCI_ANY_ID, PCI_ANY_ID, 0, 0, 0}, {
+ PCI_VENDOR_ID_NATINST, 0x14e0, PCI_ANY_ID, PCI_ANY_ID, 0, 0, 0}, {
+ PCI_VENDOR_ID_NATINST, 0x14f0, PCI_ANY_ID, PCI_ANY_ID, 0, 0, 0}, {
+ PCI_VENDOR_ID_NATINST, 0x1580, PCI_ANY_ID, PCI_ANY_ID, 0, 0, 0}, {
+ PCI_VENDOR_ID_NATINST, 0x15b0, PCI_ANY_ID, PCI_ANY_ID, 0, 0, 0}, {
+ PCI_VENDOR_ID_NATINST, 0x1880, PCI_ANY_ID, PCI_ANY_ID, 0, 0, 0}, {
+ PCI_VENDOR_ID_NATINST, 0x1870, PCI_ANY_ID, PCI_ANY_ID, 0, 0, 0}, {
+ PCI_VENDOR_ID_NATINST, 0x18b0, PCI_ANY_ID, PCI_ANY_ID, 0, 0, 0}, {
+ PCI_VENDOR_ID_NATINST, 0x18c0, PCI_ANY_ID, PCI_ANY_ID, 0, 0, 0}, {
+ PCI_VENDOR_ID_NATINST, 0x2410, PCI_ANY_ID, PCI_ANY_ID, 0, 0, 0}, {
+ PCI_VENDOR_ID_NATINST, 0x2420, PCI_ANY_ID, PCI_ANY_ID, 0, 0, 0}, {
+ PCI_VENDOR_ID_NATINST, 0x2430, PCI_ANY_ID, PCI_ANY_ID, 0, 0, 0}, {
+ PCI_VENDOR_ID_NATINST, 0x2890, PCI_ANY_ID, PCI_ANY_ID, 0, 0, 0}, {
+ PCI_VENDOR_ID_NATINST, 0x28c0, PCI_ANY_ID, PCI_ANY_ID, 0, 0, 0}, {
+ PCI_VENDOR_ID_NATINST, 0x2a60, PCI_ANY_ID, PCI_ANY_ID, 0, 0, 0}, {
+ PCI_VENDOR_ID_NATINST, 0x2a70, PCI_ANY_ID, PCI_ANY_ID, 0, 0, 0}, {
+ PCI_VENDOR_ID_NATINST, 0x2a80, PCI_ANY_ID, PCI_ANY_ID, 0, 0, 0}, {
+ PCI_VENDOR_ID_NATINST, 0x2ab0, PCI_ANY_ID, PCI_ANY_ID, 0, 0, 0}, {
+ PCI_VENDOR_ID_NATINST, 0x2b80, PCI_ANY_ID, PCI_ANY_ID, 0, 0, 0}, {
+ PCI_VENDOR_ID_NATINST, 0x2b90, PCI_ANY_ID, PCI_ANY_ID, 0, 0, 0}, {
+ PCI_VENDOR_ID_NATINST, 0x2c80, PCI_ANY_ID, PCI_ANY_ID, 0, 0, 0}, {
+ PCI_VENDOR_ID_NATINST, 0x2ca0, PCI_ANY_ID, PCI_ANY_ID, 0, 0, 0}, {
+ PCI_VENDOR_ID_NATINST, 0x70aa, PCI_ANY_ID, PCI_ANY_ID, 0, 0, 0}, {
+ PCI_VENDOR_ID_NATINST, 0x70ab, PCI_ANY_ID, PCI_ANY_ID, 0, 0, 0}, {
+ PCI_VENDOR_ID_NATINST, 0x70ac, PCI_ANY_ID, PCI_ANY_ID, 0, 0, 0}, {
+ PCI_VENDOR_ID_NATINST, 0x70af, PCI_ANY_ID, PCI_ANY_ID, 0, 0, 0}, {
+ PCI_VENDOR_ID_NATINST, 0x70b0, PCI_ANY_ID, PCI_ANY_ID, 0, 0, 0}, {
+ PCI_VENDOR_ID_NATINST, 0x70b4, PCI_ANY_ID, PCI_ANY_ID, 0, 0, 0}, {
+ PCI_VENDOR_ID_NATINST, 0x70b6, PCI_ANY_ID, PCI_ANY_ID, 0, 0, 0}, {
+ PCI_VENDOR_ID_NATINST, 0x70b7, PCI_ANY_ID, PCI_ANY_ID, 0, 0, 0}, {
+ PCI_VENDOR_ID_NATINST, 0x70b8, PCI_ANY_ID, PCI_ANY_ID, 0, 0, 0}, {
+ PCI_VENDOR_ID_NATINST, 0x70bc, PCI_ANY_ID, PCI_ANY_ID, 0, 0, 0}, {
+ PCI_VENDOR_ID_NATINST, 0x70bd, PCI_ANY_ID, PCI_ANY_ID, 0, 0, 0}, {
+ PCI_VENDOR_ID_NATINST, 0x70bf, PCI_ANY_ID, PCI_ANY_ID, 0, 0, 0}, {
+ PCI_VENDOR_ID_NATINST, 0x70c0, PCI_ANY_ID, PCI_ANY_ID, 0, 0, 0}, {
+ PCI_VENDOR_ID_NATINST, 0x70f2, PCI_ANY_ID, PCI_ANY_ID, 0, 0, 0}, {
+ PCI_VENDOR_ID_NATINST, 0x710d, PCI_ANY_ID, PCI_ANY_ID, 0, 0, 0}, {
+ PCI_VENDOR_ID_NATINST, 0x716c, PCI_ANY_ID, PCI_ANY_ID, 0, 0, 0}, {
+ PCI_VENDOR_ID_NATINST, 0x717f, PCI_ANY_ID, PCI_ANY_ID, 0, 0, 0}, {
+ PCI_VENDOR_ID_NATINST, 0x71bc, PCI_ANY_ID, PCI_ANY_ID, 0, 0, 0}, {
+ PCI_VENDOR_ID_NATINST, 0x717d, PCI_ANY_ID, PCI_ANY_ID, 0, 0, 0}, {
+ 0}
};
MODULE_DEVICE_TABLE(pci, ni_pci_table);
@@ -194,1020 +195,1023 @@ MODULE_DEVICE_TABLE(pci, ni_pci_table);
can not act as it's own OFFSET or REFERENCE.
*/
static const struct comedi_lrange range_ni_M_628x_ao = { 8, {
- RANGE(-10, 10),
- RANGE(-5, 5),
- RANGE(-2, 2),
- RANGE(-1, 1),
- RANGE(-5, 15),
- RANGE(0, 10),
- RANGE(3, 7),
- RANGE(4, 6),
- RANGE_ext(-1, 1)
- }
+ RANGE(-10, 10),
+ RANGE(-5, 5),
+ RANGE(-2, 2),
+ RANGE(-1, 1),
+ RANGE(-5, 15),
+ RANGE(0, 10),
+ RANGE(3, 7),
+ RANGE(4, 6),
+ RANGE_ext(-1, 1)
+ }
};
+
static const struct comedi_lrange range_ni_M_625x_ao = { 3, {
- RANGE(-10, 10),
- RANGE(-5, 5),
- RANGE_ext(-1, 1)
- }
+ RANGE(-10, 10),
+ RANGE(-5, 5),
+ RANGE_ext(-1, 1)
+ }
};
+
static const struct comedi_lrange range_ni_M_622x_ao = { 1, {
- RANGE(-10, 10),
- }
+ RANGE(-10, 10),
+ }
};
static const struct ni_board_struct ni_boards[] = {
{
- .device_id = 0x0162, /* NI also says 0x1620. typo? */
- .name = "pci-mio-16xe-50",
- .n_adchan = 16,
- .adbits = 16,
- .ai_fifo_depth = 2048,
- .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,
- .num_p0_dio_channels = 8,
- .caldac = {dac8800, dac8043},
- .has_8255 = 0,
- },
+ .device_id = 0x0162, /* NI also says 0x1620. typo? */
+ .name = "pci-mio-16xe-50",
+ .n_adchan = 16,
+ .adbits = 16,
+ .ai_fifo_depth = 2048,
+ .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,
+ .num_p0_dio_channels = 8,
+ .caldac = {dac8800, dac8043},
+ .has_8255 = 0,
+ },
{
- .device_id = 0x1170,
- .name = "pci-mio-16xe-10", /* aka pci-6030E */
- .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 = 10000,
- .num_p0_dio_channels = 8,
- .caldac = {dac8800, dac8043, ad8522},
- .has_8255 = 0,
- },
+ .device_id = 0x1170,
+ .name = "pci-mio-16xe-10", /* aka pci-6030E */
+ .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 = 10000,
+ .num_p0_dio_channels = 8,
+ .caldac = {dac8800, dac8043, ad8522},
+ .has_8255 = 0,
+ },
{
- .device_id = 0x28c0,
- .name = "pci-6014",
- .n_adchan = 16,
- .adbits = 16,
- .ai_fifo_depth = 512,
- .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 = 100000,
- .num_p0_dio_channels = 8,
- .caldac = {ad8804_debug},
- .has_8255 = 0,
- },
+ .device_id = 0x28c0,
+ .name = "pci-6014",
+ .n_adchan = 16,
+ .adbits = 16,
+ .ai_fifo_depth = 512,
+ .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 = 100000,
+ .num_p0_dio_channels = 8,
+ .caldac = {ad8804_debug},
+ .has_8255 = 0,
+ },
{
- .device_id = 0x11d0,
- .name = "pxi-6030e",
- .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 = 10000,
- .num_p0_dio_channels = 8,
- .caldac = {dac8800, dac8043, ad8522},
- .has_8255 = 0,
- },
+ .device_id = 0x11d0,
+ .name = "pxi-6030e",
+ .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 = 10000,
+ .num_p0_dio_channels = 8,
+ .caldac = {dac8800, dac8043, ad8522},
+ .has_8255 = 0,
+ },
{
- .device_id = 0x1180,
- .name = "pci-mio-16e-1", /* aka pci-6070e */
- .n_adchan = 16,
- .adbits = 12,
- .ai_fifo_depth = 512,
- .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,
- .num_p0_dio_channels = 8,
- .caldac = {mb88341},
- .has_8255 = 0,
- },
+ .device_id = 0x1180,
+ .name = "pci-mio-16e-1", /* aka pci-6070e */
+ .n_adchan = 16,
+ .adbits = 12,
+ .ai_fifo_depth = 512,
+ .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,
+ .num_p0_dio_channels = 8,
+ .caldac = {mb88341},
+ .has_8255 = 0,
+ },
{
- .device_id = 0x1190,
- .name = "pci-mio-16e-4", /* aka pci-6040e */
- .n_adchan = 16,
- .adbits = 12,
- .ai_fifo_depth = 512,
- .alwaysdither = 0,
- .gainlkup = ai_gain_16,
- /* .Note = there have been reported problems with full speed
- * on this board */
- .ai_speed = 2000,
- .n_aochan = 2,
- .aobits = 12,
- .ao_fifo_depth = 512,
- .ao_range_table = &range_ni_E_ao_ext,
- .ao_unipolar = 1,
- .ao_speed = 1000,
- .num_p0_dio_channels = 8,
- .caldac = {ad8804_debug}, /* doc says mb88341 */
- .has_8255 = 0,
- },
+ .device_id = 0x1190,
+ .name = "pci-mio-16e-4", /* aka pci-6040e */
+ .n_adchan = 16,
+ .adbits = 12,
+ .ai_fifo_depth = 512,
+ .alwaysdither = 0,
+ .gainlkup = ai_gain_16,
+ /* .Note = there have been reported problems with full speed
+ * on this board */
+ .ai_speed = 2000,
+ .n_aochan = 2,
+ .aobits = 12,
+ .ao_fifo_depth = 512,
+ .ao_range_table = &range_ni_E_ao_ext,
+ .ao_unipolar = 1,
+ .ao_speed = 1000,
+ .num_p0_dio_channels = 8,
+ .caldac = {ad8804_debug}, /* doc says mb88341 */
+ .has_8255 = 0,
+ },
{
- .device_id = 0x11c0,
- .name = "pxi-6040e",
- .n_adchan = 16,
- .adbits = 12,
- .ai_fifo_depth = 512,
- .alwaysdither = 0,
- .gainlkup = ai_gain_16,
- .ai_speed = 2000,
- .n_aochan = 2,
- .aobits = 12,
- .ao_fifo_depth = 512,
- .ao_range_table = &range_ni_E_ao_ext,
- .ao_unipolar = 1,
- .ao_speed = 1000,
- .num_p0_dio_channels = 8,
- .caldac = {mb88341},
- .has_8255 = 0,
- },
+ .device_id = 0x11c0,
+ .name = "pxi-6040e",
+ .n_adchan = 16,
+ .adbits = 12,
+ .ai_fifo_depth = 512,
+ .alwaysdither = 0,
+ .gainlkup = ai_gain_16,
+ .ai_speed = 2000,
+ .n_aochan = 2,
+ .aobits = 12,
+ .ao_fifo_depth = 512,
+ .ao_range_table = &range_ni_E_ao_ext,
+ .ao_unipolar = 1,
+ .ao_speed = 1000,
+ .num_p0_dio_channels = 8,
+ .caldac = {mb88341},
+ .has_8255 = 0,
+ },
{
- .device_id = 0x1330,
- .name = "pci-6031e",
- .n_adchan = 64,
- .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 = 10000,
- .num_p0_dio_channels = 8,
- .caldac = {dac8800, dac8043, ad8522},
- .has_8255 = 0,
- },
+ .device_id = 0x1330,
+ .name = "pci-6031e",
+ .n_adchan = 64,
+ .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 = 10000,
+ .num_p0_dio_channels = 8,
+ .caldac = {dac8800, dac8043, ad8522},
+ .has_8255 = 0,
+ },
{
- .device_id = 0x1270,
- .name = "pci-6032e",
- .n_adchan = 16,
- .adbits = 16,
- .ai_fifo_depth = 512,
- .alwaysdither = 1,
- .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,
- },
+ .device_id = 0x1270,
+ .name = "pci-6032e",
+ .n_adchan = 16,
+ .adbits = 16,
+ .ai_fifo_depth = 512,
+ .alwaysdither = 1,
+ .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,
+ },
{
- .device_id = 0x1340,
- .name = "pci-6033e",
- .n_adchan = 64,
- .adbits = 16,
- .ai_fifo_depth = 512,
- .alwaysdither = 1,
- .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,
- },
+ .device_id = 0x1340,
+ .name = "pci-6033e",
+ .n_adchan = 64,
+ .adbits = 16,
+ .ai_fifo_depth = 512,
+ .alwaysdither = 1,
+ .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,
+ },
{
- .device_id = 0x1350,
- .name = "pci-6071e",
- .n_adchan = 64,
- .adbits = 12,
- .ai_fifo_depth = 512,
- .alwaysdither = 1,
- .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,
- .num_p0_dio_channels = 8,
- .caldac = {ad8804_debug},
- .has_8255 = 0,
- },
+ .device_id = 0x1350,
+ .name = "pci-6071e",
+ .n_adchan = 64,
+ .adbits = 12,
+ .ai_fifo_depth = 512,
+ .alwaysdither = 1,
+ .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,
+ .num_p0_dio_channels = 8,
+ .caldac = {ad8804_debug},
+ .has_8255 = 0,
+ },
{
- .device_id = 0x2a60,
- .name = "pci-6023e",
- .n_adchan = 16,
- .adbits = 12,
- .ai_fifo_depth = 512,
- .alwaysdither = 0,
- .gainlkup = ai_gain_4,
- .ai_speed = 5000,
- .n_aochan = 0,
- .aobits = 0,
- .ao_unipolar = 0,
- .num_p0_dio_channels = 8,
- .caldac = {ad8804_debug}, /* manual is wrong */
- .has_8255 = 0,
- },
+ .device_id = 0x2a60,
+ .name = "pci-6023e",
+ .n_adchan = 16,
+ .adbits = 12,
+ .ai_fifo_depth = 512,
+ .alwaysdither = 0,
+ .gainlkup = ai_gain_4,
+ .ai_speed = 5000,
+ .n_aochan = 0,
+ .aobits = 0,
+ .ao_unipolar = 0,
+ .num_p0_dio_channels = 8,
+ .caldac = {ad8804_debug}, /* manual is wrong */
+ .has_8255 = 0,
+ },
{
- .device_id = 0x2a70,
- .name = "pci-6024e",
- .n_adchan = 16,
- .adbits = 12,
- .ai_fifo_depth = 512,
- .alwaysdither = 0,
- .gainlkup = ai_gain_4,
- .ai_speed = 5000,
- .n_aochan = 2,
- .aobits = 12,
- .ao_fifo_depth = 0,
- .ao_range_table = &range_bipolar10,
- .ao_unipolar = 0,
- .ao_speed = 100000,
- .num_p0_dio_channels = 8,
- .caldac = {ad8804_debug}, /* manual is wrong */
- .has_8255 = 0,
- },
+ .device_id = 0x2a70,
+ .name = "pci-6024e",
+ .n_adchan = 16,
+ .adbits = 12,
+ .ai_fifo_depth = 512,
+ .alwaysdither = 0,
+ .gainlkup = ai_gain_4,
+ .ai_speed = 5000,
+ .n_aochan = 2,
+ .aobits = 12,
+ .ao_fifo_depth = 0,
+ .ao_range_table = &range_bipolar10,
+ .ao_unipolar = 0,
+ .ao_speed = 100000,
+ .num_p0_dio_channels = 8,
+ .caldac = {ad8804_debug}, /* manual is wrong */
+ .has_8255 = 0,
+ },
{
- .device_id = 0x2a80,
- .name = "pci-6025e",
- .n_adchan = 16,
- .adbits = 12,
- .ai_fifo_depth = 512,
- .alwaysdither = 0,
- .gainlkup = ai_gain_4,
- .ai_speed = 5000,
- .n_aochan = 2,
- .aobits = 12,
- .ao_fifo_depth = 0,
- .ao_range_table = &range_bipolar10,
- .ao_unipolar = 0,
- .ao_speed = 100000,
- .num_p0_dio_channels = 8,
- .caldac = {ad8804_debug}, /* manual is wrong */
- .has_8255 = 1,
- },
+ .device_id = 0x2a80,
+ .name = "pci-6025e",
+ .n_adchan = 16,
+ .adbits = 12,
+ .ai_fifo_depth = 512,
+ .alwaysdither = 0,
+ .gainlkup = ai_gain_4,
+ .ai_speed = 5000,
+ .n_aochan = 2,
+ .aobits = 12,
+ .ao_fifo_depth = 0,
+ .ao_range_table = &range_bipolar10,
+ .ao_unipolar = 0,
+ .ao_speed = 100000,
+ .num_p0_dio_channels = 8,
+ .caldac = {ad8804_debug}, /* manual is wrong */
+ .has_8255 = 1,
+ },
{
- .device_id = 0x2ab0,
- .name = "pxi-6025e",
- .n_adchan = 16,
- .adbits = 12,
- .ai_fifo_depth = 512,
- .alwaysdither = 0,
- .gainlkup = ai_gain_4,
- .ai_speed = 5000,
- .n_aochan = 2,
- .aobits = 12,
- .ao_fifo_depth = 0,
- .ao_range_table = &range_ni_E_ao_ext,
- .ao_unipolar = 1,
- .ao_speed = 100000,
- .num_p0_dio_channels = 8,
- .caldac = {ad8804_debug}, /* manual is wrong */
- .has_8255 = 1,
- },
+ .device_id = 0x2ab0,
+ .name = "pxi-6025e",
+ .n_adchan = 16,
+ .adbits = 12,
+ .ai_fifo_depth = 512,
+ .alwaysdither = 0,
+ .gainlkup = ai_gain_4,
+ .ai_speed = 5000,
+ .n_aochan = 2,
+ .aobits = 12,
+ .ao_fifo_depth = 0,
+ .ao_range_table = &range_ni_E_ao_ext,
+ .ao_unipolar = 1,
+ .ao_speed = 100000,
+ .num_p0_dio_channels = 8,
+ .caldac = {ad8804_debug}, /* manual is wrong */
+ .has_8255 = 1,
+ },
{
- .device_id = 0x2ca0,
- .name = "pci-6034e",
- .n_adchan = 16,
- .adbits = 16,
- .ai_fifo_depth = 512,
- .alwaysdither = 1,
- .gainlkup = ai_gain_4,
- .ai_speed = 5000,
- .n_aochan = 0,
- .aobits = 0,
- .ao_fifo_depth = 0,
- .ao_unipolar = 0,
- .num_p0_dio_channels = 8,
- .caldac = {ad8804_debug},
- .has_8255 = 0,
- },
+ .device_id = 0x2ca0,
+ .name = "pci-6034e",
+ .n_adchan = 16,
+ .adbits = 16,
+ .ai_fifo_depth = 512,
+ .alwaysdither = 1,
+ .gainlkup = ai_gain_4,
+ .ai_speed = 5000,
+ .n_aochan = 0,
+ .aobits = 0,
+ .ao_fifo_depth = 0,
+ .ao_unipolar = 0,
+ .num_p0_dio_channels = 8,
+ .caldac = {ad8804_debug},
+ .has_8255 = 0,
+ },
{
- .device_id = 0x2c80,
- .name = "pci-6035e",
- .n_adchan = 16,
- .adbits = 16,
- .ai_fifo_depth = 512,
- .alwaysdither = 1,
- .gainlkup = ai_gain_4,
- .ai_speed = 5000,
- .n_aochan = 2,
- .aobits = 12,
- .ao_fifo_depth = 0,
- .ao_range_table = &range_bipolar10,
- .ao_unipolar = 0,
- .ao_speed = 100000,
- .num_p0_dio_channels = 8,
- .caldac = {ad8804_debug},
- .has_8255 = 0,
- },
+ .device_id = 0x2c80,
+ .name = "pci-6035e",
+ .n_adchan = 16,
+ .adbits = 16,
+ .ai_fifo_depth = 512,
+ .alwaysdither = 1,
+ .gainlkup = ai_gain_4,
+ .ai_speed = 5000,
+ .n_aochan = 2,
+ .aobits = 12,
+ .ao_fifo_depth = 0,
+ .ao_range_table = &range_bipolar10,
+ .ao_unipolar = 0,
+ .ao_speed = 100000,
+ .num_p0_dio_channels = 8,
+ .caldac = {ad8804_debug},
+ .has_8255 = 0,
+ },
{
- .device_id = 0x18b0,
- .name = "pci-6052e",
- .n_adchan = 16,
- .adbits = 16,
- .ai_fifo_depth = 512,
- .alwaysdither = 1,
- .gainlkup = ai_gain_16,
- .ai_speed = 3000,
- .n_aochan = 2,
- .aobits = 16,
- .ao_unipolar = 1,
- .ao_fifo_depth = 2048,
- .ao_range_table = &range_ni_E_ao_ext,
- .ao_speed = 3000,
- .num_p0_dio_channels = 8,
- .caldac = {ad8804_debug, ad8804_debug, ad8522}, /* manual is wrong */
- },
+ .device_id = 0x18b0,
+ .name = "pci-6052e",
+ .n_adchan = 16,
+ .adbits = 16,
+ .ai_fifo_depth = 512,
+ .alwaysdither = 1,
+ .gainlkup = ai_gain_16,
+ .ai_speed = 3000,
+ .n_aochan = 2,
+ .aobits = 16,
+ .ao_unipolar = 1,
+ .ao_fifo_depth = 2048,
+ .ao_range_table = &range_ni_E_ao_ext,
+ .ao_speed = 3000,
+ .num_p0_dio_channels = 8,
+ .caldac = {ad8804_debug, ad8804_debug, ad8522}, /* manual is wrong */
+ },
{.device_id = 0x14e0,
- .name = "pci-6110",
- .n_adchan = 4,
- .adbits = 12,
- .ai_fifo_depth = 8192,
- .alwaysdither = 0,
- .gainlkup = ai_gain_611x,
- .ai_speed = 200,
- .n_aochan = 2,
- .aobits = 16,
- .reg_type = ni_reg_611x,
- .ao_range_table = &range_bipolar10,
- .ao_unipolar = 0,
- .ao_fifo_depth = 2048,
- .ao_speed = 250,
- .num_p0_dio_channels = 8,
- .caldac = {ad8804, ad8804},
- },
+ .name = "pci-6110",
+ .n_adchan = 4,
+ .adbits = 12,
+ .ai_fifo_depth = 8192,
+ .alwaysdither = 0,
+ .gainlkup = ai_gain_611x,
+ .ai_speed = 200,
+ .n_aochan = 2,
+ .aobits = 16,
+ .reg_type = ni_reg_611x,
+ .ao_range_table = &range_bipolar10,
+ .ao_unipolar = 0,
+ .ao_fifo_depth = 2048,
+ .ao_speed = 250,
+ .num_p0_dio_channels = 8,
+ .caldac = {ad8804, ad8804},
+ },
{
- .device_id = 0x14f0,
- .name = "pci-6111",
- .n_adchan = 2,
- .adbits = 12,
- .ai_fifo_depth = 8192,
- .alwaysdither = 0,
- .gainlkup = ai_gain_611x,
- .ai_speed = 200,
- .n_aochan = 2,
- .aobits = 16,
- .reg_type = ni_reg_611x,
- .ao_range_table = &range_bipolar10,
- .ao_unipolar = 0,
- .ao_fifo_depth = 2048,
- .ao_speed = 250,
- .num_p0_dio_channels = 8,
- .caldac = {ad8804, ad8804},
- },
+ .device_id = 0x14f0,
+ .name = "pci-6111",
+ .n_adchan = 2,
+ .adbits = 12,
+ .ai_fifo_depth = 8192,
+ .alwaysdither = 0,
+ .gainlkup = ai_gain_611x,
+ .ai_speed = 200,
+ .n_aochan = 2,
+ .aobits = 16,
+ .reg_type = ni_reg_611x,
+ .ao_range_table = &range_bipolar10,
+ .ao_unipolar = 0,
+ .ao_fifo_depth = 2048,
+ .ao_speed = 250,
+ .num_p0_dio_channels = 8,
+ .caldac = {ad8804, ad8804},
+ },
#if 0
/* The 6115 boards probably need their own driver */
{
- .device_id = 0x2ed0,
- .name = "pci-6115",
- .n_adchan = 4,
- .adbits = 12,
- .ai_fifo_depth = 8192,
- .alwaysdither = 0,
- .gainlkup = ai_gain_611x,
- .ai_speed = 100,
- .n_aochan = 2,
- .aobits = 16,
- .ao_671x = 1,
- .ao_unipolar = 0,
- .ao_fifo_depth = 2048,
- .ao_speed = 250,
- .num_p0_dio_channels = 8,
- .reg_611x = 1,
- .caldac = {ad8804_debug, ad8804_debug, ad8804_debug}, /* XXX */
- },
+ .device_id = 0x2ed0,
+ .name = "pci-6115",
+ .n_adchan = 4,
+ .adbits = 12,
+ .ai_fifo_depth = 8192,
+ .alwaysdither = 0,
+ .gainlkup = ai_gain_611x,
+ .ai_speed = 100,
+ .n_aochan = 2,
+ .aobits = 16,
+ .ao_671x = 1,
+ .ao_unipolar = 0,
+ .ao_fifo_depth = 2048,
+ .ao_speed = 250,
+ .num_p0_dio_channels = 8,
+ .reg_611x = 1,
+ .caldac = {ad8804_debug, ad8804_debug, ad8804_debug}, /* XXX */
+ },
#endif
#if 0
{
- .device_id = 0x0000,
- .name = "pxi-6115",
- .n_adchan = 4,
- .adbits = 12,
- .ai_fifo_depth = 8192,
- .alwaysdither = 0,
- .gainlkup = ai_gain_611x,
- .ai_speed = 100,
- .n_aochan = 2,
- .aobits = 16,
- .ao_671x = 1,
- .ao_unipolar = 0,
- .ao_fifo_depth = 2048,
- .ao_speed = 250,
- .reg_611x = 1,
- .num_p0_dio_channels = 8,
- caldac = {ad8804_debug, ad8804_debug, ad8804_debug}, /* XXX */
- },
+ .device_id = 0x0000,
+ .name = "pxi-6115",
+ .n_adchan = 4,
+ .adbits = 12,
+ .ai_fifo_depth = 8192,
+ .alwaysdither = 0,
+ .gainlkup = ai_gain_611x,
+ .ai_speed = 100,
+ .n_aochan = 2,
+ .aobits = 16,
+ .ao_671x = 1,
+ .ao_unipolar = 0,
+ .ao_fifo_depth = 2048,
+ .ao_speed = 250,
+ .reg_611x = 1,
+ .num_p0_dio_channels = 8,
+ caldac = {ad8804_debug, ad8804_debug, ad8804_debug}, /* XXX */
+ },
#endif
{
- .device_id = 0x1880,
- .name = "pci-6711",
- .n_adchan = 0, /* no analog input */
- .n_aochan = 4,
- .aobits = 12,
- .ao_unipolar = 0,
- .ao_fifo_depth = 16384,
- /* data sheet says 8192, but fifo really holds 16384 samples */
- .ao_range_table = &range_bipolar10,
- .ao_speed = 1000,
- .num_p0_dio_channels = 8,
- .reg_type = ni_reg_6711,
- .caldac = {ad8804_debug},
- },
+ .device_id = 0x1880,
+ .name = "pci-6711",
+ .n_adchan = 0, /* no analog input */
+ .n_aochan = 4,
+ .aobits = 12,
+ .ao_unipolar = 0,
+ .ao_fifo_depth = 16384,
+ /* data sheet says 8192, but fifo really holds 16384 samples */
+ .ao_range_table = &range_bipolar10,
+ .ao_speed = 1000,
+ .num_p0_dio_channels = 8,
+ .reg_type = ni_reg_6711,
+ .caldac = {ad8804_debug},
+ },
{
- .device_id = 0x2b90,
- .name = "pxi-6711",
- .n_adchan = 0, /* no analog input */
- .n_aochan = 4,
- .aobits = 12,
- .ao_unipolar = 0,
- .ao_fifo_depth = 16384,
- .ao_range_table = &range_bipolar10,
- .ao_speed = 1000,
- .num_p0_dio_channels = 8,
- .reg_type = ni_reg_6711,
- .caldac = {ad8804_debug},
- },
+ .device_id = 0x2b90,
+ .name = "pxi-6711",
+ .n_adchan = 0, /* no analog input */
+ .n_aochan = 4,
+ .aobits = 12,
+ .ao_unipolar = 0,
+ .ao_fifo_depth = 16384,
+ .ao_range_table = &range_bipolar10,
+ .ao_speed = 1000,
+ .num_p0_dio_channels = 8,
+ .reg_type = ni_reg_6711,
+ .caldac = {ad8804_debug},
+ },
{
- .device_id = 0x1870,
- .name = "pci-6713",
- .n_adchan = 0, /* no analog input */
- .n_aochan = 8,
- .aobits = 12,
- .ao_unipolar = 0,
- .ao_fifo_depth = 16384,
- .ao_range_table = &range_bipolar10,
- .ao_speed = 1000,
- .num_p0_dio_channels = 8,
- .reg_type = ni_reg_6713,
- .caldac = {ad8804_debug, ad8804_debug},
- },
+ .device_id = 0x1870,
+ .name = "pci-6713",
+ .n_adchan = 0, /* no analog input */
+ .n_aochan = 8,
+ .aobits = 12,
+ .ao_unipolar = 0,
+ .ao_fifo_depth = 16384,
+ .ao_range_table = &range_bipolar10,
+ .ao_speed = 1000,
+ .num_p0_dio_channels = 8,
+ .reg_type = ni_reg_6713,
+ .caldac = {ad8804_debug, ad8804_debug},
+ },
{
- .device_id = 0x2b80,
- .name = "pxi-6713",
- .n_adchan = 0, /* no analog input */
- .n_aochan = 8,
- .aobits = 12,
- .ao_unipolar = 0,
- .ao_fifo_depth = 16384,
- .ao_range_table = &range_bipolar10,
- .ao_speed = 1000,
- .num_p0_dio_channels = 8,
- .reg_type = ni_reg_6713,
- .caldac = {ad8804_debug, ad8804_debug},
- },
+ .device_id = 0x2b80,
+ .name = "pxi-6713",
+ .n_adchan = 0, /* no analog input */
+ .n_aochan = 8,
+ .aobits = 12,
+ .ao_unipolar = 0,
+ .ao_fifo_depth = 16384,
+ .ao_range_table = &range_bipolar10,
+ .ao_speed = 1000,
+ .num_p0_dio_channels = 8,
+ .reg_type = ni_reg_6713,
+ .caldac = {ad8804_debug, ad8804_debug},
+ },
{
- .device_id = 0x2430,
- .name = "pci-6731",
- .n_adchan = 0, /* no analog input */
- .n_aochan = 4,
- .aobits = 16,
- .ao_unipolar = 0,
- .ao_fifo_depth = 8192,
- .ao_range_table = &range_bipolar10,
- .ao_speed = 1000,
- .num_p0_dio_channels = 8,
- .reg_type = ni_reg_6711,
- .caldac = {ad8804_debug},
- },
+ .device_id = 0x2430,
+ .name = "pci-6731",
+ .n_adchan = 0, /* no analog input */
+ .n_aochan = 4,
+ .aobits = 16,
+ .ao_unipolar = 0,
+ .ao_fifo_depth = 8192,
+ .ao_range_table = &range_bipolar10,
+ .ao_speed = 1000,
+ .num_p0_dio_channels = 8,
+ .reg_type = ni_reg_6711,
+ .caldac = {ad8804_debug},
+ },
#if 0 /* need device ids */
{
- .device_id = 0x0,
- .name = "pxi-6731",
- .n_adchan = 0, /* no analog input */
- .n_aochan = 4,
- .aobits = 16,
- .ao_unipolar = 0,
- .ao_fifo_depth = 8192,
- .ao_range_table = &range_bipolar10,
- .num_p0_dio_channels = 8,
- .reg_type = ni_reg_6711,
- .caldac = {ad8804_debug},
- },
+ .device_id = 0x0,
+ .name = "pxi-6731",
+ .n_adchan = 0, /* no analog input */
+ .n_aochan = 4,
+ .aobits = 16,
+ .ao_unipolar = 0,
+ .ao_fifo_depth = 8192,
+ .ao_range_table = &range_bipolar10,
+ .num_p0_dio_channels = 8,
+ .reg_type = ni_reg_6711,
+ .caldac = {ad8804_debug},
+ },
#endif
{
- .device_id = 0x2410,
- .name = "pci-6733",
- .n_adchan = 0, /* no analog input */
- .n_aochan = 8,
- .aobits = 16,
- .ao_unipolar = 0,
- .ao_fifo_depth = 16384,
- .ao_range_table = &range_bipolar10,
- .ao_speed = 1000,
- .num_p0_dio_channels = 8,
- .reg_type = ni_reg_6713,
- .caldac = {ad8804_debug, ad8804_debug},
- },
+ .device_id = 0x2410,
+ .name = "pci-6733",
+ .n_adchan = 0, /* no analog input */
+ .n_aochan = 8,
+ .aobits = 16,
+ .ao_unipolar = 0,
+ .ao_fifo_depth = 16384,
+ .ao_range_table = &range_bipolar10,
+ .ao_speed = 1000,
+ .num_p0_dio_channels = 8,
+ .reg_type = ni_reg_6713,
+ .caldac = {ad8804_debug, ad8804_debug},
+ },
{
- .device_id = 0x2420,
- .name = "pxi-6733",
- .n_adchan = 0, /* no analog input */
- .n_aochan = 8,
- .aobits = 16,
- .ao_unipolar = 0,
- .ao_fifo_depth = 16384,
- .ao_range_table = &range_bipolar10,
- .ao_speed = 1000,
- .num_p0_dio_channels = 8,
- .reg_type = ni_reg_6713,
- .caldac = {ad8804_debug, ad8804_debug},
- },
+ .device_id = 0x2420,
+ .name = "pxi-6733",
+ .n_adchan = 0, /* no analog input */
+ .n_aochan = 8,
+ .aobits = 16,
+ .ao_unipolar = 0,
+ .ao_fifo_depth = 16384,
+ .ao_range_table = &range_bipolar10,
+ .ao_speed = 1000,
+ .num_p0_dio_channels = 8,
+ .reg_type = ni_reg_6713,
+ .caldac = {ad8804_debug, ad8804_debug},
+ },
{
- .device_id = 0x15b0,
- .name = "pxi-6071e",
- .n_adchan = 64,
- .adbits = 12,
- .ai_fifo_depth = 512,
- .alwaysdither = 1,
- .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,
- .num_p0_dio_channels = 8,
- .caldac = {ad8804_debug},
- .has_8255 = 0,
- },
+ .device_id = 0x15b0,
+ .name = "pxi-6071e",
+ .n_adchan = 64,
+ .adbits = 12,
+ .ai_fifo_depth = 512,
+ .alwaysdither = 1,
+ .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,
+ .num_p0_dio_channels = 8,
+ .caldac = {ad8804_debug},
+ .has_8255 = 0,
+ },
{
- .device_id = 0x11b0,
- .name = "pxi-6070e",
- .n_adchan = 16,
- .adbits = 12,
- .ai_fifo_depth = 512,
- .alwaysdither = 1,
- .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,
- .num_p0_dio_channels = 8,
- .caldac = {ad8804_debug},
- .has_8255 = 0,
- },
+ .device_id = 0x11b0,
+ .name = "pxi-6070e",
+ .n_adchan = 16,
+ .adbits = 12,
+ .ai_fifo_depth = 512,
+ .alwaysdither = 1,
+ .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,
+ .num_p0_dio_channels = 8,
+ .caldac = {ad8804_debug},
+ .has_8255 = 0,
+ },
{
- .device_id = 0x18c0,
- .name = "pxi-6052e",
- .n_adchan = 16,
- .adbits = 16,
- .ai_fifo_depth = 512,
- .alwaysdither = 1,
- .gainlkup = ai_gain_16,
- .ai_speed = 3000,
- .n_aochan = 2,
- .aobits = 16,
- .ao_unipolar = 1,
- .ao_fifo_depth = 2048,
- .ao_range_table = &range_ni_E_ao_ext,
- .ao_speed = 3000,
- .num_p0_dio_channels = 8,
- .caldac = {mb88341, mb88341, ad8522},
- },
+ .device_id = 0x18c0,
+ .name = "pxi-6052e",
+ .n_adchan = 16,
+ .adbits = 16,
+ .ai_fifo_depth = 512,
+ .alwaysdither = 1,
+ .gainlkup = ai_gain_16,
+ .ai_speed = 3000,
+ .n_aochan = 2,
+ .aobits = 16,
+ .ao_unipolar = 1,
+ .ao_fifo_depth = 2048,
+ .ao_range_table = &range_ni_E_ao_ext,
+ .ao_speed = 3000,
+ .num_p0_dio_channels = 8,
+ .caldac = {mb88341, mb88341, ad8522},
+ },
{
- .device_id = 0x1580,
- .name = "pxi-6031e",
- .n_adchan = 64,
- .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 = 10000,
- .num_p0_dio_channels = 8,
- .caldac = {dac8800, dac8043, ad8522},
- },
+ .device_id = 0x1580,
+ .name = "pxi-6031e",
+ .n_adchan = 64,
+ .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 = 10000,
+ .num_p0_dio_channels = 8,
+ .caldac = {dac8800, dac8043, ad8522},
+ },
{
- .device_id = 0x2890,
- .name = "pci-6036e",
- .n_adchan = 16,
- .adbits = 16,
- .ai_fifo_depth = 512,
- .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 = 100000,
- .num_p0_dio_channels = 8,
- .caldac = {ad8804_debug},
- .has_8255 = 0,
- },
+ .device_id = 0x2890,
+ .name = "pci-6036e",
+ .n_adchan = 16,
+ .adbits = 16,
+ .ai_fifo_depth = 512,
+ .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 = 100000,
+ .num_p0_dio_channels = 8,
+ .caldac = {ad8804_debug},
+ .has_8255 = 0,
+ },
{
- .device_id = 0x70b0,
- .name = "pci-6220",
- .n_adchan = 16,
- .adbits = 16,
- .ai_fifo_depth = 512,
- /* .FIXME = guess */
- .gainlkup = ai_gain_622x,
- .ai_speed = 4000,
- .n_aochan = 0,
- .aobits = 0,
- .ao_fifo_depth = 0,
- .num_p0_dio_channels = 8,
- .reg_type = ni_reg_622x,
- .ao_unipolar = 0,
- .caldac = {caldac_none},
- .has_8255 = 0,
- },
+ .device_id = 0x70b0,
+ .name = "pci-6220",
+ .n_adchan = 16,
+ .adbits = 16,
+ .ai_fifo_depth = 512,
+ /* .FIXME = guess */
+ .gainlkup = ai_gain_622x,
+ .ai_speed = 4000,
+ .n_aochan = 0,
+ .aobits = 0,
+ .ao_fifo_depth = 0,
+ .num_p0_dio_channels = 8,
+ .reg_type = ni_reg_622x,
+ .ao_unipolar = 0,
+ .caldac = {caldac_none},
+ .has_8255 = 0,
+ },
{
- .device_id = 0x70af,
- .name = "pci-6221",
- .n_adchan = 16,
- .adbits = 16,
- .ai_fifo_depth = 4095,
- .gainlkup = ai_gain_622x,
- .ai_speed = 4000,
- .n_aochan = 2,
- .aobits = 16,
- .ao_fifo_depth = 8191,
- .ao_range_table = &range_ni_M_622x_ao,
- .reg_type = ni_reg_622x,
- .ao_unipolar = 0,
- .ao_speed = 1200,
- .num_p0_dio_channels = 8,
- .caldac = {caldac_none},
- .has_8255 = 0,
- },
+ .device_id = 0x70af,
+ .name = "pci-6221",
+ .n_adchan = 16,
+ .adbits = 16,
+ .ai_fifo_depth = 4095,
+ .gainlkup = ai_gain_622x,
+ .ai_speed = 4000,
+ .n_aochan = 2,
+ .aobits = 16,
+ .ao_fifo_depth = 8191,
+ .ao_range_table = &range_ni_M_622x_ao,
+ .reg_type = ni_reg_622x,
+ .ao_unipolar = 0,
+ .ao_speed = 1200,
+ .num_p0_dio_channels = 8,
+ .caldac = {caldac_none},
+ .has_8255 = 0,
+ },
{
- .device_id = 0x71bc,
- .name = "pci-6221_37pin",
- .n_adchan = 16,
- .adbits = 16,
- .ai_fifo_depth = 4095,
- .gainlkup = ai_gain_622x,
- .ai_speed = 4000,
- .n_aochan = 2,
- .aobits = 16,
- .ao_fifo_depth = 8191,
- .ao_range_table = &range_ni_M_622x_ao,
- .reg_type = ni_reg_622x,
- .ao_unipolar = 0,
- .ao_speed = 1200,
- .num_p0_dio_channels = 8,
- .caldac = {caldac_none},
- .has_8255 = 0,
- },
+ .device_id = 0x71bc,
+ .name = "pci-6221_37pin",
+ .n_adchan = 16,
+ .adbits = 16,
+ .ai_fifo_depth = 4095,
+ .gainlkup = ai_gain_622x,
+ .ai_speed = 4000,
+ .n_aochan = 2,
+ .aobits = 16,
+ .ao_fifo_depth = 8191,
+ .ao_range_table = &range_ni_M_622x_ao,
+ .reg_type = ni_reg_622x,
+ .ao_unipolar = 0,
+ .ao_speed = 1200,
+ .num_p0_dio_channels = 8,
+ .caldac = {caldac_none},
+ .has_8255 = 0,
+ },
{
- .device_id = 0x70f2,
- .name = "pci-6224",
- .n_adchan = 32,
- .adbits = 16,
- .ai_fifo_depth = 4095,
- .gainlkup = ai_gain_622x,
- .ai_speed = 4000,
- .n_aochan = 0,
- .aobits = 0,
- .ao_fifo_depth = 0,
- .reg_type = ni_reg_622x,
- .ao_unipolar = 0,
- .num_p0_dio_channels = 32,
- .caldac = {caldac_none},
- .has_8255 = 0,
- },
+ .device_id = 0x70f2,
+ .name = "pci-6224",
+ .n_adchan = 32,
+ .adbits = 16,
+ .ai_fifo_depth = 4095,
+ .gainlkup = ai_gain_622x,
+ .ai_speed = 4000,
+ .n_aochan = 0,
+ .aobits = 0,
+ .ao_fifo_depth = 0,
+ .reg_type = ni_reg_622x,
+ .ao_unipolar = 0,
+ .num_p0_dio_channels = 32,
+ .caldac = {caldac_none},
+ .has_8255 = 0,
+ },
{
- .device_id = 0x70f3,
- .name = "pxi-6224",
- .n_adchan = 32,
- .adbits = 16,
- .ai_fifo_depth = 4095,
- .gainlkup = ai_gain_622x,
- .ai_speed = 4000,
- .n_aochan = 0,
- .aobits = 0,
- .ao_fifo_depth = 0,
- .reg_type = ni_reg_622x,
- .ao_unipolar = 0,
- .num_p0_dio_channels = 32,
- .caldac = {caldac_none},
- .has_8255 = 0,
- },
+ .device_id = 0x70f3,
+ .name = "pxi-6224",
+ .n_adchan = 32,
+ .adbits = 16,
+ .ai_fifo_depth = 4095,
+ .gainlkup = ai_gain_622x,
+ .ai_speed = 4000,
+ .n_aochan = 0,
+ .aobits = 0,
+ .ao_fifo_depth = 0,
+ .reg_type = ni_reg_622x,
+ .ao_unipolar = 0,
+ .num_p0_dio_channels = 32,
+ .caldac = {caldac_none},
+ .has_8255 = 0,
+ },
{
- .device_id = 0x716c,
- .name = "pci-6225",
- .n_adchan = 80,
- .adbits = 16,
- .ai_fifo_depth = 4095,
- .gainlkup = ai_gain_622x,
- .ai_speed = 4000,
- .n_aochan = 2,
- .aobits = 16,
- .ao_fifo_depth = 8191,
- .ao_range_table = &range_ni_M_622x_ao,
- .reg_type = ni_reg_622x,
- .ao_unipolar = 0,
- .ao_speed = 1200,
- .num_p0_dio_channels = 32,
- .caldac = {caldac_none},
- .has_8255 = 0,
- },
+ .device_id = 0x716c,
+ .name = "pci-6225",
+ .n_adchan = 80,
+ .adbits = 16,
+ .ai_fifo_depth = 4095,
+ .gainlkup = ai_gain_622x,
+ .ai_speed = 4000,
+ .n_aochan = 2,
+ .aobits = 16,
+ .ao_fifo_depth = 8191,
+ .ao_range_table = &range_ni_M_622x_ao,
+ .reg_type = ni_reg_622x,
+ .ao_unipolar = 0,
+ .ao_speed = 1200,
+ .num_p0_dio_channels = 32,
+ .caldac = {caldac_none},
+ .has_8255 = 0,
+ },
{
- .device_id = 0x70aa,
- .name = "pci-6229",
- .n_adchan = 32,
- .adbits = 16,
- .ai_fifo_depth = 4095,
- .gainlkup = ai_gain_622x,
- .ai_speed = 4000,
- .n_aochan = 4,
- .aobits = 16,
- .ao_fifo_depth = 8191,
- .ao_range_table = &range_ni_M_622x_ao,
- .reg_type = ni_reg_622x,
- .ao_unipolar = 0,
- .ao_speed = 1200,
- .num_p0_dio_channels = 32,
- .caldac = {caldac_none},
- .has_8255 = 0,
- },
+ .device_id = 0x70aa,
+ .name = "pci-6229",
+ .n_adchan = 32,
+ .adbits = 16,
+ .ai_fifo_depth = 4095,
+ .gainlkup = ai_gain_622x,
+ .ai_speed = 4000,
+ .n_aochan = 4,
+ .aobits = 16,
+ .ao_fifo_depth = 8191,
+ .ao_range_table = &range_ni_M_622x_ao,
+ .reg_type = ni_reg_622x,
+ .ao_unipolar = 0,
+ .ao_speed = 1200,
+ .num_p0_dio_channels = 32,
+ .caldac = {caldac_none},
+ .has_8255 = 0,
+ },
{
- .device_id = 0x70b4,
- .name = "pci-6250",
- .n_adchan = 16,
- .adbits = 16,
- .ai_fifo_depth = 4095,
- .gainlkup = ai_gain_628x,
- .ai_speed = 800,
- .n_aochan = 0,
- .aobits = 0,
- .ao_fifo_depth = 0,
- .reg_type = ni_reg_625x,
- .ao_unipolar = 0,
- .num_p0_dio_channels = 8,
- .caldac = {caldac_none},
- .has_8255 = 0,
- },
+ .device_id = 0x70b4,
+ .name = "pci-6250",
+ .n_adchan = 16,
+ .adbits = 16,
+ .ai_fifo_depth = 4095,
+ .gainlkup = ai_gain_628x,
+ .ai_speed = 800,
+ .n_aochan = 0,
+ .aobits = 0,
+ .ao_fifo_depth = 0,
+ .reg_type = ni_reg_625x,
+ .ao_unipolar = 0,
+ .num_p0_dio_channels = 8,
+ .caldac = {caldac_none},
+ .has_8255 = 0,
+ },
{
- .device_id = 0x70b8,
- .name = "pci-6251",
- .n_adchan = 16,
- .adbits = 16,
- .ai_fifo_depth = 4095,
- .gainlkup = ai_gain_628x,
- .ai_speed = 800,
- .n_aochan = 2,
- .aobits = 16,
- .ao_fifo_depth = 8191,
- .ao_range_table = &range_ni_M_625x_ao,
- .reg_type = ni_reg_625x,
- .ao_unipolar = 0,
- .ao_speed = 357,
- .num_p0_dio_channels = 8,
- .caldac = {caldac_none},
- .has_8255 = 0,
- },
+ .device_id = 0x70b8,
+ .name = "pci-6251",
+ .n_adchan = 16,
+ .adbits = 16,
+ .ai_fifo_depth = 4095,
+ .gainlkup = ai_gain_628x,
+ .ai_speed = 800,
+ .n_aochan = 2,
+ .aobits = 16,
+ .ao_fifo_depth = 8191,
+ .ao_range_table = &range_ni_M_625x_ao,
+ .reg_type = ni_reg_625x,
+ .ao_unipolar = 0,
+ .ao_speed = 357,
+ .num_p0_dio_channels = 8,
+ .caldac = {caldac_none},
+ .has_8255 = 0,
+ },
{
- .device_id = 0x717d,
- .name = "pcie-6251",
- .n_adchan = 16,
- .adbits = 16,
- .ai_fifo_depth = 4095,
- .gainlkup = ai_gain_628x,
- .ai_speed = 800,
- .n_aochan = 2,
- .aobits = 16,
- .ao_fifo_depth = 8191,
- .ao_range_table = &range_ni_M_625x_ao,
- .reg_type = ni_reg_625x,
- .ao_unipolar = 0,
- .ao_speed = 357,
- .num_p0_dio_channels = 8,
- .caldac = {caldac_none},
- .has_8255 = 0,
- },
+ .device_id = 0x717d,
+ .name = "pcie-6251",
+ .n_adchan = 16,
+ .adbits = 16,
+ .ai_fifo_depth = 4095,
+ .gainlkup = ai_gain_628x,
+ .ai_speed = 800,
+ .n_aochan = 2,
+ .aobits = 16,
+ .ao_fifo_depth = 8191,
+ .ao_range_table = &range_ni_M_625x_ao,
+ .reg_type = ni_reg_625x,
+ .ao_unipolar = 0,
+ .ao_speed = 357,
+ .num_p0_dio_channels = 8,
+ .caldac = {caldac_none},
+ .has_8255 = 0,
+ },
{
- .device_id = 0x70b7,
- .name = "pci-6254",
- .n_adchan = 32,
- .adbits = 16,
- .ai_fifo_depth = 4095,
- .gainlkup = ai_gain_628x,
- .ai_speed = 800,
- .n_aochan = 0,
- .aobits = 0,
- .ao_fifo_depth = 0,
- .reg_type = ni_reg_625x,
- .ao_unipolar = 0,
- .num_p0_dio_channels = 32,
- .caldac = {caldac_none},
- .has_8255 = 0,
- },
+ .device_id = 0x70b7,
+ .name = "pci-6254",
+ .n_adchan = 32,
+ .adbits = 16,
+ .ai_fifo_depth = 4095,
+ .gainlkup = ai_gain_628x,
+ .ai_speed = 800,
+ .n_aochan = 0,
+ .aobits = 0,
+ .ao_fifo_depth = 0,
+ .reg_type = ni_reg_625x,
+ .ao_unipolar = 0,
+ .num_p0_dio_channels = 32,
+ .caldac = {caldac_none},
+ .has_8255 = 0,
+ },
{
- .device_id = 0x70ab,
- .name = "pci-6259",
- .n_adchan = 32,
- .adbits = 16,
- .ai_fifo_depth = 4095,
- .gainlkup = ai_gain_628x,
- .ai_speed = 800,
- .n_aochan = 4,
- .aobits = 16,
- .ao_fifo_depth = 8191,
- .ao_range_table = &range_ni_M_625x_ao,
- .reg_type = ni_reg_625x,
- .ao_unipolar = 0,
- .ao_speed = 357,
- .num_p0_dio_channels = 32,
- .caldac = {caldac_none},
- .has_8255 = 0,
- },
+ .device_id = 0x70ab,
+ .name = "pci-6259",
+ .n_adchan = 32,
+ .adbits = 16,
+ .ai_fifo_depth = 4095,
+ .gainlkup = ai_gain_628x,
+ .ai_speed = 800,
+ .n_aochan = 4,
+ .aobits = 16,
+ .ao_fifo_depth = 8191,
+ .ao_range_table = &range_ni_M_625x_ao,
+ .reg_type = ni_reg_625x,
+ .ao_unipolar = 0,
+ .ao_speed = 357,
+ .num_p0_dio_channels = 32,
+ .caldac = {caldac_none},
+ .has_8255 = 0,
+ },
{
- .device_id = 0x717f,
- .name = "pcie-6259",
- .n_adchan = 32,
- .adbits = 16,
- .ai_fifo_depth = 4095,
- .gainlkup = ai_gain_628x,
- .ai_speed = 800,
- .n_aochan = 4,
- .aobits = 16,
- .ao_fifo_depth = 8191,
- .ao_range_table = &range_ni_M_625x_ao,
- .reg_type = ni_reg_625x,
- .ao_unipolar = 0,
- .ao_speed = 357,
- .num_p0_dio_channels = 32,
- .caldac = {caldac_none},
- .has_8255 = 0,
- },
+ .device_id = 0x717f,
+ .name = "pcie-6259",
+ .n_adchan = 32,
+ .adbits = 16,
+ .ai_fifo_depth = 4095,
+ .gainlkup = ai_gain_628x,
+ .ai_speed = 800,
+ .n_aochan = 4,
+ .aobits = 16,
+ .ao_fifo_depth = 8191,
+ .ao_range_table = &range_ni_M_625x_ao,
+ .reg_type = ni_reg_625x,
+ .ao_unipolar = 0,
+ .ao_speed = 357,
+ .num_p0_dio_channels = 32,
+ .caldac = {caldac_none},
+ .has_8255 = 0,
+ },
{
- .device_id = 0x70b6,
- .name = "pci-6280",
- .n_adchan = 16,
- .adbits = 18,
- .ai_fifo_depth = 2047,
- .gainlkup = ai_gain_628x,
- .ai_speed = 1600,
- .n_aochan = 0,
- .aobits = 0,
- .ao_fifo_depth = 8191,
- .reg_type = ni_reg_628x,
- .ao_unipolar = 0,
- .num_p0_dio_channels = 8,
- .caldac = {caldac_none},
- .has_8255 = 0,
- },
+ .device_id = 0x70b6,
+ .name = "pci-6280",
+ .n_adchan = 16,
+ .adbits = 18,
+ .ai_fifo_depth = 2047,
+ .gainlkup = ai_gain_628x,
+ .ai_speed = 1600,
+ .n_aochan = 0,
+ .aobits = 0,
+ .ao_fifo_depth = 8191,
+ .reg_type = ni_reg_628x,
+ .ao_unipolar = 0,
+ .num_p0_dio_channels = 8,
+ .caldac = {caldac_none},
+ .has_8255 = 0,
+ },
{
- .device_id = 0x70bd,
- .name = "pci-6281",
- .n_adchan = 16,
- .adbits = 18,
- .ai_fifo_depth = 2047,
- .gainlkup = ai_gain_628x,
- .ai_speed = 1600,
- .n_aochan = 2,
- .aobits = 16,
- .ao_fifo_depth = 8191,
- .ao_range_table = &range_ni_M_628x_ao,
- .reg_type = ni_reg_628x,
- .ao_unipolar = 1,
- .ao_speed = 357,
- .num_p0_dio_channels = 8,
- .caldac = {caldac_none},
- .has_8255 = 0,
- },
+ .device_id = 0x70bd,
+ .name = "pci-6281",
+ .n_adchan = 16,
+ .adbits = 18,
+ .ai_fifo_depth = 2047,
+ .gainlkup = ai_gain_628x,
+ .ai_speed = 1600,
+ .n_aochan = 2,
+ .aobits = 16,
+ .ao_fifo_depth = 8191,
+ .ao_range_table = &range_ni_M_628x_ao,
+ .reg_type = ni_reg_628x,
+ .ao_unipolar = 1,
+ .ao_speed = 357,
+ .num_p0_dio_channels = 8,
+ .caldac = {caldac_none},
+ .has_8255 = 0,
+ },
{
- .device_id = 0x70bf,
- .name = "pxi-6281",
- .n_adchan = 16,
- .adbits = 18,
- .ai_fifo_depth = 2047,
- .gainlkup = ai_gain_628x,
- .ai_speed = 1600,
- .n_aochan = 2,
- .aobits = 16,
- .ao_fifo_depth = 8191,
- .ao_range_table = &range_ni_M_628x_ao,
- .reg_type = ni_reg_628x,
- .ao_unipolar = 1,
- .ao_speed = 357,
- .num_p0_dio_channels = 8,
- .caldac = {caldac_none},
- .has_8255 = 0,
- },
+ .device_id = 0x70bf,
+ .name = "pxi-6281",
+ .n_adchan = 16,
+ .adbits = 18,
+ .ai_fifo_depth = 2047,
+ .gainlkup = ai_gain_628x,
+ .ai_speed = 1600,
+ .n_aochan = 2,
+ .aobits = 16,
+ .ao_fifo_depth = 8191,
+ .ao_range_table = &range_ni_M_628x_ao,
+ .reg_type = ni_reg_628x,
+ .ao_unipolar = 1,
+ .ao_speed = 357,
+ .num_p0_dio_channels = 8,
+ .caldac = {caldac_none},
+ .has_8255 = 0,
+ },
{
- .device_id = 0x70bc,
- .name = "pci-6284",
- .n_adchan = 32,
- .adbits = 18,
- .ai_fifo_depth = 2047,
- .gainlkup = ai_gain_628x,
- .ai_speed = 1600,
- .n_aochan = 0,
- .aobits = 0,
- .ao_fifo_depth = 0,
- .reg_type = ni_reg_628x,
- .ao_unipolar = 0,
- .num_p0_dio_channels = 32,
- .caldac = {caldac_none},
- .has_8255 = 0,
- },
+ .device_id = 0x70bc,
+ .name = "pci-6284",
+ .n_adchan = 32,
+ .adbits = 18,
+ .ai_fifo_depth = 2047,
+ .gainlkup = ai_gain_628x,
+ .ai_speed = 1600,
+ .n_aochan = 0,
+ .aobits = 0,
+ .ao_fifo_depth = 0,
+ .reg_type = ni_reg_628x,
+ .ao_unipolar = 0,
+ .num_p0_dio_channels = 32,
+ .caldac = {caldac_none},
+ .has_8255 = 0,
+ },
{
- .device_id = 0x70ac,
- .name = "pci-6289",
- .n_adchan = 32,
- .adbits = 18,
- .ai_fifo_depth = 2047,
- .gainlkup = ai_gain_628x,
- .ai_speed = 1600,
- .n_aochan = 4,
- .aobits = 16,
- .ao_fifo_depth = 8191,
- .ao_range_table = &range_ni_M_628x_ao,
- .reg_type = ni_reg_628x,
- .ao_unipolar = 1,
- .ao_speed = 357,
- .num_p0_dio_channels = 32,
- .caldac = {caldac_none},
- .has_8255 = 0,
- },
+ .device_id = 0x70ac,
+ .name = "pci-6289",
+ .n_adchan = 32,
+ .adbits = 18,
+ .ai_fifo_depth = 2047,
+ .gainlkup = ai_gain_628x,
+ .ai_speed = 1600,
+ .n_aochan = 4,
+ .aobits = 16,
+ .ao_fifo_depth = 8191,
+ .ao_range_table = &range_ni_M_628x_ao,
+ .reg_type = ni_reg_628x,
+ .ao_unipolar = 1,
+ .ao_speed = 357,
+ .num_p0_dio_channels = 32,
+ .caldac = {caldac_none},
+ .has_8255 = 0,
+ },
{
- .device_id = 0x70C0,
- .name = "pci-6143",
- .n_adchan = 8,
- .adbits = 16,
- .ai_fifo_depth = 1024,
- .alwaysdither = 0,
- .gainlkup = ai_gain_6143,
- .ai_speed = 4000,
- .n_aochan = 0,
- .aobits = 0,
- .reg_type = ni_reg_6143,
- .ao_unipolar = 0,
- .ao_fifo_depth = 0,
- .num_p0_dio_channels = 8,
- .caldac = {ad8804_debug, ad8804_debug},
- },
+ .device_id = 0x70C0,
+ .name = "pci-6143",
+ .n_adchan = 8,
+ .adbits = 16,
+ .ai_fifo_depth = 1024,
+ .alwaysdither = 0,
+ .gainlkup = ai_gain_6143,
+ .ai_speed = 4000,
+ .n_aochan = 0,
+ .aobits = 0,
+ .reg_type = ni_reg_6143,
+ .ao_unipolar = 0,
+ .ao_fifo_depth = 0,
+ .num_p0_dio_channels = 8,
+ .caldac = {ad8804_debug, ad8804_debug},
+ },
{
- .device_id = 0x710D,
- .name = "pxi-6143",
- .n_adchan = 8,
- .adbits = 16,
- .ai_fifo_depth = 1024,
- .alwaysdither = 0,
- .gainlkup = ai_gain_6143,
- .ai_speed = 4000,
- .n_aochan = 0,
- .aobits = 0,
- .reg_type = ni_reg_6143,
- .ao_unipolar = 0,
- .ao_fifo_depth = 0,
- .num_p0_dio_channels = 8,
- .caldac = {ad8804_debug, ad8804_debug},
- },
+ .device_id = 0x710D,
+ .name = "pxi-6143",
+ .n_adchan = 8,
+ .adbits = 16,
+ .ai_fifo_depth = 1024,
+ .alwaysdither = 0,
+ .gainlkup = ai_gain_6143,
+ .ai_speed = 4000,
+ .n_aochan = 0,
+ .aobits = 0,
+ .reg_type = ni_reg_6143,
+ .ao_unipolar = 0,
+ .ao_fifo_depth = 0,
+ .num_p0_dio_channels = 8,
+ .caldac = {ad8804_debug, ad8804_debug},
+ },
};
#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_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,
@@ -1219,8 +1223,7 @@ static struct comedi_driver driver_pcimio = {
COMEDI_PCI_INITCLEANUP(driver_pcimio, ni_pci_table)
struct ni_private {
- NI_PRIVATE_COMMON
-};
+NI_PRIVATE_COMMON};
#define devpriv ((struct ni_private *)dev->private)
/* How we access registers */
@@ -1265,7 +1268,8 @@ static uint16_t e_series_win_in(struct comedi_device *dev, int reg)
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) {
@@ -1350,8 +1354,8 @@ static void m_series_stc_writew(struct comedi_device *dev, uint16_t data, int re
break;
case DIO_Control_Register:
printk
- ("%s: FIXME: register 0x%x does not map cleanly on to m-series boards.\n",
- __func__, reg);
+ ("%s: FIXME: register 0x%x does not map cleanly on to m-series boards.\n",
+ __func__, reg);
return;
break;
case G_Autoincrement_Register(0):
@@ -1412,7 +1416,7 @@ static void m_series_stc_writew(struct comedi_device *dev, uint16_t data, int re
and M_Offset_SCXI_Serial_Data_Out (8 bit) */
default:
printk("%s: bug! unhandled register=0x%x in switch.\n",
- __func__, reg);
+ __func__, reg);
BUG();
return;
break;
@@ -1447,7 +1451,7 @@ static uint16_t m_series_stc_readw(struct comedi_device *dev, int reg)
break;
default:
printk("%s: bug! unhandled register=0x%x in switch.\n",
- __func__, reg);
+ __func__, reg);
BUG();
return 0;
break;
@@ -1455,7 +1459,8 @@ 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) {
@@ -1488,7 +1493,7 @@ static void m_series_stc_writel(struct comedi_device *dev, uint32_t data, int re
break;
default:
printk("%s: bug! unhandled register=0x%x in switch.\n",
- __func__, reg);
+ __func__, reg);
BUG();
return;
break;
@@ -1514,7 +1519,7 @@ static uint32_t m_series_stc_readl(struct comedi_device *dev, int reg)
break;
default:
printk("%s: bug! unhandled register=0x%x in switch.\n",
- __func__, reg);
+ __func__, reg);
BUG();
return 0;
break;
@@ -1530,16 +1535,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,
- unsigned long new_size);
-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,
- unsigned long new_size);
-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,
- unsigned long new_size);
+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, unsigned long new_size);
+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,
+ unsigned long new_size);
+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)
{
@@ -1557,13 +1565,14 @@ static void m_series_init_eeprom_buffer(struct comedi_device *dev)
old_iodwcr1_bits = readl(devpriv->mite->mite_io_addr + MITE_IODWCR_1);
writel(0x0, devpriv->mite->mite_io_addr + MITE_IODWBSR);
writel(((0x80 | window_size) | devpriv->mite->daq_phys_addr),
- devpriv->mite->mite_io_addr + MITE_IODWBSR_1);
- writel(0x1 | old_iodwcr1_bits, devpriv->mite->mite_io_addr + MITE_IODWCR_1);
+ devpriv->mite->mite_io_addr + MITE_IODWBSR_1);
+ writel(0x1 | old_iodwcr1_bits,
+ devpriv->mite->mite_io_addr + MITE_IODWCR_1);
writel(0xf, devpriv->mite->mite_io_addr + 0x30);
BUG_ON(serial_number_eeprom_length > sizeof(devpriv->serial_number));
for (i = 0; i < serial_number_eeprom_length; ++i) {
- char *byte_ptr = (char*)&devpriv->serial_number + i;
+ char *byte_ptr = (char *)&devpriv->serial_number + i;
*byte_ptr = ni_readb(serial_number_eeprom_offset + i);
}
devpriv->serial_number = be32_to_cpu(devpriv->serial_number);
@@ -1593,7 +1602,7 @@ static void init_6143(struct comedi_device *dev)
/* Strobe Relay disable bit */
devpriv->ai_calib_source_enabled = 0;
ni_writew(devpriv->ai_calib_source | Calibration_Channel_6143_RelayOff,
- Calibration_Channel_6143);
+ Calibration_Channel_6143);
ni_writew(devpriv->ai_calib_source, Calibration_Channel_6143);
}
@@ -1710,7 +1719,7 @@ static int pcimio_find_device(struct comedi_device *dev, int bus, int slot)
continue;
if (bus || slot) {
if (bus != mite->pcidev->bus->number ||
- slot != PCI_SLOT(mite->pcidev->devfn))
+ slot != PCI_SLOT(mite->pcidev->devfn))
continue;
}
@@ -1728,8 +1737,8 @@ 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,
- unsigned long new_size)
+static int pcimio_ai_change(struct comedi_device *dev,
+ struct comedi_subdevice *s, unsigned long new_size)
{
int ret;
@@ -1740,8 +1749,8 @@ 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,
- unsigned long new_size)
+static int pcimio_ao_change(struct comedi_device *dev,
+ struct comedi_subdevice *s, unsigned long new_size)
{
int ret;
@@ -1752,8 +1761,9 @@ 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,
- unsigned long new_size)
+static int pcimio_gpct0_change(struct comedi_device *dev,
+ struct comedi_subdevice *s,
+ unsigned long new_size)
{
int ret;
@@ -1764,8 +1774,9 @@ static int pcimio_gpct0_change(struct comedi_device *dev, struct comedi_subdevic
return 0;
}
-static int pcimio_gpct1_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,
+ unsigned long new_size)
{
int ret;
@@ -1776,8 +1787,8 @@ static int pcimio_gpct1_change(struct comedi_device *dev, struct comedi_subdevic
return 0;
}
-static int pcimio_dio_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, 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 fcaedb346c44..504ea7155334 100644
--- a/drivers/staging/comedi/drivers/ni_stc.h
+++ b/drivers/staging/comedi/drivers/ni_stc.h
@@ -339,8 +339,7 @@ static inline unsigned RTSI_Output_Bit(unsigned channel, int is_mseries)
max_channel = 6;
}
if (channel > max_channel) {
- printk("%s: bug, invalid RTSI_channel=%i\n", __func__,
- channel);
+ printk("%s: bug, invalid RTSI_channel=%i\n", __func__, channel);
return 0;
}
return 1 << (base_bit_shift + channel);
@@ -369,7 +368,7 @@ enum ai_convert_output_selection {
AI_CONVERT_Output_Enable_High = 3
};
static unsigned AI_CONVERT_Output_Select(enum ai_convert_output_selection
- selection)
+ selection)
{
return selection & 0x3;
}
@@ -530,10 +529,11 @@ enum RTSI_Trig_B_Output_Bits {
RTSI_Sub_Selection_1_Bit = 0x8000 /* not for m-series */
};
static inline unsigned RTSI_Trig_Output_Bits(unsigned rtsi_channel,
- unsigned source)
+ unsigned source)
{
return (source & 0xf) << ((rtsi_channel % 4) * 4);
};
+
static inline unsigned RTSI_Trig_Output_Mask(unsigned rtsi_channel)
{
return 0xf << ((rtsi_channel % 4) * 4);
@@ -541,7 +541,7 @@ static inline unsigned RTSI_Trig_Output_Mask(unsigned rtsi_channel)
/* inverse to RTSI_Trig_Output_Bits() */
static inline unsigned RTSI_Trig_Output_Source(unsigned rtsi_channel,
- unsigned bits)
+ unsigned bits)
{
return (bits >> ((rtsi_channel % 4) * 4)) & 0xf;
};
@@ -566,7 +566,7 @@ enum ao_update_output_selection {
AO_Update_Output_Enable_High = 3
};
static unsigned AO_UPDATE_Output_Select(enum ao_update_output_selection
- selection)
+ selection)
{
return selection & 0x3;
}
@@ -730,13 +730,15 @@ static inline unsigned ni_stc_dma_channel_select_bitfield(unsigned channel)
BUG();
return 0;
}
+
static inline unsigned GPCT_DMA_Select_Bits(unsigned gpct_index,
- unsigned mite_channel)
+ unsigned mite_channel)
{
BUG_ON(gpct_index > 1);
return ni_stc_dma_channel_select_bitfield(mite_channel) << (4 *
- gpct_index);
+ gpct_index);
}
+
static inline unsigned GPCT_DMA_Select_Mask(unsigned gpct_index)
{
BUG_ON(gpct_index > 1);
@@ -839,6 +841,7 @@ static inline unsigned int DACx_Direct_Data_671x(int channel)
{
return channel;
}
+
enum AO_Misc_611x_Bits {
CLEAR_WG = 1,
};
@@ -870,10 +873,12 @@ static inline unsigned int CS5529_CONFIG_DOUT(int output)
{
return 1 << (18 + output);
}
+
static inline unsigned int CS5529_CONFIG_AOUT(int output)
{
return 1 << (22 + output);
}
+
enum cs5529_command_bits {
CSCMD_POWER_SAVE = 0x1,
CSCMD_REGISTER_SELECT_MASK = 0xe,
@@ -898,8 +903,9 @@ enum cs5529_status_bits {
*/
enum { ai_gain_16 =
- 0, ai_gain_8, ai_gain_14, ai_gain_4, ai_gain_611x, ai_gain_622x,
- ai_gain_628x, ai_gain_6143 };
+ 0, ai_gain_8, ai_gain_14, ai_gain_4, ai_gain_611x, ai_gain_622x,
+ ai_gain_628x, ai_gain_6143
+};
enum caldac_enum { caldac_none = 0, mb88341, dac8800, dac8043, ad8522,
ad8804, ad8842, ad8804_debug
};
@@ -1064,18 +1070,22 @@ static inline int M_Offset_AO_Waveform_Order(int channel)
{
return 0xc2 + 0x4 * channel;
};
+
static inline int M_Offset_AO_Config_Bank(int channel)
{
return 0xc3 + 0x4 * channel;
};
+
static inline int M_Offset_DAC_Direct_Data(int channel)
{
return 0xc0 + 0x4 * channel;
}
+
static inline int M_Offset_Gen_PWM(int channel)
{
return 0x44 + 0x2 * channel;
}
+
static inline int M_Offset_Static_AI_Control(int i)
{
int offset[] = {
@@ -1090,6 +1100,7 @@ static inline int M_Offset_Static_AI_Control(int i)
}
return offset[i];
};
+
static inline int M_Offset_AO_Reference_Attenuation(int channel)
{
int offset[] = {
@@ -1104,11 +1115,12 @@ static inline int M_Offset_AO_Reference_Attenuation(int channel)
}
return offset[channel];
};
+
static inline unsigned M_Offset_PFI_Output_Select(unsigned n)
{
if (n < 1 || n > NUM_PFI_OUTPUT_SELECT_REGS) {
printk("%s: invalid pfi output select register=%i\n",
- __func__, n);
+ __func__, n);
return M_Offset_PFI_Output_Select_1;
}
return M_Offset_PFI_Output_Select_1 + (n - 1) * 2;
@@ -1130,8 +1142,9 @@ static inline unsigned MSeries_AI_Config_Channel_Bits(unsigned channel)
{
return channel & 0xf;
}
+
static inline unsigned MSeries_AI_Config_Bank_Bits(enum ni_reg_type reg_type,
- unsigned channel)
+ unsigned channel)
{
unsigned bits = channel & 0x30;
if (reg_type == ni_reg_622x) {
@@ -1140,6 +1153,7 @@ static inline unsigned MSeries_AI_Config_Bank_Bits(enum ni_reg_type reg_type,
}
return bits;
}
+
static inline unsigned MSeries_AI_Config_Gain_Bits(unsigned range)
{
return (range & 0x7) << 9;
@@ -1159,11 +1173,11 @@ enum MSeries_Clock_and_Fout2_Bits {
MSeries_RTSI_10MHz_Bit = 0x80
};
static inline unsigned MSeries_PLL_In_Source_Select_RTSI_Bits(unsigned
- RTSI_channel)
+ RTSI_channel)
{
if (RTSI_channel > 7) {
printk("%s: bug, invalid RTSI_channel=%i\n", __func__,
- RTSI_channel);
+ RTSI_channel);
return 0;
}
if (RTSI_channel == 7)
@@ -1183,18 +1197,18 @@ static inline unsigned MSeries_PLL_Divisor_Bits(unsigned divisor)
{
static const unsigned max_divisor = 0x10;
if (divisor < 1 || divisor > max_divisor) {
- printk("%s: bug, invalid divisor=%i\n", __func__,
- divisor);
+ printk("%s: bug, invalid divisor=%i\n", __func__, divisor);
return 0;
}
return (divisor & 0xf) << 8;
}
+
static inline unsigned MSeries_PLL_Multiplier_Bits(unsigned multiplier)
{
static const unsigned max_multiplier = 0x100;
if (multiplier < 1 || multiplier > max_multiplier) {
printk("%s: bug, invalid multiplier=%i\n", __func__,
- multiplier);
+ multiplier);
return 0;
}
return multiplier & 0xff;
@@ -1217,15 +1231,17 @@ enum MSeries_AI_Config_FIFO_Bypass_Bits {
MSeries_AI_Bypass_Config_FIFO_Bit = 0x80000000
};
static inline unsigned MSeries_AI_Bypass_Cal_Sel_Pos_Bits(int
- calibration_source)
+ calibration_source)
{
return (calibration_source << 7) & MSeries_AI_Bypass_Cal_Sel_Pos_Mask;
}
+
static inline unsigned MSeries_AI_Bypass_Cal_Sel_Neg_Bits(int
- calibration_source)
+ calibration_source)
{
return (calibration_source << 10) & MSeries_AI_Bypass_Cal_Sel_Pos_Mask;
}
+
static inline unsigned MSeries_AI_Bypass_Gain_Bits(int gain)
{
return (gain << 18) & MSeries_AI_Bypass_Gain_Mask;
@@ -1260,15 +1276,16 @@ static inline unsigned MSeries_PFI_Output_Select_Mask(unsigned channel)
{
return 0x1f << (channel % 3) * 5;
};
+
static inline unsigned MSeries_PFI_Output_Select_Bits(unsigned channel,
- unsigned source)
+ unsigned source)
{
return (source & 0x1f) << ((channel % 3) * 5);
};
/* inverse to MSeries_PFI_Output_Select_Bits */
static inline unsigned MSeries_PFI_Output_Select_Source(unsigned channel,
- unsigned bits)
+ unsigned bits)
{
return (bits >> ((channel % 3) * 5)) & 0x1f;
};
@@ -1285,11 +1302,12 @@ static inline unsigned MSeries_PFI_Filter_Select_Mask(unsigned channel)
{
return 0x3 << (channel * 2);
}
+
static inline unsigned MSeries_PFI_Filter_Select_Bits(unsigned channel,
- unsigned filter)
+ unsigned filter)
{
return (filter << (channel *
- 2)) & MSeries_PFI_Filter_Select_Mask(channel);
+ 2)) & MSeries_PFI_Filter_Select_Mask(channel);
}
enum CDIO_DMA_Select_Bits {
diff --git a/drivers/staging/comedi/drivers/ni_tio.c b/drivers/staging/comedi/drivers/ni_tio.c
index 785553d0cc9d..13e5b264ff0d 100644
--- a/drivers/staging/comedi/drivers/ni_tio.c
+++ b/drivers/staging/comedi/drivers/ni_tio.c
@@ -51,7 +51,7 @@ TODO:
#include "ni_tio_internal.h"
static uint64_t ni_tio_clock_period_ps(const struct ni_gpct *counter,
- unsigned generic_clock_source);
+ unsigned generic_clock_source);
static unsigned ni_tio_generic_clock_src_select(const struct ni_gpct *counter);
MODULE_AUTHOR("Comedi <comedi@comedi.org>");
@@ -59,7 +59,8 @@ MODULE_DESCRIPTION("Comedi support for NI general-purpose counters");
MODULE_LICENSE("GPL");
static inline enum Gi_Counting_Mode_Reg_Bits Gi_Alternate_Sync_Bit(enum
- ni_gpct_variant variant)
+ ni_gpct_variant
+ variant)
{
switch (variant) {
case ni_gpct_variant_e_series:
@@ -77,8 +78,10 @@ static inline enum Gi_Counting_Mode_Reg_Bits Gi_Alternate_Sync_Bit(enum
}
return 0;
}
+
static inline enum Gi_Counting_Mode_Reg_Bits Gi_Prescale_X2_Bit(enum
- ni_gpct_variant variant)
+ ni_gpct_variant
+ variant)
{
switch (variant) {
case ni_gpct_variant_e_series:
@@ -96,8 +99,10 @@ static inline enum Gi_Counting_Mode_Reg_Bits Gi_Prescale_X2_Bit(enum
}
return 0;
}
+
static inline enum Gi_Counting_Mode_Reg_Bits Gi_Prescale_X8_Bit(enum
- ni_gpct_variant variant)
+ ni_gpct_variant
+ variant)
{
switch (variant) {
case ni_gpct_variant_e_series:
@@ -115,8 +120,10 @@ static inline enum Gi_Counting_Mode_Reg_Bits Gi_Prescale_X8_Bit(enum
}
return 0;
}
+
static inline enum Gi_Counting_Mode_Reg_Bits Gi_HW_Arm_Select_Mask(enum
- ni_gpct_variant variant)
+ ni_gpct_variant
+ variant)
{
switch (variant) {
case ni_gpct_variant_e_series:
@@ -151,6 +158,7 @@ static inline unsigned NI_660x_RTSI_Clock(unsigned n)
BUG_ON(n > ni_660x_max_rtsi_channel);
return 0xb + n;
}
+
static const unsigned ni_660x_max_source_pin = 7;
static inline unsigned NI_660x_Source_Pin_Clock(unsigned n)
{
@@ -179,6 +187,7 @@ static inline unsigned NI_M_Series_PFI_Clock(unsigned n)
else
return 0xb + n;
}
+
static const unsigned ni_m_series_max_rtsi_channel = 7;
static inline unsigned NI_M_Series_RTSI_Clock(unsigned n)
{
@@ -202,6 +211,7 @@ static inline unsigned NI_660x_Gate_Pin_Gate_Select(unsigned n)
BUG_ON(n > ni_660x_max_gate_pin);
return 0x2 + n;
}
+
static inline unsigned NI_660x_RTSI_Gate_Select(unsigned n)
{
BUG_ON(n > ni_660x_max_rtsi_channel);
@@ -225,6 +235,7 @@ static inline unsigned NI_M_Series_RTSI_Gate_Select(unsigned n)
return 0x1b;
return 0xb + n;
}
+
static inline unsigned NI_M_Series_PFI_Gate_Select(unsigned n)
{
BUG_ON(n > ni_m_series_max_pfi_channel);
@@ -237,6 +248,7 @@ static inline unsigned Gi_Source_Select_Bits(unsigned source)
{
return (source << Gi_Source_Select_Shift) & Gi_Source_Select_Mask;
}
+
static inline unsigned Gi_Gate_Select_Bits(unsigned gate_select)
{
return (gate_select << Gi_Gate_Select_Shift) & Gi_Gate_Select_Mask;
@@ -256,6 +268,7 @@ static inline unsigned NI_660x_Up_Down_Pin_Second_Gate_Select(unsigned n)
BUG_ON(n > ni_660x_max_up_down_pin);
return 0x2 + n;
}
+
static inline unsigned NI_660x_RTSI_Second_Gate_Select(unsigned n)
{
BUG_ON(n > ni_660x_max_rtsi_channel);
@@ -263,7 +276,7 @@ static inline unsigned NI_660x_RTSI_Second_Gate_Select(unsigned n)
}
static const unsigned int counter_status_mask =
- COMEDI_COUNTER_ARMED | COMEDI_COUNTER_COUNTING;
+ COMEDI_COUNTER_ARMED | COMEDI_COUNTER_COUNTING;
static int __init ni_tio_init_module(void)
{
@@ -278,17 +291,26 @@ 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,
- enum ni_gpct_register reg),
- unsigned (*read_register) (struct ni_gpct *counter,
- enum ni_gpct_register reg), enum ni_gpct_variant variant,
- unsigned num_counters)
+struct ni_gpct_device *ni_gpct_device_construct(struct comedi_device *dev,
+ void (*write_register) (struct
+ ni_gpct
+ *
+ counter,
+ unsigned
+ bits,
+ enum
+ ni_gpct_register
+ reg),
+ unsigned (*read_register)
+ (struct ni_gpct * counter,
+ enum ni_gpct_register reg),
+ enum ni_gpct_variant variant,
+ unsigned num_counters)
{
unsigned i;
struct ni_gpct_device *counter_dev =
- kzalloc(sizeof(struct ni_gpct_device), GFP_KERNEL);
+ kzalloc(sizeof(struct ni_gpct_device), GFP_KERNEL);
if (counter_dev == NULL)
return NULL;
counter_dev->dev = dev;
@@ -298,7 +320,7 @@ struct ni_gpct_device *ni_gpct_device_construct(struct comedi_device * dev,
spin_lock_init(&counter_dev->regs_lock);
BUG_ON(num_counters == 0);
counter_dev->counters =
- kzalloc(sizeof(struct ni_gpct) * num_counters, GFP_KERNEL);
+ kzalloc(sizeof(struct ni_gpct) * num_counters, GFP_KERNEL);
if (counter_dev->counters == NULL) {
kfree(counter_dev);
return NULL;
@@ -320,7 +342,7 @@ void ni_gpct_device_destroy(struct ni_gpct_device *counter_dev)
}
static int ni_tio_second_gate_registers_present(const struct ni_gpct_device
- *counter_dev)
+ *counter_dev)
{
switch (counter_dev->variant) {
case ni_gpct_variant_e_series:
@@ -340,7 +362,7 @@ static int ni_tio_second_gate_registers_present(const struct ni_gpct_device
static void ni_tio_reset_count_and_disarm(struct ni_gpct *counter)
{
write_register(counter, Gi_Reset_Bit(counter->counter_index),
- NITIO_Gxx_Joint_Reset_Reg(counter->counter_index));
+ NITIO_Gxx_Joint_Reset_Reg(counter->counter_index));
}
void ni_tio_init_counter(struct ni_gpct *counter)
@@ -350,49 +372,59 @@ void ni_tio_init_counter(struct ni_gpct *counter)
ni_tio_reset_count_and_disarm(counter);
/* initialize counter registers */
counter_dev->regs[NITIO_Gi_Autoincrement_Reg(counter->counter_index)] =
- 0x0;
+ 0x0;
write_register(counter,
- counter_dev->regs[NITIO_Gi_Autoincrement_Reg(counter->
- counter_index)],
- NITIO_Gi_Autoincrement_Reg(counter->counter_index));
+ counter_dev->
+ regs[NITIO_Gi_Autoincrement_Reg(counter->counter_index)],
+ NITIO_Gi_Autoincrement_Reg(counter->counter_index));
ni_tio_set_bits(counter, NITIO_Gi_Command_Reg(counter->counter_index),
- ~0, Gi_Synchronize_Gate_Bit);
+ ~0, Gi_Synchronize_Gate_Bit);
ni_tio_set_bits(counter, NITIO_Gi_Mode_Reg(counter->counter_index), ~0,
- 0);
+ 0);
counter_dev->regs[NITIO_Gi_LoadA_Reg(counter->counter_index)] = 0x0;
write_register(counter,
- counter_dev->regs[NITIO_Gi_LoadA_Reg(counter->counter_index)],
- NITIO_Gi_LoadA_Reg(counter->counter_index));
+ counter_dev->
+ regs[NITIO_Gi_LoadA_Reg(counter->counter_index)],
+ NITIO_Gi_LoadA_Reg(counter->counter_index));
counter_dev->regs[NITIO_Gi_LoadB_Reg(counter->counter_index)] = 0x0;
write_register(counter,
- counter_dev->regs[NITIO_Gi_LoadB_Reg(counter->counter_index)],
- NITIO_Gi_LoadB_Reg(counter->counter_index));
+ counter_dev->
+ regs[NITIO_Gi_LoadB_Reg(counter->counter_index)],
+ NITIO_Gi_LoadB_Reg(counter->counter_index));
ni_tio_set_bits(counter,
- NITIO_Gi_Input_Select_Reg(counter->counter_index), ~0, 0);
+ NITIO_Gi_Input_Select_Reg(counter->counter_index), ~0,
+ 0);
if (ni_tio_counting_mode_registers_present(counter_dev)) {
ni_tio_set_bits(counter,
- NITIO_Gi_Counting_Mode_Reg(counter->counter_index), ~0,
- 0);
+ NITIO_Gi_Counting_Mode_Reg(counter->
+ counter_index), ~0,
+ 0);
}
if (ni_tio_second_gate_registers_present(counter_dev)) {
- counter_dev->regs[NITIO_Gi_Second_Gate_Reg(counter->
- counter_index)] = 0x0;
+ counter_dev->
+ regs[NITIO_Gi_Second_Gate_Reg(counter->counter_index)] =
+ 0x0;
write_register(counter,
- counter_dev->regs[NITIO_Gi_Second_Gate_Reg(counter->
- counter_index)],
- NITIO_Gi_Second_Gate_Reg(counter->counter_index));
+ counter_dev->
+ regs[NITIO_Gi_Second_Gate_Reg
+ (counter->counter_index)],
+ NITIO_Gi_Second_Gate_Reg(counter->
+ counter_index));
}
ni_tio_set_bits(counter,
- NITIO_Gi_DMA_Config_Reg(counter->counter_index), ~0, 0x0);
+ NITIO_Gi_DMA_Config_Reg(counter->counter_index), ~0,
+ 0x0);
ni_tio_set_bits(counter,
- NITIO_Gi_Interrupt_Enable_Reg(counter->counter_index), ~0, 0x0);
+ NITIO_Gi_Interrupt_Enable_Reg(counter->counter_index),
+ ~0, 0x0);
}
static unsigned int ni_tio_counter_status(struct ni_gpct *counter)
{
unsigned int status = 0;
const unsigned bits = read_register(counter,
- NITIO_Gxx_Status_Reg(counter->counter_index));
+ NITIO_Gxx_Status_Reg(counter->
+ counter_index));
if (bits & Gi_Armed_Bit(counter->counter_index)) {
status |= COMEDI_COUNTER_ARMED;
if (bits & Gi_Counting_Bit(counter->counter_index))
@@ -405,16 +437,18 @@ static void ni_tio_set_sync_mode(struct ni_gpct *counter, int force_alt_sync)
{
struct ni_gpct_device *counter_dev = counter->counter_dev;
const unsigned counting_mode_reg =
- NITIO_Gi_Counting_Mode_Reg(counter->counter_index);
+ NITIO_Gi_Counting_Mode_Reg(counter->counter_index);
static const uint64_t min_normal_sync_period_ps = 25000;
const uint64_t clock_period_ps = ni_tio_clock_period_ps(counter,
- ni_tio_generic_clock_src_select(counter));
+ ni_tio_generic_clock_src_select
+ (counter));
if (ni_tio_counting_mode_registers_present(counter_dev) == 0)
return;
switch (ni_tio_get_soft_copy(counter,
- counting_mode_reg) & Gi_Counting_Mode_Mask) {
+ counting_mode_reg) & Gi_Counting_Mode_Mask)
+ {
case Gi_Counting_Mode_QuadratureX1_Bits:
case Gi_Counting_Mode_QuadratureX2_Bits:
case Gi_Counting_Mode_QuadratureX4_Bits:
@@ -428,14 +462,14 @@ static void ni_tio_set_sync_mode(struct ni_gpct *counter, int force_alt_sync)
using the alt sync bit in that case, but allow the caller to decide by using the
force_alt_sync parameter. */
if (force_alt_sync ||
- (clock_period_ps
- && clock_period_ps < min_normal_sync_period_ps)) {
+ (clock_period_ps && clock_period_ps < min_normal_sync_period_ps)) {
ni_tio_set_bits(counter, counting_mode_reg,
- Gi_Alternate_Sync_Bit(counter_dev->variant),
- Gi_Alternate_Sync_Bit(counter_dev->variant));
+ Gi_Alternate_Sync_Bit(counter_dev->variant),
+ Gi_Alternate_Sync_Bit(counter_dev->variant));
} else {
ni_tio_set_bits(counter, counting_mode_reg,
- Gi_Alternate_Sync_Bit(counter_dev->variant), 0x0);
+ Gi_Alternate_Sync_Bit(counter_dev->variant),
+ 0x0);
}
}
@@ -447,10 +481,10 @@ static int ni_tio_set_counter_mode(struct ni_gpct *counter, unsigned mode)
unsigned input_select_bits = 0;
/* these bits map directly on to the mode register */
static const unsigned mode_reg_direct_mask =
- NI_GPCT_GATE_ON_BOTH_EDGES_BIT | NI_GPCT_EDGE_GATE_MODE_MASK |
- NI_GPCT_STOP_MODE_MASK | NI_GPCT_OUTPUT_MODE_MASK |
- NI_GPCT_HARDWARE_DISARM_MASK | NI_GPCT_LOADING_ON_TC_BIT |
- NI_GPCT_LOADING_ON_GATE_BIT | NI_GPCT_LOAD_B_SELECT_BIT;
+ NI_GPCT_GATE_ON_BOTH_EDGES_BIT | NI_GPCT_EDGE_GATE_MODE_MASK |
+ NI_GPCT_STOP_MODE_MASK | NI_GPCT_OUTPUT_MODE_MASK |
+ NI_GPCT_HARDWARE_DISARM_MASK | NI_GPCT_LOADING_ON_TC_BIT |
+ NI_GPCT_LOADING_ON_GATE_BIT | NI_GPCT_LOAD_B_SELECT_BIT;
mode_reg_mask = mode_reg_direct_mask | Gi_Reload_Source_Switching_Bit;
mode_reg_values = mode & mode_reg_direct_mask;
@@ -469,29 +503,31 @@ static int ni_tio_set_counter_mode(struct ni_gpct *counter, unsigned mode)
break;
}
ni_tio_set_bits(counter, NITIO_Gi_Mode_Reg(counter->counter_index),
- mode_reg_mask, mode_reg_values);
+ mode_reg_mask, mode_reg_values);
if (ni_tio_counting_mode_registers_present(counter_dev)) {
unsigned counting_mode_bits = 0;
counting_mode_bits |=
- (mode >> NI_GPCT_COUNTING_MODE_SHIFT) &
- Gi_Counting_Mode_Mask;
+ (mode >> NI_GPCT_COUNTING_MODE_SHIFT) &
+ Gi_Counting_Mode_Mask;
counting_mode_bits |=
- ((mode >> NI_GPCT_INDEX_PHASE_BITSHIFT) <<
- Gi_Index_Phase_Bitshift) & Gi_Index_Phase_Mask;
+ ((mode >> NI_GPCT_INDEX_PHASE_BITSHIFT) <<
+ Gi_Index_Phase_Bitshift) & Gi_Index_Phase_Mask;
if (mode & NI_GPCT_INDEX_ENABLE_BIT) {
counting_mode_bits |= Gi_Index_Mode_Bit;
}
ni_tio_set_bits(counter,
- NITIO_Gi_Counting_Mode_Reg(counter->counter_index),
- Gi_Counting_Mode_Mask | Gi_Index_Phase_Mask |
- Gi_Index_Mode_Bit, counting_mode_bits);
+ NITIO_Gi_Counting_Mode_Reg(counter->
+ counter_index),
+ Gi_Counting_Mode_Mask | Gi_Index_Phase_Mask |
+ Gi_Index_Mode_Bit, counting_mode_bits);
ni_tio_set_sync_mode(counter, 0);
}
ni_tio_set_bits(counter, NITIO_Gi_Command_Reg(counter->counter_index),
- Gi_Up_Down_Mask,
- (mode >> NI_GPCT_COUNTING_DIRECTION_SHIFT) << Gi_Up_Down_Shift);
+ Gi_Up_Down_Mask,
+ (mode >> NI_GPCT_COUNTING_DIRECTION_SHIFT) <<
+ Gi_Up_Down_Shift);
if (mode & NI_GPCT_OR_GATE_BIT) {
input_select_bits |= Gi_Or_Gate_Bit;
@@ -500,9 +536,9 @@ static int ni_tio_set_counter_mode(struct ni_gpct *counter, unsigned mode)
input_select_bits |= Gi_Output_Polarity_Bit;
}
ni_tio_set_bits(counter,
- NITIO_Gi_Input_Select_Reg(counter->counter_index),
- Gi_Gate_Select_Load_Source_Bit | Gi_Or_Gate_Bit |
- Gi_Output_Polarity_Bit, input_select_bits);
+ NITIO_Gi_Input_Select_Reg(counter->counter_index),
+ Gi_Gate_Select_Load_Source_Bit | Gi_Or_Gate_Bit |
+ Gi_Output_Polarity_Bit, input_select_bits);
return 0;
}
@@ -535,32 +571,33 @@ int ni_tio_arm(struct ni_gpct *counter, int arm, unsigned start_trigger)
if (start_trigger & NI_GPCT_ARM_UNKNOWN) {
/* pass-through the least significant bits so we can figure out what select later */
unsigned hw_arm_select_bits =
- (start_trigger <<
- Gi_HW_Arm_Select_Shift) &
- Gi_HW_Arm_Select_Mask
- (counter_dev->variant);
+ (start_trigger <<
+ Gi_HW_Arm_Select_Shift) &
+ Gi_HW_Arm_Select_Mask
+ (counter_dev->variant);
counting_mode_bits |=
- Gi_HW_Arm_Enable_Bit |
- hw_arm_select_bits;
+ Gi_HW_Arm_Enable_Bit |
+ hw_arm_select_bits;
} else {
return -EINVAL;
}
break;
}
ni_tio_set_bits(counter,
- NITIO_Gi_Counting_Mode_Reg(counter->
- counter_index),
- Gi_HW_Arm_Select_Mask(counter_dev->
- variant) | Gi_HW_Arm_Enable_Bit,
- counting_mode_bits);
+ NITIO_Gi_Counting_Mode_Reg
+ (counter->counter_index),
+ Gi_HW_Arm_Select_Mask
+ (counter_dev->variant) |
+ Gi_HW_Arm_Enable_Bit,
+ counting_mode_bits);
}
} else {
command_transient_bits |= Gi_Disarm_Bit;
}
ni_tio_set_bits_transient(counter,
- NITIO_Gi_Command_Reg(counter->counter_index), 0, 0,
- command_transient_bits);
+ NITIO_Gi_Command_Reg(counter->counter_index),
+ 0, 0, command_transient_bits);
return 0;
}
@@ -569,7 +606,7 @@ static unsigned ni_660x_source_select_bits(unsigned int clock_source)
unsigned ni_660x_clock;
unsigned i;
const unsigned clock_select_bits =
- clock_source & NI_GPCT_CLOCK_SRC_SELECT_MASK;
+ clock_source & NI_GPCT_CLOCK_SRC_SELECT_MASK;
switch (clock_select_bits) {
case NI_GPCT_TIMEBASE_1_CLOCK_SRC_BITS:
@@ -604,7 +641,7 @@ static unsigned ni_660x_source_select_bits(unsigned int clock_source)
break;
for (i = 0; i <= ni_660x_max_source_pin; ++i) {
if (clock_select_bits ==
- NI_GPCT_SOURCE_PIN_CLOCK_SRC_BITS(i)) {
+ NI_GPCT_SOURCE_PIN_CLOCK_SRC_BITS(i)) {
ni_660x_clock = NI_660x_Source_Pin_Clock(i);
break;
}
@@ -623,7 +660,7 @@ static unsigned ni_m_series_source_select_bits(unsigned int clock_source)
unsigned ni_m_series_clock;
unsigned i;
const unsigned clock_select_bits =
- clock_source & NI_GPCT_CLOCK_SRC_SELECT_MASK;
+ clock_source & NI_GPCT_CLOCK_SRC_SELECT_MASK;
switch (clock_select_bits) {
case NI_GPCT_TIMEBASE_1_CLOCK_SRC_BITS:
ni_m_series_clock = NI_M_Series_Timebase_1_Clock;
@@ -670,7 +707,7 @@ static unsigned ni_m_series_source_select_bits(unsigned int clock_source)
if (i <= ni_m_series_max_pfi_channel)
break;
printk("invalid clock source 0x%lx\n",
- (unsigned long)clock_source);
+ (unsigned long)clock_source);
BUG();
ni_m_series_clock = 0;
break;
@@ -679,11 +716,11 @@ static unsigned ni_m_series_source_select_bits(unsigned int clock_source)
};
static void ni_tio_set_source_subselect(struct ni_gpct *counter,
- unsigned int clock_source)
+ unsigned int clock_source)
{
struct ni_gpct_device *counter_dev = counter->counter_dev;
const unsigned second_gate_reg =
- NITIO_Gi_Second_Gate_Reg(counter->counter_index);
+ NITIO_Gi_Second_Gate_Reg(counter->counter_index);
if (counter_dev->variant != ni_gpct_variant_m_series)
return;
@@ -704,11 +741,12 @@ static void ni_tio_set_source_subselect(struct ni_gpct *counter,
break;
}
write_register(counter, counter_dev->regs[second_gate_reg],
- second_gate_reg);
+ second_gate_reg);
}
static int ni_tio_set_clock_src(struct ni_gpct *counter,
- unsigned int clock_source, unsigned int period_ns)
+ unsigned int clock_source,
+ unsigned int period_ns)
{
struct ni_gpct_device *counter_dev = counter->counter_dev;
unsigned input_select_bits = 0;
@@ -722,7 +760,7 @@ static int ni_tio_set_clock_src(struct ni_gpct *counter,
case ni_gpct_variant_e_series:
case ni_gpct_variant_m_series:
input_select_bits |=
- ni_m_series_source_select_bits(clock_source);
+ ni_m_series_source_select_bits(clock_source);
break;
default:
BUG();
@@ -731,13 +769,13 @@ static int ni_tio_set_clock_src(struct ni_gpct *counter,
if (clock_source & NI_GPCT_INVERT_CLOCK_SRC_BIT)
input_select_bits |= Gi_Source_Polarity_Bit;
ni_tio_set_bits(counter,
- NITIO_Gi_Input_Select_Reg(counter->counter_index),
- Gi_Source_Select_Mask | Gi_Source_Polarity_Bit,
- input_select_bits);
+ NITIO_Gi_Input_Select_Reg(counter->counter_index),
+ Gi_Source_Select_Mask | Gi_Source_Polarity_Bit,
+ input_select_bits);
ni_tio_set_source_subselect(counter, clock_source);
if (ni_tio_counting_mode_registers_present(counter_dev)) {
const unsigned prescaling_mode =
- clock_source & NI_GPCT_PRESCALE_MODE_CLOCK_SRC_MASK;
+ clock_source & NI_GPCT_PRESCALE_MODE_CLOCK_SRC_MASK;
unsigned counting_mode_bits = 0;
switch (prescaling_mode) {
@@ -745,21 +783,22 @@ static int ni_tio_set_clock_src(struct ni_gpct *counter,
break;
case NI_GPCT_PRESCALE_X2_CLOCK_SRC_BITS:
counting_mode_bits |=
- Gi_Prescale_X2_Bit(counter_dev->variant);
+ Gi_Prescale_X2_Bit(counter_dev->variant);
break;
case NI_GPCT_PRESCALE_X8_CLOCK_SRC_BITS:
counting_mode_bits |=
- Gi_Prescale_X8_Bit(counter_dev->variant);
+ Gi_Prescale_X8_Bit(counter_dev->variant);
break;
default:
return -EINVAL;
break;
}
ni_tio_set_bits(counter,
- NITIO_Gi_Counting_Mode_Reg(counter->counter_index),
- Gi_Prescale_X2_Bit(counter_dev->
- variant) | Gi_Prescale_X8_Bit(counter_dev->
- variant), counting_mode_bits);
+ NITIO_Gi_Counting_Mode_Reg(counter->
+ counter_index),
+ Gi_Prescale_X2_Bit(counter_dev->variant) |
+ Gi_Prescale_X8_Bit(counter_dev->variant),
+ counting_mode_bits);
}
counter->clock_period_ps = pico_per_nano * period_ns;
ni_tio_set_sync_mode(counter, 0);
@@ -770,12 +809,15 @@ static unsigned ni_tio_clock_src_modifiers(const struct ni_gpct *counter)
{
struct ni_gpct_device *counter_dev = counter->counter_dev;
const unsigned counting_mode_bits = ni_tio_get_soft_copy(counter,
- NITIO_Gi_Counting_Mode_Reg(counter->counter_index));
+ NITIO_Gi_Counting_Mode_Reg
+ (counter->
+ counter_index));
unsigned bits = 0;
if (ni_tio_get_soft_copy(counter,
- NITIO_Gi_Input_Select_Reg(counter->
- counter_index)) & Gi_Source_Polarity_Bit)
+ NITIO_Gi_Input_Select_Reg
+ (counter->counter_index)) &
+ Gi_Source_Polarity_Bit)
bits |= NI_GPCT_INVERT_CLOCK_SRC_BIT;
if (counting_mode_bits & Gi_Prescale_X2_Bit(counter_dev->variant))
bits |= NI_GPCT_PRESCALE_X2_CLOCK_SRC_BITS;
@@ -788,13 +830,14 @@ static unsigned ni_m_series_clock_src_select(const struct ni_gpct *counter)
{
struct ni_gpct_device *counter_dev = counter->counter_dev;
const unsigned second_gate_reg =
- NITIO_Gi_Second_Gate_Reg(counter->counter_index);
+ NITIO_Gi_Second_Gate_Reg(counter->counter_index);
unsigned clock_source = 0;
unsigned i;
const unsigned input_select = (ni_tio_get_soft_copy(counter,
- NITIO_Gi_Input_Select_Reg(counter->
- counter_index)) & Gi_Source_Select_Mask) >>
- Gi_Source_Select_Shift;
+ NITIO_Gi_Input_Select_Reg
+ (counter->counter_index))
+ & Gi_Source_Select_Mask) >>
+ Gi_Source_Select_Shift;
switch (input_select) {
case NI_M_Series_Timebase_1_Clock:
@@ -804,10 +847,10 @@ static unsigned ni_m_series_clock_src_select(const struct ni_gpct *counter)
clock_source = NI_GPCT_TIMEBASE_2_CLOCK_SRC_BITS;
break;
case NI_M_Series_Timebase_3_Clock:
- if (counter_dev->
- regs[second_gate_reg] & Gi_Source_Subselect_Bit)
+ if (counter_dev->regs[second_gate_reg] &
+ Gi_Source_Subselect_Bit)
clock_source =
- NI_GPCT_ANALOG_TRIGGER_OUT_CLOCK_SRC_BITS;
+ NI_GPCT_ANALOG_TRIGGER_OUT_CLOCK_SRC_BITS;
else
clock_source = NI_GPCT_TIMEBASE_3_CLOCK_SRC_BITS;
break;
@@ -815,8 +858,8 @@ static unsigned ni_m_series_clock_src_select(const struct ni_gpct *counter)
clock_source = NI_GPCT_LOGIC_LOW_CLOCK_SRC_BITS;
break;
case NI_M_Series_Next_Gate_Clock:
- if (counter_dev->
- regs[second_gate_reg] & Gi_Source_Subselect_Bit)
+ if (counter_dev->regs[second_gate_reg] &
+ Gi_Source_Subselect_Bit)
clock_source = NI_GPCT_PXI_STAR_TRIGGER_CLOCK_SRC_BITS;
else
clock_source = NI_GPCT_NEXT_GATE_CLOCK_SRC_BITS;
@@ -856,9 +899,10 @@ static unsigned ni_660x_clock_src_select(const struct ni_gpct *counter)
unsigned clock_source = 0;
unsigned i;
const unsigned input_select = (ni_tio_get_soft_copy(counter,
- NITIO_Gi_Input_Select_Reg(counter->
- counter_index)) & Gi_Source_Select_Mask) >>
- Gi_Source_Select_Shift;
+ NITIO_Gi_Input_Select_Reg
+ (counter->counter_index))
+ & Gi_Source_Select_Mask) >>
+ Gi_Source_Select_Shift;
switch (input_select) {
case NI_660x_Timebase_1_Clock:
@@ -894,7 +938,7 @@ static unsigned ni_660x_clock_src_select(const struct ni_gpct *counter)
for (i = 0; i <= ni_660x_max_source_pin; ++i) {
if (input_select == NI_660x_Source_Pin_Clock(i)) {
clock_source =
- NI_GPCT_SOURCE_PIN_CLOCK_SRC_BITS(i);
+ NI_GPCT_SOURCE_PIN_CLOCK_SRC_BITS(i);
break;
}
}
@@ -925,7 +969,7 @@ static unsigned ni_tio_generic_clock_src_select(const struct ni_gpct *counter)
}
static uint64_t ni_tio_clock_period_ps(const struct ni_gpct *counter,
- unsigned generic_clock_source)
+ unsigned generic_clock_source)
{
uint64_t clock_period_ps;
@@ -965,7 +1009,8 @@ 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;
@@ -976,7 +1021,7 @@ static void ni_tio_get_clock_src(struct ni_gpct *counter,
}
static void ni_tio_set_first_gate_modifiers(struct ni_gpct *counter,
- unsigned int gate_source)
+ unsigned int gate_source)
{
const unsigned mode_mask = Gi_Gate_Polarity_Bit | Gi_Gating_Mode_Mask;
unsigned mode_values = 0;
@@ -990,10 +1035,11 @@ static void ni_tio_set_first_gate_modifiers(struct ni_gpct *counter,
mode_values |= Gi_Level_Gating_Bits;
}
ni_tio_set_bits(counter, NITIO_Gi_Mode_Reg(counter->counter_index),
- mode_mask, mode_values);
+ mode_mask, mode_values);
}
-static int ni_660x_set_first_gate(struct ni_gpct *counter, unsigned int gate_source)
+static int ni_660x_set_first_gate(struct ni_gpct *counter,
+ unsigned int gate_source)
{
const unsigned selected_gate = CR_CHAN(gate_source);
/* bits of selected_gate that may be meaningful to input select register */
@@ -1015,7 +1061,7 @@ static int ni_660x_set_first_gate(struct ni_gpct *counter, unsigned int gate_sou
for (i = 0; i <= ni_660x_max_rtsi_channel; ++i) {
if (selected_gate == NI_GPCT_RTSI_GATE_SELECT(i)) {
ni_660x_gate_select =
- selected_gate & selected_gate_mask;
+ selected_gate & selected_gate_mask;
break;
}
}
@@ -1024,7 +1070,7 @@ static int ni_660x_set_first_gate(struct ni_gpct *counter, unsigned int gate_sou
for (i = 0; i <= ni_660x_max_gate_pin; ++i) {
if (selected_gate == NI_GPCT_GATE_PIN_GATE_SELECT(i)) {
ni_660x_gate_select =
- selected_gate & selected_gate_mask;
+ selected_gate & selected_gate_mask;
break;
}
}
@@ -1034,13 +1080,14 @@ static int ni_660x_set_first_gate(struct ni_gpct *counter, unsigned int gate_sou
break;
}
ni_tio_set_bits(counter,
- NITIO_Gi_Input_Select_Reg(counter->counter_index),
- Gi_Gate_Select_Mask, Gi_Gate_Select_Bits(ni_660x_gate_select));
+ NITIO_Gi_Input_Select_Reg(counter->counter_index),
+ Gi_Gate_Select_Mask,
+ Gi_Gate_Select_Bits(ni_660x_gate_select));
return 0;
}
static int ni_m_series_set_first_gate(struct ni_gpct *counter,
- unsigned int gate_source)
+ unsigned int gate_source)
{
const unsigned selected_gate = CR_CHAN(gate_source);
/* bits of selected_gate that may be meaningful to input select register */
@@ -1063,7 +1110,7 @@ static int ni_m_series_set_first_gate(struct ni_gpct *counter,
for (i = 0; i <= ni_m_series_max_rtsi_channel; ++i) {
if (selected_gate == NI_GPCT_RTSI_GATE_SELECT(i)) {
ni_m_series_gate_select =
- selected_gate & selected_gate_mask;
+ selected_gate & selected_gate_mask;
break;
}
}
@@ -1072,7 +1119,7 @@ static int ni_m_series_set_first_gate(struct ni_gpct *counter,
for (i = 0; i <= ni_m_series_max_pfi_channel; ++i) {
if (selected_gate == NI_GPCT_PFI_GATE_SELECT(i)) {
ni_m_series_gate_select =
- selected_gate & selected_gate_mask;
+ selected_gate & selected_gate_mask;
break;
}
}
@@ -1082,18 +1129,18 @@ static int ni_m_series_set_first_gate(struct ni_gpct *counter,
break;
}
ni_tio_set_bits(counter,
- NITIO_Gi_Input_Select_Reg(counter->counter_index),
- Gi_Gate_Select_Mask,
- Gi_Gate_Select_Bits(ni_m_series_gate_select));
+ NITIO_Gi_Input_Select_Reg(counter->counter_index),
+ Gi_Gate_Select_Mask,
+ Gi_Gate_Select_Bits(ni_m_series_gate_select));
return 0;
}
static int ni_660x_set_second_gate(struct ni_gpct *counter,
- unsigned int gate_source)
+ unsigned int gate_source)
{
struct ni_gpct_device *counter_dev = counter->counter_dev;
const unsigned second_gate_reg =
- NITIO_Gi_Second_Gate_Reg(counter->counter_index);
+ NITIO_Gi_Second_Gate_Reg(counter->counter_index);
const unsigned selected_second_gate = CR_CHAN(gate_source);
/* bits of second_gate that may be meaningful to second gate register */
static const unsigned selected_second_gate_mask = 0x1f;
@@ -1107,18 +1154,18 @@ static int ni_660x_set_second_gate(struct ni_gpct *counter,
case NI_GPCT_NEXT_OUT_GATE_SELECT:
case NI_GPCT_LOGIC_LOW_GATE_SELECT:
ni_660x_second_gate_select =
- selected_second_gate & selected_second_gate_mask;
+ selected_second_gate & selected_second_gate_mask;
break;
case NI_GPCT_NEXT_SOURCE_GATE_SELECT:
ni_660x_second_gate_select =
- NI_660x_Next_SRC_Second_Gate_Select;
+ NI_660x_Next_SRC_Second_Gate_Select;
break;
default:
for (i = 0; i <= ni_660x_max_rtsi_channel; ++i) {
if (selected_second_gate == NI_GPCT_RTSI_GATE_SELECT(i)) {
ni_660x_second_gate_select =
- selected_second_gate &
- selected_second_gate_mask;
+ selected_second_gate &
+ selected_second_gate_mask;
break;
}
}
@@ -1126,10 +1173,10 @@ static int ni_660x_set_second_gate(struct ni_gpct *counter,
break;
for (i = 0; i <= ni_660x_max_up_down_pin; ++i) {
if (selected_second_gate ==
- NI_GPCT_UP_DOWN_PIN_GATE_SELECT(i)) {
+ NI_GPCT_UP_DOWN_PIN_GATE_SELECT(i)) {
ni_660x_second_gate_select =
- selected_second_gate &
- selected_second_gate_mask;
+ selected_second_gate &
+ selected_second_gate_mask;
break;
}
}
@@ -1141,18 +1188,18 @@ static int ni_660x_set_second_gate(struct ni_gpct *counter,
counter_dev->regs[second_gate_reg] |= Gi_Second_Gate_Mode_Bit;
counter_dev->regs[second_gate_reg] &= ~Gi_Second_Gate_Select_Mask;
counter_dev->regs[second_gate_reg] |=
- Gi_Second_Gate_Select_Bits(ni_660x_second_gate_select);
+ Gi_Second_Gate_Select_Bits(ni_660x_second_gate_select);
write_register(counter, counter_dev->regs[second_gate_reg],
- second_gate_reg);
+ second_gate_reg);
return 0;
}
static int ni_m_series_set_second_gate(struct ni_gpct *counter,
- unsigned int gate_source)
+ unsigned int gate_source)
{
struct ni_gpct_device *counter_dev = counter->counter_dev;
const unsigned second_gate_reg =
- NITIO_Gi_Second_Gate_Reg(counter->counter_index);
+ NITIO_Gi_Second_Gate_Reg(counter->counter_index);
const unsigned selected_second_gate = CR_CHAN(gate_source);
/* bits of second_gate that may be meaningful to second gate register */
static const unsigned selected_second_gate_mask = 0x1f;
@@ -1163,31 +1210,33 @@ static int ni_m_series_set_second_gate(struct ni_gpct *counter,
switch (selected_second_gate) {
default:
ni_m_series_second_gate_select =
- selected_second_gate & selected_second_gate_mask;
+ selected_second_gate & selected_second_gate_mask;
break;
};
counter_dev->regs[second_gate_reg] |= Gi_Second_Gate_Mode_Bit;
counter_dev->regs[second_gate_reg] &= ~Gi_Second_Gate_Select_Mask;
counter_dev->regs[second_gate_reg] |=
- Gi_Second_Gate_Select_Bits(ni_m_series_second_gate_select);
+ Gi_Second_Gate_Select_Bits(ni_m_series_second_gate_select);
write_register(counter, counter_dev->regs[second_gate_reg],
- second_gate_reg);
+ second_gate_reg);
return 0;
}
int ni_tio_set_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 second_gate_reg =
- NITIO_Gi_Second_Gate_Reg(counter->counter_index);
+ NITIO_Gi_Second_Gate_Reg(counter->counter_index);
switch (gate_index) {
case 0:
if (CR_CHAN(gate_source) == NI_GPCT_DISABLED_GATE_SELECT) {
ni_tio_set_bits(counter,
- NITIO_Gi_Mode_Reg(counter->counter_index),
- Gi_Gating_Mode_Mask, Gi_Gating_Disabled_Bits);
+ NITIO_Gi_Mode_Reg(counter->
+ counter_index),
+ Gi_Gating_Mode_Mask,
+ Gi_Gating_Disabled_Bits);
return 0;
}
ni_tio_set_first_gate_modifiers(counter, gate_source);
@@ -1209,23 +1258,23 @@ int ni_tio_set_gate_src(struct ni_gpct *counter, unsigned gate_index,
return -EINVAL;
if (CR_CHAN(gate_source) == NI_GPCT_DISABLED_GATE_SELECT) {
counter_dev->regs[second_gate_reg] &=
- ~Gi_Second_Gate_Mode_Bit;
+ ~Gi_Second_Gate_Mode_Bit;
write_register(counter,
- counter_dev->regs[second_gate_reg],
- second_gate_reg);
+ counter_dev->regs[second_gate_reg],
+ second_gate_reg);
return 0;
}
if (gate_source & CR_INVERT) {
counter_dev->regs[second_gate_reg] |=
- Gi_Second_Gate_Polarity_Bit;
+ Gi_Second_Gate_Polarity_Bit;
} else {
counter_dev->regs[second_gate_reg] &=
- ~Gi_Second_Gate_Polarity_Bit;
+ ~Gi_Second_Gate_Polarity_Bit;
}
switch (counter_dev->variant) {
case ni_gpct_variant_m_series:
return ni_m_series_set_second_gate(counter,
- gate_source);
+ gate_source);
break;
case ni_gpct_variant_660x:
return ni_660x_set_second_gate(counter, gate_source);
@@ -1243,7 +1292,7 @@ int ni_tio_set_gate_src(struct ni_gpct *counter, unsigned gate_index,
}
static int ni_tio_set_other_src(struct ni_gpct *counter, unsigned index,
- unsigned int source)
+ unsigned int source)
{
struct ni_gpct_device *counter_dev = counter->counter_dev;
@@ -1280,7 +1329,7 @@ static int ni_tio_set_other_src(struct ni_gpct *counter, unsigned index,
}
static unsigned ni_660x_first_gate_to_generic_gate_source(unsigned
- ni_660x_gate_select)
+ ni_660x_gate_select)
{
unsigned i;
@@ -1311,7 +1360,7 @@ static unsigned ni_660x_first_gate_to_generic_gate_source(unsigned
break;
for (i = 0; i <= ni_660x_max_gate_pin; ++i) {
if (ni_660x_gate_select ==
- NI_660x_Gate_Pin_Gate_Select(i)) {
+ NI_660x_Gate_Pin_Gate_Select(i)) {
return NI_GPCT_GATE_PIN_GATE_SELECT(i);
break;
}
@@ -1325,7 +1374,7 @@ static unsigned ni_660x_first_gate_to_generic_gate_source(unsigned
};
static unsigned ni_m_series_first_gate_to_generic_gate_source(unsigned
- ni_m_series_gate_select)
+ ni_m_series_gate_select)
{
unsigned i;
@@ -1357,7 +1406,7 @@ static unsigned ni_m_series_first_gate_to_generic_gate_source(unsigned
default:
for (i = 0; i <= ni_m_series_max_rtsi_channel; ++i) {
if (ni_m_series_gate_select ==
- NI_M_Series_RTSI_Gate_Select(i)) {
+ NI_M_Series_RTSI_Gate_Select(i)) {
return NI_GPCT_RTSI_GATE_SELECT(i);
break;
}
@@ -1366,7 +1415,7 @@ static unsigned ni_m_series_first_gate_to_generic_gate_source(unsigned
break;
for (i = 0; i <= ni_m_series_max_pfi_channel; ++i) {
if (ni_m_series_gate_select ==
- NI_M_Series_PFI_Gate_Select(i)) {
+ NI_M_Series_PFI_Gate_Select(i)) {
return NI_GPCT_PFI_GATE_SELECT(i);
break;
}
@@ -1380,7 +1429,7 @@ static unsigned ni_m_series_first_gate_to_generic_gate_source(unsigned
};
static unsigned ni_660x_second_gate_to_generic_gate_source(unsigned
- ni_660x_gate_select)
+ ni_660x_gate_select)
{
unsigned i;
@@ -1406,7 +1455,7 @@ static unsigned ni_660x_second_gate_to_generic_gate_source(unsigned
default:
for (i = 0; i <= ni_660x_max_rtsi_channel; ++i) {
if (ni_660x_gate_select ==
- NI_660x_RTSI_Second_Gate_Select(i)) {
+ NI_660x_RTSI_Second_Gate_Select(i)) {
return NI_GPCT_RTSI_GATE_SELECT(i);
break;
}
@@ -1415,7 +1464,7 @@ static unsigned ni_660x_second_gate_to_generic_gate_source(unsigned
break;
for (i = 0; i <= ni_660x_max_up_down_pin; ++i) {
if (ni_660x_gate_select ==
- NI_660x_Up_Down_Pin_Second_Gate_Select(i)) {
+ NI_660x_Up_Down_Pin_Second_Gate_Select(i)) {
return NI_GPCT_UP_DOWN_PIN_GATE_SELECT(i);
break;
}
@@ -1429,7 +1478,7 @@ static unsigned ni_660x_second_gate_to_generic_gate_source(unsigned
};
static unsigned ni_m_series_second_gate_to_generic_gate_source(unsigned
- ni_m_series_gate_select)
+ ni_m_series_gate_select)
{
/*FIXME: the second gate sources for the m series are undocumented, so we just return
* the raw bits for now. */
@@ -1442,39 +1491,41 @@ 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,
- NITIO_Gi_Mode_Reg(counter->counter_index));
+ NITIO_Gi_Mode_Reg
+ (counter->
+ counter_index));
const unsigned second_gate_reg =
- NITIO_Gi_Second_Gate_Reg(counter->counter_index);
+ NITIO_Gi_Second_Gate_Reg(counter->counter_index);
unsigned gate_select_bits;
switch (gate_index) {
case 0:
if ((mode_bits & Gi_Gating_Mode_Mask) ==
- Gi_Gating_Disabled_Bits) {
+ Gi_Gating_Disabled_Bits) {
*gate_source = NI_GPCT_DISABLED_GATE_SELECT;
return 0;
} else {
gate_select_bits =
- (ni_tio_get_soft_copy(counter,
- NITIO_Gi_Input_Select_Reg(counter->
- counter_index)) &
- Gi_Gate_Select_Mask) >> Gi_Gate_Select_Shift;
+ (ni_tio_get_soft_copy(counter,
+ NITIO_Gi_Input_Select_Reg
+ (counter->counter_index)) &
+ Gi_Gate_Select_Mask) >> Gi_Gate_Select_Shift;
}
switch (counter_dev->variant) {
case ni_gpct_variant_e_series:
case ni_gpct_variant_m_series:
*gate_source =
- ni_m_series_first_gate_to_generic_gate_source
- (gate_select_bits);
+ ni_m_series_first_gate_to_generic_gate_source
+ (gate_select_bits);
break;
case ni_gpct_variant_660x:
*gate_source =
- ni_660x_first_gate_to_generic_gate_source
- (gate_select_bits);
+ ni_660x_first_gate_to_generic_gate_source
+ (gate_select_bits);
break;
default:
BUG();
@@ -1489,36 +1540,35 @@ static int ni_tio_get_gate_src(struct ni_gpct *counter, unsigned gate_index,
break;
case 1:
if ((mode_bits & Gi_Gating_Mode_Mask) == Gi_Gating_Disabled_Bits
- || (counter_dev->
- regs[second_gate_reg] & Gi_Second_Gate_Mode_Bit)
- == 0) {
+ || (counter_dev->regs[second_gate_reg] &
+ Gi_Second_Gate_Mode_Bit)
+ == 0) {
*gate_source = NI_GPCT_DISABLED_GATE_SELECT;
return 0;
} else {
gate_select_bits =
- (counter_dev->
- regs[second_gate_reg] &
- Gi_Second_Gate_Select_Mask) >>
- Gi_Second_Gate_Select_Shift;
+ (counter_dev->regs[second_gate_reg] &
+ Gi_Second_Gate_Select_Mask) >>
+ Gi_Second_Gate_Select_Shift;
}
switch (counter_dev->variant) {
case ni_gpct_variant_e_series:
case ni_gpct_variant_m_series:
*gate_source =
- ni_m_series_second_gate_to_generic_gate_source
- (gate_select_bits);
+ ni_m_series_second_gate_to_generic_gate_source
+ (gate_select_bits);
break;
case ni_gpct_variant_660x:
*gate_source =
- ni_660x_second_gate_to_generic_gate_source
- (gate_select_bits);
+ ni_660x_second_gate_to_generic_gate_source
+ (gate_select_bits);
break;
default:
BUG();
break;
}
- if (counter_dev->
- regs[second_gate_reg] & Gi_Second_Gate_Polarity_Bit) {
+ if (counter_dev->regs[second_gate_reg] &
+ Gi_Second_Gate_Polarity_Bit) {
*gate_source |= CR_INVERT;
}
/* second gate can't have edge/level mode set independently */
@@ -1534,7 +1584,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:
@@ -1578,7 +1628,8 @@ int ni_tio_insn_config(struct ni_gpct *counter,
return -EINVAL;
}
-int ni_tio_rinsn(struct ni_gpct *counter, struct comedi_insn * insn, unsigned int * data)
+int ni_tio_rinsn(struct ni_gpct *counter, struct comedi_insn *insn,
+ unsigned int *data)
{
struct ni_gpct_device *counter_dev = counter->counter_dev;
const unsigned channel = CR_CHAN(insn->chanspec);
@@ -1591,26 +1642,27 @@ int ni_tio_rinsn(struct ni_gpct *counter, struct comedi_insn * insn, unsigned in
switch (channel) {
case 0:
ni_tio_set_bits(counter,
- NITIO_Gi_Command_Reg(counter->counter_index),
- Gi_Save_Trace_Bit, 0);
+ NITIO_Gi_Command_Reg(counter->counter_index),
+ Gi_Save_Trace_Bit, 0);
ni_tio_set_bits(counter,
- NITIO_Gi_Command_Reg(counter->counter_index),
- Gi_Save_Trace_Bit, Gi_Save_Trace_Bit);
+ NITIO_Gi_Command_Reg(counter->counter_index),
+ Gi_Save_Trace_Bit, Gi_Save_Trace_Bit);
/* The count doesn't get latched until the next clock edge, so it is possible the count
may change (once) while we are reading. Since the read of the SW_Save_Reg isn't
atomic (apparently even when it's a 32 bit register according to 660x docs),
we need to read twice and make sure the reading hasn't changed. If it has,
a third read will be correct since the count value will definitely have latched by then. */
first_read =
- read_register(counter,
- NITIO_Gi_SW_Save_Reg(counter->counter_index));
+ read_register(counter,
+ NITIO_Gi_SW_Save_Reg(counter->counter_index));
second_read =
- read_register(counter,
- NITIO_Gi_SW_Save_Reg(counter->counter_index));
+ read_register(counter,
+ NITIO_Gi_SW_Save_Reg(counter->counter_index));
if (first_read != second_read)
correct_read =
- read_register(counter,
- NITIO_Gi_SW_Save_Reg(counter->counter_index));
+ read_register(counter,
+ NITIO_Gi_SW_Save_Reg(counter->
+ counter_index));
else
correct_read = first_read;
data[0] = correct_read;
@@ -1618,13 +1670,13 @@ int ni_tio_rinsn(struct ni_gpct *counter, struct comedi_insn * insn, unsigned in
break;
case 1:
data[0] =
- counter_dev->regs[NITIO_Gi_LoadA_Reg(counter->
- counter_index)];
+ counter_dev->
+ regs[NITIO_Gi_LoadA_Reg(counter->counter_index)];
break;
case 2:
data[0] =
- counter_dev->regs[NITIO_Gi_LoadB_Reg(counter->
- counter_index)];
+ counter_dev->
+ regs[NITIO_Gi_LoadB_Reg(counter->counter_index)];
break;
};
return 0;
@@ -1633,7 +1685,8 @@ int ni_tio_rinsn(struct ni_gpct *counter, struct comedi_insn * insn, unsigned in
static unsigned ni_tio_next_load_register(struct ni_gpct *counter)
{
const unsigned bits = read_register(counter,
- NITIO_Gxx_Status_Reg(counter->counter_index));
+ NITIO_Gxx_Status_Reg(counter->
+ counter_index));
if (bits & Gi_Next_Load_Source_Bit(counter->counter_index)) {
return NITIO_Gi_LoadB_Reg(counter->counter_index);
@@ -1642,7 +1695,8 @@ static unsigned ni_tio_next_load_register(struct ni_gpct *counter)
}
}
-int ni_tio_winsn(struct ni_gpct *counter, struct comedi_insn * insn, unsigned int * data)
+int ni_tio_winsn(struct ni_gpct *counter, struct comedi_insn *insn,
+ unsigned int *data)
{
struct ni_gpct_device *counter_dev = counter->counter_dev;
const unsigned channel = CR_CHAN(insn->chanspec);
@@ -1657,22 +1711,23 @@ int ni_tio_winsn(struct ni_gpct *counter, struct comedi_insn * insn, unsigned in
load_reg = ni_tio_next_load_register(counter);
write_register(counter, data[0], load_reg);
ni_tio_set_bits_transient(counter,
- NITIO_Gi_Command_Reg(counter->counter_index), 0, 0,
- Gi_Load_Bit);
+ NITIO_Gi_Command_Reg(counter->
+ counter_index),
+ 0, 0, Gi_Load_Bit);
/* restore state of load reg to whatever the user set last set it to */
write_register(counter, counter_dev->regs[load_reg], load_reg);
break;
case 1:
counter_dev->regs[NITIO_Gi_LoadA_Reg(counter->counter_index)] =
- data[0];
+ data[0];
write_register(counter, data[0],
- NITIO_Gi_LoadA_Reg(counter->counter_index));
+ NITIO_Gi_LoadA_Reg(counter->counter_index));
break;
case 2:
counter_dev->regs[NITIO_Gi_LoadB_Reg(counter->counter_index)] =
- data[0];
+ data[0];
write_register(counter, data[0],
- NITIO_Gi_LoadB_Reg(counter->counter_index));
+ NITIO_Gi_LoadB_Reg(counter->counter_index));
break;
default:
return -EINVAL;
diff --git a/drivers/staging/comedi/drivers/ni_tio.h b/drivers/staging/comedi/drivers/ni_tio.h
index 3aacfe2f2420..b0588202e5ac 100644
--- a/drivers/staging/comedi/drivers/ni_tio.h
+++ b/drivers/staging/comedi/drivers/ni_tio.h
@@ -120,10 +120,10 @@ struct ni_gpct {
struct ni_gpct_device {
struct comedi_device *dev;
- void (*write_register) (struct ni_gpct *counter, unsigned bits,
- enum ni_gpct_register reg);
- unsigned (*read_register) (struct ni_gpct *counter,
- enum ni_gpct_register reg);
+ void (*write_register) (struct ni_gpct * counter, unsigned bits,
+ enum ni_gpct_register reg);
+ unsigned (*read_register) (struct ni_gpct * counter,
+ enum ni_gpct_register reg);
enum ni_gpct_variant variant;
struct ni_gpct *counters;
unsigned num_counters;
@@ -131,31 +131,42 @@ struct ni_gpct_device {
spinlock_t regs_lock;
};
-extern struct ni_gpct_device *ni_gpct_device_construct(struct comedi_device * dev,
- void (*write_register) (struct ni_gpct *counter, unsigned bits,
- enum ni_gpct_register reg),
- unsigned (*read_register) (struct ni_gpct *counter,
- enum ni_gpct_register reg), enum ni_gpct_variant variant,
- unsigned num_counters);
+extern struct ni_gpct_device *ni_gpct_device_construct(struct comedi_device
+ *dev,
+ void (*write_register)
+ (struct ni_gpct *
+ counter, unsigned bits,
+ enum ni_gpct_register
+ reg),
+ 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_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);
+ struct mite_channel *mite_chan);
extern void ni_tio_acknowledge_and_confirm(struct ni_gpct *counter,
- int *gate_error, int *tc_error, int *perm_stale_data, int *stale_data);
+ int *gate_error, int *tc_error,
+ int *perm_stale_data,
+ int *stale_data);
-static inline struct ni_gpct *subdev_to_counter(struct comedi_subdevice * s)
+static inline struct ni_gpct *subdev_to_counter(struct comedi_subdevice *s)
{
return s->private;
}
diff --git a/drivers/staging/comedi/drivers/ni_tio_internal.h b/drivers/staging/comedi/drivers/ni_tio_internal.h
index 920dd221da0d..c4ca53785832 100644
--- a/drivers/staging/comedi/drivers/ni_tio_internal.h
+++ b/drivers/staging/comedi/drivers/ni_tio_internal.h
@@ -27,7 +27,7 @@
#include "ni_tio.h"
static inline enum ni_gpct_register NITIO_Gi_Autoincrement_Reg(unsigned
- counter_index)
+ counter_index)
{
switch (counter_index) {
case 0:
@@ -72,7 +72,7 @@ static inline enum ni_gpct_register NITIO_Gi_Command_Reg(unsigned counter_index)
}
static inline enum ni_gpct_register NITIO_Gi_Counting_Mode_Reg(unsigned
- counter_index)
+ counter_index)
{
switch (counter_index) {
case 0:
@@ -95,7 +95,7 @@ static inline enum ni_gpct_register NITIO_Gi_Counting_Mode_Reg(unsigned
}
static inline enum ni_gpct_register NITIO_Gi_Input_Select_Reg(unsigned
- counter_index)
+ counter_index)
{
switch (counter_index) {
case 0:
@@ -118,7 +118,7 @@ static inline enum ni_gpct_register NITIO_Gi_Input_Select_Reg(unsigned
}
static inline enum ni_gpct_register NITIO_Gxx_Joint_Reset_Reg(unsigned
- counter_index)
+ counter_index)
{
switch (counter_index) {
case 0:
@@ -137,7 +137,7 @@ static inline enum ni_gpct_register NITIO_Gxx_Joint_Reset_Reg(unsigned
}
static inline enum ni_gpct_register NITIO_Gxx_Joint_Status1_Reg(unsigned
- counter_index)
+ counter_index)
{
switch (counter_index) {
case 0:
@@ -156,7 +156,7 @@ static inline enum ni_gpct_register NITIO_Gxx_Joint_Status1_Reg(unsigned
}
static inline enum ni_gpct_register NITIO_Gxx_Joint_Status2_Reg(unsigned
- counter_index)
+ counter_index)
{
switch (counter_index) {
case 0:
@@ -363,7 +363,7 @@ static inline enum ni_gpct_register NITIO_Gi_ABZ_Reg(int counter_index)
}
static inline enum ni_gpct_register NITIO_Gi_Interrupt_Acknowledge_Reg(int
- counter_index)
+ counter_index)
{
switch (counter_index) {
case 0:
@@ -408,7 +408,7 @@ static inline enum ni_gpct_register NITIO_Gi_Status_Reg(int counter_index)
}
static inline enum ni_gpct_register NITIO_Gi_Interrupt_Enable_Reg(int
- counter_index)
+ counter_index)
{
switch (counter_index) {
case 0:
@@ -542,7 +542,7 @@ enum Gi_Second_Gate_Bits {
static inline unsigned Gi_Second_Gate_Select_Bits(unsigned second_gate_select)
{
return (second_gate_select << Gi_Second_Gate_Select_Shift) &
- Gi_Second_Gate_Select_Mask;
+ Gi_Second_Gate_Select_Mask;
}
enum Gxx_Status_Bits {
@@ -569,31 +569,36 @@ static inline enum Gxx_Status_Bits Gi_Counting_Bit(unsigned counter_index)
return G1_Counting_Bit;
return G0_Counting_Bit;
}
+
static inline enum Gxx_Status_Bits Gi_Armed_Bit(unsigned counter_index)
{
if (counter_index % 2)
return G1_Armed_Bit;
return G0_Armed_Bit;
}
+
static inline enum Gxx_Status_Bits Gi_Next_Load_Source_Bit(unsigned
- counter_index)
+ counter_index)
{
if (counter_index % 2)
return G1_Next_Load_Source_Bit;
return G0_Next_Load_Source_Bit;
}
+
static inline enum Gxx_Status_Bits Gi_Stale_Data_Bit(unsigned counter_index)
{
if (counter_index % 2)
return G1_Stale_Data_Bit;
return G0_Stale_Data_Bit;
}
+
static inline enum Gxx_Status_Bits Gi_TC_Error_Bit(unsigned counter_index)
{
if (counter_index % 2)
return G1_TC_Error_Bit;
return G0_TC_Error_Bit;
}
+
static inline enum Gxx_Status_Bits Gi_Gate_Error_Bit(unsigned counter_index)
{
if (counter_index % 2)
@@ -616,7 +621,7 @@ enum Gxx_Joint_Status2_Bits {
G1_Permanent_Stale_Bit = 0x8000
};
static inline enum Gxx_Joint_Status2_Bits Gi_Permanent_Stale_Bit(unsigned
- counter_index)
+ counter_index)
{
if (counter_index % 2)
return G1_Permanent_Stale_Bit;
@@ -649,6 +654,7 @@ static inline unsigned Gi_Gate_Error_Confirm_Bit(unsigned counter_index)
return G1_Gate_Error_Confirm_Bit;
return G0_Gate_Error_Confirm_Bit;
}
+
static inline unsigned Gi_TC_Error_Confirm_Bit(unsigned counter_index)
{
if (counter_index % 2)
@@ -689,21 +695,22 @@ static inline unsigned Gi_Gate_Interrupt_Enable_Bit(unsigned counter_index)
}
static inline void write_register(struct ni_gpct *counter, unsigned bits,
- enum ni_gpct_register reg)
+ enum ni_gpct_register reg)
{
BUG_ON(reg >= NITIO_Num_Registers);
counter->counter_dev->write_register(counter, bits, reg);
}
static inline unsigned read_register(struct ni_gpct *counter,
- enum ni_gpct_register reg)
+ enum ni_gpct_register reg)
{
BUG_ON(reg >= NITIO_Num_Registers);
return counter->counter_dev->read_register(counter, reg);
}
-static inline int ni_tio_counting_mode_registers_present(
- const struct ni_gpct_device *counter_dev)
+static inline int ni_tio_counting_mode_registers_present(const struct
+ ni_gpct_device
+ *counter_dev)
{
switch (counter_dev->variant) {
case ni_gpct_variant_e_series:
@@ -721,8 +728,10 @@ static inline int ni_tio_counting_mode_registers_present(
}
static inline void ni_tio_set_bits_transient(struct ni_gpct *counter,
- enum ni_gpct_register register_index, unsigned bit_mask,
- unsigned bit_values, unsigned transient_bit_values)
+ enum ni_gpct_register
+ register_index, unsigned bit_mask,
+ unsigned bit_values,
+ unsigned transient_bit_values)
{
struct ni_gpct_device *counter_dev = counter->counter_dev;
unsigned long flags;
@@ -732,8 +741,8 @@ static inline void ni_tio_set_bits_transient(struct ni_gpct *counter,
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);
+ counter_dev->regs[register_index] | transient_bit_values,
+ register_index);
mmiowb();
spin_unlock_irqrestore(&counter_dev->regs_lock, flags);
}
@@ -742,11 +751,11 @@ static inline void ni_tio_set_bits_transient(struct ni_gpct *counter,
twiddled in interrupt context, or whose software copy may be read in interrupt context.
*/
static inline void ni_tio_set_bits(struct ni_gpct *counter,
- enum ni_gpct_register register_index, unsigned bit_mask,
- unsigned bit_values)
+ enum ni_gpct_register register_index,
+ unsigned bit_mask, unsigned bit_values)
{
ni_tio_set_bits_transient(counter, register_index, bit_mask, bit_values,
- 0x0);
+ 0x0);
}
/* ni_tio_get_soft_copy( ) is for safely reading the software copy of a register
@@ -754,7 +763,8 @@ whose bits might be modified in interrupt context, or whose software copy
might need to be read in interrupt context.
*/
static inline unsigned ni_tio_get_soft_copy(const struct ni_gpct *counter,
- enum ni_gpct_register register_index)
+ enum ni_gpct_register
+ register_index)
{
struct ni_gpct_device *counter_dev = counter->counter_dev;
unsigned long flags;
@@ -769,6 +779,6 @@ static inline unsigned ni_tio_get_soft_copy(const struct ni_gpct *counter,
int ni_tio_arm(struct ni_gpct *counter, int arm, unsigned start_trigger);
int ni_tio_set_gate_src(struct ni_gpct *counter, unsigned gate_index,
- unsigned int gate_source);
+ unsigned int gate_source);
#endif /* _COMEDI_NI_TIO_INTERNAL_H */
diff --git a/drivers/staging/comedi/drivers/ni_tiocmd.c b/drivers/staging/comedi/drivers/ni_tiocmd.c
index 5be1e1a62c0a..b0d44b547a69 100644
--- a/drivers/staging/comedi/drivers/ni_tiocmd.c
+++ b/drivers/staging/comedi/drivers/ni_tiocmd.c
@@ -56,7 +56,7 @@ MODULE_DESCRIPTION("Comedi command support for NI general-purpose counters");
MODULE_LICENSE("GPL");
static void ni_tio_configure_dma(struct ni_gpct *counter, short enable,
- short read_not_write)
+ short read_not_write)
{
struct ni_gpct_device *counter_dev = counter->counter_dev;
unsigned input_select_bits = 0;
@@ -69,9 +69,9 @@ static void ni_tio_configure_dma(struct ni_gpct *counter, short enable,
}
}
ni_tio_set_bits(counter,
- NITIO_Gi_Input_Select_Reg(counter->counter_index),
- Gi_Read_Acknowledges_Irq | Gi_Write_Acknowledges_Irq,
- input_select_bits);
+ NITIO_Gi_Input_Select_Reg(counter->counter_index),
+ Gi_Read_Acknowledges_Irq | Gi_Write_Acknowledges_Irq,
+ input_select_bits);
switch (counter_dev->variant) {
case ni_gpct_variant_e_series:
break;
@@ -88,16 +88,18 @@ static void ni_tio_configure_dma(struct ni_gpct *counter, short enable,
gi_dma_config_bits |= Gi_DMA_Write_Bit;
}
ni_tio_set_bits(counter,
- NITIO_Gi_DMA_Config_Reg(counter->counter_index),
- Gi_DMA_Enable_Bit | Gi_DMA_Int_Bit |
- Gi_DMA_Write_Bit, gi_dma_config_bits);
+ NITIO_Gi_DMA_Config_Reg(counter->
+ counter_index),
+ Gi_DMA_Enable_Bit | Gi_DMA_Int_Bit |
+ Gi_DMA_Write_Bit, gi_dma_config_bits);
}
break;
}
}
-static int ni_tio_input_inttrig(struct comedi_device *dev, struct comedi_subdevice *s,
- unsigned int trignum)
+static int ni_tio_input_inttrig(struct comedi_device *dev,
+ struct comedi_subdevice *s,
+ unsigned int trignum)
{
unsigned long flags;
int retval = 0;
@@ -143,7 +145,7 @@ static int ni_tio_input_cmd(struct ni_gpct *counter, struct comedi_async *async)
break;
}
ni_tio_set_bits(counter, NITIO_Gi_Command_Reg(counter->counter_index),
- Gi_Save_Trace_Bit, 0);
+ Gi_Save_Trace_Bit, 0);
ni_tio_configure_dma(counter, 1, 1);
switch (cmd->start_src) {
case TRIG_NOW:
@@ -169,7 +171,8 @@ static int ni_tio_input_cmd(struct ni_gpct *counter, struct comedi_async *async)
return retval;
}
-static int ni_tio_output_cmd(struct ni_gpct *counter, struct comedi_async *async)
+static int ni_tio_output_cmd(struct ni_gpct *counter,
+ struct comedi_async *async)
{
printk("ni_tio: output commands not yet implemented.\n");
return -ENOTSUPP;
@@ -200,9 +203,12 @@ static int ni_tio_cmd_setup(struct ni_gpct *counter, struct comedi_async *async)
}
if (cmd->flags & TRIG_WAKE_EOS) {
ni_tio_set_bits(counter,
- NITIO_Gi_Interrupt_Enable_Reg(counter->counter_index),
- Gi_Gate_Interrupt_Enable_Bit(counter->counter_index),
- Gi_Gate_Interrupt_Enable_Bit(counter->counter_index));
+ NITIO_Gi_Interrupt_Enable_Reg(counter->
+ counter_index),
+ Gi_Gate_Interrupt_Enable_Bit(counter->
+ counter_index),
+ Gi_Gate_Interrupt_Enable_Bit(counter->
+ counter_index));
}
return retval;
}
@@ -216,7 +222,7 @@ int ni_tio_cmd(struct ni_gpct *counter, struct comedi_async *async)
spin_lock_irqsave(&counter->lock, flags);
if (counter->mite_chan == NULL) {
printk
- ("ni_tio: commands only supported with DMA. Interrupt-driven commands not yet implemented.\n");
+ ("ni_tio: commands only supported with DMA. Interrupt-driven commands not yet implemented.\n");
retval = -EIO;
} else {
retval = ni_tio_cmd_setup(counter, async);
@@ -232,7 +238,7 @@ int ni_tio_cmd(struct ni_gpct *counter, struct comedi_async *async)
return retval;
}
-int ni_tio_cmdtest(struct ni_gpct *counter, struct comedi_cmd * cmd)
+int ni_tio_cmdtest(struct ni_gpct *counter, struct comedi_cmd *cmd)
{
int err = 0;
int tmp;
@@ -275,15 +281,15 @@ int ni_tio_cmdtest(struct ni_gpct *counter, struct comedi_cmd * cmd)
/* step 2: make sure trigger sources are unique... */
if (cmd->start_src != TRIG_NOW &&
- cmd->start_src != TRIG_INT &&
- cmd->start_src != TRIG_EXT && cmd->start_src != TRIG_OTHER)
+ cmd->start_src != TRIG_INT &&
+ cmd->start_src != TRIG_EXT && cmd->start_src != TRIG_OTHER)
err++;
if (cmd->scan_begin_src != TRIG_FOLLOW &&
- cmd->scan_begin_src != TRIG_EXT &&
- cmd->scan_begin_src != TRIG_OTHER)
+ cmd->scan_begin_src != TRIG_EXT &&
+ cmd->scan_begin_src != TRIG_OTHER)
err++;
if (cmd->convert_src != TRIG_OTHER &&
- cmd->convert_src != TRIG_EXT && cmd->convert_src != TRIG_NOW)
+ cmd->convert_src != TRIG_EXT && cmd->convert_src != TRIG_NOW)
err++;
if (cmd->stop_src != TRIG_NONE)
err++;
@@ -350,8 +356,9 @@ int ni_tio_cancel(struct ni_gpct *counter)
ni_tio_configure_dma(counter, 0, 0);
ni_tio_set_bits(counter,
- NITIO_Gi_Interrupt_Enable_Reg(counter->counter_index),
- Gi_Gate_Interrupt_Enable_Bit(counter->counter_index), 0x0);
+ NITIO_Gi_Interrupt_Enable_Reg(counter->counter_index),
+ Gi_Gate_Interrupt_Enable_Bit(counter->counter_index),
+ 0x0);
return 0;
}
@@ -372,8 +379,8 @@ static int should_ack_gate(struct ni_gpct *counter)
spin_lock_irqsave(&counter->lock, flags);
{
if (counter->mite_chan == NULL ||
- counter->mite_chan->dir != COMEDI_INPUT ||
- (mite_done(counter->mite_chan))) {
+ counter->mite_chan->dir != COMEDI_INPUT ||
+ (mite_done(counter->mite_chan))) {
retval = 1;
}
}
@@ -384,12 +391,17 @@ static int should_ack_gate(struct ni_gpct *counter)
}
void ni_tio_acknowledge_and_confirm(struct ni_gpct *counter, int *gate_error,
- int *tc_error, int *perm_stale_data, int *stale_data)
+ int *tc_error, int *perm_stale_data,
+ int *stale_data)
{
const unsigned short gxx_status = read_register(counter,
- NITIO_Gxx_Status_Reg(counter->counter_index));
+ NITIO_Gxx_Status_Reg
+ (counter->
+ counter_index));
const unsigned short gi_status = read_register(counter,
- NITIO_Gi_Status_Reg(counter->counter_index));
+ NITIO_Gi_Status_Reg
+ (counter->
+ counter_index));
unsigned ack = 0;
if (gate_error)
@@ -407,7 +419,7 @@ void ni_tio_acknowledge_and_confirm(struct ni_gpct *counter, int *gate_error,
/*660x don't support automatic acknowledgement of gate interrupt via dma read/write
and report bogus gate errors */
if (counter->counter_dev->variant !=
- ni_gpct_variant_660x) {
+ ni_gpct_variant_660x) {
*gate_error = 1;
}
}
@@ -426,28 +438,30 @@ void ni_tio_acknowledge_and_confirm(struct ni_gpct *counter, int *gate_error,
}
if (ack)
write_register(counter, ack,
- NITIO_Gi_Interrupt_Acknowledge_Reg(counter->
- counter_index));
- if (ni_tio_get_soft_copy(counter,
- NITIO_Gi_Mode_Reg(counter->
- counter_index)) & Gi_Loading_On_Gate_Bit) {
+ NITIO_Gi_Interrupt_Acknowledge_Reg
+ (counter->counter_index));
+ if (ni_tio_get_soft_copy
+ (counter,
+ NITIO_Gi_Mode_Reg(counter->counter_index)) &
+ Gi_Loading_On_Gate_Bit) {
if (gxx_status & Gi_Stale_Data_Bit(counter->counter_index)) {
if (stale_data)
*stale_data = 1;
}
if (read_register(counter,
- NITIO_Gxx_Joint_Status2_Reg(counter->
- counter_index)) &
- Gi_Permanent_Stale_Bit(counter->counter_index)) {
+ NITIO_Gxx_Joint_Status2_Reg
+ (counter->counter_index)) &
+ Gi_Permanent_Stale_Bit(counter->counter_index)) {
printk("%s: Gi_Permanent_Stale_Data detected.\n",
- __FUNCTION__);
+ __FUNCTION__);
if (perm_stale_data)
*perm_stale_data = 1;
}
}
}
-void ni_tio_handle_interrupt(struct ni_gpct *counter, struct comedi_subdevice * s)
+void ni_tio_handle_interrupt(struct ni_gpct *counter,
+ struct comedi_subdevice *s)
{
unsigned gpct_mite_status;
unsigned long flags;
@@ -456,7 +470,7 @@ void ni_tio_handle_interrupt(struct ni_gpct *counter, struct comedi_subdevice *
int perm_stale_data;
ni_tio_acknowledge_and_confirm(counter, &gate_error, &tc_error,
- &perm_stale_data, NULL);
+ &perm_stale_data, NULL);
if (gate_error) {
printk("%s: Gi_Gate_Error detected.\n", __FUNCTION__);
s->async->events |= COMEDI_CB_OVERFLOW;
@@ -468,8 +482,9 @@ void ni_tio_handle_interrupt(struct ni_gpct *counter, struct comedi_subdevice *
case ni_gpct_variant_m_series:
case ni_gpct_variant_660x:
if (read_register(counter,
- NITIO_Gi_DMA_Status_Reg(counter->
- counter_index)) & Gi_DRQ_Error_Bit) {
+ NITIO_Gi_DMA_Status_Reg
+ (counter->counter_index)) & Gi_DRQ_Error_Bit)
+ {
printk("%s: Gi_DRQ_Error detected.\n", __FUNCTION__);
s->async->events |= COMEDI_CB_OVERFLOW;
}
@@ -485,15 +500,15 @@ void ni_tio_handle_interrupt(struct ni_gpct *counter, struct comedi_subdevice *
gpct_mite_status = mite_get_status(counter->mite_chan);
if (gpct_mite_status & CHSR_LINKC) {
writel(CHOR_CLRLC,
- counter->mite_chan->mite->mite_io_addr +
- MITE_CHOR(counter->mite_chan->channel));
+ counter->mite_chan->mite->mite_io_addr +
+ MITE_CHOR(counter->mite_chan->channel));
}
mite_sync_input_dma(counter->mite_chan, s->async);
spin_unlock_irqrestore(&counter->lock, flags);
}
void ni_tio_set_mite_channel(struct ni_gpct *counter,
- struct mite_channel *mite_chan)
+ struct mite_channel *mite_chan)
{
unsigned long flags;
diff --git a/drivers/staging/comedi/drivers/pcl711.c b/drivers/staging/comedi/drivers/pcl711.c
index 7b72b7af75c8..dd9db069a932 100644
--- a/drivers/staging/comedi/drivers/pcl711.c
+++ b/drivers/staging/comedi/drivers/pcl711.c
@@ -89,39 +89,41 @@ supported.
#define PCL711_DO_HI 14
static const struct comedi_lrange range_pcl711b_ai = { 5, {
- BIP_RANGE(5),
- BIP_RANGE(2.5),
- BIP_RANGE(1.25),
- BIP_RANGE(0.625),
- BIP_RANGE(0.3125)
- }
+ BIP_RANGE(5),
+ BIP_RANGE(2.5),
+ BIP_RANGE(1.25),
+ BIP_RANGE(0.625),
+ BIP_RANGE(0.3125)
+ }
};
+
static const struct comedi_lrange range_acl8112hg_ai = { 12, {
- BIP_RANGE(5),
- BIP_RANGE(0.5),
- BIP_RANGE(0.05),
- BIP_RANGE(0.005),
- UNI_RANGE(10),
- UNI_RANGE(1),
- UNI_RANGE(0.1),
- UNI_RANGE(0.01),
- BIP_RANGE(10),
- BIP_RANGE(1),
- BIP_RANGE(0.1),
- BIP_RANGE(0.01)
- }
+ BIP_RANGE(5),
+ BIP_RANGE(0.5),
+ BIP_RANGE(0.05),
+ BIP_RANGE(0.005),
+ UNI_RANGE(10),
+ UNI_RANGE(1),
+ UNI_RANGE(0.1),
+ UNI_RANGE(0.01),
+ BIP_RANGE(10),
+ BIP_RANGE(1),
+ BIP_RANGE(0.1),
+ BIP_RANGE(0.01)
+ }
};
+
static const struct comedi_lrange range_acl8112dg_ai = { 9, {
- BIP_RANGE(5),
- BIP_RANGE(2.5),
- BIP_RANGE(1.25),
- BIP_RANGE(0.625),
- UNI_RANGE(10),
- UNI_RANGE(5),
- UNI_RANGE(2.5),
- UNI_RANGE(1.25),
- BIP_RANGE(10)
- }
+ BIP_RANGE(5),
+ BIP_RANGE(2.5),
+ BIP_RANGE(1.25),
+ BIP_RANGE(0.625),
+ UNI_RANGE(10),
+ UNI_RANGE(5),
+ UNI_RANGE(2.5),
+ UNI_RANGE(1.25),
+ BIP_RANGE(10)
+ }
};
/*
@@ -146,7 +148,6 @@ struct pcl711_board {
const struct comedi_lrange *ai_range_type;
};
-
static const struct pcl711_board boardtypes[] = {
{"pcl711", 0, 0, 0, 5, 8, 1, 0, &range_bipolar5},
{"pcl711b", 1, 0, 0, 5, 8, 1, 7, &range_pcl711b_ai},
@@ -157,7 +158,8 @@ 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_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",
@@ -183,7 +185,6 @@ struct pcl711_private {
unsigned int divisor2;
};
-
#define devpriv ((struct pcl711_private *)dev->private)
static irqreturn_t pcl711_interrupt(int irq, void *d)
@@ -246,7 +247,7 @@ 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)
+ struct comedi_insn *insn, unsigned int *data)
{
int i, n;
int hi, lo;
@@ -275,7 +276,7 @@ static int pcl711_ai_insn(struct comedi_device *dev, struct comedi_subdevice *s,
printk("comedi%d: pcl711: A/D timeout\n", dev->minor);
return -ETIME;
- ok:
+ok:
lo = inb(dev->iobase + PCL711_AD_LO);
data[n] = ((hi & 0xf) << 8) | lo;
@@ -284,8 +285,8 @@ static int pcl711_ai_insn(struct comedi_device *dev, struct comedi_subdevice *s,
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;
@@ -322,7 +323,7 @@ static int pcl711_ai_cmdtest(struct comedi_device *dev, struct comedi_subdevice
/* step 2 */
if (cmd->scan_begin_src != TRIG_TIMER &&
- cmd->scan_begin_src != TRIG_EXT)
+ cmd->scan_begin_src != TRIG_EXT)
err++;
if (cmd->stop_src != TRIG_COUNT && cmd->stop_src != TRIG_NONE)
err++;
@@ -374,8 +375,10 @@ static int pcl711_ai_cmdtest(struct comedi_device *dev, struct comedi_subdevice
if (cmd->scan_begin_src == TRIG_TIMER) {
tmp = cmd->scan_begin_arg;
i8253_cascade_ns_to_timer_2div(TIMER_BASE,
- &devpriv->divisor1, &devpriv->divisor2,
- &cmd->scan_begin_arg, cmd->flags & TRIG_ROUND_MASK);
+ &devpriv->divisor1,
+ &devpriv->divisor2,
+ &cmd->scan_begin_arg,
+ cmd->flags & TRIG_ROUND_MASK);
if (tmp != cmd->scan_begin_arg)
err++;
}
@@ -405,7 +408,8 @@ static int pcl711_ai_cmd(struct comedi_device *dev, struct comedi_subdevice *s)
*/
i8253_cascade_ns_to_timer(i8253_osc_base, &timer1, &timer2,
- &cmd->scan_begin_arg, TRIG_ROUND_NEAREST);
+ &cmd->scan_begin_arg,
+ TRIG_ROUND_NEAREST);
outb(0x74, dev->iobase + PCL711_CTRCTL);
outb(timer1 & 0xff, dev->iobase + PCL711_CTR1);
@@ -433,16 +437,16 @@ 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)
+ struct comedi_insn *insn, unsigned int *data)
{
int n;
int chan = CR_CHAN(insn->chanspec);
for (n = 0; n < insn->n; n++) {
outb((data[n] & 0xff),
- dev->iobase + (chan ? PCL711_DA1_LO : PCL711_DA0_LO));
+ dev->iobase + (chan ? PCL711_DA1_LO : PCL711_DA0_LO));
outb((data[n] >> 8),
- dev->iobase + (chan ? PCL711_DA1_HI : PCL711_DA0_HI));
+ dev->iobase + (chan ? PCL711_DA1_HI : PCL711_DA0_HI));
devpriv->ao_readback[chan] = data[n];
}
@@ -450,8 +454,9 @@ static int pcl711_ao_insn(struct comedi_device *dev, struct comedi_subdevice *s,
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);
@@ -465,21 +470,23 @@ static int pcl711_ao_insn_read(struct comedi_device *dev, struct comedi_subdevic
}
/* 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;
data[1] = inb(dev->iobase + PCL711_DI_LO) |
- (inb(dev->iobase + PCL711_DI_HI) << 8);
+ (inb(dev->iobase + PCL711_DI_HI) << 8);
return 2;
}
/* 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;
diff --git a/drivers/staging/comedi/drivers/pcl724.c b/drivers/staging/comedi/drivers/pcl724.c
index 699daff3035a..df1f4ef14616 100644
--- a/drivers/staging/comedi/drivers/pcl724.c
+++ b/drivers/staging/comedi/drivers/pcl724.c
@@ -56,7 +56,8 @@ See the source for configuration details.
/* #define PCL724_IRQ 1 no IRQ support now */
-static int pcl724_attach(struct comedi_device *dev, struct comedi_devconfig *it);
+static int pcl724_attach(struct comedi_device *dev,
+ struct comedi_devconfig *it);
static int pcl724_detach(struct comedi_device *dev);
struct pcl724_board {
@@ -70,7 +71,6 @@ struct pcl724_board {
char is_pet48;
};
-
static const struct pcl724_board boardtypes[] = {
{"pcl724", 24, 1, 0x00fc, PCL724_SIZE, 0, 0,},
{"pcl722", 144, 6, 0x00fc, PCL722_SIZE, 1, 0,},
@@ -108,7 +108,7 @@ static int subdev_8255_cb(int dir, int port, int data, unsigned long arg)
}
static int subdev_8255mapped_cb(int dir, int port, int data,
- unsigned long iobase)
+ unsigned long iobase)
{
int movport = SIZE_8255 * (iobase >> 12);
@@ -136,10 +136,10 @@ static int pcl724_attach(struct comedi_device *dev, struct comedi_devconfig *it)
iobase = it->options[0];
iorange = this_board->io_range;
if ((this_board->can_have96) && ((it->options[1] == 1)
- || (it->options[1] == 96)))
+ || (it->options[1] == 96)))
iorange = PCL722_96_SIZE; /* PCL-724 in 96 DIO configuration */
printk("comedi%d: pcl724: board=%s, 0x%03lx ", dev->minor,
- this_board->name, iobase);
+ this_board->name, iobase);
if (!request_region(iobase, iorange, "pcl724")) {
printk("I/O port conflict\n");
return -EIO;
@@ -156,14 +156,15 @@ static int pcl724_attach(struct comedi_device *dev, struct comedi_devconfig *it)
if (irq) { /* we want to use IRQ */
if (((1 << irq) & this_board->IRQbits) == 0) {
printk
- (", IRQ %u is out of allowed range, DISABLING IT",
- irq);
+ (", IRQ %u is out of allowed range, DISABLING IT",
+ irq);
irq = 0; /* Bad IRQ */
} else {
- if (request_irq(irq, interrupt_pcl724, 0, "pcl724", dev)) {
+ if (request_irq
+ (irq, interrupt_pcl724, 0, "pcl724", dev)) {
printk
- (", unable to allocate IRQ %u, DISABLING IT",
- irq);
+ (", unable to allocate IRQ %u, DISABLING IT",
+ irq);
irq = 0; /* Can't use IRQ */
} else {
printk(", irq=%u", irq);
@@ -179,7 +180,7 @@ static int pcl724_attach(struct comedi_device *dev, struct comedi_devconfig *it)
n_subdevices = this_board->numofports;
if ((this_board->can_have96) && ((it->options[1] == 1)
- || (it->options[1] == 96)))
+ || (it->options[1] == 96)))
n_subdevices = 4; /* PCL-724 in 96 DIO configuration */
ret = alloc_subdevices(dev, n_subdevices);
@@ -189,12 +190,14 @@ static int pcl724_attach(struct comedi_device *dev, struct comedi_devconfig *it)
for (i = 0; i < dev->n_subdevices; i++) {
if (this_board->is_pet48) {
subdev_8255_init(dev, dev->subdevices + i,
- subdev_8255mapped_cb,
- (unsigned long)(dev->iobase + i * 0x1000));
+ subdev_8255mapped_cb,
+ (unsigned long)(dev->iobase +
+ i * 0x1000));
} else
subdev_8255_init(dev, dev->subdevices + i,
- subdev_8255_cb,
- (unsigned long)(dev->iobase + SIZE_8255 * i));
+ subdev_8255_cb,
+ (unsigned long)(dev->iobase +
+ SIZE_8255 * i));
};
return 0;
diff --git a/drivers/staging/comedi/drivers/pcl725.c b/drivers/staging/comedi/drivers/pcl725.c
index 1347624d0519..1da4941fce49 100644
--- a/drivers/staging/comedi/drivers/pcl725.c
+++ b/drivers/staging/comedi/drivers/pcl725.c
@@ -20,7 +20,8 @@ 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_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",
@@ -32,7 +33,7 @@ static struct comedi_driver driver_pcl725 = {
COMEDI_INITCLEANUP(driver_pcl725);
static int pcl725_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;
@@ -49,7 +50,7 @@ static int pcl725_do_insn(struct comedi_device *dev, struct comedi_subdevice *s,
}
static int pcl725_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/pcl726.c b/drivers/staging/comedi/drivers/pcl726.c
index 149e75f0e09c..ccadd095f630 100644
--- a/drivers/staging/comedi/drivers/pcl726.c
+++ b/drivers/staging/comedi/drivers/pcl726.c
@@ -111,7 +111,8 @@ 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_attach(struct comedi_device *dev,
+ struct comedi_devconfig *it);
static int pcl726_detach(struct comedi_device *dev);
struct pcl726_board {
@@ -129,23 +130,22 @@ struct pcl726_board {
const struct comedi_lrange *const *range_type_list; /* list of supported ranges */
};
-
static const struct pcl726_board boardtypes[] = {
{"pcl726", 6, 6, 0x0000, PCL726_SIZE, 1,
- PCL726_DI_HI, PCL726_DI_LO, PCL726_DO_HI, PCL726_DO_LO,
- &rangelist_726[0],},
+ PCL726_DI_HI, PCL726_DI_LO, PCL726_DO_HI, PCL726_DO_LO,
+ &rangelist_726[0],},
{"pcl727", 12, 4, 0x0000, PCL727_SIZE, 1,
- PCL727_DI_HI, PCL727_DI_LO, PCL727_DO_HI, PCL727_DO_LO,
- &rangelist_727[0],},
+ PCL727_DI_HI, PCL727_DI_LO, PCL727_DO_HI, PCL727_DO_LO,
+ &rangelist_727[0],},
{"pcl728", 2, 6, 0x0000, PCL728_SIZE, 0,
- 0, 0, 0, 0,
- &rangelist_728[0],},
+ 0, 0, 0, 0,
+ &rangelist_728[0],},
{"acl6126", 6, 5, 0x96e8, PCL726_SIZE, 1,
- PCL726_DI_HI, PCL726_DI_LO, PCL726_DO_HI, PCL726_DO_LO,
- &rangelist_726[0],},
+ PCL726_DI_HI, PCL726_DI_LO, PCL726_DO_HI, PCL726_DO_LO,
+ &rangelist_726[0],},
{"acl6128", 2, 6, 0x0000, PCL728_SIZE, 0,
- 0, 0, 0, 0,
- &rangelist_728[0],},
+ 0, 0, 0, 0,
+ &rangelist_728[0],},
};
#define n_boardtypes (sizeof(boardtypes)/sizeof(struct pcl726_board))
@@ -173,7 +173,7 @@ 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)
+ struct comedi_insn *insn, unsigned int *data)
{
int hi, lo;
int n;
@@ -197,8 +197,9 @@ static int pcl726_ao_insn(struct comedi_device *dev, struct comedi_subdevice *s,
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,20 +210,22 @@ static int pcl726_ao_insn_read(struct comedi_device *dev, struct comedi_subdevic
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;
data[1] = inb(dev->iobase + this_board->di_lo) |
- (inb(dev->iobase + this_board->di_hi) << 8);
+ (inb(dev->iobase + this_board->di_hi) << 8);
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;
@@ -254,7 +257,7 @@ static int pcl726_attach(struct comedi_device *dev, struct comedi_devconfig *it)
iobase = it->options[0];
iorange = this_board->io_range;
printk("comedi%d: pcl726: board=%s, 0x%03lx ", dev->minor,
- this_board->name, iobase);
+ this_board->name, iobase);
if (!request_region(iobase, iorange, "pcl726")) {
printk("I/O port conflict\n");
return -EIO;
@@ -281,15 +284,15 @@ static int pcl726_attach(struct comedi_device *dev, struct comedi_devconfig *it)
if (irq) { /* we want to use IRQ */
if (((1 << irq) & boardtypes[board].IRQbits) == 0) {
printk
- (", IRQ %d is out of allowed range, DISABLING IT",
- irq);
+ (", IRQ %d is out of allowed range, DISABLING IT",
+ irq);
irq = 0; /* Bad IRQ */
} else {
if (request_irq(irq, interrupt_pcl818, 0,
"pcl726", dev)) {
printk
- (", unable to allocate IRQ %d, DISABLING IT",
- irq);
+ (", unable to allocate IRQ %d, DISABLING IT",
+ irq);
irq = 0; /* Can't use IRQ */
} else {
printk(", irq=%d", irq);
@@ -322,12 +325,14 @@ static int pcl726_attach(struct comedi_device *dev, struct comedi_devconfig *it)
j = it->options[2 + 1];
if ((j < 0) || (j >= this_board->num_of_ranges)) {
- printk("Invalid range for channel %d! Must be 0<=%d<%d\n", i, j, this_board->num_of_ranges - 1);
+ printk
+ ("Invalid range for channel %d! Must be 0<=%d<%d\n",
+ i, j, this_board->num_of_ranges - 1);
j = 0;
}
devpriv->rangelist[i] = this_board->range_type_list[j];
if (devpriv->rangelist[i]->range[0].min ==
- -devpriv->rangelist[i]->range[0].max)
+ -devpriv->rangelist[i]->range[0].max)
devpriv->bipolar[i] = 1; /* bipolar range */
}
diff --git a/drivers/staging/comedi/drivers/pcl730.c b/drivers/staging/comedi/drivers/pcl730.c
index 408cbffae418..c9859c90c152 100644
--- a/drivers/staging/comedi/drivers/pcl730.c
+++ b/drivers/staging/comedi/drivers/pcl730.c
@@ -26,7 +26,8 @@ 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_attach(struct comedi_device *dev,
+ struct comedi_devconfig *it);
static int pcl730_detach(struct comedi_device *dev);
struct pcl730_board {
@@ -35,7 +36,6 @@ struct pcl730_board {
unsigned int io_range; /* len of I/O space */
};
-
static const struct pcl730_board boardtypes[] = {
{"pcl730", PCL730_SIZE,},
{"iso730", PCL730_SIZE,},
@@ -58,7 +58,7 @@ static struct comedi_driver driver_pcl730 = {
COMEDI_INITCLEANUP(driver_pcl730);
static int pcl730_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;
@@ -69,10 +69,10 @@ static int pcl730_do_insn(struct comedi_device *dev, struct comedi_subdevice *s,
}
if (data[0] & 0x00ff)
outb(s->state & 0xff,
- dev->iobase + ((unsigned long)s->private));
+ dev->iobase + ((unsigned long)s->private));
if (data[0] & 0xff00)
outb((s->state >> 8),
- dev->iobase + ((unsigned long)s->private) + 1);
+ dev->iobase + ((unsigned long)s->private) + 1);
data[1] = s->state;
@@ -80,13 +80,13 @@ static int pcl730_do_insn(struct comedi_device *dev, struct comedi_subdevice *s,
}
static int pcl730_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;
data[1] = inb(dev->iobase + ((unsigned long)s->private)) |
- (inb(dev->iobase + ((unsigned long)s->private) + 1) << 8);
+ (inb(dev->iobase + ((unsigned long)s->private) + 1) << 8);
return 2;
}
@@ -100,7 +100,7 @@ static int pcl730_attach(struct comedi_device *dev, struct comedi_devconfig *it)
iobase = it->options[0];
iorange = this_board->io_range;
printk("comedi%d: pcl730: board=%s 0x%04lx ", dev->minor,
- this_board->name, iobase);
+ this_board->name, iobase);
if (!request_region(iobase, iorange, "pcl730")) {
printk("I/O port conflict\n");
return -EIO;
diff --git a/drivers/staging/comedi/drivers/pcl812.c b/drivers/staging/comedi/drivers/pcl812.c
index dd91fe9f5f51..0b51a48c3ad8 100644
--- a/drivers/staging/comedi/drivers/pcl812.c
+++ b/drivers/staging/comedi/drivers/pcl812.c
@@ -161,139 +161,159 @@ Options for ACL-8113, ISO-813:
#define MAX_CHANLIST_LEN 256 /* length of scan list */
static const struct comedi_lrange range_pcl812pg_ai = { 5, {
- BIP_RANGE(5),
- BIP_RANGE(2.5),
- BIP_RANGE(1.25),
- BIP_RANGE(0.625),
- BIP_RANGE(0.3125),
- }
+ BIP_RANGE(5),
+ BIP_RANGE(2.5),
+ BIP_RANGE(1.25),
+ BIP_RANGE(0.625),
+ BIP_RANGE(0.3125),
+ }
};
+
static const struct comedi_lrange range_pcl812pg2_ai = { 5, {
- BIP_RANGE(10),
- BIP_RANGE(5),
- BIP_RANGE(2.5),
- BIP_RANGE(1.25),
- BIP_RANGE(0.625),
- }
+ BIP_RANGE(10),
+ BIP_RANGE(5),
+ BIP_RANGE(2.5),
+ BIP_RANGE(1.25),
+ BIP_RANGE(0.625),
+ }
};
+
static const struct comedi_lrange range812_bipolar1_25 = { 1, {
- BIP_RANGE(1.25),
- }
+ BIP_RANGE(1.25),
+ }
};
+
static const struct comedi_lrange range812_bipolar0_625 = { 1, {
- BIP_RANGE(0.625),
- }
+ BIP_RANGE
+ (0.625),
+ }
};
+
static const struct comedi_lrange range812_bipolar0_3125 = { 1, {
- BIP_RANGE(0.3125),
- }
+ BIP_RANGE
+ (0.3125),
+ }
};
+
static const struct comedi_lrange range_pcl813b_ai = { 4, {
- BIP_RANGE(5),
- BIP_RANGE(2.5),
- BIP_RANGE(1.25),
- BIP_RANGE(0.625),
- }
+ BIP_RANGE(5),
+ BIP_RANGE(2.5),
+ BIP_RANGE(1.25),
+ BIP_RANGE(0.625),
+ }
};
+
static const struct comedi_lrange range_pcl813b2_ai = { 4, {
- UNI_RANGE(10),
- UNI_RANGE(5),
- UNI_RANGE(2.5),
- UNI_RANGE(1.25),
- }
+ UNI_RANGE(10),
+ UNI_RANGE(5),
+ UNI_RANGE(2.5),
+ UNI_RANGE(1.25),
+ }
};
+
static const struct comedi_lrange range_iso813_1_ai = { 5, {
- BIP_RANGE(5),
- BIP_RANGE(2.5),
- BIP_RANGE(1.25),
- BIP_RANGE(0.625),
- BIP_RANGE(0.3125),
- }
+ BIP_RANGE(5),
+ BIP_RANGE(2.5),
+ BIP_RANGE(1.25),
+ BIP_RANGE(0.625),
+ BIP_RANGE(0.3125),
+ }
};
+
static const struct comedi_lrange range_iso813_1_2_ai = { 5, {
- UNI_RANGE(10),
- UNI_RANGE(5),
- UNI_RANGE(2.5),
- UNI_RANGE(1.25),
- UNI_RANGE(0.625),
- }
+ UNI_RANGE(10),
+ UNI_RANGE(5),
+ UNI_RANGE(2.5),
+ UNI_RANGE(1.25),
+ UNI_RANGE(0.625),
+ }
};
+
static const struct comedi_lrange range_iso813_2_ai = { 4, {
- BIP_RANGE(5),
- BIP_RANGE(2.5),
- BIP_RANGE(1.25),
- BIP_RANGE(0.625),
- }
+ BIP_RANGE(5),
+ BIP_RANGE(2.5),
+ BIP_RANGE(1.25),
+ BIP_RANGE(0.625),
+ }
};
+
static const struct comedi_lrange range_iso813_2_2_ai = { 4, {
- UNI_RANGE(10),
- UNI_RANGE(5),
- UNI_RANGE(2.5),
- UNI_RANGE(1.25),
- }
+ UNI_RANGE(10),
+ UNI_RANGE(5),
+ UNI_RANGE(2.5),
+ UNI_RANGE(1.25),
+ }
};
+
static const struct comedi_lrange range_acl8113_1_ai = { 4, {
- BIP_RANGE(5),
- BIP_RANGE(2.5),
- BIP_RANGE(1.25),
- BIP_RANGE(0.625),
- }
+ BIP_RANGE(5),
+ BIP_RANGE(2.5),
+ BIP_RANGE(1.25),
+ BIP_RANGE(0.625),
+ }
};
+
static const struct comedi_lrange range_acl8113_1_2_ai = { 4, {
- UNI_RANGE(10),
- UNI_RANGE(5),
- UNI_RANGE(2.5),
- UNI_RANGE(1.25),
- }
+ UNI_RANGE(10),
+ UNI_RANGE(5),
+ UNI_RANGE(2.5),
+ UNI_RANGE(1.25),
+ }
};
+
static const struct comedi_lrange range_acl8113_2_ai = { 3, {
- BIP_RANGE(5),
- BIP_RANGE(2.5),
- BIP_RANGE(1.25),
- }
+ BIP_RANGE(5),
+ BIP_RANGE(2.5),
+ BIP_RANGE(1.25),
+ }
};
+
static const struct comedi_lrange range_acl8113_2_2_ai = { 3, {
- UNI_RANGE(10),
- UNI_RANGE(5),
- UNI_RANGE(2.5),
- }
+ UNI_RANGE(10),
+ UNI_RANGE(5),
+ UNI_RANGE(2.5),
+ }
};
+
static const struct comedi_lrange range_acl8112dg_ai = { 9, {
- BIP_RANGE(5),
- BIP_RANGE(2.5),
- BIP_RANGE(1.25),
- BIP_RANGE(0.625),
- UNI_RANGE(10),
- UNI_RANGE(5),
- UNI_RANGE(2.5),
- UNI_RANGE(1.25),
- BIP_RANGE(10),
- }
+ BIP_RANGE(5),
+ BIP_RANGE(2.5),
+ BIP_RANGE(1.25),
+ BIP_RANGE(0.625),
+ UNI_RANGE(10),
+ UNI_RANGE(5),
+ UNI_RANGE(2.5),
+ UNI_RANGE(1.25),
+ BIP_RANGE(10),
+ }
};
+
static const struct comedi_lrange range_acl8112hg_ai = { 12, {
- BIP_RANGE(5),
- BIP_RANGE(0.5),
- BIP_RANGE(0.05),
- BIP_RANGE(0.005),
- UNI_RANGE(10),
- UNI_RANGE(1),
- UNI_RANGE(0.1),
- UNI_RANGE(0.01),
- BIP_RANGE(10),
- BIP_RANGE(1),
- BIP_RANGE(0.1),
- BIP_RANGE(0.01),
- }
+ BIP_RANGE(5),
+ BIP_RANGE(0.5),
+ BIP_RANGE(0.05),
+ BIP_RANGE(0.005),
+ UNI_RANGE(10),
+ UNI_RANGE(1),
+ UNI_RANGE(0.1),
+ UNI_RANGE(0.01),
+ BIP_RANGE(10),
+ BIP_RANGE(1),
+ BIP_RANGE(0.1),
+ BIP_RANGE(0.01),
+ }
};
+
static const struct comedi_lrange range_a821pgh_ai = { 4, {
- BIP_RANGE(5),
- BIP_RANGE(0.5),
- BIP_RANGE(0.05),
- BIP_RANGE(0.005),
- }
+ BIP_RANGE(5),
+ BIP_RANGE(0.5),
+ BIP_RANGE(0.05),
+ BIP_RANGE(0.005),
+ }
};
-static int pcl812_attach(struct comedi_device *dev, struct comedi_devconfig *it);
+static int pcl812_attach(struct comedi_device *dev,
+ struct comedi_devconfig *it);
static int pcl812_detach(struct comedi_device *dev);
struct pcl812_board {
@@ -316,62 +336,61 @@ struct pcl812_board {
unsigned char haveMPC508; /* 1=board use MPC508A multiplexor */
};
-
static const struct pcl812_board boardtypes[] = {
{"pcl812", boardPCL812, 16, 0, 2, 16, 16, 0x0fff,
- 33000, 500, &range_bipolar10, &range_unipolar5,
- 0xdcfc, 0x0a, PCLx1x_IORANGE, 0},
+ 33000, 500, &range_bipolar10, &range_unipolar5,
+ 0xdcfc, 0x0a, PCLx1x_IORANGE, 0},
{"pcl812pg", boardPCL812PG, 16, 0, 2, 16, 16, 0x0fff,
- 33000, 500, &range_pcl812pg_ai, &range_unipolar5,
- 0xdcfc, 0x0a, PCLx1x_IORANGE, 0},
+ 33000, 500, &range_pcl812pg_ai, &range_unipolar5,
+ 0xdcfc, 0x0a, PCLx1x_IORANGE, 0},
{"acl8112pg", boardPCL812PG, 16, 0, 2, 16, 16, 0x0fff,
- 10000, 500, &range_pcl812pg_ai, &range_unipolar5,
- 0xdcfc, 0x0a, PCLx1x_IORANGE, 0},
+ 10000, 500, &range_pcl812pg_ai, &range_unipolar5,
+ 0xdcfc, 0x0a, PCLx1x_IORANGE, 0},
{"acl8112dg", boardACL8112, 16, 8, 2, 16, 16, 0x0fff,
- 10000, 500, &range_acl8112dg_ai, &range_unipolar5,
- 0xdcfc, 0x0a, PCLx1x_IORANGE, 1},
+ 10000, 500, &range_acl8112dg_ai, &range_unipolar5,
+ 0xdcfc, 0x0a, PCLx1x_IORANGE, 1},
{"acl8112hg", boardACL8112, 16, 8, 2, 16, 16, 0x0fff,
- 10000, 500, &range_acl8112hg_ai, &range_unipolar5,
- 0xdcfc, 0x0a, PCLx1x_IORANGE, 1},
+ 10000, 500, &range_acl8112hg_ai, &range_unipolar5,
+ 0xdcfc, 0x0a, PCLx1x_IORANGE, 1},
{"a821pgl", boardA821, 16, 8, 1, 16, 16, 0x0fff,
- 10000, 500, &range_pcl813b_ai, &range_unipolar5,
- 0x000c, 0x00, PCLx1x_IORANGE, 0},
+ 10000, 500, &range_pcl813b_ai, &range_unipolar5,
+ 0x000c, 0x00, PCLx1x_IORANGE, 0},
{"a821pglnda", boardA821, 16, 8, 0, 0, 0, 0x0fff,
- 10000, 500, &range_pcl813b_ai, NULL,
- 0x000c, 0x00, PCLx1x_IORANGE, 0},
+ 10000, 500, &range_pcl813b_ai, NULL,
+ 0x000c, 0x00, PCLx1x_IORANGE, 0},
{"a821pgh", boardA821, 16, 8, 1, 16, 16, 0x0fff,
- 10000, 500, &range_a821pgh_ai, &range_unipolar5,
- 0x000c, 0x00, PCLx1x_IORANGE, 0},
+ 10000, 500, &range_a821pgh_ai, &range_unipolar5,
+ 0x000c, 0x00, PCLx1x_IORANGE, 0},
{"a822pgl", boardACL8112, 16, 8, 2, 16, 16, 0x0fff,
- 10000, 500, &range_acl8112dg_ai, &range_unipolar5,
- 0xdcfc, 0x0a, PCLx1x_IORANGE, 0},
+ 10000, 500, &range_acl8112dg_ai, &range_unipolar5,
+ 0xdcfc, 0x0a, PCLx1x_IORANGE, 0},
{"a822pgh", boardACL8112, 16, 8, 2, 16, 16, 0x0fff,
- 10000, 500, &range_acl8112hg_ai, &range_unipolar5,
- 0xdcfc, 0x0a, PCLx1x_IORANGE, 0},
+ 10000, 500, &range_acl8112hg_ai, &range_unipolar5,
+ 0xdcfc, 0x0a, PCLx1x_IORANGE, 0},
{"a823pgl", boardACL8112, 16, 8, 2, 16, 16, 0x0fff,
- 8000, 500, &range_acl8112dg_ai, &range_unipolar5,
- 0xdcfc, 0x0a, PCLx1x_IORANGE, 0},
+ 8000, 500, &range_acl8112dg_ai, &range_unipolar5,
+ 0xdcfc, 0x0a, PCLx1x_IORANGE, 0},
{"a823pgh", boardACL8112, 16, 8, 2, 16, 16, 0x0fff,
- 8000, 500, &range_acl8112hg_ai, &range_unipolar5,
- 0xdcfc, 0x0a, PCLx1x_IORANGE, 0},
+ 8000, 500, &range_acl8112hg_ai, &range_unipolar5,
+ 0xdcfc, 0x0a, PCLx1x_IORANGE, 0},
{"pcl813", boardPCL813, 32, 0, 0, 0, 0, 0x0fff,
- 0, 0, &range_pcl813b_ai, NULL,
- 0x0000, 0x00, PCLx1x_IORANGE, 0},
+ 0, 0, &range_pcl813b_ai, NULL,
+ 0x0000, 0x00, PCLx1x_IORANGE, 0},
{"pcl813b", boardPCL813B, 32, 0, 0, 0, 0, 0x0fff,
- 0, 0, &range_pcl813b_ai, NULL,
- 0x0000, 0x00, PCLx1x_IORANGE, 0},
+ 0, 0, &range_pcl813b_ai, NULL,
+ 0x0000, 0x00, PCLx1x_IORANGE, 0},
{"acl8113", boardACL8113, 32, 0, 0, 0, 0, 0x0fff,
- 0, 0, &range_acl8113_1_ai, NULL,
- 0x0000, 0x00, PCLx1x_IORANGE, 0},
+ 0, 0, &range_acl8113_1_ai, NULL,
+ 0x0000, 0x00, PCLx1x_IORANGE, 0},
{"iso813", boardISO813, 32, 0, 0, 0, 0, 0x0fff,
- 0, 0, &range_iso813_1_ai, NULL,
- 0x0000, 0x00, PCLx1x_IORANGE, 0},
+ 0, 0, &range_iso813_1_ai, NULL,
+ 0x0000, 0x00, PCLx1x_IORANGE, 0},
{"acl8216", boardACL8216, 16, 8, 2, 16, 16, 0xffff,
- 10000, 500, &range_pcl813b2_ai, &range_unipolar5,
- 0xdcfc, 0x0a, PCLx1x_IORANGE, 1},
+ 10000, 500, &range_pcl813b2_ai, &range_unipolar5,
+ 0xdcfc, 0x0a, PCLx1x_IORANGE, 1},
{"a826pg", boardACL8216, 16, 8, 2, 16, 16, 0xffff,
- 10000, 500, &range_pcl813b2_ai, &range_unipolar5,
- 0xdcfc, 0x0a, PCLx1x_IORANGE, 0},
+ 10000, 500, &range_pcl813b2_ai, &range_unipolar5,
+ 0xdcfc, 0x0a, PCLx1x_IORANGE, 0},
};
#define n_boardtypes (sizeof(boardtypes)/sizeof(struct pcl812_board))
@@ -410,7 +429,7 @@ struct pcl812_private {
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 */
+ 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 */
@@ -424,22 +443,24 @@ struct pcl812_private {
unsigned int ao_readback[2]; /* data for AO readback */
};
-
#define devpriv ((struct pcl812_private *)dev->private)
/*
==============================================================================
*/
-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,
- unsigned int rangechan, char wait);
-static int pcl812_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);
+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_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;
@@ -457,12 +478,12 @@ static int pcl812_ai_insn_read(struct comedi_device *dev, struct comedi_subdevic
udelay(1);
}
printk
- ("comedi%d: pcl812: (%s at 0x%lx) A/D insn read timeout\n",
- dev->minor, dev->board_name, dev->iobase);
+ ("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);
return -ETIME;
- conv_finish:
+conv_finish:
data[n] = ((hi & 0xf) << 8) | inb(dev->iobase + PCL812_AD_LO);
}
outb(devpriv->mode_reg_int | 0, dev->iobase + PCL812_MODE);
@@ -472,8 +493,9 @@ static int pcl812_ai_insn_read(struct comedi_device *dev, struct comedi_subdevic
/*
==============================================================================
*/
-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;
@@ -490,16 +512,15 @@ static int acl8216_ai_insn_read(struct comedi_device *dev, struct comedi_subdevi
udelay(1);
}
printk
- ("comedi%d: pcl812: (%s at 0x%lx) A/D insn read timeout\n",
- dev->minor, dev->board_name, dev->iobase);
+ ("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);
return -ETIME;
- conv_finish:
+conv_finish:
data[n] =
- (inb(dev->iobase +
- PCL812_AD_HI) << 8) | inb(dev->iobase +
- PCL812_AD_LO);
+ (inb(dev->iobase +
+ PCL812_AD_HI) << 8) | inb(dev->iobase + PCL812_AD_LO);
}
outb(0, dev->iobase + PCL812_MODE);
return n;
@@ -508,17 +529,18 @@ static int acl8216_ai_insn_read(struct comedi_device *dev, struct comedi_subdevi
/*
==============================================================================
*/
-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;
for (i = 0; i < insn->n; i++) {
outb((data[i] & 0xff),
- dev->iobase + (chan ? PCL812_DA2_LO : PCL812_DA1_LO));
+ dev->iobase + (chan ? PCL812_DA2_LO : PCL812_DA1_LO));
outb((data[i] >> 8) & 0x0f,
- dev->iobase + (chan ? PCL812_DA2_HI : PCL812_DA1_HI));
+ dev->iobase + (chan ? PCL812_DA2_HI : PCL812_DA1_HI));
devpriv->ao_readback[chan] = data[i];
}
@@ -528,8 +550,9 @@ static int pcl812_ao_insn_write(struct comedi_device *dev, struct comedi_subdevi
/*
==============================================================================
*/
-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;
@@ -544,8 +567,9 @@ static int pcl812_ao_insn_read(struct comedi_device *dev, struct comedi_subdevic
/*
==============================================================================
*/
-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;
@@ -559,8 +583,9 @@ static int pcl812_di_insn_bits(struct comedi_device *dev, struct comedi_subdevic
/*
==============================================================================
*/
-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;
@@ -583,21 +608,21 @@ static int pcl812_do_insn_bits(struct comedi_device *dev, struct comedi_subdevic
static void pcl812_cmdtest_out(int e, struct comedi_cmd *cmd)
{
printk("pcl812 e=%d startsrc=%x scansrc=%x convsrc=%x\n", e,
- cmd->start_src, cmd->scan_begin_src, cmd->convert_src);
+ cmd->start_src, cmd->scan_begin_src, cmd->convert_src);
printk("pcl812 e=%d startarg=%d scanarg=%d convarg=%d\n", e,
- cmd->start_arg, cmd->scan_begin_arg, cmd->convert_arg);
+ cmd->start_arg, cmd->scan_begin_arg, cmd->convert_arg);
printk("pcl812 e=%d stopsrc=%x scanend=%x\n", e, cmd->stop_src,
- cmd->scan_end_src);
+ cmd->scan_end_src);
printk("pcl812 e=%d stoparg=%d scanendarg=%d chanlistlen=%d\n", e,
- cmd->stop_arg, cmd->scan_end_arg, cmd->chanlist_len);
+ cmd->stop_arg, cmd->scan_end_arg, cmd->chanlist_len);
}
#endif
/*
==============================================================================
*/
-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;
@@ -641,8 +666,8 @@ static int pcl812_ai_cmdtest(struct comedi_device *dev, struct comedi_subdevice
#ifdef PCL812_EXTDEBUG
pcl812_cmdtest_out(1, cmd);
printk
- ("pcl812 EDBG: BGN: pcl812_ai_cmdtest(...) err=%d ret=1\n",
- err);
+ ("pcl812 EDBG: BGN: pcl812_ai_cmdtest(...) err=%d ret=1\n",
+ err);
#endif
return 1;
}
@@ -683,8 +708,8 @@ static int pcl812_ai_cmdtest(struct comedi_device *dev, struct comedi_subdevice
#ifdef PCL812_EXTDEBUG
pcl812_cmdtest_out(2, cmd);
printk
- ("pcl812 EDBG: BGN: pcl812_ai_cmdtest(...) err=%d ret=2\n",
- err);
+ ("pcl812 EDBG: BGN: pcl812_ai_cmdtest(...) err=%d ret=2\n",
+ err);
#endif
return 2;
}
@@ -741,8 +766,8 @@ static int pcl812_ai_cmdtest(struct comedi_device *dev, struct comedi_subdevice
#ifdef PCL812_EXTDEBUG
pcl812_cmdtest_out(3, cmd);
printk
- ("pcl812 EDBG: BGN: pcl812_ai_cmdtest(...) err=%d ret=3\n",
- err);
+ ("pcl812 EDBG: BGN: pcl812_ai_cmdtest(...) err=%d ret=3\n",
+ err);
#endif
return 3;
}
@@ -752,8 +777,8 @@ static int pcl812_ai_cmdtest(struct comedi_device *dev, struct comedi_subdevice
if (cmd->convert_src == TRIG_TIMER) {
tmp = cmd->convert_arg;
i8253_cascade_ns_to_timer(this_board->i8254_osc_base, &divisor1,
- &divisor2, &cmd->convert_arg,
- cmd->flags & TRIG_ROUND_MASK);
+ &divisor2, &cmd->convert_arg,
+ cmd->flags & TRIG_ROUND_MASK);
if (cmd->convert_arg < this_board->ai_ns_min)
cmd->convert_arg = this_board->ai_ns_min;
if (tmp != cmd->convert_arg)
@@ -763,8 +788,8 @@ static int pcl812_ai_cmdtest(struct comedi_device *dev, struct comedi_subdevice
if (err) {
#ifdef PCL812_EXTDEBUG
printk
- ("pcl812 EDBG: BGN: pcl812_ai_cmdtest(...) err=%d ret=4\n",
- err);
+ ("pcl812 EDBG: BGN: pcl812_ai_cmdtest(...) err=%d ret=4\n",
+ err);
#endif
return 4;
}
@@ -806,15 +831,16 @@ static int pcl812_ai_cmd(struct comedi_device *dev, struct comedi_subdevice *s)
if (cmd->convert_arg < this_board->ai_ns_min)
cmd->convert_arg = this_board->ai_ns_min;
i8253_cascade_ns_to_timer(this_board->i8254_osc_base,
- &divisor1, &divisor2, &cmd->convert_arg,
- cmd->flags & TRIG_ROUND_MASK);
+ &divisor1, &divisor2,
+ &cmd->convert_arg,
+ cmd->flags & TRIG_ROUND_MASK);
}
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);
+ sizeof(unsigned int) * cmd->scan_end_arg);
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 */
@@ -851,19 +877,19 @@ static int pcl812_ai_cmd(struct comedi_device *dev, struct comedi_subdevice *s)
if (devpriv->ai_dma) {
if (devpriv->ai_eos) { /* we use EOS, so adapt DMA buffer to one scan */
devpriv->dmabytestomove[0] =
- devpriv->ai_n_chan * sizeof(short);
+ devpriv->ai_n_chan * sizeof(short);
devpriv->dmabytestomove[1] =
- devpriv->ai_n_chan * sizeof(short);
+ devpriv->ai_n_chan * sizeof(short);
devpriv->dma_runs_to_end = 1;
} else {
devpriv->dmabytestomove[0] = devpriv->hwdmasize[0];
devpriv->dmabytestomove[1] = devpriv->hwdmasize[1];
if (devpriv->ai_data_len < devpriv->hwdmasize[0])
devpriv->dmabytestomove[0] =
- devpriv->ai_data_len;
+ devpriv->ai_data_len;
if (devpriv->ai_data_len < devpriv->hwdmasize[1])
devpriv->dmabytestomove[1] =
- devpriv->ai_data_len;
+ devpriv->ai_data_len;
if (devpriv->ai_neverending) {
devpriv->dma_runs_to_end = 1;
} else {
@@ -872,7 +898,7 @@ static int pcl812_ai_cmd(struct comedi_device *dev, struct comedi_subdevice *s)
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;
+ devpriv->last_dma_run;
devpriv->dma_runs_to_end--;
}
}
@@ -894,10 +920,10 @@ static int pcl812_ai_cmd(struct comedi_device *dev, struct comedi_subdevice *s)
enable_dma(devpriv->dma);
#ifdef PCL812_EXTDEBUG
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],
- devpriv->dmabytestomove[1], devpriv->ai_eos);
+ ("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],
+ devpriv->dmabytestomove[1], devpriv->ai_eos);
#endif
}
@@ -955,8 +981,8 @@ static irqreturn_t interrupt_pcl812_ai_int(int irq, void *d)
if (err) {
printk
- ("comedi%d: pcl812: (%s at 0x%lx) A/D cmd IRQ without DRDY!\n",
- dev->minor, dev->board_name, dev->iobase);
+ ("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);
s->async->events |= COMEDI_CB_EOA | COMEDI_CB_ERROR;
comedi_event(dev, s);
@@ -964,8 +990,8 @@ static irqreturn_t interrupt_pcl812_ai_int(int irq, void *d)
}
comedi_buf_put(s->async,
- ((inb(dev->iobase + PCL812_AD_HI) << 8) | inb(dev->iobase +
- PCL812_AD_LO)) & mask);
+ ((inb(dev->iobase + PCL812_AD_HI) << 8) |
+ inb(dev->iobase + PCL812_AD_LO)) & mask);
outb(0, dev->iobase + PCL812_CLRINT); /* clear INT request */
@@ -985,8 +1011,9 @@ 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;
@@ -1022,9 +1049,9 @@ static irqreturn_t interrupt_pcl812_ai_dma(int irq, void *d)
#ifdef PCL812_EXTDEBUG
printk("pcl812 EDBG: BGN: interrupt_pcl812_ai_dma(...)\n");
#endif
- ptr = (short *) devpriv->dmabuf[devpriv->next_dma_buf];
+ ptr = (short *)devpriv->dmabuf[devpriv->next_dma_buf];
len = (devpriv->dmabytestomove[devpriv->next_dma_buf] >> 1) -
- devpriv->ai_poll_ptr;
+ devpriv->ai_poll_ptr;
devpriv->next_dma_buf = 1 - devpriv->next_dma_buf;
disable_dma(devpriv->dma);
@@ -1033,11 +1060,12 @@ static irqreturn_t interrupt_pcl812_ai_dma(int irq, void *d)
set_dma_addr(devpriv->dma, devpriv->hwdmaptr[devpriv->next_dma_buf]);
if (devpriv->ai_eos) {
set_dma_count(devpriv->dma,
- devpriv->dmabytestomove[devpriv->next_dma_buf]);
+ devpriv->dmabytestomove[devpriv->next_dma_buf]);
} else {
if (devpriv->dma_runs_to_end) {
set_dma_count(devpriv->dma,
- devpriv->dmabytestomove[devpriv->next_dma_buf]);
+ devpriv->dmabytestomove[devpriv->
+ next_dma_buf]);
} else {
set_dma_count(devpriv->dma, devpriv->last_dma_run);
}
@@ -1111,8 +1139,9 @@ static int pcl812_ai_poll(struct comedi_device *dev, struct comedi_subdevice *s)
}
transfer_from_dma_buf(dev, s,
- (void *)devpriv->dmabuf[1 - devpriv->next_dma_buf],
- devpriv->ai_poll_ptr, top2);
+ (void *)devpriv->dmabuf[1 -
+ devpriv->next_dma_buf],
+ devpriv->ai_poll_ptr, top2);
devpriv->ai_poll_ptr = top1; /* new buffer position */
@@ -1124,14 +1153,15 @@ static int pcl812_ai_poll(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 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 */
if ((chan_reg == devpriv->old_chan_reg)
- && (gain_reg == devpriv->old_gain_reg))
+ && (gain_reg == devpriv->old_gain_reg))
return; /* we can return, no change */
devpriv->old_chan_reg = chan_reg;
@@ -1160,12 +1190,12 @@ static void setup_range_channel(struct comedi_device *dev, struct comedi_subdevi
/*
==============================================================================
*/
-static void start_pacer(struct comedi_device *dev, int mode, unsigned int divisor1,
- unsigned int divisor2)
+static void start_pacer(struct comedi_device *dev, int mode,
+ unsigned int divisor1, unsigned int divisor2)
{
#ifdef PCL812_EXTDEBUG
printk("pcl812 EDBG: BGN: start_pacer(%d,%u,%u)\n", mode, divisor1,
- divisor2);
+ divisor2);
#endif
outb(0xb4, dev->iobase + PCL812_CTRCTL);
outb(0x74, dev->iobase + PCL812_CTRCTL);
@@ -1205,7 +1235,8 @@ 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
printk("pcl812 EDBG: BGN: pcl812_ai_cancel(...)\n");
@@ -1279,7 +1310,7 @@ static int pcl812_attach(struct comedi_device *dev, struct comedi_devconfig *it)
iobase = it->options[0];
printk("comedi%d: pcl812: board=%s, ioport=0x%03lx", dev->minor,
- this_board->name, iobase);
+ this_board->name, iobase);
if (!request_region(iobase, this_board->io_range, "pcl812")) {
printk("I/O port conflict\n");
@@ -1300,11 +1331,16 @@ static int pcl812_attach(struct comedi_device *dev, struct comedi_devconfig *it)
irq = it->options[1];
if (irq) { /* we want to use IRQ */
if (((1 << irq) & this_board->IRQbits) == 0) {
- printk(", IRQ %u is out of allowed range, DISABLING IT", irq);
+ printk
+ (", IRQ %u is out of allowed range, DISABLING IT",
+ irq);
irq = 0; /* Bad IRQ */
} else {
- if (request_irq(irq, interrupt_pcl812, 0, "pcl812", dev)) {
- printk(", unable to allocate IRQ %u, DISABLING IT", irq);
+ 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 {
printk(", irq=%u", irq);
@@ -1353,7 +1389,7 @@ static int pcl812_attach(struct comedi_device *dev, struct comedi_devconfig *it)
devpriv->hwdmaptr[1] = virt_to_bus((void *)devpriv->dmabuf[1]);
devpriv->hwdmasize[1] = PAGE_SIZE * (1 << pages);
}
- no_dma:
+no_dma:
n_subdevices = 0;
if (this_board->n_aichan > 0)
@@ -1450,7 +1486,9 @@ static int pcl812_attach(struct comedi_device *dev, struct comedi_devconfig *it)
default:
s->range_table = &range_bipolar10;
break;
- printk(", incorrect range number %d, changing to 0 (+/-10V)", it->options[4]);
+ printk
+ (", incorrect range number %d, changing to 0 (+/-10V)",
+ it->options[4]);
break;
}
break;
@@ -1478,7 +1516,9 @@ static int pcl812_attach(struct comedi_device *dev, struct comedi_devconfig *it)
default:
s->range_table = &range_iso813_1_ai;
break;
- printk(", incorrect range number %d, changing to 0 ", it->options[1]);
+ printk
+ (", incorrect range number %d, changing to 0 ",
+ it->options[1]);
break;
}
break;
@@ -1501,7 +1541,9 @@ static int pcl812_attach(struct comedi_device *dev, struct comedi_devconfig *it)
default:
s->range_table = &range_acl8113_1_ai;
break;
- printk(", incorrect range number %d, changing to 0 ", it->options[1]);
+ printk
+ (", incorrect range number %d, changing to 0 ",
+ it->options[1]);
break;
}
break;
diff --git a/drivers/staging/comedi/drivers/pcl816.c b/drivers/staging/comedi/drivers/pcl816.c
index 19465c1b53c3..fa2414500a07 100644
--- a/drivers/staging/comedi/drivers/pcl816.c
+++ b/drivers/staging/comedi/drivers/pcl816.c
@@ -91,16 +91,17 @@ Configuration Options:
#define MAGIC_DMA_WORD 0x5a5a
static const struct comedi_lrange range_pcl816 = { 8, {
- BIP_RANGE(10),
- BIP_RANGE(5),
- BIP_RANGE(2.5),
- BIP_RANGE(1.25),
- UNI_RANGE(10),
- UNI_RANGE(5),
- UNI_RANGE(2.5),
- UNI_RANGE(1.25),
- }
+ BIP_RANGE(10),
+ BIP_RANGE(5),
+ BIP_RANGE(2.5),
+ BIP_RANGE(1.25),
+ UNI_RANGE(10),
+ UNI_RANGE(5),
+ UNI_RANGE(2.5),
+ UNI_RANGE(1.25),
+ }
};
+
struct pcl816_board {
const char *name; /* board name */
@@ -122,33 +123,33 @@ struct pcl816_board {
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 */
- 1024,
- 1, /* ao chan list */
- 100},
+ &range_pcl816, PCLx1x_RANGE,
+ 0x00fc, /* IRQ mask */
+ 0x0a, /* DMA mask */
+ 0xffff, /* 16-bit card */
+ 0xffff, /* D/A maxdata */
+ 1024,
+ 1, /* ao chan list */
+ 100},
{"pcl814b", 8, 16, 10000, 1, 16, 16, &range_pcl816,
- &range_pcl816, PCLx1x_RANGE,
- 0x00fc,
- 0x0a,
- 0x3fff, /* 14 bit card */
- 0x3fff,
- 1024,
- 1,
- 100},
+ &range_pcl816, PCLx1x_RANGE,
+ 0x00fc,
+ 0x0a,
+ 0x3fff, /* 14 bit card */
+ 0x3fff,
+ 1024,
+ 1,
+ 100},
};
#define n_boardtypes (sizeof(boardtypes)/sizeof(struct pcl816_board))
#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_attach(struct comedi_device *dev,
+ struct comedi_devconfig *it);
static int pcl816_detach(struct comedi_device *dev);
#ifdef unused
@@ -209,29 +210,32 @@ struct pcl816_private {
#endif
};
-
/*
==============================================================================
*/
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);
+ 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_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;
@@ -253,12 +257,12 @@ static int pcl816_ai_insn_read(struct comedi_device *dev, struct comedi_subdevic
timeout = 100;
while (timeout--) {
if (!(inb(dev->iobase + PCL816_STATUS) &
- PCL816_STATUS_DRDY_MASK)) {
+ PCL816_STATUS_DRDY_MASK)) {
/* return read value */
data[n] =
- ((inb(dev->iobase +
- PCL816_AD_HI) << 8) |
- (inb(dev->iobase + PCL816_AD_LO)));
+ ((inb(dev->iobase +
+ PCL816_AD_HI) << 8) |
+ (inb(dev->iobase + PCL816_AD_LO)));
outb(0, dev->iobase + PCL816_CLRINT); /* clear INT (conversion end) flag */
break;
@@ -291,7 +295,7 @@ static irqreturn_t interrupt_pcl816_ai_mode13_int(int irq, void *d)
while (timeout--) {
if (!(inb(dev->iobase + PCL816_STATUS) &
- PCL816_STATUS_DRDY_MASK))
+ PCL816_STATUS_DRDY_MASK))
break;
udelay(1);
}
@@ -334,8 +338,9 @@ 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;
@@ -346,7 +351,7 @@ static void transfer_from_dma_buf(struct comedi_device *dev, struct comedi_subde
comedi_buf_put(s->async, ptr[bufptr++]);
if (++devpriv->ai_act_chanlist_pos >=
- devpriv->ai_act_chanlist_len) {
+ devpriv->ai_act_chanlist_len) {
devpriv->ai_act_chanlist_pos = 0;
devpriv->ai_act_scan++;
}
@@ -381,10 +386,11 @@ static irqreturn_t interrupt_pcl816_ai_mode13_dma(int irq, void *d)
dma_flags = claim_dma_lock();
/* clear_dma_ff (devpriv->dma); */
set_dma_addr(devpriv->dma,
- devpriv->hwdmaptr[devpriv->next_dma_buf]);
+ devpriv->hwdmaptr[devpriv->next_dma_buf]);
if (devpriv->dma_runs_to_end) {
set_dma_count(devpriv->dma,
- devpriv->hwdmasize[devpriv->next_dma_buf]);
+ devpriv->hwdmasize[devpriv->
+ next_dma_buf]);
} else {
set_dma_count(devpriv->dma, devpriv->last_dma_run);
}
@@ -395,7 +401,7 @@ static irqreturn_t interrupt_pcl816_ai_mode13_dma(int irq, void *d)
devpriv->dma_runs_to_end--;
outb(0, dev->iobase + PCL816_CLRINT); /* clear INT request */
- ptr = (short *) devpriv->dmabuf[this_dma_buf];
+ ptr = (short *)devpriv->dmabuf[this_dma_buf];
len = (devpriv->hwdmasize[0] >> 1) - devpriv->ai_poll_ptr;
bufptr = devpriv->ai_poll_ptr;
@@ -430,7 +436,7 @@ static irqreturn_t interrupt_pcl816(int irq, void *d)
outb(0, dev->iobase + PCL816_CLRINT); /* clear INT request */
if ((!dev->irq) | (!devpriv->irq_free) | (!devpriv->irq_blocked) |
- (!devpriv->int816_mode)) {
+ (!devpriv->int816_mode)) {
if (devpriv->irq_was_now_closed) {
devpriv->irq_was_now_closed = 0;
/* comedi_error(dev,"last IRQ.."); */
@@ -450,26 +456,26 @@ static irqreturn_t interrupt_pcl816(int irq, void *d)
static void pcl816_cmdtest_out(int e, struct comedi_cmd *cmd)
{
printk("pcl816 e=%d startsrc=%x scansrc=%x convsrc=%x\n", e,
- cmd->start_src, cmd->scan_begin_src, cmd->convert_src);
+ cmd->start_src, cmd->scan_begin_src, cmd->convert_src);
printk("pcl816 e=%d startarg=%d scanarg=%d convarg=%d\n", e,
- cmd->start_arg, cmd->scan_begin_arg, cmd->convert_arg);
+ cmd->start_arg, cmd->scan_begin_arg, cmd->convert_arg);
printk("pcl816 e=%d stopsrc=%x scanend=%x\n", e, cmd->stop_src,
- cmd->scan_end_src);
+ cmd->scan_end_src);
printk("pcl816 e=%d stoparg=%d scanendarg=%d chanlistlen=%d\n", e,
- cmd->stop_arg, cmd->scan_end_arg, cmd->chanlist_len);
+ 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(printk("pcl816 pcl812_ai_cmdtest\n");
- pcl816_cmdtest_out(-1, cmd););
+ DEBUG(printk("pcl816 pcl812_ai_cmdtest\n"); pcl816_cmdtest_out(-1, cmd);
+ );
/* step 1: make sure trigger sources are trivially valid */
tmp = cmd->start_src;
@@ -582,8 +588,9 @@ static int pcl816_ai_cmdtest(struct comedi_device *dev, struct comedi_subdevice
if (cmd->convert_src == TRIG_TIMER) {
tmp = cmd->convert_arg;
i8253_cascade_ns_to_timer(this_board->i8254_osc_base,
- &divisor1, &divisor2, &cmd->convert_arg,
- cmd->flags & TRIG_ROUND_MASK);
+ &divisor1, &divisor2,
+ &cmd->convert_arg,
+ cmd->flags & TRIG_ROUND_MASK);
if (cmd->convert_arg < this_board->ai_ns_min)
cmd->convert_arg = this_board->ai_ns_min;
if (tmp != cmd->convert_arg)
@@ -619,8 +626,8 @@ static int pcl816_ai_cmd(struct comedi_device *dev, struct comedi_subdevice *s)
cmd->convert_arg = this_board->ai_ns_min;
i8253_cascade_ns_to_timer(this_board->i8254_osc_base, &divisor1,
- &divisor2, &cmd->convert_arg,
- cmd->flags & TRIG_ROUND_MASK);
+ &divisor2, &cmd->convert_arg,
+ cmd->flags & TRIG_ROUND_MASK);
if (divisor1 == 1) { /* PCL816 crash if any divisor is set to 1 */
divisor1 = 2;
divisor2 /= 2;
@@ -634,7 +641,7 @@ static int pcl816_ai_cmd(struct comedi_device *dev, struct comedi_subdevice *s)
start_pacer(dev, -1, 0, 0); /* stop pacer */
if (!check_and_setup_channel_list(dev, s, cmd->chanlist,
- cmd->chanlist_len))
+ cmd->chanlist_len))
return -EINVAL;
udelay(1);
@@ -732,8 +739,8 @@ static int pcl816_ai_poll(struct comedi_device *dev, struct comedi_subdevice *s)
}
transfer_from_dma_buf(dev, s,
- (short *) devpriv->dmabuf[devpriv->next_dma_buf],
- devpriv->ai_poll_ptr, top2);
+ (short *)devpriv->dmabuf[devpriv->next_dma_buf],
+ devpriv->ai_poll_ptr, top2);
devpriv->ai_poll_ptr = top1; /* new buffer position */
spin_unlock_irqrestore(&dev->spinlock, flags);
@@ -745,7 +752,8 @@ static int pcl816_ai_poll(struct comedi_device *dev, struct comedi_subdevice *s)
==============================================================================
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(printk("pcl816_ai_cancel()\n");) */
@@ -781,9 +789,8 @@ static int pcl816_ai_cancel(struct comedi_device *dev, struct comedi_subdevice *
}
}
- DEBUG(printk("comedi: pcl816_ai_cancel() successful\n");
- )
- return 0;
+ DEBUG(printk("comedi: pcl816_ai_cancel() successful\n");)
+ return 0;
}
/*
@@ -836,7 +843,7 @@ static void pcl816_reset(struct comedi_device *dev)
*/
static void
start_pacer(struct comedi_device *dev, int mode, unsigned int divisor1,
- unsigned int divisor2)
+ unsigned int divisor2)
{
outb(0x32, dev->iobase + PCL816_CTRCTL);
outb(0xff, dev->iobase + PCL816_CTR0);
@@ -865,8 +872,9 @@ 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,
- unsigned int *chanlist, int chanlen)
+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;
@@ -882,18 +890,17 @@ check_and_setup_channel_list(struct comedi_device *dev, struct comedi_subdevice
for (i = 1, seglen = 1; i < chanlen; i++, seglen++) {
/* build part of chanlist */
DEBUG(printk("%d. %d %d\n", i, CR_CHAN(chanlist[i]),
- CR_RANGE(chanlist[i]));
- )
- if (chanlist[0] == chanlist[i])
+ CR_RANGE(chanlist[i]));)
+ if (chanlist[0] == chanlist[i])
break; /* we detect loop, this must by finish */
nowmustbechan =
- (CR_CHAN(chansegment[i - 1]) + 1) % chanlen;
+ (CR_CHAN(chansegment[i - 1]) + 1) % chanlen;
if (nowmustbechan != CR_CHAN(chanlist[i])) {
/* 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]));
+ ("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 */
@@ -901,20 +908,19 @@ check_and_setup_channel_list(struct comedi_device *dev, struct comedi_subdevice
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]) {
+ CR_CHAN(chansegment[i % seglen]),
+ CR_RANGE(chansegment[i % seglen]),
+ CR_CHAN(chanlist[i]),
+ CR_RANGE(chanlist[i]));)
+ if (chanlist[i] != chansegment[i % seglen]) {
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]),
- CR_AREF(chansegment[i]),
- CR_CHAN(chanlist[i % seglen]),
- CR_RANGE(chanlist[i % seglen]),
- CR_AREF(chansegment[i % seglen]));
+ ("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]),
+ CR_AREF(chansegment[i]),
+ CR_CHAN(chanlist[i % seglen]),
+ CR_RANGE(chanlist[i % seglen]),
+ CR_AREF(chansegment[i % seglen]));
return 0; /* chan/gain list is strange */
}
}
@@ -997,7 +1003,7 @@ static void free_resources(struct comedi_device *dev)
if ((devpriv->dma_rtc) && (RTC_lock == 1)) {
if (devpriv->rtc_iobase)
release_region(devpriv->rtc_iobase,
- devpriv->rtc_iosize);
+ devpriv->rtc_iosize);
}
#endif
}
@@ -1027,7 +1033,7 @@ static int pcl816_attach(struct comedi_device *dev, struct comedi_devconfig *it)
/* claim our I/O space */
iobase = it->options[0];
printk("comedi%d: pcl816: board=%s, ioport=0x%03lx", dev->minor,
- this_board->name, iobase);
+ this_board->name, iobase);
if (!request_region(iobase, this_board->io_range, "pcl816")) {
printk("I/O port conflict\n");
@@ -1055,14 +1061,15 @@ static int pcl816_attach(struct comedi_device *dev, struct comedi_devconfig *it)
if (irq) { /* we want to use IRQ */
if (((1 << irq) & this_board->IRQbits) == 0) {
printk
- (", IRQ %u is out of allowed range, DISABLING IT",
- irq);
+ (", IRQ %u is out of allowed range, DISABLING IT",
+ irq);
irq = 0; /* Bad IRQ */
} else {
- if (request_irq(irq, interrupt_pcl816, 0, "pcl816", dev)) {
+ if (request_irq
+ (irq, interrupt_pcl816, 0, "pcl816", dev)) {
printk
- (", unable to allocate IRQ %u, DISABLING IT",
- irq);
+ (", unable to allocate IRQ %u, DISABLING IT",
+ irq);
irq = 0; /* Can't use IRQ */
} else {
printk(", irq=%u", irq);
@@ -1087,7 +1094,7 @@ static int pcl816_attach(struct comedi_device *dev, struct comedi_devconfig *it)
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)"))
+ "pcl816 (RTC)"))
goto no_rtc;
}
devpriv->rtc_iobase = RTC_PORT(0);
@@ -1095,7 +1102,7 @@ static int pcl816_attach(struct comedi_device *dev, struct comedi_devconfig *it)
RTC_lock++;
#ifdef UNTESTED_CODE
if (!request_irq(RTC_IRQ, interrupt_pcl816_ai_mode13_dma_rtc, 0,
- "pcl816 DMA (RTC)", dev)) {
+ "pcl816 DMA (RTC)", dev)) {
devpriv->dma_rtc = 1;
devpriv->rtc_irq = RTC_IRQ;
printk(", dma_irq=%u", devpriv->rtc_irq);
@@ -1104,7 +1111,7 @@ static int pcl816_attach(struct comedi_device *dev, struct comedi_devconfig *it)
if (RTC_lock == 0) {
if (devpriv->rtc_iobase)
release_region(devpriv->rtc_iobase,
- devpriv->rtc_iosize);
+ devpriv->rtc_iosize);
}
devpriv->rtc_iobase = 0;
devpriv->rtc_iosize = 0;
@@ -1115,7 +1122,7 @@ static int pcl816_attach(struct comedi_device *dev, struct comedi_devconfig *it)
}
- no_rtc:
+no_rtc:
#endif
/* grab our DMA */
dma = 0;
@@ -1157,17 +1164,17 @@ static int pcl816_attach(struct comedi_device *dev, struct comedi_devconfig *it)
devpriv->dmabuf[1] = __get_dma_pages(GFP_KERNEL, pages);
if (!devpriv->dmabuf[1]) {
printk
- (", unable to allocate DMA buffer, FAIL!\n");
+ (", unable to allocate DMA buffer, FAIL!\n");
return -EBUSY;
}
devpriv->dmapages[1] = pages;
devpriv->hwdmaptr[1] =
- virt_to_bus((void *)devpriv->dmabuf[1]);
+ virt_to_bus((void *)devpriv->dmabuf[1]);
devpriv->hwdmasize[1] = (1 << pages) * PAGE_SIZE;
}
}
- no_dma:
+no_dma:
/* if (this_board->n_aochan > 0)
subdevs[1] = COMEDI_SUBD_AO;
@@ -1241,9 +1248,8 @@ case COMEDI_SUBD_DO:
*/
static int pcl816_detach(struct comedi_device *dev)
{
- DEBUG(printk("comedi%d: pcl816: remove\n", dev->minor);
- )
- free_resources(dev);
+ DEBUG(printk("comedi%d: pcl816: remove\n", dev->minor);)
+ free_resources(dev);
#ifdef unused
if (devpriv->dma_rtc)
RTC_lock--;
diff --git a/drivers/staging/comedi/drivers/pcl818.c b/drivers/staging/comedi/drivers/pcl818.c
index 039a77a66451..e95229b13118 100644
--- a/drivers/staging/comedi/drivers/pcl818.c
+++ b/drivers/staging/comedi/drivers/pcl818.c
@@ -195,56 +195,58 @@ A word or two about DMA. Driver support DMA operations at two ways:
#define MAGIC_DMA_WORD 0x5a5a
static const struct comedi_lrange range_pcl818h_ai = { 9, {
- BIP_RANGE(5),
- BIP_RANGE(2.5),
- BIP_RANGE(1.25),
- BIP_RANGE(0.625),
- UNI_RANGE(10),
- UNI_RANGE(5),
- UNI_RANGE(2.5),
- UNI_RANGE(1.25),
- BIP_RANGE(10),
- }
+ BIP_RANGE(5),
+ BIP_RANGE(2.5),
+ BIP_RANGE(1.25),
+ BIP_RANGE(0.625),
+ UNI_RANGE(10),
+ UNI_RANGE(5),
+ UNI_RANGE(2.5),
+ UNI_RANGE(1.25),
+ BIP_RANGE(10),
+ }
};
static const struct comedi_lrange range_pcl818hg_ai = { 10, {
- BIP_RANGE(5),
- BIP_RANGE(0.5),
- BIP_RANGE(0.05),
- BIP_RANGE(0.005),
- UNI_RANGE(10),
- UNI_RANGE(1),
- UNI_RANGE(0.1),
- UNI_RANGE(0.01),
- BIP_RANGE(10),
- BIP_RANGE(1),
- BIP_RANGE(0.1),
- BIP_RANGE(0.01),
- }
+ BIP_RANGE(5),
+ BIP_RANGE(0.5),
+ BIP_RANGE(0.05),
+ BIP_RANGE(0.005),
+ UNI_RANGE(10),
+ UNI_RANGE(1),
+ UNI_RANGE(0.1),
+ UNI_RANGE(0.01),
+ BIP_RANGE(10),
+ BIP_RANGE(1),
+ BIP_RANGE(0.1),
+ BIP_RANGE(0.01),
+ }
};
static const struct comedi_lrange range_pcl818l_l_ai = { 4, {
- BIP_RANGE(5),
- BIP_RANGE(2.5),
- BIP_RANGE(1.25),
- BIP_RANGE(0.625),
- }
+ BIP_RANGE(5),
+ BIP_RANGE(2.5),
+ BIP_RANGE(1.25),
+ BIP_RANGE(0.625),
+ }
};
static const struct comedi_lrange range_pcl818l_h_ai = { 4, {
- BIP_RANGE(10),
- BIP_RANGE(5),
- BIP_RANGE(2.5),
- BIP_RANGE(1.25),
- }
+ BIP_RANGE(10),
+ BIP_RANGE(5),
+ BIP_RANGE(2.5),
+ BIP_RANGE(1.25),
+ }
};
static const struct comedi_lrange range718_bipolar1 = { 1, {BIP_RANGE(1),} };
-static const struct comedi_lrange range718_bipolar0_5 = { 1, {BIP_RANGE(0.5),} };
+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_attach(struct comedi_device *dev,
+ struct comedi_devconfig *it);
static int pcl818_detach(struct comedi_device *dev);
#ifdef unused
@@ -273,30 +275,29 @@ struct pcl818_board {
int is_818;
};
-
static const struct pcl818_board boardtypes[] = {
{"pcl818l", 4, 16, 8, 25000, 1, 16, 16, &range_pcl818l_l_ai,
- &range_unipolar5, PCLx1x_RANGE, 0x00fc,
- 0x0a, 0xfff, 0xfff, 0, 1},
+ &range_unipolar5, PCLx1x_RANGE, 0x00fc,
+ 0x0a, 0xfff, 0xfff, 0, 1},
{"pcl818h", 9, 16, 8, 10000, 1, 16, 16, &range_pcl818h_ai,
- &range_unipolar5, PCLx1x_RANGE, 0x00fc,
- 0x0a, 0xfff, 0xfff, 0, 1},
+ &range_unipolar5, PCLx1x_RANGE, 0x00fc,
+ 0x0a, 0xfff, 0xfff, 0, 1},
{"pcl818hd", 9, 16, 8, 10000, 1, 16, 16, &range_pcl818h_ai,
- &range_unipolar5, PCLx1x_RANGE, 0x00fc,
- 0x0a, 0xfff, 0xfff, 1, 1},
+ &range_unipolar5, PCLx1x_RANGE, 0x00fc,
+ 0x0a, 0xfff, 0xfff, 1, 1},
{"pcl818hg", 12, 16, 8, 10000, 1, 16, 16, &range_pcl818hg_ai,
- &range_unipolar5, PCLx1x_RANGE, 0x00fc,
- 0x0a, 0xfff, 0xfff, 1, 1},
+ &range_unipolar5, PCLx1x_RANGE, 0x00fc,
+ 0x0a, 0xfff, 0xfff, 1, 1},
{"pcl818", 9, 16, 8, 10000, 2, 16, 16, &range_pcl818h_ai,
- &range_unipolar5, PCLx1x_RANGE, 0x00fc,
- 0x0a, 0xfff, 0xfff, 0, 1},
+ &range_unipolar5, PCLx1x_RANGE, 0x00fc,
+ 0x0a, 0xfff, 0xfff, 0, 1},
{"pcl718", 1, 16, 8, 16000, 2, 16, 16, &range_unipolar5,
- &range_unipolar5, PCLx1x_RANGE, 0x00fc,
- 0x0a, 0xfff, 0xfff, 0, 0},
+ &range_unipolar5, PCLx1x_RANGE, 0x00fc,
+ 0x0a, 0xfff, 0xfff, 0, 0},
/* pcm3718 */
{"pcm3718", 9, 16, 8, 10000, 0, 16, 16, &range_pcl818h_ai,
- &range_unipolar5, PCLx1x_RANGE, 0x00fc,
- 0x0a, 0xfff, 0xfff, 0, 1 /* XXX ? */ },
+ &range_unipolar5, PCLx1x_RANGE, 0x00fc,
+ 0x0a, 0xfff, 0xfff, 0, 1 /* XXX ? */ },
};
#define n_boardtypes (sizeof(boardtypes)/sizeof(struct pcl818_board))
@@ -353,7 +354,7 @@ struct pcl818_private {
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 */
+ short *ai_data; /* data buffer */
unsigned int ai_timer1; /* timers */
unsigned int ai_timer2;
struct comedi_subdevice *sub_ai; /* ptr to AI subdevice */
@@ -361,7 +362,6 @@ struct pcl818_private {
unsigned int ao_readback[2];
};
-
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,14 +372,18 @@ 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,
- unsigned int *chanlist, unsigned int n_chan, unsigned int seglen);
-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,
- unsigned int divisor2);
+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,
+ 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, unsigned int divisor2);
#ifdef unused
static int set_rtc_irq_bit(unsigned char bit);
@@ -391,8 +395,9 @@ 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;
@@ -425,9 +430,9 @@ static int pcl818_ai_insn_read(struct comedi_device *dev, struct comedi_subdevic
outb(0, dev->iobase + PCL818_CLRINT);
return -EIO;
- conv_finish:
+conv_finish:
data[n] = ((inb(dev->iobase + PCL818_AD_HI) << 4) |
- (inb(dev->iobase + PCL818_AD_LO) >> 4));
+ (inb(dev->iobase + PCL818_AD_LO) >> 4));
}
return n;
@@ -438,8 +443,9 @@ static int pcl818_ai_insn_read(struct comedi_device *dev, struct comedi_subdevic
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 +457,9 @@ static int pcl818_ao_insn_read(struct comedi_device *dev, struct comedi_subdevic
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);
@@ -460,9 +467,9 @@ static int pcl818_ao_insn_write(struct comedi_device *dev, struct comedi_subdevi
for (n = 0; n < insn->n; n++) {
devpriv->ao_readback[chan] = data[n];
outb((data[n] & 0x000f) << 4, dev->iobase +
- (chan ? PCL718_DA2_LO : PCL818_DA_LO));
+ (chan ? PCL718_DA2_LO : PCL818_DA_LO));
outb((data[n] & 0x0ff0) >> 4, dev->iobase +
- (chan ? PCL718_DA2_HI : PCL818_DA_HI));
+ (chan ? PCL718_DA2_HI : PCL818_DA_HI));
}
return n;
@@ -474,14 +481,15 @@ static int pcl818_ao_insn_write(struct comedi_device *dev, struct comedi_subdevi
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;
data[1] = inb(dev->iobase + PCL818_DI_LO) |
- (inb(dev->iobase + PCL818_DI_HI) << 8);
+ (inb(dev->iobase + PCL818_DI_HI) << 8);
return 2;
}
@@ -492,8 +500,9 @@ static int pcl818_di_insn_bits(struct comedi_device *dev, struct comedi_subdevic
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;
@@ -533,16 +542,16 @@ static irqreturn_t interrupt_pcl818_ai_mode13_int(int irq, void *d)
comedi_event(dev, s);
return IRQ_HANDLED;
- conv_finish:
+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 */
outb(0, dev->iobase + PCL818_CLRINT); /* clear INT request */
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]);
+ ("comedi: A/D mode1/3 IRQ - channel dropout %x!=%x !\n",
+ (low & 0xf),
+ devpriv->act_chanlist[devpriv->act_chanlist_pos]);
pcl818_ai_cancel(dev, s);
s->async->events |= COMEDI_CB_EOA | COMEDI_CB_ERROR;
comedi_event(dev, s);
@@ -581,10 +590,11 @@ static irqreturn_t interrupt_pcl818_ai_mode13_dma(int irq, void *d)
set_dma_mode(devpriv->dma, DMA_MODE_READ);
flags = claim_dma_lock();
set_dma_addr(devpriv->dma,
- devpriv->hwdmaptr[devpriv->next_dma_buf]);
+ devpriv->hwdmaptr[devpriv->next_dma_buf]);
if (devpriv->dma_runs_to_end || devpriv->neverending_ai) {
set_dma_count(devpriv->dma,
- devpriv->hwdmasize[devpriv->next_dma_buf]);
+ devpriv->hwdmasize[devpriv->
+ next_dma_buf]);
} else {
set_dma_count(devpriv->dma, devpriv->last_dma_run);
}
@@ -595,7 +605,7 @@ static irqreturn_t interrupt_pcl818_ai_mode13_dma(int irq, void *d)
devpriv->dma_runs_to_end--;
outb(0, dev->iobase + PCL818_CLRINT); /* clear INT request */
- ptr = (short *) devpriv->dmabuf[1 - devpriv->next_dma_buf];
+ ptr = (short *)devpriv->dmabuf[1 - devpriv->next_dma_buf];
len = devpriv->hwdmasize[0] >> 1;
bufptr = 0;
@@ -603,11 +613,10 @@ static irqreturn_t interrupt_pcl818_ai_mode13_dma(int irq, void *d)
for (i = 0; i < len; i++) {
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->
- act_chanlist_pos],
- devpriv->act_chanlist_pos);
+ ("comedi: A/D mode1/3 DMA - channel dropout %d(card)!=%d(chanlist) at %d !\n",
+ (ptr[bufptr] & 0xf),
+ devpriv->act_chanlist[devpriv->act_chanlist_pos],
+ devpriv->act_chanlist_pos);
pcl818_ai_cancel(dev, s);
s->async->events |= COMEDI_CB_EOA | COMEDI_CB_ERROR;
comedi_event(dev, s);
@@ -649,7 +658,7 @@ static irqreturn_t interrupt_pcl818_ai_mode13_dma_rtc(int irq, void *d)
unsigned long tmp;
unsigned int top1, top2, i, bufptr;
long ofs_dats;
- short *dmabuf = (short *) devpriv->dmabuf[0];
+ short *dmabuf = (short *)devpriv->dmabuf[0];
/* outb(2,0x378); */
switch (devpriv->ai_mode) {
@@ -657,7 +666,7 @@ static irqreturn_t interrupt_pcl818_ai_mode13_dma_rtc(int irq, void *d)
case INT_TYPE_AI3_DMA_RTC:
tmp = (CMOS_READ(RTC_INTR_FLAGS) & 0xF0);
mod_timer(&devpriv->rtc_irq_timer,
- jiffies + HZ / devpriv->rtc_freq + 2 * HZ / 100);
+ jiffies + HZ / devpriv->rtc_freq + 2 * HZ / 100);
for (i = 0; i < 10; i++) {
top1 = get_dma_residue(devpriv->dma);
@@ -694,13 +703,13 @@ static irqreturn_t interrupt_pcl818_ai_mode13_dma_rtc(int irq, void *d)
for (i = 0; i < ofs_dats; i++) {
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->
- act_chanlist_pos]);
+ ("comedi: A/D mode1/3 DMA - channel dropout %d!=%d !\n",
+ (dmabuf[bufptr] & 0xf),
+ devpriv->
+ act_chanlist[devpriv->act_chanlist_pos]);
pcl818_ai_cancel(dev, s);
s->async->events |=
- COMEDI_CB_EOA | COMEDI_CB_ERROR;
+ COMEDI_CB_EOA | COMEDI_CB_ERROR;
comedi_event(dev, s);
return IRQ_HANDLED;
}
@@ -776,10 +785,9 @@ static irqreturn_t interrupt_pcl818_ai_mode13_fifo(int irq, void *d)
lo = inb(dev->iobase + PCL818_FI_DATALO);
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->
- act_chanlist_pos]);
+ ("comedi: A/D mode1/3 FIFO - channel dropout %d!=%d !\n",
+ (lo & 0xf),
+ devpriv->act_chanlist[devpriv->act_chanlist_pos]);
pcl818_ai_cancel(dev, s);
s->async->events |= COMEDI_CB_EOA | COMEDI_CB_ERROR;
comedi_event(dev, s);
@@ -822,9 +830,9 @@ static irqreturn_t interrupt_pcl818(int irq, void *d)
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)) {
+ 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
@@ -863,7 +871,7 @@ static irqreturn_t interrupt_pcl818(int irq, void *d)
outb(0, dev->iobase + PCL818_CLRINT); /* clear INT request */
if ((!dev->irq) || (!devpriv->irq_free) || (!devpriv->irq_blocked)
- || (!devpriv->ai_mode)) {
+ || (!devpriv->ai_mode)) {
comedi_error(dev, "bad IRQ!");
return IRQ_NONE;
}
@@ -877,7 +885,7 @@ static irqreturn_t interrupt_pcl818(int irq, void *d)
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)
+ struct comedi_subdevice *s)
{
unsigned int flags;
unsigned int bytes;
@@ -918,7 +926,7 @@ 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)
+ struct comedi_subdevice *s)
{
unsigned int flags;
short *pole;
@@ -931,13 +939,13 @@ static void pcl818_ai_mode13dma_rtc(int mode, struct comedi_device *dev,
release_dma_lock(flags);
enable_dma(devpriv->dma);
devpriv->last_top_dma = 0; /* devpriv->hwdmasize[0]; */
- pole = (short *) devpriv->dmabuf[0];
+ pole = (short *)devpriv->dmabuf[0];
devpriv->dmasamplsize = devpriv->hwdmasize[0] / 2;
pole[devpriv->dmasamplsize - 1] = MAGIC_DMA_WORD;
#ifdef unused
devpriv->rtc_freq = rtc_setfreq_irq(2048);
devpriv->rtc_irq_timer.expires =
- jiffies + HZ / devpriv->rtc_freq + 2 * HZ / 100;
+ jiffies + HZ / devpriv->rtc_freq + 2 * HZ / 100;
devpriv->rtc_irq_timer.data = (unsigned long)dev;
devpriv->rtc_irq_timer.function = rtc_dropped_irq;
@@ -959,7 +967,7 @@ 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)
+ struct comedi_subdevice *s)
{
struct comedi_cmd *cmd = &s->async->cmd;
int divisor1, divisor2;
@@ -977,11 +985,11 @@ static int pcl818_ai_cmd_mode(int mode, struct comedi_device *dev,
start_pacer(dev, -1, 0, 0); /* stop pacer */
seglen = check_channel_list(dev, s, devpriv->ai_chanlist,
- devpriv->ai_n_chan);
+ devpriv->ai_n_chan);
if (seglen < 1)
return -EINVAL;
setup_channel_list(dev, s, devpriv->ai_chanlist,
- devpriv->ai_n_chan, seglen);
+ devpriv->ai_n_chan, seglen);
udelay(1);
@@ -998,7 +1006,8 @@ static int pcl818_ai_cmd_mode(int mode, struct comedi_device *dev,
if (mode == 1) {
i8253_cascade_ns_to_timer(devpriv->i8253_osc_base, &divisor1,
- &divisor2, &cmd->convert_arg, TRIG_ROUND_NEAREST);
+ &divisor2, &cmd->convert_arg,
+ TRIG_ROUND_NEAREST);
if (divisor1 == 1) { /* PCL718/818 crash if any divisor is set to 1 */
divisor1 = 2;
divisor2 /= 2;
@@ -1034,11 +1043,13 @@ static int pcl818_ai_cmd_mode(int mode, struct comedi_device *dev,
if (mode == 1) {
devpriv->ai_mode = INT_TYPE_AI1_INT;
/* Pacer+IRQ */
- outb(0x83 | (dev->irq << 4), dev->iobase + PCL818_CONTROL);
+ 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);
+ outb(0x82 | (dev->irq << 4),
+ dev->iobase + PCL818_CONTROL);
}
} else {
/* FIFO */
@@ -1075,8 +1086,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;
@@ -1099,7 +1110,8 @@ static int pcl818_ao_mode13(int mode, struct comedi_device *dev, struct comedi_s
if (mode == 1) {
i8253_cascade_ns_to_timer(devpriv->i8253_osc_base, &divisor1,
- &divisor2, &it->trigvar, TRIG_ROUND_NEAREST);
+ &divisor2, &it->trigvar,
+ TRIG_ROUND_NEAREST);
if (divisor1 == 1) { /* PCL818 crash if any divisor is set to 1 */
divisor1 = 2;
divisor2 /= 2;
@@ -1128,8 +1140,8 @@ static int pcl818_ao_mode13(int mode, struct comedi_device *dev, struct comedi_s
==============================================================================
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);
}
@@ -1138,8 +1150,8 @@ static int pcl818_ao_mode1(struct comedi_device *dev, struct comedi_subdevice *s
==============================================================================
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);
}
@@ -1150,8 +1162,8 @@ static int pcl818_ao_mode3(struct comedi_device *dev, struct comedi_subdevice *s
==============================================================================
Start/stop pacer onboard pacer
*/
-static void start_pacer(struct comedi_device *dev, int mode, unsigned int divisor1,
- unsigned int divisor2)
+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);
@@ -1170,8 +1182,9 @@ static void start_pacer(struct comedi_device *dev, int mode, unsigned int diviso
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,
- unsigned int *chanlist, unsigned int n_chan)
+static int check_channel_list(struct comedi_device *dev,
+ struct comedi_subdevice *s,
+ unsigned int *chanlist, unsigned int n_chan)
{
unsigned int chansegment[16];
unsigned int i, nowmustbechan, seglen, segpos;
@@ -1196,12 +1209,12 @@ static int check_channel_list(struct comedi_device *dev, struct comedi_subdevice
if (chanlist[0] == chanlist[i])
break;
nowmustbechan =
- (CR_CHAN(chansegment[i - 1]) + 1) % s->n_chan;
+ (CR_CHAN(chansegment[i - 1]) + 1) % s->n_chan;
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]));
+ ("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 */
@@ -1213,13 +1226,13 @@ static int check_channel_list(struct comedi_device *dev, struct comedi_subdevice
/* 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]) {
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]),
- CR_AREF(chansegment[i]),
- CR_CHAN(chanlist[i % seglen]),
- CR_RANGE(chanlist[i % seglen]),
- CR_AREF(chansegment[i % seglen]));
+ ("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]),
+ CR_AREF(chansegment[i]),
+ CR_CHAN(chanlist[i % seglen]),
+ CR_RANGE(chanlist[i % seglen]),
+ CR_AREF(chansegment[i % seglen]));
return 0; /* chan/gain list is strange */
}
}
@@ -1230,8 +1243,10 @@ static int check_channel_list(struct comedi_device *dev, struct comedi_subdevice
return seglen;
}
-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 setup_channel_list(struct comedi_device *dev,
+ struct comedi_subdevice *s,
+ unsigned int *chanlist, unsigned int n_chan,
+ unsigned int seglen)
{
int i;
@@ -1248,7 +1263,8 @@ static void setup_channel_list(struct comedi_device *dev, struct comedi_subdevic
/* select channel interval to scan */
outb(devpriv->act_chanlist[0] | (devpriv->act_chanlist[seglen -
- 1] << 4), dev->iobase + PCL818_MUX);
+ 1] << 4),
+ dev->iobase + PCL818_MUX);
}
/*
@@ -1268,7 +1284,7 @@ static int check_single_ended(unsigned int port)
==============================================================================
*/
static int ai_cmdtest(struct comedi_device *dev, struct comedi_subdevice *s,
- struct comedi_cmd *cmd)
+ struct comedi_cmd *cmd)
{
int err = 0;
int tmp, divisor1, divisor2;
@@ -1386,8 +1402,8 @@ static int ai_cmdtest(struct comedi_device *dev, struct comedi_subdevice *s,
if (cmd->convert_src == TRIG_TIMER) {
tmp = cmd->convert_arg;
i8253_cascade_ns_to_timer(devpriv->i8253_osc_base, &divisor1,
- &divisor2, &cmd->convert_arg,
- cmd->flags & TRIG_ROUND_MASK);
+ &divisor2, &cmd->convert_arg,
+ cmd->flags & TRIG_ROUND_MASK);
if (cmd->convert_arg < this_board->ns_min)
cmd->convert_arg = this_board->ns_min;
if (tmp != cmd->convert_arg)
@@ -1402,7 +1418,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))
+ cmd->chanlist_len))
return 5; /* incorrect channels list */
}
@@ -1451,7 +1467,8 @@ 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) {
printk("pcl818_ai_cancel()\n");
@@ -1467,8 +1484,8 @@ static int pcl818_ai_cancel(struct comedi_device *dev, struct comedi_subdevice *
case INT_TYPE_AI1_DMA:
case INT_TYPE_AI3_DMA:
if (devpriv->neverending_ai ||
- (!devpriv->neverending_ai &&
- devpriv->ai_act_scan > 0)) {
+ (!devpriv->neverending_ai &&
+ devpriv->ai_act_scan > 0)) {
/* wait for running dma transfer to end, do cleanup in interrupt */
goto end;
}
@@ -1503,7 +1520,7 @@ static int pcl818_ai_cancel(struct comedi_device *dev, struct comedi_subdevice *
}
}
- end:
+end:
printk("pcl818_ai_cancel() end\n");
return 0;
}
@@ -1612,7 +1629,7 @@ static void rtc_dropped_irq(unsigned long data)
case INT_TYPE_AI1_DMA_RTC:
case INT_TYPE_AI3_DMA_RTC:
mod_timer(&devpriv->rtc_irq_timer,
- jiffies + HZ / devpriv->rtc_freq + 2 * HZ / 100);
+ jiffies + HZ / devpriv->rtc_freq + 2 * HZ / 100);
save_flags(flags);
cli();
tmp = (CMOS_READ(RTC_INTR_FLAGS) & 0xF0); /* restart */
@@ -1674,7 +1691,7 @@ static void free_resources(struct comedi_device *dev)
if ((devpriv->dma_rtc) && (RTC_lock == 1)) {
if (devpriv->rtc_iobase)
release_region(devpriv->rtc_iobase,
- devpriv->rtc_iosize);
+ devpriv->rtc_iosize);
}
if (devpriv->dma_rtc)
RTC_lock--;
@@ -1710,7 +1727,7 @@ static int pcl818_attach(struct comedi_device *dev, struct comedi_devconfig *it)
/* claim our I/O space */
iobase = it->options[0];
printk("comedi%d: pcl818: board=%s, ioport=0x%03lx",
- dev->minor, this_board->name, iobase);
+ 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 */
devpriv->io_range = PCLx1xFIFO_RANGE;
@@ -1737,14 +1754,15 @@ static int pcl818_attach(struct comedi_device *dev, struct comedi_devconfig *it)
if (irq) { /* we want to use IRQ */
if (((1 << irq) & this_board->IRQbits) == 0) {
printk
- (", IRQ %u is out of allowed range, DISABLING IT",
- irq);
+ (", IRQ %u is out of allowed range, DISABLING IT",
+ irq);
irq = 0; /* Bad IRQ */
} else {
- if (request_irq(irq, interrupt_pcl818, 0, "pcl818", dev)) {
+ if (request_irq
+ (irq, interrupt_pcl818, 0, "pcl818", dev)) {
printk
- (", unable to allocate IRQ %u, DISABLING IT",
- irq);
+ (", unable to allocate IRQ %u, DISABLING IT",
+ irq);
irq = 0; /* Can't use IRQ */
} else {
printk(", irq=%u", irq);
@@ -1769,14 +1787,14 @@ static int pcl818_attach(struct comedi_device *dev, struct comedi_devconfig *it)
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)"))
+ "pcl818 (RTC)"))
goto no_rtc;
}
devpriv->rtc_iobase = RTC_PORT(0);
devpriv->rtc_iosize = RTC_IO_EXTENT;
RTC_lock++;
if (!request_irq(RTC_IRQ, interrupt_pcl818_ai_mode13_dma_rtc, 0,
- "pcl818 DMA (RTC)", dev)) {
+ "pcl818 DMA (RTC)", dev)) {
devpriv->dma_rtc = 1;
devpriv->rtc_irq = RTC_IRQ;
printk(", dma_irq=%u", devpriv->rtc_irq);
@@ -1785,14 +1803,14 @@ static int pcl818_attach(struct comedi_device *dev, struct comedi_devconfig *it)
if (RTC_lock == 0) {
if (devpriv->rtc_iobase)
release_region(devpriv->rtc_iobase,
- devpriv->rtc_iosize);
+ devpriv->rtc_iosize);
}
devpriv->rtc_iobase = 0;
devpriv->rtc_iosize = 0;
}
}
- no_rtc:
+no_rtc:
#endif
/* grab our DMA */
dma = 0;
@@ -1829,17 +1847,17 @@ static int pcl818_attach(struct comedi_device *dev, struct comedi_devconfig *it)
devpriv->dmabuf[1] = __get_dma_pages(GFP_KERNEL, pages);
if (!devpriv->dmabuf[1]) {
printk
- (", unable to allocate DMA buffer, FAIL!\n");
+ (", unable to allocate DMA buffer, FAIL!\n");
return -EBUSY;
}
devpriv->dmapages[1] = pages;
devpriv->hwdmaptr[1] =
- virt_to_bus((void *)devpriv->dmabuf[1]);
+ virt_to_bus((void *)devpriv->dmabuf[1]);
devpriv->hwdmasize[1] = (1 << pages) * PAGE_SIZE;
}
}
- no_dma:
+no_dma:
ret = alloc_subdevices(dev, 4);
if (ret < 0)
diff --git a/drivers/staging/comedi/drivers/pcm3724.c b/drivers/staging/comedi/drivers/pcm3724.c
index a5d6b1d9a1aa..52811824b05a 100644
--- a/drivers/staging/comedi/drivers/pcm3724.c
+++ b/drivers/staging/comedi/drivers/pcm3724.c
@@ -62,7 +62,8 @@ 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_attach(struct comedi_device *dev,
+ struct comedi_devconfig *it);
static int pcm3724_detach(struct comedi_device *dev);
struct pcm3724_board {
@@ -143,8 +144,8 @@ 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,
- int chanspec)
+static void do_3724_config(struct comedi_device *dev,
+ struct comedi_subdevice *s, int chanspec)
{
int config;
int buffer_config;
@@ -177,14 +178,15 @@ static void do_3724_config(struct comedi_device *dev, struct comedi_subdevice *s
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;
struct priv_pcm3724 *priv;
gatecfg = 0;
- priv = (struct priv_pcm3724 *) (dev->private);
+ priv = (struct priv_pcm3724 *)(dev->private);
mask = 1 << CR_CHAN(chanspec);
if (s == dev->subdevices) { /* subdev 0 */
@@ -215,8 +217,9 @@ static void enable_chan(struct comedi_device *dev, struct comedi_subdevice *s, i
}
/* 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 +255,8 @@ static int subdev_3724_insn_config(struct comedi_device *dev, struct comedi_subd
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;
@@ -265,11 +269,11 @@ static int pcm3724_attach(struct comedi_device *dev, struct comedi_devconfig *it
if (ret < 0)
return -ENOMEM;
- ((struct priv_pcm3724 *) (dev->private))->dio_1 = 0;
- ((struct priv_pcm3724 *) (dev->private))->dio_2 = 0;
+ ((struct priv_pcm3724 *)(dev->private))->dio_1 = 0;
+ ((struct priv_pcm3724 *)(dev->private))->dio_2 = 0;
printk("comedi%d: pcm3724: board=%s, 0x%03lx ", dev->minor,
- this_board->name, iobase);
+ this_board->name, iobase);
if (!iobase || !request_region(iobase, iorange, "pcm3724")) {
printk("I/O port conflict\n");
return -EIO;
@@ -287,7 +291,7 @@ static int pcm3724_attach(struct comedi_device *dev, struct comedi_devconfig *it
for (i = 0; i < dev->n_subdevices; i++) {
subdev_8255_init(dev, dev->subdevices + i, subdev_8255_cb,
- (unsigned long)(dev->iobase + SIZE_8255 * i));
+ (unsigned long)(dev->iobase + SIZE_8255 * i));
((dev->subdevices) + i)->insn_config = subdev_3724_insn_config;
};
return 0;
diff --git a/drivers/staging/comedi/drivers/pcm3730.c b/drivers/staging/comedi/drivers/pcm3730.c
index ae90ea4ae3c9..9e4adbd89dda 100644
--- a/drivers/staging/comedi/drivers/pcm3730.c
+++ b/drivers/staging/comedi/drivers/pcm3730.c
@@ -28,7 +28,8 @@ Configuration options:
#define PCM3730_DIB 2
#define PCM3730_DIC 3
-static int pcm3730_attach(struct comedi_device *dev, struct comedi_devconfig *it);
+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",
@@ -39,8 +40,9 @@ static struct comedi_driver driver_pcm3730 = {
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 +56,9 @@ static int pcm3730_do_insn_bits(struct comedi_device *dev, struct comedi_subdevi
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 +66,8 @@ static int pcm3730_di_insn_bits(struct comedi_device *dev, struct comedi_subdevi
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;
diff --git a/drivers/staging/comedi/drivers/pcmad.c b/drivers/staging/comedi/drivers/pcmad.c
index 9bb26699f47e..7368bf3011c9 100644
--- a/drivers/staging/comedi/drivers/pcmad.c
+++ b/drivers/staging/comedi/drivers/pcmad.c
@@ -59,13 +59,13 @@ 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,
+ },
};
#define this_board ((const struct pcmad_board_struct *)(dev->board_ptr))
@@ -93,8 +93,9 @@ 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;
diff --git a/drivers/staging/comedi/drivers/pcmda12.c b/drivers/staging/comedi/drivers/pcmda12.c
index 6e172a6b1cb2..7133eb0352bc 100644
--- a/drivers/staging/comedi/drivers/pcmda12.c
+++ b/drivers/staging/comedi/drivers/pcmda12.c
@@ -76,14 +76,14 @@ struct pcmda12_board {
static const struct comedi_lrange pcmda12_ranges = {
3,
{
- UNI_RANGE(5), UNI_RANGE(10), BIP_RANGE(5)
- }
+ UNI_RANGE(5), UNI_RANGE(10), BIP_RANGE(5)
+ }
};
static const struct pcmda12_board pcmda12_boards[] = {
{
- .name = "pcmda12",
- },
+ .name = "pcmda12",
+ },
};
/*
@@ -97,7 +97,6 @@ struct pcmda12_private {
int simultaneous_xfer_mode;
};
-
#define devpriv ((struct pcmda12_private *)(dev->private))
/*
@@ -106,7 +105,8 @@ 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_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);
@@ -140,9 +140,9 @@ static struct comedi_driver driver = {
};
static int ao_winsn(struct comedi_device *dev, struct comedi_subdevice *s,
- struct comedi_insn *insn, unsigned int *data);
+ 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);
+ struct comedi_insn *insn, unsigned int *data);
/*
* Attach is called by the Comedi core to configure the driver
@@ -150,14 +150,15 @@ 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;
iobase = it->options[0];
printk("comedi%d: %s: io: %lx %s ", dev->minor, driver.driver_name,
- iobase, it->options[1] ? "simultaneous xfer mode enabled" : "");
+ iobase, it->options[1] ? "simultaneous xfer mode enabled" : "");
if (!request_region(iobase, IOSIZE, driver.driver_name)) {
printk("I/O port conflict\n");
@@ -241,7 +242,7 @@ static void zero_chans(struct comedi_device *dev)
}
static int ao_winsn(struct comedi_device *dev, struct comedi_subdevice *s,
- struct comedi_insn *insn, unsigned int *data)
+ struct comedi_insn *insn, unsigned int *data)
{
int i;
int chan = CR_CHAN(insn->chanspec);
@@ -283,7 +284,7 @@ static int ao_winsn(struct comedi_device *dev, struct comedi_subdevice *s,
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)
+ 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 cdf501afa14e..d812c2c3af12 100644
--- a/drivers/staging/comedi/drivers/pcmmio.c
+++ b/drivers/staging/comedi/drivers/pcmmio.c
@@ -139,15 +139,16 @@ Configuration Options:
#define PAGE_ENAB 2
#define PAGE_INT_ID 3
-typedef int (*comedi_insn_fn_t) (struct comedi_device *, struct comedi_subdevice *,
- struct comedi_insn *, unsigned int *);
+typedef int (*comedi_insn_fn_t) (struct comedi_device *,
+ struct comedi_subdevice *,
+ struct comedi_insn *, unsigned int *);
-static int ai_rinsn(struct comedi_device *, struct comedi_subdevice *, struct comedi_insn *,
- unsigned int *);
-static int ao_rinsn(struct comedi_device *, struct comedi_subdevice *, struct comedi_insn *,
- unsigned int *);
-static int ao_winsn(struct comedi_device *, struct comedi_subdevice *, struct comedi_insn *,
- unsigned int *);
+static int ai_rinsn(struct comedi_device *, struct comedi_subdevice *,
+ struct comedi_insn *, unsigned int *);
+static int ao_rinsn(struct comedi_device *, struct comedi_subdevice *,
+ struct comedi_insn *, unsigned int *);
+static int ao_winsn(struct comedi_device *, struct comedi_subdevice *,
+ struct comedi_insn *, unsigned int *);
/*
* Board descriptions for two imaginary boards. Describing the
@@ -168,30 +169,30 @@ struct pcmmio_board {
};
static const struct comedi_lrange ranges_ai =
- { 4, {RANGE(-5., 5.), RANGE(-10., 10.), RANGE(0., 5.), RANGE(0.,
- 10.)}
+ { 4, {RANGE(-5., 5.), RANGE(-10., 10.), RANGE(0., 5.), RANGE(0.,
+ 10.)}
};
static const struct comedi_lrange ranges_ao =
- { 6, {RANGE(0., 5.), RANGE(0., 10.), RANGE(-5., 5.), RANGE(-10., 10.),
- RANGE(-2.5, 2.5), RANGE(-2.5, 7.5)}
+ { 6, {RANGE(0., 5.), RANGE(0., 10.), RANGE(-5., 5.), RANGE(-10., 10.),
+ RANGE(-2.5, 2.5), RANGE(-2.5, 7.5)}
};
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,7 +265,8 @@ 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_attach(struct comedi_device *dev,
+ struct comedi_devconfig *it);
static int pcmmio_detach(struct comedi_device *dev);
static struct comedi_driver driver = {
@@ -295,17 +297,19 @@ static struct comedi_driver driver = {
.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);
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);
+ 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 */
@@ -325,7 +329,7 @@ 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,
- thisasic_chanct = 0;
+ thisasic_chanct = 0;
unsigned long iobase;
unsigned int irq[MAX_ASICS];
@@ -333,12 +337,13 @@ static int pcmmio_attach(struct comedi_device *dev, struct comedi_devconfig *it)
irq[0] = it->options[1];
printk("comedi%d: %s: io: %lx ", dev->minor, driver.driver_name,
- iobase);
+ iobase);
dev->iobase = iobase;
if (!iobase || !request_region(iobase,
- thisboard->total_iosize, driver.driver_name)) {
+ thisboard->total_iosize,
+ driver.driver_name)) {
printk("I/O port conflict\n");
return -EIO;
}
@@ -361,7 +366,7 @@ static int pcmmio_attach(struct comedi_device *dev, struct comedi_devconfig *it)
for (asic = 0; asic < MAX_ASICS; ++asic) {
devpriv->asics[asic].num = asic;
devpriv->asics[asic].iobase =
- dev->iobase + 16 + asic * ASIC_IOSIZE;
+ dev->iobase + 16 + asic * ASIC_IOSIZE;
devpriv->asics[asic].irq = 0; /* this gets actually set at the end of
this function when we
request_irqs */
@@ -372,7 +377,8 @@ static int pcmmio_attach(struct comedi_device *dev, struct comedi_devconfig *it)
n_dio_subdevs = CALC_N_DIO_SUBDEVS(chans_left);
n_subdevs = n_dio_subdevs + 2;
devpriv->sprivs =
- kcalloc(n_subdevs, sizeof(struct pcmmio_subdev_private), GFP_KERNEL);
+ kcalloc(n_subdevs, sizeof(struct pcmmio_subdev_private),
+ GFP_KERNEL);
if (!devpriv->sprivs) {
printk("cannot allocate subdevice private data structures\n");
return -ENOMEM;
@@ -452,11 +458,11 @@ static int pcmmio_attach(struct comedi_device *dev, struct comedi_devconfig *it)
thisasic_chanct = 0;
}
subpriv->iobases[byte_no] =
- devpriv->asics[asic].iobase + port;
+ devpriv->asics[asic].iobase + port;
if (thisasic_chanct <
- CHANS_PER_PORT * INTR_PORTS_PER_ASIC
- && subpriv->dio.intr.asic < 0) {
+ CHANS_PER_PORT * INTR_PORTS_PER_ASIC
+ && subpriv->dio.intr.asic < 0) {
/* this is an interrupt subdevice, so setup the struct */
subpriv->dio.intr.asic = asic;
subpriv->dio.intr.active = 0;
@@ -464,13 +470,12 @@ static int pcmmio_attach(struct comedi_device *dev, struct comedi_devconfig *it)
subpriv->dio.intr.first_chan = byte_no * 8;
subpriv->dio.intr.asic_chan = thisasic_chanct;
subpriv->dio.intr.num_asic_chans =
- s->n_chan -
- subpriv->dio.intr.first_chan;
+ s->n_chan - subpriv->dio.intr.first_chan;
s->cancel = pcmmio_cancel;
s->do_cmd = pcmmio_cmd;
s->do_cmdtest = pcmmio_cmdtest;
s->len_chanlist =
- subpriv->dio.intr.num_asic_chans;
+ subpriv->dio.intr.num_asic_chans;
}
thisasic_chanct += CHANS_PER_PORT;
}
@@ -489,8 +494,8 @@ static int pcmmio_attach(struct comedi_device *dev, struct comedi_devconfig *it)
for (asic = 0; irq[0] && asic < MAX_ASICS; ++asic) {
if (irq[asic]
- && request_irq(irq[asic], interrupt_pcmmio,
- IRQF_SHARED, thisboard->name, dev)) {
+ && request_irq(irq[asic], interrupt_pcmmio,
+ IRQF_SHARED, thisboard->name, dev)) {
int i;
/* unroll the allocated irqs.. */
for (i = asic - 1; i >= 0; --i) {
@@ -550,8 +555,9 @@ 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)
@@ -578,20 +584,23 @@ static int pcmmio_dio_insn_bits(struct comedi_device *dev, struct comedi_subdevi
for (byte_no = 0; byte_no < s->n_chan / CHANS_PER_PORT; ++byte_no) {
/* address of 8-bit port */
unsigned long ioaddr = subpriv->iobases[byte_no],
- /* bit offset of port in 32-bit doubleword */
- offset = byte_no * 8;
+ /* bit offset of port in 32-bit doubleword */
+ offset = byte_no * 8;
/* this 8-bit port's data */
unsigned char byte = 0,
- /* The write mask for this port (if any) */
- write_mask_byte = (data[0] >> offset) & 0xff,
- /* The data byte for this port */
- data_byte = (data[1] >> offset) & 0xff;
+ /* The write mask for this port (if any) */
+ write_mask_byte = (data[0] >> offset) & 0xff,
+ /* The data byte for this port */
+ data_byte = (data[1] >> offset) & 0xff;
byte = inb(ioaddr); /* read all 8-bits for this port */
#ifdef DAMMIT_ITS_BROKEN
/* DEBUG */
- printk("byte %d wmb %02x db %02x offset %02d io %04x, data_in %02x ", byte_no, (unsigned)write_mask_byte, (unsigned)data_byte, offset, ioaddr, (unsigned)byte);
+ printk
+ ("byte %d wmb %02x db %02x offset %02d io %04x, data_in %02x ",
+ byte_no, (unsigned)write_mask_byte, (unsigned)data_byte,
+ offset, ioaddr, (unsigned)byte);
#endif
if (write_mask_byte) {
@@ -624,11 +633,12 @@ static int pcmmio_dio_insn_bits(struct comedi_device *dev, struct comedi_subdevi
* 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;
+ chan % 8;
unsigned long ioaddr;
unsigned char byte;
@@ -672,8 +682,7 @@ static int pcmmio_dio_insn_config(struct comedi_device *dev, struct comedi_subde
case INSN_CONFIG_DIO_QUERY:
/* retreive from shadow register */
data[1] =
- (s->
- io_bits & (1 << chan)) ? COMEDI_OUTPUT : COMEDI_INPUT;
+ (s->io_bits & (1 << chan)) ? COMEDI_OUTPUT : COMEDI_INPUT;
return insn->n;
break;
@@ -706,7 +715,7 @@ static void init_asics(struct comedi_device *dev)
/* now clear all the paged registers */
switch_page(dev, asic, page);
for (reg = FIRST_PAGED_REG;
- reg < FIRST_PAGED_REG + NUM_PAGED_REGS; ++reg)
+ reg < FIRST_PAGED_REG + NUM_PAGED_REGS; ++reg)
outb(0, baseaddr + reg);
}
@@ -734,7 +743,7 @@ static void switch_page(struct comedi_device *dev, int asic, int page)
/* now write out the shadow register */
outb(devpriv->asics[asic].pagelock,
- devpriv->asics[asic].iobase + REG_PAGELOCK);
+ devpriv->asics[asic].iobase + REG_PAGELOCK);
}
#ifdef notused
@@ -748,7 +757,7 @@ static void lock_port(struct comedi_device *dev, int asic, int port)
devpriv->asics[asic].pagelock |= 0x1 << port;
/* now write out the shadow register */
outb(devpriv->asics[asic].pagelock,
- devpriv->asics[asic].iobase + REG_PAGELOCK);
+ devpriv->asics[asic].iobase + REG_PAGELOCK);
return;
}
@@ -761,14 +770,14 @@ static void unlock_port(struct comedi_device *dev, int asic, int port)
devpriv->asics[asic].pagelock &= ~(0x1 << port) | REG_LOCK_MASK;
/* now write out the shadow register */
outb(devpriv->asics[asic].pagelock,
- devpriv->asics[asic].iobase + REG_PAGELOCK);
+ devpriv->asics[asic].iobase + REG_PAGELOCK);
}
#endif /* notused */
static irqreturn_t interrupt_pcmmio(int irq, void *d)
{
int asic, got1 = 0;
- struct comedi_device *dev = (struct comedi_device *) d;
+ struct comedi_device *dev = (struct comedi_device *)d;
for (asic = 0; asic < MAX_ASICS; ++asic) {
if (irq == devpriv->asics[asic].irq) {
@@ -778,124 +787,130 @@ static irqreturn_t interrupt_pcmmio(int irq, void *d)
/* it is an interrupt for ASIC #asic */
unsigned char int_pend;
- spin_lock_irqsave(&devpriv->asics[asic].spinlock, flags);
+ spin_lock_irqsave(&devpriv->asics[asic].spinlock,
+ flags);
int_pend = inb(iobase + REG_INT_PENDING) & 0x07;
if (int_pend) {
int port;
for (port = 0; port < INTR_PORTS_PER_ASIC;
- ++port) {
+ ++port) {
if (int_pend & (0x1 << port)) {
unsigned char
- io_lines_with_edges = 0;
+ io_lines_with_edges = 0;
switch_page(dev, asic,
- PAGE_INT_ID);
+ PAGE_INT_ID);
io_lines_with_edges =
- inb(iobase +
+ inb(iobase +
REG_INT_ID0 + port);
if (io_lines_with_edges)
/* clear pending interrupt */
outb(0, iobase +
- REG_INT_ID0 +
- port);
+ REG_INT_ID0 +
+ port);
triggered |=
- io_lines_with_edges <<
- port * 8;
+ io_lines_with_edges <<
+ port * 8;
}
}
++got1;
}
- spin_unlock_irqrestore(&devpriv->asics[asic]. spinlock, flags);
+ spin_unlock_irqrestore(&devpriv->asics[asic].spinlock,
+ flags);
if (triggered) {
struct comedi_subdevice *s;
/* TODO here: dispatch io lines to subdevs with commands.. */
- printk("PCMMIO DEBUG: got edge detect interrupt %d asic %d which_chans: %06x\n", irq, asic, triggered);
+ printk
+ ("PCMMIO DEBUG: got edge detect interrupt %d asic %d which_chans: %06x\n",
+ irq, asic, triggered);
for (s = dev->subdevices + 2;
- s < dev->subdevices + dev->n_subdevices;
- ++s) {
+ s < dev->subdevices + dev->n_subdevices;
+ ++s) {
if (subpriv->dio.intr.asic == asic) { /* this is an interrupt subdev, and it matches this asic! */
unsigned long flags;
unsigned oldevents;
- spin_lock_irqsave(&subpriv->dio.intr.spinlock, flags);
+ spin_lock_irqsave(&subpriv->dio.
+ intr.spinlock,
+ flags);
oldevents = s->async->events;
if (subpriv->dio.intr.active) {
unsigned mytrig =
- ((triggered >>
- subpriv->
- dio.
- intr.
- asic_chan)
- & ((0x1 << subpriv->dio.intr.num_asic_chans) - 1)) << subpriv->dio.intr.first_chan;
- if (mytrig & subpriv->
- dio.intr.
- enabled_mask) {
- unsigned int val =
- 0;
+ ((triggered >>
+ subpriv->dio.intr.asic_chan)
+ &
+ ((0x1 << subpriv->
+ dio.intr.
+ num_asic_chans) -
+ 1)) << subpriv->
+ dio.intr.first_chan;
+ if (mytrig &
+ subpriv->dio.
+ intr.enabled_mask) {
+ unsigned int val
+ = 0;
unsigned int n,
- ch, len;
+ ch, len;
- len = s->async->
- cmd.
- chanlist_len;
+ len =
+ s->
+ async->cmd.chanlist_len;
for (n = 0;
- n < len;
- n++) {
+ n < len;
+ n++) {
ch = CR_CHAN(s->async->cmd.chanlist[n]);
if (mytrig & (1U << ch)) {
val |= (1U << n);
}
}
/* Write the scan to the buffer. */
- if (comedi_buf_put(s->async, ((short *) &val)[0])
- &&
- comedi_buf_put
- (s->async, ((short *) &val)[1])) {
+ if (comedi_buf_put(s->async, ((short *)&val)[0])
+ &&
+ comedi_buf_put
+ (s->async,
+ ((short *)
+ &val)[1]))
+ {
s->async->events |= (COMEDI_CB_BLOCK | COMEDI_CB_EOS);
} else {
/* Overflow! Stop acquisition!! */
/* TODO: STOP_ACQUISITION_CALL_HERE!! */
pcmmio_stop_intr
- (dev,
- s);
+ (dev,
+ s);
}
/* Check for end of acquisition. */
- if (!subpriv->
- dio.
- intr.
- continuous)
- {
+ if (!subpriv->dio.intr.continuous) {
/* stop_src == TRIG_COUNT */
if (subpriv->dio.intr.stop_count > 0) {
- subpriv->
- dio.
- intr.
- stop_count--;
+ subpriv->dio.intr.stop_count--;
if (subpriv->dio.intr.stop_count == 0) {
s->async->events |= COMEDI_CB_EOA;
/* TODO: STOP_ACQUISITION_CALL_HERE!! */
pcmmio_stop_intr
- (dev,
- s);
+ (dev,
+ s);
}
}
}
}
}
- spin_unlock_irqrestore(&subpriv->dio.intr.spinlock, flags);
+ spin_unlock_irqrestore
+ (&subpriv->dio.intr.
+ spinlock, flags);
if (oldevents !=
- s->async->events) {
+ s->async->events) {
comedi_event(dev, s);
}
@@ -911,7 +926,8 @@ static irqreturn_t interrupt_pcmmio(int irq, void *d)
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;
@@ -931,7 +947,8 @@ 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! */
@@ -944,7 +961,7 @@ static int pcmmio_start_intr(struct comedi_device *dev, struct comedi_subdevice
struct comedi_cmd *cmd = &s->async->cmd;
asic = subpriv->dio.intr.asic;
- if (asic < 0)
+ if (asic < 0)
return 1; /* not an interrupt
subdev */
subpriv->dio.intr.enabled_mask = 0;
@@ -955,12 +972,13 @@ static int pcmmio_start_intr(struct comedi_device *dev, struct comedi_subdevice
for (n = 0; n < cmd->chanlist_len; n++) {
bits |= (1U << CR_CHAN(cmd->chanlist[n]));
pol_bits |= (CR_AREF(cmd->chanlist[n])
- || CR_RANGE(cmd->chanlist[n]) ? 1U : 0U)
- << CR_CHAN(cmd->chanlist[n]);
+ || CR_RANGE(cmd->
+ chanlist[n]) ? 1U : 0U)
+ << CR_CHAN(cmd->chanlist[n]);
}
}
bits &= ((0x1 << subpriv->dio.intr.num_asic_chans) -
- 1) << subpriv->dio.intr.first_chan;
+ 1) << subpriv->dio.intr.first_chan;
subpriv->dio.intr.enabled_mask = bits;
{ /* the below code configures the board to use a specific IRQ from 0-15. */
@@ -976,16 +994,17 @@ static int pcmmio_start_intr(struct comedi_device *dev, struct comedi_subdevice
switch_page(dev, asic, PAGE_ENAB);
for (port = firstport; port < firstport + nports; ++port) {
unsigned enab =
- bits >> (subpriv->dio.intr.first_chan + (port -
- firstport) * 8) & 0xff, pol =
- pol_bits >> (subpriv->dio.intr.first_chan +
- (port - firstport) * 8) & 0xff;
+ bits >> (subpriv->dio.intr.first_chan + (port -
+ firstport)
+ * 8) & 0xff, pol =
+ pol_bits >> (subpriv->dio.intr.first_chan +
+ (port - firstport) * 8) & 0xff;
/* set enab intrs for this subdev.. */
outb(enab,
- devpriv->asics[asic].iobase + REG_ENAB0 + port);
+ devpriv->asics[asic].iobase + REG_ENAB0 + port);
switch_page(dev, asic, PAGE_POL);
outb(pol,
- devpriv->asics[asic].iobase + REG_ENAB0 + port);
+ devpriv->asics[asic].iobase + REG_ENAB0 + port);
}
}
return 0;
@@ -1008,7 +1027,7 @@ static int pcmmio_cancel(struct comedi_device *dev, struct comedi_subdevice *s)
*/
static int
pcmmio_inttrig_start_intr(struct comedi_device *dev, struct comedi_subdevice *s,
- unsigned int trignum)
+ unsigned int trignum)
{
unsigned long flags;
int event = 0;
@@ -1075,7 +1094,8 @@ 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)
+pcmmio_cmdtest(struct comedi_device *dev, struct comedi_subdevice *s,
+ struct comedi_cmd *cmd)
{
return comedi_pcm_cmdtest(dev, s, cmd);
}
@@ -1091,7 +1111,7 @@ 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)
+ struct comedi_insn *insn, unsigned int *data)
{
int n;
unsigned long iobase = subpriv->iobase;
@@ -1110,8 +1130,7 @@ static int ai_rinsn(struct comedi_device *dev, struct comedi_subdevice *s,
/* convert n samples */
for (n = 0; n < insn->n; n++) {
unsigned chan = CR_CHAN(insn->chanspec), range =
- CR_RANGE(insn->chanspec), aref =
- CR_AREF(insn->chanspec);
+ CR_RANGE(insn->chanspec), aref = CR_AREF(insn->chanspec);
unsigned char command_byte = 0;
unsigned iooffset = 0;
short sample, adc_adjust = 0;
@@ -1155,7 +1174,7 @@ static int ai_rinsn(struct comedi_device *dev, struct comedi_subdevice *s,
}
static int ao_rinsn(struct comedi_device *dev, struct comedi_subdevice *s,
- struct comedi_insn *insn, unsigned int *data)
+ struct comedi_insn *insn, unsigned int *data)
{
int n;
for (n = 0; n < insn->n; n++) {
@@ -1185,17 +1204,17 @@ static int wait_dac_ready(unsigned long iobase)
}
static int ao_winsn(struct comedi_device *dev, struct comedi_subdevice *s,
- struct comedi_insn *insn, unsigned int *data)
+ struct comedi_insn *insn, unsigned int *data)
{
int n;
unsigned iobase = subpriv->iobase, iooffset = 0;
for (n = 0; n < insn->n; n++) {
unsigned chan = CR_CHAN(insn->chanspec), range =
- CR_RANGE(insn->chanspec);
+ CR_RANGE(insn->chanspec);
if (chan < s->n_chan) {
unsigned char command_byte = 0, range_byte =
- range & ((1 << 4) - 1);
+ range & ((1 << 4) - 1);
if (chan >= 4)
chan -= 4, iooffset += 4;
/* set the range.. */
diff --git a/drivers/staging/comedi/drivers/pcmuio.c b/drivers/staging/comedi/drivers/pcmuio.c
index 81ee7cdc0caf..c1ae20ffb379 100644
--- a/drivers/staging/comedi/drivers/pcmuio.c
+++ b/drivers/staging/comedi/drivers/pcmuio.c
@@ -156,15 +156,15 @@ 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,
+ },
};
/*
@@ -223,7 +223,8 @@ 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_attach(struct comedi_device *dev,
+ struct comedi_devconfig *it);
static int pcmuio_detach(struct comedi_device *dev);
static struct comedi_driver driver = {
@@ -254,17 +255,19 @@ static struct comedi_driver driver = {
.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);
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);
+ 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 */
@@ -292,13 +295,13 @@ static int pcmuio_attach(struct comedi_device *dev, struct comedi_devconfig *it)
irq[1] = it->options[2];
printk("comedi%d: %s: io: %lx ", dev->minor, driver.driver_name,
- iobase);
+ iobase);
dev->iobase = iobase;
if (!iobase || !request_region(iobase,
- thisboard->num_asics * ASIC_IOSIZE,
- driver.driver_name)) {
+ thisboard->num_asics * ASIC_IOSIZE,
+ driver.driver_name)) {
printk("I/O port conflict\n");
return -EIO;
}
@@ -330,7 +333,8 @@ static int pcmuio_attach(struct comedi_device *dev, struct comedi_devconfig *it)
chans_left = CHANS_PER_ASIC * thisboard->num_asics;
n_subdevs = CALC_N_SUBDEVS(chans_left);
devpriv->sprivs =
- kcalloc(n_subdevs, sizeof(struct pcmuio_subdev_private), GFP_KERNEL);
+ kcalloc(n_subdevs, sizeof(struct pcmuio_subdev_private),
+ GFP_KERNEL);
if (!devpriv->sprivs) {
printk("cannot allocate subdevice private data structures\n");
return -ENOMEM;
@@ -377,11 +381,11 @@ static int pcmuio_attach(struct comedi_device *dev, struct comedi_devconfig *it)
thisasic_chanct = 0;
}
subpriv->iobases[byte_no] =
- devpriv->asics[asic].iobase + port;
+ devpriv->asics[asic].iobase + port;
if (thisasic_chanct <
- CHANS_PER_PORT * INTR_PORTS_PER_ASIC
- && subpriv->intr.asic < 0) {
+ CHANS_PER_PORT * INTR_PORTS_PER_ASIC
+ && subpriv->intr.asic < 0) {
/* this is an interrupt subdevice, so setup the struct */
subpriv->intr.asic = asic;
subpriv->intr.active = 0;
@@ -389,7 +393,7 @@ static int pcmuio_attach(struct comedi_device *dev, struct comedi_devconfig *it)
subpriv->intr.first_chan = byte_no * 8;
subpriv->intr.asic_chan = thisasic_chanct;
subpriv->intr.num_asic_chans =
- s->n_chan - subpriv->intr.first_chan;
+ s->n_chan - subpriv->intr.first_chan;
dev->read_subdev = s;
s->subdev_flags |= SDF_CMD_READ;
s->cancel = pcmuio_cancel;
@@ -414,8 +418,8 @@ static int pcmuio_attach(struct comedi_device *dev, struct comedi_devconfig *it)
for (asic = 0; irq[0] && asic < MAX_ASICS; ++asic) {
if (irq[asic]
- && request_irq(irq[asic], interrupt_pcmuio,
- IRQF_SHARED, thisboard->name, dev)) {
+ && request_irq(irq[asic], interrupt_pcmuio,
+ IRQF_SHARED, thisboard->name, dev)) {
int i;
/* unroll the allocated irqs.. */
for (i = asic - 1; i >= 0; --i) {
@@ -475,8 +479,9 @@ 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)
@@ -503,20 +508,23 @@ static int pcmuio_dio_insn_bits(struct comedi_device *dev, struct comedi_subdevi
for (byte_no = 0; byte_no < s->n_chan / CHANS_PER_PORT; ++byte_no) {
/* address of 8-bit port */
unsigned long ioaddr = subpriv->iobases[byte_no],
- /* bit offset of port in 32-bit doubleword */
- offset = byte_no * 8;
+ /* bit offset of port in 32-bit doubleword */
+ offset = byte_no * 8;
/* this 8-bit port's data */
unsigned char byte = 0,
- /* The write mask for this port (if any) */
- write_mask_byte = (data[0] >> offset) & 0xff,
- /* The data byte for this port */
- data_byte = (data[1] >> offset) & 0xff;
+ /* The write mask for this port (if any) */
+ write_mask_byte = (data[0] >> offset) & 0xff,
+ /* The data byte for this port */
+ data_byte = (data[1] >> offset) & 0xff;
byte = inb(ioaddr); /* read all 8-bits for this port */
#ifdef DAMMIT_ITS_BROKEN
/* DEBUG */
- printk("byte %d wmb %02x db %02x offset %02d io %04x, data_in %02x ", byte_no, (unsigned)write_mask_byte, (unsigned)data_byte, offset, ioaddr, (unsigned)byte);
+ printk
+ ("byte %d wmb %02x db %02x offset %02d io %04x, data_in %02x ",
+ byte_no, (unsigned)write_mask_byte, (unsigned)data_byte,
+ offset, ioaddr, (unsigned)byte);
#endif
if (write_mask_byte) {
@@ -549,11 +557,12 @@ static int pcmuio_dio_insn_bits(struct comedi_device *dev, struct comedi_subdevi
* 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;
+ chan % 8;
unsigned long ioaddr;
unsigned char byte;
@@ -597,8 +606,7 @@ static int pcmuio_dio_insn_config(struct comedi_device *dev, struct comedi_subde
case INSN_CONFIG_DIO_QUERY:
/* retreive from shadow register */
data[1] =
- (s->
- io_bits & (1 << chan)) ? COMEDI_OUTPUT : COMEDI_INPUT;
+ (s->io_bits & (1 << chan)) ? COMEDI_OUTPUT : COMEDI_INPUT;
return insn->n;
break;
@@ -631,7 +639,7 @@ static void init_asics(struct comedi_device *dev)
/* now clear all the paged registers */
switch_page(dev, asic, page);
for (reg = FIRST_PAGED_REG;
- reg < FIRST_PAGED_REG + NUM_PAGED_REGS; ++reg)
+ reg < FIRST_PAGED_REG + NUM_PAGED_REGS; ++reg)
outb(0, baseaddr + reg);
}
@@ -659,7 +667,7 @@ static void switch_page(struct comedi_device *dev, int asic, int page)
/* now write out the shadow register */
outb(devpriv->asics[asic].pagelock,
- dev->iobase + ASIC_IOSIZE * asic + REG_PAGELOCK);
+ dev->iobase + ASIC_IOSIZE * asic + REG_PAGELOCK);
}
#ifdef notused
@@ -673,7 +681,7 @@ static void lock_port(struct comedi_device *dev, int asic, int port)
devpriv->asics[asic].pagelock |= 0x1 << port;
/* now write out the shadow register */
outb(devpriv->asics[asic].pagelock,
- dev->iobase + ASIC_IOSIZE * asic + REG_PAGELOCK);
+ dev->iobase + ASIC_IOSIZE * asic + REG_PAGELOCK);
}
static void unlock_port(struct comedi_device *dev, int asic, int port)
@@ -685,14 +693,14 @@ static void unlock_port(struct comedi_device *dev, int asic, int port)
devpriv->asics[asic].pagelock &= ~(0x1 << port) | REG_LOCK_MASK;
/* now write out the shadow register */
outb(devpriv->asics[asic].pagelock,
- dev->iobase + ASIC_IOSIZE * asic + REG_PAGELOCK);
+ dev->iobase + ASIC_IOSIZE * asic + REG_PAGELOCK);
}
#endif /* notused */
static irqreturn_t interrupt_pcmuio(int irq, void *d)
{
int asic, got1 = 0;
- struct comedi_device *dev = (struct comedi_device *) d;
+ struct comedi_device *dev = (struct comedi_device *)d;
for (asic = 0; asic < MAX_ASICS; ++asic) {
if (irq == devpriv->asics[asic].irq) {
@@ -702,121 +710,130 @@ static irqreturn_t interrupt_pcmuio(int irq, void *d)
/* it is an interrupt for ASIC #asic */
unsigned char int_pend;
- spin_lock_irqsave(&devpriv->asics[asic].spinlock, flags);
+ spin_lock_irqsave(&devpriv->asics[asic].spinlock,
+ flags);
int_pend = inb(iobase + REG_INT_PENDING) & 0x07;
if (int_pend) {
int port;
for (port = 0; port < INTR_PORTS_PER_ASIC;
- ++port) {
+ ++port) {
if (int_pend & (0x1 << port)) {
unsigned char
- io_lines_with_edges = 0;
+ io_lines_with_edges = 0;
switch_page(dev, asic,
- PAGE_INT_ID);
+ PAGE_INT_ID);
io_lines_with_edges =
- inb(iobase +
+ inb(iobase +
REG_INT_ID0 + port);
if (io_lines_with_edges)
/* clear pending interrupt */
outb(0, iobase +
- REG_INT_ID0 +
- port);
+ REG_INT_ID0 +
+ port);
triggered |=
- io_lines_with_edges <<
- port * 8;
+ io_lines_with_edges <<
+ port * 8;
}
}
++got1;
}
- spin_unlock_irqrestore(&devpriv->asics[asic].spinlock, flags);
+ spin_unlock_irqrestore(&devpriv->asics[asic].spinlock,
+ flags);
if (triggered) {
struct comedi_subdevice *s;
/* TODO here: dispatch io lines to subdevs with commands.. */
- printk("PCMUIO DEBUG: got edge detect interrupt %d asic %d which_chans: %06x\n", irq, asic, triggered);
+ printk
+ ("PCMUIO DEBUG: got edge detect interrupt %d asic %d which_chans: %06x\n",
+ irq, asic, triggered);
for (s = dev->subdevices;
- s < dev->subdevices + dev->n_subdevices;
- ++s) {
+ s < dev->subdevices + dev->n_subdevices;
+ ++s) {
if (subpriv->intr.asic == asic) { /* this is an interrupt subdev, and it matches this asic! */
unsigned long flags;
unsigned oldevents;
- spin_lock_irqsave (&subpriv->intr.spinlock, flags);
+ spin_lock_irqsave(&subpriv->
+ intr.spinlock,
+ flags);
oldevents = s->async->events;
if (subpriv->intr.active) {
unsigned mytrig =
- ((triggered >>
- subpriv->
- intr.
- asic_chan)
- & ((0x1 << subpriv->intr.num_asic_chans) - 1)) << subpriv->intr.first_chan;
- if (mytrig & subpriv->
- intr.
- enabled_mask) {
- unsigned int val =
- 0;
+ ((triggered >>
+ subpriv->intr.asic_chan)
+ &
+ ((0x1 << subpriv->
+ intr.
+ num_asic_chans) -
+ 1)) << subpriv->
+ intr.first_chan;
+ if (mytrig &
+ subpriv->intr.enabled_mask)
+ {
+ unsigned int val
+ = 0;
unsigned int n,
- ch, len;
+ ch, len;
- len = s->async->
- cmd.
- chanlist_len;
+ len =
+ s->
+ async->cmd.chanlist_len;
for (n = 0;
- n < len;
- n++) {
+ n < len;
+ n++) {
ch = CR_CHAN(s->async->cmd.chanlist[n]);
if (mytrig & (1U << ch)) {
val |= (1U << n);
}
}
/* Write the scan to the buffer. */
- if (comedi_buf_put(s->async, ((short *) &val)[0])
- &&
- comedi_buf_put
- (s->async, ((short *) &val)[1])) {
+ if (comedi_buf_put(s->async, ((short *)&val)[0])
+ &&
+ comedi_buf_put
+ (s->async,
+ ((short *)
+ &val)[1]))
+ {
s->async->events |= (COMEDI_CB_BLOCK | COMEDI_CB_EOS);
} else {
/* Overflow! Stop acquisition!! */
/* TODO: STOP_ACQUISITION_CALL_HERE!! */
pcmuio_stop_intr
- (dev,
- s);
+ (dev,
+ s);
}
/* Check for end of acquisition. */
- if (!subpriv->
- intr.
- continuous)
- {
+ if (!subpriv->intr.continuous) {
/* stop_src == TRIG_COUNT */
if (subpriv->intr.stop_count > 0) {
- subpriv->
- intr.
- stop_count--;
+ subpriv->intr.stop_count--;
if (subpriv->intr.stop_count == 0) {
s->async->events |= COMEDI_CB_EOA;
/* TODO: STOP_ACQUISITION_CALL_HERE!! */
pcmuio_stop_intr
- (dev,
- s);
+ (dev,
+ s);
}
}
}
}
}
- spin_unlock_irqrestore(&subpriv->intr.spinlock, flags);
+ spin_unlock_irqrestore
+ (&subpriv->intr.spinlock,
+ flags);
if (oldevents !=
- s->async->events) {
+ s->async->events) {
comedi_event(dev, s);
}
@@ -832,7 +849,8 @@ static irqreturn_t interrupt_pcmuio(int irq, void *d)
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;
@@ -852,7 +870,8 @@ 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! */
@@ -876,27 +895,29 @@ static int pcmuio_start_intr(struct comedi_device *dev, struct comedi_subdevice
for (n = 0; n < cmd->chanlist_len; n++) {
bits |= (1U << CR_CHAN(cmd->chanlist[n]));
pol_bits |= (CR_AREF(cmd->chanlist[n])
- || CR_RANGE(cmd->chanlist[n]) ? 1U : 0U)
- << CR_CHAN(cmd->chanlist[n]);
+ || CR_RANGE(cmd->
+ chanlist[n]) ? 1U : 0U)
+ << CR_CHAN(cmd->chanlist[n]);
}
}
bits &= ((0x1 << subpriv->intr.num_asic_chans) -
- 1) << subpriv->intr.first_chan;
+ 1) << subpriv->intr.first_chan;
subpriv->intr.enabled_mask = bits;
switch_page(dev, asic, PAGE_ENAB);
for (port = firstport; port < firstport + nports; ++port) {
unsigned enab =
- bits >> (subpriv->intr.first_chan + (port -
- firstport) * 8) & 0xff, pol =
- pol_bits >> (subpriv->intr.first_chan + (port -
- firstport) * 8) & 0xff;
+ bits >> (subpriv->intr.first_chan + (port -
+ firstport) *
+ 8) & 0xff, pol =
+ pol_bits >> (subpriv->intr.first_chan +
+ (port - firstport) * 8) & 0xff;
/* set enab intrs for this subdev.. */
outb(enab,
- devpriv->asics[asic].iobase + REG_ENAB0 + port);
+ devpriv->asics[asic].iobase + REG_ENAB0 + port);
switch_page(dev, asic, PAGE_POL);
outb(pol,
- devpriv->asics[asic].iobase + REG_ENAB0 + port);
+ devpriv->asics[asic].iobase + REG_ENAB0 + port);
}
}
return 0;
@@ -919,7 +940,7 @@ static int pcmuio_cancel(struct comedi_device *dev, struct comedi_subdevice *s)
*/
static int
pcmuio_inttrig_start_intr(struct comedi_device *dev, struct comedi_subdevice *s,
- unsigned int trignum)
+ unsigned int trignum)
{
unsigned long flags;
int event = 0;
@@ -986,7 +1007,8 @@ 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)
+pcmuio_cmdtest(struct comedi_device *dev, struct comedi_subdevice *s,
+ struct comedi_cmd *cmd)
{
return comedi_pcm_cmdtest(dev, s, cmd);
}
diff --git a/drivers/staging/comedi/drivers/plx9080.h b/drivers/staging/comedi/drivers/plx9080.h
index e4bbd5dc9a61..53bcdb7b5c5a 100644
--- a/drivers/staging/comedi/drivers/plx9080.h
+++ b/drivers/staging/comedi/drivers/plx9080.h
@@ -404,8 +404,8 @@ static inline int plx9080_abort_dma(void *iobase, unsigned int channel)
}
if (i == timeout) {
printk
- ("plx9080: cancel() timed out waiting for dma %i done clear\n",
- channel);
+ ("plx9080: cancel() timed out waiting for dma %i done clear\n",
+ channel);
return -ETIMEDOUT;
}
/* disable and abort channel */
@@ -418,8 +418,8 @@ static inline int plx9080_abort_dma(void *iobase, unsigned int channel)
}
if (i == timeout) {
printk
- ("plx9080: cancel() timed out waiting for dma %i done set\n",
- channel);
+ ("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 47850bd15484..729a0d8766e8 100644
--- a/drivers/staging/comedi/drivers/poc.c
+++ b/drivers/staging/comedi/drivers/poc.c
@@ -44,14 +44,16 @@ Configuration options:
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);
+ 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 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;
@@ -60,44 +62,44 @@ struct boarddef_struct {
int type;
int n_chan;
int n_bits;
- int (*winsn) (struct comedi_device *, struct comedi_subdevice *, struct comedi_insn *,
- unsigned int *);
- int (*rinsn) (struct comedi_device *, struct comedi_subdevice *, struct comedi_insn *,
- unsigned int *);
- int (*insnbits) (struct comedi_device *, struct comedi_subdevice *, struct comedi_insn *,
- unsigned int *);
+ int (*winsn) (struct comedi_device *, struct comedi_subdevice *,
+ struct comedi_insn *, unsigned int *);
+ int (*rinsn) (struct comedi_device *, struct comedi_subdevice *,
+ struct comedi_insn *, unsigned int *);
+ int (*insnbits) (struct comedi_device *, struct comedi_subdevice *,
+ struct comedi_insn *, unsigned int *);
const struct comedi_lrange *range;
};
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,
+ },
};
#define n_boards (sizeof(boards)/sizeof(boards[0]))
@@ -121,7 +123,7 @@ static int poc_attach(struct comedi_device *dev, struct comedi_devconfig *it)
iobase = it->options[0];
printk("comedi%d: poc: using %s iobase 0x%lx\n", dev->minor,
- this_board->name, iobase);
+ this_board->name, iobase);
dev->board_name = this_board->name;
@@ -133,7 +135,9 @@ static int poc_attach(struct comedi_device *dev, struct comedi_devconfig *it)
iosize = this_board->iosize;
/* check if io addresses are available */
if (!request_region(iobase, iosize, "dac02")) {
- printk("I/O port conflict: failed to allocate ports 0x%lx to 0x%lx\n", iobase, iobase + iosize - 1);
+ printk
+ ("I/O port conflict: failed to allocate ports 0x%lx to 0x%lx\n",
+ iobase, iobase + iosize - 1);
return -EIO;
}
dev->iobase = iobase;
@@ -171,12 +175,12 @@ 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)
+ struct comedi_insn *insn, unsigned int *data)
{
int chan;
chan = CR_CHAN(insn->chanspec);
- data[0] = ((unsigned int *) dev->private)[chan];
+ data[0] = ((unsigned int *)dev->private)[chan];
return 1;
}
@@ -186,14 +190,14 @@ static int readback_insn(struct comedi_device *dev, struct comedi_subdevice *s,
#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)
+ struct comedi_insn *insn, unsigned int *data)
{
int temp;
int chan;
int output;
chan = CR_CHAN(insn->chanspec);
- ((unsigned int *) dev->private)[chan] = data[0];
+ ((unsigned int *)dev->private)[chan] = data[0];
output = data[0];
#ifdef wrong
/* convert to complementary binary if range is bipolar */
@@ -208,8 +212,9 @@ static int dac02_ao_winsn(struct comedi_device *dev, struct comedi_subdevice *s,
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 +227,9 @@ 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 85b53c93e135..f63bdc35cffd 100644
--- a/drivers/staging/comedi/drivers/quatech_daqp_cs.c
+++ b/drivers/staging/comedi/drivers/quatech_daqp_cs.c
@@ -184,11 +184,11 @@ static struct local_info_t *dev_table[MAX_DEV] = { NULL, /* ... */ };
*/
static const struct comedi_lrange range_daqp_ai = { 4, {
- BIP_RANGE(10),
- BIP_RANGE(5),
- BIP_RANGE(2.5),
- BIP_RANGE(1.25)
- }
+ BIP_RANGE(10),
+ BIP_RANGE(5),
+ BIP_RANGE(2.5),
+ BIP_RANGE(1.25)
+ }
};
static const struct comedi_lrange range_daqp_ao = { 1, {BIP_RANGE(5)} };
@@ -211,7 +211,7 @@ static struct comedi_driver driver_daqp = {
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));
+ inb(dev->iobase + DAQP_STATUS), inb(dev->iobase + DAQP_AUX));
}
static void hex_dump(char *str, void *ptr, int len)
@@ -236,7 +236,7 @@ static void hex_dump(char *str, void *ptr, int len)
static int daqp_ai_cancel(struct comedi_device *dev, struct comedi_subdevice *s)
{
- struct local_info_t *local = (struct local_info_t *) s->private;
+ struct local_info_t *local = (struct local_info_t *)s->private;
if (local->stop) {
return -EIO;
@@ -264,7 +264,7 @@ static int daqp_ai_cancel(struct comedi_device *dev, struct comedi_subdevice *s)
static void daqp_interrupt(int irq, void *dev_id)
{
- struct local_info_t *local = (struct local_info_t *) dev_id;
+ struct local_info_t *local = (struct local_info_t *)dev_id;
struct comedi_device *dev;
struct comedi_subdevice *s;
int loop_limit = 10000;
@@ -272,7 +272,7 @@ static void daqp_interrupt(int irq, void *dev_id)
if (local == NULL) {
printk(KERN_WARNING
- "daqp_interrupt(): irq %d for unknown device.\n", irq);
+ "daqp_interrupt(): irq %d for unknown device.\n", irq);
return;
}
@@ -284,20 +284,20 @@ static void daqp_interrupt(int irq, void *dev_id)
if (!dev->attached) {
printk(KERN_WARNING
- "daqp_interrupt(): struct comedi_device not yet attached.\n");
+ "daqp_interrupt(): struct comedi_device not yet attached.\n");
return;
}
s = local->s;
if (s == NULL) {
printk(KERN_WARNING
- "daqp_interrupt(): NULL comedi_subdevice.\n");
+ "daqp_interrupt(): NULL comedi_subdevice.\n");
return;
}
- if ((struct local_info_t *) s->private != local) {
+ if ((struct local_info_t *)s->private != local) {
printk(KERN_WARNING
- "daqp_interrupt(): invalid comedi_subdevice.\n");
+ "daqp_interrupt(): invalid comedi_subdevice.\n");
return;
}
@@ -311,13 +311,13 @@ static void daqp_interrupt(int irq, void *dev_id)
case buffer:
while (!((status = inb(dev->iobase + DAQP_STATUS))
- & DAQP_STATUS_FIFO_EMPTY)) {
+ & DAQP_STATUS_FIFO_EMPTY)) {
short data;
if (status & DAQP_STATUS_DATA_LOST) {
s->async->events |=
- COMEDI_CB_EOA | COMEDI_CB_OVERFLOW;
+ COMEDI_CB_EOA | COMEDI_CB_OVERFLOW;
printk("daqp: data lost\n");
daqp_ai_cancel(dev, s);
break;
@@ -348,7 +348,7 @@ static void daqp_interrupt(int irq, void *dev_id)
if (loop_limit <= 0) {
printk(KERN_WARNING
- "loop_limit reached in daqp_interrupt()\n");
+ "loop_limit reached in daqp_interrupt()\n");
daqp_ai_cancel(dev, s);
s->async->events |= COMEDI_CB_EOA | COMEDI_CB_ERROR;
}
@@ -361,10 +361,11 @@ static void daqp_interrupt(int irq, void *dev_id)
/* 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;
+ struct local_info_t *local = (struct local_info_t *)s->private;
int i;
int v;
int counter = 10000;
@@ -384,7 +385,7 @@ static int daqp_ai_insn_read(struct comedi_device *dev, struct comedi_subdevice
/* Program one scan list entry */
v = DAQP_SCANLIST_CHANNEL(CR_CHAN(insn->chanspec))
- | DAQP_SCANLIST_GAIN(CR_RANGE(insn->chanspec));
+ | DAQP_SCANLIST_GAIN(CR_RANGE(insn->chanspec));
if (CR_AREF(insn->chanspec) == AREF_DIFF) {
v |= DAQP_SCANLIST_DIFFERENTIAL;
@@ -402,7 +403,7 @@ static int daqp_ai_insn_read(struct comedi_device *dev, struct comedi_subdevice
/* Set trigger */
v = DAQP_CONTROL_TRIGGER_ONESHOT | DAQP_CONTROL_TRIGGER_INTERNAL
- | DAQP_CONTROL_PACER_100kHz | DAQP_CONTROL_EOS_INT_ENABLE;
+ | DAQP_CONTROL_PACER_100kHz | DAQP_CONTROL_EOS_INT_ENABLE;
outb(v, dev->iobase + DAQP_CONTROL);
@@ -411,7 +412,7 @@ static int daqp_ai_insn_read(struct comedi_device *dev, struct comedi_subdevice
*/
while (--counter
- && (inb(dev->iobase + DAQP_STATUS) & DAQP_STATUS_EVENTS)) ;
+ && (inb(dev->iobase + DAQP_STATUS) & DAQP_STATUS_EVENTS)) ;
if (!counter) {
printk("daqp: couldn't clear interrupts in status register\n");
return -1;
@@ -427,7 +428,7 @@ static int daqp_ai_insn_read(struct comedi_device *dev, struct comedi_subdevice
/* Start conversion */
outb(DAQP_COMMAND_ARM | DAQP_COMMAND_FIFO_DATA,
- dev->iobase + DAQP_COMMAND);
+ dev->iobase + DAQP_COMMAND);
/* Wait for interrupt service routine to unblock semaphore */
/* Maybe could use a timeout here, but it's interruptible */
@@ -467,8 +468,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;
@@ -507,7 +508,7 @@ static int daqp_ai_cmdtest(struct comedi_device *dev, struct comedi_subdevice *s
/* note that mutual compatiblity is not an issue here */
if (cmd->scan_begin_src != TRIG_TIMER &&
- cmd->scan_begin_src != TRIG_FOLLOW)
+ cmd->scan_begin_src != TRIG_FOLLOW)
err++;
if (cmd->convert_src != TRIG_NOW && cmd->convert_src != TRIG_TIMER)
err++;
@@ -528,7 +529,7 @@ static int daqp_ai_cmdtest(struct comedi_device *dev, struct comedi_subdevice *s
#define MAX_SPEED 10000 /* 100 kHz - in nanoseconds */
if (cmd->scan_begin_src == TRIG_TIMER
- && cmd->scan_begin_arg < MAX_SPEED) {
+ && cmd->scan_begin_arg < MAX_SPEED) {
cmd->scan_begin_arg = MAX_SPEED;
err++;
}
@@ -539,8 +540,7 @@ static int daqp_ai_cmdtest(struct comedi_device *dev, struct comedi_subdevice *s
*/
if (cmd->scan_begin_src == TRIG_TIMER && cmd->convert_src == TRIG_TIMER
- && cmd->scan_begin_arg !=
- cmd->convert_arg * cmd->scan_end_arg) {
+ && cmd->scan_begin_arg != cmd->convert_arg * cmd->scan_end_arg) {
err++;
}
@@ -574,7 +574,7 @@ static int daqp_ai_cmdtest(struct comedi_device *dev, struct comedi_subdevice *s
if (cmd->scan_begin_src == TRIG_TIMER) {
tmp = cmd->scan_begin_arg;
daqp_ns_to_timer(&cmd->scan_begin_arg,
- cmd->flags & TRIG_ROUND_MASK);
+ cmd->flags & TRIG_ROUND_MASK);
if (tmp != cmd->scan_begin_arg)
err++;
}
@@ -582,7 +582,7 @@ static int daqp_ai_cmdtest(struct comedi_device *dev, struct comedi_subdevice *s
if (cmd->convert_src == TRIG_TIMER) {
tmp = cmd->convert_arg;
daqp_ns_to_timer(&cmd->convert_arg,
- cmd->flags & TRIG_ROUND_MASK);
+ cmd->flags & TRIG_ROUND_MASK);
if (tmp != cmd->convert_arg)
err++;
}
@@ -595,7 +595,7 @@ static int daqp_ai_cmdtest(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 local_info_t *local = (struct local_info_t *)s->private;
struct comedi_cmd *cmd = &s->async->cmd;
int counter = 100;
int scanlist_start_on_every_entry;
@@ -631,14 +631,14 @@ static int daqp_ai_cmd(struct comedi_device *dev, struct comedi_subdevice *s)
if (cmd->convert_src == TRIG_TIMER) {
int counter = daqp_ns_to_timer(&cmd->convert_arg,
- cmd->flags & TRIG_ROUND_MASK);
+ cmd->flags & TRIG_ROUND_MASK);
outb(counter & 0xff, dev->iobase + DAQP_PACER_LOW);
outb((counter >> 8) & 0xff, dev->iobase + DAQP_PACER_MID);
outb((counter >> 16) & 0xff, dev->iobase + DAQP_PACER_HIGH);
scanlist_start_on_every_entry = 1;
} else {
int counter = daqp_ns_to_timer(&cmd->scan_begin_arg,
- cmd->flags & TRIG_ROUND_MASK);
+ cmd->flags & TRIG_ROUND_MASK);
outb(counter & 0xff, dev->iobase + DAQP_PACER_LOW);
outb((counter >> 8) & 0xff, dev->iobase + DAQP_PACER_MID);
outb((counter >> 16) & 0xff, dev->iobase + DAQP_PACER_HIGH);
@@ -654,7 +654,7 @@ static int daqp_ai_cmd(struct comedi_device *dev, struct comedi_subdevice *s)
/* Program one scan list entry */
v = DAQP_SCANLIST_CHANNEL(CR_CHAN(chanspec))
- | DAQP_SCANLIST_GAIN(CR_RANGE(chanspec));
+ | DAQP_SCANLIST_GAIN(CR_RANGE(chanspec));
if (CR_AREF(chanspec) == AREF_DIFF) {
v |= DAQP_SCANLIST_DIFFERENTIAL;
@@ -765,7 +765,7 @@ static int daqp_ai_cmd(struct comedi_device *dev, struct comedi_subdevice *s)
/* Set trigger */
v = DAQP_CONTROL_TRIGGER_CONTINUOUS | DAQP_CONTROL_TRIGGER_INTERNAL
- | DAQP_CONTROL_PACER_5MHz | DAQP_CONTROL_FIFO_INT_ENABLE;
+ | DAQP_CONTROL_PACER_5MHz | DAQP_CONTROL_FIFO_INT_ENABLE;
outb(v, dev->iobase + DAQP_CONTROL);
@@ -774,7 +774,7 @@ static int daqp_ai_cmd(struct comedi_device *dev, struct comedi_subdevice *s)
*/
while (--counter
- && (inb(dev->iobase + DAQP_STATUS) & DAQP_STATUS_EVENTS)) ;
+ && (inb(dev->iobase + DAQP_STATUS) & DAQP_STATUS_EVENTS)) ;
if (!counter) {
printk("daqp: couldn't clear interrupts in status register\n");
return -1;
@@ -786,17 +786,18 @@ static int daqp_ai_cmd(struct comedi_device *dev, struct comedi_subdevice *s)
/* Start conversion */
outb(DAQP_COMMAND_ARM | DAQP_COMMAND_FIFO_DATA,
- dev->iobase + DAQP_COMMAND);
+ dev->iobase + DAQP_COMMAND);
return 0;
}
/* 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;
+ struct local_info_t *local = (struct local_info_t *)s->private;
int d;
unsigned int chan;
@@ -820,10 +821,11 @@ static int daqp_ao_insn_write(struct comedi_device *dev, struct comedi_subdevice
/* 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;
+ struct local_info_t *local = (struct local_info_t *)s->private;
if (local->stop) {
return -EIO;
@@ -836,10 +838,11 @@ 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;
+ struct local_info_t *local = (struct local_info_t *)s->private;
if (local->stop) {
return -EIO;
@@ -866,7 +869,7 @@ static int daqp_attach(struct comedi_device *dev, struct comedi_devconfig *it)
if (it->options[0] < 0 || it->options[0] >= MAX_DEV || !local) {
printk("comedi%d: No such daqp device %d\n",
- dev->minor, it->options[0]);
+ dev->minor, it->options[0]);
return -EIO;
}
@@ -899,7 +902,7 @@ static int daqp_attach(struct comedi_device *dev, struct comedi_devconfig *it)
break;
i++;
if ((i < tuple.TupleDataLen - 4)
- && (strncmp(buf + i, "DAQP", 4) == 0)) {
+ && (strncmp(buf + i, "DAQP", 4) == 0)) {
strncpy(local->board_name, buf + i,
sizeof(local->board_name));
}
@@ -913,7 +916,7 @@ static int daqp_attach(struct comedi_device *dev, struct comedi_devconfig *it)
return ret;
printk("comedi%d: attaching daqp%d (io 0x%04lx)\n",
- dev->minor, it->options[0], dev->iobase);
+ dev->minor, it->options[0], dev->iobase);
s = dev->subdevices + 0;
dev->read_subdev = s;
@@ -1234,7 +1237,7 @@ static void daqp_cs_config(struct pcmcia_device *link)
/* If we got this far, we're cool! */
break;
- next_entry:
+next_entry:
last_ret = pcmcia_get_next_tuple(link, &tuple);
if (last_ret) {
cs_error(link, GetNextTuple, last_ret);
@@ -1280,20 +1283,20 @@ static void daqp_cs_config(struct pcmcia_device *link)
/* Finally, report what we've done */
printk(KERN_INFO "%s: index 0x%02x",
- dev->node.dev_name, link->conf.ConfigIndex);
+ dev->node.dev_name, link->conf.ConfigIndex);
if (link->conf.Attributes & CONF_ENABLE_IRQ)
printk(", irq %u", link->irq.AssignedIRQ);
if (link->io.NumPorts1)
printk(", io 0x%04x-0x%04x", link->io.BasePort1,
- link->io.BasePort1 + link->io.NumPorts1 - 1);
+ link->io.BasePort1 + link->io.NumPorts1 - 1);
if (link->io.NumPorts2)
printk(" & 0x%04x-0x%04x", link->io.BasePort2,
- link->io.BasePort2 + link->io.NumPorts2 - 1);
+ link->io.BasePort2 + link->io.NumPorts2 - 1);
printk("\n");
return;
- cs_failed:
+cs_failed:
daqp_cs_release(link);
} /* daqp_cs_config */
@@ -1354,7 +1357,7 @@ struct pcmcia_driver daqp_cs_driver = {
.id_table = daqp_cs_id_table,
.owner = THIS_MODULE,
.drv = {
- .name = dev_info,
+ .name = dev_info,
},
};
diff --git a/drivers/staging/comedi/drivers/rtd520.c b/drivers/staging/comedi/drivers/rtd520.c
index 243ee76c836d..f35cce597140 100644
--- a/drivers/staging/comedi/drivers/rtd520.c
+++ b/drivers/staging/comedi/drivers/rtd520.c
@@ -198,70 +198,100 @@ Configuration options:
The board has 3 input modes and the gains of 1,2,4,...32 (, 64, 128)
*/
static const struct comedi_lrange rtd_ai_7520_range = { 18, {
- /* +-5V input range gain steps */
- BIP_RANGE(5.0),
- BIP_RANGE(5.0 / 2),
- BIP_RANGE(5.0 / 4),
- BIP_RANGE(5.0 / 8),
- BIP_RANGE(5.0 / 16),
- BIP_RANGE(5.0 / 32),
- /* +-10V input range gain steps */
- BIP_RANGE(10.0),
- BIP_RANGE(10.0 / 2),
- BIP_RANGE(10.0 / 4),
- BIP_RANGE(10.0 / 8),
- BIP_RANGE(10.0 / 16),
- BIP_RANGE(10.0 / 32),
- /* +10V input range gain steps */
- UNI_RANGE(10.0),
- UNI_RANGE(10.0 / 2),
- UNI_RANGE(10.0 / 4),
- UNI_RANGE(10.0 / 8),
- UNI_RANGE(10.0 / 16),
- UNI_RANGE(10.0 / 32),
-
- }
+ /* +-5V input range gain steps */
+ BIP_RANGE(5.0),
+ BIP_RANGE(5.0 / 2),
+ BIP_RANGE(5.0 / 4),
+ BIP_RANGE(5.0 / 8),
+ BIP_RANGE(5.0 /
+ 16),
+ BIP_RANGE(5.0 /
+ 32),
+ /* +-10V input range gain steps */
+ BIP_RANGE(10.0),
+ BIP_RANGE(10.0 /
+ 2),
+ BIP_RANGE(10.0 /
+ 4),
+ BIP_RANGE(10.0 /
+ 8),
+ BIP_RANGE(10.0 /
+ 16),
+ BIP_RANGE(10.0 /
+ 32),
+ /* +10V input range gain steps */
+ UNI_RANGE(10.0),
+ UNI_RANGE(10.0 /
+ 2),
+ UNI_RANGE(10.0 /
+ 4),
+ UNI_RANGE(10.0 /
+ 8),
+ UNI_RANGE(10.0 /
+ 16),
+ UNI_RANGE(10.0 /
+ 32),
+
+ }
};
/* PCI4520 has two more gains (6 more entries) */
static const struct comedi_lrange rtd_ai_4520_range = { 24, {
- /* +-5V input range gain steps */
- BIP_RANGE(5.0),
- BIP_RANGE(5.0 / 2),
- BIP_RANGE(5.0 / 4),
- BIP_RANGE(5.0 / 8),
- BIP_RANGE(5.0 / 16),
- BIP_RANGE(5.0 / 32),
- BIP_RANGE(5.0 / 64),
- BIP_RANGE(5.0 / 128),
- /* +-10V input range gain steps */
- BIP_RANGE(10.0),
- BIP_RANGE(10.0 / 2),
- BIP_RANGE(10.0 / 4),
- BIP_RANGE(10.0 / 8),
- BIP_RANGE(10.0 / 16),
- BIP_RANGE(10.0 / 32),
- BIP_RANGE(10.0 / 64),
- BIP_RANGE(10.0 / 128),
- /* +10V input range gain steps */
- UNI_RANGE(10.0),
- UNI_RANGE(10.0 / 2),
- UNI_RANGE(10.0 / 4),
- UNI_RANGE(10.0 / 8),
- UNI_RANGE(10.0 / 16),
- UNI_RANGE(10.0 / 32),
- UNI_RANGE(10.0 / 64),
- UNI_RANGE(10.0 / 128),
- }
+ /* +-5V input range gain steps */
+ BIP_RANGE(5.0),
+ BIP_RANGE(5.0 / 2),
+ BIP_RANGE(5.0 / 4),
+ BIP_RANGE(5.0 / 8),
+ BIP_RANGE(5.0 /
+ 16),
+ BIP_RANGE(5.0 /
+ 32),
+ BIP_RANGE(5.0 /
+ 64),
+ BIP_RANGE(5.0 /
+ 128),
+ /* +-10V input range gain steps */
+ BIP_RANGE(10.0),
+ BIP_RANGE(10.0 /
+ 2),
+ BIP_RANGE(10.0 /
+ 4),
+ BIP_RANGE(10.0 /
+ 8),
+ BIP_RANGE(10.0 /
+ 16),
+ BIP_RANGE(10.0 /
+ 32),
+ BIP_RANGE(10.0 /
+ 64),
+ BIP_RANGE(10.0 /
+ 128),
+ /* +10V input range gain steps */
+ UNI_RANGE(10.0),
+ UNI_RANGE(10.0 /
+ 2),
+ UNI_RANGE(10.0 /
+ 4),
+ UNI_RANGE(10.0 /
+ 8),
+ UNI_RANGE(10.0 /
+ 16),
+ UNI_RANGE(10.0 /
+ 32),
+ UNI_RANGE(10.0 /
+ 64),
+ UNI_RANGE(10.0 /
+ 128),
+ }
};
/* Table order matches range values */
static const struct comedi_lrange rtd_ao_range = { 4, {
- RANGE(0, 5),
- RANGE(0, 10),
- RANGE(-5, 5),
- RANGE(-10, 10),
- }
+ RANGE(0, 5),
+ RANGE(0, 10),
+ RANGE(-5, 5),
+ RANGE(-10, 10),
+ }
};
/*
@@ -279,29 +309,30 @@ 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,
+ },
};
static DEFINE_PCI_DEVICE_TABLE(rtd520_pci_table) = {
- {PCI_VENDOR_ID_RTD, 0x7520, PCI_ANY_ID, PCI_ANY_ID, 0, 0, 0},
- {PCI_VENDOR_ID_RTD, 0x4520, PCI_ANY_ID, PCI_ANY_ID, 0, 0, 0},
- {0}
+ {
+ PCI_VENDOR_ID_RTD, 0x7520, PCI_ANY_ID, PCI_ANY_ID, 0, 0, 0}, {
+ PCI_VENDOR_ID_RTD, 0x4520, PCI_ANY_ID, PCI_ANY_ID, 0, 0, 0}, {
+ 0}
};
MODULE_DEVICE_TABLE(pci, rtd520_pci_table);
@@ -692,17 +723,19 @@ static struct comedi_driver rtd520Driver = {
};
static int rtd_ai_rinsn(struct comedi_device *dev, struct comedi_subdevice *s,
- struct comedi_insn *insn, unsigned int *data);
+ struct comedi_insn *insn, unsigned int *data);
static int rtd_ao_winsn(struct comedi_device *dev, struct comedi_subdevice *s,
- struct comedi_insn *insn, unsigned int *data);
+ struct comedi_insn *insn, unsigned int *data);
static int rtd_ao_rinsn(struct comedi_device *dev, struct comedi_subdevice *s,
- struct comedi_insn *insn, unsigned int *data);
-static int rtd_dio_insn_bits(struct comedi_device *dev, struct comedi_subdevice *s,
- struct comedi_insn *insn, unsigned int *data);
-static int rtd_dio_insn_config(struct comedi_device *dev, struct comedi_subdevice *s,
- struct comedi_insn *insn, unsigned int *data);
+ struct comedi_insn *insn, unsigned int *data);
+static int rtd_dio_insn_bits(struct comedi_device *dev,
+ struct comedi_subdevice *s,
+ struct comedi_insn *insn, unsigned int *data);
+static int rtd_dio_insn_config(struct comedi_device *dev,
+ struct comedi_subdevice *s,
+ struct comedi_insn *insn, unsigned int *data);
static int rtd_ai_cmdtest(struct comedi_device *dev, struct comedi_subdevice *s,
- struct comedi_cmd *cmd);
+ struct comedi_cmd *cmd);
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); */
@@ -747,31 +780,29 @@ static int rtd_attach(struct comedi_device *dev, struct comedi_devconfig *it)
* Probe the device to determine what device in the series it is.
*/
for (pcidev = pci_get_device(PCI_VENDOR_ID_RTD, PCI_ANY_ID, NULL);
- pcidev != NULL;
- pcidev = pci_get_device(PCI_VENDOR_ID_RTD, PCI_ANY_ID, pcidev)) {
+ pcidev != NULL;
+ pcidev = pci_get_device(PCI_VENDOR_ID_RTD, PCI_ANY_ID, pcidev)) {
int i;
if (it->options[0] || it->options[1]) {
if (pcidev->bus->number != it->options[0]
- || PCI_SLOT(pcidev->devfn) !=
- it->options[1]) {
+ || PCI_SLOT(pcidev->devfn) != it->options[1]) {
continue;
}
}
- for (i = 0; i < ARRAY_SIZE(rtd520Boards); ++i)
- {
- if (pcidev->device == rtd520Boards[i].device_id)
- {
+ for (i = 0; i < ARRAY_SIZE(rtd520Boards); ++i) {
+ 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]) {
printk("No RTD card at bus=%d slot=%d.\n",
- it->options[0], it->options[1]);
+ it->options[0], it->options[1]);
} else {
printk("No RTD card found.\n");
}
@@ -813,16 +844,16 @@ static int rtd_attach(struct comedi_device *dev, struct comedi_devconfig *it)
/*uint32_t epld_version; */
pci_read_config_word(devpriv->pci_dev, PCI_REVISION_ID,
- &revision);
+ &revision);
DPRINTK("%s: PCI revision %d.\n", dev->board_name, revision);
pci_read_config_byte(devpriv->pci_dev,
- PCI_LATENCY_TIMER, &pci_latency);
+ PCI_LATENCY_TIMER, &pci_latency);
if (pci_latency < 32) {
printk("%s: PCI latency changed from %d to %d\n",
- dev->board_name, pci_latency, 32);
+ dev->board_name, pci_latency, 32);
pci_write_config_byte(devpriv->pci_dev,
- PCI_LATENCY_TIMER, 32);
+ PCI_LATENCY_TIMER, 32);
} else {
DPRINTK("rtd520: PCI latency = %d\n", pci_latency);
}
@@ -854,8 +885,7 @@ static int rtd_attach(struct comedi_device *dev, struct comedi_devconfig *it)
/* analog input subdevice */
s->type = COMEDI_SUBD_AI;
s->subdev_flags =
- SDF_READABLE | SDF_GROUND | SDF_COMMON | SDF_DIFF |
- SDF_CMD_READ;
+ SDF_READABLE | SDF_GROUND | SDF_COMMON | SDF_DIFF | SDF_CMD_READ;
s->n_chan = thisboard->aiChans;
s->maxdata = (1 << thisboard->aiBits) - 1;
if (thisboard->aiMaxGain <= 32) {
@@ -868,7 +898,7 @@ static int rtd_attach(struct comedi_device *dev, struct comedi_devconfig *it)
s->do_cmd = rtd_ai_cmd;
s->do_cmdtest = rtd_ai_cmdtest;
s->cancel = rtd_ai_cancel;
- /* s->poll = rtd_ai_poll; */ /* not ready yet */
+ /* s->poll = rtd_ai_poll; *//* not ready yet */
s = dev->subdevices + 1;
/* analog output subdevice */
@@ -901,7 +931,7 @@ static int rtd_attach(struct comedi_device *dev, struct comedi_devconfig *it)
/* initialize board, per RTD spec */
/* also, initialize shadow registers */
RtdResetBoard(dev);
- udelay(100); /* needed? */
+ udelay(100); /* needed? */
RtdPlxInterruptWrite(dev, 0);
RtdInterruptMask(dev, 0); /* and sets shadow */
RtdInterruptClearMask(dev, ~0); /* and sets shadow */
@@ -921,11 +951,11 @@ static int rtd_attach(struct comedi_device *dev, struct comedi_devconfig *it)
/* check if our interrupt is available and get it */
ret = request_irq(devpriv->pci_dev->irq, rtd_interrupt,
- IRQF_SHARED, DRV_NAME, dev);
+ IRQF_SHARED, DRV_NAME, dev);
if (ret < 0) {
printk("Could not get interrupt! (%u)\n",
- devpriv->pci_dev->irq);
+ devpriv->pci_dev->irq);
return ret;
}
dev->irq = devpriv->pci_dev->irq;
@@ -948,9 +978,11 @@ static int rtd_attach(struct comedi_device *dev, struct comedi_devconfig *it)
for (index = 0; index < DMA_CHAIN_COUNT; index++) {
devpriv->dma0Buff[index] =
- pci_alloc_consistent(devpriv->pci_dev,
- sizeof(u16) * devpriv->fifoLen / 2,
- &devpriv->dma0BuffPhysAddr[index]);
+ pci_alloc_consistent(devpriv->pci_dev,
+ sizeof(u16) *
+ devpriv->fifoLen / 2,
+ &devpriv->
+ dma0BuffPhysAddr[index]);
if (devpriv->dma0Buff[index] == NULL) {
ret = -ENOMEM;
goto rtd_attach_die_error;
@@ -962,21 +994,23 @@ static int rtd_attach(struct comedi_device *dev, struct comedi_devconfig *it)
/* setup DMA descriptor ring (use cpu_to_le32 for byte ordering?) */
devpriv->dma0Chain =
- pci_alloc_consistent(devpriv->pci_dev,
- sizeof(struct plx_dma_desc) * DMA_CHAIN_COUNT,
- &devpriv->dma0ChainPhysAddr);
+ pci_alloc_consistent(devpriv->pci_dev,
+ sizeof(struct plx_dma_desc) *
+ DMA_CHAIN_COUNT,
+ &devpriv->dma0ChainPhysAddr);
for (index = 0; index < DMA_CHAIN_COUNT; index++) {
devpriv->dma0Chain[index].pci_start_addr =
- devpriv->dma0BuffPhysAddr[index];
+ devpriv->dma0BuffPhysAddr[index];
devpriv->dma0Chain[index].local_start_addr =
- DMALADDR_ADC;
+ DMALADDR_ADC;
devpriv->dma0Chain[index].transfer_size =
- sizeof(u16) * devpriv->fifoLen / 2;
+ sizeof(u16) * devpriv->fifoLen / 2;
devpriv->dma0Chain[index].next =
- (devpriv->dma0ChainPhysAddr + ((index +
- 1) % (DMA_CHAIN_COUNT))
- * sizeof(devpriv->dma0Chain[0]))
- | DMA_TRANSFER_BITS;
+ (devpriv->dma0ChainPhysAddr + ((index +
+ 1) %
+ (DMA_CHAIN_COUNT))
+ * sizeof(devpriv->dma0Chain[0]))
+ | DMA_TRANSFER_BITS;
/*DPRINTK ("ring[%d] @%lx PCI: %x, local: %x, N: 0x%x, next: %x\n",
index,
((long)devpriv->dma0ChainPhysAddr
@@ -1014,17 +1048,18 @@ static int rtd_attach(struct comedi_device *dev, struct comedi_devconfig *it)
for (index = 0; index < DMA_CHAIN_COUNT; index++) {
if (NULL != devpriv->dma0Buff[index]) { /* free buffer memory */
pci_free_consistent(devpriv->pci_dev,
- sizeof(u16) * devpriv->fifoLen / 2,
- devpriv->dma0Buff[index],
- devpriv->dma0BuffPhysAddr[index]);
+ sizeof(u16) * devpriv->fifoLen / 2,
+ devpriv->dma0Buff[index],
+ devpriv->dma0BuffPhysAddr[index]);
devpriv->dma0Buff[index] = NULL;
}
}
if (NULL != devpriv->dma0Chain) {
pci_free_consistent(devpriv->pci_dev,
- sizeof(struct plx_dma_desc)
- * DMA_CHAIN_COUNT,
- devpriv->dma0Chain, devpriv->dma0ChainPhysAddr);
+ sizeof(struct plx_dma_desc)
+ * DMA_CHAIN_COUNT,
+ devpriv->dma0Chain,
+ devpriv->dma0ChainPhysAddr);
devpriv->dma0Chain = NULL;
}
#endif /* USE_DMA */
@@ -1032,7 +1067,7 @@ static int rtd_attach(struct comedi_device *dev, struct comedi_devconfig *it)
if (dev->irq) {
/* disable interrupt controller */
RtdPlxInterruptWrite(dev, RtdPlxInterruptRead(dev)
- & ~(ICS_PLIE | ICS_DMA0_E | ICS_DMA1_E));
+ & ~(ICS_PLIE | ICS_DMA0_E | ICS_DMA1_E));
free_irq(dev->irq, dev);
}
@@ -1070,7 +1105,11 @@ static int rtd_detach(struct comedi_device *dev)
DPRINTK("comedi%d: rtd520: removing (%ld ints)\n",
dev->minor, (devpriv ? devpriv->intCount : 0L));
if (devpriv && devpriv->lcfg) {
- DPRINTK("(int status 0x%x, overrun status 0x%x, fifo status 0x%x)...\n", 0xffff & RtdInterruptStatus(dev), 0xffff & RtdInterruptOverrunStatus(dev), (0xffff & RtdFifoStatus(dev)) ^ 0x6666);
+ DPRINTK
+ ("(int status 0x%x, overrun status 0x%x, fifo status 0x%x)...\n",
+ 0xffff & RtdInterruptStatus(dev),
+ 0xffff & RtdInterruptOverrunStatus(dev),
+ (0xffff & RtdFifoStatus(dev)) ^ 0x6666);
}
if (devpriv) {
@@ -1093,16 +1132,19 @@ static int rtd_detach(struct comedi_device *dev)
for (index = 0; index < DMA_CHAIN_COUNT; index++) {
if (NULL != devpriv->dma0Buff[index]) {
pci_free_consistent(devpriv->pci_dev,
- sizeof(u16) * devpriv->fifoLen / 2,
- devpriv->dma0Buff[index],
- devpriv->dma0BuffPhysAddr[index]);
+ sizeof(u16) *
+ devpriv->fifoLen / 2,
+ devpriv->dma0Buff[index],
+ devpriv->
+ dma0BuffPhysAddr[index]);
devpriv->dma0Buff[index] = NULL;
}
}
if (NULL != devpriv->dma0Chain) {
pci_free_consistent(devpriv->pci_dev,
- sizeof(struct plx_dma_desc) * DMA_CHAIN_COUNT,
- devpriv->dma0Chain, devpriv->dma0ChainPhysAddr);
+ sizeof(struct plx_dma_desc) *
+ DMA_CHAIN_COUNT, devpriv->dma0Chain,
+ devpriv->dma0ChainPhysAddr);
devpriv->dma0Chain = NULL;
}
#endif /* USE_DMA */
@@ -1111,7 +1153,8 @@ static int rtd_detach(struct comedi_device *dev)
if (dev->irq) {
/* disable interrupt controller */
RtdPlxInterruptWrite(dev, RtdPlxInterruptRead(dev)
- & ~(ICS_PLIE | ICS_DMA0_E | ICS_DMA1_E));
+ & ~(ICS_PLIE | ICS_DMA0_E |
+ ICS_DMA1_E));
free_irq(dev->irq, dev);
}
@@ -1142,7 +1185,7 @@ static int rtd_detach(struct comedi_device *dev)
Convert a single comedi channel-gain entry to a RTD520 table entry
*/
static unsigned short rtdConvertChanGain(struct comedi_device *dev,
- unsigned int comediChan, int chanIndex)
+ unsigned int comediChan, int chanIndex)
{ /* index in channel list */
unsigned int chan, range, aref;
unsigned short r = 0;
@@ -1192,7 +1235,7 @@ static unsigned short rtdConvertChanGain(struct comedi_device *dev,
Setup the channel-gain table from a comedi list
*/
static void rtd_load_channelgain_list(struct comedi_device *dev,
- unsigned int n_chan, unsigned int *list)
+ unsigned int n_chan, unsigned int *list)
{
if (n_chan > 1) { /* setup channel gain table */
int ii;
@@ -1200,7 +1243,7 @@ static void rtd_load_channelgain_list(struct comedi_device *dev,
RtdEnableCGT(dev, 1); /* enable table */
for (ii = 0; ii < n_chan; ii++) {
RtdWriteCGTable(dev, rtdConvertChanGain(dev, list[ii],
- ii));
+ ii));
}
} else { /* just use the channel gain latch */
RtdEnableCGT(dev, 0); /* disable table, enable latch */
@@ -1232,16 +1275,15 @@ static int rtd520_probe_fifo_depth(struct comedi_device *dev)
break;
}
}
- if (i == limit)
- {
+ if (i == limit) {
printk("\ncomedi: %s: failed to probe fifo size.\n", DRV_NAME);
return -EIO;
}
RtdAdcClearFifo(dev);
- if (fifo_size != 0x400 && fifo_size != 0x2000)
- {
- printk("\ncomedi: %s: unexpected fifo size of %i, expected 1024 or 8192.\n",
- DRV_NAME, fifo_size);
+ if (fifo_size != 0x400 && fifo_size != 0x2000) {
+ printk
+ ("\ncomedi: %s: unexpected fifo size of %i, expected 1024 or 8192.\n",
+ DRV_NAME, fifo_size);
return -EIO;
}
return fifo_size;
@@ -1256,7 +1298,8 @@ static int rtd520_probe_fifo_depth(struct comedi_device *dev)
select, delay, then read.
*/
static int rtd_ai_rinsn(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)
{
int n, ii;
int stat;
@@ -1283,7 +1326,9 @@ static int rtd_ai_rinsn(struct comedi_device *dev,
WAIT_QUIETLY;
}
if (ii >= RTD_ADC_TIMEOUT) {
- DPRINTK("rtd520: Error: ADC never finished! FifoStatus=0x%x\n", stat ^ 0x6666);
+ DPRINTK
+ ("rtd520: Error: ADC never finished! FifoStatus=0x%x\n",
+ stat ^ 0x6666);
return -ETIMEDOUT;
}
@@ -1308,7 +1353,8 @@ static int rtd_ai_rinsn(struct comedi_device *dev,
The manual claims that we can do a lword read, but it doesn't work here.
*/
-static int ai_read_n(struct comedi_device *dev, struct comedi_subdevice *s, int count)
+static int ai_read_n(struct comedi_device *dev, struct comedi_subdevice *s,
+ int count)
{
int ii;
@@ -1384,7 +1430,7 @@ void abort_dma(struct comedi_device *dev, unsigned int channel)
/* unsigned long flags; */
dma_cs_addr = (unsigned long)devpriv->lcfg
- + ((channel == 0) ? LCFG_DMACSR0 : LCFG_DMACSR1);
+ + ((channel == 0) ? LCFG_DMACSR0 : LCFG_DMACSR1);
/* spinlock for plx dma control/status reg */
/* spin_lock_irqsave( &dev->spinlock, flags ); */
@@ -1404,30 +1450,29 @@ void abort_dma(struct comedi_device *dev, unsigned int channel)
}
if (status & PLX_DMA_DONE_BIT) {
printk("rtd520: Timeout waiting for dma %i done clear\n",
- channel);
+ channel);
goto abortDmaExit;
}
/* disable channel (required) */
writeb(0, dma_cs_addr);
- udelay(1); /* needed?? */
+ udelay(1); /* needed?? */
/* set abort bit for channel */
writeb(PLX_DMA_ABORT_BIT, dma_cs_addr);
/* wait for dma done bit to be set */
status = readb(dma_cs_addr);
for (ii = 0;
- (status & PLX_DMA_DONE_BIT) == 0 && ii < RTD_DMA_TIMEOUT;
- ii++) {
+ (status & PLX_DMA_DONE_BIT) == 0 && ii < RTD_DMA_TIMEOUT; ii++) {
status = readb(dma_cs_addr);
WAIT_QUIETLY;
}
if ((status & PLX_DMA_DONE_BIT) == 0) {
printk("rtd520: Timeout waiting for dma %i done set\n",
- channel);
+ channel);
}
- abortDmaExit:
+abortDmaExit:
/* spin_unlock_irqrestore( &dev->spinlock, flags ); */
}
@@ -1495,8 +1540,8 @@ 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 */
-{ /* cpu context (ignored) */
+ void *d)
+{ /* our data *//* cpu context (ignored) */
struct comedi_device *dev = d; /* must be called "dev" for devpriv */
u16 status;
u16 fifoStatus;
@@ -1520,20 +1565,22 @@ static irqreturn_t rtd_interrupt(int irq, /* interrupt number (ignored) */
if (istatus & ICS_DMA0_A) {
if (ai_process_dma(dev, s) < 0) {
- DPRINTK("rtd520: comedi read buffer overflow (DMA) with %ld to go!\n", devpriv->aiCount);
+ DPRINTK
+ ("rtd520: comedi read buffer overflow (DMA) with %ld to go!\n",
+ devpriv->aiCount);
RtdDma0Control(dev,
- (devpriv->
- dma0Control &
+ (devpriv->dma0Control &
~PLX_DMA_START_BIT)
- | PLX_CLEAR_DMA_INTR_BIT);
+ | PLX_CLEAR_DMA_INTR_BIT);
goto abortTransfer;
}
/*DPRINTK ("rtd520: DMA transfer: %ld to go, istatus %x\n",
devpriv->aiCount, istatus); */
RtdDma0Control(dev,
- (devpriv->dma0Control & ~PLX_DMA_START_BIT)
- | PLX_CLEAR_DMA_INTR_BIT);
+ (devpriv->
+ dma0Control & ~PLX_DMA_START_BIT)
+ | PLX_CLEAR_DMA_INTR_BIT);
if (0 == devpriv->aiCount) { /* counted down */
DPRINTK("rtd520: Samples Done (DMA).\n");
goto transferDone;
@@ -1560,7 +1607,9 @@ static irqreturn_t rtd_interrupt(int irq, /* interrupt number (ignored) */
/*DPRINTK("rtd520: Sample int, reading 1/2FIFO. fifo_status 0x%x\n",
(fifoStatus ^ 0x6666) & 0x7777); */
if (ai_read_n(dev, s, devpriv->fifoLen / 2) < 0) {
- DPRINTK("rtd520: comedi read buffer overflow (1/2FIFO) with %ld to go!\n", devpriv->aiCount);
+ DPRINTK
+ ("rtd520: comedi read buffer overflow (1/2FIFO) with %ld to go!\n",
+ devpriv->aiCount);
goto abortTransfer;
}
if (0 == devpriv->aiCount) { /* counted down */
@@ -1573,24 +1622,32 @@ static irqreturn_t rtd_interrupt(int irq, /* interrupt number (ignored) */
devpriv->transCount, (fifoStatus ^ 0x6666) & 0x7777); */
if (fifoStatus & FS_ADC_NOT_EMPTY) { /* 1 -> not empty */
if (ai_read_n(dev, s, devpriv->transCount) < 0) {
- DPRINTK("rtd520: comedi read buffer overflow (N) with %ld to go!\n", devpriv->aiCount);
+ DPRINTK
+ ("rtd520: comedi read buffer overflow (N) with %ld to go!\n",
+ devpriv->aiCount);
goto abortTransfer;
}
if (0 == devpriv->aiCount) { /* counted down */
- DPRINTK("rtd520: Samples Done (N). fifo_status was 0x%x\n", (fifoStatus ^ 0x6666) & 0x7777);
+ DPRINTK
+ ("rtd520: Samples Done (N). fifo_status was 0x%x\n",
+ (fifoStatus ^ 0x6666) & 0x7777);
goto transferDone;
}
comedi_event(dev, s);
}
} else { /* wait for 1/2 FIFO (old) */
- DPRINTK("rtd520: Sample int. Wait for 1/2. fifo_status 0x%x\n", (fifoStatus ^ 0x6666) & 0x7777);
+ DPRINTK
+ ("rtd520: Sample int. Wait for 1/2. fifo_status 0x%x\n",
+ (fifoStatus ^ 0x6666) & 0x7777);
}
} else {
DPRINTK("rtd520: unknown interrupt source!\n");
}
if (0xffff & RtdInterruptOverrunStatus(dev)) { /* interrupt overrun */
- DPRINTK("rtd520: Interrupt overrun with %ld to go! over_status=0x%x\n", devpriv->aiCount, 0xffff & RtdInterruptOverrunStatus(dev));
+ DPRINTK
+ ("rtd520: Interrupt overrun with %ld to go! over_status=0x%x\n",
+ devpriv->aiCount, 0xffff & RtdInterruptOverrunStatus(dev));
goto abortTransfer;
}
@@ -1599,13 +1656,13 @@ static irqreturn_t rtd_interrupt(int irq, /* interrupt number (ignored) */
RtdInterruptClear(dev);
return IRQ_HANDLED;
- abortTransfer:
+abortTransfer:
RtdAdcClearFifo(dev); /* clears full flag */
s->async->events |= COMEDI_CB_ERROR;
devpriv->aiCount = 0; /* stop and don't transfer any more */
/* fall into transferDone */
- transferDone:
+transferDone:
RtdPacerStopSource(dev, 0); /* stop on SOFTWARE stop */
RtdPacerStop(dev); /* Stop PACER */
RtdAdcConversionSource(dev, 0); /* software trigger only */
@@ -1613,7 +1670,7 @@ static irqreturn_t rtd_interrupt(int irq, /* interrupt number (ignored) */
#ifdef USE_DMA
if (devpriv->flags & DMA0_ACTIVE) {
RtdPlxInterruptWrite(dev, /* disable any more interrupts */
- RtdPlxInterruptRead(dev) & ~ICS_DMA0_E);
+ RtdPlxInterruptRead(dev) & ~ICS_DMA0_E);
abort_dma(dev, 0);
devpriv->flags &= ~DMA0_ACTIVE;
/* if Using DMA, then we should have read everything by now */
@@ -1639,7 +1696,10 @@ static irqreturn_t rtd_interrupt(int irq, /* interrupt number (ignored) */
RtdInterruptClear(dev);
fifoStatus = RtdFifoStatus(dev); /* DEBUG */
- DPRINTK("rtd520: Acquisition complete. %ld ints, intStat=%x, overStat=%x\n", devpriv->intCount, status, 0xffff & RtdInterruptOverrunStatus(dev));
+ DPRINTK
+ ("rtd520: Acquisition complete. %ld ints, intStat=%x, overStat=%x\n",
+ devpriv->intCount, status,
+ 0xffff & RtdInterruptOverrunStatus(dev));
return IRQ_HANDLED;
}
@@ -1666,7 +1726,7 @@ static int rtd_ai_poll(struct comedi_device *dev, struct comedi_subdevice *s)
*/
static int rtd_ai_cmdtest(struct comedi_device *dev,
- struct comedi_subdevice *s, struct comedi_cmd *cmd)
+ struct comedi_subdevice *s, struct comedi_cmd *cmd)
{
int err = 0;
int tmp;
@@ -1710,7 +1770,7 @@ static int rtd_ai_cmdtest(struct comedi_device *dev,
and mutually compatible */
/* note that mutual compatiblity is not an issue here */
if (cmd->scan_begin_src != TRIG_TIMER &&
- cmd->scan_begin_src != TRIG_EXT) {
+ cmd->scan_begin_src != TRIG_EXT) {
err++;
}
if (cmd->convert_src != TRIG_TIMER && cmd->convert_src != TRIG_EXT) {
@@ -1737,26 +1797,26 @@ static int rtd_ai_cmdtest(struct comedi_device *dev,
if (cmd->scan_begin_arg < RTD_MAX_SPEED_1) {
cmd->scan_begin_arg = RTD_MAX_SPEED_1;
rtd_ns_to_timer(&cmd->scan_begin_arg,
- TRIG_ROUND_UP);
+ TRIG_ROUND_UP);
err++;
}
if (cmd->scan_begin_arg > RTD_MIN_SPEED_1) {
cmd->scan_begin_arg = RTD_MIN_SPEED_1;
rtd_ns_to_timer(&cmd->scan_begin_arg,
- TRIG_ROUND_DOWN);
+ TRIG_ROUND_DOWN);
err++;
}
} else {
if (cmd->scan_begin_arg < RTD_MAX_SPEED) {
cmd->scan_begin_arg = RTD_MAX_SPEED;
rtd_ns_to_timer(&cmd->scan_begin_arg,
- TRIG_ROUND_UP);
+ TRIG_ROUND_UP);
err++;
}
if (cmd->scan_begin_arg > RTD_MIN_SPEED) {
cmd->scan_begin_arg = RTD_MIN_SPEED;
rtd_ns_to_timer(&cmd->scan_begin_arg,
- TRIG_ROUND_DOWN);
+ TRIG_ROUND_DOWN);
err++;
}
}
@@ -1774,26 +1834,26 @@ static int rtd_ai_cmdtest(struct comedi_device *dev,
if (cmd->convert_arg < RTD_MAX_SPEED_1) {
cmd->convert_arg = RTD_MAX_SPEED_1;
rtd_ns_to_timer(&cmd->convert_arg,
- TRIG_ROUND_UP);
+ TRIG_ROUND_UP);
err++;
}
if (cmd->convert_arg > RTD_MIN_SPEED_1) {
cmd->convert_arg = RTD_MIN_SPEED_1;
rtd_ns_to_timer(&cmd->convert_arg,
- TRIG_ROUND_DOWN);
+ TRIG_ROUND_DOWN);
err++;
}
} else {
if (cmd->convert_arg < RTD_MAX_SPEED) {
cmd->convert_arg = RTD_MAX_SPEED;
rtd_ns_to_timer(&cmd->convert_arg,
- TRIG_ROUND_UP);
+ TRIG_ROUND_UP);
err++;
}
if (cmd->convert_arg > RTD_MIN_SPEED) {
cmd->convert_arg = RTD_MIN_SPEED;
rtd_ns_to_timer(&cmd->convert_arg,
- TRIG_ROUND_DOWN);
+ TRIG_ROUND_DOWN);
err++;
}
}
@@ -1836,7 +1896,7 @@ static int rtd_ai_cmdtest(struct comedi_device *dev,
if (cmd->scan_begin_src == TRIG_TIMER) {
tmp = cmd->scan_begin_arg;
rtd_ns_to_timer(&cmd->scan_begin_arg,
- cmd->flags & TRIG_ROUND_MASK);
+ cmd->flags & TRIG_ROUND_MASK);
if (tmp != cmd->scan_begin_arg) {
err++;
}
@@ -1844,15 +1904,15 @@ static int rtd_ai_cmdtest(struct comedi_device *dev,
if (cmd->convert_src == TRIG_TIMER) {
tmp = cmd->convert_arg;
rtd_ns_to_timer(&cmd->convert_arg,
- cmd->flags & TRIG_ROUND_MASK);
+ cmd->flags & TRIG_ROUND_MASK);
if (tmp != cmd->convert_arg) {
err++;
}
if (cmd->scan_begin_src == TRIG_TIMER
- && (cmd->scan_begin_arg
- < (cmd->convert_arg * cmd->scan_end_arg))) {
+ && (cmd->scan_begin_arg
+ < (cmd->convert_arg * cmd->scan_end_arg))) {
cmd->scan_begin_arg =
- cmd->convert_arg * cmd->scan_end_arg;
+ cmd->convert_arg * cmd->scan_end_arg;
err++;
}
}
@@ -1883,7 +1943,7 @@ static int rtd_ai_cmd(struct comedi_device *dev, struct comedi_subdevice *s)
#ifdef USE_DMA
if (devpriv->flags & DMA0_ACTIVE) { /* cancel anything running */
RtdPlxInterruptWrite(dev, /* disable any more interrupts */
- RtdPlxInterruptRead(dev) & ~ICS_DMA0_E);
+ RtdPlxInterruptRead(dev) & ~ICS_DMA0_E);
abort_dma(dev, 0);
devpriv->flags &= ~DMA0_ACTIVE;
if (RtdPlxInterruptRead(dev) & ICS_DMA0_A) { /*clear pending int */
@@ -1929,17 +1989,17 @@ static int rtd_ai_cmd(struct comedi_device *dev, struct comedi_subdevice *s)
} else {
/* arrange to transfer data periodically */
devpriv->transCount
- =
- (TRANS_TARGET_PERIOD * cmd->chanlist_len) /
- cmd->scan_begin_arg;
+ =
+ (TRANS_TARGET_PERIOD * cmd->chanlist_len) /
+ cmd->scan_begin_arg;
if (devpriv->transCount < cmd->chanlist_len) {
/* tranfer after each scan (and avoid 0) */
devpriv->transCount = cmd->chanlist_len;
} else { /* make a multiple of scan length */
devpriv->transCount =
- (devpriv->transCount +
- cmd->chanlist_len - 1)
- / cmd->chanlist_len;
+ (devpriv->transCount +
+ cmd->chanlist_len - 1)
+ / cmd->chanlist_len;
devpriv->transCount *= cmd->chanlist_len;
}
devpriv->flags |= SEND_EOS;
@@ -1953,7 +2013,10 @@ static int rtd_ai_cmd(struct comedi_device *dev, struct comedi_subdevice *s)
RtdAboutCounter(dev, devpriv->transCount - 1);
}
- DPRINTK("rtd520: scanLen=%d tranferCount=%d fifoLen=%d\n scanTime(ns)=%d flags=0x%x\n", cmd->chanlist_len, devpriv->transCount, devpriv->fifoLen, cmd->scan_begin_arg, devpriv->flags);
+ DPRINTK
+ ("rtd520: scanLen=%d tranferCount=%d fifoLen=%d\n scanTime(ns)=%d flags=0x%x\n",
+ cmd->chanlist_len, devpriv->transCount, devpriv->fifoLen,
+ cmd->scan_begin_arg, devpriv->flags);
} else { /* unknown timing, just use 1/2 FIFO */
devpriv->transCount = 0;
devpriv->flags &= ~SEND_EOS;
@@ -1968,7 +2031,7 @@ static int rtd_ai_cmd(struct comedi_device *dev, struct comedi_subdevice *s)
case TRIG_COUNT: /* stop after N scans */
devpriv->aiCount = cmd->stop_arg * cmd->chanlist_len;
if ((devpriv->transCount > 0)
- && (devpriv->transCount > devpriv->aiCount)) {
+ && (devpriv->transCount > devpriv->aiCount)) {
devpriv->transCount = devpriv->aiCount;
}
break;
@@ -1986,7 +2049,7 @@ static int rtd_ai_cmd(struct comedi_device *dev, struct comedi_subdevice *s)
switch (cmd->scan_begin_src) {
case TRIG_TIMER: /* periodic scanning */
timer = rtd_ns_to_timer(&cmd->scan_begin_arg,
- TRIG_ROUND_NEAREST);
+ TRIG_ROUND_NEAREST);
/* set PACER clock */
/*DPRINTK ("rtd520: loading %d into pacer\n", timer); */
RtdPacerCounter(dev, timer);
@@ -2007,7 +2070,7 @@ static int rtd_ai_cmd(struct comedi_device *dev, struct comedi_subdevice *s)
case TRIG_TIMER: /* periodic */
if (cmd->chanlist_len > 1) { /* only needed for multi-channel */
timer = rtd_ns_to_timer(&cmd->convert_arg,
- TRIG_ROUND_NEAREST);
+ TRIG_ROUND_NEAREST);
/* setup BURST clock */
/*DPRINTK ("rtd520: loading %d into burst\n", timer); */
RtdBurstCounter(dev, timer);
@@ -2042,11 +2105,11 @@ static int rtd_ai_cmd(struct comedi_device *dev, struct comedi_subdevice *s)
devpriv->dma0Offset = 0;
RtdDma0Mode(dev, DMA_MODE_BITS);
RtdDma0Next(dev, /* point to first block */
- devpriv->dma0Chain[DMA_CHAIN_COUNT - 1].next);
+ devpriv->dma0Chain[DMA_CHAIN_COUNT - 1].next);
RtdDma0Source(dev, DMAS_ADFIFO_HALF_FULL); /* set DMA trigger source */
RtdPlxInterruptWrite(dev, /* enable interrupt */
- RtdPlxInterruptRead(dev) | ICS_DMA0_E);
+ RtdPlxInterruptRead(dev) | ICS_DMA0_E);
/* Must be 2 steps. See PLX app note about "Starting a DMA transfer" */
RtdDma0Control(dev, PLX_DMA_EN_BIT); /* enable DMA (clear INTR?) */
RtdDma0Control(dev, PLX_DMA_EN_BIT | PLX_DMA_START_BIT); /*start DMA */
@@ -2079,13 +2142,16 @@ static int rtd_ai_cancel(struct comedi_device *dev, struct comedi_subdevice *s)
#ifdef USE_DMA
if (devpriv->flags & DMA0_ACTIVE) {
RtdPlxInterruptWrite(dev, /* disable any more interrupts */
- RtdPlxInterruptRead(dev) & ~ICS_DMA0_E);
+ RtdPlxInterruptRead(dev) & ~ICS_DMA0_E);
abort_dma(dev, 0);
devpriv->flags &= ~DMA0_ACTIVE;
}
#endif /* USE_DMA */
status = RtdInterruptStatus(dev);
- DPRINTK("rtd520: Acquisition canceled. %ld ints, intStat=%x, overStat=%x\n", devpriv->intCount, status, 0xffff & RtdInterruptOverrunStatus(dev));
+ DPRINTK
+ ("rtd520: Acquisition canceled. %ld ints, intStat=%x, overStat=%x\n",
+ devpriv->intCount, status,
+ 0xffff & RtdInterruptOverrunStatus(dev));
return 0;
}
@@ -2096,7 +2162,7 @@ static int rtd_ai_cancel(struct comedi_device *dev, struct comedi_subdevice *s)
Note: you have to check if the value is larger than the counter range!
*/
static int rtd_ns_to_timer_base(unsigned int *nanosec, /* desired period (in ns) */
- int round_mode, int base)
+ int round_mode, int base)
{ /* clock period (in ns) */
int divider;
@@ -2136,7 +2202,8 @@ static int rtd_ns_to_timer(unsigned int *ns, int round_mode)
Output one (or more) analog values to a single port as fast as possible.
*/
static int rtd_ao_winsn(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)
{
int i;
int chan = CR_CHAN(insn->chanspec);
@@ -2155,14 +2222,16 @@ static int rtd_ao_winsn(struct comedi_device *dev,
/* VERIFY: comedi range and offset conversions */
if ((range > 1) /* bipolar */
- && (data[i] < 2048)) {
+ &&(data[i] < 2048)) {
/* offset and sign extend */
val = (((int)data[i]) - 2048) << 3;
} else { /* unipolor */
val = data[i] << 3;
}
- DPRINTK("comedi: rtd520 DAC chan=%d range=%d writing %d as 0x%x\n", chan, range, data[i], val);
+ DPRINTK
+ ("comedi: rtd520 DAC chan=%d range=%d writing %d as 0x%x\n",
+ chan, range, data[i], val);
/* a typical programming sequence */
RtdDacFifoPut(dev, chan, val); /* put the value in */
@@ -2174,12 +2243,14 @@ static int rtd_ao_winsn(struct comedi_device *dev,
stat = RtdFifoStatus(dev);
/* 1 -> not empty */
if (stat & ((0 == chan) ? FS_DAC1_NOT_EMPTY :
- FS_DAC2_NOT_EMPTY))
+ FS_DAC2_NOT_EMPTY))
break;
WAIT_QUIETLY;
}
if (ii >= RTD_DAC_TIMEOUT) {
- DPRINTK("rtd520: Error: DAC never finished! FifoStatus=0x%x\n", stat ^ 0x6666);
+ DPRINTK
+ ("rtd520: Error: DAC never finished! FifoStatus=0x%x\n",
+ stat ^ 0x6666);
return -ETIMEDOUT;
}
}
@@ -2191,7 +2262,8 @@ static int rtd_ao_winsn(struct comedi_device *dev,
/* AO subdevices should have a read insn as well as a write insn.
* Usually this means copying a value stored in devpriv. */
static int rtd_ao_rinsn(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)
{
int i;
int chan = CR_CHAN(insn->chanspec);
@@ -2214,7 +2286,8 @@ static int rtd_ao_rinsn(struct comedi_device *dev,
* comedi core can convert between insn_bits and insn_read/write
*/
static int rtd_dio_insn_bits(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)
{
if (insn->n != 2)
return -EINVAL;
@@ -2241,7 +2314,8 @@ static int rtd_dio_insn_bits(struct comedi_device *dev,
Configure one bit on a IO port as Input or Output (hence the name :-).
*/
static int rtd_dio_insn_config(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)
{
int chan = CR_CHAN(insn->chanspec);
@@ -2258,8 +2332,7 @@ static int rtd_dio_insn_config(struct comedi_device *dev,
break;
case INSN_CONFIG_DIO_QUERY:
data[1] =
- (s->
- io_bits & (1 << chan)) ? COMEDI_OUTPUT : COMEDI_INPUT;
+ (s->io_bits & (1 << chan)) ? COMEDI_OUTPUT : COMEDI_INPUT;
return insn->n;
break;
default:
diff --git a/drivers/staging/comedi/drivers/rti800.c b/drivers/staging/comedi/drivers/rti800.c
index f1b7e0252f13..2c9d05bd288c 100644
--- a/drivers/staging/comedi/drivers/rti800.c
+++ b/drivers/staging/comedi/drivers/rti800.c
@@ -98,25 +98,38 @@ Configuration options:
#include "am9513.h"
static const struct comedi_lrange range_rti800_ai_10_bipolar = { 4, {
- BIP_RANGE(10),
- BIP_RANGE(1),
- BIP_RANGE(0.1),
- BIP_RANGE(0.02)
- }
+ BIP_RANGE
+ (10),
+ BIP_RANGE
+ (1),
+ BIP_RANGE
+ (0.1),
+ BIP_RANGE
+ (0.02)
+ }
};
+
static const struct comedi_lrange range_rti800_ai_5_bipolar = { 4, {
- BIP_RANGE(5),
- BIP_RANGE(0.5),
- BIP_RANGE(0.05),
- BIP_RANGE(0.01)
- }
+ BIP_RANGE
+ (5),
+ BIP_RANGE
+ (0.5),
+ BIP_RANGE
+ (0.05),
+ BIP_RANGE
+ (0.01)
+ }
};
+
static const struct comedi_lrange range_rti800_ai_unipolar = { 4, {
- UNI_RANGE(10),
- UNI_RANGE(1),
- UNI_RANGE(0.1),
- UNI_RANGE(0.02)
- }
+ UNI_RANGE
+ (10),
+ UNI_RANGE(1),
+ UNI_RANGE
+ (0.1),
+ UNI_RANGE
+ (0.02)
+ }
};
struct rti800_board {
@@ -132,7 +145,8 @@ 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_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",
@@ -181,8 +195,9 @@ static irqreturn_t rti800_interrupt(int irq, void *dev)
/* 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;
@@ -233,8 +248,9 @@ static int rti800_ai_insn_read(struct comedi_device *dev, struct comedi_subdevic
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 +261,9 @@ static int rti800_ao_insn_read(struct comedi_device *dev, struct comedi_subdevic
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;
@@ -258,15 +275,16 @@ static int rti800_ao_insn_write(struct comedi_device *dev, struct comedi_subdevi
d ^= 0x800;
}
outb(d & 0xff,
- dev->iobase + (chan ? RTI800_DAC1LO : RTI800_DAC0LO));
+ dev->iobase + (chan ? RTI800_DAC1LO : RTI800_DAC0LO));
outb(d >> 8,
- dev->iobase + (chan ? RTI800_DAC1HI : RTI800_DAC0HI));
+ dev->iobase + (chan ? RTI800_DAC1HI : RTI800_DAC0HI));
}
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 +292,9 @@ static int rti800_di_insn_bits(struct comedi_device *dev, struct comedi_subdevic
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;
@@ -326,10 +345,10 @@ static int rti800_attach(struct comedi_device *dev, struct comedi_devconfig *it)
#ifdef DEBUG
printk("fingerprint=%x,%x,%x,%x,%x ",
- inb(dev->iobase + 0),
- inb(dev->iobase + 1),
- inb(dev->iobase + 2),
- inb(dev->iobase + 3), inb(dev->iobase + 4));
+ inb(dev->iobase + 0),
+ inb(dev->iobase + 1),
+ inb(dev->iobase + 2),
+ inb(dev->iobase + 3), inb(dev->iobase + 4));
#endif
outb(0, dev->iobase + RTI800_CSR);
diff --git a/drivers/staging/comedi/drivers/rti802.c b/drivers/staging/comedi/drivers/rti802.c
index fffde45a352b..2f75c737ea15 100644
--- a/drivers/staging/comedi/drivers/rti802.c
+++ b/drivers/staging/comedi/drivers/rti802.c
@@ -47,7 +47,8 @@ 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_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",
@@ -68,8 +69,9 @@ 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 +81,9 @@ static int rti802_ao_insn_read(struct comedi_device *dev, struct comedi_subdevic
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);
@@ -113,7 +116,7 @@ static int rti802_attach(struct comedi_device *dev, struct comedi_devconfig *it)
dev->board_name = "rti802";
if (alloc_subdevices(dev, 1) < 0
- || alloc_private(dev, sizeof(struct rti802_private))) {
+ || alloc_private(dev, sizeof(struct rti802_private))) {
return -ENOMEM;
}
@@ -129,10 +132,10 @@ static int rti802_attach(struct comedi_device *dev, struct comedi_devconfig *it)
for (i = 0; i < 8; i++) {
devpriv->dac_coding[i] = (it->options[3 + 2 * i])
- ? (dac_straight)
- : (dac_2comp);
+ ? (dac_straight)
+ : (dac_2comp);
devpriv->range_type_list[i] = (it->options[2 + 2 * i])
- ? &range_unipolar10 : &range_bipolar10;
+ ? &range_unipolar10 : &range_bipolar10;
}
printk("\n");
diff --git a/drivers/staging/comedi/drivers/s526.c b/drivers/staging/comedi/drivers/s526.c
index d9509d7a3283..b89e1ec267c5 100644
--- a/drivers/staging/comedi/drivers/s526.c
+++ b/drivers/staging/comedi/drivers/s526.c
@@ -169,15 +169,15 @@ 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,
+ }
};
#define ADDR_REG(reg) (dev->iobase + (reg))
@@ -247,24 +247,30 @@ static struct comedi_driver driver_s526 = {
.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_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);
+ 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);
+ 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);
+ 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
@@ -424,7 +430,7 @@ static int s526_attach(struct comedi_device *dev, struct comedi_devconfig *it)
n = 0;
printk("Mode reg=0x%04x, 0x%04lx\n", cmReg.value, ADDR_CHAN_REG(REG_C0M,
- n));
+ n));
outw(cmReg.value, ADDR_CHAN_REG(REG_C0M, n));
udelay(1000);
printk("Read back mode reg=0x%04x\n", inw(ADDR_CHAN_REG(REG_C0M, n)));
@@ -455,7 +461,7 @@ static int s526_attach(struct comedi_device *dev, struct comedi_devconfig *it)
for (i = 0; i < S526_NUM_PORTS; i++) {
printk("0x%02lx: 0x%04x\n", ADDR_REG(s526_ports[i]),
- inw(ADDR_REG(s526_ports[i])));
+ inw(ADDR_REG(s526_ports[i])));
}
return 1;
}
@@ -478,8 +484,9 @@ 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 counter_channel = CR_CHAN(insn->chanspec);
@@ -502,8 +509,9 @@ static int s526_gpct_rinsn(struct comedi_device *dev, struct comedi_subdevice *s
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 i;
@@ -513,7 +521,7 @@ static int s526_gpct_insn_config(struct comedi_device *dev, struct comedi_subdev
for (i = 0; i < MAX_GPCT_CONFIG_DATA; i++) {
devpriv->s526_gpct_config[subdev_channel].data[i] =
- insn->data[i];
+ insn->data[i];
/* printk("data[%d]=%x\n", i, insn->data[i]); */
}
@@ -529,32 +537,32 @@ static int s526_gpct_insn_config(struct comedi_device *dev, struct comedi_subdev
*/
printk("s526: GPCT_INSN_CONFIG: Configuring Encoder\n");
devpriv->s526_gpct_config[subdev_channel].app =
- PositionMeasurement;
+ PositionMeasurement;
#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));
-
- outw(0x0001, ADDR_CHAN_REG(REG_C0H, subdev_channel));
- outw(0x3C68, ADDR_CHAN_REG(REG_C0L, subdev_channel));
+ /* 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(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(cmReg.value, ADDR_CHAN_REG(REG_C0M, subdev_channel));
+
+ 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(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
@@ -604,20 +612,20 @@ static int s526_gpct_insn_config(struct comedi_device *dev, struct comedi_subdev
cmReg.reg.autoLoadResetRcap = 4; /* Auto load with INDEX^ */
/* Set Counter Mode Register */
- cmReg.value = (short) (insn->data[1] & 0xFFFF);
+ cmReg.value = (short)(insn->data[1] & 0xFFFF);
outw(cmReg.value, ADDR_CHAN_REG(REG_C0M, subdev_channel));
/* Load the pre-laod register high word */
- value = (short) ((insn->data[2] >> 16) & 0xFFFF);
+ value = (short)((insn->data[2] >> 16) & 0xFFFF);
outw(value, ADDR_CHAN_REG(REG_C0H, subdev_channel));
/* Load the pre-laod register low word */
- value = (short) (insn->data[2] & 0xFFFF);
+ value = (short)(insn->data[2] & 0xFFFF);
outw(value, ADDR_CHAN_REG(REG_C0L, subdev_channel));
/* Write the Counter Control Register */
if (insn->data[3] != 0) {
- value = (short) (insn->data[3] & 0xFFFF);
+ value = (short)(insn->data[3] & 0xFFFF);
outw(value, ADDR_CHAN_REG(REG_C0C, subdev_channel));
}
/* Reset the counter if it is software preload */
@@ -638,37 +646,37 @@ static int s526_gpct_insn_config(struct comedi_device *dev, struct comedi_subdev
*/
printk("s526: GPCT_INSN_CONFIG: Configuring SPG\n");
devpriv->s526_gpct_config[subdev_channel].app =
- SinglePulseGeneration;
+ SinglePulseGeneration;
/* Set Counter Mode Register */
- cmReg.value = (short) (insn->data[1] & 0xFFFF);
+ cmReg.value = (short)(insn->data[1] & 0xFFFF);
cmReg.reg.preloadRegSel = 0; /* PR0 */
outw(cmReg.value, ADDR_CHAN_REG(REG_C0M, subdev_channel));
/* Load the pre-laod register 0 high word */
- value = (short) ((insn->data[2] >> 16) & 0xFFFF);
+ value = (short)((insn->data[2] >> 16) & 0xFFFF);
outw(value, ADDR_CHAN_REG(REG_C0H, subdev_channel));
/* Load the pre-laod register 0 low word */
- value = (short) (insn->data[2] & 0xFFFF);
+ value = (short)(insn->data[2] & 0xFFFF);
outw(value, ADDR_CHAN_REG(REG_C0L, subdev_channel));
/* Set Counter Mode Register */
- cmReg.value = (short) (insn->data[1] & 0xFFFF);
+ cmReg.value = (short)(insn->data[1] & 0xFFFF);
cmReg.reg.preloadRegSel = 1; /* PR1 */
outw(cmReg.value, ADDR_CHAN_REG(REG_C0M, subdev_channel));
/* Load the pre-laod register 1 high word */
- value = (short) ((insn->data[3] >> 16) & 0xFFFF);
+ value = (short)((insn->data[3] >> 16) & 0xFFFF);
outw(value, ADDR_CHAN_REG(REG_C0H, subdev_channel));
/* Load the pre-laod register 1 low word */
- value = (short) (insn->data[3] & 0xFFFF);
+ value = (short)(insn->data[3] & 0xFFFF);
outw(value, ADDR_CHAN_REG(REG_C0L, subdev_channel));
/* Write the Counter Control Register */
if (insn->data[3] != 0) {
- value = (short) (insn->data[3] & 0xFFFF);
+ value = (short)(insn->data[3] & 0xFFFF);
outw(value, ADDR_CHAN_REG(REG_C0C, subdev_channel));
}
break;
@@ -683,37 +691,37 @@ static int s526_gpct_insn_config(struct comedi_device *dev, struct comedi_subdev
*/
printk("s526: GPCT_INSN_CONFIG: Configuring PTG\n");
devpriv->s526_gpct_config[subdev_channel].app =
- PulseTrainGeneration;
+ PulseTrainGeneration;
/* Set Counter Mode Register */
- cmReg.value = (short) (insn->data[1] & 0xFFFF);
+ cmReg.value = (short)(insn->data[1] & 0xFFFF);
cmReg.reg.preloadRegSel = 0; /* PR0 */
outw(cmReg.value, ADDR_CHAN_REG(REG_C0M, subdev_channel));
/* Load the pre-laod register 0 high word */
- value = (short) ((insn->data[2] >> 16) & 0xFFFF);
+ value = (short)((insn->data[2] >> 16) & 0xFFFF);
outw(value, ADDR_CHAN_REG(REG_C0H, subdev_channel));
/* Load the pre-laod register 0 low word */
- value = (short) (insn->data[2] & 0xFFFF);
+ value = (short)(insn->data[2] & 0xFFFF);
outw(value, ADDR_CHAN_REG(REG_C0L, subdev_channel));
/* Set Counter Mode Register */
- cmReg.value = (short) (insn->data[1] & 0xFFFF);
+ cmReg.value = (short)(insn->data[1] & 0xFFFF);
cmReg.reg.preloadRegSel = 1; /* PR1 */
outw(cmReg.value, ADDR_CHAN_REG(REG_C0M, subdev_channel));
/* Load the pre-laod register 1 high word */
- value = (short) ((insn->data[3] >> 16) & 0xFFFF);
+ value = (short)((insn->data[3] >> 16) & 0xFFFF);
outw(value, ADDR_CHAN_REG(REG_C0H, subdev_channel));
/* Load the pre-laod register 1 low word */
- value = (short) (insn->data[3] & 0xFFFF);
+ value = (short)(insn->data[3] & 0xFFFF);
outw(value, ADDR_CHAN_REG(REG_C0L, subdev_channel));
/* Write the Counter Control Register */
if (insn->data[3] != 0) {
- value = (short) (insn->data[3] & 0xFFFF);
+ value = (short)(insn->data[3] & 0xFFFF);
outw(value, ADDR_CHAN_REG(REG_C0C, subdev_channel));
}
break;
@@ -727,8 +735,9 @@ static int s526_gpct_insn_config(struct comedi_device *dev, struct comedi_subdev
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 */
short value;
@@ -741,14 +750,14 @@ static int s526_gpct_winsn(struct comedi_device *dev, struct comedi_subdevice *s
case PositionMeasurement:
printk("S526: INSN_WRITE: PM\n");
outw(0xFFFF & ((*data) >> 16), ADDR_CHAN_REG(REG_C0H,
- subdev_channel));
+ subdev_channel));
outw(0xFFFF & (*data), ADDR_CHAN_REG(REG_C0L, subdev_channel));
break;
case SinglePulseGeneration:
printk("S526: INSN_WRITE: SPG\n");
outw(0xFFFF & ((*data) >> 16), ADDR_CHAN_REG(REG_C0H,
- subdev_channel));
+ subdev_channel));
outw(0xFFFF & (*data), ADDR_CHAN_REG(REG_C0L, subdev_channel));
break;
@@ -762,22 +771,25 @@ static int s526_gpct_winsn(struct comedi_device *dev, struct comedi_subdevice *s
printk("S526: INSN_WRITE: PTG\n");
if ((insn->data[1] > insn->data[0]) && (insn->data[0] > 0)) {
(devpriv->s526_gpct_config[subdev_channel]).data[0] =
- insn->data[0];
+ insn->data[0];
(devpriv->s526_gpct_config[subdev_channel]).data[1] =
- insn->data[1];
+ insn->data[1];
} else {
printk("%d \t %d\n", insn->data[1], insn->data[2]);
- printk("s526: INSN_WRITE: PTG: Problem with Pulse params\n");
+ printk
+ ("s526: INSN_WRITE: PTG: Problem with Pulse params\n");
return -EINVAL;
}
- value = (short) ((*data >> 16) & 0xFFFF);
+ value = (short)((*data >> 16) & 0xFFFF);
outw(value, ADDR_CHAN_REG(REG_C0H, subdev_channel));
- value = (short) (*data & 0xFFFF);
+ value = (short)(*data & 0xFFFF);
outw(value, ADDR_CHAN_REG(REG_C0L, subdev_channel));
break;
default: /* Impossible */
- printk("s526: INSN_WRITE: Functionality %d not implemented yet\n", devpriv->s526_gpct_config[subdev_channel].app);
+ printk
+ ("s526: INSN_WRITE: Functionality %d not implemented yet\n",
+ devpriv->s526_gpct_config[subdev_channel].app);
return -EINVAL;
break;
}
@@ -786,8 +798,9 @@ static int s526_gpct_winsn(struct comedi_device *dev, struct comedi_subdevice *s
}
#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;
@@ -820,7 +833,7 @@ static int s526_ai_insn_config(struct comedi_device *dev, struct comedi_subdevic
* mode.
*/
static int s526_ai_rinsn(struct comedi_device *dev, struct comedi_subdevice *s,
- struct comedi_insn *insn, unsigned int *data)
+ struct comedi_insn *insn, unsigned int *data)
{
int n, i;
int chan = CR_CHAN(insn->chanspec);
@@ -831,7 +844,7 @@ static int s526_ai_rinsn(struct comedi_device *dev, struct comedi_subdevice *s,
/* Set configured delay, enable channel for this channel only,
* select "ADC read" channel, set "ADC start" bit. */
value = (devpriv->s526_ai_config & 0x8000) |
- ((1 << 5) << chan) | (chan << 1) | 0x0001;
+ ((1 << 5) << chan) | (chan << 1) | 0x0001;
/* convert n samples */
for (n = 0; n < insn->n; n++) {
@@ -853,7 +866,7 @@ static int s526_ai_rinsn(struct comedi_device *dev, struct comedi_subdevice *s,
/* printk() should be used instead of printk()
* whenever the code can be called from real-time. */
printk("s526: ADC(0x%04x) timeout\n",
- inw(ADDR_REG(REG_ISR)));
+ inw(ADDR_REG(REG_ISR)));
return -ETIMEDOUT;
}
@@ -870,7 +883,7 @@ static int s526_ai_rinsn(struct comedi_device *dev, struct comedi_subdevice *s,
}
static int s526_ao_winsn(struct comedi_device *dev, struct comedi_subdevice *s,
- struct comedi_insn *insn, unsigned int *data)
+ struct comedi_insn *insn, unsigned int *data)
{
int i;
int chan = CR_CHAN(insn->chanspec);
@@ -899,7 +912,7 @@ 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)
+ struct comedi_insn *insn, unsigned int *data)
{
int i;
int chan = CR_CHAN(insn->chanspec);
@@ -915,8 +928,9 @@ 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;
@@ -940,8 +954,9 @@ static int s526_dio_insn_bits(struct comedi_device *dev, struct comedi_subdevice
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;
diff --git a/drivers/staging/comedi/drivers/s626.c b/drivers/staging/comedi/drivers/s626.c
index 92121cf8c45c..6549d116f2e6 100644
--- a/drivers/staging/comedi/drivers/s626.c
+++ b/drivers/staging/comedi/drivers/s626.c
@@ -96,24 +96,28 @@ 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,
+ }
};
#define thisboard ((const struct s626_board *)dev->board_ptr)
#define PCI_VENDOR_ID_S626 0x1131
#define PCI_DEVICE_ID_S626 0x7146
+/*
+ * For devices with vendor:device id == 0x1131:0x7146 you must specify
+ * also subvendor:subdevice ids, because otherwise it will conflict with
+ * Philips SAA7146 media/dvb based cards.
+ */
static DEFINE_PCI_DEVICE_TABLE(s626_pci_table) = {
- {PCI_VENDOR_ID_S626, PCI_DEVICE_ID_S626, PCI_ANY_ID, PCI_ANY_ID, 0, 0,
- 0},
+ {PCI_VENDOR_ID_S626, PCI_DEVICE_ID_S626, 0x6000, 0x0272, 0, 0, 0},
{0}
};
@@ -145,7 +149,7 @@ struct s626_private {
uint16_t CounterIntEnabs;
/* Counter interrupt enable mask for MISC2 register. */
uint8_t AdcItems; /* Number of items in ADC poll list. */
- struct bufferDMA RPSBuf; /* DMA buffer used to hold ADC (RPS1) program. */
+ struct bufferDMA RPSBuf; /* DMA buffer used to hold ADC (RPS1) program. */
struct bufferDMA ANABuf;
/* DMA buffer used to receive ADC data and hold DAC data. */
uint32_t *pDacWBuf;
@@ -223,37 +227,45 @@ static struct dio_private *dio_private_word[]={
COMEDI_PCI_INITCLEANUP_NOMODULE(driver_s626, s626_pci_table);
/* ioctl routines */
-static int s626_ai_insn_config(struct comedi_device *dev, struct comedi_subdevice *s,
- struct comedi_insn *insn, unsigned int *data);
+static int s626_ai_insn_config(struct comedi_device *dev,
+ struct comedi_subdevice *s,
+ struct comedi_insn *insn, unsigned int *data);
/* static int s626_ai_rinsn(struct comedi_device *dev,struct comedi_subdevice *s,struct comedi_insn *insn,unsigned int *data); */
-static int s626_ai_insn_read(struct comedi_device *dev, struct comedi_subdevice *s,
- struct comedi_insn *insn, unsigned int *data);
+static int s626_ai_insn_read(struct comedi_device *dev,
+ struct comedi_subdevice *s,
+ struct comedi_insn *insn, unsigned int *data);
static int s626_ai_cmd(struct comedi_device *dev, struct comedi_subdevice *s);
-static int s626_ai_cmdtest(struct comedi_device *dev, struct comedi_subdevice *s,
- struct comedi_cmd *cmd);
-static int s626_ai_cancel(struct comedi_device *dev, struct comedi_subdevice *s);
+static int s626_ai_cmdtest(struct comedi_device *dev,
+ struct comedi_subdevice *s, struct comedi_cmd *cmd);
+static int s626_ai_cancel(struct comedi_device *dev,
+ struct comedi_subdevice *s);
static int s626_ao_winsn(struct comedi_device *dev, struct comedi_subdevice *s,
- struct comedi_insn *insn, unsigned int *data);
+ struct comedi_insn *insn, unsigned int *data);
static int s626_ao_rinsn(struct comedi_device *dev, struct comedi_subdevice *s,
- struct comedi_insn *insn, unsigned int *data);
-static int s626_dio_insn_bits(struct comedi_device *dev, struct comedi_subdevice *s,
- struct comedi_insn *insn, unsigned int *data);
-static int s626_dio_insn_config(struct comedi_device *dev, struct comedi_subdevice *s,
- struct comedi_insn *insn, unsigned int *data);
+ struct comedi_insn *insn, unsigned int *data);
+static int s626_dio_insn_bits(struct comedi_device *dev,
+ struct comedi_subdevice *s,
+ struct comedi_insn *insn, unsigned int *data);
+static int s626_dio_insn_config(struct comedi_device *dev,
+ struct comedi_subdevice *s,
+ struct comedi_insn *insn, unsigned int *data);
static int s626_dio_set_irq(struct comedi_device *dev, unsigned int chan);
static int s626_dio_reset_irq(struct comedi_device *dev, unsigned int gruop,
- unsigned int mask);
+ unsigned int mask);
static int s626_dio_clear_irq(struct comedi_device *dev);
-static int s626_enc_insn_config(struct comedi_device *dev, struct comedi_subdevice *s,
- struct comedi_insn *insn, unsigned int *data);
-static int s626_enc_insn_read(struct comedi_device *dev, struct comedi_subdevice *s,
- struct comedi_insn *insn, unsigned int *data);
-static int s626_enc_insn_write(struct comedi_device *dev, struct comedi_subdevice *s,
- struct comedi_insn *insn, unsigned int *data);
+static int s626_enc_insn_config(struct comedi_device *dev,
+ struct comedi_subdevice *s,
+ struct comedi_insn *insn, unsigned int *data);
+static int s626_enc_insn_read(struct comedi_device *dev,
+ struct comedi_subdevice *s,
+ struct comedi_insn *insn, unsigned int *data);
+static int s626_enc_insn_write(struct comedi_device *dev,
+ struct comedi_subdevice *s,
+ struct comedi_insn *insn, unsigned int *data);
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 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);
static unsigned int s626_ai_reg_to_uint(int data);
/* static unsigned int s626_uint_to_reg(struct comedi_subdevice *s, int data); */
@@ -262,10 +274,10 @@ static unsigned int s626_ai_reg_to_uint(int data);
/* internal routines */
static void s626_dio_init(struct comedi_device *dev);
-static void ResetADC(struct comedi_device *dev, uint8_t *ppl);
+static void ResetADC(struct comedi_device *dev, uint8_t * ppl);
static void LoadTrimDACs(struct comedi_device *dev);
static void WriteTrimDAC(struct comedi_device *dev, uint8_t LogicalChan,
- uint8_t DacData);
+ uint8_t DacData);
static uint8_t I2Cread(struct comedi_device *dev, uint8_t addr);
static uint32_t I2Chandshake(struct comedi_device *dev, uint32_t val);
static void SetDAC(struct comedi_device *dev, uint16_t chan, short dacdata);
@@ -275,22 +287,23 @@ static void DEBItransfer(struct comedi_device *dev);
static uint16_t DEBIread(struct comedi_device *dev, uint16_t addr);
static void DEBIwrite(struct comedi_device *dev, uint16_t addr, uint16_t wdata);
static void DEBIreplace(struct comedi_device *dev, uint16_t addr, uint16_t mask,
- uint16_t wdata);
-static void CloseDMAB(struct comedi_device *dev, struct bufferDMA *pdma, size_t bsize);
+ uint16_t wdata);
+static void CloseDMAB(struct comedi_device *dev, struct bufferDMA *pdma,
+ size_t bsize);
/* COUNTER OBJECT ------------------------------------------------ */
struct enc_private {
/* Pointers to functions that differ for A and B counters: */
- uint16_t(*GetEnable) (struct comedi_device *dev, struct enc_private *); /* Return clock enable. */
- uint16_t(*GetIntSrc) (struct comedi_device *dev, struct enc_private *); /* Return interrupt source. */
- uint16_t(*GetLoadTrig) (struct comedi_device *dev, struct enc_private *); /* Return preload trigger source. */
- uint16_t(*GetMode) (struct comedi_device *dev, struct enc_private *); /* Return standardized operating mode. */
- void (*PulseIndex) (struct comedi_device *dev, struct enc_private *); /* Generate soft index strobe. */
- void (*SetEnable) (struct comedi_device *dev, struct enc_private *, uint16_t enab); /* Program clock enable. */
- void (*SetIntSrc) (struct comedi_device *dev, struct enc_private *, uint16_t IntSource); /* Program interrupt source. */
- void (*SetLoadTrig) (struct comedi_device *dev, struct enc_private *, uint16_t Trig); /* Program preload trigger source. */
- void (*SetMode) (struct comedi_device *dev, struct enc_private *, uint16_t Setup, uint16_t DisableIntSrc); /* Program standardized operating mode. */
- void (*ResetCapFlags) (struct comedi_device *dev, struct enc_private *); /* Reset event capture flags. */
+ uint16_t(*GetEnable) (struct comedi_device * dev, struct enc_private *); /* Return clock enable. */
+ uint16_t(*GetIntSrc) (struct comedi_device * dev, struct enc_private *); /* Return interrupt source. */
+ uint16_t(*GetLoadTrig) (struct comedi_device * dev, struct enc_private *); /* Return preload trigger source. */
+ uint16_t(*GetMode) (struct comedi_device * dev, struct enc_private *); /* Return standardized operating mode. */
+ void (*PulseIndex) (struct comedi_device * dev, struct enc_private *); /* Generate soft index strobe. */
+ void (*SetEnable) (struct comedi_device * dev, struct enc_private *, uint16_t enab); /* Program clock enable. */
+ void (*SetIntSrc) (struct comedi_device * dev, struct enc_private *, uint16_t IntSource); /* Program interrupt source. */
+ void (*SetLoadTrig) (struct comedi_device * dev, struct enc_private *, uint16_t Trig); /* Program preload trigger source. */
+ void (*SetMode) (struct comedi_device * dev, struct enc_private *, uint16_t Setup, uint16_t DisableIntSrc); /* Program standardized operating mode. */
+ void (*ResetCapFlags) (struct comedi_device * dev, struct enc_private *); /* Reset event capture flags. */
uint16_t MyCRA; /* Address of CRA register. */
uint16_t MyCRB; /* Address of CRB register. */
@@ -302,31 +315,36 @@ struct enc_private {
#define encpriv ((struct enc_private *)(dev->subdevices+5)->private)
/* counters routines */
-static void s626_timer_load(struct comedi_device *dev, struct enc_private *k, int tick);
+static void s626_timer_load(struct comedi_device *dev, struct enc_private *k,
+ int tick);
static uint32_t ReadLatch(struct comedi_device *dev, struct enc_private *k);
static void ResetCapFlags_A(struct comedi_device *dev, struct enc_private *k);
static void ResetCapFlags_B(struct comedi_device *dev, struct enc_private *k);
static uint16_t GetMode_A(struct comedi_device *dev, struct enc_private *k);
static uint16_t GetMode_B(struct comedi_device *dev, struct enc_private *k);
-static void SetMode_A(struct comedi_device *dev, struct enc_private *k, uint16_t Setup,
- uint16_t DisableIntSrc);
-static void SetMode_B(struct comedi_device *dev, struct enc_private *k, uint16_t Setup,
- uint16_t DisableIntSrc);
-static void SetEnable_A(struct comedi_device *dev, struct enc_private *k, uint16_t enab);
-static void SetEnable_B(struct comedi_device *dev, struct enc_private *k, uint16_t enab);
+static void SetMode_A(struct comedi_device *dev, struct enc_private *k,
+ uint16_t Setup, uint16_t DisableIntSrc);
+static void SetMode_B(struct comedi_device *dev, struct enc_private *k,
+ uint16_t Setup, uint16_t DisableIntSrc);
+static void SetEnable_A(struct comedi_device *dev, struct enc_private *k,
+ uint16_t enab);
+static void SetEnable_B(struct comedi_device *dev, struct enc_private *k,
+ uint16_t enab);
static uint16_t GetEnable_A(struct comedi_device *dev, struct enc_private *k);
static uint16_t GetEnable_B(struct comedi_device *dev, struct enc_private *k);
static void SetLatchSource(struct comedi_device *dev, struct enc_private *k,
- uint16_t value);
+ uint16_t value);
/* static uint16_t GetLatchSource(struct comedi_device *dev, struct enc_private *k ); */
-static void SetLoadTrig_A(struct comedi_device *dev, struct enc_private *k, uint16_t Trig);
-static void SetLoadTrig_B(struct comedi_device *dev, struct enc_private *k, uint16_t Trig);
+static void SetLoadTrig_A(struct comedi_device *dev, struct enc_private *k,
+ uint16_t Trig);
+static void SetLoadTrig_B(struct comedi_device *dev, struct enc_private *k,
+ uint16_t Trig);
static uint16_t GetLoadTrig_A(struct comedi_device *dev, struct enc_private *k);
static uint16_t GetLoadTrig_B(struct comedi_device *dev, struct enc_private *k);
static void SetIntSrc_B(struct comedi_device *dev, struct enc_private *k,
- uint16_t IntSource);
+ uint16_t IntSource);
static void SetIntSrc_A(struct comedi_device *dev, struct enc_private *k,
- uint16_t IntSource);
+ uint16_t IntSource);
static uint16_t GetIntSrc_A(struct comedi_device *dev, struct enc_private *k);
static uint16_t GetIntSrc_B(struct comedi_device *dev, struct enc_private *k);
/* static void SetClkMult(struct comedi_device *dev, struct enc_private *k, uint16_t value ) ; */
@@ -339,7 +357,8 @@ static uint16_t GetIntSrc_B(struct comedi_device *dev, struct enc_private *k);
/* static uint16_t GetIndexSrc( struct comedi_device *dev,struct enc_private *k ); */
static void PulseIndex_A(struct comedi_device *dev, struct enc_private *k);
static void PulseIndex_B(struct comedi_device *dev, struct enc_private *k);
-static void Preload(struct comedi_device *dev, struct enc_private *k, uint32_t value);
+static void Preload(struct comedi_device *dev, struct enc_private *k,
+ uint32_t value);
static void CountersInit(struct comedi_device *dev);
/* end internal routines */
@@ -356,101 +375,101 @@ 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),
+ },
};
/* enab/disable a function or test status bit(s) that are accessed */
@@ -481,9 +500,9 @@ static struct enc_private enc_private_data[] = {
#define I2C_B0(ATTR, VAL) (((ATTR) << 2) | ((VAL) << 8))
static const struct comedi_lrange s626_range_table = { 2, {
- RANGE(-5, 5),
- RANGE(-10, 10),
- }
+ RANGE(-5, 5),
+ RANGE(-10, 10),
+ }
};
static int s626_attach(struct comedi_device *dev, struct comedi_devconfig *it)
@@ -499,25 +518,27 @@ static int s626_attach(struct comedi_device *dev, struct comedi_devconfig *it)
resource_size_t resourceStart;
dma_addr_t appdma;
struct comedi_subdevice *s;
- struct pci_dev *pdev;
+ const struct pci_device_id *ids;
+ struct pci_dev *pdev = NULL;
if (alloc_private(dev, sizeof(struct s626_private)) < 0)
return -ENOMEM;
- for (pdev = pci_get_device(PCI_VENDOR_ID_S626, PCI_DEVICE_ID_S626,
- NULL); pdev != NULL;
- pdev = pci_get_device(PCI_VENDOR_ID_S626,
- PCI_DEVICE_ID_S626, pdev)) {
- if (it->options[0] || it->options[1]) {
- if (pdev->bus->number == it->options[0] &&
- PCI_SLOT(pdev->devfn) == it->options[1]) {
+ for (i = 0; i < (ARRAY_SIZE(s626_pci_table) - 1) && !pdev; i++) {
+ ids = &s626_pci_table[i];
+ do {
+ pdev = pci_get_subsys(ids->vendor, ids->device,
+ ids->subvendor, ids->subdevice,
+ pdev);
+
+ if ((it->options[0] || it->options[1]) && pdev) {
/* matches requested bus/slot */
+ if (pdev->bus->number == it->options[0] &&
+ PCI_SLOT(pdev->devfn) == it->options[1])
+ break;
+ } else
break;
- }
- } else {
- /* no bus/slot specified */
- break;
- }
+ } while (1);
}
devpriv->pdev = pdev;
@@ -555,7 +576,7 @@ static int s626_attach(struct comedi_device *dev, struct comedi_devconfig *it)
devpriv->allocatedBuf = 0;
devpriv->ANABuf.LogicalBase =
- pci_alloc_consistent(devpriv->pdev, DMABUF_SIZE, &appdma);
+ pci_alloc_consistent(devpriv->pdev, DMABUF_SIZE, &appdma);
if (devpriv->ANABuf.LogicalBase == NULL) {
printk("s626_attach: DMA Memory mapping error\n");
@@ -564,12 +585,15 @@ static int s626_attach(struct comedi_device *dev, struct comedi_devconfig *it)
devpriv->ANABuf.PhysicalBase = appdma;
- DEBUG("s626_attach: AllocDMAB ADC Logical=%p, bsize=%d, Physical=0x%x\n", devpriv->ANABuf.LogicalBase, DMABUF_SIZE, (uint32_t) devpriv->ANABuf.PhysicalBase);
+ DEBUG
+ ("s626_attach: AllocDMAB ADC Logical=%p, bsize=%d, Physical=0x%x\n",
+ devpriv->ANABuf.LogicalBase, DMABUF_SIZE,
+ (uint32_t) devpriv->ANABuf.PhysicalBase);
devpriv->allocatedBuf++;
devpriv->RPSBuf.LogicalBase =
- pci_alloc_consistent(devpriv->pdev, DMABUF_SIZE, &appdma);
+ pci_alloc_consistent(devpriv->pdev, DMABUF_SIZE, &appdma);
if (devpriv->RPSBuf.LogicalBase == NULL) {
printk("s626_attach: DMA Memory mapping error\n");
@@ -578,7 +602,10 @@ static int s626_attach(struct comedi_device *dev, struct comedi_devconfig *it)
devpriv->RPSBuf.PhysicalBase = appdma;
- DEBUG("s626_attach: AllocDMAB RPS Logical=%p, bsize=%d, Physical=0x%x\n", devpriv->RPSBuf.LogicalBase, DMABUF_SIZE, (uint32_t) devpriv->RPSBuf.PhysicalBase);
+ DEBUG
+ ("s626_attach: AllocDMAB RPS Logical=%p, bsize=%d, Physical=0x%x\n",
+ devpriv->RPSBuf.LogicalBase, DMABUF_SIZE,
+ (uint32_t) devpriv->RPSBuf.PhysicalBase);
devpriv->allocatedBuf++;
@@ -607,7 +634,7 @@ static int s626_attach(struct comedi_device *dev, struct comedi_devconfig *it)
}
DEBUG("s626_attach: -- it opts %d,%d -- \n",
- it->options[0], it->options[1]);
+ it->options[0], it->options[1]);
s = dev->subdevices + 0;
/* analog input subdevice */
@@ -696,20 +723,22 @@ static int s626_attach(struct comedi_device *dev, struct comedi_devconfig *it)
MC_ENABLE(P_MC1, MC1_DEBI | MC1_AUDIO | MC1_I2C);
/* Configure DEBI operating mode. */
WR7146(P_DEBICFG, DEBI_CFG_SLAVE16 /* Local bus is 16 */
- /* bits wide. */
- | (DEBI_TOUT << DEBI_CFG_TOUT_BIT) /* Declare DEBI */
- /* transfer timeout */
- /* interval. */
- | DEBI_SWAP /* Set up byte lane */
- /* steering. */
- | DEBI_CFG_INTEL); /* Intel-compatible */
+ /* bits wide. */
+ | (DEBI_TOUT << DEBI_CFG_TOUT_BIT)
+
+ /* Declare DEBI */
+ /* transfer timeout */
+ /* interval. */
+ |DEBI_SWAP /* Set up byte lane */
+ /* steering. */
+ | DEBI_CFG_INTEL); /* Intel-compatible */
/* local bus (DEBI */
/* never times out). */
DEBUG("s626_attach: %d debi init -- %d\n",
- DEBI_CFG_SLAVE16 | (DEBI_TOUT << DEBI_CFG_TOUT_BIT) |
- DEBI_SWAP | DEBI_CFG_INTEL,
- DEBI_CFG_INTEL | DEBI_CFG_TOQ | DEBI_CFG_INCQ |
- DEBI_CFG_16Q);
+ DEBI_CFG_SLAVE16 | (DEBI_TOUT << DEBI_CFG_TOUT_BIT) |
+ DEBI_SWAP | DEBI_CFG_INTEL,
+ DEBI_CFG_INTEL | DEBI_CFG_TOQ | DEBI_CFG_INCQ |
+ DEBI_CFG_16Q);
/* DEBI INIT S626 WR7146( P_DEBICFG, DEBI_CFG_INTEL | DEBI_CFG_TOQ */
/* | DEBI_CFG_INCQ| DEBI_CFG_16Q); //end */
@@ -720,22 +749,22 @@ static int s626_attach(struct comedi_device *dev, struct comedi_devconfig *it)
/* Init GPIO so that ADC Start* is negated. */
WR7146(P_GPIO, GPIO_BASE | GPIO1_HI);
- /* IsBoardRevA is a boolean that indicates whether the board is RevA.
- *
- * VERSION 2.01 CHANGE: REV A & B BOARDS NOW SUPPORTED BY DYNAMIC
- * EEPROM ADDRESS SELECTION. Initialize the I2C interface, which
- * is used to access the onboard serial EEPROM. The EEPROM's I2C
- * DeviceAddress is hardwired to a value that is dependent on the
- * 626 board revision. On all board revisions, the EEPROM stores
- * TrimDAC calibration constants for analog I/O. On RevB and
- * higher boards, the DeviceAddress is hardwired to 0 to enable
- * the EEPROM to also store the PCI SubVendorID and SubDeviceID;
- * this is the address at which the SAA7146 expects a
- * configuration EEPROM to reside. On RevA boards, the EEPROM
- * device address, which is hardwired to 4, prevents the SAA7146
- * from retrieving PCI sub-IDs, so the SAA7146 uses its built-in
- * default values, instead.
- */
+ /* IsBoardRevA is a boolean that indicates whether the board is RevA.
+ *
+ * VERSION 2.01 CHANGE: REV A & B BOARDS NOW SUPPORTED BY DYNAMIC
+ * EEPROM ADDRESS SELECTION. Initialize the I2C interface, which
+ * is used to access the onboard serial EEPROM. The EEPROM's I2C
+ * DeviceAddress is hardwired to a value that is dependent on the
+ * 626 board revision. On all board revisions, the EEPROM stores
+ * TrimDAC calibration constants for analog I/O. On RevB and
+ * higher boards, the DeviceAddress is hardwired to 0 to enable
+ * the EEPROM to also store the PCI SubVendorID and SubDeviceID;
+ * this is the address at which the SAA7146 expects a
+ * configuration EEPROM to reside. On RevA boards, the EEPROM
+ * device address, which is hardwired to 4, prevents the SAA7146
+ * from retrieving PCI sub-IDs, so the SAA7146 uses its built-in
+ * default values, instead.
+ */
/* devpriv->I2Cards= IsBoardRevA ? 0xA8 : 0xA0; // Set I2C EEPROM */
/* DeviceType (0xA0) */
@@ -750,8 +779,7 @@ static int s626_attach(struct comedi_device *dev, struct comedi_devconfig *it)
/* Write I2C control: abort any I2C activity. */
MC_ENABLE(P_MC2, MC2_UPLD_IIC);
/* Invoke command upload */
- while ((RR7146(P_MC2) & MC2_UPLD_IIC) == 0)
- ;
+ while ((RR7146(P_MC2) & MC2_UPLD_IIC) == 0) ;
/* and wait for upload to complete. */
/* Per SAA7146 data sheet, write to STATUS reg twice to
@@ -760,8 +788,7 @@ static int s626_attach(struct comedi_device *dev, struct comedi_devconfig *it)
WR7146(P_I2CSTAT, I2C_CLKSEL);
/* Write I2C control: reset error flags. */
MC_ENABLE(P_MC2, MC2_UPLD_IIC); /* Invoke command upload */
- while (!MC_TEST(P_MC2, MC2_UPLD_IIC))
- ;
+ while (!MC_TEST(P_MC2, MC2_UPLD_IIC)) ;
/* and wait for upload to complete. */
}
@@ -842,8 +869,8 @@ static int s626_attach(struct comedi_device *dev, struct comedi_devconfig *it)
* enabled. */
pPhysBuf =
- devpriv->ANABuf.PhysicalBase +
- (DAC_WDMABUF_OS * sizeof(uint32_t));
+ devpriv->ANABuf.PhysicalBase +
+ (DAC_WDMABUF_OS * sizeof(uint32_t));
WR7146(P_BASEA2_OUT, (uint32_t) pPhysBuf); /* Buffer base adrs. */
WR7146(P_PROTA2_OUT, (uint32_t) (pPhysBuf + sizeof(uint32_t))); /* Protection address. */
@@ -851,8 +878,7 @@ static int s626_attach(struct comedi_device *dev, struct comedi_devconfig *it)
/* Cache Audio2's output DMA buffer logical address. This is
* where DAC data is buffered for A2 output DMA transfers. */
devpriv->pDacWBuf =
- (uint32_t *) devpriv->ANABuf.LogicalBase +
- DAC_WDMABUF_OS;
+ (uint32_t *) devpriv->ANABuf.LogicalBase + DAC_WDMABUF_OS;
/* Audio2's output channels does not use paging. The protection
* violation handling bit is set so that the DMAC will
@@ -937,7 +963,8 @@ static int s626_attach(struct comedi_device *dev, struct comedi_devconfig *it)
* charger, and reset the watchdog interval selector to zero.
*/
WriteMISC2(dev, (uint16_t) (DEBIread(dev,
- LP_RDMISC2) & MISC2_BATT_ENABLE));
+ LP_RDMISC2) &
+ MISC2_BATT_ENABLE));
/* Initialize the digital I/O subsystem. */
s626_dio_init(dev);
@@ -947,7 +974,7 @@ static int s626_attach(struct comedi_device *dev, struct comedi_devconfig *it)
}
DEBUG("s626_attach: comedi%d s626 attached %04x\n", dev->minor,
- (uint32_t) devpriv->base_addr);
+ (uint32_t) devpriv->base_addr);
return 1;
}
@@ -1030,10 +1057,11 @@ static irqreturn_t s626_irq_handler(int irq, void *d)
/* put data into read buffer */
/* comedi_buf_put(s->async, tempdata); */
if (cfc_write_to_buffer(s, tempdata) == 0)
- printk("s626_irq_handler: cfc_write_to_buffer error!\n");
+ printk
+ ("s626_irq_handler: cfc_write_to_buffer error!\n");
DEBUG("s626_irq_handler: ai channel %d acquired: %d\n",
- i, tempdata);
+ i, tempdata);
}
/* end of scan occurs */
@@ -1055,7 +1083,9 @@ static irqreturn_t s626_irq_handler(int irq, void *d)
}
if (devpriv->ai_cmd_running && cmd->scan_begin_src == TRIG_EXT) {
- DEBUG("s626_irq_handler: enable interrupt on dio channel %d\n", cmd->scan_begin_arg);
+ DEBUG
+ ("s626_irq_handler: enable interrupt on dio channel %d\n",
+ cmd->scan_begin_arg);
s626_dio_set_irq(dev, cmd->scan_begin_arg);
@@ -1079,102 +1109,120 @@ static irqreturn_t s626_irq_handler(int irq, void *d)
irqbit = 0;
/* read interrupt type */
irqbit = DEBIread(dev,
- ((struct dio_private *) (dev->subdevices + 2 +
- group)->private)->RDCapFlg);
+ ((struct dio_private *)(dev->
+ subdevices +
+ 2 +
+ group)->
+ private)->RDCapFlg);
/* check if interrupt is generated from dio channels */
if (irqbit) {
s626_dio_reset_irq(dev, group, irqbit);
- DEBUG("s626_irq_handler: check interrupt on dio group %d %d\n", group, i);
+ DEBUG
+ ("s626_irq_handler: check interrupt on dio group %d %d\n",
+ group, i);
if (devpriv->ai_cmd_running) {
/* check if interrupt is an ai acquisition start trigger */
if ((irqbit >> (cmd->start_arg -
- (16 * group)))
- == 1
- && cmd->start_src == TRIG_EXT) {
- DEBUG("s626_irq_handler: Edge capture interrupt recieved from channel %d\n", cmd->start_arg);
+ (16 * group)))
+ == 1 && cmd->start_src == TRIG_EXT) {
+ DEBUG
+ ("s626_irq_handler: Edge capture interrupt recieved from channel %d\n",
+ cmd->start_arg);
/* Start executing the RPS program. */
MC_ENABLE(P_MC1, MC1_ERPS1);
- DEBUG("s626_irq_handler: aquisition start triggered!!!\n");
+ DEBUG
+ ("s626_irq_handler: aquisition start triggered!!!\n");
if (cmd->scan_begin_src ==
- TRIG_EXT) {
- DEBUG("s626_ai_cmd: enable interrupt on dio channel %d\n", cmd->scan_begin_arg);
+ TRIG_EXT) {
+ DEBUG
+ ("s626_ai_cmd: enable interrupt on dio channel %d\n",
+ cmd->
+ scan_begin_arg);
s626_dio_set_irq(dev,
- cmd->
- scan_begin_arg);
+ cmd->scan_begin_arg);
- DEBUG("s626_irq_handler: External scan trigger is set!!!\n");
+ DEBUG
+ ("s626_irq_handler: External scan trigger is set!!!\n");
}
}
if ((irqbit >> (cmd->scan_begin_arg -
- (16 * group)))
- == 1
- && cmd->scan_begin_src ==
- TRIG_EXT) {
- DEBUG("s626_irq_handler: Edge capture interrupt recieved from channel %d\n", cmd->scan_begin_arg);
+ (16 * group)))
+ == 1
+ && cmd->scan_begin_src ==
+ TRIG_EXT) {
+ DEBUG
+ ("s626_irq_handler: Edge capture interrupt recieved from channel %d\n",
+ cmd->scan_begin_arg);
/* Trigger ADC scan loop start by setting RPS Signal 0. */
MC_ENABLE(P_MC2, MC2_ADC_RPS);
- DEBUG("s626_irq_handler: scan triggered!!! %d\n", devpriv->ai_sample_count);
+ DEBUG
+ ("s626_irq_handler: scan triggered!!! %d\n",
+ devpriv->ai_sample_count);
if (cmd->convert_src ==
- TRIG_EXT) {
+ TRIG_EXT) {
- DEBUG("s626_ai_cmd: enable interrupt on dio channel %d group %d\n", cmd->convert_arg - (16 * group), group);
+ DEBUG
+ ("s626_ai_cmd: enable interrupt on dio channel %d group %d\n",
+ cmd->convert_arg -
+ (16 * group),
+ group);
- devpriv->
- ai_convert_count
- =
- cmd->
- chanlist_len;
+ devpriv->ai_convert_count
+ = cmd->chanlist_len;
s626_dio_set_irq(dev,
- cmd->
- convert_arg);
+ cmd->convert_arg);
- DEBUG("s626_irq_handler: External convert trigger is set!!!\n");
+ DEBUG
+ ("s626_irq_handler: External convert trigger is set!!!\n");
}
if (cmd->convert_src ==
- TRIG_TIMER) {
+ TRIG_TIMER) {
k = &encpriv[5];
- devpriv->
- ai_convert_count
- =
- cmd->
- chanlist_len;
+ devpriv->ai_convert_count
+ = cmd->chanlist_len;
k->SetEnable(dev, k,
- CLKENAB_ALWAYS);
+ CLKENAB_ALWAYS);
}
}
if ((irqbit >> (cmd->convert_arg -
- (16 * group)))
- == 1
- && cmd->convert_src ==
- TRIG_EXT) {
- DEBUG("s626_irq_handler: Edge capture interrupt recieved from channel %d\n", cmd->convert_arg);
+ (16 * group)))
+ == 1
+ && cmd->convert_src == TRIG_EXT) {
+ DEBUG
+ ("s626_irq_handler: Edge capture interrupt recieved from channel %d\n",
+ cmd->convert_arg);
/* Trigger ADC scan loop start by setting RPS Signal 0. */
MC_ENABLE(P_MC2, MC2_ADC_RPS);
- DEBUG("s626_irq_handler: adc convert triggered!!!\n");
+ DEBUG
+ ("s626_irq_handler: adc convert triggered!!!\n");
devpriv->ai_convert_count--;
if (devpriv->ai_convert_count >
- 0) {
+ 0) {
- DEBUG("s626_ai_cmd: enable interrupt on dio channel %d group %d\n", cmd->convert_arg - (16 * group), group);
+ DEBUG
+ ("s626_ai_cmd: enable interrupt on dio channel %d group %d\n",
+ cmd->convert_arg -
+ (16 * group),
+ group);
s626_dio_set_irq(dev,
- cmd->
- convert_arg);
+ cmd->convert_arg);
- DEBUG("s626_irq_handler: External trigger is set!!!\n");
+ DEBUG
+ ("s626_irq_handler: External trigger is set!!!\n");
}
}
}
@@ -1187,38 +1235,43 @@ static irqreturn_t s626_irq_handler(int irq, void *d)
/* check interrupt on counters */
DEBUG("s626_irq_handler: check counters interrupt %d\n",
- irqbit);
+ irqbit);
if (irqbit & IRQ_COINT1A) {
- DEBUG("s626_irq_handler: interrupt on counter 1A overflow\n");
+ DEBUG
+ ("s626_irq_handler: interrupt on counter 1A overflow\n");
k = &encpriv[0];
/* clear interrupt capture flag */
k->ResetCapFlags(dev, k);
}
if (irqbit & IRQ_COINT2A) {
- DEBUG("s626_irq_handler: interrupt on counter 2A overflow\n");
+ DEBUG
+ ("s626_irq_handler: interrupt on counter 2A overflow\n");
k = &encpriv[1];
/* clear interrupt capture flag */
k->ResetCapFlags(dev, k);
}
if (irqbit & IRQ_COINT3A) {
- DEBUG("s626_irq_handler: interrupt on counter 3A overflow\n");
+ DEBUG
+ ("s626_irq_handler: interrupt on counter 3A overflow\n");
k = &encpriv[2];
/* clear interrupt capture flag */
k->ResetCapFlags(dev, k);
}
if (irqbit & IRQ_COINT1B) {
- DEBUG("s626_irq_handler: interrupt on counter 1B overflow\n");
+ DEBUG
+ ("s626_irq_handler: interrupt on counter 1B overflow\n");
k = &encpriv[3];
/* clear interrupt capture flag */
k->ResetCapFlags(dev, k);
}
if (irqbit & IRQ_COINT2B) {
- DEBUG("s626_irq_handler: interrupt on counter 2B overflow\n");
+ DEBUG
+ ("s626_irq_handler: interrupt on counter 2B overflow\n");
k = &encpriv[4];
/* clear interrupt capture flag */
@@ -1230,7 +1283,9 @@ static irqreturn_t s626_irq_handler(int irq, void *d)
k->SetEnable(dev, k, CLKENAB_INDEX);
if (cmd->convert_src == TRIG_TIMER) {
- DEBUG("s626_irq_handler: conver timer trigger!!! %d\n", devpriv->ai_convert_count);
+ DEBUG
+ ("s626_irq_handler: conver timer trigger!!! %d\n",
+ devpriv->ai_convert_count);
/* Trigger ADC scan loop start by setting RPS Signal 0. */
MC_ENABLE(P_MC2, MC2_ADC_RPS);
@@ -1238,21 +1293,24 @@ static irqreturn_t s626_irq_handler(int irq, void *d)
}
}
if (irqbit & IRQ_COINT3B) {
- DEBUG("s626_irq_handler: interrupt on counter 3B overflow\n");
+ DEBUG
+ ("s626_irq_handler: interrupt on counter 3B overflow\n");
k = &encpriv[5];
/* clear interrupt capture flag */
k->ResetCapFlags(dev, k);
if (cmd->scan_begin_src == TRIG_TIMER) {
- DEBUG("s626_irq_handler: scan timer trigger!!!\n");
+ DEBUG
+ ("s626_irq_handler: scan timer trigger!!!\n");
/* Trigger ADC scan loop start by setting RPS Signal 0. */
MC_ENABLE(P_MC2, MC2_ADC_RPS);
}
if (cmd->convert_src == TRIG_TIMER) {
- DEBUG("s626_irq_handler: convert timer trigger is set\n");
+ DEBUG
+ ("s626_irq_handler: convert timer trigger is set\n");
k = &encpriv[4];
devpriv->ai_convert_count = cmd->chanlist_len;
k->SetEnable(dev, k, CLKENAB_ALWAYS);
@@ -1312,7 +1370,7 @@ static int s626_detach(struct comedi_device *dev)
/*
* this functions build the RPS program for hardware driven acquistion
*/
-void ResetADC(struct comedi_device *dev, uint8_t *ppl)
+void ResetADC(struct comedi_device *dev, uint8_t * ppl)
{
register uint32_t *pRPS;
uint32_t JmpAdrs;
@@ -1366,14 +1424,14 @@ void ResetADC(struct comedi_device *dev, uint8_t *ppl)
* forgot to set the EOPL flag in the final slot.
*/
for (devpriv->AdcItems = 0; devpriv->AdcItems < 16; devpriv->AdcItems++) {
- /* Convert application's poll list item to private board class
- * format. Each app poll list item is an uint8_t with form
- * (EOPL,x,x,RANGE,CHAN<3:0>), where RANGE code indicates 0 =
- * +-10V, 1 = +-5V, and EOPL = End of Poll List marker.
- */
+ /* Convert application's poll list item to private board class
+ * format. Each app poll list item is an uint8_t with form
+ * (EOPL,x,x,RANGE,CHAN<3:0>), where RANGE code indicates 0 =
+ * +-10V, 1 = +-5V, and EOPL = End of Poll List marker.
+ */
LocalPPL =
- (*ppl << 8) | (*ppl & 0x10 ? GSEL_BIPOLAR5V :
- GSEL_BIPOLAR10V);
+ (*ppl << 8) | (*ppl & 0x10 ? GSEL_BIPOLAR5V :
+ GSEL_BIPOLAR10V);
/* Switch ADC analog gain. */
*pRPS++ = RPS_LDREG | (P_DEBICMD >> 2); /* Write DEBI command */
@@ -1413,9 +1471,9 @@ void ResetADC(struct comedi_device *dev, uint8_t *ppl)
* instruction prefetch pipeline.
*/
JmpAdrs =
- (uint32_t) devpriv->RPSBuf.PhysicalBase +
- (uint32_t) ((unsigned long)pRPS -
- (unsigned long)devpriv->RPSBuf.LogicalBase);
+ (uint32_t) devpriv->RPSBuf.PhysicalBase +
+ (uint32_t) ((unsigned long)pRPS -
+ (unsigned long)devpriv->RPSBuf.LogicalBase);
for (i = 0; i < (10 * RPSCLK_PER_US / 2); i++) {
JmpAdrs += 8; /* Repeat to implement time delay: */
*pRPS++ = RPS_JUMP; /* Jump to next RPS instruction. */
@@ -1445,8 +1503,8 @@ void ResetADC(struct comedi_device *dev, uint8_t *ppl)
/* Transfer ADC data from FB BUFFER 1 register to DMA buffer. */
*pRPS++ = RPS_STREG | (BUGFIX_STREG(P_FB_BUFFER1) >> 2);
*pRPS++ =
- (uint32_t) devpriv->ANABuf.PhysicalBase +
- (devpriv->AdcItems << 2);
+ (uint32_t) devpriv->ANABuf.PhysicalBase +
+ (devpriv->AdcItems << 2);
/* If this slot's EndOfPollList flag is set, all channels have */
/* now been processed. */
@@ -1485,8 +1543,7 @@ void ResetADC(struct comedi_device *dev, uint8_t *ppl)
/* Transfer final ADC data from FB BUFFER 1 register to DMA buffer. */
*pRPS++ = RPS_STREG | (BUGFIX_STREG(P_FB_BUFFER1) >> 2); /* */
*pRPS++ =
- (uint32_t) devpriv->ANABuf.PhysicalBase +
- (devpriv->AdcItems << 2);
+ (uint32_t) devpriv->ANABuf.PhysicalBase + (devpriv->AdcItems << 2);
/* Indicate ADC scan loop is finished. */
/* *pRPS++= RPS_CLRSIGNAL | RPS_SIGADC ; // Signal ReadADC() that scan is done. */
@@ -1504,8 +1561,9 @@ void ResetADC(struct comedi_device *dev, uint8_t *ppl)
}
/* TO COMPLETE, IF NECESSARY */
-static int s626_ai_insn_config(struct comedi_device *dev, struct comedi_subdevice *s,
- struct comedi_insn *insn, unsigned int *data)
+static int s626_ai_insn_config(struct comedi_device *dev,
+ struct comedi_subdevice *s,
+ struct comedi_insn *insn, unsigned int *data)
{
return -EINVAL;
@@ -1541,8 +1599,9 @@ static int s626_ai_insn_config(struct comedi_device *dev, struct comedi_subdevic
/* return i; */
/* } */
-static int s626_ai_insn_read(struct comedi_device *dev, struct comedi_subdevice *s,
- struct comedi_insn *insn, unsigned int *data)
+static int s626_ai_insn_read(struct comedi_device *dev,
+ struct comedi_subdevice *s,
+ struct comedi_insn *insn, unsigned int *data)
{
uint16_t chan = CR_CHAN(insn->chanspec);
uint16_t range = CR_RANGE(insn->chanspec);
@@ -1550,7 +1609,7 @@ static int s626_ai_insn_read(struct comedi_device *dev, struct comedi_subdevice
uint32_t GpioImage;
int n;
- /* interrupt call test */
+ /* interrupt call test */
/* writel(IRQ_GPIO3,devpriv->base_addr+P_PSR); */
/* Writing a logical 1 into any of the RPS_PSR bits causes the
* corresponding interrupt to be generated if enabled
@@ -1592,8 +1651,7 @@ static int s626_ai_insn_read(struct comedi_device *dev, struct comedi_subdevice
/* shift into FB BUFFER 1 register. */
/* Wait for ADC done. */
- while (!(RR7146(P_PSR) & PSR_GPIO2))
- ;
+ while (!(RR7146(P_PSR) & PSR_GPIO2)) ;
/* Fetch ADC data. */
if (n != 0)
@@ -1625,8 +1683,7 @@ static int s626_ai_insn_read(struct comedi_device *dev, struct comedi_subdevice
/* Wait for the data to arrive in FB BUFFER 1 register. */
/* Wait for ADC done. */
- while (!(RR7146(P_PSR) & PSR_GPIO2))
- ;
+ while (!(RR7146(P_PSR) & PSR_GPIO2)) ;
/* Fetch ADC data from audio interface's input shift register. */
@@ -1639,7 +1696,7 @@ static int s626_ai_insn_read(struct comedi_device *dev, struct comedi_subdevice
return n;
}
-static int s626_ai_load_polllist(uint8_t *ppl, struct comedi_cmd *cmd)
+static int s626_ai_load_polllist(uint8_t * ppl, struct comedi_cmd *cmd)
{
int n;
@@ -1655,8 +1712,8 @@ static int s626_ai_load_polllist(uint8_t *ppl, struct comedi_cmd *cmd)
return n;
}
-static int s626_ai_inttrig(struct comedi_device *dev, struct comedi_subdevice *s,
- unsigned int trignum)
+static int s626_ai_inttrig(struct comedi_device *dev,
+ struct comedi_subdevice *s, unsigned int trignum)
{
if (trignum != 0)
return -EINVAL;
@@ -1686,7 +1743,7 @@ static int s626_ai_cmd(struct comedi_device *dev, struct comedi_subdevice *s)
if (devpriv->ai_cmd_running) {
printk("s626_ai_cmd: Another ai_cmd is running %d\n",
- dev->minor);
+ dev->minor);
return -EBUSY;
}
/* disable interrupt */
@@ -1712,7 +1769,7 @@ static int s626_ai_cmd(struct comedi_device *dev, struct comedi_subdevice *s)
if (dev->irq == 0) {
comedi_error(dev,
- "s626_ai_cmd: cannot run command without an irq");
+ "s626_ai_cmd: cannot run command without an irq");
return -EIO;
}
@@ -1727,14 +1784,14 @@ static int s626_ai_cmd(struct comedi_device *dev, struct comedi_subdevice *s)
/* set a conter to generate adc trigger at scan_begin_arg interval */
k = &encpriv[5];
tick = s626_ns_to_timer((int *)&cmd->scan_begin_arg,
- cmd->flags & TRIG_ROUND_MASK);
+ cmd->flags & TRIG_ROUND_MASK);
/* load timer value and enable interrupt */
s626_timer_load(dev, k, tick);
k->SetEnable(dev, k, CLKENAB_ALWAYS);
DEBUG("s626_ai_cmd: scan trigger timer is set with value %d\n",
- tick);
+ tick);
break;
case TRIG_EXT:
@@ -1754,18 +1811,20 @@ static int s626_ai_cmd(struct comedi_device *dev, struct comedi_subdevice *s)
/* set a conter to generate adc trigger at convert_arg interval */
k = &encpriv[4];
tick = s626_ns_to_timer((int *)&cmd->convert_arg,
- cmd->flags & TRIG_ROUND_MASK);
+ cmd->flags & TRIG_ROUND_MASK);
/* load timer value and enable interrupt */
s626_timer_load(dev, k, tick);
k->SetEnable(dev, k, CLKENAB_INDEX);
- DEBUG("s626_ai_cmd: convert trigger timer is set with value %d\n", tick);
+ DEBUG
+ ("s626_ai_cmd: convert trigger timer is set with value %d\n",
+ tick);
break;
case TRIG_EXT:
/* set the digital line and interrupt for convert trigger */
if (cmd->scan_begin_src != TRIG_EXT
- && cmd->start_src == TRIG_EXT)
+ && cmd->start_src == TRIG_EXT)
s626_dio_set_irq(dev, cmd->convert_arg);
DEBUG("s626_ai_cmd: External convert trigger is set!!!\n");
@@ -1820,8 +1879,8 @@ static int s626_ai_cmd(struct comedi_device *dev, struct comedi_subdevice *s)
return 0;
}
-static int s626_ai_cmdtest(struct comedi_device *dev, struct comedi_subdevice *s,
- struct comedi_cmd *cmd)
+static int s626_ai_cmdtest(struct comedi_device *dev,
+ struct comedi_subdevice *s, struct comedi_cmd *cmd)
{
int err = 0;
int tmp;
@@ -1868,11 +1927,11 @@ static int s626_ai_cmdtest(struct comedi_device *dev, struct comedi_subdevice *s
/* note that mutual compatiblity is not an issue here */
if (cmd->scan_begin_src != TRIG_TIMER &&
- cmd->scan_begin_src != TRIG_EXT
- && cmd->scan_begin_src != TRIG_FOLLOW)
+ cmd->scan_begin_src != TRIG_EXT
+ && cmd->scan_begin_src != TRIG_FOLLOW)
err++;
if (cmd->convert_src != TRIG_TIMER &&
- cmd->convert_src != TRIG_EXT && cmd->convert_src != TRIG_NOW)
+ cmd->convert_src != TRIG_EXT && cmd->convert_src != TRIG_NOW)
err++;
if (cmd->stop_src != TRIG_COUNT && cmd->stop_src != TRIG_NONE)
err++;
@@ -1965,21 +2024,21 @@ static int s626_ai_cmdtest(struct comedi_device *dev, struct comedi_subdevice *s
if (cmd->scan_begin_src == TRIG_TIMER) {
tmp = cmd->scan_begin_arg;
s626_ns_to_timer((int *)&cmd->scan_begin_arg,
- cmd->flags & TRIG_ROUND_MASK);
+ cmd->flags & TRIG_ROUND_MASK);
if (tmp != cmd->scan_begin_arg)
err++;
}
if (cmd->convert_src == TRIG_TIMER) {
tmp = cmd->convert_arg;
s626_ns_to_timer((int *)&cmd->convert_arg,
- cmd->flags & TRIG_ROUND_MASK);
+ cmd->flags & TRIG_ROUND_MASK);
if (tmp != cmd->convert_arg)
err++;
if (cmd->scan_begin_src == TRIG_TIMER &&
- cmd->scan_begin_arg <
- cmd->convert_arg * cmd->scan_end_arg) {
+ cmd->scan_begin_arg <
+ cmd->convert_arg * cmd->scan_end_arg) {
cmd->scan_begin_arg =
- cmd->convert_arg * cmd->scan_end_arg;
+ cmd->convert_arg * cmd->scan_end_arg;
err++;
}
}
@@ -2032,7 +2091,7 @@ static int s626_ns_to_timer(int *nanosec, int round_mode)
}
static int s626_ao_winsn(struct comedi_device *dev, struct comedi_subdevice *s,
- struct comedi_insn *insn, unsigned int *data)
+ struct comedi_insn *insn, unsigned int *data)
{
int i;
@@ -2051,7 +2110,7 @@ static int s626_ao_winsn(struct comedi_device *dev, struct comedi_subdevice *s,
}
static int s626_ao_rinsn(struct comedi_device *dev, struct comedi_subdevice *s,
- struct comedi_insn *insn, unsigned int *data)
+ struct comedi_insn *insn, unsigned int *data)
{
int i;
@@ -2096,8 +2155,9 @@ static void s626_dio_init(struct comedi_device *dev)
* This allows packed reading/writing of the DIO channels. The comedi
* core can convert between insn_bits and insn_read/write */
-static int s626_dio_insn_bits(struct comedi_device *dev, struct comedi_subdevice *s,
- struct comedi_insn *insn, unsigned int *data)
+static int s626_dio_insn_bits(struct comedi_device *dev,
+ struct comedi_subdevice *s,
+ struct comedi_insn *insn, unsigned int *data)
{
/* Length of data must be 2 (mask and new data, see below) */
@@ -2105,7 +2165,9 @@ static int s626_dio_insn_bits(struct comedi_device *dev, struct comedi_subdevice
return 0;
if (insn->n != 2) {
- printk("comedi%d: s626: s626_dio_insn_bits(): Invalid instruction length\n", dev->minor);
+ printk
+ ("comedi%d: s626: s626_dio_insn_bits(): Invalid instruction length\n",
+ dev->minor);
return -EINVAL;
}
@@ -2132,16 +2194,17 @@ static int s626_dio_insn_bits(struct comedi_device *dev, struct comedi_subdevice
return 2;
}
-static int s626_dio_insn_config(struct comedi_device *dev, struct comedi_subdevice *s,
- struct comedi_insn *insn, unsigned int *data)
+static int s626_dio_insn_config(struct comedi_device *dev,
+ struct comedi_subdevice *s,
+ struct comedi_insn *insn, unsigned int *data)
{
switch (data[0]) {
case INSN_CONFIG_DIO_QUERY:
data[1] =
- (s->io_bits & (1 << CR_CHAN(insn->
- chanspec))) ? COMEDI_OUTPUT :
- COMEDI_INPUT;
+ (s->
+ io_bits & (1 << CR_CHAN(insn->chanspec))) ? COMEDI_OUTPUT :
+ COMEDI_INPUT;
return insn->n;
break;
case COMEDI_INPUT:
@@ -2169,50 +2232,55 @@ static int s626_dio_set_irq(struct comedi_device *dev, unsigned int chan)
group = chan / 16;
bitmask = 1 << (chan - (16 * group));
DEBUG("s626_dio_set_irq: enable interrupt on dio channel %d group %d\n",
- chan - (16 * group), group);
+ chan - (16 * group), group);
/* set channel to capture positive edge */
status = DEBIread(dev,
- ((struct dio_private *) (dev->subdevices + 2 +
- group)->private)->RDEdgSel);
+ ((struct dio_private *)(dev->subdevices + 2 +
+ group)->private)->RDEdgSel);
DEBIwrite(dev,
- ((struct dio_private *) (dev->subdevices + 2 +
- group)->private)->WREdgSel, bitmask | status);
+ ((struct dio_private *)(dev->subdevices + 2 +
+ group)->private)->WREdgSel,
+ bitmask | status);
/* enable interrupt on selected channel */
status = DEBIread(dev,
- ((struct dio_private *) (dev->subdevices + 2 +
- group)->private)->RDIntSel);
+ ((struct dio_private *)(dev->subdevices + 2 +
+ group)->private)->RDIntSel);
DEBIwrite(dev,
- ((struct dio_private *) (dev->subdevices + 2 +
- group)->private)->WRIntSel, bitmask | status);
+ ((struct dio_private *)(dev->subdevices + 2 +
+ group)->private)->WRIntSel,
+ bitmask | status);
/* enable edge capture write command */
DEBIwrite(dev, LP_MISC1, MISC1_EDCAP);
/* enable edge capture on selected channel */
status = DEBIread(dev,
- ((struct dio_private *) (dev->subdevices + 2 +
- group)->private)->RDCapSel);
+ ((struct dio_private *)(dev->subdevices + 2 +
+ group)->private)->RDCapSel);
DEBIwrite(dev,
- ((struct dio_private *) (dev->subdevices + 2 +
- group)->private)->WRCapSel, bitmask | status);
+ ((struct dio_private *)(dev->subdevices + 2 +
+ group)->private)->WRCapSel,
+ bitmask | status);
return 0;
}
static int s626_dio_reset_irq(struct comedi_device *dev, unsigned int group,
- unsigned int mask)
+ unsigned int mask)
{
- DEBUG("s626_dio_reset_irq: disable interrupt on dio channel %d group %d\n", mask, group);
+ DEBUG
+ ("s626_dio_reset_irq: disable interrupt on dio channel %d group %d\n",
+ mask, group);
/* disable edge capture write command */
DEBIwrite(dev, LP_MISC1, MISC1_NOEDCAP);
/* enable edge capture on selected channel */
DEBIwrite(dev,
- ((struct dio_private *) (dev->subdevices + 2 +
- group)->private)->WRCapSel, mask);
+ ((struct dio_private *)(dev->subdevices + 2 +
+ group)->private)->WRCapSel, mask);
return 0;
}
@@ -2227,8 +2295,9 @@ static int s626_dio_clear_irq(struct comedi_device *dev)
for (group = 0; group < S626_DIO_BANKS; group++) {
/* clear pending events and interrupt */
DEBIwrite(dev,
- ((struct dio_private *) (dev->subdevices + 2 +
- group)->private)->WRCapSel, 0xffff);
+ ((struct dio_private *)(dev->subdevices + 2 +
+ group)->private)->WRCapSel,
+ 0xffff);
}
return 0;
@@ -2237,17 +2306,18 @@ static int s626_dio_clear_irq(struct comedi_device *dev)
/* Now this function initializes the value of the counter (data[0])
and set the subdevice. To complete with trigger and interrupt
configuration */
-static int s626_enc_insn_config(struct comedi_device *dev, struct comedi_subdevice *s,
- struct comedi_insn *insn, unsigned int *data)
+static int s626_enc_insn_config(struct comedi_device *dev,
+ struct comedi_subdevice *s,
+ struct comedi_insn *insn, unsigned int *data)
{
uint16_t Setup = (LOADSRC_INDX << BF_LOADSRC) | /* Preload upon */
- /* index. */
- (INDXSRC_SOFT << BF_INDXSRC) | /* Disable hardware index. */
- (CLKSRC_COUNTER << BF_CLKSRC) | /* Operating mode is Counter. */
- (CLKPOL_POS << BF_CLKPOL) | /* Active high clock. */
- /* ( CNTDIR_UP << BF_CLKPOL ) | // Count direction is Down. */
- (CLKMULT_1X << BF_CLKMULT) | /* Clock multiplier is 1x. */
- (CLKENAB_INDEX << BF_CLKENAB);
+ /* index. */
+ (INDXSRC_SOFT << BF_INDXSRC) | /* Disable hardware index. */
+ (CLKSRC_COUNTER << BF_CLKSRC) | /* Operating mode is Counter. */
+ (CLKPOL_POS << BF_CLKPOL) | /* Active high clock. */
+ /* ( CNTDIR_UP << BF_CLKPOL ) | // Count direction is Down. */
+ (CLKMULT_1X << BF_CLKMULT) | /* Clock multiplier is 1x. */
+ (CLKENAB_INDEX << BF_CLKENAB);
/* uint16_t DisableIntSrc=TRUE; */
/* uint32_t Preloadvalue; //Counter initial value */
uint16_t valueSrclatch = LATCHSRC_AB_READ;
@@ -2267,15 +2337,16 @@ static int s626_enc_insn_config(struct comedi_device *dev, struct comedi_subdevi
return insn->n;
}
-static int s626_enc_insn_read(struct comedi_device *dev, struct comedi_subdevice *s,
- struct comedi_insn *insn, unsigned int *data)
+static int s626_enc_insn_read(struct comedi_device *dev,
+ struct comedi_subdevice *s,
+ struct comedi_insn *insn, unsigned int *data)
{
int n;
struct enc_private *k = &encpriv[CR_CHAN(insn->chanspec)];
DEBUG("s626_enc_insn_read: encoder read channel %d \n",
- CR_CHAN(insn->chanspec));
+ CR_CHAN(insn->chanspec));
for (n = 0; n < insn->n; n++)
data[n] = ReadLatch(dev, k);
@@ -2285,14 +2356,15 @@ static int s626_enc_insn_read(struct comedi_device *dev, struct comedi_subdevice
return n;
}
-static int s626_enc_insn_write(struct comedi_device *dev, struct comedi_subdevice *s,
- struct comedi_insn *insn, unsigned int *data)
+static int s626_enc_insn_write(struct comedi_device *dev,
+ struct comedi_subdevice *s,
+ struct comedi_insn *insn, unsigned int *data)
{
struct enc_private *k = &encpriv[CR_CHAN(insn->chanspec)];
DEBUG("s626_enc_insn_write: encoder write channel %d \n",
- CR_CHAN(insn->chanspec));
+ CR_CHAN(insn->chanspec));
/* Set the preload register */
Preload(dev, k, data[0]);
@@ -2308,16 +2380,17 @@ static int s626_enc_insn_write(struct comedi_device *dev, struct comedi_subdevic
return 1;
}
-static void s626_timer_load(struct comedi_device *dev, struct enc_private *k, int tick)
+static void s626_timer_load(struct comedi_device *dev, struct enc_private *k,
+ int tick)
{
uint16_t Setup = (LOADSRC_INDX << BF_LOADSRC) | /* Preload upon */
- /* index. */
- (INDXSRC_SOFT << BF_INDXSRC) | /* Disable hardware index. */
- (CLKSRC_TIMER << BF_CLKSRC) | /* Operating mode is Timer. */
- (CLKPOL_POS << BF_CLKPOL) | /* Active high clock. */
- (CNTDIR_DOWN << BF_CLKPOL) | /* Count direction is Down. */
- (CLKMULT_1X << BF_CLKMULT) | /* Clock multiplier is 1x. */
- (CLKENAB_INDEX << BF_CLKENAB);
+ /* index. */
+ (INDXSRC_SOFT << BF_INDXSRC) | /* Disable hardware index. */
+ (CLKSRC_TIMER << BF_CLKSRC) | /* Operating mode is Timer. */
+ (CLKPOL_POS << BF_CLKPOL) | /* Active high clock. */
+ (CNTDIR_DOWN << BF_CLKPOL) | /* Count direction is Down. */
+ (CLKMULT_1X << BF_CLKMULT) | /* Clock multiplier is 1x. */
+ (CLKENAB_INDEX << BF_CLKENAB);
uint16_t valueSrclatch = LATCHSRC_A_INDXA;
/* uint16_t enab=CLKENAB_ALWAYS; */
@@ -2352,7 +2425,7 @@ static uint8_t trimchan[] = { 10, 9, 8, 3, 2, 7, 6, 1, 0, 5, 4 };
/* TrimDac LogicalChan-to-EepromAdrs mapping table. */
static uint8_t trimadrs[] =
- { 0x40, 0x41, 0x42, 0x50, 0x51, 0x52, 0x53, 0x60, 0x61, 0x62, 0x63 };
+ { 0x40, 0x41, 0x42, 0x50, 0x51, 0x52, 0x53, 0x60, 0x61, 0x62, 0x63 };
static void LoadTrimDACs(struct comedi_device *dev)
{
@@ -2364,7 +2437,7 @@ static void LoadTrimDACs(struct comedi_device *dev)
}
static void WriteTrimDAC(struct comedi_device *dev, uint8_t LogicalChan,
- uint8_t DacData)
+ uint8_t DacData)
{
uint32_t chan;
@@ -2411,22 +2484,26 @@ static uint8_t I2Cread(struct comedi_device *dev, uint8_t addr)
/* Send EEPROM target address. */
if (I2Chandshake(dev, I2C_B2(I2C_ATTRSTART, I2CW)
/* Byte2 = I2C command: write to I2C EEPROM device. */
- | I2C_B1(I2C_ATTRSTOP, addr)
+ | I2C_B1(I2C_ATTRSTOP, addr)
/* Byte1 = EEPROM internal target address. */
- | I2C_B0(I2C_ATTRNOP, 0))) { /* Byte0 = Not sent. */
+ | I2C_B0(I2C_ATTRNOP, 0))) { /* Byte0 = Not sent. */
/* Abort function and declare error if handshake failed. */
DEBUG("I2Cread: error handshake I2Cread a\n");
return 0;
}
/* Execute EEPROM read. */
- if (I2Chandshake(dev, I2C_B2(I2C_ATTRSTART, I2CR) /* Byte2 = I2C */
- /* command: read */
- /* from I2C EEPROM */
- /* device. */
- | I2C_B1(I2C_ATTRSTOP, 0) /* Byte1 receives */
- /* uint8_t from */
- /* EEPROM. */
- | I2C_B0(I2C_ATTRNOP, 0))) { /* Byte0 = Not sent. */
+ if (I2Chandshake(dev, I2C_B2(I2C_ATTRSTART, I2CR)
+
+ /* Byte2 = I2C */
+ /* command: read */
+ /* from I2C EEPROM */
+ /* device. */
+ |I2C_B1(I2C_ATTRSTOP, 0)
+
+ /* Byte1 receives */
+ /* uint8_t from */
+ /* EEPROM. */
+ |I2C_B0(I2C_ATTRNOP, 0))) { /* Byte0 = Not sent. */
/* Abort function and declare error if handshake failed. */
DEBUG("I2Cread: error handshake I2Cread b\n");
@@ -2446,12 +2523,10 @@ static uint32_t I2Chandshake(struct comedi_device *dev, uint32_t val)
/* upload confirmation. */
MC_ENABLE(P_MC2, MC2_UPLD_IIC);
- while (!MC_TEST(P_MC2, MC2_UPLD_IIC))
- ;
+ while (!MC_TEST(P_MC2, MC2_UPLD_IIC)) ;
/* Wait until I2C bus transfer is finished or an error occurs. */
- while ((RR7146(P_I2CCTRL) & (I2C_BUSY | I2C_ERR)) == I2C_BUSY)
- ;
+ while ((RR7146(P_I2CCTRL) & (I2C_BUSY | I2C_ERR)) == I2C_BUSY) ;
/* Return non-zero if I2C error occured. */
return RR7146(P_I2CCTRL) & I2C_ERR;
@@ -2565,8 +2640,7 @@ static void SendDAC(struct comedi_device *dev, uint32_t val)
* Done by polling the DMAC enable flag; this flag is automatically
* cleared when the transfer has finished.
*/
- while ((RR7146(P_MC1) & MC1_A2OUT) != 0)
- ;
+ while ((RR7146(P_MC1) & MC1_A2OUT) != 0) ;
/* START THE OUTPUT STREAM TO THE TARGET DAC -------------------- */
@@ -2583,8 +2657,7 @@ static void SendDAC(struct comedi_device *dev, uint32_t val)
* finished transferring the DAC's data DWORD from the output FIFO
* to the output buffer register.
*/
- while ((RR7146(P_SSR) & SSR_AF2_OUT) == 0)
- ;
+ while ((RR7146(P_SSR) & SSR_AF2_OUT) == 0) ;
/* Set up to trap execution at slot 0 when the TSL sequencer cycles
* back to slot 0 after executing the EOS in slot 5. Also,
@@ -2620,8 +2693,7 @@ static void SendDAC(struct comedi_device *dev, uint32_t val)
* from 0xFF to 0x00, which slot 0 causes to happen by shifting
* out/in on SD2 the 0x00 that is always referenced by slot 5.
*/
- while ((RR7146(P_FB_BUFFER2) & 0xFF000000) != 0)
- ;
+ while ((RR7146(P_FB_BUFFER2) & 0xFF000000) != 0) ;
}
/* Either (1) we were too late setting the slot 0 trap; the TSL
* sequencer restarted slot 0 before we could set the EOS trap flag,
@@ -2637,8 +2709,7 @@ static void SendDAC(struct comedi_device *dev, uint32_t val)
* the next DAC write. This is detected when FB_BUFFER2 MSB changes
* from 0x00 to 0xFF.
*/
- while ((RR7146(P_FB_BUFFER2) & 0xFF000000) == 0)
- ;
+ while ((RR7146(P_FB_BUFFER2) & 0xFF000000) == 0) ;
}
static void WriteMISC2(struct comedi_device *dev, uint16_t NewImage)
@@ -2677,12 +2748,10 @@ static void DEBItransfer(struct comedi_device *dev)
/* Wait for completion of upload from shadow RAM to DEBI control */
/* register. */
- while (!MC_TEST(P_MC2, MC2_UPLD_DEBI))
- ;
+ while (!MC_TEST(P_MC2, MC2_UPLD_DEBI)) ;
/* Wait until DEBI transfer is done. */
- while (RR7146(P_PSR) & PSR_DEBI_S)
- ;
+ while (RR7146(P_PSR) & PSR_DEBI_S) ;
}
/* Write a value to a gate array register. */
@@ -2702,7 +2771,7 @@ static void DEBIwrite(struct comedi_device *dev, uint16_t addr, uint16_t wdata)
* or'd with the masked original.
*/
static void DEBIreplace(struct comedi_device *dev, uint16_t addr, uint16_t mask,
- uint16_t wdata)
+ uint16_t wdata)
{
/* Copy target gate array register into P_DEBIAD register. */
@@ -2719,7 +2788,8 @@ static void DEBIreplace(struct comedi_device *dev, uint16_t addr, uint16_t mask,
DEBItransfer(dev); /* Execute the DEBI Write transfer. */
}
-static void CloseDMAB(struct comedi_device *dev, struct bufferDMA *pdma, size_t bsize)
+static void CloseDMAB(struct comedi_device *dev, struct bufferDMA *pdma,
+ size_t bsize)
{
void *vbptr;
dma_addr_t vpptr;
@@ -2737,7 +2807,7 @@ static void CloseDMAB(struct comedi_device *dev, struct bufferDMA *pdma, size_t
pdma->PhysicalBase = 0;
DEBUG("CloseDMAB(): Logical=%p, bsize=%d, Physical=0x%x\n",
- vbptr, bsize, (uint32_t) vpptr);
+ vbptr, bsize, (uint32_t) vpptr);
}
}
@@ -2776,13 +2846,13 @@ static uint32_t ReadLatch(struct comedi_device *dev, struct enc_private *k)
static void ResetCapFlags_A(struct comedi_device *dev, struct enc_private *k)
{
DEBIreplace(dev, k->MyCRB, (uint16_t) (~CRBMSK_INTCTRL),
- CRBMSK_INTRESETCMD | CRBMSK_INTRESET_A);
+ CRBMSK_INTRESETCMD | CRBMSK_INTRESET_A);
}
static void ResetCapFlags_B(struct comedi_device *dev, struct enc_private *k)
{
DEBIreplace(dev, k->MyCRB, (uint16_t) (~CRBMSK_INTCTRL),
- CRBMSK_INTRESETCMD | CRBMSK_INTRESET_B);
+ CRBMSK_INTRESETCMD | CRBMSK_INTRESET_B);
}
/* Return counter setup in a format (COUNTER_SETUP) that is consistent */
@@ -2801,26 +2871,25 @@ static uint16_t GetMode_A(struct comedi_device *dev, struct enc_private *k)
/* Populate the standardized counter setup bit fields. Note: */
/* IndexSrc is restricted to ENC_X or IndxPol. */
setup = ((cra & STDMSK_LOADSRC) /* LoadSrc = LoadSrcA. */
- | ((crb << (STDBIT_LATCHSRC - CRBBIT_LATCHSRC)) & STDMSK_LATCHSRC) /* LatchSrc = LatchSrcA. */
- | ((cra << (STDBIT_INTSRC - CRABIT_INTSRC_A)) & STDMSK_INTSRC) /* IntSrc = IntSrcA. */
- | ((cra << (STDBIT_INDXSRC - (CRABIT_INDXSRC_A + 1))) & STDMSK_INDXSRC) /* IndxSrc = IndxSrcA<1>. */
- | ((cra >> (CRABIT_INDXPOL_A - STDBIT_INDXPOL)) & STDMSK_INDXPOL) /* IndxPol = IndxPolA. */
- | ((crb >> (CRBBIT_CLKENAB_A - STDBIT_CLKENAB)) & STDMSK_CLKENAB)); /* ClkEnab = ClkEnabA. */
+ |((crb << (STDBIT_LATCHSRC - CRBBIT_LATCHSRC)) & STDMSK_LATCHSRC) /* LatchSrc = LatchSrcA. */
+ |((cra << (STDBIT_INTSRC - CRABIT_INTSRC_A)) & STDMSK_INTSRC) /* IntSrc = IntSrcA. */
+ |((cra << (STDBIT_INDXSRC - (CRABIT_INDXSRC_A + 1))) & STDMSK_INDXSRC) /* IndxSrc = IndxSrcA<1>. */
+ |((cra >> (CRABIT_INDXPOL_A - STDBIT_INDXPOL)) & STDMSK_INDXPOL) /* IndxPol = IndxPolA. */
+ |((crb >> (CRBBIT_CLKENAB_A - STDBIT_CLKENAB)) & STDMSK_CLKENAB)); /* ClkEnab = ClkEnabA. */
/* Adjust mode-dependent parameters. */
if (cra & (2 << CRABIT_CLKSRC_A)) /* If Timer mode (ClkSrcA<1> == 1): */
setup |= ((CLKSRC_TIMER << STDBIT_CLKSRC) /* Indicate Timer mode. */
- | ((cra << (STDBIT_CLKPOL - CRABIT_CLKSRC_A)) & STDMSK_CLKPOL) /* Set ClkPol to indicate count direction (ClkSrcA<0>). */
- | (MULT_X1 << STDBIT_CLKMULT)); /* ClkMult must be 1x in Timer mode. */
+ |((cra << (STDBIT_CLKPOL - CRABIT_CLKSRC_A)) & STDMSK_CLKPOL) /* Set ClkPol to indicate count direction (ClkSrcA<0>). */
+ |(MULT_X1 << STDBIT_CLKMULT)); /* ClkMult must be 1x in Timer mode. */
else /* If Counter mode (ClkSrcA<1> == 0): */
setup |= ((CLKSRC_COUNTER << STDBIT_CLKSRC) /* Indicate Counter mode. */
- | ((cra >> (CRABIT_CLKPOL_A - STDBIT_CLKPOL)) & STDMSK_CLKPOL) /* Pass through ClkPol. */
- | (((cra & CRAMSK_CLKMULT_A) == (MULT_X0 << CRABIT_CLKMULT_A)) ? /* Force ClkMult to 1x if not legal, else pass through. */
- (MULT_X1 << STDBIT_CLKMULT) :
- ((cra >> (CRABIT_CLKMULT_A -
- STDBIT_CLKMULT)) &
- STDMSK_CLKMULT)));
+ |((cra >> (CRABIT_CLKPOL_A - STDBIT_CLKPOL)) & STDMSK_CLKPOL) /* Pass through ClkPol. */
+ |(((cra & CRAMSK_CLKMULT_A) == (MULT_X0 << CRABIT_CLKMULT_A)) ? /* Force ClkMult to 1x if not legal, else pass through. */
+ (MULT_X1 << STDBIT_CLKMULT) :
+ ((cra >> (CRABIT_CLKMULT_A -
+ STDBIT_CLKMULT)) & STDMSK_CLKMULT)));
/* Return adjusted counter setup. */
return setup;
@@ -2839,27 +2908,27 @@ static uint16_t GetMode_B(struct comedi_device *dev, struct enc_private *k)
/* Populate the standardized counter setup bit fields. Note: */
/* IndexSrc is restricted to ENC_X or IndxPol. */
setup = (((crb << (STDBIT_INTSRC - CRBBIT_INTSRC_B)) & STDMSK_INTSRC) /* IntSrc = IntSrcB. */
- | ((crb << (STDBIT_LATCHSRC - CRBBIT_LATCHSRC)) & STDMSK_LATCHSRC) /* LatchSrc = LatchSrcB. */
- | ((crb << (STDBIT_LOADSRC - CRBBIT_LOADSRC_B)) & STDMSK_LOADSRC) /* LoadSrc = LoadSrcB. */
- | ((crb << (STDBIT_INDXPOL - CRBBIT_INDXPOL_B)) & STDMSK_INDXPOL) /* IndxPol = IndxPolB. */
- | ((crb >> (CRBBIT_CLKENAB_B - STDBIT_CLKENAB)) & STDMSK_CLKENAB) /* ClkEnab = ClkEnabB. */
- | ((cra >> ((CRABIT_INDXSRC_B + 1) - STDBIT_INDXSRC)) & STDMSK_INDXSRC)); /* IndxSrc = IndxSrcB<1>. */
+ |((crb << (STDBIT_LATCHSRC - CRBBIT_LATCHSRC)) & STDMSK_LATCHSRC) /* LatchSrc = LatchSrcB. */
+ |((crb << (STDBIT_LOADSRC - CRBBIT_LOADSRC_B)) & STDMSK_LOADSRC) /* LoadSrc = LoadSrcB. */
+ |((crb << (STDBIT_INDXPOL - CRBBIT_INDXPOL_B)) & STDMSK_INDXPOL) /* IndxPol = IndxPolB. */
+ |((crb >> (CRBBIT_CLKENAB_B - STDBIT_CLKENAB)) & STDMSK_CLKENAB) /* ClkEnab = ClkEnabB. */
+ |((cra >> ((CRABIT_INDXSRC_B + 1) - STDBIT_INDXSRC)) & STDMSK_INDXSRC)); /* IndxSrc = IndxSrcB<1>. */
/* Adjust mode-dependent parameters. */
if ((crb & CRBMSK_CLKMULT_B) == (MULT_X0 << CRBBIT_CLKMULT_B)) /* If Extender mode (ClkMultB == MULT_X0): */
setup |= ((CLKSRC_EXTENDER << STDBIT_CLKSRC) /* Indicate Extender mode. */
- | (MULT_X1 << STDBIT_CLKMULT) /* Indicate multiplier is 1x. */
- | ((cra >> (CRABIT_CLKSRC_B - STDBIT_CLKPOL)) & STDMSK_CLKPOL)); /* Set ClkPol equal to Timer count direction (ClkSrcB<0>). */
+ |(MULT_X1 << STDBIT_CLKMULT) /* Indicate multiplier is 1x. */
+ |((cra >> (CRABIT_CLKSRC_B - STDBIT_CLKPOL)) & STDMSK_CLKPOL)); /* Set ClkPol equal to Timer count direction (ClkSrcB<0>). */
else if (cra & (2 << CRABIT_CLKSRC_B)) /* If Timer mode (ClkSrcB<1> == 1): */
setup |= ((CLKSRC_TIMER << STDBIT_CLKSRC) /* Indicate Timer mode. */
- | (MULT_X1 << STDBIT_CLKMULT) /* Indicate multiplier is 1x. */
- | ((cra >> (CRABIT_CLKSRC_B - STDBIT_CLKPOL)) & STDMSK_CLKPOL)); /* Set ClkPol equal to Timer count direction (ClkSrcB<0>). */
+ |(MULT_X1 << STDBIT_CLKMULT) /* Indicate multiplier is 1x. */
+ |((cra >> (CRABIT_CLKSRC_B - STDBIT_CLKPOL)) & STDMSK_CLKPOL)); /* Set ClkPol equal to Timer count direction (ClkSrcB<0>). */
else /* If Counter mode (ClkSrcB<1> == 0): */
setup |= ((CLKSRC_COUNTER << STDBIT_CLKSRC) /* Indicate Timer mode. */
- | ((crb >> (CRBBIT_CLKMULT_B - STDBIT_CLKMULT)) & STDMSK_CLKMULT) /* Clock multiplier is passed through. */
- | ((crb << (STDBIT_CLKPOL - CRBBIT_CLKPOL_B)) & STDMSK_CLKPOL)); /* Clock polarity is passed through. */
+ |((crb >> (CRBBIT_CLKMULT_B - STDBIT_CLKMULT)) & STDMSK_CLKMULT) /* Clock multiplier is passed through. */
+ |((crb << (STDBIT_CLKPOL - CRBBIT_CLKPOL_B)) & STDMSK_CLKPOL)); /* Clock polarity is passed through. */
/* Return adjusted counter setup. */
return setup;
@@ -2872,8 +2941,8 @@ static uint16_t GetMode_B(struct comedi_device *dev, struct enc_private *k)
* ClkPol, ClkEnab, IndexSrc, IndexPol, LoadSrc.
*/
-static void SetMode_A(struct comedi_device *dev, struct enc_private *k, uint16_t Setup,
- uint16_t DisableIntSrc)
+static void SetMode_A(struct comedi_device *dev, struct enc_private *k,
+ uint16_t Setup, uint16_t DisableIntSrc)
{
register uint16_t cra;
register uint16_t crb;
@@ -2881,15 +2950,15 @@ static void SetMode_A(struct comedi_device *dev, struct enc_private *k, uint16_t
/* Initialize CRA and CRB images. */
cra = ((setup & CRAMSK_LOADSRC_A) /* Preload trigger is passed through. */
- | ((setup & STDMSK_INDXSRC) >> (STDBIT_INDXSRC - (CRABIT_INDXSRC_A + 1)))); /* IndexSrc is restricted to ENC_X or IndxPol. */
+ |((setup & STDMSK_INDXSRC) >> (STDBIT_INDXSRC - (CRABIT_INDXSRC_A + 1)))); /* IndexSrc is restricted to ENC_X or IndxPol. */
crb = (CRBMSK_INTRESETCMD | CRBMSK_INTRESET_A /* Reset any pending CounterA event captures. */
- | ((setup & STDMSK_CLKENAB) << (CRBBIT_CLKENAB_A - STDBIT_CLKENAB))); /* Clock enable is passed through. */
+ | ((setup & STDMSK_CLKENAB) << (CRBBIT_CLKENAB_A - STDBIT_CLKENAB))); /* Clock enable is passed through. */
/* Force IntSrc to Disabled if DisableIntSrc is asserted. */
if (!DisableIntSrc)
cra |= ((setup & STDMSK_INTSRC) >> (STDBIT_INTSRC -
- CRABIT_INTSRC_A));
+ CRABIT_INTSRC_A));
/* Populate all mode-dependent attributes of CRA & CRB images. */
switch ((setup & STDMSK_CLKSRC) >> STDBIT_CLKSRC) {
@@ -2898,25 +2967,25 @@ static void SetMode_A(struct comedi_device *dev, struct enc_private *k, uint16_t
case CLKSRC_TIMER: /* Timer Mode: */
cra |= ((2 << CRABIT_CLKSRC_A) /* ClkSrcA<1> selects system clock */
- | ((setup & STDMSK_CLKPOL) >> (STDBIT_CLKPOL - CRABIT_CLKSRC_A)) /* with count direction (ClkSrcA<0>) obtained from ClkPol. */
- | (1 << CRABIT_CLKPOL_A) /* ClkPolA behaves as always-on clock enable. */
- | (MULT_X1 << CRABIT_CLKMULT_A)); /* ClkMult must be 1x. */
+ |((setup & STDMSK_CLKPOL) >> (STDBIT_CLKPOL - CRABIT_CLKSRC_A)) /* with count direction (ClkSrcA<0>) obtained from ClkPol. */
+ |(1 << CRABIT_CLKPOL_A) /* ClkPolA behaves as always-on clock enable. */
+ |(MULT_X1 << CRABIT_CLKMULT_A)); /* ClkMult must be 1x. */
break;
default: /* Counter Mode: */
cra |= (CLKSRC_COUNTER /* Select ENC_C and ENC_D as clock/direction inputs. */
| ((setup & STDMSK_CLKPOL) << (CRABIT_CLKPOL_A - STDBIT_CLKPOL)) /* Clock polarity is passed through. */
- | (((setup & STDMSK_CLKMULT) == (MULT_X0 << STDBIT_CLKMULT)) ? /* Force multiplier to x1 if not legal, otherwise pass through. */
- (MULT_X1 << CRABIT_CLKMULT_A) :
- ((setup & STDMSK_CLKMULT) << (CRABIT_CLKMULT_A -
- STDBIT_CLKMULT))));
+ |(((setup & STDMSK_CLKMULT) == (MULT_X0 << STDBIT_CLKMULT)) ? /* Force multiplier to x1 if not legal, otherwise pass through. */
+ (MULT_X1 << CRABIT_CLKMULT_A) :
+ ((setup & STDMSK_CLKMULT) << (CRABIT_CLKMULT_A -
+ STDBIT_CLKMULT))));
}
/* Force positive index polarity if IndxSrc is software-driven only, */
/* otherwise pass it through. */
if (~setup & STDMSK_INDXSRC)
cra |= ((setup & STDMSK_INDXPOL) << (CRABIT_INDXPOL_A -
- STDBIT_INDXPOL));
+ STDBIT_INDXPOL));
/* If IntSrc has been forced to Disabled, update the MISC2 interrupt */
/* enable mask to indicate the counter interrupt is disabled. */
@@ -2927,11 +2996,11 @@ static void SetMode_A(struct comedi_device *dev, struct enc_private *k, uint16_t
/* new counter operating mode. */
DEBIreplace(dev, k->MyCRA, CRAMSK_INDXSRC_B | CRAMSK_CLKSRC_B, cra);
DEBIreplace(dev, k->MyCRB,
- (uint16_t) (~(CRBMSK_INTCTRL | CRBMSK_CLKENAB_A)), crb);
+ (uint16_t) (~(CRBMSK_INTCTRL | CRBMSK_CLKENAB_A)), crb);
}
-static void SetMode_B(struct comedi_device *dev, struct enc_private *k, uint16_t Setup,
- uint16_t DisableIntSrc)
+static void SetMode_B(struct comedi_device *dev, struct enc_private *k,
+ uint16_t Setup, uint16_t DisableIntSrc)
{
register uint16_t cra;
register uint16_t crb;
@@ -2941,44 +3010,44 @@ static void SetMode_B(struct comedi_device *dev, struct enc_private *k, uint16_t
cra = ((setup & STDMSK_INDXSRC) << ((CRABIT_INDXSRC_B + 1) - STDBIT_INDXSRC)); /* IndexSrc field is restricted to ENC_X or IndxPol. */
crb = (CRBMSK_INTRESETCMD | CRBMSK_INTRESET_B /* Reset event captures and disable interrupts. */
- | ((setup & STDMSK_CLKENAB) << (CRBBIT_CLKENAB_B - STDBIT_CLKENAB)) /* Clock enable is passed through. */
- | ((setup & STDMSK_LOADSRC) >> (STDBIT_LOADSRC - CRBBIT_LOADSRC_B))); /* Preload trigger source is passed through. */
+ | ((setup & STDMSK_CLKENAB) << (CRBBIT_CLKENAB_B - STDBIT_CLKENAB)) /* Clock enable is passed through. */
+ |((setup & STDMSK_LOADSRC) >> (STDBIT_LOADSRC - CRBBIT_LOADSRC_B))); /* Preload trigger source is passed through. */
/* Force IntSrc to Disabled if DisableIntSrc is asserted. */
if (!DisableIntSrc)
crb |= ((setup & STDMSK_INTSRC) >> (STDBIT_INTSRC -
- CRBBIT_INTSRC_B));
+ CRBBIT_INTSRC_B));
/* Populate all mode-dependent attributes of CRA & CRB images. */
switch ((setup & STDMSK_CLKSRC) >> STDBIT_CLKSRC) {
case CLKSRC_TIMER: /* Timer Mode: */
cra |= ((2 << CRABIT_CLKSRC_B) /* ClkSrcB<1> selects system clock */
- | ((setup & STDMSK_CLKPOL) << (CRABIT_CLKSRC_B - STDBIT_CLKPOL))); /* with direction (ClkSrcB<0>) obtained from ClkPol. */
+ |((setup & STDMSK_CLKPOL) << (CRABIT_CLKSRC_B - STDBIT_CLKPOL))); /* with direction (ClkSrcB<0>) obtained from ClkPol. */
crb |= ((1 << CRBBIT_CLKPOL_B) /* ClkPolB behaves as always-on clock enable. */
- | (MULT_X1 << CRBBIT_CLKMULT_B)); /* ClkMultB must be 1x. */
+ |(MULT_X1 << CRBBIT_CLKMULT_B)); /* ClkMultB must be 1x. */
break;
case CLKSRC_EXTENDER: /* Extender Mode: */
cra |= ((2 << CRABIT_CLKSRC_B) /* ClkSrcB source is OverflowA (same as "timer") */
- | ((setup & STDMSK_CLKPOL) << (CRABIT_CLKSRC_B - STDBIT_CLKPOL))); /* with direction obtained from ClkPol. */
+ |((setup & STDMSK_CLKPOL) << (CRABIT_CLKSRC_B - STDBIT_CLKPOL))); /* with direction obtained from ClkPol. */
crb |= ((1 << CRBBIT_CLKPOL_B) /* ClkPolB controls IndexB -- always set to active. */
- | (MULT_X0 << CRBBIT_CLKMULT_B)); /* ClkMultB selects OverflowA as the clock source. */
+ |(MULT_X0 << CRBBIT_CLKMULT_B)); /* ClkMultB selects OverflowA as the clock source. */
break;
default: /* Counter Mode: */
cra |= (CLKSRC_COUNTER << CRABIT_CLKSRC_B); /* Select ENC_C and ENC_D as clock/direction inputs. */
crb |= (((setup & STDMSK_CLKPOL) >> (STDBIT_CLKPOL - CRBBIT_CLKPOL_B)) /* ClkPol is passed through. */
- | (((setup & STDMSK_CLKMULT) == (MULT_X0 << STDBIT_CLKMULT)) ? /* Force ClkMult to x1 if not legal, otherwise pass through. */
- (MULT_X1 << CRBBIT_CLKMULT_B) :
- ((setup & STDMSK_CLKMULT) << (CRBBIT_CLKMULT_B -
- STDBIT_CLKMULT))));
+ |(((setup & STDMSK_CLKMULT) == (MULT_X0 << STDBIT_CLKMULT)) ? /* Force ClkMult to x1 if not legal, otherwise pass through. */
+ (MULT_X1 << CRBBIT_CLKMULT_B) :
+ ((setup & STDMSK_CLKMULT) << (CRBBIT_CLKMULT_B -
+ STDBIT_CLKMULT))));
}
/* Force positive index polarity if IndxSrc is software-driven only, */
/* otherwise pass it through. */
if (~setup & STDMSK_INDXSRC)
crb |= ((setup & STDMSK_INDXPOL) >> (STDBIT_INDXPOL -
- CRBBIT_INDXPOL_B));
+ CRBBIT_INDXPOL_B));
/* If IntSrc has been forced to Disabled, update the MISC2 interrupt */
/* enable mask to indicate the counter interrupt is disabled. */
@@ -2988,25 +3057,27 @@ static void SetMode_B(struct comedi_device *dev, struct enc_private *k, uint16_t
/* While retaining CounterA and LatchSrc configurations, program the */
/* new counter operating mode. */
DEBIreplace(dev, k->MyCRA,
- (uint16_t) (~(CRAMSK_INDXSRC_B | CRAMSK_CLKSRC_B)), cra);
+ (uint16_t) (~(CRAMSK_INDXSRC_B | CRAMSK_CLKSRC_B)), cra);
DEBIreplace(dev, k->MyCRB, CRBMSK_CLKENAB_A | CRBMSK_LATCHSRC, crb);
}
/* Return/set a counter's enable. enab: 0=always enabled, 1=enabled by index. */
-static void SetEnable_A(struct comedi_device *dev, struct enc_private *k, uint16_t enab)
+static void SetEnable_A(struct comedi_device *dev, struct enc_private *k,
+ uint16_t enab)
{
DEBUG("SetEnable_A: SetEnable_A enter 3541\n");
DEBIreplace(dev, k->MyCRB,
- (uint16_t) (~(CRBMSK_INTCTRL | CRBMSK_CLKENAB_A)),
- (uint16_t) (enab << CRBBIT_CLKENAB_A));
+ (uint16_t) (~(CRBMSK_INTCTRL | CRBMSK_CLKENAB_A)),
+ (uint16_t) (enab << CRBBIT_CLKENAB_A));
}
-static void SetEnable_B(struct comedi_device *dev, struct enc_private *k, uint16_t enab)
+static void SetEnable_B(struct comedi_device *dev, struct enc_private *k,
+ uint16_t enab)
{
DEBIreplace(dev, k->MyCRB,
- (uint16_t) (~(CRBMSK_INTCTRL | CRBMSK_CLKENAB_B)),
- (uint16_t) (enab << CRBBIT_CLKENAB_B));
+ (uint16_t) (~(CRBMSK_INTCTRL | CRBMSK_CLKENAB_B)),
+ (uint16_t) (enab << CRBBIT_CLKENAB_B));
}
static uint16_t GetEnable_A(struct comedi_device *dev, struct enc_private *k)
@@ -3024,12 +3095,13 @@ static uint16_t GetEnable_B(struct comedi_device *dev, struct enc_private *k)
* latches B.
*/
-static void SetLatchSource(struct comedi_device *dev, struct enc_private *k, uint16_t value)
+static void SetLatchSource(struct comedi_device *dev, struct enc_private *k,
+ uint16_t value)
{
DEBUG("SetLatchSource: SetLatchSource enter 3550 \n");
DEBIreplace(dev, k->MyCRB,
- (uint16_t) (~(CRBMSK_INTCTRL | CRBMSK_LATCHSRC)),
- (uint16_t) (value << CRBBIT_LATCHSRC));
+ (uint16_t) (~(CRBMSK_INTCTRL | CRBMSK_LATCHSRC)),
+ (uint16_t) (value << CRBBIT_LATCHSRC));
DEBUG("SetLatchSource: SetLatchSource exit \n");
}
@@ -3047,17 +3119,19 @@ static void SetLatchSource(struct comedi_device *dev, struct enc_private *k, uin
* 2=OverflowA (B counters only), 3=disabled.
*/
-static void SetLoadTrig_A(struct comedi_device *dev, struct enc_private *k, uint16_t Trig)
+static void SetLoadTrig_A(struct comedi_device *dev, struct enc_private *k,
+ uint16_t Trig)
{
DEBIreplace(dev, k->MyCRA, (uint16_t) (~CRAMSK_LOADSRC_A),
- (uint16_t) (Trig << CRABIT_LOADSRC_A));
+ (uint16_t) (Trig << CRABIT_LOADSRC_A));
}
-static void SetLoadTrig_B(struct comedi_device *dev, struct enc_private *k, uint16_t Trig)
+static void SetLoadTrig_B(struct comedi_device *dev, struct enc_private *k,
+ uint16_t Trig)
{
DEBIreplace(dev, k->MyCRB,
- (uint16_t) (~(CRBMSK_LOADSRC_B | CRBMSK_INTCTRL)),
- (uint16_t) (Trig << CRBBIT_LOADSRC_B));
+ (uint16_t) (~(CRBMSK_LOADSRC_B | CRBMSK_INTCTRL)),
+ (uint16_t) (Trig << CRBBIT_LOADSRC_B));
}
static uint16_t GetLoadTrig_A(struct comedi_device *dev, struct enc_private *k)
@@ -3076,24 +3150,24 @@ static uint16_t GetLoadTrig_B(struct comedi_device *dev, struct enc_private *k)
*/
static void SetIntSrc_A(struct comedi_device *dev, struct enc_private *k,
- uint16_t IntSource)
+ uint16_t IntSource)
{
/* Reset any pending counter overflow or index captures. */
DEBIreplace(dev, k->MyCRB, (uint16_t) (~CRBMSK_INTCTRL),
- CRBMSK_INTRESETCMD | CRBMSK_INTRESET_A);
+ CRBMSK_INTRESETCMD | CRBMSK_INTRESET_A);
/* Program counter interrupt source. */
DEBIreplace(dev, k->MyCRA, ~CRAMSK_INTSRC_A,
- (uint16_t) (IntSource << CRABIT_INTSRC_A));
+ (uint16_t) (IntSource << CRABIT_INTSRC_A));
/* Update MISC2 interrupt enable mask. */
devpriv->CounterIntEnabs =
- (devpriv->CounterIntEnabs & ~k->MyEventBits[3]) | k->
- MyEventBits[IntSource];
+ (devpriv->CounterIntEnabs & ~k->
+ MyEventBits[3]) | k->MyEventBits[IntSource];
}
static void SetIntSrc_B(struct comedi_device *dev, struct enc_private *k,
- uint16_t IntSource)
+ uint16_t IntSource)
{
uint16_t crb;
@@ -3102,17 +3176,17 @@ static void SetIntSrc_B(struct comedi_device *dev, struct enc_private *k,
/* Reset any pending counter overflow or index captures. */
DEBIwrite(dev, k->MyCRB,
- (uint16_t) (crb | CRBMSK_INTRESETCMD | CRBMSK_INTRESET_B));
+ (uint16_t) (crb | CRBMSK_INTRESETCMD | CRBMSK_INTRESET_B));
/* Program counter interrupt source. */
DEBIwrite(dev, k->MyCRB,
- (uint16_t) ((crb & ~CRBMSK_INTSRC_B) | (IntSource <<
- CRBBIT_INTSRC_B)));
+ (uint16_t) ((crb & ~CRBMSK_INTSRC_B) | (IntSource <<
+ CRBBIT_INTSRC_B)));
/* Update MISC2 interrupt enable mask. */
devpriv->CounterIntEnabs =
- (devpriv->CounterIntEnabs & ~k->MyEventBits[3]) | k->
- MyEventBits[IntSource];
+ (devpriv->CounterIntEnabs & ~k->
+ MyEventBits[3]) | k->MyEventBits[IntSource];
}
static uint16_t GetIntSrc_A(struct comedi_device *dev, struct enc_private *k)
@@ -3211,13 +3285,14 @@ static void PulseIndex_B(struct comedi_device *dev, struct enc_private *k)
/* Write value into counter preload register. */
-static void Preload(struct comedi_device *dev, struct enc_private *k, uint32_t value)
+static void Preload(struct comedi_device *dev, struct enc_private *k,
+ uint32_t value)
{
DEBUG("Preload: preload enter\n");
DEBIwrite(dev, (uint16_t) (k->MyLatchLsw), (uint16_t) value); /* Write value to preload register. */
DEBUG("Preload: preload step 1\n");
DEBIwrite(dev, (uint16_t) (k->MyLatchLsw + 2),
- (uint16_t) (value >> 16));
+ (uint16_t) (value >> 16));
}
static void CountersInit(struct comedi_device *dev)
@@ -3225,13 +3300,13 @@ static void CountersInit(struct comedi_device *dev)
int chan;
struct enc_private *k;
uint16_t Setup = (LOADSRC_INDX << BF_LOADSRC) | /* Preload upon */
- /* index. */
- (INDXSRC_SOFT << BF_INDXSRC) | /* Disable hardware index. */
- (CLKSRC_COUNTER << BF_CLKSRC) | /* Operating mode is counter. */
- (CLKPOL_POS << BF_CLKPOL) | /* Active high clock. */
- (CNTDIR_UP << BF_CLKPOL) | /* Count direction is up. */
- (CLKMULT_1X << BF_CLKMULT) | /* Clock multiplier is 1x. */
- (CLKENAB_INDEX << BF_CLKENAB); /* Enabled by index */
+ /* index. */
+ (INDXSRC_SOFT << BF_INDXSRC) | /* Disable hardware index. */
+ (CLKSRC_COUNTER << BF_CLKSRC) | /* Operating mode is counter. */
+ (CLKPOL_POS << BF_CLKPOL) | /* Active high clock. */
+ (CNTDIR_UP << BF_CLKPOL) | /* Count direction is up. */
+ (CLKMULT_1X << BF_CLKMULT) | /* Clock multiplier is 1x. */
+ (CLKENAB_INDEX << BF_CLKENAB); /* Enabled by index */
/* Disable all counter interrupts and clear any captured counter events. */
for (chan = 0; chan < S626_ENCODER_CHANNELS; chan++) {
diff --git a/drivers/staging/comedi/drivers/s626.h b/drivers/staging/comedi/drivers/s626.h
index 27ae02be5300..1d04922ea16c 100644
--- a/drivers/staging/comedi/drivers/s626.h
+++ b/drivers/staging/comedi/drivers/s626.h
@@ -134,17 +134,17 @@
#define DAC_WDMABUF_OS ADC_DMABUF_DWORDS
/* Interrupt enab bit in ISR and IER. */
-#define IRQ_GPIO3 0x00000040 /* IRQ enable for GPIO3. */
+#define IRQ_GPIO3 0x00000040 /* IRQ enable for GPIO3. */
#define IRQ_RPS1 0x10000000
#define ISR_AFOU 0x00000800
/* Audio fifo under/overflow detected. */
-#define IRQ_COINT1A 0x0400 /* conter 1A overflow interrupt mask */
-#define IRQ_COINT1B 0x0800 /* conter 1B overflow interrupt mask */
-#define IRQ_COINT2A 0x1000 /* conter 2A overflow interrupt mask */
-#define IRQ_COINT2B 0x2000 /* conter 2B overflow interrupt mask */
-#define IRQ_COINT3A 0x4000 /* conter 3A overflow interrupt mask */
-#define IRQ_COINT3B 0x8000 /* conter 3B overflow interrupt mask */
+#define IRQ_COINT1A 0x0400 /* conter 1A overflow interrupt mask */
+#define IRQ_COINT1B 0x0800 /* conter 1B overflow interrupt mask */
+#define IRQ_COINT2A 0x1000 /* conter 2A overflow interrupt mask */
+#define IRQ_COINT2B 0x2000 /* conter 2B overflow interrupt mask */
+#define IRQ_COINT3A 0x4000 /* conter 3A overflow interrupt mask */
+#define IRQ_COINT3B 0x8000 /* conter 3B overflow interrupt mask */
/* RPS command codes. */
#define RPS_CLRSIGNAL 0x00000000 /* CLEAR SIGNAL */
@@ -438,7 +438,6 @@
/* tri-state. */
#define EOS 0x00000001 /* End of superframe. */
-
/* I2C configuration constants. */
#define I2C_CLKSEL 0x0400
/* I2C bit rate = PCIclk/480 = 68.75 KHz. */
@@ -729,7 +728,6 @@
#define STDMSK_CLKMULT ((uint16_t)(3 << STDBIT_CLKMULT))
#define STDMSK_CLKENAB ((uint16_t)(1 << STDBIT_CLKENAB))
-
/* typedef struct indexCounter */
/* { */
/* unsigned int ao; */
diff --git a/drivers/staging/comedi/drivers/serial2002.c b/drivers/staging/comedi/drivers/serial2002.c
index db18b11b9d30..a21967983942 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"}
};
/*
@@ -67,7 +67,6 @@ struct serial2002_range_table_t {
struct comedi_krange range;
};
-
struct serial2002_private {
int port; /* /dev/ttyS<port> */
@@ -82,14 +81,14 @@ struct serial2002_private {
struct serial2002_range_table_t in_range[32], out_range[32];
};
-
/*
* most drivers define the following macro to make it easy to
* access the private structure.
*/
#define devpriv ((struct serial2002_private *)dev->private)
-static int serial2002_attach(struct comedi_device *dev, struct comedi_devconfig *it);
+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",
@@ -101,16 +100,21 @@ struct comedi_driver driver_serial2002 = {
.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;
@@ -184,28 +188,28 @@ static int tty_read(struct file *f, int timeout)
mask = f->f_op->poll(f, &table.pt);
if (mask & (POLLRDNORM | POLLRDBAND | POLLIN |
- POLLHUP | POLLERR)) {
+ POLLHUP | POLLERR)) {
break;
}
do_gettimeofday(&now);
elapsed =
- (1000000 * (now.tv_sec - start.tv_sec) +
- now.tv_usec - start.tv_usec);
+ (1000000 * (now.tv_sec - start.tv_sec) +
+ now.tv_usec - start.tv_usec);
if (elapsed > timeout) {
break;
}
set_current_state(TASK_INTERRUPTIBLE);
schedule_timeout(((timeout -
- elapsed) * HZ) / 10000);
+ elapsed) * HZ) / 10000);
}
poll_freewait(&table);
{
- unsigned char ch;
+ unsigned char ch;
- f->f_pos = 0;
- if (f->f_op->read(f, &ch, 1, &f->f_pos) == 1) {
- result = ch;
- }
+ f->f_pos = 0;
+ if (f->f_op->read(f, &ch, 1, &f->f_pos) == 1) {
+ result = ch;
+ }
}
} else {
/* Device does not support poll, busy wait */
@@ -348,8 +352,7 @@ static struct serial_data serial_read(struct file *f, int timeout)
}
} else {
result.value =
- (result.
- value << 2) | ((data & 0x60) >> 5);
+ (result.value << 2) | ((data & 0x60) >> 5);
result.kind = is_channel;
}
result.index = data & 0x1f;
@@ -364,7 +367,7 @@ static void serial_write(struct file *f, struct serial_data data)
{
if (data.kind == is_digital) {
unsigned char ch =
- ((data.value << 5) & 0x20) | (data.index & 0x1f);
+ ((data.value << 5) & 0x20) | (data.index & 0x1f);
tty_write(f, &ch, 1);
} else {
unsigned char ch[6];
@@ -401,7 +404,7 @@ static void serial_2002_open(struct comedi_device *dev)
devpriv->tty = filp_open(port, 0, O_RDWR);
if (IS_ERR(devpriv->tty)) {
printk("serial_2002: file open error = %ld\n",
- PTR_ERR(devpriv->tty));
+ PTR_ERR(devpriv->tty));
} else {
struct config_t {
@@ -443,7 +446,7 @@ static void serial_2002_open(struct comedi_device *dev)
data = serial_read(devpriv->tty, 1000);
if (data.kind != is_channel || data.index != 31
- || !(data.value & 0xe0)) {
+ || !(data.value & 0xe0)) {
break;
} else {
int command, channel, kind;
@@ -479,77 +482,92 @@ static void serial_2002_open(struct comedi_device *dev)
cur_config[channel].kind = kind;
switch (command) {
case 0:{
- cur_config[channel].
- bits =
- (data.
- value >> 10) &
- 0x3f;
+ cur_config[channel].bits
+ =
+ (data.value >> 10) &
+ 0x3f;
}
break;
case 1:{
int unit, sign, min;
- unit = (data.
- value >> 10) &
- 0x7;
- sign = (data.
- value >> 13) &
- 0x1;
- min = (data.
- value >> 14) &
- 0xfffff;
+ unit =
+ (data.value >> 10) &
+ 0x7;
+ sign =
+ (data.value >> 13) &
+ 0x1;
+ min =
+ (data.value >> 14) &
+ 0xfffff;
switch (unit) {
case 0:{
- min = min * 1000000;
+ min =
+ min
+ *
+ 1000000;
}
break;
case 1:{
- min = min * 1000;
+ min =
+ min
+ *
+ 1000;
}
break;
case 2:{
- min = min * 1;
+ min =
+ min
+ * 1;
}
break;
}
if (sign) {
min = -min;
}
- cur_config[channel].
- min = min;
+ cur_config[channel].min
+ = min;
}
break;
case 2:{
int unit, sign, max;
- unit = (data.
- value >> 10) &
- 0x7;
- sign = (data.
- value >> 13) &
- 0x1;
- max = (data.
- value >> 14) &
- 0xfffff;
+ unit =
+ (data.value >> 10) &
+ 0x7;
+ sign =
+ (data.value >> 13) &
+ 0x1;
+ max =
+ (data.value >> 14) &
+ 0xfffff;
switch (unit) {
case 0:{
- max = max * 1000000;
+ max =
+ max
+ *
+ 1000000;
}
break;
case 1:{
- max = max * 1000;
+ max =
+ max
+ *
+ 1000;
}
break;
case 2:{
- max = max * 1;
+ max =
+ max
+ * 1;
}
break;
}
if (sign) {
max = -max;
}
- cur_config[channel].
- max = max;
+ cur_config[channel].max
+ = max;
}
break;
}
@@ -604,7 +622,8 @@ static void serial_2002_open(struct comedi_device *dev)
}
if (c) {
struct comedi_subdevice *s;
- const struct comedi_lrange **range_table_list = NULL;
+ const struct comedi_lrange **range_table_list =
+ NULL;
unsigned int *maxdata_list;
int j, chan;
@@ -620,17 +639,18 @@ static void serial_2002_open(struct comedi_device *dev)
kfree(s->maxdata_list);
}
s->maxdata_list = maxdata_list =
- kmalloc(sizeof(unsigned int) * s->n_chan,
- GFP_KERNEL);
+ kmalloc(sizeof(unsigned int) * s->n_chan,
+ GFP_KERNEL);
if (s->range_table_list) {
kfree(s->range_table_list);
}
if (range) {
s->range_table = 0;
s->range_table_list = range_table_list =
- kmalloc(sizeof
- (struct serial2002_range_table_t) *
- s->n_chan, GFP_KERNEL);
+ kmalloc(sizeof
+ (struct
+ serial2002_range_table_t) *
+ s->n_chan, GFP_KERNEL);
}
for (chan = 0, j = 0; j < 32; j++) {
if (c[j].kind == kind) {
@@ -640,17 +660,17 @@ static void serial_2002_open(struct comedi_device *dev)
if (range) {
range[j].length = 1;
range[j].range.min =
- c[j].min;
+ c[j].min;
range[j].range.max =
- c[j].max;
+ c[j].max;
range_table_list[chan] =
- (const struct
- comedi_lrange *)
- &range[j];
+ (const struct
+ comedi_lrange *)
+ &range[j];
}
maxdata_list[chan] =
- ((long long)1 << c[j].
- bits) - 1;
+ ((long long)1 << c[j].bits)
+ - 1;
chan++;
}
}
@@ -666,8 +686,9 @@ static void serial_2002_close(struct comedi_device *dev)
}
}
-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 +709,9 @@ static int serial2002_di_rinsn(struct comedi_device *dev, struct comedi_subdevic
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 +728,9 @@ static int serial2002_do_winsn(struct comedi_device *dev, struct comedi_subdevic
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 +751,9 @@ static int serial2002_ai_rinsn(struct comedi_device *dev, struct comedi_subdevic
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 +771,9 @@ static int serial2002_ao_winsn(struct comedi_device *dev, struct comedi_subdevic
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 +785,9 @@ static int serial2002_ao_rinsn(struct comedi_device *dev, struct comedi_subdevic
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 +808,8 @@ static int serial2002_ei_rinsn(struct comedi_device *dev, struct comedi_subdevic
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;
diff --git a/drivers/staging/comedi/drivers/skel.c b/drivers/staging/comedi/drivers/skel.c
index 07f580a48206..3dee62aa2d7b 100644
--- a/drivers/staging/comedi/drivers/skel.c
+++ b/drivers/staging/comedi/drivers/skel.c
@@ -97,17 +97,17 @@ 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,
+ },
};
/* This is used by modprobe to translate PCI IDs to drivers. Should
@@ -116,9 +116,10 @@ static const struct skel_board skel_boards[] = {
* upstream. */
#define PCI_VENDOR_ID_SKEL 0xdafe
static DEFINE_PCI_DEVICE_TABLE(skel_pci_table) = {
- {PCI_VENDOR_ID_SKEL, 0x0100, PCI_ANY_ID, PCI_ANY_ID, 0, 0, 0},
- {PCI_VENDOR_ID_SKEL, 0x0200, PCI_ANY_ID, PCI_ANY_ID, 0, 0, 0},
- {0}
+ {
+ PCI_VENDOR_ID_SKEL, 0x0100, PCI_ANY_ID, PCI_ANY_ID, 0, 0, 0}, {
+ PCI_VENDOR_ID_SKEL, 0x0200, PCI_ANY_ID, PCI_ANY_ID, 0, 0, 0}, {
+ 0}
};
MODULE_DEVICE_TABLE(pci, skel_pci_table);
@@ -185,17 +186,19 @@ static struct comedi_driver driver_skel = {
};
static int skel_ai_rinsn(struct comedi_device *dev, struct comedi_subdevice *s,
- struct comedi_insn *insn, unsigned int *data);
+ 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);
+ 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);
+ 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);
/*
@@ -304,7 +307,7 @@ static int skel_detach(struct comedi_device *dev)
* mode.
*/
static int skel_ai_rinsn(struct comedi_device *dev, struct comedi_subdevice *s,
- struct comedi_insn *insn, unsigned int *data)
+ struct comedi_insn *insn, unsigned int *data)
{
int n, i;
unsigned int d;
@@ -351,8 +354,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;
@@ -398,7 +401,7 @@ static int skel_ai_cmdtest(struct comedi_device *dev, struct comedi_subdevice *s
/* note that mutual compatiblity is not an issue here */
if (cmd->scan_begin_src != TRIG_TIMER &&
- cmd->scan_begin_src != TRIG_EXT)
+ cmd->scan_begin_src != TRIG_EXT)
err++;
if (cmd->convert_src != TRIG_TIMER && cmd->convert_src != TRIG_EXT)
err++;
@@ -478,21 +481,21 @@ static int skel_ai_cmdtest(struct comedi_device *dev, struct comedi_subdevice *s
if (cmd->scan_begin_src == TRIG_TIMER) {
tmp = cmd->scan_begin_arg;
skel_ns_to_timer(&cmd->scan_begin_arg,
- cmd->flags & TRIG_ROUND_MASK);
+ cmd->flags & TRIG_ROUND_MASK);
if (tmp != cmd->scan_begin_arg)
err++;
}
if (cmd->convert_src == TRIG_TIMER) {
tmp = cmd->convert_arg;
skel_ns_to_timer(&cmd->convert_arg,
- cmd->flags & TRIG_ROUND_MASK);
+ cmd->flags & TRIG_ROUND_MASK);
if (tmp != cmd->convert_arg)
err++;
if (cmd->scan_begin_src == TRIG_TIMER &&
- cmd->scan_begin_arg <
- cmd->convert_arg * cmd->scan_end_arg) {
+ cmd->scan_begin_arg <
+ cmd->convert_arg * cmd->scan_end_arg) {
cmd->scan_begin_arg =
- cmd->convert_arg * cmd->scan_end_arg;
+ cmd->convert_arg * cmd->scan_end_arg;
err++;
}
}
@@ -521,7 +524,7 @@ static int skel_ns_to_timer(unsigned int *ns, int round)
}
static int skel_ao_winsn(struct comedi_device *dev, struct comedi_subdevice *s,
- struct comedi_insn *insn, unsigned int *data)
+ struct comedi_insn *insn, unsigned int *data)
{
int i;
int chan = CR_CHAN(insn->chanspec);
@@ -542,7 +545,7 @@ 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)
+ struct comedi_insn *insn, unsigned int *data)
{
int i;
int chan = CR_CHAN(insn->chanspec);
@@ -558,8 +561,9 @@ 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 +587,9 @@ static int skel_dio_insn_bits(struct comedi_device *dev, struct comedi_subdevice
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);
@@ -601,8 +606,7 @@ static int skel_dio_insn_config(struct comedi_device *dev, struct comedi_subdevi
break;
case INSN_CONFIG_DIO_QUERY:
data[1] =
- (s->
- io_bits & (1 << chan)) ? COMEDI_OUTPUT : COMEDI_INPUT;
+ (s->io_bits & (1 << chan)) ? COMEDI_OUTPUT : COMEDI_INPUT;
return insn->n;
break;
default:
diff --git a/drivers/staging/comedi/drivers/ssv_dnp.c b/drivers/staging/comedi/drivers/ssv_dnp.c
index 13c29bb99100..4918fbfab5e8 100644
--- a/drivers/staging/comedi/drivers/ssv_dnp.c
+++ b/drivers/staging/comedi/drivers/ssv_dnp.c
@@ -61,11 +61,11 @@ 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,
+ },
};
/* Useful for shorthand access to the particular board structure ----------- */
@@ -76,7 +76,6 @@ struct dnp_private_data {
};
-
/* Shorthand macro for faster access to the private data ------------------- */
#define devpriv ((dnp_private *)dev->private)
@@ -98,17 +97,19 @@ static struct comedi_driver driver_dnp = {
.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. */
+ .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);
+ 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);
+ struct comedi_subdevice *s,
+ struct comedi_insn *insn, unsigned int *data);
/* ------------------------------------------------------------------------- */
/* Attach is called by comedi core to configure the driver for a particular */
@@ -202,7 +203,8 @@ static int dnp_detach(struct comedi_device *dev)
/* ------------------------------------------------------------------------- */
static int dnp_dio_insn_bits(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)
{
if (insn->n != 2)
@@ -219,18 +221,18 @@ static int dnp_dio_insn_bits(struct comedi_device *dev,
outb(PADR, CSCIR);
outb((inb(CSCDR)
- & ~(u8) (data[0] & 0x0000FF))
- | (u8) (data[1] & 0x0000FF), CSCDR);
+ & ~(u8) (data[0] & 0x0000FF))
+ | (u8) (data[1] & 0x0000FF), CSCDR);
outb(PBDR, CSCIR);
outb((inb(CSCDR)
- & ~(u8) ((data[0] & 0x00FF00) >> 8))
- | (u8) ((data[1] & 0x00FF00) >> 8), CSCDR);
+ & ~(u8) ((data[0] & 0x00FF00) >> 8))
+ | (u8) ((data[1] & 0x00FF00) >> 8), CSCDR);
outb(PCDR, CSCIR);
outb((inb(CSCDR)
- & ~(u8) ((data[0] & 0x0F0000) >> 12))
- | (u8) ((data[1] & 0x0F0000) >> 12), CSCDR);
+ & ~(u8) ((data[0] & 0x0F0000) >> 12))
+ | (u8) ((data[1] & 0x0F0000) >> 12), CSCDR);
}
/* on return, data[1] contains the value of the digital input lines. */
@@ -252,7 +254,8 @@ static int dnp_dio_insn_bits(struct comedi_device *dev,
/* ------------------------------------------------------------------------- */
static int dnp_dio_insn_config(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)
{
u8 register_buffer;
@@ -265,8 +268,7 @@ static int dnp_dio_insn_config(struct comedi_device *dev,
break;
case INSN_CONFIG_DIO_QUERY:
data[1] =
- (inb(CSCDR) & (1 << chan)) ? COMEDI_OUTPUT :
- COMEDI_INPUT;
+ (inb(CSCDR) & (1 << chan)) ? COMEDI_OUTPUT : COMEDI_INPUT;
return insn->n;
break;
default:
diff --git a/drivers/staging/comedi/drivers/unioxx5.c b/drivers/staging/comedi/drivers/unioxx5.c
index 96bb15ccccb1..75a9a62e1a70 100644
--- a/drivers/staging/comedi/drivers/unioxx5.c
+++ b/drivers/staging/comedi/drivers/unioxx5.c
@@ -80,25 +80,29 @@ 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_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,
- int channel, int minor);
-static int __unioxx5_digital_read(struct unioxx5_subd_priv *usp, unsigned int *data,
- int channel, int minor);
+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, int channel, int minor);
+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,
- int channel, int minor);
-static int __unioxx5_analog_read(struct unioxx5_subd_priv *usp, unsigned int *data,
- int channel, int minor);
+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, 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);
@@ -111,7 +115,8 @@ static struct comedi_driver unioxx5_driver = {
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;
@@ -136,7 +141,7 @@ static int unioxx5_attach(struct comedi_device *dev, struct comedi_devconfig *it
/* unioxx5 can has from two to four subdevices */
if (n_subd < 2) {
printk(KERN_ERR
- "your card must has at least 2 'g01' subdevices\n");
+ "your card must has at least 2 'g01' subdevices\n");
return -1;
}
@@ -148,7 +153,7 @@ static int unioxx5_attach(struct comedi_device *dev, struct comedi_devconfig *it
/* initializing each of for same subdevices */
for (i = 0; i < n_subd; i++, iobase += UNIOXX5_SUBDEV_ODDS) {
if (__unioxx5_subdev_init(&dev->subdevices[i], iobase,
- dev->minor) < 0)
+ dev->minor) < 0)
return -1;
}
@@ -156,8 +161,9 @@ static int unioxx5_attach(struct comedi_device *dev, struct comedi_devconfig *it
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 +182,9 @@ static int unioxx5_subdev_read(struct comedi_device *dev, struct comedi_subdevic
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 +204,9 @@ static int unioxx5_subdev_write(struct comedi_device *dev, struct comedi_subdevi
}
/* 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;
@@ -208,16 +216,16 @@ static int unioxx5_insn_config(struct comedi_device *dev, struct comedi_subdevic
if (type != MODULE_DIGITAL) {
printk(KERN_ERR
- "comedi%d: channel configuration accessible only for digital modules\n",
- dev->minor);
+ "comedi%d: channel configuration accessible only for digital modules\n",
+ dev->minor);
return -1;
}
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);
+ "comedi%d: undefined channel %d. channel range is 0 .. 23\n",
+ dev->minor, channel);
return -1;
}
@@ -265,8 +273,8 @@ 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,
- int minor)
+static int __unioxx5_subdev_init(struct comedi_subdevice *subdev,
+ int subdev_iobase, int minor)
{
struct unioxx5_subd_priv *usp;
int i, to, ndef_flag = 0;
@@ -276,7 +284,7 @@ static int __unioxx5_subdev_init(struct comedi_subdevice *subdev, int subdev_iob
return -EIO;
}
- usp = (struct unioxx5_subd_priv *) kzalloc(sizeof(*usp), GFP_KERNEL);
+ usp = (struct unioxx5_subd_priv *)kzalloc(sizeof(*usp), GFP_KERNEL);
if (usp == NULL) {
printk(KERN_ERR "comedi%d: erorr! --> out of memory!\n", minor);
@@ -332,8 +340,8 @@ static int __unioxx5_subdev_init(struct comedi_subdevice *subdev, int subdev_iob
return 0;
}
-static int __unioxx5_digital_write(struct unioxx5_subd_priv *usp, unsigned int *data,
- int channel, int minor)
+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);
@@ -341,8 +349,8 @@ static int __unioxx5_digital_write(struct unioxx5_subd_priv *usp, unsigned int *
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);
+ "comedi%d: undefined channel %d. channel range is 0 .. 23\n",
+ minor, channel);
return 0;
}
@@ -360,16 +368,16 @@ 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,
- int channel, int minor)
+static int __unioxx5_digital_read(struct unioxx5_subd_priv *usp,
+ unsigned int *data, int channel, int minor)
{
int channel_offset, mask = 1 << (channel & 0x07);
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);
+ "comedi%d: undefined channel %d. channel range is 0 .. 23\n",
+ minor, channel);
return 0;
}
@@ -400,8 +408,8 @@ 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,
- int channel, int minor)
+static int __unioxx5_analog_write(struct unioxx5_subd_priv *usp,
+ unsigned int *data, int channel, int minor)
{
int module, i;
@@ -411,8 +419,8 @@ static int __unioxx5_analog_write(struct unioxx5_subd_priv *usp, unsigned int *d
/* defining if given module can work on output */
if (!(usp->usp_module_type[module] & MODULE_OUTPUT_MASK)) {
printk(KERN_ERR
- "comedi%d: module in position %d with id 0x%0x is for input only!\n",
- minor, module, usp->usp_module_type[module]);
+ "comedi%d: module in position %d with id 0x%0x is for input only!\n",
+ minor, module, usp->usp_module_type[module]);
return 0;
}
@@ -435,8 +443,8 @@ static int __unioxx5_analog_write(struct unioxx5_subd_priv *usp, unsigned int *d
return 1;
}
-static int __unioxx5_analog_read(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, int channel, int minor)
{
int module_no, read_ch;
char control;
@@ -447,8 +455,8 @@ static int __unioxx5_analog_read(struct unioxx5_subd_priv *usp, unsigned int *da
/* defining if given module can work on input */
if (usp->usp_module_type[module_no] & MODULE_OUTPUT_MASK) {
printk(KERN_ERR
- "comedi%d: module in position %d with id 0x%02x is for output only",
- minor, module_no, usp->usp_module_type[module_no]);
+ "comedi%d: module in position %d with id 0x%02x is for output only",
+ minor, module_no, usp->usp_module_type[module_no]);
return 0;
}
diff --git a/drivers/staging/comedi/drivers/usbdux.c b/drivers/staging/comedi/drivers/usbdux.c
index 171a6f2ff74f..cca4e869f0ec 100644
--- a/drivers/staging/comedi/drivers/usbdux.c
+++ b/drivers/staging/comedi/drivers/usbdux.c
@@ -215,17 +215,23 @@ sampling rate. If you sample two channels you get 4kHz and so on.
/**************************************************/
/* comedi constants */
static const struct comedi_lrange range_usbdux_ai_range = { 4, {
- BIP_RANGE(4.096),
- BIP_RANGE(4.096 / 2),
- UNI_RANGE(4.096),
- UNI_RANGE(4.096 / 2)
- }
+ BIP_RANGE
+ (4.096),
+ BIP_RANGE(4.096
+ / 2),
+ UNI_RANGE
+ (4.096),
+ UNI_RANGE(4.096
+ / 2)
+ }
};
static const struct comedi_lrange range_usbdux_ao_range = { 2, {
- BIP_RANGE(4.096),
- UNI_RANGE(4.096),
- }
+ BIP_RANGE
+ (4.096),
+ UNI_RANGE
+ (4.096),
+ }
};
/*
@@ -363,7 +369,8 @@ static int usbdux_ai_stop(struct usbduxsub *this_usbduxsub, int do_unlink)
* This will cancel a running acquisition operation.
* This is called by comedi but never from inside the driver.
*/
-static int usbdux_ai_cancel(struct comedi_device *dev, struct comedi_subdevice *s)
+static int usbdux_ai_cancel(struct comedi_device *dev,
+ struct comedi_subdevice *s)
{
struct usbduxsub *this_usbduxsub;
int res = 0;
@@ -407,7 +414,7 @@ static void usbduxsub_ai_IsocIrq(struct urb *urb)
case 0:
/* copy the result in the transfer buffer */
memcpy(this_usbduxsub->inBuffer,
- urb->transfer_buffer, SIZEINBUF);
+ urb->transfer_buffer, SIZEINBUF);
break;
case -EILSEQ:
/* error in the ISOchronous data */
@@ -510,13 +517,12 @@ static void usbduxsub_ai_IsocIrq(struct urb *urb)
/* transfer data */
if (CR_RANGE(s->async->cmd.chanlist[i]) <= 1) {
err = comedi_buf_put
- (s->async,
- le16_to_cpu(this_usbduxsub->
- inBuffer[i]) ^ 0x800);
+ (s->async,
+ le16_to_cpu(this_usbduxsub->inBuffer[i]) ^ 0x800);
} else {
err = comedi_buf_put
- (s->async,
- le16_to_cpu(this_usbduxsub->inBuffer[i]));
+ (s->async,
+ le16_to_cpu(this_usbduxsub->inBuffer[i]));
}
if (unlikely(err == 0)) {
/* buffer overflow */
@@ -566,7 +572,8 @@ static int usbdux_ao_stop(struct usbduxsub *this_usbduxsub, int do_unlink)
}
/* force unlink, is called by comedi */
-static int usbdux_ao_cancel(struct comedi_device *dev, struct comedi_subdevice *s)
+static int usbdux_ao_cancel(struct comedi_device *dev,
+ struct comedi_subdevice *s)
{
struct usbduxsub *this_usbduxsub = dev->private;
int res = 0;
@@ -659,7 +666,7 @@ static void usbduxsub_ao_IsocIrq(struct urb *urb)
}
/* transmit data to the USB bus */
((uint8_t *) (urb->transfer_buffer))[0] =
- s->async->cmd.chanlist_len;
+ s->async->cmd.chanlist_len;
for (i = 0; i < s->async->cmd.chanlist_len; i++) {
short temp;
if (i >= NUMOUTCHANNELS)
@@ -667,7 +674,7 @@ static void usbduxsub_ao_IsocIrq(struct urb *urb)
/* pointer to the DA */
datap =
- (&(((int8_t *)urb->transfer_buffer)[i * 3 + 1]));
+ (&(((int8_t *) urb->transfer_buffer)[i * 3 + 1]));
/* get the data from comedi */
ret = comedi_buf_get(s->async, &temp);
datap[0] = temp;
@@ -783,32 +790,30 @@ static int usbduxsub_stop(struct usbduxsub *usbduxsub)
}
static int usbduxsub_upload(struct usbduxsub *usbduxsub,
- uint8_t *local_transfer_buffer,
+ uint8_t * local_transfer_buffer,
unsigned int startAddr, unsigned int len)
{
int errcode;
errcode = usb_control_msg(usbduxsub->usbdev,
- usb_sndctrlpipe(usbduxsub->usbdev, 0),
- /* brequest, firmware */
- USBDUXSUB_FIRMWARE,
- /* bmRequestType */
- VENDOR_DIR_OUT,
- /* value */
- startAddr,
- /* index */
- 0x0000,
- /* our local safe buffer */
- local_transfer_buffer,
- /* length */
- len,
- /* timeout */
- EZTIMEOUT);
- dev_dbg(&usbduxsub->interface->dev,
- "comedi_: result=%d\n", errcode);
+ usb_sndctrlpipe(usbduxsub->usbdev, 0),
+ /* brequest, firmware */
+ USBDUXSUB_FIRMWARE,
+ /* bmRequestType */
+ VENDOR_DIR_OUT,
+ /* value */
+ startAddr,
+ /* index */
+ 0x0000,
+ /* our local safe buffer */
+ local_transfer_buffer,
+ /* length */
+ len,
+ /* timeout */
+ EZTIMEOUT);
+ dev_dbg(&usbduxsub->interface->dev, "comedi_: result=%d\n", errcode);
if (errcode < 0) {
- dev_err(&usbduxsub->interface->dev,
- "comedi_: upload failed\n");
+ dev_err(&usbduxsub->interface->dev, "comedi_: upload failed\n");
return errcode;
}
return 0;
@@ -817,8 +822,7 @@ static int usbduxsub_upload(struct usbduxsub *usbduxsub,
#define FIRMWARE_MAX_LEN 0x2000
static int firmwareUpload(struct usbduxsub *usbduxsub,
- const u8 *firmwareBinary,
- int sizeFirmware)
+ const u8 * firmwareBinary, int sizeFirmware)
{
int ret;
uint8_t *fwBuf;
@@ -826,7 +830,7 @@ static int firmwareUpload(struct usbduxsub *usbduxsub,
if (!firmwareBinary)
return 0;
- if (sizeFirmware>FIRMWARE_MAX_LEN) {
+ if (sizeFirmware > FIRMWARE_MAX_LEN) {
dev_err(&usbduxsub->interface->dev,
"comedi_: usbdux firmware binary it too large for FX2.\n");
return -ENOMEM;
@@ -839,7 +843,7 @@ static int firmwareUpload(struct usbduxsub *usbduxsub,
"comedi_: mem alloc for firmware failed\n");
return -ENOMEM;
}
- memcpy(fwBuf,firmwareBinary,sizeFirmware);
+ memcpy(fwBuf, firmwareBinary, sizeFirmware);
ret = usbduxsub_stop(usbduxsub);
if (ret < 0) {
@@ -925,8 +929,8 @@ static int usbduxsub_submit_OutURBs(struct usbduxsub *usbduxsub)
return 0;
}
-static int usbdux_ai_cmdtest(struct comedi_device *dev, struct comedi_subdevice *s,
- struct comedi_cmd *cmd)
+static int usbdux_ai_cmdtest(struct comedi_device *dev,
+ struct comedi_subdevice *s, struct comedi_cmd *cmd)
{
int err = 0, tmp, i;
unsigned int tmpTimer;
@@ -978,8 +982,8 @@ static int usbdux_ai_cmdtest(struct comedi_device *dev, struct comedi_subdevice
* note that mutual compatiblity is not an issue here
*/
if (cmd->scan_begin_src != TRIG_FOLLOW &&
- cmd->scan_begin_src != TRIG_EXT &&
- cmd->scan_begin_src != TRIG_TIMER)
+ cmd->scan_begin_src != TRIG_EXT &&
+ cmd->scan_begin_src != TRIG_TIMER)
err++;
if (cmd->stop_src != TRIG_COUNT && cmd->stop_src != TRIG_NONE)
err++;
@@ -1021,8 +1025,8 @@ static int usbdux_ai_cmdtest(struct comedi_device *dev, struct comedi_subdevice
/* now calc the real sampling rate with all the
* rounding errors */
tmpTimer =
- ((unsigned int)(cmd->scan_begin_arg / 125000)) *
- 125000;
+ ((unsigned int)(cmd->scan_begin_arg / 125000)) *
+ 125000;
if (cmd->scan_begin_arg != tmpTimer) {
cmd->scan_begin_arg = tmpTimer;
err++;
@@ -1038,7 +1042,7 @@ static int usbdux_ai_cmdtest(struct comedi_device *dev, struct comedi_subdevice
* calc the real sampling rate with the rounding errors
*/
tmpTimer = ((unsigned int)(cmd->scan_begin_arg /
- 1000000)) * 1000000;
+ 1000000)) * 1000000;
if (cmd->scan_begin_arg != tmpTimer) {
cmd->scan_begin_arg = tmpTimer;
err++;
@@ -1097,7 +1101,7 @@ static int send_dux_commands(struct usbduxsub *this_usbduxsub, int cmd_type)
this_usbduxsub->dux_commands[0] = cmd_type;
#ifdef NOISY_DUX_DEBUGBUG
printk(KERN_DEBUG "comedi%d: usbdux: dux_commands: ",
- this_usbduxsub->comedidev->minor);
+ this_usbduxsub->comedidev->minor);
for (result = 0; result < SIZEOFDUXBUFFER; result++)
printk(" %02x", this_usbduxsub->dux_commands[result]);
printk("\n");
@@ -1145,8 +1149,8 @@ static int receive_dux_commands(struct usbduxsub *this_usbduxsub, int command)
return -EFAULT;
}
-static int usbdux_ai_inttrig(struct comedi_device *dev, struct comedi_subdevice *s,
- unsigned int trignum)
+static int usbdux_ai_inttrig(struct comedi_device *dev,
+ struct comedi_subdevice *s, unsigned int trignum)
{
int ret;
struct usbduxsub *this_usbduxsub = dev->private;
@@ -1231,7 +1235,7 @@ static int usbdux_ai_cmd(struct comedi_device *dev, struct comedi_subdevice *s)
break;
}
this_usbduxsub->dux_commands[i + 2] =
- create_adc_command(chan, range);
+ create_adc_command(chan, range);
}
dev_dbg(&this_usbduxsub->interface->dev,
@@ -1254,10 +1258,11 @@ static int usbdux_ai_cmd(struct comedi_device *dev, struct comedi_subdevice *s)
/* find a power of 2 for the interval */
while ((this_usbduxsub->ai_interval) < (cmd->chanlist_len)) {
this_usbduxsub->ai_interval =
- (this_usbduxsub->ai_interval) * 2;
+ (this_usbduxsub->ai_interval) * 2;
}
this_usbduxsub->ai_timer = cmd->scan_begin_arg / (125000 *
- (this_usbduxsub->ai_interval));
+ (this_usbduxsub->
+ ai_interval));
} else {
/* interval always 1ms */
this_usbduxsub->ai_interval = 1;
@@ -1305,7 +1310,8 @@ static int usbdux_ai_cmd(struct comedi_device *dev, struct comedi_subdevice *s)
}
/* Mode 0 is used to get a single conversion on demand */
-static int usbdux_ai_insn_read(struct comedi_device *dev, struct comedi_subdevice *s,
+static int usbdux_ai_insn_read(struct comedi_device *dev,
+ struct comedi_subdevice *s,
struct comedi_insn *insn, unsigned int *data)
{
int i;
@@ -1366,7 +1372,8 @@ static int usbdux_ai_insn_read(struct comedi_device *dev, struct comedi_subdevic
/************************************/
/* analog out */
-static int usbdux_ao_insn_read(struct comedi_device *dev, struct comedi_subdevice *s,
+static int usbdux_ao_insn_read(struct comedi_device *dev,
+ struct comedi_subdevice *s,
struct comedi_insn *insn, unsigned int *data)
{
int i;
@@ -1388,7 +1395,8 @@ static int usbdux_ao_insn_read(struct comedi_device *dev, struct comedi_subdevic
return i;
}
-static int usbdux_ao_insn_write(struct comedi_device *dev, struct comedi_subdevice *s,
+static int usbdux_ao_insn_write(struct comedi_device *dev,
+ struct comedi_subdevice *s,
struct comedi_insn *insn, unsigned int *data)
{
int i, err;
@@ -1423,7 +1431,7 @@ static int usbdux_ao_insn_write(struct comedi_device *dev, struct comedi_subdevi
this_usbduxsub->dux_commands[1] = 1;
/* one 16 bit value */
*((int16_t *) (this_usbduxsub->dux_commands + 2)) =
- cpu_to_le16(data[i]);
+ cpu_to_le16(data[i]);
this_usbduxsub->outBuffer[chan] = data[i];
/* channel number */
this_usbduxsub->dux_commands[4] = (chan << 6);
@@ -1438,8 +1446,8 @@ static int usbdux_ao_insn_write(struct comedi_device *dev, struct comedi_subdevi
return i;
}
-static int usbdux_ao_inttrig(struct comedi_device *dev, struct comedi_subdevice *s,
- unsigned int trignum)
+static int usbdux_ao_inttrig(struct comedi_device *dev,
+ struct comedi_subdevice *s, unsigned int trignum)
{
int ret;
struct usbduxsub *this_usbduxsub = dev->private;
@@ -1479,8 +1487,8 @@ static int usbdux_ao_inttrig(struct comedi_device *dev, struct comedi_subdevice
return 1;
}
-static int usbdux_ao_cmdtest(struct comedi_device *dev, struct comedi_subdevice *s,
- struct comedi_cmd *cmd)
+static int usbdux_ao_cmdtest(struct comedi_device *dev,
+ struct comedi_subdevice *s, struct comedi_cmd *cmd)
{
int err = 0, tmp;
struct usbduxsub *this_usbduxsub = dev->private;
@@ -1552,8 +1560,8 @@ static int usbdux_ao_cmdtest(struct comedi_device *dev, struct comedi_subdevice
* note that mutual compatiblity is not an issue here
*/
if (cmd->scan_begin_src != TRIG_FOLLOW &&
- cmd->scan_begin_src != TRIG_EXT &&
- cmd->scan_begin_src != TRIG_TIMER)
+ cmd->scan_begin_src != TRIG_EXT &&
+ cmd->scan_begin_src != TRIG_TIMER)
err++;
if (cmd->stop_src != TRIG_COUNT && cmd->stop_src != TRIG_NONE)
err++;
@@ -1690,7 +1698,7 @@ static int usbdux_ao_cmd(struct comedi_device *dev, struct comedi_subdevice *s)
/* high speed also scans everything at once */
if (0) { /* (this_usbduxsub->high_speed) */
this_usbduxsub->ao_sample_count =
- (cmd->stop_arg) * (cmd->scan_end_arg);
+ (cmd->stop_arg) * (cmd->scan_end_arg);
} else {
/* there's no scan as the scan has been */
/* perf inside the FX2 */
@@ -1726,7 +1734,8 @@ static int usbdux_ao_cmd(struct comedi_device *dev, struct comedi_subdevice *s)
return 0;
}
-static int usbdux_dio_insn_config(struct comedi_device *dev, struct comedi_subdevice *s,
+static int usbdux_dio_insn_config(struct comedi_device *dev,
+ struct comedi_subdevice *s,
struct comedi_insn *insn, unsigned int *data)
{
int chan = CR_CHAN(insn->chanspec);
@@ -1745,8 +1754,7 @@ static int usbdux_dio_insn_config(struct comedi_device *dev, struct comedi_subde
break;
case INSN_CONFIG_DIO_QUERY:
data[1] =
- (s->
- io_bits & (1 << chan)) ? COMEDI_OUTPUT : COMEDI_INPUT;
+ (s->io_bits & (1 << chan)) ? COMEDI_OUTPUT : COMEDI_INPUT;
break;
default:
return -EINVAL;
@@ -1757,7 +1765,8 @@ static int usbdux_dio_insn_config(struct comedi_device *dev, struct comedi_subde
return insn->n;
}
-static int usbdux_dio_insn_bits(struct comedi_device *dev, struct comedi_subdevice *s,
+static int usbdux_dio_insn_bits(struct comedi_device *dev,
+ struct comedi_subdevice *s,
struct comedi_insn *insn, unsigned int *data)
{
@@ -1767,7 +1776,6 @@ static int usbdux_dio_insn_bits(struct comedi_device *dev, struct comedi_subdevi
if (!this_usbduxsub)
return -EFAULT;
-
if (insn->n != 2)
return -EINVAL;
@@ -1804,7 +1812,8 @@ static int usbdux_dio_insn_bits(struct comedi_device *dev, struct comedi_subdevi
}
/* reads the 4 counters, only two are used just now */
-static int usbdux_counter_read(struct comedi_device *dev, struct comedi_subdevice *s,
+static int usbdux_counter_read(struct comedi_device *dev,
+ struct comedi_subdevice *s,
struct comedi_insn *insn, unsigned int *data)
{
struct usbduxsub *this_usbduxsub = dev->private;
@@ -1838,7 +1847,8 @@ static int usbdux_counter_read(struct comedi_device *dev, struct comedi_subdevic
return 1;
}
-static int usbdux_counter_write(struct comedi_device *dev, struct comedi_subdevice *s,
+static int usbdux_counter_write(struct comedi_device *dev,
+ struct comedi_subdevice *s,
struct comedi_insn *insn, unsigned int *data)
{
struct usbduxsub *this_usbduxsub = dev->private;
@@ -1868,7 +1878,8 @@ static int usbdux_counter_write(struct comedi_device *dev, struct comedi_subdevi
return 1;
}
-static int usbdux_counter_config(struct comedi_device *dev, struct comedi_subdevice *s,
+static int usbdux_counter_config(struct comedi_device *dev,
+ struct comedi_subdevice *s,
struct comedi_insn *insn, unsigned int *data)
{
/* nothing to do so far */
@@ -1905,14 +1916,14 @@ static int usbdux_pwm_stop(struct usbduxsub *this_usbduxsub, int do_unlink)
if (do_unlink)
ret = usbduxsub_unlink_PwmURBs(this_usbduxsub);
-
this_usbduxsub->pwm_cmd_running = 0;
return ret;
}
/* force unlink - is called by comedi */
-static int usbdux_pwm_cancel(struct comedi_device *dev, struct comedi_subdevice *s)
+static int usbdux_pwm_cancel(struct comedi_device *dev,
+ struct comedi_subdevice *s)
{
struct usbduxsub *this_usbduxsub = dev->private;
int res = 0;
@@ -2010,10 +2021,11 @@ static int usbduxsub_submit_PwmURBs(struct usbduxsub *usbduxsub)
/* in case of a resubmission after an unlink... */
usb_fill_bulk_urb(usbduxsub->urbPwm,
- usbduxsub->usbdev,
- usb_sndbulkpipe(usbduxsub->usbdev, PWM_EP),
- usbduxsub->urbPwm->transfer_buffer,
- usbduxsub->sizePwmBuf, usbduxsub_pwm_irq, usbduxsub->comedidev);
+ usbduxsub->usbdev,
+ usb_sndbulkpipe(usbduxsub->usbdev, PWM_EP),
+ usbduxsub->urbPwm->transfer_buffer,
+ usbduxsub->sizePwmBuf, usbduxsub_pwm_irq,
+ usbduxsub->comedidev);
errFlag = usb_submit_urb(usbduxsub->urbPwm, GFP_ATOMIC);
if (errFlag) {
@@ -2025,8 +2037,8 @@ static int usbduxsub_submit_PwmURBs(struct usbduxsub *usbduxsub)
return 0;
}
-static int usbdux_pwm_period(struct comedi_device *dev, struct comedi_subdevice *s,
- unsigned int period)
+static int usbdux_pwm_period(struct comedi_device *dev,
+ struct comedi_subdevice *s, unsigned int period)
{
struct usbduxsub *this_usbduxsub = dev->private;
int fx2delay = 255;
@@ -2037,11 +2049,11 @@ static int usbdux_pwm_period(struct comedi_device *dev, struct comedi_subdevice
dev->minor);
return -EAGAIN;
} else {
- fx2delay = period / ((int)(6*512*(1.0/0.033))) - 6;
+ fx2delay = period / ((int)(6 * 512 * (1.0 / 0.033))) - 6;
if (fx2delay > 255) {
dev_err(&this_usbduxsub->interface->dev,
"comedi%d: period %d for pwm is too low.\n",
- dev->minor, period);
+ dev->minor, period);
return -EAGAIN;
}
}
@@ -2053,7 +2065,8 @@ static int usbdux_pwm_period(struct comedi_device *dev, struct comedi_subdevice
}
/* is called from insn so there's no need to do all the sanity checks */
-static int usbdux_pwm_start(struct comedi_device *dev, struct comedi_subdevice *s)
+static int usbdux_pwm_start(struct comedi_device *dev,
+ struct comedi_subdevice *s)
{
int ret, i;
struct usbduxsub *this_usbduxsub = dev->private;
@@ -2085,8 +2098,9 @@ static int usbdux_pwm_start(struct comedi_device *dev, struct comedi_subdevice *
}
/* generates the bit pattern for PWM with the optional sign bit */
-static int usbdux_pwm_pattern(struct comedi_device *dev, struct comedi_subdevice *s,
- int channel, unsigned int value, unsigned int sign)
+static int usbdux_pwm_pattern(struct comedi_device *dev,
+ struct comedi_subdevice *s, int channel,
+ unsigned int value, unsigned int sign)
{
struct usbduxsub *this_usbduxsub = dev->private;
int i, szbuf;
@@ -2126,7 +2140,8 @@ static int usbdux_pwm_pattern(struct comedi_device *dev, struct comedi_subdevice
return 1;
}
-static int usbdux_pwm_write(struct comedi_device *dev, struct comedi_subdevice *s,
+static int usbdux_pwm_write(struct comedi_device *dev,
+ struct comedi_subdevice *s,
struct comedi_insn *insn, unsigned int *data)
{
struct usbduxsub *this_usbduxsub = dev->private;
@@ -2147,19 +2162,20 @@ static int usbdux_pwm_write(struct comedi_device *dev, struct comedi_subdevice *
* normal operation
* relay sign 0 by default
*/
- return usbdux_pwm_pattern(dev, s, CR_CHAN(insn->chanspec),
- data[0], 0);
+ return usbdux_pwm_pattern(dev, s, CR_CHAN(insn->chanspec), data[0], 0);
}
-static int usbdux_pwm_read(struct comedi_device *x1, struct comedi_subdevice *x2,
- struct comedi_insn *x3, unsigned int *x4)
+static int usbdux_pwm_read(struct comedi_device *x1,
+ struct comedi_subdevice *x2, struct comedi_insn *x3,
+ unsigned int *x4)
{
/* not needed */
return -EINVAL;
};
/* switches on/off PWM */
-static int usbdux_pwm_config(struct comedi_device *dev, struct comedi_subdevice *s,
+static int usbdux_pwm_config(struct comedi_device *dev,
+ struct comedi_subdevice *s,
struct comedi_insn *insn, unsigned int *data)
{
struct usbduxsub *this_usbduxsub = dev->private;
@@ -2249,10 +2265,10 @@ static void tidy_up(struct usbduxsub *usbduxsub_tmp)
}
for (i = 0; i < usbduxsub_tmp->numOfOutBuffers; i++) {
if (usbduxsub_tmp->urbOut[i]->transfer_buffer) {
- kfree(usbduxsub_tmp->urbOut[i]->
- transfer_buffer);
+ kfree(usbduxsub_tmp->
+ urbOut[i]->transfer_buffer);
usbduxsub_tmp->urbOut[i]->transfer_buffer =
- NULL;
+ NULL;
}
if (usbduxsub_tmp->urbOut[i]) {
usb_kill_urb(usbduxsub_tmp->urbOut[i]);
@@ -2310,8 +2326,7 @@ static void usbdux_firmware_request_complete_handler(const struct firmware *fw,
if (ret) {
dev_err(&usbdev->dev,
- "Could not upload firmware (err=%d)\n",
- ret);
+ "Could not upload firmware (err=%d)\n", ret);
return;
}
comedi_usb_auto_config(usbdev, BOARDNAME);
@@ -2365,7 +2380,7 @@ static int usbduxsub_probe(struct usb_interface *uinterf,
/* test if it is high speed (USB 2.0) */
usbduxsub[index].high_speed =
- (usbduxsub[index].usbdev->speed == USB_SPEED_HIGH);
+ (usbduxsub[index].usbdev->speed == USB_SPEED_HIGH);
/* create space for the commands of the DA converter */
usbduxsub[index].dac_commands = kzalloc(NUMOUTCHANNELS, GFP_KERNEL);
@@ -2429,8 +2444,8 @@ static int usbduxsub_probe(struct usb_interface *uinterf,
usbduxsub[index].numOfInBuffers = NUMOFINBUFFERSFULL;
usbduxsub[index].urbIn =
- kzalloc(sizeof(struct urb *) * usbduxsub[index].numOfInBuffers,
- GFP_KERNEL);
+ kzalloc(sizeof(struct urb *) * usbduxsub[index].numOfInBuffers,
+ GFP_KERNEL);
if (!(usbduxsub[index].urbIn)) {
dev_err(dev, "comedi_: usbdux: Could not alloc. urbIn array\n");
tidy_up(&(usbduxsub[index]));
@@ -2452,10 +2467,10 @@ static int usbduxsub_probe(struct usb_interface *uinterf,
/* and ONLY then the urb should be submitted */
usbduxsub[index].urbIn[i]->context = NULL;
usbduxsub[index].urbIn[i]->pipe =
- usb_rcvisocpipe(usbduxsub[index].usbdev, ISOINEP);
+ usb_rcvisocpipe(usbduxsub[index].usbdev, ISOINEP);
usbduxsub[index].urbIn[i]->transfer_flags = URB_ISO_ASAP;
usbduxsub[index].urbIn[i]->transfer_buffer =
- kzalloc(SIZEINBUF, GFP_KERNEL);
+ kzalloc(SIZEINBUF, GFP_KERNEL);
if (!(usbduxsub[index].urbIn[i]->transfer_buffer)) {
dev_err(dev, "comedi_: usbdux%d: "
"could not alloc. transb.\n", index);
@@ -2477,8 +2492,8 @@ static int usbduxsub_probe(struct usb_interface *uinterf,
usbduxsub[index].numOfOutBuffers = NUMOFOUTBUFFERSFULL;
usbduxsub[index].urbOut =
- kzalloc(sizeof(struct urb *) * usbduxsub[index].numOfOutBuffers,
- GFP_KERNEL);
+ kzalloc(sizeof(struct urb *) * usbduxsub[index].numOfOutBuffers,
+ GFP_KERNEL);
if (!(usbduxsub[index].urbOut)) {
dev_err(dev, "comedi_: usbdux: "
"Could not alloc. urbOut array\n");
@@ -2501,10 +2516,10 @@ static int usbduxsub_probe(struct usb_interface *uinterf,
/* and ONLY then the urb should be submitted */
usbduxsub[index].urbOut[i]->context = NULL;
usbduxsub[index].urbOut[i]->pipe =
- usb_sndisocpipe(usbduxsub[index].usbdev, ISOOUTEP);
+ usb_sndisocpipe(usbduxsub[index].usbdev, ISOOUTEP);
usbduxsub[index].urbOut[i]->transfer_flags = URB_ISO_ASAP;
usbduxsub[index].urbOut[i]->transfer_buffer =
- kzalloc(SIZEOUTBUF, GFP_KERNEL);
+ kzalloc(SIZEOUTBUF, GFP_KERNEL);
if (!(usbduxsub[index].urbOut[i]->transfer_buffer)) {
dev_err(dev, "comedi_: usbdux%d: "
"could not alloc. transb.\n", index);
@@ -2517,7 +2532,7 @@ static int usbduxsub_probe(struct usb_interface *uinterf,
usbduxsub[index].urbOut[i]->transfer_buffer_length = SIZEOUTBUF;
usbduxsub[index].urbOut[i]->iso_frame_desc[0].offset = 0;
usbduxsub[index].urbOut[i]->iso_frame_desc[0].length =
- SIZEOUTBUF;
+ SIZEOUTBUF;
if (usbduxsub[index].high_speed) {
/* uframes */
usbduxsub[index].urbOut[i]->interval = 8;
@@ -2540,7 +2555,7 @@ static int usbduxsub_probe(struct usb_interface *uinterf,
return -ENOMEM;
}
usbduxsub[index].urbPwm->transfer_buffer =
- kzalloc(usbduxsub[index].sizePwmBuf, GFP_KERNEL);
+ kzalloc(usbduxsub[index].sizePwmBuf, GFP_KERNEL);
if (!(usbduxsub[index].urbPwm->transfer_buffer)) {
dev_err(dev, "comedi_: usbdux%d: "
"could not alloc. transb. for pwm\n", index);
@@ -2568,8 +2583,6 @@ static int usbduxsub_probe(struct usb_interface *uinterf,
usbduxsub + index,
usbdux_firmware_request_complete_handler);
-
-
if (ret) {
dev_err(dev, "Could not load firmware (err=%d)\n", ret);
return ret;
@@ -2592,8 +2605,7 @@ static void usbduxsub_disconnect(struct usb_interface *intf)
return;
}
if (usbduxsub_tmp->usbdev != udev) {
- dev_err(&intf->dev,
- "comedi_: BUG! called with wrong ptr!!!\n");
+ dev_err(&intf->dev, "comedi_: BUG! called with wrong ptr!!!\n");
return;
}
comedi_usb_auto_unconfig(udev);
@@ -2641,7 +2653,7 @@ 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]) {
+ it->options[COMEDI_DEVCONF_AUX_DATA_LENGTH]) {
firmwareUpload(udev, comedi_aux_data(it->options, 0),
it->options[COMEDI_DEVCONF_AUX_DATA_LENGTH]);
}
@@ -2667,8 +2679,8 @@ static int usbdux_attach(struct comedi_device *dev, struct comedi_devconfig *it)
}
dev_info(&udev->interface->dev,
- "comedi%d: usb-device %d is attached to comedi.\n",
- dev->minor, index);
+ "comedi%d: usb-device %d is attached to comedi.\n",
+ dev->minor, index);
/* private structure is also simply the usb-structure */
dev->private = udev;
@@ -2779,14 +2791,14 @@ static int usbdux_detach(struct comedi_device *dev)
if (!dev) {
printk(KERN_ERR
- "comedi?: usbdux: detach without dev variable...\n");
+ "comedi?: usbdux: detach without dev variable...\n");
return -EFAULT;
}
usbduxsub_tmp = dev->private;
if (!usbduxsub_tmp) {
printk(KERN_ERR
- "comedi?: usbdux: detach without ptr to usbduxsub[]\n");
+ "comedi?: usbdux: detach without ptr to usbduxsub[]\n");
return -EFAULT;
}
@@ -2807,16 +2819,16 @@ static int usbdux_detach(struct comedi_device *dev)
/* main driver struct */
static struct comedi_driver driver_usbdux = {
- .driver_name = "usbdux",
- .module = THIS_MODULE,
- .attach = usbdux_attach,
- .detach = usbdux_detach,
+ .driver_name = "usbdux",
+ .module = THIS_MODULE,
+ .attach = usbdux_attach,
+ .detach = usbdux_detach,
};
/* Table with the USB-devices: just now only testing IDs */
static struct usb_device_id usbduxsub_table[] = {
- {USB_DEVICE(0x13d8, 0x0001) },
- {USB_DEVICE(0x13d8, 0x0002) },
+ {USB_DEVICE(0x13d8, 0x0001)},
+ {USB_DEVICE(0x13d8, 0x0002)},
{} /* Terminating entry */
};
@@ -2824,10 +2836,10 @@ MODULE_DEVICE_TABLE(usb, usbduxsub_table);
/* The usbduxsub-driver */
static struct usb_driver usbduxsub_driver = {
- .name = BOARDNAME,
- .probe = usbduxsub_probe,
- .disconnect = usbduxsub_disconnect,
- .id_table = usbduxsub_table,
+ .name = BOARDNAME,
+ .probe = usbduxsub_probe,
+ .disconnect = usbduxsub_disconnect,
+ .id_table = usbduxsub_table,
};
/* Can't use the nice macro as I have also to initialise the USB */
diff --git a/drivers/staging/comedi/drivers/usbduxfast.c b/drivers/staging/comedi/drivers/usbduxfast.c
index 939b53fa569c..d143222579c2 100644
--- a/drivers/staging/comedi/drivers/usbduxfast.c
+++ b/drivers/staging/comedi/drivers/usbduxfast.c
@@ -50,7 +50,6 @@
#include "comedi_fc.h"
#include "../comedidev.h"
-
#define DRIVER_VERSION "v1.0"
#define DRIVER_AUTHOR "Bernd Porr, BerndPorr@f2s.com"
#define DRIVER_DESC "USB-DUXfast, BerndPorr@f2s.com"
@@ -161,7 +160,7 @@
* comedi constants
*/
static const struct comedi_lrange range_usbduxfast_ai_range = {
- 2, { BIP_RANGE(0.75), BIP_RANGE(0.5) }
+ 2, {BIP_RANGE(0.75), BIP_RANGE(0.5)}
};
/*
@@ -171,22 +170,22 @@ static const struct comedi_lrange range_usbduxfast_ai_range = {
* one sub device just now: A/D
*/
struct usbduxfastsub_s {
- int attached; /* is attached? */
- int probed; /* is it associated with a subdevice? */
+ int attached; /* is attached? */
+ int probed; /* is it associated with a subdevice? */
struct usb_device *usbdev; /* pointer to the usb-device */
- struct urb *urbIn; /* BULK-transfer handling: urb */
+ struct urb *urbIn; /* BULK-transfer handling: urb */
int8_t *transfer_buffer;
- int16_t *insnBuffer; /* input buffer for single insn */
- int ifnum; /* interface number */
+ int16_t *insnBuffer; /* input buffer for single insn */
+ int ifnum; /* interface number */
struct usb_interface *interface; /* interface structure */
struct comedi_device *comedidev; /* comedi device for the interrupt
- context */
+ context */
short int ai_cmd_running; /* asynchronous command is running */
- short int ai_continous; /* continous aquisition */
+ short int ai_continous; /* continous aquisition */
long int ai_sample_count; /* number of samples to aquire */
- uint8_t *dux_commands; /* commands */
- int ignore; /* counter which ignores the first
- buffers */
+ uint8_t *dux_commands; /* commands */
+ int ignore; /* counter which ignores the first
+ buffers */
struct semaphore sem;
};
@@ -217,7 +216,7 @@ static int send_dux_commands(struct usbduxfastsub_s *udfs, int cmd_type)
#ifdef CONFIG_COMEDI_DEBUG
printk(KERN_DEBUG "comedi%d: usbduxfast: dux_commands: ",
- udfs->comedidev->minor);
+ udfs->comedidev->minor);
for (tmp = 0; tmp < SIZEOFDUXBUFFER; tmp++)
printk(" %02x", udfs->dux_commands[tmp]);
printk("\n");
@@ -228,7 +227,7 @@ static int send_dux_commands(struct usbduxfastsub_s *udfs, int cmd_type)
udfs->dux_commands, SIZEOFDUXBUFFER, &nsent, 10000);
if (tmp < 0)
printk(KERN_ERR "comedi%d: could not transmit dux_commands to"
- "the usb-device, err=%d\n", udfs->comedidev->minor, tmp);
+ "the usb-device, err=%d\n", udfs->comedidev->minor, tmp);
return tmp;
}
@@ -258,8 +257,7 @@ static int usbduxfastsub_unlink_InURBs(struct usbduxfastsub_s *udfs)
* Is called from within this driver from both the
* interrupt context and from comedi.
*/
-static int usbduxfast_ai_stop(struct usbduxfastsub_s *udfs,
- int do_unlink)
+static int usbduxfast_ai_stop(struct usbduxfastsub_s *udfs, int do_unlink)
{
int ret = 0;
@@ -267,7 +265,6 @@ static int usbduxfast_ai_stop(struct usbduxfastsub_s *udfs,
printk(KERN_ERR "comedi?: usbduxfast_ai_stop: udfs=NULL!\n");
return -EFAULT;
}
-
#ifdef CONFIG_COMEDI_DEBUG
printk(KERN_DEBUG "comedi: usbduxfast_ai_stop\n");
#endif
@@ -275,7 +272,7 @@ static int usbduxfast_ai_stop(struct usbduxfastsub_s *udfs,
udfs->ai_cmd_running = 0;
if (do_unlink)
- ret = usbduxfastsub_unlink_InURBs(udfs); /* stop aquistion */
+ ret = usbduxfastsub_unlink_InURBs(udfs); /* stop aquistion */
return ret;
}
@@ -284,7 +281,8 @@ static int usbduxfast_ai_stop(struct usbduxfastsub_s *udfs,
* This will cancel a running acquisition operation.
* This is called by comedi but never from inside the driver.
*/
-static int usbduxfast_ai_cancel(struct comedi_device *dev, struct comedi_subdevice *s)
+static int usbduxfast_ai_cancel(struct comedi_device *dev,
+ struct comedi_subdevice *s)
{
struct usbduxfastsub_s *udfs;
int ret;
@@ -402,9 +400,9 @@ static void usbduxfastsub_ai_Irq(struct urb *urb)
* received
*/
cfc_write_array_to_buffer(s,
- urb->transfer_buffer,
- udfs->ai_sample_count
- * sizeof(uint16_t));
+ urb->transfer_buffer,
+ udfs->ai_sample_count
+ * sizeof(uint16_t));
usbduxfast_ai_stop(udfs, 0);
/* tell comedi that the acquistion is over */
s->async->events |= COMEDI_CB_EOA;
@@ -439,7 +437,7 @@ static void usbduxfastsub_ai_Irq(struct urb *urb)
err = usb_submit_urb(urb, GFP_ATOMIC);
if (err < 0) {
printk(KERN_ERR "comedi%d: usbduxfast: urb resubm failed: %d",
- udfs->comedidev->minor, err);
+ udfs->comedidev->minor, err);
s->async->events |= COMEDI_CB_EOA;
s->async->events |= COMEDI_CB_ERROR;
comedi_event(udfs->comedidev, s);
@@ -454,15 +452,13 @@ static int usbduxfastsub_start(struct usbduxfastsub_s *udfs)
/* 7f92 to zero */
local_transfer_buffer[0] = 0;
- ret = usb_control_msg(udfs->usbdev,
- usb_sndctrlpipe(udfs->usbdev, 0),
- USBDUXFASTSUB_FIRMWARE, /* bRequest, "Firmware" */
- VENDOR_DIR_OUT, /* bmRequestType */
- USBDUXFASTSUB_CPUCS, /* Value */
- 0x0000, /* Index */
- local_transfer_buffer, /* address of the transfer buffer */
- 1, /* Length */
- EZTIMEOUT); /* Timeout */
+ ret = usb_control_msg(udfs->usbdev, usb_sndctrlpipe(udfs->usbdev, 0), USBDUXFASTSUB_FIRMWARE, /* bRequest, "Firmware" */
+ VENDOR_DIR_OUT, /* bmRequestType */
+ USBDUXFASTSUB_CPUCS, /* Value */
+ 0x0000, /* Index */
+ local_transfer_buffer, /* address of the transfer buffer */
+ 1, /* Length */
+ EZTIMEOUT); /* Timeout */
if (ret < 0) {
printk("comedi_: usbduxfast_: control msg failed (start)\n");
return ret;
@@ -478,15 +474,12 @@ static int usbduxfastsub_stop(struct usbduxfastsub_s *udfs)
/* 7f92 to one */
local_transfer_buffer[0] = 1;
- ret = usb_control_msg(udfs->usbdev,
- usb_sndctrlpipe(udfs->usbdev, 0),
- USBDUXFASTSUB_FIRMWARE, /* bRequest, "Firmware" */
- VENDOR_DIR_OUT, /* bmRequestType */
- USBDUXFASTSUB_CPUCS, /* Value */
- 0x0000, /* Index */
- local_transfer_buffer,
- 1, /* Length */
- EZTIMEOUT); /* Timeout */
+ ret = usb_control_msg(udfs->usbdev, usb_sndctrlpipe(udfs->usbdev, 0), USBDUXFASTSUB_FIRMWARE, /* bRequest, "Firmware" */
+ VENDOR_DIR_OUT, /* bmRequestType */
+ USBDUXFASTSUB_CPUCS, /* Value */
+ 0x0000, /* Index */
+ local_transfer_buffer, 1, /* Length */
+ EZTIMEOUT); /* Timeout */
if (ret < 0) {
printk(KERN_ERR "comedi_: usbduxfast: control msg failed "
"(stop)\n");
@@ -497,25 +490,23 @@ static int usbduxfastsub_stop(struct usbduxfastsub_s *udfs)
}
static int usbduxfastsub_upload(struct usbduxfastsub_s *udfs,
- unsigned char *local_transfer_buffer,
- unsigned int startAddr, unsigned int len)
+ unsigned char *local_transfer_buffer,
+ unsigned int startAddr, unsigned int len)
{
int ret;
#ifdef CONFIG_COMEDI_DEBUG
printk(KERN_DEBUG "comedi: usbduxfast: uploading %d bytes", len);
printk(KERN_DEBUG " to addr %d, first byte=%d.\n",
- startAddr, local_transfer_buffer[0]);
+ startAddr, local_transfer_buffer[0]);
#endif
- ret = usb_control_msg(udfs->usbdev,
- usb_sndctrlpipe(udfs->usbdev, 0),
- USBDUXFASTSUB_FIRMWARE, /* brequest, firmware */
- VENDOR_DIR_OUT, /* bmRequestType */
- startAddr, /* value */
- 0x0000, /* index */
- local_transfer_buffer, /* our local safe buffer */
- len, /* length */
- EZTIMEOUT); /* timeout */
+ ret = usb_control_msg(udfs->usbdev, usb_sndctrlpipe(udfs->usbdev, 0), USBDUXFASTSUB_FIRMWARE, /* brequest, firmware */
+ VENDOR_DIR_OUT, /* bmRequestType */
+ startAddr, /* value */
+ 0x0000, /* index */
+ local_transfer_buffer, /* our local safe buffer */
+ len, /* length */
+ EZTIMEOUT); /* timeout */
#ifdef CONFIG_COMEDI_DEBUG
printk(KERN_DEBUG "comedi_: usbduxfast: result=%d\n", ret);
@@ -544,7 +535,7 @@ int usbduxfastsub_submit_InURBs(struct usbduxfastsub_s *udfs)
#ifdef CONFIG_COMEDI_DEBUG
printk(KERN_DEBUG "comedi%d: usbduxfast: submitting in-urb: "
"0x%p,0x%p\n", udfs->comedidev->minor, udfs->urbIn->context,
- udfs->urbIn->dev);
+ udfs->urbIn->dev);
#endif
ret = usb_submit_urb(udfs->urbIn, GFP_ATOMIC);
if (ret) {
@@ -556,7 +547,8 @@ int usbduxfastsub_submit_InURBs(struct usbduxfastsub_s *udfs)
}
static int usbduxfast_ai_cmdtest(struct comedi_device *dev,
- struct comedi_subdevice *s, struct comedi_cmd *cmd)
+ struct comedi_subdevice *s,
+ struct comedi_cmd *cmd)
{
int err = 0, stop_mask = 0;
long int steps, tmp;
@@ -608,16 +600,16 @@ static int usbduxfast_ai_cmdtest(struct comedi_device *dev,
*/
if (cmd->start_src != TRIG_NOW &&
- cmd->start_src != TRIG_EXT && cmd->start_src != TRIG_INT)
+ cmd->start_src != TRIG_EXT && cmd->start_src != TRIG_INT)
err++;
if (cmd->scan_begin_src != TRIG_TIMER &&
- cmd->scan_begin_src != TRIG_FOLLOW &&
- cmd->scan_begin_src != TRIG_EXT)
+ cmd->scan_begin_src != TRIG_FOLLOW &&
+ cmd->scan_begin_src != TRIG_EXT)
err++;
if (cmd->convert_src != TRIG_TIMER && cmd->convert_src != TRIG_EXT)
err++;
if (cmd->stop_src != TRIG_COUNT &&
- cmd->stop_src != TRIG_EXT && cmd->stop_src != TRIG_NONE)
+ cmd->stop_src != TRIG_EXT && cmd->stop_src != TRIG_NONE)
err++;
/* can't have external stop and start triggers at once */
@@ -698,7 +690,8 @@ static int usbduxfast_ai_cmdtest(struct comedi_device *dev,
}
static int usbduxfast_ai_inttrig(struct comedi_device *dev,
- struct comedi_subdevice *s, unsigned int trignum)
+ struct comedi_subdevice *s,
+ unsigned int trignum)
{
int ret;
struct usbduxfastsub_s *udfs = dev->private;
@@ -749,7 +742,8 @@ static int usbduxfast_ai_inttrig(struct comedi_device *dev,
#define OUTBASE (1+0x10)
#define LOGBASE (1+0x18)
-static int usbduxfast_ai_cmd(struct comedi_device *dev, struct comedi_subdevice *s)
+static int usbduxfast_ai_cmd(struct comedi_device *dev,
+ struct comedi_subdevice *s)
{
struct comedi_cmd *cmd = &s->async->cmd;
unsigned int chan, gain, rngmask = 0xff;
@@ -797,7 +791,7 @@ static int usbduxfast_ai_cmd(struct comedi_device *dev, struct comedi_subdevice
return -EINVAL;
}
if ((gain != CR_RANGE(cmd->chanlist[i]))
- && (cmd->chanlist_len > 3)) {
+ && (cmd->chanlist_len > 3)) {
printk(KERN_ERR "comedi%d: the gain must be"
" the same for all channels.\n",
dev->minor);
@@ -835,7 +829,7 @@ static int usbduxfast_ai_cmd(struct comedi_device *dev, struct comedi_subdevice
return -EINVAL;
}
if ((cmd->start_src == TRIG_EXT) && (cmd->chanlist_len != 1)
- && (cmd->chanlist_len != 16)) {
+ && (cmd->chanlist_len != 16)) {
printk(KERN_ERR "comedi%d: usbduxfast: ai_cmd: TRIG_EXT only"
" with 1 or 16 channels possible.\n", dev->minor);
up(&udfs->sem);
@@ -865,17 +859,17 @@ static int usbduxfast_ai_cmd(struct comedi_device *dev, struct comedi_subdevice
/* we loop here until ready has been set */
if (cmd->start_src == TRIG_EXT) {
/* branch back to state 0 */
- udfs->dux_commands[LENBASE+0] = 0x01;
+ udfs->dux_commands[LENBASE + 0] = 0x01;
/* deceision state w/o data */
- udfs->dux_commands[OPBASE+0] = 0x01;
- udfs->dux_commands[OUTBASE+0] = 0xFF & rngmask;
+ udfs->dux_commands[OPBASE + 0] = 0x01;
+ udfs->dux_commands[OUTBASE + 0] = 0xFF & rngmask;
/* RDY0 = 0 */
- udfs->dux_commands[LOGBASE+0] = 0x00;
+ udfs->dux_commands[LOGBASE + 0] = 0x00;
} else { /* we just proceed to state 1 */
- udfs->dux_commands[LENBASE+0] = 1;
- udfs->dux_commands[OPBASE+0] = 0;
- udfs->dux_commands[OUTBASE+0] = 0xFF & rngmask;
- udfs->dux_commands[LOGBASE+0] = 0;
+ udfs->dux_commands[LENBASE + 0] = 1;
+ udfs->dux_commands[OPBASE + 0] = 0;
+ udfs->dux_commands[OUTBASE + 0] = 0xFF & rngmask;
+ udfs->dux_commands[LOGBASE + 0] = 0;
}
if (steps < MIN_SAMPLING_PERIOD) {
@@ -888,30 +882,33 @@ static int usbduxfast_ai_cmd(struct comedi_device *dev, struct comedi_subdevice
*/
/* branch back to state 1 */
- udfs->dux_commands[LENBASE+1] = 0x89;
+ udfs->dux_commands[LENBASE + 1] = 0x89;
/* deceision state with data */
- udfs->dux_commands[OPBASE+1] = 0x03;
- udfs->dux_commands[OUTBASE+1] = 0xFF & rngmask;
+ udfs->dux_commands[OPBASE + 1] = 0x03;
+ udfs->dux_commands[OUTBASE + 1] =
+ 0xFF & rngmask;
/* doesn't matter */
- udfs->dux_commands[LOGBASE+1] = 0xFF;
+ udfs->dux_commands[LOGBASE + 1] = 0xFF;
} else {
/*
* we loop through two states: data and delay
* max rate is 15MHz
*/
- udfs->dux_commands[LENBASE+1] = steps - 1;
+ udfs->dux_commands[LENBASE + 1] = steps - 1;
/* data */
- udfs->dux_commands[OPBASE+1] = 0x02;
- udfs->dux_commands[OUTBASE+1] = 0xFF & rngmask;
+ udfs->dux_commands[OPBASE + 1] = 0x02;
+ udfs->dux_commands[OUTBASE + 1] =
+ 0xFF & rngmask;
/* doesn't matter */
- udfs->dux_commands[LOGBASE+1] = 0;
+ udfs->dux_commands[LOGBASE + 1] = 0;
/* branch back to state 1 */
- udfs->dux_commands[LENBASE+2] = 0x09;
+ udfs->dux_commands[LENBASE + 2] = 0x09;
/* deceision state w/o data */
- udfs->dux_commands[OPBASE+2] = 0x01;
- udfs->dux_commands[OUTBASE+2] = 0xFF & rngmask;
+ udfs->dux_commands[OPBASE + 2] = 0x01;
+ udfs->dux_commands[OUTBASE + 2] =
+ 0xFF & rngmask;
/* doesn't matter */
- udfs->dux_commands[LOGBASE+2] = 0xFF;
+ udfs->dux_commands[LOGBASE + 2] = 0xFF;
}
} else {
/*
@@ -923,26 +920,26 @@ static int usbduxfast_ai_cmd(struct comedi_device *dev, struct comedi_subdevice
steps = steps - 1;
/* do the first part of the delay */
- udfs->dux_commands[LENBASE+1] = steps / 2;
- udfs->dux_commands[OPBASE+1] = 0;
- udfs->dux_commands[OUTBASE+1] = 0xFF & rngmask;
- udfs->dux_commands[LOGBASE+1] = 0;
+ udfs->dux_commands[LENBASE + 1] = steps / 2;
+ udfs->dux_commands[OPBASE + 1] = 0;
+ udfs->dux_commands[OUTBASE + 1] = 0xFF & rngmask;
+ udfs->dux_commands[LOGBASE + 1] = 0;
/* and the second part */
- udfs->dux_commands[LENBASE+2] = steps - steps / 2;
- udfs->dux_commands[OPBASE+2] = 0;
- udfs->dux_commands[OUTBASE+2] = 0xFF & rngmask;
- udfs->dux_commands[LOGBASE+2] = 0;
+ udfs->dux_commands[LENBASE + 2] = steps - steps / 2;
+ udfs->dux_commands[OPBASE + 2] = 0;
+ udfs->dux_commands[OUTBASE + 2] = 0xFF & rngmask;
+ udfs->dux_commands[LOGBASE + 2] = 0;
/* get the data and branch back */
/* branch back to state 1 */
- udfs->dux_commands[LENBASE+3] = 0x09;
+ udfs->dux_commands[LENBASE + 3] = 0x09;
/* deceision state w data */
- udfs->dux_commands[OPBASE+3] = 0x03;
- udfs->dux_commands[OUTBASE+3] = 0xFF & rngmask;
+ udfs->dux_commands[OPBASE + 3] = 0x03;
+ udfs->dux_commands[OUTBASE + 3] = 0xFF & rngmask;
/* doesn't matter */
- udfs->dux_commands[LOGBASE+3] = 0xFF;
+ udfs->dux_commands[LOGBASE + 3] = 0xFF;
}
break;
@@ -957,11 +954,11 @@ static int usbduxfast_ai_cmd(struct comedi_device *dev, struct comedi_subdevice
else
rngmask = 0xff;
- udfs->dux_commands[LENBASE+0] = 1;
+ udfs->dux_commands[LENBASE + 0] = 1;
/* data */
- udfs->dux_commands[OPBASE+0] = 0x02;
- udfs->dux_commands[OUTBASE+0] = 0xFF & rngmask;
- udfs->dux_commands[LOGBASE+0] = 0;
+ udfs->dux_commands[OPBASE + 0] = 0x02;
+ udfs->dux_commands[OUTBASE + 0] = 0xFF & rngmask;
+ udfs->dux_commands[LOGBASE + 0] = 0;
/* we have 1 state with duration 1: state 0 */
steps_tmp = steps - 1;
@@ -972,23 +969,23 @@ static int usbduxfast_ai_cmd(struct comedi_device *dev, struct comedi_subdevice
rngmask = 0xff;
/* do the first part of the delay */
- udfs->dux_commands[LENBASE+1] = steps_tmp / 2;
- udfs->dux_commands[OPBASE+1] = 0;
+ udfs->dux_commands[LENBASE + 1] = steps_tmp / 2;
+ udfs->dux_commands[OPBASE + 1] = 0;
/* count */
- udfs->dux_commands[OUTBASE+1] = 0xFE & rngmask;
- udfs->dux_commands[LOGBASE+1] = 0;
+ udfs->dux_commands[OUTBASE + 1] = 0xFE & rngmask;
+ udfs->dux_commands[LOGBASE + 1] = 0;
/* and the second part */
- udfs->dux_commands[LENBASE+2] = steps_tmp - steps_tmp / 2;
- udfs->dux_commands[OPBASE+2] = 0;
- udfs->dux_commands[OUTBASE+2] = 0xFF & rngmask;
- udfs->dux_commands[LOGBASE+2] = 0;
+ udfs->dux_commands[LENBASE + 2] = steps_tmp - steps_tmp / 2;
+ udfs->dux_commands[OPBASE + 2] = 0;
+ udfs->dux_commands[OUTBASE + 2] = 0xFF & rngmask;
+ udfs->dux_commands[LOGBASE + 2] = 0;
- udfs->dux_commands[LENBASE+3] = 1;
+ udfs->dux_commands[LENBASE + 3] = 1;
/* data */
- udfs->dux_commands[OPBASE+3] = 0x02;
- udfs->dux_commands[OUTBASE+3] = 0xFF & rngmask;
- udfs->dux_commands[LOGBASE+3] = 0;
+ udfs->dux_commands[OPBASE + 3] = 0x02;
+ udfs->dux_commands[OUTBASE + 3] = 0xFF & rngmask;
+ udfs->dux_commands[LOGBASE + 3] = 0;
/*
* we have 2 states with duration 1: step 6 and
@@ -1002,22 +999,22 @@ static int usbduxfast_ai_cmd(struct comedi_device *dev, struct comedi_subdevice
rngmask = 0xff;
/* do the first part of the delay */
- udfs->dux_commands[LENBASE+4] = steps_tmp / 2;
- udfs->dux_commands[OPBASE+4] = 0;
+ udfs->dux_commands[LENBASE + 4] = steps_tmp / 2;
+ udfs->dux_commands[OPBASE + 4] = 0;
/* reset */
- udfs->dux_commands[OUTBASE+4] = (0xFF - 0x02) & rngmask;
- udfs->dux_commands[LOGBASE+4] = 0;
+ udfs->dux_commands[OUTBASE + 4] = (0xFF - 0x02) & rngmask;
+ udfs->dux_commands[LOGBASE + 4] = 0;
/* and the second part */
- udfs->dux_commands[LENBASE+5] = steps_tmp - steps_tmp / 2;
- udfs->dux_commands[OPBASE+5] = 0;
- udfs->dux_commands[OUTBASE+5] = 0xFF & rngmask;
- udfs->dux_commands[LOGBASE+5] = 0;
-
- udfs->dux_commands[LENBASE+6] = 1;
- udfs->dux_commands[OPBASE+6] = 0;
- udfs->dux_commands[OUTBASE+6] = 0xFF & rngmask;
- udfs->dux_commands[LOGBASE+6] = 0;
+ udfs->dux_commands[LENBASE + 5] = steps_tmp - steps_tmp / 2;
+ udfs->dux_commands[OPBASE + 5] = 0;
+ udfs->dux_commands[OUTBASE + 5] = 0xFF & rngmask;
+ udfs->dux_commands[LOGBASE + 5] = 0;
+
+ udfs->dux_commands[LENBASE + 6] = 1;
+ udfs->dux_commands[OPBASE + 6] = 0;
+ udfs->dux_commands[OUTBASE + 6] = 0xFF & rngmask;
+ udfs->dux_commands[LOGBASE + 6] = 0;
break;
case 3:
@@ -1033,12 +1030,12 @@ static int usbduxfast_ai_cmd(struct comedi_device *dev, struct comedi_subdevice
* commit data to the FIFO and do the first part
* of the delay
*/
- udfs->dux_commands[LENBASE+j*2] = steps / 2;
+ udfs->dux_commands[LENBASE + j * 2] = steps / 2;
/* data */
- udfs->dux_commands[OPBASE+j*2] = 0x02;
+ udfs->dux_commands[OPBASE + j * 2] = 0x02;
/* no change */
- udfs->dux_commands[OUTBASE+j*2] = 0xFF & rngmask;
- udfs->dux_commands[LOGBASE+j*2] = 0;
+ udfs->dux_commands[OUTBASE + j * 2] = 0xFF & rngmask;
+ udfs->dux_commands[LOGBASE + j * 2] = 0;
if (CR_RANGE(cmd->chanlist[j + 1]) > 0)
rngmask = 0xff - 0x04;
@@ -1046,23 +1043,25 @@ static int usbduxfast_ai_cmd(struct comedi_device *dev, struct comedi_subdevice
rngmask = 0xff;
/* do the second part of the delay */
- udfs->dux_commands[LENBASE+j*2+1] = steps - steps / 2;
+ udfs->dux_commands[LENBASE + j * 2 + 1] =
+ steps - steps / 2;
/* no data */
- udfs->dux_commands[OPBASE+j*2+1] = 0;
+ udfs->dux_commands[OPBASE + j * 2 + 1] = 0;
/* count */
- udfs->dux_commands[OUTBASE+j*2+1] = 0xFE & rngmask;
- udfs->dux_commands[LOGBASE+j*2+1] = 0;
+ udfs->dux_commands[OUTBASE + j * 2 + 1] =
+ 0xFE & rngmask;
+ udfs->dux_commands[LOGBASE + j * 2 + 1] = 0;
}
/* 2 steps with duration 1: the idele step and step 6: */
steps_tmp = steps - 2;
/* commit data to the FIFO and do the first part of the delay */
- udfs->dux_commands[LENBASE+4] = steps_tmp / 2;
+ udfs->dux_commands[LENBASE + 4] = steps_tmp / 2;
/* data */
- udfs->dux_commands[OPBASE+4] = 0x02;
- udfs->dux_commands[OUTBASE+4] = 0xFF & rngmask;
- udfs->dux_commands[LOGBASE+4] = 0;
+ udfs->dux_commands[OPBASE + 4] = 0x02;
+ udfs->dux_commands[OUTBASE + 4] = 0xFF & rngmask;
+ udfs->dux_commands[LOGBASE + 4] = 0;
if (CR_RANGE(cmd->chanlist[0]) > 0)
rngmask = 0xff - 0x04;
@@ -1070,17 +1069,17 @@ static int usbduxfast_ai_cmd(struct comedi_device *dev, struct comedi_subdevice
rngmask = 0xff;
/* do the second part of the delay */
- udfs->dux_commands[LENBASE+5] = steps_tmp - steps_tmp / 2;
+ udfs->dux_commands[LENBASE + 5] = steps_tmp - steps_tmp / 2;
/* no data */
- udfs->dux_commands[OPBASE+5] = 0;
+ udfs->dux_commands[OPBASE + 5] = 0;
/* reset */
- udfs->dux_commands[OUTBASE+5] = (0xFF - 0x02) & rngmask;
- udfs->dux_commands[LOGBASE+5] = 0;
+ udfs->dux_commands[OUTBASE + 5] = (0xFF - 0x02) & rngmask;
+ udfs->dux_commands[LOGBASE + 5] = 0;
- udfs->dux_commands[LENBASE+6] = 1;
- udfs->dux_commands[OPBASE+6] = 0;
- udfs->dux_commands[OUTBASE+6] = 0xFF & rngmask;
- udfs->dux_commands[LOGBASE+6] = 0;
+ udfs->dux_commands[LENBASE + 6] = 1;
+ udfs->dux_commands[OPBASE + 6] = 0;
+ udfs->dux_commands[OUTBASE + 6] = 0xFF & rngmask;
+ udfs->dux_commands[LOGBASE + 6] = 0;
case 16:
if (CR_RANGE(cmd->chanlist[0]) > 0)
@@ -1094,55 +1093,57 @@ static int usbduxfast_ai_cmd(struct comedi_device *dev, struct comedi_subdevice
*/
/* branch back to state 0 */
- udfs->dux_commands[LENBASE+0] = 0x01;
+ udfs->dux_commands[LENBASE + 0] = 0x01;
/* deceision state w/o data */
- udfs->dux_commands[OPBASE+0] = 0x01;
+ udfs->dux_commands[OPBASE + 0] = 0x01;
/* reset */
- udfs->dux_commands[OUTBASE+0] = (0xFF-0x02) & rngmask;
+ udfs->dux_commands[OUTBASE + 0] =
+ (0xFF - 0x02) & rngmask;
/* RDY0 = 0 */
- udfs->dux_commands[LOGBASE+0] = 0x00;
+ udfs->dux_commands[LOGBASE + 0] = 0x00;
} else {
/*
* we just proceed to state 1
*/
/* 30us reset pulse */
- udfs->dux_commands[LENBASE+0] = 255;
- udfs->dux_commands[OPBASE+0] = 0;
+ udfs->dux_commands[LENBASE + 0] = 255;
+ udfs->dux_commands[OPBASE + 0] = 0;
/* reset */
- udfs->dux_commands[OUTBASE+0] = (0xFF-0x02) & rngmask;
- udfs->dux_commands[LOGBASE+0] = 0;
+ udfs->dux_commands[OUTBASE + 0] =
+ (0xFF - 0x02) & rngmask;
+ udfs->dux_commands[LOGBASE + 0] = 0;
}
/* commit data to the FIFO */
- udfs->dux_commands[LENBASE+1] = 1;
+ udfs->dux_commands[LENBASE + 1] = 1;
/* data */
- udfs->dux_commands[OPBASE+1] = 0x02;
- udfs->dux_commands[OUTBASE+1] = 0xFF & rngmask;
- udfs->dux_commands[LOGBASE+1] = 0;
+ udfs->dux_commands[OPBASE + 1] = 0x02;
+ udfs->dux_commands[OUTBASE + 1] = 0xFF & rngmask;
+ udfs->dux_commands[LOGBASE + 1] = 0;
/* we have 2 states with duration 1 */
steps = steps - 2;
/* do the first part of the delay */
- udfs->dux_commands[LENBASE+2] = steps / 2;
- udfs->dux_commands[OPBASE+2] = 0;
- udfs->dux_commands[OUTBASE+2] = 0xFE & rngmask;
- udfs->dux_commands[LOGBASE+2] = 0;
+ udfs->dux_commands[LENBASE + 2] = steps / 2;
+ udfs->dux_commands[OPBASE + 2] = 0;
+ udfs->dux_commands[OUTBASE + 2] = 0xFE & rngmask;
+ udfs->dux_commands[LOGBASE + 2] = 0;
/* and the second part */
- udfs->dux_commands[LENBASE+3] = steps - steps / 2;
- udfs->dux_commands[OPBASE+3] = 0;
- udfs->dux_commands[OUTBASE+3] = 0xFF & rngmask;
- udfs->dux_commands[LOGBASE+3] = 0;
+ udfs->dux_commands[LENBASE + 3] = steps - steps / 2;
+ udfs->dux_commands[OPBASE + 3] = 0;
+ udfs->dux_commands[OUTBASE + 3] = 0xFF & rngmask;
+ udfs->dux_commands[LOGBASE + 3] = 0;
/* branch back to state 1 */
- udfs->dux_commands[LENBASE+4] = 0x09;
+ udfs->dux_commands[LENBASE + 4] = 0x09;
/* deceision state w/o data */
- udfs->dux_commands[OPBASE+4] = 0x01;
- udfs->dux_commands[OUTBASE+4] = 0xFF & rngmask;
+ udfs->dux_commands[OPBASE + 4] = 0x01;
+ udfs->dux_commands[OUTBASE + 4] = 0xFF & rngmask;
/* doesn't matter */
- udfs->dux_commands[LOGBASE+4] = 0xFF;
+ udfs->dux_commands[LOGBASE + 4] = 0xFF;
break;
@@ -1166,7 +1167,7 @@ static int usbduxfast_ai_cmd(struct comedi_device *dev, struct comedi_subdevice
return result;
}
if (cmd->stop_src == TRIG_COUNT) {
- udfs->ai_sample_count = cmd->stop_arg * cmd->scan_end_arg;
+ udfs->ai_sample_count = cmd->stop_arg * cmd->scan_end_arg;
if (udfs->ai_sample_count < 1) {
printk(KERN_ERR "comedi%d: "
"(cmd->stop_arg)*(cmd->scan_end_arg)<1, "
@@ -1209,7 +1210,8 @@ static int usbduxfast_ai_cmd(struct comedi_device *dev, struct comedi_subdevice
* Mode 0 is used to get a single conversion on demand.
*/
static int usbduxfast_ai_insn_read(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)
{
int i, j, n, actual_length;
int chan, range, rngmask;
@@ -1248,43 +1250,43 @@ static int usbduxfast_ai_insn_read(struct comedi_device *dev,
rngmask = 0xff;
/* commit data to the FIFO */
- udfs->dux_commands[LENBASE+0] = 1;
+ udfs->dux_commands[LENBASE + 0] = 1;
/* data */
- udfs->dux_commands[OPBASE+0] = 0x02;
- udfs->dux_commands[OUTBASE+0] = 0xFF & rngmask;
- udfs->dux_commands[LOGBASE+0] = 0;
+ udfs->dux_commands[OPBASE + 0] = 0x02;
+ udfs->dux_commands[OUTBASE + 0] = 0xFF & rngmask;
+ udfs->dux_commands[LOGBASE + 0] = 0;
/* do the first part of the delay */
- udfs->dux_commands[LENBASE+1] = 12;
- udfs->dux_commands[OPBASE+1] = 0;
- udfs->dux_commands[OUTBASE+1] = 0xFE & rngmask;
- udfs->dux_commands[LOGBASE+1] = 0;
-
- udfs->dux_commands[LENBASE+2] = 1;
- udfs->dux_commands[OPBASE+2] = 0;
- udfs->dux_commands[OUTBASE+2] = 0xFE & rngmask;
- udfs->dux_commands[LOGBASE+2] = 0;
-
- udfs->dux_commands[LENBASE+3] = 1;
- udfs->dux_commands[OPBASE+3] = 0;
- udfs->dux_commands[OUTBASE+3] = 0xFE & rngmask;
- udfs->dux_commands[LOGBASE+3] = 0;
-
- udfs->dux_commands[LENBASE+4] = 1;
- udfs->dux_commands[OPBASE+4] = 0;
- udfs->dux_commands[OUTBASE+4] = 0xFE & rngmask;
- udfs->dux_commands[LOGBASE+4] = 0;
+ udfs->dux_commands[LENBASE + 1] = 12;
+ udfs->dux_commands[OPBASE + 1] = 0;
+ udfs->dux_commands[OUTBASE + 1] = 0xFE & rngmask;
+ udfs->dux_commands[LOGBASE + 1] = 0;
+
+ udfs->dux_commands[LENBASE + 2] = 1;
+ udfs->dux_commands[OPBASE + 2] = 0;
+ udfs->dux_commands[OUTBASE + 2] = 0xFE & rngmask;
+ udfs->dux_commands[LOGBASE + 2] = 0;
+
+ udfs->dux_commands[LENBASE + 3] = 1;
+ udfs->dux_commands[OPBASE + 3] = 0;
+ udfs->dux_commands[OUTBASE + 3] = 0xFE & rngmask;
+ udfs->dux_commands[LOGBASE + 3] = 0;
+
+ udfs->dux_commands[LENBASE + 4] = 1;
+ udfs->dux_commands[OPBASE + 4] = 0;
+ udfs->dux_commands[OUTBASE + 4] = 0xFE & rngmask;
+ udfs->dux_commands[LOGBASE + 4] = 0;
/* second part */
- udfs->dux_commands[LENBASE+5] = 12;
- udfs->dux_commands[OPBASE+5] = 0;
- udfs->dux_commands[OUTBASE+5] = 0xFF & rngmask;
- udfs->dux_commands[LOGBASE+5] = 0;
+ udfs->dux_commands[LENBASE + 5] = 12;
+ udfs->dux_commands[OPBASE + 5] = 0;
+ udfs->dux_commands[OUTBASE + 5] = 0xFF & rngmask;
+ udfs->dux_commands[LOGBASE + 5] = 0;
- udfs->dux_commands[LENBASE+6] = 1;
- udfs->dux_commands[OPBASE+6] = 0;
- udfs->dux_commands[OUTBASE+6] = 0xFF & rngmask;
- udfs->dux_commands[LOGBASE+0] = 0;
+ udfs->dux_commands[LENBASE + 6] = 1;
+ udfs->dux_commands[OPBASE + 6] = 0;
+ udfs->dux_commands[OUTBASE + 6] = 0xFF & rngmask;
+ udfs->dux_commands[LOGBASE + 0] = 0;
#ifdef CONFIG_COMEDI_DEBUG
printk(KERN_DEBUG "comedi %d: sending commands to the usb device\n",
@@ -1310,7 +1312,7 @@ static int usbduxfast_ai_insn_read(struct comedi_device *dev,
&actual_length, 10000);
if (err < 0) {
printk(KERN_ERR "comedi%d: insn timeout. No data.\n",
- dev->minor);
+ dev->minor);
up(&udfs->sem);
return err;
}
@@ -1323,7 +1325,7 @@ static int usbduxfast_ai_insn_read(struct comedi_device *dev,
&actual_length, 10000);
if (err < 0) {
printk(KERN_ERR "comedi%d: insn data error: %d\n",
- dev->minor, err);
+ dev->minor, err);
up(&udfs->sem);
return err;
}
@@ -1346,8 +1348,7 @@ static int usbduxfast_ai_insn_read(struct comedi_device *dev,
#define FIRMWARE_MAX_LEN 0x2000
static int firmwareUpload(struct usbduxfastsub_s *usbduxfastsub,
- const u8 *firmwareBinary,
- int sizeFirmware)
+ const u8 * firmwareBinary, int sizeFirmware)
{
int ret;
uint8_t *fwBuf;
@@ -1355,7 +1356,7 @@ static int firmwareUpload(struct usbduxfastsub_s *usbduxfastsub,
if (!firmwareBinary)
return 0;
- if (sizeFirmware>FIRMWARE_MAX_LEN) {
+ if (sizeFirmware > FIRMWARE_MAX_LEN) {
dev_err(&usbduxfastsub->interface->dev,
"comedi_: usbduxfast firmware binary it too large for FX2.\n");
return -ENOMEM;
@@ -1368,7 +1369,7 @@ static int firmwareUpload(struct usbduxfastsub_s *usbduxfastsub,
"comedi_: mem alloc for firmware failed\n");
return -ENOMEM;
}
- memcpy(fwBuf,firmwareBinary,sizeFirmware);
+ memcpy(fwBuf, firmwareBinary, sizeFirmware);
ret = usbduxfastsub_stop(usbduxfastsub);
if (ret < 0) {
@@ -1396,8 +1397,6 @@ static int firmwareUpload(struct usbduxfastsub_s *usbduxfastsub,
return 0;
}
-
-
static void tidy_up(struct usbduxfastsub_s *udfs)
{
#ifdef CONFIG_COMEDI_DEBUG
@@ -1433,8 +1432,8 @@ static void tidy_up(struct usbduxfastsub_s *udfs)
udfs->ai_cmd_running = 0;
}
-static void usbduxfast_firmware_request_complete_handler(const struct firmware *fw,
- void *context)
+static void usbduxfast_firmware_request_complete_handler(const struct firmware
+ *fw, void *context)
{
struct usbduxfastsub_s *usbduxfastsub_tmp = context;
struct usb_device *usbdev = usbduxfastsub_tmp->usbdev;
@@ -1451,8 +1450,7 @@ static void usbduxfast_firmware_request_complete_handler(const struct firmware *
if (ret) {
dev_err(&usbdev->dev,
- "Could not upload firmware (err=%d)\n",
- ret);
+ "Could not upload firmware (err=%d)\n", ret);
return;
}
@@ -1463,7 +1461,7 @@ static void usbduxfast_firmware_request_complete_handler(const struct firmware *
* allocate memory for the urbs and initialise them
*/
static int usbduxfastsub_probe(struct usb_interface *uinterf,
- const struct usb_device_id *id)
+ const struct usb_device_id *id)
{
struct usb_device *udev = interface_to_usbdev(uinterf);
int i;
@@ -1539,7 +1537,7 @@ static int usbduxfastsub_probe(struct usb_interface *uinterf,
}
/* setting to alternate setting 1: enabling bulk ep */
i = usb_set_interface(usbduxfastsub[index].usbdev,
- usbduxfastsub[index].ifnum, 1);
+ usbduxfastsub[index].ifnum, 1);
if (i < 0) {
printk(KERN_ERR "comedi_: usbduxfast%d: could not switch to "
"alternate setting 1.\n", index);
@@ -1575,8 +1573,7 @@ static int usbduxfastsub_probe(struct usb_interface *uinterf,
usbduxfast_firmware_request_complete_handler);
if (ret) {
- dev_err(&udev->dev, "could not load firmware (err=%d)\n",
- ret);
+ dev_err(&udev->dev, "could not load firmware (err=%d)\n", ret);
return ret;
}
@@ -1618,7 +1615,8 @@ static void usbduxfastsub_disconnect(struct usb_interface *intf)
/*
* is called when comedi-config is called
*/
-static int usbduxfast_attach(struct comedi_device *dev, struct comedi_devconfig *it)
+static int usbduxfast_attach(struct comedi_device *dev,
+ struct comedi_devconfig *it)
{
int ret;
int index;
@@ -1725,7 +1723,6 @@ static int usbduxfast_detach(struct comedi_device *dev)
"variable...\n");
return -EFAULT;
}
-
#ifdef CONFIG_COMEDI_DEBUG
printk(KERN_DEBUG "comedi%d: usbduxfast: detach usb device\n",
dev->minor);
@@ -1760,10 +1757,10 @@ static int usbduxfast_detach(struct comedi_device *dev)
* main driver struct
*/
static struct comedi_driver driver_usbduxfast = {
- .driver_name = "usbduxfast",
- .module = THIS_MODULE,
- .attach = usbduxfast_attach,
- .detach = usbduxfast_detach
+ .driver_name = "usbduxfast",
+ .module = THIS_MODULE,
+ .attach = usbduxfast_attach,
+ .detach = usbduxfast_detach
};
/*
@@ -1771,9 +1768,9 @@ static struct comedi_driver driver_usbduxfast = {
*/
static struct usb_device_id usbduxfastsub_table[] = {
/* { USB_DEVICE(0x4b4, 0x8613) }, testing */
- { USB_DEVICE(0x13d8, 0x0010) }, /* real ID */
- { USB_DEVICE(0x13d8, 0x0011) }, /* real ID */
- { } /* Terminating entry */
+ {USB_DEVICE(0x13d8, 0x0010)}, /* real ID */
+ {USB_DEVICE(0x13d8, 0x0011)}, /* real ID */
+ {} /* Terminating entry */
};
MODULE_DEVICE_TABLE(usb, usbduxfastsub_table);
@@ -1783,12 +1780,12 @@ MODULE_DEVICE_TABLE(usb, usbduxfastsub_table);
*/
static struct usb_driver usbduxfastsub_driver = {
#ifdef COMEDI_HAVE_USB_DRIVER_OWNER
- .owner = THIS_MODULE,
+ .owner = THIS_MODULE,
#endif
- .name = BOARDNAME,
- .probe = usbduxfastsub_probe,
- .disconnect = usbduxfastsub_disconnect,
- .id_table = usbduxfastsub_table
+ .name = BOARDNAME,
+ .probe = usbduxfastsub_probe,
+ .disconnect = usbduxfastsub_disconnect,
+ .id_table = usbduxfastsub_table
};
/*
diff --git a/drivers/staging/comedi/drivers/vmk80xx.c b/drivers/staging/comedi/drivers/vmk80xx.c
index 9de43b5310d7..c335040778f0 100644
--- a/drivers/staging/comedi/drivers/vmk80xx.c
+++ b/drivers/staging/comedi/drivers/vmk80xx.c
@@ -76,19 +76,19 @@ enum {
};
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 */
+ {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);
@@ -120,19 +120,19 @@ MODULE_DEVICE_TABLE(usb, vmk80xx_id_table);
#define VMK8055_CMD_WRT_AD 0x05
#define VMK8061_CMD_RD_AI 0x00
-#define VMK8061_CMR_RD_ALL_AI 0x01 /* !non-active! */
+#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_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_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_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
@@ -153,15 +153,15 @@ MODULE_DEVICE_TABLE(usb, vmk80xx_id_table);
#undef CONFIG_VMK80XX_DEBUG
#ifdef CONFIG_VMK80XX_DEBUG
- static int dbgvm = 1;
+static int dbgvm = 1;
#else
- static int dbgvm;
+static int dbgvm;
#endif
#ifdef CONFIG_COMEDI_DEBUG
- static int dbgcm = 1;
+static int dbgcm = 1;
#else
- static int dbgcm;
+static int dbgcm;
#endif
#define dbgvm(fmt, arg...) \
@@ -182,33 +182,33 @@ enum vmk80xx_model {
};
struct firmware_version {
- unsigned char ic3_vers[32]; /* USB-Controller */
- unsigned char ic6_vers[32]; /* CPU */
+ unsigned char ic3_vers[32]; /* USB-Controller */
+ unsigned char ic6_vers[32]; /* CPU */
};
static const struct comedi_lrange vmk8055_range = {
- 1, { UNI_RANGE(5) }
+ 1, {UNI_RANGE(5)}
};
static const struct comedi_lrange vmk8061_range = {
- 2, { UNI_RANGE(5), UNI_RANGE(10) }
+ 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;
+ __u8 ai_chans;
__le16 ai_bits;
- __u8 ao_chans;
+ __u8 ao_chans;
__le16 ao_bits;
- __u8 di_chans;
+ __u8 di_chans;
__le16 di_bits;
- __u8 do_chans;
+ __u8 do_chans;
__le16 do_bits;
- __u8 cnt_chans;
+ __u8 cnt_chans;
__le16 cnt_bits;
- __u8 pwm_chans;
+ __u8 pwm_chans;
__le16 pwm_bits;
};
@@ -253,8 +253,7 @@ static void vmk80xx_tx_callback(struct urb *urb)
dbgvm("vmk80xx: %s\n", __func__);
if (stat && !(stat == -ENOENT
- || stat == -ECONNRESET
- || stat == -ESHUTDOWN))
+ || stat == -ECONNRESET || stat == -ESHUTDOWN))
dbgcm("comedi#: vmk80xx: %s - nonzero urb status (%d)\n",
__func__, stat);
@@ -319,10 +318,8 @@ static int vmk80xx_check_data_link(struct vmk80xx_usb *dev)
/* 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);
+ 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];
}
@@ -342,16 +339,14 @@ static void vmk80xx_read_eeprom(struct vmk80xx_usb *dev, int flag)
/* 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);
+ 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.ic3_vers, rx + 1, 24);
+ else /* IC6_VERSION */
strncpy(dev->fw.ic6_vers, rx + 25, 24);
}
@@ -397,7 +392,7 @@ static void vmk80xx_build_int_urb(struct urb *urb, int flag)
unsigned int pipe;
unsigned char *buf;
size_t size;
- void (*callback)(struct urb *);
+ void (*callback) (struct urb *);
int ival;
dbgvm("vmk80xx: %s\n", __func__);
@@ -409,7 +404,7 @@ static void vmk80xx_build_int_urb(struct urb *urb, int flag)
size = le16_to_cpu(dev->ep_rx->wMaxPacketSize);
callback = vmk80xx_rx_callback;
ival = dev->ep_rx->bInterval;
- } else { /* URB_SND_FLAG */
+ } else { /* URB_SND_FLAG */
tx_addr = dev->ep_tx->bEndpointAddress;
pipe = usb_sndintpipe(dev->udev, tx_addr);
buf = dev->usb_tx_buf;
@@ -418,8 +413,7 @@ static void vmk80xx_build_int_urb(struct urb *urb, int flag)
ival = dev->ep_tx->bInterval;
}
- usb_fill_int_urb(urb, dev->udev, pipe, buf,
- size, callback, dev, ival);
+ usb_fill_int_urb(urb, dev->udev, pipe, buf, size, callback, dev, ival);
}
static void vmk80xx_do_bulk_msg(struct vmk80xx_usb *dev)
@@ -444,8 +438,7 @@ static void vmk80xx_do_bulk_msg(struct vmk80xx_usb *dev)
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);
+ 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);
@@ -464,7 +457,8 @@ static int vmk80xx_read_packet(struct vmk80xx_usb *dev)
/* 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)))
+ !test_bit(TRANS_IN_BUSY,
+ &dev->flags)))
return -ERESTART;
if (dev->board.model == VMK8061_MODEL) {
@@ -510,7 +504,8 @@ static int vmk80xx_write_packet(struct vmk80xx_usb *dev, int cmd)
if (test_bit(TRANS_OUT_BUSY, &dev->flags))
if (wait_event_interruptible(dev->write_wait,
- !test_bit(TRANS_OUT_BUSY, &dev->flags)))
+ !test_bit(TRANS_OUT_BUSY,
+ &dev->flags)))
return -ERESTART;
if (dev->board.model == VMK8061_MODEL) {
@@ -607,7 +602,7 @@ static int vmk80xx_ai_rinsn(struct comedi_device *cdev,
/* VMK8061_MODEL */
data[n] = dev->usb_rx_buf[reg[0]] + 256 *
- dev->usb_rx_buf[reg[1]];
+ dev->usb_rx_buf[reg[1]];
}
up(&dev->limit_sem);
@@ -638,7 +633,7 @@ static int vmk80xx_ao_winsn(struct comedi_device *cdev,
else
reg = VMK8055_AO2_REG;
break;
- default: /* NOTE: avoid compiler warnings */
+ default: /* NOTE: avoid compiler warnings */
cmd = VMK8061_CMD_SET_AO;
reg = VMK8061_AO_REG;
dev->usb_tx_buf[VMK8061_CH_REG] = chan;
@@ -680,7 +675,7 @@ static int vmk80xx_ao_rinsn(struct comedi_device *cdev,
if (vmk80xx_read_packet(dev))
break;
- data[n] = dev->usb_rx_buf[reg+chan];
+ data[n] = dev->usb_rx_buf[reg + chan];
}
up(&dev->limit_sem);
@@ -855,8 +850,8 @@ static int vmk80xx_cnt_rinsn(struct comedi_device *cdev,
}
/* VMK8061_MODEL */
- data[n] = dev->usb_rx_buf[reg[0]*(chan+1)+1]
- + 256 * dev->usb_rx_buf[reg[1]*2+2];
+ data[n] = dev->usb_rx_buf[reg[0] * (chan + 1) + 1]
+ + 256 * dev->usb_rx_buf[reg[1] * 2 + 2];
}
up(&dev->limit_sem);
@@ -941,7 +936,7 @@ static int vmk80xx_cnt_winsn(struct comedi_device *cdev,
if (((val + 1) * val) < debtime * 1000 / 115)
val += 1;
- dev->usb_tx_buf[6+chan] = val;
+ dev->usb_tx_buf[6 + chan] = val;
if (vmk80xx_write_packet(dev, cmd))
break;
@@ -975,8 +970,7 @@ static int vmk80xx_pwm_rinsn(struct comedi_device *cdev,
if (vmk80xx_read_packet(dev))
break;
- data[n] = dev->usb_rx_buf[reg[0]] + 4 *
- dev->usb_rx_buf[reg[1]];
+ data[n] = dev->usb_rx_buf[reg[0]] + 4 * dev->usb_rx_buf[reg[1]];
}
up(&dev->limit_sem);
@@ -1309,8 +1303,7 @@ vmk80xx_probe(struct usb_interface *intf, const struct usb_device_id *id)
if (dev->board.model == VMK8061_MODEL) {
vmk80xx_read_eeprom(dev, IC3_VERSION);
- printk(KERN_INFO "comedi#: vmk80xx: %s\n",
- dev->fw.ic3_vers);
+ printk(KERN_INFO "comedi#: vmk80xx: %s\n", dev->fw.ic3_vers);
if (vmk80xx_check_data_link(dev)) {
vmk80xx_read_eeprom(dev, IC6_VERSION);
@@ -1368,17 +1361,17 @@ static void vmk80xx_disconnect(struct usb_interface *intf)
/* TODO: Add support for suspend, resume, pre_reset,
* post_reset and flush */
static struct usb_driver vmk80xx_driver = {
- .name = "vmk80xx",
- .probe = vmk80xx_probe,
+ .name = "vmk80xx",
+ .probe = vmk80xx_probe,
.disconnect = vmk80xx_disconnect,
- .id_table = vmk80xx_id_table
+ .id_table = vmk80xx_id_table
};
static struct comedi_driver driver_vmk80xx = {
- .module = THIS_MODULE,
+ .module = THIS_MODULE,
.driver_name = "vmk80xx",
- .attach = vmk80xx_attach,
- .detach = vmk80xx_detach
+ .attach = vmk80xx_attach,
+ .detach = vmk80xx_detach
};
static int __init vmk80xx_init(void)
diff --git a/drivers/staging/comedi/kcomedilib/data.c b/drivers/staging/comedi/kcomedilib/data.c
index d808556460aa..aefc41ab7c46 100644
--- a/drivers/staging/comedi/kcomedilib/data.c
+++ b/drivers/staging/comedi/kcomedilib/data.c
@@ -29,7 +29,7 @@
#include <linux/delay.h>
int comedi_data_write(void *dev, unsigned int subdev, unsigned int chan,
- unsigned int range, unsigned int aref, unsigned int data)
+ unsigned int range, unsigned int aref, unsigned int data)
{
struct comedi_insn insn;
@@ -44,7 +44,7 @@ int comedi_data_write(void *dev, unsigned int subdev, unsigned int chan,
}
int comedi_data_read(void *dev, unsigned int subdev, unsigned int chan,
- unsigned int range, unsigned int aref, unsigned int *data)
+ unsigned int range, unsigned int aref, unsigned int *data)
{
struct comedi_insn insn;
@@ -59,7 +59,8 @@ int comedi_data_read(void *dev, unsigned int subdev, unsigned int chan,
}
int comedi_data_read_hint(void *dev, unsigned int subdev,
- unsigned int chan, unsigned int range, unsigned int aref)
+ unsigned int chan, unsigned int range,
+ unsigned int aref)
{
struct comedi_insn insn;
unsigned int dummy_data;
@@ -75,8 +76,9 @@ int comedi_data_read_hint(void *dev, unsigned int subdev,
}
int comedi_data_read_delayed(void *dev, unsigned int subdev,
- unsigned int chan, unsigned int range, unsigned int aref,
- unsigned int *data, unsigned int nano_sec)
+ unsigned int chan, unsigned int range,
+ unsigned int aref, unsigned int *data,
+ unsigned int nano_sec)
{
int retval;
diff --git a/drivers/staging/comedi/kcomedilib/dio.c b/drivers/staging/comedi/kcomedilib/dio.c
index 8595567e48fb..30192f3c4652 100644
--- a/drivers/staging/comedi/kcomedilib/dio.c
+++ b/drivers/staging/comedi/kcomedilib/dio.c
@@ -27,7 +27,7 @@
#include <linux/string.h>
int comedi_dio_config(void *dev, unsigned int subdev, unsigned int chan,
- unsigned int io)
+ unsigned int io)
{
struct comedi_insn insn;
@@ -42,7 +42,7 @@ int comedi_dio_config(void *dev, unsigned int subdev, unsigned int chan,
}
int comedi_dio_read(void *dev, unsigned int subdev, unsigned int chan,
- unsigned int *val)
+ unsigned int *val)
{
struct comedi_insn insn;
@@ -57,7 +57,7 @@ int comedi_dio_read(void *dev, unsigned int subdev, unsigned int chan,
}
int comedi_dio_write(void *dev, unsigned int subdev, unsigned int chan,
- unsigned int val)
+ unsigned int val)
{
struct comedi_insn insn;
@@ -72,7 +72,7 @@ int comedi_dio_write(void *dev, unsigned int subdev, unsigned int chan,
}
int comedi_dio_bitfield(void *dev, unsigned int subdev, unsigned int mask,
- unsigned int *bits)
+ unsigned int *bits)
{
struct comedi_insn insn;
unsigned int data[2];
diff --git a/drivers/staging/comedi/kcomedilib/get.c b/drivers/staging/comedi/kcomedilib/get.c
index b6b726a69f14..6d8418715253 100644
--- a/drivers/staging/comedi/kcomedilib/get.c
+++ b/drivers/staging/comedi/kcomedilib/get.c
@@ -28,7 +28,7 @@
int comedi_get_n_subdevices(void *d)
{
- struct comedi_device *dev = (struct comedi_device *) d;
+ struct comedi_device *dev = (struct comedi_device *)d;
return dev->n_subdevices;
}
@@ -38,23 +38,23 @@ int comedi_get_version_code(void *d)
return COMEDI_VERSION_CODE;
}
-const char *comedi_get_driver_name(void * d)
+const char *comedi_get_driver_name(void *d)
{
- struct comedi_device *dev = (struct comedi_device *) d;
+ struct comedi_device *dev = (struct comedi_device *)d;
return dev->driver->driver_name;
}
-const char *comedi_get_board_name(void * d)
+const char *comedi_get_board_name(void *d)
{
- struct comedi_device *dev = (struct comedi_device *) d;
+ struct comedi_device *dev = (struct comedi_device *)d;
return dev->board_name;
}
int comedi_get_subdevice_type(void *d, unsigned int subdevice)
{
- struct comedi_device *dev = (struct comedi_device *) d;
+ struct comedi_device *dev = (struct comedi_device *)d;
struct comedi_subdevice *s = dev->subdevices + subdevice;
return s->type;
@@ -62,7 +62,7 @@ int comedi_get_subdevice_type(void *d, unsigned int subdevice)
unsigned int comedi_get_subdevice_flags(void *d, unsigned int subdevice)
{
- struct comedi_device *dev = (struct comedi_device *) d;
+ struct comedi_device *dev = (struct comedi_device *)d;
struct comedi_subdevice *s = dev->subdevices + subdevice;
return s->subdev_flags;
@@ -70,7 +70,7 @@ unsigned int comedi_get_subdevice_flags(void *d, unsigned int subdevice)
int comedi_find_subdevice_by_type(void *d, int type, unsigned int subd)
{
- struct comedi_device *dev = (struct comedi_device *) d;
+ struct comedi_device *dev = (struct comedi_device *)d;
if (subd > dev->n_subdevices)
return -ENODEV;
@@ -84,7 +84,7 @@ int comedi_find_subdevice_by_type(void *d, int type, unsigned int subd)
int comedi_get_n_channels(void *d, unsigned int subdevice)
{
- struct comedi_device *dev = (struct comedi_device *) d;
+ struct comedi_device *dev = (struct comedi_device *)d;
struct comedi_subdevice *s = dev->subdevices + subdevice;
return s->n_chan;
@@ -92,16 +92,16 @@ int comedi_get_n_channels(void *d, unsigned int subdevice)
int comedi_get_len_chanlist(void *d, unsigned int subdevice)
{
- struct comedi_device *dev = (struct comedi_device *) d;
+ struct comedi_device *dev = (struct comedi_device *)d;
struct comedi_subdevice *s = dev->subdevices + subdevice;
return s->len_chanlist;
}
unsigned int comedi_get_maxdata(void *d, unsigned int subdevice,
- unsigned int chan)
+ unsigned int chan)
{
- struct comedi_device *dev = (struct comedi_device *) d;
+ struct comedi_device *dev = (struct comedi_device *)d;
struct comedi_subdevice *s = dev->subdevices + subdevice;
if (s->maxdata_list)
@@ -111,10 +111,9 @@ unsigned int comedi_get_maxdata(void *d, unsigned int subdevice,
}
#ifdef KCOMEDILIB_DEPRECATED
-int comedi_get_rangetype(void *d, unsigned int subdevice,
- unsigned int chan)
+int comedi_get_rangetype(void *d, unsigned int subdevice, unsigned int chan)
{
- struct comedi_device *dev = (struct comedi_device *) d;
+ struct comedi_device *dev = (struct comedi_device *)d;
struct comedi_subdevice *s = dev->subdevices + subdevice;
int ret;
@@ -132,7 +131,7 @@ int comedi_get_rangetype(void *d, unsigned int subdevice,
int comedi_get_n_ranges(void *d, unsigned int subdevice, unsigned int chan)
{
- struct comedi_device *dev = (struct comedi_device *) d;
+ struct comedi_device *dev = (struct comedi_device *)d;
struct comedi_subdevice *s = dev->subdevices + subdevice;
int ret;
@@ -149,9 +148,9 @@ int comedi_get_n_ranges(void *d, unsigned int subdevice, unsigned int chan)
* ALPHA (non-portable)
*/
int comedi_get_krange(void *d, unsigned int subdevice, unsigned int chan,
- unsigned int range, struct comedi_krange *krange)
+ unsigned int range, struct comedi_krange *krange)
{
- struct comedi_device *dev = (struct comedi_device *) d;
+ struct comedi_device *dev = (struct comedi_device *)d;
struct comedi_subdevice *s = dev->subdevices + subdevice;
const struct comedi_lrange *lr;
@@ -173,7 +172,7 @@ int comedi_get_krange(void *d, unsigned int subdevice, unsigned int chan,
*/
unsigned int comedi_get_buf_head_pos(void *d, unsigned int subdevice)
{
- struct comedi_device *dev = (struct comedi_device *) d;
+ struct comedi_device *dev = (struct comedi_device *)d;
struct comedi_subdevice *s = dev->subdevices + subdevice;
struct comedi_async *async;
@@ -186,7 +185,7 @@ unsigned int comedi_get_buf_head_pos(void *d, unsigned int subdevice)
int comedi_get_buffer_contents(void *d, unsigned int subdevice)
{
- struct comedi_device *dev = (struct comedi_device *) d;
+ struct comedi_device *dev = (struct comedi_device *)d;
struct comedi_subdevice *s = dev->subdevices + subdevice;
struct comedi_async *async;
unsigned int num_bytes;
@@ -204,9 +203,9 @@ int comedi_get_buffer_contents(void *d, unsigned int subdevice)
* ALPHA
*/
int comedi_set_user_int_count(void *d, unsigned int subdevice,
- unsigned int buf_user_count)
+ unsigned int buf_user_count)
{
- struct comedi_device *dev = (struct comedi_device *) d;
+ struct comedi_device *dev = (struct comedi_device *)d;
struct comedi_subdevice *s = dev->subdevices + subdevice;
struct comedi_async *async;
int num_bytes;
@@ -225,9 +224,9 @@ int comedi_set_user_int_count(void *d, unsigned int subdevice,
}
int comedi_mark_buffer_read(void *d, unsigned int subdevice,
- unsigned int num_bytes)
+ unsigned int num_bytes)
{
- struct comedi_device *dev = (struct comedi_device *) d;
+ struct comedi_device *dev = (struct comedi_device *)d;
struct comedi_subdevice *s = dev->subdevices + subdevice;
struct comedi_async *async;
@@ -244,9 +243,9 @@ int comedi_mark_buffer_read(void *d, unsigned int subdevice,
}
int comedi_mark_buffer_written(void *d, unsigned int subdevice,
- unsigned int num_bytes)
+ unsigned int num_bytes)
{
- struct comedi_device *dev = (struct comedi_device *) d;
+ struct comedi_device *dev = (struct comedi_device *)d;
struct comedi_subdevice *s = dev->subdevices + subdevice;
struct comedi_async *async;
int bytes_written;
@@ -265,7 +264,7 @@ int comedi_mark_buffer_written(void *d, unsigned int subdevice,
int comedi_get_buffer_size(void *d, unsigned int subdev)
{
- struct comedi_device *dev = (struct comedi_device *) d;
+ struct comedi_device *dev = (struct comedi_device *)d;
struct comedi_subdevice *s = dev->subdevices + subdev;
struct comedi_async *async;
@@ -280,7 +279,7 @@ int comedi_get_buffer_size(void *d, unsigned int subdev)
int comedi_get_buffer_offset(void *d, unsigned int subdevice)
{
- struct comedi_device *dev = (struct comedi_device *) d;
+ struct comedi_device *dev = (struct comedi_device *)d;
struct comedi_subdevice *s = dev->subdevices + subdevice;
struct comedi_async *async;
diff --git a/drivers/staging/comedi/kcomedilib/kcomedilib_main.c b/drivers/staging/comedi/kcomedilib/kcomedilib_main.c
index b39ea7c50b87..6552ef6d8297 100644
--- a/drivers/staging/comedi/kcomedilib/kcomedilib_main.c
+++ b/drivers/staging/comedi/kcomedilib/kcomedilib_main.c
@@ -67,7 +67,7 @@ void *comedi_open(const char *filename)
if (!try_module_get(dev->driver->module))
return NULL;
- return (void *) dev;
+ return (void *)dev;
}
void *comedi_open_old(unsigned int minor)
@@ -86,12 +86,12 @@ void *comedi_open_old(unsigned int minor)
if (dev == NULL || !dev->attached)
return NULL;
- return (void *) dev;
+ return (void *)dev;
}
int comedi_close(void *d)
{
- struct comedi_device *dev = (struct comedi_device *) d;
+ struct comedi_device *dev = (struct comedi_device *)d;
module_put(dev->driver->module);
@@ -115,7 +115,7 @@ char *comedi_strerror(int err)
int comedi_fileno(void *d)
{
- struct comedi_device *dev = (struct comedi_device *) d;
+ struct comedi_device *dev = (struct comedi_device *)d;
/* return something random */
return dev->minor;
@@ -123,7 +123,7 @@ int comedi_fileno(void *d)
int comedi_command(void *d, struct comedi_cmd *cmd)
{
- struct comedi_device *dev = (struct comedi_device *) d;
+ struct comedi_device *dev = (struct comedi_device *)d;
struct comedi_subdevice *s;
struct comedi_async *async;
unsigned runflags;
@@ -159,7 +159,7 @@ int comedi_command(void *d, struct comedi_cmd *cmd)
int comedi_command_test(void *d, struct comedi_cmd *cmd)
{
- struct comedi_device *dev = (struct comedi_device *) d;
+ struct comedi_device *dev = (struct comedi_device *)d;
struct comedi_subdevice *s;
if (cmd->subdev >= dev->n_subdevices)
@@ -181,7 +181,7 @@ int comedi_command_test(void *d, struct comedi_cmd *cmd)
*/
int comedi_do_insn(void *d, struct comedi_insn *insn)
{
- struct comedi_device *dev = (struct comedi_device *) d;
+ struct comedi_device *dev = (struct comedi_device *)d;
struct comedi_subdevice *s;
int ret = 0;
@@ -214,7 +214,7 @@ int comedi_do_insn(void *d, struct comedi_insn *insn)
}
if (insn->subdev >= dev->n_subdevices) {
printk("%d not usable subdevice\n",
- insn->subdev);
+ insn->subdev);
ret = -EINVAL;
break;
}
@@ -296,7 +296,7 @@ int comedi_do_insn(void *d, struct comedi_insn *insn)
goto error;
}
#endif
- error:
+error:
return ret;
}
@@ -322,7 +322,7 @@ int comedi_do_insn(void *d, struct comedi_insn *insn)
*/
int comedi_lock(void *d, unsigned int subdevice)
{
- struct comedi_device *dev = (struct comedi_device *) d;
+ struct comedi_device *dev = (struct comedi_device *)d;
struct comedi_subdevice *s;
unsigned long flags;
int ret = 0;
@@ -365,7 +365,7 @@ int comedi_lock(void *d, unsigned int subdevice)
*/
int comedi_unlock(void *d, unsigned int subdevice)
{
- struct comedi_device *dev = (struct comedi_device *) d;
+ struct comedi_device *dev = (struct comedi_device *)d;
struct comedi_subdevice *s;
unsigned long flags;
struct comedi_async *async;
@@ -417,7 +417,7 @@ int comedi_unlock(void *d, unsigned int subdevice)
*/
int comedi_cancel(void *d, unsigned int subdevice)
{
- struct comedi_device *dev = (struct comedi_device *) d;
+ struct comedi_device *dev = (struct comedi_device *)d;
struct comedi_subdevice *s;
int ret = 0;
@@ -456,9 +456,10 @@ int comedi_cancel(void *d, unsigned int subdevice)
registration of callback functions
*/
int comedi_register_callback(void *d, unsigned int subdevice,
- unsigned int mask, int (*cb) (unsigned int, void *), void *arg)
+ unsigned int mask, int (*cb) (unsigned int,
+ void *), void *arg)
{
- struct comedi_device *dev = (struct comedi_device *) d;
+ struct comedi_device *dev = (struct comedi_device *)d;
struct comedi_subdevice *s;
struct comedi_async *async;
@@ -494,7 +495,7 @@ int comedi_register_callback(void *d, unsigned int subdevice,
int comedi_poll(void *d, unsigned int subdevice)
{
- struct comedi_device *dev = (struct comedi_device *) d;
+ struct comedi_device *dev = (struct comedi_device *)d;
struct comedi_subdevice *s = dev->subdevices;
struct comedi_async *async;
@@ -521,7 +522,7 @@ int comedi_poll(void *d, unsigned int subdevice)
/* WARNING: not portable */
int comedi_map(void *d, unsigned int subdevice, void *ptr)
{
- struct comedi_device *dev = (struct comedi_device *) d;
+ struct comedi_device *dev = (struct comedi_device *)d;
struct comedi_subdevice *s;
if (subdevice >= dev->n_subdevices)
@@ -543,7 +544,7 @@ int comedi_map(void *d, unsigned int subdevice, void *ptr)
/* WARNING: not portable */
int comedi_unmap(void *d, unsigned int subdevice)
{
- struct comedi_device *dev = (struct comedi_device *) d;
+ struct comedi_device *dev = (struct comedi_device *)d;
struct comedi_subdevice *s;
if (subdevice >= dev->n_subdevices)
diff --git a/drivers/staging/comedi/kcomedilib/ksyms.c b/drivers/staging/comedi/kcomedilib/ksyms.c
index 314765db51fe..19293d1f998d 100644
--- a/drivers/staging/comedi/kcomedilib/ksyms.c
+++ b/drivers/staging/comedi/kcomedilib/ksyms.c
@@ -21,10 +21,6 @@
*/
-#ifndef EXPORT_SYMTAB
-#define EXPORT_SYMTAB
-#endif
-
#include "../comedi.h"
#include "../comedilib.h"
#include "../comedidev.h"
diff --git a/drivers/staging/comedi/proc.c b/drivers/staging/comedi/proc.c
index 36ae2cd92ad9..5a22fe62c400 100644
--- a/drivers/staging/comedi/proc.c
+++ b/drivers/staging/comedi/proc.c
@@ -34,12 +34,12 @@
/* #include <linux/string.h> */
int comedi_read_procmem(char *buf, char **start, off_t offset, int len,
- int *eof, void *data);
+ int *eof, void *data);
extern struct comedi_driver *comedi_drivers;
int comedi_read_procmem(char *buf, char **start, off_t offset, int len,
- int *eof, void *data)
+ int *eof, void *data)
{
int i;
int devices_q = 0;
@@ -47,12 +47,13 @@ int comedi_read_procmem(char *buf, char **start, off_t offset, int len,
struct comedi_driver *driv;
l += sprintf(buf + l,
- "comedi version " COMEDI_RELEASE "\n"
- "format string: %s\n",
- "\"%2d: %-20s %-20s %4d\",i,driver_name,board_name,n_subdevices");
+ "comedi version " COMEDI_RELEASE "\n"
+ "format string: %s\n",
+ "\"%2d: %-20s %-20s %4d\",i,driver_name,board_name,n_subdevices");
for (i = 0; i < COMEDI_NUM_BOARD_MINORS; i++) {
- struct comedi_device_file_info *dev_file_info = comedi_get_device_file_info(i);
+ struct comedi_device_file_info *dev_file_info =
+ comedi_get_device_file_info(i);
struct comedi_device *dev;
if (dev_file_info == NULL)
@@ -62,9 +63,9 @@ int comedi_read_procmem(char *buf, char **start, off_t offset, int len,
if (dev->attached) {
devices_q = 1;
l += sprintf(buf + l, "%2d: %-20s %-20s %4d\n",
- i,
- dev->driver->driver_name,
- dev->board_name, dev->n_subdevices);
+ i,
+ dev->driver->driver_name,
+ dev->board_name, dev->n_subdevices);
}
}
if (!devices_q)
@@ -74,8 +75,8 @@ int comedi_read_procmem(char *buf, char **start, off_t offset, int len,
l += sprintf(buf + l, "%s:\n", driv->driver_name);
for (i = 0; i < driv->num_names; i++) {
l += sprintf(buf + l, " %s\n",
- *(char **)((char *)driv->board_name +
- i * driv->offset));
+ *(char **)((char *)driv->board_name +
+ i * driv->offset));
}
if (!driv->num_names)
l += sprintf(buf + l, " %s\n", driv->driver_name);
diff --git a/drivers/staging/comedi/range.c b/drivers/staging/comedi/range.c
index 445909e6f334..8313dfcb6732 100644
--- a/drivers/staging/comedi/range.c
+++ b/drivers/staging/comedi/range.c
@@ -78,7 +78,7 @@ int do_rangeinfo_ioctl(struct comedi_device *dev, struct comedi_rangeinfo *arg)
}
if (copy_to_user(it.range_ptr, lr->range,
- sizeof(struct comedi_krange) * lr->length))
+ sizeof(struct comedi_krange) * lr->length))
return -EFAULT;
return 0;
@@ -128,11 +128,12 @@ int check_chanlist(struct comedi_subdevice *s, int n, unsigned int *chanlist)
if (s->range_table) {
for (i = 0; i < n; i++)
if (CR_CHAN(chanlist[i]) >= s->n_chan ||
- CR_RANGE(chanlist[i]) >= s->range_table->length
- || aref_invalid(s, chanlist[i])) {
- printk("bad chanlist[%d]=0x%08x n_chan=%d range length=%d\n",
- i, chanlist[i], s->n_chan,
- s->range_table->length);
+ CR_RANGE(chanlist[i]) >= s->range_table->length
+ || aref_invalid(s, chanlist[i])) {
+ 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
for (i = 0; i < n; i++)
printk("[%d]=0x%08x\n", i, chanlist[i]);
@@ -143,11 +144,11 @@ int check_chanlist(struct comedi_subdevice *s, int n, unsigned int *chanlist)
for (i = 0; i < n; i++) {
chan = CR_CHAN(chanlist[i]);
if (chan >= s->n_chan ||
- CR_RANGE(chanlist[i]) >=
- s->range_table_list[chan]->length
- || aref_invalid(s, chanlist[i])) {
+ CR_RANGE(chanlist[i]) >=
+ s->range_table_list[chan]->length
+ || aref_invalid(s, chanlist[i])) {
printk("bad chanlist[%d]=0x%08x\n", i,
- chanlist[i]);
+ chanlist[i]);
return -EINVAL;
}
}
diff --git a/drivers/staging/cpc-usb/cpc-usb_drv.c b/drivers/staging/cpc-usb/cpc-usb_drv.c
index 9bf3f98c6825..c5eca46996fb 100644
--- a/drivers/staging/cpc-usb/cpc-usb_drv.c
+++ b/drivers/staging/cpc-usb/cpc-usb_drv.c
@@ -28,7 +28,6 @@
#include <asm/uaccess.h>
#include <linux/usb.h>
-#include <linux/version.h>
#include <linux/proc_fs.h>
diff --git a/drivers/staging/et131x/et1310_address_map.h b/drivers/staging/et131x/et1310_address_map.h
index 3c85999d64db..388ac40bfead 100644
--- a/drivers/staging/et131x/et1310_address_map.h
+++ b/drivers/staging/et131x/et1310_address_map.h
@@ -2,7 +2,7 @@
* Agere Systems Inc.
* 10/100/1000 Base-T Ethernet Driver for the ET1301 and ET131x series MACs
*
- * Copyright © 2005 Agere Systems Inc.
+ * Copyright © 2005 Agere Systems Inc.
* All rights reserved.
* http://www.agere.com
*
@@ -19,7 +19,7 @@
* software indicates your acceptance of these terms and conditions. If you do
* not agree with these terms and conditions, do not use the software.
*
- * Copyright © 2005 Agere Systems Inc.
+ * Copyright © 2005 Agere Systems Inc.
* All rights reserved.
*
* Redistribution and use in source or binary forms, with or without
@@ -40,7 +40,7 @@
*
* Disclaimer
*
- * THIS SOFTWARE IS PROVIDED “AS IS” AND ANY EXPRESS OR IMPLIED WARRANTIES,
+ * THIS SOFTWARE IS PROVIDED "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES,
* INCLUDING, BUT NOT LIMITED TO, INFRINGEMENT AND THE IMPLIED WARRANTIES OF
* MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. ANY
* USE, MODIFICATION OR DISTRIBUTION OF THIS SOFTWARE IS SOLELY AT THE USERS OWN
@@ -65,11 +65,11 @@ typedef union _Q_ADDR_t {
u32 value;
struct {
#ifdef _BIT_FIELDS_HTOL
- u32 unused:22; // bits 10-31
- u32 addr:10; // bits 0-9
+ u32 unused:22; /* bits 10-31 */
+ u32 addr:10; /* bits 0-9 */
#else
- u32 addr:10; // bits 0-9
- u32 unused:22; // bits 10-31
+ u32 addr:10; /* bits 0-9 */
+ u32 unused:22; /* bits 10-31 */
#endif
} bits;
} Q_ADDR_t, *PQ_ADDR_t;
@@ -106,29 +106,29 @@ typedef union _PM_CSR_t {
u32 value;
struct {
#ifdef _BIT_FIELDS_HTOL
- u32 unused:22; // bits 10-31
- u32 pm_jagcore_rx_rdy:1; // bit 9
- u32 pm_jagcore_tx_rdy:1; // bit 8
- u32 pm_phy_lped_en:1; // bit 7
- u32 pm_phy_sw_coma:1; // bit 6
- u32 pm_rxclk_gate:1; // bit 5
- u32 pm_txclk_gate:1; // bit 4
- u32 pm_sysclk_gate:1; // bit 3
- u32 pm_jagcore_rx_en:1; // bit 2
- u32 pm_jagcore_tx_en:1; // bit 1
- u32 pm_gigephy_en:1; // bit 0
-#else
- u32 pm_gigephy_en:1; // bit 0
- u32 pm_jagcore_tx_en:1; // bit 1
- u32 pm_jagcore_rx_en:1; // bit 2
- u32 pm_sysclk_gate:1; // bit 3
- u32 pm_txclk_gate:1; // bit 4
- u32 pm_rxclk_gate:1; // bit 5
- u32 pm_phy_sw_coma:1; // bit 6
- u32 pm_phy_lped_en:1; // bit 7
- u32 pm_jagcore_tx_rdy:1; // bit 8
- u32 pm_jagcore_rx_rdy:1; // bit 9
- u32 unused:22; // bits 10-31
+ u32 unused:22; /* bits 10-31 */
+ u32 pm_jagcore_rx_rdy:1; /* bit 9 */
+ u32 pm_jagcore_tx_rdy:1; /* bit 8 */
+ u32 pm_phy_lped_en:1; /* bit 7 */
+ u32 pm_phy_sw_coma:1; /* bit 6 */
+ u32 pm_rxclk_gate:1; /* bit 5 */
+ u32 pm_txclk_gate:1; /* bit 4 */
+ u32 pm_sysclk_gate:1; /* bit 3 */
+ u32 pm_jagcore_rx_en:1; /* bit 2 */
+ u32 pm_jagcore_tx_en:1; /* bit 1 */
+ u32 pm_gigephy_en:1; /* bit 0 */
+#else
+ u32 pm_gigephy_en:1; /* bit 0 */
+ u32 pm_jagcore_tx_en:1; /* bit 1 */
+ u32 pm_jagcore_rx_en:1; /* bit 2 */
+ u32 pm_sysclk_gate:1; /* bit 3 */
+ u32 pm_txclk_gate:1; /* bit 4 */
+ u32 pm_rxclk_gate:1; /* bit 5 */
+ u32 pm_phy_sw_coma:1; /* bit 6 */
+ u32 pm_phy_lped_en:1; /* bit 7 */
+ u32 pm_jagcore_tx_rdy:1; /* bit 8 */
+ u32 pm_jagcore_rx_rdy:1; /* bit 9 */
+ u32 unused:22; /* bits 10-31 */
#endif
} bits;
} PM_CSR_t, *PPM_CSR_t;
@@ -141,45 +141,45 @@ typedef union _INTERRUPT_t {
u32 value;
struct {
#ifdef _BIT_FIELDS_HTOL
- u32 unused5:11; // bits 21-31
- u32 slv_timeout:1; // bit 20
- u32 mac_stat_interrupt:1; // bit 19
- u32 rxmac_interrupt:1; // bit 18
- u32 txmac_interrupt:1; // bit 17
- u32 phy_interrupt:1; // bit 16
- u32 wake_on_lan:1; // bit 15
- u32 watchdog_interrupt:1; // bit 14
- u32 unused4:4; // bits 10-13
- u32 rxdma_err:1; // bit 9
- u32 rxdma_pkt_stat_ring_low:1; // bit 8
- u32 rxdma_fb_ring1_low:1; // bit 7
- u32 rxdma_fb_ring0_low:1; // bit 6
- u32 rxdma_xfr_done:1; // bit 5
- u32 txdma_err:1; // bit 4
- u32 txdma_isr:1; // bit 3
- u32 unused3:1; // bit 2
- u32 unused2:1; // bit 1
- u32 unused1:1; // bit 0
-#else
- u32 unused1:1; // bit 0
- u32 unused2:1; // bit 1
- u32 unused3:1; // bit 2
- u32 txdma_isr:1; // bit 3
- u32 txdma_err:1; // bit 4
- u32 rxdma_xfr_done:1; // bit 5
- u32 rxdma_fb_ring0_low:1; // bit 6
- u32 rxdma_fb_ring1_low:1; // bit 7
- u32 rxdma_pkt_stat_ring_low:1; // bit 8
- u32 rxdma_err:1; // bit 9
- u32 unused4:4; // bits 10-13
- u32 watchdog_interrupt:1; // bit 14
- u32 wake_on_lan:1; // bit 15
- u32 phy_interrupt:1; // bit 16
- u32 txmac_interrupt:1; // bit 17
- u32 rxmac_interrupt:1; // bit 18
- u32 mac_stat_interrupt:1; // bit 19
- u32 slv_timeout:1; // bit 20
- u32 unused5:11; // bits 21-31
+ u32 unused5:11; /* bits 21-31 */
+ u32 slv_timeout:1; /* bit 20 */
+ u32 mac_stat_interrupt:1; /* bit 19 */
+ u32 rxmac_interrupt:1; /* bit 18 */
+ u32 txmac_interrupt:1; /* bit 17 */
+ u32 phy_interrupt:1; /* bit 16 */
+ u32 wake_on_lan:1; /* bit 15 */
+ u32 watchdog_interrupt:1; /* bit 14 */
+ u32 unused4:4; /* bits 10-13 */
+ u32 rxdma_err:1; /* bit 9 */
+ u32 rxdma_pkt_stat_ring_low:1; /* bit 8 */
+ u32 rxdma_fb_ring1_low:1; /* bit 7 */
+ u32 rxdma_fb_ring0_low:1; /* bit 6 */
+ u32 rxdma_xfr_done:1; /* bit 5 */
+ u32 txdma_err:1; /* bit 4 */
+ u32 txdma_isr:1; /* bit 3 */
+ u32 unused3:1; /* bit 2 */
+ u32 unused2:1; /* bit 1 */
+ u32 unused1:1; /* bit 0 */
+#else
+ u32 unused1:1; /* bit 0 */
+ u32 unused2:1; /* bit 1 */
+ u32 unused3:1; /* bit 2 */
+ u32 txdma_isr:1; /* bit 3 */
+ u32 txdma_err:1; /* bit 4 */
+ u32 rxdma_xfr_done:1; /* bit 5 */
+ u32 rxdma_fb_ring0_low:1; /* bit 6 */
+ u32 rxdma_fb_ring1_low:1; /* bit 7 */
+ u32 rxdma_pkt_stat_ring_low:1; /* bit 8 */
+ u32 rxdma_err:1; /* bit 9 */
+ u32 unused4:4; /* bits 10-13 */
+ u32 watchdog_interrupt:1; /* bit 14 */
+ u32 wake_on_lan:1; /* bit 15 */
+ u32 phy_interrupt:1; /* bit 16 */
+ u32 txmac_interrupt:1; /* bit 17 */
+ u32 rxmac_interrupt:1; /* bit 18 */
+ u32 mac_stat_interrupt:1; /* bit 19 */
+ u32 slv_timeout:1; /* bit 20 */
+ u32 unused5:11; /* bits 21-31 */
#endif
} bits;
} INTERRUPT_t, *PINTERRUPT_t;
@@ -210,25 +210,25 @@ typedef union _SW_RESET_t {
u32 value;
struct {
#ifdef _BIT_FIELDS_HTOL
- u32 selfclr_disable:1; // bit 31
- u32 unused:24; // bits 7-30
- u32 mmc_sw_reset:1; // bit 6
- u32 mac_stat_sw_reset:1; // bit 5
- u32 mac_sw_reset:1; // bit 4
- u32 rxmac_sw_reset:1; // bit 3
- u32 txmac_sw_reset:1; // bit 2
- u32 rxdma_sw_reset:1; // bit 1
- u32 txdma_sw_reset:1; // bit 0
+ u32 selfclr_disable:1; /* bit 31 */
+ u32 unused:24; /* bits 7-30 */
+ u32 mmc_sw_reset:1; /* bit 6 */
+ u32 mac_stat_sw_reset:1; /* bit 5 */
+ u32 mac_sw_reset:1; /* bit 4 */
+ u32 rxmac_sw_reset:1; /* bit 3 */
+ u32 txmac_sw_reset:1; /* bit 2 */
+ u32 rxdma_sw_reset:1; /* bit 1 */
+ u32 txdma_sw_reset:1; /* bit 0 */
#else
- u32 txdma_sw_reset:1; // bit 0
- u32 rxdma_sw_reset:1; // bit 1
- u32 txmac_sw_reset:1; // bit 2
- u32 rxmac_sw_reset:1; // bit 3
- u32 mac_sw_reset:1; // bit 4
- u32 mac_stat_sw_reset:1; // bit 5
- u32 mmc_sw_reset:1; // bit 6
- u32 unused:24; // bits 7-30
- u32 selfclr_disable:1; // bit 31
+ u32 txdma_sw_reset:1; /* bit 0 */
+ u32 rxdma_sw_reset:1; /* bit 1 */
+ u32 txmac_sw_reset:1; /* bit 2 */
+ u32 rxmac_sw_reset:1; /* bit 3 */
+ u32 mac_sw_reset:1; /* bit 4 */
+ u32 mac_stat_sw_reset:1; /* bit 5 */
+ u32 mmc_sw_reset:1; /* bit 6 */
+ u32 unused:24; /* bits 7-30 */
+ u32 selfclr_disable:1; /* bit 31 */
#endif
} bits;
} SW_RESET_t, *PSW_RESET_t;
@@ -241,11 +241,11 @@ typedef union _SLV_TIMER_t {
u32 value;
struct {
#ifdef _BIT_FIELDS_HTOL
- u32 unused:8; // bits 24-31
- u32 timer_ini:24; // bits 0-23
+ u32 unused:8; /* bits 24-31 */
+ u32 timer_ini:24; /* bits 0-23 */
#else
- u32 timer_ini:24; // bits 0-23
- u32 unused:8; // bits 24-31
+ u32 timer_ini:24; /* bits 0-23 */
+ u32 unused:8; /* bits 24-31 */
#endif
} bits;
} SLV_TIMER_t, *PSLV_TIMER_t;
@@ -258,15 +258,15 @@ typedef union _MSI_CONFIG_t {
u32 value;
struct {
#ifdef _BIT_FIELDS_HTOL
- u32 unused1:13; // bits 19-31
- u32 msi_tc:3; // bits 16-18
- u32 unused2:11; // bits 5-15
- u32 msi_vector:5; // bits 0-4
+ u32 unused1:13; /* bits 19-31 */
+ u32 msi_tc:3; /* bits 16-18 */
+ u32 unused2:11; /* bits 5-15 */
+ u32 msi_vector:5; /* bits 0-4 */
#else
- u32 msi_vector:5; // bits 0-4
- u32 unused2:11; // bits 5-15
- u32 msi_tc:3; // bits 16-18
- u32 unused1:13; // bits 19-31
+ u32 msi_vector:5; /* bits 0-4 */
+ u32 unused2:11; /* bits 5-15 */
+ u32 msi_tc:3; /* bits 16-18 */
+ u32 unused1:13; /* bits 19-31 */
#endif
} bits;
} MSI_CONFIG_t, *PMSI_CONFIG_t;
@@ -279,13 +279,13 @@ typedef union _LOOPBACK_t {
u32 value;
struct {
#ifdef _BIT_FIELDS_HTOL
- u32 unused:30; // bits 2-31
- u32 dma_loopback:1; // bit 1
- u32 mac_loopback:1; // bit 0
+ u32 unused:30; /* bits 2-31 */
+ u32 dma_loopback:1; /* bit 1 */
+ u32 mac_loopback:1; /* bit 0 */
#else
- u32 mac_loopback:1; // bit 0
- u32 dma_loopback:1; // bit 1
- u32 unused:30; // bits 2-31
+ u32 mac_loopback:1; /* bit 0 */
+ u32 dma_loopback:1; /* bit 1 */
+ u32 unused:30; /* bits 2-31 */
#endif
} bits;
} LOOPBACK_t, *PLOOPBACK_t;
@@ -294,22 +294,22 @@ typedef union _LOOPBACK_t {
* GLOBAL Module of JAGCore Address Mapping
* Located at address 0x0000
*/
-typedef struct _GLOBAL_t { // Location:
- Q_ADDR_t txq_start_addr; // 0x0000
- Q_ADDR_t txq_end_addr; // 0x0004
- Q_ADDR_t rxq_start_addr; // 0x0008
- Q_ADDR_t rxq_end_addr; // 0x000C
- PM_CSR_t pm_csr; // 0x0010
- u32 unused; // 0x0014
- INTERRUPT_t int_status; // 0x0018
- INTERRUPT_t int_mask; // 0x001C
- INTERRUPT_t int_alias_clr_en; // 0x0020
- INTERRUPT_t int_status_alias; // 0x0024
- SW_RESET_t sw_reset; // 0x0028
- SLV_TIMER_t slv_timer; // 0x002C
- MSI_CONFIG_t msi_config; // 0x0030
- LOOPBACK_t loopback; // 0x0034
- u32 watchdog_timer; // 0x0038
+typedef struct _GLOBAL_t { /* Location: */
+ Q_ADDR_t txq_start_addr; /* 0x0000 */
+ Q_ADDR_t txq_end_addr; /* 0x0004 */
+ Q_ADDR_t rxq_start_addr; /* 0x0008 */
+ Q_ADDR_t rxq_end_addr; /* 0x000C */
+ PM_CSR_t pm_csr; /* 0x0010 */
+ u32 unused; /* 0x0014 */
+ INTERRUPT_t int_status; /* 0x0018 */
+ INTERRUPT_t int_mask; /* 0x001C */
+ INTERRUPT_t int_alias_clr_en; /* 0x0020 */
+ INTERRUPT_t int_status_alias; /* 0x0024 */
+ SW_RESET_t sw_reset; /* 0x0028 */
+ SLV_TIMER_t slv_timer; /* 0x002C */
+ MSI_CONFIG_t msi_config; /* 0x0030 */
+ LOOPBACK_t loopback; /* 0x0034 */
+ u32 watchdog_timer; /* 0x0038 */
} GLOBAL_t, *PGLOBAL_t;
/* END OF GLOBAL REGISTER ADDRESS MAP */
@@ -325,21 +325,21 @@ typedef union _TXDMA_CSR_t {
u32 value;
struct {
#ifdef _BIT_FIELDS_HTOL
- u32 unused2:19; // bits 13-31
- u32 traffic_class:4; // bits 9-12
- u32 sngl_epkt_mode:1; // bit 8
- u32 cache_thrshld:4; // bits 4-7
- u32 unused1:2; // bits 2-3
- u32 drop_TLP_disable:1; // bit 1
- u32 halt:1; // bit 0
+ u32 unused2:19; /* bits 13-31 */
+ u32 traffic_class:4; /* bits 9-12 */
+ u32 sngl_epkt_mode:1; /* bit 8 */
+ u32 cache_thrshld:4; /* bits 4-7 */
+ u32 unused1:2; /* bits 2-3 */
+ u32 drop_TLP_disable:1; /* bit 1 */
+ u32 halt:1; /* bit 0 */
#else
- u32 halt:1; // bit 0
- u32 drop_TLP_disable:1; // bit 1
- u32 unused1:2; // bits 2-3
- u32 cache_thrshld:4; // bits 4-7
- u32 sngl_epkt_mode:1; // bit 8
- u32 traffic_class:4; // bits 9-12
- u32 unused2:19; // bits 13-31
+ u32 halt:1; /* bit 0 */
+ u32 drop_TLP_disable:1; /* bit 1 */
+ u32 unused1:2; /* bits 2-3 */
+ u32 cache_thrshld:4; /* bits 4-7 */
+ u32 sngl_epkt_mode:1; /* bit 8 */
+ u32 traffic_class:4; /* bits 9-12 */
+ u32 unused2:19; /* bits 13-31 */
#endif
} bits;
} TXDMA_CSR_t, *PTXDMA_CSR_t;
@@ -364,11 +364,11 @@ typedef union _TXDMA_PR_NUM_DES_t {
u32 value;
struct {
#ifdef _BIT_FIELDS_HTOL
- u32 unused:22; // bits 10-31
- u32 pr_ndes:10; // bits 0-9
+ u32 unused:22; /* bits 10-31 */
+ u32 pr_ndes:10; /* bits 0-9 */
#else
- u32 pr_ndes:10; // bits 0-9
- u32 unused:22; // bits 10-31
+ u32 pr_ndes:10; /* bits 0-9 */
+ u32 unused:22; /* bits 10-31 */
#endif
} bits;
} TXDMA_PR_NUM_DES_t, *PTXDMA_PR_NUM_DES_t;
@@ -378,13 +378,13 @@ typedef union _DMA10W_t {
u32 value;
struct {
#ifdef _BIT_FIELDS_HTOL
- u32 unused:21; // bits 11-31
- u32 wrap:1; // bit 10
- u32 val:10; // bits 0-9
+ u32 unused:21; /* bits 11-31 */
+ u32 wrap:1; /* bit 10 */
+ u32 val:10; /* bits 0-9 */
#else
- u32 val:10; // bits 0-9
- u32 wrap:1; // bit 10
- u32 unused:21; // bits 11-31
+ u32 val:10; /* bits 0-9 */
+ u32 wrap:1; /* bit 10 */
+ u32 unused:21; /* bits 11-31 */
#endif
} bits;
} DMA10W_t, *PDMA10W_t;
@@ -435,13 +435,13 @@ typedef union _DMA4W_t {
u32 value;
struct {
#ifdef _BIT_FIELDS_HTOL
- u32 unused:27; // bits 5-31
- u32 wrap:1; // bit 4
- u32 val:4; // bit 0-3
+ u32 unused:27; /* bits 5-31 */
+ u32 wrap:1; /* bit 4 */
+ u32 val:4; /* bit 0-3 */
#else
- u32 val:4; // bits 0-3
- u32 wrap:1; // bit 4
- u32 unused:27; // bits 5-31
+ u32 val:4; /* bits 0-3 */
+ u32 wrap:1; /* bit 4 */
+ u32 unused:27; /* bits 5-31 */
#endif
} bits;
} DMA4W_t, *PDMA4W_t;
@@ -466,25 +466,25 @@ typedef union _TXDMA_ERROR_t {
u32 value;
struct {
#ifdef _BIT_FIELDS_HTOL
- u32 unused3:22; // bits 10-31
- u32 WrbkRewind:1; // bit 9
- u32 WrbkResend:1; // bit 8
- u32 unused2:2; // bits 6-7
- u32 DescrRewind:1; // bit 5
- u32 DescrResend:1; // bit 4
- u32 unused1:2; // bits 2-3
- u32 PyldRewind:1; // bit 1
- u32 PyldResend:1; // bit 0
+ u32 unused3:22; /* bits 10-31 */
+ u32 WrbkRewind:1; /* bit 9 */
+ u32 WrbkResend:1; /* bit 8 */
+ u32 unused2:2; /* bits 6-7 */
+ u32 DescrRewind:1; /* bit 5 */
+ u32 DescrResend:1; /* bit 4 */
+ u32 unused1:2; /* bits 2-3 */
+ u32 PyldRewind:1; /* bit 1 */
+ u32 PyldResend:1; /* bit 0 */
#else
- u32 PyldResend:1; // bit 0
- u32 PyldRewind:1; // bit 1
- u32 unused1:2; // bits 2-3
- u32 DescrResend:1; // bit 4
- u32 DescrRewind:1; // bit 5
- u32 unused2:2; // bits 6-7
- u32 WrbkResend:1; // bit 8
- u32 WrbkRewind:1; // bit 9
- u32 unused3:22; // bits 10-31
+ u32 PyldResend:1; /* bit 0 */
+ u32 PyldRewind:1; /* bit 1 */
+ u32 unused1:2; /* bits 2-3 */
+ u32 DescrResend:1; /* bit 4 */
+ u32 DescrRewind:1; /* bit 5 */
+ u32 unused2:2; /* bits 6-7 */
+ u32 WrbkResend:1; /* bit 8 */
+ u32 WrbkRewind:1; /* bit 9 */
+ u32 unused3:22; /* bits 10-31 */
#endif
} bits;
} TXDMA_ERROR_t, *PTXDMA_ERROR_t;
@@ -493,33 +493,33 @@ typedef union _TXDMA_ERROR_t {
* Tx DMA Module of JAGCore Address Mapping
* Located at address 0x1000
*/
-typedef struct _TXDMA_t { // Location:
- TXDMA_CSR_t csr; // 0x1000
- u32 pr_base_hi; // 0x1004
- u32 pr_base_lo; // 0x1008
- TXDMA_PR_NUM_DES_t pr_num_des; // 0x100C
- DMA10W_t txq_wr_addr; // 0x1010
- DMA10W_t txq_wr_addr_ext; // 0x1014
- DMA10W_t txq_rd_addr; // 0x1018
- u32 dma_wb_base_hi; // 0x101C
- u32 dma_wb_base_lo; // 0x1020
- DMA10W_t service_request; // 0x1024
- DMA10W_t service_complete; // 0x1028
- DMA4W_t cache_rd_index; // 0x102C
- DMA4W_t cache_wr_index; // 0x1030
- TXDMA_ERROR_t TxDmaError; // 0x1034
- u32 DescAbortCount; // 0x1038
- u32 PayloadAbortCnt; // 0x103c
- u32 WriteBackAbortCnt; // 0x1040
- u32 DescTimeoutCnt; // 0x1044
- u32 PayloadTimeoutCnt; // 0x1048
- u32 WriteBackTimeoutCnt; // 0x104c
- u32 DescErrorCount; // 0x1050
- u32 PayloadErrorCnt; // 0x1054
- u32 WriteBackErrorCnt; // 0x1058
- u32 DroppedTLPCount; // 0x105c
- DMA10W_t NewServiceComplete; // 0x1060
- u32 EthernetPacketCount; // 0x1064
+typedef struct _TXDMA_t { /* Location: */
+ TXDMA_CSR_t csr; /* 0x1000 */
+ u32 pr_base_hi; /* 0x1004 */
+ u32 pr_base_lo; /* 0x1008 */
+ TXDMA_PR_NUM_DES_t pr_num_des; /* 0x100C */
+ DMA10W_t txq_wr_addr; /* 0x1010 */
+ DMA10W_t txq_wr_addr_ext; /* 0x1014 */
+ DMA10W_t txq_rd_addr; /* 0x1018 */
+ u32 dma_wb_base_hi; /* 0x101C */
+ u32 dma_wb_base_lo; /* 0x1020 */
+ DMA10W_t service_request; /* 0x1024 */
+ DMA10W_t service_complete; /* 0x1028 */
+ DMA4W_t cache_rd_index; /* 0x102C */
+ DMA4W_t cache_wr_index; /* 0x1030 */
+ TXDMA_ERROR_t TxDmaError; /* 0x1034 */
+ u32 DescAbortCount; /* 0x1038 */
+ u32 PayloadAbortCnt; /* 0x103c */
+ u32 WriteBackAbortCnt; /* 0x1040 */
+ u32 DescTimeoutCnt; /* 0x1044 */
+ u32 PayloadTimeoutCnt; /* 0x1048 */
+ u32 WriteBackTimeoutCnt; /* 0x104c */
+ u32 DescErrorCount; /* 0x1050 */
+ u32 PayloadErrorCnt; /* 0x1054 */
+ u32 WriteBackErrorCnt; /* 0x1058 */
+ u32 DroppedTLPCount; /* 0x105c */
+ DMA10W_t NewServiceComplete; /* 0x1060 */
+ u32 EthernetPacketCount; /* 0x1064 */
} TXDMA_t, *PTXDMA_t;
/* END OF TXDMA REGISTER ADDRESS MAP */
@@ -535,37 +535,37 @@ typedef union _RXDMA_CSR_t {
u32 value;
struct {
#ifdef _BIT_FIELDS_HTOL
- u32 unused2:14; // bits 18-31
- u32 halt_status:1; // bit 17
- u32 pkt_done_flush:1; // bit 16
- u32 pkt_drop_disable:1; // bit 15
- u32 unused1:1; // bit 14
- u32 fbr1_enable:1; // bit 13
- u32 fbr1_size:2; // bits 11-12
- u32 fbr0_enable:1; // bit 10
- u32 fbr0_size:2; // bits 8-9
- u32 dma_big_endian:1; // bit 7
- u32 pkt_big_endian:1; // bit 6
- u32 psr_big_endian:1; // bit 5
- u32 fbr_big_endian:1; // bit 4
- u32 tc:3; // bits 1-3
- u32 halt:1; // bit 0
-#else
- u32 halt:1; // bit 0
- u32 tc:3; // bits 1-3
- u32 fbr_big_endian:1; // bit 4
- u32 psr_big_endian:1; // bit 5
- u32 pkt_big_endian:1; // bit 6
- u32 dma_big_endian:1; // bit 7
- u32 fbr0_size:2; // bits 8-9
- u32 fbr0_enable:1; // bit 10
- u32 fbr1_size:2; // bits 11-12
- u32 fbr1_enable:1; // bit 13
- u32 unused1:1; // bit 14
- u32 pkt_drop_disable:1; // bit 15
- u32 pkt_done_flush:1; // bit 16
- u32 halt_status:1; // bit 17
- u32 unused2:14; // bits 18-31
+ u32 unused2:14; /* bits 18-31 */
+ u32 halt_status:1; /* bit 17 */
+ u32 pkt_done_flush:1; /* bit 16 */
+ u32 pkt_drop_disable:1; /* bit 15 */
+ u32 unused1:1; /* bit 14 */
+ u32 fbr1_enable:1; /* bit 13 */
+ u32 fbr1_size:2; /* bits 11-12 */
+ u32 fbr0_enable:1; /* bit 10 */
+ u32 fbr0_size:2; /* bits 8-9 */
+ u32 dma_big_endian:1; /* bit 7 */
+ u32 pkt_big_endian:1; /* bit 6 */
+ u32 psr_big_endian:1; /* bit 5 */
+ u32 fbr_big_endian:1; /* bit 4 */
+ u32 tc:3; /* bits 1-3 */
+ u32 halt:1; /* bit 0 */
+#else
+ u32 halt:1; /* bit 0 */
+ u32 tc:3; /* bits 1-3 */
+ u32 fbr_big_endian:1; /* bit 4 */
+ u32 psr_big_endian:1; /* bit 5 */
+ u32 pkt_big_endian:1; /* bit 6 */
+ u32 dma_big_endian:1; /* bit 7 */
+ u32 fbr0_size:2; /* bits 8-9 */
+ u32 fbr0_enable:1; /* bit 10 */
+ u32 fbr1_size:2; /* bits 11-12 */
+ u32 fbr1_enable:1; /* bit 13 */
+ u32 unused1:1; /* bit 14 */
+ u32 pkt_drop_disable:1; /* bit 15 */
+ u32 pkt_done_flush:1; /* bit 16 */
+ u32 halt_status:1; /* bit 17 */
+ u32 unused2:14; /* bits 18-31 */
#endif
} bits;
} RXDMA_CSR_t, *PRXDMA_CSR_t;
@@ -590,11 +590,11 @@ typedef union _RXDMA_NUM_PKT_DONE_t {
u32 value;
struct {
#ifdef _BIT_FIELDS_HTOL
- u32 unused:24; // bits 8-31
- u32 num_done:8; // bits 0-7
+ u32 unused:24; /* bits 8-31 */
+ u32 num_done:8; /* bits 0-7 */
#else
- u32 num_done:8; // bits 0-7
- u32 unused:24; // bits 8-31
+ u32 num_done:8; /* bits 0-7 */
+ u32 unused:24; /* bits 8-31 */
#endif
} bits;
} RXDMA_NUM_PKT_DONE_t, *PRXDMA_NUM_PKT_DONE_t;
@@ -607,11 +607,11 @@ typedef union _RXDMA_MAX_PKT_TIME_t {
u32 value;
struct {
#ifdef _BIT_FIELDS_HTOL
- u32 unused:14; // bits 18-31
- u32 time_done:18; // bits 0-17
+ u32 unused:14; /* bits 18-31 */
+ u32 time_done:18; /* bits 0-17 */
#else
- u32 time_done:18; // bits 0-17
- u32 unused:14; // bits 18-31
+ u32 time_done:18; /* bits 0-17 */
+ u32 unused:14; /* bits 18-31 */
#endif
} bits;
} RXDMA_MAX_PKT_TIME_t, *PRXDMA_MAX_PKT_TIME_t;
@@ -654,11 +654,11 @@ typedef union _RXDMA_PSR_NUM_DES_t {
u32 value;
struct {
#ifdef _BIT_FIELDS_HTOL
- u32 unused:20; // bits 12-31
- u32 psr_ndes:12; // bit 0-11
+ u32 unused:20; /* bits 12-31 */
+ u32 psr_ndes:12; /* bit 0-11 */
#else
- u32 psr_ndes:12; // bit 0-11
- u32 unused:20; // bits 12-31
+ u32 psr_ndes:12; /* bit 0-11 */
+ u32 unused:20; /* bits 12-31 */
#endif
} bits;
} RXDMA_PSR_NUM_DES_t, *PRXDMA_PSR_NUM_DES_t;
@@ -671,13 +671,13 @@ typedef union _RXDMA_PSR_AVAIL_OFFSET_t {
u32 value;
struct {
#ifdef _BIT_FIELDS_HTOL
- u32 unused:19; // bits 13-31
- u32 psr_avail_wrap:1; // bit 12
- u32 psr_avail:12; // bit 0-11
+ u32 unused:19; /* bits 13-31 */
+ u32 psr_avail_wrap:1; /* bit 12 */
+ u32 psr_avail:12; /* bit 0-11 */
#else
- u32 psr_avail:12; // bit 0-11
- u32 psr_avail_wrap:1; // bit 12
- u32 unused:19; // bits 13-31
+ u32 psr_avail:12; /* bit 0-11 */
+ u32 psr_avail_wrap:1; /* bit 12 */
+ u32 unused:19; /* bits 13-31 */
#endif
} bits;
} RXDMA_PSR_AVAIL_OFFSET_t, *PRXDMA_PSR_AVAIL_OFFSET_t;
@@ -690,13 +690,13 @@ typedef union _RXDMA_PSR_FULL_OFFSET_t {
u32 value;
struct {
#ifdef _BIT_FIELDS_HTOL
- u32 unused:19; // bits 13-31
- u32 psr_full_wrap:1; // bit 12
- u32 psr_full:12; // bit 0-11
+ u32 unused:19; /* bits 13-31 */
+ u32 psr_full_wrap:1; /* bit 12 */
+ u32 psr_full:12; /* bit 0-11 */
#else
- u32 psr_full:12; // bit 0-11
- u32 psr_full_wrap:1; // bit 12
- u32 unused:19; // bits 13-31
+ u32 psr_full:12; /* bit 0-11 */
+ u32 psr_full_wrap:1; /* bit 12 */
+ u32 unused:19; /* bits 13-31 */
#endif
} bits;
} RXDMA_PSR_FULL_OFFSET_t, *PRXDMA_PSR_FULL_OFFSET_t;
@@ -709,11 +709,11 @@ typedef union _RXDMA_PSR_ACCESS_INDEX_t {
u32 value;
struct {
#ifdef _BIT_FIELDS_HTOL
- u32 unused:27; // bits 5-31
- u32 psr_ai:5; // bits 0-4
+ u32 unused:27; /* bits 5-31 */
+ u32 psr_ai:5; /* bits 0-4 */
#else
- u32 psr_ai:5; // bits 0-4
- u32 unused:27; // bits 5-31
+ u32 psr_ai:5; /* bits 0-4 */
+ u32 unused:27; /* bits 5-31 */
#endif
} bits;
} RXDMA_PSR_ACCESS_INDEX_t, *PRXDMA_PSR_ACCESS_INDEX_t;
@@ -726,11 +726,11 @@ typedef union _RXDMA_PSR_MIN_DES_t {
u32 value;
struct {
#ifdef _BIT_FIELDS_HTOL
- u32 unused:20; // bits 12-31
- u32 psr_min:12; // bits 0-11
+ u32 unused:20; /* bits 12-31 */
+ u32 psr_min:12; /* bits 0-11 */
#else
- u32 psr_min:12; // bits 0-11
- u32 unused:20; // bits 12-31
+ u32 psr_min:12; /* bits 0-11 */
+ u32 unused:20; /* bits 12-31 */
#endif
} bits;
} RXDMA_PSR_MIN_DES_t, *PRXDMA_PSR_MIN_DES_t;
@@ -755,11 +755,11 @@ typedef union _RXDMA_FBR_NUM_DES_t {
u32 value;
struct {
#ifdef _BIT_FIELDS_HTOL
- u32 unused:22; // bits 10-31
- u32 fbr_ndesc:10; // bits 0-9
+ u32 unused:22; /* bits 10-31 */
+ u32 fbr_ndesc:10; /* bits 0-9 */
#else
- u32 fbr_ndesc:10; // bits 0-9
- u32 unused:22; // bits 10-31
+ u32 fbr_ndesc:10; /* bits 0-9 */
+ u32 unused:22; /* bits 10-31 */
#endif
} bits;
} RXDMA_FBR_NUM_DES_t, *PRXDMA_FBR_NUM_DES_t;
@@ -784,11 +784,11 @@ typedef union _RXDMA_FBC_RD_INDEX_t {
u32 value;
struct {
#ifdef _BIT_FIELDS_HTOL
- u32 unused:27; // bits 5-31
- u32 fbc_rdi:5; // bit 0-4
+ u32 unused:27; /* bits 5-31 */
+ u32 fbc_rdi:5; /* bit 0-4 */
#else
- u32 fbc_rdi:5; // bit 0-4
- u32 unused:27; // bits 5-31
+ u32 fbc_rdi:5; /* bit 0-4 */
+ u32 unused:27; /* bits 5-31 */
#endif
} bits;
} RXDMA_FBC_RD_INDEX_t, *PRXDMA_FBC_RD_INDEX_t;
@@ -801,11 +801,11 @@ typedef union _RXDMA_FBR_MIN_DES_t {
u32 value;
struct {
#ifdef _BIT_FIELDS_HTOL
- u32 unused:22; // bits 10-31
- u32 fbr_min:10; // bits 0-9
+ u32 unused:22; /* bits 10-31 */
+ u32 fbr_min:10; /* bits 0-9 */
#else
- u32 fbr_min:10; // bits 0-9
- u32 unused:22; // bits 10-31
+ u32 fbr_min:10; /* bits 0-9 */
+ u32 unused:22; /* bits 10-31 */
#endif
} bits;
} RXDMA_FBR_MIN_DES_t, *PRXDMA_FBR_MIN_DES_t;
@@ -850,36 +850,36 @@ typedef union _RXDMA_FBR_MIN_DES_t {
* Rx DMA Module of JAGCore Address Mapping
* Located at address 0x2000
*/
-typedef struct _RXDMA_t { // Location:
- RXDMA_CSR_t csr; // 0x2000
- u32 dma_wb_base_lo; // 0x2004
- u32 dma_wb_base_hi; // 0x2008
- RXDMA_NUM_PKT_DONE_t num_pkt_done; // 0x200C
- RXDMA_MAX_PKT_TIME_t max_pkt_time; // 0x2010
- DMA10W_t rxq_rd_addr; // 0x2014
- DMA10W_t rxq_rd_addr_ext; // 0x2018
- DMA10W_t rxq_wr_addr; // 0x201C
- u32 psr_base_lo; // 0x2020
- u32 psr_base_hi; // 0x2024
- RXDMA_PSR_NUM_DES_t psr_num_des; // 0x2028
- RXDMA_PSR_AVAIL_OFFSET_t psr_avail_offset; // 0x202C
- RXDMA_PSR_FULL_OFFSET_t psr_full_offset; // 0x2030
- RXDMA_PSR_ACCESS_INDEX_t psr_access_index; // 0x2034
- RXDMA_PSR_MIN_DES_t psr_min_des; // 0x2038
- u32 fbr0_base_lo; // 0x203C
- u32 fbr0_base_hi; // 0x2040
- RXDMA_FBR_NUM_DES_t fbr0_num_des; // 0x2044
- DMA10W_t fbr0_avail_offset; // 0x2048
- DMA10W_t fbr0_full_offset; // 0x204C
- RXDMA_FBC_RD_INDEX_t fbr0_rd_index; // 0x2050
- RXDMA_FBR_MIN_DES_t fbr0_min_des; // 0x2054
- u32 fbr1_base_lo; // 0x2058
- u32 fbr1_base_hi; // 0x205C
- RXDMA_FBR_NUM_DES_t fbr1_num_des; // 0x2060
- DMA10W_t fbr1_avail_offset; // 0x2064
- DMA10W_t fbr1_full_offset; // 0x2068
- RXDMA_FBC_RD_INDEX_t fbr1_rd_index; // 0x206C
- RXDMA_FBR_MIN_DES_t fbr1_min_des; // 0x2070
+typedef struct _RXDMA_t { /* Location: */
+ RXDMA_CSR_t csr; /* 0x2000 */
+ u32 dma_wb_base_lo; /* 0x2004 */
+ u32 dma_wb_base_hi; /* 0x2008 */
+ RXDMA_NUM_PKT_DONE_t num_pkt_done; /* 0x200C */
+ RXDMA_MAX_PKT_TIME_t max_pkt_time; /* 0x2010 */
+ DMA10W_t rxq_rd_addr; /* 0x2014 */
+ DMA10W_t rxq_rd_addr_ext; /* 0x2018 */
+ DMA10W_t rxq_wr_addr; /* 0x201C */
+ u32 psr_base_lo; /* 0x2020 */
+ u32 psr_base_hi; /* 0x2024 */
+ RXDMA_PSR_NUM_DES_t psr_num_des; /* 0x2028 */
+ RXDMA_PSR_AVAIL_OFFSET_t psr_avail_offset; /* 0x202C */
+ RXDMA_PSR_FULL_OFFSET_t psr_full_offset; /* 0x2030 */
+ RXDMA_PSR_ACCESS_INDEX_t psr_access_index; /* 0x2034 */
+ RXDMA_PSR_MIN_DES_t psr_min_des; /* 0x2038 */
+ u32 fbr0_base_lo; /* 0x203C */
+ u32 fbr0_base_hi; /* 0x2040 */
+ RXDMA_FBR_NUM_DES_t fbr0_num_des; /* 0x2044 */
+ DMA10W_t fbr0_avail_offset; /* 0x2048 */
+ DMA10W_t fbr0_full_offset; /* 0x204C */
+ RXDMA_FBC_RD_INDEX_t fbr0_rd_index; /* 0x2050 */
+ RXDMA_FBR_MIN_DES_t fbr0_min_des; /* 0x2054 */
+ u32 fbr1_base_lo; /* 0x2058 */
+ u32 fbr1_base_hi; /* 0x205C */
+ RXDMA_FBR_NUM_DES_t fbr1_num_des; /* 0x2060 */
+ DMA10W_t fbr1_avail_offset; /* 0x2064 */
+ DMA10W_t fbr1_full_offset; /* 0x2068 */
+ RXDMA_FBC_RD_INDEX_t fbr1_rd_index; /* 0x206C */
+ RXDMA_FBR_MIN_DES_t fbr1_min_des; /* 0x2070 */
} RXDMA_t, *PRXDMA_t;
/* END OF RXDMA REGISTER ADDRESS MAP */
@@ -895,25 +895,25 @@ typedef union _TXMAC_CTL_t {
u32 value;
struct {
#ifdef _BIT_FIELDS_HTOL
- u32 unused:24; // bits 8-31
- u32 cklseg_diable:1; // bit 7
- u32 ckbcnt_disable:1; // bit 6
- u32 cksegnum:1; // bit 5
- u32 async_disable:1; // bit 4
- u32 fc_disable:1; // bit 3
- u32 mcif_disable:1; // bit 2
- u32 mif_disable:1; // bit 1
- u32 txmac_en:1; // bit 0
+ u32 unused:24; /* bits 8-31 */
+ u32 cklseg_diable:1; /* bit 7 */
+ u32 ckbcnt_disable:1; /* bit 6 */
+ u32 cksegnum:1; /* bit 5 */
+ u32 async_disable:1; /* bit 4 */
+ u32 fc_disable:1; /* bit 3 */
+ u32 mcif_disable:1; /* bit 2 */
+ u32 mif_disable:1; /* bit 1 */
+ u32 txmac_en:1; /* bit 0 */
#else
- u32 txmac_en:1; // bit 0
- u32 mif_disable:1; // bit 1 mac interface
- u32 mcif_disable:1; // bit 2 mem. contr. interface
- u32 fc_disable:1; // bit 3
- u32 async_disable:1; // bit 4
- u32 cksegnum:1; // bit 5
- u32 ckbcnt_disable:1; // bit 6
- u32 cklseg_diable:1; // bit 7
- u32 unused:24; // bits 8-31
+ u32 txmac_en:1; /* bit 0 */
+ u32 mif_disable:1; /* bit 1 mac interface */
+ u32 mcif_disable:1; /* bit 2 mem. contr. interface */
+ u32 fc_disable:1; /* bit 3 */
+ u32 async_disable:1; /* bit 4 */
+ u32 cksegnum:1; /* bit 5 */
+ u32 ckbcnt_disable:1; /* bit 6 */
+ u32 cklseg_diable:1; /* bit 7 */
+ u32 unused:24; /* bits 8-31 */
#endif
} bits;
} TXMAC_CTL_t, *PTXMAC_CTL_t;
@@ -926,15 +926,15 @@ typedef union _TXMAC_SHADOW_PTR_t {
u32 value;
struct {
#ifdef _BIT_FIELDS_HTOL
- u32 reserved2:5; // bits 27-31
- u32 txq_rd_ptr:11; // bits 16-26
- u32 reserved:5; // bits 11-15
- u32 txq_wr_ptr:11; // bits 0-10
+ u32 reserved2:5; /* bits 27-31 */
+ u32 txq_rd_ptr:11; /* bits 16-26 */
+ u32 reserved:5; /* bits 11-15 */
+ u32 txq_wr_ptr:11; /* bits 0-10 */
#else
- u32 txq_wr_ptr:11; // bits 0-10
- u32 reserved:5; // bits 11-15
- u32 txq_rd_ptr:11; // bits 16-26
- u32 reserved2:5; // bits 27-31
+ u32 txq_wr_ptr:11; /* bits 0-10 */
+ u32 reserved:5; /* bits 11-15 */
+ u32 txq_rd_ptr:11; /* bits 16-26 */
+ u32 reserved2:5; /* bits 27-31 */
#endif
} bits;
} TXMAC_SHADOW_PTR_t, *PTXMAC_SHADOW_PTR_t;
@@ -947,15 +947,15 @@ typedef union _TXMAC_ERR_CNT_t {
u32 value;
struct {
#ifdef _BIT_FIELDS_HTOL
- u32 unused:20; // bits 12-31
- u32 reserved:4; // bits 8-11
- u32 txq_underrun:4; // bits 4-7
- u32 fifo_underrun:4; // bits 0-3
+ u32 unused:20; /* bits 12-31 */
+ u32 reserved:4; /* bits 8-11 */
+ u32 txq_underrun:4; /* bits 4-7 */
+ u32 fifo_underrun:4; /* bits 0-3 */
#else
- u32 fifo_underrun:4; // bits 0-3
- u32 txq_underrun:4; // bits 4-7
- u32 reserved:4; // bits 8-11
- u32 unused:20; // bits 12-31
+ u32 fifo_underrun:4; /* bits 0-3 */
+ u32 txq_underrun:4; /* bits 4-7 */
+ u32 reserved:4; /* bits 8-11 */
+ u32 unused:20; /* bits 12-31 */
#endif
} bits;
} TXMAC_ERR_CNT_t, *PTXMAC_ERR_CNT_t;
@@ -968,11 +968,11 @@ typedef union _TXMAC_MAX_FILL_t {
u32 value;
struct {
#ifdef _BIT_FIELDS_HTOL
- u32 unused:20; // bits 12-31
- u32 max_fill:12; // bits 0-11
+ u32 unused:20; /* bits 12-31 */
+ u32 max_fill:12; /* bits 0-11 */
#else
- u32 max_fill:12; // bits 0-11
- u32 unused:20; // bits 12-31
+ u32 max_fill:12; /* bits 0-11 */
+ u32 unused:20; /* bits 12-31 */
#endif
} bits;
} TXMAC_MAX_FILL_t, *PTXMAC_MAX_FILL_t;
@@ -985,11 +985,11 @@ typedef union _TXMAC_CF_PARAM_t {
u32 value;
struct {
#ifdef _BIT_FIELDS_HTOL
- u32 cfep:16; // bits 16-31
- u32 cfpt:16; // bits 0-15
+ u32 cfep:16; /* bits 16-31 */
+ u32 cfpt:16; /* bits 0-15 */
#else
- u32 cfpt:16; // bits 0-15
- u32 cfep:16; // bits 16-31
+ u32 cfpt:16; /* bits 0-15 */
+ u32 cfep:16; /* bits 16-31 */
#endif
} bits;
} TXMAC_CF_PARAM_t, *PTXMAC_CF_PARAM_t;
@@ -1002,17 +1002,17 @@ typedef union _TXMAC_TXTEST_t {
u32 value;
struct {
#ifdef _BIT_FIELDS_HTOL
- u32 unused2:15; // bits 17-31
- u32 reserved1:1; // bit 16
- u32 txtest_en:1; // bit 15
- u32 unused1:4; // bits 11-14
- u32 txqtest_ptr:11; // bits 0-11
+ u32 unused2:15; /* bits 17-31 */
+ u32 reserved1:1; /* bit 16 */
+ u32 txtest_en:1; /* bit 15 */
+ u32 unused1:4; /* bits 11-14 */
+ u32 txqtest_ptr:11; /* bits 0-11 */
#else
- u32 txqtest_ptr:11; // bits 0-10
- u32 unused1:4; // bits 11-14
- u32 txtest_en:1; // bit 15
- u32 reserved1:1; // bit 16
- u32 unused2:15; // bits 17-31
+ u32 txqtest_ptr:11; /* bits 0-10 */
+ u32 unused1:4; /* bits 11-14 */
+ u32 txtest_en:1; /* bit 15 */
+ u32 reserved1:1; /* bit 16 */
+ u32 unused2:15; /* bits 17-31 */
#endif
} bits;
} TXMAC_TXTEST_t, *PTXMAC_TXTEST_t;
@@ -1025,25 +1025,25 @@ typedef union _TXMAC_ERR_t {
u32 value;
struct {
#ifdef _BIT_FIELDS_HTOL
- u32 unused2:23; // bits 9-31
- u32 fifo_underrun:1; // bit 8
- u32 unused1:2; // bits 6-7
- u32 ctrl2_err:1; // bit 5
- u32 txq_underrun:1; // bit 4
- u32 bcnt_err:1; // bit 3
- u32 lseg_err:1; // bit 2
- u32 segnum_err:1; // bit 1
- u32 seg0_err:1; // bit 0
+ u32 unused2:23; /* bits 9-31 */
+ u32 fifo_underrun:1; /* bit 8 */
+ u32 unused1:2; /* bits 6-7 */
+ u32 ctrl2_err:1; /* bit 5 */
+ u32 txq_underrun:1; /* bit 4 */
+ u32 bcnt_err:1; /* bit 3 */
+ u32 lseg_err:1; /* bit 2 */
+ u32 segnum_err:1; /* bit 1 */
+ u32 seg0_err:1; /* bit 0 */
#else
- u32 seg0_err:1; // bit 0
- u32 segnum_err:1; // bit 1
- u32 lseg_err:1; // bit 2
- u32 bcnt_err:1; // bit 3
- u32 txq_underrun:1; // bit 4
- u32 ctrl2_err:1; // bit 5
- u32 unused1:2; // bits 6-7
- u32 fifo_underrun:1; // bit 8
- u32 unused2:23; // bits 9-31
+ u32 seg0_err:1; /* bit 0 */
+ u32 segnum_err:1; /* bit 1 */
+ u32 lseg_err:1; /* bit 2 */
+ u32 bcnt_err:1; /* bit 3 */
+ u32 txq_underrun:1; /* bit 4 */
+ u32 ctrl2_err:1; /* bit 5 */
+ u32 unused1:2; /* bits 6-7 */
+ u32 fifo_underrun:1; /* bit 8 */
+ u32 unused2:23; /* bits 9-31 */
#endif
} bits;
} TXMAC_ERR_t, *PTXMAC_ERR_t;
@@ -1056,25 +1056,25 @@ typedef union _TXMAC_ERR_INT_t {
u32 value;
struct {
#ifdef _BIT_FIELDS_HTOL
- u32 unused2:23; // bits 9-31
- u32 fifo_underrun:1; // bit 8
- u32 unused1:2; // bits 6-7
- u32 ctrl2_err:1; // bit 5
- u32 txq_underrun:1; // bit 4
- u32 bcnt_err:1; // bit 3
- u32 lseg_err:1; // bit 2
- u32 segnum_err:1; // bit 1
- u32 seg0_err:1; // bit 0
+ u32 unused2:23; /* bits 9-31 */
+ u32 fifo_underrun:1; /* bit 8 */
+ u32 unused1:2; /* bits 6-7 */
+ u32 ctrl2_err:1; /* bit 5 */
+ u32 txq_underrun:1; /* bit 4 */
+ u32 bcnt_err:1; /* bit 3 */
+ u32 lseg_err:1; /* bit 2 */
+ u32 segnum_err:1; /* bit 1 */
+ u32 seg0_err:1; /* bit 0 */
#else
- u32 seg0_err:1; // bit 0
- u32 segnum_err:1; // bit 1
- u32 lseg_err:1; // bit 2
- u32 bcnt_err:1; // bit 3
- u32 txq_underrun:1; // bit 4
- u32 ctrl2_err:1; // bit 5
- u32 unused1:2; // bits 6-7
- u32 fifo_underrun:1; // bit 8
- u32 unused2:23; // bits 9-31
+ u32 seg0_err:1; /* bit 0 */
+ u32 segnum_err:1; /* bit 1 */
+ u32 lseg_err:1; /* bit 2 */
+ u32 bcnt_err:1; /* bit 3 */
+ u32 txq_underrun:1; /* bit 4 */
+ u32 ctrl2_err:1; /* bit 5 */
+ u32 unused1:2; /* bits 6-7 */
+ u32 fifo_underrun:1; /* bit 8 */
+ u32 unused2:23; /* bits 9-31 */
#endif
} bits;
} TXMAC_ERR_INT_t, *PTXMAC_ERR_INT_t;
@@ -1087,13 +1087,13 @@ typedef union _TXMAC_CP_CTRL_t {
u32 value;
struct {
#ifdef _BIT_FIELDS_HTOL
- u32 unused:30; // bits 2-31
- u32 bp_req:1; // bit 1
- u32 bp_xonxoff:1; // bit 0
+ u32 unused:30; /* bits 2-31 */
+ u32 bp_req:1; /* bit 1 */
+ u32 bp_xonxoff:1; /* bit 0 */
#else
- u32 bp_xonxoff:1; // bit 0
- u32 bp_req:1; // bit 1
- u32 unused:30; // bits 2-31
+ u32 bp_xonxoff:1; /* bit 0 */
+ u32 bp_req:1; /* bit 1 */
+ u32 unused:30; /* bits 2-31 */
#endif
} bits;
} TXMAC_BP_CTRL_t, *PTXMAC_BP_CTRL_t;
@@ -1101,16 +1101,16 @@ typedef union _TXMAC_CP_CTRL_t {
/*
* Tx MAC Module of JAGCore Address Mapping
*/
-typedef struct _TXMAC_t { // Location:
- TXMAC_CTL_t ctl; // 0x3000
- TXMAC_SHADOW_PTR_t shadow_ptr; // 0x3004
- TXMAC_ERR_CNT_t err_cnt; // 0x3008
- TXMAC_MAX_FILL_t max_fill; // 0x300C
- TXMAC_CF_PARAM_t cf_param; // 0x3010
- TXMAC_TXTEST_t tx_test; // 0x3014
- TXMAC_ERR_t err; // 0x3018
- TXMAC_ERR_INT_t err_int; // 0x301C
- TXMAC_BP_CTRL_t bp_ctrl; // 0x3020
+typedef struct _TXMAC_t { /* Location: */
+ TXMAC_CTL_t ctl; /* 0x3000 */
+ TXMAC_SHADOW_PTR_t shadow_ptr; /* 0x3004 */
+ TXMAC_ERR_CNT_t err_cnt; /* 0x3008 */
+ TXMAC_MAX_FILL_t max_fill; /* 0x300C */
+ TXMAC_CF_PARAM_t cf_param; /* 0x3010 */
+ TXMAC_TXTEST_t tx_test; /* 0x3014 */
+ TXMAC_ERR_t err; /* 0x3018 */
+ TXMAC_ERR_INT_t err_int; /* 0x301C */
+ TXMAC_BP_CTRL_t bp_ctrl; /* 0x3020 */
} TXMAC_t, *PTXMAC_t;
/* END OF TXMAC REGISTER ADDRESS MAP */
@@ -1125,23 +1125,23 @@ typedef union _RXMAC_CTRL_t {
u32 value;
struct {
#ifdef _BIT_FIELDS_HTOL
- u32 reserved:25; // bits 7-31
- u32 rxmac_int_disable:1; // bit 6
- u32 async_disable:1; // bit 5
- u32 mif_disable:1; // bit 4
- u32 wol_disable:1; // bit 3
- u32 pkt_filter_disable:1; // bit 2
- u32 mcif_disable:1; // bit 1
- u32 rxmac_en:1; // bit 0
+ u32 reserved:25; /* bits 7-31 */
+ u32 rxmac_int_disable:1; /* bit 6 */
+ u32 async_disable:1; /* bit 5 */
+ u32 mif_disable:1; /* bit 4 */
+ u32 wol_disable:1; /* bit 3 */
+ u32 pkt_filter_disable:1; /* bit 2 */
+ u32 mcif_disable:1; /* bit 1 */
+ u32 rxmac_en:1; /* bit 0 */
#else
- u32 rxmac_en:1; // bit 0
- u32 mcif_disable:1; // bit 1
- u32 pkt_filter_disable:1; // bit 2
- u32 wol_disable:1; // bit 3
- u32 mif_disable:1; // bit 4
- u32 async_disable:1; // bit 5
- u32 rxmac_int_disable:1; // bit 6
- u32 reserved:25; // bits 7-31
+ u32 rxmac_en:1; /* bit 0 */
+ u32 mcif_disable:1; /* bit 1 */
+ u32 pkt_filter_disable:1; /* bit 2 */
+ u32 wol_disable:1; /* bit 3 */
+ u32 mif_disable:1; /* bit 4 */
+ u32 async_disable:1; /* bit 5 */
+ u32 rxmac_int_disable:1; /* bit 6 */
+ u32 reserved:25; /* bits 7-31 */
#endif
} bits;
} RXMAC_CTRL_t, *PRXMAC_CTRL_t;
@@ -1154,35 +1154,35 @@ typedef union _RXMAC_WOL_CTL_CRC0_t {
u32 value;
struct {
#ifdef _BIT_FIELDS_HTOL
- u32 crc0:16; // bits 16-31
- u32 reserve:4; // bits 12-15
- u32 ignore_pp:1; // bit 11
- u32 ignore_mp:1; // bit 10
- u32 clr_intr:1; // bit 9
- u32 ignore_link_chg:1; // bit 8
- u32 ignore_uni:1; // bit 7
- u32 ignore_multi:1; // bit 6
- u32 ignore_broad:1; // bit 5
- u32 valid_crc4:1; // bit 4
- u32 valid_crc3:1; // bit 3
- u32 valid_crc2:1; // bit 2
- u32 valid_crc1:1; // bit 1
- u32 valid_crc0:1; // bit 0
-#else
- u32 valid_crc0:1; // bit 0
- u32 valid_crc1:1; // bit 1
- u32 valid_crc2:1; // bit 2
- u32 valid_crc3:1; // bit 3
- u32 valid_crc4:1; // bit 4
- u32 ignore_broad:1; // bit 5
- u32 ignore_multi:1; // bit 6
- u32 ignore_uni:1; // bit 7
- u32 ignore_link_chg:1; // bit 8
- u32 clr_intr:1; // bit 9
- u32 ignore_mp:1; // bit 10
- u32 ignore_pp:1; // bit 11
- u32 reserve:4; // bits 12-15
- u32 crc0:16; // bits 16-31
+ u32 crc0:16; /* bits 16-31 */
+ u32 reserve:4; /* bits 12-15 */
+ u32 ignore_pp:1; /* bit 11 */
+ u32 ignore_mp:1; /* bit 10 */
+ u32 clr_intr:1; /* bit 9 */
+ u32 ignore_link_chg:1; /* bit 8 */
+ u32 ignore_uni:1; /* bit 7 */
+ u32 ignore_multi:1; /* bit 6 */
+ u32 ignore_broad:1; /* bit 5 */
+ u32 valid_crc4:1; /* bit 4 */
+ u32 valid_crc3:1; /* bit 3 */
+ u32 valid_crc2:1; /* bit 2 */
+ u32 valid_crc1:1; /* bit 1 */
+ u32 valid_crc0:1; /* bit 0 */
+#else
+ u32 valid_crc0:1; /* bit 0 */
+ u32 valid_crc1:1; /* bit 1 */
+ u32 valid_crc2:1; /* bit 2 */
+ u32 valid_crc3:1; /* bit 3 */
+ u32 valid_crc4:1; /* bit 4 */
+ u32 ignore_broad:1; /* bit 5 */
+ u32 ignore_multi:1; /* bit 6 */
+ u32 ignore_uni:1; /* bit 7 */
+ u32 ignore_link_chg:1; /* bit 8 */
+ u32 clr_intr:1; /* bit 9 */
+ u32 ignore_mp:1; /* bit 10 */
+ u32 ignore_pp:1; /* bit 11 */
+ u32 reserve:4; /* bits 12-15 */
+ u32 crc0:16; /* bits 16-31 */
#endif
} bits;
} RXMAC_WOL_CTL_CRC0_t, *PRXMAC_WOL_CTL_CRC0_t;
@@ -1195,11 +1195,11 @@ typedef union _RXMAC_WOL_CRC12_t {
u32 value;
struct {
#ifdef _BIT_FIELDS_HTOL
- u32 crc2:16; // bits 16-31
- u32 crc1:16; // bits 0-15
+ u32 crc2:16; /* bits 16-31 */
+ u32 crc1:16; /* bits 0-15 */
#else
- u32 crc1:16; // bits 0-15
- u32 crc2:16; // bits 16-31
+ u32 crc1:16; /* bits 0-15 */
+ u32 crc2:16; /* bits 16-31 */
#endif
} bits;
} RXMAC_WOL_CRC12_t, *PRXMAC_WOL_CRC12_t;
@@ -1212,11 +1212,11 @@ typedef union _RXMAC_WOL_CRC34_t {
u32 value;
struct {
#ifdef _BIT_FIELDS_HTOL
- u32 crc4:16; // bits 16-31
- u32 crc3:16; // bits 0-15
+ u32 crc4:16; /* bits 16-31 */
+ u32 crc3:16; /* bits 0-15 */
#else
- u32 crc3:16; // bits 0-15
- u32 crc4:16; // bits 16-31
+ u32 crc3:16; /* bits 0-15 */
+ u32 crc4:16; /* bits 16-31 */
#endif
} bits;
} RXMAC_WOL_CRC34_t, *PRXMAC_WOL_CRC34_t;
@@ -1229,15 +1229,15 @@ typedef union _RXMAC_WOL_SA_LO_t {
u32 value;
struct {
#ifdef _BIT_FIELDS_HTOL
- u32 sa3:8; // bits 24-31
- u32 sa4:8; // bits 16-23
- u32 sa5:8; // bits 8-15
- u32 sa6:8; // bits 0-7
+ u32 sa3:8; /* bits 24-31 */
+ u32 sa4:8; /* bits 16-23 */
+ u32 sa5:8; /* bits 8-15 */
+ u32 sa6:8; /* bits 0-7 */
#else
- u32 sa6:8; // bits 0-7
- u32 sa5:8; // bits 8-15
- u32 sa4:8; // bits 16-23
- u32 sa3:8; // bits 24-31
+ u32 sa6:8; /* bits 0-7 */
+ u32 sa5:8; /* bits 8-15 */
+ u32 sa4:8; /* bits 16-23 */
+ u32 sa3:8; /* bits 24-31 */
#endif
} bits;
} RXMAC_WOL_SA_LO_t, *PRXMAC_WOL_SA_LO_t;
@@ -1250,13 +1250,13 @@ typedef union _RXMAC_WOL_SA_HI_t {
u32 value;
struct {
#ifdef _BIT_FIELDS_HTOL
- u32 reserved:16; // bits 16-31
- u32 sa1:8; // bits 8-15
- u32 sa2:8; // bits 0-7
+ u32 reserved:16; /* bits 16-31 */
+ u32 sa1:8; /* bits 8-15 */
+ u32 sa2:8; /* bits 0-7 */
#else
- u32 sa2:8; // bits 0-7
- u32 sa1:8; // bits 8-15
- u32 reserved:16; // bits 16-31
+ u32 sa2:8; /* bits 0-7 */
+ u32 sa1:8; /* bits 8-15 */
+ u32 reserved:16; /* bits 16-31 */
#endif
} bits;
} RXMAC_WOL_SA_HI_t, *PRXMAC_WOL_SA_HI_t;
@@ -1275,15 +1275,15 @@ typedef union _RXMAC_UNI_PF_ADDR1_t {
u32 value;
struct {
#ifdef _BIT_FIELDS_HTOL
- u32 addr1_3:8; // bits 24-31
- u32 addr1_4:8; // bits 16-23
- u32 addr1_5:8; // bits 8-15
- u32 addr1_6:8; // bits 0-7
+ u32 addr1_3:8; /* bits 24-31 */
+ u32 addr1_4:8; /* bits 16-23 */
+ u32 addr1_5:8; /* bits 8-15 */
+ u32 addr1_6:8; /* bits 0-7 */
#else
- u32 addr1_6:8; // bits 0-7
- u32 addr1_5:8; // bits 8-15
- u32 addr1_4:8; // bits 16-23
- u32 addr1_3:8; // bits 24-31
+ u32 addr1_6:8; /* bits 0-7 */
+ u32 addr1_5:8; /* bits 8-15 */
+ u32 addr1_4:8; /* bits 16-23 */
+ u32 addr1_3:8; /* bits 24-31 */
#endif
} bits;
} RXMAC_UNI_PF_ADDR1_t, *PRXMAC_UNI_PF_ADDR1_t;
@@ -1296,15 +1296,15 @@ typedef union _RXMAC_UNI_PF_ADDR2_t {
u32 value;
struct {
#ifdef _BIT_FIELDS_HTOL
- u32 addr2_3:8; // bits 24-31
- u32 addr2_4:8; // bits 16-23
- u32 addr2_5:8; // bits 8-15
- u32 addr2_6:8; // bits 0-7
+ u32 addr2_3:8; /* bits 24-31 */
+ u32 addr2_4:8; /* bits 16-23 */
+ u32 addr2_5:8; /* bits 8-15 */
+ u32 addr2_6:8; /* bits 0-7 */
#else
- u32 addr2_6:8; // bits 0-7
- u32 addr2_5:8; // bits 8-15
- u32 addr2_4:8; // bits 16-23
- u32 addr2_3:8; // bits 24-31
+ u32 addr2_6:8; /* bits 0-7 */
+ u32 addr2_5:8; /* bits 8-15 */
+ u32 addr2_4:8; /* bits 16-23 */
+ u32 addr2_3:8; /* bits 24-31 */
#endif
} bits;
} RXMAC_UNI_PF_ADDR2_t, *PRXMAC_UNI_PF_ADDR2_t;
@@ -1317,15 +1317,15 @@ typedef union _RXMAC_UNI_PF_ADDR3_t {
u32 value;
struct {
#ifdef _BIT_FIELDS_HTOL
- u32 addr2_1:8; // bits 24-31
- u32 addr2_2:8; // bits 16-23
- u32 addr1_1:8; // bits 8-15
- u32 addr1_2:8; // bits 0-7
+ u32 addr2_1:8; /* bits 24-31 */
+ u32 addr2_2:8; /* bits 16-23 */
+ u32 addr1_1:8; /* bits 8-15 */
+ u32 addr1_2:8; /* bits 0-7 */
#else
- u32 addr1_2:8; // bits 0-7
- u32 addr1_1:8; // bits 8-15
- u32 addr2_2:8; // bits 16-23
- u32 addr2_1:8; // bits 24-31
+ u32 addr1_2:8; /* bits 0-7 */
+ u32 addr1_1:8; /* bits 8-15 */
+ u32 addr2_2:8; /* bits 16-23 */
+ u32 addr2_1:8; /* bits 24-31 */
#endif
} bits;
} RXMAC_UNI_PF_ADDR3_t, *PRXMAC_UNI_PF_ADDR3_t;
@@ -1344,21 +1344,21 @@ typedef union _RXMAC_PF_CTRL_t {
u32 value;
struct {
#ifdef _BIT_FIELDS_HTOL
- u32 unused2:9; // bits 23-31
- u32 min_pkt_size:7; // bits 16-22
- u32 unused1:12; // bits 4-15
- u32 filter_frag_en:1; // bit 3
- u32 filter_uni_en:1; // bit 2
- u32 filter_multi_en:1; // bit 1
- u32 filter_broad_en:1; // bit 0
+ u32 unused2:9; /* bits 23-31 */
+ u32 min_pkt_size:7; /* bits 16-22 */
+ u32 unused1:12; /* bits 4-15 */
+ u32 filter_frag_en:1; /* bit 3 */
+ u32 filter_uni_en:1; /* bit 2 */
+ u32 filter_multi_en:1; /* bit 1 */
+ u32 filter_broad_en:1; /* bit 0 */
#else
- u32 filter_broad_en:1; // bit 0
- u32 filter_multi_en:1; // bit 1
- u32 filter_uni_en:1; // bit 2
- u32 filter_frag_en:1; // bit 3
- u32 unused1:12; // bits 4-15
- u32 min_pkt_size:7; // bits 16-22
- u32 unused2:9; // bits 23-31
+ u32 filter_broad_en:1; /* bit 0 */
+ u32 filter_multi_en:1; /* bit 1 */
+ u32 filter_uni_en:1; /* bit 2 */
+ u32 filter_frag_en:1; /* bit 3 */
+ u32 unused1:12; /* bits 4-15 */
+ u32 min_pkt_size:7; /* bits 16-22 */
+ u32 unused2:9; /* bits 23-31 */
#endif
} bits;
} RXMAC_PF_CTRL_t, *PRXMAC_PF_CTRL_t;
@@ -1371,15 +1371,15 @@ typedef union _RXMAC_MCIF_CTRL_MAX_SEG_t {
u32 value;
struct {
#ifdef _BIT_FIELDS_HTOL
- u32 reserved:22; // bits 10-31
- u32 max_size:8; // bits 2-9
- u32 fc_en:1; // bit 1
- u32 seg_en:1; // bit 0
+ u32 reserved:22; /* bits 10-31 */
+ u32 max_size:8; /* bits 2-9 */
+ u32 fc_en:1; /* bit 1 */
+ u32 seg_en:1; /* bit 0 */
#else
- u32 seg_en:1; // bit 0
- u32 fc_en:1; // bit 1
- u32 max_size:8; // bits 2-9
- u32 reserved:22; // bits 10-31
+ u32 seg_en:1; /* bit 0 */
+ u32 fc_en:1; /* bit 1 */
+ u32 max_size:8; /* bits 2-9 */
+ u32 reserved:22; /* bits 10-31 */
#endif
} bits;
} RXMAC_MCIF_CTRL_MAX_SEG_t, *PRXMAC_MCIF_CTRL_MAX_SEG_t;
@@ -1392,15 +1392,15 @@ typedef union _RXMAC_MCIF_WATER_MARK_t {
u32 value;
struct {
#ifdef _BIT_FIELDS_HTOL
- u32 reserved2:6; // bits 26-31
- u32 mark_hi:10; // bits 16-25
- u32 reserved1:6; // bits 10-15
- u32 mark_lo:10; // bits 0-9
+ u32 reserved2:6; /* bits 26-31 */
+ u32 mark_hi:10; /* bits 16-25 */
+ u32 reserved1:6; /* bits 10-15 */
+ u32 mark_lo:10; /* bits 0-9 */
#else
- u32 mark_lo:10; // bits 0-9
- u32 reserved1:6; // bits 10-15
- u32 mark_hi:10; // bits 16-25
- u32 reserved2:6; // bits 26-31
+ u32 mark_lo:10; /* bits 0-9 */
+ u32 reserved1:6; /* bits 10-15 */
+ u32 mark_hi:10; /* bits 16-25 */
+ u32 reserved2:6; /* bits 26-31 */
#endif
} bits;
} RXMAC_MCIF_WATER_MARK_t, *PRXMAC_MCIF_WATER_MARK_t;
@@ -1413,15 +1413,15 @@ typedef union _RXMAC_RXQ_DIAG_t {
u32 value;
struct {
#ifdef _BIT_FIELDS_HTOL
- u32 reserved2:6; // bits 26-31
- u32 rd_ptr:10; // bits 16-25
- u32 reserved1:6; // bits 10-15
- u32 wr_ptr:10; // bits 0-9
+ u32 reserved2:6; /* bits 26-31 */
+ u32 rd_ptr:10; /* bits 16-25 */
+ u32 reserved1:6; /* bits 10-15 */
+ u32 wr_ptr:10; /* bits 0-9 */
#else
- u32 wr_ptr:10; // bits 0-9
- u32 reserved1:6; // bits 10-15
- u32 rd_ptr:10; // bits 16-25
- u32 reserved2:6; // bits 26-31
+ u32 wr_ptr:10; /* bits 0-9 */
+ u32 reserved1:6; /* bits 10-15 */
+ u32 rd_ptr:10; /* bits 16-25 */
+ u32 reserved2:6; /* bits 26-31 */
#endif
} bits;
} RXMAC_RXQ_DIAG_t, *PRXMAC_RXQ_DIAG_t;
@@ -1434,15 +1434,15 @@ typedef union _RXMAC_SPACE_AVAIL_t {
u32 value;
struct {
#ifdef _BIT_FIELDS_HTOL
- u32 reserved2:15; // bits 17-31
- u32 space_avail_en:1; // bit 16
- u32 reserved1:6; // bits 10-15
- u32 space_avail:10; // bits 0-9
+ u32 reserved2:15; /* bits 17-31 */
+ u32 space_avail_en:1; /* bit 16 */
+ u32 reserved1:6; /* bits 10-15 */
+ u32 space_avail:10; /* bits 0-9 */
#else
- u32 space_avail:10; // bits 0-9
- u32 reserved1:6; // bits 10-15
- u32 space_avail_en:1; // bit 16
- u32 reserved2:15; // bits 17-31
+ u32 space_avail:10; /* bits 0-9 */
+ u32 reserved1:6; /* bits 10-15 */
+ u32 space_avail_en:1; /* bit 16 */
+ u32 reserved2:15; /* bits 17-31 */
#endif
} bits;
} RXMAC_SPACE_AVAIL_t, *PRXMAC_SPACE_AVAIL_t;
@@ -1455,13 +1455,13 @@ typedef union _RXMAC_MIF_CTL_t {
u32 value;
struct {
#ifdef _BIT_FIELDS_HTOL
- u32 reserve:14; // bits 18-31
- u32 drop_pkt_en:1; // bit 17
- u32 drop_pkt_mask:17; // bits 0-16
+ u32 reserve:14; /* bits 18-31 */
+ u32 drop_pkt_en:1; /* bit 17 */
+ u32 drop_pkt_mask:17; /* bits 0-16 */
#else
- u32 drop_pkt_mask:17; // bits 0-16
- u32 drop_pkt_en:1; // bit 17
- u32 reserve:14; // bits 18-31
+ u32 drop_pkt_mask:17; /* bits 0-16 */
+ u32 drop_pkt_en:1; /* bit 17 */
+ u32 reserve:14; /* bits 18-31 */
#endif
} bits;
} RXMAC_MIF_CTL_t, *PRXMAC_MIF_CTL_t;
@@ -1474,17 +1474,17 @@ typedef union _RXMAC_ERROR_REG_t {
u32 value;
struct {
#ifdef _BIT_FIELDS_HTOL
- u32 reserve:28; // bits 4-31
- u32 mif:1; // bit 3
- u32 async:1; // bit 2
- u32 pkt_filter:1; // bit 1
- u32 mcif:1; // bit 0
+ u32 reserve:28; /* bits 4-31 */
+ u32 mif:1; /* bit 3 */
+ u32 async:1; /* bit 2 */
+ u32 pkt_filter:1; /* bit 1 */
+ u32 mcif:1; /* bit 0 */
#else
- u32 mcif:1; // bit 0
- u32 pkt_filter:1; // bit 1
- u32 async:1; // bit 2
- u32 mif:1; // bit 3
- u32 reserve:28; // bits 4-31
+ u32 mcif:1; /* bit 0 */
+ u32 pkt_filter:1; /* bit 1 */
+ u32 async:1; /* bit 2 */
+ u32 mif:1; /* bit 3 */
+ u32 reserve:28; /* bits 4-31 */
#endif
} bits;
} RXMAC_ERROR_REG_t, *PRXMAC_ERROR_REG_t;
@@ -1492,48 +1492,48 @@ typedef union _RXMAC_ERROR_REG_t {
/*
* Rx MAC Module of JAGCore Address Mapping
*/
-typedef struct _RXMAC_t { // Location:
- RXMAC_CTRL_t ctrl; // 0x4000
- RXMAC_WOL_CTL_CRC0_t crc0; // 0x4004
- RXMAC_WOL_CRC12_t crc12; // 0x4008
- RXMAC_WOL_CRC34_t crc34; // 0x400C
- RXMAC_WOL_SA_LO_t sa_lo; // 0x4010
- RXMAC_WOL_SA_HI_t sa_hi; // 0x4014
- u32 mask0_word0; // 0x4018
- u32 mask0_word1; // 0x401C
- u32 mask0_word2; // 0x4020
- u32 mask0_word3; // 0x4024
- u32 mask1_word0; // 0x4028
- u32 mask1_word1; // 0x402C
- u32 mask1_word2; // 0x4030
- u32 mask1_word3; // 0x4034
- u32 mask2_word0; // 0x4038
- u32 mask2_word1; // 0x403C
- u32 mask2_word2; // 0x4040
- u32 mask2_word3; // 0x4044
- u32 mask3_word0; // 0x4048
- u32 mask3_word1; // 0x404C
- u32 mask3_word2; // 0x4050
- u32 mask3_word3; // 0x4054
- u32 mask4_word0; // 0x4058
- u32 mask4_word1; // 0x405C
- u32 mask4_word2; // 0x4060
- u32 mask4_word3; // 0x4064
- RXMAC_UNI_PF_ADDR1_t uni_pf_addr1; // 0x4068
- RXMAC_UNI_PF_ADDR2_t uni_pf_addr2; // 0x406C
- RXMAC_UNI_PF_ADDR3_t uni_pf_addr3; // 0x4070
- u32 multi_hash1; // 0x4074
- u32 multi_hash2; // 0x4078
- u32 multi_hash3; // 0x407C
- u32 multi_hash4; // 0x4080
- RXMAC_PF_CTRL_t pf_ctrl; // 0x4084
- RXMAC_MCIF_CTRL_MAX_SEG_t mcif_ctrl_max_seg; // 0x4088
- RXMAC_MCIF_WATER_MARK_t mcif_water_mark; // 0x408C
- RXMAC_RXQ_DIAG_t rxq_diag; // 0x4090
- RXMAC_SPACE_AVAIL_t space_avail; // 0x4094
-
- RXMAC_MIF_CTL_t mif_ctrl; // 0x4098
- RXMAC_ERROR_REG_t err_reg; // 0x409C
+typedef struct _RXMAC_t { /* Location: */
+ RXMAC_CTRL_t ctrl; /* 0x4000 */
+ RXMAC_WOL_CTL_CRC0_t crc0; /* 0x4004 */
+ RXMAC_WOL_CRC12_t crc12; /* 0x4008 */
+ RXMAC_WOL_CRC34_t crc34; /* 0x400C */
+ RXMAC_WOL_SA_LO_t sa_lo; /* 0x4010 */
+ RXMAC_WOL_SA_HI_t sa_hi; /* 0x4014 */
+ u32 mask0_word0; /* 0x4018 */
+ u32 mask0_word1; /* 0x401C */
+ u32 mask0_word2; /* 0x4020 */
+ u32 mask0_word3; /* 0x4024 */
+ u32 mask1_word0; /* 0x4028 */
+ u32 mask1_word1; /* 0x402C */
+ u32 mask1_word2; /* 0x4030 */
+ u32 mask1_word3; /* 0x4034 */
+ u32 mask2_word0; /* 0x4038 */
+ u32 mask2_word1; /* 0x403C */
+ u32 mask2_word2; /* 0x4040 */
+ u32 mask2_word3; /* 0x4044 */
+ u32 mask3_word0; /* 0x4048 */
+ u32 mask3_word1; /* 0x404C */
+ u32 mask3_word2; /* 0x4050 */
+ u32 mask3_word3; /* 0x4054 */
+ u32 mask4_word0; /* 0x4058 */
+ u32 mask4_word1; /* 0x405C */
+ u32 mask4_word2; /* 0x4060 */
+ u32 mask4_word3; /* 0x4064 */
+ RXMAC_UNI_PF_ADDR1_t uni_pf_addr1; /* 0x4068 */
+ RXMAC_UNI_PF_ADDR2_t uni_pf_addr2; /* 0x406C */
+ RXMAC_UNI_PF_ADDR3_t uni_pf_addr3; /* 0x4070 */
+ u32 multi_hash1; /* 0x4074 */
+ u32 multi_hash2; /* 0x4078 */
+ u32 multi_hash3; /* 0x407C */
+ u32 multi_hash4; /* 0x4080 */
+ RXMAC_PF_CTRL_t pf_ctrl; /* 0x4084 */
+ RXMAC_MCIF_CTRL_MAX_SEG_t mcif_ctrl_max_seg; /* 0x4088 */
+ RXMAC_MCIF_WATER_MARK_t mcif_water_mark; /* 0x408C */
+ RXMAC_RXQ_DIAG_t rxq_diag; /* 0x4090 */
+ RXMAC_SPACE_AVAIL_t space_avail; /* 0x4094 */
+
+ RXMAC_MIF_CTL_t mif_ctrl; /* 0x4098 */
+ RXMAC_ERROR_REG_t err_reg; /* 0x409C */
} RXMAC_t, *PRXMAC_t;
/* END OF TXMAC REGISTER ADDRESS MAP */
@@ -1549,39 +1549,39 @@ typedef union _MAC_CFG1_t {
u32 value;
struct {
#ifdef _BIT_FIELDS_HTOL
- u32 soft_reset:1; // bit 31
- u32 sim_reset:1; // bit 30
- u32 reserved3:10; // bits 20-29
- u32 reset_rx_mc:1; // bit 19
- u32 reset_tx_mc:1; // bit 18
- u32 reset_rx_fun:1; // bit 17
- u32 reset_tx_fun:1; // bit 16
- u32 reserved2:7; // bits 9-15
- u32 loop_back:1; // bit 8
- u32 reserved1:2; // bits 6-7
- u32 rx_flow:1; // bit 5
- u32 tx_flow:1; // bit 4
- u32 syncd_rx_en:1; // bit 3
- u32 rx_enable:1; // bit 2
- u32 syncd_tx_en:1; // bit 1
- u32 tx_enable:1; // bit 0
-#else
- u32 tx_enable:1; // bit 0
- u32 syncd_tx_en:1; // bit 1
- u32 rx_enable:1; // bit 2
- u32 syncd_rx_en:1; // bit 3
- u32 tx_flow:1; // bit 4
- u32 rx_flow:1; // bit 5
- u32 reserved1:2; // bits 6-7
- u32 loop_back:1; // bit 8
- u32 reserved2:7; // bits 9-15
- u32 reset_tx_fun:1; // bit 16
- u32 reset_rx_fun:1; // bit 17
- u32 reset_tx_mc:1; // bit 18
- u32 reset_rx_mc:1; // bit 19
- u32 reserved3:10; // bits 20-29
- u32 sim_reset:1; // bit 30
- u32 soft_reset:1; // bit 31
+ u32 soft_reset:1; /* bit 31 */
+ u32 sim_reset:1; /* bit 30 */
+ u32 reserved3:10; /* bits 20-29 */
+ u32 reset_rx_mc:1; /* bit 19 */
+ u32 reset_tx_mc:1; /* bit 18 */
+ u32 reset_rx_fun:1; /* bit 17 */
+ u32 reset_tx_fun:1; /* bit 16 */
+ u32 reserved2:7; /* bits 9-15 */
+ u32 loop_back:1; /* bit 8 */
+ u32 reserved1:2; /* bits 6-7 */
+ u32 rx_flow:1; /* bit 5 */
+ u32 tx_flow:1; /* bit 4 */
+ u32 syncd_rx_en:1; /* bit 3 */
+ u32 rx_enable:1; /* bit 2 */
+ u32 syncd_tx_en:1; /* bit 1 */
+ u32 tx_enable:1; /* bit 0 */
+#else
+ u32 tx_enable:1; /* bit 0 */
+ u32 syncd_tx_en:1; /* bit 1 */
+ u32 rx_enable:1; /* bit 2 */
+ u32 syncd_rx_en:1; /* bit 3 */
+ u32 tx_flow:1; /* bit 4 */
+ u32 rx_flow:1; /* bit 5 */
+ u32 reserved1:2; /* bits 6-7 */
+ u32 loop_back:1; /* bit 8 */
+ u32 reserved2:7; /* bits 9-15 */
+ u32 reset_tx_fun:1; /* bit 16 */
+ u32 reset_rx_fun:1; /* bit 17 */
+ u32 reset_tx_mc:1; /* bit 18 */
+ u32 reset_rx_mc:1; /* bit 19 */
+ u32 reserved3:10; /* bits 20-29 */
+ u32 sim_reset:1; /* bit 30 */
+ u32 soft_reset:1; /* bit 31 */
#endif
} bits;
} MAC_CFG1_t, *PMAC_CFG1_t;
@@ -1594,29 +1594,29 @@ typedef union _MAC_CFG2_t {
u32 value;
struct {
#ifdef _BIT_FIELDS_HTOL
- u32 reserved3:16; // bits 16-31
- u32 preamble_len:4; // bits 12-15
- u32 reserved2:2; // bits 10-11
- u32 if_mode:2; // bits 8-9
- u32 reserved1:2; // bits 6-7
- u32 huge_frame:1; // bit 5
- u32 len_check:1; // bit 4
- u32 undefined:1; // bit 3
- u32 pad_crc:1; // bit 2
- u32 crc_enable:1; // bit 1
- u32 full_duplex:1; // bit 0
-#else
- u32 full_duplex:1; // bit 0
- u32 crc_enable:1; // bit 1
- u32 pad_crc:1; // bit 2
- u32 undefined:1; // bit 3
- u32 len_check:1; // bit 4
- u32 huge_frame:1; // bit 5
- u32 reserved1:2; // bits 6-7
- u32 if_mode:2; // bits 8-9
- u32 reserved2:2; // bits 10-11
- u32 preamble_len:4; // bits 12-15
- u32 reserved3:16; // bits 16-31
+ u32 reserved3:16; /* bits 16-31 */
+ u32 preamble_len:4; /* bits 12-15 */
+ u32 reserved2:2; /* bits 10-11 */
+ u32 if_mode:2; /* bits 8-9 */
+ u32 reserved1:2; /* bits 6-7 */
+ u32 huge_frame:1; /* bit 5 */
+ u32 len_check:1; /* bit 4 */
+ u32 undefined:1; /* bit 3 */
+ u32 pad_crc:1; /* bit 2 */
+ u32 crc_enable:1; /* bit 1 */
+ u32 full_duplex:1; /* bit 0 */
+#else
+ u32 full_duplex:1; /* bit 0 */
+ u32 crc_enable:1; /* bit 1 */
+ u32 pad_crc:1; /* bit 2 */
+ u32 undefined:1; /* bit 3 */
+ u32 len_check:1; /* bit 4 */
+ u32 huge_frame:1; /* bit 5 */
+ u32 reserved1:2; /* bits 6-7 */
+ u32 if_mode:2; /* bits 8-9 */
+ u32 reserved2:2; /* bits 10-11 */
+ u32 preamble_len:4; /* bits 12-15 */
+ u32 reserved3:16; /* bits 16-31 */
#endif
} bits;
} MAC_CFG2_t, *PMAC_CFG2_t;
@@ -1629,21 +1629,21 @@ typedef union _MAC_IPG_t {
u32 value;
struct {
#ifdef _BIT_FIELDS_HTOL
- u32 reserved:1; // bit 31
- u32 non_B2B_ipg_1:7; // bits 24-30
- u32 undefined2:1; // bit 23
- u32 non_B2B_ipg_2:7; // bits 16-22
- u32 min_ifg_enforce:8; // bits 8-15
- u32 undefined1:1; // bit 7
- u32 B2B_ipg:7; // bits 0-6
+ u32 reserved:1; /* bit 31 */
+ u32 non_B2B_ipg_1:7; /* bits 24-30 */
+ u32 undefined2:1; /* bit 23 */
+ u32 non_B2B_ipg_2:7; /* bits 16-22 */
+ u32 min_ifg_enforce:8; /* bits 8-15 */
+ u32 undefined1:1; /* bit 7 */
+ u32 B2B_ipg:7; /* bits 0-6 */
#else
- u32 B2B_ipg:7; // bits 0-6
- u32 undefined1:1; // bit 7
- u32 min_ifg_enforce:8; // bits 8-15
- u32 non_B2B_ipg_2:7; // bits 16-22
- u32 undefined2:1; // bit 23
- u32 non_B2B_ipg_1:7; // bits 24-30
- u32 reserved:1; // bit 31
+ u32 B2B_ipg:7; /* bits 0-6 */
+ u32 undefined1:1; /* bit 7 */
+ u32 min_ifg_enforce:8; /* bits 8-15 */
+ u32 non_B2B_ipg_2:7; /* bits 16-22 */
+ u32 undefined2:1; /* bit 23 */
+ u32 non_B2B_ipg_1:7; /* bits 24-30 */
+ u32 reserved:1; /* bit 31 */
#endif
} bits;
} MAC_IPG_t, *PMAC_IPG_t;
@@ -1656,25 +1656,25 @@ typedef union _MAC_HFDP_t {
u32 value;
struct {
#ifdef _BIT_FIELDS_HTOL
- u32 reserved2:8; // bits 24-31
- u32 alt_beb_trunc:4; // bits 23-20
- u32 alt_beb_enable:1; // bit 19
- u32 bp_no_backoff:1; // bit 18
- u32 no_backoff:1; // bit 17
- u32 excess_defer:1; // bit 16
- u32 rexmit_max:4; // bits 12-15
- u32 reserved1:2; // bits 10-11
- u32 coll_window:10; // bits 0-9
+ u32 reserved2:8; /* bits 24-31 */
+ u32 alt_beb_trunc:4; /* bits 23-20 */
+ u32 alt_beb_enable:1; /* bit 19 */
+ u32 bp_no_backoff:1; /* bit 18 */
+ u32 no_backoff:1; /* bit 17 */
+ u32 excess_defer:1; /* bit 16 */
+ u32 rexmit_max:4; /* bits 12-15 */
+ u32 reserved1:2; /* bits 10-11 */
+ u32 coll_window:10; /* bits 0-9 */
#else
- u32 coll_window:10; // bits 0-9
- u32 reserved1:2; // bits 10-11
- u32 rexmit_max:4; // bits 12-15
- u32 excess_defer:1; // bit 16
- u32 no_backoff:1; // bit 17
- u32 bp_no_backoff:1; // bit 18
- u32 alt_beb_enable:1; // bit 19
- u32 alt_beb_trunc:4; // bits 23-20
- u32 reserved2:8; // bits 24-31
+ u32 coll_window:10; /* bits 0-9 */
+ u32 reserved1:2; /* bits 10-11 */
+ u32 rexmit_max:4; /* bits 12-15 */
+ u32 excess_defer:1; /* bit 16 */
+ u32 no_backoff:1; /* bit 17 */
+ u32 bp_no_backoff:1; /* bit 18 */
+ u32 alt_beb_enable:1; /* bit 19 */
+ u32 alt_beb_trunc:4; /* bits 23-20 */
+ u32 reserved2:8; /* bits 24-31 */
#endif
} bits;
} MAC_HFDP_t, *PMAC_HFDP_t;
@@ -1687,11 +1687,11 @@ typedef union _MAC_MAX_FM_LEN_t {
u32 value;
struct {
#ifdef _BIT_FIELDS_HTOL
- u32 reserved:16; // bits 16-31
- u32 max_len:16; // bits 0-15
+ u32 reserved:16; /* bits 16-31 */
+ u32 max_len:16; /* bits 0-15 */
#else
- u32 max_len:16; // bits 0-15
- u32 reserved:16; // bits 16-31
+ u32 max_len:16; /* bits 0-15 */
+ u32 reserved:16; /* bits 16-31 */
#endif
} bits;
} MAC_MAX_FM_LEN_t, *PMAC_MAX_FM_LEN_t;
@@ -1710,11 +1710,11 @@ typedef union _MAC_TEST_t {
u32 value;
struct {
#ifdef _BIT_FIELDS_HTOL
- u32 unused:29; // bits 3-31
- u32 mac_test:3; // bits 0-2
+ u32 unused:29; /* bits 3-31 */
+ u32 mac_test:3; /* bits 0-2 */
#else
- u32 mac_test:3; // bits 0-2
- u32 unused:29; // bits 3-31
+ u32 mac_test:3; /* bits 0-2 */
+ u32 unused:29; /* bits 3-31 */
#endif
} bits;
} MAC_TEST_t, *PMAC_TEST_t;
@@ -1727,19 +1727,19 @@ typedef union _MII_MGMT_CFG_t {
u32 value;
struct {
#ifdef _BIT_FIELDS_HTOL
- u32 reset_mii_mgmt:1; // bit 31
- u32 reserved:25; // bits 6-30
- u32 scan_auto_incremt:1; // bit 5
- u32 preamble_suppress:1; // bit 4
- u32 undefined:1; // bit 3
- u32 mgmt_clk_reset:3; // bits 0-2
+ u32 reset_mii_mgmt:1; /* bit 31 */
+ u32 reserved:25; /* bits 6-30 */
+ u32 scan_auto_incremt:1; /* bit 5 */
+ u32 preamble_suppress:1; /* bit 4 */
+ u32 undefined:1; /* bit 3 */
+ u32 mgmt_clk_reset:3; /* bits 0-2 */
#else
- u32 mgmt_clk_reset:3; // bits 0-2
- u32 undefined:1; // bit 3
- u32 preamble_suppress:1; // bit 4
- u32 scan_auto_incremt:1; // bit 5
- u32 reserved:25; // bits 6-30
- u32 reset_mii_mgmt:1; // bit 31
+ u32 mgmt_clk_reset:3; /* bits 0-2 */
+ u32 undefined:1; /* bit 3 */
+ u32 preamble_suppress:1; /* bit 4 */
+ u32 scan_auto_incremt:1; /* bit 5 */
+ u32 reserved:25; /* bits 6-30 */
+ u32 reset_mii_mgmt:1; /* bit 31 */
#endif
} bits;
} MII_MGMT_CFG_t, *PMII_MGMT_CFG_t;
@@ -1752,13 +1752,13 @@ typedef union _MII_MGMT_CMD_t {
u32 value;
struct {
#ifdef _BIT_FIELDS_HTOL
- u32 reserved:30; // bits 2-31
- u32 scan_cycle:1; // bit 1
- u32 read_cycle:1; // bit 0
+ u32 reserved:30; /* bits 2-31 */
+ u32 scan_cycle:1; /* bit 1 */
+ u32 read_cycle:1; /* bit 0 */
#else
- u32 read_cycle:1; // bit 0
- u32 scan_cycle:1; // bit 1
- u32 reserved:30; // bits 2-31
+ u32 read_cycle:1; /* bit 0 */
+ u32 scan_cycle:1; /* bit 1 */
+ u32 reserved:30; /* bits 2-31 */
#endif
} bits;
} MII_MGMT_CMD_t, *PMII_MGMT_CMD_t;
@@ -1771,15 +1771,15 @@ typedef union _MII_MGMT_ADDR_t {
u32 value;
struct {
#ifdef _BIT_FIELDS_HTOL
- u32 reserved2:19; // bit 13-31
- u32 phy_addr:5; // bits 8-12
- u32 reserved1:3; // bits 5-7
- u32 reg_addr:5; // bits 0-4
+ u32 reserved2:19; /* bit 13-31 */
+ u32 phy_addr:5; /* bits 8-12 */
+ u32 reserved1:3; /* bits 5-7 */
+ u32 reg_addr:5; /* bits 0-4 */
#else
- u32 reg_addr:5; // bits 0-4
- u32 reserved1:3; // bits 5-7
- u32 phy_addr:5; // bits 8-12
- u32 reserved2:19; // bit 13-31
+ u32 reg_addr:5; /* bits 0-4 */
+ u32 reserved1:3; /* bits 5-7 */
+ u32 phy_addr:5; /* bits 8-12 */
+ u32 reserved2:19; /* bit 13-31 */
#endif
} bits;
} MII_MGMT_ADDR_t, *PMII_MGMT_ADDR_t;
@@ -1792,11 +1792,11 @@ typedef union _MII_MGMT_CTRL_t {
u32 value;
struct {
#ifdef _BIT_FIELDS_HTOL
- u32 reserved:16; // bits 16-31
- u32 phy_ctrl:16; // bits 0-15
+ u32 reserved:16; /* bits 16-31 */
+ u32 phy_ctrl:16; /* bits 0-15 */
#else
- u32 phy_ctrl:16; // bits 0-15
- u32 reserved:16; // bits 16-31
+ u32 phy_ctrl:16; /* bits 0-15 */
+ u32 reserved:16; /* bits 16-31 */
#endif
} bits;
} MII_MGMT_CTRL_t, *PMII_MGMT_CTRL_t;
@@ -1809,11 +1809,11 @@ typedef union _MII_MGMT_STAT_t {
u32 value;
struct {
#ifdef _BIT_FIELDS_HTOL
- u32 reserved:16; // bits 16-31
- u32 phy_stat:16; // bits 0-15
+ u32 reserved:16; /* bits 16-31 */
+ u32 phy_stat:16; /* bits 0-15 */
#else
- u32 phy_stat:16; // bits 0-15
- u32 reserved:16; // bits 16-31
+ u32 phy_stat:16; /* bits 0-15 */
+ u32 reserved:16; /* bits 16-31 */
#endif
} bits;
} MII_MGMT_STAT_t, *PMII_MGMT_STAT_t;
@@ -1826,15 +1826,15 @@ typedef union _MII_MGMT_INDICATOR_t {
u32 value;
struct {
#ifdef _BIT_FIELDS_HTOL
- u32 reserved:29; // bits 3-31
- u32 not_valid:1; // bit 2
- u32 scanning:1; // bit 1
- u32 busy:1; // bit 0
+ u32 reserved:29; /* bits 3-31 */
+ u32 not_valid:1; /* bit 2 */
+ u32 scanning:1; /* bit 1 */
+ u32 busy:1; /* bit 0 */
#else
- u32 busy:1; // bit 0
- u32 scanning:1; // bit 1
- u32 not_valid:1; // bit 2
- u32 reserved:29; // bits 3-31
+ u32 busy:1; /* bit 0 */
+ u32 scanning:1; /* bit 1 */
+ u32 not_valid:1; /* bit 2 */
+ u32 reserved:29; /* bits 3-31 */
#endif
} bits;
} MII_MGMT_INDICATOR_t, *PMII_MGMT_INDICATOR_t;
@@ -1847,41 +1847,41 @@ typedef union _MAC_IF_CTRL_t {
u32 value;
struct {
#ifdef _BIT_FIELDS_HTOL
- u32 reset_if_module:1; // bit 31
- u32 reserved4:3; // bit 28-30
- u32 tbi_mode:1; // bit 27
- u32 ghd_mode:1; // bit 26
- u32 lhd_mode:1; // bit 25
- u32 phy_mode:1; // bit 24
- u32 reset_per_mii:1; // bit 23
- u32 reserved3:6; // bits 17-22
- u32 speed:1; // bit 16
- u32 reset_pe100x:1; // bit 15
- u32 reserved2:4; // bits 11-14
- u32 force_quiet:1; // bit 10
- u32 no_cipher:1; // bit 9
- u32 disable_link_fail:1; // bit 8
- u32 reset_gpsi:1; // bit 7
- u32 reserved1:6; // bits 1-6
- u32 enab_jab_protect:1; // bit 0
-#else
- u32 enab_jab_protect:1; // bit 0
- u32 reserved1:6; // bits 1-6
- u32 reset_gpsi:1; // bit 7
- u32 disable_link_fail:1; // bit 8
- u32 no_cipher:1; // bit 9
- u32 force_quiet:1; // bit 10
- u32 reserved2:4; // bits 11-14
- u32 reset_pe100x:1; // bit 15
- u32 speed:1; // bit 16
- u32 reserved3:6; // bits 17-22
- u32 reset_per_mii:1; // bit 23
- u32 phy_mode:1; // bit 24
- u32 lhd_mode:1; // bit 25
- u32 ghd_mode:1; // bit 26
- u32 tbi_mode:1; // bit 27
- u32 reserved4:3; // bit 28-30
- u32 reset_if_module:1; // bit 31
+ u32 reset_if_module:1; /* bit 31 */
+ u32 reserved4:3; /* bit 28-30 */
+ u32 tbi_mode:1; /* bit 27 */
+ u32 ghd_mode:1; /* bit 26 */
+ u32 lhd_mode:1; /* bit 25 */
+ u32 phy_mode:1; /* bit 24 */
+ u32 reset_per_mii:1; /* bit 23 */
+ u32 reserved3:6; /* bits 17-22 */
+ u32 speed:1; /* bit 16 */
+ u32 reset_pe100x:1; /* bit 15 */
+ u32 reserved2:4; /* bits 11-14 */
+ u32 force_quiet:1; /* bit 10 */
+ u32 no_cipher:1; /* bit 9 */
+ u32 disable_link_fail:1; /* bit 8 */
+ u32 reset_gpsi:1; /* bit 7 */
+ u32 reserved1:6; /* bits 1-6 */
+ u32 enab_jab_protect:1; /* bit 0 */
+#else
+ u32 enab_jab_protect:1; /* bit 0 */
+ u32 reserved1:6; /* bits 1-6 */
+ u32 reset_gpsi:1; /* bit 7 */
+ u32 disable_link_fail:1; /* bit 8 */
+ u32 no_cipher:1; /* bit 9 */
+ u32 force_quiet:1; /* bit 10 */
+ u32 reserved2:4; /* bits 11-14 */
+ u32 reset_pe100x:1; /* bit 15 */
+ u32 speed:1; /* bit 16 */
+ u32 reserved3:6; /* bits 17-22 */
+ u32 reset_per_mii:1; /* bit 23 */
+ u32 phy_mode:1; /* bit 24 */
+ u32 lhd_mode:1; /* bit 25 */
+ u32 ghd_mode:1; /* bit 26 */
+ u32 tbi_mode:1; /* bit 27 */
+ u32 reserved4:3; /* bit 28-30 */
+ u32 reset_if_module:1; /* bit 31 */
#endif
} bits;
} MAC_IF_CTRL_t, *PMAC_IF_CTRL_t;
@@ -1894,29 +1894,29 @@ typedef union _MAC_IF_STAT_t {
u32 value;
struct {
#ifdef _BIT_FIELDS_HTOL
- u32 reserved:22; // bits 10-31
- u32 excess_defer:1; // bit 9
- u32 clash:1; // bit 8
- u32 phy_jabber:1; // bit 7
- u32 phy_link_ok:1; // bit 6
- u32 phy_full_duplex:1; // bit 5
- u32 phy_speed:1; // bit 4
- u32 pe100x_link_fail:1; // bit 3
- u32 pe10t_loss_carrie:1; // bit 2
- u32 pe10t_sqe_error:1; // bit 1
- u32 pe10t_jabber:1; // bit 0
-#else
- u32 pe10t_jabber:1; // bit 0
- u32 pe10t_sqe_error:1; // bit 1
- u32 pe10t_loss_carrie:1; // bit 2
- u32 pe100x_link_fail:1; // bit 3
- u32 phy_speed:1; // bit 4
- u32 phy_full_duplex:1; // bit 5
- u32 phy_link_ok:1; // bit 6
- u32 phy_jabber:1; // bit 7
- u32 clash:1; // bit 8
- u32 excess_defer:1; // bit 9
- u32 reserved:22; // bits 10-31
+ u32 reserved:22; /* bits 10-31 */
+ u32 excess_defer:1; /* bit 9 */
+ u32 clash:1; /* bit 8 */
+ u32 phy_jabber:1; /* bit 7 */
+ u32 phy_link_ok:1; /* bit 6 */
+ u32 phy_full_duplex:1; /* bit 5 */
+ u32 phy_speed:1; /* bit 4 */
+ u32 pe100x_link_fail:1; /* bit 3 */
+ u32 pe10t_loss_carrie:1; /* bit 2 */
+ u32 pe10t_sqe_error:1; /* bit 1 */
+ u32 pe10t_jabber:1; /* bit 0 */
+#else
+ u32 pe10t_jabber:1; /* bit 0 */
+ u32 pe10t_sqe_error:1; /* bit 1 */
+ u32 pe10t_loss_carrie:1; /* bit 2 */
+ u32 pe100x_link_fail:1; /* bit 3 */
+ u32 phy_speed:1; /* bit 4 */
+ u32 phy_full_duplex:1; /* bit 5 */
+ u32 phy_link_ok:1; /* bit 6 */
+ u32 phy_jabber:1; /* bit 7 */
+ u32 clash:1; /* bit 8 */
+ u32 excess_defer:1; /* bit 9 */
+ u32 reserved:22; /* bits 10-31 */
#endif
} bits;
} MAC_IF_STAT_t, *PMAC_IF_STAT_t;
@@ -1929,15 +1929,15 @@ typedef union _MAC_STATION_ADDR1_t {
u32 value;
struct {
#ifdef _BIT_FIELDS_HTOL
- u32 Octet6:8; // bits 24-31
- u32 Octet5:8; // bits 16-23
- u32 Octet4:8; // bits 8-15
- u32 Octet3:8; // bits 0-7
+ u32 Octet6:8; /* bits 24-31 */
+ u32 Octet5:8; /* bits 16-23 */
+ u32 Octet4:8; /* bits 8-15 */
+ u32 Octet3:8; /* bits 0-7 */
#else
- u32 Octet3:8; // bits 0-7
- u32 Octet4:8; // bits 8-15
- u32 Octet5:8; // bits 16-23
- u32 Octet6:8; // bits 24-31
+ u32 Octet3:8; /* bits 0-7 */
+ u32 Octet4:8; /* bits 8-15 */
+ u32 Octet5:8; /* bits 16-23 */
+ u32 Octet6:8; /* bits 24-31 */
#endif
} bits;
} MAC_STATION_ADDR1_t, *PMAC_STATION_ADDR1_t;
@@ -1950,13 +1950,13 @@ typedef union _MAC_STATION_ADDR2_t {
u32 value;
struct {
#ifdef _BIT_FIELDS_HTOL
- u32 Octet2:8; // bits 24-31
- u32 Octet1:8; // bits 16-23
- u32 reserved:16; // bits 0-15
+ u32 Octet2:8; /* bits 24-31 */
+ u32 Octet1:8; /* bits 16-23 */
+ u32 reserved:16; /* bits 0-15 */
#else
- u32 reserved:16; // bit 0-15
- u32 Octet1:8; // bits 16-23
- u32 Octet2:8; // bits 24-31
+ u32 reserved:16; /* bit 0-15 */
+ u32 Octet1:8; /* bits 16-23 */
+ u32 Octet2:8; /* bits 24-31 */
#endif
} bits;
} MAC_STATION_ADDR2_t, *PMAC_STATION_ADDR2_t;
@@ -1964,25 +1964,25 @@ typedef union _MAC_STATION_ADDR2_t {
/*
* MAC Module of JAGCore Address Mapping
*/
-typedef struct _MAC_t { // Location:
- MAC_CFG1_t cfg1; // 0x5000
- MAC_CFG2_t cfg2; // 0x5004
- MAC_IPG_t ipg; // 0x5008
- MAC_HFDP_t hfdp; // 0x500C
- MAC_MAX_FM_LEN_t max_fm_len; // 0x5010
- u32 rsv1; // 0x5014
- u32 rsv2; // 0x5018
- MAC_TEST_t mac_test; // 0x501C
- MII_MGMT_CFG_t mii_mgmt_cfg; // 0x5020
- MII_MGMT_CMD_t mii_mgmt_cmd; // 0x5024
- MII_MGMT_ADDR_t mii_mgmt_addr; // 0x5028
- MII_MGMT_CTRL_t mii_mgmt_ctrl; // 0x502C
- MII_MGMT_STAT_t mii_mgmt_stat; // 0x5030
- MII_MGMT_INDICATOR_t mii_mgmt_indicator; // 0x5034
- MAC_IF_CTRL_t if_ctrl; // 0x5038
- MAC_IF_STAT_t if_stat; // 0x503C
- MAC_STATION_ADDR1_t station_addr_1; // 0x5040
- MAC_STATION_ADDR2_t station_addr_2; // 0x5044
+typedef struct _MAC_t { /* Location: */
+ MAC_CFG1_t cfg1; /* 0x5000 */
+ MAC_CFG2_t cfg2; /* 0x5004 */
+ MAC_IPG_t ipg; /* 0x5008 */
+ MAC_HFDP_t hfdp; /* 0x500C */
+ MAC_MAX_FM_LEN_t max_fm_len; /* 0x5010 */
+ u32 rsv1; /* 0x5014 */
+ u32 rsv2; /* 0x5018 */
+ MAC_TEST_t mac_test; /* 0x501C */
+ MII_MGMT_CFG_t mii_mgmt_cfg; /* 0x5020 */
+ MII_MGMT_CMD_t mii_mgmt_cmd; /* 0x5024 */
+ MII_MGMT_ADDR_t mii_mgmt_addr; /* 0x5028 */
+ MII_MGMT_CTRL_t mii_mgmt_ctrl; /* 0x502C */
+ MII_MGMT_STAT_t mii_mgmt_stat; /* 0x5030 */
+ MII_MGMT_INDICATOR_t mii_mgmt_indicator; /* 0x5034 */
+ MAC_IF_CTRL_t if_ctrl; /* 0x5038 */
+ MAC_IF_STAT_t if_stat; /* 0x503C */
+ MAC_STATION_ADDR1_t station_addr_1; /* 0x5040 */
+ MAC_STATION_ADDR2_t station_addr_2; /* 0x5044 */
} MAC_t, *PMAC_t;
/* END OF MAC REGISTER ADDRESS MAP */
@@ -1997,57 +1997,57 @@ typedef union _MAC_STAT_REG_1_t {
u32 value;
struct {
#ifdef _BIT_FIELDS_HTOL
- u32 tr64:1; // bit 31
- u32 tr127:1; // bit 30
- u32 tr255:1; // bit 29
- u32 tr511:1; // bit 28
- u32 tr1k:1; // bit 27
- u32 trmax:1; // bit 26
- u32 trmgv:1; // bit 25
- u32 unused:8; // bits 17-24
- u32 rbyt:1; // bit 16
- u32 rpkt:1; // bit 15
- u32 rfcs:1; // bit 14
- u32 rmca:1; // bit 13
- u32 rbca:1; // bit 12
- u32 rxcf:1; // bit 11
- u32 rxpf:1; // bit 10
- u32 rxuo:1; // bit 9
- u32 raln:1; // bit 8
- u32 rflr:1; // bit 7
- u32 rcde:1; // bit 6
- u32 rcse:1; // bit 5
- u32 rund:1; // bit 4
- u32 rovr:1; // bit 3
- u32 rfrg:1; // bit 2
- u32 rjbr:1; // bit 1
- u32 rdrp:1; // bit 0
-#else
- u32 rdrp:1; // bit 0
- u32 rjbr:1; // bit 1
- u32 rfrg:1; // bit 2
- u32 rovr:1; // bit 3
- u32 rund:1; // bit 4
- u32 rcse:1; // bit 5
- u32 rcde:1; // bit 6
- u32 rflr:1; // bit 7
- u32 raln:1; // bit 8
- u32 rxuo:1; // bit 9
- u32 rxpf:1; // bit 10
- u32 rxcf:1; // bit 11
- u32 rbca:1; // bit 12
- u32 rmca:1; // bit 13
- u32 rfcs:1; // bit 14
- u32 rpkt:1; // bit 15
- u32 rbyt:1; // bit 16
- u32 unused:8; // bits 17-24
- u32 trmgv:1; // bit 25
- u32 trmax:1; // bit 26
- u32 tr1k:1; // bit 27
- u32 tr511:1; // bit 28
- u32 tr255:1; // bit 29
- u32 tr127:1; // bit 30
- u32 tr64:1; // bit 31
+ u32 tr64:1; /* bit 31 */
+ u32 tr127:1; /* bit 30 */
+ u32 tr255:1; /* bit 29 */
+ u32 tr511:1; /* bit 28 */
+ u32 tr1k:1; /* bit 27 */
+ u32 trmax:1; /* bit 26 */
+ u32 trmgv:1; /* bit 25 */
+ u32 unused:8; /* bits 17-24 */
+ u32 rbyt:1; /* bit 16 */
+ u32 rpkt:1; /* bit 15 */
+ u32 rfcs:1; /* bit 14 */
+ u32 rmca:1; /* bit 13 */
+ u32 rbca:1; /* bit 12 */
+ u32 rxcf:1; /* bit 11 */
+ u32 rxpf:1; /* bit 10 */
+ u32 rxuo:1; /* bit 9 */
+ u32 raln:1; /* bit 8 */
+ u32 rflr:1; /* bit 7 */
+ u32 rcde:1; /* bit 6 */
+ u32 rcse:1; /* bit 5 */
+ u32 rund:1; /* bit 4 */
+ u32 rovr:1; /* bit 3 */
+ u32 rfrg:1; /* bit 2 */
+ u32 rjbr:1; /* bit 1 */
+ u32 rdrp:1; /* bit 0 */
+#else
+ u32 rdrp:1; /* bit 0 */
+ u32 rjbr:1; /* bit 1 */
+ u32 rfrg:1; /* bit 2 */
+ u32 rovr:1; /* bit 3 */
+ u32 rund:1; /* bit 4 */
+ u32 rcse:1; /* bit 5 */
+ u32 rcde:1; /* bit 6 */
+ u32 rflr:1; /* bit 7 */
+ u32 raln:1; /* bit 8 */
+ u32 rxuo:1; /* bit 9 */
+ u32 rxpf:1; /* bit 10 */
+ u32 rxcf:1; /* bit 11 */
+ u32 rbca:1; /* bit 12 */
+ u32 rmca:1; /* bit 13 */
+ u32 rfcs:1; /* bit 14 */
+ u32 rpkt:1; /* bit 15 */
+ u32 rbyt:1; /* bit 16 */
+ u32 unused:8; /* bits 17-24 */
+ u32 trmgv:1; /* bit 25 */
+ u32 trmax:1; /* bit 26 */
+ u32 tr1k:1; /* bit 27 */
+ u32 tr511:1; /* bit 28 */
+ u32 tr255:1; /* bit 29 */
+ u32 tr127:1; /* bit 30 */
+ u32 tr64:1; /* bit 31 */
#endif
} bits;
} MAC_STAT_REG_1_t, *PMAC_STAT_REG_1_t;
@@ -2060,49 +2060,49 @@ typedef union _MAC_STAT_REG_2_t {
u32 value;
struct {
#ifdef _BIT_FIELDS_HTOL
- u32 unused:12; // bit 20-31
- u32 tjbr:1; // bit 19
- u32 tfcs:1; // bit 18
- u32 txcf:1; // bit 17
- u32 tovr:1; // bit 16
- u32 tund:1; // bit 15
- u32 tfrg:1; // bit 14
- u32 tbyt:1; // bit 13
- u32 tpkt:1; // bit 12
- u32 tmca:1; // bit 11
- u32 tbca:1; // bit 10
- u32 txpf:1; // bit 9
- u32 tdfr:1; // bit 8
- u32 tedf:1; // bit 7
- u32 tscl:1; // bit 6
- u32 tmcl:1; // bit 5
- u32 tlcl:1; // bit 4
- u32 txcl:1; // bit 3
- u32 tncl:1; // bit 2
- u32 tpfh:1; // bit 1
- u32 tdrp:1; // bit 0
-#else
- u32 tdrp:1; // bit 0
- u32 tpfh:1; // bit 1
- u32 tncl:1; // bit 2
- u32 txcl:1; // bit 3
- u32 tlcl:1; // bit 4
- u32 tmcl:1; // bit 5
- u32 tscl:1; // bit 6
- u32 tedf:1; // bit 7
- u32 tdfr:1; // bit 8
- u32 txpf:1; // bit 9
- u32 tbca:1; // bit 10
- u32 tmca:1; // bit 11
- u32 tpkt:1; // bit 12
- u32 tbyt:1; // bit 13
- u32 tfrg:1; // bit 14
- u32 tund:1; // bit 15
- u32 tovr:1; // bit 16
- u32 txcf:1; // bit 17
- u32 tfcs:1; // bit 18
- u32 tjbr:1; // bit 19
- u32 unused:12; // bit 20-31
+ u32 unused:12; /* bit 20-31 */
+ u32 tjbr:1; /* bit 19 */
+ u32 tfcs:1; /* bit 18 */
+ u32 txcf:1; /* bit 17 */
+ u32 tovr:1; /* bit 16 */
+ u32 tund:1; /* bit 15 */
+ u32 tfrg:1; /* bit 14 */
+ u32 tbyt:1; /* bit 13 */
+ u32 tpkt:1; /* bit 12 */
+ u32 tmca:1; /* bit 11 */
+ u32 tbca:1; /* bit 10 */
+ u32 txpf:1; /* bit 9 */
+ u32 tdfr:1; /* bit 8 */
+ u32 tedf:1; /* bit 7 */
+ u32 tscl:1; /* bit 6 */
+ u32 tmcl:1; /* bit 5 */
+ u32 tlcl:1; /* bit 4 */
+ u32 txcl:1; /* bit 3 */
+ u32 tncl:1; /* bit 2 */
+ u32 tpfh:1; /* bit 1 */
+ u32 tdrp:1; /* bit 0 */
+#else
+ u32 tdrp:1; /* bit 0 */
+ u32 tpfh:1; /* bit 1 */
+ u32 tncl:1; /* bit 2 */
+ u32 txcl:1; /* bit 3 */
+ u32 tlcl:1; /* bit 4 */
+ u32 tmcl:1; /* bit 5 */
+ u32 tscl:1; /* bit 6 */
+ u32 tedf:1; /* bit 7 */
+ u32 tdfr:1; /* bit 8 */
+ u32 txpf:1; /* bit 9 */
+ u32 tbca:1; /* bit 10 */
+ u32 tmca:1; /* bit 11 */
+ u32 tpkt:1; /* bit 12 */
+ u32 tbyt:1; /* bit 13 */
+ u32 tfrg:1; /* bit 14 */
+ u32 tund:1; /* bit 15 */
+ u32 tovr:1; /* bit 16 */
+ u32 txcf:1; /* bit 17 */
+ u32 tfcs:1; /* bit 18 */
+ u32 tjbr:1; /* bit 19 */
+ u32 unused:12; /* bit 20-31 */
#endif
} bits;
} MAC_STAT_REG_2_t, *PMAC_STAT_REG_2_t;
@@ -2110,152 +2110,152 @@ typedef union _MAC_STAT_REG_2_t {
/*
* MAC STATS Module of JAGCore Address Mapping
*/
-typedef struct _MAC_STAT_t { // Location:
- u32 pad[32]; // 0x6000 - 607C
+typedef struct _MAC_STAT_t { /* Location: */
+ u32 pad[32]; /* 0x6000 - 607C */
- // Tx/Rx 0-64 Byte Frame Counter
- u32 TR64; // 0x6080
+ /* Tx/Rx 0-64 Byte Frame Counter */
+ u32 TR64; /* 0x6080 */
- // Tx/Rx 65-127 Byte Frame Counter
- u32 TR127; // 0x6084
+ /* Tx/Rx 65-127 Byte Frame Counter */
+ u32 TR127; /* 0x6084 */
- // Tx/Rx 128-255 Byte Frame Counter
- u32 TR255; // 0x6088
+ /* Tx/Rx 128-255 Byte Frame Counter */
+ u32 TR255; /* 0x6088 */
- // Tx/Rx 256-511 Byte Frame Counter
- u32 TR511; // 0x608C
+ /* Tx/Rx 256-511 Byte Frame Counter */
+ u32 TR511; /* 0x608C */
- // Tx/Rx 512-1023 Byte Frame Counter
- u32 TR1K; // 0x6090
+ /* Tx/Rx 512-1023 Byte Frame Counter */
+ u32 TR1K; /* 0x6090 */
- // Tx/Rx 1024-1518 Byte Frame Counter
- u32 TRMax; // 0x6094
+ /* Tx/Rx 1024-1518 Byte Frame Counter */
+ u32 TRMax; /* 0x6094 */
- // Tx/Rx 1519-1522 Byte Good VLAN Frame Count
- u32 TRMgv; // 0x6098
+ /* Tx/Rx 1519-1522 Byte Good VLAN Frame Count */
+ u32 TRMgv; /* 0x6098 */
- // Rx Byte Counter
- u32 RByt; // 0x609C
+ /* Rx Byte Counter */
+ u32 RByt; /* 0x609C */
- // Rx Packet Counter
- u32 RPkt; // 0x60A0
+ /* Rx Packet Counter */
+ u32 RPkt; /* 0x60A0 */
- // Rx FCS Error Counter
- u32 RFcs; // 0x60A4
+ /* Rx FCS Error Counter */
+ u32 RFcs; /* 0x60A4 */
- // Rx Multicast Packet Counter
- u32 RMca; // 0x60A8
+ /* Rx Multicast Packet Counter */
+ u32 RMca; /* 0x60A8 */
- // Rx Broadcast Packet Counter
- u32 RBca; // 0x60AC
+ /* Rx Broadcast Packet Counter */
+ u32 RBca; /* 0x60AC */
- // Rx Control Frame Packet Counter
- u32 RxCf; // 0x60B0
+ /* Rx Control Frame Packet Counter */
+ u32 RxCf; /* 0x60B0 */
- // Rx Pause Frame Packet Counter
- u32 RxPf; // 0x60B4
+ /* Rx Pause Frame Packet Counter */
+ u32 RxPf; /* 0x60B4 */
- // Rx Unknown OP Code Counter
- u32 RxUo; // 0x60B8
+ /* Rx Unknown OP Code Counter */
+ u32 RxUo; /* 0x60B8 */
- // Rx Alignment Error Counter
- u32 RAln; // 0x60BC
+ /* Rx Alignment Error Counter */
+ u32 RAln; /* 0x60BC */
- // Rx Frame Length Error Counter
- u32 RFlr; // 0x60C0
+ /* Rx Frame Length Error Counter */
+ u32 RFlr; /* 0x60C0 */
- // Rx Code Error Counter
- u32 RCde; // 0x60C4
+ /* Rx Code Error Counter */
+ u32 RCde; /* 0x60C4 */
- // Rx Carrier Sense Error Counter
- u32 RCse; // 0x60C8
+ /* Rx Carrier Sense Error Counter */
+ u32 RCse; /* 0x60C8 */
- // Rx Undersize Packet Counter
- u32 RUnd; // 0x60CC
+ /* Rx Undersize Packet Counter */
+ u32 RUnd; /* 0x60CC */
- // Rx Oversize Packet Counter
- u32 ROvr; // 0x60D0
+ /* Rx Oversize Packet Counter */
+ u32 ROvr; /* 0x60D0 */
- // Rx Fragment Counter
- u32 RFrg; // 0x60D4
+ /* Rx Fragment Counter */
+ u32 RFrg; /* 0x60D4 */
- // Rx Jabber Counter
- u32 RJbr; // 0x60D8
+ /* Rx Jabber Counter */
+ u32 RJbr; /* 0x60D8 */
- // Rx Drop
- u32 RDrp; // 0x60DC
+ /* Rx Drop */
+ u32 RDrp; /* 0x60DC */
- // Tx Byte Counter
- u32 TByt; // 0x60E0
+ /* Tx Byte Counter */
+ u32 TByt; /* 0x60E0 */
- // Tx Packet Counter
- u32 TPkt; // 0x60E4
+ /* Tx Packet Counter */
+ u32 TPkt; /* 0x60E4 */
- // Tx Multicast Packet Counter
- u32 TMca; // 0x60E8
+ /* Tx Multicast Packet Counter */
+ u32 TMca; /* 0x60E8 */
- // Tx Broadcast Packet Counter
- u32 TBca; // 0x60EC
+ /* Tx Broadcast Packet Counter */
+ u32 TBca; /* 0x60EC */
- // Tx Pause Control Frame Counter
- u32 TxPf; // 0x60F0
+ /* Tx Pause Control Frame Counter */
+ u32 TxPf; /* 0x60F0 */
- // Tx Deferral Packet Counter
- u32 TDfr; // 0x60F4
+ /* Tx Deferral Packet Counter */
+ u32 TDfr; /* 0x60F4 */
- // Tx Excessive Deferral Packet Counter
- u32 TEdf; // 0x60F8
+ /* Tx Excessive Deferral Packet Counter */
+ u32 TEdf; /* 0x60F8 */
- // Tx Single Collision Packet Counter
- u32 TScl; // 0x60FC
+ /* Tx Single Collision Packet Counter */
+ u32 TScl; /* 0x60FC */
- // Tx Multiple Collision Packet Counter
- u32 TMcl; // 0x6100
+ /* Tx Multiple Collision Packet Counter */
+ u32 TMcl; /* 0x6100 */
- // Tx Late Collision Packet Counter
- u32 TLcl; // 0x6104
+ /* Tx Late Collision Packet Counter */
+ u32 TLcl; /* 0x6104 */
- // Tx Excessive Collision Packet Counter
- u32 TXcl; // 0x6108
+ /* Tx Excessive Collision Packet Counter */
+ u32 TXcl; /* 0x6108 */
- // Tx Total Collision Packet Counter
- u32 TNcl; // 0x610C
+ /* Tx Total Collision Packet Counter */
+ u32 TNcl; /* 0x610C */
- // Tx Pause Frame Honored Counter
- u32 TPfh; // 0x6110
+ /* Tx Pause Frame Honored Counter */
+ u32 TPfh; /* 0x6110 */
- // Tx Drop Frame Counter
- u32 TDrp; // 0x6114
+ /* Tx Drop Frame Counter */
+ u32 TDrp; /* 0x6114 */
- // Tx Jabber Frame Counter
- u32 TJbr; // 0x6118
+ /* Tx Jabber Frame Counter */
+ u32 TJbr; /* 0x6118 */
- // Tx FCS Error Counter
- u32 TFcs; // 0x611C
+ /* Tx FCS Error Counter */
+ u32 TFcs; /* 0x611C */
- // Tx Control Frame Counter
- u32 TxCf; // 0x6120
+ /* Tx Control Frame Counter */
+ u32 TxCf; /* 0x6120 */
- // Tx Oversize Frame Counter
- u32 TOvr; // 0x6124
+ /* Tx Oversize Frame Counter */
+ u32 TOvr; /* 0x6124 */
- // Tx Undersize Frame Counter
- u32 TUnd; // 0x6128
+ /* Tx Undersize Frame Counter */
+ u32 TUnd; /* 0x6128 */
- // Tx Fragments Frame Counter
- u32 TFrg; // 0x612C
+ /* Tx Fragments Frame Counter */
+ u32 TFrg; /* 0x612C */
- // Carry Register One Register
- MAC_STAT_REG_1_t Carry1; // 0x6130
+ /* Carry Register One Register */
+ MAC_STAT_REG_1_t Carry1; /* 0x6130 */
- // Carry Register Two Register
- MAC_STAT_REG_2_t Carry2; // 0x6134
+ /* Carry Register Two Register */
+ MAC_STAT_REG_2_t Carry2; /* 0x6134 */
- // Carry Register One Mask Register
- MAC_STAT_REG_1_t Carry1M; // 0x6138
+ /* Carry Register One Mask Register */
+ MAC_STAT_REG_1_t Carry1M; /* 0x6138 */
- // Carry Register Two Mask Register
- MAC_STAT_REG_2_t Carry2M; // 0x613C
+ /* Carry Register Two Mask Register */
+ MAC_STAT_REG_2_t Carry2M; /* 0x613C */
} MAC_STAT_t, *PMAC_STAT_t;
/* END OF MAC STAT REGISTER ADDRESS MAP */
@@ -2271,23 +2271,23 @@ typedef union _MMC_CTRL_t {
u32 value;
struct {
#ifdef _BIT_FIELDS_HTOL
- u32 reserved:25; // bits 7-31
- u32 force_ce:1; // bit 6
- u32 rxdma_disable:1; // bit 5
- u32 txdma_disable:1; // bit 4
- u32 txmac_disable:1; // bit 3
- u32 rxmac_disable:1; // bit 2
- u32 arb_disable:1; // bit 1
- u32 mmc_enable:1; // bit 0
+ u32 reserved:25; /* bits 7-31 */
+ u32 force_ce:1; /* bit 6 */
+ u32 rxdma_disable:1; /* bit 5 */
+ u32 txdma_disable:1; /* bit 4 */
+ u32 txmac_disable:1; /* bit 3 */
+ u32 rxmac_disable:1; /* bit 2 */
+ u32 arb_disable:1; /* bit 1 */
+ u32 mmc_enable:1; /* bit 0 */
#else
- u32 mmc_enable:1; // bit 0
- u32 arb_disable:1; // bit 1
- u32 rxmac_disable:1; // bit 2
- u32 txmac_disable:1; // bit 3
- u32 txdma_disable:1; // bit 4
- u32 rxdma_disable:1; // bit 5
- u32 force_ce:1; // bit 6
- u32 reserved:25; // bits 7-31
+ u32 mmc_enable:1; /* bit 0 */
+ u32 arb_disable:1; /* bit 1 */
+ u32 rxmac_disable:1; /* bit 2 */
+ u32 txmac_disable:1; /* bit 3 */
+ u32 txdma_disable:1; /* bit 4 */
+ u32 rxdma_disable:1; /* bit 5 */
+ u32 force_ce:1; /* bit 6 */
+ u32 reserved:25; /* bits 7-31 */
#endif
} bits;
} MMC_CTRL_t, *PMMC_CTRL_t;
@@ -2300,21 +2300,21 @@ typedef union _MMC_SRAM_ACCESS_t {
u32 value;
struct {
#ifdef _BIT_FIELDS_HTOL
- u32 byte_enable:16; // bits 16-31
- u32 reserved2:2; // bits 14-15
- u32 req_addr:10; // bits 4-13
- u32 reserved1:1; // bit 3
- u32 is_ctrl_word:1; // bit 2
- u32 wr_access:1; // bit 1
- u32 req_access:1; // bit 0
+ u32 byte_enable:16; /* bits 16-31 */
+ u32 reserved2:2; /* bits 14-15 */
+ u32 req_addr:10; /* bits 4-13 */
+ u32 reserved1:1; /* bit 3 */
+ u32 is_ctrl_word:1; /* bit 2 */
+ u32 wr_access:1; /* bit 1 */
+ u32 req_access:1; /* bit 0 */
#else
- u32 req_access:1; // bit 0
- u32 wr_access:1; // bit 1
- u32 is_ctrl_word:1; // bit 2
- u32 reserved1:1; // bit 3
- u32 req_addr:10; // bits 4-13
- u32 reserved2:2; // bits 14-15
- u32 byte_enable:16; // bits 16-31
+ u32 req_access:1; /* bit 0 */
+ u32 wr_access:1; /* bit 1 */
+ u32 is_ctrl_word:1; /* bit 2 */
+ u32 reserved1:1; /* bit 3 */
+ u32 req_addr:10; /* bits 4-13 */
+ u32 reserved2:2; /* bits 14-15 */
+ u32 byte_enable:16; /* bits 16-31 */
#endif
} bits;
} MMC_SRAM_ACCESS_t, *PMMC_SRAM_ACCESS_t;
@@ -2328,13 +2328,13 @@ typedef union _MMC_SRAM_ACCESS_t {
/*
* Memory Control Module of JAGCore Address Mapping
*/
-typedef struct _MMC_t { // Location:
- MMC_CTRL_t mmc_ctrl; // 0x7000
- MMC_SRAM_ACCESS_t sram_access; // 0x7004
- u32 sram_word1; // 0x7008
- u32 sram_word2; // 0x700C
- u32 sram_word3; // 0x7010
- u32 sram_word4; // 0x7014
+typedef struct _MMC_t { /* Location: */
+ MMC_CTRL_t mmc_ctrl; /* 0x7000 */
+ MMC_SRAM_ACCESS_t sram_access; /* 0x7004 */
+ u32 sram_word1; /* 0x7008 */
+ u32 sram_word2; /* 0x700C */
+ u32 sram_word3; /* 0x7010 */
+ u32 sram_word4; /* 0x7014 */
} MMC_t, *PMMC_t;
/* END OF MMC REGISTER ADDRESS MAP */
@@ -2361,30 +2361,30 @@ typedef struct _EXP_ROM_t {
*/
typedef struct _ADDRESS_MAP_t {
GLOBAL_t global;
- // unused section of global address map
+ /* unused section of global address map */
u8 unused_global[4096 - sizeof(GLOBAL_t)];
TXDMA_t txdma;
- // unused section of txdma address map
+ /* unused section of txdma address map */
u8 unused_txdma[4096 - sizeof(TXDMA_t)];
RXDMA_t rxdma;
- // unused section of rxdma address map
+ /* unused section of rxdma address map */
u8 unused_rxdma[4096 - sizeof(RXDMA_t)];
TXMAC_t txmac;
- // unused section of txmac address map
+ /* unused section of txmac address map */
u8 unused_txmac[4096 - sizeof(TXMAC_t)];
RXMAC_t rxmac;
- // unused section of rxmac address map
+ /* unused section of rxmac address map */
u8 unused_rxmac[4096 - sizeof(RXMAC_t)];
MAC_t mac;
- // unused section of mac address map
+ /* unused section of mac address map */
u8 unused_mac[4096 - sizeof(MAC_t)];
MAC_STAT_t macStat;
- // unused section of mac stat address map
+ /* unused section of mac stat address map */
u8 unused_mac_stat[4096 - sizeof(MAC_STAT_t)];
MMC_t mmc;
- // unused section of mmc address map
+ /* unused section of mmc address map */
u8 unused_mmc[4096 - sizeof(MMC_t)];
- // unused section of address map
+ /* unused section of address map */
u8 unused_[1015808];
/* Take this out until it is not empty */
@@ -2392,8 +2392,8 @@ typedef struct _ADDRESS_MAP_t {
EXP_ROM_t exp_rom;
#endif
- u8 unused_exp_rom[4096]; // MGS-size TBD
- u8 unused__[524288]; // unused section of address map
+ u8 unused_exp_rom[4096]; /* MGS-size TBD */
+ u8 unused__[524288]; /* unused section of address map */
} ADDRESS_MAP_t, *PADDRESS_MAP_t;
#endif /* _ET1310_ADDRESS_MAP_H_ */
diff --git a/drivers/staging/et131x/et1310_eeprom.c b/drivers/staging/et131x/et1310_eeprom.c
index c2b194e6a54c..3a81a8562893 100644
--- a/drivers/staging/et131x/et1310_eeprom.c
+++ b/drivers/staging/et131x/et1310_eeprom.c
@@ -2,7 +2,7 @@
* Agere Systems Inc.
* 10/100/1000 Base-T Ethernet Driver for the ET1301 and ET131x series MACs
*
- * Copyright © 2005 Agere Systems Inc.
+ * Copyright © 2005 Agere Systems Inc.
* All rights reserved.
* http://www.agere.com
*
@@ -19,7 +19,7 @@
* software indicates your acceptance of these terms and conditions. If you do
* not agree with these terms and conditions, do not use the software.
*
- * Copyright © 2005 Agere Systems Inc.
+ * Copyright © 2005 Agere Systems Inc.
* All rights reserved.
*
* Redistribution and use in source or binary forms, with or without
@@ -40,7 +40,7 @@
*
* Disclaimer
*
- * THIS SOFTWARE IS PROVIDED “AS IS” AND ANY EXPRESS OR IMPLIED WARRANTIES,
+ * THIS SOFTWARE IS PROVIDED "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES,
* INCLUDING, BUT NOT LIMITED TO, INFRINGEMENT AND THE IMPLIED WARRANTIES OF
* MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. ANY
* USE, MODIFICATION OR DISTRIBUTION OF THIS SOFTWARE IS SOLELY AT THE USERS OWN
@@ -74,9 +74,9 @@
#include <linux/interrupt.h>
#include <linux/in.h>
#include <linux/delay.h>
-#include <asm/io.h>
+#include <linux/bitops.h>
+#include <linux/io.h>
#include <asm/system.h>
-#include <asm/bitops.h>
#include <linux/netdevice.h>
#include <linux/etherdevice.h>
@@ -155,7 +155,7 @@ int32_t EepromWriteByte(struct et131x_adapter *pAdapter, uint32_t unAddress,
uint8_t bData, uint32_t unEepromId,
uint32_t unAddressingMode)
{
- struct pci_dev *pdev = pAdapter->pdev;
+ struct pci_dev *pdev = pAdapter->pdev;
int32_t nIndex;
int32_t nRetries;
int32_t nError = false;
@@ -226,23 +226,20 @@ int32_t EepromWriteByte(struct et131x_adapter *pAdapter, uint32_t unAddress,
bStatus = EXTRACT_STATUS_REGISTER(unDword1);
if (bStatus & LBCIF_STATUS_PHY_QUEUE_AVAIL &&
- bStatus & LBCIF_STATUS_I2C_IDLE) {
- /* bits 1:0 are equal to 1 */
+ bStatus & LBCIF_STATUS_I2C_IDLE)
+ /* bits 1:0 are equal to 1 */
break;
- }
}
- if (nError || (nIndex >= MAX_NUM_REGISTER_POLLS)) {
+ if (nError || (nIndex >= MAX_NUM_REGISTER_POLLS))
return FAILURE;
- }
/* Step 2: */
bControl = 0;
bControl |= LBCIF_CONTROL_LBCIF_ENABLE | LBCIF_CONTROL_I2C_WRITE;
- if (unAddressingMode == DUAL_BYTE) {
+ if (unAddressingMode == DUAL_BYTE)
bControl |= LBCIF_CONTROL_TWO_BYTE_ADDR;
- }
if (pci_write_config_byte(pdev, LBCIF_CONTROL_REGISTER_OFFSET,
bControl)) {
@@ -281,20 +278,19 @@ int32_t EepromWriteByte(struct et131x_adapter *pAdapter, uint32_t unAddress,
bStatus = EXTRACT_STATUS_REGISTER(unDword1);
if (bStatus & LBCIF_STATUS_PHY_QUEUE_AVAIL &&
- bStatus & LBCIF_STATUS_I2C_IDLE) {
- /* I2C write complete */
+ bStatus & LBCIF_STATUS_I2C_IDLE) {
+ /* I2C write complete */
break;
}
}
- if (nError || (nIndex >= MAX_NUM_REGISTER_POLLS)) {
+ if (nError || (nIndex >= MAX_NUM_REGISTER_POLLS))
break;
- }
/*
* Step 6: Don't break here if we are revision 1, this is
* so we do a blind write for load bug.
- */
+ */
if (bStatus & LBCIF_STATUS_GENERAL_ERROR
&& pAdapter->RevisionID == 0) {
break;
@@ -342,9 +338,8 @@ int32_t EepromWriteByte(struct et131x_adapter *pAdapter, uint32_t unAddress,
bControl = EXTRACT_CONTROL_REG(unData);
- if (bControl != 0xC0 || nIndex == 10000) {
+ if (bControl != 0xC0 || nIndex == 10000)
break;
- }
nIndex++;
}
@@ -366,7 +361,7 @@ int32_t EepromReadByte(struct et131x_adapter *pAdapter, uint32_t unAddress,
uint8_t *pbData, uint32_t unEepromId,
uint32_t unAddressingMode)
{
- struct pci_dev *pdev = pAdapter->pdev;
+ struct pci_dev *pdev = pAdapter->pdev;
int32_t nIndex;
int32_t nError = 0;
uint8_t bControl;
@@ -425,17 +420,15 @@ int32_t EepromReadByte(struct et131x_adapter *pAdapter, uint32_t unAddress,
}
}
- if (nError || (nIndex >= MAX_NUM_REGISTER_POLLS)) {
+ if (nError || (nIndex >= MAX_NUM_REGISTER_POLLS))
return FAILURE;
- }
/* Step 2: */
bControl = 0;
bControl |= LBCIF_CONTROL_LBCIF_ENABLE;
- if (unAddressingMode == DUAL_BYTE) {
+ if (unAddressingMode == DUAL_BYTE)
bControl |= LBCIF_CONTROL_TWO_BYTE_ADDR;
- }
if (pci_write_config_byte(pdev, LBCIF_CONTROL_REGISTER_OFFSET,
bControl)) {
@@ -469,9 +462,8 @@ int32_t EepromReadByte(struct et131x_adapter *pAdapter, uint32_t unAddress,
}
}
- if (nError || (nIndex >= MAX_NUM_REGISTER_POLLS)) {
+ if (nError || (nIndex >= MAX_NUM_REGISTER_POLLS))
return FAILURE;
- }
/* Step 6: */
*pbData = EXTRACT_DATA_REGISTER(unDword1);
diff --git a/drivers/staging/et131x/et1310_eeprom.h b/drivers/staging/et131x/et1310_eeprom.h
index 9b6f8ad77b49..8033743e888e 100644
--- a/drivers/staging/et131x/et1310_eeprom.h
+++ b/drivers/staging/et131x/et1310_eeprom.h
@@ -2,7 +2,7 @@
* Agere Systems Inc.
* 10/100/1000 Base-T Ethernet Driver for the ET1301 and ET131x series MACs
*
- * Copyright © 2005 Agere Systems Inc.
+ * Copyright © 2005 Agere Systems Inc.
* All rights reserved.
* http://www.agere.com
*
@@ -20,7 +20,7 @@
* software indicates your acceptance of these terms and conditions. If you do
* not agree with these terms and conditions, do not use the software.
*
- * Copyright © 2005 Agere Systems Inc.
+ * Copyright © 2005 Agere Systems Inc.
* All rights reserved.
*
* Redistribution and use in source or binary forms, with or without
@@ -41,7 +41,7 @@
*
* Disclaimer
*
- * THIS SOFTWARE IS PROVIDED “AS IS” AND ANY EXPRESS OR IMPLIED WARRANTIES,
+ * THIS SOFTWARE IS PROVIDED "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES,
* INCLUDING, BUT NOT LIMITED TO, INFRINGEMENT AND THE IMPLIED WARRANTIES OF
* MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. ANY
* USE, MODIFICATION OR DISTRIBUTION OF THIS SOFTWARE IS SOLELY AT THE USERS OWN
diff --git a/drivers/staging/et131x/et1310_jagcore.c b/drivers/staging/et131x/et1310_jagcore.c
index 993b30ea71e2..6fb2c6d29d90 100644
--- a/drivers/staging/et131x/et1310_jagcore.c
+++ b/drivers/staging/et131x/et1310_jagcore.c
@@ -2,7 +2,7 @@
* Agere Systems Inc.
* 10/100/1000 Base-T Ethernet Driver for the ET1301 and ET131x series MACs
*
- * Copyright © 2005 Agere Systems Inc.
+ * Copyright © 2005 Agere Systems Inc.
* All rights reserved.
* http://www.agere.com
*
@@ -19,7 +19,7 @@
* software indicates your acceptance of these terms and conditions. If you do
* not agree with these terms and conditions, do not use the software.
*
- * Copyright © 2005 Agere Systems Inc.
+ * Copyright © 2005 Agere Systems Inc.
* All rights reserved.
*
* Redistribution and use in source or binary forms, with or without
@@ -40,7 +40,7 @@
*
* Disclaimer
*
- * THIS SOFTWARE IS PROVIDED “AS IS” AND ANY EXPRESS OR IMPLIED WARRANTIES,
+ * THIS SOFTWARE IS PROVIDED "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES,
* INCLUDING, BUT NOT LIMITED TO, INFRINGEMENT AND THE IMPLIED WARRANTIES OF
* MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. ANY
* USE, MODIFICATION OR DISTRIBUTION OF THIS SOFTWARE IS SOLELY AT THE USERS OWN
@@ -73,9 +73,9 @@
#include <linux/interrupt.h>
#include <linux/in.h>
#include <linux/delay.h>
-#include <asm/io.h>
+#include <linux/io.h>
+#include <linux/bitops.h>
#include <asm/system.h>
-#include <asm/bitops.h>
#include <linux/netdevice.h>
#include <linux/etherdevice.h>
@@ -198,21 +198,19 @@ void et131x_enable_interrupts(struct et131x_adapter *adapter)
uint32_t MaskValue;
/* Enable all global interrupts */
- if ((adapter->FlowControl == TxOnly) || (adapter->FlowControl == Both)) {
+ if (adapter->FlowControl == TxOnly || adapter->FlowControl == Both)
MaskValue = INT_MASK_ENABLE;
- } else {
+ else
MaskValue = INT_MASK_ENABLE_NO_FLOW;
- }
- if (adapter->DriverNoPhyAccess) {
+ if (adapter->DriverNoPhyAccess)
MaskValue |= 0x10000;
- }
adapter->CachedMaskValue.value = MaskValue;
writel(MaskValue, &adapter->CSRAddress->global.int_mask.value);
}
-void et131x_disable_interrupts(struct et131x_adapter * adapter)
+void et131x_disable_interrupts(struct et131x_adapter *adapter)
{
/* Disable all global interrupts */
adapter->CachedMaskValue.value = INT_MASK_DISABLE;
diff --git a/drivers/staging/et131x/et1310_jagcore.h b/drivers/staging/et131x/et1310_jagcore.h
index 9fc829336df1..78228afb7805 100644
--- a/drivers/staging/et131x/et1310_jagcore.h
+++ b/drivers/staging/et131x/et1310_jagcore.h
@@ -2,7 +2,7 @@
* Agere Systems Inc.
* 10/100/1000 Base-T Ethernet Driver for the ET1301 and ET131x series MACs
*
- * Copyright © 2005 Agere Systems Inc.
+ * Copyright © 2005 Agere Systems Inc.
* All rights reserved.
* http://www.agere.com
*
@@ -20,7 +20,7 @@
* software indicates your acceptance of these terms and conditions. If you do
* not agree with these terms and conditions, do not use the software.
*
- * Copyright © 2005 Agere Systems Inc.
+ * Copyright © 2005 Agere Systems Inc.
* All rights reserved.
*
* Redistribution and use in source or binary forms, with or without
@@ -41,7 +41,7 @@
*
* Disclaimer
*
- * THIS SOFTWARE IS PROVIDED “AS IS” AND ANY EXPRESS OR IMPLIED WARRANTIES,
+ * THIS SOFTWARE IS PROVIDED "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES,
* INCLUDING, BUT NOT LIMITED TO, INFRINGEMENT AND THE IMPLIED WARRANTIES OF
* MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. ANY
* USE, MODIFICATION OR DISTRIBUTION OF THIS SOFTWARE IS SOLELY AT THE USERS OWN
@@ -62,8 +62,8 @@
#include "et1310_address_map.h"
-#define INTERNAL_MEM_SIZE 0x400 //1024 of internal memory
-#define INTERNAL_MEM_RX_OFFSET 0x1FF //50% Tx, 50% Rx
+#define INTERNAL_MEM_SIZE 0x400 /* 1024 of internal memory */
+#define INTERNAL_MEM_RX_OFFSET 0x1FF /* 50% Tx, 50% Rx */
#define REGS_MAX_ARRAY 4096
@@ -78,9 +78,10 @@
*/
#define INT_MASK_DISABLE 0xffffffff
-// NOTE: Masking out MAC_STAT Interrupt for now...
-//#define INT_MASK_ENABLE 0xfff6bf17
-//#define INT_MASK_ENABLE_NO_FLOW 0xfff6bfd7
+/* NOTE: Masking out MAC_STAT Interrupt for now...
+ * #define INT_MASK_ENABLE 0xfff6bf17
+ * #define INT_MASK_ENABLE_NO_FLOW 0xfff6bfd7
+ */
#define INT_MASK_ENABLE 0xfffebf17
#define INT_MASK_ENABLE_NO_FLOW 0xfffebfd7
diff --git a/drivers/staging/et131x/et1310_mac.c b/drivers/staging/et131x/et1310_mac.c
index 1924968ab24f..02ae636e9b14 100644
--- a/drivers/staging/et131x/et1310_mac.c
+++ b/drivers/staging/et131x/et1310_mac.c
@@ -2,7 +2,7 @@
* Agere Systems Inc.
* 10/100/1000 Base-T Ethernet Driver for the ET1301 and ET131x series MACs
*
- * Copyright © 2005 Agere Systems Inc.
+ * Copyright © 2005 Agere Systems Inc.
* All rights reserved.
* http://www.agere.com
*
@@ -19,7 +19,7 @@
* software indicates your acceptance of these terms and conditions. If you do
* not agree with these terms and conditions, do not use the software.
*
- * Copyright © 2005 Agere Systems Inc.
+ * Copyright © 2005 Agere Systems Inc.
* All rights reserved.
*
* Redistribution and use in source or binary forms, with or without
@@ -40,7 +40,7 @@
*
* Disclaimer
*
- * THIS SOFTWARE IS PROVIDED “AS IS” AND ANY EXPRESS OR IMPLIED WARRANTIES,
+ * THIS SOFTWARE IS PROVIDED "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES,
* INCLUDING, BUT NOT LIMITED TO, INFRINGEMENT AND THE IMPLIED WARRANTIES OF
* MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. ANY
* USE, MODIFICATION OR DISTRIBUTION OF THIS SOFTWARE IS SOLELY AT THE USERS OWN
@@ -73,9 +73,9 @@
#include <linux/interrupt.h>
#include <linux/in.h>
#include <linux/delay.h>
-#include <asm/io.h>
+#include <linux/io.h>
+#include <linux/bitops.h>
#include <asm/system.h>
-#include <asm/bitops.h>
#include <linux/netdevice.h>
#include <linux/etherdevice.h>
@@ -118,10 +118,10 @@ void ConfigMACRegs1(struct et131x_adapter *pAdapter)
writel(0xC00F0000, &pMac->cfg1.value);
/* Next lets configure the MAC Inter-packet gap register */
- ipg.bits.non_B2B_ipg_1 = 0x38; // 58d
- ipg.bits.non_B2B_ipg_2 = 0x58; // 88d
- ipg.bits.min_ifg_enforce = 0x50; // 80d
- ipg.bits.B2B_ipg = 0x60; // 96d
+ ipg.bits.non_B2B_ipg_1 = 0x38; /* 58d */
+ ipg.bits.non_B2B_ipg_2 = 0x58; /* 88d */
+ ipg.bits.min_ifg_enforce = 0x50; /* 80d */
+ ipg.bits.B2B_ipg = 0x60; /* 96d */
writel(ipg.value, &pMac->ipg.value);
/* Next lets configure the MAC Half Duplex register */
@@ -131,7 +131,7 @@ void ConfigMACRegs1(struct et131x_adapter *pAdapter)
hfdp.bits.no_backoff = 0x0;
hfdp.bits.excess_defer = 0x1;
hfdp.bits.rexmit_max = 0xF;
- hfdp.bits.coll_window = 0x37; // 55d
+ hfdp.bits.coll_window = 0x37; /* 55d */
writel(hfdp.value, &pMac->hfdp.value);
/* Next lets configure the MAC Interface Control register */
@@ -251,21 +251,20 @@ void ConfigMACRegs2(struct et131x_adapter *pAdapter)
udelay(10);
delay++;
cfg1.value = readl(&pMac->cfg1.value);
- } while ((!cfg1.bits.syncd_rx_en ||
- !cfg1.bits.syncd_tx_en) &&
- delay < 100);
+ } while ((!cfg1.bits.syncd_rx_en || !cfg1.bits.syncd_tx_en) &&
+ delay < 100);
if (delay == 100) {
DBG_ERROR(et131x_dbginfo,
- "Syncd bits did not respond correctly cfg1 word 0x%08x\n",
- cfg1.value);
+ "Syncd bits did not respond correctly cfg1 word 0x%08x\n",
+ cfg1.value);
}
DBG_TRACE(et131x_dbginfo,
- "Speed %d, Dup %d, CFG1 0x%08x, CFG2 0x%08x, if_ctrl 0x%08x\n",
- pAdapter->uiLinkSpeed, pAdapter->uiDuplexMode,
- readl(&pMac->cfg1.value), readl(&pMac->cfg2.value),
- readl(&pMac->if_ctrl.value));
+ "Speed %d, Dup %d, CFG1 0x%08x, CFG2 0x%08x, if_ctrl 0x%08x\n",
+ pAdapter->uiLinkSpeed, pAdapter->uiDuplexMode,
+ readl(&pMac->cfg1.value), readl(&pMac->cfg2.value),
+ readl(&pMac->if_ctrl.value));
/* Enable TXMAC */
ctl.bits.txmac_en = 0x1;
@@ -409,11 +408,10 @@ void ConfigRxMacRegs(struct et131x_adapter *pAdapter)
* bit 16: Receive frame truncated.
* bit 17: Drop packet enable
*/
- if (pAdapter->uiLinkSpeed == TRUEPHY_SPEED_100MBPS) {
+ if (pAdapter->uiLinkSpeed == TRUEPHY_SPEED_100MBPS)
writel(0x30038, &pRxMac->mif_ctrl.value);
- } else {
+ else
writel(0x30030, &pRxMac->mif_ctrl.value);
- }
/* Finally we initialize RxMac to be enabled & WOL disabled. Packet
* filter is always enabled since it is where the runt packets are
@@ -540,7 +538,7 @@ void ConfigMacStatRegs(struct et131x_adapter *pAdapter)
DBG_LEAVE(et131x_dbginfo);
}
-void ConfigFlowControl(struct et131x_adapter * pAdapter)
+void ConfigFlowControl(struct et131x_adapter *pAdapter)
{
if (pAdapter->uiDuplexMode == 0) {
pAdapter->FlowControl = None;
@@ -558,21 +556,19 @@ void ConfigFlowControl(struct et131x_adapter * pAdapter)
pAdapter->FlowControl = pAdapter->RegistryFlowControl;
} else if ((RemotePause == TRUEPHY_BIT_SET) &&
(RemoteAsyncPause == TRUEPHY_BIT_CLEAR)) {
- if (pAdapter->RegistryFlowControl == Both) {
+ if (pAdapter->RegistryFlowControl == Both)
pAdapter->FlowControl = Both;
- } else {
+ else
pAdapter->FlowControl = None;
- }
} else if ((RemotePause == TRUEPHY_BIT_CLEAR) &&
(RemoteAsyncPause == TRUEPHY_BIT_CLEAR)) {
pAdapter->FlowControl = None;
} else {/* if (RemotePause == TRUEPHY_CLEAR_BIT &&
RemoteAsyncPause == TRUEPHY_SET_BIT) */
- if (pAdapter->RegistryFlowControl == Both) {
+ if (pAdapter->RegistryFlowControl == Both)
pAdapter->FlowControl = RxOnly;
- } else {
+ else
pAdapter->FlowControl = None;
- }
}
}
}
@@ -635,48 +631,34 @@ void HandleMacStatInterrupt(struct et131x_adapter *pAdapter)
* revolution of the counter. This routine is called when the counter
* block indicates that one of the counters has wrapped.
*/
- if (Carry1.bits.rfcs) {
+ if (Carry1.bits.rfcs)
pAdapter->Stats.code_violations += COUNTER_WRAP_16_BIT;
- }
- if (Carry1.bits.raln) {
+ if (Carry1.bits.raln)
pAdapter->Stats.alignment_err += COUNTER_WRAP_12_BIT;
- }
- if (Carry1.bits.rflr) {
+ if (Carry1.bits.rflr)
pAdapter->Stats.length_err += COUNTER_WRAP_16_BIT;
- }
- if (Carry1.bits.rfrg) {
+ if (Carry1.bits.rfrg)
pAdapter->Stats.other_errors += COUNTER_WRAP_16_BIT;
- }
- if (Carry1.bits.rcde) {
+ if (Carry1.bits.rcde)
pAdapter->Stats.crc_err += COUNTER_WRAP_16_BIT;
- }
- if (Carry1.bits.rovr) {
+ if (Carry1.bits.rovr)
pAdapter->Stats.rx_ov_flow += COUNTER_WRAP_16_BIT;
- }
- if (Carry1.bits.rdrp) {
+ if (Carry1.bits.rdrp)
pAdapter->Stats.norcvbuf += COUNTER_WRAP_16_BIT;
- }
- if (Carry2.bits.tovr) {
+ if (Carry2.bits.tovr)
pAdapter->Stats.max_pkt_error += COUNTER_WRAP_12_BIT;
- }
- if (Carry2.bits.tund) {
+ if (Carry2.bits.tund)
pAdapter->Stats.tx_uflo += COUNTER_WRAP_12_BIT;
- }
- if (Carry2.bits.tscl) {
+ if (Carry2.bits.tscl)
pAdapter->Stats.first_collision += COUNTER_WRAP_12_BIT;
- }
- if (Carry2.bits.tdfr) {
+ if (Carry2.bits.tdfr)
pAdapter->Stats.tx_deferred += COUNTER_WRAP_12_BIT;
- }
- if (Carry2.bits.tmcl) {
+ if (Carry2.bits.tmcl)
pAdapter->Stats.excessive_collisions += COUNTER_WRAP_12_BIT;
- }
- if (Carry2.bits.tlcl) {
+ if (Carry2.bits.tlcl)
pAdapter->Stats.late_collisions += COUNTER_WRAP_12_BIT;
- }
- if (Carry2.bits.tncl) {
+ if (Carry2.bits.tncl)
pAdapter->Stats.collisions += COUNTER_WRAP_12_BIT;
- }
DBG_LEAVE(et131x_dbginfo);
}
@@ -707,14 +689,14 @@ void SetupDeviceForMulticast(struct et131x_adapter *pAdapter)
/* Loop through our multicast array and set up the device */
for (nIndex = 0; nIndex < pAdapter->MCAddressCount; nIndex++) {
DBG_VERBOSE(et131x_dbginfo,
- "MCList[%d]: %02x:%02x:%02x:%02x:%02x:%02x\n",
- nIndex,
- pAdapter->MCList[nIndex][0],
- pAdapter->MCList[nIndex][1],
- pAdapter->MCList[nIndex][2],
- pAdapter->MCList[nIndex][3],
- pAdapter->MCList[nIndex][4],
- pAdapter->MCList[nIndex][5]);
+ "MCList[%d]: %02x:%02x:%02x:%02x:%02x:%02x\n",
+ nIndex,
+ pAdapter->MCList[nIndex][0],
+ pAdapter->MCList[nIndex][1],
+ pAdapter->MCList[nIndex][2],
+ pAdapter->MCList[nIndex][3],
+ pAdapter->MCList[nIndex][4],
+ pAdapter->MCList[nIndex][5]);
result = ether_crc(6, pAdapter->MCList[nIndex]);
diff --git a/drivers/staging/et131x/et1310_mac.h b/drivers/staging/et131x/et1310_mac.h
index bd26cd351780..2c3859594538 100644
--- a/drivers/staging/et131x/et1310_mac.h
+++ b/drivers/staging/et131x/et1310_mac.h
@@ -2,7 +2,7 @@
* Agere Systems Inc.
* 10/100/1000 Base-T Ethernet Driver for the ET1301 and ET131x series MACs
*
- * Copyright © 2005 Agere Systems Inc.
+ * Copyright © 2005 Agere Systems Inc.
* All rights reserved.
* http://www.agere.com
*
@@ -20,7 +20,7 @@
* software indicates your acceptance of these terms and conditions. If you do
* not agree with these terms and conditions, do not use the software.
*
- * Copyright © 2005 Agere Systems Inc.
+ * Copyright © 2005 Agere Systems Inc.
* All rights reserved.
*
* Redistribution and use in source or binary forms, with or without
@@ -41,7 +41,7 @@
*
* Disclaimer
*
- * THIS SOFTWARE IS PROVIDED “AS IS” AND ANY EXPRESS OR IMPLIED WARRANTIES,
+ * THIS SOFTWARE IS PROVIDED "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES,
* INCLUDING, BUT NOT LIMITED TO, INFRINGEMENT AND THE IMPLIED WARRANTIES OF
* MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. ANY
* USE, MODIFICATION OR DISTRIBUTION OF THIS SOFTWARE IS SOLELY AT THE USERS OWN
@@ -73,7 +73,7 @@
#define COUNTER_MASK_16_BIT (COUNTER_WRAP_16_BIT - 1)
#define COUNTER_MASK_12_BIT (COUNTER_WRAP_12_BIT - 1)
-#define UPDATE_COUNTER(HostCnt,DevCnt) \
+#define UPDATE_COUNTER(HostCnt, DevCnt) \
HostCnt = HostCnt + DevCnt;
/* Forward declaration of the private adapter structure */
diff --git a/drivers/staging/et131x/et1310_phy.c b/drivers/staging/et131x/et1310_phy.c
index 9dd6dfd9a033..326d38993955 100644
--- a/drivers/staging/et131x/et1310_phy.c
+++ b/drivers/staging/et131x/et1310_phy.c
@@ -2,7 +2,7 @@
* Agere Systems Inc.
* 10/100/1000 Base-T Ethernet Driver for the ET1301 and ET131x series MACs
*
- * Copyright © 2005 Agere Systems Inc.
+ * Copyright * 2005 Agere Systems Inc.
* All rights reserved.
* http://www.agere.com
*
@@ -19,7 +19,7 @@
* software indicates your acceptance of these terms and conditions. If you do
* not agree with these terms and conditions, do not use the software.
*
- * Copyright © 2005 Agere Systems Inc.
+ * Copyright * 2005 Agere Systems Inc.
* All rights reserved.
*
* Redistribution and use in source or binary forms, with or without
@@ -40,7 +40,7 @@
*
* Disclaimer
*
- * THIS SOFTWARE IS PROVIDED “AS IS” AND ANY EXPRESS OR IMPLIED WARRANTIES,
+ * THIS SOFTWARE IS PROVIDED "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES,
* INCLUDING, BUT NOT LIMITED TO, INFRINGEMENT AND THE IMPLIED WARRANTIES OF
* MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. ANY
* USE, MODIFICATION OR DISTRIBUTION OF THIS SOFTWARE IS SOLELY AT THE USERS OWN
@@ -74,9 +74,9 @@
#include <linux/interrupt.h>
#include <linux/in.h>
#include <linux/delay.h>
-#include <asm/io.h>
+#include <linux/io.h>
+#include <linux/bitops.h>
#include <asm/system.h>
-#include <asm/bitops.h>
#include <linux/netdevice.h>
#include <linux/etherdevice.h>
@@ -258,8 +258,8 @@ int MiWrite(struct et131x_adapter *adapter, uint8_t xcvrReg, uint16_t value)
writel(0, &mac->mii_mgmt_cmd.value);
/* set the registers we touched back to the state at which we entered
- * this function
- */
+ * this function
+ */
writel(miiAddr.value, &mac->mii_mgmt_addr.value);
writel(miiCmd.value, &mac->mii_mgmt_cmd.value);
@@ -449,22 +449,20 @@ static int et131x_xcvr_init(struct et131x_adapter *adapter)
switch (adapter->AiForceSpeed) {
case 10:
- if (adapter->AiForceDpx == 1) {
+ if (adapter->AiForceDpx == 1)
TPAL_SetPhy10HalfDuplex(adapter);
- } else if (adapter->AiForceDpx == 2) {
+ else if (adapter->AiForceDpx == 2)
TPAL_SetPhy10FullDuplex(adapter);
- } else {
+ else
TPAL_SetPhy10Force(adapter);
- }
break;
case 100:
- if (adapter->AiForceDpx == 1) {
+ if (adapter->AiForceDpx == 1)
TPAL_SetPhy100HalfDuplex(adapter);
- } else if (adapter->AiForceDpx == 2) {
+ else if (adapter->AiForceDpx == 2)
TPAL_SetPhy100FullDuplex(adapter);
- } else {
+ else
TPAL_SetPhy100Force(adapter);
- }
break;
case 1000:
TPAL_SetPhy1000FullDuplex(adapter);
@@ -505,16 +503,17 @@ void et131x_Mii_check(struct et131x_adapter *pAdapter,
spin_unlock_irqrestore(&pAdapter->Lock, lockflags);
/* Don't indicate state if we're in loopback mode */
- if (pAdapter->RegistryPhyLoopbk == false) {
+ if (pAdapter->RegistryPhyLoopbk == false)
netif_carrier_on(pAdapter->netdev);
- }
} else {
DBG_WARNING(et131x_dbginfo,
"Link down cable problem\n");
if (pAdapter->uiLinkSpeed == TRUEPHY_SPEED_10MBPS) {
- // NOTE - Is there a way to query this without TruePHY?
- // && TRU_QueryCoreType(pAdapter->hTruePhy, 0) == EMI_TRUEPHY_A13O) {
+ /* NOTE - Is there a way to query this without
+ * TruePHY?
+ * && TRU_QueryCoreType(pAdapter->hTruePhy, 0) == EMI_TRUEPHY_A13O) {
+ */
uint16_t Register18;
MiRead(pAdapter, 0x12, &Register18);
@@ -543,9 +542,8 @@ void et131x_Mii_check(struct et131x_adapter *pAdapter,
/* Only indicate state if we're in loopback
* mode
*/
- if (pAdapter->RegistryPhyLoopbk == false) {
+ if (pAdapter->RegistryPhyLoopbk == false)
netif_carrier_off(pAdapter->netdev);
- }
}
pAdapter->uiLinkSpeed = 0;
@@ -574,15 +572,14 @@ void et131x_Mii_check(struct et131x_adapter *pAdapter,
/* Setup the PHY into coma mode until the cable is
* plugged back in
*/
- if (pAdapter->RegistryPhyComa == 1) {
+ if (pAdapter->RegistryPhyComa == 1)
EnablePhyComa(pAdapter);
- }
}
}
if (bmsr_ints.bits.auto_neg_complete ||
- ((pAdapter->AiForceDpx == 3) && (bmsr_ints.bits.link_status))) {
- if (bmsr.bits.auto_neg_complete || (pAdapter->AiForceDpx == 3)) {
+ (pAdapter->AiForceDpx == 3 && bmsr_ints.bits.link_status)) {
+ if (bmsr.bits.auto_neg_complete || pAdapter->AiForceDpx == 3) {
ET1310_PhyLinkStatus(pAdapter,
&ucLinkStatus, &uiAutoNegStatus,
&uiSpeed, &uiDuplex, &uiMdiMdix,
@@ -592,15 +589,18 @@ void et131x_Mii_check(struct et131x_adapter *pAdapter,
pAdapter->uiDuplexMode = uiDuplex;
DBG_TRACE(et131x_dbginfo,
- "pAdapter->uiLinkSpeed 0x%04x, pAdapter->uiDuplex 0x%08x\n",
- pAdapter->uiLinkSpeed,
- pAdapter->uiDuplexMode);
+ "pAdapter->uiLinkSpeed 0x%04x, pAdapter->uiDuplex 0x%08x\n",
+ pAdapter->uiLinkSpeed,
+ pAdapter->uiDuplexMode);
pAdapter->PoMgmt.TransPhyComaModeOnBoot = 20;
if (pAdapter->uiLinkSpeed == TRUEPHY_SPEED_10MBPS) {
- // NOTE - Is there a way to query this without TruePHY?
- // && TRU_QueryCoreType(pAdapter->hTruePhy, 0) == EMI_TRUEPHY_A13O) {
+ /*
+ * NOTE - Is there a way to query this without
+ * TruePHY?
+ * && TRU_QueryCoreType(pAdapter->hTruePhy, 0)== EMI_TRUEPHY_A13O) {
+ */
uint16_t Register18;
MiRead(pAdapter, 0x12, &Register18);
@@ -612,12 +612,10 @@ void et131x_Mii_check(struct et131x_adapter *pAdapter,
ConfigFlowControl(pAdapter);
- if ((pAdapter->uiLinkSpeed == TRUEPHY_SPEED_1000MBPS) &&
- (pAdapter->RegistryJumboPacket > 2048))
- {
+ if (pAdapter->uiLinkSpeed == TRUEPHY_SPEED_1000MBPS &&
+ pAdapter->RegistryJumboPacket > 2048)
ET1310_PhyAndOrReg(pAdapter, 0x16, 0xcfff,
- 0x2000);
- }
+ 0x2000);
SetRxDmaTimer(pAdapter);
ConfigMACRegs2(pAdapter);
@@ -843,11 +841,10 @@ void TPAL_SetPhyAutoNeg(struct et131x_adapter *pAdapter)
ET1310_PhyAdvertise100BaseT(pAdapter, TRUEPHY_ADV_DUPLEX_BOTH);
- if (pAdapter->DeviceID != ET131X_PCI_DEVICE_ID_FAST) {
+ if (pAdapter->DeviceID != ET131X_PCI_DEVICE_ID_FAST)
ET1310_PhyAdvertise1000BaseT(pAdapter, TRUEPHY_ADV_DUPLEX_FULL);
- } else {
+ else
ET1310_PhyAdvertise1000BaseT(pAdapter, TRUEPHY_ADV_DUPLEX_NONE);
- }
/* Make sure auto-neg is ON (it is disabled in FORCE modes) */
ET1310_PhyAutoNeg(pAdapter, true);
@@ -910,64 +907,65 @@ void ET1310_PhyInit(struct et131x_adapter *pAdapter)
{
uint16_t usData, usIndex;
- if (pAdapter == NULL) {
+ if (pAdapter == NULL)
return;
- }
- // get the identity (again ?)
+ /* get the identity (again ?) */
MiRead(pAdapter, PHY_ID_1, &usData);
MiRead(pAdapter, PHY_ID_2, &usData);
- // what does this do/achieve ?
- MiRead(pAdapter, PHY_MPHY_CONTROL_REG, &usData); // should read 0002
+ /* what does this do/achieve ? */
+ MiRead(pAdapter, PHY_MPHY_CONTROL_REG, &usData); /* should read 0002 */
MiWrite(pAdapter, PHY_MPHY_CONTROL_REG, 0x0006);
- // read modem register 0402, should I do something with the return data ?
+ /* read modem register 0402, should I do something with the return
+ data ? */
MiWrite(pAdapter, PHY_INDEX_REG, 0x0402);
MiRead(pAdapter, PHY_DATA_REG, &usData);
- // what does this do/achieve ?
+ /* what does this do/achieve ? */
MiWrite(pAdapter, PHY_MPHY_CONTROL_REG, 0x0002);
- // get the identity (again ?)
+ /* get the identity (again ?) */
MiRead(pAdapter, PHY_ID_1, &usData);
MiRead(pAdapter, PHY_ID_2, &usData);
- // what does this achieve ?
- MiRead(pAdapter, PHY_MPHY_CONTROL_REG, &usData); // should read 0002
+ /* what does this achieve ? */
+ MiRead(pAdapter, PHY_MPHY_CONTROL_REG, &usData); /* should read 0002 */
MiWrite(pAdapter, PHY_MPHY_CONTROL_REG, 0x0006);
- // read modem register 0402, should I do something with the return data?
+ /* read modem register 0402, should I do something with
+ the return data? */
MiWrite(pAdapter, PHY_INDEX_REG, 0x0402);
MiRead(pAdapter, PHY_DATA_REG, &usData);
MiWrite(pAdapter, PHY_MPHY_CONTROL_REG, 0x0002);
- // what does this achieve (should return 0x1040)
+ /* what does this achieve (should return 0x1040) */
MiRead(pAdapter, PHY_CONTROL, &usData);
- MiRead(pAdapter, PHY_MPHY_CONTROL_REG, &usData); // should read 0002
+ MiRead(pAdapter, PHY_MPHY_CONTROL_REG, &usData); /* should read 0002 */
MiWrite(pAdapter, PHY_CONTROL, 0x1840);
MiWrite(pAdapter, PHY_MPHY_CONTROL_REG, 0x0007);
- // here the writing of the array starts....
+ /* here the writing of the array starts.... */
usIndex = 0;
while (ConfigPhy[usIndex][0] != 0x0000) {
- // write value
+ /* write value */
MiWrite(pAdapter, PHY_INDEX_REG, ConfigPhy[usIndex][0]);
MiWrite(pAdapter, PHY_DATA_REG, ConfigPhy[usIndex][1]);
- // read it back
+ /* read it back */
MiWrite(pAdapter, PHY_INDEX_REG, ConfigPhy[usIndex][0]);
MiRead(pAdapter, PHY_DATA_REG, &usData);
- // do a check on the value read back ?
+ /* do a check on the value read back ? */
usIndex++;
}
- // here the writing of the array ends...
+ /* here the writing of the array ends... */
- MiRead(pAdapter, PHY_CONTROL, &usData); // 0x1840
- MiRead(pAdapter, PHY_MPHY_CONTROL_REG, &usData); // should read 0007
+ MiRead(pAdapter, PHY_CONTROL, &usData); /* 0x1840 */
+ MiRead(pAdapter, PHY_MPHY_CONTROL_REG, &usData);/* should read 0007 */
MiWrite(pAdapter, PHY_CONTROL, 0x1040);
MiWrite(pAdapter, PHY_MPHY_CONTROL_REG, 0x0002);
}
@@ -984,11 +982,11 @@ void ET1310_PhyPowerDown(struct et131x_adapter *pAdapter, bool down)
MiRead(pAdapter, PHY_CONTROL, &usData);
if (down == false) {
- // Power UP
+ /* Power UP */
usData &= ~0x0800;
MiWrite(pAdapter, PHY_CONTROL, usData);
} else {
- // Power DOWN
+ /* Power DOWN */
usData |= 0x0800;
MiWrite(pAdapter, PHY_CONTROL, usData);
}
@@ -1001,11 +999,11 @@ void ET1310_PhyAutoNeg(struct et131x_adapter *pAdapter, bool enable)
MiRead(pAdapter, PHY_CONTROL, &usData);
if (enable == true) {
- // Autonegotiation ON
+ /* Autonegotiation ON */
usData |= 0x1000;
MiWrite(pAdapter, PHY_CONTROL, usData);
} else {
- // Autonegotiation OFF
+ /* Autonegotiation OFF */
usData &= ~0x1000;
MiWrite(pAdapter, PHY_CONTROL, usData);
}
@@ -1018,11 +1016,11 @@ void ET1310_PhyDuplexMode(struct et131x_adapter *pAdapter, uint16_t duplex)
MiRead(pAdapter, PHY_CONTROL, &usData);
if (duplex == TRUEPHY_DUPLEX_FULL) {
- // Set Full Duplex
+ /* Set Full Duplex */
usData |= 0x100;
MiWrite(pAdapter, PHY_CONTROL, usData);
} else {
- // Set Half Duplex
+ /* Set Half Duplex */
usData &= ~0x100;
MiWrite(pAdapter, PHY_CONTROL, usData);
}
@@ -1032,20 +1030,20 @@ void ET1310_PhySpeedSelect(struct et131x_adapter *pAdapter, uint16_t speed)
{
uint16_t usData;
- // Read the PHY control register
+ /* Read the PHY control register */
MiRead(pAdapter, PHY_CONTROL, &usData);
- // Clear all Speed settings (Bits 6, 13)
+ /* Clear all Speed settings (Bits 6, 13) */
usData &= ~0x2040;
- // Reset the speed bits based on user selection
+ /* Reset the speed bits based on user selection */
switch (speed) {
case TRUEPHY_SPEED_10MBPS:
- // Bits already cleared above, do nothing
+ /* Bits already cleared above, do nothing */
break;
case TRUEPHY_SPEED_100MBPS:
- // 100M == Set bit 13
+ /* 100M == Set bit 13 */
usData |= 0x2000;
break;
@@ -1055,7 +1053,7 @@ void ET1310_PhySpeedSelect(struct et131x_adapter *pAdapter, uint16_t speed)
break;
}
- // Write back the new speed
+ /* Write back the new speed */
MiWrite(pAdapter, PHY_CONTROL, usData);
}
@@ -1064,24 +1062,24 @@ void ET1310_PhyAdvertise1000BaseT(struct et131x_adapter *pAdapter,
{
uint16_t usData;
- // Read the PHY 1000 Base-T Control Register
+ /* Read the PHY 1000 Base-T Control Register */
MiRead(pAdapter, PHY_1000_CONTROL, &usData);
- // Clear Bits 8,9
+ /* Clear Bits 8,9 */
usData &= ~0x0300;
switch (duplex) {
case TRUEPHY_ADV_DUPLEX_NONE:
- // Duplex already cleared, do nothing
+ /* Duplex already cleared, do nothing */
break;
case TRUEPHY_ADV_DUPLEX_FULL:
- // Set Bit 9
+ /* Set Bit 9 */
usData |= 0x0200;
break;
case TRUEPHY_ADV_DUPLEX_HALF:
- // Set Bit 8
+ /* Set Bit 8 */
usData |= 0x0100;
break;
@@ -1091,7 +1089,7 @@ void ET1310_PhyAdvertise1000BaseT(struct et131x_adapter *pAdapter,
break;
}
- // Write back advertisement
+ /* Write back advertisement */
MiWrite(pAdapter, PHY_1000_CONTROL, usData);
}
@@ -1100,35 +1098,35 @@ void ET1310_PhyAdvertise100BaseT(struct et131x_adapter *pAdapter,
{
uint16_t usData;
- // Read the Autonegotiation Register (10/100)
+ /* Read the Autonegotiation Register (10/100) */
MiRead(pAdapter, PHY_AUTO_ADVERTISEMENT, &usData);
- // Clear bits 7,8
+ /* Clear bits 7,8 */
usData &= ~0x0180;
switch (duplex) {
case TRUEPHY_ADV_DUPLEX_NONE:
- // Duplex already cleared, do nothing
+ /* Duplex already cleared, do nothing */
break;
case TRUEPHY_ADV_DUPLEX_FULL:
- // Set Bit 8
+ /* Set Bit 8 */
usData |= 0x0100;
break;
case TRUEPHY_ADV_DUPLEX_HALF:
- // Set Bit 7
+ /* Set Bit 7 */
usData |= 0x0080;
break;
case TRUEPHY_ADV_DUPLEX_BOTH:
default:
- // Set Bits 7,8
+ /* Set Bits 7,8 */
usData |= 0x0180;
break;
}
- // Write back advertisement
+ /* Write back advertisement */
MiWrite(pAdapter, PHY_AUTO_ADVERTISEMENT, usData);
}
@@ -1137,35 +1135,35 @@ void ET1310_PhyAdvertise10BaseT(struct et131x_adapter *pAdapter,
{
uint16_t usData;
- // Read the Autonegotiation Register (10/100)
+ /* Read the Autonegotiation Register (10/100) */
MiRead(pAdapter, PHY_AUTO_ADVERTISEMENT, &usData);
- // Clear bits 5,6
+ /* Clear bits 5,6 */
usData &= ~0x0060;
switch (duplex) {
case TRUEPHY_ADV_DUPLEX_NONE:
- // Duplex already cleared, do nothing
+ /* Duplex already cleared, do nothing */
break;
case TRUEPHY_ADV_DUPLEX_FULL:
- // Set Bit 6
+ /* Set Bit 6 */
usData |= 0x0040;
break;
case TRUEPHY_ADV_DUPLEX_HALF:
- // Set Bit 5
+ /* Set Bit 5 */
usData |= 0x0020;
break;
case TRUEPHY_ADV_DUPLEX_BOTH:
default:
- // Set Bits 5,6
+ /* Set Bits 5,6 */
usData |= 0x0060;
break;
}
- // Write back advertisement
+ /* Write back advertisement */
MiWrite(pAdapter, PHY_AUTO_ADVERTISEMENT, usData);
}
@@ -1200,18 +1198,15 @@ void ET1310_PhyLinkStatus(struct et131x_adapter *pAdapter,
TRUEPHY_ANEG_DISABLED;
}
- if (uiLinkSpeed) {
+ if (uiLinkSpeed)
*uiLinkSpeed = (usVmiPhyStatus & 0x0300) >> 8;
- }
- if (uiDuplexMode) {
+ if (uiDuplexMode)
*uiDuplexMode = (usVmiPhyStatus & 0x0080) >> 7;
- }
- if (uiMdiMdix) {
+ if (uiMdiMdix)
/* NOTE: Need to complete this */
*uiMdiMdix = 0;
- }
if (uiMasterSlave) {
*uiMasterSlave =
@@ -1231,16 +1226,16 @@ void ET1310_PhyAndOrReg(struct et131x_adapter *pAdapter,
{
uint16_t reg;
- // Read the requested register
+ /* Read the requested register */
MiRead(pAdapter, regnum, &reg);
- // Apply the AND mask
+ /* Apply the AND mask */
reg &= andMask;
- // Apply the OR mask
+ /* Apply the OR mask */
reg |= orMask;
- // Write the value back to the register
+ /* Write the value back to the register */
MiWrite(pAdapter, regnum, reg);
}
@@ -1250,17 +1245,16 @@ void ET1310_PhyAccessMiBit(struct et131x_adapter *pAdapter, uint16_t action,
uint16_t reg;
uint16_t mask = 0;
- // Create a mask to isolate the requested bit
+ /* Create a mask to isolate the requested bit */
mask = 0x0001 << bitnum;
- // Read the requested register
+ /* Read the requested register */
MiRead(pAdapter, regnum, &reg);
switch (action) {
case TRUEPHY_BIT_READ:
- if (value != NULL) {
+ if (value != NULL)
*value = (reg & mask) >> bitnum;
- }
break;
case TRUEPHY_BIT_SET:
diff --git a/drivers/staging/et131x/et1310_phy.h b/drivers/staging/et131x/et1310_phy.h
index d624cbbadbd7..34e08e889ef7 100644
--- a/drivers/staging/et131x/et1310_phy.h
+++ b/drivers/staging/et131x/et1310_phy.h
@@ -2,7 +2,7 @@
* Agere Systems Inc.
* 10/100/1000 Base-T Ethernet Driver for the ET1301 and ET131x series MACs
*
- * Copyright © 2005 Agere Systems Inc.
+ * Copyright © 2005 Agere Systems Inc.
* All rights reserved.
* http://www.agere.com
*
@@ -20,7 +20,7 @@
* software indicates your acceptance of these terms and conditions. If you do
* not agree with these terms and conditions, do not use the software.
*
- * Copyright © 2005 Agere Systems Inc.
+ * Copyright © 2005 Agere Systems Inc.
* All rights reserved.
*
* Redistribution and use in source or binary forms, with or without
@@ -41,7 +41,7 @@
*
* Disclaimer
*
- * THIS SOFTWARE IS PROVIDED “AS IS” AND ANY EXPRESS OR IMPLIED WARRANTIES,
+ * THIS SOFTWARE IS PROVIDED "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES,
* INCLUDING, BUT NOT LIMITED TO, INFRINGEMENT AND THE IMPLIED WARRANTIES OF
* MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. ANY
* USE, MODIFICATION OR DISTRIBUTION OF THIS SOFTWARE IS SOLELY AT THE USERS OWN
@@ -105,31 +105,31 @@ typedef void *TRUEPHY_OSAL_HANDLE;
/* PHY Register Mapping(MI) Management Interface Regs */
typedef struct _MI_REGS_t {
- u8 bmcr; // Basic mode control reg(Reg 0x00)
- u8 bmsr; // Basic mode status reg(Reg 0x01)
- u8 idr1; // Phy identifier reg 1(Reg 0x02)
- u8 idr2; // Phy identifier reg 2(Reg 0x03)
- u8 anar; // Auto-Negotiation advertisement(Reg 0x04)
- u8 anlpar; // Auto-Negotiation link Partner Ability(Reg 0x05)
- u8 aner; // Auto-Negotiation expansion reg(Reg 0x06)
- u8 annptr; // Auto-Negotiation next page transmit reg(Reg 0x07)
- u8 lpnpr; // link partner next page reg(Reg 0x08)
- u8 gcr; // Gigabit basic mode control reg(Reg 0x09)
- u8 gsr; // Gigabit basic mode status reg(Reg 0x0A)
- u8 mi_res1[4]; // Future use by MI working group(Reg 0x0B - 0x0E)
- u8 esr; // Extended status reg(Reg 0x0F)
- u8 mi_res2[3]; // Future use by MI working group(Reg 0x10 - 0x12)
- u8 loop_ctl; // Loopback Control Reg(Reg 0x13)
- u8 mi_res3; // Future use by MI working group(Reg 0x14)
- u8 mcr; // MI Control Reg(Reg 0x15)
- u8 pcr; // Configuration Reg(Reg 0x16)
- u8 phy_ctl; // PHY Control Reg(Reg 0x17)
- u8 imr; // Interrupt Mask Reg(Reg 0x18)
- u8 isr; // Interrupt Status Reg(Reg 0x19)
- u8 psr; // PHY Status Reg(Reg 0x1A)
- u8 lcr1; // LED Control 1 Reg(Reg 0x1B)
- u8 lcr2; // LED Control 2 Reg(Reg 0x1C)
- u8 mi_res4[3]; // Future use by MI working group(Reg 0x1D - 0x1F)
+ u8 bmcr; /* Basic mode control reg(Reg 0x00) */
+ u8 bmsr; /* Basic mode status reg(Reg 0x01) */
+ u8 idr1; /* Phy identifier reg 1(Reg 0x02) */
+ u8 idr2; /* Phy identifier reg 2(Reg 0x03) */
+ u8 anar; /* Auto-Negotiation advertisement(Reg 0x04) */
+ u8 anlpar; /* Auto-Negotiation link Partner Ability(Reg 0x05) */
+ u8 aner; /* Auto-Negotiation expansion reg(Reg 0x06) */
+ u8 annptr; /* Auto-Negotiation next page transmit reg(Reg 0x07) */
+ u8 lpnpr; /* link partner next page reg(Reg 0x08) */
+ u8 gcr; /* Gigabit basic mode control reg(Reg 0x09) */
+ u8 gsr; /* Gigabit basic mode status reg(Reg 0x0A) */
+ u8 mi_res1[4]; /* Future use by MI working group(Reg 0x0B - 0x0E) */
+ u8 esr; /* Extended status reg(Reg 0x0F) */
+ u8 mi_res2[3]; /* Future use by MI working group(Reg 0x10 - 0x12) */
+ u8 loop_ctl; /* Loopback Control Reg(Reg 0x13) */
+ u8 mi_res3; /* Future use by MI working group(Reg 0x14) */
+ u8 mcr; /* MI Control Reg(Reg 0x15) */
+ u8 pcr; /* Configuration Reg(Reg 0x16) */
+ u8 phy_ctl; /* PHY Control Reg(Reg 0x17) */
+ u8 imr; /* Interrupt Mask Reg(Reg 0x18) */
+ u8 isr; /* Interrupt Status Reg(Reg 0x19) */
+ u8 psr; /* PHY Status Reg(Reg 0x1A) */
+ u8 lcr1; /* LED Control 1 Reg(Reg 0x1B) */
+ u8 lcr2; /* LED Control 2 Reg(Reg 0x1C) */
+ u8 mi_res4[3]; /* Future use by MI working group(Reg 0x1D - 0x1F) */
} MI_REGS_t, *PMI_REGS_t;
/* MI Register 0: Basic mode control register */
@@ -137,29 +137,29 @@ typedef union _MI_BMCR_t {
u16 value;
struct {
#ifdef _BIT_FIELDS_HTOL
- u16 reset:1; // bit 15
- u16 loopback:1; // bit 14
- u16 speed_sel:1; // bit 13
- u16 enable_autoneg:1; // bit 12
- u16 power_down:1; // bit 11
- u16 isolate:1; // bit 10
- u16 restart_autoneg:1; // bit 9
- u16 duplex_mode:1; // bit 8
- u16 col_test:1; // bit 7
- u16 speed_1000_sel:1; // bit 6
- u16 res1:6; // bits 0-5
+ u16 reset:1; /* bit 15 */
+ u16 loopback:1; /* bit 14 */
+ u16 speed_sel:1; /* bit 13 */
+ u16 enable_autoneg:1; /* bit 12 */
+ u16 power_down:1; /* bit 11 */
+ u16 isolate:1; /* bit 10 */
+ u16 restart_autoneg:1; /* bit 9 */
+ u16 duplex_mode:1; /* bit 8 */
+ u16 col_test:1; /* bit 7 */
+ u16 speed_1000_sel:1; /* bit 6 */
+ u16 res1:6; /* bits 0-5 */
#else
- u16 res1:6; // bits 0-5
- u16 speed_1000_sel:1; // bit 6
- u16 col_test:1; // bit 7
- u16 duplex_mode:1; // bit 8
- u16 restart_autoneg:1; // bit 9
- u16 isolate:1; // bit 10
- u16 power_down:1; // bit 11
- u16 enable_autoneg:1; // bit 12
- u16 speed_sel:1; // bit 13
- u16 loopback:1; // bit 14
- u16 reset:1; // bit 15
+ u16 res1:6; /* bits 0-5 */
+ u16 speed_1000_sel:1; /* bit 6 */
+ u16 col_test:1; /* bit 7 */
+ u16 duplex_mode:1; /* bit 8 */
+ u16 restart_autoneg:1; /* bit 9 */
+ u16 isolate:1; /* bit 10 */
+ u16 power_down:1; /* bit 11 */
+ u16 enable_autoneg:1; /* bit 12 */
+ u16 speed_sel:1; /* bit 13 */
+ u16 loopback:1; /* bit 14 */
+ u16 reset:1; /* bit 15 */
#endif
} bits;
} MI_BMCR_t, *PMI_BMCR_t;
@@ -169,39 +169,39 @@ typedef union _MI_BMSR_t {
u16 value;
struct {
#ifdef _BIT_FIELDS_HTOL
- u16 link_100T4:1; // bit 15
- u16 link_100fdx:1; // bit 14
- u16 link_100hdx:1; // bit 13
- u16 link_10fdx:1; // bit 12
- u16 link_10hdx:1; // bit 11
- u16 link_100T2fdx:1; // bit 10
- u16 link_100T2hdx:1; // bit 9
- u16 extend_status:1; // bit 8
- u16 res1:1; // bit 7
- u16 preamble_supress:1; // bit 6
- u16 auto_neg_complete:1; // bit 5
- u16 remote_fault:1; // bit 4
- u16 auto_neg_able:1; // bit 3
- u16 link_status:1; // bit 2
- u16 jabber_detect:1; // bit 1
- u16 ext_cap:1; // bit 0
+ u16 link_100T4:1; /* bit 15 */
+ u16 link_100fdx:1; /* bit 14 */
+ u16 link_100hdx:1; /* bit 13 */
+ u16 link_10fdx:1; /* bit 12 */
+ u16 link_10hdx:1; /* bit 11 */
+ u16 link_100T2fdx:1; /* bit 10 */
+ u16 link_100T2hdx:1; /* bit 9 */
+ u16 extend_status:1; /* bit 8 */
+ u16 res1:1; /* bit 7 */
+ u16 preamble_supress:1; /* bit 6 */
+ u16 auto_neg_complete:1; /* bit 5 */
+ u16 remote_fault:1; /* bit 4 */
+ u16 auto_neg_able:1; /* bit 3 */
+ u16 link_status:1; /* bit 2 */
+ u16 jabber_detect:1; /* bit 1 */
+ u16 ext_cap:1; /* bit 0 */
#else
- u16 ext_cap:1; // bit 0
- u16 jabber_detect:1; // bit 1
- u16 link_status:1; // bit 2
- u16 auto_neg_able:1; // bit 3
- u16 remote_fault:1; // bit 4
- u16 auto_neg_complete:1; // bit 5
- u16 preamble_supress:1; // bit 6
- u16 res1:1; // bit 7
- u16 extend_status:1; // bit 8
- u16 link_100T2hdx:1; // bit 9
- u16 link_100T2fdx:1; // bit 10
- u16 link_10hdx:1; // bit 11
- u16 link_10fdx:1; // bit 12
- u16 link_100hdx:1; // bit 13
- u16 link_100fdx:1; // bit 14
- u16 link_100T4:1; // bit 15
+ u16 ext_cap:1; /* bit 0 */
+ u16 jabber_detect:1; /* bit 1 */
+ u16 link_status:1; /* bit 2 */
+ u16 auto_neg_able:1; /* bit 3 */
+ u16 remote_fault:1; /* bit 4 */
+ u16 auto_neg_complete:1; /* bit 5 */
+ u16 preamble_supress:1; /* bit 6 */
+ u16 res1:1; /* bit 7 */
+ u16 extend_status:1; /* bit 8 */
+ u16 link_100T2hdx:1; /* bit 9 */
+ u16 link_100T2fdx:1; /* bit 10 */
+ u16 link_10hdx:1; /* bit 11 */
+ u16 link_10fdx:1; /* bit 12 */
+ u16 link_100hdx:1; /* bit 13 */
+ u16 link_100fdx:1; /* bit 14 */
+ u16 link_100T4:1; /* bit 15 */
#endif
} bits;
} MI_BMSR_t, *PMI_BMSR_t;
@@ -210,7 +210,7 @@ typedef union _MI_BMSR_t {
typedef union _MI_IDR1_t {
u16 value;
struct {
- u16 ieee_address:16; // 0x0282 default(bits 0-15)
+ u16 ieee_address:16; /* 0x0282 default(bits 0-15) */
} bits;
} MI_IDR1_t, *PMI_IDR1_t;
@@ -219,13 +219,13 @@ typedef union _MI_IDR2_t {
u16 value;
struct {
#ifdef _BIT_FIELDS_HTOL
- u16 ieee_address:6; // 111100 default(bits 10-15)
- u16 model_no:6; // 000001 default(bits 4-9)
- u16 rev_no:4; // 0010 default(bits 0-3)
+ u16 ieee_address:6; /* 111100 default(bits 10-15) */
+ u16 model_no:6; /* 000001 default(bits 4-9) */
+ u16 rev_no:4; /* 0010 default(bits 0-3) */
#else
- u16 rev_no:4; // 0010 default(bits 0-3)
- u16 model_no:6; // 000001 default(bits 4-9)
- u16 ieee_address:6; // 111100 default(bits 10-15)
+ u16 rev_no:4; /* 0010 default(bits 0-3) */
+ u16 model_no:6; /* 000001 default(bits 4-9) */
+ u16 ieee_address:6; /* 111100 default(bits 10-15) */
#endif
} bits;
} MI_IDR2_t, *PMI_IDR2_t;
@@ -235,31 +235,31 @@ typedef union _MI_ANAR_t {
u16 value;
struct {
#ifdef _BIT_FIELDS_HTOL
- u16 np_indication:1; // bit 15
- u16 res2:1; // bit 14
- u16 remote_fault:1; // bit 13
- u16 res1:1; // bit 12
- u16 cap_asmpause:1; // bit 11
- u16 cap_pause:1; // bit 10
- u16 cap_100T4:1; // bit 9
- u16 cap_100fdx:1; // bit 8
- u16 cap_100hdx:1; // bit 7
- u16 cap_10fdx:1; // bit 6
- u16 cap_10hdx:1; // bit 5
- u16 selector:5; // bits 0-4
+ u16 np_indication:1; /* bit 15 */
+ u16 res2:1; /* bit 14 */
+ u16 remote_fault:1; /* bit 13 */
+ u16 res1:1; /* bit 12 */
+ u16 cap_asmpause:1; /* bit 11 */
+ u16 cap_pause:1; /* bit 10 */
+ u16 cap_100T4:1; /* bit 9 */
+ u16 cap_100fdx:1; /* bit 8 */
+ u16 cap_100hdx:1; /* bit 7 */
+ u16 cap_10fdx:1; /* bit 6 */
+ u16 cap_10hdx:1; /* bit 5 */
+ u16 selector:5; /* bits 0-4 */
#else
- u16 selector:5; // bits 0-4
- u16 cap_10hdx:1; // bit 5
- u16 cap_10fdx:1; // bit 6
- u16 cap_100hdx:1; // bit 7
- u16 cap_100fdx:1; // bit 8
- u16 cap_100T4:1; // bit 9
- u16 cap_pause:1; // bit 10
- u16 cap_asmpause:1; // bit 11
- u16 res1:1; // bit 12
- u16 remote_fault:1; // bit 13
- u16 res2:1; // bit 14
- u16 np_indication:1; // bit 15
+ u16 selector:5; /* bits 0-4 */
+ u16 cap_10hdx:1; /* bit 5 */
+ u16 cap_10fdx:1; /* bit 6 */
+ u16 cap_100hdx:1; /* bit 7 */
+ u16 cap_100fdx:1; /* bit 8 */
+ u16 cap_100T4:1; /* bit 9 */
+ u16 cap_pause:1; /* bit 10 */
+ u16 cap_asmpause:1; /* bit 11 */
+ u16 res1:1; /* bit 12 */
+ u16 remote_fault:1; /* bit 13 */
+ u16 res2:1; /* bit 14 */
+ u16 np_indication:1; /* bit 15 */
#endif
} bits;
} MI_ANAR_t, *PMI_ANAR_t;
@@ -269,31 +269,31 @@ typedef struct _MI_ANLPAR_t {
u16 value;
struct {
#ifdef _BIT_FIELDS_HTOL
- u16 np_indication:1; // bit 15
- u16 acknowledge:1; // bit 14
- u16 remote_fault:1; // bit 13
- u16 res1:1; // bit 12
- u16 cap_asmpause:1; // bit 11
- u16 cap_pause:1; // bit 10
- u16 cap_100T4:1; // bit 9
- u16 cap_100fdx:1; // bit 8
- u16 cap_100hdx:1; // bit 7
- u16 cap_10fdx:1; // bit 6
- u16 cap_10hdx:1; // bit 5
- u16 selector:5; // bits 0-4
+ u16 np_indication:1; /* bit 15 */
+ u16 acknowledge:1; /* bit 14 */
+ u16 remote_fault:1; /* bit 13 */
+ u16 res1:1; /* bit 12 */
+ u16 cap_asmpause:1; /* bit 11 */
+ u16 cap_pause:1; /* bit 10 */
+ u16 cap_100T4:1; /* bit 9 */
+ u16 cap_100fdx:1; /* bit 8 */
+ u16 cap_100hdx:1; /* bit 7 */
+ u16 cap_10fdx:1; /* bit 6 */
+ u16 cap_10hdx:1; /* bit 5 */
+ u16 selector:5; /* bits 0-4 */
#else
- u16 selector:5; // bits 0-4
- u16 cap_10hdx:1; // bit 5
- u16 cap_10fdx:1; // bit 6
- u16 cap_100hdx:1; // bit 7
- u16 cap_100fdx:1; // bit 8
- u16 cap_100T4:1; // bit 9
- u16 cap_pause:1; // bit 10
- u16 cap_asmpause:1; // bit 11
- u16 res1:1; // bit 12
- u16 remote_fault:1; // bit 13
- u16 acknowledge:1; // bit 14
- u16 np_indication:1; // bit 15
+ u16 selector:5; /* bits 0-4 */
+ u16 cap_10hdx:1; /* bit 5 */
+ u16 cap_10fdx:1; /* bit 6 */
+ u16 cap_100hdx:1; /* bit 7 */
+ u16 cap_100fdx:1; /* bit 8 */
+ u16 cap_100T4:1; /* bit 9 */
+ u16 cap_pause:1; /* bit 10 */
+ u16 cap_asmpause:1; /* bit 11 */
+ u16 res1:1; /* bit 12 */
+ u16 remote_fault:1; /* bit 13 */
+ u16 acknowledge:1; /* bit 14 */
+ u16 np_indication:1; /* bit 15 */
#endif
} bits;
} MI_ANLPAR_t, *PMI_ANLPAR_t;
@@ -303,19 +303,19 @@ typedef union _MI_ANER_t {
u16 value;
struct {
#ifdef _BIT_FIELDS_HTOL
- u16 res:11; // bits 5-15
- u16 pdf:1; // bit 4
- u16 lp_np_able:1; // bit 3
- u16 np_able:1; // bit 2
- u16 page_rx:1; // bit 1
- u16 lp_an_able:1; // bit 0
+ u16 res:11; /* bits 5-15 */
+ u16 pdf:1; /* bit 4 */
+ u16 lp_np_able:1; /* bit 3 */
+ u16 np_able:1; /* bit 2 */
+ u16 page_rx:1; /* bit 1 */
+ u16 lp_an_able:1; /* bit 0 */
#else
- u16 lp_an_able:1; // bit 0
- u16 page_rx:1; // bit 1
- u16 np_able:1; // bit 2
- u16 lp_np_able:1; // bit 3
- u16 pdf:1; // bit 4
- u16 res:11; // bits 5-15
+ u16 lp_an_able:1; /* bit 0 */
+ u16 page_rx:1; /* bit 1 */
+ u16 np_able:1; /* bit 2 */
+ u16 lp_np_able:1; /* bit 3 */
+ u16 pdf:1; /* bit 4 */
+ u16 res:11; /* bits 5-15 */
#endif
} bits;
} MI_ANER_t, *PMI_ANER_t;
@@ -325,19 +325,19 @@ typedef union _MI_ANNPTR_t {
u16 value;
struct {
#ifdef _BIT_FIELDS_HTOL
- u16 np:1; // bit 15
- u16 res1:1; // bit 14
- u16 msg_page:1; // bit 13
- u16 ack2:1; // bit 12
- u16 toggle:1; // bit 11
- u16 msg:11; // bits 0-10
+ u16 np:1; /* bit 15 */
+ u16 res1:1; /* bit 14 */
+ u16 msg_page:1; /* bit 13 */
+ u16 ack2:1; /* bit 12 */
+ u16 toggle:1; /* bit 11 */
+ u16 msg:11; /* bits 0-10 */
#else
- u16 msg:11; // bits 0-10
- u16 toggle:1; // bit 11
- u16 ack2:1; // bit 12
- u16 msg_page:1; // bit 13
- u16 res1:1; // bit 14
- u16 np:1; // bit 15
+ u16 msg:11; /* bits 0-10 */
+ u16 toggle:1; /* bit 11 */
+ u16 ack2:1; /* bit 12 */
+ u16 msg_page:1; /* bit 13 */
+ u16 res1:1; /* bit 14 */
+ u16 np:1; /* bit 15 */
#endif
} bits;
} MI_ANNPTR_t, *PMI_ANNPTR_t;
@@ -347,19 +347,19 @@ typedef union _MI_LPNPR_t {
u16 value;
struct {
#ifdef _BIT_FIELDS_HTOL
- u16 np:1; // bit 15
- u16 ack:1; // bit 14
- u16 msg_page:1; // bit 13
- u16 ack2:1; // bit 12
- u16 toggle:1; // bit 11
- u16 msg:11; // bits 0-10
+ u16 np:1; /* bit 15 */
+ u16 ack:1; /* bit 14 */
+ u16 msg_page:1; /* bit 13 */
+ u16 ack2:1; /* bit 12 */
+ u16 toggle:1; /* bit 11 */
+ u16 msg:11; /* bits 0-10 */
#else
- u16 msg:11; // bits 0-10
- u16 toggle:1; // bit 11
- u16 ack2:1; // bit 12
- u16 msg_page:1; // bit 13
- u16 ack:1; // bit 14
- u16 np:1; // bit 15
+ u16 msg:11; /* bits 0-10 */
+ u16 toggle:1; /* bit 11 */
+ u16 ack2:1; /* bit 12 */
+ u16 msg_page:1; /* bit 13 */
+ u16 ack:1; /* bit 14 */
+ u16 np:1; /* bit 15 */
#endif
} bits;
} MI_LPNPR_t, *PMI_LPNPR_t;
@@ -369,21 +369,21 @@ typedef union _MI_GCR_t {
u16 value;
struct {
#ifdef _BIT_FIELDS_HTOL
- u16 test_mode:3; // bits 13-15
- u16 ms_config_en:1; // bit 12
- u16 ms_value:1; // bit 11
- u16 port_type:1; // bit 10
- u16 link_1000fdx:1; // bit 9
- u16 link_1000hdx:1; // bit 8
- u16 res:8; // bit 0-7
+ u16 test_mode:3; /* bits 13-15 */
+ u16 ms_config_en:1; /* bit 12 */
+ u16 ms_value:1; /* bit 11 */
+ u16 port_type:1; /* bit 10 */
+ u16 link_1000fdx:1; /* bit 9 */
+ u16 link_1000hdx:1; /* bit 8 */
+ u16 res:8; /* bit 0-7 */
#else
- u16 res:8; // bit 0-7
- u16 link_1000hdx:1; // bit 8
- u16 link_1000fdx:1; // bit 9
- u16 port_type:1; // bit 10
- u16 ms_value:1; // bit 11
- u16 ms_config_en:1; // bit 12
- u16 test_mode:3; // bits 13-15
+ u16 res:8; /* bit 0-7 */
+ u16 link_1000hdx:1; /* bit 8 */
+ u16 link_1000fdx:1; /* bit 9 */
+ u16 port_type:1; /* bit 10 */
+ u16 ms_value:1; /* bit 11 */
+ u16 ms_config_en:1; /* bit 12 */
+ u16 test_mode:3; /* bits 13-15 */
#endif
} bits;
} MI_GCR_t, *PMI_GCR_t;
@@ -393,23 +393,23 @@ typedef union _MI_GSR_t {
u16 value;
struct {
#ifdef _BIT_FIELDS_HTOL
- u16 ms_config_fault:1; // bit 15
- u16 ms_resolve:1; // bit 14
- u16 local_rx_status:1; // bit 13
- u16 remote_rx_status:1; // bit 12
- u16 link_1000fdx:1; // bit 11
- u16 link_1000hdx:1; // bit 10
- u16 res:2; // bits 8-9
- u16 idle_err_cnt:8; // bits 0-7
+ u16 ms_config_fault:1; /* bit 15 */
+ u16 ms_resolve:1; /* bit 14 */
+ u16 local_rx_status:1; /* bit 13 */
+ u16 remote_rx_status:1; /* bit 12 */
+ u16 link_1000fdx:1; /* bit 11 */
+ u16 link_1000hdx:1; /* bit 10 */
+ u16 res:2; /* bits 8-9 */
+ u16 idle_err_cnt:8; /* bits 0-7 */
#else
- u16 idle_err_cnt:8; // bits 0-7
- u16 res:2; // bits 8-9
- u16 link_1000hdx:1; // bit 10
- u16 link_1000fdx:1; // bit 11
- u16 remote_rx_status:1; // bit 12
- u16 local_rx_status:1; // bit 13
- u16 ms_resolve:1; // bit 14
- u16 ms_config_fault:1; // bit 15
+ u16 idle_err_cnt:8; /* bits 0-7 */
+ u16 res:2; /* bits 8-9 */
+ u16 link_1000hdx:1; /* bit 10 */
+ u16 link_1000fdx:1; /* bit 11 */
+ u16 remote_rx_status:1; /* bit 12 */
+ u16 local_rx_status:1; /* bit 13 */
+ u16 ms_resolve:1; /* bit 14 */
+ u16 ms_config_fault:1; /* bit 15 */
#endif
} bits;
} MI_GSR_t, *PMI_GSR_t;
@@ -419,39 +419,39 @@ typedef union _MI_RES_t {
u16 value;
struct {
#ifdef _BIT_FIELDS_HTOL
- u16 res15:1; // bit 15
- u16 res14:1; // bit 14
- u16 res13:1; // bit 13
- u16 res12:1; // bit 12
- u16 res11:1; // bit 11
- u16 res10:1; // bit 10
- u16 res9:1; // bit 9
- u16 res8:1; // bit 8
- u16 res7:1; // bit 7
- u16 res6:1; // bit 6
- u16 res5:1; // bit 5
- u16 res4:1; // bit 4
- u16 res3:1; // bit 3
- u16 res2:1; // bit 2
- u16 res1:1; // bit 1
- u16 res0:1; // bit 0
+ u16 res15:1; /* bit 15 */
+ u16 res14:1; /* bit 14 */
+ u16 res13:1; /* bit 13 */
+ u16 res12:1; /* bit 12 */
+ u16 res11:1; /* bit 11 */
+ u16 res10:1; /* bit 10 */
+ u16 res9:1; /* bit 9 */
+ u16 res8:1; /* bit 8 */
+ u16 res7:1; /* bit 7 */
+ u16 res6:1; /* bit 6 */
+ u16 res5:1; /* bit 5 */
+ u16 res4:1; /* bit 4 */
+ u16 res3:1; /* bit 3 */
+ u16 res2:1; /* bit 2 */
+ u16 res1:1; /* bit 1 */
+ u16 res0:1; /* bit 0 */
#else
- u16 res0:1; // bit 0
- u16 res1:1; // bit 1
- u16 res2:1; // bit 2
- u16 res3:1; // bit 3
- u16 res4:1; // bit 4
- u16 res5:1; // bit 5
- u16 res6:1; // bit 6
- u16 res7:1; // bit 7
- u16 res8:1; // bit 8
- u16 res9:1; // bit 9
- u16 res10:1; // bit 10
- u16 res11:1; // bit 11
- u16 res12:1; // bit 12
- u16 res13:1; // bit 13
- u16 res14:1; // bit 14
- u16 res15:1; // bit 15
+ u16 res0:1; /* bit 0 */
+ u16 res1:1; /* bit 1 */
+ u16 res2:1; /* bit 2 */
+ u16 res3:1; /* bit 3 */
+ u16 res4:1; /* bit 4 */
+ u16 res5:1; /* bit 5 */
+ u16 res6:1; /* bit 6 */
+ u16 res7:1; /* bit 7 */
+ u16 res8:1; /* bit 8 */
+ u16 res9:1; /* bit 9 */
+ u16 res10:1; /* bit 10 */
+ u16 res11:1; /* bit 11 */
+ u16 res12:1; /* bit 12 */
+ u16 res13:1; /* bit 13 */
+ u16 res14:1; /* bit 14 */
+ u16 res15:1; /* bit 15 */
#endif
} bits;
} MI_RES_t, *PMI_RES_t;
@@ -461,17 +461,17 @@ typedef union _MI_ESR_t {
u16 value;
struct {
#ifdef _BIT_FIELDS_HTOL
- u16 link_1000Xfdx:1; // bit 15
- u16 link_1000Xhdx:1; // bit 14
- u16 link_1000fdx:1; // bit 13
- u16 link_1000hdx:1; // bit 12
- u16 res:12; // bit 0-11
+ u16 link_1000Xfdx:1; /* bit 15 */
+ u16 link_1000Xhdx:1; /* bit 14 */
+ u16 link_1000fdx:1; /* bit 13 */
+ u16 link_1000hdx:1; /* bit 12 */
+ u16 res:12; /* bit 0-11 */
#else
- u16 res:12; // bit 0-11
- u16 link_1000hdx:1; // bit 12
- u16 link_1000fdx:1; // bit 13
- u16 link_1000Xhdx:1; // bit 14
- u16 link_1000Xfdx:1; // bit 15
+ u16 res:12; /* bit 0-11 */
+ u16 link_1000hdx:1; /* bit 12 */
+ u16 link_1000fdx:1; /* bit 13 */
+ u16 link_1000Xhdx:1; /* bit 14 */
+ u16 link_1000Xfdx:1; /* bit 15 */
#endif
} bits;
} MI_ESR_t, *PMI_ESR_t;
@@ -483,21 +483,21 @@ typedef union _MI_LCR_t {
u16 value;
struct {
#ifdef _BIT_FIELDS_HTOL
- u16 mii_en:1; // bit 15
- u16 pcs_en:1; // bit 14
- u16 pmd_en:1; // bit 13
- u16 all_digital_en:1; // bit 12
- u16 replica_en:1; // bit 11
- u16 line_driver_en:1; // bit 10
- u16 res:10; // bit 0-9
+ u16 mii_en:1; /* bit 15 */
+ u16 pcs_en:1; /* bit 14 */
+ u16 pmd_en:1; /* bit 13 */
+ u16 all_digital_en:1; /* bit 12 */
+ u16 replica_en:1; /* bit 11 */
+ u16 line_driver_en:1; /* bit 10 */
+ u16 res:10; /* bit 0-9 */
#else
- u16 res:10; // bit 0-9
- u16 line_driver_en:1; // bit 10
- u16 replica_en:1; // bit 11
- u16 all_digital_en:1; // bit 12
- u16 pmd_en:1; // bit 13
- u16 pcs_en:1; // bit 14
- u16 mii_en:1; // bit 15
+ u16 res:10; /* bit 0-9 */
+ u16 line_driver_en:1; /* bit 10 */
+ u16 replica_en:1; /* bit 11 */
+ u16 all_digital_en:1; /* bit 12 */
+ u16 pmd_en:1; /* bit 13 */
+ u16 pcs_en:1; /* bit 14 */
+ u16 mii_en:1; /* bit 15 */
#endif
} bits;
} MI_LCR_t, *PMI_LCR_t;
@@ -509,19 +509,19 @@ typedef union _MI_MICR_t {
u16 value;
struct {
#ifdef _BIT_FIELDS_HTOL
- u16 res1:5; // bits 11-15
- u16 mi_error_count:7; // bits 4-10
- u16 res2:1; // bit 3
- u16 ignore_10g_fr:1; // bit 2
- u16 res3:1; // bit 1
- u16 preamble_supress_en:1; // bit 0
+ u16 res1:5; /* bits 11-15 */
+ u16 mi_error_count:7; /* bits 4-10 */
+ u16 res2:1; /* bit 3 */
+ u16 ignore_10g_fr:1; /* bit 2 */
+ u16 res3:1; /* bit 1 */
+ u16 preamble_supress_en:1; /* bit 0 */
#else
- u16 preamble_supress_en:1; // bit 0
- u16 res3:1; // bit 1
- u16 ignore_10g_fr:1; // bit 2
- u16 res2:1; // bit 3
- u16 mi_error_count:7; // bits 4-10
- u16 res1:5; // bits 11-15
+ u16 preamble_supress_en:1; /* bit 0 */
+ u16 res3:1; /* bit 1 */
+ u16 ignore_10g_fr:1; /* bit 2 */
+ u16 res2:1; /* bit 3 */
+ u16 mi_error_count:7; /* bits 4-10 */
+ u16 res1:5; /* bits 11-15 */
#endif
} bits;
} MI_MICR_t, *PMI_MICR_t;
@@ -531,31 +531,31 @@ typedef union _MI_PHY_CONFIG_t {
u16 value;
struct {
#ifdef _BIT_FIELDS_HTOL
- u16 crs_tx_en:1; // bit 15
- u16 res1:1; // bit 14
- u16 tx_fifo_depth:2; // bits 12-13
- u16 speed_downshift:2; // bits 10-11
- u16 pbi_detect:1; // bit 9
- u16 tbi_rate:1; // bit 8
- u16 alternate_np:1; // bit 7
- u16 group_mdio_en:1; // bit 6
- u16 tx_clock_en:1; // bit 5
- u16 sys_clock_en:1; // bit 4
- u16 res2:1; // bit 3
- u16 mac_if_mode:3; // bits 0-2
+ u16 crs_tx_en:1; /* bit 15 */
+ u16 res1:1; /* bit 14 */
+ u16 tx_fifo_depth:2; /* bits 12-13 */
+ u16 speed_downshift:2; /* bits 10-11 */
+ u16 pbi_detect:1; /* bit 9 */
+ u16 tbi_rate:1; /* bit 8 */
+ u16 alternate_np:1; /* bit 7 */
+ u16 group_mdio_en:1; /* bit 6 */
+ u16 tx_clock_en:1; /* bit 5 */
+ u16 sys_clock_en:1; /* bit 4 */
+ u16 res2:1; /* bit 3 */
+ u16 mac_if_mode:3; /* bits 0-2 */
#else
- u16 mac_if_mode:3; // bits 0-2
- u16 res2:1; // bit 3
- u16 sys_clock_en:1; // bit 4
- u16 tx_clock_en:1; // bit 5
- u16 group_mdio_en:1; // bit 6
- u16 alternate_np:1; // bit 7
- u16 tbi_rate:1; // bit 8
- u16 pbi_detect:1; // bit 9
- u16 speed_downshift:2; // bits 10-11
- u16 tx_fifo_depth:2; // bits 12-13
- u16 res1:1; // bit 14
- u16 crs_tx_en:1; // bit 15
+ u16 mac_if_mode:3; /* bits 0-2 */
+ u16 res2:1; /* bit 3 */
+ u16 sys_clock_en:1; /* bit 4 */
+ u16 tx_clock_en:1; /* bit 5 */
+ u16 group_mdio_en:1; /* bit 6 */
+ u16 alternate_np:1; /* bit 7 */
+ u16 tbi_rate:1; /* bit 8 */
+ u16 pbi_detect:1; /* bit 9 */
+ u16 speed_downshift:2; /* bits 10-11 */
+ u16 tx_fifo_depth:2; /* bits 12-13 */
+ u16 res1:1; /* bit 14 */
+ u16 crs_tx_en:1; /* bit 15 */
#endif
} bits;
} MI_PHY_CONFIG_t, *PMI_PHY_CONFIG_t;
@@ -565,29 +565,29 @@ typedef union _MI_PHY_CONTROL_t {
u16 value;
struct {
#ifdef _BIT_FIELDS_HTOL
- u16 res1:1; // bit 15
- u16 tdr_en:1; // bit 14
- u16 res2:1; // bit 13
- u16 downshift_attempts:2; // bits 11-12
- u16 res3:5; // bit 6-10
- u16 jabber_10baseT:1; // bit 5
- u16 sqe_10baseT:1; // bit 4
- u16 tp_loopback_10baseT:1; // bit 3
- u16 preamble_gen_en:1; // bit 2
- u16 res4:1; // bit 1
- u16 force_int:1; // bit 0
+ u16 res1:1; /* bit 15 */
+ u16 tdr_en:1; /* bit 14 */
+ u16 res2:1; /* bit 13 */
+ u16 downshift_attempts:2; /* bits 11-12 */
+ u16 res3:5; /* bit 6-10 */
+ u16 jabber_10baseT:1; /* bit 5 */
+ u16 sqe_10baseT:1; /* bit 4 */
+ u16 tp_loopback_10baseT:1; /* bit 3 */
+ u16 preamble_gen_en:1; /* bit 2 */
+ u16 res4:1; /* bit 1 */
+ u16 force_int:1; /* bit 0 */
#else
- u16 force_int:1; // bit 0
- u16 res4:1; // bit 1
- u16 preamble_gen_en:1; // bit 2
- u16 tp_loopback_10baseT:1; // bit 3
- u16 sqe_10baseT:1; // bit 4
- u16 jabber_10baseT:1; // bit 5
- u16 res3:5; // bit 6-10
- u16 downshift_attempts:2; // bits 11-12
- u16 res2:1; // bit 13
- u16 tdr_en:1; // bit 14
- u16 res1:1; // bit 15
+ u16 force_int:1; /* bit 0 */
+ u16 res4:1; /* bit 1 */
+ u16 preamble_gen_en:1; /* bit 2 */
+ u16 tp_loopback_10baseT:1; /* bit 3 */
+ u16 sqe_10baseT:1; /* bit 4 */
+ u16 jabber_10baseT:1; /* bit 5 */
+ u16 res3:5; /* bit 6-10 */
+ u16 downshift_attempts:2; /* bits 11-12 */
+ u16 res2:1; /* bit 13 */
+ u16 tdr_en:1; /* bit 14 */
+ u16 res1:1; /* bit 15 */
#endif
} bits;
} MI_PHY_CONTROL_t, *PMI_PHY_CONTROL_t;
@@ -597,29 +597,29 @@ typedef union _MI_IMR_t {
u16 value;
struct {
#ifdef _BIT_FIELDS_HTOL
- u16 res1:6; // bits 10-15
- u16 mdio_sync_lost:1; // bit 9
- u16 autoneg_status:1; // bit 8
- u16 hi_bit_err:1; // bit 7
- u16 np_rx:1; // bit 6
- u16 err_counter_full:1; // bit 5
- u16 fifo_over_underflow:1; // bit 4
- u16 rx_status:1; // bit 3
- u16 link_status:1; // bit 2
- u16 automatic_speed:1; // bit 1
- u16 int_en:1; // bit 0
+ u16 res1:6; /* bits 10-15 */
+ u16 mdio_sync_lost:1; /* bit 9 */
+ u16 autoneg_status:1; /* bit 8 */
+ u16 hi_bit_err:1; /* bit 7 */
+ u16 np_rx:1; /* bit 6 */
+ u16 err_counter_full:1; /* bit 5 */
+ u16 fifo_over_underflow:1; /* bit 4 */
+ u16 rx_status:1; /* bit 3 */
+ u16 link_status:1; /* bit 2 */
+ u16 automatic_speed:1; /* bit 1 */
+ u16 int_en:1; /* bit 0 */
#else
- u16 int_en:1; // bit 0
- u16 automatic_speed:1; // bit 1
- u16 link_status:1; // bit 2
- u16 rx_status:1; // bit 3
- u16 fifo_over_underflow:1; // bit 4
- u16 err_counter_full:1; // bit 5
- u16 np_rx:1; // bit 6
- u16 hi_bit_err:1; // bit 7
- u16 autoneg_status:1; // bit 8
- u16 mdio_sync_lost:1; // bit 9
- u16 res1:6; // bits 10-15
+ u16 int_en:1; /* bit 0 */
+ u16 automatic_speed:1; /* bit 1 */
+ u16 link_status:1; /* bit 2 */
+ u16 rx_status:1; /* bit 3 */
+ u16 fifo_over_underflow:1; /* bit 4 */
+ u16 err_counter_full:1; /* bit 5 */
+ u16 np_rx:1; /* bit 6 */
+ u16 hi_bit_err:1; /* bit 7 */
+ u16 autoneg_status:1; /* bit 8 */
+ u16 mdio_sync_lost:1; /* bit 9 */
+ u16 res1:6; /* bits 10-15 */
#endif
} bits;
} MI_IMR_t, *PMI_IMR_t;
@@ -629,29 +629,29 @@ typedef union _MI_ISR_t {
u16 value;
struct {
#ifdef _BIT_FIELDS_HTOL
- u16 res1:6; // bits 10-15
- u16 mdio_sync_lost:1; // bit 9
- u16 autoneg_status:1; // bit 8
- u16 hi_bit_err:1; // bit 7
- u16 np_rx:1; // bit 6
- u16 err_counter_full:1; // bit 5
- u16 fifo_over_underflow:1; // bit 4
- u16 rx_status:1; // bit 3
- u16 link_status:1; // bit 2
- u16 automatic_speed:1; // bit 1
- u16 int_en:1; // bit 0
+ u16 res1:6; /* bits 10-15 */
+ u16 mdio_sync_lost:1; /* bit 9 */
+ u16 autoneg_status:1; /* bit 8 */
+ u16 hi_bit_err:1; /* bit 7 */
+ u16 np_rx:1; /* bit 6 */
+ u16 err_counter_full:1; /* bit 5 */
+ u16 fifo_over_underflow:1; /* bit 4 */
+ u16 rx_status:1; /* bit 3 */
+ u16 link_status:1; /* bit 2 */
+ u16 automatic_speed:1; /* bit 1 */
+ u16 int_en:1; /* bit 0 */
#else
- u16 int_en:1; // bit 0
- u16 automatic_speed:1; // bit 1
- u16 link_status:1; // bit 2
- u16 rx_status:1; // bit 3
- u16 fifo_over_underflow:1; // bit 4
- u16 err_counter_full:1; // bit 5
- u16 np_rx:1; // bit 6
- u16 hi_bit_err:1; // bit 7
- u16 autoneg_status:1; // bit 8
- u16 mdio_sync_lost:1; // bit 9
- u16 res1:6; // bits 10-15
+ u16 int_en:1; /* bit 0 */
+ u16 automatic_speed:1; /* bit 1 */
+ u16 link_status:1; /* bit 2 */
+ u16 rx_status:1; /* bit 3 */
+ u16 fifo_over_underflow:1; /* bit 4 */
+ u16 err_counter_full:1; /* bit 5 */
+ u16 np_rx:1; /* bit 6 */
+ u16 hi_bit_err:1; /* bit 7 */
+ u16 autoneg_status:1; /* bit 8 */
+ u16 mdio_sync_lost:1; /* bit 9 */
+ u16 res1:6; /* bits 10-15 */
#endif
} bits;
} MI_ISR_t, *PMI_ISR_t;
@@ -661,35 +661,35 @@ typedef union _MI_PSR_t {
u16 value;
struct {
#ifdef _BIT_FIELDS_HTOL
- u16 res1:1; // bit 15
- u16 autoneg_fault:2; // bit 13-14
- u16 autoneg_status:1; // bit 12
- u16 mdi_x_status:1; // bit 11
- u16 polarity_status:1; // bit 10
- u16 speed_status:2; // bits 8-9
- u16 duplex_status:1; // bit 7
- u16 link_status:1; // bit 6
- u16 tx_status:1; // bit 5
- u16 rx_status:1; // bit 4
- u16 collision_status:1; // bit 3
- u16 autoneg_en:1; // bit 2
- u16 pause_en:1; // bit 1
- u16 asymmetric_dir:1; // bit 0
+ u16 res1:1; /* bit 15 */
+ u16 autoneg_fault:2; /* bit 13-14 */
+ u16 autoneg_status:1; /* bit 12 */
+ u16 mdi_x_status:1; /* bit 11 */
+ u16 polarity_status:1; /* bit 10 */
+ u16 speed_status:2; /* bits 8-9 */
+ u16 duplex_status:1; /* bit 7 */
+ u16 link_status:1; /* bit 6 */
+ u16 tx_status:1; /* bit 5 */
+ u16 rx_status:1; /* bit 4 */
+ u16 collision_status:1; /* bit 3 */
+ u16 autoneg_en:1; /* bit 2 */
+ u16 pause_en:1; /* bit 1 */
+ u16 asymmetric_dir:1; /* bit 0 */
#else
- u16 asymmetric_dir:1; // bit 0
- u16 pause_en:1; // bit 1
- u16 autoneg_en:1; // bit 2
- u16 collision_status:1; // bit 3
- u16 rx_status:1; // bit 4
- u16 tx_status:1; // bit 5
- u16 link_status:1; // bit 6
- u16 duplex_status:1; // bit 7
- u16 speed_status:2; // bits 8-9
- u16 polarity_status:1; // bit 10
- u16 mdi_x_status:1; // bit 11
- u16 autoneg_status:1; // bit 12
- u16 autoneg_fault:2; // bit 13-14
- u16 res1:1; // bit 15
+ u16 asymmetric_dir:1; /* bit 0 */
+ u16 pause_en:1; /* bit 1 */
+ u16 autoneg_en:1; /* bit 2 */
+ u16 collision_status:1; /* bit 3 */
+ u16 rx_status:1; /* bit 4 */
+ u16 tx_status:1; /* bit 5 */
+ u16 link_status:1; /* bit 6 */
+ u16 duplex_status:1; /* bit 7 */
+ u16 speed_status:2; /* bits 8-9 */
+ u16 polarity_status:1; /* bit 10 */
+ u16 mdi_x_status:1; /* bit 11 */
+ u16 autoneg_status:1; /* bit 12 */
+ u16 autoneg_fault:2; /* bit 13-14 */
+ u16 res1:1; /* bit 15 */
#endif
} bits;
} MI_PSR_t, *PMI_PSR_t;
@@ -699,25 +699,25 @@ typedef union _MI_LCR1_t {
u16 value;
struct {
#ifdef _BIT_FIELDS_HTOL
- u16 res1:2; // bits 14-15
- u16 led_dup_indicate:2; // bits 12-13
- u16 led_10baseT:2; // bits 10-11
- u16 led_collision:2; // bits 8-9
- u16 res2:2; // bits 6-7
- u16 res3:2; // bits 4-5
- u16 pulse_dur:2; // bits 2-3
- u16 pulse_stretch1:1; // bit 1
- u16 pulse_stretch0:1; // bit 0
+ u16 res1:2; /* bits 14-15 */
+ u16 led_dup_indicate:2; /* bits 12-13 */
+ u16 led_10baseT:2; /* bits 10-11 */
+ u16 led_collision:2; /* bits 8-9 */
+ u16 res2:2; /* bits 6-7 */
+ u16 res3:2; /* bits 4-5 */
+ u16 pulse_dur:2; /* bits 2-3 */
+ u16 pulse_stretch1:1; /* bit 1 */
+ u16 pulse_stretch0:1; /* bit 0 */
#else
- u16 pulse_stretch0:1; // bit 0
- u16 pulse_stretch1:1; // bit 1
- u16 pulse_dur:2; // bits 2-3
- u16 res3:2; // bits 4-5
- u16 res2:2; // bits 6-7
- u16 led_collision:2; // bits 8-9
- u16 led_10baseT:2; // bits 10-11
- u16 led_dup_indicate:2; // bits 12-13
- u16 res1:2; // bits 14-15
+ u16 pulse_stretch0:1; /* bit 0 */
+ u16 pulse_stretch1:1; /* bit 1 */
+ u16 pulse_dur:2; /* bits 2-3 */
+ u16 res3:2; /* bits 4-5 */
+ u16 res2:2; /* bits 6-7 */
+ u16 led_collision:2; /* bits 8-9 */
+ u16 led_10baseT:2; /* bits 10-11 */
+ u16 led_dup_indicate:2; /* bits 12-13 */
+ u16 res1:2; /* bits 14-15 */
#endif
} bits;
} MI_LCR1_t, *PMI_LCR1_t;
@@ -727,15 +727,15 @@ typedef union _MI_LCR2_t {
u16 value;
struct {
#ifdef _BIT_FIELDS_HTOL
- u16 led_link:4; // bits 12-15
- u16 led_tx_rx:4; // bits 8-11
- u16 led_100BaseTX:4; // bits 4-7
- u16 led_1000BaseT:4; // bits 0-3
+ u16 led_link:4; /* bits 12-15 */
+ u16 led_tx_rx:4; /* bits 8-11 */
+ u16 led_100BaseTX:4; /* bits 4-7 */
+ u16 led_1000BaseT:4; /* bits 0-3 */
#else
- u16 led_1000BaseT:4; // bits 0-3
- u16 led_100BaseTX:4; // bits 4-7
- u16 led_tx_rx:4; // bits 8-11
- u16 led_link:4; // bits 12-15
+ u16 led_1000BaseT:4; /* bits 0-3 */
+ u16 led_100BaseTX:4; /* bits 4-7 */
+ u16 led_tx_rx:4; /* bits 8-11 */
+ u16 led_link:4; /* bits 12-15 */
#endif
} bits;
} MI_LCR2_t, *PMI_LCR2_t;
@@ -802,41 +802,41 @@ void SetPhy_10BaseTHalfDuplex(struct et131x_adapter *adapter);
/* Defines for PHY access routines */
-// Define bit operation flags
+/* Define bit operation flags */
#define TRUEPHY_BIT_CLEAR 0
#define TRUEPHY_BIT_SET 1
#define TRUEPHY_BIT_READ 2
-// Define read/write operation flags
+/* Define read/write operation flags */
#ifndef TRUEPHY_READ
#define TRUEPHY_READ 0
#define TRUEPHY_WRITE 1
#define TRUEPHY_MASK 2
#endif
-// Define speeds
+/* Define speeds */
#define TRUEPHY_SPEED_10MBPS 0
#define TRUEPHY_SPEED_100MBPS 1
#define TRUEPHY_SPEED_1000MBPS 2
-// Define duplex modes
+/* Define duplex modes */
#define TRUEPHY_DUPLEX_HALF 0
#define TRUEPHY_DUPLEX_FULL 1
-// Define master/slave configuration values
+/* Define master/slave configuration values */
#define TRUEPHY_CFG_SLAVE 0
#define TRUEPHY_CFG_MASTER 1
-// Define MDI/MDI-X settings
+/* Define MDI/MDI-X settings */
#define TRUEPHY_MDI 0
#define TRUEPHY_MDIX 1
#define TRUEPHY_AUTO_MDI_MDIX 2
-// Define 10Base-T link polarities
+/* Define 10Base-T link polarities */
#define TRUEPHY_POLARITY_NORMAL 0
#define TRUEPHY_POLARITY_INVERTED 1
-// Define auto-negotiation results
+/* Define auto-negotiation results */
#define TRUEPHY_ANEG_NOT_COMPLETE 0
#define TRUEPHY_ANEG_COMPLETE 1
#define TRUEPHY_ANEG_DISABLED 2
@@ -848,38 +848,38 @@ void SetPhy_10BaseTHalfDuplex(struct et131x_adapter *adapter);
#define TRUEPHY_ADV_DUPLEX_BOTH \
(TRUEPHY_ADV_DUPLEX_FULL | TRUEPHY_ADV_DUPLEX_HALF)
-#define PHY_CONTROL 0x00 //#define TRU_MI_CONTROL_REGISTER 0
-#define PHY_STATUS 0x01 //#define TRU_MI_STATUS_REGISTER 1
-#define PHY_ID_1 0x02 //#define TRU_MI_PHY_IDENTIFIER_1_REGISTER 2
-#define PHY_ID_2 0x03 //#define TRU_MI_PHY_IDENTIFIER_2_REGISTER 3
-#define PHY_AUTO_ADVERTISEMENT 0x04 //#define TRU_MI_ADVERTISEMENT_REGISTER 4
-#define PHY_AUTO_LINK_PARTNER 0x05 //#define TRU_MI_LINK_PARTNER_ABILITY_REGISTER 5
-#define PHY_AUTO_EXPANSION 0x06 //#define TRU_MI_EXPANSION_REGISTER 6
-#define PHY_AUTO_NEXT_PAGE_TX 0x07 //#define TRU_MI_NEXT_PAGE_TRANSMIT_REGISTER 7
-#define PHY_LINK_PARTNER_NEXT_PAGE 0x08 //#define TRU_MI_LINK_PARTNER_NEXT_PAGE_REGISTER 8
-#define PHY_1000_CONTROL 0x09 //#define TRU_MI_1000BASET_CONTROL_REGISTER 9
-#define PHY_1000_STATUS 0x0A //#define TRU_MI_1000BASET_STATUS_REGISTER 10
-
-#define PHY_EXTENDED_STATUS 0x0F //#define TRU_MI_EXTENDED_STATUS_REGISTER 15
-
-// some defines for modem registers that seem to be 'reserved'
+#define PHY_CONTROL 0x00 /* #define TRU_MI_CONTROL_REGISTER 0 */
+#define PHY_STATUS 0x01 /* #define TRU_MI_STATUS_REGISTER 1 */
+#define PHY_ID_1 0x02 /* #define TRU_MI_PHY_IDENTIFIER_1_REGISTER 2 */
+#define PHY_ID_2 0x03 /* #define TRU_MI_PHY_IDENTIFIER_2_REGISTER 3 */
+#define PHY_AUTO_ADVERTISEMENT 0x04 /* #define TRU_MI_ADVERTISEMENT_REGISTER 4 */
+#define PHY_AUTO_LINK_PARTNER 0x05 /* #define TRU_MI_LINK_PARTNER_ABILITY_REGISTER 5 */
+#define PHY_AUTO_EXPANSION 0x06 /* #define TRU_MI_EXPANSION_REGISTER 6 */
+#define PHY_AUTO_NEXT_PAGE_TX 0x07 /* #define TRU_MI_NEXT_PAGE_TRANSMIT_REGISTER 7 */
+#define PHY_LINK_PARTNER_NEXT_PAGE 0x08 /* #define TRU_MI_LINK_PARTNER_NEXT_PAGE_REGISTER 8 */
+#define PHY_1000_CONTROL 0x09 /* #define TRU_MI_1000BASET_CONTROL_REGISTER 9 */
+#define PHY_1000_STATUS 0x0A /* #define TRU_MI_1000BASET_STATUS_REGISTER 10 */
+
+#define PHY_EXTENDED_STATUS 0x0F /* #define TRU_MI_EXTENDED_STATUS_REGISTER 15 */
+
+/* some defines for modem registers that seem to be 'reserved' */
#define PHY_INDEX_REG 0x10
#define PHY_DATA_REG 0x11
-#define PHY_MPHY_CONTROL_REG 0x12 //#define TRU_VMI_MPHY_CONTROL_REGISTER 18
-
-#define PHY_LOOPBACK_CONTROL 0x13 //#define TRU_VMI_LOOPBACK_CONTROL_1_REGISTER 19
- //#define TRU_VMI_LOOPBACK_CONTROL_2_REGISTER 20
-#define PHY_REGISTER_MGMT_CONTROL 0x15 //#define TRU_VMI_MI_SEQ_CONTROL_REGISTER 21
-#define PHY_CONFIG 0x16 //#define TRU_VMI_CONFIGURATION_REGISTER 22
-#define PHY_PHY_CONTROL 0x17 //#define TRU_VMI_PHY_CONTROL_REGISTER 23
-#define PHY_INTERRUPT_MASK 0x18 //#define TRU_VMI_INTERRUPT_MASK_REGISTER 24
-#define PHY_INTERRUPT_STATUS 0x19 //#define TRU_VMI_INTERRUPT_STATUS_REGISTER 25
-#define PHY_PHY_STATUS 0x1A //#define TRU_VMI_PHY_STATUS_REGISTER 26
-#define PHY_LED_1 0x1B //#define TRU_VMI_LED_CONTROL_1_REGISTER 27
-#define PHY_LED_2 0x1C //#define TRU_VMI_LED_CONTROL_2_REGISTER 28
- //#define TRU_VMI_LINK_CONTROL_REGISTER 29
- //#define TRU_VMI_TIMING_CONTROL_REGISTER
+#define PHY_MPHY_CONTROL_REG 0x12 /* #define TRU_VMI_MPHY_CONTROL_REGISTER 18 */
+
+#define PHY_LOOPBACK_CONTROL 0x13 /* #define TRU_VMI_LOOPBACK_CONTROL_1_REGISTER 19 */
+ /* #define TRU_VMI_LOOPBACK_CONTROL_2_REGISTER 20 */
+#define PHY_REGISTER_MGMT_CONTROL 0x15 /* #define TRU_VMI_MI_SEQ_CONTROL_REGISTER 21 */
+#define PHY_CONFIG 0x16 /* #define TRU_VMI_CONFIGURATION_REGISTER 22 */
+#define PHY_PHY_CONTROL 0x17 /* #define TRU_VMI_PHY_CONTROL_REGISTER 23 */
+#define PHY_INTERRUPT_MASK 0x18 /* #define TRU_VMI_INTERRUPT_MASK_REGISTER 24 */
+#define PHY_INTERRUPT_STATUS 0x19 /* #define TRU_VMI_INTERRUPT_STATUS_REGISTER 25 */
+#define PHY_PHY_STATUS 0x1A /* #define TRU_VMI_PHY_STATUS_REGISTER 26 */
+#define PHY_LED_1 0x1B /* #define TRU_VMI_LED_CONTROL_1_REGISTER 27 */
+#define PHY_LED_2 0x1C /* #define TRU_VMI_LED_CONTROL_2_REGISTER 28 */
+ /* #define TRU_VMI_LINK_CONTROL_REGISTER 29 */
+ /* #define TRU_VMI_TIMING_CONTROL_REGISTER */
/* Prototypes for PHY access routines */
void ET1310_PhyInit(struct et131x_adapter *adapter);
diff --git a/drivers/staging/et131x/et1310_pm.c b/drivers/staging/et131x/et1310_pm.c
index 9539bc628cae..5d652caf82e0 100644
--- a/drivers/staging/et131x/et1310_pm.c
+++ b/drivers/staging/et131x/et1310_pm.c
@@ -2,7 +2,7 @@
* Agere Systems Inc.
* 10/100/1000 Base-T Ethernet Driver for the ET1301 and ET131x series MACs
*
- * Copyright © 2005 Agere Systems Inc.
+ * Copyright © 2005 Agere Systems Inc.
* All rights reserved.
* http://www.agere.com
*
@@ -19,7 +19,7 @@
* software indicates your acceptance of these terms and conditions. If you do
* not agree with these terms and conditions, do not use the software.
*
- * Copyright © 2005 Agere Systems Inc.
+ * Copyright © 2005 Agere Systems Inc.
* All rights reserved.
*
* Redistribution and use in source or binary forms, with or without
@@ -40,7 +40,7 @@
*
* Disclaimer
*
- * THIS SOFTWARE IS PROVIDED “AS IS” AND ANY EXPRESS OR IMPLIED WARRANTIES,
+ * THIS SOFTWARE IS PROVIDED "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES,
* INCLUDING, BUT NOT LIMITED TO, INFRINGEMENT AND THE IMPLIED WARRANTIES OF
* MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. ANY
* USE, MODIFICATION OR DISTRIBUTION OF THIS SOFTWARE IS SOLELY AT THE USERS OWN
@@ -73,9 +73,9 @@
#include <linux/interrupt.h>
#include <linux/in.h>
#include <linux/delay.h>
-#include <asm/io.h>
+#include <linux/io.h>
+#include <linux/bitops.h>
#include <asm/system.h>
-#include <asm/bitops.h>
#include <linux/netdevice.h>
#include <linux/etherdevice.h>
@@ -139,9 +139,8 @@ void EnablePhyComa(struct et131x_adapter *pAdapter)
spin_unlock_irqrestore(&pAdapter->SendHWLock, lockflags);
/* Wait for outstanding Receive packets */
- while ((MP_GET_RCV_REF(pAdapter) != 0) && (LoopCounter-- > 0)) {
+ while ((MP_GET_RCV_REF(pAdapter) != 0) && (LoopCounter-- > 0))
mdelay(2);
- }
/* Gate off JAGCore 3 clock domains */
GlobalPmCSR.bits.pm_sysclk_gate = 0;
@@ -188,9 +187,9 @@ void DisablePhyComa(struct et131x_adapter *pAdapter)
et131x_reset_recv(pAdapter);
/* Bring the device back to the state it was during init prior to
- * autonegotiation being complete. This way, when we get the auto-neg
- * complete interrupt, we can complete init by calling ConfigMacREGS2.
- */
+ * autonegotiation being complete. This way, when we get the auto-neg
+ * complete interrupt, we can complete init by calling ConfigMacREGS2.
+ */
et131x_soft_reset(pAdapter);
/* setup et1310 as per the documentation ?? */
diff --git a/drivers/staging/et131x/et1310_pm.h b/drivers/staging/et131x/et1310_pm.h
index 6802338e29d9..dca9977f59a2 100644
--- a/drivers/staging/et131x/et1310_pm.h
+++ b/drivers/staging/et131x/et1310_pm.h
@@ -2,7 +2,7 @@
* Agere Systems Inc.
* 10/100/1000 Base-T Ethernet Driver for the ET1301 and ET131x series MACs
*
- * Copyright © 2005 Agere Systems Inc.
+ * Copyright © 2005 Agere Systems Inc.
* All rights reserved.
* http://www.agere.com
*
@@ -20,7 +20,7 @@
* software indicates your acceptance of these terms and conditions. If you do
* not agree with these terms and conditions, do not use the software.
*
- * Copyright © 2005 Agere Systems Inc.
+ * Copyright © 2005 Agere Systems Inc.
* All rights reserved.
*
* Redistribution and use in source or binary forms, with or without
@@ -41,7 +41,7 @@
*
* Disclaimer
*
- * THIS SOFTWARE IS PROVIDED “AS IS” AND ANY EXPRESS OR IMPLIED WARRANTIES,
+ * THIS SOFTWARE IS PROVIDED "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES,
* INCLUDING, BUT NOT LIMITED TO, INFRINGEMENT AND THE IMPLIED WARRANTIES OF
* MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. ANY
* USE, MODIFICATION OR DISTRIBUTION OF THIS SOFTWARE IS SOLELY AT THE USERS OWN
@@ -62,7 +62,7 @@
#include "et1310_address_map.h"
#define MAX_WOL_PACKET_SIZE 0x80
-#define MAX_WOL_MASK_SIZE ( MAX_WOL_PACKET_SIZE / 8 )
+#define MAX_WOL_MASK_SIZE (MAX_WOL_PACKET_SIZE / 8)
#define NUM_WOL_PATTERNS 0x5
#define CRC16_POLY 0x1021
diff --git a/drivers/staging/et131x/et1310_rx.c b/drivers/staging/et131x/et1310_rx.c
index 8dc559a77ad3..9b9e7733f8ac 100644
--- a/drivers/staging/et131x/et1310_rx.c
+++ b/drivers/staging/et131x/et1310_rx.c
@@ -2,7 +2,7 @@
* Agere Systems Inc.
* 10/100/1000 Base-T Ethernet Driver for the ET1301 and ET131x series MACs
*
- * Copyright © 2005 Agere Systems Inc.
+ * Copyright © 2005 Agere Systems Inc.
* All rights reserved.
* http://www.agere.com
*
@@ -19,7 +19,7 @@
* software indicates your acceptance of these terms and conditions. If you do
* not agree with these terms and conditions, do not use the software.
*
- * Copyright © 2005 Agere Systems Inc.
+ * Copyright © 2005 Agere Systems Inc.
* All rights reserved.
*
* Redistribution and use in source or binary forms, with or without
@@ -40,7 +40,7 @@
*
* Disclaimer
*
- * THIS SOFTWARE IS PROVIDED “AS IS” AND ANY EXPRESS OR IMPLIED WARRANTIES,
+ * THIS SOFTWARE IS PROVIDED "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES,
* INCLUDING, BUT NOT LIMITED TO, INFRINGEMENT AND THE IMPLIED WARRANTIES OF
* MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. ANY
* USE, MODIFICATION OR DISTRIBUTION OF THIS SOFTWARE IS SOLELY AT THE USERS OWN
@@ -74,9 +74,9 @@
#include <linux/interrupt.h>
#include <linux/in.h>
#include <linux/delay.h>
-#include <asm/io.h>
+#include <linux/io.h>
+#include <linux/bitops.h>
#include <asm/system.h>
-#include <asm/bitops.h>
#include <linux/netdevice.h>
#include <linux/etherdevice.h>
@@ -120,7 +120,7 @@ int et131x_rx_dma_memory_alloc(struct et131x_adapter *adapter)
DBG_ENTER(et131x_dbginfo);
/* Setup some convenience pointers */
- rx_ring = (RX_RING_t *) & adapter->RxRing;
+ rx_ring = (RX_RING_t *) &adapter->RxRing;
/* Alloc memory for the lookup table */
#ifdef USE_FBR0
@@ -250,11 +250,10 @@ int et131x_rx_dma_memory_alloc(struct et131x_adapter *adapter)
* the size of FBR0. By allocating N buffers at once, we
* reduce this overhead.
*/
- if (rx_ring->Fbr1BufferSize > 4096) {
+ if (rx_ring->Fbr1BufferSize > 4096)
Fbr1Align = 4096;
- } else {
+ else
Fbr1Align = rx_ring->Fbr1BufferSize;
- }
FBRChunkSize =
(FBR_CHUNKS * rx_ring->Fbr1BufferSize) + Fbr1Align - 1;
@@ -443,7 +442,7 @@ void et131x_rx_dma_memory_free(struct et131x_adapter *adapter)
DBG_ENTER(et131x_dbginfo);
/* Setup some convenience pointers */
- rx_ring = (RX_RING_t *) & adapter->RxRing;
+ rx_ring = (RX_RING_t *) &adapter->RxRing;
/* Free RFDs and associated packet descriptors */
DBG_ASSERT(rx_ring->nReadyRecv == rx_ring->NumRfd);
@@ -471,11 +470,10 @@ void et131x_rx_dma_memory_free(struct et131x_adapter *adapter)
if (rx_ring->Fbr1MemVa[index]) {
uint32_t Fbr1Align;
- if (rx_ring->Fbr1BufferSize > 4096) {
+ if (rx_ring->Fbr1BufferSize > 4096)
Fbr1Align = 4096;
- } else {
+ else
Fbr1Align = rx_ring->Fbr1BufferSize;
- }
bufsize =
(rx_ring->Fbr1BufferSize * FBR_CHUNKS) +
@@ -491,8 +489,8 @@ void et131x_rx_dma_memory_free(struct et131x_adapter *adapter)
}
/* Now the FIFO itself */
- rx_ring->pFbr1RingVa = (void *)((uint8_t *) rx_ring->pFbr1RingVa -
- rx_ring->Fbr1offset);
+ rx_ring->pFbr1RingVa = (void *)((uint8_t *)
+ rx_ring->pFbr1RingVa - rx_ring->Fbr1offset);
bufsize =
(sizeof(FBR_DESC_t) * rx_ring->Fbr1NumEntries) + 0xfff;
@@ -525,8 +523,8 @@ void et131x_rx_dma_memory_free(struct et131x_adapter *adapter)
}
/* Now the FIFO itself */
- rx_ring->pFbr0RingVa = (void *)((uint8_t *) rx_ring->pFbr0RingVa -
- rx_ring->Fbr0offset);
+ rx_ring->pFbr0RingVa = (void *)((uint8_t *)
+ rx_ring->pFbr0RingVa - rx_ring->Fbr0offset);
bufsize =
(sizeof(FBR_DESC_t) * rx_ring->Fbr0NumEntries) + 0xfff;
@@ -556,12 +554,12 @@ void et131x_rx_dma_memory_free(struct et131x_adapter *adapter)
/* Free area of memory for the writeback of status information */
if (rx_ring->pRxStatusVa) {
- rx_ring->pRxStatusVa = (void *)((uint8_t *) rx_ring->pRxStatusVa -
- rx_ring->RxStatusOffset);
+ rx_ring->pRxStatusVa = (void *)((uint8_t *)
+ rx_ring->pRxStatusVa - rx_ring->RxStatusOffset);
pci_free_consistent(adapter->pdev,
- sizeof(RX_STATUS_BLOCK_t) + 0x7,
- rx_ring->pRxStatusVa, rx_ring->pRxStatusPa);
+ sizeof(RX_STATUS_BLOCK_t) + 0x7,
+ rx_ring->pRxStatusVa, rx_ring->pRxStatusPa);
rx_ring->pRxStatusVa = NULL;
}
@@ -606,7 +604,7 @@ int et131x_init_recv(struct et131x_adapter *adapter)
DBG_ENTER(et131x_dbginfo);
/* Setup some convenience pointers */
- rx_ring = (RX_RING_t *) & adapter->RxRing;
+ rx_ring = (RX_RING_t *) &adapter->RxRing;
/* Setup each RFD */
for (RfdCount = 0; RfdCount < rx_ring->NumRfd; RfdCount++) {
@@ -636,9 +634,8 @@ int et131x_init_recv(struct et131x_adapter *adapter)
TotalNumRfd++;
}
- if (TotalNumRfd > NIC_MIN_NUM_RFD) {
+ if (TotalNumRfd > NIC_MIN_NUM_RFD)
status = 0;
- }
rx_ring->NumRfd = TotalNumRfd;
@@ -841,11 +838,10 @@ void et131x_rx_dma_disable(struct et131x_adapter *pAdapter)
if (csr.bits.halt_status != 1) {
udelay(5);
csr.value = readl(&pAdapter->CSRAddress->rxdma.csr.value);
- if (csr.bits.halt_status != 1) {
+ if (csr.bits.halt_status != 1)
DBG_ERROR(et131x_dbginfo,
- "RX Dma failed to enter halt state. CSR 0x%08x\n",
- csr.value);
- }
+ "RX Dma failed to enter halt state. CSR 0x%08x\n",
+ csr.value);
}
DBG_LEAVE(et131x_dbginfo);
@@ -859,30 +855,28 @@ void et131x_rx_dma_enable(struct et131x_adapter *pAdapter)
{
DBG_RX_ENTER(et131x_dbginfo);
- if (pAdapter->RegistryPhyLoopbk) {
- /* RxDMA is disabled for loopback operation. */
+ if (pAdapter->RegistryPhyLoopbk)
+ /* RxDMA is disabled for loopback operation. */
writel(0x1, &pAdapter->CSRAddress->rxdma.csr.value);
- } else {
+ else {
/* Setup the receive dma configuration register for normal operation */
RXDMA_CSR_t csr = { 0 };
csr.bits.fbr1_enable = 1;
- if (pAdapter->RxRing.Fbr1BufferSize == 4096) {
+ if (pAdapter->RxRing.Fbr1BufferSize == 4096)
csr.bits.fbr1_size = 1;
- } else if (pAdapter->RxRing.Fbr1BufferSize == 8192) {
+ else if (pAdapter->RxRing.Fbr1BufferSize == 8192)
csr.bits.fbr1_size = 2;
- } else if (pAdapter->RxRing.Fbr1BufferSize == 16384) {
+ else if (pAdapter->RxRing.Fbr1BufferSize == 16384)
csr.bits.fbr1_size = 3;
- }
#ifdef USE_FBR0
csr.bits.fbr0_enable = 1;
- if (pAdapter->RxRing.Fbr0BufferSize == 256) {
+ if (pAdapter->RxRing.Fbr0BufferSize == 256)
csr.bits.fbr0_size = 1;
- } else if (pAdapter->RxRing.Fbr0BufferSize == 512) {
+ else if (pAdapter->RxRing.Fbr0BufferSize == 512)
csr.bits.fbr0_size = 2;
- } else if (pAdapter->RxRing.Fbr0BufferSize == 1024) {
+ else if (pAdapter->RxRing.Fbr0BufferSize == 1024)
csr.bits.fbr0_size = 3;
- }
#endif
writel(csr.value, &pAdapter->CSRAddress->rxdma.csr.value);
@@ -892,8 +886,8 @@ void et131x_rx_dma_enable(struct et131x_adapter *pAdapter)
csr.value = readl(&pAdapter->CSRAddress->rxdma.csr.value);
if (csr.bits.halt_status != 0) {
DBG_ERROR(et131x_dbginfo,
- "RX Dma failed to exit halt state. CSR 0x%08x\n",
- csr.value);
+ "RX Dma failed to exit halt state. CSR 0x%08x\n",
+ csr.value);
}
}
}
@@ -938,8 +932,8 @@ PMP_RFD nic_rx_pkts(struct et131x_adapter *pAdapter)
if (pRxStatusBlock->Word1.bits.PSRoffset ==
pRxLocal->local_psr_full.bits.psr_full &&
- pRxStatusBlock->Word1.bits.PSRwrap ==
- pRxLocal->local_psr_full.bits.psr_full_wrap) {
+ pRxStatusBlock->Word1.bits.PSRwrap ==
+ pRxLocal->local_psr_full.bits.psr_full_wrap) {
/* Looks like this ring is not updated yet */
DBG_RX(et131x_dbginfo, "(0)\n");
DBG_RX_LEAVE(et131x_dbginfo);
@@ -999,13 +993,13 @@ PMP_RFD nic_rx_pkts(struct et131x_adapter *pAdapter)
#ifdef USE_FBR0
if (ringIndex > 1 ||
- (ringIndex == 0 &&
- bufferIndex > pRxLocal->Fbr0NumEntries - 1) ||
- (ringIndex == 1 &&
- bufferIndex > pRxLocal->Fbr1NumEntries - 1))
+ (ringIndex == 0 &&
+ bufferIndex > pRxLocal->Fbr0NumEntries - 1) ||
+ (ringIndex == 1 &&
+ bufferIndex > pRxLocal->Fbr1NumEntries - 1))
#else
if (ringIndex != 1 ||
- bufferIndex > pRxLocal->Fbr1NumEntries - 1)
+ bufferIndex > pRxLocal->Fbr1NumEntries - 1)
#endif
{
/* Illegal buffer or ring index cannot be used by S/W*/
@@ -1124,30 +1118,27 @@ PMP_RFD nic_rx_pkts(struct et131x_adapter *pAdapter)
* so we free our RFD when we return
* from this function.
*/
- if (nIndex == pAdapter->MCAddressCount) {
+ if (nIndex == pAdapter->MCAddressCount)
localLen = 0;
- }
}
- if (localLen > 0) {
+ if (localLen > 0)
pAdapter->Stats.multircv++;
- }
- } else if (Word0.value & ALCATEL_BROADCAST_PKT) {
+ } else if (Word0.value & ALCATEL_BROADCAST_PKT)
pAdapter->Stats.brdcstrcv++;
- } else {
+ else
/* Not sure what this counter measures in
* promiscuous mode. Perhaps we should check
* the MAC address to see if it is directed
* to us in promiscuous mode.
*/
pAdapter->Stats.unircv++;
- }
}
if (localLen > 0) {
struct sk_buff *skb = NULL;
- //pMpRfd->PacketSize = localLen - 4;
+ /* pMpRfd->PacketSize = localLen - 4; */
pMpRfd->PacketSize = localLen;
skb = dev_alloc_skb(pMpRfd->PacketSize + 2);
@@ -1240,9 +1231,8 @@ void et131x_handle_recv_interrupt(struct et131x_adapter *pAdapter)
pMpRfd = nic_rx_pkts(pAdapter);
- if (pMpRfd == NULL) {
+ if (pMpRfd == NULL)
break;
- }
/* Do not receive any packets until a filter has been set.
* Do not receive any packets until we are at D0.
@@ -1270,12 +1260,13 @@ void et131x_handle_recv_interrupt(struct et131x_adapter *pAdapter)
* Besides, we don't really need (at this point) the
* pending list anyway.
*/
- //spin_lock_irqsave( &pAdapter->RcvPendLock, lockflags );
- //list_add_tail( &pMpRfd->list_node, &pAdapter->RxRing.RecvPendingList );
- //spin_unlock_irqrestore( &pAdapter->RcvPendLock, lockflags );
+ /* spin_lock_irqsave( &pAdapter->RcvPendLock, lockflags );
+ * list_add_tail( &pMpRfd->list_node, &pAdapter->RxRing.RecvPendingList );
+ * spin_unlock_irqrestore( &pAdapter->RcvPendLock, lockflags );
+ */
/* Update the number of outstanding Recvs */
- //MP_INC_RCV_REF( pAdapter );
+ /* MP_INC_RCV_REF( pAdapter ); */
} else {
RFDFreeArray[PacketFreeCount] = pMpRfd;
PacketFreeCount++;
diff --git a/drivers/staging/et131x/et1310_rx.h b/drivers/staging/et131x/et1310_rx.h
index ea66dbcd8dfc..3bfabd8f9671 100644
--- a/drivers/staging/et131x/et1310_rx.h
+++ b/drivers/staging/et131x/et1310_rx.h
@@ -2,7 +2,7 @@
* Agere Systems Inc.
* 10/100/1000 Base-T Ethernet Driver for the ET1301 and ET131x series MACs
*
- * Copyright © 2005 Agere Systems Inc.
+ * Copyright © 2005 Agere Systems Inc.
* All rights reserved.
* http://www.agere.com
*
@@ -20,7 +20,7 @@
* software indicates your acceptance of these terms and conditions. If you do
* not agree with these terms and conditions, do not use the software.
*
- * Copyright © 2005 Agere Systems Inc.
+ * Copyright © 2005 Agere Systems Inc.
* All rights reserved.
*
* Redistribution and use in source or binary forms, with or without
@@ -41,7 +41,7 @@
*
* Disclaimer
*
- * THIS SOFTWARE IS PROVIDED “AS IS” AND ANY EXPRESS OR IMPLIED WARRANTIES,
+ * THIS SOFTWARE IS PROVIDED "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES,
* INCLUDING, BUT NOT LIMITED TO, INFRINGEMENT AND THE IMPLIED WARRANTIES OF
* MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. ANY
* USE, MODIFICATION OR DISTRIBUTION OF THIS SOFTWARE IS SOLELY AT THE USERS OWN
@@ -64,10 +64,10 @@
#define USE_FBR0 true
#ifdef USE_FBR0
-//#define FBR0_BUFFER_SIZE 256
+/* #define FBR0_BUFFER_SIZE 256 */
#endif
-//#define FBR1_BUFFER_SIZE 2048
+/* #define FBR1_BUFFER_SIZE 2048 */
#define FBR_CHUNKS 32
@@ -95,11 +95,11 @@ typedef union _FBR_WORD2_t {
u32 value;
struct {
#ifdef _BIT_FIELDS_HTOL
- u32 reserved:22; // bits 10-31
- u32 bi:10; // bits 0-9(Buffer Index)
+ u32 reserved:22; /* bits 10-31 */
+ u32 bi:10; /* bits 0-9(Buffer Index) */
#else
- u32 bi:10; // bits 0-9(Buffer Index)
- u32 reserved:22; // bit 10-31
+ u32 bi:10; /* bits 0-9(Buffer Index) */
+ u32 reserved:22; /* bit 10-31 */
#endif
} bits;
} FBR_WORD2_t, *PFBR_WORD2_t;
@@ -115,70 +115,70 @@ typedef union _PKT_STAT_DESC_WORD0_t {
u32 value;
struct {
#ifdef _BIT_FIELDS_HTOL
- // top 16 bits are from the Alcatel Status Word as enumerated in
- // PE-MCXMAC Data Sheet IPD DS54 0210-1 (also IPD-DS80 0205-2)
+ /* top 16 bits are from the Alcatel Status Word as enumerated in */
+ /* PE-MCXMAC Data Sheet IPD DS54 0210-1 (also IPD-DS80 0205-2) */
#if 0
- u32 asw_trunc:1; // bit 31(Rx frame truncated)
+ u32 asw_trunc:1; /* bit 31(Rx frame truncated) */
#endif
- u32 asw_long_evt:1; // bit 31(Rx long event)
- u32 asw_VLAN_tag:1; // bit 30(VLAN tag detected)
- u32 asw_unsupported_op:1; // bit 29(unsupported OP code)
- u32 asw_pause_frame:1; // bit 28(is a pause frame)
- u32 asw_control_frame:1; // bit 27(is a control frame)
- u32 asw_dribble_nibble:1; // bit 26(spurious bits after EOP)
- u32 asw_broadcast:1; // bit 25(has a broadcast address)
- u32 asw_multicast:1; // bit 24(has a multicast address)
- u32 asw_OK:1; // bit 23(valid CRC + no code error)
- u32 asw_too_long:1; // bit 22(frame length > 1518 bytes)
- u32 asw_len_chk_err:1; // bit 21(frame length field incorrect)
- u32 asw_CRC_err:1; // bit 20(CRC error)
- u32 asw_code_err:1; // bit 19(one or more nibbles signalled as errors)
- u32 asw_false_carrier_event:1; // bit 18(bad carrier since last good packet)
- u32 asw_RX_DV_event:1; // bit 17(short receive event detected)
- u32 asw_prev_pkt_dropped:1;// bit 16(e.g. IFG too small on previous)
- u32 unused:5; // bits 11-15
- u32 vp:1; // bit 10(VLAN Packet)
- u32 jp:1; // bit 9(Jumbo Packet)
- u32 ft:1; // bit 8(Frame Truncated)
- u32 drop:1; // bit 7(Drop packet)
- u32 rxmac_error:1; // bit 6(RXMAC Error Indicator)
- u32 wol:1; // bit 5(WOL Event)
- u32 tcpp:1; // bit 4(TCP checksum pass)
- u32 tcpa:1; // bit 3(TCP checksum assist)
- u32 ipp:1; // bit 2(IP checksum pass)
- u32 ipa:1; // bit 1(IP checksum assist)
- u32 hp:1; // bit 0(hash pass)
+ u32 asw_long_evt:1; /* bit 31(Rx long event) */
+ u32 asw_VLAN_tag:1; /* bit 30(VLAN tag detected) */
+ u32 asw_unsupported_op:1; /* bit 29(unsupported OP code) */
+ u32 asw_pause_frame:1; /* bit 28(is a pause frame) */
+ u32 asw_control_frame:1; /* bit 27(is a control frame) */
+ u32 asw_dribble_nibble:1; /* bit 26(spurious bits after EOP) */
+ u32 asw_broadcast:1; /* bit 25(has a broadcast address) */
+ u32 asw_multicast:1; /* bit 24(has a multicast address) */
+ u32 asw_OK:1; /* bit 23(valid CRC + no code error) */
+ u32 asw_too_long:1; /* bit 22(frame length > 1518 bytes) */
+ u32 asw_len_chk_err:1; /* bit 21(frame length field incorrect) */
+ u32 asw_CRC_err:1; /* bit 20(CRC error) */
+ u32 asw_code_err:1; /* bit 19(one or more nibbles signalled as errors) */
+ u32 asw_false_carrier_event:1; /* bit 18(bad carrier since last good packet) */
+ u32 asw_RX_DV_event:1; /* bit 17(short receive event detected) */
+ u32 asw_prev_pkt_dropped:1;/* bit 16(e.g. IFG too small on previous) */
+ u32 unused:5; /* bits 11-15 */
+ u32 vp:1; /* bit 10(VLAN Packet) */
+ u32 jp:1; /* bit 9(Jumbo Packet) */
+ u32 ft:1; /* bit 8(Frame Truncated) */
+ u32 drop:1; /* bit 7(Drop packet) */
+ u32 rxmac_error:1; /* bit 6(RXMAC Error Indicator) */
+ u32 wol:1; /* bit 5(WOL Event) */
+ u32 tcpp:1; /* bit 4(TCP checksum pass) */
+ u32 tcpa:1; /* bit 3(TCP checksum assist) */
+ u32 ipp:1; /* bit 2(IP checksum pass) */
+ u32 ipa:1; /* bit 1(IP checksum assist) */
+ u32 hp:1; /* bit 0(hash pass) */
#else
- u32 hp:1; // bit 0(hash pass)
- u32 ipa:1; // bit 1(IP checksum assist)
- u32 ipp:1; // bit 2(IP checksum pass)
- u32 tcpa:1; // bit 3(TCP checksum assist)
- u32 tcpp:1; // bit 4(TCP checksum pass)
- u32 wol:1; // bit 5(WOL Event)
- u32 rxmac_error:1; // bit 6(RXMAC Error Indicator)
- u32 drop:1; // bit 7(Drop packet)
- u32 ft:1; // bit 8(Frame Truncated)
- u32 jp:1; // bit 9(Jumbo Packet)
- u32 vp:1; // bit 10(VLAN Packet)
- u32 unused:5; // bits 11-15
- u32 asw_prev_pkt_dropped:1;// bit 16(e.g. IFG too small on previous)
- u32 asw_RX_DV_event:1; // bit 17(short receive event detected)
- u32 asw_false_carrier_event:1; // bit 18(bad carrier since last good packet)
- u32 asw_code_err:1; // bit 19(one or more nibbles signalled as errors)
- u32 asw_CRC_err:1; // bit 20(CRC error)
- u32 asw_len_chk_err:1; // bit 21(frame length field incorrect)
- u32 asw_too_long:1; // bit 22(frame length > 1518 bytes)
- u32 asw_OK:1; // bit 23(valid CRC + no code error)
- u32 asw_multicast:1; // bit 24(has a multicast address)
- u32 asw_broadcast:1; // bit 25(has a broadcast address)
- u32 asw_dribble_nibble:1; // bit 26(spurious bits after EOP)
- u32 asw_control_frame:1; // bit 27(is a control frame)
- u32 asw_pause_frame:1; // bit 28(is a pause frame)
- u32 asw_unsupported_op:1; // bit 29(unsupported OP code)
- u32 asw_VLAN_tag:1; // bit 30(VLAN tag detected)
- u32 asw_long_evt:1; // bit 31(Rx long event)
+ u32 hp:1; /* bit 0(hash pass) */
+ u32 ipa:1; /* bit 1(IP checksum assist) */
+ u32 ipp:1; /* bit 2(IP checksum pass) */
+ u32 tcpa:1; /* bit 3(TCP checksum assist) */
+ u32 tcpp:1; /* bit 4(TCP checksum pass) */
+ u32 wol:1; /* bit 5(WOL Event) */
+ u32 rxmac_error:1; /* bit 6(RXMAC Error Indicator) */
+ u32 drop:1; /* bit 7(Drop packet) */
+ u32 ft:1; /* bit 8(Frame Truncated) */
+ u32 jp:1; /* bit 9(Jumbo Packet) */
+ u32 vp:1; /* bit 10(VLAN Packet) */
+ u32 unused:5; /* bits 11-15 */
+ u32 asw_prev_pkt_dropped:1;/* bit 16(e.g. IFG too small on previous) */
+ u32 asw_RX_DV_event:1; /* bit 17(short receive event detected) */
+ u32 asw_false_carrier_event:1; /* bit 18(bad carrier since last good packet) */
+ u32 asw_code_err:1; /* bit 19(one or more nibbles signalled as errors) */
+ u32 asw_CRC_err:1; /* bit 20(CRC error) */
+ u32 asw_len_chk_err:1; /* bit 21(frame length field incorrect) */
+ u32 asw_too_long:1; /* bit 22(frame length > 1518 bytes) */
+ u32 asw_OK:1; /* bit 23(valid CRC + no code error) */
+ u32 asw_multicast:1; /* bit 24(has a multicast address) */
+ u32 asw_broadcast:1; /* bit 25(has a broadcast address) */
+ u32 asw_dribble_nibble:1; /* bit 26(spurious bits after EOP) */
+ u32 asw_control_frame:1; /* bit 27(is a control frame) */
+ u32 asw_pause_frame:1; /* bit 28(is a pause frame) */
+ u32 asw_unsupported_op:1; /* bit 29(unsupported OP code) */
+ u32 asw_VLAN_tag:1; /* bit 30(VLAN tag detected) */
+ u32 asw_long_evt:1; /* bit 31(Rx long event) */
#if 0
- u32 asw_trunc:1; // bit 31(Rx frame truncated)
+ u32 asw_trunc:1; /* bit 31(Rx frame truncated) */
#endif
#endif
} bits;
@@ -188,15 +188,15 @@ typedef union _PKT_STAT_DESC_WORD1_t {
u32 value;
struct {
#ifdef _BIT_FIELDS_HTOL
- u32 unused:4; // bits 28-31
- u32 ri:2; // bits 26-27(Ring Index)
- u32 bi:10; // bits 16-25(Buffer Index)
- u32 length:16; // bit 0-15(length in bytes)
+ u32 unused:4; /* bits 28-31 */
+ u32 ri:2; /* bits 26-27(Ring Index) */
+ u32 bi:10; /* bits 16-25(Buffer Index) */
+ u32 length:16; /* bit 0-15(length in bytes) */
#else
- u32 length:16; // bit 0-15(length in bytes)
- u32 bi:10; // bits 16-25(Buffer Index)
- u32 ri:2; // bits 26-27(Ring Index)
- u32 unused:4; // bits 28-31
+ u32 length:16; /* bit 0-15(length in bytes) */
+ u32 bi:10; /* bits 16-25(Buffer Index) */
+ u32 ri:2; /* bits 26-27(Ring Index) */
+ u32 unused:4; /* bits 28-31 */
#endif
} bits;
} PKT_STAT_DESC_WORD1_t, *PPKT_STAT_WORD1_t;
@@ -217,19 +217,19 @@ typedef union _rxstat_word0_t {
u32 value;
struct {
#ifdef _BIT_FIELDS_HTOL
- u32 FBR1unused:5; // bits 27-31
- u32 FBR1wrap:1; // bit 26
- u32 FBR1offset:10; // bits 16-25
- u32 FBR0unused:5; // bits 11-15
- u32 FBR0wrap:1; // bit 10
- u32 FBR0offset:10; // bits 0-9
+ u32 FBR1unused:5; /* bits 27-31 */
+ u32 FBR1wrap:1; /* bit 26 */
+ u32 FBR1offset:10; /* bits 16-25 */
+ u32 FBR0unused:5; /* bits 11-15 */
+ u32 FBR0wrap:1; /* bit 10 */
+ u32 FBR0offset:10; /* bits 0-9 */
#else
- u32 FBR0offset:10; // bits 0-9
- u32 FBR0wrap:1; // bit 10
- u32 FBR0unused:5; // bits 11-15
- u32 FBR1offset:10; // bits 16-25
- u32 FBR1wrap:1; // bit 26
- u32 FBR1unused:5; // bits 27-31
+ u32 FBR0offset:10; /* bits 0-9 */
+ u32 FBR0wrap:1; /* bit 10 */
+ u32 FBR0unused:5; /* bits 11-15 */
+ u32 FBR1offset:10; /* bits 16-25 */
+ u32 FBR1wrap:1; /* bit 26 */
+ u32 FBR1unused:5; /* bits 27-31 */
#endif
} bits;
} RXSTAT_WORD0_t, *PRXSTAT_WORD0_t;
@@ -243,15 +243,15 @@ typedef union _rxstat_word1_t {
u32 value;
struct {
#ifdef _BIT_FIELDS_HTOL
- u32 PSRunused:3; // bits 29-31
- u32 PSRwrap:1; // bit 28
- u32 PSRoffset:12; // bits 16-27
- u32 reserved:16; // bits 0-15
+ u32 PSRunused:3; /* bits 29-31 */
+ u32 PSRwrap:1; /* bit 28 */
+ u32 PSRoffset:12; /* bits 16-27 */
+ u32 reserved:16; /* bits 0-15 */
#else
- u32 reserved:16; // bits 0-15
- u32 PSRoffset:12; // bits 16-27
- u32 PSRwrap:1; // bit 28
- u32 PSRunused:3; // bits 29-31
+ u32 reserved:16; /* bits 0-15 */
+ u32 PSRoffset:12; /* bits 16-27 */
+ u32 PSRwrap:1; /* bit 28 */
+ u32 PSRunused:3; /* bits 29-31 */
#endif
} bits;
} RXSTAT_WORD1_t, *PRXSTAT_WORD1_t;
diff --git a/drivers/staging/et131x/et1310_tx.c b/drivers/staging/et131x/et1310_tx.c
index 30eaac4c8707..b4e77267d026 100644
--- a/drivers/staging/et131x/et1310_tx.c
+++ b/drivers/staging/et131x/et1310_tx.c
@@ -2,7 +2,7 @@
* Agere Systems Inc.
* 10/100/1000 Base-T Ethernet Driver for the ET1301 and ET131x series MACs
*
- * Copyright © 2005 Agere Systems Inc.
+ * Copyright © 2005 Agere Systems Inc.
* All rights reserved.
* http://www.agere.com
*
@@ -19,7 +19,7 @@
* software indicates your acceptance of these terms and conditions. If you do
* not agree with these terms and conditions, do not use the software.
*
- * Copyright © 2005 Agere Systems Inc.
+ * Copyright © 2005 Agere Systems Inc.
* All rights reserved.
*
* Redistribution and use in source or binary forms, with or without
@@ -40,7 +40,7 @@
*
* Disclaimer
*
- * THIS SOFTWARE IS PROVIDED “AS IS” AND ANY EXPRESS OR IMPLIED WARRANTIES,
+ * THIS SOFTWARE IS PROVIDED "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES,
* INCLUDING, BUT NOT LIMITED TO, INFRINGEMENT AND THE IMPLIED WARRANTIES OF
* MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. ANY
* USE, MODIFICATION OR DISTRIBUTION OF THIS SOFTWARE IS SOLELY AT THE USERS OWN
@@ -74,9 +74,9 @@
#include <linux/interrupt.h>
#include <linux/in.h>
#include <linux/delay.h>
-#include <asm/io.h>
+#include <linux/io.h>
+#include <linux/bitops.h>
#include <asm/system.h>
-#include <asm/bitops.h>
#include <linux/netdevice.h>
#include <linux/etherdevice.h>
@@ -127,7 +127,7 @@ int et131x_tx_dma_memory_alloc(struct et131x_adapter *adapter)
DBG_ENTER(et131x_dbginfo);
/* Allocate memory for the TCB's (Transmit Control Block) */
- adapter->TxRing.MpTcbMem = (MP_TCB *) kcalloc(NUM_TCB, sizeof(MP_TCB),
+ adapter->TxRing.MpTcbMem = (MP_TCB *)kcalloc(NUM_TCB, sizeof(MP_TCB),
GFP_ATOMIC | GFP_DMA);
if (!adapter->TxRing.MpTcbMem) {
DBG_ERROR(et131x_dbginfo, "Cannot alloc memory for TCBs\n");
@@ -238,10 +238,7 @@ void et131x_tx_dma_memory_free(struct et131x_adapter *adapter)
}
/* Free the memory for MP_TCB structures */
- if (adapter->TxRing.MpTcbMem) {
- kfree(adapter->TxRing.MpTcbMem);
- adapter->TxRing.MpTcbMem = NULL;
- }
+ kfree(adapter->TxRing.MpTcbMem);
DBG_LEAVE(et131x_dbginfo);
}
@@ -308,7 +305,7 @@ void et131x_tx_dma_enable(struct et131x_adapter *pAdapter)
DBG_ENTER(et131x_dbginfo);
if (pAdapter->RegistryPhyLoopbk) {
- /* TxDMA is disabled for loopback operation. */
+ /* TxDMA is disabled for loopback operation. */
writel(0x101, &pAdapter->CSRAddress->txdma.csr.value);
} else {
TXDMA_CSR_t csr = { 0 };
@@ -405,11 +402,14 @@ int et131x_send_packets(struct sk_buff *skb, struct net_device *netdev)
/* We need to see if the link is up; if it's not, make the
* netif layer think we're good and drop the packet
*/
- //if( MP_SHOULD_FAIL_SEND( pAdapter ) || pAdapter->DriverNoPhyAccess )
+ /*
+ * if( MP_SHOULD_FAIL_SEND( pAdapter ) ||
+ * pAdapter->DriverNoPhyAccess )
+ */
if (MP_SHOULD_FAIL_SEND(pAdapter) || pAdapter->DriverNoPhyAccess
|| !netif_carrier_ok(netdev)) {
DBG_VERBOSE(et131x_dbginfo,
- "Can't Tx, Link is DOWN; drop the packet\n");
+ "Can't Tx, Link is DOWN; drop the packet\n");
dev_kfree_skb_any(skb);
skb = NULL;
@@ -496,9 +496,8 @@ static int et131x_send_packet(struct sk_buff *skb,
pAdapter->TxRing.TCBReadyQueueHead = pMpTcb->Next;
- if (pAdapter->TxRing.TCBReadyQueueHead == NULL) {
+ if (pAdapter->TxRing.TCBReadyQueueHead == NULL)
pAdapter->TxRing.TCBReadyQueueTail = NULL;
- }
spin_unlock_irqrestore(&pAdapter->TCBReadyQLock, lockflags);
@@ -519,9 +518,8 @@ static int et131x_send_packet(struct sk_buff *skb,
pMpTcb->Next = NULL;
/* Call the NIC specific send handler. */
- if (status == 0) {
+ if (status == 0)
status = nic_send_packet(pAdapter, pMpTcb);
- }
if (status != 0) {
spin_lock_irqsave(&pAdapter->TCBReadyQLock, lockflags);
@@ -749,11 +747,10 @@ static int nic_send_packet(struct et131x_adapter *pAdapter, PMP_TCB pMpTcb)
if ((pAdapter->TxRing.txDmaReadyToSend.bits.val == 0) ||
(pAdapter->TxRing.txDmaReadyToSend.bits.val ==
NUM_DESC_PER_RING_TX)) {
- if (pAdapter->TxRing.txDmaReadyToSend.bits.wrap) {
+ if (pAdapter->TxRing.txDmaReadyToSend.bits.wrap)
pAdapter->TxRing.txDmaReadyToSend.value = 0;
- } else {
+ else
pAdapter->TxRing.txDmaReadyToSend.value = 0x400;
- }
}
if (iRemainder) {
@@ -765,24 +762,21 @@ static int nic_send_packet(struct et131x_adapter *pAdapter, PMP_TCB pMpTcb)
}
if (pAdapter->TxRing.txDmaReadyToSend.bits.val == 0) {
- if (pAdapter->TxRing.txDmaReadyToSend.value) {
+ if (pAdapter->TxRing.txDmaReadyToSend.value)
pMpTcb->WrIndex.value = NUM_DESC_PER_RING_TX - 1;
- } else {
+ else
pMpTcb->WrIndex.value =
0x400 | (NUM_DESC_PER_RING_TX - 1);
- }
- } else {
+ } else
pMpTcb->WrIndex.value =
pAdapter->TxRing.txDmaReadyToSend.value - 1;
- }
spin_lock_irqsave(&pAdapter->TCBSendQLock, lockflags2);
- if (pAdapter->TxRing.CurrSendTail) {
+ if (pAdapter->TxRing.CurrSendTail)
pAdapter->TxRing.CurrSendTail->Next = pMpTcb;
- } else {
+ else
pAdapter->TxRing.CurrSendHead = pMpTcb;
- }
pAdapter->TxRing.CurrSendTail = pMpTcb;
@@ -870,14 +864,14 @@ static int nic_send_packet(struct et131x_adapter *pAdapter, PMP_TCB pMpTcb)
DBG_TX(et131x_dbginfo,
"Even number of descs, split 1st elem\n");
iSplitFirstElement = 1;
- //SegmentSize = pFragList[0].size / 2;
+ /* SegmentSize = pFragList[0].size / 2; */
SegmentSize = (pPacket->len - pPacket->data_len) / 2;
}
} else if (FragListCount & 0x1) {
DBG_TX(et131x_dbginfo, "Odd number of descs, split 1st elem\n");
iSplitFirstElement = 1;
- //SegmentSize = pFragList[0].size / 2;
+ /* SegmentSize = pFragList[0].size / 2; */
SegmentSize = (pPacket->len - pPacket->data_len) / 2;
}
@@ -918,9 +912,8 @@ static int nic_send_packet(struct et131x_adapter *pAdapter, PMP_TCB pMpTcb)
FragListCount, iSplitFirstElement, loopEnd);
for (loopIndex = 0; loopIndex < loopEnd; loopIndex++) {
- if (loopIndex > iSplitFirstElement) {
+ if (loopIndex > iSplitFirstElement)
fragIndex++;
- }
DBG_TX(et131x_dbginfo,
"In loop, loopIndex: %d\t fragIndex: %d\n", loopIndex,
@@ -935,13 +928,17 @@ static int nic_send_packet(struct et131x_adapter *pAdapter, PMP_TCB pMpTcb)
pPacket->len,
pAdapter->TxRing.txDmaReadyToSend.bits.serv_req);
- // NOTE - Should we do a paranoia check here to make sure the fragment
- // actually has a length? It's HIGHLY unlikely the fragment would
- // contain no data...
+ /*
+ * NOTE - Should we do a paranoia check here to make sure the fragment
+ * actually has a length? It's HIGHLY unlikely the fragment would
+ * contain no data...
+ */
if (1) {
- // NOTE - Currently always getting 32-bit addrs, and dma_addr_t is
- // only 32-bit, so leave "high" ptr value out for now
- CurDesc.DataBufferPtrHigh = 0;
+ /* NOTE - Currently always getting 32-bit addrs, and
+ * dma_addr_t is only 32-bit, so leave "high" ptr
+ * value out for now
+ * CurDesc.DataBufferPtrHigh = 0;
+ */
CurDesc.word2.value = 0;
CurDesc.word3.value = 0;
@@ -1128,7 +1125,7 @@ static int nic_send_packet(struct et131x_adapter *pAdapter, PMP_TCB pMpTcb)
if (pAdapter->uiDuplexMode == 0 &&
pMpTcb->PacketLength < NIC_MIN_PACKET_SIZE) {
- // NOTE - Same 32/64-bit issue as above...
+ /* NOTE - Same 32/64-bit issue as above... */
CurDesc.DataBufferPtrHigh = 0x0;
CurDesc.DataBufferPtrLow = pAdapter->TxRing.pTxDummyBlkPa;
CurDesc.word2.value = 0;
@@ -1183,18 +1180,17 @@ static int nic_send_packet(struct et131x_adapter *pAdapter, PMP_TCB pMpTcb)
}
DBG_TX(et131x_dbginfo, "Padding descriptor %d by %d bytes\n",
- //pAdapter->TxRing.txDmaReadyToSend.value,
+ /* pAdapter->TxRing.txDmaReadyToSend.value, */
pAdapter->TxRing.txDmaReadyToSend.bits.serv_req,
NIC_MIN_PACKET_SIZE - pMpTcb->PacketLength);
}
spin_lock_irqsave(&pAdapter->TCBSendQLock, lockflags2);
- if (pAdapter->TxRing.CurrSendTail) {
+ if (pAdapter->TxRing.CurrSendTail)
pAdapter->TxRing.CurrSendTail->Next = pMpTcb;
- } else {
+ else
pAdapter->TxRing.CurrSendHead = pMpTcb;
- }
pAdapter->TxRing.CurrSendTail = pMpTcb;
@@ -1235,19 +1231,19 @@ static int nic_send_packet(struct et131x_adapter *pAdapter, PMP_TCB pMpTcb)
*
* Assumption - Send spinlock has been acquired
*/
-__inline void et131x_free_send_packet(struct et131x_adapter *pAdapter, PMP_TCB pMpTcb)
+inline void et131x_free_send_packet(struct et131x_adapter *pAdapter,
+ PMP_TCB pMpTcb)
{
unsigned long lockflags;
TX_DESC_ENTRY_t *desc = NULL;
struct net_device_stats *stats = &pAdapter->net_stats;
- if (MP_TEST_FLAG(pMpTcb, fMP_DEST_BROAD)) {
+ if (MP_TEST_FLAG(pMpTcb, fMP_DEST_BROAD))
atomic_inc(&pAdapter->Stats.brdcstxmt);
- } else if (MP_TEST_FLAG(pMpTcb, fMP_DEST_MULTI)) {
+ else if (MP_TEST_FLAG(pMpTcb, fMP_DEST_MULTI))
atomic_inc(&pAdapter->Stats.multixmt);
- } else {
+ else
atomic_inc(&pAdapter->Stats.unixmt);
- }
if (pMpTcb->Packet) {
stats->tx_bytes += pMpTcb->Packet->len;
@@ -1298,14 +1294,12 @@ __inline void et131x_free_send_packet(struct et131x_adapter *pAdapter, PMP_TCB p
if (++pMpTcb->WrIndexStart.bits.val >=
NUM_DESC_PER_RING_TX) {
- if (pMpTcb->WrIndexStart.bits.wrap) {
+ if (pMpTcb->WrIndexStart.bits.wrap)
pMpTcb->WrIndexStart.value = 0;
- } else {
+ else
pMpTcb->WrIndexStart.value = 0x400;
- }
}
- }
- while (desc != (pAdapter->TxRing.pTxDescRingVa +
+ } while (desc != (pAdapter->TxRing.pTxDescRingVa +
pMpTcb->WrIndex.bits.val));
DBG_TX(et131x_dbginfo,
@@ -1371,9 +1365,8 @@ void et131x_free_busy_send_packets(struct et131x_adapter *pAdapter)
pAdapter->TxRing.CurrSendHead = pNext;
- if (pNext == NULL) {
+ if (pNext == NULL)
pAdapter->TxRing.CurrSendTail = NULL;
- }
pAdapter->TxRing.nBusySend--;
@@ -1391,7 +1384,7 @@ void et131x_free_busy_send_packets(struct et131x_adapter *pAdapter)
if (FreeCounter == NUM_TCB) {
DBG_ERROR(et131x_dbginfo,
- "MpFreeBusySendPackets exitted loop for a bad reason\n");
+ "MpFreeBusySendPackets exitted loop for a bad reason\n");
BUG();
}
@@ -1454,9 +1447,8 @@ static void et131x_update_tcb_list(struct et131x_adapter *pAdapter)
ServiceComplete.bits.val < pMpTcb->WrIndex.bits.val) {
pAdapter->TxRing.nBusySend--;
pAdapter->TxRing.CurrSendHead = pMpTcb->Next;
- if (pMpTcb->Next == NULL) {
+ if (pMpTcb->Next == NULL)
pAdapter->TxRing.CurrSendTail = NULL;
- }
spin_unlock_irqrestore(&pAdapter->TCBSendQLock, lockflags);
MP_FREE_SEND_PACKET_FUN(pAdapter, pMpTcb);
@@ -1470,9 +1462,8 @@ static void et131x_update_tcb_list(struct et131x_adapter *pAdapter)
ServiceComplete.bits.val > pMpTcb->WrIndex.bits.val) {
pAdapter->TxRing.nBusySend--;
pAdapter->TxRing.CurrSendHead = pMpTcb->Next;
- if (pMpTcb->Next == NULL) {
+ if (pMpTcb->Next == NULL)
pAdapter->TxRing.CurrSendTail = NULL;
- }
spin_unlock_irqrestore(&pAdapter->TCBSendQLock, lockflags);
MP_FREE_SEND_PACKET_FUN(pAdapter, pMpTcb);
@@ -1483,9 +1474,8 @@ static void et131x_update_tcb_list(struct et131x_adapter *pAdapter)
}
/* Wake up the queue when we hit a low-water mark */
- if (pAdapter->TxRing.nBusySend <= (NUM_TCB / 3)) {
+ if (pAdapter->TxRing.nBusySend <= (NUM_TCB / 3))
netif_wake_queue(pAdapter->netdev);
- }
spin_unlock_irqrestore(&pAdapter->TCBSendQLock, lockflags);
}
@@ -1504,7 +1494,7 @@ static void et131x_check_send_wait_list(struct et131x_adapter *pAdapter)
spin_lock_irqsave(&pAdapter->SendWaitLock, lockflags);
while (!list_empty(&pAdapter->TxRing.SendWaitQueue) &&
- MP_TCB_RESOURCES_AVAILABLE(pAdapter)) {
+ MP_TCB_RESOURCES_AVAILABLE(pAdapter)) {
struct list_head *pEntry;
DBG_VERBOSE(et131x_dbginfo, "Tx packets on the wait queue\n");
@@ -1514,8 +1504,8 @@ static void et131x_check_send_wait_list(struct et131x_adapter *pAdapter)
pAdapter->TxRing.nWaitSend--;
DBG_WARNING(et131x_dbginfo,
- "MpHandleSendInterrupt - sent a queued pkt. Waiting %d\n",
- pAdapter->TxRing.nWaitSend);
+ "MpHandleSendInterrupt - sent a queued pkt. Waiting %d\n",
+ pAdapter->TxRing.nWaitSend);
}
spin_unlock_irqrestore(&pAdapter->SendWaitLock, lockflags);
diff --git a/drivers/staging/et131x/et1310_tx.h b/drivers/staging/et131x/et1310_tx.h
index 2819c7843d21..107292840556 100644
--- a/drivers/staging/et131x/et1310_tx.h
+++ b/drivers/staging/et131x/et1310_tx.h
@@ -2,7 +2,7 @@
* Agere Systems Inc.
* 10/100/1000 Base-T Ethernet Driver for the ET1301 and ET131x series MACs
*
- * Copyright © 2005 Agere Systems Inc.
+ * Copyright © 2005 Agere Systems Inc.
* All rights reserved.
* http://www.agere.com
*
@@ -20,7 +20,7 @@
* software indicates your acceptance of these terms and conditions. If you do
* not agree with these terms and conditions, do not use the software.
*
- * Copyright © 2005 Agere Systems Inc.
+ * Copyright © 2005 Agere Systems Inc.
* All rights reserved.
*
* Redistribution and use in source or binary forms, with or without
@@ -41,7 +41,7 @@
*
* Disclaimer
*
- * THIS SOFTWARE IS PROVIDED “AS IS” AND ANY EXPRESS OR IMPLIED WARRANTIES,
+ * THIS SOFTWARE IS PROVIDED "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES,
* INCLUDING, BUT NOT LIMITED TO, INFRINGEMENT AND THE IMPLIED WARRANTIES OF
* MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. ANY
* USE, MODIFICATION OR DISTRIBUTION OF THIS SOFTWARE IS SOLELY AT THE USERS OWN
@@ -70,15 +70,15 @@ typedef union _txdesc_word2_t {
u32 value;
struct {
#ifdef _BIT_FIELDS_HTOL
- u32 vlan_prio:3; // bits 29-31(VLAN priority)
- u32 vlan_cfi:1; // bit 28(cfi)
- u32 vlan_tag:12; // bits 16-27(VLAN tag)
- u32 length_in_bytes:16; // bits 0-15(packet length)
+ u32 vlan_prio:3; /* bits 29-31(VLAN priority) */
+ u32 vlan_cfi:1; /* bit 28(cfi) */
+ u32 vlan_tag:12; /* bits 16-27(VLAN tag) */
+ u32 length_in_bytes:16; /* bits 0-15(packet length) */
#else
- u32 length_in_bytes:16; // bits 0-15(packet length)
- u32 vlan_tag:12; // bits 16-27(VLAN tag)
- u32 vlan_cfi:1; // bit 28(cfi)
- u32 vlan_prio:3; // bits 29-31(VLAN priority)
+ u32 length_in_bytes:16; /* bits 0-15(packet length) */
+ u32 vlan_tag:12; /* bits 16-27(VLAN tag) */
+ u32 vlan_cfi:1; /* bit 28(cfi) */
+ u32 vlan_prio:3; /* bits 29-31(VLAN priority) */
#endif /* _BIT_FIELDS_HTOL */
} bits;
} TXDESC_WORD2_t, *PTXDESC_WORD2_t;
@@ -91,39 +91,39 @@ typedef union _txdesc_word3_t {
u32 value;
struct {
#ifdef _BIT_FIELDS_HTOL
- u32 unused:17; // bits 15-31
- u32 udpa:1; // bit 14(UDP checksum assist)
- u32 tcpa:1; // bit 13(TCP checksum assist)
- u32 ipa:1; // bit 12(IP checksum assist)
- u32 vlan:1; // bit 11(append VLAN tag)
- u32 hp:1; // bit 10(Packet is a Huge packet)
- u32 pp:1; // bit 9(pad packet)
- u32 mac:1; // bit 8(MAC override)
- u32 crc:1; // bit 7(append CRC)
- u32 e:1; // bit 6(Tx frame has error)
- u32 pf:1; // bit 5(send pause frame)
- u32 bp:1; // bit 4(Issue half-duplex backpressure (XON/XOFF)
- u32 cw:1; // bit 3(Control word - no packet data)
- u32 ir:1; // bit 2(interrupt the processor when this pkt sent)
- u32 f:1; // bit 1(first packet in the sequence)
- u32 l:1; // bit 0(last packet in the sequence)
+ u32 unused:17; /* bits 15-31 */
+ u32 udpa:1; /* bit 14(UDP checksum assist) */
+ u32 tcpa:1; /* bit 13(TCP checksum assist) */
+ u32 ipa:1; /* bit 12(IP checksum assist) */
+ u32 vlan:1; /* bit 11(append VLAN tag) */
+ u32 hp:1; /* bit 10(Packet is a Huge packet) */
+ u32 pp:1; /* bit 9(pad packet) */
+ u32 mac:1; /* bit 8(MAC override) */
+ u32 crc:1; /* bit 7(append CRC) */
+ u32 e:1; /* bit 6(Tx frame has error) */
+ u32 pf:1; /* bit 5(send pause frame) */
+ u32 bp:1; /* bit 4(Issue half-duplex backpressure (XON/XOFF) */
+ u32 cw:1; /* bit 3(Control word - no packet data) */
+ u32 ir:1; /* bit 2(interrupt the processor when this pkt sent) */
+ u32 f:1; /* bit 1(first packet in the sequence) */
+ u32 l:1; /* bit 0(last packet in the sequence) */
#else
- u32 l:1; // bit 0(last packet in the sequence)
- u32 f:1; // bit 1(first packet in the sequence)
- u32 ir:1; // bit 2(interrupt the processor when this pkt sent)
- u32 cw:1; // bit 3(Control word - no packet data)
- u32 bp:1; // bit 4(Issue half-duplex backpressure (XON/XOFF)
- u32 pf:1; // bit 5(send pause frame)
- u32 e:1; // bit 6(Tx frame has error)
- u32 crc:1; // bit 7(append CRC)
- u32 mac:1; // bit 8(MAC override)
- u32 pp:1; // bit 9(pad packet)
- u32 hp:1; // bit 10(Packet is a Huge packet)
- u32 vlan:1; // bit 11(append VLAN tag)
- u32 ipa:1; // bit 12(IP checksum assist)
- u32 tcpa:1; // bit 13(TCP checksum assist)
- u32 udpa:1; // bit 14(UDP checksum assist)
- u32 unused:17; // bits 15-31
+ u32 l:1; /* bit 0(last packet in the sequence) */
+ u32 f:1; /* bit 1(first packet in the sequence) */
+ u32 ir:1; /* bit 2(interrupt the processor when this pkt sent) */
+ u32 cw:1; /* bit 3(Control word - no packet data) */
+ u32 bp:1; /* bit 4(Issue half-duplex backpressure (XON/XOFF) */
+ u32 pf:1; /* bit 5(send pause frame) */
+ u32 e:1; /* bit 6(Tx frame has error) */
+ u32 crc:1; /* bit 7(append CRC) */
+ u32 mac:1; /* bit 8(MAC override) */
+ u32 pp:1; /* bit 9(pad packet) */
+ u32 hp:1; /* bit 10(Packet is a Huge packet) */
+ u32 vlan:1; /* bit 11(append VLAN tag) */
+ u32 ipa:1; /* bit 12(IP checksum assist) */
+ u32 tcpa:1; /* bit 13(TCP checksum assist) */
+ u32 udpa:1; /* bit 14(UDP checksum assist) */
+ u32 unused:17; /* bits 15-31 */
#endif /* _BIT_FIELDS_HTOL */
} bits;
} TXDESC_WORD3_t, *PTXDESC_WORD3_t;
@@ -132,8 +132,8 @@ typedef union _txdesc_word3_t {
typedef struct _tx_desc_entry_t {
u32 DataBufferPtrHigh;
u32 DataBufferPtrLow;
- TXDESC_WORD2_t word2; // control words how to xmit the
- TXDESC_WORD3_t word3; // data (detailed above)
+ TXDESC_WORD2_t word2; /* control words how to xmit the */
+ TXDESC_WORD3_t word3; /* data (detailed above) */
} TX_DESC_ENTRY_t, *PTX_DESC_ENTRY_t;
@@ -147,13 +147,13 @@ typedef union _tx_status_block_t {
u32 value;
struct {
#ifdef _BIT_FIELDS_HTOL
- u32 unused:21; // bits 11-31
- u32 serv_cpl_wrap:1; // bit 10
- u32 serv_cpl:10; // bits 0-9
+ u32 unused:21; /* bits 11-31 */
+ u32 serv_cpl_wrap:1; /* bit 10 */
+ u32 serv_cpl:10; /* bits 0-9 */
#else
- u32 serv_cpl:10; // bits 0-9
- u32 serv_cpl_wrap:1; // bit 10
- u32 unused:21; // bits 11-31
+ u32 serv_cpl:10; /* bits 0-9 */
+ u32 serv_cpl_wrap:1; /* bit 10 */
+ u32 unused:21; /* bits 11-31 */
#endif
} bits;
} TX_STATUS_BLOCK_t, *PTX_STATUS_BLOCK_t;
diff --git a/drivers/staging/et131x/et131x_adapter.h b/drivers/staging/et131x/et131x_adapter.h
index 36e61a47ae27..2b553199680f 100644
--- a/drivers/staging/et131x/et131x_adapter.h
+++ b/drivers/staging/et131x/et131x_adapter.h
@@ -2,7 +2,7 @@
* Agere Systems Inc.
* 10/100/1000 Base-T Ethernet Driver for the ET1301 and ET131x series MACs
*
- * Copyright © 2005 Agere Systems Inc.
+ * Copyright © 2005 Agere Systems Inc.
* All rights reserved.
* http://www.agere.com
*
@@ -20,7 +20,7 @@
* software indicates your acceptance of these terms and conditions. If you do
* not agree with these terms and conditions, do not use the software.
*
- * Copyright © 2005 Agere Systems Inc.
+ * Copyright © 2005 Agere Systems Inc.
* All rights reserved.
*
* Redistribution and use in source or binary forms, with or without
@@ -41,7 +41,7 @@
*
* Disclaimer
*
- * THIS SOFTWARE IS PROVIDED “AS IS” AND ANY EXPRESS OR IMPLIED WARRANTIES,
+ * THIS SOFTWARE IS PROVIDED "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES,
* INCLUDING, BUT NOT LIMITED TO, INFRINGEMENT AND THE IMPLIED WARRANTIES OF
* MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. ANY
* USE, MODIFICATION OR DISTRIBUTION OF THIS SOFTWARE IS SOLELY AT THE USERS OWN
@@ -67,7 +67,7 @@
* Do not change these values: if changed, then change also in respective
* TXdma and Rxdma engines
*/
-#define NUM_DESC_PER_RING_TX 512 // TX Do not change these values
+#define NUM_DESC_PER_RING_TX 512 /* TX Do not change these values */
#define NUM_TCB 64
/*
@@ -118,10 +118,10 @@
#define MP_SHOULD_FAIL_SEND(_M) ((_M)->Flags & fMP_ADAPTER_FAIL_SEND_MASK)
#define MP_IS_NOT_READY(_M) ((_M)->Flags & fMP_ADAPTER_NOT_READY_MASK)
-#define MP_IS_READY(_M) !((_M)->Flags & fMP_ADAPTER_NOT_READY_MASK)
+#define MP_IS_READY(_M) (!((_M)->Flags & fMP_ADAPTER_NOT_READY_MASK))
-#define MP_HAS_CABLE(_M) !((_M)->Flags & fMP_ADAPTER_NO_CABLE)
-#define MP_LINK_DETECTED(_M) !((_M)->Flags & fMP_ADAPTER_LINK_DETECTION)
+#define MP_HAS_CABLE(_M) (!((_M)->Flags & fMP_ADAPTER_NO_CABLE))
+#define MP_LINK_DETECTED(_M) (!((_M)->Flags & fMP_ADAPTER_LINK_DETECTION))
/* Counters for error rate monitoring */
typedef struct _MP_ERR_COUNTERS {
@@ -136,7 +136,7 @@ typedef struct _MP_ERR_COUNTERS {
typedef struct _MP_RFD {
struct list_head list_node;
struct sk_buff *Packet;
- u32 PacketSize; // total size of receive frame
+ u32 PacketSize; /* total size of receive frame */
u16 iBufferIndex;
u8 iRingIndex;
} MP_RFD, *PMP_RFD;
@@ -152,8 +152,8 @@ typedef enum _eflow_control_t {
/* Struct to define some device statistics */
typedef struct _ce_stats_t {
/* Link Input/Output stats */
- uint64_t ipackets; // # of in packets
- uint64_t opackets; // # of out packets
+ uint64_t ipackets; /* # of in packets */
+ uint64_t opackets; /* # of out packets */
/* MIB II variables
*
@@ -161,21 +161,21 @@ typedef struct _ce_stats_t {
* MUST have 32, then we'll need another way to perform atomic
* operations
*/
- u32 unircv; // # multicast packets received
- atomic_t unixmt; // # multicast packets for Tx
- u32 multircv; // # multicast packets received
- atomic_t multixmt; // # multicast packets for Tx
- u32 brdcstrcv; // # broadcast packets received
- atomic_t brdcstxmt; // # broadcast packets for Tx
- u32 norcvbuf; // # Rx packets discarded
- u32 noxmtbuf; // # Tx packets discarded
+ u32 unircv; /* # multicast packets received */
+ atomic_t unixmt; /* # multicast packets for Tx */
+ u32 multircv; /* # multicast packets received */
+ atomic_t multixmt; /* # multicast packets for Tx */
+ u32 brdcstrcv; /* # broadcast packets received */
+ atomic_t brdcstxmt; /* # broadcast packets for Tx */
+ u32 norcvbuf; /* # Rx packets discarded */
+ u32 noxmtbuf; /* # Tx packets discarded */
/* Transciever state informations. */
u8 xcvr_addr;
u32 xcvr_id;
/* Tx Statistics. */
- u32 tx_uflo; // Tx Underruns
+ u32 tx_uflo; /* Tx Underruns */
u32 collisions;
u32 excessive_collisions;
@@ -185,7 +185,7 @@ typedef struct _ce_stats_t {
u32 tx_deferred;
/* Rx Statistics. */
- u32 rx_ov_flow; // Rx Over Flow
+ u32 rx_ov_flow; /* Rx Over Flow */
u32 length_err;
u32 alignment_err;
@@ -268,16 +268,16 @@ struct et131x_adapter {
u32 pci_cfg_state[64 / sizeof(u32)];
/* Registry parameters */
- u8 SpeedDuplex; // speed/duplex
- eFLOW_CONTROL_t RegistryFlowControl; // for 802.3x flow control
- u8 RegistryWOLMatch; // Enable WOL pattern-matching
- u8 RegistryWOLLink; // Link state change is independant
- u8 RegistryPhyComa; // Phy Coma mode enable/disable
+ u8 SpeedDuplex; /* speed/duplex */
+ eFLOW_CONTROL_t RegistryFlowControl; /* for 802.3x flow control */
+ u8 RegistryWOLMatch; /* Enable WOL pattern-matching */
+ u8 RegistryWOLLink; /* Link state change is independant */
+ u8 RegistryPhyComa; /* Phy Coma mode enable/disable */
- u32 RegistryRxMemEnd; // Size of internal rx memory
- u8 RegistryMACStat; // If set, read MACSTAT, else don't
- u32 RegistryVlanTag; // 802.1q Vlan TAG
- u32 RegistryJumboPacket; // Max supported ethernet packet size
+ u32 RegistryRxMemEnd; /* Size of internal rx memory */
+ u8 RegistryMACStat; /* If set, read MACSTAT, else don't */
+ u32 RegistryVlanTag; /* 802.1q Vlan TAG */
+ u32 RegistryJumboPacket; /* Max supported ethernet packet size */
u32 RegistryTxNumBuffers;
u32 RegistryTxTimeInterval;
@@ -290,12 +290,12 @@ struct et131x_adapter {
u8 RegistryNMIDisable;
u32 RegistryDMACache;
u32 RegistrySCGain;
- u8 RegistryPhyLoopbk; // Enable Phy loopback
+ u8 RegistryPhyLoopbk; /* Enable Phy loopback */
/* Derived from the registry: */
- u8 AiForceDpx; // duplex setting
- u16 AiForceSpeed; // 'Speed', user over-ride of line speed
- eFLOW_CONTROL_t FlowControl; // flow control validated by the far-end
+ u8 AiForceDpx; /* duplex setting */
+ u16 AiForceSpeed; /* 'Speed', user over-ride of line speed */
+ eFLOW_CONTROL_t FlowControl; /* flow control validated by the far-end */
enum {
NETIF_STATUS_INVALID = 0,
NETIF_STATUS_MEDIA_CONNECT,
@@ -313,7 +313,7 @@ struct et131x_adapter {
MP_POWER_MGMT PoMgmt;
INTERRUPT_t CachedMaskValue;
- atomic_t RcvRefCount; // Num packets not yet returned
+ atomic_t RcvRefCount; /* Num packets not yet returned */
/* Xcvr status at last poll */
MI_BMSR_t Bmsr;
@@ -329,8 +329,8 @@ struct et131x_adapter {
PCI_CFG_SPACE_REGS PciCfgRegs;
/* Loopback specifics */
- u8 ReplicaPhyLoopbk; // Replica Enable
- u8 ReplicaPhyLoopbkPF; // Replica Enable Pass/Fail
+ u8 ReplicaPhyLoopbk; /* Replica Enable */
+ u8 ReplicaPhyLoopbkPF; /* Replica Enable Pass/Fail */
/* Stats */
CE_STATS_t Stats;
diff --git a/drivers/staging/et131x/et131x_config.c b/drivers/staging/et131x/et131x_config.c
index 0adbaa6ca078..15e6d4e7bd06 100644
--- a/drivers/staging/et131x/et131x_config.c
+++ b/drivers/staging/et131x/et131x_config.c
@@ -2,7 +2,7 @@
* Agere Systems Inc.
* 10/100/1000 Base-T Ethernet Driver for the ET1301 and ET131x series MACs
*
- * Copyright © 2005 Agere Systems Inc.
+ * Copyright © 2005 Agere Systems Inc.
* All rights reserved.
* http://www.agere.com
*
@@ -20,7 +20,7 @@
* software indicates your acceptance of these terms and conditions. If you do
* not agree with these terms and conditions, do not use the software.
*
- * Copyright © 2005 Agere Systems Inc.
+ * Copyright © 2005 Agere Systems Inc.
* All rights reserved.
*
* Redistribution and use in source or binary forms, with or without
@@ -41,7 +41,7 @@
*
* Disclaimer
*
- * THIS SOFTWARE IS PROVIDED “AS IS” AND ANY EXPRESS OR IMPLIED WARRANTIES,
+ * THIS SOFTWARE IS PROVIDED "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES,
* INCLUDING, BUT NOT LIMITED TO, INFRINGEMENT AND THE IMPLIED WARRANTIES OF
* MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. ANY
* USE, MODIFICATION OR DISTRIBUTION OF THIS SOFTWARE IS SOLELY AT THE USERS OWN
@@ -74,9 +74,9 @@
#include <linux/interrupt.h>
#include <linux/in.h>
#include <linux/delay.h>
-#include <asm/io.h>
+#include <linux/io.h>
+#include <linux/bitops.h>
#include <asm/system.h>
-#include <asm/bitops.h>
#include <linux/netdevice.h>
#include <linux/etherdevice.h>
@@ -198,7 +198,7 @@ MODULE_PARM_DESC(et131x_nmi_disable, "Disable NMI (0-2) [0]");
static u32 et131x_speed_set = PARM_SPEED_DUPLEX_DEF;
module_param(et131x_speed_set, uint, 0);
MODULE_PARM_DESC(et131x_speed_set,
- "Set Link speed and dublex manually (0-5) [0] \n 1 : 10Mb Half-Duplex \n 2 : 10Mb Full-Duplex \n 3 : 100Mb Half-Duplex \n 4 : 100Mb Full-Duplex \n 5 : 1000Mb Full-Duplex \n 0 : Auto Speed Auto Dublex");
+ "Set Link speed and dublex manually (0-5) [0] \n 1 : 10Mb Half-Duplex \n 2 : 10Mb Full-Duplex \n 3 : 100Mb Half-Duplex \n 4 : 100Mb Full-Duplex \n 5 : 1000Mb Full-Duplex \n 0 : Auto Speed Auto Dublex");
/**
* et131x_config_parse
@@ -242,7 +242,7 @@ void et131x_config_parse(struct et131x_adapter *pAdapter)
pAdapter->SpeedDuplex = PARM_SPEED_DUPLEX_DEF;
}
- // pAdapter->SpeedDuplex = PARM_SPEED_DUPLEX_DEF;
+ /* pAdapter->SpeedDuplex = PARM_SPEED_DUPLEX_DEF; */
pAdapter->RegistryVlanTag = PARM_VLAN_TAG_DEF;
pAdapter->RegistryFlowControl = PARM_FLOW_CTL_DEF;
@@ -259,11 +259,10 @@ void et131x_config_parse(struct et131x_adapter *pAdapter)
pAdapter->RegistrySCGain = PARM_SC_GAIN_DEF;
pAdapter->RegistryPMWOL = PARM_PM_WOL_DEF;
- if (et131x_nmi_disable != PARM_NMI_DISABLE_DEF) {
+ if (et131x_nmi_disable != PARM_NMI_DISABLE_DEF)
pAdapter->RegistryNMIDisable = et131x_nmi_disable;
- } else {
+ else
pAdapter->RegistryNMIDisable = PARM_NMI_DISABLE_DEF;
- }
pAdapter->RegistryDMACache = PARM_DMA_CACHE_DEF;
pAdapter->RegistryPhyLoopbk = PARM_PHY_LOOPBK_DEF;
@@ -283,39 +282,38 @@ void et131x_config_parse(struct et131x_adapter *pAdapter)
* Set up as if we are auto negotiating always and then change if we
* go into force mode
*/
- pAdapter->AiForceSpeed = 0; // Auto speed
- pAdapter->AiForceDpx = 0; // Auto FDX
+ pAdapter->AiForceSpeed = 0; /* Auto speed */
+ pAdapter->AiForceDpx = 0; /* Auto FDX */
/* If we are the 10/100 device, and gigabit is somehow requested then
* knock it down to 100 full.
*/
- if ((pAdapter->DeviceID == ET131X_PCI_DEVICE_ID_FAST) &&
- (pAdapter->SpeedDuplex == 5)) {
+ if (pAdapter->DeviceID == ET131X_PCI_DEVICE_ID_FAST &&
+ pAdapter->SpeedDuplex == 5)
pAdapter->SpeedDuplex = 4;
- }
switch (pAdapter->SpeedDuplex) {
- case 1: // 10Mb Half-Duplex
+ case 1: /* 10Mb Half-Duplex */
pAdapter->AiForceSpeed = 10;
pAdapter->AiForceDpx = 1;
break;
- case 2: // 10Mb Full-Duplex
+ case 2: /* 10Mb Full-Duplex */
pAdapter->AiForceSpeed = 10;
pAdapter->AiForceDpx = 2;
break;
- case 3: // 100Mb Half-Duplex
+ case 3: /* 100Mb Half-Duplex */
pAdapter->AiForceSpeed = 100;
pAdapter->AiForceDpx = 1;
break;
- case 4: // 100Mb Full-Duplex
+ case 4: /* 100Mb Full-Duplex */
pAdapter->AiForceSpeed = 100;
pAdapter->AiForceDpx = 2;
break;
- case 5: // 1000Mb Full-Duplex
+ case 5: /* 1000Mb Full-Duplex */
pAdapter->AiForceSpeed = 1000;
pAdapter->AiForceDpx = 2;
break;
diff --git a/drivers/staging/et131x/et131x_debug.c b/drivers/staging/et131x/et131x_debug.c
index d1dd46e0a9c8..c7f64a836bee 100644
--- a/drivers/staging/et131x/et131x_debug.c
+++ b/drivers/staging/et131x/et131x_debug.c
@@ -2,7 +2,7 @@
* Agere Systems Inc.
* 10/100/1000 Base-T Ethernet Driver for the ET1301 and ET131x series MACs
*
- * Copyright © 2005 Agere Systems Inc.
+ * Copyright © 2005 Agere Systems Inc.
* All rights reserved.
* http://www.agere.com
*
@@ -19,7 +19,7 @@
* software indicates your acceptance of these terms and conditions. If you do
* not agree with these terms and conditions, do not use the software.
*
- * Copyright © 2005 Agere Systems Inc.
+ * Copyright © 2005 Agere Systems Inc.
* All rights reserved.
*
* Redistribution and use in source or binary forms, with or without
@@ -40,7 +40,7 @@
*
* Disclaimer
*
- * THIS SOFTWARE IS PROVIDED “AS IS” AND ANY EXPRESS OR IMPLIED WARRANTIES,
+ * THIS SOFTWARE IS PROVIDED "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES,
* INCLUDING, BUT NOT LIMITED TO, INFRINGEMENT AND THE IMPLIED WARRANTIES OF
* MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. ANY
* USE, MODIFICATION OR DISTRIBUTION OF THIS SOFTWARE IS SOLELY AT THE USERS OWN
@@ -76,9 +76,9 @@
#include <linux/interrupt.h>
#include <linux/in.h>
#include <linux/delay.h>
-#include <asm/io.h>
+#include <linux/io.h>
+#include <linux/bitops.h>
#include <asm/system.h>
-#include <asm/bitops.h>
#include <linux/netdevice.h>
#include <linux/etherdevice.h>
@@ -214,4 +214,4 @@ void DumpDeviceReg(int dbgLvl, struct et131x_adapter *pAdapter)
}
}
-#endif // CONFIG_ET131X_DEBUG
+#endif /* CONFIG_ET131X_DEBUG */
diff --git a/drivers/staging/et131x/et131x_debug.h b/drivers/staging/et131x/et131x_debug.h
index 994108eca663..7c70e230ccd2 100644
--- a/drivers/staging/et131x/et131x_debug.h
+++ b/drivers/staging/et131x/et131x_debug.h
@@ -2,7 +2,7 @@
* Agere Systems Inc.
* 10/100/1000 Base-T Ethernet Driver for the ET1301 and ET131x series MACs
*
- * Copyright © 2005 Agere Systems Inc.
+ * Copyright © 2005 Agere Systems Inc.
* All rights reserved.
* http://www.agere.com
*
@@ -21,7 +21,7 @@
* software indicates your acceptance of these terms and conditions. If you do
* not agree with these terms and conditions, do not use the software.
*
- * Copyright © 2005 Agere Systems Inc.
+ * Copyright © 2005 Agere Systems Inc.
* All rights reserved.
*
* Redistribution and use in source or binary forms, with or without
@@ -42,7 +42,7 @@
*
* Disclaimer
*
- * THIS SOFTWARE IS PROVIDED “AS IS” AND ANY EXPRESS OR IMPLIED WARRANTIES,
+ * THIS SOFTWARE IS PROVIDED "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES,
* INCLUDING, BUT NOT LIMITED TO, INFRINGEMENT AND THE IMPLIED WARRANTIES OF
* MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. ANY
* USE, MODIFICATION OR DISTRIBUTION OF THIS SOFTWARE IS SOLELY AT THE USERS OWN
@@ -97,7 +97,7 @@
#endif /* DBG_PRINTC */
#ifndef DBG_TRAP
-#define DBG_TRAP {} /* BUG() */
+#define DBG_TRAP do {} while (0) /* BUG() */
#endif /* DBG_TRAP */
#define _ENTER_STR ">>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>"
@@ -227,16 +227,16 @@ typedef struct {
#define DBG_PRINT(S...)
#define DBG_ENTER(A)
#define DBG_LEAVE(A)
-#define DBG_PARAM(A,N,F,S...)
-#define DBG_ERROR(A,S...)
-#define DBG_WARNING(A,S...)
-#define DBG_NOTICE(A,S...)
-#define DBG_TRACE(A,S...)
-#define DBG_VERBOSE(A,S...)
-#define DBG_RX(A,S...)
+#define DBG_PARAM(A, N, F, S...)
+#define DBG_ERROR(A, S...)
+#define DBG_WARNING(A, S...)
+#define DBG_NOTICE(A, S...)
+#define DBG_TRACE(A, S...)
+#define DBG_VERBOSE(A, S...)
+#define DBG_RX(A, S...)
#define DBG_RX_ENTER(A)
#define DBG_RX_LEAVE(A)
-#define DBG_TX(A,S...)
+#define DBG_TX(A, S...)
#define DBG_TX_ENTER(A)
#define DBG_TX_LEAVE(A)
#define DBG_ASSERT(C)
diff --git a/drivers/staging/et131x/et131x_defs.h b/drivers/staging/et131x/et131x_defs.h
index 886cb78698ef..9d609e530621 100644
--- a/drivers/staging/et131x/et131x_defs.h
+++ b/drivers/staging/et131x/et131x_defs.h
@@ -2,7 +2,7 @@
* Agere Systems Inc.
* 10/100/1000 Base-T Ethernet Driver for the ET1301 and ET131x series MACs
*
- * Copyright © 2005 Agere Systems Inc.
+ * Copyright © 2005 Agere Systems Inc.
* All rights reserved.
* http://www.agere.com
*
@@ -20,7 +20,7 @@
* software indicates your acceptance of these terms and conditions. If you do
* not agree with these terms and conditions, do not use the software.
*
- * Copyright © 2005 Agere Systems Inc.
+ * Copyright © 2005 Agere Systems Inc.
* All rights reserved.
*
* Redistribution and use in source or binary forms, with or without
@@ -41,7 +41,7 @@
*
* Disclaimer
*
- * THIS SOFTWARE IS PROVIDED “AS IS” AND ANY EXPRESS OR IMPLIED WARRANTIES,
+ * THIS SOFTWARE IS PROVIDED "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES,
* INCLUDING, BUT NOT LIMITED TO, INFRINGEMENT AND THE IMPLIED WARRANTIES OF
* MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. ANY
* USE, MODIFICATION OR DISTRIBUTION OF THIS SOFTWARE IS SOLELY AT THE USERS OWN
@@ -118,9 +118,9 @@
#define ET1310_PCI_ADVANCED_ERR 0x100
/* PCI Vendor/Product IDs */
-#define ET131X_PCI_VENDOR_ID 0x11C1 // Agere Systems
-#define ET131X_PCI_DEVICE_ID_GIG 0xED00 // ET1310 1000 Base-T
-#define ET131X_PCI_DEVICE_ID_FAST 0xED01 // ET1310 100 Base-T
+#define ET131X_PCI_VENDOR_ID 0x11C1 /* Agere Systems */
+#define ET131X_PCI_DEVICE_ID_GIG 0xED00 /* ET1310 1000 Base-T 8 */
+#define ET131X_PCI_DEVICE_ID_FAST 0xED01 /* ET1310 100 Base-T */
/* Define order of magnitude converter */
#define NANO_IN_A_MICRO 1000
diff --git a/drivers/staging/et131x/et131x_initpci.c b/drivers/staging/et131x/et131x_initpci.c
index a18c499d0ae0..c9345896e408 100644
--- a/drivers/staging/et131x/et131x_initpci.c
+++ b/drivers/staging/et131x/et131x_initpci.c
@@ -2,7 +2,7 @@
* Agere Systems Inc.
* 10/100/1000 Base-T Ethernet Driver for the ET1301 and ET131x series MACs
*
- * Copyright © 2005 Agere Systems Inc.
+ * Copyright © 2005 Agere Systems Inc.
* All rights reserved.
* http://www.agere.com
*
@@ -21,7 +21,7 @@
* software indicates your acceptance of these terms and conditions. If you do
* not agree with these terms and conditions, do not use the software.
*
- * Copyright © 2005 Agere Systems Inc.
+ * Copyright © 2005 Agere Systems Inc.
* All rights reserved.
*
* Redistribution and use in source or binary forms, with or without
@@ -42,7 +42,7 @@
*
* Disclaimer
*
- * THIS SOFTWARE IS PROVIDED “AS IS” AND ANY EXPRESS OR IMPLIED WARRANTIES,
+ * THIS SOFTWARE IS PROVIDED "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES,
* INCLUDING, BUT NOT LIMITED TO, INFRINGEMENT AND THE IMPLIED WARRANTIES OF
* MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. ANY
* USE, MODIFICATION OR DISTRIBUTION OF THIS SOFTWARE IS SOLELY AT THE USERS OWN
@@ -76,9 +76,9 @@
#include <linux/interrupt.h>
#include <linux/in.h>
#include <linux/delay.h>
-#include <asm/io.h>
+#include <linux/io.h>
+#include <linux/bitops.h>
#include <asm/system.h>
-#include <asm/bitops.h>
#include <linux/netdevice.h>
#include <linux/etherdevice.h>
@@ -155,8 +155,8 @@ static struct pci_driver et131x_driver = {
.id_table = et131x_pci_table,
.probe = et131x_pci_setup,
.remove = __devexit_p(et131x_pci_remove),
- .suspend = NULL, //et131x_pci_suspend,
- .resume = NULL, //et131x_pci_resume,
+ .suspend = NULL, /* et131x_pci_suspend */
+ .resume = NULL, /* et131x_pci_resume */
};
@@ -252,9 +252,8 @@ int et131x_find_adapter(struct et131x_adapter *adapter, struct pci_dev *pdev)
RegisterVal = inb(ET1310_NMI_DISABLE);
RegisterVal &= 0xf3;
- if (adapter->RegistryNMIDisable == 2) {
+ if (adapter->RegistryNMIDisable == 2)
RegisterVal |= 0xc;
- }
outb(ET1310_NMI_DISABLE, RegisterVal);
}
@@ -266,7 +265,7 @@ int et131x_find_adapter(struct et131x_adapter *adapter, struct pci_dev *pdev)
&eepromStat);
/* THIS IS A WORKAROUND:
- * I need to call this function twice to get my card in a
+ * I need to call this function twice to get my card in a
* LG M1 Express Dual running. I tried also a msleep before this
* function, because I thougth there could be some time condidions
* but it didn't work. Call the whole function twice also work.
@@ -331,9 +330,9 @@ int et131x_find_adapter(struct et131x_adapter *adapter, struct pci_dev *pdev)
EepromReadByte(adapter, 0x70, &adapter->eepromData[0], 0, SINGLE_BYTE);
EepromReadByte(adapter, 0x71, &adapter->eepromData[1], 0, SINGLE_BYTE);
- if (adapter->eepromData[0] != 0xcd) {
- adapter->eepromData[1] = 0x00; // Disable all optional features
- }
+ if (adapter->eepromData[0] != 0xcd)
+ /* Disable all optional features */
+ adapter->eepromData[1] = 0x00;
/* Let's set up the PORT LOGIC Register. First we need to know what
* the max_payload_size is
@@ -347,7 +346,7 @@ int et131x_find_adapter(struct et131x_adapter *adapter, struct pci_dev *pdev)
}
/* Program the Ack/Nak latency and replay timers */
- maxPayload &= 0x07; // Only the lower 3 bits are valid
+ maxPayload &= 0x07; /* Only the lower 3 bits are valid */
if (maxPayload < 2) {
const uint16_t AckNak[2] = { 0x76, 0xD0 };
@@ -390,7 +389,7 @@ int et131x_find_adapter(struct et131x_adapter *adapter, struct pci_dev *pdev)
result = pci_read_config_byte(pdev, 0x51, &read_size_reg);
if (result != PCIBIOS_SUCCESSFUL) {
DBG_ERROR(et131x_dbginfo,
- "Could not read PCI config space for Max read size\n");
+ "Could not read PCI config space for Max read size\n");
DBG_LEAVE(et131x_dbginfo);
return -EIO;
}
@@ -401,7 +400,7 @@ int et131x_find_adapter(struct et131x_adapter *adapter, struct pci_dev *pdev)
result = pci_write_config_byte(pdev, 0x51, read_size_reg);
if (result != PCIBIOS_SUCCESSFUL) {
DBG_ERROR(et131x_dbginfo,
- "Could not write PCI config space for Max read size\n");
+ "Could not write PCI config space for Max read size\n");
DBG_LEAVE(et131x_dbginfo);
return -EIO;
}
@@ -411,7 +410,7 @@ int et131x_find_adapter(struct et131x_adapter *adapter, struct pci_dev *pdev)
&adapter->PciXDevCtl);
if (result != PCIBIOS_SUCCESSFUL) {
DBG_ERROR(et131x_dbginfo,
- "Could not read PCI config space for PCI Express Dev Ctl\n");
+ "Could not read PCI config space for PCI Express Dev Ctl\n");
DBG_LEAVE(et131x_dbginfo);
return -EIO;
}
@@ -428,7 +427,7 @@ int et131x_find_adapter(struct et131x_adapter *adapter, struct pci_dev *pdev)
adapter->PermanentAddress + i);
if (result != PCIBIOS_SUCCESSFUL) {
DBG_ERROR(et131x_dbginfo,
- "Could not read PCI config space for MAC address\n");
+ "Could not read PCI config space for MAC address\n");
DBG_LEAVE(et131x_dbginfo);
return -EIO;
}
@@ -454,14 +453,12 @@ void et131x_error_timer_handler(unsigned long data)
pm_csr.value = readl(&pAdapter->CSRAddress->global.pm_csr.value);
if (pm_csr.bits.pm_phy_sw_coma == 0) {
- if (pAdapter->RegistryMACStat) {
+ if (pAdapter->RegistryMACStat)
UpdateMacStatHostCounters(pAdapter);
- }
- } else {
+ } else
DBG_VERBOSE(et131x_dbginfo,
"No interrupts, in PHY coma, pm_csr = 0x%x\n",
pm_csr.value);
- }
if (!pAdapter->Bmsr.bits.link_status &&
pAdapter->RegistryPhyComa &&
@@ -473,8 +470,9 @@ void et131x_error_timer_handler(unsigned long data)
if (!pAdapter->Bmsr.bits.link_status
&& pAdapter->RegistryPhyComa) {
if (pm_csr.bits.pm_phy_sw_coma == 0) {
- // NOTE - This was originally a 'sync with interrupt'. How
- // to do that under Linux?
+ /* NOTE - This was originally a 'sync with
+ * interrupt'. How to do that under Linux?
+ */
et131x_enable_interrupts(pAdapter);
EnablePhyComa(pAdapter);
}
@@ -483,7 +481,7 @@ void et131x_error_timer_handler(unsigned long data)
/* This is a periodic timer, so reschedule */
mod_timer(&pAdapter->ErrorTimer, jiffies +
- TX_ERROR_PERIOD * HZ / 1000);
+ TX_ERROR_PERIOD * HZ / 1000);
}
/**
@@ -542,9 +540,8 @@ int et131x_adapter_setup(struct et131x_adapter *pAdapter)
/* Move the following code to Timer function?? */
status = et131x_xcvr_find(pAdapter);
- if (status != 0) {
+ if (status != 0)
DBG_WARNING(et131x_dbginfo, "Could not find the xcvr\n");
- }
/* Prepare the TRUEPHY library. */
ET1310_PhyInit(pAdapter);
@@ -559,11 +556,10 @@ int et131x_adapter_setup(struct et131x_adapter *pAdapter)
* We need to turn off 1000 base half dulplex, the mac does not
* support it. For the 10/100 part, turn off all gig advertisement
*/
- if (pAdapter->DeviceID != ET131X_PCI_DEVICE_ID_FAST) {
+ if (pAdapter->DeviceID != ET131X_PCI_DEVICE_ID_FAST)
ET1310_PhyAdvertise1000BaseT(pAdapter, TRUEPHY_ADV_DUPLEX_FULL);
- } else {
+ else
ET1310_PhyAdvertise1000BaseT(pAdapter, TRUEPHY_ADV_DUPLEX_NONE);
- }
/* Power up PHY */
ET1310_PhyPowerDown(pAdapter, 0);
@@ -861,9 +857,11 @@ int __devinit et131x_pci_setup(struct pci_dev *pdev,
/* Setup the fundamental net_device and private adapter structure elements */
DBG_TRACE(et131x_dbginfo, "Setting fundamental net_device info...\n");
SET_NETDEV_DEV(netdev, &pdev->dev);
+ /*
if (pci_using_dac) {
- //netdev->features |= NETIF_F_HIGHDMA;
+ netdev->features |= NETIF_F_HIGHDMA;
}
+ */
/*
* NOTE - Turn this on when we're ready to deal with SG-DMA
@@ -884,9 +882,9 @@ int __devinit et131x_pci_setup(struct pci_dev *pdev,
* receiving a scattered buffer from the network stack, so leave it
* off until checksums are calculated in HW.
*/
- //netdev->features |= NETIF_F_SG;
- //netdev->features |= NETIF_F_NO_CSUM;
- //netdev->features |= NETIF_F_LLTX;
+ /* netdev->features |= NETIF_F_SG; */
+ /* netdev->features |= NETIF_F_NO_CSUM; */
+ /* netdev->features |= NETIF_F_LLTX; */
/* Allocate private adapter struct and copy in relevant information */
adapter = netdev_priv(netdev);
@@ -921,7 +919,7 @@ int __devinit et131x_pci_setup(struct pci_dev *pdev,
* lump it's init with the device specific init below into a
* single init function?
*/
- //while (et131x_find_adapter(adapter, pdev) != 0);
+ /* while (et131x_find_adapter(adapter, pdev) != 0); */
et131x_find_adapter(adapter, pdev);
/* Map the bus-relative registers to system virtual memory */
@@ -1002,7 +1000,8 @@ int __devinit et131x_pci_setup(struct pci_dev *pdev,
/* Initialize link state */
et131x_link_detection_handler((unsigned long)adapter);
- /* Intialize variable for counting how long we do not have link status */
+ /* Intialize variable for counting how long we do not have
+ link status */
adapter->PoMgmt.TransPhyComaModeOnBoot = 0;
/* We can enable interrupts now
@@ -1014,7 +1013,8 @@ int __devinit et131x_pci_setup(struct pci_dev *pdev,
/* Register the net_device struct with the Linux network layer */
DBG_TRACE(et131x_dbginfo, "Registering net_device...\n");
- if ((result = register_netdev(netdev)) != 0) {
+ result = register_netdev(netdev);
+ if (result != 0) {
DBG_ERROR(et131x_dbginfo, "register_netdev() failed\n");
goto err_mem_free;
}
diff --git a/drivers/staging/et131x/et131x_initpci.h b/drivers/staging/et131x/et131x_initpci.h
index bbacb6277595..8131d6a65c2a 100644
--- a/drivers/staging/et131x/et131x_initpci.h
+++ b/drivers/staging/et131x/et131x_initpci.h
@@ -2,7 +2,7 @@
* Agere Systems Inc.
* 10/100/1000 Base-T Ethernet Driver for the ET1301 and ET131x series MACs
*
- * Copyright © 2005 Agere Systems Inc.
+ * Copyright © 2005 Agere Systems Inc.
* All rights reserved.
* http://www.agere.com
*
@@ -20,7 +20,7 @@
* software indicates your acceptance of these terms and conditions. If you do
* not agree with these terms and conditions, do not use the software.
*
- * Copyright © 2005 Agere Systems Inc.
+ * Copyright © 2005 Agere Systems Inc.
* All rights reserved.
*
* Redistribution and use in source or binary forms, with or without
@@ -41,7 +41,7 @@
*
* Disclaimer
*
- * THIS SOFTWARE IS PROVIDED “AS IS” AND ANY EXPRESS OR IMPLIED WARRANTIES,
+ * THIS SOFTWARE IS PROVIDED "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES,
* INCLUDING, BUT NOT LIMITED TO, INFRINGEMENT AND THE IMPLIED WARRANTIES OF
* MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. ANY
* USE, MODIFICATION OR DISTRIBUTION OF THIS SOFTWARE IS SOLELY AT THE USERS OWN
diff --git a/drivers/staging/et131x/et131x_isr.c b/drivers/staging/et131x/et131x_isr.c
index 00afad174a62..bbe3c1a6c24e 100644
--- a/drivers/staging/et131x/et131x_isr.c
+++ b/drivers/staging/et131x/et131x_isr.c
@@ -2,7 +2,7 @@
* Agere Systems Inc.
* 10/100/1000 Base-T Ethernet Driver for the ET1301 and ET131x series MACs
*
- * Copyright © 2005 Agere Systems Inc.
+ * Copyright © 2005 Agere Systems Inc.
* All rights reserved.
* http://www.agere.com
*
@@ -20,7 +20,7 @@
* software indicates your acceptance of these terms and conditions. If you do
* not agree with these terms and conditions, do not use the software.
*
- * Copyright © 2005 Agere Systems Inc.
+ * Copyright © 2005 Agere Systems Inc.
* All rights reserved.
*
* Redistribution and use in source or binary forms, with or without
@@ -41,7 +41,7 @@
*
* Disclaimer
*
- * THIS SOFTWARE IS PROVIDED “AS IS” AND ANY EXPRESS OR IMPLIED WARRANTIES,
+ * THIS SOFTWARE IS PROVIDED "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES,
* INCLUDING, BUT NOT LIMITED TO, INFRINGEMENT AND THE IMPLIED WARRANTIES OF
* MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. ANY
* USE, MODIFICATION OR DISTRIBUTION OF THIS SOFTWARE IS SOLELY AT THE USERS OWN
@@ -74,9 +74,9 @@
#include <linux/interrupt.h>
#include <linux/in.h>
#include <linux/delay.h>
-#include <asm/io.h>
+#include <linux/io.h>
+#include <linux/bitops.h>
#include <asm/system.h>
-#include <asm/bitops.h>
#include <linux/netdevice.h>
#include <linux/etherdevice.h>
@@ -151,29 +151,24 @@ irqreturn_t et131x_isr(int irq, void *dev_id)
/* This is our interrupt, so process accordingly */
#ifdef CONFIG_ET131X_DEBUG
- if (status.bits.rxdma_xfr_done) {
+ if (status.bits.rxdma_xfr_done)
adapter->Stats.RxDmaInterruptsPerSec++;
- }
- if (status.bits.txdma_isr) {
+ if (status.bits.txdma_isr)
adapter->Stats.TxDmaInterruptsPerSec++;
- }
#endif
if (status.bits.watchdog_interrupt) {
PMP_TCB pMpTcb = adapter->TxRing.CurrSendHead;
- if (pMpTcb) {
- if (++pMpTcb->PacketStaleCount > 1) {
+ if (pMpTcb)
+ if (++pMpTcb->PacketStaleCount > 1)
status.bits.txdma_isr = 1;
- }
- }
- if (adapter->RxRing.UnfinishedReceives) {
+ if (adapter->RxRing.UnfinishedReceives)
status.bits.rxdma_xfr_done = 1;
- } else if (pMpTcb == NULL) {
+ else if (pMpTcb == NULL)
writel(0, &adapter->CSRAddress->global.watchdog_timer);
- }
status.bits.watchdog_interrupt = 0;
#ifdef CONFIG_ET131X_DEBUG
@@ -284,7 +279,8 @@ void et131x_isr_handler(struct work_struct *work)
/* Tell the device to send a pause packet via
* the back pressure register
*/
- pm_csr.value = readl(&iomem->global.pm_csr.value);
+ pm_csr.value =
+ readl(&iomem->global.pm_csr.value);
if (pm_csr.bits.pm_phy_sw_coma == 0) {
TXMAC_BP_CTRL_t bp_ctrl = { 0 };
@@ -332,7 +328,7 @@ void et131x_isr_handler(struct work_struct *work)
* something bad has occurred. A reset might be the
* thing to do.
*/
- // TRAP();
+ /* TRAP();*/
pAdapter->TxMacTest.value =
readl(&iomem->txmac.tx_test.value);
@@ -425,7 +421,7 @@ void et131x_isr_handler(struct work_struct *work)
* otherwise we just want the device to be reset and
* continue
*/
- //DBG_TRAP();
+ /* DBG_TRAP(); */
}
/* Handle RXMAC Interrupt */
@@ -436,10 +432,11 @@ void et131x_isr_handler(struct work_struct *work)
* set the flag to cause us to reset so we can solve
* this issue.
*/
- // MP_SET_FLAG( pAdapter, fMP_ADAPTER_HARDWARE_ERROR );
+ /* MP_SET_FLAG( pAdapter,
+ fMP_ADAPTER_HARDWARE_ERROR); */
DBG_WARNING(et131x_dbginfo,
- "RXMAC interrupt, error 0x%08x. Requesting reset\n",
+ "RXMAC interrupt, error 0x%08x. Requesting reset\n",
readl(&iomem->rxmac.err_reg.value));
DBG_WARNING(et131x_dbginfo,
@@ -452,7 +449,7 @@ void et131x_isr_handler(struct work_struct *work)
* otherwise we just want the device to be reset and
* continue
*/
- // TRAP();
+ /* TRAP(); */
}
/* Handle MAC_STAT Interrupt */
@@ -482,7 +479,6 @@ void et131x_isr_handler(struct work_struct *work)
}
}
- if (pAdapter->PoMgmt.PowerState == NdisDeviceStateD0) {
+ if (pAdapter->PoMgmt.PowerState == NdisDeviceStateD0)
et131x_enable_interrupts(pAdapter);
- }
}
diff --git a/drivers/staging/et131x/et131x_isr.h b/drivers/staging/et131x/et131x_isr.h
index 76a51d56551e..906d57727e20 100644
--- a/drivers/staging/et131x/et131x_isr.h
+++ b/drivers/staging/et131x/et131x_isr.h
@@ -2,7 +2,7 @@
* Agere Systems Inc.
* 10/100/1000 Base-T Ethernet Driver for the ET1301 and ET131x series MACs
*
- * Copyright © 2005 Agere Systems Inc.
+ * Copyright © 2005 Agere Systems Inc.
* All rights reserved.
* http://www.agere.com
*
@@ -20,7 +20,7 @@
* software indicates your acceptance of these terms and conditions. If you do
* not agree with these terms and conditions, do not use the software.
*
- * Copyright © 2005 Agere Systems Inc.
+ * Copyright © 2005 Agere Systems Inc.
* All rights reserved.
*
* Redistribution and use in source or binary forms, with or without
@@ -41,7 +41,7 @@
*
* Disclaimer
*
- * THIS SOFTWARE IS PROVIDED “AS IS” AND ANY EXPRESS OR IMPLIED WARRANTIES,
+ * THIS SOFTWARE IS PROVIDED "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES,
* INCLUDING, BUT NOT LIMITED TO, INFRINGEMENT AND THE IMPLIED WARRANTIES OF
* MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. ANY
* USE, MODIFICATION OR DISTRIBUTION OF THIS SOFTWARE IS SOLELY AT THE USERS OWN
diff --git a/drivers/staging/et131x/et131x_netdev.c b/drivers/staging/et131x/et131x_netdev.c
index 59e99cc7786b..74a8375f9477 100644
--- a/drivers/staging/et131x/et131x_netdev.c
+++ b/drivers/staging/et131x/et131x_netdev.c
@@ -2,7 +2,7 @@
* Agere Systems Inc.
* 10/100/1000 Base-T Ethernet Driver for the ET1301 and ET131x series MACs
*
- * Copyright © 2005 Agere Systems Inc.
+ * Copyright © 2005 Agere Systems Inc.
* All rights reserved.
* http://www.agere.com
*
@@ -19,7 +19,7 @@
* software indicates your acceptance of these terms and conditions. If you do
* not agree with these terms and conditions, do not use the software.
*
- * Copyright © 2005 Agere Systems Inc.
+ * Copyright © 2005 Agere Systems Inc.
* All rights reserved.
*
* Redistribution and use in source or binary forms, with or without
@@ -40,7 +40,7 @@
*
* Disclaimer
*
- * THIS SOFTWARE IS PROVIDED “AS IS” AND ANY EXPRESS OR IMPLIED WARRANTIES,
+ * THIS SOFTWARE IS PROVIDED "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES,
* INCLUDING, BUT NOT LIMITED TO, INFRINGEMENT AND THE IMPLIED WARRANTIES OF
* MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. ANY
* USE, MODIFICATION OR DISTRIBUTION OF THIS SOFTWARE IS SOLELY AT THE USERS OWN
@@ -73,9 +73,9 @@
#include <linux/interrupt.h>
#include <linux/in.h>
#include <linux/delay.h>
-#include <asm/io.h>
+#include <linux/io.h>
+#include <linux/bitops.h>
#include <asm/system.h>
-#include <asm/bitops.h>
#include <linux/mii.h>
#include <linux/netdevice.h>
@@ -153,16 +153,16 @@ struct net_device *et131x_device_alloc(void)
/* Setup the function registration table (and other data) for a
* net_device
*/
- //netdev->init = &et131x_init;
- //netdev->set_config = &et131x_config;
+ /* netdev->init = &et131x_init; */
+ /* netdev->set_config = &et131x_config; */
netdev->watchdog_timeo = ET131X_TX_TIMEOUT;
netdev->netdev_ops = &et131x_netdev_ops;
- //netdev->ethtool_ops = &et131x_ethtool_ops;
+ /* netdev->ethtool_ops = &et131x_ethtool_ops; */
- // Poll?
- //netdev->poll = &et131x_poll;
- //netdev->poll_controller = &et131x_poll_controller;
+ /* Poll? */
+ /* netdev->poll = &et131x_poll; */
+ /* netdev->poll_controller = &et131x_poll_controller; */
DBG_LEAVE(et131x_dbginfo);
return netdev;
@@ -194,23 +194,25 @@ struct net_device_stats *et131x_stats(struct net_device *netdev)
stats->rx_over_errors = devstat->rx_ov_flow;
stats->rx_crc_errors = devstat->crc_err;
- // NOTE: These stats don't have corresponding values in CE_STATS, so we're
- // going to have to update these directly from within the TX/RX code
- //stats->rx_bytes = 20; //devstat->;
- //stats->tx_bytes = 20; //devstat->;
- //stats->rx_dropped = devstat->;
- //stats->tx_dropped = devstat->;
-
- // NOTE: Not used, can't find analogous statistics
- //stats->rx_frame_errors = devstat->;
- //stats->rx_fifo_errors = devstat->;
- //stats->rx_missed_errors = devstat->;
-
- //stats->tx_aborted_errors = devstat->;
- //stats->tx_carrier_errors = devstat->;
- //stats->tx_fifo_errors = devstat->;
- //stats->tx_heartbeat_errors = devstat->;
- //stats->tx_window_errors = devstat->;
+ /* NOTE: These stats don't have corresponding values in CE_STATS,
+ * so we're going to have to update these directly from within the
+ * TX/RX code
+ */
+ /* stats->rx_bytes = 20; devstat->; */
+ /* stats->tx_bytes = 20; devstat->; */
+ /* stats->rx_dropped = devstat->; */
+ /* stats->tx_dropped = devstat->; */
+
+ /* NOTE: Not used, can't find analogous statistics */
+ /* stats->rx_frame_errors = devstat->; */
+ /* stats->rx_fifo_errors = devstat->; */
+ /* stats->rx_missed_errors = devstat->; */
+
+ /* stats->tx_aborted_errors = devstat->; */
+ /* stats->tx_carrier_errors = devstat->; */
+ /* stats->tx_fifo_errors = devstat->; */
+ /* stats->tx_heartbeat_errors = devstat->; */
+ /* stats->tx_window_errors = devstat->; */
DBG_LEAVE(et131x_dbginfo);
return stats;
@@ -414,10 +416,11 @@ int et131x_set_packet_filter(struct et131x_adapter *adapter)
*/
if (filter & ET131X_PACKET_TYPE_ALL_MULTICAST) {
DBG_VERBOSE(et131x_dbginfo,
- "Multicast filtering OFF (Rx ALL MULTICAST)\n");
+ "Multicast filtering OFF (Rx ALL MULTICAST)\n");
pf_ctrl.bits.filter_multi_en = 0;
} else {
- DBG_VERBOSE(et131x_dbginfo, "Multicast filtering ON\n");
+ DBG_VERBOSE(et131x_dbginfo,
+ "Multicast filtering ON\n");
SetupDeviceForMulticast(adapter);
pf_ctrl.bits.filter_multi_en = 1;
ctrl.bits.pkt_filter_disable = 0;
@@ -505,9 +508,7 @@ void et131x_multicast(struct net_device *netdev)
if (netdev->mc_count > NIC_MAX_MCAST_LIST) {
DBG_WARNING(et131x_dbginfo,
- "ACCEPT ALL MULTICAST for now, as there's more Multicast "
- "addresses than the HW supports\n");
-
+ "ACCEPT ALL MULTICAST for now, as there's more Multicast addresses than the HW supports\n");
adapter->PacketFilter |= ET131X_PACKET_TYPE_ALL_MULTICAST;
}
@@ -525,10 +526,10 @@ void et131x_multicast(struct net_device *netdev)
adapter->MCAddressCount = netdev->mc_count;
if (netdev->mc_count) {
- if (mclist->dmi_addrlen != ETH_ALEN) {
+ if (mclist->dmi_addrlen != ETH_ALEN)
DBG_WARNING(et131x_dbginfo,
- "Multicast addrs are not ETH_ALEN in size\n");
- } else {
+ "Multicast addrs are not ETH_ALEN in size\n");
+ else {
count = netdev->mc_count - 1;
memcpy(adapter->MCList[count], mclist->dmi_addr,
ETH_ALEN);
@@ -662,15 +663,15 @@ void et131x_tx_timeout(struct net_device *netdev)
lockflags);
DBG_WARNING(et131x_dbginfo,
- "Send stuck - reset. pMpTcb->WrIndex %x, Flags 0x%08x\n",
- pMpTcb->WrIndex.bits.val,
- pMpTcb->Flags);
+ "Send stuck - reset. pMpTcb->WrIndex %x, Flags 0x%08x\n",
+ pMpTcb->WrIndex.bits.val,
+ pMpTcb->Flags);
DBG_WARNING(et131x_dbginfo,
- "pDesc 0x%08x, 0x%08x, 0x%08x, 0x%08x\n",
- pDesc->DataBufferPtrHigh,
- pDesc->DataBufferPtrLow, pDesc->word2.value,
- pDesc->word3.value);
+ "pDesc 0x%08x, 0x%08x, 0x%08x, 0x%08x\n",
+ pDesc->DataBufferPtrHigh,
+ pDesc->DataBufferPtrLow, pDesc->word2.value,
+ pDesc->word3.value);
DBG_WARNING(et131x_dbginfo,
"WbStatus 0x%08x\n", txDmaComplete.value);
@@ -737,7 +738,7 @@ int et131x_change_mtu(struct net_device *netdev, int new_mtu)
result = et131x_adapter_memory_alloc(adapter);
if (result != 0) {
DBG_WARNING(et131x_dbginfo,
- "Change MTU failed; couldn't re-alloc DMA memory\n");
+ "Change MTU failed; couldn't re-alloc DMA memory\n");
return result;
}
@@ -750,9 +751,8 @@ int et131x_change_mtu(struct net_device *netdev, int new_mtu)
et131x_adapter_setup(adapter);
/* Enable interrupts */
- if (MP_TEST_FLAG(adapter, fMP_ADAPTER_INTERRUPT_IN_USE)) {
+ if (MP_TEST_FLAG(adapter, fMP_ADAPTER_INTERRUPT_IN_USE))
et131x_enable_interrupts(adapter);
- }
/* Restart the Tx and Rx DMA engines */
et131x_rx_dma_enable(adapter);
@@ -781,8 +781,8 @@ int et131x_set_mac_addr(struct net_device *netdev, void *new_mac)
struct sockaddr *address = new_mac;
DBG_ENTER(et131x_dbginfo);
- // begin blux
- // DBG_VERBOSE( et131x_dbginfo, "Function not implemented!!\n" );
+ /* begin blux */
+ /* DBG_VERBOSE( et131x_dbginfo, "Function not implemented!!\n" ); */
if (adapter == NULL) {
DBG_LEAVE(et131x_dbginfo);
@@ -808,22 +808,24 @@ int et131x_set_mac_addr(struct net_device *netdev, void *new_mac)
et131x_handle_recv_interrupt(adapter);
/* Set the new MAC */
- // netdev->set_mac_address = &new_mac;
- // netdev->mtu = new_mtu;
+ /* netdev->set_mac_address = &new_mac; */
+ /* netdev->mtu = new_mtu; */
memcpy(netdev->dev_addr, address->sa_data, netdev->addr_len);
- printk("%s: Setting MAC address to %02x:%02x:%02x:%02x:%02x:%02x\n",
- netdev->name, netdev->dev_addr[0], netdev->dev_addr[1],
- netdev->dev_addr[2], netdev->dev_addr[3], netdev->dev_addr[4],
- netdev->dev_addr[5]);
+ printk(KERN_INFO
+ "%s: Setting MAC address to %02x:%02x:%02x:%02x:%02x:%02x\n",
+ netdev->name,
+ netdev->dev_addr[0], netdev->dev_addr[1],
+ netdev->dev_addr[2], netdev->dev_addr[3],
+ netdev->dev_addr[4], netdev->dev_addr[5]);
/* Free Rx DMA memory */
et131x_adapter_memory_free(adapter);
/* Set the config parameter for Jumbo Packet support */
- // adapter->RegistryJumboPacket = new_mtu + 14;
- // blux: not needet here, w'll change the MAC
+ /* adapter->RegistryJumboPacket = new_mtu + 14; */
+ /* blux: not needet here, we'll change the MAC */
et131x_soft_reset(adapter);
@@ -831,23 +833,22 @@ int et131x_set_mac_addr(struct net_device *netdev, void *new_mac)
result = et131x_adapter_memory_alloc(adapter);
if (result != 0) {
DBG_WARNING(et131x_dbginfo,
- "Change MAC failed; couldn't re-alloc DMA memory\n");
+ "Change MAC failed; couldn't re-alloc DMA memory\n");
return result;
}
et131x_init_send(adapter);
et131x_setup_hardware_properties(adapter);
- // memcpy( netdev->dev_addr, adapter->CurrentAddress, ETH_ALEN );
- // blux: no, do not override our nice address
+ /* memcpy( netdev->dev_addr, adapter->CurrentAddress, ETH_ALEN ); */
+ /* blux: no, do not override our nice address */
/* Init the device with the new settings */
et131x_adapter_setup(adapter);
/* Enable interrupts */
- if (MP_TEST_FLAG(adapter, fMP_ADAPTER_INTERRUPT_IN_USE)) {
+ if (MP_TEST_FLAG(adapter, fMP_ADAPTER_INTERRUPT_IN_USE))
et131x_enable_interrupts(adapter);
- }
/* Restart the Tx and Rx DMA engines */
et131x_rx_dma_enable(adapter);
diff --git a/drivers/staging/et131x/et131x_netdev.h b/drivers/staging/et131x/et131x_netdev.h
index b8acd14ff830..1eb4a922c01d 100644
--- a/drivers/staging/et131x/et131x_netdev.h
+++ b/drivers/staging/et131x/et131x_netdev.h
@@ -2,7 +2,7 @@
* Agere Systems Inc.
* 10/100/1000 Base-T Ethernet Driver for the ET1301 and ET131x series MACs
*
- * Copyright © 2005 Agere Systems Inc.
+ * Copyright © 2005 Agere Systems Inc.
* All rights reserved.
* http://www.agere.com
*
@@ -20,7 +20,7 @@
* software indicates your acceptance of these terms and conditions. If you do
* not agree with these terms and conditions, do not use the software.
*
- * Copyright © 2005 Agere Systems Inc.
+ * Copyright © 2005 Agere Systems Inc.
* All rights reserved.
*
* Redistribution and use in source or binary forms, with or without
@@ -41,7 +41,7 @@
*
* Disclaimer
*
- * THIS SOFTWARE IS PROVIDED “AS IS” AND ANY EXPRESS OR IMPLIED WARRANTIES,
+ * THIS SOFTWARE IS PROVIDED "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES,
* INCLUDING, BUT NOT LIMITED TO, INFRINGEMENT AND THE IMPLIED WARRANTIES OF
* MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. ANY
* USE, MODIFICATION OR DISTRIBUTION OF THIS SOFTWARE IS SOLELY AT THE USERS OWN
diff --git a/drivers/staging/et131x/et131x_version.h b/drivers/staging/et131x/et131x_version.h
index 2ea645e1066e..568f6c8c34f5 100644
--- a/drivers/staging/et131x/et131x_version.h
+++ b/drivers/staging/et131x/et131x_version.h
@@ -2,7 +2,7 @@
* Agere Systems Inc.
* 10/100/1000 Base-T Ethernet Driver for the ET1301 and ET131x series MACs
*
- * Copyright © 2005 Agere Systems Inc.
+ * Copyright © 2005 Agere Systems Inc.
* All rights reserved.
* http://www.agere.com
*
@@ -19,7 +19,7 @@
* software indicates your acceptance of these terms and conditions. If you do
* not agree with these terms and conditions, do not use the software.
*
- * Copyright © 2005 Agere Systems Inc.
+ * Copyright © 2005 Agere Systems Inc.
* All rights reserved.
*
* Redistribution and use in source or binary forms, with or without
@@ -40,7 +40,7 @@
*
* Disclaimer
*
- * THIS SOFTWARE IS PROVIDED “AS IS” AND ANY EXPRESS OR IMPLIED WARRANTIES,
+ * THIS SOFTWARE IS PROVIDED "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES,
* INCLUDING, BUT NOT LIMITED TO, INFRINGEMENT AND THE IMPLIED WARRANTIES OF
* MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. ANY
* USE, MODIFICATION OR DISTRIBUTION OF THIS SOFTWARE IS SOLELY AT THE USERS OWN
diff --git a/drivers/staging/meilhaus/TODO b/drivers/staging/meilhaus/TODO
index 6ec25203089c..d6ce39823de6 100644
--- a/drivers/staging/meilhaus/TODO
+++ b/drivers/staging/meilhaus/TODO
@@ -7,4 +7,4 @@ TODO:
- possible comedi merge
Please send cleanup patches to Greg Kroah-Hartman <greg@kroah.com>
-and CC: David Kiliani <mail@davidkiliani.de>
+and CC: David Kiliani <mail@davidkiliani.de> and Meilhaus Support <support@meilhaus.de>
diff --git a/drivers/staging/otus/ioctl.c b/drivers/staging/otus/ioctl.c
index ce04218253dd..6808e69fb354 100644
--- a/drivers/staging/otus/ioctl.c
+++ b/drivers/staging/otus/ioctl.c
@@ -58,9 +58,7 @@
#define ZD_MAX_KEY_SIZE 32
#define ZD_MAX_GENERIC_SIZE 64
-#if WIRELESS_EXT > 12
#include <net/iw_handler.h>
-#endif
extern u16_t zfLnxGetVapId(zdev_t *dev);
@@ -248,7 +246,6 @@ int usbdrv_ioctl_setrts(struct net_device *dev, struct iw_param *rrq)
return 0;
}
-#if WIRELESS_EXT > 14
/*
* Encode a WPA or RSN information element as a custom
* element using the hostap format.
@@ -269,7 +266,6 @@ u32 encode_ie(void *buf, u32 bufsize, const u8 *ie, u32 ielen,
p += sprintf(p, "%02x", ie[i]);
return (i == ielen ? p - (u8 *)buf:0);
}
-#endif /* WIRELESS_EXT > 14 */
/*
* Translate scan data returned from the card to a card independent
@@ -284,9 +280,7 @@ char *usbdrv_translate_scan(struct net_device *dev,
char *current_val; /* For rates */
char *last_ev;
int i;
- #if WIRELESS_EXT > 14
- char buf[64*2 + 30];
- #endif
+ char buf[64*2 + 30];
last_ev = current_ev;
@@ -365,10 +359,8 @@ char *usbdrv_translate_scan(struct net_device *dev,
/* Add quality statistics */
iwe.cmd = IWEVQUAL;
- #if WIRELESS_EXT > 18
iwe.u.qual.updated = IW_QUAL_QUAL_UPDATED | IW_QUAL_LEVEL_UPDATED
| IW_QUAL_NOISE_UPDATED;
- #endif
iwe.u.qual.level = list->signalStrength;
iwe.u.qual.noise = 0;
iwe.u.qual.qual = list->signalQuality;
@@ -441,7 +433,6 @@ char *usbdrv_translate_scan(struct net_device *dev,
/* Check if we added any event */
if ((current_val - current_ev) > IW_EV_LCP_LEN)
current_ev = current_val;
- #if WIRELESS_EXT > 14
#define IEEE80211_ELEMID_RSN 0x30
memset(&iwe, 0, sizeof(iwe));
iwe.cmd = IWEVCUSTOM;
@@ -503,7 +494,6 @@ char *usbdrv_translate_scan(struct net_device *dev,
last_ev = current_ev;
}
}
- #endif
/* The other data in the scan result are not really
* interesting, so for now drop it
*/
@@ -697,12 +687,9 @@ int usbdrvwext_giwrange(struct net_device *dev,
if (!netif_running(dev))
return -EINVAL;
- #if WIRELESS_EXT > 9
range->txpower_capa = IW_TXPOW_DBM;
/* XXX what about min/max_pmp, min/max_pmt, etc. */
- #endif
- #if WIRELESS_EXT > 10
range->we_version_compiled = WIRELESS_EXT;
range->we_version_source = 13;
@@ -710,7 +697,6 @@ int usbdrvwext_giwrange(struct net_device *dev,
range->retry_flags = IW_RETRY_LIMIT;
range->min_retry = 0;
range->max_retry = 255;
- #endif /* WIRELESS_EXT > 10 */
channel_num = zfiWlanQueryAllowChannels(dev, channels);
@@ -917,13 +903,11 @@ int usbdrvwext_giwscan(struct net_device *dev,
current_ev = usbdrv_translate_scan(dev, info, current_ev,
end_buf, &pBssList->bssInfo[i]);
- #if WIRELESS_EXT > 16
if (current_ev == end_buf) {
kfree(pBssList);
data->length = current_ev - extra;
return -E2BIG;
}
- #endif
}
/* Length of data */
@@ -2045,6 +2029,7 @@ int usbdrv_wpa_ioctl(struct net_device *dev, struct athr_wlan_param *zdparm)
struct zsKeyInfo keyInfo;
struct usbdrv_private *macp = dev->ml_priv;
u16_t vapId = 0;
+ int ii;
/* zmw_get_wlan_dev(dev); */
@@ -2168,7 +2153,6 @@ int usbdrv_wpa_ioctl(struct net_device *dev, struct athr_wlan_param *zdparm)
/* DUMP key context */
/* #ifdef WPA_DEBUG */
if (keyInfo.keyLength > 0) {
- int ii;
printk(KERN_WARNING
"Otus: Key Context:\n");
for (ii = 0; ii < keyInfo.keyLength; ) {
@@ -2266,7 +2250,6 @@ int usbdrv_wpa_ioctl(struct net_device *dev, struct athr_wlan_param *zdparm)
/* zfiWlanSetWpaIe(dev, zdparm->u.generic_elem.data,
* zdparm->u.generic_elem.len);
*/
- int ii;
u8_t len = zdparm->u.generic_elem.len;
u8_t *wpaie = (u8_t *)zdparm->u.generic_elem.data;
@@ -2401,7 +2384,7 @@ int usbdrv_ioctl(struct net_device *dev, struct ifreq *ifr, int cmd)
struct athr_wlan_param zdparm;
struct usbdrv_private *macp = dev->ml_priv;
- int err = 0;
+ int err = 0, val = 0;
int changed = 0;
/* regp = macp->regp; */
@@ -2445,7 +2428,7 @@ int usbdrv_ioctl(struct net_device *dev, struct ifreq *ifr, int cmd)
err = -EPERM;
break;
}
- int val = *((int *) wrq->u.name);
+ val = *((int *) wrq->u.name);
if ((val < 0) || (val > 2)) {
err = -EINVAL;
break;
diff --git a/drivers/staging/otus/usbdrv.c b/drivers/staging/otus/usbdrv.c
index 7cd87caa6812..48aa30a62164 100644
--- a/drivers/staging/otus/usbdrv.c
+++ b/drivers/staging/otus/usbdrv.c
@@ -39,9 +39,7 @@
#include "linux/netlink.h"
#include "linux/rtnetlink.h"
-#if WIRELESS_EXT > 12
#include <net/iw_handler.h>
-#endif
#ifdef ZM_HOSTAPD_SUPPORT
#include "athr_common.h"
@@ -113,9 +111,6 @@ extern u8_t zfLnxCreateThread(zdev_t *dev);
/* Definition of Wireless Extension */
-#if WIRELESS_EXT > 12
-#include <net/iw_handler.h>
-#endif
//wireless extension helper functions
extern int usbdrv_ioctl_setessid(struct net_device *dev, struct iw_point *erq);
extern int usbdrv_ioctl_setrts(struct net_device *dev, struct iw_param *rrq);
@@ -203,7 +198,6 @@ struct iw_priv_args usbdrv_private_args[] = {
// { SIOCIWFIRSTPRIV + 0xC, 0, IW_PRIV_TYPE_CHAR | 12, "get_mac_mode" },
};
-#if WIRELESS_EXT > 12
static iw_handler usbdrvwext_handler[] = {
(iw_handler) NULL, /* SIOCSIWCOMMIT */
(iw_handler) usbdrvwext_giwname, /* SIOCGIWNAME */
@@ -229,13 +223,8 @@ static iw_handler usbdrvwext_handler[] = {
(iw_handler) usbdrvwext_giwap, /* SIOCGIWAP */
(iw_handler) NULL, /* -- hole -- */
(iw_handler) usbdrvwext_iwaplist, /* SIOCGIWAPLIST */
-#if WIRELESS_EXT > 13
(iw_handler) usbdrvwext_siwscan, /* SIOCSIWSCAN */
(iw_handler) usbdrvwext_giwscan, /* SIOCGIWSCAN */
-#else /* WIRELESS_EXT > 13 */
- (iw_handler) NULL, /* null */ /* SIOCSIWSCAN */
- (iw_handler) NULL, /* null */ /* SIOCGIWSCAN */
-#endif /* WIRELESS_EXT > 13 */
(iw_handler) usbdrvwext_siwessid, /* SIOCSIWESSID */
(iw_handler) usbdrvwext_giwessid, /* SIOCGIWESSID */
@@ -291,7 +280,6 @@ static struct iw_handler_def p80211wext_handler_def = {
.private = (iw_handler *) usbdrv_private_handler,
.private_args = (struct iw_priv_args *) usbdrv_private_args
};
-#endif
/* WDS */
//struct zsWdsStruct wds[ZM_WDS_PORT_NUMBER];
@@ -1106,9 +1094,7 @@ u8_t zfLnxInitSetup(struct net_device *dev, struct usbdrv_private *macp)
dev->dev_addr[4] = addr[4];
dev->dev_addr[5] = addr[5];
#endif
-#if WIRELESS_EXT > 12
dev->wireless_handlers = (struct iw_handler_def *)&p80211wext_handler_def;
-#endif
dev->netdev_ops = &otus_netdev_ops;
diff --git a/drivers/staging/otus/wrap_buf.c b/drivers/staging/otus/wrap_buf.c
index 62496a0f8e3f..a0f677a52616 100644
--- a/drivers/staging/otus/wrap_buf.c
+++ b/drivers/staging/otus/wrap_buf.c
@@ -30,10 +30,7 @@
#include <linux/netlink.h>
-#if WIRELESS_EXT > 12
#include <net/iw_handler.h>
-#endif
-
/* Called to allocate buffer, must return a continue buffer space */
diff --git a/drivers/staging/otus/wrap_dbg.c b/drivers/staging/otus/wrap_dbg.c
index 53763d9d2d85..d47e9ab9179a 100644
--- a/drivers/staging/otus/wrap_dbg.c
+++ b/drivers/staging/otus/wrap_dbg.c
@@ -27,10 +27,7 @@
#include "usbdrv.h"
#include <linux/netlink.h>
-
-#if WIRELESS_EXT > 12
#include <net/iw_handler.h>
-#endif
void zfwDumpBuf(zdev_t* dev, zbuf_t* buf)
{
diff --git a/drivers/staging/otus/wrap_ev.c b/drivers/staging/otus/wrap_ev.c
index 966b787eef62..bcda0b9673dc 100644
--- a/drivers/staging/otus/wrap_ev.c
+++ b/drivers/staging/otus/wrap_ev.c
@@ -28,10 +28,7 @@
#include "usbdrv.h"
#include <linux/netlink.h>
-
-#if WIRELESS_EXT > 12
#include <net/iw_handler.h>
-#endif
/***** Management *****/
@@ -75,7 +72,6 @@ u16_t zfLnxAsocNotify(zdev_t* dev, u16_t* macAddr, u8_t* body, u16_t bodySize, u
// //wireless_send_event(macp->device, SIOCGIWSCAN, &wreq, NULL);
// wireless_send_event(macp->device, SIOCGIWAP, &wreq, NULL);
//}
-#if WIRELESS_EXT >= 15
//else if(macp->cardSetting.BssType == AP_BSS) {
// if (port == 0)
// {
@@ -94,7 +90,6 @@ u16_t zfLnxAsocNotify(zdev_t* dev, u16_t* macAddr, u8_t* body, u16_t bodySize, u
// }
// }
//}
-#endif
//#endif
return 0;
@@ -185,7 +180,6 @@ void zfLnxConnectNotify(zdev_t* dev, u16_t status, u16_t* bssid)
// //wireless_send_event(dev, SIOCGIWSCAN, &wreq, NULL);
wireless_send_event(dev, SIOCGIWAP, &wreq, NULL);
}
-#if WIRELESS_EXT >= 15
else if(zfiWlanQueryWlanMode(dev) == ZM_MODE_AP) {
//if (port == 0)
//{
@@ -204,7 +198,6 @@ void zfLnxConnectNotify(zdev_t* dev, u16_t status, u16_t* bssid)
// }
//}
}
-#endif
}
//return 0;
}
diff --git a/drivers/staging/otus/wrap_mem.c b/drivers/staging/otus/wrap_mem.c
index 8081bb2f8878..32416d77a471 100644
--- a/drivers/staging/otus/wrap_mem.c
+++ b/drivers/staging/otus/wrap_mem.c
@@ -27,10 +27,7 @@
#include "usbdrv.h"
#include <linux/netlink.h>
-
-#if WIRELESS_EXT > 12
#include <net/iw_handler.h>
-#endif
/* Memory management */
/* Called to allocate uncached memory, allocated memory must */
diff --git a/drivers/staging/otus/wrap_mis.c b/drivers/staging/otus/wrap_mis.c
index 337918b9de9a..ea2199fecbbe 100644
--- a/drivers/staging/otus/wrap_mis.c
+++ b/drivers/staging/otus/wrap_mis.c
@@ -28,10 +28,7 @@
#include "usbdrv.h"
#include <linux/netlink.h>
-
-#if WIRELESS_EXT > 12
#include <net/iw_handler.h>
-#endif
//extern struct zsWdsStruct wds[ZM_WDS_PORT_NUMBER];
extern struct zsVapStruct vap[ZM_VAP_PORT_NUMBER];
diff --git a/drivers/staging/otus/wrap_pkt.c b/drivers/staging/otus/wrap_pkt.c
index 89a6b92f5972..0d5920fdf4f3 100644
--- a/drivers/staging/otus/wrap_pkt.c
+++ b/drivers/staging/otus/wrap_pkt.c
@@ -28,11 +28,7 @@
#include "usbdrv.h"
#include <linux/netlink.h>
-
-#if WIRELESS_EXT > 12
#include <net/iw_handler.h>
-#endif
-
//extern struct zsWdsStruct wds[ZM_WDS_PORT_NUMBER];
diff --git a/drivers/staging/otus/wrap_sec.c b/drivers/staging/otus/wrap_sec.c
index f688d064175d..0f780bacc598 100644
--- a/drivers/staging/otus/wrap_sec.c
+++ b/drivers/staging/otus/wrap_sec.c
@@ -28,10 +28,7 @@
#include "usbdrv.h"
#include <linux/netlink.h>
-
-#if WIRELESS_EXT > 12
#include <net/iw_handler.h>
-#endif
#ifdef ZM_ENABLE_CENC
extern int zfLnxCencSendMsg(struct sock *netlink_sk, u_int8_t *msg, int len);
diff --git a/drivers/staging/otus/wrap_usb.c b/drivers/staging/otus/wrap_usb.c
index c076e5645224..70fd410bc894 100644
--- a/drivers/staging/otus/wrap_usb.c
+++ b/drivers/staging/otus/wrap_usb.c
@@ -28,10 +28,7 @@
#include "usbdrv.h"
#include <linux/netlink.h>
-
-#if WIRELESS_EXT > 12
#include <net/iw_handler.h>
-#endif
extern void zfLnxInitUsbTxQ(zdev_t* dev);
extern void zfLnxInitUsbRxQ(zdev_t* dev);
diff --git a/drivers/staging/otus/wwrap.c b/drivers/staging/otus/wwrap.c
index 4db8f6e75ad8..53d2a45d55f9 100644
--- a/drivers/staging/otus/wwrap.c
+++ b/drivers/staging/otus/wwrap.c
@@ -26,10 +26,7 @@
#include "usbdrv.h"
#include <linux/netlink.h>
-
-#if WIRELESS_EXT > 12
#include <net/iw_handler.h>
-#endif
extern void zfiRecv80211(zdev_t* dev, zbuf_t* buf, struct zsAdditionInfo* addInfo);
extern void zfCoreRecv(zdev_t* dev, zbuf_t* buf, struct zsAdditionInfo* addInfo);
@@ -1018,11 +1015,6 @@ void kevent(struct work_struct *work)
container_of(work, struct usbdrv_private, kevent);
zdev_t *dev = macp->device;
- if (macp == NULL)
- {
- return;
- }
-
if (test_and_set_bit(0, (void *)&smp_kevent_Lock))
{
//schedule_work(&macp->kevent);
diff --git a/drivers/staging/otus/zdcompat.h b/drivers/staging/otus/zdcompat.h
index d9a3b2d5ba1e..84ac43356b77 100644
--- a/drivers/staging/otus/zdcompat.h
+++ b/drivers/staging/otus/zdcompat.h
@@ -35,16 +35,6 @@
#undef netdevice_t
typedef struct net_device netdevice_t;
-#ifdef WIRELESS_EXT
-#if (WIRELESS_EXT < 13)
-struct iw_request_info
-{
- __u16 cmd; /* Wireless Extension command */
- __u16 flags; /* More to come ;-) */
-};
-#endif
-#endif
-
#ifndef in_atomic
#define in_atomic() 0
#endif
diff --git a/drivers/staging/quatech_usb2/Kconfig b/drivers/staging/quatech_usb2/Kconfig
new file mode 100644
index 000000000000..1494f42f3da0
--- /dev/null
+++ b/drivers/staging/quatech_usb2/Kconfig
@@ -0,0 +1,15 @@
+config USB_SERIAL_QUATECH_USB2
+ tristate "USB Quatech xSU2-[14]00 USB Serial Driver"
+ depends on USB_SERIAL
+ help
+ Say Y here if you want to use a Quatech USB2.0 to serial adaptor. This
+ driver supports the SSU2-100, DSU2-100, DSU2-400, QSU2-100, QSU2-400,
+ ESU2-400 and ESU2-100 USB2.0 to RS232 / 485 / 422 serial adaptors.
+
+ Some hardware has an incorrect product string and announces itself as
+ ESU-100 (which uses the serqt driver) even though it is an ESU2-100.
+ Check the label on the bottom of your device.
+
+ To compile this driver as a module, choose M here: the module will be
+ called quatech_usb2 .
+
diff --git a/drivers/staging/quatech_usb2/Makefile b/drivers/staging/quatech_usb2/Makefile
new file mode 100644
index 000000000000..bcd1f890d163
--- /dev/null
+++ b/drivers/staging/quatech_usb2/Makefile
@@ -0,0 +1 @@
+obj-$(CONFIG_USB_SERIAL_QUATECH_USB2) += quatech_usb2.o
diff --git a/drivers/staging/quatech_usb2/quatech_usb2.c b/drivers/staging/quatech_usb2/quatech_usb2.c
new file mode 100644
index 000000000000..3544e7005404
--- /dev/null
+++ b/drivers/staging/quatech_usb2/quatech_usb2.c
@@ -0,0 +1,611 @@
+/*
+ * Driver for Quatech Inc USB2.0 to serial adaptors. Largely unrelated to the
+ * serqt_usb driver, based on a re-write of the vendor supplied serqt_usb2 code,
+ * which is unrelated to the serqt_usb2 in the staging kernel
+ */
+
+#include <linux/errno.h>
+#include <linux/init.h>
+#include <linux/slab.h>
+#include <linux/tty.h>
+#include <linux/tty_driver.h>
+#include <linux/tty_flip.h>
+#include <linux/module.h>
+#include <linux/serial.h>
+#include <linux/usb.h>
+#include <linux/usb/serial.h>
+#include <linux/uaccess.h>
+
+static int debug;
+
+/* Version Information */
+#define DRIVER_VERSION "v2.00"
+#define DRIVER_AUTHOR "Tim Gobeli, Quatech, Inc"
+#define DRIVER_DESC "Quatech USB 2.0 to Serial Driver"
+
+/* vendor and device IDs */
+#define USB_VENDOR_ID_QUATECH 0x061d /* Quatech VID */
+#define QUATECH_SSU2_100 0xC120 /* RS232 single port */
+#define QUATECH_DSU2_100 0xC140 /* RS232 dual port */
+#define QUATECH_DSU2_400 0xC150 /* RS232/422/485 dual port */
+#define QUATECH_QSU2_100 0xC160 /* RS232 four port */
+#define QUATECH_QSU2_400 0xC170 /* RS232/422/485 four port */
+#define QUATECH_ESU2_100 0xC1A0 /* RS232 eight port */
+#define QUATECH_ESU2_400 0xC180 /* RS232/422/485 eight port */
+
+/* magic numbers go here, when we find out which ones are needed */
+
+#define QU2BOXPWRON 0x8000 /* magic number to turn FPGA power on */
+#define QU2BOX232 0x40 /* RS232 mode on MEI devices */
+#define QU2BOXSPD9600 0x60 /* set speed to 9600 baud */
+/* directions for USB transfers */
+#define USBD_TRANSFER_DIRECTION_IN 0xc0
+#define USBD_TRANSFER_DIRECTION_OUT 0x40
+/* special Quatech command IDs */
+#define QT_SET_GET_DEVICE 0xc2
+#define QT_OPEN_CLOSE_CHANNEL 0xca
+/*#define QT_GET_SET_PREBUF_TRIG_LVL 0xcc
+#define QT_SET_ATF 0xcd
+#define QT_GET_SET_REGISTER 0xc0*/
+#define QT_GET_SET_UART 0xc1
+/*#define QT_HW_FLOW_CONTROL_MASK 0xc5
+#define QT_SW_FLOW_CONTROL_MASK 0xc6
+#define QT_SW_FLOW_CONTROL_DISABLE 0xc7
+#define QT_BREAK_CONTROL 0xc8
+#define QT_STOP_RECEIVE 0xe0
+#define QT_FLUSH_DEVICE 0xc4*/
+#define QT_GET_SET_QMCR 0xe1
+/* port setting constants */
+#define SERIAL_MCR_DTR 0x01
+#define SERIAL_MCR_RTS 0x02
+#define SERIAL_MCR_LOOP 0x10
+
+#define SERIAL_MSR_CTS 0x10
+#define SERIAL_MSR_CD 0x80
+#define SERIAL_MSR_RI 0x40
+#define SERIAL_MSR_DSR 0x20
+#define SERIAL_MSR_MASK 0xf0
+
+#define SERIAL_8_DATA 0x03
+#define SERIAL_7_DATA 0x02
+#define SERIAL_6_DATA 0x01
+#define SERIAL_5_DATA 0x00
+
+#define SERIAL_ODD_PARITY 0X08
+#define SERIAL_EVEN_PARITY 0X18
+#define SERIAL_TWO_STOPB 0x04
+#define SERIAL_ONE_STOPB 0x00
+
+#define MAX_BAUD_RATE 921600
+#define MAX_BAUD_REMAINDER 4608
+
+#define SERIAL_LSR_OE 0x02
+#define SERIAL_LSR_PE 0x04
+#define SERIAL_LSR_FE 0x08
+#define SERIAL_LSR_BI 0x10
+
+
+static struct usb_device_id quausb2_id_table[] = {
+ {USB_DEVICE(USB_VENDOR_ID_QUATECH, QUATECH_SSU2_100)},
+ {USB_DEVICE(USB_VENDOR_ID_QUATECH, QUATECH_DSU2_100)},
+ {USB_DEVICE(USB_VENDOR_ID_QUATECH, QUATECH_DSU2_400)},
+ {USB_DEVICE(USB_VENDOR_ID_QUATECH, QUATECH_QSU2_100)},
+ {USB_DEVICE(USB_VENDOR_ID_QUATECH, QUATECH_QSU2_400)},
+ {USB_DEVICE(USB_VENDOR_ID_QUATECH, QUATECH_ESU2_100)},
+ {USB_DEVICE(USB_VENDOR_ID_QUATECH, QUATECH_ESU2_400)},
+ {} /* Terminating entry */
+};
+
+MODULE_DEVICE_TABLE(usb, quausb2_id_table);
+
+/* custom structures we need go here */
+
+
+static struct usb_driver quausb2_usb_driver = {
+ .name = "quatech-usb2-serial",
+ .probe = usb_serial_probe,
+ .disconnect = usb_serial_disconnect,
+ .id_table = quausb2_id_table,
+ .no_dynamic_id = 1,
+};
+
+/* structure in which to keep all the messy stuff that this driver needs
+ * alongside the usb_serial_port structure */
+struct quatech2_port {
+ int magic;
+ char active; /* someone has this device open */
+ unsigned char *xfer_to_tty_buffer;
+ wait_queue_head_t wait;
+ int open_count; /* number of times this port has been opened */
+ struct semaphore sem; /* locks this structure */
+ __u8 shadowLCR; /* last LCR value received */
+ __u8 shadowMCR; /* last MCR value received */
+ __u8 shadowMSR; /* last MSR value received */
+ __u8 shadowLSR; /* last LSR value received */
+ char open_ports; /* ports open on whole device */
+ char RxHolding;
+ char Rcv_Flush;
+ char Xmit_Flush;
+ char closePending;
+ char fifo_empty_flag;
+ int xmit_pending_bytes;
+ int xmit_fifo_room_bytes;
+ struct semaphore pend_xmit_sem; /* locks this structure */
+ spinlock_t lock;
+};
+
+/* structure which holds line and modem status flags */
+struct qt2_status_data {
+ __u8 line_status;
+ __u8 modem_status;
+};
+
+/* Function prototypes */
+static int qt2_boxpoweron(struct usb_serial *serial);
+static int qt2_boxsetQMCR(struct usb_serial *serial, __u16 Uart_Number,
+ __u8 QMCR_Value);
+static int port_paranoia_check(struct usb_serial_port *port,
+ const char *function);
+static int serial_paranoia_check(struct usb_serial *serial,
+ const char *function);
+static inline struct quatech2_port *qt2_get_port_private(struct usb_serial_port
+ *port);
+static inline void qt2_set_port_private(struct usb_serial_port *port,
+ struct quatech2_port *data);
+static int qt2_openboxchannel(struct usb_serial *serial, __u16
+ Uart_Number, struct qt2_status_data *pDeviceData);
+static int qt2_closeboxchannel(struct usb_serial *serial, __u16
+ Uart_Number);
+static int qt2_conf_uart(struct usb_serial *serial, unsigned short Uart_Number,
+ unsigned short divisor, unsigned char LCR);
+/* implementation functions, roughly in order of use, are here */
+static int qt2_calc_num_ports(struct usb_serial *serial)
+{
+ int num_ports;
+ int flag_as_400;
+ switch (serial->dev->descriptor.idProduct) {
+ case QUATECH_SSU2_100:
+ num_ports = 1;
+ break;
+
+ case QUATECH_DSU2_400:
+ flag_as_400 = true;
+ case QUATECH_DSU2_100:
+ num_ports = 2;
+ break;
+
+ case QUATECH_QSU2_400:
+ flag_as_400 = true;
+ case QUATECH_QSU2_100:
+ num_ports = 4;
+ break;
+
+ case QUATECH_ESU2_400:
+ flag_as_400 = true;
+ case QUATECH_ESU2_100:
+ num_ports = 8;
+ break;
+ default:
+ num_ports = 1;
+ break;
+ }
+ return num_ports;
+}
+
+static int qt2_attach(struct usb_serial *serial)
+{
+ struct usb_serial_port *port;
+ struct quatech2_port *qt2_port;
+ int i;
+ /* stuff for printing endpoint addresses, not needed for
+ * production */
+ struct usb_endpoint_descriptor *endpoint;
+ struct usb_host_interface *iface_desc;
+
+ /* check how many endpoints there are on the device, for
+ * sanity's sake */
+ dbg("%s(): Endpoints: %d bulk in, %d bulk out, %d interrupt in",
+ __func__, serial->num_bulk_in,
+ serial->num_bulk_out, serial->num_interrupt_in);
+ if ((serial->num_bulk_in != 1) || (serial->num_bulk_out != 1)) {
+ dbg("Device has wrong number of bulk endpoints!");
+ return -ENODEV;
+ }
+ iface_desc = serial->interface->cur_altsetting;
+ /* print endpoint addresses so we can check them later
+ * by hand */
+ for (i = 0; i < iface_desc->desc.bNumEndpoints; ++i)
+ {
+ endpoint = &iface_desc->endpoint[i].desc;
+
+ if ((endpoint->bEndpointAddress & 0x80) &&
+ ((endpoint->bmAttributes & 3) == 0x02)) {
+ /* we found a bulk in endpoint */
+ dbg("found bulk in at 0x%x",
+ endpoint->bEndpointAddress);
+ }
+
+ if (((endpoint->bEndpointAddress & 0x80) == 0x00) &&
+ ((endpoint->bmAttributes & 3) == 0x02))
+ {
+ /* we found a bulk out endpoint */
+ dbg("found bulk out at 0x%x",
+ endpoint->bEndpointAddress);
+ }
+ } /* end printing endpoint addresses */
+
+ /* Now setup per port private data, which replaces all the things
+ * that quatech added to standard kernel structures in their driver */
+ for (i = 0; i < serial->num_ports; i++) {
+ port = serial->port[i];
+ qt2_port = kzalloc(sizeof(*qt2_port), GFP_KERNEL);
+ if (!qt2_port) {
+ dbg("%s: kmalloc for quatech2_port (%d) failed!.",
+ __func__, i);
+ return -ENOMEM;
+ }
+ spin_lock_init(&qt2_port->lock);
+ if (i == 0)
+ qt2_port->open_ports = 0; /* no ports */
+ else
+ qt2_port->open_ports = -1; /* unused */
+
+ usb_set_serial_port_data(port, qt2_port);
+
+ }
+ /* switch on power to the hardware */
+ if (qt2_boxpoweron(serial) < 0) {
+ dbg("qt2_boxpoweron() failed");
+ goto startup_error;
+ }
+ /* set all ports to RS232 mode */
+ for (i = 0; i < serial->num_ports; ++i) {
+ if (qt2_boxsetQMCR(serial, i, QU2BOX232) < 0) {
+ dbg("qt2_boxsetQMCR() on port %d failed",
+ i);
+ goto startup_error;
+ }
+ }
+
+ return 0;
+
+startup_error:
+ for (i = 0; i < serial->num_ports; i++) {
+ port = serial->port[i];
+ qt2_port = qt2_get_port_private(port);
+ kfree(qt2_port);
+ usb_set_serial_port_data(port, NULL);
+ }
+
+ dbg("Exit fail %s\n", __func__);
+ return -EIO;
+}
+
+static void qt2_release(struct usb_serial *serial)
+{
+ struct usb_serial_port *port;
+ struct quatech2_port *qt_port;
+ int i;
+
+ dbg("enterting %s", __func__);
+
+ for (i = 0; i < serial->num_ports; i++) {
+ port = serial->port[i];
+ if (!port)
+ continue;
+
+ qt_port = usb_get_serial_port_data(port);
+ kfree(qt_port);
+ usb_set_serial_port_data(port, NULL);
+ }
+}
+/* This function is called once per serial port on the device.
+ * The tty_struct and the usb_serial_port belong to this port,
+ * i.e. there are multiple ones for a multi-port device.
+ * However the usb_serial_port structure has a back-pointer
+ * to the parent usb_serial structure which belongs to the device,
+ * so we can access either the device-wide information or
+ * any other port's information (because there are also forward
+ * pointers) via that pointer.
+ * This is most helpful if the device shares resources (e.g. end
+ * points) between different ports
+ */
+int qt2_open(struct tty_struct *tty,
+ struct usb_serial_port *port, struct file *filp)
+{
+ struct usb_serial *serial; /* device structure */
+ struct usb_serial_port *port0; /* first port structure on device */
+ struct quatech2_port *port_extra; /* extra data for this port */
+ struct quatech2_port *port0_extra; /* extra data for first port */
+ struct qt2_status_data ChannelData;
+ unsigned short default_divisor = QU2BOXSPD9600;
+ unsigned char default_LCR = SERIAL_8_DATA;
+ int status;
+
+ if (port_paranoia_check(port, __func__))
+ return -ENODEV;
+
+ dbg("%s - port %d\n", __func__, port->number);
+
+ serial = port->serial; /* get the parent device structure */
+ if (serial_paranoia_check(serial, __func__))
+ return -ENODEV;
+ port0 = serial->port[0]; /* get the first port's device structure */
+
+ port_extra = qt2_get_port_private(port);
+ port0_extra = qt2_get_port_private(port0);
+
+ if (port_extra == NULL || port0_extra == NULL)
+ return -ENODEV;
+
+ usb_clear_halt(serial->dev, port->write_urb->pipe);
+ usb_clear_halt(serial->dev, port->read_urb->pipe);
+ port0_extra->open_ports++;
+
+ /* FIXME: are these needed? Does it even do anything useful? */
+ /* get the modem and line status values from the UART */
+ status = qt2_openboxchannel(serial, port->number,
+ &ChannelData);
+ if (status < 0) {
+ dbg("qt2_openboxchannel on channel %d failed",
+ port->number);
+ return status;
+ }
+ port_extra->shadowLSR = ChannelData.line_status &
+ (SERIAL_LSR_OE | SERIAL_LSR_PE | SERIAL_LSR_FE |
+ SERIAL_LSR_BI);
+
+ port_extra->shadowMSR = ChannelData.modem_status &
+ (SERIAL_MSR_CTS | SERIAL_MSR_DSR | SERIAL_MSR_RI |
+ SERIAL_MSR_CD);
+
+ port_extra->fifo_empty_flag = true;
+ dbg("qt2_openboxchannel on channel %d completed.",
+ port->number);
+
+ /* Set Baud rate to default and turn off flow control here */
+ status = qt2_conf_uart(serial, port->number, default_divisor,
+ default_LCR);
+ if (status < 0) {
+ dbg("qt2_conf_uart() failed on channel %d",
+ port->number);
+ return status;
+ }
+ dbg("qt2_conf_uart() completed on channel %d",
+ port->number);
+
+ dbg("port number is %d", port->number);
+ dbg("serial number is %d", port->serial->minor);
+
+ /* We need to set up endpoints here. We only
+ * have one pair of endpoints per device, so in fact
+ * we only need to set up endpoints on the first time
+ * round, not subsequent ones.
+ * When we do a write to a port, we will use the same endpoint
+ * regardless of the port, with a 5-byte header added on to
+ * tell the box which port it should eventually come out of,
+ * so the same endpoint information needs to be visible to
+ * write calls regardless of which port is being written.
+ * To this end we actually keep the relevant endpoints
+ * in port 0's structure, because that's always there
+ * and avoids providing our own duplicate members in some
+ * user data structure for the same purpose.
+ * URBs will be allocated and freed dynamically as the are
+ * used, so are not touched here.
+ */
+ if (port0_extra->open_ports == 1) {
+ /* this is first port to be opened */
+ }
+
+ 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);
+
+ /* initialize our wait queues */
+ init_waitqueue_head(&port_extra->wait);
+
+ /* remember to store port_extra and port0 back again at end !*/
+ qt2_set_port_private(port, port_extra);
+ qt2_set_port_private(serial->port[0], port0_extra);
+
+ return 0;
+}
+
+/* internal, private helper functions for the driver */
+
+/* Power up the FPGA in the box to get it working */
+static int qt2_boxpoweron(struct usb_serial *serial)
+{
+ int result;
+ __u8 Direcion;
+ unsigned int pipe;
+ Direcion = USBD_TRANSFER_DIRECTION_OUT;
+ pipe = usb_rcvctrlpipe(serial->dev, 0);
+ result = usb_control_msg(serial->dev, pipe, QT_SET_GET_DEVICE,
+ Direcion, QU2BOXPWRON, 0x00, NULL, 0x00,
+ 5000);
+ return result;
+}
+
+/*
+ * qt2_boxsetQMCR Issue a QT_GET_SET_QMCR vendor-spcific request on the
+ * default control pipe. If successful return the number of bytes written,
+ * otherwise return a negative error number of the problem.
+ */
+static int qt2_boxsetQMCR(struct usb_serial *serial, __u16 Uart_Number,
+ __u8 QMCR_Value)
+{
+ int result;
+ __u16 PortSettings;
+
+ PortSettings = (__u16)(QMCR_Value);
+
+ dbg("%s(): Port = %d, PortSettings = 0x%x", __func__,
+ Uart_Number, PortSettings);
+
+ result = usb_control_msg(serial->dev, usb_sndctrlpipe(serial->dev, 0),
+ QT_GET_SET_QMCR, 0x40, PortSettings,
+ (__u16)Uart_Number, NULL, 0, 5000);
+ return result;
+}
+
+static int port_paranoia_check(struct usb_serial_port *port,
+ const char *function)
+{
+ if (!port) {
+ dbg("%s - port == NULL", function);
+ return -1;
+ }
+ if (!port->serial) {
+ dbg("%s - port->serial == NULL\n", function);
+ return -1;
+ }
+ return 0;
+}
+
+static int serial_paranoia_check(struct usb_serial *serial,
+ const char *function)
+{
+ if (!serial) {
+ dbg("%s - serial == NULL\n", function);
+ return -1;
+ }
+
+ if (!serial->type) {
+ dbg("%s - serial->type == NULL!", function);
+ return -1;
+ }
+
+ return 0;
+}
+
+static inline struct quatech2_port *qt2_get_port_private(struct usb_serial_port
+ *port)
+{
+ return (struct quatech2_port *)usb_get_serial_port_data(port);
+}
+
+static inline void qt2_set_port_private(struct usb_serial_port *port,
+ struct quatech2_port *data)
+{
+ usb_set_serial_port_data(port, (void *)data);
+}
+
+static int qt2_openboxchannel(struct usb_serial *serial, __u16
+ Uart_Number, struct qt2_status_data *status)
+{
+ int result;
+ __u16 length;
+ __u8 Direcion;
+ unsigned int pipe;
+ length = sizeof(struct qt2_status_data);
+ Direcion = USBD_TRANSFER_DIRECTION_IN;
+ pipe = usb_rcvctrlpipe(serial->dev, 0);
+ result = usb_control_msg(serial->dev, pipe, QT_OPEN_CLOSE_CHANNEL,
+ Direcion, 0x00, Uart_Number, status, length, 5000);
+ return result;
+}
+static int qt2_closeboxchannel(struct usb_serial *serial, __u16 Uart_Number)
+{
+ int result;
+ __u8 direcion;
+ unsigned int pipe;
+ direcion = USBD_TRANSFER_DIRECTION_OUT;
+ pipe = usb_sndctrlpipe(serial->dev, 0);
+ result = usb_control_msg(serial->dev, pipe, QT_OPEN_CLOSE_CHANNEL,
+ direcion, 0, Uart_Number, NULL, 0, 5000);
+ return result;
+}
+
+/* qt2_conf_uart Issue a SET_UART vendor-spcific request on the default
+ * control pipe. If successful sets baud rate divisor and LCR value
+ */
+static int qt2_conf_uart(struct usb_serial *serial, unsigned short Uart_Number,
+ unsigned short divisor, unsigned char LCR)
+{
+ int result;
+ unsigned short UartNumandLCR;
+
+ UartNumandLCR = (LCR << 8) + Uart_Number;
+
+ result = usb_control_msg(serial->dev, usb_sndctrlpipe(serial->dev, 0),
+ QT_GET_SET_UART, 0x40, divisor, UartNumandLCR,
+ NULL, 0, 300);
+ return result;
+}
+
+/*
+ * last things in file: stuff to register this driver into the generic
+ * USB serial framework.
+ */
+
+static struct usb_serial_driver quatech2_device = {
+ .driver = {
+ .owner = THIS_MODULE,
+ .name = "quatech_usb2",
+ },
+ .description = DRIVER_DESC,
+ .usb_driver = &quausb2_usb_driver,
+ .id_table = quausb2_id_table,
+ .num_ports = 8,
+ .open = qt2_open,
+ /*.close = qt_close,
+ .write = qt_write,
+ .write_room = qt_write_room,
+ .chars_in_buffer = qt_chars_in_buffer,
+ .throttle = qt_throttle,
+ .unthrottle = qt_unthrottle,*/
+ .calc_num_ports = qt2_calc_num_ports,
+ /*.ioctl = qt_ioctl,
+ .set_termios = qt_set_termios,
+ .break_ctl = qt_break,
+ .tiocmget = qt_tiocmget,
+ .tiocmset = qt_tiocmset,*/
+ .attach = qt2_attach,
+ .release = qt2_release,
+};
+
+static int __init quausb2_usb_init(void)
+{
+ int retval;
+
+ dbg("%s\n", __func__);
+
+ /* register with usb-serial */
+ retval = usb_serial_register(&quatech2_device);
+
+ if (retval)
+ goto failed_usb_serial_register;
+
+ printk(KERN_INFO KBUILD_MODNAME ": " DRIVER_VERSION ":"
+ DRIVER_DESC "\n");
+
+ /* register with usb */
+
+ retval = usb_register(&quausb2_usb_driver);
+ if (retval == 0)
+ return 0;
+
+ /* if we're here, usb_register() failed */
+ usb_serial_deregister(&quatech2_device);
+failed_usb_serial_register:
+ return retval;
+}
+
+
+
+static void __exit quausb2_usb_exit(void)
+{
+ usb_deregister(&quausb2_usb_driver);
+ usb_serial_deregister(&quatech2_device);
+}
+
+module_init(quausb2_usb_init);
+module_exit(quausb2_usb_exit);
+
+MODULE_AUTHOR(DRIVER_AUTHOR);
+MODULE_DESCRIPTION(DRIVER_DESC);
+MODULE_LICENSE("GPL");
+
+module_param(debug, bool, S_IRUGO | S_IWUSR);
+MODULE_PARM_DESC(debug, "Debug enabled or not");
diff --git a/drivers/staging/rspiusb/rspiusb.c b/drivers/staging/rspiusb/rspiusb.c
index 1cdfe69585ea..2f8155c1968b 100644
--- a/drivers/staging/rspiusb/rspiusb.c
+++ b/drivers/staging/rspiusb/rspiusb.c
@@ -444,8 +444,7 @@ static void piusb_write_bulk_callback(struct urb *urb)
__func__, status);
pdx->pendingWrite = 0;
- usb_buffer_free(urb->dev, urb->transfer_buffer_length,
- urb->transfer_buffer, urb->transfer_dma);
+ kfree(urb->transfer_buffer);
}
int piusb_output(struct ioctl_struct *io, unsigned char *uBuf, int len,
@@ -457,9 +456,7 @@ int piusb_output(struct ioctl_struct *io, unsigned char *uBuf, int len,
urb = usb_alloc_urb(0, GFP_KERNEL);
if (urb != NULL) {
- kbuf =
- usb_buffer_alloc(pdx->udev, len, GFP_KERNEL,
- &urb->transfer_dma);
+ kbuf = kmalloc(len, GFP_KERNEL);
if (!kbuf) {
dev_err(&pdx->udev->dev, "buffer_alloc failed\n");
return -ENOMEM;
@@ -470,7 +467,6 @@ int piusb_output(struct ioctl_struct *io, unsigned char *uBuf, int len,
}
usb_fill_bulk_urb(urb, pdx->udev, pdx->hEP[io->endpoint], kbuf,
len, piusb_write_bulk_callback, pdx);
- urb->transfer_flags |= URB_NO_TRANSFER_DMA_MAP;
err = usb_submit_urb(urb, GFP_KERNEL);
if (err) {
dev_err(&pdx->udev->dev,
@@ -641,7 +637,7 @@ static int MapUserBuffer(struct ioctl_struct *io, struct device_extension *pdx)
numPagesRequired =
((uaddr & ~PAGE_MASK) + count + ~PAGE_MASK) >> PAGE_SHIFT;
dbg("Number of pages needed = %d", numPagesRequired);
- maplist_p = vmalloc(numPagesRequired * sizeof(struct page));
+ maplist_p = vmalloc(numPagesRequired * sizeof(struct page *));
if (!maplist_p) {
dbg("Can't Allocate Memory for maplist_p");
return -ENOMEM;
@@ -712,9 +708,7 @@ static int MapUserBuffer(struct ioctl_struct *io, struct device_extension *pdx)
usb_fill_bulk_urb(pdx->PixelUrb[frameInfo][i],
pdx->udev,
epAddr,
- (dma_addr_t *) sg_dma_address(&pdx->
- sgl[frameInfo]
- [i]),
+ NULL, // non-DMA HC? buy a better hardware
sg_dma_len(&pdx->sgl[frameInfo][i]),
piusb_readPIXEL_callback, (void *)pdx);
pdx->PixelUrb[frameInfo][i]->transfer_dma =
diff --git a/drivers/staging/rt2860/rt_linux.h b/drivers/staging/rt2860/rt_linux.h
index 85175c182432..426229398b09 100644
--- a/drivers/staging/rt2860/rt_linux.h
+++ b/drivers/staging/rt2860/rt_linux.h
@@ -93,22 +93,23 @@ typedef int (*HARD_START_XMIT_FUNC)(struct sk_buff *skb, struct net_device *net_
// add by kathy
-#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"
-#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
+/* order of "if defined()" is important, because for 3070 driver
+ both RT2870 and RT3070 are defined */
+#if defined(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"
+#elif defined(RT3070)
+ #define STA_PROFILE_PATH "/etc/Wireless/RT3070STA/RT3070STA.dat"
+ #define STA_RT2870_IMAGE_FILE_NAME "/etc/Wireless/RT3070STA/rt2870.bin"
+ #define STA_NIC_DEVICE_NAME "RT3070STA"
+ #define STA_DRIVER_VERSION "2.0.1.0"
+#elif defined(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"
#endif
#ifdef RT2860
diff --git a/drivers/staging/rt2860/rt_main_dev.c b/drivers/staging/rt2860/rt_main_dev.c
index 35c59d5aa99c..8fd1aafc4592 100644
--- a/drivers/staging/rt2860/rt_main_dev.c
+++ b/drivers/staging/rt2860/rt_main_dev.c
@@ -190,7 +190,7 @@ int rt28xx_close(IN PNET_DEV dev)
BOOLEAN Cancelled = FALSE;
UINT32 i = 0;
#ifdef RT2870
- DECLARE_WAIT_QUEUE_HEAD(unlink_wakeup);
+ DECLARE_WAIT_QUEUE_HEAD_ONSTACK(unlink_wakeup);
DECLARE_WAITQUEUE(wait, current);
//RTMP_SET_FLAG(pAd, fRTMP_ADAPTER_REMOVE_IN_PROGRESS);
diff --git a/drivers/staging/rt2860/sta_ioctl.c b/drivers/staging/rt2860/sta_ioctl.c
index eb0109ad2fc0..a4f22dfee573 100644
--- a/drivers/staging/rt2860/sta_ioctl.c
+++ b/drivers/staging/rt2860/sta_ioctl.c
@@ -531,12 +531,7 @@ 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 //
+ strncpy(name, RT28xx_CHIP_NAME " Wireless", IFNAMSIZ);
return 0;
}
diff --git a/drivers/staging/rt2870/2870_main_dev.c b/drivers/staging/rt2870/2870_main_dev.c
index dd01c64fbf61..154b853343b1 100644
--- a/drivers/staging/rt2870/2870_main_dev.c
+++ b/drivers/staging/rt2870/2870_main_dev.c
@@ -45,7 +45,7 @@
// *** 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");
+MODULE_DESCRIPTION(RT28xx_CHIP_NAME " Wireless LAN Linux Driver");
MODULE_LICENSE("GPL");
#ifdef MODULE_VERSION
MODULE_VERSION(STA_DRIVER_VERSION);
@@ -1418,7 +1418,7 @@ VOID RT2870_BssBeaconStart(
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);
+ printk(RT28xx_CHIP_NAME "_BssBeaconStart:BeaconFactor=%d, BeaconRemain=%d!\n", pAd->CommonCfg.BeaconFactor, pAd->CommonCfg.BeaconRemain);
RTMPSetTimer(&pAd->CommonCfg.BeaconUpdateTimer, pAd->CommonCfg.BeaconPeriod);
}
diff --git a/drivers/staging/rt2870/rt2870.h b/drivers/staging/rt2870/rt2870.h
index 5e5b3f2b7eb1..fec2599c9e91 100644
--- a/drivers/staging/rt2870/rt2870.h
+++ b/drivers/staging/rt2870/rt2870.h
@@ -89,6 +89,7 @@
{USB_DEVICE(0x0DF6,0x002C)}, /* Sitecom */ \
{USB_DEVICE(0x0DF6,0x002D)}, /* Sitecom */ \
{USB_DEVICE(0x0DF6,0x0039)}, /* Sitecom */ \
+ {USB_DEVICE(0x0DF6,0x003F)}, /* Sitecom WL-608 */ \
{USB_DEVICE(0x14B2,0x3C06)}, /* Conceptronic */ \
{USB_DEVICE(0x14B2,0x3C28)}, /* Conceptronic */ \
{USB_DEVICE(0x2019,0xED06)}, /* Planex Communications, Inc. */ \
@@ -215,6 +216,7 @@
{USB_DEVICE(0x0789,0x0163)}, /* Logitec 2870 */ \
{USB_DEVICE(0x0789,0x0164)}, /* Logitec 2870 */ \
{USB_DEVICE(0x1EDA,0x2310)}, /* AirTies 3070 */ \
+ {USB_DEVICE(0x1737,0x0077)}, /* Linksys WUSB54GC-EU v3 */ \
{ }/* Terminating entry */ \
}
#endif
@@ -522,7 +524,11 @@ extern UCHAR EpToQueue[6];
{ RTUSB_SET_BULK_FLAG(pAd, fRTUSB_BULK_OUT_PSPOLL); \
RTUSBKickBulkOut(pAd); }
+#ifdef RT30xx
+#define RT28xx_CHIP_NAME "RT3070"
+#else
#define RT28xx_CHIP_NAME "RT2870"
+#endif
#define USB_CYC_CFG 0x02a4
#ifndef RT30xx
#define STATUS_SUCCESS 0x00
diff --git a/drivers/staging/rt3090/Kconfig b/drivers/staging/rt3090/Kconfig
new file mode 100644
index 000000000000..255e8eaa4836
--- /dev/null
+++ b/drivers/staging/rt3090/Kconfig
@@ -0,0 +1,5 @@
+config RT3090
+ tristate "Ralink 3090 wireless support"
+ depends on PCI && X86 && WLAN_80211
+ ---help---
+ This is an experimental driver for the Ralink 3090 wireless chip.
diff --git a/drivers/staging/rt3090/Makefile b/drivers/staging/rt3090/Makefile
new file mode 100644
index 000000000000..995491c91fce
--- /dev/null
+++ b/drivers/staging/rt3090/Makefile
@@ -0,0 +1,80 @@
+obj-$(CONFIG_RT3090) += rt3090sta.o
+
+include drivers/staging/rt3090/config.mk
+
+rt3090sta-objs := \
+ common/crypt_md5.o \
+ common/crypt_sha2.o \
+ common/crypt_hmac.o \
+ common/mlme.o \
+ common/cmm_wep.o \
+ common/action.o \
+ common/cmm_data.o \
+ common/rtmp_init.o \
+ common/cmm_tkip.o \
+ common/cmm_aes.o \
+ common/cmm_sync.o \
+ common/eeprom.o \
+ common/cmm_sanity.o \
+ common/cmm_info.o \
+ common/cmm_cfg.o \
+ common/cmm_wpa.o \
+ common/dfs.o \
+ common/spectrum.o \
+ common/rtmp_timer.o \
+ common/rt_channel.o \
+ common/cmm_profile.o \
+ common/cmm_asic.o \
+ sta/assoc.o \
+ sta/auth.o \
+ sta/auth_rsp.o \
+ sta/sync.o \
+ sta/sanity.o \
+ sta/rtmp_data.o \
+ sta/connect.o \
+ sta/wpa.o \
+ rt_linux.o \
+ rt_profile.o \
+ rt_main_dev.o \
+ sta_ioctl.o
+
+#ifdef DOT11_N_SUPPORT
+ifeq ($(HAS_DOT11_N_SUPPORT),y)
+rt3090sta-objs += \
+ common/ba_action.o
+endif
+#endif // DOT11_N_SUPPORT //
+
+#ifdef ETH_CONVERT
+ifeq ($(HAS_ETH_CONVERT_SUPPORT), y)
+rt3090sta-objs += \
+ common/cmm_mat.o \
+ common/cmm_mat_iparp.o \
+ common/cmm_mat_pppoe.o \
+ common/cmm_mat_ipv6.o
+endif
+#endif // ETH_CONVERT //
+
+ifeq ($(HAS_BLOCK_NET_IF),y)
+rt3090sta-objs += common/netif_block.o
+endif
+
+ifeq ($(HAS_QOS_DLS_SUPPORT),y)
+rt3090sta-objs += sta/dls.o
+endif
+
+rt3090sta-objs += \
+ pci_main_dev.o \
+ rt_pci_rbus.o \
+ common/cmm_mac_pci.o \
+ common/cmm_data_pci.o \
+ common/ee_prom.o \
+ common/ee_efuse.o \
+ common/rtmp_mcu.o \
+ chips/rt30xx.o \
+ common/rt_rf.o \
+ chips/rt3090.o
+
+ifeq ($(HAS_ATE),y)
+rt3090sta-objs += rt_ate.o
+endif
diff --git a/drivers/staging/rt3090/action.h b/drivers/staging/rt3090/action.h
new file mode 100644
index 000000000000..ac0a0a3c5ce4
--- /dev/null
+++ b/drivers/staging/rt3090/action.h
@@ -0,0 +1,66 @@
+/*
+ *************************************************************************
+ * 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__ */
diff --git a/drivers/staging/rt3090/ap.h b/drivers/staging/rt3090/ap.h
new file mode 100644
index 000000000000..e89430381071
--- /dev/null
+++ b/drivers/staging/rt3090/ap.h
@@ -0,0 +1,512 @@
+/*
+ *************************************************************************
+ * 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__
+
+
+// =============================================================
+// 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);
+
+
+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 APCls2errAction(
+ IN PRTMP_ADAPTER pAd,
+ IN ULONG Wcid,
+ IN PHEADER_802_11 pHeader);
+
+// ap_connect.c
+
+
+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,
+ IN PNDIS_802_11_SSID pSsid,
+ IN UCHAR ScanType);
+
+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 WpaStateMachineInit(
+ 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);
+
+
+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);
+
+// 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,
+ OUT 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);
+#if defined(RT30xx) || defined(RT305x)
+VOID EnableAPMIMOPS(
+ IN PRTMP_ADAPTER pAd);
+
+VOID DisableAPMIMOPS(
+ IN PRTMP_ADAPTER pAd);
+#endif
+#endif // __AP_H__
diff --git a/drivers/staging/rt3090/ap_apcli.h b/drivers/staging/rt3090/ap_apcli.h
new file mode 100644
index 000000000000..d363c36b8287
--- /dev/null
+++ b/drivers/staging/rt3090/ap_apcli.h
@@ -0,0 +1,276 @@
+/*
+ *************************************************************************
+ * 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_apcli.h
+
+ Abstract:
+ Miniport generic portion header file
+
+ Revision History:
+ Who When What
+ -------- ---------- ----------------------------------------------
+ Shiang, Fonchi 02-13-2007 created
+*/
+
+#ifndef _AP_APCLI_H_
+#define _AP_APCLI_H_
+
+#ifdef APCLI_SUPPORT
+
+#include "rtmp.h"
+
+#define AUTH_TIMEOUT 300 // unit: msec
+#define ASSOC_TIMEOUT 300 // unit: msec
+//#define JOIN_TIMEOUT 2000 // unit: msec // not used in Ap-client mode, remove it
+#define PROBE_TIMEOUT 1000 // unit: msec
+
+#define APCLI_ROOT_BSSID_GET(pAd, wcid) ((pAd)->MacTab.Content[(wcid)].Addr)
+#define APCLI_IF_UP_CHECK(pAd, ifidx) ((pAd)->ApCfg.ApCliTab[(ifidx)].dev->flags & IFF_UP)
+
+/* sanity check for apidx */
+#define APCLI_MR_APIDX_SANITY_CHECK(idx) \
+{ \
+ if ((idx) >= MAX_APCLI_NUM) \
+ { \
+ (idx) = 0; \
+ DBGPRINT(RT_DEBUG_ERROR, ("%s> Error! apcli-idx > MAX_APCLI_NUM!\n", __FUNCTION__)); \
+ } \
+}
+
+typedef struct _APCLI_MLME_JOIN_REQ_STRUCT {
+ UCHAR Bssid[MAC_ADDR_LEN];
+ UCHAR SsidLen;
+ UCHAR Ssid[MAX_LEN_OF_SSID];
+} APCLI_MLME_JOIN_REQ_STRUCT;
+
+typedef struct _STA_CTRL_JOIN_REQ_STRUCT {
+ USHORT Status;
+} APCLI_CTRL_MSG_STRUCT, *PSTA_CTRL_MSG_STRUCT;
+
+BOOLEAN isValidApCliIf(
+ SHORT ifIndex);
+
+//
+// Private routines in apcli_ctrl.c
+//
+VOID ApCliCtrlStateMachineInit(
+ IN PRTMP_ADAPTER pAd,
+ IN STATE_MACHINE_EX *Sm,
+ OUT STATE_MACHINE_FUNC_EX Trans[]);
+
+//
+// Private routines in apcli_sync.c
+//
+VOID ApCliSyncStateMachineInit(
+ IN PRTMP_ADAPTER pAd,
+ IN STATE_MACHINE_EX *Sm,
+ OUT STATE_MACHINE_FUNC_EX Trans[]);
+
+//
+// Private routines in apcli_auth.c
+//
+VOID ApCliAuthStateMachineInit(
+ IN PRTMP_ADAPTER pAd,
+ IN STATE_MACHINE_EX *Sm,
+ OUT STATE_MACHINE_FUNC_EX Trans[]);
+
+//
+// Private routines in apcli_assoc.c
+//
+VOID ApCliAssocStateMachineInit(
+ IN PRTMP_ADAPTER pAd,
+ IN STATE_MACHINE_EX *Sm,
+ OUT STATE_MACHINE_FUNC_EX Trans[]);
+
+MAC_TABLE_ENTRY *ApCliTableLookUpByWcid(
+ IN PRTMP_ADAPTER pAd,
+ IN UCHAR wcid,
+ IN PUCHAR pAddrs);
+
+
+BOOLEAN ApCliAllowToSendPacket(
+ IN RTMP_ADAPTER *pAd,
+ IN PNDIS_PACKET pPacket,
+ OUT UCHAR *pWcid);
+
+BOOLEAN ApCliValidateRSNIE(
+ IN PRTMP_ADAPTER pAd,
+ IN PEID_STRUCT pEid_ptr,
+ IN USHORT eid_len,
+ IN USHORT idx);
+
+VOID RT28xx_ApCli_Init(
+ IN PRTMP_ADAPTER pAd,
+ IN PNET_DEV pPhyNetDev);
+
+VOID RT28xx_ApCli_Close(
+ IN PRTMP_ADAPTER pAd);
+
+VOID RT28xx_ApCli_Remove(
+ IN PRTMP_ADAPTER pAd);
+
+
+VOID RT28xx_ApCli_Remove(
+ IN PRTMP_ADAPTER ad_p);
+
+INT ApCliIfLookUp(
+ IN PRTMP_ADAPTER pAd,
+ IN PUCHAR pAddr);
+
+INT ApCli_VirtualIF_Open(
+ IN PNET_DEV dev_p);
+
+INT ApCli_VirtualIF_Close(
+ IN PNET_DEV dev_p);
+
+INT ApCli_VirtualIF_PacketSend(
+ IN PNDIS_PACKET skb_p,
+ IN PNET_DEV dev_p);
+
+INT ApCli_VirtualIF_Ioctl(
+ IN PNET_DEV dev_p,
+ IN OUT struct ifreq *rq_p,
+ IN INT cmd);
+
+
+VOID ApCliMgtMacHeaderInit(
+ IN PRTMP_ADAPTER pAd,
+ IN OUT PHEADER_802_11 pHdr80211,
+ IN UCHAR SubType,
+ IN UCHAR ToDs,
+ IN PUCHAR pDA,
+ IN PUCHAR pBssid,
+ IN USHORT ifIndex);
+
+#ifdef DOT11_N_SUPPORT
+BOOLEAN ApCliCheckHt(
+ IN PRTMP_ADAPTER pAd,
+ IN USHORT IfIndex,
+ IN OUT HT_CAPABILITY_IE *pHtCapability,
+ IN OUT ADD_HT_INFO_IE *pAddHtInfo);
+#endif // DOT11_N_SUPPORT //
+
+BOOLEAN ApCliLinkUp(
+ IN PRTMP_ADAPTER pAd,
+ IN UCHAR ifIndex);
+
+VOID ApCliLinkDown(
+ IN PRTMP_ADAPTER pAd,
+ IN UCHAR ifIndex);
+
+VOID ApCliIfUp(
+ IN PRTMP_ADAPTER pAd);
+
+VOID ApCliIfDown(
+ IN PRTMP_ADAPTER pAd);
+
+VOID ApCliIfMonitor(
+ IN PRTMP_ADAPTER pAd);
+
+BOOLEAN ApCliMsgTypeSubst(
+ IN PRTMP_ADAPTER pAd,
+ IN PFRAME_802_11 pFrame,
+ OUT INT *Machine,
+ OUT INT *MsgType);
+
+BOOLEAN preCheckMsgTypeSubset(
+ IN PRTMP_ADAPTER pAd,
+ IN PFRAME_802_11 pFrame,
+ OUT INT *Machine,
+ OUT INT *MsgType);
+
+BOOLEAN ApCliPeerAssocRspSanity(
+ 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);
+
+VOID ApCliPeerPairMsg1Action(
+ IN PRTMP_ADAPTER pAd,
+ IN MAC_TABLE_ENTRY *pEntry,
+ IN MLME_QUEUE_ELEM *Elem);
+
+VOID ApCliPeerPairMsg3Action(
+ IN PRTMP_ADAPTER pAd,
+ IN MAC_TABLE_ENTRY *pEntry,
+ IN MLME_QUEUE_ELEM *Elem);
+
+VOID ApCliPeerGroupMsg1Action(
+ IN PRTMP_ADAPTER pAd,
+ IN MAC_TABLE_ENTRY *pEntry,
+ IN MLME_QUEUE_ELEM *Elem);
+
+BOOLEAN ApCliCheckRSNIE(
+ IN PRTMP_ADAPTER pAd,
+ IN PUCHAR pData,
+ IN UCHAR DataLen,
+ IN MAC_TABLE_ENTRY *pEntry,
+ OUT UCHAR *Offset);
+
+BOOLEAN ApCliParseKeyData(
+ IN PRTMP_ADAPTER pAd,
+ IN PUCHAR pKeyData,
+ IN UCHAR KeyDataLen,
+ IN MAC_TABLE_ENTRY *pEntry,
+ IN UCHAR IfIdx,
+ IN UCHAR bPairewise);
+
+BOOLEAN ApCliHandleRxBroadcastFrame(
+ IN PRTMP_ADAPTER pAd,
+ IN RX_BLK *pRxBlk,
+ IN MAC_TABLE_ENTRY *pEntry,
+ IN UCHAR FromWhichBSSID);
+
+VOID APCliUpdatePairwiseKeyTable(
+ IN PRTMP_ADAPTER pAd,
+ IN UCHAR *KeyRsc,
+ IN MAC_TABLE_ENTRY *pEntry);
+
+BOOLEAN APCliUpdateSharedKeyTable(
+ IN PRTMP_ADAPTER pAd,
+ IN PUCHAR pKey,
+ IN UCHAR KeyLen,
+ IN UCHAR DefaultKeyIdx,
+ IN MAC_TABLE_ENTRY *pEntry);
+
+#endif // APCLI_SUPPORT //
+
+#endif /* _AP_APCLI_H_ */
diff --git a/drivers/staging/rt3090/ap_autoChSel.h b/drivers/staging/rt3090/ap_autoChSel.h
new file mode 100644
index 000000000000..46881ff857ac
--- /dev/null
+++ b/drivers/staging/rt3090/ap_autoChSel.h
@@ -0,0 +1,79 @@
+/*
+ *************************************************************************
+ * 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_autoChSel.h
+
+ Abstract:
+ Miniport generic portion header file
+
+ Revision History:
+ Who When What
+ -------- ---------- ----------------------------------------------
+*/
+
+#include "ap_autoChSel_cmm.h"
+
+#ifndef __AUTOCHSELECT_H__
+#define __AUTOCHSELECT_H__
+
+#ifdef AUTO_CH_SELECT_ENHANCE
+#define AP_AUTO_CH_SEL(__P, __O) New_APAutoSelectChannel((__P), (__O))
+#else
+#define AP_AUTO_CH_SEL(__P, __O) APAutoSelectChannel((__P), (__O))
+#endif
+
+
+ULONG AutoChBssInsertEntry(
+ IN PRTMP_ADAPTER pAd,
+ IN PUCHAR pBssid,
+ IN CHAR Ssid[],
+ IN UCHAR SsidLen,
+ IN UCHAR ChannelNo,
+ IN UCHAR ExtChOffset,
+ 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,
+ IN BOOLEAN Optimal);
+
+UCHAR APAutoSelectChannel(
+ IN PRTMP_ADAPTER pAd,
+ IN BOOLEAN Optimal);
+
+#endif // __AUTOCHSELECT_H__ //
diff --git a/drivers/staging/rt3090/ap_autoChSel_cmm.h b/drivers/staging/rt3090/ap_autoChSel_cmm.h
new file mode 100644
index 000000000000..ad77ec125625
--- /dev/null
+++ b/drivers/staging/rt3090/ap_autoChSel_cmm.h
@@ -0,0 +1,66 @@
+/*
+ *************************************************************************
+ * 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_autoChSel_cmm.h
+
+ Abstract:
+ Miniport generic portion header file
+
+ Revision History:
+ Who When What
+ -------- ---------- ----------------------------------------------
+*/
+
+
+#ifndef __AUTOCHSELECT_CMM_H__
+#define __AUTOCHSELECT_CMM_H__
+
+#define RSSI_TO_DBM_OFFSET 120 // RSSI-115 = dBm
+
+
+typedef struct {
+ ULONG dirtyness[MAX_NUM_OF_CHANNELS+1];
+ ULONG max_rssi[MAX_NUM_OF_CHANNELS+1];
+ ULONG total_rssi[MAX_NUM_OF_CHANNELS+1];
+ UINT32 FalseCCA[MAX_NUM_OF_CHANNELS+1];
+} CHANNELINFO, *PCHANNELINFO;
+
+typedef struct {
+ UCHAR Bssid[MAC_ADDR_LEN];
+ UCHAR SsidLen;
+ CHAR Ssid[MAX_LEN_OF_SSID];
+ UCHAR Channel;
+ UCHAR ExtChOffset;
+ UCHAR Rssi;
+} BSSENTRY, *PBSSENTRY;
+
+typedef struct {
+ UCHAR BssNr;
+ BSSENTRY BssEntry[MAX_LEN_OF_BSS_TABLE];
+} BSSINFO, *PBSSINFO;
+
+#endif // __AUTOCHSELECT_CMM_H__ //
diff --git a/drivers/staging/rt3090/ap_cfg.h b/drivers/staging/rt3090/ap_cfg.h
new file mode 100644
index 000000000000..7c99423900ad
--- /dev/null
+++ b/drivers/staging/rt3090/ap_cfg.h
@@ -0,0 +1,118 @@
+/*
+ *************************************************************************
+ * 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_cfg.h
+
+ Abstract:
+ Miniport generic portion header file
+
+ Revision History:
+ Who When What
+ -------- ---------- ----------------------------------------------
+*/
+#ifndef __AP_CFG_H__
+#define __AP_CFG_H__
+
+
+#include "rt_config.h"
+
+INT RTMPAPPrivIoctlSet(
+ IN RTMP_ADAPTER *pAd,
+ IN struct iwreq *pIoctlCmdStr);
+
+INT RTMPAPPrivIoctlShow(
+ IN RTMP_ADAPTER *pAd,
+ IN struct iwreq *pIoctlCmdStr);
+
+INT RTMPAPSetInformation(
+ IN PRTMP_ADAPTER pAd,
+ IN OUT struct iwreq *rq,
+ IN INT cmd);
+
+INT RTMPAPQueryInformation(
+ IN PRTMP_ADAPTER pAd,
+ IN OUT struct iwreq *rq,
+ IN INT cmd);
+
+VOID RTMPIoctlStatistics(
+ IN PRTMP_ADAPTER pAd,
+ IN struct iwreq *wrq);
+
+VOID RTMPIoctlGetMacTable(
+ IN PRTMP_ADAPTER pAd,
+ IN struct iwreq *wrq);
+
+#ifdef DBG
+VOID RTMPAPIoctlBBP(
+ IN PRTMP_ADAPTER pAdapter,
+ IN struct iwreq *wrq);
+
+VOID RTMPAPIoctlMAC(
+ IN PRTMP_ADAPTER pAdapter,
+ IN struct iwreq *wrq);
+
+VOID RTMPAPIoctlE2PROM(
+ IN PRTMP_ADAPTER pAdapter,
+ IN struct iwreq *wrq);
+
+#ifdef RTMP_RF_RW_SUPPORT
+VOID RTMPAPIoctlRF(
+ IN PRTMP_ADAPTER pAdapter,
+ IN struct iwreq *wrq);
+#endif // RTMP_RF_RW_SUPPORT //
+
+#endif // DBG //
+
+VOID RT28XX_IOCTL_MaxRateGet(
+ IN RTMP_ADAPTER *pAd,
+ IN PHTTRANSMIT_SETTING pHtPhyMode,
+ OUT UINT32 *pRate);
+
+
+#ifdef DOT11_N_SUPPORT
+VOID RTMPIoctlQueryBaTable(
+ IN PRTMP_ADAPTER pAd,
+ IN struct iwreq *wrq);
+#endif // DOT11_N_SUPPORT //
+
+VOID RTMPIoctlStaticWepCopy(
+ IN PRTMP_ADAPTER pAd,
+ IN struct iwreq *wrq);
+
+VOID RTMPIoctlRadiusData(
+ IN PRTMP_ADAPTER pAd,
+ IN struct iwreq *wrq);
+
+VOID RTMPIoctlAddWPAKey(
+ IN PRTMP_ADAPTER pAd,
+ IN struct iwreq *wrq);
+
+VOID RTMPIoctlAddPMKIDCache(
+ IN PRTMP_ADAPTER pAd,
+ IN struct iwreq *wrq);
+
+#endif // __AP_CFG_H__ //
diff --git a/drivers/staging/rt3090/ap_ids.h b/drivers/staging/rt3090/ap_ids.h
new file mode 100644
index 000000000000..cf8797f7f580
--- /dev/null
+++ b/drivers/staging/rt3090/ap_ids.h
@@ -0,0 +1,82 @@
+/*
+ *************************************************************************
+ * 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_ids.h
+
+ Abstract:
+ Miniport generic portion header file
+
+ Revision History:
+ Who When What
+ -------- ---------- ----------------------------------------------
+*/
+
+VOID RTMPIdsPeriodicExec(
+ IN PVOID SystemSpecific1,
+ IN PVOID FunctionContext,
+ IN PVOID SystemSpecific2,
+ IN PVOID SystemSpecific3);
+
+BOOLEAN RTMPSpoofedMgmtDetection(
+ IN PRTMP_ADAPTER pAd,
+ IN PHEADER_802_11 pHeader,
+ IN CHAR Rssi0,
+ IN CHAR Rssi1,
+ IN CHAR Rssi2);
+
+VOID RTMPConflictSsidDetection(
+ IN PRTMP_ADAPTER pAd,
+ IN PUCHAR pSsid,
+ IN UCHAR SsidLen,
+ IN CHAR Rssi0,
+ IN CHAR Rssi1,
+ IN CHAR Rssi2);
+
+BOOLEAN RTMPReplayAttackDetection(
+ IN PRTMP_ADAPTER pAd,
+ IN PUCHAR pAddr2,
+ IN CHAR Rssi0,
+ IN CHAR Rssi1,
+ IN CHAR Rssi2);
+
+VOID RTMPUpdateStaMgmtCounter(
+ IN PRTMP_ADAPTER pAd,
+ IN USHORT type);
+
+VOID RTMPClearAllIdsCounter(
+ IN PRTMP_ADAPTER pAd);
+
+VOID RTMPIdsStart(
+ IN PRTMP_ADAPTER pAd);
+
+VOID RTMPIdsStop(
+ IN PRTMP_ADAPTER pAd);
+
+VOID rtmp_read_ids_from_file(
+ IN PRTMP_ADAPTER pAd,
+ char *tmpbuf,
+ char *buffer);
diff --git a/drivers/staging/rt3090/ap_mbss.h b/drivers/staging/rt3090/ap_mbss.h
new file mode 100644
index 000000000000..f78556c529a8
--- /dev/null
+++ b/drivers/staging/rt3090/ap_mbss.h
@@ -0,0 +1,72 @@
+/*
+ *************************************************************************
+ * 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_mbss.h
+
+ Abstract:
+ Miniport generic portion header file
+
+ Revision History:
+ Who When What
+ -------- ---------- ----------------------------------------------
+*/
+
+#ifndef MODULE_MBSS
+
+#define MBSS_EXTERN extern
+
+#else
+
+#define MBSS_EXTERN
+
+#endif // MODULE_MBSS //
+
+
+/* Public function list */
+MBSS_EXTERN VOID RT28xx_MBSS_Init(
+ IN PRTMP_ADAPTER ad_p,
+ IN PNET_DEV main_dev_p);
+
+MBSS_EXTERN VOID RT28xx_MBSS_Close(
+ IN PRTMP_ADAPTER ad_p);
+
+MBSS_EXTERN VOID RT28xx_MBSS_Remove(
+ IN PRTMP_ADAPTER ad_p);
+
+INT MBSS_VirtualIF_Open(
+ IN PNET_DEV dev_p);
+INT MBSS_VirtualIF_Close(
+ IN PNET_DEV dev_p);
+INT MBSS_VirtualIF_PacketSend(
+ IN PNDIS_PACKET skb_p,
+ IN PNET_DEV dev_p);
+INT MBSS_VirtualIF_Ioctl(
+ IN PNET_DEV dev_p,
+ IN OUT struct ifreq *rq_p,
+ IN INT cmd);
+
+/* End of ap_mbss.h */
diff --git a/drivers/staging/rt3090/ap_uapsd.h b/drivers/staging/rt3090/ap_uapsd.h
new file mode 100644
index 000000000000..d49a9e7500b4
--- /dev/null
+++ b/drivers/staging/rt3090/ap_uapsd.h
@@ -0,0 +1,636 @@
+/*
+ *************************************************************************
+ * 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_uapsd.h
+
+ Abstract:
+ Miniport generic portion header file
+
+ Revision History:
+ Who When What
+ -------- ---------- ----------------------------------------------
+*/
+
+/* only for UAPSD_TIMING_RECORD */
+
+//#define UAPSD_TIMING_RECORD_FUNC
+
+#define UAPSD_TIMING_RECORD_MAX 1000
+#define UAPSD_TIMING_RECORD_DISPLAY_TIMES 10
+
+#define UAPSD_TIMING_RECORD_ISR 1
+#define UAPSD_TIMING_RECORD_TASKLET 2
+#define UAPSD_TIMING_RECORD_TRG_RCV 3
+#define UAPSD_TIMING_RECORD_MOVE2TX 4
+#define UAPSD_TIMING_RECORD_TX2AIR 5
+
+#define UAPSD_TIMING_CTRL_STOP 0
+#define UAPSD_TIMING_CTRL_START 1
+#define UAPSD_TIMING_CTRL_SUSPEND 2
+
+#define UAPSD_TIMESTAMP_GET(__pAd, __TimeStamp) \
+ { \
+ UINT32 __CSR=0; UINT64 __Value64; \
+ RTMP_IO_READ32((__pAd), TSF_TIMER_DW0, &__CSR); \
+ __TimeStamp = (UINT64)__CSR; \
+ RTMP_IO_READ32((__pAd), TSF_TIMER_DW1, &__CSR); \
+ __Value64 = (UINT64)__CSR; \
+ __TimeStamp |= (__Value64 << 32); \
+ }
+
+#ifdef LINUX
+#define UAPSD_TIME_GET(__pAd, __Time) \
+ __Time = jiffies
+#endif // LINUX //
+
+
+#ifdef UAPSD_TIMING_RECORD_FUNC
+#define UAPSD_TIMING_RECORD_START() \
+ UAPSD_TimingRecordCtrl(UAPSD_TIMING_CTRL_START);
+#define UAPSD_TIMING_RECORD_STOP() \
+ UAPSD_TimingRecordCtrl(UAPSD_TIMING_CTRL_STOP);
+#define UAPSD_TIMING_RECORD(__pAd, __Type) \
+ UAPSD_TimingRecord(__pAd, __Type);
+#define UAPSD_TIMING_RECORD_INDEX(__LoopIndex) \
+ UAPSD_TimeingRecordLoopIndex(__LoopIndex);
+#else
+
+#define UAPSD_TIMING_RECORD_START()
+#define UAPSD_TIMING_RECORD_STOP()
+#define UAPSD_TIMING_RECORD(__pAd, __type)
+#define UAPSD_TIMING_RECORD_INDEX(__LoopIndex)
+#endif // UAPSD_TIMING_RECORD_FUNC //
+
+
+#ifndef MODULE_WMM_UAPSD
+
+#define UAPSD_EXTERN extern
+
+/* Public Marco list */
+
+/*
+ Init some parameters in packet structure for QoS Null frame;
+ purpose: is for management frame tx done use
+*/
+#define UAPSD_MR_QOS_NULL_HANDLE(__pAd, __pData, __pPacket) \
+ { \
+ PHEADER_802_11 __pHeader = (PHEADER_802_11)(__pData); \
+ MAC_TABLE_ENTRY *__pEntry; \
+ if (__pHeader->FC.SubType == SUBTYPE_QOS_NULL) \
+ { \
+ RTMP_SET_PACKET_QOS_NULL((__pPacket)); \
+ __pEntry = MacTableLookup((__pAd), __pHeader->Addr1); \
+ if (__pEntry != NULL) \
+ { \
+ RTMP_SET_PACKET_WCID((__pPacket), __pEntry->Aid); \
+ } \
+ } \
+ else \
+ { \
+ RTMP_SET_PACKET_NON_QOS_NULL((__pPacket)); \
+ } \
+ }
+
+/*
+ Init MAC entry UAPSD parameters;
+ purpose: initialize UAPSD PS queue and control parameters
+*/
+#define UAPSD_MR_ENTRY_INIT(__pEntry) \
+ { \
+ UINT16 __IdAc; \
+ for(__IdAc=0; __IdAc<WMM_NUM_OF_AC; __IdAc++) \
+ InitializeQueueHeader(&(__pEntry)->UAPSDQueue[__IdAc]); \
+ (__pEntry)->UAPSDTxNum = 0; \
+ (__pEntry)->pUAPSDEOSPFrame = NULL; \
+ (__pEntry)->bAPSDFlagSPStart = 0; \
+ (__pEntry)->bAPSDFlagEOSPOK = 0; \
+ (__pEntry)->MaxSPLength = 0; \
+ }
+
+/*
+ Reset MAC entry UAPSD parameters;
+ purpose: clean all UAPSD PS queue; release the EOSP frame if exists;
+ reset control parameters
+*/
+#define UAPSD_MR_ENTRY_RESET(__pAd, __pEntry) \
+ { \
+ MAC_TABLE_ENTRY *__pSta; \
+ UINT32 __IdAc; \
+ __pSta = (__pEntry); \
+ /* clear all U-APSD queues */ \
+ for(__IdAc=0; __IdAc<WMM_NUM_OF_AC; __IdAc++) \
+ APCleanupPsQueue((__pAd), &__pSta->UAPSDQueue[__IdAc]); \
+ /* clear EOSP frame */ \
+ __pSta->UAPSDTxNum = 0; \
+ if (__pSta->pUAPSDEOSPFrame != NULL) { \
+ RELEASE_NDIS_PACKET((__pAd), \
+ QUEUE_ENTRY_TO_PACKET(__pSta->pUAPSDEOSPFrame), \
+ NDIS_STATUS_FAILURE); \
+ __pSta->pUAPSDEOSPFrame = NULL; } \
+ __pSta->bAPSDFlagSPStart = 0; \
+ __pSta->bAPSDFlagEOSPOK = 0; }
+
+/*
+ Enable or disable UAPSD flag in WMM element in beacon frame;
+ purpose: set UAPSD enable/disable bit
+*/
+#define UAPSD_MR_IE_FILL(__QosCtrlField, __pAd) \
+ (__QosCtrlField) |= ((__pAd)->CommonCfg.bAPSDCapable) ? 0x80 : 0x00;
+
+/*
+ Check if we do NOT need to control TIM bit for the station;
+ note: we control TIM bit only when all AC are UAPSD AC
+*/
+#define UAPSD_MR_IS_NOT_TIM_BIT_NEEDED_HANDLED(__pMacEntry, __QueIdx) \
+ (CLIENT_STATUS_TEST_FLAG((__pMacEntry), fCLIENT_STATUS_APSD_CAPABLE) && \
+ (!(__pMacEntry)->bAPSDDeliverEnabledPerAC[QID_AC_VO] || \
+ !(__pMacEntry)->bAPSDDeliverEnabledPerAC[QID_AC_VI] || \
+ !(__pMacEntry)->bAPSDDeliverEnabledPerAC[QID_AC_BE] || \
+ !(__pMacEntry)->bAPSDDeliverEnabledPerAC[QID_AC_BK]) && \
+ (__pMacEntry)->bAPSDDeliverEnabledPerAC[__QueIdx])
+
+/* check if the AC is UAPSD delivery-enabled AC */
+#define UAPSD_MR_IS_UAPSD_AC(__pMacEntry, __AcId) \
+ (CLIENT_STATUS_TEST_FLAG((__pMacEntry), fCLIENT_STATUS_APSD_CAPABLE) && \
+ ((0 <= (__AcId)) && ((__AcId) < WMM_NUM_OF_AC)) && /* 0 ~ 3 */ \
+ (__pMacEntry)->bAPSDDeliverEnabledPerAC[(__AcId)])
+
+/* check if all AC are UAPSD delivery-enabled AC */
+#define UAPSD_MR_IS_ALL_AC_UAPSD(__FlgIsActive, __pMacEntry) \
+ (((__FlgIsActive) == FALSE) && ((__pMacEntry)->bAPSDAllAC == 1))
+
+/* suspend SP */
+#define UAPSD_MR_SP_SUSPEND(__pAd) \
+ (__pAd)->bAPSDFlagSPSuspend = 1;
+
+/* resume SP */
+#define UAPSD_MR_SP_RESUME(__pAd) \
+ (__pAd)->bAPSDFlagSPSuspend = 0;
+
+/* mark PS poll frame sent in mix mode */
+#ifdef RTMP_MAC_PCI
+/*
+ Note:
+ (1) When SP is not started, try to mark a flag to record if the legacy ps
+ packet is handled in statistics handler;
+ (2) When SP is started, increase the UAPSD count number for the legacy PS.
+*/
+#define UAPSD_MR_MIX_PS_POLL_RCV(__pAd, __pMacEntry) \
+ if ((__pMacEntry)->bAPSDFlagSpRoughUse == 0) \
+ { \
+ if ((__pMacEntry)->bAPSDFlagSPStart == 0) \
+ { \
+ if ((__pMacEntry)->bAPSDFlagLegacySent == 1) \
+ NICUpdateFifoStaCounters((__pAd)); \
+ (__pMacEntry)->bAPSDFlagLegacySent = 1; \
+ } \
+ else \
+ { \
+ (__pMacEntry)->UAPSDTxNum ++; \
+ } \
+ }
+#endif // RTMP_MAC_PCI //
+
+
+#else
+
+#define UAPSD_EXTERN
+#define UAPSD_QOS_NULL_QUE_ID 0x7f
+
+#ifdef RTMP_MAC_PCI
+/*
+ In RT2870, FIFO counter is for all stations, not for per-entry,
+ so we can not use accurate method in RT2870
+*/
+
+/*
+ Note for SP ACCURATE Mechanism:
+ 1. When traffic is busy for the PS station
+ Statistics FIFO counter maybe overflow before we read it, so UAPSD
+ counting mechanism will not accurately.
+
+ Solution:
+ We need to avoid the worse case so we suggest a maximum interval for
+ a SP that the interval between last frame from QAP and data frame from
+ QSTA is larger than UAPSD_EPT_SP_INT.
+
+ 2. When traffic use CCK/1Mbps from QAP
+ Statistics FIFO will not count the packet. There are 2 cases:
+ (1) We force to downgrage ARP response & DHCP packet to 1Mbps;
+ (2) After rate switch mechanism, tx rate is fixed to 1Mbps.
+
+ Solution:
+ Use old DMA UAPSD mechanism.
+
+ 3. When part of AC uses legacy PS mode
+ Statistics count will inclue packet statistics for legacy PS packets
+ so we can not know which one is UAPSD, which one is legacy.
+
+ Solution:
+ Cound the legacy PS packet.
+
+ 4. Check FIFO statistics count in Rx Done function
+ We can not to check TX FIFO statistics count in Rx Done function or
+ the real packet tx/rx sequence will be disarranged.
+
+ Solution:
+ Suspend SP handle before rx done and resume SP handle after rx done.
+*/
+#define UAPSD_SP_ACCURATE /* use more accurate method to send EOSP */
+#endif // RTMP_MAC_PCI //
+
+#define UAPSD_EPT_SP_INT (100000/(1000000/OS_HZ)) /* 100ms */
+
+#endif // MODULE_WMM_UAPSD //
+
+
+/* max UAPSD buffer queue size */
+#define MAX_PACKETS_IN_UAPSD_QUEUE 16 /* for each AC = 16*4 = 64 */
+
+
+/* Public function list */
+/*
+========================================================================
+Routine Description:
+ UAPSD Module Init.
+
+Arguments:
+ pAd Pointer to our adapter
+
+Return Value:
+ None
+
+Note:
+========================================================================
+*/
+UAPSD_EXTERN VOID UAPSD_Init(
+ IN PRTMP_ADAPTER pAd);
+
+
+/*
+========================================================================
+Routine Description:
+ UAPSD Module Release.
+
+Arguments:
+ pAd Pointer to our adapter
+
+Return Value:
+ None
+
+Note:
+========================================================================
+*/
+UAPSD_EXTERN VOID UAPSD_Release(
+ IN PRTMP_ADAPTER pAd);
+
+
+/*
+========================================================================
+Routine Description:
+ Free all EOSP frames and close all SP.
+
+Arguments:
+ pAd Pointer to our adapter
+
+Return Value:
+ None
+
+Note:
+========================================================================
+*/
+UAPSD_EXTERN VOID UAPSD_FreeAll(
+ IN PRTMP_ADAPTER pAd);
+
+
+/*
+========================================================================
+Routine Description:
+ Close current Service Period.
+
+Arguments:
+ pAd Pointer to our adapter
+ pEntry Close the SP of the entry
+
+Return Value:
+ None
+
+Note:
+========================================================================
+*/
+UAPSD_EXTERN VOID UAPSD_SP_Close(
+ IN PRTMP_ADAPTER pAd,
+ IN MAC_TABLE_ENTRY *pEntry);
+
+
+/*
+========================================================================
+Routine Description:
+ Deliver all queued packets.
+
+Arguments:
+ pAd Pointer to our adapter
+ *pEntry STATION
+
+Return Value:
+ None
+
+Note:
+ SMP protection by caller for packet enqueue.
+========================================================================
+*/
+UAPSD_EXTERN VOID UAPSD_AllPacketDeliver(
+ IN PRTMP_ADAPTER pAd,
+ IN MAC_TABLE_ENTRY *pEntry);
+
+
+/*
+========================================================================
+Routine Description:
+ Parse the UAPSD field in WMM element in (re)association request frame.
+
+Arguments:
+ pAd Pointer to our adapter
+ *pEntry STATION
+ *pElm QoS information field
+
+Return Value:
+ None
+
+Note:
+ No protection is needed.
+
+ 1. Association -> TSPEC:
+ use static UAPSD settings in Association
+ update UAPSD settings in TSPEC
+
+ 2. Association -> TSPEC(11r) -> Reassociation:
+ update UAPSD settings in TSPEC
+ backup static UAPSD settings in Reassociation
+
+ 3. Association -> Reassociation:
+ update UAPSD settings in TSPEC
+ backup static UAPSD settings in Reassociation
+========================================================================
+*/
+UAPSD_EXTERN VOID UAPSD_AssocParse(
+ IN PRTMP_ADAPTER pAd,
+ IN MAC_TABLE_ENTRY *pEntry,
+ IN UCHAR *pElm);
+
+
+/*
+========================================================================
+Routine Description:
+ Enqueue a UAPSD packet.
+
+Arguments:
+ pAd Pointer to our adapter
+ *pEntry STATION
+ pPacket UAPSD dnlink packet
+ IdAc UAPSD AC ID (0 ~ 3)
+
+Return Value:
+ None
+
+Note:
+========================================================================
+*/
+UAPSD_EXTERN VOID UAPSD_PacketEnqueue(
+ IN PRTMP_ADAPTER pAd,
+ IN MAC_TABLE_ENTRY *pEntry,
+ IN PNDIS_PACKET pPacket,
+ IN UINT32 IdAc);
+
+
+/*
+========================================================================
+Routine Description:
+ Handle QoS Null Frame Tx Done or Management Tx Done interrupt.
+
+Arguments:
+ pAd Pointer to our adapter
+ pPacket Completed TX packet
+ pDstMac Destinated MAC address
+
+Return Value:
+ None
+
+Note:
+========================================================================
+*/
+UAPSD_EXTERN VOID UAPSD_QoSNullTxMgmtTxDoneHandle(
+ IN PRTMP_ADAPTER pAd,
+ IN PNDIS_PACKET pPacket,
+ IN UCHAR *pDstMac);
+
+
+/*
+========================================================================
+Routine Description:
+ Maintenance our UAPSD PS queue. Release all queued packet if timeout.
+
+Arguments:
+ pAd Pointer to our adapter
+ *pEntry STATION
+
+Return Value:
+ None
+
+Note:
+ If in RT2870, pEntry can not be removed during UAPSD_QueueMaintenance()
+========================================================================
+*/
+UAPSD_EXTERN VOID UAPSD_QueueMaintenance(
+ IN PRTMP_ADAPTER pAd,
+ IN MAC_TABLE_ENTRY *pEntry);
+
+
+/*
+========================================================================
+Routine Description:
+ Close SP in Tx Done, not Tx DMA Done.
+
+Arguments:
+ pAd Pointer to our adapter
+ pEntry destination entry
+ FlgSuccess 0:tx success, 1:tx fail
+
+Return Value:
+ None
+
+Note:
+ For RT28xx series, for packetID=0 or multicast frame, no statistics
+ count can be got, ex: ARP response or DHCP packets, we will use
+ low rate to set (CCK, MCS=0=packetID).
+ So SP will not be close until UAPSD_EPT_SP_INT timeout.
+
+ So if the tx rate is 1Mbps for a entry, we will use DMA done, not
+ use UAPSD_SP_AUE_Handle().
+========================================================================
+*/
+UAPSD_EXTERN VOID UAPSD_SP_AUE_Handle(
+ IN RTMP_ADAPTER *pAd,
+ IN MAC_TABLE_ENTRY *pEntry,
+ IN UCHAR FlgSuccess);
+
+
+/*
+========================================================================
+Routine Description:
+ Close current Service Period.
+
+Arguments:
+ pAd Pointer to our adapter
+
+Return Value:
+ None
+
+Note:
+ When we receive EOSP frame tx done interrupt and a uplink packet
+ from the station simultaneously, we will regard it as a new trigger
+ frame because the packet is received when EOSP frame tx done interrupt.
+
+ We can not sure the uplink packet is sent after old SP or in the old SP.
+ So we must close the old SP in receive done ISR to avoid the problem.
+========================================================================
+*/
+UAPSD_EXTERN VOID UAPSD_SP_CloseInRVDone(
+ IN PRTMP_ADAPTER pAd);
+
+
+/*
+========================================================================
+Routine Description:
+ Check if we need to close current SP.
+
+Arguments:
+ pAd Pointer to our adapter
+ pPacket Completed TX packet
+ pDstMac Destinated MAC address
+
+Return Value:
+ None
+
+Note:
+ 1. We need to call the function in TxDone ISR.
+ 2. SMP protection by caller for packet enqueue.
+========================================================================
+*/
+UAPSD_EXTERN VOID UAPSD_SP_PacketCheck(
+ IN PRTMP_ADAPTER pAd,
+ IN PNDIS_PACKET pPacket,
+ IN UCHAR *pDstMac);
+
+
+#ifdef UAPSD_TIMING_RECORD_FUNC
+/*
+========================================================================
+Routine Description:
+ Enable/Disable Timing Record Function.
+
+Arguments:
+ pAd Pointer to our adapter
+ Flag 1 (Enable) or 0 (Disable)
+
+Return Value:
+ None
+
+Note:
+========================================================================
+*/
+UAPSD_EXTERN VOID UAPSD_TimingRecordCtrl(
+ IN UINT32 Flag);
+
+/*
+========================================================================
+Routine Description:
+ Record some timings.
+
+Arguments:
+ pAd Pointer to our adapter
+ Type The timing is for what type
+
+Return Value:
+ None
+
+Note:
+ UAPSD_TIMING_RECORD_ISR
+ UAPSD_TIMING_RECORD_TASKLET
+ UAPSD_TIMING_RECORD_TRG_RCV
+ UAPSD_TIMING_RECORD_MOVE2TX
+ UAPSD_TIMING_RECORD_TX2AIR
+========================================================================
+*/
+UAPSD_EXTERN VOID UAPSD_TimingRecord(
+ IN PRTMP_ADAPTER pAd,
+ IN UINT32 Type);
+
+/*
+========================================================================
+Routine Description:
+ Record the loop index for received packet handle.
+
+Arguments:
+ pAd Pointer to our adapter
+ LoopIndex The RxProcessed in APRxDoneInterruptHandle()
+
+Return Value:
+ None
+
+Note:
+========================================================================
+*/
+UAPSD_EXTERN VOID UAPSD_TimeingRecordLoopIndex(
+ IN UINT32 LoopIndex);
+#endif // UAPSD_TIMING_RECORD_FUNC //
+
+
+/*
+========================================================================
+Routine Description:
+ Handle UAPSD Trigger Frame.
+
+Arguments:
+ pAd Pointer to our adapter
+ *pEntry the source STATION
+ UpOfFrame the UP of the trigger frame
+
+Return Value:
+ None
+
+Note:
+========================================================================
+*/
+UAPSD_EXTERN VOID UAPSD_TriggerFrameHandle(
+ IN PRTMP_ADAPTER pAd,
+ IN MAC_TABLE_ENTRY *pEntry,
+ IN UCHAR UpOfFrame);
+
+
+
+/* End of ap_uapsd.h */
diff --git a/drivers/staging/rt3090/ap_wds.h b/drivers/staging/rt3090/ap_wds.h
new file mode 100644
index 000000000000..efcb107db4ff
--- /dev/null
+++ b/drivers/staging/rt3090/ap_wds.h
@@ -0,0 +1,212 @@
+/*
+ *************************************************************************
+ * 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_cfg.h
+
+ Abstract:
+ Miniport generic portion header file
+
+ Revision History:
+ Who When What
+ -------- ---------- ----------------------------------------------
+ Fonchi 02-13-2007 created
+*/
+
+#ifndef _AP_WDS_H_
+#define _AP_WDS_H_
+
+#define WDS_ENTRY_RETRY_INTERVAL (100 * OS_HZ / 1000)
+
+
+static inline BOOLEAN WDS_IF_UP_CHECK(
+ IN PRTMP_ADAPTER pAd,
+ IN ULONG ifidx)
+{
+ if ((pAd->flg_wds_init != TRUE) ||
+ (ifidx >= MAX_WDS_ENTRY))
+ return FALSE;
+
+// if (pAd->WdsTab.WdsEntry[ifidx].dev->flags & IFF_UP)
+// Patch for wds ,when dirver call apmlmeperiod => APMlmeDynamicTxRateSwitching check if wds device ready
+if ((pAd->WdsTab.WdsEntry[ifidx].dev != NULL) && (pAd->WdsTab.WdsEntry[ifidx].dev->flags & IFF_UP))
+ return TRUE;
+
+ return FALSE;
+}
+
+LONG WdsEntryAlloc(
+ IN PRTMP_ADAPTER pAd,
+ IN PUCHAR pAddr);
+
+VOID WdsEntryDel(
+ IN PRTMP_ADAPTER pAd,
+ IN PUCHAR pAddr);
+
+MAC_TABLE_ENTRY *MacTableInsertWDSEntry(
+ IN PRTMP_ADAPTER pAd,
+ IN PUCHAR pAddr,
+ UINT WdsTabIdx);
+
+BOOLEAN MacTableDeleteWDSEntry(
+ IN PRTMP_ADAPTER pAd,
+ IN USHORT wcid,
+ IN PUCHAR pAddr);
+
+
+BOOLEAN ApWdsAllowToSendPacket(
+ IN RTMP_ADAPTER *pAd,
+ IN PNDIS_PACKET pPacket,
+ OUT UCHAR *pWcid);
+
+MAC_TABLE_ENTRY *WdsTableLookupByWcid(
+ IN PRTMP_ADAPTER pAd,
+ IN UCHAR wcid,
+ IN PUCHAR pAddr,
+ IN BOOLEAN bResetIdelCount);
+
+MAC_TABLE_ENTRY *WdsTableLookup(
+ IN PRTMP_ADAPTER pAd,
+ IN PUCHAR pAddr,
+ IN BOOLEAN bResetIdelCount);
+
+MAC_TABLE_ENTRY *FindWdsEntry(
+ IN PRTMP_ADAPTER pAd,
+ IN UCHAR Wcid,
+ IN PUCHAR pAddr,
+ IN UINT32 PhyMode);
+
+VOID WdsTableMaintenance(
+ IN PRTMP_ADAPTER pAd);
+
+VOID RT28xx_WDS_Init(
+ IN PRTMP_ADAPTER pAd,
+ IN PNET_DEV net_dev);
+
+VOID RT28xx_WDS_Close(
+ IN PRTMP_ADAPTER pAd);
+
+VOID RT28xx_WDS_Remove(
+ IN PRTMP_ADAPTER pAd);
+
+VOID WdsDown(
+ IN PRTMP_ADAPTER pAd);
+
+VOID AsicUpdateWdsRxWCIDTable(
+ IN PRTMP_ADAPTER pAd);
+
+VOID AsicUpdateWdsEncryption(
+ IN PRTMP_ADAPTER pAd,
+ IN UCHAR wcid);
+
+VOID WdsPeerBeaconProc(
+ IN PRTMP_ADAPTER pAd,
+ IN PMAC_TABLE_ENTRY pEntry,
+ IN USHORT CapabilityInfo,
+ IN UCHAR MaxSupportedRateIn500Kbps,
+ IN UCHAR MaxSupportedRateLen,
+ IN BOOLEAN bWmmCapable,
+ IN ULONG ClientRalinkIe,
+ IN HT_CAPABILITY_IE *pHtCapability,
+ IN UCHAR HtCapabilityLen);
+
+VOID APWdsInitialize(
+ IN PRTMP_ADAPTER pAd);
+
+INT Show_WdsTable_Proc(
+ IN PRTMP_ADAPTER pAd,
+ IN PSTRING arg);
+
+VOID rtmp_read_wds_from_file(
+ IN PRTMP_ADAPTER pAd,
+ PSTRING tmpbuf,
+ PSTRING buffer);
+
+VOID WdsPrepareWepKeyFromMainBss(
+ IN PRTMP_ADAPTER pAd);
+
+INT WdsVirtualIFSendPackets(
+ IN PNDIS_PACKET pSkb,
+ IN PNET_DEV dev);
+
+INT WdsVirtualIF_open(
+ IN PNET_DEV dev);
+
+INT WdsVirtualIF_close(
+ IN PNET_DEV dev);
+
+INT WdsVirtualIF_ioctl(
+ IN PNET_DEV net_dev,
+ IN OUT struct ifreq *rq,
+ IN INT cmd);
+
+/*
+ ==========================================================================
+ Description:
+ Check the WDS Entry is valid or not.
+ ==========================================================================
+ */
+static inline BOOLEAN ValidWdsEntry(
+ IN PRTMP_ADAPTER pAd,
+ IN UCHAR WdsIndex)
+{
+ BOOLEAN result;
+ PMAC_TABLE_ENTRY pMacEntry;
+
+ do
+ {
+ if (WdsIndex >= MAX_WDS_ENTRY)
+ {
+ result = FALSE;
+ break;
+ }
+
+ if (pAd->WdsTab.WdsEntry[WdsIndex].Valid != TRUE)
+ {
+ result = FALSE;
+ break;
+ }
+
+ if ((pAd->WdsTab.WdsEntry[WdsIndex].MacTabMatchWCID==0)
+ || (pAd->WdsTab.WdsEntry[WdsIndex].MacTabMatchWCID >= MAX_LEN_OF_MAC_TABLE))
+ {
+ result = FALSE;
+ break;
+ }
+
+ pMacEntry = &pAd->MacTab.Content[pAd->WdsTab.WdsEntry[WdsIndex].MacTabMatchWCID];
+ if (pMacEntry->ValidAsWDS != TRUE)
+ {
+ result = FALSE;
+ break;
+ }
+
+ result = TRUE;
+ } while(FALSE);
+
+ return result;
+}
+#endif // _AP_WDS_H_ //
diff --git a/drivers/staging/rt3090/chips/rt3090.c b/drivers/staging/rt3090/chips/rt3090.c
new file mode 100644
index 000000000000..35c549dc4ce1
--- /dev/null
+++ b/drivers/staging/rt3090/chips/rt3090.c
@@ -0,0 +1,123 @@
+/*
+ *************************************************************************
+ * 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:
+ rt3090.c
+
+ Abstract:
+ Specific funcitons and variables for RT3070
+
+ Revision History:
+ Who When What
+ -------- ---------- ----------------------------------------------
+*/
+
+#ifdef RT3090
+
+#include "../rt_config.h"
+
+
+#ifndef RTMP_RF_RW_SUPPORT
+#error "You Should Enable compile flag RTMP_RF_RW_SUPPORT for this chip"
+#endif // RTMP_RF_RW_SUPPORT //
+
+
+VOID NICInitRT3090RFRegisters(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_RT3090(pAd))
+ {
+ // Init RF calibration
+ // Driver should toggle RF R30 bit7 before init RF registers
+ UINT32 RfReg = 0, 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);
+
+ // init R24, R31
+ RT30xxWriteRFRegister(pAd, RF_R24, 0x0F);
+ RT30xxWriteRFRegister(pAd, RF_R31, 0x0F);
+
+ // RT309x 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, &data);
+ data = ((data & 0xE0FFFFFF) | 0x0D000000);
+ RTMP_IO_WRITE32(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
+ RTMP_IO_READ32(pAd, GPIO_SWITCH, &data);
+ data &= ~(0x20);
+ RTMP_IO_WRITE32(pAd, GPIO_SWITCH, data);
+
+ // 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);
+ }
+
+ // Driver should set RF R6 bit6 on before calibration
+ RT30xxReadRFRegister(pAd, RF_R06, (PUCHAR)&RfReg);
+ RfReg |= 0x40;
+ RT30xxWriteRFRegister(pAd, RF_R06, (UCHAR)RfReg);
+
+ //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
+ RTMP_IO_READ32(pAd, OPT_14, &data);
+ data |= 0x01;
+ RTMP_IO_WRITE32(pAd, OPT_14, data);
+
+ // set default antenna as main
+ if (pAd->RfIcType == RFIC_3020)
+ AsicSetRxAnt(pAd, pAd->RxAnt.Pair1PrimaryRxAnt);
+
+ // add by johnli, RF power sequence setup, load RF normal operation-mode setup
+ RT30xxLoadRFNormalModeSetup(pAd);
+ }
+
+}
+
+#endif // RT3090 //
diff --git a/drivers/staging/rt3090/chips/rt30xx.c b/drivers/staging/rt3090/chips/rt30xx.c
new file mode 100644
index 000000000000..9c8ae009dff9
--- /dev/null
+++ b/drivers/staging/rt3090/chips/rt30xx.c
@@ -0,0 +1,525 @@
+/*
+ *************************************************************************
+ * 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:
+ rt30xx.c
+
+ Abstract:
+ Specific funcitons and variables for RT30xx.
+
+ Revision History:
+ Who When What
+ -------- ---------- ----------------------------------------------
+*/
+
+
+#ifdef RT30xx
+
+
+#ifndef RTMP_RF_RW_SUPPORT
+#error "You Should Enable compile flag RTMP_RF_RW_SUPPORT for this chip"
+#endif // RTMP_RF_RW_SUPPORT //
+
+#include "../rt_config.h"
+
+
+//
+// RF register initialization set
+//
+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},
+};
+
+UCHAR NUM_RF_REG_PARMS = (sizeof(RT30xx_RFRegTable) / sizeof(REG_PAIR));
+
+
+
+// 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
+// The original name of this function is AsicSetRxAnt(), now change to
+//VOID AsicSetRxAnt(
+VOID RT30xxSetRxAnt(
+ IN PRTMP_ADAPTER pAd,
+ IN UCHAR Ant)
+{
+ 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
+#ifdef RTMP_MAC_PCI
+ RTMP_IO_READ32(pAd, E2PROM_CSR, &x);
+ x |= (EESK);
+ RTMP_IO_WRITE32(pAd, E2PROM_CSR, x);
+#else
+ AsicSendCommandToMcu(pAd, 0x73, 0xFF, 0x1, 0x0);
+#endif // RTMP_MAC_PCI //
+
+ 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
+#ifdef RTMP_MAC_PCI
+ RTMP_IO_READ32(pAd, E2PROM_CSR, &x);
+ x &= ~(EESK);
+ RTMP_IO_WRITE32(pAd, E2PROM_CSR, x);
+#else
+ AsicSendCommandToMcu(pAd, 0x73, 0xFF, 0x0, 0x0);
+#endif // RTMP_MAC_PCI //
+ 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"));
+ }
+}
+
+
+/*
+ ========================================================================
+
+ 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) || IS_RT3572(pAd)|| IS_RT3390(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) || IS_RT3572(pAd)|| IS_RT3390(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));
+}
+
+
+// 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);
+
+ /* move to NICInitRT30xxRFRegisters
+ // 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;
+ }
+ // set RF_R17_bit[2:0] equal to EEPROM setting at 0x48h
+ if (pAd->TxMixerGain24G >= 2)
+ {
+ RFValue &= (~0x7); // clean bit [2:0]
+ RFValue |= pAd->TxMixerGain24G;
+ }
+ 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);
+
+ /* add by johnli, reset RF_R27 when interface down & up to fix throughput problem*/
+ // LDORF_VC, RF R27 register Bit 2 to 0
+ RT30xxReadRFRegister(pAd, RF_R27, &RFValue);
+ // TX to RX IQ glitch(RF_R27) has been fixed in RT3070(F).
+ // Raising RF voltage is no longer needed for RT3070(F)
+ if (IS_RT3090(pAd)) // RT309x and RT3071/72
+ {
+ 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);
+ }
+
+ if (IS_RT3090(pAd) || // IS_RT3090 including RT309x and RT3071/72
+ IS_RT3572(pAd) ||
+ (IS_RT3070(pAd) && ((pAd->MACVersion & 0xffff) < 0x0201)))
+ {
+ {
+ 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);
+ }
+
+ if (IS_RT3090(pAd) || // IS_RT3090 including RT309x and RT3071/72
+ IS_RT3572(pAd) ||
+ IS_RT3390(pAd) ||
+ (IS_RT3070(pAd) && ((pAd->MACVersion & 0xffff) < 0x0201)))
+ {
+ {
+ 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);
+ }
+ }
+
+ if(IS_RT3572(pAd))
+ RT30xxWriteRFRegister(pAd, RF_R08, 0x80);
+}
+// end johnli
+
+VOID RT30xxHaltAction(
+ IN PRTMP_ADAPTER pAd)
+{
+ UINT32 TxPinCfg = 0x00050F0F;
+
+ //
+ // Turn off LNA_PE or TRSW_POL
+ //
+ if (IS_RT3070(pAd) || IS_RT3071(pAd) || IS_RT3572(pAd))
+ {
+ if ((IS_RT3071(pAd) || IS_RT3572(pAd))
+#ifdef RTMP_EFUSE_SUPPORT
+ && (pAd->bUseEfuse)
+#endif // RTMP_EFUSE_SUPPORT //
+ )
+ {
+ TxPinCfg &= 0xFFFBF0F0; // bit18 off
+ }
+ else
+ {
+ TxPinCfg &= 0xFFFFF0F0;
+ }
+
+ RTMP_IO_WRITE32(pAd, TX_PIN_CFG, TxPinCfg);
+ }
+}
+
+#endif // RT30xx //
diff --git a/drivers/staging/rt3090/chips/rt3370.c b/drivers/staging/rt3090/chips/rt3370.c
new file mode 100644
index 000000000000..38ecb0623424
--- /dev/null
+++ b/drivers/staging/rt3090/chips/rt3370.c
@@ -0,0 +1,121 @@
+/*
+ *************************************************************************
+ * 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:
+ rt3370.c
+
+ Abstract:
+ Specific funcitons and variables for RT30xx.
+
+ Revision History:
+ Who When What
+ -------- ---------- ----------------------------------------------
+*/
+
+#ifdef RT3370
+
+#include "../rt_config.h"
+
+
+#ifndef RTMP_RF_RW_SUPPORT
+#error "You Should Enable compile flag RTMP_RF_RW_SUPPORT for this chip"
+#endif // RTMP_RF_RW_SUPPORT //
+
+
+VOID NICInitRT3370RFRegisters(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_RT3090(pAd)||IS_RT3390(pAd)||IS_RT3572(pAd))
+ {
+ // Init RF calibration
+ // Driver should toggle RF R30 bit7 before init RF registers
+ UINT32 RfReg = 0, 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);
+
+ // init R24, R31
+ RT30xxWriteRFRegister(pAd, RF_R24, 0x0F);
+ RT30xxWriteRFRegister(pAd, RF_R31, 0x0F);
+
+ if (IS_RT3390(pAd))
+ {
+ // patch LNA_PE_G1 failed issue
+ RTMP_IO_READ32(pAd, GPIO_SWITCH, &data);
+ data &= ~(0x20);
+ RTMP_IO_WRITE32(pAd, GPIO_SWITCH, data);
+
+ // RF registers initialization
+ for (i = 0; i < NUM_RF_REG_PARMS_OVER_RT3390; i++)
+ {
+ RT30xxWriteRFRegister(pAd, RFRegTableOverRT3390[i].Register, RFRegTableOverRT3390[i].Value);
+ }
+ }
+
+ // patch LNA_PE_G1 failed issue
+ RTMP_IO_READ32(pAd, GPIO_SWITCH, &data);
+ data &= ~(0x20);
+ RTMP_IO_WRITE32(pAd, GPIO_SWITCH, data);
+
+ // Initialize RF register to default value
+ for (i = 0; i < NUM_RF_REG_PARMS_OVER_RT3390; i++)
+ {
+ RT30xxWriteRFRegister(pAd, RT30xx_RFRegTable[i].Register, RT30xx_RFRegTable[i].Value);
+ }
+
+ // Driver should set RF R6 bit6 on before calibration
+ RT30xxReadRFRegister(pAd, RF_R06, (PUCHAR)&RfReg);
+ RfReg |= 0x40;
+ RT30xxWriteRFRegister(pAd, RF_R06, (UCHAR)RfReg);
+
+ //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
+ RTMP_IO_READ32(pAd, OPT_14, &data);
+ data |= 0x01;
+ RTMP_IO_WRITE32(pAd, OPT_14, data);
+
+ // set default antenna as main
+ if (pAd->RfIcType == RFIC_3020)
+ AsicSetRxAnt(pAd, pAd->RxAnt.Pair1PrimaryRxAnt);
+
+ // add by johnli, RF power sequence setup, load RF normal operation-mode setup
+ RT30xxLoadRFNormalModeSetup(pAd);
+ }
+
+}
+#endif // RT3070 //
diff --git a/drivers/staging/rt3090/chips/rt3390.c b/drivers/staging/rt3090/chips/rt3390.c
new file mode 100644
index 000000000000..afed9e705e8d
--- /dev/null
+++ b/drivers/staging/rt3090/chips/rt3390.c
@@ -0,0 +1,122 @@
+/*
+ *************************************************************************
+ * 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:
+ rt3390.c
+
+ Abstract:
+ Specific funcitons and variables for RT30xx.
+
+ Revision History:
+ Who When What
+ -------- ---------- ----------------------------------------------
+*/
+
+#ifdef RT3390
+
+#include "../rt_config.h"
+
+
+#ifndef RTMP_RF_RW_SUPPORT
+#error "You Should Enable compile flag RTMP_RF_RW_SUPPORT for this chip"
+#endif // RTMP_RF_RW_SUPPORT //
+
+
+VOID NICInitRT3390RFRegisters(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_RT3090(pAd)||IS_RT3390(pAd)||IS_RT3572(pAd))
+ {
+ // Init RF calibration
+ // Driver should toggle RF R30 bit7 before init RF registers
+ UINT32 RfReg = 0, 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);
+
+ // init R24, R31
+ RT30xxWriteRFRegister(pAd, RF_R24, 0x0F);
+ RT30xxWriteRFRegister(pAd, RF_R31, 0x0F);
+
+ if (IS_RT3390(pAd))
+ {
+ // patch LNA_PE_G1 failed issue
+ RTMP_IO_READ32(pAd, GPIO_SWITCH, &data);
+ data &= ~(0x20);
+ RTMP_IO_WRITE32(pAd, GPIO_SWITCH, data);
+
+ // RF registers initialization
+ for (i = 0; i < NUM_RF_REG_PARMS_OVER_RT3390; i++)
+ {
+ RT30xxWriteRFRegister(pAd, RFRegTableOverRT3390[i].Register, RFRegTableOverRT3390[i].Value);
+ }
+ }
+
+ // patch LNA_PE_G1 failed issue
+ RTMP_IO_READ32(pAd, GPIO_SWITCH, &data);
+ data &= ~(0x20);
+ RTMP_IO_WRITE32(pAd, GPIO_SWITCH, data);
+
+ // Initialize RF register to default value
+ for (i = 0; i < NUM_RF_REG_PARMS_OVER_RT3390; i++)
+ {
+ RT30xxWriteRFRegister(pAd, RFRegTableOverRT3390[i].Register, RFRegTableOverRT3390[i].Value);
+ }
+
+ // Driver should set RF R6 bit6 on before calibration
+ RT30xxReadRFRegister(pAd, RF_R06, (PUCHAR)&RfReg);
+ RfReg |= 0x40;
+ RT30xxWriteRFRegister(pAd, RF_R06, (UCHAR)RfReg);
+
+ //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
+ RTMP_IO_READ32(pAd, OPT_14, &data);
+ data |= 0x01;
+ RTMP_IO_WRITE32(pAd, OPT_14, data);
+
+ // set default antenna as main
+ if (pAd->RfIcType == RFIC_3020)
+ AsicSetRxAnt(pAd, pAd->RxAnt.Pair1PrimaryRxAnt);
+
+ // add by johnli, RF power sequence setup, load RF normal operation-mode setup
+ RT33xxLoadRFNormalModeSetup(pAd);
+ }
+
+}
+
+#endif // RT3390 //
diff --git a/drivers/staging/rt3090/chips/rt33xx.c b/drivers/staging/rt3090/chips/rt33xx.c
new file mode 100644
index 000000000000..56f376c88bda
--- /dev/null
+++ b/drivers/staging/rt3090/chips/rt33xx.c
@@ -0,0 +1,536 @@
+/*
+ *************************************************************************
+ * 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:
+ rt33xx.c
+
+ Abstract:
+ Specific funcitons and variables for RT30xx.
+
+ Revision History:
+ Who When What
+ -------- ---------- ----------------------------------------------
+*/
+
+
+#ifdef RT33xx
+
+
+#ifndef RTMP_RF_RW_SUPPORT
+#error "You Should Enable compile flag RTMP_RF_RW_SUPPORT for this chip"
+#endif // RTMP_RF_RW_SUPPORT //
+
+#include "../rt_config.h"
+
+
+//
+// RF register initialization set
+//
+REG_PAIR RFRegTableOverRT3390[] = {
+ {RF_R00, 0xA0},
+ {RF_R01, 0xE1},
+ {RF_R02, 0xF1},
+ {RF_R03, 0x62},
+ {RF_R04, 0x40},
+ {RF_R05, 0x8B},
+ {RF_R06, 0x42},
+ {RF_R07, 0x34},
+ {RF_R08, 0x00}, // Read only
+ {RF_R09, 0xC0},
+
+ {RF_R10, 0x61},
+ {RF_R11, 0x21},
+ {RF_R12, 0x3B},
+ {RF_R13, 0xE0},
+ {RF_R14, 0x90},
+ {RF_R15, 0x53},
+ {RF_R16, 0x0E},
+ {RF_R17, 0x94},
+ {RF_R18, 0x5C},
+ {RF_R19, 0x4A},
+
+ {RF_R20, 0xB2},
+ {RF_R21, 0xF6},
+ {RF_R22, 0x00},
+ {RF_R23, 0x14},
+ {RF_R24, 0x08},
+ {RF_R25, 0x3D},
+ {RF_R26, 0x85},
+ {RF_R27, 0x00},
+ {RF_R28, 0x41},
+ {RF_R29, 0x8F},
+ {RF_R30, 0x20},
+ {RF_R31, 0x0F},
+};
+
+UCHAR NUM_RF_REG_PARMS_OVER_RT3390=(sizeof(RFRegTableOverRT3390) / sizeof(REG_PAIR));
+
+
+
+// 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
+// The original name of this function is AsicSetRxAnt(), now change to
+//VOID AsicSetRxAnt(
+
+VOID RT33xxSetRxAnt(
+ IN PRTMP_ADAPTER pAd,
+ IN UCHAR Ant)
+{
+ 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"));
+ }
+}
+
+
+/*
+ ========================================================================
+
+ 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) || IS_RT3572(pAd)|| IS_RT3390(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) || IS_RT3572(pAd)|| IS_RT3390(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));
+}
+
+
+// add by johnli, RF power sequence setup
+/*
+ ==========================================================================
+ Description:
+
+ Load RF normal operation-mode setup
+
+ ==========================================================================
+ */
+VOID RT33xxLoadRFNormalModeSetup(
+ 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);
+
+ /* move to NICInitRT30xxRFRegisters
+ // 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;
+ }
+ // set RF_R17_bit[2:0] equal to EEPROM setting at 0x48h
+ if (pAd->TxMixerGain24G >= 2)
+ {
+ RFValue &= (~0x7); // clean bit [2:0]
+ RFValue |= pAd->TxMixerGain24G;
+ }
+ 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);
+
+ /* add by johnli, reset RF_R27 when interface down & up to fix throughput problem*/
+ // LDORF_VC, RF R27 register Bit 2 to 0
+ RT30xxReadRFRegister(pAd, RF_R27, &RFValue);
+ // TX to RX IQ glitch(RF_R27) has been fixed in RT3070(F).
+ // Raising RF voltage is no longer needed for RT3070(F)
+ if (IS_RT3090(pAd)) // RT309x and RT3071/72
+ {
+ 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 RT33xxLoadRFSleepModeSetup(
+ 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);
+ }
+
+ if (IS_RT3090(pAd) || // IS_RT3090 including RT309x and RT3071/72
+ IS_RT3572(pAd) ||
+ IS_RT3390(pAd) ||
+ (IS_RT3070(pAd) && ((pAd->MACVersion & 0xffff) < 0x0201)))
+ {
+ {
+ 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 RT33xxReverseRFSleepModeSetup(
+ 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);
+ }
+
+ if (IS_RT3090(pAd) || // IS_RT3090 including RT309x and RT3071/72
+ IS_RT3572(pAd) ||
+ IS_RT3390(pAd) ||
+ (IS_RT3070(pAd) && ((pAd->MACVersion & 0xffff) < 0x0201)))
+ {
+ {
+ 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);
+ }
+ }
+
+ if(IS_RT3572(pAd))
+ RT30xxWriteRFRegister(pAd, RF_R08, 0x80);
+}
+// end johnli
+
+VOID RT33xxHaltAction(
+ IN PRTMP_ADAPTER pAd)
+{
+ UINT32 TxPinCfg = 0x00050F0F;
+
+ //
+ // Turn off LNA_PE or TRSW_POL
+ //
+ if (IS_RT3070(pAd) || IS_RT3071(pAd) || IS_RT3390(pAd)||IS_RT3572(pAd))
+ {
+ //KH? Both support 3390 usb and PCI
+ if ((IS_RT3071(pAd) || IS_RT3572(pAd)||IS_RT3390(pAd))
+#ifdef RTMP_EFUSE_SUPPORT
+ && (pAd->bUseEfuse)
+#endif // RTMP_EFUSE_SUPPORT //
+ )
+ {
+ TxPinCfg &= 0xFFFBF0F0; // bit18 off
+ }
+ else
+ {
+ TxPinCfg &= 0xFFFFF0F0;
+ }
+
+ RTMP_IO_WRITE32(pAd, TX_PIN_CFG, TxPinCfg);
+ }
+}
+
+#endif // RT30xx //
diff --git a/drivers/staging/rt3090/chlist.h b/drivers/staging/rt3090/chlist.h
new file mode 100644
index 000000000000..d03cb4754394
--- /dev/null
+++ b/drivers/staging/rt3090/chlist.h
@@ -0,0 +1,130 @@
+/*
+ *************************************************************************
+ * 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.h
+
+ Abstract:
+ Miniport generic portion header file
+
+ 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;
+
+extern CH_REGION ChRegion[];
+
+typedef struct _CH_FREQ_MAP_{
+ UINT16 channel;
+ UINT16 freqKHz;
+}CH_FREQ_MAP;
+
+extern CH_FREQ_MAP CH_HZ_ID_MAP[];
+extern int CH_HZ_ID_MAP_NUM;
+
+
+#define MAP_CHANNEL_ID_TO_KHZ(_ch, _khz) \
+ do{ \
+ int _chIdx; \
+ for (_chIdx = 0; _chIdx < CH_HZ_ID_MAP_NUM; _chIdx++)\
+ { \
+ if ((_ch) == CH_HZ_ID_MAP[_chIdx].channel) \
+ { \
+ (_khz) = CH_HZ_ID_MAP[_chIdx].freqKHz * 1000; \
+ break; \
+ } \
+ } \
+ if (_chIdx == CH_HZ_ID_MAP_NUM) \
+ (_khz) = 2412000; \
+ }while(0)
+
+#define MAP_KHZ_TO_CHANNEL_ID(_khz, _ch) \
+ do{ \
+ int _chIdx; \
+ for (_chIdx = 0; _chIdx < CH_HZ_ID_MAP_NUM; _chIdx++)\
+ { \
+ if ((_khz) == CH_HZ_ID_MAP[_chIdx].freqKHz) \
+ { \
+ (_ch) = CH_HZ_ID_MAP[_chIdx].channel; \
+ break; \
+ } \
+ } \
+ if (_chIdx == CH_HZ_ID_MAP_NUM) \
+ (_ch) = 1; \
+ }while(0)
+
+
+VOID BuildChannelListEx(
+ IN PRTMP_ADAPTER pAd);
+
+VOID BuildBeaconChList(
+ IN PRTMP_ADAPTER pAd,
+ OUT PUCHAR pBuf,
+ OUT PULONG pBufLen);
+
+#ifdef DOT11_N_SUPPORT
+VOID N_ChannelCheck(
+ IN PRTMP_ADAPTER pAd);
+
+VOID N_SetCenCh(
+ IN PRTMP_ADAPTER pAd);
+#endif // DOT11_N_SUPPORT //
+
+UINT8 GetCuntryMaxTxPwr(
+ IN PRTMP_ADAPTER pAd,
+ IN UINT8 channel);
+
+#endif // __CHLIST_H__
diff --git a/drivers/staging/rt3090/common/action.c b/drivers/staging/rt3090/common/action.c
new file mode 100644
index 000000000000..8e3b0a0c2d64
--- /dev/null
+++ b/drivers/staging/rt3090/common/action.c
@@ -0,0 +1,1057 @@
+/*
+ *************************************************************************
+ * 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, (MGMT_USE_QUEUE_FLAG | 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
+#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 DOT11_N_SUPPORT
+#ifdef DOT11N_DRAFT3
+ UCHAR Action = Elem->Msg[LENGTH_802_11+1];
+#endif // DOT11N_DRAFT3 //
+#endif // DOT11_N_SUPPORT //
+ if (Elem->Wcid >= MAX_LEN_OF_MAC_TABLE)
+ return;
+
+#ifdef DOT11_N_SUPPORT
+#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 //
+#endif // DOT11_N_SUPPORT //
+
+}
+
+
+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, (MGMT_USE_QUEUE_FLAG | 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;
+}
diff --git a/drivers/staging/rt3090/common/ba_action.c b/drivers/staging/rt3090/common/ba_action.c
new file mode 100644
index 000000000000..c73248980690
--- /dev/null
+++ b/drivers/staging/rt3090/common/ba_action.c
@@ -0,0 +1,1779 @@
+/*
+ *************************************************************************
+ * 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 * OS_HZ)/1000) // system ticks -- 100 ms
+#define MAX_REORDERING_PACKET_TIMEOUT ((3000 * OS_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)
+ )
+ {
+// DBGPRINT(RT_DEBUG_OFF, ("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;
+ }
+
+ DBGPRINT(RT_DEBUG_OFF, ("%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;
+// DBGPRINT(RT_DEBUG_TRACE, ("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;
+ pAd->BATable.numDoneOriginator ++;
+
+ // 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;
+
+ DBGPRINT(RT_DEBUG_OFF, ("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.
+ RTMP_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)
+ {
+ DBGPRINT(RT_DEBUG_OFF, ("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)
+ {
+ pAd->BATable.numDoneOriginator -= 1;
+ 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);
+ if (Elem != NULL)
+ {
+ 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;
+ Elem->MsgLen = sizeof(DelbaReq);
+ NdisMoveMemory(Elem->Msg, &DelbaReq, sizeof(DelbaReq));
+ MlmeDELBAAction(pAd, Elem);
+ kfree(Elem);
+ }
+ else
+ {
+ DBGPRINT(RT_DEBUG_ERROR, ("%s(bForceSend):alloc memory failed!\n", __FUNCTION__));
+ }
+ }
+
+ 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);
+ if (Elem != NULL)
+ {
+ 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;
+ Elem->MsgLen = sizeof(DelbaReq);
+ NdisMoveMemory(Elem->Msg, &DelbaReq, sizeof(DelbaReq));
+ MlmeDELBAAction(pAd, Elem);
+ kfree(Elem);
+ }
+ else
+ {
+ DBGPRINT(RT_DEBUG_ERROR, ("%s():alloc memory failed!\n", __FUNCTION__));
+ return;
+ }
+ }
+ 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;
+ //ULONG offset;
+ //UINT32 VALUE;
+
+ RTMPCancelTimer(&pBAEntry->RECBATimer, &Cancelled);
+
+ //
+ // 1. Send DELBA Action Frame
+ //
+ if (bPassive == FALSE)
+ {
+ MLME_QUEUE_ELEM *Elem = (MLME_QUEUE_ELEM *) kmalloc(sizeof(MLME_QUEUE_ELEM), MEM_ALLOC_FLAG);
+ if (Elem != NULL)
+ {
+ 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;
+ Elem->MsgLen = sizeof(DelbaReq);
+ NdisMoveMemory(Elem->Msg, &DelbaReq, sizeof(DelbaReq));
+ MlmeDELBAAction(pAd, Elem);
+ kfree(Elem);
+ }
+ else
+ {
+ DBGPRINT(RT_DEBUG_ERROR, ("%s():alloc memory failed!\n", __FUNCTION__));
+ return;
+ }
+ }
+
+
+ //
+ // 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;
+
+ RTMP_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);
+ RTMP_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);
+ DBGPRINT(RT_DEBUG_OFF, ("%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]);
+ DBGPRINT(RT_DEBUG_OFF, ("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", __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))
+ {
+ //DBGPRINT(RT_DEBUG_TRACE, ("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:
+#ifdef RT30xx
+ if (IS_RT30xx(pAd)
+ &&(pAd->Antenna.field.RxPath>1||pAd->Antenna.field.TxPath>1))
+ {
+ RTMP_ASIC_MMPS_DISABLE(pAd);
+ }
+#endif // RT30xx //
+ Frame.Psmp = 0;
+ break;
+ case MMPS_DYNAMIC:
+ Frame.Psmp = 3;
+ break;
+ case MMPS_STATIC:
+#ifdef RT30xx
+ if (IS_RT30xx(pAd)
+ &&(pAd->Antenna.field.RxPath>1||pAd->Antenna.field.TxPath>1))
+ {
+ RTMP_ASIC_MMPS_ENABLE(pAd);
+ }
+#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);
+
+ SET_OS_PKT_NETDEV(pRxPkt, get_netdev_from_bssid(pAd, FromWhichBSSID));
+ SET_OS_PKT_DATAPTR(pRxPkt, pRxBlk->pData);
+ SET_OS_PKT_LEN(pRxPkt, pRxBlk->DataSize);
+ SET_OS_PKT_DATATAIL(pRxPkt, pRxBlk->pData, pRxBlk->DataSize);
+
+ //
+ // 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
+ }
+#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) &&
+ (!RX_BLK_TEST_FLAG(pRxBlk, fRX_EAP)))
+ {
+ // 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 //
diff --git a/drivers/staging/rt3090/common/cmm_aes.c b/drivers/staging/rt3090/common/cmm_aes.c
new file mode 100644
index 000000000000..4ccbbbfe4cca
--- /dev/null
+++ b/drivers/staging/rt3090/common/cmm_aes.c
@@ -0,0 +1,1560 @@
+/*
+ *************************************************************************
+ * 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:
+ cmm_aes.c
+
+ Abstract:
+
+ Revision History:
+ Who When What
+ -------- ---------- ----------------------------------------------
+ Paul Wu 02-25-02 Initial
+*/
+
+#include "../rt_config.h"
+
+
+typedef struct
+{
+ UINT32 erk[64]; /* encryption round keys */
+ UINT32 drk[64]; /* decryption round keys */
+ int nr; /* number of rounds */
+}
+aes_context;
+
+/*****************************/
+/******** 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)
+{
+ INT i;
+
+ for (i=0;i<4; i++)
+ {
+ out[i] = a[i] ^ b[i];
+ }
+}
+
+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];
+ }
+}
+
+UCHAR RTMPCkipSbox(
+ IN UCHAR a)
+{
+ return SboxTable[(int)a];
+}
+
+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 byte_sub(
+ IN PUCHAR in,
+ OUT PUCHAR out)
+{
+ INT i;
+
+ for (i=0; i< 16; i++)
+ {
+ out[i] = RTMPCkipSbox(in[i]);
+ }
+}
+
+/************************************/
+/* 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 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);
+}
+
+
+/************************************************/
+/* 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);
+
+}
+
+/****************************************/
+/* aes128k128d() */
+/* Performs a 128 bit AES encrypt with */
+/* 128 bit data. */
+/****************************************/
+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);
+
+}
+
+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;
+}
+
+/* ========================= AES En/Decryption ========================== */
+#ifndef uint8
+#define uint8 unsigned char
+#endif
+
+#ifndef uint32
+#define uint32 unsigned int
+#endif
+
+/* 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) ); \
+}
+
+
+int rt_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 = (uint32 *) 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 = (uint32 *) 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 rt_aes_encrypt(aes_context *ctx, uint8 input[16], uint8 output[16] )
+{
+ uint32 *RK, X0, X1, X2, X3, Y0, Y1, Y2, Y3;
+
+ RK = (uint32 *) 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 rt_aes_decrypt( aes_context *ctx, uint8 input[16], uint8 output[16] )
+{
+ uint32 *RK, X0, X1, X2, X3, Y0, Y1, Y2, Y3;
+
+ RK = (uint32 *) 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 );
+}
+
+/*
+ ==========================================================================
+ 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 UINT32 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;
+
+ rt_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);
+ rt_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 UINT32 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];
+ }
+
+ rt_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);
+ rt_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);
+}
+
+
+/* ======= The related function of AES-128-CMAC ======= */
+VOID leftshift_onebit(
+ IN PUCHAR input,
+ OUT PUCHAR output)
+{
+ INT i;
+ UCHAR overflow = 0;
+
+ for (i=15; i>=0; i--)
+ {
+ output[i] = input[i] << 1;
+ output[i] |= overflow;
+ overflow = (input[i] & 0x80) ? 1 : 0;
+ }
+}
+
+VOID do_padding(
+ IN PUCHAR lastb,
+ OUT PUCHAR pad,
+ IN INT len)
+{
+ INT j;
+
+ for (j=0; j<16; j++)
+ {
+ if (j < len)
+ pad[j] = lastb[j];
+ else if (j == len)
+ pad[j] = 0x80;
+ else
+ pad[j] = 0x00;
+ }
+
+
+}
+
+/*
+ * The Subkey Generation Algorithm
+ */
+VOID generate_subkey(
+ IN PUCHAR key,
+ OUT PUCHAR K1,
+ OUT PUCHAR K2)
+{
+ aes_context aesctx;
+ UCHAR aes_128_key[16];
+ UCHAR const_Zero[16];
+ UCHAR tmp[16];
+ UCHAR const_Rb[16] = {0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x87};
+
+ // initial the key material
+ memset(const_Zero, 0, 16);
+ memset(aes_128_key, 0, 16);
+
+ // AES-128 with key is applied to an all-zero input block
+ rt_aes_set_key(&aesctx, key, 128);
+ rt_aes_encrypt(&aesctx, const_Zero, aes_128_key);
+
+ // derive K1(128-bit first subkey) and K2(128-bit second subkey), refer to rfc-4493 ch 2.3
+ if ((aes_128_key[0] & 0x80) == 0)
+ {
+ leftshift_onebit(aes_128_key, K1);
+ }
+ else
+ {
+ leftshift_onebit(aes_128_key, tmp);
+ xor_128(tmp, const_Rb, K1);
+ }
+
+ if ((K1[0] & 0x80) == 0)
+ {
+ leftshift_onebit(K1, K2);
+ }
+ else
+ {
+ leftshift_onebit(K1, tmp);
+ xor_128(tmp, const_Rb, K2);
+ }
+
+}
+
+/*
+ * AES-CMAC Algorithm. (refer to rfc-4493 and SP800-38B)
+ *
+ * Input : key (128-bit key)
+ * input (message to be authenticated)
+ * len (length of the message in octets)
+ *
+ * output: mac (message authentication code)
+ */
+VOID AES_128_CMAC(
+ IN PUCHAR key,
+ IN PUCHAR input,
+ IN INT len,
+ OUT PUCHAR mac)
+{
+ UCHAR X[16], Y[16], M_last[16], padded[16];
+ UCHAR K1[16], K2[16];
+ aes_context aesctx;
+ INT n, i, flag;
+
+ generate_subkey(key, K1, K2);
+
+ n = (len+15) / 16; // n is number of rounds
+
+ if (n == 0)
+ {
+ n = 1;
+ flag = 0;
+ }
+ else
+ {
+ if ((len%16) == 0)
+ flag = 1; // indicate that last block is a complete block
+ else
+ flag = 0; // indicate that last block is not a complete block
+ }
+
+ if (flag)
+ {
+ xor_128(&input[16*(n-1)], K1, M_last);
+ }
+ else
+ {
+ do_padding(&input[16*(n-1)], padded, len%16);
+ xor_128(padded, K2, M_last);
+ }
+
+ memset(X, 0, 16);
+ for (i=0; i<n-1; i++)
+ {
+ xor_128(X, &input[16*i], Y);
+ rt_aes_set_key(&aesctx, key, 128);
+ rt_aes_encrypt(&aesctx, Y, X);
+ }
+
+ xor_128(X, M_last, Y);
+ rt_aes_set_key(&aesctx, key, 128);
+ rt_aes_encrypt(&aesctx, Y, X);
+
+ for (i=0; i<16; i++)
+ {
+ mac[i] = X[i];
+ }
+
+}
+/* ======= The related function of AES-128-CMAC ======= */
diff --git a/drivers/staging/rt3090/common/cmm_asic.c b/drivers/staging/rt3090/common/cmm_asic.c
new file mode 100644
index 000000000000..3d1c808496f3
--- /dev/null
+++ b/drivers/staging/rt3090/common/cmm_asic.c
@@ -0,0 +1,2753 @@
+/*
+ *************************************************************************
+ * 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:
+ cmm_asic.c
+
+ Abstract:
+ Functions used to communicate with ASIC
+
+ Revision History:
+ Who When What
+ -------- ---------- ----------------------------------------------
+*/
+
+#include "../rt_config.h"
+
+
+// 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},
+ {167, 0x98402ec4, 0x984c03d2, 0x98179855, 0x9815531f},
+ {169, 0x98402ec4, 0x984c03d2, 0x98179855, 0x98155327},
+ {171, 0x98402ec4, 0x984c03d6, 0x98179855, 0x98155307},
+ {173, 0x98402ec4, 0x984c03d6, 0x98179855, 0x9815530f},
+
+ // 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},
+};
+UCHAR NUM_OF_3020_CHNL = (sizeof(FreqItems3020) / sizeof(FREQUENCY_ITEM));
+
+
+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.numDoneOriginator)
+ {
+ //
+ // 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;
+ pAd->FlgCtsEnabled = 0; /* CTS-self is not used */
+ }
+ 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;
+ pAd->FlgCtsEnabled = 1; /* CTS-self is used */
+ }
+
+#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;
+ UCHAR RFValue;
+
+ RFValue = 0;
+ // Search Tx power value
+ // 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;
+ }
+ }
+
+ 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)||IS_RT3390(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 */
+
+ 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;
+
+#ifdef DFS_DEBUG
+#ifdef DFS_FCC_BW40_FIX
+ if (pAd->infType == RTMP_DEV_INF_PCI) // RT2880 PCI
+ {
+ /* only for RT2880 */
+ // FCC DFS test
+ pAd->LatchRfRegs.R1 |= 0x100;
+ pAd->LatchRfRegs.R4 |= 0x00400000;
+ }
+#endif // DFS_FCC_BW40_FIX //
+#endif // DFS_DEBUG //
+
+ // 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;
+ }
+
+ 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));
+ }
+
+ // 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);
+
+#if defined(RT3090) || defined(RT3390)
+ // PCIe PHY Transmit attenuation adjustment
+ if (IS_RT3090A(pAd) || IS_RT3390(pAd))
+ {
+ TX_ATTENUATION_CTRL_STRUC TxAttenuationCtrl = {0};
+
+ RTMP_IO_READ32(pAd, PCIE_PHY_TX_ATTENUATION_CTRL, &TxAttenuationCtrl.word);
+
+ if (Channel == 14) // Channel #14
+ {
+ TxAttenuationCtrl.field.PCIE_PHY_TX_ATTEN_EN = 1; // Enable PCIe PHY Tx attenuation
+ TxAttenuationCtrl.field.PCIE_PHY_TX_ATTEN_VALUE = 4; // 9/16 full drive level
+ }
+ else // Channel #1~#13
+ {
+ TxAttenuationCtrl.field.PCIE_PHY_TX_ATTEN_EN = 0; // Disable PCIe PHY Tx attenuation
+ TxAttenuationCtrl.field.PCIE_PHY_TX_ATTEN_VALUE = 0; // n/a
+ }
+
+ RTMP_IO_WRITE32(pAd, PCIE_PHY_TX_ATTENUATION_CTRL, TxAttenuationCtrl.word);
+ }
+#endif
+ }
+ 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);
+}
+
+/*
+ ==========================================================================
+ 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
+
+ ==========================================================================
+ */
+#ifdef ANT_DIVERSITY_SUPPORT
+VOID AsicAntennaSelect(
+ IN PRTMP_ADAPTER pAd,
+ IN UCHAR Channel)
+{
+#ifdef CONFIG_STA_SUPPORT
+ IF_DEV_CONFIG_OPMODE_ON_STA(pAd)
+ if (pAd->Mlme.OneSecPeriodicRound % 2 == 1)
+#endif // CONFIG_STA_SUPPORT //
+ {
+ // 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;
+ realavgrssi1 = (pAd->RxAnt.Pair1AvgRssi[pAd->RxAnt.Pair1PrimaryRxAnt] >> 3);
+#endif // CONFIG_STA_SUPPORT //
+
+ 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)))
+ AsicEvaluateRxAnt(pAd);
+
+ pAd->RxAnt.Pair1LastAvgRssi = realavgrssi1;
+ }
+ 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 // ANT_DIVERSITY_SUPPORT //
+
+/*
+ ========================================================================
+
+ 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;
+#ifdef CONFIG_STA_SUPPORT
+ CHAR Rssi = -127;
+#endif // CONFIG_STA_SUPPORT //
+#ifdef CARRIER_SENSE_NEW_ALGO
+ unsigned long flags; //KH Add to Fix PCIe Power-Saving bug
+#endif // CARRIER_SENSE_NEW_ALGO //
+
+
+#ifdef CARRIER_SENSE_NEW_ALGO
+ //KH Add to Fix PCIe Power-Saving bug<--
+ RTMP_INT_LOCK(&pAd->irq_lock, flags);
+ //KH Add to Fix PCIe Power-Saving bug-->
+#endif // CARRIER_SENSE_NEW_ALGO //
+
+#ifdef CONFIG_STA_SUPPORT
+ if (OPSTATUS_TEST_FLAG(pAd, fOP_STATUS_DOZE) ||
+#ifdef RTMP_MAC_PCI
+ (pAd->bPCIclkOff == TRUE) ||
+#endif // RTMP_MAC_PCI //
+ RTMP_TEST_FLAG(pAd, fRTMP_ADAPTER_IDLE_RADIO_OFF) ||
+ RTMP_TEST_FLAG(pAd, fRTMP_ADAPTER_BSS_SCAN_IN_PROGRESS))
+{
+
+#ifdef CARRIER_SENSE_NEW_ALGO
+ //KH Add to Fix PCIe Power-Saving bug<--
+ RTMP_INT_UNLOCK(&pAd->irq_lock, flags);
+ //KH add to fix PCIe-Power Saving -->
+#endif // CARRIER_SENSE_NEW_ALGO //
+ return;
+}
+ IF_DEV_CONFIG_OPMODE_ON_STA(pAd)
+ Rssi = RTMPMaxRssi(pAd,
+ pAd->StaCfg.RssiSample.AvgRssi0,
+ pAd->StaCfg.RssiSample.AvgRssi1,
+ pAd->StaCfg.RssiSample.AvgRssi2);
+#endif // CONFIG_STA_SUPPORT //
+
+ 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
+ {
+#ifdef CONFIG_STA_SUPPORT
+ IF_DEV_CONFIG_OPMODE_ON_STA(pAd)
+ {
+ // to patch high power issue with some APs, like Belkin N1.
+ if (Rssi > -35)
+ {
+ BbpR1 |= 0x02; // DeltaPwr -= 12;
+ }
+ else if (Rssi > -40)
+ {
+ BbpR1 |= 0x01; // DeltaPwr -= 6;
+ }
+ else
+ ;
+ }
+#endif // CONFIG_STA_SUPPORT //
+ }
+ 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 CARRIER_SENSE_NEW_ALGO
+ //KH Add to Fix PCIe Power-Saving bug<--
+ RTMP_INT_UNLOCK(&pAd->irq_lock, flags);
+ //KH add to fix PCIe-Power Saving -->
+#endif // CARRIER_SENSE_NEW_ALGO //
+
+}
+
+
+#ifdef CONFIG_STA_SUPPORT
+VOID AsicResetBBPAgent(
+IN PRTMP_ADAPTER pAd)
+{
+ BBP_CSR_CFG_STRUC BbpCsr;
+ DBGPRINT(RT_DEBUG_ERROR, ("Reset BBP Agent busy bit.!! \n"));
+ // Still need to find why BBP agent keeps busy, but in fact, hardware still function ok. Now clear busy first.
+ RTMP_IO_READ32(pAd, H2M_BBP_AGENT, &BbpCsr.word);
+ BbpCsr.field.Busy = 0;
+ RTMP_IO_WRITE32(pAd, H2M_BBP_AGENT, BbpCsr.word);
+}
+/*
+ ==========================================================================
+ 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)
+{
+ RTMP_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_INFO, ("--> AsicForceWakeup \n"));
+ RTMP_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 RTMP_MAC_PCI
+ // 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
+ {
+ UINT32 longptr = *ptr + (*(ptr+1)<<8) + (*(ptr+2)<<16) + (*(ptr+3)<<24);
+ RTMP_IO_WRITE32(pAd, HW_BEACON_BASE0 + i, longptr);
+ ptr += 4;
+ }
+
+ // start right after the 16-byte TXWI field
+ ptr = pAd->BeaconBuf;
+ for (i=0; i< pAd->BeaconTxWI.MPDUtotalByteCount; i+=4)
+ {
+ UINT32 longptr = *ptr + (*(ptr+1)<<8) + (*(ptr+2)<<16) + (*(ptr+3)<<24);
+ RTMP_IO_WRITE32(pAd, HW_BEACON_BASE0 + TXWI_SIZE + i, longptr);
+ ptr +=4;
+ }
+#endif // RTMP_MAC_PCI //
+
+
+ //
+ // 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;
+ if(pAd->Antenna.field.TxPath == 1)
+ {
+ Ac2Cfg.field.Cwmin = pEdcaParm->Cwmin[QID_AC_VI] + 1;
+ Ac2Cfg.field.Cwmax = pEdcaParm->Cwmax[QID_AC_VI] + 1;
+ }
+ else
+ {
+ Ac2Cfg.field.Cwmin = pEdcaParm->Cwmin[QID_AC_VI];
+ Ac2Cfg.field.Cwmax = pEdcaParm->Cwmax[QID_AC_VI];
+ }
+ Ac2Cfg.field.Aifsn = pEdcaParm->Aifsn[QID_AC_VI] + 1;
+#ifdef CONFIG_STA_SUPPORT
+#endif // CONFIG_STA_SUPPORT //
+
+#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
+ // TODO: Shiang, this modification also suitable for RT3052/RT3050 ???
+ 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_TEST_FLAG(pAd, fOP_STATUS_SHORT_SLOT_INUSED))
+ return;
+ else if ((!bUseShortSlotTime) && (!OPSTATUS_TEST_FLAG(pAd, fOP_STATUS_SHORT_SLOT_INUSED)))
+ return;
+
+ 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)
+ {
+ OPSTATUS_SET_FLAG(pAd, fOP_STATUS_SHORT_SLOT_INUSED);
+ 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)
+ {
+ OPSTATUS_CLEAR_FLAG(pAd, fOP_STATUS_SHORT_SLOT_INUSED);
+ 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;
+#ifdef RTMP_MAC_PCI
+ INT i;
+#endif // RTMP_MAC_PCI //
+
+ 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 RTMP_MAC_PCI
+ offset = SHARED_KEY_TABLE_BASE + (4*BssIndex + KeyIdx)*HW_KEY_ENTRY_SIZE;
+ for (i=0; i<MAX_LEN_OF_SHARE_KEY; i++)
+ {
+ RTMP_IO_WRITE8(pAd, offset + i, pKey[i]);
+ }
+
+ offset += MAX_LEN_OF_SHARE_KEY;
+ if (pTxMic)
+ {
+ for (i=0; i<8; i++)
+ {
+ RTMP_IO_WRITE8(pAd, offset + i, pTxMic[i]);
+ }
+ }
+
+ offset += 8;
+ if (pRxMic)
+ {
+ for (i=0; i<8; i++)
+ {
+ RTMP_IO_WRITE8(pAd, offset + i, pRxMic[i]);
+ }
+ }
+#endif // RTMP_MAC_PCI //
+
+
+ //
+ // 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;
+#ifdef RTMP_MAC_PCI
+ UCHAR i;
+#endif // RTMP_MAC_PCI //
+
+// 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 RTMP_MAC_PCI
+ for (i = 0; i < MAX_LEN_OF_PEER_KEY; i++)
+ {
+ RTMP_IO_WRITE8(pAd, offset + i, pKey[i]);
+ }
+ offset += MAX_LEN_OF_PEER_KEY;
+
+ //
+ // 3.) Set MIC key if available
+ //
+ if (pTxMic)
+ {
+ for (i = 0; i < 8; i++)
+ {
+ RTMP_IO_WRITE8(pAd, offset + i, pTxMic[i]);
+ }
+ }
+ offset += LEN_TKIP_TXMICK;
+
+ if (pRxMic)
+ {
+ for (i = 0; i < 8; i++)
+ {
+ RTMP_IO_WRITE8(pAd, offset + i, pRxMic[i]);
+ }
+ }
+#endif // RTMP_MAC_PCI //
+
+
+ //
+ // 4.) Modify IV/EIV if needs
+ // This will force Asic to use this key ID by setting IV.
+ //
+ if (bTxKey)
+ {
+#ifdef RTMP_MAC_PCI
+ offset = MAC_IVEIV_TABLE_BASE + (WCID * HW_IVEIV_ENTRY_SIZE);
+ //
+ // Write IV
+ //
+ RTMP_IO_WRITE8(pAd, offset, pTxtsc[1]);
+ RTMP_IO_WRITE8(pAd, offset + 1, ((pTxtsc[1] | 0x20) & 0x7f));
+ RTMP_IO_WRITE8(pAd, offset + 2, pTxtsc[0]);
+
+ IV4 = (KeyIdx << 6);
+ if ((CipherAlg == CIPHER_TKIP) || (CipherAlg == CIPHER_TKIP_NO_MIC) ||(CipherAlg == CIPHER_AES))
+ IV4 |= 0x20; // turn on extension bit means EIV existence
+
+ RTMP_IO_WRITE8(pAd, offset + 3, IV4);
+
+ //
+ // Write EIV
+ //
+ offset += 4;
+ for (i = 0; i < 4; i++)
+ {
+ RTMP_IO_WRITE8(pAd, offset + i, pTxtsc[i + 2]);
+ }
+#endif // RTMP_MAC_PCI //
+
+ 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 RTMP_MAC_PCI
+ for (i=0; i<MAX_LEN_OF_PEER_KEY; i++)
+ {
+ RTMP_IO_WRITE8(pAd, offset + i, pKey[i]);
+ }
+#endif // RTMP_MAC_PCI //
+ 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 RTMP_MAC_PCI
+ for (i=0; i<8; i++)
+ {
+ RTMP_IO_WRITE8(pAd, offset+i, pTxMic[i]);
+ }
+#endif // RTMP_MAC_PCI //
+ }
+ offset += 8;
+ if (pRxMic)
+ {
+#ifdef RTMP_MAC_PCI
+ for (i=0; i<8; i++)
+ {
+ RTMP_IO_WRITE8(pAd, offset+i, pRxMic[i]);
+ }
+#endif // RTMP_MAC_PCI //
+ }
+
+ 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)
+{
+
+
+ if (pAd->chipOps.sendCommandToMcu)
+ pAd->chipOps.sendCommandToMcu(pAd, Command, Token, Arg0, Arg1);
+
+ return TRUE;
+}
+
+
+VOID AsicSetRxAnt(
+ IN PRTMP_ADAPTER pAd,
+ IN UCHAR Ant)
+{
+#ifdef RT33xx
+ RT33xxSetRxAnt(pAd, Ant);
+#else
+#ifdef RT30xx
+ /* RT3572 ATE need not to do this. */
+ RT30xxSetRxAnt(pAd, Ant);
+#endif // RT30xx //
+#endif // RT33xx //
+}
+
+
+VOID AsicTurnOffRFClk(
+ IN PRTMP_ADAPTER pAd,
+ IN UCHAR Channel)
+{
+ if (pAd->chipOps.AsicRfTurnOff)
+ {
+ pAd->chipOps.AsicRfTurnOff(pAd);
+ }
+ else
+ {
+ // 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;
+
+#ifdef PCIE_PS_SUPPORT
+ // The RF programming sequence is difference between 3xxx and 2xxx
+ if ((IS_RT3090(pAd) || IS_RT3572(pAd) || IS_RT3390(pAd)))
+ {
+ return;
+ }
+#endif // PCIE_PS_SUPPORT //
+
+ 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));
+}
diff --git a/drivers/staging/rt3090/common/cmm_cfg.c b/drivers/staging/rt3090/common/cmm_cfg.c
new file mode 100644
index 000000000000..d8be9793c61b
--- /dev/null
+++ b/drivers/staging/rt3090/common/cmm_cfg.c
@@ -0,0 +1,295 @@
+/*
+ *************************************************************************
+ * 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:
+ cmm_cfg.c
+
+ Abstract:
+ Ralink WiFi Driver configuration related subroutines
+
+ Revision History:
+ Who When What
+ --------- ---------- ----------------------------------------------
+*/
+
+#include "../rt_config.h"
+
+
+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";
+ }
+}
+
+
+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";
+ }
+}
+
+
+/*
+ ==========================================================================
+ Description:
+ Set Country Region to pAd->CommonCfg.CountryRegion.
+ This command will not work, if the field of CountryRegion in eeprom is programmed.
+
+ Return:
+ TRUE if all parameters are OK, FALSE otherwise
+ ==========================================================================
+*/
+INT RT_CfgSetCountryRegion(
+ IN PRTMP_ADAPTER pAd,
+ IN PSTRING arg,
+ IN INT band)
+{
+ LONG region, regionMax;
+ UCHAR *pCountryRegion;
+
+ region = simple_strtol(arg, 0, 10);
+
+ if (band == BAND_24G)
+ {
+ pCountryRegion = &pAd->CommonCfg.CountryRegion;
+ regionMax = REGION_MAXIMUM_BG_BAND;
+ }
+ else
+ {
+ pCountryRegion = &pAd->CommonCfg.CountryRegionForABand;
+ regionMax = REGION_MAXIMUM_A_BAND;
+ }
+
+ // TODO: Is it neccesay for following check???
+ // Country can be set only when EEPROM not programmed
+ if (*pCountryRegion & 0x80)
+ {
+ DBGPRINT(RT_DEBUG_ERROR, ("CfgSetCountryRegion():CountryRegion in eeprom was programmed\n"));
+ return FALSE;
+ }
+
+ if((region >= 0) && (region <= REGION_MAXIMUM_BG_BAND))
+ {
+ *pCountryRegion= (UCHAR) region;
+ }
+ else if ((region == REGION_31_BG_BAND) && (band == BAND_24G))
+ {
+ *pCountryRegion = (UCHAR) region;
+ }
+ else
+ {
+ DBGPRINT(RT_DEBUG_ERROR, ("CfgSetCountryRegion():region(%ld) out of range!\n", region));
+ return FALSE;
+ }
+
+ return TRUE;
+
+}
+
+
+/*
+ ==========================================================================
+ Description:
+ Set Wireless Mode
+ Return:
+ TRUE if all parameters are OK, FALSE otherwise
+ ==========================================================================
+*/
+INT RT_CfgSetWirelessMode(
+ IN PRTMP_ADAPTER pAd,
+ IN PSTRING arg)
+{
+ INT MaxPhyMode = PHY_11G;
+ LONG WirelessMode;
+
+#ifdef DOT11_N_SUPPORT
+ MaxPhyMode = PHY_11N_5G;
+#endif // DOT11_N_SUPPORT //
+
+ WirelessMode = simple_strtol(arg, 0, 10);
+ if (WirelessMode <= MaxPhyMode)
+ {
+ pAd->CommonCfg.PhyMode = WirelessMode;
+ pAd->CommonCfg.DesiredPhyMode = WirelessMode;
+ return TRUE;
+ }
+
+ return FALSE;
+
+}
+
+
+INT RT_CfgSetShortSlot(
+ IN PRTMP_ADAPTER pAd,
+ IN PSTRING arg)
+{
+ LONG 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
+
+ return TRUE;
+}
+
+
+/*
+ ==========================================================================
+ Description:
+ Set WEP KEY base on KeyIdx
+ Return:
+ TRUE if all parameters are OK, FALSE otherwise
+ ==========================================================================
+*/
+INT RT_CfgSetWepKey(
+ IN PRTMP_ADAPTER pAd,
+ IN PSTRING keyString,
+ IN CIPHER_KEY *pSharedKey,
+ IN INT keyIdx)
+{
+ INT KeyLen;
+ INT i;
+ UCHAR CipherAlg = CIPHER_NONE;
+ BOOLEAN bKeyIsHex = FALSE;
+
+ // TODO: Shall we do memset for the original key info??
+ memset(pSharedKey, 0, sizeof(CIPHER_KEY));
+ KeyLen = strlen(keyString);
+ switch (KeyLen)
+ {
+ case 5: //wep 40 Ascii type
+ case 13: //wep 104 Ascii type
+ bKeyIsHex = FALSE;
+ pSharedKey->KeyLen = KeyLen;
+ NdisMoveMemory(pSharedKey->Key, keyString, KeyLen);
+ break;
+
+ case 10: //wep 40 Hex type
+ case 26: //wep 104 Hex type
+ for(i=0; i < KeyLen; i++)
+ {
+ if( !isxdigit(*(keyString+i)) )
+ return FALSE; //Not Hex value;
+ }
+ bKeyIsHex = TRUE;
+ pSharedKey->KeyLen = KeyLen/2 ;
+ AtoH(keyString, pSharedKey->Key, pSharedKey->KeyLen);
+ break;
+
+ default: //Invalid argument
+ DBGPRINT(RT_DEBUG_TRACE, ("RT_CfgSetWepKey(keyIdx=%d):Invalid argument (arg=%s)\n", keyIdx, keyString));
+ return FALSE;
+ }
+
+ pSharedKey->CipherAlg = ((KeyLen % 5) ? CIPHER_WEP128 : CIPHER_WEP64);
+ DBGPRINT(RT_DEBUG_TRACE, ("RT_CfgSetWepKey:(KeyIdx=%d,type=%s, Alg=%s)\n",
+ keyIdx, (bKeyIsHex == FALSE ? "Ascii" : "Hex"), CipherName[CipherAlg]));
+
+ return TRUE;
+}
+
+
+/*
+ ==========================================================================
+ Description:
+ Set WPA PSK key
+
+ Arguments:
+ pAdapter Pointer to our adapter
+ keyString WPA pre-shared key string
+ pHashStr String used for password hash function
+ hashStrLen Lenght of the hash string
+ pPMKBuf Output buffer of WPAPSK key
+
+ Return:
+ TRUE if all parameters are OK, FALSE otherwise
+ ==========================================================================
+*/
+INT RT_CfgSetWPAPSKKey(
+ IN RTMP_ADAPTER *pAd,
+ IN PSTRING keyString,
+ IN UCHAR *pHashStr,
+ IN INT hashStrLen,
+ OUT PUCHAR pPMKBuf)
+{
+ int keyLen;
+ UCHAR keyMaterial[40];
+
+ keyLen = strlen(keyString);
+ if ((keyLen < 8) || (keyLen > 64))
+ {
+ DBGPRINT(RT_DEBUG_TRACE, ("WPAPSK Key length(%d) error, required 8 ~ 64 characters!(keyStr=%s)\n",
+ keyLen, keyString));
+ return FALSE;
+ }
+
+ memset(pPMKBuf, 0, 32);
+ if (keyLen == 64)
+ {
+ AtoH(keyString, pPMKBuf, 32);
+ }
+ else
+ {
+ PasswordHash(keyString, pHashStr, hashStrLen, keyMaterial);
+ NdisMoveMemory(pPMKBuf, keyMaterial, 32);
+ }
+
+ return TRUE;
+}
diff --git a/drivers/staging/rt3090/common/cmm_data.c b/drivers/staging/rt3090/common/cmm_data.c
new file mode 100644
index 000000000000..634007163160
--- /dev/null
+++ b/drivers/staging/rt3090/common/cmm_data.c
@@ -0,0 +1,2763 @@
+/*
+ *************************************************************************
+ * 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:
+ cmm_data.c
+
+ Abstract:
+
+ Revision History:
+ Who When What
+ --------- ---------- ----------------------------------------------
+ */
+
+#include "../rt_config.h"
+
+
+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 rtmpHwHdr[TXINFO_SIZE + TXWI_SIZE]; //RTMP_HW_HDR_LEN];
+#ifdef RTMP_MAC_PCI
+ unsigned long IrqFlags = 0;
+ UCHAR IrqState;
+#endif // RTMP_MAC_PCI //
+ BOOLEAN bUseDataQ = FALSE;
+ int retryCnt = 0;
+
+ ASSERT(Length <= MGMT_DMA_BUFFER_SIZE);
+
+ if ((QueIdx & MGMT_USE_QUEUE_FLAG) == MGMT_USE_QUEUE_FLAG)
+ {
+ bUseDataQ = TRUE;
+ QueIdx &= (~MGMT_USE_QUEUE_FLAG);
+ }
+
+#ifdef RTMP_MAC_PCI
+ // 2860C use Tx Ring
+ IrqState = pAd->irq_disabled;
+ if (pAd->MACVersion == 0x28600100)
+ {
+ QueIdx = (bUseDataQ ==TRUE ? QueIdx : 3);
+ bUseDataQ = TRUE;
+ }
+ if (bUseDataQ && (!IrqState))
+ RTMP_IRQ_LOCK(&pAd->irq_lock, IrqFlags);
+#endif // RTMP_MAC_PCI //
+
+ 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.
+#ifdef RTMP_MAC_PCI
+ if (bUseDataQ)
+ {
+ retryCnt = MAX_DATAMM_RETRY;
+ // free Tx(QueIdx) resources
+ RTMPFreeTXDUponTxDmaDone(pAd, QueIdx);
+ FreeNum = GET_TXRING_FREENO(pAd, QueIdx);
+ }
+ else
+#endif // RTMP_MAC_PCI //
+ {
+ 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;
+
+
+#ifdef RTMP_MAC_PCI
+ if (bUseDataQ)
+ {
+ Status = MlmeDataHardTransmit(pAd, QueIdx, pPacket);
+ retryCnt--;
+ }
+ else
+#endif // RTMP_MAC_PCI //
+ Status = MlmeHardTransmit(pAd, QueIdx, pPacket);
+ if (Status == NDIS_STATUS_SUCCESS)
+ retryCnt = 0;
+ else
+ RTMPFreeNdisPacket(pAd, pPacket);
+ }
+ else
+ {
+ pAd->RalinkCounters.MgmtRingFullCount++;
+#ifdef RTMP_MAC_PCI
+ if (bUseDataQ)
+ {
+ retryCnt--;
+ DBGPRINT(RT_DEBUG_TRACE, ("retryCnt %d\n", retryCnt));
+ if (retryCnt == 0)
+ {
+ DBGPRINT(RT_DEBUG_ERROR, ("Qidx(%d), not enough space in DataRing, MgmtRingFullCount=%ld!\n",
+ QueIdx, pAd->RalinkCounters.MgmtRingFullCount));
+ }
+ }
+#endif // RTMP_MAC_PCI //
+ DBGPRINT(RT_DEBUG_ERROR, ("Qidx(%d), not enough space in MgmtRing, MgmtRingFullCount=%ld!\n",
+ QueIdx, pAd->RalinkCounters.MgmtRingFullCount));
+
+
+
+ }
+ } while (retryCnt > 0);
+
+
+#ifdef RTMP_MAC_PCI
+ if (bUseDataQ && (!IrqState))
+ RTMP_IRQ_UNLOCK(&pAd->irq_lock, IrqFlags);
+#endif // RTMP_MAC_PCI //
+
+ 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)
+{
+ PACKET_INFO PacketInfo;
+ PUCHAR pSrcBufVA;
+ UINT SrcBufLen;
+ PHEADER_802_11 pHeader_802_11;
+
+ if ((pAd->CommonCfg.RadarDetect.RDMode != RD_NORMAL_MODE)
+#ifdef CARRIER_DETECTION_SUPPORT
+#endif // CARRIER_DETECTION_SUPPORT //
+ )
+ {
+ return NDIS_STATUS_FAILURE;
+ }
+
+ RTMP_QueryPacketInfo(pPacket, &PacketInfo, &pSrcBufVA, &SrcBufLen);
+ if (pSrcBufVA == NULL)
+ return NDIS_STATUS_FAILURE;
+
+ pHeader_802_11 = (PHEADER_802_11) (pSrcBufVA + TXINFO_SIZE + TXWI_SIZE);
+
+
+#ifdef RTMP_MAC_PCI
+ if ( pAd->MACVersion == 0x28600100 )
+ return MlmeHardTransmitTxRing(pAd,QueIdx,pPacket);
+ else
+#endif // RTMP_MAC_PCI //
+ 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;
+ UCHAR PID;
+
+ RTMP_QueryPacketInfo(pPacket, &PacketInfo, &pSrcBufVA, &SrcBufLen);
+
+ // Make sure MGMT ring resource won't be used by other threads
+ RTMP_SEM_LOCK(&pAd->MgmtRingLock);
+ if (pSrcBufVA == NULL)
+ {
+ // The buffer shouldn't be NULL
+ 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 = PWR_ACTIVE; // (pAd->StaCfg.Psm == PWR_SAVE);
+
+#ifdef CONFIG_STA_SUPPORT
+ //
+ // In WMM-UAPSD, mlme frame should be set psm as power saving but probe request frame
+ // 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 ((pHeader_802_11->FC.SubType == SUBTYPE_ACTION) ||
+ ((pHeader_802_11->FC.Type == BTYPE_DATA) &&
+ ((pHeader_802_11->FC.SubType == SUBTYPE_QOS_NULL) ||
+ (pHeader_802_11->FC.SubType == SUBTYPE_NULL_FUNC))))
+ {
+ if (pAd->StaCfg.Psm == PWR_SAVE)
+ pHeader_802_11->FC.PwrMgmt = PWR_SAVE;
+ else
+ 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
+ {
+#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) && (pHeader_802_11->FC.Type == BTYPE_MGMT))
+ {
+ bInsertTimestamp = TRUE;
+ bAckRequired = FALSE; // Disable ACK to prevent retry 0x1f for Probe Response
+ }
+ else if ((pHeader_802_11->FC.SubType == SUBTYPE_PROBE_REQ) && (pHeader_802_11->FC.Type == BTYPE_MGMT))
+ {
+ bAckRequired = FALSE; // Disable ACK to prevent retry 0x1f for Probe Request
+ }
+ }
+ }
+
+ 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 physical 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.
+ PID = PID_MGMT;
+
+
+ if (pMacEntry == NULL)
+ {
+ RTMPWriteTxWI(pAd, pFirstTxWI, FALSE, FALSE, bInsertTimestamp, FALSE, bAckRequired, FALSE,
+ 0, RESERVED_WCID, (SrcBufLen - TXINFO_SIZE - TXWI_SIZE), PID, 0, (UCHAR)pAd->CommonCfg.MlmeTransmit.field.MCS, IFS_BACKOFF, FALSE, &pAd->CommonCfg.MlmeTransmit);
+ }
+ else
+ {
+ /* dont use low rate to send QoS Null data frame */
+ 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 ((pAd->OpMode == OPMODE_STA) &&
+ (ADHOC_ON(pAd)) &&
+ (RX_FILTER_TEST_FLAG(pAd, fRX_FILTER_ACCEPT_PROMISCUOUS)))
+ {
+ if(pAd->CommonCfg.PSPXlink)
+ TX_BLK_CLEAR_FLAG(pTxBlk, fTX_bAckRequired);
+ }
+#endif // CONFIG_STA_SUPPORT //
+
+ {
+
+#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;
+}
+
+
+BOOLEAN CanDoAggregateTransmit(
+ IN RTMP_ADAPTER *pAd,
+ IN NDIS_PACKET *pPacket,
+ IN TX_BLK *pTxBlk)
+{
+
+ //DBGPRINT(RT_DEBUG_TRACE, ("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;
+
+ RTMP_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))))
+ {
+ RTMP_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;
+ }
+
+#ifdef RTMP_MAC_PCI
+ FreeNumber[QueIdx] = GET_TXRING_FREENO(pAd, QueIdx);
+
+#ifdef DBG_DIAGNOSE
+ if (firstRound == TRUE)
+ {
+ UCHAR txDescNumLevel, txSwQNumLevel;
+
+ txDescNumLevel = (TX_RING_SIZE - FreeNumber[QueIdx]); // Number of occupied hw desc.
+ txDescNumLevel = ((txDescNumLevel <=15) ? txDescNumLevel : 15);
+ pDiagStruct->TxDescCnt[pDiagStruct->ArrayCurIdx][txDescNumLevel]++;
+
+ txSwQNumLevel = ((pAd->TxSwQueue[QueIdx].Number <=7) ? pAd->TxSwQueue[QueIdx].Number : 8);
+ pDiagStruct->TxSWQueCnt[pDiagStruct->ArrayCurIdx][txSwQNumLevel]++;
+
+ firstRound = FALSE;
+ }
+#endif // DBG_DIAGNOSE //
+
+ if (FreeNumber[QueIdx] <= 5)
+ {
+ // free Tx(QueIdx) resources
+ RTMPFreeTXDUponTxDmaDone(pAd, QueIdx);
+ FreeNumber[QueIdx] = GET_TXRING_FREENO(pAd, QueIdx);
+ }
+#endif // RTMP_MAC_PCI //
+
+ // 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_PACKET(pEntry);
+
+
+ // Early check to make sure we have enoguh Tx Resource.
+ hasTxDesc = RTMP_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_PACKET(pEntry);
+ FreeNumber[QueIdx] = GET_TXRING_FREENO(pAd, QueIdx);
+ hasTxDesc = RTMP_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_PACKET(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;
+ }
+
+
+ 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 //
+
+#ifdef RTMP_MAC_PCI
+ 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 // RTMP_MAC_PCI //
+
+ }
+
+ RTMP_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 //
+
+ }
+
+}
+
+
+/*
+ ========================================================================
+
+ 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 (pAd->MACVersion == 0x28720200)
+ {
+ if( BASize >13 )
+ BASize =13;
+ }
+ else
+ {
+ 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 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 //
+#endif // DOT11_N_SUPPORT //
+
+ 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;
+
+}
+
+
+// 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;
+ }
+
+ //DBGPRINT(RT_DEBUG_TRACE,("%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);
+ if (Elem != NULL)
+ {
+ 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);
+ REPORT_MGMT_FRAME_TO_MLME(pAd, BSSID_WCID, Elem->Msg, Elem->MsgLen, 0, 0, 0, 0);
+ 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;
+#ifdef RTMP_MAC_PCI
+ AsicRemovePairwiseKeyEntry(pAd, pEntry->apidx, (UCHAR)i);
+#endif // RTMP_MAC_PCI //
+ }
+#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->AssocDeadLine = MAC_TABLE_ASSOC_TIMEOUT;
+ pEntry->ContinueTxFailCnt = 0;
+#ifdef WDS_SUPPORT
+ pEntry->LockEntryTx = FALSE;
+ pEntry->TimeStamp_toTxRing = 0;
+#endif // WDS_SUPPORT //
+ InitializeQueueHeader(&pEntry->PsQueue);
+
+
+ pAd->MacTab.Size ++;
+ // Add this entry into ASIC RX WCID search table
+ RTMP_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
+ RTMP_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);
+
+ RTMP_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
+ {
+ DBGPRINT(RT_DEBUG_OFF, ("\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*/);
+ RTMP_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++)
+ {
+#ifdef RTMP_MAC_PCI
+ RTMP_STA_ENTRY_MAC_RESET(pAd, i);
+#endif // RTMP_MAC_PCI //
+ 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;
+
+
+
+
+ //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((PNDIS_BUFFER)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((PNDIS_BUFFER)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(get_unaligned((PUINT16)(pSrcBuf)));
+ dstPort = OS_NTOHS(get_unaligned((PUINT16)(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);
+
+
+ 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);
+ }
+ }
+}
diff --git a/drivers/staging/rt3090/common/cmm_data_pci.c b/drivers/staging/rt3090/common/cmm_data_pci.c
new file mode 100644
index 000000000000..084f81927158
--- /dev/null
+++ b/drivers/staging/rt3090/common/cmm_data_pci.c
@@ -0,0 +1,1576 @@
+/*
+ *************************************************************************
+ * 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 PCI-depended, or you should out your function
+ in other files.
+
+*/
+#include "../rt_config.h"
+
+
+USHORT RtmpPCI_WriteTxResource(
+ IN PRTMP_ADAPTER pAd,
+ IN TX_BLK *pTxBlk,
+ IN BOOLEAN bIsLast,
+ OUT USHORT *FreeNumber)
+{
+
+ UCHAR *pDMAHeaderBufVA;
+ USHORT TxIdx, RetTxIdx;
+ PTXD_STRUC pTxD;
+ UINT32 BufBasePaLow;
+ PRTMP_TX_RING pTxRing;
+ USHORT hwHeaderLen;
+
+ //
+ // get Tx Ring Resource
+ //
+ pTxRing = &pAd->TxRing[pTxBlk->QueIdx];
+ TxIdx = pAd->TxRing[pTxBlk->QueIdx].TxCpuIdx;
+ pDMAHeaderBufVA = (PUCHAR) pTxRing->Cell[TxIdx].DmaBuf.AllocVa;
+ BufBasePaLow = RTMP_GetPhysicalAddressLow(pTxRing->Cell[TxIdx].DmaBuf.AllocPa);
+
+ // copy TXINFO + TXWI + WLAN Header + LLC into DMA Header Buffer
+ if (pTxBlk->TxFrameType == TX_AMSDU_FRAME)
+ {
+ //hwHeaderLen = ROUND_UP(pTxBlk->MpduHeaderLen-LENGTH_AMSDU_SUBFRAMEHEAD, 4)+LENGTH_AMSDU_SUBFRAMEHEAD;
+ hwHeaderLen = pTxBlk->MpduHeaderLen - LENGTH_AMSDU_SUBFRAMEHEAD + pTxBlk->HdrPadLen + LENGTH_AMSDU_SUBFRAMEHEAD;
+ }
+ else
+ {
+ //hwHeaderLen = ROUND_UP(pTxBlk->MpduHeaderLen, 4);
+ hwHeaderLen = pTxBlk->MpduHeaderLen + pTxBlk->HdrPadLen;
+ }
+ NdisMoveMemory(pDMAHeaderBufVA, pTxBlk->HeaderBuf, TXINFO_SIZE + TXWI_SIZE + hwHeaderLen);
+
+ pTxRing->Cell[TxIdx].pNdisPacket = pTxBlk->pPacket;
+ pTxRing->Cell[TxIdx].pNextNdisPacket = NULL;
+
+ //
+ // build Tx Descriptor
+ //
+
+ pTxD = (PTXD_STRUC) pTxRing->Cell[TxIdx].AllocVa;
+ NdisZeroMemory(pTxD, TXD_SIZE);
+
+ pTxD->SDPtr0 = BufBasePaLow;
+ pTxD->SDLen0 = TXINFO_SIZE + TXWI_SIZE + hwHeaderLen; // include padding
+ pTxD->SDPtr1 = PCI_MAP_SINGLE(pAd, pTxBlk, 0, 1, PCI_DMA_TODEVICE);
+ pTxD->SDLen1 = pTxBlk->SrcBufLen;
+ pTxD->LastSec0 = 0;
+ pTxD->LastSec1 = (bIsLast) ? 1 : 0;
+
+ RTMPWriteTxDescriptor(pAd, pTxD, FALSE, FIFO_EDCA);
+
+ RetTxIdx = TxIdx;
+ //
+ // Update Tx index
+ //
+ INC_RING_INDEX(TxIdx, TX_RING_SIZE);
+ pTxRing->TxCpuIdx = TxIdx;
+
+ *FreeNumber -= 1;
+
+ return RetTxIdx;
+}
+
+
+USHORT RtmpPCI_WriteSingleTxResource(
+ IN PRTMP_ADAPTER pAd,
+ IN TX_BLK *pTxBlk,
+ IN BOOLEAN bIsLast,
+ OUT USHORT *FreeNumber)
+{
+
+ 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;
+
+ //
+ // get Tx Ring Resource
+ //
+ pTxRing = &pAd->TxRing[pTxBlk->QueIdx];
+ TxIdx = pAd->TxRing[pTxBlk->QueIdx].TxCpuIdx;
+ pDMAHeaderBufVA = (PUCHAR) pTxRing->Cell[TxIdx].DmaBuf.AllocVa;
+ BufBasePaLow = RTMP_GetPhysicalAddressLow(pTxRing->Cell[TxIdx].DmaBuf.AllocPa);
+
+ // copy TXINFO + TXWI + WLAN Header + LLC into DMA Header Buffer
+ //hwHeaderLen = ROUND_UP(pTxBlk->MpduHeaderLen, 4);
+ hwHeaderLen = pTxBlk->MpduHeaderLen + pTxBlk->HdrPadLen;
+
+ NdisMoveMemory(pDMAHeaderBufVA, pTxBlk->HeaderBuf, TXINFO_SIZE + TXWI_SIZE + hwHeaderLen);
+
+ pTxRing->Cell[TxIdx].pNdisPacket = pTxBlk->pPacket;
+ pTxRing->Cell[TxIdx].pNextNdisPacket = NULL;
+
+ //
+ // 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;
+ pTxD->SDLen0 = TXINFO_SIZE + TXWI_SIZE + hwHeaderLen; // include padding
+ pTxD->SDPtr1 = PCI_MAP_SINGLE(pAd, pTxBlk, 0, 1, PCI_DMA_TODEVICE);;
+ pTxD->SDLen1 = pTxBlk->SrcBufLen;
+ pTxD->LastSec0 = 0;
+ 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;
+ //
+ // Update Tx index
+ //
+ INC_RING_INDEX(TxIdx, TX_RING_SIZE);
+ pTxRing->TxCpuIdx = TxIdx;
+
+ *FreeNumber -= 1;
+
+ return RetTxIdx;
+}
+
+
+USHORT RtmpPCI_WriteMultiTxResource(
+ IN PRTMP_ADAPTER pAd,
+ IN TX_BLK *pTxBlk,
+ IN UCHAR frameNum,
+ OUT USHORT *FreeNumber)
+{
+ BOOLEAN bIsLast;
+ 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;
+ UINT32 firstDMALen;
+
+ bIsLast = ((frameNum == (pTxBlk->TotalFrameNum - 1)) ? 1 : 0);
+
+ //
+ // get Tx Ring Resource
+ //
+ pTxRing = &pAd->TxRing[pTxBlk->QueIdx];
+ TxIdx = pAd->TxRing[pTxBlk->QueIdx].TxCpuIdx;
+ pDMAHeaderBufVA = (PUCHAR) pTxRing->Cell[TxIdx].DmaBuf.AllocVa;
+ BufBasePaLow = RTMP_GetPhysicalAddressLow(pTxRing->Cell[TxIdx].DmaBuf.AllocPa);
+
+ if (frameNum == 0)
+ {
+ // 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;
+
+ firstDMALen = TXINFO_SIZE + TXWI_SIZE + hwHdrLen;
+ }
+ else
+ {
+ firstDMALen = pTxBlk->MpduHeaderLen;
+ }
+
+ NdisMoveMemory(pDMAHeaderBufVA, pTxBlk->HeaderBuf, firstDMALen);
+
+ pTxRing->Cell[TxIdx].pNdisPacket = pTxBlk->pPacket;
+ pTxRing->Cell[TxIdx].pNextNdisPacket = NULL;
+
+ //
+ // 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;
+ pTxD->SDLen0 = firstDMALen; // include padding
+ pTxD->SDPtr1 = PCI_MAP_SINGLE(pAd, pTxBlk, 0, 1, PCI_DMA_TODEVICE);;
+ pTxD->SDLen1 = pTxBlk->SrcBufLen;
+ pTxD->LastSec0 = 0;
+ pTxD->LastSec1 = (bIsLast) ? 1 : 0;
+
+ 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
+ //
+ INC_RING_INDEX(TxIdx, TX_RING_SIZE);
+ pTxRing->TxCpuIdx = TxIdx;
+
+ *FreeNumber -= 1;
+
+ return RetTxIdx;
+
+}
+
+
+VOID RtmpPCI_FinalWriteTxResource(
+ IN PRTMP_ADAPTER pAd,
+ IN TX_BLK *pTxBlk,
+ IN USHORT totalMPDUSize,
+ IN USHORT FirstTxIdx)
+{
+
+ PTXWI_STRUC pTxWI;
+ PRTMP_TX_RING pTxRing;
+
+ //
+ // get Tx Ring Resource
+ //
+ 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 //
+
+}
+
+
+VOID RtmpPCIDataLastTxIdx(
+ IN PRTMP_ADAPTER pAd,
+ IN UCHAR QueIdx,
+ IN USHORT LastTxIdx)
+{
+ PTXD_STRUC pTxD;
+#ifdef RT_BIG_ENDIAN
+ PTXD_STRUC pDestTxD;
+ TXD_STRUC TxD;
+#endif
+ PRTMP_TX_RING pTxRing;
+
+ //
+ // get Tx Ring Resource
+ //
+ pTxRing = &pAd->TxRing[QueIdx];
+
+ //
+ // 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 //
+
+}
+
+
+USHORT RtmpPCI_WriteFragTxResource(
+ IN PRTMP_ADAPTER pAd,
+ IN TX_BLK *pTxBlk,
+ IN UCHAR fragNum,
+ OUT USHORT *FreeNumber)
+{
+ 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;
+ UINT32 firstDMALen;
+
+ //
+ // Get Tx Ring Resource
+ //
+ pTxRing = &pAd->TxRing[pTxBlk->QueIdx];
+ TxIdx = pAd->TxRing[pTxBlk->QueIdx].TxCpuIdx;
+ pDMAHeaderBufVA = (PUCHAR) pTxRing->Cell[TxIdx].DmaBuf.AllocVa;
+ BufBasePaLow = RTMP_GetPhysicalAddressLow(pTxRing->Cell[TxIdx].DmaBuf.AllocPa);
+
+ //
+ // Copy TXINFO + TXWI + WLAN Header + LLC into DMA Header Buffer
+ //
+ //hwHeaderLen = ROUND_UP(pTxBlk->MpduHeaderLen, 4);
+ hwHeaderLen = pTxBlk->MpduHeaderLen + pTxBlk->HdrPadLen;
+
+ firstDMALen = TXINFO_SIZE + TXWI_SIZE + hwHeaderLen;
+ NdisMoveMemory(pDMAHeaderBufVA, pTxBlk->HeaderBuf, firstDMALen);
+
+
+ //
+ // 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)
+ {
+ pTxRing->Cell[TxIdx].pNdisPacket = pTxBlk->pPacket;
+ pTxRing->Cell[TxIdx].pNextNdisPacket = NULL;
+ }
+
+ pTxD->SDPtr0 = BufBasePaLow;
+ pTxD->SDLen0 = firstDMALen; // include padding
+ pTxD->SDPtr1 = PCI_MAP_SINGLE(pAd, pTxBlk, 0, 1, PCI_DMA_TODEVICE);
+ pTxD->SDLen1 = pTxBlk->SrcBufLen;
+ pTxD->LastSec0 = 0;
+ pTxD->LastSec1 = 1;
+
+ 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;
+
+ //
+ // Update Tx index
+ //
+ INC_RING_INDEX(TxIdx, TX_RING_SIZE);
+ pTxRing->TxCpuIdx = TxIdx;
+
+ *FreeNumber -= 1;
+
+ return RetTxIdx;
+
+}
+
+
+/*
+ Must be run in Interrupt context
+ This function handle PCI specific TxDesc and cpu index update and kick the packet out.
+ */
+int RtmpPCIMgmtKickOut(
+ IN RTMP_ADAPTER *pAd,
+ IN UCHAR QueIdx,
+ IN PNDIS_PACKET pPacket,
+ IN PUCHAR pSrcBufVA,
+ 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;
+
+ RTMPWriteTxDescriptor(pAd, pTxD, TRUE, FIFO_MGMT);
+ pTxD->LastSec0 = 1;
+ pTxD->LastSec1 = 1;
+ pTxD->DMADONE = 0;
+ pTxD->SDLen1 = 0;
+ 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
+
+//==================================================================
+/* DBGPRINT_RAW(RT_DEBUG_TRACE, ("MLMEHardTransmit\n"));
+ for (i = 0; i < (TXWI_SIZE+24); i++)
+ {
+
+ DBGPRINT_RAW(RT_DEBUG_TRACE, ("%x:", *(pSrcBufVA+i)));
+ if ( i%4 == 3)
+ DBGPRINT_RAW(RT_DEBUG_TRACE, (" :: "));
+ if ( i%16 == 15)
+ DBGPRINT_RAW(RT_DEBUG_TRACE, ("\n "));
+ }
+ DBGPRINT_RAW(RT_DEBUG_TRACE, ("\n "));*/
+//=======================================================================
+
+ pAd->RalinkCounters.KickTxCount++;
+ pAd->RalinkCounters.OneSecTxDoneCount++;
+
+ // Increase TX_CTX_IDX, but write to register later.
+ INC_RING_INDEX(pAd->MgmtRing.TxCpuIdx, MGMT_RING_SIZE);
+
+ RTMP_IO_WRITE32(pAd, TX_MGMTCTX_IDX, pAd->MgmtRing.TxCpuIdx);
+
+ return 0;
+}
+
+
+#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 pRxD)
+{
+ PCIPHER_KEY pWpaKey;
+ INT dBm;
+
+ // Phy errors & CRC errors
+ if (/*(pRxD->PhyErr) ||*/ (pRxD->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 += (pRxD->SDL0 + 14);
+
+ // Drop ToDs promiscous frame, it is opened due to CCX 2 channel load statistics
+ if (pHeader != NULL)
+ {
+ if (pHeader->FC.ToDs)
+ {
+ 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 (pRxD->CipherErr)
+ {
+ if (pRxD->CipherErr == 2)
+ {DBGPRINT_RAW(RT_DEBUG_TRACE,("pRxD ERROR: ICV ok but MICErr "));}
+ else if (pRxD->CipherErr == 1)
+ {DBGPRINT_RAW(RT_DEBUG_TRACE,("pRxD ERROR: ICV Err "));}
+ else if (pRxD->CipherErr == 3)
+ DBGPRINT_RAW(RT_DEBUG_TRACE,("pRxD ERROR: Key not valid "));
+
+ if (((pRxD->CipherErr & 1) == 1) && pAd->CommonCfg.bWirelessEvent && INFRA_ON(pAd))
+ RTMPSendWirelessEvent(pAd, IW_ICV_ERROR_EVENT_FLAG, pAd->MacTab.Content[BSSID_WCID].Addr, BSS0, 0);
+
+ DBGPRINT_RAW(RT_DEBUG_TRACE,(" %d (len=%d, Mcast=%d, MyBss=%d, Wcid=%d, KeyId=%d)\n",
+ pRxD->CipherErr,
+ pRxD->SDL0,
+ pRxD->Mcast | pRxD->Bcast,
+ pRxD->MyBss,
+ pRxWI->WirelessCliID,
+// CipherName[pRxD->CipherAlg],
+ pRxWI->KeyIndex));
+
+ //
+ // MIC Error
+ //
+ 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))
+ RTMPSendWirelessEvent(pAd, IW_MIC_ERROR_EVENT_FLAG, pAd->MacTab.Content[BSSID_WCID].Addr, BSS0, 0);
+
+ DBGPRINT_RAW(RT_DEBUG_ERROR,("Rx MIC Value error\n"));
+ }
+
+ if (pHeader == NULL)
+ return(NDIS_STATUS_SUCCESS);
+ /*if ((pRxD->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);
+}
+#endif // CONFIG_STA_SUPPORT //
+
+
+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;
+ //ULONG IrqFlags;
+ BOOLEAN bReschedule = FALSE;
+
+
+ ASSERT(QueIdx < NUM_OF_TX_RING);
+ pTxRing = &pAd->TxRing[QueIdx];
+
+ RTMP_IO_READ32(pAd, TX_DTX_IDX0 + QueIdx * RINGREG_DIFF, &pTxRing->TxDmaIdx);
+ while (pTxRing->TxSwFreeIdx != pTxRing->TxDmaIdx)
+ {
+// RTMP_IRQ_LOCK(&pAd->irq_lock, IrqFlags);
+#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->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.OneSecTransmittedByteCount += (pTxD->SDLen1 + pTxD->SDLen0);
+ pAd->RalinkCounters.OneSecDmaDoneCount[QueIdx] ++;
+ INC_RING_INDEX(pTxRing->TxSwFreeIdx, TX_RING_SIZE);
+
+ /* get TX_DTX_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))
+ {
+ 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;
+ if (pPacket)
+ {
+#ifdef CONFIG_5VT_ENHANCE
+ if (RTMP_GET_PACKET_5VT(pPacket))
+ PCI_UNMAP_SINGLE(pAd, pTxD->SDPtr1, 16, PCI_DMA_TODEVICE);
+ else
+#endif // CONFIG_5VT_ENHANCE //
+ PCI_UNMAP_SINGLE(pAd, pTxD->SDPtr1, pTxD->SDLen1, PCI_DMA_TODEVICE);
+ RELEASE_NDIS_PACKET(pAd, pPacket, NDIS_STATUS_SUCCESS);
+ }
+ //Always assign pNdisPacket as NULL after clear
+ pTxRing->Cell[pTxRing->TxSwFreeIdx].pNdisPacket = NULL;
+
+ pPacket = pTxRing->Cell[pTxRing->TxSwFreeIdx].pNextNdisPacket;
+
+ ASSERT(pPacket == NULL);
+ if (pPacket)
+ {
+#ifdef CONFIG_5VT_ENHANCE
+ if (RTMP_GET_PACKET_5VT(pPacket))
+ PCI_UNMAP_SINGLE(pAd, pTxD->SDPtr1, 16, PCI_DMA_TODEVICE);
+ else
+#endif // CONFIG_5VT_ENHANCE //
+ 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[pTxRing->TxSwFreeIdx].pNextNdisPacket = NULL;
+ }
+
+ 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);
+#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
+ 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
+ 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 //
+// RTMP_IRQ_UNLOCK(&pAd->irq_lock, IrqFlags);
+ }
+
+
+ return bReschedule;
+
+}
+
+
+/*
+ ========================================================================
+
+ Routine Description:
+ Process TX Rings DMA Done interrupt, running in DPC level
+
+ Arguments:
+ Adapter Pointer to our adapter
+
+ Return Value:
+ None
+
+ IRQL = DISPATCH_LEVEL
+
+ ========================================================================
+*/
+BOOLEAN RTMPHandleTxRingDmaDoneInterrupt(
+ IN PRTMP_ADAPTER pAd,
+ IN INT_SOURCE_CSR_STRUC TxRingBitmap)
+{
+// UCHAR Count = 0;
+ unsigned long IrqFlags;
+ BOOLEAN bReschedule = FALSE;
+
+ // Make sure Tx ring resource won't be used by other threads
+ //NdisAcquireSpinLock(&pAd->TxRingLock);
+
+ RTMP_IRQ_LOCK(&pAd->irq_lock, IrqFlags);
+
+ if (TxRingBitmap.field.Ac0DmaDone)
+ bReschedule = RTMPFreeTXDUponTxDmaDone(pAd, QID_AC_BE);
+/*
+ if (TxRingBitmap.field.HccaDmaDone)
+ bReschedule |= RTMPFreeTXDUponTxDmaDone(pAd, QID_HCCA);
+*/
+
+ if (TxRingBitmap.field.Ac3DmaDone)
+ bReschedule |= RTMPFreeTXDUponTxDmaDone(pAd, QID_AC_VO);
+
+ if (TxRingBitmap.field.Ac2DmaDone)
+ bReschedule |= RTMPFreeTXDUponTxDmaDone(pAd, QID_AC_VI);
+
+ if (TxRingBitmap.field.Ac1DmaDone)
+ bReschedule |= RTMPFreeTXDUponTxDmaDone(pAd, QID_AC_BK);
+
+ // Make sure to release Tx ring resource
+ //NdisReleaseSpinLock(&pAd->TxRingLock);
+ RTMP_IRQ_UNLOCK(&pAd->irq_lock, IrqFlags);
+
+ // Dequeue outgoing frames from TxSwQueue[] and process it
+ RTMPDeQueuePacket(pAd, FALSE, NUM_OF_TX_RING, MAX_TX_PROCESS);
+
+ return bReschedule;
+}
+
+
+/*
+ ========================================================================
+
+ Routine Description:
+ Process MGMT ring DMA done interrupt, running in DPC level
+
+ Arguments:
+ pAd Pointer to our adapter
+
+ Return Value:
+ None
+
+ IRQL = DISPATCH_LEVEL
+
+ Note:
+
+ ========================================================================
+*/
+VOID RTMPHandleMgmtRingDmaDoneInterrupt(
+ IN PRTMP_ADAPTER pAd)
+{
+ PTXD_STRUC pTxD;
+#ifdef RT_BIG_ENDIAN
+ PTXD_STRUC pDestTxD;
+ TXD_STRUC TxD;
+#endif
+ PNDIS_PACKET pPacket;
+// int i;
+ UCHAR FREE = 0;
+ PRTMP_MGMT_RING pMgmtRing = &pAd->MgmtRing;
+
+ NdisAcquireSpinLock(&pAd->MgmtRingLock);
+
+ RTMP_IO_READ32(pAd, TX_MGMTDTX_IDX, &pMgmtRing->TxDmaIdx);
+ 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;
+
+
+ if (pPacket)
+ {
+ PCI_UNMAP_SINGLE(pAd, pTxD->SDPtr0, pTxD->SDLen0, PCI_DMA_TODEVICE);
+ RELEASE_NDIS_PACKET(pAd, pPacket, NDIS_STATUS_SUCCESS);
+ }
+ pMgmtRing->Cell[pMgmtRing->TxSwFreeIdx].pNdisPacket = NULL;
+
+ pPacket = pMgmtRing->Cell[pMgmtRing->TxSwFreeIdx].pNextNdisPacket;
+ if (pPacket)
+ {
+ PCI_UNMAP_SINGLE(pAd, pTxD->SDPtr1, pTxD->SDLen1, PCI_DMA_TODEVICE);
+ RELEASE_NDIS_PACKET(pAd, pPacket, NDIS_STATUS_SUCCESS);
+ }
+ 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);
+
+#ifdef CONFIG_STA_SUPPORT
+#endif // CONFIG_STA_SUPPORT //
+}
+
+
+/*
+ ========================================================================
+
+ Routine Description:
+ Arguments:
+ Adapter Pointer to our adapter. Dequeue all power safe delayed braodcast frames after beacon.
+
+ IRQL = DISPATCH_LEVEL
+
+ ========================================================================
+*/
+VOID RTMPHandleTBTTInterrupt(
+ IN PRTMP_ADAPTER pAd)
+{
+ {
+ if (OPSTATUS_TEST_FLAG(pAd, fOP_STATUS_DOZE))
+ {
+ }
+ }
+}
+
+
+/*
+ ========================================================================
+
+ Routine Description:
+ Arguments:
+ pAd Pointer to our adapter. Rewrite beacon content before next send-out.
+
+ IRQL = DISPATCH_LEVEL
+
+ ========================================================================
+*/
+VOID RTMPHandlePreTBTTInterrupt(
+ IN PRTMP_ADAPTER pAd)
+{
+ {
+ if (OPSTATUS_TEST_FLAG(pAd, fOP_STATUS_DOZE))
+ {
+ DBGPRINT(RT_DEBUG_TRACE, ("RTMPHandlePreTBTTInterrupt...\n"));
+ }
+ }
+
+
+}
+
+VOID RTMPHandleRxCoherentInterrupt(
+ IN PRTMP_ADAPTER pAd)
+{
+ WPDMA_GLO_CFG_STRUC GloCfg;
+
+ if (pAd == NULL)
+ {
+ DBGPRINT(RT_DEBUG_TRACE, ("====> pAd is NULL, return.\n"));
+ return;
+ }
+
+ DBGPRINT(RT_DEBUG_TRACE, ("==> RTMPHandleRxCoherentInterrupt \n"));
+
+ RTMP_IO_READ32(pAd, WPDMA_GLO_CFG , &GloCfg.word);
+
+ GloCfg.field.EnTXWriteBackDDONE = 0;
+ GloCfg.field.EnableRxDMA = 0;
+ GloCfg.field.EnableTxDMA = 0;
+ RTMP_IO_WRITE32(pAd, WPDMA_GLO_CFG, GloCfg.word);
+
+ RTMPRingCleanUp(pAd, QID_AC_BE);
+ RTMPRingCleanUp(pAd, QID_AC_BK);
+ RTMPRingCleanUp(pAd, QID_AC_VI);
+ RTMPRingCleanUp(pAd, QID_AC_VO);
+ /*RTMPRingCleanUp(pAd, QID_HCCA);*/
+ RTMPRingCleanUp(pAd, QID_MGMT);
+ RTMPRingCleanUp(pAd, QID_RX);
+
+ RTMPEnableRxTx(pAd);
+
+ DBGPRINT(RT_DEBUG_TRACE, ("<== RTMPHandleRxCoherentInterrupt \n"));
+}
+
+
+
+
+VOID DBGPRINT_TX_RING(
+ IN PRTMP_ADAPTER pAd,
+ IN UCHAR QueIdx)
+{
+ UINT32 Ac0Base;
+ UINT32 Ac0HwIdx = 0, Ac0SwIdx = 0, AC0freeIdx;
+ int i;
+// PULONG pTxD;
+ PULONG ptemp;
+
+ DBGPRINT_RAW(RT_DEBUG_TRACE, ("=====================================================\n " ));
+ switch (QueIdx)
+ {
+ case QID_AC_BE:
+ RTMP_IO_READ32(pAd, TX_BASE_PTR0, &Ac0Base);
+ RTMP_IO_READ32(pAd, TX_CTX_IDX0, &Ac0SwIdx);
+ RTMP_IO_READ32(pAd, TX_DTX_IDX0, &Ac0HwIdx);
+ DBGPRINT_RAW(RT_DEBUG_TRACE, ("All QID_AC_BE DESCRIPTOR \n " ));
+ for (i=0;i<TX_RING_SIZE;i++)
+ {
+ ptemp= (PULONG)pAd->TxRing[QID_AC_BE].Cell[i].AllocVa;
+ DBGPRINT_RAW(RT_DEBUG_TRACE, ("[%02d] %08lx: %08lx: %08lx: %08lx\n " , i, *ptemp,*(ptemp+1),*(ptemp+2),*(ptemp+3)));
+ }
+ DBGPRINT_RAW(RT_DEBUG_TRACE, (" \n " ));
+ break;
+ case QID_AC_BK:
+ RTMP_IO_READ32(pAd, TX_BASE_PTR1, &Ac0Base);
+ RTMP_IO_READ32(pAd, TX_CTX_IDX1, &Ac0SwIdx);
+ RTMP_IO_READ32(pAd, TX_DTX_IDX1, &Ac0HwIdx);
+ DBGPRINT_RAW(RT_DEBUG_TRACE, ("All QID_AC_BK DESCRIPTOR \n " ));
+ for (i=0;i<TX_RING_SIZE;i++)
+ {
+ ptemp= (PULONG)pAd->TxRing[QID_AC_BK].Cell[i].AllocVa;
+ DBGPRINT_RAW(RT_DEBUG_TRACE, ("[%02d] %08lx: %08lx: %08lx: %08lx\n " , i, *ptemp,*(ptemp+1),*(ptemp+2),*(ptemp+3)));
+ }
+ DBGPRINT_RAW(RT_DEBUG_TRACE, (" \n " ));
+ break;
+ case QID_AC_VI:
+ RTMP_IO_READ32(pAd, TX_BASE_PTR2, &Ac0Base);
+ RTMP_IO_READ32(pAd, TX_CTX_IDX2, &Ac0SwIdx);
+ RTMP_IO_READ32(pAd, TX_DTX_IDX2, &Ac0HwIdx);
+ DBGPRINT_RAW(RT_DEBUG_TRACE, ("All QID_AC_VI DESCRIPTOR \n " ));
+ for (i=0;i<TX_RING_SIZE;i++)
+ {
+ ptemp= (PULONG)pAd->TxRing[QID_AC_VI].Cell[i].AllocVa;
+ DBGPRINT_RAW(RT_DEBUG_TRACE, ("[%02d] %08lx: %08lx: %08lx: %08lx\n " , i, *ptemp,*(ptemp+1),*(ptemp+2),*(ptemp+3)));
+ }
+ DBGPRINT_RAW(RT_DEBUG_TRACE, (" \n " ));
+ break;
+ case QID_AC_VO:
+ RTMP_IO_READ32(pAd, TX_BASE_PTR3, &Ac0Base);
+ RTMP_IO_READ32(pAd, TX_CTX_IDX3, &Ac0SwIdx);
+ RTMP_IO_READ32(pAd, TX_DTX_IDX3, &Ac0HwIdx);
+ DBGPRINT_RAW(RT_DEBUG_TRACE, ("All QID_AC_VO DESCRIPTOR \n " ));
+ for (i=0;i<TX_RING_SIZE;i++)
+ {
+ ptemp= (PULONG)pAd->TxRing[QID_AC_VO].Cell[i].AllocVa;
+ DBGPRINT_RAW(RT_DEBUG_TRACE, ("[%02d] %08lx: %08lx: %08lx: %08lx\n " , i, *ptemp,*(ptemp+1),*(ptemp+2),*(ptemp+3)));
+ }
+ DBGPRINT_RAW(RT_DEBUG_TRACE, (" \n " ));
+ break;
+ case QID_MGMT:
+ RTMP_IO_READ32(pAd, TX_BASE_PTR5, &Ac0Base);
+ RTMP_IO_READ32(pAd, TX_CTX_IDX5, &Ac0SwIdx);
+ RTMP_IO_READ32(pAd, TX_DTX_IDX5, &Ac0HwIdx);
+ DBGPRINT_RAW(RT_DEBUG_TRACE, (" All QID_MGMT DESCRIPTOR \n " ));
+ for (i=0;i<MGMT_RING_SIZE;i++)
+ {
+ ptemp= (PULONG)pAd->MgmtRing.Cell[i].AllocVa;
+ DBGPRINT_RAW(RT_DEBUG_TRACE, ("[%02d] %08lx: %08lx: %08lx: %08lx\n " , i, *ptemp,*(ptemp+1),*(ptemp+2),*(ptemp+3)));
+ }
+ DBGPRINT_RAW(RT_DEBUG_TRACE, (" \n " ));
+ break;
+
+ default:
+ DBGPRINT_ERR(("DBGPRINT_TX_RING(Ring %d) not supported\n", QueIdx));
+ break;
+ }
+ AC0freeIdx = pAd->TxRing[QueIdx].TxSwFreeIdx;
+
+ DBGPRINT(RT_DEBUG_TRACE,("TxRing%d, TX_DTX_IDX=%d, TX_CTX_IDX=%d\n", QueIdx, Ac0HwIdx, Ac0SwIdx));
+ DBGPRINT_RAW(RT_DEBUG_TRACE,(" TxSwFreeIdx[%d]", AC0freeIdx));
+ DBGPRINT_RAW(RT_DEBUG_TRACE,(" pending-NDIS=%ld\n", pAd->RalinkCounters.PendingNdisPacketCount));
+
+
+}
+
+
+VOID DBGPRINT_RX_RING(
+ IN PRTMP_ADAPTER pAd)
+{
+ UINT32 Ac0Base;
+ UINT32 Ac0HwIdx = 0, Ac0SwIdx = 0, AC0freeIdx;
+// PULONG pTxD;
+ int i;
+ UINT32 *ptemp;
+// PRXD_STRUC pRxD;
+
+ DBGPRINT_RAW(RT_DEBUG_TRACE, ("=====================================================\n " ));
+ RTMP_IO_READ32(pAd, RX_BASE_PTR, &Ac0Base);
+ RTMP_IO_READ32(pAd, RX_CRX_IDX, &Ac0SwIdx);
+ RTMP_IO_READ32(pAd, RX_DRX_IDX, &Ac0HwIdx);
+ AC0freeIdx = pAd->RxRing.RxSwReadIdx;
+
+ DBGPRINT_RAW(RT_DEBUG_TRACE, ("All RX DSP \n " ));
+ for (i=0;i<RX_RING_SIZE;i++)
+ {
+ ptemp = (UINT32 *)pAd->RxRing.Cell[i].AllocVa;
+ DBGPRINT_RAW(RT_DEBUG_TRACE, ("[%02d] %08x: %08x: %08x: %08x\n " , i, *ptemp,*(ptemp+1),*(ptemp+2),*(ptemp+3)));
+ }
+ DBGPRINT(RT_DEBUG_TRACE,("RxRing, RX_DRX_IDX=%d, RX_CRX_IDX=%d \n", Ac0HwIdx, Ac0SwIdx));
+ DBGPRINT_RAW(RT_DEBUG_TRACE,(" RxSwReadIdx [%d]=", AC0freeIdx));
+ DBGPRINT_RAW(RT_DEBUG_TRACE,(" pending-NDIS=%ld\n", pAd->RalinkCounters.PendingNdisPacketCount));
+}
+
+
+PNDIS_PACKET GetPacketFromRxRing(
+ IN PRTMP_ADAPTER pAd,
+ OUT PRT28XX_RXD_STRUC pSaveRxD,
+ OUT BOOLEAN *pbReschedule,
+ 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;
+ NDIS_PHYSICAL_ADDRESS AllocPa;
+ BOOLEAN bReschedule = FALSE;
+
+ RTMP_SEM_LOCK(&pAd->RxRingLock);
+
+ if (*pRxPending == 0)
+ {
+ // Get how may packets had been received
+ RTMP_IO_READ32(pAd, RX_DRX_IDX , &pAd->RxRing.RxDmaIdx);
+
+ if (pAd->RxRing.RxSwReadIdx == pAd->RxRing.RxDmaIdx)
+ {
+ // no more rx packets
+ bReschedule = FALSE;
+ goto done;
+ }
+
+ // get rx pending count
+ if (pAd->RxRing.RxDmaIdx > pAd->RxRing.RxSwReadIdx)
+ *pRxPending = pAd->RxRing.RxDmaIdx - pAd->RxRing.RxSwReadIdx;
+ else
+ *pRxPending = pAd->RxRing.RxDmaIdx + RX_RING_SIZE - pAd->RxRing.RxSwReadIdx;
+
+ }
+
+#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)
+ {
+ *pRxPending = 0;
+ // DMAIndx had done but DDONE bit not ready
+ bReschedule = TRUE;
+ goto done;
+ }
+
+
+ // return rx descriptor
+ NdisMoveMemory(pSaveRxD, pRxD, RXD_SIZE);
+
+ pNewPacket = RTMP_AllocateRxPacketBuffer(pAd, RX_BUFFER_AGGRESIZE, FALSE, &AllocVa, &AllocPa);
+
+ if (pNewPacket)
+ {
+ // unmap the rx buffer
+ PCI_UNMAP_SINGLE(pAd, pAd->RxRing.Cell[pAd->RxRing.RxSwReadIdx].DmaBuf.AllocPa,
+ pAd->RxRing.Cell[pAd->RxRing.RxSwReadIdx].DmaBuf.AllocSize, PCI_DMA_FROMDEVICE);
+ pRxPacket = pAd->RxRing.Cell[pAd->RxRing.RxSwReadIdx].pNdisPacket;
+
+ pAd->RxRing.Cell[pAd->RxRing.RxSwReadIdx].DmaBuf.AllocSize = RX_BUFFER_AGGRESIZE;
+ pAd->RxRing.Cell[pAd->RxRing.RxSwReadIdx].pNdisPacket = (PNDIS_PACKET) pNewPacket;
+ pAd->RxRing.Cell[pAd->RxRing.RxSwReadIdx].DmaBuf.AllocVa = AllocVa;
+ pAd->RxRing.Cell[pAd->RxRing.RxSwReadIdx].DmaBuf.AllocPa = AllocPa;
+ /* update SDP0 to new buffer of rx packet */
+ pRxD->SDP0 = AllocPa;
+ }
+ else
+ {
+ //DBGPRINT(RT_DEBUG_TRACE,("No Rx Buffer\n"));
+ pRxPacket = NULL;
+ bReschedule = TRUE;
+ }
+
+ pRxD->DDONE = 0;
+
+ // had handled one rx packet
+ *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);
+ RTMP_IO_WRITE32(pAd, RX_CRX_IDX, pAd->RxRing.RxCpuIdx);
+
+done:
+ RTMP_SEM_UNLOCK(&pAd->RxRingLock);
+ *pbReschedule = bReschedule;
+ return pRxPacket;
+}
+
+
+NDIS_STATUS MlmeHardTransmitTxRing(
+ IN PRTMP_ADAPTER pAd,
+ IN UCHAR QueIdx,
+ IN PNDIS_PACKET pPacket)
+{
+ PACKET_INFO PacketInfo;
+ 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;
+ //UCHAR TxBufIdx;
+ UCHAR MlmeRate;
+ ULONG SwIdx = pAd->TxRing[QueIdx].TxCpuIdx;
+ PTXWI_STRUC pFirstTxWI;
+ //ULONG i;
+ //HTTRANSMIT_SETTING MlmeTransmit; //Rate for this MGMT frame.
+ ULONG FreeNum;
+ MAC_TABLE_ENTRY *pMacEntry = NULL;
+
+
+ RTMP_QueryPacketInfo(pPacket, &PacketInfo, &pSrcBufVA, &SrcBufLen);
+
+
+ if (pSrcBufVA == NULL)
+ {
+ // The buffer shouldn't be NULL
+ return NDIS_STATUS_FAILURE;
+ }
+
+ // Make sure MGMT ring resource won't be used by other threads
+ //NdisAcquireSpinLock(&pAd->TxRingLock);
+
+ FreeNum = GET_TXRING_FREENO(pAd, QueIdx);
+
+ if (FreeNum == 0)
+ {
+ //NdisReleaseSpinLock(&pAd->TxRingLock);
+ return NDIS_STATUS_FAILURE;
+ }
+
+ 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)
+ {
+ DBGPRINT(RT_DEBUG_OFF, ("MlmeHardTransmit Error\n"));
+ //NdisReleaseSpinLock(&pAd->TxRingLock);
+ 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 (pAd->StaCfg.Psm == PWR_SAVE)
+ if (OPSTATUS_TEST_FLAG(pAd, fOP_STATUS_DOZE))
+ AsicForceWakeup(pAd, TRUE);
+ }
+#endif // CONFIG_STA_SUPPORT //
+ pFirstTxWI =(PTXWI_STRUC)pSrcBufVA;
+
+ pHeader_802_11 = (PHEADER_802_11) (pSrcBufVA + TXWI_SIZE);
+ if (pHeader_802_11->Addr1[0] & 0x01)
+ {
+ MlmeRate = pAd->CommonCfg.BasicMlmeRate;
+ }
+ else
+ {
+ MlmeRate = pAd->CommonCfg.MlmeRate;
+ }
+
+ if ((pHeader_802_11->FC.Type == BTYPE_DATA) &&
+ (pHeader_802_11->FC.SubType == SUBTYPE_QOS_NULL))
+ {
+ pMacEntry = MacTableLookup(pAd, pHeader_802_11->Addr1);
+ }
+
+ // Verify Mlme rate for a / g bands.
+ if ((pAd->LatchRfRegs.Channel > 14) && (MlmeRate < RATE_6)) // 11A band
+ MlmeRate = RATE_6;
+
+ //
+ // 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.
+ //
+ //
+ // 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)
+ {
+ if ((pHeader_802_11->FC.SubType == SUBTYPE_PROBE_REQ) || !(pAd->CommonCfg.bAPSDCapable && pAd->CommonCfg.APEdcaParm.bAPSDCapable))
+ {
+ pHeader_802_11->FC.PwrMgmt = PWR_ACTIVE;
+ }
+ else
+ {
+ 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
+ {
+ bAckRequired = FALSE;
+ }
+ else // BTYPE_MGMT or BTYPE_DATA(must be NULL frame)
+ {
+ 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"));
+ //NdisReleaseSpinLock(&pAd->TxRingLock);
+ 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.
+ // Only beacon use Nseq=TRUE. So here we use Nseq=FALSE.
+ if (pMacEntry == NULL)
+ {
+ RTMPWriteTxWI(pAd, pFirstTxWI, FALSE, FALSE, bInsertTimestamp, FALSE, bAckRequired, FALSE,
+ 0, RESERVED_WCID, (SrcBufLen - 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 - TXWI_SIZE),
+ pMacEntry->MaxHTPhyMode.field.MCS, 0,
+ (UCHAR)pMacEntry->MaxHTPhyMode.field.MCS,
+ IFS_BACKOFF, FALSE, &pMacEntry->MaxHTPhyMode);
+ }
+
+ pAd->TxRing[QueIdx].Cell[SwIdx].pNdisPacket = pPacket;
+ pAd->TxRing[QueIdx].Cell[SwIdx].pNextNdisPacket = NULL;
+// pFirstTxWI->MPDUtotalByteCount = SrcBufLen - TXWI_SIZE;
+#ifdef RT_BIG_ENDIAN
+ RTMPWIEndianChange((PUCHAR)pFirstTxWI, TYPE_TXWI);
+#endif
+ SrcBufPA = PCI_MAP_SINGLE(pAd, pSrcBufVA, SrcBufLen, 0, PCI_DMA_TODEVICE);
+
+
+ RTMPWriteTxDescriptor(pAd, pTxD, TRUE, FIFO_EDCA);
+ pTxD->LastSec0 = 1;
+ pTxD->LastSec1 = 1;
+ pTxD->SDLen0 = SrcBufLen;
+ pTxD->SDLen1 = 0;
+ 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++;
+
+ // Increase TX_CTX_IDX, but write to register later.
+ INC_RING_INDEX(pAd->TxRing[QueIdx].TxCpuIdx, TX_RING_SIZE);
+
+ RTMP_IO_WRITE32(pAd, TX_CTX_IDX0 + QueIdx*0x10, pAd->TxRing[QueIdx].TxCpuIdx);
+
+ // Make sure to release MGMT ring resource
+// NdisReleaseSpinLock(&pAd->TxRingLock);
+
+ return NDIS_STATUS_SUCCESS;
+}
+
+
+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;
+ }
+
+ return MlmeHardTransmitTxRing(pAd,QueIdx,pPacket);
+}
+
+
+/*
+ ========================================================================
+
+ 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;
+}
diff --git a/drivers/staging/rt3090/common/cmm_info.c b/drivers/staging/rt3090/common/cmm_info.c
new file mode 100644
index 000000000000..5be0714666cb
--- /dev/null
+++ b/drivers/staging/rt3090/common/cmm_info.c
@@ -0,0 +1,3717 @@
+/*
+ *************************************************************************
+ * 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:
+ cmm_info.c
+
+ Abstract:
+
+ Revision History:
+ Who When What
+ --------- ---------- ----------------------------------------------
+ */
+
+#include "../rt_config.h"
+
+
+INT Show_SSID_Proc(
+ IN PRTMP_ADAPTER pAd,
+ OUT PSTRING pBuf);
+
+INT Show_WirelessMode_Proc(
+ IN PRTMP_ADAPTER pAd,
+ OUT PSTRING pBuf);
+
+INT Show_TxBurst_Proc(
+ IN PRTMP_ADAPTER pAd,
+ OUT PSTRING pBuf);
+
+INT Show_TxPreamble_Proc(
+ IN PRTMP_ADAPTER pAd,
+ OUT PSTRING pBuf);
+
+INT Show_TxPower_Proc(
+ IN PRTMP_ADAPTER pAd,
+ OUT PSTRING pBuf);
+
+INT Show_Channel_Proc(
+ IN PRTMP_ADAPTER pAd,
+ OUT PSTRING pBuf);
+
+INT Show_BGProtection_Proc(
+ IN PRTMP_ADAPTER pAd,
+ OUT PSTRING pBuf);
+
+INT Show_RTSThreshold_Proc(
+ IN PRTMP_ADAPTER pAd,
+ OUT PSTRING pBuf);
+
+INT Show_FragThreshold_Proc(
+ IN PRTMP_ADAPTER pAd,
+ OUT PSTRING pBuf);
+
+#ifdef DOT11_N_SUPPORT
+INT Show_HtBw_Proc(
+ IN PRTMP_ADAPTER pAd,
+ OUT PSTRING pBuf);
+
+INT Show_HtMcs_Proc(
+ IN PRTMP_ADAPTER pAd,
+ OUT PSTRING pBuf);
+
+INT Show_HtGi_Proc(
+ IN PRTMP_ADAPTER pAd,
+ OUT PSTRING pBuf);
+
+INT Show_HtOpMode_Proc(
+ IN PRTMP_ADAPTER pAd,
+ OUT PSTRING pBuf);
+
+INT Show_HtExtcha_Proc(
+ IN PRTMP_ADAPTER pAd,
+ OUT PSTRING pBuf);
+
+INT Show_HtMpduDensity_Proc(
+ IN PRTMP_ADAPTER pAd,
+ OUT PSTRING pBuf);
+
+INT Show_HtBaWinSize_Proc(
+ IN PRTMP_ADAPTER pAd,
+ OUT PSTRING pBuf);
+
+INT Show_HtRdg_Proc(
+ IN PRTMP_ADAPTER pAd,
+ OUT PSTRING pBuf);
+
+INT Show_HtAmsdu_Proc(
+ IN PRTMP_ADAPTER pAd,
+ OUT PSTRING pBuf);
+
+INT Show_HtAutoBa_Proc(
+ IN PRTMP_ADAPTER pAd,
+ OUT PSTRING pBuf);
+#endif // DOT11_N_SUPPORT //
+
+INT Show_CountryRegion_Proc(
+ IN PRTMP_ADAPTER pAd,
+ OUT PSTRING pBuf);
+
+INT Show_CountryRegionABand_Proc(
+ IN PRTMP_ADAPTER pAd,
+ OUT PSTRING pBuf);
+
+INT Show_CountryCode_Proc(
+ IN PRTMP_ADAPTER pAd,
+ OUT PSTRING pBuf);
+
+#ifdef AGGREGATION_SUPPORT
+INT Show_PktAggregate_Proc(
+ IN PRTMP_ADAPTER pAd,
+ OUT PSTRING pBuf);
+#endif // AGGREGATION_SUPPORT //
+
+#ifdef WMM_SUPPORT
+INT Show_WmmCapable_Proc(
+ IN PRTMP_ADAPTER pAd,
+ OUT PSTRING pBuf);
+#endif // WMM_SUPPORT //
+
+INT Show_IEEE80211H_Proc(
+ IN PRTMP_ADAPTER pAd,
+ OUT PSTRING pBuf);
+
+#ifdef CONFIG_STA_SUPPORT
+INT Show_NetworkType_Proc(
+ IN PRTMP_ADAPTER pAd,
+ OUT PSTRING pBuf);
+
+#endif // CONFIG_STA_SUPPORT //
+
+INT Show_AuthMode_Proc(
+ IN PRTMP_ADAPTER pAd,
+ OUT PSTRING pBuf);
+
+INT Show_EncrypType_Proc(
+ IN PRTMP_ADAPTER pAd,
+ OUT PSTRING pBuf);
+
+INT Show_DefaultKeyID_Proc(
+ IN PRTMP_ADAPTER pAd,
+ OUT PSTRING pBuf);
+
+INT Show_Key1_Proc(
+ IN PRTMP_ADAPTER pAd,
+ OUT PSTRING pBuf);
+
+INT Show_Key2_Proc(
+ IN PRTMP_ADAPTER pAd,
+ OUT PSTRING pBuf);
+
+INT Show_Key3_Proc(
+ IN PRTMP_ADAPTER pAd,
+ OUT PSTRING pBuf);
+
+INT Show_Key4_Proc(
+ IN PRTMP_ADAPTER pAd,
+ OUT PSTRING pBuf);
+
+INT Show_WPAPSK_Proc(
+ IN PRTMP_ADAPTER pAd,
+ OUT PSTRING pBuf);
+
+static struct {
+ PSTRING name;
+ INT (*show_proc)(PRTMP_ADAPTER pAdapter, PSTRING 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 PSTRING 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 PSTRING arg)
+{
+ int retval;
+
+#ifdef EXT_BUILD_CHANNEL_LIST
+ return -EOPNOTSUPP;
+#endif // EXT_BUILD_CHANNEL_LIST //
+
+ retval = RT_CfgSetCountryRegion(pAd, arg, BAND_24G);
+ if (retval == FALSE)
+ 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 PSTRING arg)
+{
+ int retval;
+
+#ifdef EXT_BUILD_CHANNEL_LIST
+ return -EOPNOTSUPP;
+#endif // EXT_BUILD_CHANNEL_LIST //
+
+ retval = RT_CfgSetCountryRegion(pAd, arg, BAND_5G);
+ if (retval == FALSE)
+ 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 PSTRING arg)
+{
+ INT success = TRUE;
+
+ success = RT_CfgSetWirelessMode(pAd, arg);
+ if (success)
+ {
+
+#ifdef CONFIG_STA_SUPPORT
+ IF_DEV_CONFIG_OPMODE_ON_STA(pAd)
+ {
+ LONG WirelessMode = pAd->CommonCfg.PhyMode;
+
+ 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
+ }
+ }
+#endif // CONFIG_STA_SUPPORT //
+
+ // it is needed to set SSID to take effect
+#ifdef DOT11_N_SUPPORT
+ SetCommonHT(pAd);
+#endif // DOT11_N_SUPPORT //
+ DBGPRINT(RT_DEBUG_TRACE, ("Set_WirelessMode_Proc::(=%d)\n", pAd->CommonCfg.PhyMode));
+ }
+ 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 PSTRING 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 PSTRING arg)
+{
+ int retval;
+
+ retval = RT_CfgSetShortSlot(pAd, arg);
+ if (retval == TRUE)
+ DBGPRINT(RT_DEBUG_TRACE, ("Set_ShortSlot_Proc::(ShortSlot=%d)\n", pAd->CommonCfg.bUseShortSlotTime));
+
+ return retval;
+}
+
+
+/*
+ ==========================================================================
+ Description:
+ Set Tx power
+ Return:
+ TRUE if all parameters are OK, FALSE otherwise
+ ==========================================================================
+*/
+INT Set_TxPower_Proc(
+ IN PRTMP_ADAPTER pAd,
+ IN PSTRING arg)
+{
+ LONG TxPower;
+ INT success = FALSE;
+
+ TxPower = 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 PSTRING 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 PSTRING 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 PSTRING 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 PSTRING 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 PSTRING arg)
+{
+ LONG 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 PSTRING arg)
+{
+ LONG 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
+
+
+#ifdef INF_AMAZON_PPA
+INT Set_INF_AMAZON_SE_PPA_Proc(
+ IN PRTMP_ADAPTER pAd,
+ IN PUCHAR arg)
+{
+ ULONG aggre;
+ UINT status;
+
+ aggre = simple_strtol(arg, 0, 10);
+
+ if (aggre == 1)
+ {
+ if(pAd->PPAEnable==TRUE)
+ {
+ printk("INF_AMAZON_SE_PPA already enabled \n");
+ }
+ else
+ {
+ if (ppa_hook_directpath_register_dev_fn)
+ {
+ UINT32 g_if_id;
+
+ if (pAd->pDirectpathCb == NULL)
+ {
+ pAd->pDirectpathCb = (PPA_DIRECTPATH_CB *) kmalloc (sizeof(PPA_DIRECTPATH_CB), GFP_ATOMIC);
+ printk("Realloc memory for pDirectpathCb ??\n");
+ }
+
+ /* register callback */
+ pAd->pDirectpathCb->rx_fn = NULL;
+ pAd->pDirectpathCb->stop_tx_fn = NULL;
+ pAd->pDirectpathCb->start_tx_fn = NULL;
+
+ status = ppa_hook_directpath_register_dev_fn(&g_if_id, pAd->net_dev, pAd->pDirectpathCb, PPA_F_DIRECTPATH_ETH_IF);
+
+ if(status==1)
+ {
+ pAd->g_if_id=g_if_id;
+ printk("register INF_AMAZON_SE_PPA success :ret:%d id:%d:%d\n",status,pAd->g_if_id,g_if_id);
+ pAd->PPAEnable=TRUE;
+ }
+ else
+ {
+ printk("register INF_AMAZON_SE_PPA fail :ret:%d\n",status);
+ }
+
+ }
+ else
+ {
+ printk("INF_AMAZON_SE_PPA enable fail : there is no INF_AMAZON_SE_PPA module . \n");
+ }
+ }
+
+
+ }
+ else if (aggre == 0)
+ {
+ if(pAd->PPAEnable==FALSE)
+ {
+
+printk("INF_AMAZON_SE_PPA already disable \n");
+ }
+ else
+ {
+ if (ppa_hook_directpath_register_dev_fn)
+ {
+ UINT32 g_if_id;
+ g_if_id=pAd->g_if_id;
+ printk("g_if_id=%d \n",pAd->g_if_id);
+ status=ppa_hook_directpath_register_dev_fn(&g_if_id, pAd->net_dev, NULL, PPA_F_DIRECTPATH_DEREGISTER);
+
+ if(status==1)
+ {
+ pAd->g_if_id=0;
+ printk("unregister INF_AMAZON_SE_PPA success :ret:%d\n",status);
+ pAd->PPAEnable=FALSE;
+ }
+ else
+ {
+ printk("unregister INF_AMAZON_SE_PPA fail :ret:%d\n",status);
+ }
+
+ }
+ else
+ {
+ printk("INF_AMAZON_SE_PPA enable fail : there is no INF_AMAZON_SE_PPA module . \n");
+ }
+ }
+
+ }
+ else
+ {
+ printk("Invalid argument %d \n",aggre);
+ return FALSE; //Invalid argument
+ }
+
+ return TRUE;
+
+}
+#endif // INF_AMAZON_PPA //
+
+
+/*
+ ==========================================================================
+ 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 PSTRING arg)
+{
+ LONG 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 PSTRING 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 PSTRING arg)
+{
+#ifdef RTMP_MAC_PCI
+ INT i, QueIdx=0;
+// ULONG RegValue;
+ PRT28XX_RXD_STRUC pRxD;
+ PTXD_STRUC pTxD;
+ PRTMP_TX_RING pTxRing = &pAd->TxRing[QueIdx];
+ PRTMP_MGMT_RING pMgmtRing = &pAd->MgmtRing;
+ PRTMP_RX_RING pRxRing = &pAd->RxRing;
+
+ for(i=0;i<TX_RING_SIZE;i++)
+ {
+ pTxD = (PTXD_STRUC) pTxRing->Cell[i].AllocVa;
+ DBGPRINT(RT_DEBUG_OFF, ("Desc #%d\n",i));
+ hex_dump("Tx Descriptor", (PUCHAR)pTxD, 16);
+ DBGPRINT(RT_DEBUG_OFF, ("pTxD->DMADONE = %x\n", pTxD->DMADONE));
+ }
+ DBGPRINT(RT_DEBUG_OFF, ("---------------------------------------------------\n"));
+ for(i=0;i<MGMT_RING_SIZE;i++)
+ {
+ pTxD = (PTXD_STRUC) pMgmtRing->Cell[i].AllocVa;
+ DBGPRINT(RT_DEBUG_OFF, ("Desc #%d\n",i));
+ hex_dump("Mgmt Descriptor", (PUCHAR)pTxD, 16);
+ DBGPRINT(RT_DEBUG_OFF, ("pMgmt->DMADONE = %x\n", pTxD->DMADONE));
+ }
+ DBGPRINT(RT_DEBUG_OFF, ("---------------------------------------------------\n"));
+ for(i=0;i<RX_RING_SIZE;i++)
+ {
+ pRxD = (PRT28XX_RXD_STRUC) pRxRing->Cell[i].AllocVa;
+ DBGPRINT(RT_DEBUG_OFF, ("Desc #%d\n",i));
+ hex_dump("Rx Descriptor", (PUCHAR)pRxD, 16);
+ DBGPRINT(RT_DEBUG_OFF, ("pRxD->DDONE = %x\n", pRxD->DDONE));
+ }
+#endif // RTMP_MAC_PCI //
+
+ 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 PSTRING 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
+
+
+ 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:
+
+ ========================================================================
+*/
+
+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));
+ RTMP_CLEAR_PSFLAG(pAd, fRTMP_PS_CAN_GO_SLEEP);
+ // 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);
+ }
+ RTMP_SET_PSFLAG(pAd, fRTMP_PS_CAN_GO_SLEEP);
+
+}
+#endif // 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
+
+ IRQL = DISPATCH_LEVEL
+
+ Note:
+
+ ========================================================================
+*/
+/*
+ ========================================================================
+ 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;
+ }
+
+ 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)
+ Wcid = pEntry->Aid;
+ 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 RTMP_MAC_PCI
+ RTMP_IO_WRITE8(pAd, offset+3, IVEIV);
+#endif // RTMP_MAC_PCI //
+
+ 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:
+ ==========================================================================
+*/
+PSTRING 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";
+}
+
+PSTRING 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";
+}
+
+
+/*
+ ==========================================================================
+ 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+23+9+7+3) // Channel+SSID+Bssid+Security+Signal+WiressMode+NetworkType
+#ifdef CONFIG_STA_SUPPORT
+#endif // CONFIG_STA_SUPPORT //
+VOID RTMPCommSiteSurveyData(
+ IN PSTRING msg,
+ IN PBSS_ENTRY pBss)
+{
+ INT Rssi = 0;
+ UINT Rssi_Quality = 0;
+ NDIS_802_11_NETWORK_TYPE wireless_mode;
+ CHAR Ssid[MAX_LEN_OF_SSID +1];
+ STRING SecurityStr[32] = {0};
+ NDIS_802_11_ENCRYPTION_STATUS ap_cipher = Ndis802_11EncryptionDisabled;
+ NDIS_802_11_AUTHENTICATION_MODE ap_auth_mode = Ndis802_11AuthModeOpen;
+
+ memset(Ssid, 0 ,(MAX_LEN_OF_SSID +1));
+
+ //Channel
+ sprintf(msg+strlen(msg),"%-4d", pBss->Channel);
+ //SSID
+ memcpy(Ssid, pBss->Ssid, pBss->SsidLen);
+ Ssid[pBss->SsidLen] = '\0';
+ sprintf(msg+strlen(msg),"%-33s", Ssid);
+ //BSSID
+ sprintf(msg+strlen(msg),"%02x:%02x:%02x:%02x:%02x:%02x ",
+ pBss->Bssid[0],
+ pBss->Bssid[1],
+ pBss->Bssid[2],
+ pBss->Bssid[3],
+ pBss->Bssid[4],
+ pBss->Bssid[5]);
+
+ //Security
+ if ((Ndis802_11AuthModeWPA <= pBss->AuthMode) &&
+ (pBss->AuthMode <= Ndis802_11AuthModeWPA1PSKWPA2PSK))
+ {
+ if (pBss->AuthModeAux == Ndis802_11AuthModeWPANone)
+ {
+ ap_auth_mode = pBss->AuthMode;
+ if (pBss->WPA.PairCipherAux == Ndis802_11WEPDisabled)
+ ap_cipher = pBss->WPA.PairCipher;
+ else
+ ap_cipher = Ndis802_11Encryption4Enabled;
+ }
+ else if (pBss->AuthModeAux == Ndis802_11AuthModeOpen)
+ {
+ ap_auth_mode = pBss->AuthMode;
+ if ((ap_auth_mode == Ndis802_11AuthModeWPA) ||
+ (ap_auth_mode == Ndis802_11AuthModeWPAPSK))
+ {
+ if (pBss->WPA.PairCipherAux == Ndis802_11WEPDisabled)
+ ap_cipher = pBss->WPA.PairCipher;
+ else
+ ap_cipher = Ndis802_11Encryption4Enabled;
+ }
+ else if ((ap_auth_mode == Ndis802_11AuthModeWPA2) ||
+ (ap_auth_mode == Ndis802_11AuthModeWPA2PSK))
+ {
+ if (pBss->WPA2.PairCipherAux == Ndis802_11WEPDisabled)
+ ap_cipher = pBss->WPA2.PairCipher;
+ else
+ ap_cipher = Ndis802_11Encryption4Enabled;
+ }
+ }
+ else if ((pBss->AuthMode == Ndis802_11AuthModeWPAPSK) ||
+ (pBss->AuthMode == Ndis802_11AuthModeWPA2PSK))
+ {
+ if ((pBss->AuthModeAux == Ndis802_11AuthModeWPAPSK) ||
+ (pBss->AuthModeAux == Ndis802_11AuthModeWPA2PSK))
+ ap_auth_mode = Ndis802_11AuthModeWPA1PSKWPA2PSK;
+ else
+ ap_auth_mode = pBss->AuthMode;
+
+ if (pBss->WPA.PairCipher != pBss->WPA2.PairCipher)
+ ap_cipher = Ndis802_11Encryption4Enabled;
+ else if ((pBss->WPA.PairCipher == pBss->WPA2.PairCipher) &&
+ (pBss->WPA.PairCipherAux != pBss->WPA2.PairCipherAux))
+ ap_cipher = Ndis802_11Encryption4Enabled;
+ else if ((pBss->WPA.PairCipher == pBss->WPA2.PairCipher) &&
+ (pBss->WPA.PairCipherAux == pBss->WPA2.PairCipherAux) &&
+ (pBss->WPA.PairCipherAux != Ndis802_11WEPDisabled))
+ ap_cipher = Ndis802_11Encryption4Enabled;
+ else if ((pBss->WPA.PairCipher == pBss->WPA2.PairCipher) &&
+ (pBss->WPA.PairCipherAux == pBss->WPA2.PairCipherAux) &&
+ (pBss->WPA.PairCipherAux == Ndis802_11WEPDisabled))
+ ap_cipher = pBss->WPA.PairCipher;
+ }
+ else if ((pBss->AuthMode == Ndis802_11AuthModeWPA) ||
+ (pBss->AuthMode == Ndis802_11AuthModeWPA2))
+ {
+ if ((pBss->AuthModeAux == Ndis802_11AuthModeWPA) ||
+ (pBss->AuthMode == Ndis802_11AuthModeWPA2))
+ ap_auth_mode = Ndis802_11AuthModeWPA1WPA2;
+ else
+ ap_auth_mode = pBss->AuthMode;
+
+ if (pBss->WPA.PairCipher != pBss->WPA2.PairCipher)
+ ap_cipher = Ndis802_11Encryption4Enabled;
+ else if ((pBss->WPA.PairCipher == pBss->WPA2.PairCipher) &&
+ (pBss->WPA.PairCipherAux != pBss->WPA2.PairCipherAux))
+ ap_cipher = Ndis802_11Encryption4Enabled;
+ else if ((pBss->WPA.PairCipher == pBss->WPA2.PairCipher) &&
+ (pBss->WPA.PairCipherAux == pBss->WPA2.PairCipherAux) &&
+ (pBss->WPA.PairCipherAux != Ndis802_11WEPDisabled))
+ ap_cipher = Ndis802_11Encryption4Enabled;
+ else if ((pBss->WPA.PairCipher == pBss->WPA2.PairCipher) &&
+ (pBss->WPA.PairCipherAux == pBss->WPA2.PairCipherAux) &&
+ (pBss->WPA.PairCipherAux == Ndis802_11WEPDisabled))
+ ap_cipher = pBss->WPA.PairCipher;
+ }
+
+ sprintf(SecurityStr, "%s/%s", GetAuthMode((CHAR)ap_auth_mode), GetEncryptType((CHAR)ap_cipher));
+ }
+ else
+ {
+ ap_auth_mode = pBss->AuthMode;
+ ap_cipher = pBss->WepStatus;
+ if (ap_cipher == Ndis802_11WEPDisabled)
+ sprintf(SecurityStr, "NONE");
+ else if (ap_cipher == Ndis802_11WEPEnabled)
+ sprintf(SecurityStr, "WEP");
+ else
+ sprintf(SecurityStr, "%s/%s", GetAuthMode((CHAR)ap_auth_mode), GetEncryptType((CHAR)ap_cipher));
+ }
+
+ sprintf(msg+strlen(msg), "%-23s", SecurityStr);
+
+ // Rssi
+ Rssi = (INT)pBss->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(pBss);
+ 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 (pBss->BssType == BSS_ADHOC)
+ sprintf(msg+strlen(msg),"%-3s", " Ad");
+ else
+ sprintf(msg+strlen(msg),"%-3s", " In");
+
+ sprintf(msg+strlen(msg),"\n");
+
+ return;
+}
+
+VOID RTMPIoctlGetSiteSurvey(
+ IN PRTMP_ADAPTER pAdapter,
+ IN struct iwreq *wrq)
+{
+ PSTRING msg;
+ INT i=0;
+ INT WaitCnt;
+ INT Status=0;
+ INT max_len = LINE_LEN;
+ PBSS_ENTRY pBss;
+
+#ifdef CONFIG_STA_SUPPORT
+#endif // CONFIG_STA_SUPPORT //
+
+ 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 );
+ sprintf(msg,"%s","\n");
+ sprintf(msg+strlen(msg),"%-4s%-33s%-20s%-23s%-9s%-7s%-3s\n",
+ "Ch", "SSID", "BSSID", "Security", "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++)
+ {
+ pBss = &pAdapter->ScanTab.BssEntry[i];
+
+ if( pBss->Channel==0)
+ break;
+
+ if((strlen(msg)+max_len ) >= IW_SCAN_MAX_DATA)
+ break;
+
+
+ RTMPCommSiteSurveyData(msg, pBss);
+
+#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 = kmalloc(sizeof(CHAR)*(MAX_LEN_OF_MAC_TABLE*MAC_LINE_LEN), MEM_ALLOC_FLAG);
+ if (msg == NULL)
+ {
+ DBGPRINT(RT_DEBUG_ERROR, ("%s():Alloc memory failed\n", __FUNCTION__));
+ return;
+ }
+ 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);
+}
+
+
+#ifdef DOT11_N_SUPPORT
+INT Set_BASetup_Proc(
+ IN PRTMP_ADAPTER pAd,
+ IN PSTRING arg)
+{
+ UCHAR mac[6], tid;
+ PSTRING token;
+ STRING 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.
+*/
+ //DBGPRINT(RT_DEBUG_TRACE,("\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 = (UCHAR) 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, (&mac[i]), 1);
+ }
+ if(i != 6)
+ return FALSE;
+
+ DBGPRINT(RT_DEBUG_OFF, ("\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, (PUCHAR) mac);
+
+ if (pEntry) {
+ DBGPRINT(RT_DEBUG_OFF, ("\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 PSTRING 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 PSTRING arg)
+{
+ UCHAR mac[6], tid;
+ PSTRING token;
+ STRING sepValue[] = ":", DASH = '-';
+ INT i;
+ MAC_TABLE_ENTRY *pEntry;
+
+ //DBGPRINT(RT_DEBUG_TRACE,("\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, (&mac[i]), 1);
+ }
+ if(i != 6)
+ return FALSE;
+
+ DBGPRINT(RT_DEBUG_OFF, ("\n%02x:%02x:%02x:%02x:%02x:%02x-%02x",
+ mac[0], mac[1], mac[2], mac[3], mac[4], mac[5], tid));
+
+ pEntry = MacTableLookup(pAd, (PUCHAR) mac);
+
+ if (pEntry) {
+ DBGPRINT(RT_DEBUG_OFF, ("\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 PSTRING arg)
+{
+ UCHAR mac[6], tid;
+ PSTRING token;
+ STRING sepValue[] = ":", DASH = '-';
+ INT i;
+ MAC_TABLE_ENTRY *pEntry;
+
+ //DBGPRINT(RT_DEBUG_TRACE,("\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, (&mac[i]), 1);
+ }
+ if(i != 6)
+ return FALSE;
+
+ DBGPRINT(RT_DEBUG_OFF, ("\n%02x:%02x:%02x:%02x:%02x:%02x-%02x",
+ mac[0], mac[1], mac[2], mac[3], mac[4], mac[5], tid));
+
+ pEntry = MacTableLookup(pAd, (PUCHAR) mac);
+
+ if (pEntry) {
+ DBGPRINT(RT_DEBUG_OFF, ("\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 PSTRING 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 PSTRING 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 PSTRING 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 PSTRING 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_HtDisallowTKIP_Proc(
+ IN PRTMP_ADAPTER pAd,
+ IN PSTRING arg)
+{
+ ULONG Value;
+
+ Value = simple_strtol(arg, 0, 10);
+
+ if (Value == 1)
+ {
+ pAd->CommonCfg.HT_DisallowTKIP = TRUE;
+ }
+ else
+ {
+ pAd->CommonCfg.HT_DisallowTKIP = FALSE;
+ }
+
+ DBGPRINT(RT_DEBUG_TRACE, ("Set_HtDisallowTKIP_Proc ::%s\n",
+ (pAd->CommonCfg.HT_DisallowTKIP == TRUE) ? "enabled" : "disabled"));
+
+ return TRUE;
+}
+
+INT Set_HtOpMode_Proc(
+ IN PRTMP_ADAPTER pAd,
+ IN PSTRING 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 PSTRING 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 PSTRING 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 PSTRING 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 PSTRING 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 PSTRING 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 PSTRING 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 PSTRING 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 PSTRING 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 PSTRING 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 PSTRING 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 PSTRING arg)
+{
+ UCHAR mac[6], mode;
+ PSTRING token;
+ STRING sepValue[] = ":", DASH = '-';
+ INT i;
+ MAC_TABLE_ENTRY *pEntry;
+
+ //DBGPRINT(RT_DEBUG_TRACE,("\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, (&mac[i]), 1);
+ }
+ if(i != 6)
+ return FALSE;
+
+ DBGPRINT(RT_DEBUG_OFF, ("\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) {
+ DBGPRINT(RT_DEBUG_OFF, ("\nSendPSMPAction MIPS mode = %d\n", mode));
+ SendPSMPAction(pAd, pEntry->Aid, mode);
+ }
+
+ return TRUE;
+ }
+
+ return FALSE;
+
+
+}
+
+INT Set_HtMIMOPSmode_Proc(
+ IN PRTMP_ADAPTER pAd,
+ IN PSTRING 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 PSTRING 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 PSTRING 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 PSTRING 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 PSTRING 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 PSTRING arg)
+{
+ ULONG Value;
+
+ Value = simple_strtol(arg, 0, 10);
+
+#ifdef RTMP_MAC_PCI
+ if (RTMP_TEST_FLAG(pAd, fRTMP_ADAPTER_INTERRUPT_IN_USE))
+#endif // RTMP_MAC_PCI //
+ {
+ 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 //
+
+
+
+INT Set_LongRetryLimit_Proc(
+ IN PRTMP_ADAPTER pAdapter,
+ IN PSTRING 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 PSTRING 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;
+}
+
+
+/////////////////////////////////////////////////////////////////////////
+PSTRING 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";
+ }
+}
+
+PSTRING 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 PSTRING pName,
+ IN PSTRING 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 PSTRING 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 PSTRING 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 PSTRING pBuf)
+{
+ sprintf(pBuf, "\t%s", pAd->CommonCfg.bEnableTxBurst ? "TRUE":"FALSE");
+ return 0;
+}
+
+INT Show_TxPreamble_Proc(
+ IN PRTMP_ADAPTER pAd,
+ OUT PSTRING 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 PSTRING pBuf)
+{
+ sprintf(pBuf, "\t%lu", pAd->CommonCfg.TxPowerPercentage);
+ return 0;
+}
+
+INT Show_Channel_Proc(
+ IN PRTMP_ADAPTER pAd,
+ OUT PSTRING pBuf)
+{
+ sprintf(pBuf, "\t%d", pAd->CommonCfg.Channel);
+ return 0;
+}
+
+INT Show_BGProtection_Proc(
+ IN PRTMP_ADAPTER pAd,
+ OUT PSTRING 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 PSTRING pBuf)
+{
+ sprintf(pBuf, "\t%u", pAd->CommonCfg.RtsThreshold);
+ return 0;
+}
+
+INT Show_FragThreshold_Proc(
+ IN PRTMP_ADAPTER pAd,
+ OUT PSTRING pBuf)
+{
+ sprintf(pBuf, "\t%u", pAd->CommonCfg.FragmentThreshold);
+ return 0;
+}
+
+#ifdef DOT11_N_SUPPORT
+INT Show_HtBw_Proc(
+ IN PRTMP_ADAPTER pAd,
+ OUT PSTRING 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 PSTRING 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 PSTRING 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 PSTRING 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 PSTRING 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 PSTRING pBuf)
+{
+ sprintf(pBuf, "\t%u", pAd->CommonCfg.BACapability.field.MpduDensity);
+ return 0;
+}
+
+INT Show_HtBaWinSize_Proc(
+ IN PRTMP_ADAPTER pAd,
+ OUT PSTRING pBuf)
+{
+ sprintf(pBuf, "\t%u", pAd->CommonCfg.BACapability.field.RxBAWinLimit);
+ return 0;
+}
+
+INT Show_HtRdg_Proc(
+ IN PRTMP_ADAPTER pAd,
+ OUT PSTRING pBuf)
+{
+ sprintf(pBuf, "\t%s", pAd->CommonCfg.bRdg ? "TRUE":"FALSE");
+ return 0;
+}
+
+INT Show_HtAmsdu_Proc(
+ IN PRTMP_ADAPTER pAd,
+ OUT PSTRING pBuf)
+{
+ sprintf(pBuf, "\t%s", pAd->CommonCfg.BACapability.field.AmsduEnable ? "TRUE":"FALSE");
+ return 0;
+}
+
+INT Show_HtAutoBa_Proc(
+ IN PRTMP_ADAPTER pAd,
+ OUT PSTRING 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 PSTRING pBuf)
+{
+ sprintf(pBuf, "\t%d", pAd->CommonCfg.CountryRegion);
+ return 0;
+}
+
+INT Show_CountryRegionABand_Proc(
+ IN PRTMP_ADAPTER pAd,
+ OUT PSTRING pBuf)
+{
+ sprintf(pBuf, "\t%d", pAd->CommonCfg.CountryRegionForABand);
+ return 0;
+}
+
+INT Show_CountryCode_Proc(
+ IN PRTMP_ADAPTER pAd,
+ OUT PSTRING pBuf)
+{
+ sprintf(pBuf, "\t%s", pAd->CommonCfg.CountryCode);
+ return 0;
+}
+
+#ifdef AGGREGATION_SUPPORT
+INT Show_PktAggregate_Proc(
+ IN PRTMP_ADAPTER pAd,
+ OUT PSTRING 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 PSTRING 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 PSTRING 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 PSTRING 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 PSTRING 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 PSTRING 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 PSTRING 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 PSTRING 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((PCHAR)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 PSTRING pBuf)
+{
+ Show_WepKey_Proc(pAd, 0, pBuf);
+ return 0;
+}
+
+INT Show_Key2_Proc(
+ IN PRTMP_ADAPTER pAd,
+ OUT PSTRING pBuf)
+{
+ Show_WepKey_Proc(pAd, 1, pBuf);
+ return 0;
+}
+
+INT Show_Key3_Proc(
+ IN PRTMP_ADAPTER pAd,
+ OUT PSTRING pBuf)
+{
+ Show_WepKey_Proc(pAd, 2, pBuf);
+ return 0;
+}
+
+INT Show_Key4_Proc(
+ IN PRTMP_ADAPTER pAd,
+ OUT PSTRING pBuf)
+{
+ Show_WepKey_Proc(pAd, 3, pBuf);
+ return 0;
+}
+
+INT Show_WPAPSK_Proc(
+ IN PRTMP_ADAPTER pAd,
+ OUT PSTRING 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;
+}
diff --git a/drivers/staging/rt3090/common/cmm_mac_pci.c b/drivers/staging/rt3090/common/cmm_mac_pci.c
new file mode 100644
index 000000000000..8e1636315a8b
--- /dev/null
+++ b/drivers/staging/rt3090/common/cmm_mac_pci.c
@@ -0,0 +1,1757 @@
+/*
+ *************************************************************************
+ * 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 RTMP_MAC_PCI
+
+#include "../rt_config.h"
+
+
+/*
+ ========================================================================
+
+ Routine Description:
+ Allocate DMA memory blocks for send, receive
+
+ Arguments:
+ Adapter Pointer to our adapter
+
+ Return Value:
+ NDIS_STATUS_SUCCESS
+ NDIS_STATUS_FAILURE
+ NDIS_STATUS_RESOURCES
+
+ IRQL = PASSIVE_LEVEL
+
+ Note:
+
+ ========================================================================
+*/
+NDIS_STATUS RTMPAllocTxRxRingMemory(
+ IN PRTMP_ADAPTER pAd)
+{
+ NDIS_STATUS Status = NDIS_STATUS_SUCCESS;
+ ULONG RingBasePaHigh;
+ ULONG RingBasePaLow;
+ PVOID RingBaseVa;
+ INT index, num;
+ PTXD_STRUC pTxD;
+ PRXD_STRUC pRxD;
+ ULONG ErrorValue = 0;
+ PRTMP_TX_RING pTxRing;
+ PRTMP_DMABUF pDmaBuf;
+ PNDIS_PACKET pPacket;
+// PRTMP_REORDERBUF pReorderBuf;
+
+ DBGPRINT(RT_DEBUG_TRACE, ("--> RTMPAllocTxRxRingMemory\n"));
+ do
+ {
+ //
+ // Allocate all ring descriptors, include TxD, RxD, MgmtD.
+ // Although each size is different, to prevent cacheline and alignment
+ // issue, I intentional set them all to 64 bytes.
+ //
+ for (num=0; num<NUM_OF_TX_RING; num++)
+ {
+ ULONG BufBasePaHigh;
+ ULONG BufBasePaLow;
+ PVOID BufBaseVa;
+
+ //
+ // Allocate Tx ring descriptor's memory (5 TX rings = 4 ACs + 1 HCCA)
+ //
+ pAd->TxDescRing[num].AllocSize = TX_RING_SIZE * TXD_SIZE;
+ RTMP_AllocateTxDescMemory(
+ pAd,
+ num,
+ pAd->TxDescRing[num].AllocSize,
+ FALSE,
+ &pAd->TxDescRing[num].AllocVa,
+ &pAd->TxDescRing[num].AllocPa);
+
+ if (pAd->TxDescRing[num].AllocVa == NULL)
+ {
+ ErrorValue = ERRLOG_OUT_OF_SHARED_MEMORY;
+ DBGPRINT_ERR(("Failed to allocate a big buffer\n"));
+ Status = NDIS_STATUS_RESOURCES;
+ break;
+ }
+
+ // Zero init this memory block
+ NdisZeroMemory(pAd->TxDescRing[num].AllocVa, pAd->TxDescRing[num].AllocSize);
+
+ // Save PA & VA for further operation
+ RingBasePaHigh = RTMP_GetPhysicalAddressHigh(pAd->TxDescRing[num].AllocPa);
+ RingBasePaLow = RTMP_GetPhysicalAddressLow (pAd->TxDescRing[num].AllocPa);
+ RingBaseVa = pAd->TxDescRing[num].AllocVa;
+
+ //
+ // Allocate all 1st TXBuf's memory for this TxRing
+ //
+ pAd->TxBufSpace[num].AllocSize = TX_RING_SIZE * TX_DMA_1ST_BUFFER_SIZE;
+ RTMP_AllocateFirstTxBuffer(
+ pAd,
+ num,
+ pAd->TxBufSpace[num].AllocSize,
+ FALSE,
+ &pAd->TxBufSpace[num].AllocVa,
+ &pAd->TxBufSpace[num].AllocPa);
+
+ if (pAd->TxBufSpace[num].AllocVa == NULL)
+ {
+ ErrorValue = ERRLOG_OUT_OF_SHARED_MEMORY;
+ DBGPRINT_ERR(("Failed to allocate a big buffer\n"));
+ Status = NDIS_STATUS_RESOURCES;
+ break;
+ }
+
+ // Zero init this memory block
+ NdisZeroMemory(pAd->TxBufSpace[num].AllocVa, pAd->TxBufSpace[num].AllocSize);
+
+ // Save PA & VA for further operation
+ BufBasePaHigh = RTMP_GetPhysicalAddressHigh(pAd->TxBufSpace[num].AllocPa);
+ BufBasePaLow = RTMP_GetPhysicalAddressLow (pAd->TxBufSpace[num].AllocPa);
+ BufBaseVa = pAd->TxBufSpace[num].AllocVa;
+
+ //
+ // Initialize Tx Ring Descriptor and associated buffer memory
+ //
+ pTxRing = &pAd->TxRing[num];
+ for (index = 0; index < TX_RING_SIZE; index++)
+ {
+ pTxRing->Cell[index].pNdisPacket = NULL;
+ pTxRing->Cell[index].pNextNdisPacket = NULL;
+ // Init Tx Ring Size, Va, Pa variables
+ pTxRing->Cell[index].AllocSize = TXD_SIZE;
+ pTxRing->Cell[index].AllocVa = RingBaseVa;
+ RTMP_SetPhysicalAddressHigh(pTxRing->Cell[index].AllocPa, RingBasePaHigh);
+ RTMP_SetPhysicalAddressLow (pTxRing->Cell[index].AllocPa, RingBasePaLow);
+
+ // Setup Tx Buffer size & address. only 802.11 header will store in this space
+ pDmaBuf = &pTxRing->Cell[index].DmaBuf;
+ pDmaBuf->AllocSize = TX_DMA_1ST_BUFFER_SIZE;
+ pDmaBuf->AllocVa = BufBaseVa;
+ RTMP_SetPhysicalAddressHigh(pDmaBuf->AllocPa, BufBasePaHigh);
+ RTMP_SetPhysicalAddressLow(pDmaBuf->AllocPa, BufBasePaLow);
+
+ // link the pre-allocated TxBuf to TXD
+ pTxD = (PTXD_STRUC) pTxRing->Cell[index].AllocVa;
+ 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;
+
+ // advance to next TxBuf address
+ BufBasePaLow += TX_DMA_1ST_BUFFER_SIZE;
+ BufBaseVa = (PUCHAR) BufBaseVa + TX_DMA_1ST_BUFFER_SIZE;
+ }
+ DBGPRINT(RT_DEBUG_TRACE, ("TxRing[%d]: total %d entry allocated\n", num, index));
+ }
+ if (Status == NDIS_STATUS_RESOURCES)
+ break;
+
+ //
+ // Allocate MGMT ring descriptor's memory except Tx ring which allocated eariler
+ //
+ pAd->MgmtDescRing.AllocSize = MGMT_RING_SIZE * TXD_SIZE;
+ RTMP_AllocateMgmtDescMemory(
+ pAd,
+ pAd->MgmtDescRing.AllocSize,
+ FALSE,
+ &pAd->MgmtDescRing.AllocVa,
+ &pAd->MgmtDescRing.AllocPa);
+
+ if (pAd->MgmtDescRing.AllocVa == NULL)
+ {
+ ErrorValue = ERRLOG_OUT_OF_SHARED_MEMORY;
+ DBGPRINT_ERR(("Failed to allocate a big buffer\n"));
+ Status = NDIS_STATUS_RESOURCES;
+ break;
+ }
+
+ // Zero init this memory block
+ NdisZeroMemory(pAd->MgmtDescRing.AllocVa, pAd->MgmtDescRing.AllocSize);
+
+ // Save PA & VA for further operation
+ RingBasePaHigh = RTMP_GetPhysicalAddressHigh(pAd->MgmtDescRing.AllocPa);
+ RingBasePaLow = RTMP_GetPhysicalAddressLow (pAd->MgmtDescRing.AllocPa);
+ RingBaseVa = pAd->MgmtDescRing.AllocVa;
+
+ //
+ // Initialize MGMT Ring and associated buffer memory
+ //
+ for (index = 0; index < MGMT_RING_SIZE; index++)
+ {
+ pAd->MgmtRing.Cell[index].pNdisPacket = NULL;
+ pAd->MgmtRing.Cell[index].pNextNdisPacket = NULL;
+ // Init MGMT Ring Size, Va, Pa variables
+ pAd->MgmtRing.Cell[index].AllocSize = TXD_SIZE;
+ pAd->MgmtRing.Cell[index].AllocVa = RingBaseVa;
+ RTMP_SetPhysicalAddressHigh(pAd->MgmtRing.Cell[index].AllocPa, RingBasePaHigh);
+ RTMP_SetPhysicalAddressLow (pAd->MgmtRing.Cell[index].AllocPa, RingBasePaLow);
+
+ // Offset to next ring descriptor address
+ RingBasePaLow += TXD_SIZE;
+ RingBaseVa = (PUCHAR) RingBaseVa + TXD_SIZE;
+
+ // link the pre-allocated TxBuf to TXD
+ 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));
+
+ //
+ // Allocate RX ring descriptor's memory except Tx ring which allocated eariler
+ //
+ pAd->RxDescRing.AllocSize = RX_RING_SIZE * RXD_SIZE;
+ RTMP_AllocateRxDescMemory(
+ pAd,
+ pAd->RxDescRing.AllocSize,
+ FALSE,
+ &pAd->RxDescRing.AllocVa,
+ &pAd->RxDescRing.AllocPa);
+
+ if (pAd->RxDescRing.AllocVa == NULL)
+ {
+ ErrorValue = ERRLOG_OUT_OF_SHARED_MEMORY;
+ DBGPRINT_ERR(("Failed to allocate a big buffer\n"));
+ Status = NDIS_STATUS_RESOURCES;
+ break;
+ }
+
+ // Zero init this memory block
+ NdisZeroMemory(pAd->RxDescRing.AllocVa, pAd->RxDescRing.AllocSize);
+
+
+ DBGPRINT(RT_DEBUG_OFF,
+ ("RX DESC %p size = %ld\n", pAd->RxDescRing.AllocVa, pAd->RxDescRing.AllocSize));
+
+ // Save PA & VA for further operation
+ RingBasePaHigh = RTMP_GetPhysicalAddressHigh(pAd->RxDescRing.AllocPa);
+ RingBasePaLow = RTMP_GetPhysicalAddressLow (pAd->RxDescRing.AllocPa);
+ RingBaseVa = pAd->RxDescRing.AllocVa;
+
+ //
+ // Initialize Rx Ring and associated buffer memory
+ //
+ for (index = 0; index < RX_RING_SIZE; index++)
+ {
+ // Init RX Ring Size, Va, Pa variables
+ pAd->RxRing.Cell[index].AllocSize = RXD_SIZE;
+ pAd->RxRing.Cell[index].AllocVa = RingBaseVa;
+ RTMP_SetPhysicalAddressHigh(pAd->RxRing.Cell[index].AllocPa, RingBasePaHigh);
+ RTMP_SetPhysicalAddressLow (pAd->RxRing.Cell[index].AllocPa, RingBasePaLow);
+
+ //NdisZeroMemory(RingBaseVa, RXD_SIZE);
+
+ // Offset to next ring descriptor address
+ RingBasePaLow += RXD_SIZE;
+ RingBaseVa = (PUCHAR) RingBaseVa + RXD_SIZE;
+
+ // Setup Rx associated Buffer size & allocate share memory
+ pDmaBuf = &pAd->RxRing.Cell[index].DmaBuf;
+ pDmaBuf->AllocSize = RX_BUFFER_AGGRESIZE;
+ pPacket = RTMP_AllocateRxPacketBuffer(
+ pAd,
+ pDmaBuf->AllocSize,
+ FALSE,
+ &pDmaBuf->AllocVa,
+ &pDmaBuf->AllocPa);
+
+ /* keep allocated rx packet */
+ pAd->RxRing.Cell[index].pNdisPacket = pPacket;
+
+ // Error handling
+ if (pDmaBuf->AllocVa == NULL)
+ {
+ ErrorValue = ERRLOG_OUT_OF_SHARED_MEMORY;
+ DBGPRINT_ERR(("Failed to allocate RxRing's 1st buffer\n"));
+ Status = NDIS_STATUS_RESOURCES;
+ break;
+ }
+
+ // Zero init this memory block
+ NdisZeroMemory(pDmaBuf->AllocVa, pDmaBuf->AllocSize);
+
+ // Write RxD buffer address & allocated buffer length
+ 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));
+
+ } 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;
+ }
+
+ if (Status != NDIS_STATUS_SUCCESS)
+ {
+ // Log error inforamtion
+ NdisWriteErrorLogEntry(
+ pAd->AdapterHandle,
+ NDIS_ERROR_CODE_OUT_OF_RESOURCES,
+ 1,
+ ErrorValue);
+ }
+
+ // Following code segment get from original func:NICInitTxRxRingAndBacklogQueue(), now should integrate it to here.
+ {
+ DBGPRINT(RT_DEBUG_TRACE, ("--> NICInitTxRxRingAndBacklogQueue\n"));
+
+/*
+ // Disable DMA.
+ RTMP_IO_READ32(pAd, WPDMA_GLO_CFG, &GloCfg.word);
+ GloCfg.word &= 0xff0;
+ GloCfg.field.EnTXWriteBackDDONE =1;
+ RTMP_IO_WRITE32(pAd, WPDMA_GLO_CFG, GloCfg.word);
+*/
+
+ // Initialize all transmit related software queues
+ for(index = 0; index < NUM_OF_TX_RING; index++)
+ {
+ InitializeQueueHeader(&pAd->TxSwQueue[index]);
+ // Init TX rings index pointer
+ pAd->TxRing[index].TxSwFreeIdx = 0;
+ pAd->TxRing[index].TxCpuIdx = 0;
+ //RTMP_IO_WRITE32(pAd, (TX_CTX_IDX0 + i * 0x10) , pAd->TxRing[i].TX_CTX_IDX);
+ }
+
+ // Init RX Ring index pointer
+ pAd->RxRing.RxSwReadIdx = 0;
+ pAd->RxRing.RxCpuIdx = RX_RING_SIZE - 1;
+ //RTMP_IO_WRITE32(pAd, RX_CRX_IDX, pAd->RxRing.RX_CRX_IDX0);
+
+
+ // init MGMT ring index pointer
+ pAd->MgmtRing.TxSwFreeIdx = 0;
+ pAd->MgmtRing.TxCpuIdx = 0;
+
+ pAd->PrivateInfo.TxRingFullCnt = 0;
+
+ DBGPRINT(RT_DEBUG_TRACE, ("<-- NICInitTxRxRingAndBacklogQueue\n"));
+ }
+
+ DBGPRINT_S(Status, ("<-- RTMPAllocTxRxRingMemory, Status=%x\n", Status));
+ return Status;
+}
+
+
+
+
+/*
+ ========================================================================
+
+ Routine Description:
+ Reset NIC Asics. Call after rest DMA. So reset TX_CTX_IDX to zero.
+
+ Arguments:
+ Adapter Pointer to our adapter
+
+ Return Value:
+ None
+
+ IRQL = PASSIVE_LEVEL
+ IRQL = DISPATCH_LEVEL
+
+ Note:
+ Reset NIC to initial state AS IS system boot up time.
+
+ ========================================================================
+*/
+VOID RTMPRingCleanUp(
+ IN PRTMP_ADAPTER pAd,
+ IN UCHAR RingType)
+{
+ PTXD_STRUC pTxD;
+ PRXD_STRUC pRxD;
+ PQUEUE_ENTRY pEntry;
+ PNDIS_PACKET pPacket;
+ int i;
+ PRTMP_TX_RING pTxRing;
+ unsigned long IrqFlags;
+ //UINT32 RxSwReadIdx;
+
+
+ DBGPRINT(RT_DEBUG_TRACE,("RTMPRingCleanUp(RingIdx=%d, Pending-NDIS=%ld)\n", RingType, pAd->RalinkCounters.PendingNdisPacketCount));
+ switch (RingType)
+ {
+ case QID_AC_BK:
+ case QID_AC_BE:
+ case QID_AC_VI:
+ case QID_AC_VO:
+ /*case QID_HCCA:*/
+
+ pTxRing = &pAd->TxRing[RingType];
+
+ RTMP_IRQ_LOCK(&pAd->irq_lock, IrqFlags);
+ // We have to clean all descriptors in case some error happened with reset
+ for (i=0; i<TX_RING_SIZE; i++) // We have to scan all TX ring
+ {
+ pTxD = (PTXD_STRUC) pTxRing->Cell[i].AllocVa;
+
+ pPacket = (PNDIS_PACKET) pTxRing->Cell[i].pNdisPacket;
+ // release scatter-and-gather NDIS_PACKET
+ if (pPacket)
+ {
+ RELEASE_NDIS_PACKET(pAd, pPacket, NDIS_STATUS_FAILURE);
+ pTxRing->Cell[i].pNdisPacket = NULL;
+ }
+
+ pPacket = (PNDIS_PACKET) pTxRing->Cell[i].pNextNdisPacket;
+ // release scatter-and-gather NDIS_PACKET
+ if (pPacket)
+ {
+ RELEASE_NDIS_PACKET(pAd, pPacket, NDIS_STATUS_FAILURE);
+ pTxRing->Cell[i].pNextNdisPacket = NULL;
+ }
+ }
+
+ RTMP_IO_READ32(pAd, TX_DTX_IDX0 + RingType * 0x10, &pTxRing->TxDmaIdx);
+ pTxRing->TxSwFreeIdx = pTxRing->TxDmaIdx;
+ pTxRing->TxCpuIdx = pTxRing->TxDmaIdx;
+ RTMP_IO_WRITE32(pAd, TX_CTX_IDX0 + RingType * 0x10, pTxRing->TxCpuIdx);
+
+ RTMP_IRQ_UNLOCK(&pAd->irq_lock, IrqFlags);
+
+ RTMP_IRQ_LOCK(&pAd->irq_lock, IrqFlags);
+ while (pAd->TxSwQueue[RingType].Head != NULL)
+ {
+ pEntry = RemoveHeadQueue(&pAd->TxSwQueue[RingType]);
+ pPacket = QUEUE_ENTRY_TO_PACKET(pEntry);
+ RELEASE_NDIS_PACKET(pAd, pPacket, NDIS_STATUS_FAILURE);
+ DBGPRINT(RT_DEBUG_TRACE,("Release 1 NDIS packet from s/w backlog queue\n"));
+ }
+ RTMP_IRQ_UNLOCK(&pAd->irq_lock, IrqFlags);
+ break;
+
+ case QID_MGMT:
+ // We have to clean all descriptors in case some error happened with reset
+ NdisAcquireSpinLock(&pAd->MgmtRingLock);
+
+ for (i=0; i<MGMT_RING_SIZE; i++)
+ {
+ pTxD = (PTXD_STRUC) pAd->MgmtRing.Cell[i].AllocVa;
+
+ pPacket = (PNDIS_PACKET) pAd->MgmtRing.Cell[i].pNdisPacket;
+ // rlease scatter-and-gather NDIS_PACKET
+ if (pPacket)
+ {
+ PCI_UNMAP_SINGLE(pAd, pTxD->SDPtr0, pTxD->SDLen0, PCI_DMA_TODEVICE);
+ RELEASE_NDIS_PACKET(pAd, pPacket, NDIS_STATUS_FAILURE);
+ }
+ pAd->MgmtRing.Cell[i].pNdisPacket = NULL;
+
+ pPacket = (PNDIS_PACKET) pAd->MgmtRing.Cell[i].pNextNdisPacket;
+ // release scatter-and-gather NDIS_PACKET
+ if (pPacket)
+ {
+ PCI_UNMAP_SINGLE(pAd, pTxD->SDPtr1, pTxD->SDLen1, PCI_DMA_TODEVICE);
+ RELEASE_NDIS_PACKET(pAd, pPacket, NDIS_STATUS_FAILURE);
+ }
+ pAd->MgmtRing.Cell[i].pNextNdisPacket = NULL;
+
+ }
+
+ RTMP_IO_READ32(pAd, TX_MGMTDTX_IDX, &pAd->MgmtRing.TxDmaIdx);
+ pAd->MgmtRing.TxSwFreeIdx = pAd->MgmtRing.TxDmaIdx;
+ pAd->MgmtRing.TxCpuIdx = pAd->MgmtRing.TxDmaIdx;
+ RTMP_IO_WRITE32(pAd, TX_MGMTCTX_IDX, pAd->MgmtRing.TxCpuIdx);
+
+ NdisReleaseSpinLock(&pAd->MgmtRingLock);
+ pAd->RalinkCounters.MgmtRingFullCount = 0;
+ break;
+
+ case QID_RX:
+ // We have to clean all descriptors in case some error happened with reset
+ NdisAcquireSpinLock(&pAd->RxRingLock);
+
+ for (i=0; i<RX_RING_SIZE; i++)
+ {
+ pRxD = (PRXD_STRUC) pAd->RxRing.Cell[i].AllocVa;
+ pRxD->DDONE = 0 ;
+ }
+
+ RTMP_IO_READ32(pAd, RX_DRX_IDX, &pAd->RxRing.RxDmaIdx);
+ pAd->RxRing.RxSwReadIdx = pAd->RxRing.RxDmaIdx;
+ pAd->RxRing.RxCpuIdx = ((pAd->RxRing.RxDmaIdx == 0) ? (RX_RING_SIZE-1) : (pAd->RxRing.RxDmaIdx-1));
+ RTMP_IO_WRITE32(pAd, RX_CRX_IDX, pAd->RxRing.RxCpuIdx);
+
+ NdisReleaseSpinLock(&pAd->RxRingLock);
+ break;
+
+ default:
+ break;
+ }
+}
+
+
+VOID RTMPFreeTxRxRingMemory(
+ IN PRTMP_ADAPTER pAd)
+{
+ int index, num , j;
+ PRTMP_TX_RING pTxRing;
+ PTXD_STRUC pTxD;
+ PNDIS_PACKET pPacket;
+ unsigned int IrqFlags;
+
+ //POS_COOKIE pObj =(POS_COOKIE) pAd->OS_Cookie;
+
+ DBGPRINT(RT_DEBUG_TRACE, ("--> RTMPFreeTxRxRingMemory\n"));
+
+ // Free TxSwQueue Packet
+ for (index=0; index <NUM_OF_TX_RING; index++)
+ {
+ PQUEUE_ENTRY pEntry;
+ PNDIS_PACKET pPacket;
+ PQUEUE_HEADER pQueue;
+
+ RTMP_IRQ_LOCK(&pAd->irq_lock, IrqFlags);
+ pQueue = &pAd->TxSwQueue[index];
+ while (pQueue->Head)
+ {
+ pEntry = RemoveHeadQueue(pQueue);
+ pPacket = QUEUE_ENTRY_TO_PACKET(pEntry);
+ RELEASE_NDIS_PACKET(pAd, pPacket, NDIS_STATUS_FAILURE);
+ }
+ RTMP_IRQ_UNLOCK(&pAd->irq_lock, IrqFlags);
+ }
+
+ // Free Tx Ring Packet
+ for (index=0;index< NUM_OF_TX_RING;index++)
+ {
+ pTxRing = &pAd->TxRing[index];
+
+ for (j=0; j< TX_RING_SIZE; j++)
+ {
+ pTxD = (PTXD_STRUC) (pTxRing->Cell[j].AllocVa);
+ pPacket = pTxRing->Cell[j].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[j].pNdisPacket = NULL;
+
+ pPacket = pTxRing->Cell[j].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[pTxRing->TxSwFreeIdx].pNextNdisPacket = NULL;
+
+ }
+ }
+
+ for (index = RX_RING_SIZE - 1 ; index >= 0; index--)
+ {
+ if ((pAd->RxRing.Cell[index].DmaBuf.AllocVa) && (pAd->RxRing.Cell[index].pNdisPacket))
+ {
+ PCI_UNMAP_SINGLE(pAd, pAd->RxRing.Cell[index].DmaBuf.AllocPa, pAd->RxRing.Cell[index].DmaBuf.AllocSize, PCI_DMA_FROMDEVICE);
+ RELEASE_NDIS_PACKET(pAd, pAd->RxRing.Cell[index].pNdisPacket, NDIS_STATUS_SUCCESS);
+ }
+ }
+ NdisZeroMemory(pAd->RxRing.Cell, RX_RING_SIZE * sizeof(RTMP_DMACB));
+
+ if (pAd->RxDescRing.AllocVa)
+ {
+ RTMP_FreeDescMemory(pAd, pAd->RxDescRing.AllocSize, pAd->RxDescRing.AllocVa, pAd->RxDescRing.AllocPa);
+ }
+ NdisZeroMemory(&pAd->RxDescRing, sizeof(RTMP_DMABUF));
+
+ if (pAd->MgmtDescRing.AllocVa)
+ {
+ RTMP_FreeDescMemory(pAd, pAd->MgmtDescRing.AllocSize, pAd->MgmtDescRing.AllocVa, pAd->MgmtDescRing.AllocPa);
+ }
+ NdisZeroMemory(&pAd->MgmtDescRing, sizeof(RTMP_DMABUF));
+
+ for (num = 0; num < NUM_OF_TX_RING; num++)
+ {
+ if (pAd->TxBufSpace[num].AllocVa)
+ {
+ RTMP_FreeFirstTxBuffer(pAd, pAd->TxBufSpace[num].AllocSize, FALSE, pAd->TxBufSpace[num].AllocVa, pAd->TxBufSpace[num].AllocPa);
+ }
+ NdisZeroMemory(&pAd->TxBufSpace[num], sizeof(RTMP_DMABUF));
+
+ if (pAd->TxDescRing[num].AllocVa)
+ {
+ RTMP_FreeDescMemory(pAd, pAd->TxDescRing[num].AllocSize, pAd->TxDescRing[num].AllocVa, pAd->TxDescRing[num].AllocPa);
+ }
+ NdisZeroMemory(&pAd->TxDescRing[num], sizeof(RTMP_DMABUF));
+ }
+
+ if (pAd->FragFrame.pFragPacket)
+ RELEASE_NDIS_PACKET(pAd, pAd->FragFrame.pFragPacket, NDIS_STATUS_SUCCESS);
+
+ DBGPRINT(RT_DEBUG_TRACE, ("<-- RTMPFreeTxRxRingMemory\n"));
+}
+
+
+/***************************************************************************
+ *
+ * register related procedures.
+ *
+ **************************************************************************/
+/*
+========================================================================
+Routine Description:
+ Disable DMA.
+
+Arguments:
+ *pAd the raxx interface data pointer
+
+Return Value:
+ None
+
+Note:
+========================================================================
+*/
+VOID RT28XXDMADisable(
+ IN RTMP_ADAPTER *pAd)
+{
+ WPDMA_GLO_CFG_STRUC GloCfg;
+
+
+ RTMP_IO_READ32(pAd, WPDMA_GLO_CFG, &GloCfg.word);
+ GloCfg.word &= 0xff0;
+ GloCfg.field.EnTXWriteBackDDONE =1;
+ RTMP_IO_WRITE32(pAd, WPDMA_GLO_CFG, GloCfg.word);
+}
+
+
+/*
+========================================================================
+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;
+ 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.WPDMABurstSIZE = 2;
+ 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);
+
+}
+
+
+BOOLEAN AsicCheckCommanOk(
+ IN PRTMP_ADAPTER pAd,
+ IN UCHAR Command)
+{
+ UINT32 CmdStatus = 0, CID = 0, i;
+ UINT32 ThisCIDMask = 0;
+
+ i = 0;
+ do
+ {
+ RTMP_IO_READ32(pAd, H2M_MAILBOX_CID, &CID);
+ // Find where the command is. Because this is randomly specified by firmware.
+ if ((CID & CID0MASK) == Command)
+ {
+ ThisCIDMask = CID0MASK;
+ break;
+ }
+ else if ((((CID & CID1MASK)>>8) & 0xff) == Command)
+ {
+ ThisCIDMask = CID1MASK;
+ break;
+ }
+ else if ((((CID & CID2MASK)>>16) & 0xff) == Command)
+ {
+ ThisCIDMask = CID2MASK;
+ break;
+ }
+ else if ((((CID & CID3MASK)>>24) & 0xff) == Command)
+ {
+ ThisCIDMask = CID3MASK;
+ break;
+ }
+
+ RTMPusecDelay(100);
+ i++;
+ }while (i < 200);
+
+ // Get CommandStatus Value
+ RTMP_IO_READ32(pAd, H2M_MAILBOX_STATUS, &CmdStatus);
+
+ // This command's status is at the same position as command. So AND command position's bitmask to read status.
+ if (i < 200)
+ {
+ // If Status is 1, the comamnd is success.
+ if (((CmdStatus & ThisCIDMask) == 0x1) || ((CmdStatus & ThisCIDMask) == 0x100)
+ || ((CmdStatus & ThisCIDMask) == 0x10000) || ((CmdStatus & ThisCIDMask) == 0x1000000))
+ {
+ DBGPRINT(RT_DEBUG_TRACE, ("--> AsicCheckCommanOk CID = 0x%x, CmdStatus= 0x%x \n", CID, CmdStatus));
+ RTMP_IO_WRITE32(pAd, H2M_MAILBOX_STATUS, 0xffffffff);
+ RTMP_IO_WRITE32(pAd, H2M_MAILBOX_CID, 0xffffffff);
+ return TRUE;
+ }
+ DBGPRINT(RT_DEBUG_TRACE, ("--> AsicCheckCommanFail1 CID = 0x%x, CmdStatus= 0x%x \n", CID, CmdStatus));
+ }
+ else
+ {
+ DBGPRINT(RT_DEBUG_TRACE, ("--> AsicCheckCommanFail2 Timeout Command = %d, CmdStatus= 0x%x \n", Command, CmdStatus));
+ }
+ // Clear Command and Status.
+ RTMP_IO_WRITE32(pAd, H2M_MAILBOX_STATUS, 0xffffffff);
+ RTMP_IO_WRITE32(pAd, H2M_MAILBOX_CID, 0xffffffff);
+
+ return FALSE;
+}
+
+
+/*
+========================================================================
+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)
+{
+ ULONG CapInfoPos = 0;
+ UCHAR *ptr, *ptr_update, *ptr_capinfo;
+ UINT i;
+ BOOLEAN bBcnReq = FALSE;
+ UCHAR bcn_idx = 0;
+
+
+ {
+ DBGPRINT(RT_DEBUG_ERROR, ("%s() : No valid Interface be found.\n", __FUNCTION__));
+ 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);
+ }
+ 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);
+ RTMP_IO_WRITE32(pAd, pAd->BeaconOffset[bcn_idx] + i, longptr);
+ ptr += 4;
+ }
+
+ // Update CapabilityInfo in Beacon
+ for (i = CapInfoPos; i < (CapInfoPos+2); i++)
+ {
+ RTMP_IO_WRITE8(pAd, pAd->BeaconOffset[bcn_idx] + TXWI_SIZE + i, *ptr_capinfo);
+ ptr_capinfo ++;
+ }
+
+ if (FrameLen > UpdatePos)
+ {
+ for (i= UpdatePos; i< (FrameLen); i++)
+ {
+ RTMP_IO_WRITE8(pAd, pAd->BeaconOffset[bcn_idx] + TXWI_SIZE + i, *ptr_update);
+ ptr_update ++;
+ }
+ }
+
+ }
+
+}
+
+
+#ifdef CONFIG_STA_SUPPORT
+VOID RT28xxPciStaAsicForceWakeup(
+ IN PRTMP_ADAPTER pAd,
+ IN BOOLEAN bFromTx)
+{
+ AUTO_WAKEUP_STRUC AutoWakeupCfg;
+
+ if (!OPSTATUS_TEST_FLAG(pAd, fOP_STATUS_DOZE))
+ return;
+
+ if (OPSTATUS_TEST_FLAG(pAd, fOP_STATUS_WAKEUP_NOW))
+ {
+ DBGPRINT(RT_DEBUG_TRACE, ("waking up now!\n"));
+ return;
+ }
+
+ OPSTATUS_SET_FLAG(pAd, fOP_STATUS_WAKEUP_NOW);
+
+ RTMP_CLEAR_PSFLAG(pAd, fRTMP_PS_GO_TO_SLEEP_NOW);
+
+ if (OPSTATUS_TEST_FLAG(pAd, fOP_STATUS_PCIE_DEVICE)
+ &&pAd->StaCfg.PSControl.field.EnableNewPS == TRUE)
+ {
+ // Support PCIe Advance Power Save
+ if (bFromTx == TRUE
+ &&(pAd->Mlme.bPsPollTimerRunning == TRUE))
+ {
+ pAd->Mlme.bPsPollTimerRunning = FALSE;
+ RTMPPCIeLinkCtrlValueRestore(pAd, RESTORE_WAKEUP);
+ RTMPusecDelay(3000);
+ DBGPRINT(RT_DEBUG_TRACE, ("=======AsicForceWakeup===bFromTx\n"));
+ }
+
+ AutoWakeupCfg.word = 0;
+ RTMP_IO_WRITE32(pAd, AUTO_WAKEUP_CFG, AutoWakeupCfg.word);
+
+ if (RT28xxPciAsicRadioOn(pAd, DOT11POWERSAVE))
+ {
+#ifdef PCIE_PS_SUPPORT
+ // add by johnli, RF power sequence setup, load RF normal operation-mode setup
+ if ((IS_RT3090(pAd) || IS_RT3572(pAd) || IS_RT3390(pAd)) && IS_VERSION_AFTER_F(pAd))
+ {
+ RTMP_CHIP_OP *pChipOps = &pAd->chipOps;
+
+ if (pChipOps->AsicReverseRfFromSleepMode)
+ pChipOps->AsicReverseRfFromSleepMode(pAd);
+ }
+ else
+#endif // PCIE_PS_SUPPORT //
+ {
+ // end johnli
+ // In Radio Off, we turn off RF clk, So now need to call ASICSwitchChannel again.
+ if (INFRA_ON(pAd) && (pAd->CommonCfg.CentralChannel != pAd->CommonCfg.Channel)
+ && (pAd->MlmeAux.HtCapability.HtCapInfo.ChannelWidth == BW_40))
+ {
+ // Must using 40MHz.
+ AsicSwitchChannel(pAd, pAd->CommonCfg.CentralChannel, FALSE);
+ AsicLockChannel(pAd, pAd->CommonCfg.CentralChannel);
+ }
+ else
+ {
+ // Must using 20MHz.
+ AsicSwitchChannel(pAd, pAd->CommonCfg.Channel, FALSE);
+ AsicLockChannel(pAd, pAd->CommonCfg.Channel);
+ }
+ }
+ }
+#ifdef PCIE_PS_SUPPORT
+ // 3090 MCU Wakeup command needs more time to be stable.
+ // Before stable, don't issue other MCU command to prevent from firmware error.
+ if (((IS_RT3090(pAd) || IS_RT3572(pAd) || IS_RT3390(pAd)) && IS_VERSION_AFTER_F(pAd)) && IS_VERSION_AFTER_F(pAd)
+ && (pAd->StaCfg.PSControl.field.rt30xxPowerMode == 3)
+ && (pAd->StaCfg.PSControl.field.EnableNewPS == TRUE))
+ {
+ DBGPRINT(RT_DEBUG_TRACE, ("<==RT28xxPciStaAsicForceWakeup::Release the MCU Lock(3090)\n"));
+ RTMP_SEM_LOCK(&pAd->McuCmdLock);
+ pAd->brt30xxBanMcuCmd = FALSE;
+ RTMP_SEM_UNLOCK(&pAd->McuCmdLock);
+ }
+#endif // PCIE_PS_SUPPORT //
+ }
+ else
+ {
+ // PCI, 2860-PCIe
+ DBGPRINT(RT_DEBUG_TRACE, ("<==RT28xxPciStaAsicForceWakeup::Original PCI Power Saving\n"));
+ AsicSendCommandToMcu(pAd, 0x31, 0xff, 0x00, 0x02);
+ AutoWakeupCfg.word = 0;
+ RTMP_IO_WRITE32(pAd, AUTO_WAKEUP_CFG, AutoWakeupCfg.word);
+ }
+
+ OPSTATUS_CLEAR_FLAG(pAd, fOP_STATUS_DOZE);
+ OPSTATUS_CLEAR_FLAG(pAd, fOP_STATUS_WAKEUP_NOW);
+ DBGPRINT(RT_DEBUG_TRACE, ("<=======RT28xxPciStaAsicForceWakeup\n"));
+}
+
+
+VOID RT28xxPciStaAsicSleepThenAutoWakeup(
+ IN PRTMP_ADAPTER pAd,
+ IN USHORT TbttNumToNextWakeUp)
+{
+ BOOLEAN brc;
+
+ if (pAd->StaCfg.bRadio == FALSE)
+ {
+ OPSTATUS_CLEAR_FLAG(pAd, fOP_STATUS_DOZE);
+ return;
+ }
+ if (OPSTATUS_TEST_FLAG(pAd, fOP_STATUS_PCIE_DEVICE)
+ &&pAd->StaCfg.PSControl.field.EnableNewPS == TRUE)
+ {
+ ULONG Now = 0;
+ if (OPSTATUS_TEST_FLAG(pAd, fOP_STATUS_WAKEUP_NOW))
+ {
+ DBGPRINT(RT_DEBUG_TRACE, ("waking up now!\n"));
+ OPSTATUS_CLEAR_FLAG(pAd, fOP_STATUS_DOZE);
+ return;
+ }
+
+ NdisGetSystemUpTime(&Now);
+ // If last send NULL fram time is too close to this receiving beacon (within 8ms), don't go to sleep for this DTM.
+ // Because Some AP can't queuing outgoing frames immediately.
+ if (((pAd->Mlme.LastSendNULLpsmTime + 8) >= Now) && (pAd->Mlme.LastSendNULLpsmTime <= Now))
+ {
+ DBGPRINT(RT_DEBUG_TRACE, ("Now = %lu, LastSendNULLpsmTime=%lu : RxCountSinceLastNULL = %lu. \n", Now, pAd->Mlme.LastSendNULLpsmTime, pAd->RalinkCounters.RxCountSinceLastNULL));
+ return;
+ }
+ else if ((pAd->RalinkCounters.RxCountSinceLastNULL > 0) && ((pAd->Mlme.LastSendNULLpsmTime + pAd->CommonCfg.BeaconPeriod) >= Now))
+ {
+ DBGPRINT(RT_DEBUG_TRACE, ("Now = %lu, LastSendNULLpsmTime=%lu: RxCountSinceLastNULL = %lu > 0 \n", Now, pAd->Mlme.LastSendNULLpsmTime, pAd->RalinkCounters.RxCountSinceLastNULL));
+ return;
+ }
+
+ brc = RT28xxPciAsicRadioOff(pAd, DOT11POWERSAVE, TbttNumToNextWakeUp);
+ if (brc==TRUE)
+ OPSTATUS_SET_FLAG(pAd, fOP_STATUS_DOZE);
+ }
+ else
+ {
+ AUTO_WAKEUP_STRUC AutoWakeupCfg;
+ // we have decided to SLEEP, so at least do it for a BEACON period.
+ if (TbttNumToNextWakeUp == 0)
+ TbttNumToNextWakeUp = 1;
+
+ //RTMP_IO_WRITE32(pAd, INT_MASK_CSR, AutoWakeupInt);
+
+ 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, 0x00); // send POWER-SAVE command to MCU. Timeout 40us.
+ OPSTATUS_SET_FLAG(pAd, fOP_STATUS_DOZE);
+ DBGPRINT(RT_DEBUG_TRACE, ("<-- %s, TbttNumToNextWakeUp=%d \n", __FUNCTION__, TbttNumToNextWakeUp));
+ }
+
+}
+
+
+VOID PsPollWakeExec(
+ IN PVOID SystemSpecific1,
+ IN PVOID FunctionContext,
+ IN PVOID SystemSpecific2,
+ IN PVOID SystemSpecific3)
+{
+ RTMP_ADAPTER *pAd = (RTMP_ADAPTER *)FunctionContext;
+ unsigned long flags;
+
+ DBGPRINT(RT_DEBUG_TRACE,("-->PsPollWakeExec \n"));
+
+ RTMP_INT_LOCK(&pAd->irq_lock, flags);
+ if (pAd->Mlme.bPsPollTimerRunning)
+ {
+ RTMPPCIeLinkCtrlValueRestore(pAd, RESTORE_WAKEUP);
+ }
+ pAd->Mlme.bPsPollTimerRunning = FALSE;
+ RTMP_INT_UNLOCK(&pAd->irq_lock, flags);
+#ifdef PCIE_PS_SUPPORT
+ // For rt30xx power solution 3, Use software timer to wake up in psm. So call
+ // AsicForceWakeup here instead of handling twakeup interrupt.
+ if (((IS_RT3090(pAd) || IS_RT3572(pAd) || IS_RT3390(pAd)) && IS_VERSION_AFTER_F(pAd))
+ && (pAd->StaCfg.PSControl.field.rt30xxPowerMode == 3)
+ && (pAd->StaCfg.PSControl.field.EnableNewPS == TRUE))
+ {
+ DBGPRINT(RT_DEBUG_TRACE,("<--PsPollWakeExec::3090 calls AsicForceWakeup(pAd, DOT11POWERSAVE) in advance \n"));
+ AsicForceWakeup(pAd, DOT11POWERSAVE);
+ }
+
+#endif // PCIE_PS_SUPPORT //
+}
+
+VOID RadioOnExec(
+ IN PVOID SystemSpecific1,
+ IN PVOID FunctionContext,
+ IN PVOID SystemSpecific2,
+ IN PVOID SystemSpecific3)
+{
+ RTMP_ADAPTER *pAd = (RTMP_ADAPTER *)FunctionContext;
+ RTMP_CHIP_OP *pChipOps = &pAd->chipOps;
+ WPDMA_GLO_CFG_STRUC DmaCfg;
+ BOOLEAN Cancelled;
+
+ if (OPSTATUS_TEST_FLAG(pAd, fOP_STATUS_DOZE))
+ {
+ DBGPRINT(RT_DEBUG_TRACE,("-->RadioOnExec() return on fOP_STATUS_DOZE == TRUE; \n"));
+//KH Debug: Add the compile flag "RT2860 and condition
+#ifdef RTMP_PCI_SUPPORT
+ if (OPSTATUS_TEST_FLAG(pAd, fOP_STATUS_PCIE_DEVICE)
+ &&pAd->StaCfg.PSControl.field.EnableNewPS == TRUE)
+ RTMPSetTimer(&pAd->Mlme.RadioOnOffTimer, 10);
+#endif // RTMP_PCI_SUPPORT //
+ return;
+ }
+
+ if (RTMP_TEST_FLAG(pAd, fRTMP_ADAPTER_BSS_SCAN_IN_PROGRESS))
+ {
+ DBGPRINT(RT_DEBUG_TRACE,("-->RadioOnExec() return on SCAN_IN_PROGRESS; \n"));
+
+
+#ifdef RTMP_PCI_SUPPORT
+if (OPSTATUS_TEST_FLAG(pAd, fOP_STATUS_PCIE_DEVICE)
+ &&pAd->StaCfg.PSControl.field.EnableNewPS == TRUE)
+ RTMPSetTimer(&pAd->Mlme.RadioOnOffTimer, 10);
+#endif // RTMP_PCI_SUPPORT //
+ return;
+ }
+//KH Debug: need to check. I add the compile flag "CONFIG_STA_SUPPORT" to enclose the following codes.
+#ifdef RTMP_PCI_SUPPORT
+if (OPSTATUS_TEST_FLAG(pAd, fOP_STATUS_PCIE_DEVICE)
+ &&pAd->StaCfg.PSControl.field.EnableNewPS == TRUE)
+ {
+ pAd->Mlme.bPsPollTimerRunning = FALSE;
+ RTMPCancelTimer(&pAd->Mlme.PsPollTimer, &Cancelled);
+ }
+#endif // RTMP_PCI_SUPPORT //
+ if (pAd->StaCfg.bRadio == TRUE)
+ {
+ pAd->bPCIclkOff = FALSE;
+ RTMPRingCleanUp(pAd, QID_AC_BK);
+ RTMPRingCleanUp(pAd, QID_AC_BE);
+ RTMPRingCleanUp(pAd, QID_AC_VI);
+ RTMPRingCleanUp(pAd, QID_AC_VO);
+ /*RTMPRingCleanUp(pAd, QID_HCCA);*/
+ RTMPRingCleanUp(pAd, QID_MGMT);
+ RTMPRingCleanUp(pAd, QID_RX);
+
+ // 2. Send wake up command.
+ AsicSendCommandToMcu(pAd, 0x31, PowerWakeCID, 0x00, 0x02);
+ // 2-1. wait command ok.
+ AsicCheckCommanOk(pAd, PowerWakeCID);
+
+ // When PCI clock is off, don't want to service interrupt. So when back to clock on, enable interrupt.
+ //RTMP_IO_WRITE32(pAd, INT_MASK_CSR, (DELAYINTMASK|RxINT));
+ RTMP_ASIC_INTERRUPT_ENABLE(pAd);
+
+ // 3. Enable Tx DMA.
+ RTMP_IO_READ32(pAd, WPDMA_GLO_CFG, &DmaCfg.word);
+ DmaCfg.field.EnableTxDMA = 1;
+ RTMP_IO_WRITE32(pAd, WPDMA_GLO_CFG, DmaCfg.word);
+
+ // In Radio Off, we turn off RF clk, So now need to call ASICSwitchChannel again.
+ if (INFRA_ON(pAd) && (pAd->CommonCfg.CentralChannel != pAd->CommonCfg.Channel)
+ && (pAd->MlmeAux.HtCapability.HtCapInfo.ChannelWidth == BW_40))
+ {
+ // Must using 40MHz.
+ AsicSwitchChannel(pAd, pAd->CommonCfg.CentralChannel, FALSE);
+ AsicLockChannel(pAd, pAd->CommonCfg.CentralChannel);
+ }
+ else
+ {
+ // Must using 20MHz.
+ AsicSwitchChannel(pAd, pAd->CommonCfg.Channel, FALSE);
+ AsicLockChannel(pAd, pAd->CommonCfg.Channel);
+ }
+//KH Debug:The following codes should be enclosed by RT3090 compile flag
+ if (pChipOps->AsicReverseRfFromSleepMode)
+ pChipOps->AsicReverseRfFromSleepMode(pAd);
+#ifdef PCIE_PS_SUPPORT
+#ifdef CONFIG_STA_SUPPORT
+// 3090 MCU Wakeup command needs more time to be stable.
+// Before stable, don't issue other MCU command to prevent from firmware error.
+if ((IS_RT3090(pAd) || IS_RT3572(pAd) || IS_RT3390(pAd)) && IS_VERSION_AFTER_F(pAd)
+ && (pAd->StaCfg.PSControl.field.rt30xxPowerMode == 3)
+ && (pAd->StaCfg.PSControl.field.EnableNewPS == TRUE))
+ {
+ RTMP_SEM_LOCK(&pAd->McuCmdLock);
+ pAd->brt30xxBanMcuCmd = FALSE;
+ RTMP_SEM_UNLOCK(&pAd->McuCmdLock);
+ }
+#endif // CONFIG_STA_SUPPORT //
+#endif // PCIE_PS_SUPPORT //
+ // Clear Radio off flag
+ RTMP_CLEAR_FLAG(pAd, fRTMP_ADAPTER_RADIO_OFF);
+
+ // Set LED
+ RTMPSetLED(pAd, LED_RADIO_ON);
+
+ if (pAd->StaCfg.Psm == PWR_ACTIVE)
+ {
+ RTMP_BBP_IO_WRITE8_BY_REG_ID(pAd, BBP_R3, pAd->StaCfg.BBPR3);
+ }
+ }
+ else
+ {
+ RT28xxPciAsicRadioOff(pAd, GUIRADIO_OFF, 0);
+ }
+}
+#endif // CONFIG_STA_SUPPORT //
+
+
+/*
+ ==========================================================================
+ Description:
+ This routine sends command to firmware and turn our chip to wake up mode from power save mode.
+ Both RadioOn and .11 power save function needs to call this routine.
+ Input:
+ Level = GUIRADIO_OFF : call this function is from Radio Off to Radio On. Need to restore PCI host value.
+ Level = other value : normal wake up function.
+
+ ==========================================================================
+ */
+BOOLEAN RT28xxPciAsicRadioOn(
+ IN PRTMP_ADAPTER pAd,
+ IN UCHAR Level)
+{
+ //WPDMA_GLO_CFG_STRUC DmaCfg;
+#ifdef CONFIG_STA_SUPPORT
+ BOOLEAN Cancelled;
+#endif // CONFIG_STA_SUPPORT //
+ //UINT32 MACValue;
+
+ if (pAd->OpMode == OPMODE_AP && Level==DOT11POWERSAVE)
+ return FALSE;
+
+#ifdef CONFIG_STA_SUPPORT
+ if (OPSTATUS_TEST_FLAG(pAd, fOP_STATUS_PCIE_DEVICE))
+ {
+ if (pAd->StaCfg.PSControl.field.EnableNewPS == TRUE)
+ {
+ pAd->Mlme.bPsPollTimerRunning = FALSE;
+ RTMPCancelTimer(&pAd->Mlme.PsPollTimer, &Cancelled);
+ }
+ if ((pAd->StaCfg.PSControl.field.EnableNewPS == TRUE)&&
+ ((Level == GUIRADIO_OFF) || (Level == GUI_IDLE_POWER_SAVE))
+ ||(RTMP_TEST_PSFLAG(pAd, fRTMP_PS_SET_PCI_CLK_OFF_COMMAND)))
+ {
+ // Some chips don't need to delay 6ms, so copy RTMPPCIePowerLinkCtrlRestore
+ // return condition here.
+ /*
+ if (((pAd->MACVersion&0xffff0000) != 0x28600000)
+ && ((pAd->DeviceID == NIC2860_PCIe_DEVICE_ID)
+ ||(pAd->DeviceID == NIC2790_PCIe_DEVICE_ID)))
+ */
+ {
+ DBGPRINT(RT_DEBUG_TRACE, ("RT28xxPciAsicRadioOn ()\n"));
+ // 1. Set PCI Link Control in Configuration Space.
+ RTMPPCIeLinkCtrlValueRestore(pAd, RESTORE_WAKEUP);
+ RTMPusecDelay(6000);
+ }
+ }
+ }
+
+#ifdef PCIE_PS_SUPPORT
+if (!(((IS_RT3090(pAd) || IS_RT3572(pAd) || IS_RT3390(pAd)) && IS_VERSION_AFTER_F(pAd)
+ && (pAd->StaCfg.PSControl.field.rt30xxPowerMode == 3)
+ && (pAd->StaCfg.PSControl.field.EnableNewPS == TRUE))))
+#endif // PCIE_PS_SUPPORT //
+ {
+ pAd->bPCIclkOff = FALSE;
+ DBGPRINT(RT_DEBUG_TRACE, ("PSM :309xbPCIclkOff == %d\n", pAd->bPCIclkOff));
+
+ }
+#endif // CONFIG_STA_SUPPORT //
+ // 2. Send wake up command.
+ AsicSendCommandToMcu(pAd, 0x31, PowerWakeCID, 0x00, 0x02);
+ pAd->bPCIclkOff = FALSE;
+ // 2-1. wait command ok.
+ AsicCheckCommanOk(pAd, PowerWakeCID);
+ RTMP_ASIC_INTERRUPT_ENABLE(pAd);
+
+
+ RTMP_CLEAR_FLAG(pAd, fRTMP_ADAPTER_IDLE_RADIO_OFF);
+ if (Level == GUI_IDLE_POWER_SAVE)
+ {
+#ifdef PCIE_PS_SUPPORT
+
+ // add by johnli, RF power sequence setup, load RF normal operation-mode setup
+ if ((IS_RT3090(pAd) || IS_RT3572(pAd) || IS_RT3390(pAd)))
+ {
+ RTMP_CHIP_OP *pChipOps = &pAd->chipOps;
+
+ if (pChipOps->AsicReverseRfFromSleepMode)
+ pChipOps->AsicReverseRfFromSleepMode(pAd);
+#ifdef CONFIG_STA_SUPPORT
+ // 3090 MCU Wakeup command needs more time to be stable.
+ // Before stable, don't issue other MCU command to prevent from firmware error.
+ if ((IS_RT3090(pAd) || IS_RT3572(pAd) || IS_RT3390(pAd)) && IS_VERSION_AFTER_F(pAd)
+ && (pAd->StaCfg.PSControl.field.rt30xxPowerMode == 3)
+ && (pAd->StaCfg.PSControl.field.EnableNewPS == TRUE))
+ {
+ RTMP_SEM_LOCK(&pAd->McuCmdLock);
+ pAd->brt30xxBanMcuCmd = FALSE;
+ RTMP_SEM_UNLOCK(&pAd->McuCmdLock);
+ }
+#endif // CONFIG_STA_SUPPORT //
+ }
+ else
+ // end johnli
+#endif // PCIE_PS_SUPPORT //
+ {
+ // In Radio Off, we turn off RF clk, So now need to call ASICSwitchChannel again.
+#ifdef CONFIG_STA_SUPPORT
+ IF_DEV_CONFIG_OPMODE_ON_STA(pAd)
+ {
+ if (INFRA_ON(pAd) && (pAd->CommonCfg.CentralChannel != pAd->CommonCfg.Channel)
+ && (pAd->MlmeAux.HtCapability.HtCapInfo.ChannelWidth == BW_40))
+ {
+ // Must using 40MHz.
+ AsicSwitchChannel(pAd, pAd->CommonCfg.CentralChannel, FALSE);
+ AsicLockChannel(pAd, pAd->CommonCfg.CentralChannel);
+ }
+ else
+ {
+ // Must using 20MHz.
+ AsicSwitchChannel(pAd, pAd->CommonCfg.Channel, FALSE);
+ AsicLockChannel(pAd, pAd->CommonCfg.Channel);
+ }
+ }
+#endif // CONFIG_STA_SUPPORT //
+ }
+ }
+ return TRUE;
+
+}
+
+
+/*
+ ==========================================================================
+ Description:
+ This routine sends command to firmware and turn our chip to power save mode.
+ Both RadioOff and .11 power save function needs to call this routine.
+ Input:
+ Level = GUIRADIO_OFF : GUI Radio Off mode
+ Level = DOT11POWERSAVE : 802.11 power save mode
+ Level = RTMP_HALT : When Disable device.
+
+ ==========================================================================
+ */
+BOOLEAN RT28xxPciAsicRadioOff(
+ IN PRTMP_ADAPTER pAd,
+ IN UCHAR Level,
+ IN USHORT TbttNumToNextWakeUp)
+{
+#ifdef CONFIG_STA_SUPPORT
+ WPDMA_GLO_CFG_STRUC DmaCfg;
+ UCHAR i, tempBBP_R3 = 0;
+#endif // CONFIG_STA_SUPPORT //
+ BOOLEAN brc = FALSE, Cancelled;
+ UINT32 TbTTTime = 0;
+ UINT32 PsPollTime = 0/*, MACValue*/;
+ ULONG BeaconPeriodTime;
+ UINT32 RxDmaIdx, RxCpuIdx;
+ DBGPRINT(RT_DEBUG_TRACE, ("AsicRadioOff ===> Lv= %d, TxCpuIdx = %d, TxDmaIdx = %d. RxCpuIdx = %d, RxDmaIdx = %d.\n", Level,pAd->TxRing[0].TxCpuIdx, pAd->TxRing[0].TxDmaIdx, pAd->RxRing.RxCpuIdx, pAd->RxRing.RxDmaIdx));
+
+ if (pAd->OpMode == OPMODE_AP && Level==DOT11POWERSAVE)
+ return FALSE;
+
+ // Check Rx DMA busy status, if more than half is occupied, give up this radio off.
+ RTMP_IO_READ32(pAd, RX_DRX_IDX , &RxDmaIdx);
+ RTMP_IO_READ32(pAd, RX_CRX_IDX , &RxCpuIdx);
+ if ((RxDmaIdx > RxCpuIdx) && ((RxDmaIdx - RxCpuIdx) > RX_RING_SIZE/3))
+ {
+ DBGPRINT(RT_DEBUG_TRACE, ("AsicRadioOff ===> return1. RxDmaIdx = %d , RxCpuIdx = %d. \n", RxDmaIdx, RxCpuIdx));
+ return FALSE;
+ }
+ else if ((RxCpuIdx >= RxDmaIdx) && ((RxCpuIdx - RxDmaIdx) < RX_RING_SIZE/3))
+ {
+ DBGPRINT(RT_DEBUG_TRACE, ("AsicRadioOff ===> return2. RxCpuIdx = %d. RxDmaIdx = %d , \n", RxCpuIdx, RxDmaIdx));
+ return FALSE;
+ }
+
+ // Once go into this function, disable tx because don't want too many packets in queue to prevent HW stops.
+ //pAd->bPCIclkOffDisableTx = TRUE;
+ RTMP_SET_PSFLAG(pAd, fRTMP_PS_DISABLE_TX);
+ if (OPSTATUS_TEST_FLAG(pAd, fOP_STATUS_PCIE_DEVICE)
+ && pAd->OpMode == OPMODE_STA
+#ifdef CONFIG_STA_SUPPORT
+ &&pAd->StaCfg.PSControl.field.EnableNewPS == TRUE
+#endif // CONFIG_STA_SUPPORT //
+ )
+ {
+
+ RTMPCancelTimer(&pAd->Mlme.RadioOnOffTimer, &Cancelled);
+ RTMPCancelTimer(&pAd->Mlme.PsPollTimer, &Cancelled);
+
+ if (Level == DOT11POWERSAVE)
+ {
+ RTMP_IO_READ32(pAd, TBTT_TIMER, &TbTTTime);
+ TbTTTime &= 0x1ffff;
+ // 00. check if need to do sleep in this DTIM period. If next beacon will arrive within 30ms , ...doesn't necessarily sleep.
+ // TbTTTime uint = 64us, LEAD_TIME unit = 1024us, PsPollTime unit = 1ms
+ if (((64*TbTTTime) <((LEAD_TIME*1024) + 40000)) && (TbttNumToNextWakeUp == 0))
+ {
+ DBGPRINT(RT_DEBUG_TRACE, ("TbTTTime = 0x%x , give up this sleep. \n", TbTTTime));
+ OPSTATUS_CLEAR_FLAG(pAd, fOP_STATUS_DOZE);
+ //pAd->bPCIclkOffDisableTx = FALSE;
+ RTMP_CLEAR_PSFLAG(pAd, fRTMP_PS_DISABLE_TX);
+ return FALSE;
+ }
+ else
+ {
+ PsPollTime = (64*TbTTTime- LEAD_TIME*1024)/1000;
+#ifdef PCIE_PS_SUPPORT
+#ifdef CONFIG_STA_SUPPORT
+ if ((IS_RT3090(pAd) || IS_RT3572(pAd) || IS_RT3390(pAd)) && IS_VERSION_AFTER_F(pAd)
+ && (pAd->StaCfg.PSControl.field.rt30xxPowerMode == 3)
+ && (pAd->StaCfg.PSControl.field.EnableNewPS == TRUE))
+ {
+ PsPollTime -= 5;
+ }
+ else
+#endif // CONFIG_STA_SUPPORT //
+#endif // PCIE_PS_SUPPORT //
+ PsPollTime -= 3;
+
+ BeaconPeriodTime = pAd->CommonCfg.BeaconPeriod*102/100;
+ if (TbttNumToNextWakeUp > 0)
+ PsPollTime += ((TbttNumToNextWakeUp -1) * BeaconPeriodTime);
+
+ pAd->Mlme.bPsPollTimerRunning = TRUE;
+ RTMPSetTimer(&pAd->Mlme.PsPollTimer, PsPollTime);
+ }
+ }
+ }
+ else
+ {
+ DBGPRINT(RT_DEBUG_TRACE, ("RT28xxPciAsicRadioOff::Level!=DOT11POWERSAVE \n"));
+ }
+
+ pAd->bPCIclkOffDisableTx = FALSE;
+ RTMP_SET_FLAG(pAd, fRTMP_ADAPTER_IDLE_RADIO_OFF);
+
+#ifdef CONFIG_STA_SUPPORT
+ // Set to 1R.
+ if (pAd->Antenna.field.RxPath > 1 && pAd->OpMode == OPMODE_STA)
+ {
+ tempBBP_R3 = (pAd->StaCfg.BBPR3 & 0xE7);
+ RTMP_BBP_IO_WRITE8_BY_REG_ID(pAd, BBP_R3, tempBBP_R3);
+ }
+#endif // CONFIG_STA_SUPPORT //
+
+ // In Radio Off, we turn off RF clk, So now need to call ASICSwitchChannel again.
+ if ((INFRA_ON(pAd) || pAd->OpMode == OPMODE_AP) && (pAd->CommonCfg.CentralChannel != pAd->CommonCfg.Channel)
+ && (pAd->MlmeAux.HtCapability.HtCapInfo.ChannelWidth == BW_40))
+ {
+ // Must using 40MHz.
+ AsicTurnOffRFClk(pAd, pAd->CommonCfg.CentralChannel);
+ }
+ else
+ {
+ // Must using 20MHz.
+ AsicTurnOffRFClk(pAd, pAd->CommonCfg.Channel);
+ }
+
+ if (Level != RTMP_HALT)
+ {
+ // Change Interrupt bitmask.
+ // When PCI clock is off, don't want to service interrupt.
+ RTMP_IO_WRITE32(pAd, INT_MASK_CSR, AutoWakeupInt);
+ }
+ else
+ {
+ RTMP_ASIC_INTERRUPT_DISABLE(pAd);
+ }
+
+
+ RTMP_IO_WRITE32(pAd, RX_CRX_IDX, pAd->RxRing.RxCpuIdx);
+ // 2. Send Sleep command
+ RTMP_IO_WRITE32(pAd, H2M_MAILBOX_STATUS, 0xffffffff);
+ RTMP_IO_WRITE32(pAd, H2M_MAILBOX_CID, 0xffffffff);
+ // send POWER-SAVE command to MCU. high-byte = 1 save power as much as possible. high byte = 0 save less power
+ AsicSendCommandToMcu(pAd, 0x30, PowerSafeCID, 0xff, 0x1);
+ // 2-1. Wait command success
+ // Status = 1 : success, Status = 2, already sleep, Status = 3, Maybe MAC is busy so can't finish this task.
+ brc = AsicCheckCommanOk(pAd, PowerSafeCID);
+
+ // 3. After 0x30 command is ok, send radio off command. lowbyte = 0 for power safe.
+ // If 0x30 command is not ok this time, we can ignore 0x35 command. It will make sure not cause firmware'r problem.
+ if ((Level == DOT11POWERSAVE) && (brc == TRUE))
+ {
+ AsicSendCommandToMcu(pAd, 0x35, PowerRadioOffCID, 0, 0x00); // lowbyte = 0 means to do power safe, NOT turn off radio.
+ // 3-1. Wait command success
+ AsicCheckCommanOk(pAd, PowerRadioOffCID);
+ }
+ else if (brc == TRUE)
+ {
+ AsicSendCommandToMcu(pAd, 0x35, PowerRadioOffCID, 1, 0x00); // lowbyte = 0 means to do power safe, NOT turn off radio.
+ // 3-1. Wait command success
+ AsicCheckCommanOk(pAd, PowerRadioOffCID);
+ }
+
+#ifdef CONFIG_STA_SUPPORT
+ // 1. Wait DMA not busy
+ i = 0;
+ do
+ {
+ RTMP_IO_READ32(pAd, WPDMA_GLO_CFG, &DmaCfg.word);
+ if ((DmaCfg.field.RxDMABusy == 0) && (DmaCfg.field.TxDMABusy == 0))
+ break;
+ RTMPusecDelay(20);
+ i++;
+ }while(i < 50);
+
+ /*
+ if (i >= 50)
+ {
+ pAd->CheckDmaBusyCount++;
+ DBGPRINT(RT_DEBUG_TRACE, ("DMA Rx keeps busy. return on AsicRadioOff () CheckDmaBusyCount = %d \n", pAd->CheckDmaBusyCount));
+ }
+ else
+ {
+ pAd->CheckDmaBusyCount = 0;
+ }
+ */
+#endif // CONFIG_STA_SUPPORT //
+//KH Debug:My original codes have the follwoing codes, but currecnt codes do not have it.
+// Disable for stability. If PCIE Link Control is modified for advance power save, re-covery this code segment.
+RTMP_IO_WRITE32(pAd, PBF_SYS_CTRL, 0x1280);
+//OPSTATUS_SET_FLAG(pAd, fOP_STATUS_CLKSELECT_40MHZ);
+
+#ifdef PCIE_PS_SUPPORT
+#ifdef CONFIG_STA_SUPPORT
+if ((IS_RT3090(pAd) || IS_RT3572(pAd) || IS_RT3390(pAd)) && IS_VERSION_AFTER_F(pAd)
+ && (pAd->StaCfg.PSControl.field.rt30xxPowerMode == 3)
+ && (pAd->StaCfg.PSControl.field.EnableNewPS == TRUE))
+ {
+ DBGPRINT(RT_DEBUG_TRACE, ("RT28xxPciAsicRadioOff::3090 return to skip the following TbttNumToNextWakeUp setting for 279x\n"));
+ pAd->bPCIclkOff = TRUE;
+ RTMP_CLEAR_PSFLAG(pAd, fRTMP_PS_DISABLE_TX);
+ // For this case, doesn't need to below actions, so return here.
+ return brc;
+ }
+#endif // CONFIG_STA_SUPPORT //
+#endif // PCIE_PS_SUPPORT //
+ if (Level == DOT11POWERSAVE)
+ {
+ AUTO_WAKEUP_STRUC AutoWakeupCfg;
+ //RTMPSetTimer(&pAd->Mlme.PsPollTimer, 90);
+
+ // 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);
+
+ // 1. Set auto wake up timer.
+ AutoWakeupCfg.field.NumofSleepingTbtt = TbttNumToNextWakeUp - 1;
+ AutoWakeupCfg.field.EnableAutoWakeup = 1;
+ AutoWakeupCfg.field.AutoLeadTime = LEAD_TIME;
+ RTMP_IO_WRITE32(pAd, AUTO_WAKEUP_CFG, AutoWakeupCfg.word);
+ }
+
+#ifdef CONFIG_STA_SUPPORT
+ // 4-1. If it's to disable our device. Need to restore PCI Configuration Space to its original value.
+ if (Level == RTMP_HALT && pAd->OpMode == OPMODE_STA)
+ {
+ if ((brc == TRUE) && (i < 50))
+ RTMPPCIeLinkCtrlSetting(pAd, 1);
+ }
+ // 4. Set PCI configuration Space Link Comtrol fields. Only Radio Off needs to call this function
+ else if (pAd->OpMode == OPMODE_STA)
+ {
+ if ((brc == TRUE) && (i < 50))
+ RTMPPCIeLinkCtrlSetting(pAd, 3);
+ }
+#endif // CONFIG_STA_SUPPORT //
+
+ //pAd->bPCIclkOffDisableTx = FALSE;
+ RTMP_CLEAR_PSFLAG(pAd, fRTMP_PS_DISABLE_TX);
+ return TRUE;
+}
+
+
+
+
+VOID RT28xxPciMlmeRadioOn(
+ IN PRTMP_ADAPTER pAd)
+{
+ if (!RTMP_TEST_FLAG(pAd, fRTMP_ADAPTER_RADIO_OFF))
+ return;
+
+ DBGPRINT(RT_DEBUG_TRACE,("%s===>\n", __FUNCTION__));
+
+ if ((pAd->OpMode == OPMODE_AP) ||
+ ((pAd->OpMode == OPMODE_STA)
+ && (!OPSTATUS_TEST_FLAG(pAd, fOP_STATUS_PCIE_DEVICE)
+#ifdef CONFIG_STA_SUPPORT
+ ||pAd->StaCfg.PSControl.field.EnableNewPS == FALSE
+#endif // CONFIG_STA_SUPPORT //
+ )))
+ {
+ RT28xxPciAsicRadioOn(pAd, GUI_IDLE_POWER_SAVE);
+ //NICResetFromError(pAd);
+
+ RTMPRingCleanUp(pAd, QID_AC_BK);
+ RTMPRingCleanUp(pAd, QID_AC_BE);
+ RTMPRingCleanUp(pAd, QID_AC_VI);
+ RTMPRingCleanUp(pAd, QID_AC_VO);
+ /*RTMPRingCleanUp(pAd, QID_HCCA);*/
+ RTMPRingCleanUp(pAd, QID_MGMT);
+ RTMPRingCleanUp(pAd, QID_RX);
+
+ // Enable Tx/Rx
+ RTMPEnableRxTx(pAd);
+
+ // Clear Radio off flag
+ RTMP_CLEAR_FLAG(pAd, fRTMP_ADAPTER_RADIO_OFF);
+ RTMP_CLEAR_FLAG(pAd, fRTMP_ADAPTER_IDLE_RADIO_OFF);
+ // Set LED
+ RTMPSetLED(pAd, LED_RADIO_ON);
+ }
+
+#ifdef CONFIG_STA_SUPPORT
+ if ((pAd->OpMode == OPMODE_STA) &&
+ (OPSTATUS_TEST_FLAG(pAd, fOP_STATUS_PCIE_DEVICE))
+ &&(pAd->StaCfg.PSControl.field.EnableNewPS == TRUE))
+ {
+ BOOLEAN Cancelled;
+
+ RTMPPCIeLinkCtrlValueRestore(pAd, RESTORE_WAKEUP);
+
+ pAd->Mlme.bPsPollTimerRunning = FALSE;
+ RTMPCancelTimer(&pAd->Mlme.PsPollTimer, &Cancelled);
+ RTMPCancelTimer(&pAd->Mlme.RadioOnOffTimer, &Cancelled);
+ RTMPSetTimer(&pAd->Mlme.RadioOnOffTimer, 40);
+ }
+#endif // CONFIG_STA_SUPPORT //
+}
+
+
+VOID RT28xxPciMlmeRadioOFF(
+ IN PRTMP_ADAPTER pAd)
+{
+ BOOLEAN brc=TRUE;
+
+ if (RTMP_TEST_FLAG(pAd, fRTMP_ADAPTER_RADIO_OFF))
+ return;
+
+#ifdef CONFIG_STA_SUPPORT
+ // Link down first if any association exists
+ if (!RTMP_TEST_FLAG(pAd, fRTMP_ADAPTER_NIC_NOT_EXIST))
+ {
+ if (INFRA_ON(pAd) || ADHOC_ON(pAd))
+ {
+ MLME_DISASSOC_REQ_STRUCT DisReq;
+ MLME_QUEUE_ELEM *pMsgElem = (MLME_QUEUE_ELEM *) kmalloc(sizeof(MLME_QUEUE_ELEM), MEM_ALLOC_FLAG);
+
+ if (pMsgElem)
+ {
+ COPY_MAC_ADDR(&DisReq.Addr, pAd->CommonCfg.Bssid);
+ DisReq.Reason = REASON_DISASSOC_STA_LEAVING;
+
+ pMsgElem->Machine = ASSOC_STATE_MACHINE;
+ pMsgElem->MsgType = MT2_MLME_DISASSOC_REQ;
+ pMsgElem->MsgLen = sizeof(MLME_DISASSOC_REQ_STRUCT);
+ NdisMoveMemory(pMsgElem->Msg, &DisReq, sizeof(MLME_DISASSOC_REQ_STRUCT));
+
+ MlmeDisassocReqAction(pAd, pMsgElem);
+ kfree(pMsgElem);
+
+ RTMPusecDelay(1000);
+ }
+ }
+ }
+#endif // CONFIG_STA_SUPPORT //
+
+ DBGPRINT(RT_DEBUG_TRACE,("%s===>\n", __FUNCTION__));
+
+ // 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)
+ {
+ BOOLEAN Cancelled;
+ if (pAd->StaCfg.PSControl.field.EnableNewPS == TRUE)
+ {
+ if (RTMP_TEST_FLAG(pAd, fRTMP_ADAPTER_BSS_SCAN_IN_PROGRESS))
+ {
+ RTMPCancelTimer(&pAd->MlmeAux.ScanTimer, &Cancelled);
+ RTMP_CLEAR_FLAG(pAd, fRTMP_ADAPTER_BSS_SCAN_IN_PROGRESS);
+ }
+ // If during power safe mode.
+ if (pAd->StaCfg.bRadio == TRUE)
+ {
+ DBGPRINT(RT_DEBUG_TRACE,("-->MlmeRadioOff() return on bRadio == TRUE; \n"));
+ return;
+ }
+ // Always radio on since the NIC needs to set the MCU command (LED_RADIO_OFF).
+ if (IDLE_ON(pAd) &&
+ (RTMP_TEST_FLAG(pAd, fRTMP_ADAPTER_IDLE_RADIO_OFF)))
+ {
+ RT28xxPciAsicRadioOn(pAd, GUI_IDLE_POWER_SAVE);
+ }
+ if (OPSTATUS_TEST_FLAG(pAd, fOP_STATUS_PCIE_DEVICE))
+ {
+ BOOLEAN Cancelled;
+ pAd->Mlme.bPsPollTimerRunning = FALSE;
+ RTMPCancelTimer(&pAd->Mlme.PsPollTimer, &Cancelled);
+ RTMPCancelTimer(&pAd->Mlme.RadioOnOffTimer, &Cancelled);
+ }
+ }
+
+ // 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);
+
+ /*
+ if (OPSTATUS_TEST_FLAG(pAd, fOP_STATUS_PCIE_DEVICE))
+ {
+ RTMPSetTimer(&pAd->Mlme.RadioOnOffTimer, 10);
+ return;
+ }
+ */
+ }
+#endif // CONFIG_STA_SUPPORT //
+ // Set LED.Move to here for fixing LED bug. This flag must be called after LinkDown
+ RTMPSetLED(pAd, LED_RADIO_OFF);
+
+#ifdef CONFIG_STA_SUPPORT
+//KH Debug:All PCIe devices need to use timer to execute radio off function, or the PCIe&&EnableNewPS needs.
+//KH Ans:It is right, because only when the PCIe and EnableNewPs is true, we need to delay the RadioOffTimer
+//to avoid the deadlock with PCIe Power saving function.
+if (pAd->OpMode == OPMODE_STA&&
+ OPSTATUS_TEST_FLAG(pAd, fOP_STATUS_PCIE_DEVICE)&&
+ pAd->StaCfg.PSControl.field.EnableNewPS == TRUE)
+ {
+ RTMPSetTimer(&pAd->Mlme.RadioOnOffTimer, 10);
+ }
+else
+#endif // CONFIG_STA_SUPPORT //
+{
+
+
+ brc=RT28xxPciAsicRadioOff(pAd, GUIRADIO_OFF, 0);
+
+ if (brc==FALSE)
+ {
+ DBGPRINT(RT_DEBUG_ERROR,("%s call RT28xxPciAsicRadioOff fail !!\n", __FUNCTION__));
+ }
+}
+/*
+ // Disable Tx/Rx DMA
+ RTMP_IO_READ32(pAd, WPDMA_GLO_CFG, &GloCfg.word); // disable DMA
+ GloCfg.field.EnableTxDMA = 0;
+ GloCfg.field.EnableRxDMA = 0;
+ RTMP_IO_WRITE32(pAd, WPDMA_GLO_CFG, GloCfg.word); // abort all TX rings
+
+
+ // 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);
+
+ if (pAd->CommonCfg.BBPCurrentBW == BW_40)
+ {
+ // Must using 40MHz.
+ AsicTurnOffRFClk(pAd, pAd->CommonCfg.CentralChannel);
+ }
+ else
+ {
+ // Must using 20MHz.
+ AsicTurnOffRFClk(pAd, pAd->CommonCfg.Channel);
+ }
+
+ // 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);
+*/
+}
+
+#endif // RTMP_MAC_PCI //
diff --git a/drivers/staging/rt3090/common/cmm_profile.c b/drivers/staging/rt3090/common/cmm_profile.c
new file mode 100644
index 000000000000..5803f422ae09
--- /dev/null
+++ b/drivers/staging/rt3090/common/cmm_profile.c
@@ -0,0 +1,2321 @@
+/*
+ *************************************************************************
+ * 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:
+ cmm_profile.c
+
+ Abstract:
+
+ Revision History:
+ Who When What
+ --------- ---------- ----------------------------------------------
+ */
+
+#include "../rt_config.h"
+
+
+#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(PSTRING s1, PSTRING s2)
+{
+ int i = 0;
+ PSTRING 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, (PUCHAR)&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(PSTRING s1, PSTRING s2)
+{
+ PSTRING 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.
+PSTRING rtstrstruncasecmp(PSTRING s1, PSTRING 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
+ */
+PSTRING rtstrstr(PSTRING s1,const PSTRING s2)
+{
+ INT l1, l2;
+
+ l2 = strlen(s2);
+ if (!l2)
+ return s1;
+
+ l1 = strlen(s1);
+
+ while (l1 >= l2)
+ {
+ l1--;
+ if (!memcmp(s1,s2,l2))
+ return 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.
+ */
+PSTRING __rstrtok;
+PSTRING rstrtok(PSTRING s,const PSTRING ct)
+{
+ PSTRING 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(PSTRING s,PSTRING ct)
+{
+ INT count = 0;
+ /* point to the beginning of the line */
+ PSTRING 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(PSTRING cp, unsigned int *addr)
+{
+ unsigned int val;
+ int base, n;
+ STRING 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
+ ========================================================================
+*/
+PSTRING RTMPFindSection(
+ IN PSTRING buffer)
+{
+ STRING temp_buf[32];
+ PSTRING 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
+ bTrimSpace Set true if you want to strip the space character of the result pattern
+
+ Return Value:
+ TRUE Success
+ FALSE Fail
+
+ Note:
+ This routine get the value with the matched key (case case-sensitive)
+ For SSID and security key related parameters, we SHALL NOT trim the space(' ') character.
+ ========================================================================
+*/
+INT RTMPGetKeyParameter(
+ IN PSTRING key,
+ OUT PSTRING dest,
+ IN INT destsize,
+ IN PSTRING buffer,
+ IN BOOLEAN bTrimSpace)
+{
+ PSTRING pMemBuf, temp_buf1 = NULL, temp_buf2 = NULL;
+ PSTRING start_ptr, end_ptr;
+ PSTRING ptr;
+ PSTRING offset = NULL;
+ INT len, keyLen;
+
+
+ keyLen = strlen(key);
+ os_alloc_mem(NULL, (PUCHAR *)&pMemBuf, MAX_PARAM_BUFFER_SIZE * 2);
+ if (pMemBuf == NULL)
+ return (FALSE);
+
+ memset(pMemBuf, 0, MAX_PARAM_BUFFER_SIZE * 2);
+ temp_buf1 = pMemBuf;
+ temp_buf2 = (PSTRING)(pMemBuf + MAX_PARAM_BUFFER_SIZE);
+
+
+ //find section
+ if((offset = RTMPFindSection(buffer)) == NULL)
+ {
+ os_free_mem(NULL, (PUCHAR)pMemBuf);
+ 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, (PUCHAR)pMemBuf);
+ 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, (PUCHAR)pMemBuf);
+ return (FALSE);
+ }
+
+ NdisMoveMemory(temp_buf2, start_ptr, end_ptr-start_ptr);
+ temp_buf2[end_ptr-start_ptr]='\0';
+ if((start_ptr=rtstrstr(temp_buf2, "=")) == NULL)
+ {
+ os_free_mem(NULL, (PUCHAR)pMemBuf);
+ return (FALSE);
+ }
+ ptr = (start_ptr +1);
+ //trim special characters, i.e., TAB or space
+ while(*start_ptr != 0x00)
+ {
+ if( ((*ptr == ' ') && bTrimSpace) || (*ptr == '\t') )
+ ptr++;
+ else
+ break;
+ }
+ len = strlen(start_ptr);
+
+ memset(dest, 0x00, destsize);
+ strncpy(dest, ptr, ((len >= destsize) ? destsize: len));
+
+ os_free_mem(NULL, (PUCHAR)pMemBuf);
+
+ 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 PSTRING key,
+ OUT PSTRING dest,
+ OUT USHORT *end_offset,
+ IN INT destsize,
+ IN PSTRING buffer,
+ IN BOOLEAN bTrimSpace)
+{
+ PSTRING temp_buf1 = NULL;
+ PSTRING temp_buf2 = NULL;
+ PSTRING start_ptr;
+ PSTRING end_ptr;
+ PSTRING ptr;
+ PSTRING offset = 0;
+ INT len;
+
+ if (*end_offset >= MAX_INI_BUFFER_SIZE)
+ return (FALSE);
+
+ os_alloc_mem(NULL, (PUCHAR *)&temp_buf1, MAX_PARAM_BUFFER_SIZE);
+
+ if(temp_buf1 == NULL)
+ return (FALSE);
+
+ os_alloc_mem(NULL, (PUCHAR *)&temp_buf2, MAX_PARAM_BUFFER_SIZE);
+ if(temp_buf2 == NULL)
+ {
+ os_free_mem(NULL, (PUCHAR)temp_buf1);
+ return (FALSE);
+ }
+
+ //find section
+ if(*end_offset == 0)
+ {
+ if ((offset = RTMPFindSection(buffer)) == NULL)
+ {
+ os_free_mem(NULL, (PUCHAR)temp_buf1);
+ os_free_mem(NULL, (PUCHAR)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, (PUCHAR)temp_buf1);
+ os_free_mem(NULL, (PUCHAR)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, (PUCHAR)temp_buf1);
+ os_free_mem(NULL, (PUCHAR)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, (PUCHAR)temp_buf1);
+ os_free_mem(NULL, (PUCHAR)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, (PUCHAR)temp_buf1);
+ os_free_mem(NULL, (PUCHAR)temp_buf2);
+ return TRUE;
+}
+
+
+static int rtmp_parse_key_buffer_from_file(IN PRTMP_ADAPTER pAd,IN PSTRING buffer,IN ULONG KeyType,IN INT BSSIdx,IN INT KeyIdx)
+{
+ PSTRING keybuff;
+ //INT i = BSSIdx, idx = KeyIdx, retVal;
+ ULONG KeyLen;
+ //UCHAR CipherAlg = CIPHER_WEP64;
+ CIPHER_KEY *pSharedKey;
+
+ keybuff = buffer;
+ KeyLen = strlen(keybuff);
+ pSharedKey = &pAd->SharedKey[BSSIdx][KeyIdx];
+
+ if(((KeyType != 0) && (KeyType != 1)) ||
+ ((KeyType == 0) && (KeyLen != 10) && (KeyLen != 26)) ||
+ ((KeyType== 1) && (KeyLen != 5) && (KeyLen != 13)))
+ {
+ DBGPRINT(RT_DEBUG_ERROR, ("Key%dStr is Invalid key length(%ld) or Type(%ld)\n",
+ KeyIdx+1, KeyLen, KeyType));
+ return FALSE;
+ }
+ else
+ {
+ return RT_CfgSetWepKey(pAd, buffer, pSharedKey, KeyIdx);
+ }
+
+}
+
+
+static void rtmp_read_key_parms_from_file(IN PRTMP_ADAPTER pAd, PSTRING tmpbuf, PSTRING buffer)
+{
+ STRING tok_str[16];
+ PSTRING macptr;
+ INT i = 0, idx;
+ ULONG KeyType[MAX_MBSSID_NUM];
+ ULONG KeyIdx;
+
+ NdisZeroMemory(KeyType, sizeof(KeyType));
+
+ //DefaultKeyID
+ if(RTMPGetKeyParameter("DefaultKeyID", tmpbuf, 25, buffer, TRUE))
+ {
+
+#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, TRUE))
+ {
+ for (i = 0, macptr = rstrtok(tmpbuf,";"); macptr; macptr = rstrtok(NULL,";"), i++)
+ {
+ /*
+ do sanity check for KeyType length;
+ or in station mode, the KeyType length > 1,
+ the code will overwrite the stack of caller
+ (RTMPSetProfileParameters) and cause srcbuf = NULL
+ */
+ if (i < MAX_MBSSID_NUM)
+ 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 (RTMPGetKeyParameter(tok_str, tmpbuf, 128, buffer, FALSE))
+ {
+ 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)
+{
+ PSTRING macptr;
+ INT i=0;
+ BOOLEAN bWmmEnable = FALSE;
+
+ //WmmCapable
+ if(RTMPGetKeyParameter("WmmCapable", tmpbuf, 32, buffer, TRUE))
+ {
+ 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, TRUE))
+ {
+ 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, TRUE))
+ {
+ 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, TRUE))
+ {
+ 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));
+ }
+
+ //MaxSPLength
+ if(RTMPGetKeyParameter("MaxSPLength", tmpbuf, 10, buffer, TRUE))
+ {
+ pAd->CommonCfg.MaxSPLength = simple_strtol(tmpbuf, 0, 10);
+
+ DBGPRINT(RT_DEBUG_TRACE, ("MaxSPLength=%d\n", pAd->CommonCfg.MaxSPLength));
+ }
+
+ //APSDAC for AC_BE, AC_BK, AC_VI, AC_VO
+ if(RTMPGetKeyParameter("APSDAC", tmpbuf, 32, buffer, TRUE))
+ {
+ 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];
+
+ pAd->CommonCfg.bACMAPSDTr[0] = apsd_ac[0];
+ pAd->CommonCfg.bACMAPSDTr[1] = apsd_ac[1];
+ pAd->CommonCfg.bACMAPSDTr[2] = apsd_ac[2];
+ pAd->CommonCfg.bACMAPSDTr[3] = apsd_ac[3];
+ }
+ }
+
+}
+#endif // CONFIG_STA_SUPPORT //
+
+
+#ifdef DOT11_N_SUPPORT
+static void HTParametersHook(
+ IN PRTMP_ADAPTER pAd,
+ IN PSTRING pValueStr,
+ IN PSTRING pInput)
+{
+
+ long Value;
+
+ if (RTMPGetKeyParameter("HT_PROTECT", pValueStr, 25, pInput, TRUE))
+ {
+ 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, TRUE))
+ {
+ 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, TRUE))
+ {
+ 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", (INT) Value));
+ }
+
+ if (RTMPGetKeyParameter("HT_BADecline", pValueStr, 25, pInput, TRUE))
+ {
+ 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, TRUE))
+ {
+ 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, TRUE))
+ {
+ 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;
+ DBGPRINT(RT_DEBUG_TRACE, ("HT: Auto BA = %s\n", (Value==0) ? "Disable" : "Enable"));
+ }
+
+ // Tx_+HTC frame
+ if (RTMPGetKeyParameter("HT_HTC", pValueStr, 25, pInput, TRUE))
+ {
+ 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, TRUE))
+ {
+ 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, TRUE))
+ {
+ 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, TRUE))
+ {
+ 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, TRUE))
+ {
+ 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", (INT) 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, TRUE))
+ {
+ 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", (INT) 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, TRUE))
+ {
+ 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, TRUE))
+ {
+ 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, TRUE))
+ {
+ 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, TRUE))
+ {
+ 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, TRUE))
+ {
+ 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, TRUE))
+ {
+
+#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, TRUE))
+ {
+ 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, TRUE))
+ {
+ 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, TRUE))
+ {
+ 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, TRUE))
+ {
+ 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));
+ }
+ //2008/11/05: KH add to support Antenna power-saving of AP<--
+ //Green AP
+ if(RTMPGetKeyParameter("GreenAP", pValueStr, 10, pInput, TRUE))
+ {
+ Value = simple_strtol(pValueStr, 0, 10);
+ if (Value == 0)
+ {
+ pAd->CommonCfg.bGreenAPEnable = FALSE;
+ }
+ else
+ {
+ pAd->CommonCfg.bGreenAPEnable = TRUE;
+ }
+ DBGPRINT(RT_DEBUG_TRACE, ("HT: Green AP= %d\n", pAd->CommonCfg.bGreenAPEnable));
+ }
+
+ // HT_DisallowTKIP
+ if (RTMPGetKeyParameter("HT_DisallowTKIP", pValueStr, 25, pInput, TRUE))
+ {
+ Value = simple_strtol(pValueStr, 0, 10);
+
+ if (Value == 1)
+ {
+ pAd->CommonCfg.HT_DisallowTKIP = TRUE;
+ }
+ else
+ {
+ pAd->CommonCfg.HT_DisallowTKIP = FALSE;
+ }
+
+ DBGPRINT(RT_DEBUG_TRACE, ("HT: Disallow TKIP mode = %s\n", (pAd->CommonCfg.HT_DisallowTKIP == TRUE) ? "ON" : "OFF" ));
+ }
+
+
+ //2008/11/05:KH add to support Antenna power-saving of AP-->
+}
+#endif // DOT11_N_SUPPORT //
+
+
+NDIS_STATUS RTMPSetProfileParameters(
+ IN RTMP_ADAPTER *pAd,
+ IN PSTRING pBuffer)
+{
+ PSTRING tmpbuf;
+ ULONG RtsThresh;
+ ULONG FragThresh;
+ PSTRING macptr;
+ INT i = 0, retval;
+ tmpbuf = kmalloc(MAX_PARAM_BUFFER_SIZE, MEM_ALLOC_FLAG);
+ if(tmpbuf == NULL)
+ return NDIS_STATUS_FAILURE;
+
+ do
+ {
+ // set file parameter to portcfg
+ //CountryRegion
+ if(RTMPGetKeyParameter("CountryRegion", tmpbuf, 25, pBuffer, TRUE))
+ {
+ retval = RT_CfgSetCountryRegion(pAd, tmpbuf, BAND_24G);
+ DBGPRINT(RT_DEBUG_TRACE, ("CountryRegion=%d\n", pAd->CommonCfg.CountryRegion));
+ }
+ //CountryRegionABand
+ if(RTMPGetKeyParameter("CountryRegionABand", tmpbuf, 25, pBuffer, TRUE))
+ {
+ retval = RT_CfgSetCountryRegion(pAd, tmpbuf, BAND_5G);
+ DBGPRINT(RT_DEBUG_TRACE, ("CountryRegionABand=%d\n", pAd->CommonCfg.CountryRegionForABand));
+ }
+#ifdef RTMP_EFUSE_SUPPORT
+#ifdef RT30xx
+ //EfuseBufferMode
+ if(RTMPGetKeyParameter("EfuseBufferMode", tmpbuf, 25, pBuffer, TRUE))
+ {
+ pAd->bEEPROMFile = (UCHAR) simple_strtol(tmpbuf, 0, 10);
+ DBGPRINT(RT_DEBUG_TRACE, ("EfuseBufferMode=%d\n", pAd->bUseEfuse));
+ }
+#endif // RT30xx //
+#endif // RTMP_EFUSE_SUPPORT //
+ //CountryCode
+ if(RTMPGetKeyParameter("CountryCode", tmpbuf, 25, pBuffer, TRUE))
+ {
+ 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((PSTRING) pAd->CommonCfg.CountryCode) != 0)
+ {
+ pAd->CommonCfg.bCountryFlag = TRUE;
+ }
+ DBGPRINT(RT_DEBUG_TRACE, ("CountryCode=%s\n", pAd->CommonCfg.CountryCode));
+ }
+ //ChannelGeography
+ if(RTMPGetKeyParameter("ChannelGeography", tmpbuf, 25, pBuffer, TRUE))
+ {
+ 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 (RTMPGetKeyParameter("SSID", tmpbuf, 256, pBuffer, FALSE))
+ {
+ 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, pBuffer, TRUE))
+ {
+ 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));
+ }
+ }
+#ifdef RTMP_MAC_PCI
+ //NewPCIePS
+ if(RTMPGetKeyParameter("NewPCIePS", tmpbuf, 10, pBuffer, TRUE))
+ {
+ UCHAR temp_buffer = (UCHAR) simple_strtol(tmpbuf, 0, 10);
+ if(temp_buffer>0)
+ pAd->StaCfg.PSControl.field.EnableNewPS=TRUE;
+ else
+ pAd->StaCfg.PSControl.field.EnableNewPS=FALSE;
+ DBGPRINT(RT_DEBUG_TRACE, ("NewPCIePS=%d\n", pAd->StaCfg.PSControl.field.EnableNewPS));
+ }
+#endif // RTMP_MAC_PCI //
+#ifdef RT3090
+ //PCIePowerLevel
+
+ if(RTMPGetKeyParameter("PCIePowerLevel", tmpbuf, 10, pBuffer, TRUE))
+ {
+ pAd->StaCfg.PSControl.field.rt30xxPowerMode = (UCHAR) simple_strtol(tmpbuf, 0, 10);
+ DBGPRINT(RT_DEBUG_TRACE, ("PCIePowerLevel=%d\n", pAd->StaCfg.PSControl.field.rt30xxPowerMode));
+ }
+ //FollowHostASPM
+ if(RTMPGetKeyParameter("FollowHostASPM", tmpbuf, 10, pBuffer, TRUE))
+ {
+ UCHAR temp_buffer = (UCHAR) simple_strtol(tmpbuf, 0, 10);
+
+ if(temp_buffer>0)
+ pAd->StaCfg.PSControl.field.rt30xxFollowHostASPM=TRUE;
+ else
+ pAd->StaCfg.PSControl.field.rt30xxFollowHostASPM=FALSE;
+ DBGPRINT(RT_DEBUG_TRACE, ("rt30xxFollowHostASPM=%d\n", pAd->StaCfg.PSControl.field.rt30xxFollowHostASPM));
+ }
+ //ForceTestASPM
+ if(RTMPGetKeyParameter("ForceTestASPM", tmpbuf, 10, pBuffer, TRUE))
+ {
+ UCHAR temp_buffer = (UCHAR) simple_strtol(tmpbuf, 0, 10);
+
+ if(temp_buffer>0)
+ pAd->StaCfg.PSControl.field.rt30xxForceASPMTest=TRUE;
+ else
+ pAd->StaCfg.PSControl.field.rt30xxForceASPMTest=FALSE;
+ DBGPRINT(RT_DEBUG_TRACE, ("rt30xxForceASPM=%d\n", pAd->StaCfg.PSControl.field.rt30xxForceASPMTest));
+ }
+#endif // RT3090 //
+#endif // CONFIG_STA_SUPPORT //
+ //Channel
+ if(RTMPGetKeyParameter("Channel", tmpbuf, 10, pBuffer, TRUE))
+ {
+ 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, pBuffer, TRUE))
+ {
+ RT_CfgSetWirelessMode(pAd, tmpbuf);
+ DBGPRINT(RT_DEBUG_TRACE, ("PhyMode=%d\n", pAd->CommonCfg.PhyMode));
+ }
+ //BasicRate
+ if(RTMPGetKeyParameter("BasicRate", tmpbuf, 10, pBuffer, TRUE))
+ {
+ 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, pBuffer, TRUE))
+ {
+ 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, pBuffer, TRUE))
+ {
+ 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, pBuffer, TRUE))
+ {
+ //#if 0 //#ifndef WIFI_TEST
+ // pAd->CommonCfg.UseBGProtection = 2;// disable b/g protection for throughput test
+ //#else
+ 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;
+ }
+ //#endif
+ DBGPRINT(RT_DEBUG_TRACE, ("BGProtection=%ld\n", pAd->CommonCfg.UseBGProtection));
+ }
+ //OLBCDetection
+ if(RTMPGetKeyParameter("DisableOLBC", tmpbuf, 10, pBuffer, TRUE))
+ {
+ 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, pBuffer, TRUE))
+ {
+ 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, pBuffer, TRUE))
+ {
+ 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, pBuffer, TRUE))
+ {
+ 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, pBuffer, TRUE))
+ {
+ //#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, pBuffer, TRUE))
+ {
+ 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, pBuffer);
+#endif // CONFIG_STA_SUPPORT //
+
+ //ShortSlot
+ if(RTMPGetKeyParameter("ShortSlot", tmpbuf, 10, pBuffer, TRUE))
+ {
+ RT_CfgSetShortSlot(pAd, tmpbuf);
+ DBGPRINT(RT_DEBUG_TRACE, ("ShortSlot=%d\n", pAd->CommonCfg.bUseShortSlotTime));
+ }
+ //IEEE80211H
+ if(RTMPGetKeyParameter("IEEE80211H", tmpbuf, 10, pBuffer, TRUE))
+ {
+ 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, pBuffer, TRUE))
+ {
+ 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));
+ }
+
+#ifdef MERGE_ARCH_TEAM
+ // DfsLowerLimit
+ if(RTMPGetKeyParameter("DfsLowerLimit", tmpbuf, 10, pBuffer, TRUE))
+ {
+ if(simple_strtol(tmpbuf, 0, 10) != 0)
+ pAd->CommonCfg.RadarDetect.DfsLowerLimit = simple_strtol(tmpbuf, 0, 10);
+
+ DBGPRINT(RT_DEBUG_TRACE, ("DfsLowerLimit=%ld\n", pAd->CommonCfg.RadarDetect.DfsLowerLimit));
+ }
+
+ // DfsUpperLimit
+ if(RTMPGetKeyParameter("DfsUpperLimit", tmpbuf, 10, pBuffer, TRUE))
+ {
+ if(simple_strtol(tmpbuf, 0, 10) != 0)
+ pAd->CommonCfg.RadarDetect.DfsUpperLimit = simple_strtol(tmpbuf, 0, 10);
+
+ DBGPRINT(RT_DEBUG_TRACE, ("DfsUpperLimit=%ld\n", pAd->CommonCfg.RadarDetect.DfsUpperLimit));
+ }
+
+ // FixDfsLimit
+ if(RTMPGetKeyParameter("FixDfsLimit", tmpbuf, 10, pBuffer, TRUE))
+ {
+ if(simple_strtol(tmpbuf, 0, 10) != 0)
+ pAd->CommonCfg.RadarDetect.FixDfsLimit = TRUE;
+ else
+ pAd->CommonCfg.RadarDetect.FixDfsLimit = FALSE;
+
+ DBGPRINT(RT_DEBUG_TRACE, ("FixDfsLimit=%d\n", pAd->CommonCfg.RadarDetect.FixDfsLimit));
+ }
+
+ // LongPulseRadarTh
+ if(RTMPGetKeyParameter("LongPulseRadarTh", tmpbuf, 10, pBuffer, TRUE))
+ {
+ if(simple_strtol(tmpbuf, 0, 10) != 0)
+ pAd->CommonCfg.RadarDetect.LongPulseRadarTh = simple_strtol(tmpbuf, 0, 10);
+
+ DBGPRINT(RT_DEBUG_TRACE, ("LongPulseRadarTh=%d\n", pAd->CommonCfg.RadarDetect.LongPulseRadarTh));
+ }
+
+ // AvgRssiReq
+ if(RTMPGetKeyParameter("AvgRssiReq", tmpbuf, 10, pBuffer, TRUE))
+ {
+ if(simple_strtol(tmpbuf, 0, 10) != 0)
+ pAd->CommonCfg.RadarDetect.AvgRssiReq = simple_strtol(tmpbuf, 0, 10);
+
+ DBGPRINT(RT_DEBUG_TRACE, ("AvgRssiReq=%d\n", pAd->CommonCfg.RadarDetect.AvgRssiReq));
+ }
+
+#endif // MERGE_ARCH_TEAM //
+
+ //RDRegion
+ if(RTMPGetKeyParameter("RDRegion", tmpbuf, 128, pBuffer, TRUE))
+ {
+ RADAR_DETECT_STRUCT *pRadarDetect = &pAd->CommonCfg.RadarDetect;
+ if ((strncmp(tmpbuf, "JAP_W53", 7) == 0) || (strncmp(tmpbuf, "jap_w53", 7) == 0))
+ {
+ pRadarDetect->RDDurRegion = JAP_W53;
+ pRadarDetect->DfsSessionTime = 15;
+ }
+ else if ((strncmp(tmpbuf, "JAP_W56", 7) == 0) || (strncmp(tmpbuf, "jap_w56", 7) == 0))
+ {
+ pRadarDetect->RDDurRegion = JAP_W56;
+ pRadarDetect->DfsSessionTime = 13;
+ }
+ else if ((strncmp(tmpbuf, "JAP", 3) == 0) || (strncmp(tmpbuf, "jap", 3) == 0))
+ {
+ pRadarDetect->RDDurRegion = JAP;
+ pRadarDetect->DfsSessionTime = 5;
+ }
+ else if ((strncmp(tmpbuf, "FCC", 3) == 0) || (strncmp(tmpbuf, "fcc", 3) == 0))
+ {
+ pRadarDetect->RDDurRegion = FCC;
+ pRadarDetect->DfsSessionTime = 5;
+#ifdef DFS_FCC_BW40_FIX
+ pRadarDetect->DfsSessionFccOff = 0;
+#endif // DFS_FCC_BW40_FIX //
+ }
+ else if ((strncmp(tmpbuf, "CE", 2) == 0) || (strncmp(tmpbuf, "ce", 2) == 0))
+ {
+ pRadarDetect->RDDurRegion = CE;
+ pRadarDetect->DfsSessionTime = 13;
+ }
+ else
+ {
+ pRadarDetect->RDDurRegion = CE;
+ pRadarDetect->DfsSessionTime = 13;
+ }
+
+ DBGPRINT(RT_DEBUG_TRACE, ("RDRegion=%d\n", pRadarDetect->RDDurRegion));
+ }
+ else
+ {
+ pAd->CommonCfg.RadarDetect.RDDurRegion = CE;
+ pAd->CommonCfg.RadarDetect.DfsSessionTime = 13;
+ }
+
+ //WirelessEvent
+ if(RTMPGetKeyParameter("WirelessEvent", tmpbuf, 10, pBuffer, TRUE))
+ {
+#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, pBuffer, TRUE))
+ {
+ 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, pBuffer, TRUE))
+ {
+#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, pBuffer, TRUE))
+ {
+
+#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(RTMPGetKeyParameter("WPAPSK", tmpbuf, 512, pBuffer, FALSE))
+ {
+ int ret = TRUE;
+
+ 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)
+ )
+ {
+ ret = FALSE;
+ }
+ else
+ {
+ ret = RT_CfgSetWPAPSKKey(pAd, tmpbuf, (PUCHAR)pAd->CommonCfg.Ssid, pAd->CommonCfg.SsidLen, pAd->StaCfg.PMK);
+ }
+
+ if (ret == TRUE)
+ {
+ RTMPZeroMemory(pAd->StaCfg.WpaPassPhrase, 64);
+ RTMPMoveMemory(pAd->StaCfg.WpaPassPhrase, tmpbuf, strlen(tmpbuf));
+ pAd->StaCfg.WpaPassPhraseLen= strlen(tmpbuf);
+
+ 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)
+ {
+ 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, pBuffer);
+
+
+ //HSCounter
+ /*if(RTMPGetKeyParameter("HSCounter", tmpbuf, 10, pBuffer, TRUE))
+ {
+ 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, pBuffer);
+#endif // DOT11_N_SUPPORT //
+
+
+#ifdef CARRIER_DETECTION_SUPPORT
+ //CarrierDetect
+ if(RTMPGetKeyParameter("CarrierDetect", tmpbuf, 128, pBuffer, TRUE))
+ {
+ 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, pBuffer, TRUE))
+ {
+ 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
+ RTMP_SET_PSM_BIT(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));
+ }
+ }
+ // AutoRoaming by RSSI
+ if (RTMPGetKeyParameter("AutoRoaming", tmpbuf, 32, pBuffer, TRUE))
+ {
+ if (simple_strtol(tmpbuf, 0, 10) == 0)
+ pAd->StaCfg.bAutoRoaming = FALSE;
+ else
+ pAd->StaCfg.bAutoRoaming = TRUE;
+
+ DBGPRINT(RT_DEBUG_TRACE, ("AutoRoaming=%d\n", pAd->StaCfg.bAutoRoaming));
+ }
+ // RoamThreshold
+ if (RTMPGetKeyParameter("RoamThreshold", tmpbuf, 32, pBuffer, TRUE))
+ {
+ 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, pBuffer, TRUE))
+ {
+ 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));
+ }
+
+ // Beacon Lost Time
+ if (RTMPGetKeyParameter("BeaconLostTime", tmpbuf, 32, pBuffer, TRUE))
+ {
+ ULONG lInfo = (ULONG)simple_strtol(tmpbuf, 0, 10);
+
+ if ((lInfo != 0) && (lInfo <= 60))
+ pAd->StaCfg.BeaconLostTime = (lInfo * OS_HZ);
+ DBGPRINT(RT_DEBUG_TRACE, ("BeaconLostTime=%ld \n", pAd->StaCfg.BeaconLostTime));
+ }
+
+
+ }
+#endif // CONFIG_STA_SUPPORT //
+
+
+
+#ifdef RT30xx
+#ifdef ANT_DIVERSITY_SUPPORT
+ IF_DEV_CONFIG_OPMODE_ON_STA(pAd)
+ {
+ if(RTMPGetKeyParameter("AntDiversity", tmpbuf, 10, pBuffer, TRUE))
+ {
+ for (i = 0, macptr = rstrtok(tmpbuf,";"); macptr; macptr = rstrtok(NULL,";"), i++)
+ {
+ UCHAR Ant = simple_strtol(tmpbuf, 0, 10);
+ if(Ant < 3)
+ pAd->CommonCfg.bRxAntDiversity = Ant;
+ else
+ pAd->CommonCfg.bRxAntDiversity = ANT_DIVERSITY_DISABLE;
+
+ DBGPRINT(RT_DEBUG_ERROR, ("AntDiversity=%d\n", pAd->CommonCfg.bRxAntDiversity));
+ }
+ }
+ }
+#endif // ANT_DIVERSITY_SUPPORT //
+#endif // RT30xx //
+
+ }while(0);
+
+
+ kfree(tmpbuf);
+
+ return NDIS_STATUS_SUCCESS;
+
+}
+
+
+#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];
+
+/*
+========================================================================
+Routine Description:
+ Get card profile path.
+
+Arguments:
+ pAd
+
+Return Value:
+ TRUE - Find a card profile
+ FALSE - use default profile
+
+Note:
+========================================================================
+*/
+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'); \
+ } }
+
+ RTMP_OS_FD srcf;
+ INT retval;
+ PSTRING buffer, tmpbuf;
+ STRING 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;
+ RTMP_OS_FS_INFO osFSInfo;
+
+ // 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;
+ }
+
+ // 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);
+
+ DBGPRINT(RT_DEBUG_TRACE, ("mac addr=%02x:%02x:%02x:%02x:%02x:%02x!\n", PRINT_MAC(mac)));
+
+ RtmpOSFSInfoChange(&osFSInfo, TRUE);
+ // open card information file
+ srcf = RtmpOSFileOpen(CARD_INFO_PATH, O_RDONLY, 0);
+ if (IS_FILE_OPEN_ERR(srcf))
+ {
+ /* card information file does not exist */
+ DBGPRINT(RT_DEBUG_TRACE,
+ ("--> Error opening %s\n", CARD_INFO_PATH));
+ goto free_resource;
+ }
+
+ /* card information file exists so reading the card information */
+ memset(buffer, 0x00, MAX_INI_BUFFER_SIZE);
+ retval = RtmpOSFileRead(srcf, buffer, MAX_INI_BUFFER_SIZE);
+ 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, TRUE))
+ {
+ 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 = (PUCHAR)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 = (PUCHAR)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 = (PUCHAR)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, TRUE))
+ {
+ 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 = RtmpOSFileClose(srcf);
+
+free_resource:
+ RtmpOSFSInfoChange(&osFSInfo, FALSE);
+ kfree(buffer);
+ kfree(tmpbuf);
+
+ return flg_match_ok;
+}
+#endif // MULTIPLE_CARD_SUPPORT //
diff --git a/drivers/staging/rt3090/common/cmm_sanity.c b/drivers/staging/rt3090/common/cmm_sanity.c
new file mode 100644
index 000000000000..de631c38a44e
--- /dev/null
+++ b/drivers/staging/rt3090/common/cmm_sanity.c
@@ -0,0 +1,1718 @@
+/*
+ *************************************************************************
+ * 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.
+#ifdef UNALIGNMENT_SUPPORT
+ {
+ BA_PARM tmpBaParm;
+
+ NdisMoveMemory((PUCHAR)(&tmpBaParm), (PUCHAR)(&pAddFrame->BaParm), sizeof(BA_PARM));
+ *(USHORT *)(&tmpBaParm) = cpu2le16(*(USHORT *)(&tmpBaParm));
+ NdisMoveMemory((PUCHAR)(&pAddFrame->BaParm), (PUCHAR)(&tmpBaParm), sizeof(BA_PARM));
+ }
+#else
+ *(USHORT *)(&pAddFrame->BaParm) = cpu2le16(*(USHORT *)(&pAddFrame->BaParm));
+#endif
+ 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.
+#ifdef UNALIGNMENT_SUPPORT
+ {
+ BA_PARM tmpBaParm;
+
+ NdisMoveMemory((PUCHAR)(&tmpBaParm), (PUCHAR)(&pAddFrame->BaParm), sizeof(BA_PARM));
+ *(USHORT *)(&tmpBaParm) = cpu2le16(*(USHORT *)(&tmpBaParm));
+ NdisMoveMemory((PUCHAR)(&pAddFrame->BaParm), (PUCHAR)(&tmpBaParm), sizeof(BA_PARM));
+ }
+#else
+ *(USHORT *)(&pAddFrame->BaParm) = cpu2le16(*(USHORT *)(&pAddFrame->BaParm));
+#endif
+ 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)
+{
+ UCHAR *Ptr;
+#ifdef CONFIG_STA_SUPPORT
+ UCHAR 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));
+#ifdef UNALIGNMENT_SUPPORT
+ {
+ EXT_HT_CAP_INFO extHtCapInfo;
+ NdisMoveMemory((PUCHAR)(&extHtCapInfo), (PUCHAR)(&pHtCapability->ExtHtCapInfo), sizeof(EXT_HT_CAP_INFO));
+ *(USHORT *)(&extHtCapInfo) = cpu2le16(*(USHORT *)(&extHtCapInfo));
+ NdisMoveMemory((PUCHAR)(&pHtCapability->ExtHtCapInfo), (PUCHAR)(&extHtCapInfo), sizeof(EXT_HT_CAP_INFO));
+ }
+#else
+ *(USHORT *)(&pHtCapability->ExtHtCapInfo) = cpu2le16(*(USHORT *)(&pHtCapability->ExtHtCapInfo));
+#endif // UNALIGNMENT_SUPPORT //
+
+#ifdef CONFIG_STA_SUPPORT
+ IF_DEV_CONFIG_OPMODE_ON_STA(pAd)
+ {
+ *pPreNHtCapabilityLen = 0; // Now 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((PCHAR)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 //
+
+
+ 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_LOUD, ("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 = (PCHAR) 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
+#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 == AUTH_MODE_OPEN)
+ {
+ if (*pSeq == 1 || *pSeq == 2)
+ {
+ return TRUE;
+ }
+ else
+ {
+ DBGPRINT(RT_DEBUG_TRACE, ("PeerAuthSanity fail - wrong Seg#\n"));
+ return FALSE;
+ }
+ }
+ else if (*pAlg == AUTH_MODE_KEY)
+ {
+ 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 == AUTH_MODE_KEY) ||(*pAlg == AUTH_MODE_OPEN)
+ ) &&
+ ((*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:
+ Check the validity of the received EAPoL frame
+ 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 (EapolKeyInfo.KeyDescVer == DESC_TYPE_TKIP) // TKIP
+ {
+ HMAC_MD5(pEntry->PTK, LEN_EAP_MICK, (PUCHAR)pMsg, MsgLen, mic, MD5_DIGEST_SIZE);
+ }
+ else if (EapolKeyInfo.KeyDescVer == DESC_TYPE_AES) // AES
+ {
+ HMAC_SHA1(pEntry->PTK, LEN_EAP_MICK, (PUCHAR)pMsg, MsgLen, digest, SHA1_DIGEST_SIZE);
+ 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;
+ }
+ }
+
+ // 1. Decrypt the Key Data field if GTK is included.
+ // 2. Extract the context of the Key Data field if it exist.
+ // The field in pairwise_msg_2_WPA1(WPA2) & pairwise_msg_3_WPA1 is clear.
+ // The field in group_msg_1_WPA1(WPA2) & pairwise_msg_3_WPA2 is encrypted.
+ if (CONV_ARRARY_TO_UINT16(pMsg->KeyDesc.KeyDataLen) > 0)
+ {
+ // Decrypt this field
+ if ((MsgType == EAPOL_PAIR_MSG_3 && bWPA2) || (MsgType == EAPOL_GROUP_MSG_1))
+ {
+ if(
+ (EapolKeyInfo.KeyDescVer == DESC_TYPE_AES))
+ {
+ // AES
+ AES_GTK_KEY_UNWRAP(&pEntry->PTK[16], KEYDATA,
+ CONV_ARRARY_TO_UINT16(pMsg->KeyDesc.KeyDataLen),
+ 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,
+ CONV_ARRARY_TO_UINT16(pMsg->KeyDesc.KeyDataLen));
+ }
+
+ 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, CONV_ARRARY_TO_UINT16(pMsg->KeyDesc.KeyDataLen));
+ }
+ 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,
+ CONV_ARRARY_TO_UINT16(pMsg->KeyDesc.KeyDataLen),
+ 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 = (PCHAR)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));
+#ifdef UNALIGNMENT_SUPPORT
+ {
+ EXT_HT_CAP_INFO extHtCapInfo;
+
+ NdisMoveMemory((PUCHAR)(&extHtCapInfo), (PUCHAR)(&pHtCapability->ExtHtCapInfo), sizeof(EXT_HT_CAP_INFO));
+ *(USHORT *)(&extHtCapInfo) = cpu2le16(*(USHORT *)(&extHtCapInfo));
+ NdisMoveMemory((PUCHAR)(&pHtCapability->ExtHtCapInfo), (PUCHAR)(&extHtCapInfo), sizeof(EXT_HT_CAP_INFO));
+ }
+#else
+ *(USHORT *)(&pHtCapability->ExtHtCapInfo) = cpu2le16(*(USHORT *)(&pHtCapability->ExtHtCapInfo));
+#endif // UNALIGNMENT_SUPPORT //
+ *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 = (PCHAR)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));
+#ifdef UNALIGNMENT_SUPPORT
+ {
+ EXT_HT_CAP_INFO extHtCapInfo;
+
+ NdisMoveMemory((PUCHAR)(&extHtCapInfo), (PUCHAR)(&pHtCapability->ExtHtCapInfo), sizeof(EXT_HT_CAP_INFO));
+ *(USHORT *)(&extHtCapInfo) = cpu2le16(*(USHORT *)(&extHtCapInfo));
+ NdisMoveMemory((PUCHAR)(&pHtCapability->ExtHtCapInfo), (PUCHAR)(&extHtCapInfo), sizeof(EXT_HT_CAP_INFO));
+ }
+#else
+ *(USHORT *)(&pHtCapability->ExtHtCapInfo) = cpu2le16(*(USHORT *)(&pHtCapability->ExtHtCapInfo));
+#endif // UNALIGNMENT_SUPPORT //
+ *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 = (PCHAR)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/rt3090/common/cmm_sync.c b/drivers/staging/rt3090/common/cmm_sync.c
new file mode 100644
index 000000000000..6d7b974d7e15
--- /dev/null
+++ b/drivers/staging/rt3090/common/cmm_sync.c
@@ -0,0 +1,734 @@
+/*
+ *************************************************************************
+ * 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:
+ cmm_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, 169, 173};
+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};
+UCHAR A_BAND_REGION_12_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_13_CHANNEL_LIST[]={52, 56, 60, 64, 100, 104, 108, 112, 116, 120, 124, 128, 132, 136, 140, 149, 153, 157, 161};
+UCHAR A_BAND_REGION_14_CHANNEL_LIST[]={36, 40, 44, 48, 52, 56, 60, 64, 100, 104, 108, 112, 116, 136, 140, 149, 153, 157, 161, 165};
+UCHAR A_BAND_REGION_15_CHANNEL_LIST[]={149, 153, 157, 161, 165, 169, 173};
+
+
+//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;
+ case REGION_12_A_BAND:
+ num = sizeof(A_BAND_REGION_12_CHANNEL_LIST)/sizeof(UCHAR);
+ pChannelList = A_BAND_REGION_12_CHANNEL_LIST;
+ break;
+ case REGION_13_A_BAND:
+ num = sizeof(A_BAND_REGION_13_CHANNEL_LIST)/sizeof(UCHAR);
+ pChannelList = A_BAND_REGION_13_CHANNEL_LIST;
+ break;
+ case REGION_14_A_BAND:
+ num = sizeof(A_BAND_REGION_14_CHANNEL_LIST)/sizeof(UCHAR);
+ pChannelList = A_BAND_REGION_14_CHANNEL_LIST;
+ break;
+ case REGION_15_A_BAND:
+ num = sizeof(A_BAND_REGION_15_CHANNEL_LIST)/sizeof(UCHAR);
+ pChannelList = A_BAND_REGION_15_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);
+ }
+ 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)
+ RTMP_SET_PSM_BIT(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);
+ 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)
+ )
+ {
+ 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;
+
+#ifdef CONFIG_STA_SUPPORT
+ IF_DEV_CONFIG_OPMODE_ON_STA(pAd)
+ MgtMacHeaderInit(pAd, &Hdr80211, SUBTYPE_PROBE_REQ, 0, BROADCAST_ADDR, BROADCAST_ADDR);
+#endif // CONFIG_STA_SUPPORT //
+
+
+ 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));
+#ifdef UNALIGNMENT_SUPPORT
+ {
+ EXT_HT_CAP_INFO extHtCapInfo;
+
+ NdisMoveMemory((PUCHAR)(&extHtCapInfo), (PUCHAR)(&HtCapabilityTmp.ExtHtCapInfo), sizeof(EXT_HT_CAP_INFO));
+ *(USHORT *)(&extHtCapInfo) = cpu2le16(*(USHORT *)(&extHtCapInfo));
+ NdisMoveMemory((PUCHAR)(&HtCapabilityTmp.ExtHtCapInfo), (PUCHAR)(&extHtCapInfo), sizeof(EXT_HT_CAP_INFO));
+ }
+#else
+ *(USHORT *)(&HtCapabilityTmp.ExtHtCapInfo) = cpu2le16(*(USHORT *)(&HtCapabilityTmp.ExtHtCapInfo));
+#endif // UNALIGNMENT_SUPPORT //
+
+ 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));
+#ifdef UNALIGNMENT_SUPPORT
+ {
+ EXT_HT_CAP_INFO extHtCapInfo;
+
+ NdisMoveMemory((PUCHAR)(&extHtCapInfo), (PUCHAR)(&HtCapabilityTmp.ExtHtCapInfo), sizeof(EXT_HT_CAP_INFO));
+ *(USHORT *)(&extHtCapInfo) = cpu2le16(*(USHORT *)(&extHtCapInfo));
+ NdisMoveMemory((PUCHAR)(&HtCapabilityTmp.ExtHtCapInfo), (PUCHAR)(&extHtCapInfo), sizeof(EXT_HT_CAP_INFO));
+ }
+#else
+ *(USHORT *)(&HtCapabilityTmp.ExtHtCapInfo) = cpu2le16(*(USHORT *)(&HtCapabilityTmp.ExtHtCapInfo));
+#endif // UNALIGNMENT_SUPPORT //
+
+ 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);
+}
diff --git a/drivers/staging/rt3090/common/cmm_tkip.c b/drivers/staging/rt3090/common/cmm_tkip.c
new file mode 100644
index 000000000000..0b474f20859b
--- /dev/null
+++ b/drivers/staging/rt3090/common/cmm_tkip.c
@@ -0,0 +1,966 @@
+/*
+ *************************************************************************
+ * 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:
+ cmm_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
+};
+
+//
+// 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;
+}
+
+
+//
+// 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;
+}
diff --git a/drivers/staging/rt3090/common/cmm_wep.c b/drivers/staging/rt3090/common/cmm_wep.c
new file mode 100644
index 000000000000..d8ddfb245578
--- /dev/null
+++ b/drivers/staging/rt3090/common/cmm_wep.c
@@ -0,0 +1,500 @@
+/*
+ *************************************************************************
+ * 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.
+
+ {
+ 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);
+}
diff --git a/drivers/staging/rt3090/common/cmm_wpa.c b/drivers/staging/rt3090/common/cmm_wpa.c
new file mode 100644
index 000000000000..35f4701c0242
--- /dev/null
+++ b/drivers/staging/rt3090/common/cmm_wpa.c
@@ -0,0 +1,3149 @@
+/*
+ *************************************************************************
+ * 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};
+
+
+
+static VOID ConstructEapolKeyData(
+ IN PMAC_TABLE_ENTRY pEntry,
+ IN UCHAR GroupKeyWepStatus,
+ IN UCHAR keyDescVer,
+ IN UCHAR MsgType,
+ IN UCHAR DefaultKeyIdx,
+ IN UCHAR *GTK,
+ IN UCHAR *RSNIE,
+ IN UCHAR RSNIE_LEN,
+ OUT PEAPOL_PACKET pMsg);
+
+static VOID CalculateMIC(
+ IN UCHAR KeyDescVer,
+ IN UCHAR *PTK,
+ OUT PEAPOL_PACKET pMsg);
+
+static VOID WpaEAPPacketAction(
+ IN PRTMP_ADAPTER pAd,
+ IN MLME_QUEUE_ELEM *Elem);
+
+static VOID WpaEAPOLASFAlertAction(
+ IN PRTMP_ADAPTER pAd,
+ IN MLME_QUEUE_ELEM *Elem);
+
+static VOID WpaEAPOLLogoffAction(
+ IN PRTMP_ADAPTER pAd,
+ IN MLME_QUEUE_ELEM *Elem);
+
+static VOID WpaEAPOLStartAction(
+ IN PRTMP_ADAPTER pAd,
+ IN MLME_QUEUE_ELEM *Elem);
+
+static VOID WpaEAPOLKeyAction(
+ 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
+ ==========================================================================
+ */
+VOID WpaStateMachineInit(
+ IN PRTMP_ADAPTER pAd,
+ IN STATE_MACHINE *S,
+ OUT STATE_MACHINE_FUNC Trans[])
+{
+ StateMachineInit(S, (STATE_MACHINE_FUNC *)Trans, MAX_WPA_PTK_STATE, MAX_WPA_MSG, (STATE_MACHINE_FUNC)Drop, WPA_PTK, WPA_MACHINE_BASE);
+
+ StateMachineSetAction(S, WPA_PTK, MT2_EAPPacket, (STATE_MACHINE_FUNC)WpaEAPPacketAction);
+ StateMachineSetAction(S, WPA_PTK, MT2_EAPOLStart, (STATE_MACHINE_FUNC)WpaEAPOLStartAction);
+ StateMachineSetAction(S, WPA_PTK, MT2_EAPOLLogoff, (STATE_MACHINE_FUNC)WpaEAPOLLogoffAction);
+ StateMachineSetAction(S, WPA_PTK, MT2_EAPOLKey, (STATE_MACHINE_FUNC)WpaEAPOLKeyAction);
+ StateMachineSetAction(S, WPA_PTK, MT2_EAPOLASFAlert, (STATE_MACHINE_FUNC)WpaEAPOLASFAlertAction);
+}
+
+/*
+ ==========================================================================
+ Description:
+ this is state machine function.
+ When receiving EAP packets which is for 802.1x authentication use.
+ Not use in PSK case
+ Return:
+ ==========================================================================
+*/
+VOID WpaEAPPacketAction(
+ IN PRTMP_ADAPTER pAd,
+ IN MLME_QUEUE_ELEM *Elem)
+{
+}
+
+VOID WpaEAPOLASFAlertAction(
+ IN PRTMP_ADAPTER pAd,
+ IN MLME_QUEUE_ELEM *Elem)
+{
+}
+
+VOID WpaEAPOLLogoffAction(
+ IN PRTMP_ADAPTER pAd,
+ IN MLME_QUEUE_ELEM *Elem)
+{
+}
+
+/*
+ ==========================================================================
+ Description:
+ Start 4-way HS when rcv EAPOL_START which may create by our driver in assoc.c
+ Return:
+ ==========================================================================
+*/
+VOID WpaEAPOLStartAction(
+ IN PRTMP_ADAPTER pAd,
+ IN MLME_QUEUE_ELEM *Elem)
+{
+ MAC_TABLE_ENTRY *pEntry;
+ PHEADER_802_11 pHeader;
+
+ DBGPRINT(RT_DEBUG_TRACE, ("WpaEAPOLStartAction ===> \n"));
+
+ pHeader = (PHEADER_802_11)Elem->Msg;
+
+ //For normaol PSK, we enqueue an EAPOL-Start command to trigger the process.
+ if (Elem->MsgLen == 6)
+ pEntry = MacTableLookup(pAd, Elem->Msg);
+ else
+ {
+ pEntry = MacTableLookup(pAd, pHeader->Addr2);
+ }
+
+ if (pEntry)
+ {
+ DBGPRINT(RT_DEBUG_TRACE, (" PortSecured(%d), WpaState(%d), AuthMode(%d), PMKID_CacheIdx(%d) \n", pEntry->PortSecured, pEntry->WpaState, pEntry->AuthMode, pEntry->PMKID_CacheIdx));
+
+ if ((pEntry->PortSecured == WPA_802_1X_PORT_NOT_SECURED)
+ && (pEntry->WpaState < AS_PTKSTART)
+ && ((pEntry->AuthMode == Ndis802_11AuthModeWPAPSK) || (pEntry->AuthMode == Ndis802_11AuthModeWPA2PSK) || ((pEntry->AuthMode == Ndis802_11AuthModeWPA2) && (pEntry->PMKID_CacheIdx != ENTRY_NOT_FOUND))))
+ {
+ pEntry->PrivacyFilter = Ndis802_11PrivFilter8021xWEP;
+ pEntry->WpaState = AS_INITPSK;
+ pEntry->PortSecured = WPA_802_1X_PORT_NOT_SECURED;
+ NdisZeroMemory(pEntry->R_Counter, sizeof(pEntry->R_Counter));
+ pEntry->ReTryCounter = PEER_MSG1_RETRY_TIMER_CTR;
+
+ WPAStart4WayHS(pAd, pEntry, PEER_MSG1_RETRY_EXEC_INTV);
+ }
+ }
+}
+
+/*
+ ==========================================================================
+ 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)
+{
+ MAC_TABLE_ENTRY *pEntry;
+ PHEADER_802_11 pHeader;
+ PEAPOL_PACKET pEapol_packet;
+ KEY_INFO peerKeyInfo;
+
+ DBGPRINT(RT_DEBUG_TRACE, ("WpaEAPOLKeyAction ===>\n"));
+
+ pHeader = (PHEADER_802_11)Elem->Msg;
+ pEapol_packet = (PEAPOL_PACKET)&Elem->Msg[LENGTH_802_11 + LENGTH_802_1_H];
+
+ NdisZeroMemory((PUCHAR)&peerKeyInfo, sizeof(peerKeyInfo));
+ NdisMoveMemory((PUCHAR)&peerKeyInfo, (PUCHAR)&pEapol_packet->KeyDesc.KeyInfo, sizeof(KEY_INFO));
+
+ hex_dump("Received Eapol frame", (unsigned char *)pEapol_packet, (Elem->MsgLen - LENGTH_802_11 - LENGTH_802_1_H));
+
+ *((USHORT *)&peerKeyInfo) = cpu2le16(*((USHORT *)&peerKeyInfo));
+
+ do
+ {
+ pEntry = MacTableLookup(pAd, pHeader->Addr2);
+
+ if (!pEntry || ((!pEntry->ValidAsCLI) && (!pEntry->ValidAsApCli)))
+ break;
+
+ if (pEntry->AuthMode < Ndis802_11AuthModeWPA)
+ break;
+
+ DBGPRINT(RT_DEBUG_TRACE, ("Receive EAPoL-Key frame from STA %02X-%02X-%02X-%02X-%02X-%02X\n", PRINT_MAC(pEntry->Addr)));
+
+ if (((pEapol_packet->ProVer != EAPOL_VER) && (pEapol_packet->ProVer != EAPOL_VER2)) ||
+ ((pEapol_packet->KeyDesc.Type != WPA1_KEY_DESC) && (pEapol_packet->KeyDesc.Type != WPA2_KEY_DESC)))
+ {
+ DBGPRINT(RT_DEBUG_ERROR, ("Key descripter does not match with WPA rule\n"));
+ break;
+ }
+
+ // The value 1 shall be used for all EAPOL-Key frames to and from a STA when
+ // neither the group nor pairwise ciphers are CCMP for Key Descriptor 1.
+ if ((pEntry->WepStatus == Ndis802_11Encryption2Enabled) && (peerKeyInfo.KeyDescVer != DESC_TYPE_TKIP))
+ {
+ DBGPRINT(RT_DEBUG_ERROR, ("Key descripter version not match(TKIP) \n"));
+ break;
+ }
+ // The value 2 shall be used for all EAPOL-Key frames to and from a STA when
+ // either the pairwise or the group cipher is AES-CCMP for Key Descriptor 2.
+ else if ((pEntry->WepStatus == Ndis802_11Encryption3Enabled) && (peerKeyInfo.KeyDescVer != DESC_TYPE_AES))
+ {
+ DBGPRINT(RT_DEBUG_ERROR, ("Key descripter version not match(AES) \n"));
+ break;
+ }
+
+ // Check if this STA is in class 3 state and the WPA state is started
+ if ((pEntry->Sst == SST_ASSOC) && (pEntry->WpaState >= AS_INITPSK))
+ {
+ // Check the Key Ack (bit 7) of the Key Information to determine the Authenticator
+ // or not.
+ // An EAPOL-Key frame that is sent by the Supplicant in response to an EAPOL-
+ // Key frame from the Authenticator must not have the Ack bit set.
+ if (peerKeyInfo.KeyAck == 1)
+ {
+ // The frame is snet by Authenticator.
+ // So the Supplicant side shall handle this.
+
+ if ((peerKeyInfo.Secure == 0) && (peerKeyInfo.Request == 0) &&
+ (peerKeyInfo.Error == 0) && (peerKeyInfo.KeyType == PAIRWISEKEY))
+ {
+ // Process 1. the message 1 of 4-way HS in WPA or WPA2
+ // EAPOL-Key(0,0,1,0,P,0,0,ANonce,0,DataKD_M1)
+ // 2. the message 3 of 4-way HS in WPA
+ // EAPOL-Key(0,1,1,1,P,0,KeyRSC,ANonce,MIC,DataKD_M3)
+ if (peerKeyInfo.KeyMic == 0)
+ PeerPairMsg1Action(pAd, pEntry, Elem);
+ else
+ PeerPairMsg3Action(pAd, pEntry, Elem);
+ }
+ else if ((peerKeyInfo.Secure == 1) &&
+ (peerKeyInfo.KeyMic == 1) &&
+ (peerKeyInfo.Request == 0) &&
+ (peerKeyInfo.Error == 0))
+ {
+ // Process 1. the message 3 of 4-way HS in WPA2
+ // EAPOL-Key(1,1,1,1,P,0,KeyRSC,ANonce,MIC,DataKD_M3)
+ // 2. the message 1 of group KS in WPA or WPA2
+ // EAPOL-Key(1,1,1,0,G,0,Key RSC,0, MIC,GTK[N])
+ if (peerKeyInfo.KeyType == PAIRWISEKEY)
+ PeerPairMsg3Action(pAd, pEntry, Elem);
+ else
+ PeerGroupMsg1Action(pAd, pEntry, Elem);
+ }
+ }
+ else
+ {
+ // The frame is snet by Supplicant.
+ // So the Authenticator side shall handle this.
+ if ((peerKeyInfo.Request == 0) &&
+ (peerKeyInfo.Error == 0) &&
+ (peerKeyInfo.KeyMic == 1))
+ {
+ if (peerKeyInfo.Secure == 0 && peerKeyInfo.KeyType == PAIRWISEKEY)
+ {
+ // EAPOL-Key(0,1,0,0,P,0,0,SNonce,MIC,Data)
+ // Process 1. message 2 of 4-way HS in WPA or WPA2
+ // 2. message 4 of 4-way HS in WPA
+ if (CONV_ARRARY_TO_UINT16(pEapol_packet->KeyDesc.KeyDataLen) == 0)
+ {
+ PeerPairMsg4Action(pAd, pEntry, Elem);
+ }
+ else
+ {
+ PeerPairMsg2Action(pAd, pEntry, Elem);
+ }
+ }
+ else if (peerKeyInfo.Secure == 1 && peerKeyInfo.KeyType == PAIRWISEKEY)
+ {
+ // EAPOL-Key(1,1,0,0,P,0,0,0,MIC,0)
+ // Process message 4 of 4-way HS in WPA2
+ PeerPairMsg4Action(pAd, pEntry, Elem);
+ }
+ else if (peerKeyInfo.Secure == 1 && peerKeyInfo.KeyType == GROUPKEY)
+ {
+ // EAPOL-Key(1,1,0,0,G,0,0,0,MIC,0)
+ // Process message 2 of Group key HS in WPA or WPA2
+ PeerGroupMsg2Action(pAd, pEntry, &Elem->Msg[LENGTH_802_11], (Elem->MsgLen - LENGTH_802_11));
+ }
+ }
+ }
+ }
+ }while(FALSE);
+}
+
+/*
+ ========================================================================
+
+ 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 PMAC_TABLE_ENTRY pEntry,
+ IN PUCHAR pHeader802_3,
+ IN UINT HdrLen,
+ IN PUCHAR pData,
+ IN UINT DataLen,
+ IN BOOLEAN bClearFrame)
+{
+ PNDIS_PACKET pPacket;
+ NDIS_STATUS Status;
+
+ if ((!pEntry) || ((!pEntry->ValidAsCLI) && (!pEntry->ValidAsApCli)))
+ return;
+
+ do {
+ // build a NDIS packet
+ Status = RTMPAllocateNdisPacket(pAd, &pPacket, pHeader802_3, HdrLen, pData, DataLen);
+ if (Status != NDIS_STATUS_SUCCESS)
+ break;
+
+
+ if (bClearFrame)
+ RTMP_SET_PACKET_CLEAR_EAP_FRAME(pPacket, 1);
+ else
+ RTMP_SET_PACKET_CLEAR_EAP_FRAME(pPacket, 0);
+ {
+ RTMP_SET_PACKET_SOURCE(pPacket, PKTSRC_NDIS);
+
+ RTMP_SET_PACKET_NET_DEVICE_MBSSID(pPacket, MAIN_MBSSID); // set a default value
+ if(pEntry->apidx != 0)
+ RTMP_SET_PACKET_NET_DEVICE_MBSSID(pPacket, pEntry->apidx);
+
+ RTMP_SET_PACKET_WCID(pPacket, (UCHAR)pEntry->Aid);
+ RTMP_SET_PACKET_MOREDATA(pPacket, FALSE);
+ }
+
+#ifdef CONFIG_STA_SUPPORT
+ IF_DEV_CONFIG_OPMODE_ON_STA(pAd)
+ {
+ // send out the packet
+ Status = STASendPacket(pAd, pPacket);
+ if (Status == NDIS_STATUS_SUCCESS)
+ {
+ UCHAR Index;
+
+ // 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);
+ }
+ }
+ }
+#endif // CONFIG_STA_SUPPORT //
+
+ } while (FALSE);
+}
+
+/*
+ ==========================================================================
+ Description:
+ This is a function to initilize 4-way handshake
+
+ Return:
+
+ ==========================================================================
+*/
+VOID WPAStart4WayHS(
+ IN PRTMP_ADAPTER pAd,
+ IN MAC_TABLE_ENTRY *pEntry,
+ IN ULONG TimeInterval)
+{
+ UCHAR Header802_3[14];
+ EAPOL_PACKET EAPOLPKT;
+ PUINT8 pBssid = NULL;
+ UCHAR group_cipher = Ndis802_11WEPDisabled;
+
+ DBGPRINT(RT_DEBUG_TRACE, ("===> WPAStart4WayHS\n"));
+
+ if (RTMP_TEST_FLAG(pAd, fRTMP_ADAPTER_RESET_IN_PROGRESS | fRTMP_ADAPTER_HALT_IN_PROGRESS))
+ {
+ DBGPRINT(RT_DEBUG_ERROR, ("[ERROR]WPAStart4WayHS : The interface is closed...\n"));
+ return;
+ }
+
+
+ if (pBssid == NULL)
+ {
+ DBGPRINT(RT_DEBUG_ERROR, ("[ERROR]WPAStart4WayHS : No corresponding Authenticator.\n"));
+ return;
+ }
+
+ // Check the status
+ if ((pEntry->WpaState > AS_PTKSTART) || (pEntry->WpaState < AS_INITPMK))
+ {
+ DBGPRINT(RT_DEBUG_ERROR, ("[ERROR]WPAStart4WayHS : Not expect calling\n"));
+ return;
+ }
+
+
+ // Increment replay counter by 1
+ ADD_ONE_To_64BIT_VAR(pEntry->R_Counter);
+
+ // Randomly generate ANonce
+ GenRandom(pAd, (UCHAR *)pBssid, pEntry->ANonce);
+
+ // Construct EAPoL message - Pairwise Msg 1
+ // EAPOL-Key(0,0,1,0,P,0,0,ANonce,0,DataKD_M1)
+ NdisZeroMemory(&EAPOLPKT, sizeof(EAPOL_PACKET));
+ ConstructEapolMsg(pEntry,
+ group_cipher,
+ EAPOL_PAIR_MSG_1,
+ 0, // Default key index
+ pEntry->ANonce,
+ NULL, // TxRSC
+ NULL, // GTK
+ NULL, // RSNIE
+ 0, // RSNIE length
+ &EAPOLPKT);
+
+
+ // Make outgoing frame
+ MAKE_802_3_HEADER(Header802_3, pEntry->Addr, pBssid, EAPOL);
+ RTMPToWirelessSta(pAd, pEntry, Header802_3,
+ LENGTH_802_3, (PUCHAR)&EAPOLPKT,
+ CONV_ARRARY_TO_UINT16(EAPOLPKT.Body_Len) + 4,
+ (pEntry->PortSecured == WPA_802_1X_PORT_SECURED) ? FALSE : TRUE);
+
+ // Trigger Retry Timer
+ RTMPModTimer(&pEntry->RetryTimer, TimeInterval);
+
+ // Update State
+ pEntry->WpaState = AS_PTKSTART;
+
+ DBGPRINT(RT_DEBUG_TRACE, ("<=== WPAStart4WayHS: send Msg1 of 4-way \n"));
+
+}
+
+/*
+ ========================================================================
+
+ Routine Description:
+ Process Pairwise key Msg-1 of 4-way handshaking and send Msg-2
+
+ Arguments:
+ pAd Pointer to our adapter
+ Elem Message body
+
+ Return Value:
+ None
+
+ Note:
+
+ ========================================================================
+*/
+VOID PeerPairMsg1Action(
+ IN PRTMP_ADAPTER pAd,
+ IN MAC_TABLE_ENTRY *pEntry,
+ IN MLME_QUEUE_ELEM *Elem)
+{
+ UCHAR PTK[80];
+ UCHAR Header802_3[14];
+ PEAPOL_PACKET pMsg1;
+ UINT MsgLen;
+ EAPOL_PACKET EAPOLPKT;
+ PUINT8 pCurrentAddr = NULL;
+ PUINT8 pmk_ptr = NULL;
+ UCHAR group_cipher = Ndis802_11WEPDisabled;
+ PUINT8 rsnie_ptr = NULL;
+ UCHAR rsnie_len = 0;
+
+ DBGPRINT(RT_DEBUG_TRACE, ("===> PeerPairMsg1Action \n"));
+
+ if ((!pEntry) || ((!pEntry->ValidAsCLI) && (!pEntry->ValidAsApCli)))
+ return;
+
+ if (Elem->MsgLen < (LENGTH_802_11 + LENGTH_802_1_H + LENGTH_EAPOL_H + sizeof(KEY_DESCRIPTER) - MAX_LEN_OF_RSNIE - 2))
+ return;
+
+#ifdef CONFIG_STA_SUPPORT
+ IF_DEV_CONFIG_OPMODE_ON_STA(pAd)
+ {
+ pCurrentAddr = pAd->CurrentAddress;
+ pmk_ptr = pAd->StaCfg.PMK;
+ group_cipher = pAd->StaCfg.GroupCipher;
+ rsnie_ptr = pAd->StaCfg.RSN_IE;
+ rsnie_len = pAd->StaCfg.RSNIE_Len;
+ }
+#endif // CONFIG_STA_SUPPORT //
+
+ // Store the received frame
+ pMsg1 = (PEAPOL_PACKET) &Elem->Msg[LENGTH_802_11 + LENGTH_802_1_H];
+ MsgLen = Elem->MsgLen - LENGTH_802_11 - LENGTH_802_1_H;
+
+ // Sanity Check peer Pairwise message 1 - Replay Counter
+ if (PeerWpaMessageSanity(pAd, pMsg1, MsgLen, EAPOL_PAIR_MSG_1, pEntry) == FALSE)
+ return;
+
+ // Store Replay counter, it will use to verify message 3 and construct message 2
+ NdisMoveMemory(pEntry->R_Counter, pMsg1->KeyDesc.ReplayCounter, LEN_KEY_DESC_REPLAY);
+
+ // Store ANonce
+ NdisMoveMemory(pEntry->ANonce, pMsg1->KeyDesc.KeyNonce, LEN_KEY_DESC_NONCE);
+
+ // Generate random SNonce
+ GenRandom(pAd, (UCHAR *)pCurrentAddr, pEntry->SNonce);
+
+ {
+ // Calculate PTK(ANonce, SNonce)
+ WpaDerivePTK(pAd,
+ pmk_ptr,
+ pEntry->ANonce,
+ pEntry->Addr,
+ pEntry->SNonce,
+ pCurrentAddr,
+ PTK,
+ LEN_PTK);
+
+ // Save key to PTK entry
+ NdisMoveMemory(pEntry->PTK, PTK, LEN_PTK);
+ }
+
+ // Update WpaState
+ pEntry->WpaState = AS_PTKINIT_NEGOTIATING;
+
+ // Construct EAPoL message - Pairwise Msg 2
+ // EAPOL-Key(0,1,0,0,P,0,0,SNonce,MIC,DataKD_M2)
+ NdisZeroMemory(&EAPOLPKT, sizeof(EAPOL_PACKET));
+ ConstructEapolMsg(pEntry,
+ group_cipher,
+ EAPOL_PAIR_MSG_2,
+ 0, // DefaultKeyIdx
+ pEntry->SNonce,
+ NULL, // TxRsc
+ NULL, // GTK
+ (UCHAR *)rsnie_ptr,
+ rsnie_len,
+ &EAPOLPKT);
+
+ // Make outgoing frame
+ MAKE_802_3_HEADER(Header802_3, pEntry->Addr, pCurrentAddr, EAPOL);
+
+ RTMPToWirelessSta(pAd, pEntry,
+ Header802_3, sizeof(Header802_3), (PUCHAR)&EAPOLPKT,
+ CONV_ARRARY_TO_UINT16(EAPOLPKT.Body_Len) + 4, TRUE);
+
+ DBGPRINT(RT_DEBUG_TRACE, ("<=== PeerPairMsg1Action: send Msg2 of 4-way \n"));
+}
+
+
+/*
+ ==========================================================================
+ Description:
+ When receiving the second packet of 4-way pairwisekey handshake.
+ Return:
+ ==========================================================================
+*/
+VOID PeerPairMsg2Action(
+ IN PRTMP_ADAPTER pAd,
+ IN MAC_TABLE_ENTRY *pEntry,
+ IN MLME_QUEUE_ELEM *Elem)
+{
+ UCHAR PTK[80];
+ BOOLEAN Cancelled;
+ PHEADER_802_11 pHeader;
+ EAPOL_PACKET EAPOLPKT;
+ PEAPOL_PACKET pMsg2;
+ UINT MsgLen;
+ UCHAR Header802_3[LENGTH_802_3];
+ UCHAR TxTsc[6];
+ PUINT8 pBssid = NULL;
+ PUINT8 pmk_ptr = NULL;
+ PUINT8 gtk_ptr = NULL;
+ UCHAR default_key = 0;
+ UCHAR group_cipher = Ndis802_11WEPDisabled;
+ PUINT8 rsnie_ptr = NULL;
+ UCHAR rsnie_len = 0;
+
+ DBGPRINT(RT_DEBUG_TRACE, ("===> PeerPairMsg2Action \n"));
+
+ if ((!pEntry) || (!pEntry->ValidAsCLI))
+ return;
+
+ if (Elem->MsgLen < (LENGTH_802_11 + LENGTH_802_1_H + LENGTH_EAPOL_H + sizeof(KEY_DESCRIPTER) - MAX_LEN_OF_RSNIE - 2))
+ return;
+
+ // check Entry in valid State
+ if (pEntry->WpaState < AS_PTKSTART)
+ return;
+
+
+
+ // pointer to 802.11 header
+ pHeader = (PHEADER_802_11)Elem->Msg;
+
+ // skip 802.11_header(24-byte) and LLC_header(8)
+ pMsg2 = (PEAPOL_PACKET)&Elem->Msg[LENGTH_802_11 + LENGTH_802_1_H];
+ MsgLen = Elem->MsgLen - LENGTH_802_11 - LENGTH_802_1_H;
+
+ // Store SNonce
+ NdisMoveMemory(pEntry->SNonce, pMsg2->KeyDesc.KeyNonce, LEN_KEY_DESC_NONCE);
+
+ {
+ // Derive PTK
+ WpaDerivePTK(pAd,
+ (UCHAR *)pmk_ptr,
+ pEntry->ANonce, // ANONCE
+ (UCHAR *)pBssid,
+ pEntry->SNonce, // SNONCE
+ pEntry->Addr,
+ PTK,
+ LEN_PTK);
+
+ NdisMoveMemory(pEntry->PTK, PTK, LEN_PTK);
+ }
+
+ // Sanity Check peer Pairwise message 2 - Replay Counter, MIC, RSNIE
+ if (PeerWpaMessageSanity(pAd, pMsg2, MsgLen, EAPOL_PAIR_MSG_2, pEntry) == FALSE)
+ return;
+
+ do
+ {
+ // delete retry timer
+ RTMPCancelTimer(&pEntry->RetryTimer, &Cancelled);
+
+ // Change state
+ pEntry->WpaState = AS_PTKINIT_NEGOTIATING;
+
+ // Increment replay counter by 1
+ ADD_ONE_To_64BIT_VAR(pEntry->R_Counter);
+
+ // Construct EAPoL message - Pairwise Msg 3
+ NdisZeroMemory(&EAPOLPKT, sizeof(EAPOL_PACKET));
+ ConstructEapolMsg(pEntry,
+ group_cipher,
+ EAPOL_PAIR_MSG_3,
+ default_key,
+ pEntry->ANonce,
+ TxTsc,
+ (UCHAR *)gtk_ptr,
+ (UCHAR *)rsnie_ptr,
+ rsnie_len,
+ &EAPOLPKT);
+
+ // Make outgoing frame
+ MAKE_802_3_HEADER(Header802_3, pEntry->Addr, pBssid, EAPOL);
+ RTMPToWirelessSta(pAd, pEntry, Header802_3, LENGTH_802_3,
+ (PUCHAR)&EAPOLPKT,
+ CONV_ARRARY_TO_UINT16(EAPOLPKT.Body_Len) + 4,
+ (pEntry->PortSecured == WPA_802_1X_PORT_SECURED) ? FALSE : TRUE);
+
+ pEntry->ReTryCounter = PEER_MSG3_RETRY_TIMER_CTR;
+ RTMPSetTimer(&pEntry->RetryTimer, PEER_MSG3_RETRY_EXEC_INTV);
+
+ // Update State
+ pEntry->WpaState = AS_PTKINIT_NEGOTIATING;
+ }while(FALSE);
+
+ DBGPRINT(RT_DEBUG_TRACE, ("<=== PeerPairMsg2Action: send Msg3 of 4-way \n"));
+}
+
+/*
+ ========================================================================
+
+ Routine Description:
+ Process Pairwise key Msg 3 of 4-way handshaking and send Msg 4
+
+ Arguments:
+ pAd Pointer to our adapter
+ Elem Message body
+
+ Return Value:
+ None
+
+ Note:
+
+ ========================================================================
+*/
+VOID PeerPairMsg3Action(
+ IN PRTMP_ADAPTER pAd,
+ IN MAC_TABLE_ENTRY *pEntry,
+ IN MLME_QUEUE_ELEM *Elem)
+{
+ PHEADER_802_11 pHeader;
+ UCHAR Header802_3[14];
+ EAPOL_PACKET EAPOLPKT;
+ PEAPOL_PACKET pMsg3;
+ UINT MsgLen;
+ PUINT8 pCurrentAddr = NULL;
+ UCHAR group_cipher = Ndis802_11WEPDisabled;
+
+ DBGPRINT(RT_DEBUG_TRACE, ("===> PeerPairMsg3Action \n"));
+
+ if ((!pEntry) || ((!pEntry->ValidAsCLI) && (!pEntry->ValidAsApCli)))
+ return;
+
+ if (Elem->MsgLen < (LENGTH_802_11 + LENGTH_802_1_H + LENGTH_EAPOL_H + sizeof(KEY_DESCRIPTER) - MAX_LEN_OF_RSNIE - 2))
+ return;
+
+#ifdef CONFIG_STA_SUPPORT
+ IF_DEV_CONFIG_OPMODE_ON_STA(pAd)
+ {
+ pCurrentAddr = pAd->CurrentAddress;
+ group_cipher = pAd->StaCfg.GroupCipher;
+
+ }
+#endif // CONFIG_STA_SUPPORT //
+
+ // 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];
+ MsgLen = Elem->MsgLen - LENGTH_802_11 - LENGTH_802_1_H;
+
+ // Sanity Check peer Pairwise message 3 - Replay Counter, MIC, RSNIE
+ if (PeerWpaMessageSanity(pAd, pMsg3, MsgLen, EAPOL_PAIR_MSG_3, pEntry) == FALSE)
+ return;
+
+ // Save Replay counter, it will use construct message 4
+ NdisMoveMemory(pEntry->R_Counter, pMsg3->KeyDesc.ReplayCounter, LEN_KEY_DESC_REPLAY);
+
+ // Double check ANonce
+ if (!NdisEqualMemory(pEntry->ANonce, pMsg3->KeyDesc.KeyNonce, LEN_KEY_DESC_NONCE))
+ {
+ return;
+ }
+
+ // Construct EAPoL message - Pairwise Msg 4
+ NdisZeroMemory(&EAPOLPKT, sizeof(EAPOL_PACKET));
+ ConstructEapolMsg(pEntry,
+ group_cipher,
+ EAPOL_PAIR_MSG_4,
+ 0, // group key index not used in message 4
+ NULL, // Nonce not used in message 4
+ NULL, // TxRSC not used in message 4
+ NULL, // GTK not used in message 4
+ NULL, // RSN IE not used in message 4
+ 0,
+ &EAPOLPKT);
+
+ // Update WpaState
+ pEntry->WpaState = AS_PTKINITDONE;
+
+ // Update pairwise key
+#ifdef CONFIG_STA_SUPPORT
+ IF_DEV_CONFIG_OPMODE_ON_STA(pAd)
+ {
+ PCIPHER_KEY pSharedKey;
+
+ pSharedKey = &pAd->SharedKey[BSS0][0];
+
+ NdisMoveMemory(pAd->StaCfg.PTK, pEntry->PTK, LEN_PTK);
+
+ // Prepare pair-wise key information into shared key table
+ NdisZeroMemory(pSharedKey, sizeof(CIPHER_KEY));
+ pSharedKey->KeyLen = LEN_TKIP_EK;
+ NdisMoveMemory(pSharedKey->Key, &pAd->StaCfg.PTK[32], LEN_TKIP_EK);
+ NdisMoveMemory(pSharedKey->RxMic, &pAd->StaCfg.PTK[48], LEN_TKIP_RXMICK);
+ NdisMoveMemory(pSharedKey->TxMic, &pAd->StaCfg.PTK[48+LEN_TKIP_RXMICK], LEN_TKIP_TXMICK);
+
+ // Decide its ChiperAlg
+ if (pAd->StaCfg.PairCipher == Ndis802_11Encryption2Enabled)
+ pSharedKey->CipherAlg = CIPHER_TKIP;
+ else if (pAd->StaCfg.PairCipher == Ndis802_11Encryption3Enabled)
+ pSharedKey->CipherAlg = CIPHER_AES;
+ else
+ pSharedKey->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 = pSharedKey->CipherAlg;
+
+ // Update pairwise key information to ASIC Shared Key Table
+ AsicAddSharedKeyEntry(pAd,
+ BSS0,
+ 0,
+ pSharedKey->CipherAlg,
+ pSharedKey->Key,
+ pSharedKey->TxMic,
+ pSharedKey->RxMic);
+
+ // Update ASIC WCID attribute table and IVEIV table
+ RTMPAddWcidAttributeEntry(pAd,
+ BSS0,
+ 0,
+ pSharedKey->CipherAlg,
+ pEntry);
+
+ }
+#endif // CONFIG_STA_SUPPORT //
+
+ // open 802.1x port control and privacy filter
+ if (pEntry->AuthMode == Ndis802_11AuthModeWPA2PSK ||
+ pEntry->AuthMode == Ndis802_11AuthModeWPA2)
+ {
+ pEntry->PortSecured = WPA_802_1X_PORT_SECURED;
+ pEntry->PrivacyFilter = Ndis802_11PrivFilterAcceptAll;
+
+#ifdef CONFIG_STA_SUPPORT
+ STA_PORT_SECURED(pAd);
+ // Indicate Connected for GUI
+ pAd->IndicateMediaState = NdisMediaStateConnected;
+#endif // CONFIG_STA_SUPPORT //
+ DBGPRINT(RT_DEBUG_TRACE, ("PeerPairMsg3Action: AuthMode(%s) PairwiseCipher(%s) GroupCipher(%s) \n",
+ GetAuthMode(pEntry->AuthMode),
+ GetEncryptType(pEntry->WepStatus),
+ GetEncryptType(group_cipher)));
+ }
+ else
+ {
+ }
+
+ // Init 802.3 header and send out
+ MAKE_802_3_HEADER(Header802_3, pEntry->Addr, pCurrentAddr, EAPOL);
+ RTMPToWirelessSta(pAd, pEntry,
+ Header802_3, sizeof(Header802_3),
+ (PUCHAR)&EAPOLPKT,
+ CONV_ARRARY_TO_UINT16(EAPOLPKT.Body_Len) + 4, TRUE);
+
+ DBGPRINT(RT_DEBUG_TRACE, ("<=== PeerPairMsg3Action: send Msg4 of 4-way \n"));
+}
+
+/*
+ ==========================================================================
+ Description:
+ When receiving the last packet of 4-way pairwisekey handshake.
+ Initilize 2-way groupkey handshake following.
+ Return:
+ ==========================================================================
+*/
+VOID PeerPairMsg4Action(
+ IN PRTMP_ADAPTER pAd,
+ IN MAC_TABLE_ENTRY *pEntry,
+ IN MLME_QUEUE_ELEM *Elem)
+{
+ PEAPOL_PACKET pMsg4;
+ PHEADER_802_11 pHeader;
+ UINT MsgLen;
+ BOOLEAN Cancelled;
+ UCHAR group_cipher = Ndis802_11WEPDisabled;
+
+ DBGPRINT(RT_DEBUG_TRACE, ("===> PeerPairMsg4Action\n"));
+
+ do
+ {
+ if ((!pEntry) || (!pEntry->ValidAsCLI))
+ break;
+
+ if (Elem->MsgLen < (LENGTH_802_11 + LENGTH_802_1_H + LENGTH_EAPOL_H + sizeof(KEY_DESCRIPTER) - MAX_LEN_OF_RSNIE - 2 ) )
+ break;
+
+ if (pEntry->WpaState < AS_PTKINIT_NEGOTIATING)
+ break;
+
+
+ // pointer to 802.11 header
+ pHeader = (PHEADER_802_11)Elem->Msg;
+
+ // skip 802.11_header(24-byte) and LLC_header(8)
+ pMsg4 = (PEAPOL_PACKET)&Elem->Msg[LENGTH_802_11 + LENGTH_802_1_H];
+ MsgLen = Elem->MsgLen - LENGTH_802_11 - LENGTH_802_1_H;
+
+ // Sanity Check peer Pairwise message 4 - Replay Counter, MIC
+ if (PeerWpaMessageSanity(pAd, pMsg4, MsgLen, EAPOL_PAIR_MSG_4, pEntry) == FALSE)
+ break;
+
+ // 3. uses the MLME.SETKEYS.request to configure PTK into MAC
+ NdisZeroMemory(&pEntry->PairwiseKey, sizeof(CIPHER_KEY));
+
+ // reset IVEIV in Asic
+ AsicUpdateWCIDIVEIV(pAd, pEntry->Aid, 1, 0);
+
+ pEntry->PairwiseKey.KeyLen = LEN_TKIP_EK;
+ NdisMoveMemory(pEntry->PairwiseKey.Key, &pEntry->PTK[32], LEN_TKIP_EK);
+ NdisMoveMemory(pEntry->PairwiseKey.RxMic, &pEntry->PTK[TKIP_AP_RXMICK_OFFSET], LEN_TKIP_RXMICK);
+ NdisMoveMemory(pEntry->PairwiseKey.TxMic, &pEntry->PTK[TKIP_AP_TXMICK_OFFSET], LEN_TKIP_TXMICK);
+
+ // Set pairwise key to Asic
+ {
+ pEntry->PairwiseKey.CipherAlg = CIPHER_NONE;
+ if (pEntry->WepStatus == Ndis802_11Encryption2Enabled)
+ pEntry->PairwiseKey.CipherAlg = CIPHER_TKIP;
+ else if (pEntry->WepStatus == Ndis802_11Encryption3Enabled)
+ pEntry->PairwiseKey.CipherAlg = CIPHER_AES;
+
+ // 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,
+ pEntry->apidx,
+ 0,
+ pEntry->PairwiseKey.CipherAlg,
+ pEntry);
+ }
+
+ // 4. upgrade state
+ pEntry->PrivacyFilter = Ndis802_11PrivFilterAcceptAll;
+ pEntry->WpaState = AS_PTKINITDONE;
+ pEntry->PortSecured = WPA_802_1X_PORT_SECURED;
+
+
+ if (pEntry->AuthMode == Ndis802_11AuthModeWPA2 ||
+ pEntry->AuthMode == Ndis802_11AuthModeWPA2PSK)
+ {
+ pEntry->GTKState = REKEY_ESTABLISHED;
+ RTMPCancelTimer(&pEntry->RetryTimer, &Cancelled);
+
+
+ // send wireless event - for set key done WPA2
+ if (pAd->CommonCfg.bWirelessEvent)
+ RTMPSendWirelessEvent(pAd, IW_SET_KEY_DONE_WPA2_EVENT_FLAG, pEntry->Addr, pEntry->apidx, 0);
+
+ DBGPRINT(RT_DEBUG_OFF, ("AP SETKEYS DONE - WPA2, AuthMode(%d)=%s, WepStatus(%d)=%s, GroupWepStatus(%d)=%s\n\n",
+ pEntry->AuthMode, GetAuthMode(pEntry->AuthMode),
+ pEntry->WepStatus, GetEncryptType(pEntry->WepStatus),
+ group_cipher,
+ GetEncryptType(group_cipher)));
+ }
+ else
+ {
+ // 5. init Group 2-way handshake if necessary.
+ WPAStart2WayGroupHS(pAd, pEntry);
+
+ pEntry->ReTryCounter = GROUP_MSG1_RETRY_TIMER_CTR;
+ RTMPModTimer(&pEntry->RetryTimer, PEER_MSG3_RETRY_EXEC_INTV);
+ }
+ }while(FALSE);
+
+}
+
+/*
+ ==========================================================================
+ Description:
+ This is a function to send the first packet of 2-way groupkey handshake
+ Return:
+
+ ==========================================================================
+*/
+VOID WPAStart2WayGroupHS(
+ IN PRTMP_ADAPTER pAd,
+ IN MAC_TABLE_ENTRY *pEntry)
+{
+ UCHAR Header802_3[14];
+ UCHAR TxTsc[6];
+ EAPOL_PACKET EAPOLPKT;
+ UCHAR group_cipher = Ndis802_11WEPDisabled;
+ UCHAR default_key = 0;
+ PUINT8 gnonce_ptr = NULL;
+ PUINT8 gtk_ptr = NULL;
+ PUINT8 pBssid = NULL;
+
+ DBGPRINT(RT_DEBUG_TRACE, ("===> WPAStart2WayGroupHS\n"));
+
+ if ((!pEntry) || (!pEntry->ValidAsCLI))
+ return;
+
+
+ do
+ {
+ // Increment replay counter by 1
+ ADD_ONE_To_64BIT_VAR(pEntry->R_Counter);
+
+ // Construct EAPoL message - Group Msg 1
+ NdisZeroMemory(&EAPOLPKT, sizeof(EAPOL_PACKET));
+ ConstructEapolMsg(pEntry,
+ group_cipher,
+ EAPOL_GROUP_MSG_1,
+ default_key,
+ (UCHAR *)gnonce_ptr,
+ TxTsc,
+ (UCHAR *)gtk_ptr,
+ NULL,
+ 0,
+ &EAPOLPKT);
+
+ // Make outgoing frame
+ MAKE_802_3_HEADER(Header802_3, pEntry->Addr, pBssid, EAPOL);
+ RTMPToWirelessSta(pAd, pEntry,
+ Header802_3, LENGTH_802_3,
+ (PUCHAR)&EAPOLPKT,
+ CONV_ARRARY_TO_UINT16(EAPOLPKT.Body_Len) + 4, FALSE);
+
+
+
+ }while (FALSE);
+
+ DBGPRINT(RT_DEBUG_TRACE, ("<=== WPAStart2WayGroupHS : send out Group Message 1 \n"));
+
+ return;
+}
+
+/*
+ ========================================================================
+
+ Routine Description:
+ Process Group key 2-way handshaking
+
+ Arguments:
+ pAd Pointer to our adapter
+ Elem Message body
+
+ Return Value:
+ None
+
+ Note:
+
+ ========================================================================
+*/
+VOID PeerGroupMsg1Action(
+ IN PRTMP_ADAPTER pAd,
+ IN MAC_TABLE_ENTRY *pEntry,
+ IN MLME_QUEUE_ELEM *Elem)
+{
+ UCHAR Header802_3[14];
+ EAPOL_PACKET EAPOLPKT;
+ PEAPOL_PACKET pGroup;
+ UINT MsgLen;
+ BOOLEAN Cancelled;
+ UCHAR default_key = 0;
+ UCHAR group_cipher = Ndis802_11WEPDisabled;
+ PUINT8 pCurrentAddr = NULL;
+
+ DBGPRINT(RT_DEBUG_TRACE, ("===> PeerGroupMsg1Action \n"));
+
+ if ((!pEntry) || ((!pEntry->ValidAsCLI) && (!pEntry->ValidAsApCli)))
+ return;
+
+#ifdef CONFIG_STA_SUPPORT
+ IF_DEV_CONFIG_OPMODE_ON_STA(pAd)
+ {
+ pCurrentAddr = pAd->CurrentAddress;
+ group_cipher = pAd->StaCfg.GroupCipher;
+ default_key = pAd->StaCfg.DefaultKeyId;
+ }
+#endif // CONFIG_STA_SUPPORT //
+
+ // 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];
+ MsgLen = Elem->MsgLen - LENGTH_802_11 - LENGTH_802_1_H;
+
+ // Sanity Check peer group message 1 - Replay Counter, MIC, RSNIE
+ if (PeerWpaMessageSanity(pAd, pGroup, MsgLen, EAPOL_GROUP_MSG_1, pEntry) == FALSE)
+ return;
+
+ // delete retry timer
+ RTMPCancelTimer(&pEntry->RetryTimer, &Cancelled);
+
+ // Save Replay counter, it will use to construct message 2
+ NdisMoveMemory(pEntry->R_Counter, pGroup->KeyDesc.ReplayCounter, LEN_KEY_DESC_REPLAY);
+
+ // Construct EAPoL message - Group Msg 2
+ NdisZeroMemory(&EAPOLPKT, sizeof(EAPOL_PACKET));
+ ConstructEapolMsg(pEntry,
+ group_cipher,
+ EAPOL_GROUP_MSG_2,
+ default_key,
+ NULL, // Nonce not used
+ NULL, // TxRSC not used
+ NULL, // GTK not used
+ NULL, // RSN IE not used
+ 0,
+ &EAPOLPKT);
+
+ // open 802.1x port control and privacy filter
+ pEntry->PortSecured = WPA_802_1X_PORT_SECURED;
+ pEntry->PrivacyFilter = Ndis802_11PrivFilterAcceptAll;
+
+#ifdef CONFIG_STA_SUPPORT
+ STA_PORT_SECURED(pAd);
+ // Indicate Connected for GUI
+ pAd->IndicateMediaState = NdisMediaStateConnected;
+#endif // CONFIG_STA_SUPPORT //
+
+ DBGPRINT(RT_DEBUG_TRACE, ("PeerGroupMsg1Action: AuthMode(%s) PairwiseCipher(%s) GroupCipher(%s) \n",
+ GetAuthMode(pEntry->AuthMode),
+ GetEncryptType(pEntry->WepStatus),
+ GetEncryptType(group_cipher)));
+
+ // init header and Fill Packet and send Msg 2 to authenticator
+ MAKE_802_3_HEADER(Header802_3, pEntry->Addr, pCurrentAddr, EAPOL);
+ RTMPToWirelessSta(pAd, pEntry,
+ Header802_3, sizeof(Header802_3),
+ (PUCHAR)&EAPOLPKT,
+ CONV_ARRARY_TO_UINT16(EAPOLPKT.Body_Len) + 4, FALSE);
+
+ DBGPRINT(RT_DEBUG_TRACE, ("<=== PeerGroupMsg1Action: sned group message 2\n"));
+}
+
+/*
+ ==========================================================================
+ Description:
+ When receiving the last packet of 2-way groupkey handshake.
+ Return:
+ ==========================================================================
+*/
+VOID PeerGroupMsg2Action(
+ IN PRTMP_ADAPTER pAd,
+ IN MAC_TABLE_ENTRY *pEntry,
+ IN VOID *Msg,
+ IN UINT MsgLen)
+{
+ UINT Len;
+ PUCHAR pData;
+ BOOLEAN Cancelled;
+ PEAPOL_PACKET pMsg2;
+ UCHAR group_cipher = Ndis802_11WEPDisabled;
+
+ DBGPRINT(RT_DEBUG_TRACE, ("===> PeerGroupMsg2Action \n"));
+
+ do
+ {
+ if ((!pEntry) || (!pEntry->ValidAsCLI))
+ break;
+
+ if (MsgLen < (LENGTH_802_1_H + LENGTH_EAPOL_H + sizeof(KEY_DESCRIPTER) - MAX_LEN_OF_RSNIE - 2))
+ break;
+
+ if (pEntry->WpaState != AS_PTKINITDONE)
+ break;
+
+
+ pData = (PUCHAR)Msg;
+ pMsg2 = (PEAPOL_PACKET) (pData + LENGTH_802_1_H);
+ Len = MsgLen - LENGTH_802_1_H;
+
+ // Sanity Check peer group message 2 - Replay Counter, MIC
+ if (PeerWpaMessageSanity(pAd, pMsg2, Len, EAPOL_GROUP_MSG_2, pEntry) == FALSE)
+ break;
+
+ // 3. upgrade state
+
+ RTMPCancelTimer(&pEntry->RetryTimer, &Cancelled);
+ pEntry->GTKState = REKEY_ESTABLISHED;
+
+ if ((pEntry->AuthMode == Ndis802_11AuthModeWPA2) || (pEntry->AuthMode == Ndis802_11AuthModeWPA2PSK))
+ {
+ // send wireless event - for set key done WPA2
+ if (pAd->CommonCfg.bWirelessEvent)
+ RTMPSendWirelessEvent(pAd, IW_SET_KEY_DONE_WPA2_EVENT_FLAG, pEntry->Addr, pEntry->apidx, 0);
+
+ DBGPRINT(RT_DEBUG_OFF, ("AP SETKEYS DONE - WPA2, AuthMode(%d)=%s, WepStatus(%d)=%s, GroupWepStatus(%d)=%s\n\n",
+ pEntry->AuthMode, GetAuthMode(pEntry->AuthMode),
+ pEntry->WepStatus, GetEncryptType(pEntry->WepStatus),
+ group_cipher, GetEncryptType(group_cipher)));
+ }
+ else
+ {
+ // send wireless event - for set key done WPA
+ if (pAd->CommonCfg.bWirelessEvent)
+ RTMPSendWirelessEvent(pAd, IW_SET_KEY_DONE_WPA1_EVENT_FLAG, pEntry->Addr, pEntry->apidx, 0);
+
+ DBGPRINT(RT_DEBUG_OFF, ("AP SETKEYS DONE - WPA1, AuthMode(%d)=%s, WepStatus(%d)=%s, GroupWepStatus(%d)=%s\n\n",
+ pEntry->AuthMode, GetAuthMode(pEntry->AuthMode),
+ pEntry->WepStatus, GetEncryptType(pEntry->WepStatus),
+ group_cipher, GetEncryptType(group_cipher)));
+ }
+ }while(FALSE);
+}
+
+/*
+ ========================================================================
+
+ 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;
+}
+
+/*
+ ========================================================================
+
+ 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(key, key_len, input, total_len, &output[currentindex], SHA1_DIGEST_SIZE);
+ currentindex += 20;
+
+ // update the last octet
+ input[total_len - 1]++;
+ }
+ os_free_mem(NULL, input);
+}
+
+/*
+* 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)
+*/
+
+static void F(char *password, unsigned char *ssid, int ssidlength, int iterations, int count, unsigned char *output)
+{
+ unsigned char digest[36], digest1[SHA1_DIGEST_SIZE];
+ 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((unsigned char*) password, (int) strlen(password), digest, ssidlength+4, digest1, SHA1_DIGEST_SIZE); // for WPA update
+
+ /* output = U1 */
+ memcpy(output, digest1, SHA1_DIGEST_SIZE);
+
+ for (i = 1; i < iterations; i++)
+ {
+ /* Un = PRF(P, Un-1) */
+ HMAC_SHA1((unsigned char*) password, (int) strlen(password), digest1, SHA1_DIGEST_SIZE, digest, SHA1_DIGEST_SIZE); // for WPA update
+ memcpy(digest1, digest, SHA1_DIGEST_SIZE);
+
+ /* output = output xor Un */
+ for (j = 0; j < SHA1_DIGEST_SIZE; 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(PSTRING password, PUCHAR ssid, INT ssidlength, PUCHAR output)
+{
+ if ((strlen(password) > 63) || (ssidlength > 32))
+ return 0;
+
+ F(password, ssid, ssidlength, 4096, 1, output);
+ F(password, ssid, ssidlength, 4096, 2, &output[SHA1_DIGEST_SIZE]);
+ return 1;
+}
+
+
+
+/*
+ ========================================================================
+
+ 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 WpaDerivePTK(
+ 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 RTMPMakeRsnIeCipher(
+ 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 RTMPMakeRsnIeAKM(
+ IN PRTMP_ADAPTER pAd,
+ IN UCHAR ElementID,
+ IN UINT AuthMode,
+ IN UCHAR apidx,
+ OUT PUCHAR pRsnIe,
+ OUT UCHAR *rsn_len)
+{
+ RSNIE_AUTH *pRsnie_auth;
+ UCHAR AkmCnt = 1; // default as 1
+
+ pRsnie_auth = (RSNIE_AUTH*)(pRsnIe + (*rsn_len));
+
+ // decide WPA2 or WPA1
+ if (ElementID == Wpa2Ie)
+ {
+
+ switch (AuthMode)
+ {
+ case Ndis802_11AuthModeWPA2:
+ case Ndis802_11AuthModeWPA1WPA2:
+ NdisMoveMemory(pRsnie_auth->auth[0].oui, OUI_WPA2_8021X_AKM, 4);
+ break;
+
+ case Ndis802_11AuthModeWPA2PSK:
+ case Ndis802_11AuthModeWPA1PSKWPA2PSK:
+ NdisMoveMemory(pRsnie_auth->auth[0].oui, OUI_WPA2_PSK_AKM, 4);
+ break;
+ default:
+ AkmCnt = 0;
+ break;
+
+ }
+ }
+ else
+ {
+ switch (AuthMode)
+ {
+ case Ndis802_11AuthModeWPA:
+ case Ndis802_11AuthModeWPA1WPA2:
+ NdisMoveMemory(pRsnie_auth->auth[0].oui, OUI_WPA_8021X_AKM, 4);
+ break;
+
+ case Ndis802_11AuthModeWPAPSK:
+ case Ndis802_11AuthModeWPA1PSKWPA2PSK:
+ NdisMoveMemory(pRsnie_auth->auth[0].oui, OUI_WPA_PSK_AKM, 4);
+ break;
+
+ case Ndis802_11AuthModeWPANone:
+ NdisMoveMemory(pRsnie_auth->auth[0].oui, OUI_WPA_NONE_AKM, 4);
+ break;
+ default:
+ AkmCnt = 0;
+ break;
+ }
+ }
+
+ pRsnie_auth->acount = AkmCnt;
+ pRsnie_auth->acount = cpu2le16(pRsnie_auth->acount);
+
+ // update current RSNIE length
+ (*rsn_len) += (sizeof(RSNIE_AUTH) + (4 * (AkmCnt - 1)));
+
+}
+
+/*
+ ========================================================================
+
+ 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 RTMPMakeRsnIeCap(
+ 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
+ RTMPMakeRsnIeCipher(pAd, PrimaryRsnie, WepStatus, bMixCipher, FlexibleCipher, pRsnIe, &p_offset);
+
+ // 2. insert AKM
+ RTMPMakeRsnIeAKM(pAd, PrimaryRsnie, AuthMode, apidx, pRsnIe, &p_offset);
+
+ // 3. insert capability
+ RTMPMakeRsnIeCap(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))
+// if (*(UINT16 *)EAPOL == *(UINT16 *)pData)
+ {
+ 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:
+ 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
+
+ ==========================================================================
+*/
+PSTRING 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) &&
+ (pEid->Eid == pEntry->RSN_IE[0]) &&
+ ((pEid->Len + 2) >= pEntry->RSNIE_Len) &&
+ (NdisEqualMemory(pEid->Octet, &pEntry->RSN_IE[2], pEntry->RSNIE_Len - 2)))
+ {
+
+ 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)
+ {
+ WpaShowAllsuite(pMyKeyData, skip_offset);
+
+ // 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));
+ //hex_dump("remain data", pMyKeyData, 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
+ IF_DEV_CONFIG_OPMODE_ON_STA(pAd)
+ {
+ PCIPHER_KEY pSharedKey;
+
+ // set key material, TxMic and RxMic
+ NdisMoveMemory(pAd->StaCfg.GTK, pMyKeyData, 32);
+ pAd->StaCfg.DefaultKeyId = DefaultIdx;
+
+ pSharedKey = &pAd->SharedKey[BSS0][pAd->StaCfg.DefaultKeyId];
+
+ // Prepare pair-wise key information into shared key table
+ NdisZeroMemory(pSharedKey, sizeof(CIPHER_KEY));
+ pSharedKey->KeyLen = LEN_TKIP_EK;
+ NdisMoveMemory(pSharedKey->Key, pAd->StaCfg.GTK, LEN_TKIP_EK);
+ NdisMoveMemory(pSharedKey->RxMic, &pAd->StaCfg.GTK[16], LEN_TKIP_RXMICK);
+ NdisMoveMemory(pSharedKey->TxMic, &pAd->StaCfg.GTK[24], LEN_TKIP_TXMICK);
+
+ // Update Shared Key CipherAlg
+ pSharedKey->CipherAlg = CIPHER_NONE;
+ if (pAd->StaCfg.GroupCipher == Ndis802_11Encryption2Enabled)
+ pSharedKey->CipherAlg = CIPHER_TKIP;
+ else if (pAd->StaCfg.GroupCipher == Ndis802_11Encryption3Enabled)
+ pSharedKey->CipherAlg = CIPHER_AES;
+ else if (pAd->StaCfg.GroupCipher == Ndis802_11GroupWEP40Enabled)
+ pSharedKey->CipherAlg = CIPHER_WEP64;
+ else if (pAd->StaCfg.GroupCipher == Ndis802_11GroupWEP104Enabled)
+ pSharedKey->CipherAlg = CIPHER_WEP128;
+
+
+ // Update group key information to ASIC Shared Key Table
+ AsicAddSharedKeyEntry(pAd,
+ BSS0,
+ pAd->StaCfg.DefaultKeyId,
+ pSharedKey->CipherAlg,
+ pSharedKey->Key,
+ pSharedKey->TxMic,
+ pSharedKey->RxMic);
+
+ // Update ASIC WCID attribute table and IVEIV table
+ RTMPAddWcidAttributeEntry(pAd,
+ BSS0,
+ pAd->StaCfg.DefaultKeyId,
+ pSharedKey->CipherAlg,
+ NULL);
+ }
+#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 PMAC_TABLE_ENTRY pEntry,
+ IN UCHAR GroupKeyWepStatus,
+ IN UCHAR MsgType,
+ IN UCHAR DefaultKeyIdx,
+ IN UCHAR *KeyNonce,
+ IN UCHAR *TxRSC,
+ IN UCHAR *GTK,
+ IN UCHAR *RSNIE,
+ IN UCHAR RSNIE_Len,
+ OUT PEAPOL_PACKET pMsg)
+{
+ BOOLEAN bWPA2 = FALSE;
+ UCHAR KeyDescVer;
+
+ // Choose WPA2 or not
+ if ((pEntry->AuthMode == Ndis802_11AuthModeWPA2) ||
+ (pEntry->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
+ SET_UINT16_TO_ARRARY(pMsg->Body_Len, LEN_EAPOL_KEY_MSG);
+
+ // Fill in EAPoL descriptor
+ if (bWPA2)
+ pMsg->KeyDesc.Type = WPA2_KEY_DESC;
+ else
+ pMsg->KeyDesc.Type = WPA1_KEY_DESC;
+
+ // Key Descriptor Version (bits 0-2) specifies the key descriptor version type
+ {
+ // 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.
+ KeyDescVer = (((pEntry->WepStatus == Ndis802_11Encryption3Enabled) ||
+ (GroupKeyWepStatus == Ndis802_11Encryption3Enabled)) ? (DESC_TYPE_AES) : (DESC_TYPE_TKIP));
+ }
+
+ pMsg->KeyDesc.KeyInfo.KeyDescVer = KeyDescVer;
+
+ // 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] = ((pEntry->WepStatus == Ndis802_11Encryption2Enabled) ? LEN_TKIP_KEY : LEN_AES_KEY);
+ }
+ }
+
+ // Fill in replay counter
+ NdisMoveMemory(pMsg->KeyDesc.ReplayCounter, pEntry->R_Counter, 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(pEntry,
+ GroupKeyWepStatus,
+ KeyDescVer,
+ MsgType,
+ DefaultKeyIdx,
+ GTK,
+ RSNIE,
+ RSNIE_Len,
+ pMsg);
+
+ // Calculate MIC and fill in KeyMic Field except Pairwise Msg 1.
+ if (MsgType != EAPOL_PAIR_MSG_1)
+ {
+ CalculateMIC(KeyDescVer, pEntry->PTK, pMsg);
+ }
+
+ DBGPRINT(RT_DEBUG_TRACE, ("===> ConstructEapolMsg for %s %s\n", ((bWPA2) ? "WPA2" : "WPA"), GetEapolMsgType(MsgType)));
+ DBGPRINT(RT_DEBUG_TRACE, (" Body length = %d \n", CONV_ARRARY_TO_UINT16(pMsg->Body_Len)));
+ DBGPRINT(RT_DEBUG_TRACE, (" Key length = %d \n", CONV_ARRARY_TO_UINT16(pMsg->KeyDesc.KeyLength)));
+
+
+}
+
+/*
+ ========================================================================
+
+ 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 PMAC_TABLE_ENTRY pEntry,
+ IN UCHAR GroupKeyWepStatus,
+ IN UCHAR keyDescVer,
+ IN UCHAR MsgType,
+ IN UCHAR DefaultKeyIdx,
+ 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)];
+ ULONG data_offset;
+ BOOLEAN bWPA2Capable = FALSE;
+ PRTMP_ADAPTER pAd = pEntry->pAd;
+ BOOLEAN GTK_Included = FALSE;
+
+ // Choose WPA2 or not
+ if ((pEntry->AuthMode == Ndis802_11AuthModeWPA2) ||
+ (pEntry->AuthMode == Ndis802_11AuthModeWPA2PSK))
+ bWPA2Capable = TRUE;
+
+ if (MsgType == EAPOL_PAIR_MSG_1 ||
+ MsgType == EAPOL_PAIR_MSG_4 ||
+ MsgType == EAPOL_GROUP_MSG_2)
+ return;
+
+ // allocate memory pool
+ os_alloc_mem(NULL, (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);
+ SET_UINT16_TO_ARRARY(pMsg->KeyDesc.KeyDataLen, 0);
+ data_offset = 0;
+
+ // Encapsulate RSNIE in pairwise_msg2 & pairwise_msg3
+ if (RSNIE_LEN && ((MsgType == EAPOL_PAIR_MSG_2) || (MsgType == EAPOL_PAIR_MSG_3)))
+ {
+ PUINT8 pmkid_ptr = NULL;
+ UINT8 pmkid_len = 0;
+
+
+ RTMPInsertRSNIE(&Key_Data[data_offset],
+ (PULONG)&data_offset,
+ RSNIE,
+ RSNIE_LEN,
+ pmkid_ptr,
+ pmkid_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
+ // 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;
+ }
+
+ GTK_Included = TRUE;
+ }
+
+
+ // This whole key-data field shall be encrypted if a GTK is included.
+ // Encrypt the data material in key data field with KEK
+ if (GTK_Included)
+ {
+ //hex_dump("GTK_Included", Key_Data, data_offset);
+
+ if (
+ (keyDescVer == DESC_TYPE_AES))
+ {
+ UCHAR remainder = 0;
+ UCHAR pad_len = 0;
+
+ // Key Descriptor Version 2 or 3: AES key wrap, defined in IETF RFC 3394,
+ // shall be used to encrypt the Key Data field using the KEK field from
+ // the derived PTK.
+
+ // If the Key Data field uses the NIST AES key wrap, then the Key Data field
+ // shall be padded before encrypting if the key data length is less than 16
+ // octets or if it is not a multiple of 8. The padding consists of appending
+ // a single octet 0xdd followed by zero or more 0x00 octets.
+ if ((remainder = data_offset & 0x07) != 0)
+ {
+ INT i;
+
+ pad_len = (8 - remainder);
+ Key_Data[data_offset] = 0xDD;
+ for (i = 1; i < pad_len; i++)
+ Key_Data[data_offset + i] = 0;
+
+ data_offset += pad_len;
+ }
+
+ AES_GTK_KEY_WRAP(&pEntry->PTK[16], Key_Data, data_offset, Rc4GTK);
+ // AES wrap function will grow 8 bytes in length
+ data_offset += 8;
+ }
+ else
+ {
+ /* Key Descriptor Version 1: ARC4 is used to encrypt the Key Data field
+ using the KEK field from the derived PTK. */
+
+ // 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], &pEntry->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);
+ }
+
+ // Update key data length field and total body length
+ SET_UINT16_TO_ARRARY(pMsg->KeyDesc.KeyDataLen, data_offset);
+ INC_UINT16_TO_ARRARY(pMsg->Body_Len, data_offset);
+
+ os_free_mem(NULL, 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:
+
+ ========================================================================
+*/
+static VOID CalculateMIC(
+ IN UCHAR KeyDescVer,
+ 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(NULL, (PUCHAR *)&OutBuffer, 512);
+
+ if (OutBuffer == NULL)
+ {
+ DBGPRINT(RT_DEBUG_ERROR, ("!!!CalculateMIC: no memory!!!\n"));
+ return;
+ }
+
+ // make a frame for calculating MIC.
+ MakeOutgoingFrame(OutBuffer, &FrameLen,
+ CONV_ARRARY_TO_UINT16(pMsg->Body_Len) + 4, pMsg,
+ END_OF_ARGS);
+
+ NdisZeroMemory(mic, sizeof(mic));
+
+ // Calculate MIC
+ if (KeyDescVer == DESC_TYPE_AES)
+ {
+ HMAC_SHA1(PTK, LEN_EAP_MICK, OutBuffer, FrameLen, digest, SHA1_DIGEST_SIZE);
+ NdisMoveMemory(mic, digest, LEN_KEY_DESC_MIC);
+ }
+ else
+ {
+ HMAC_MD5(PTK, LEN_EAP_MICK, OutBuffer, FrameLen, mic, MD5_DIGEST_SIZE);
+ }
+
+ // store the calculated MIC
+ NdisMoveMemory(pMsg->KeyDesc.KeyMic, mic, LEN_KEY_DESC_MIC);
+
+ os_free_mem(NULL, 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;
+
+}
+
+
+PUINT8 GetSuiteFromRSNIE(
+ IN PUINT8 rsnie,
+ IN UINT rsnie_len,
+ IN UINT8 type,
+ OUT UINT8 *count)
+{
+ PEID_STRUCT pEid;
+ INT len;
+ PUINT8 pBuf;
+ INT offset = 0;
+ PRSNIE_AUTH pAkm;
+ UINT16 acount;
+ BOOLEAN isWPA2 = FALSE;
+
+ pEid = (PEID_STRUCT)rsnie;
+ len = rsnie_len - 2; // exclude IE and length
+ pBuf = (PUINT8)&pEid->Octet[0];
+
+
+
+ // set default value
+ *count = 0;
+
+ // Check length
+ if ((len <= 0) || (pEid->Len != len))
+ {
+ DBGPRINT_ERR(("%s : The length is invalid\n", __FUNCTION__));
+ return NULL;
+ }
+
+ // Check WPA or WPA2
+ if (pEid->Eid == IE_WPA)
+ {
+ PRSNIE pRsnie = (PRSNIE)pBuf;
+ UINT16 ucount;
+
+ if (len < sizeof(RSNIE))
+ {
+ DBGPRINT_ERR(("%s : The length is too short for WPA\n", __FUNCTION__));
+ return NULL;
+ }
+
+ // Get the count of pairwise cipher
+ ucount = cpu2le16(pRsnie->ucount);
+ if (ucount > 2)
+ {
+ DBGPRINT_ERR(("%s : The count(%d) of pairwise cipher is invlaid\n",
+ __FUNCTION__, ucount));
+ return NULL;
+ }
+
+ // Get the group cipher
+ if (type == GROUP_SUITE)
+ {
+ *count = 1;
+ return pRsnie->mcast;
+ }
+ // Get the pairwise cipher suite
+ else if (type == PAIRWISE_SUITE)
+ {
+ DBGPRINT(RT_DEBUG_TRACE, ("%s : The count of pairwise cipher is %d\n",
+ __FUNCTION__, ucount));
+ *count = ucount;
+ return pRsnie->ucast[0].oui;
+ }
+
+ offset = sizeof(RSNIE) + (4 * (ucount - 1));
+
+ }
+ else if (pEid->Eid == IE_RSN)
+ {
+ PRSNIE2 pRsnie = (PRSNIE2)pBuf;
+ UINT16 ucount;
+
+ isWPA2 = TRUE;
+
+ if (len < sizeof(RSNIE2))
+ {
+ DBGPRINT_ERR(("%s : The length is too short for WPA2\n", __FUNCTION__));
+ return NULL;
+ }
+
+ // Get the count of pairwise cipher
+ ucount = cpu2le16(pRsnie->ucount);
+ if (ucount > 2)
+ {
+ DBGPRINT_ERR(("%s : The count(%d) of pairwise cipher is invlaid\n",
+ __FUNCTION__, ucount));
+ return NULL;
+ }
+
+ // Get the group cipher
+ if (type == GROUP_SUITE)
+ {
+ *count = 1;
+ return pRsnie->mcast;
+ }
+ // Get the pairwise cipher suite
+ else if (type == PAIRWISE_SUITE)
+ {
+ DBGPRINT(RT_DEBUG_TRACE, ("%s : The count of pairwise cipher is %d\n",
+ __FUNCTION__, ucount));
+ *count = ucount;
+ return pRsnie->ucast[0].oui;
+ }
+
+ offset = sizeof(RSNIE2) + (4 * (ucount - 1));
+
+ }
+ else
+ {
+ DBGPRINT_ERR(("%s : Unknown IE (%d)\n", __FUNCTION__, pEid->Eid));
+ return NULL;
+ }
+
+ // skip group cipher and pairwise cipher suite
+ pBuf += offset;
+ len -= offset;
+
+ if (len < sizeof(RSNIE_AUTH))
+ {
+ DBGPRINT_ERR(("%s : The length of RSNIE is too short\n", __FUNCTION__));
+ return NULL;
+ }
+
+ // pointer to AKM count
+ pAkm = (PRSNIE_AUTH)pBuf;
+
+ // Get the count of pairwise cipher
+ acount = cpu2le16(pAkm->acount);
+ if (acount > 2)
+ {
+ DBGPRINT_ERR(("%s : The count(%d) of AKM is invlaid\n",
+ __FUNCTION__, acount));
+ return NULL;
+ }
+
+ // Get the AKM suite
+ if (type == AKM_SUITE)
+ {
+ DBGPRINT(RT_DEBUG_TRACE, ("%s : The count of AKM is %d\n",
+ __FUNCTION__, acount));
+ *count = acount;
+ return pAkm->auth[0].oui;
+ }
+ offset = sizeof(RSNIE_AUTH) + (4 * (acount - 1));
+
+ pBuf += offset;
+ len -= offset;
+
+ // The remaining length must larger than (RSN-Capability(2) + PMKID-Count(2) + PMKID(16~))
+ if (len >= (sizeof(RSN_CAPABILITIES) + 2 + LEN_PMKID))
+ {
+ // Skip RSN capability and PMKID-Count
+ pBuf += (sizeof(RSN_CAPABILITIES) + 2);
+ len -= (sizeof(RSN_CAPABILITIES) + 2);
+
+ // Get PMKID
+ if (type == PMKID_LIST)
+ {
+ *count = 1;
+ return pBuf;
+ }
+ }
+ else
+ {
+ DBGPRINT_ERR(("%s : it can't get any more information beyond AKM \n", __FUNCTION__));
+ return NULL;
+ }
+
+ *count = 0;
+ //DBGPRINT_ERR(("%s : The type(%d) doesn't support \n", __FUNCTION__, type));
+ return NULL;
+
+}
+
+VOID WpaShowAllsuite(
+ IN PUINT8 rsnie,
+ IN UINT rsnie_len)
+{
+ PUINT8 pSuite = NULL;
+ UINT8 count;
+
+ hex_dump("RSNIE", rsnie, rsnie_len);
+
+ // group cipher
+ if ((pSuite = GetSuiteFromRSNIE(rsnie, rsnie_len, GROUP_SUITE, &count)) != NULL)
+ {
+ hex_dump("group cipher", pSuite, 4*count);
+ }
+
+ // pairwise cipher
+ if ((pSuite = GetSuiteFromRSNIE(rsnie, rsnie_len, PAIRWISE_SUITE, &count)) != NULL)
+ {
+ hex_dump("pairwise cipher", pSuite, 4*count);
+ }
+
+ // AKM
+ if ((pSuite = GetSuiteFromRSNIE(rsnie, rsnie_len, AKM_SUITE, &count)) != NULL)
+ {
+ hex_dump("AKM suite", pSuite, 4*count);
+ }
+
+ // PMKID
+ if ((pSuite = GetSuiteFromRSNIE(rsnie, rsnie_len, PMKID_LIST, &count)) != NULL)
+ {
+ hex_dump("PMKID", pSuite, LEN_PMKID);
+ }
+
+}
+
+VOID RTMPInsertRSNIE(
+ IN PUCHAR pFrameBuf,
+ OUT PULONG pFrameLen,
+ IN PUINT8 rsnie_ptr,
+ IN UINT8 rsnie_len,
+ IN PUINT8 pmkid_ptr,
+ IN UINT8 pmkid_len)
+{
+ PUCHAR pTmpBuf;
+ ULONG TempLen = 0;
+ UINT8 extra_len = 0;
+ UINT16 pmk_count = 0;
+ UCHAR ie_num;
+ UINT8 total_len = 0;
+ UCHAR WPA2_OUI[3]={0x00,0x0F,0xAC};
+
+ pTmpBuf = pFrameBuf;
+
+ /* PMKID-List Must larger than 0 and the multiple of 16. */
+ if (pmkid_len > 0 && ((pmkid_len & 0x0f) == 0))
+ {
+ extra_len = sizeof(UINT16) + pmkid_len;
+
+ pmk_count = (pmkid_len >> 4);
+ pmk_count = cpu2le16(pmk_count);
+ }
+ else
+ {
+ DBGPRINT(RT_DEBUG_WARN, ("%s : The length is PMKID-List is invalid (%d), so don't insert it.\n",
+ __FUNCTION__, pmkid_len));
+ }
+
+ if (rsnie_len != 0)
+ {
+ ie_num = IE_WPA;
+ total_len = rsnie_len;
+
+ if (NdisEqualMemory(rsnie_ptr + 2, WPA2_OUI, sizeof(WPA2_OUI)))
+ {
+ ie_num = IE_RSN;
+ total_len += extra_len;
+ }
+
+ /* construct RSNIE body */
+ MakeOutgoingFrame(pTmpBuf, &TempLen,
+ 1, &ie_num,
+ 1, &total_len,
+ rsnie_len, rsnie_ptr,
+ END_OF_ARGS);
+
+ pTmpBuf += TempLen;
+ *pFrameLen = *pFrameLen + TempLen;
+
+ if (ie_num == IE_RSN)
+ {
+ /* Insert PMKID-List field */
+ if (extra_len > 0)
+ {
+ MakeOutgoingFrame(pTmpBuf, &TempLen,
+ 2, &pmk_count,
+ pmkid_len, pmkid_ptr,
+ END_OF_ARGS);
+
+ pTmpBuf += TempLen;
+ *pFrameLen = *pFrameLen + TempLen;
+ }
+ }
+ }
+
+ return;
+}
diff --git a/drivers/staging/rt3090/common/crypt_aes.c b/drivers/staging/rt3090/common/crypt_aes.c
new file mode 100644
index 000000000000..f400f1eab516
--- /dev/null
+++ b/drivers/staging/rt3090/common/crypt_aes.c
@@ -0,0 +1,1007 @@
+/*
+ *************************************************************************
+ * 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:
+ crypt_aes.c
+
+ Abstract:
+
+ Revision History:
+ Who When What
+ -------- ---------- ----------------------------------------------
+ Eddy 2009/01/19 Create AES-128, AES-192, AES-256, AES-CBC
+*/
+
+#include "crypt_aes.h"
+
+/* The value given by [x^(i-1),{00},{00},{00}], with x^(i-1) being powers of x in the field GF(2^8). */
+static const UINT32 aes_rcon[] = {
+ 0x00000000, 0x01000000, 0x02000000, 0x04000000,
+ 0x08000000, 0x10000000, 0x20000000, 0x40000000,
+ 0x80000000, 0x1B000000, 0x36000000};
+
+static const UINT8 aes_sbox_enc[] = {
+ /* 0 1 2 3 4 5 6 7 8 9 a b c d e f */
+ 0x63, 0x7c, 0x77, 0x7b, 0xf2, 0x6b, 0x6f, 0xc5, 0x30, 0x01, 0x67, 0x2b, 0xfe, 0xd7 ,0xab, 0x76, /* 0 */
+ 0xca, 0x82, 0xc9, 0x7d, 0xfa, 0x59, 0x47, 0xf0, 0xad, 0xd4, 0xa2, 0xaf, 0x9c, 0xa4 ,0x72, 0xc0, /* 1 */
+ 0xb7, 0xfd, 0x93, 0x26, 0x36, 0x3f, 0xf7, 0xcc, 0x34, 0xa5, 0xe5, 0xf1, 0x71, 0xd8 ,0x31, 0x15, /* 2 */
+ 0x04, 0xc7, 0x23, 0xc3, 0x18, 0x96, 0x05, 0x9a, 0x07, 0x12, 0x80, 0xe2, 0xeb, 0x27 ,0xb2, 0x75, /* 3 */
+ 0x09, 0x83, 0x2c, 0x1a, 0x1b, 0x6e, 0x5a, 0xa0, 0x52, 0x3b, 0xd6, 0xb3, 0x29, 0xe3 ,0x2f, 0x84, /* 4 */
+ 0x53, 0xd1, 0x00, 0xed, 0x20, 0xfc, 0xb1, 0x5b, 0x6a, 0xcb, 0xbe, 0x39, 0x4a, 0x4c ,0x58, 0xcf, /* 5 */
+ 0xd0, 0xef, 0xaa, 0xfb, 0x43, 0x4d, 0x33, 0x85, 0x45, 0xf9, 0x02, 0x7f, 0x50, 0x3c ,0x9f, 0xa8, /* 6 */
+ 0x51, 0xa3, 0x40, 0x8f, 0x92, 0x9d, 0x38, 0xf5, 0xbc, 0xb6, 0xda, 0x21, 0x10, 0xff ,0xf3, 0xd2, /* 7 */
+ 0xcd, 0x0c, 0x13, 0xec, 0x5f, 0x97, 0x44, 0x17, 0xc4, 0xa7, 0x7e, 0x3d, 0x64, 0x5d ,0x19, 0x73, /* 8 */
+ 0x60, 0x81, 0x4f, 0xdc, 0x22, 0x2a, 0x90, 0x88, 0x46, 0xee, 0xb8, 0x14, 0xde, 0x5e ,0x0b, 0xdb, /* 9 */
+ 0xe0, 0x32, 0x3a, 0x0a, 0x49, 0x06, 0x24, 0x5c, 0xc2, 0xd3, 0xac, 0x62, 0x91, 0x95 ,0xe4, 0x79, /* a */
+ 0xe7, 0xc8, 0x37, 0x6d, 0x8d, 0xd5, 0x4e, 0xa9, 0x6c, 0x56, 0xf4, 0xea, 0x65, 0x7a ,0xae, 0x08, /* b */
+ 0xba, 0x78, 0x25, 0x2e, 0x1c, 0xa6, 0xb4, 0xc6, 0xe8, 0xdd, 0x74, 0x1f, 0x4b, 0xbd ,0x8b, 0x8a, /* c */
+ 0x70, 0x3e, 0xb5, 0x66, 0x48, 0x03, 0xf6, 0x0e, 0x61, 0x35, 0x57, 0xb9, 0x86, 0xc1 ,0x1d, 0x9e, /* d */
+ 0xe1, 0xf8, 0x98, 0x11, 0x69, 0xd9, 0x8e, 0x94, 0x9b, 0x1e, 0x87, 0xe9, 0xce, 0x55 ,0x28, 0xdf, /* e */
+ 0x8c, 0xa1, 0x89, 0x0d, 0xbf, 0xe6, 0x42, 0x68, 0x41, 0x99, 0x2d, 0x0f, 0xb0, 0x54 ,0xbb, 0x16, /* f */
+};
+
+static const UINT8 aes_sbox_dec[] = {
+ /* 0 1 2 3 4 5 6 7 8 9 a b c d e f */
+ 0x52, 0x09, 0x6a, 0xd5, 0x30, 0x36, 0xa5, 0x38, 0xbf, 0x40, 0xa3, 0x9e, 0x81, 0xf3, 0xd7, 0xfb, /* 0 */
+ 0x7c, 0xe3, 0x39, 0x82, 0x9b, 0x2f, 0xff, 0x87, 0x34, 0x8e, 0x43, 0x44, 0xc4, 0xde, 0xe9, 0xcb, /* 1 */
+ 0x54, 0x7b, 0x94, 0x32, 0xa6, 0xc2, 0x23, 0x3d, 0xee, 0x4c, 0x95, 0x0b, 0x42, 0xfa, 0xc3, 0x4e, /* 2 */
+ 0x08, 0x2e, 0xa1, 0x66, 0x28, 0xd9, 0x24, 0xb2, 0x76, 0x5b, 0xa2, 0x49, 0x6d, 0x8b, 0xd1, 0x25, /* 3 */
+ 0x72, 0xf8, 0xf6, 0x64, 0x86, 0x68, 0x98, 0x16, 0xd4, 0xa4, 0x5c, 0xcc, 0x5d, 0x65, 0xb6, 0x92, /* 4 */
+ 0x6c, 0x70, 0x48, 0x50, 0xfd, 0xed, 0xb9, 0xda, 0x5e, 0x15, 0x46, 0x57, 0xa7, 0x8d, 0x9d, 0x84, /* 5 */
+ 0x90, 0xd8, 0xab, 0x00, 0x8c, 0xbc, 0xd3, 0x0a, 0xf7, 0xe4, 0x58, 0x05, 0xb8, 0xb3, 0x45, 0x06, /* 6 */
+ 0xd0, 0x2c, 0x1e, 0x8f, 0xca, 0x3f, 0x0f, 0x02, 0xc1, 0xaf, 0xbd, 0x03, 0x01, 0x13, 0x8a, 0x6b, /* 7 */
+ 0x3a, 0x91, 0x11, 0x41, 0x4f, 0x67, 0xdc, 0xea, 0x97, 0xf2, 0xcf, 0xce, 0xf0, 0xb4, 0xe6, 0x73, /* 8 */
+ 0x96, 0xac, 0x74, 0x22, 0xe7, 0xad, 0x35, 0x85, 0xe2, 0xf9, 0x37, 0xe8, 0x1c, 0x75, 0xdf, 0x6e, /* 9 */
+ 0x47, 0xf1, 0x1a, 0x71, 0x1d, 0x29, 0xc5, 0x89, 0x6f, 0xb7, 0x62, 0x0e, 0xaa, 0x18, 0xbe, 0x1b, /* a */
+ 0xfc, 0x56, 0x3e, 0x4b, 0xc6, 0xd2, 0x79, 0x20, 0x9a, 0xdb, 0xc0, 0xfe, 0x78, 0xcd, 0x5a, 0xf4, /* b */
+ 0x1f, 0xdd, 0xa8, 0x33, 0x88, 0x07, 0xc7, 0x31, 0xb1, 0x12, 0x10, 0x59, 0x27, 0x80, 0xec, 0x5f, /* c */
+ 0x60, 0x51, 0x7f, 0xa9, 0x19, 0xb5, 0x4a, 0x0d, 0x2d, 0xe5, 0x7a, 0x9f, 0x93, 0xc9, 0x9c, 0xef, /* d */
+ 0xa0, 0xe0, 0x3b, 0x4d, 0xae, 0x2a, 0xf5, 0xb0, 0xc8, 0xeb, 0xbb, 0x3c, 0x83, 0x53, 0x99, 0x61, /* e */
+ 0x17, 0x2b, 0x04, 0x7e, 0xba, 0x77, 0xd6, 0x26, 0xe1, 0x69, 0x14, 0x63, 0x55, 0x21, 0x0c, 0x7d, /* f */
+};
+
+/* ArrayIndex*{02} */
+static const UINT8 aes_mul_2[] = {
+ /* 0 1 2 3 4 5 6 7 8 9 a b c d e f */
+ 0x00, 0x02, 0x04, 0x06, 0x08, 0x0a, 0x0c, 0x0e, 0x10, 0x12, 0x14, 0x16, 0x18, 0x1a, 0x1c, 0x1e, /* 0 */
+ 0x20, 0x22, 0x24, 0x26, 0x28, 0x2a, 0x2c, 0x2e, 0x30, 0x32, 0x34, 0x36, 0x38, 0x3a, 0x3c, 0x3e, /* 1 */
+ 0x40, 0x42, 0x44, 0x46, 0x48, 0x4a, 0x4c, 0x4e, 0x50, 0x52, 0x54, 0x56, 0x58, 0x5a, 0x5c, 0x5e, /* 2 */
+ 0x60, 0x62, 0x64, 0x66, 0x68, 0x6a, 0x6c, 0x6e, 0x70, 0x72, 0x74, 0x76, 0x78, 0x7a, 0x7c, 0x7e, /* 3 */
+ 0x80, 0x82, 0x84, 0x86, 0x88, 0x8a, 0x8c, 0x8e, 0x90, 0x92, 0x94, 0x96, 0x98, 0x9a, 0x9c, 0x9e, /* 4 */
+ 0xa0, 0xa2, 0xa4, 0xa6, 0xa8, 0xaa, 0xac, 0xae, 0xb0, 0xb2, 0xb4, 0xb6, 0xb8, 0xba, 0xbc, 0xbe, /* 5 */
+ 0xc0, 0xc2, 0xc4, 0xc6, 0xc8, 0xca, 0xcc, 0xce, 0xd0, 0xd2, 0xd4, 0xd6, 0xd8, 0xda, 0xdc, 0xde, /* 6 */
+ 0xe0, 0xe2, 0xe4, 0xe6, 0xe8, 0xea, 0xec, 0xee, 0xf0, 0xf2, 0xf4, 0xf6, 0xf8, 0xfa, 0xfc, 0xfe, /* 7 */
+ 0x1b, 0x19, 0x1f, 0x1d, 0x13, 0x11, 0x17, 0x15, 0x0b, 0x09, 0x0f, 0x0d, 0x03, 0x01, 0x07, 0x05, /* 8 */
+ 0x3b, 0x39, 0x3f, 0x3d, 0x33, 0x31, 0x37, 0x35, 0x2b, 0x29, 0x2f, 0x2d, 0x23, 0x21, 0x27, 0x25, /* 9 */
+ 0x5b, 0x59, 0x5f, 0x5d, 0x53, 0x51, 0x57, 0x55, 0x4b, 0x49, 0x4f, 0x4d, 0x43, 0x41, 0x47, 0x45, /* a */
+ 0x7b, 0x79, 0x7f, 0x7d, 0x73, 0x71, 0x77, 0x75, 0x6b, 0x69, 0x6f, 0x6d, 0x63, 0x61, 0x67, 0x65, /* b */
+ 0x9b, 0x99, 0x9f, 0x9d, 0x93, 0x91, 0x97, 0x95, 0x8b, 0x89, 0x8f, 0x8d, 0x83, 0x81, 0x87, 0x85, /* c */
+ 0xbb, 0xb9, 0xbf, 0xbd, 0xb3, 0xb1, 0xb7, 0xb5, 0xab, 0xa9, 0xaf, 0xad, 0xa3, 0xa1, 0xa7, 0xa5, /* d */
+ 0xdb, 0xd9, 0xdf, 0xdd, 0xd3, 0xd1, 0xd7, 0xd5, 0xcb, 0xc9, 0xcf, 0xcd, 0xc3, 0xc1, 0xc7, 0xc5, /* e */
+ 0xfb, 0xf9, 0xff, 0xfd, 0xf3, 0xf1, 0xf7, 0xf5, 0xeb, 0xe9, 0xef, 0xed, 0xe3, 0xe1, 0xe7, 0xe5, /* f */
+};
+
+/* ArrayIndex*{03} */
+static const UINT8 aes_mul_3[] = {
+ /* 0 1 2 3 4 5 6 7 8 9 a b c d e f */
+ 0x00, 0x03, 0x06, 0x05, 0x0c, 0x0f, 0x0a, 0x09, 0x18, 0x1b, 0x1e, 0x1d, 0x14, 0x17, 0x12, 0x11, /* 0 */
+ 0x30, 0x33, 0x36, 0x35, 0x3c, 0x3f, 0x3a, 0x39, 0x28, 0x2b, 0x2e, 0x2d, 0x24, 0x27, 0x22, 0x21, /* 1 */
+ 0x60, 0x63, 0x66, 0x65, 0x6c, 0x6f, 0x6a, 0x69, 0x78, 0x7b, 0x7e, 0x7d, 0x74, 0x77, 0x72, 0x71, /* 2 */
+ 0x50, 0x53, 0x56, 0x55, 0x5c, 0x5f, 0x5a, 0x59, 0x48, 0x4b, 0x4e, 0x4d, 0x44, 0x47, 0x42, 0x41, /* 3 */
+ 0xc0, 0xc3, 0xc6, 0xc5, 0xcc, 0xcf, 0xca, 0xc9, 0xd8, 0xdb, 0xde, 0xdd, 0xd4, 0xd7, 0xd2, 0xd1, /* 4 */
+ 0xf0, 0xf3, 0xf6, 0xf5, 0xfc, 0xff, 0xfa, 0xf9, 0xe8, 0xeb, 0xee, 0xed, 0xe4, 0xe7, 0xe2, 0xe1, /* 5 */
+ 0xa0, 0xa3, 0xa6, 0xa5, 0xac, 0xaf, 0xaa, 0xa9, 0xb8, 0xbb, 0xbe, 0xbd, 0xb4, 0xb7, 0xb2, 0xb1, /* 6 */
+ 0x90, 0x93, 0x96, 0x95, 0x9c, 0x9f, 0x9a, 0x99, 0x88, 0x8b, 0x8e, 0x8d, 0x84, 0x87, 0x82, 0x81, /* 7 */
+ 0x9b, 0x98, 0x9d, 0x9e, 0x97, 0x94, 0x91, 0x92, 0x83, 0x80, 0x85, 0x86, 0x8f, 0x8c, 0x89, 0x8a, /* 8 */
+ 0xab, 0xa8, 0xad, 0xae, 0xa7, 0xa4, 0xa1, 0xa2, 0xb3, 0xb0, 0xb5, 0xb6, 0xbf, 0xbc, 0xb9, 0xba, /* 9 */
+ 0xfb, 0xf8, 0xfd, 0xfe, 0xf7, 0xf4, 0xf1, 0xf2, 0xe3, 0xe0, 0xe5, 0xe6, 0xef, 0xec, 0xe9, 0xea, /* a */
+ 0xcb, 0xc8, 0xcd, 0xce, 0xc7, 0xc4, 0xc1, 0xc2, 0xd3, 0xd0, 0xd5, 0xd6, 0xdf, 0xdc, 0xd9, 0xda, /* b */
+ 0x5b, 0x58, 0x5d, 0x5e, 0x57, 0x54, 0x51, 0x52, 0x43, 0x40, 0x45, 0x46, 0x4f, 0x4c, 0x49, 0x4a, /* c */
+ 0x6b, 0x68, 0x6d, 0x6e, 0x67, 0x64, 0x61, 0x62, 0x73, 0x70, 0x75, 0x76, 0x7f, 0x7c, 0x79, 0x7a, /* d */
+ 0x3b, 0x38, 0x3d, 0x3e, 0x37, 0x34, 0x31, 0x32, 0x23, 0x20, 0x25, 0x26, 0x2f, 0x2c, 0x29, 0x2a, /* e */
+ 0x0b, 0x08, 0x0d, 0x0e, 0x07, 0x04, 0x01, 0x02, 0x13, 0x10, 0x15, 0x16, 0x1f, 0x1c, 0x19, 0x1a, /* f */
+};
+
+/* ArrayIndex*{09} */
+static const UINT8 aes_mul_9[] = {
+ /* 0 1 2 3 4 5 6 7 8 9 a b c d e f */
+ 0x00, 0x09, 0x12, 0x1b, 0x24, 0x2d, 0x36, 0x3f, 0x48, 0x41, 0x5a, 0x53, 0x6c, 0x65, 0x7e, 0x77, /* 0 */
+ 0x90, 0x99, 0x82, 0x8b, 0xb4, 0xbd, 0xa6, 0xaf, 0xd8, 0xd1, 0xca, 0xc3, 0xfc, 0xf5, 0xee, 0xe7, /* 1 */
+ 0x3b, 0x32, 0x29, 0x20, 0x1f, 0x16, 0x0d, 0x04, 0x73, 0x7a, 0x61, 0x68, 0x57, 0x5e, 0x45, 0x4c, /* 2 */
+ 0xab, 0xa2, 0xb9, 0xb0, 0x8f, 0x86, 0x9d, 0x94, 0xe3, 0xea, 0xf1, 0xf8, 0xc7, 0xce, 0xd5, 0xdc, /* 3 */
+ 0x76, 0x7f, 0x64, 0x6d, 0x52, 0x5b, 0x40, 0x49, 0x3e, 0x37, 0x2c, 0x25, 0x1a, 0x13, 0x08, 0x01, /* 4 */
+ 0xe6, 0xef, 0xf4, 0xfd, 0xc2, 0xcb, 0xd0, 0xd9, 0xae, 0xa7, 0xbc, 0xb5, 0x8a, 0x83, 0x98, 0x91, /* 5 */
+ 0x4d, 0x44, 0x5f, 0x56, 0x69, 0x60, 0x7b, 0x72, 0x05, 0x0c, 0x17, 0x1e, 0x21, 0x28, 0x33, 0x3a, /* 6 */
+ 0xdd, 0xd4, 0xcf, 0xc6, 0xf9, 0xf0, 0xeb, 0xe2, 0x95, 0x9c, 0x87, 0x8e, 0xb1, 0xb8, 0xa3, 0xaa, /* 7 */
+ 0xec, 0xe5, 0xfe, 0xf7, 0xc8, 0xc1, 0xda, 0xd3, 0xa4, 0xad, 0xb6, 0xbf, 0x80, 0x89, 0x92, 0x9b, /* 8 */
+ 0x7c, 0x75, 0x6e, 0x67, 0x58, 0x51, 0x4a, 0x43, 0x34, 0x3d, 0x26, 0x2f, 0x10, 0x19, 0x02, 0x0b, /* 9 */
+ 0xd7, 0xde, 0xc5, 0xcc, 0xf3, 0xfa, 0xe1, 0xe8, 0x9f, 0x96, 0x8d, 0x84, 0xbb, 0xb2, 0xa9, 0xa0, /* a */
+ 0x47, 0x4e, 0x55, 0x5c, 0x63, 0x6a, 0x71, 0x78, 0x0f, 0x06, 0x1d, 0x14, 0x2b, 0x22, 0x39, 0x30, /* b */
+ 0x9a, 0x93, 0x88, 0x81, 0xbe, 0xb7, 0xac, 0xa5, 0xd2, 0xdb, 0xc0, 0xc9, 0xf6, 0xff, 0xe4, 0xed, /* c */
+ 0x0a, 0x03, 0x18, 0x11, 0x2e, 0x27, 0x3c, 0x35, 0x42, 0x4b, 0x50, 0x59, 0x66, 0x6f, 0x74, 0x7d, /* d */
+ 0xa1, 0xa8, 0xb3, 0xba, 0x85, 0x8c, 0x97, 0x9e, 0xe9, 0xe0, 0xfb, 0xf2, 0xcd, 0xc4, 0xdf, 0xd6, /* e */
+ 0x31, 0x38, 0x23, 0x2a, 0x15, 0x1c, 0x07, 0x0e, 0x79, 0x70, 0x6b, 0x62, 0x5d, 0x54, 0x4f, 0x46, /* f */
+};
+
+/* ArrayIndex*{0b} */
+static const UINT8 aes_mul_b[] = {
+ /* 0 1 2 3 4 5 6 7 8 9 a b c d e f */
+ 0x00, 0x0b, 0x16, 0x1d, 0x2c, 0x27, 0x3a, 0x31, 0x58, 0x53, 0x4e, 0x45, 0x74, 0x7f, 0x62, 0x69, /* 0 */
+ 0xb0, 0xbb, 0xa6, 0xad, 0x9c, 0x97, 0x8a, 0x81, 0xe8, 0xe3, 0xfe, 0xf5, 0xc4, 0xcf, 0xd2, 0xd9, /* 1 */
+ 0x7b, 0x70, 0x6d, 0x66, 0x57, 0x5c, 0x41, 0x4a, 0x23, 0x28, 0x35, 0x3e, 0x0f, 0x04, 0x19, 0x12, /* 2 */
+ 0xcb, 0xc0, 0xdd, 0xd6, 0xe7, 0xec, 0xf1, 0xfa, 0x93, 0x98, 0x85, 0x8e, 0xbf, 0xb4, 0xa9, 0xa2, /* 3 */
+ 0xf6, 0xfd, 0xe0, 0xeb, 0xda, 0xd1, 0xcc, 0xc7, 0xae, 0xa5, 0xb8, 0xb3, 0x82, 0x89, 0x94, 0x9f, /* 4 */
+ 0x46, 0x4d, 0x50, 0x5b, 0x6a, 0x61, 0x7c, 0x77, 0x1e, 0x15, 0x08, 0x03, 0x32, 0x39, 0x24, 0x2f, /* 5 */
+ 0x8d, 0x86, 0x9b, 0x90, 0xa1, 0xaa, 0xb7, 0xbc, 0xd5, 0xde, 0xc3, 0xc8, 0xf9, 0xf2, 0xef, 0xe4, /* 6 */
+ 0x3d, 0x36, 0x2b, 0x20, 0x11, 0x1a, 0x07, 0x0c, 0x65, 0x6e, 0x73, 0x78, 0x49, 0x42, 0x5f, 0x54, /* 7 */
+ 0xf7, 0xfc, 0xe1, 0xea, 0xdb, 0xd0, 0xcd, 0xc6, 0xaf, 0xa4, 0xb9, 0xb2, 0x83, 0x88, 0x95, 0x9e, /* 8 */
+ 0x47, 0x4c, 0x51, 0x5a, 0x6b, 0x60, 0x7d, 0x76, 0x1f, 0x14, 0x09, 0x02, 0x33, 0x38, 0x25, 0x2e, /* 9 */
+ 0x8c, 0x87, 0x9a, 0x91, 0xa0, 0xab, 0xb6, 0xbd, 0xd4, 0xdf, 0xc2, 0xc9, 0xf8, 0xf3, 0xee, 0xe5, /* a */
+ 0x3c, 0x37, 0x2a, 0x21, 0x10, 0x1b, 0x06, 0x0d, 0x64, 0x6f, 0x72, 0x79, 0x48, 0x43, 0x5e, 0x55, /* b */
+ 0x01, 0x0a, 0x17, 0x1c, 0x2d, 0x26, 0x3b, 0x30, 0x59, 0x52, 0x4f, 0x44, 0x75, 0x7e, 0x63, 0x68, /* c */
+ 0xb1, 0xba, 0xa7, 0xac, 0x9d, 0x96, 0x8b, 0x80, 0xe9, 0xe2, 0xff, 0xf4, 0xc5, 0xce, 0xd3, 0xd8, /* d */
+ 0x7a, 0x71, 0x6c, 0x67, 0x56, 0x5d, 0x40, 0x4b, 0x22, 0x29, 0x34, 0x3f, 0x0e, 0x05, 0x18, 0x13, /* e */
+ 0xca, 0xc1, 0xdc, 0xd7, 0xe6, 0xed, 0xf0, 0xfb, 0x92, 0x99, 0x84, 0x8f, 0xbe, 0xb5, 0xa8, 0xa3, /* f */
+};
+
+/* ArrayIndex*{0d} */
+static const UINT8 aes_mul_d[] = {
+ /* 0 1 2 3 4 5 6 7 8 9 a b c d e f */
+ 0x00, 0x0d, 0x1a, 0x17, 0x34, 0x39, 0x2e, 0x23, 0x68, 0x65, 0x72, 0x7f, 0x5c, 0x51, 0x46, 0x4b, /* 0 */
+ 0xd0, 0xdd, 0xca, 0xc7, 0xe4, 0xe9, 0xfe, 0xf3, 0xb8, 0xb5, 0xa2, 0xaf, 0x8c, 0x81, 0x96, 0x9b, /* 1 */
+ 0xbb, 0xb6, 0xa1, 0xac, 0x8f, 0x82, 0x95, 0x98, 0xd3, 0xde, 0xc9, 0xc4, 0xe7, 0xea, 0xfd, 0xf0, /* 2 */
+ 0x6b, 0x66, 0x71, 0x7c, 0x5f, 0x52, 0x45, 0x48, 0x03, 0x0e, 0x19, 0x14, 0x37, 0x3a, 0x2d, 0x20, /* 3 */
+ 0x6d, 0x60, 0x77, 0x7a, 0x59, 0x54, 0x43, 0x4e, 0x05, 0x08, 0x1f, 0x12, 0x31, 0x3c, 0x2b, 0x26, /* 4 */
+ 0xbd, 0xb0, 0xa7, 0xaa, 0x89, 0x84, 0x93, 0x9e, 0xd5, 0xd8, 0xcf, 0xc2, 0xe1, 0xec, 0xfb, 0xf6, /* 5 */
+ 0xd6, 0xdb, 0xcc, 0xc1, 0xe2, 0xef, 0xf8, 0xf5, 0xbe, 0xb3, 0xa4, 0xa9, 0x8a, 0x87, 0x90, 0x9d, /* 6 */
+ 0x06, 0x0b, 0x1c, 0x11, 0x32, 0x3f, 0x28, 0x25, 0x6e, 0x63, 0x74, 0x79, 0x5a, 0x57, 0x40, 0x4d, /* 7 */
+ 0xda, 0xd7, 0xc0, 0xcd, 0xee, 0xe3, 0xf4, 0xf9, 0xb2, 0xbf, 0xa8, 0xa5, 0x86, 0x8b, 0x9c, 0x91, /* 8 */
+ 0x0a, 0x07, 0x10, 0x1d, 0x3e, 0x33, 0x24, 0x29, 0x62, 0x6f, 0x78, 0x75, 0x56, 0x5b, 0x4c, 0x41, /* 9 */
+ 0x61, 0x6c, 0x7b, 0x76, 0x55, 0x58, 0x4f, 0x42, 0x09, 0x04, 0x13, 0x1e, 0x3d, 0x30, 0x27, 0x2a, /* a */
+ 0xb1, 0xbc, 0xab, 0xa6, 0x85, 0x88, 0x9f, 0x92, 0xd9, 0xd4, 0xc3, 0xce, 0xed, 0xe0, 0xf7, 0xfa, /* b */
+ 0xb7, 0xba, 0xad, 0xa0, 0x83, 0x8e, 0x99, 0x94, 0xdf, 0xd2, 0xc5, 0xc8, 0xeb, 0xe6, 0xf1, 0xfc, /* c */
+ 0x67, 0x6a, 0x7d, 0x70, 0x53, 0x5e, 0x49, 0x44, 0x0f, 0x02, 0x15, 0x18, 0x3b, 0x36, 0x21, 0x2c, /* d */
+ 0x0c, 0x01, 0x16, 0x1b, 0x38, 0x35, 0x22, 0x2f, 0x64, 0x69, 0x7e, 0x73, 0x50, 0x5d, 0x4a, 0x47, /* e */
+ 0xdc, 0xd1, 0xc6, 0xcb, 0xe8, 0xe5, 0xf2, 0xff, 0xb4, 0xb9, 0xae, 0xa3, 0x80, 0x8d, 0x9a, 0x97, /* f */
+};
+
+/* ArrayIndex*{0e} */
+static const UINT8 aes_mul_e[] = {
+ /* 0 1 2 3 4 5 6 7 8 9 a b c d e f */
+ 0x00, 0x0e, 0x1c, 0x12, 0x38, 0x36, 0x24, 0x2a, 0x70, 0x7e, 0x6c, 0x62, 0x48, 0x46, 0x54, 0x5a, /* 0 */
+ 0xe0, 0xee, 0xfc, 0xf2, 0xd8, 0xd6, 0xc4, 0xca, 0x90, 0x9e, 0x8c, 0x82, 0xa8, 0xa6, 0xb4, 0xba, /* 1 */
+ 0xdb, 0xd5, 0xc7, 0xc9, 0xe3, 0xed, 0xff, 0xf1, 0xab, 0xa5, 0xb7, 0xb9, 0x93, 0x9d, 0x8f, 0x81, /* 2 */
+ 0x3b, 0x35, 0x27, 0x29, 0x03, 0x0d, 0x1f, 0x11, 0x4b, 0x45, 0x57, 0x59, 0x73, 0x7d, 0x6f, 0x61, /* 3 */
+ 0xad, 0xa3, 0xb1, 0xbf, 0x95, 0x9b, 0x89, 0x87, 0xdd, 0xd3, 0xc1, 0xcf, 0xe5, 0xeb, 0xf9, 0xf7, /* 4 */
+ 0x4d, 0x43, 0x51, 0x5f, 0x75, 0x7b, 0x69, 0x67, 0x3d, 0x33, 0x21, 0x2f, 0x05, 0x0b, 0x19, 0x17, /* 5 */
+ 0x76, 0x78, 0x6a, 0x64, 0x4e, 0x40, 0x52, 0x5c, 0x06, 0x08, 0x1a, 0x14, 0x3e, 0x30, 0x22, 0x2c, /* 6 */
+ 0x96, 0x98, 0x8a, 0x84, 0xae, 0xa0, 0xb2, 0xbc, 0xe6, 0xe8, 0xfa, 0xf4, 0xde, 0xd0, 0xc2, 0xcc, /* 7 */
+ 0x41, 0x4f, 0x5d, 0x53, 0x79, 0x77, 0x65, 0x6b, 0x31, 0x3f, 0x2d, 0x23, 0x09, 0x07, 0x15, 0x1b, /* 8 */
+ 0xa1, 0xaf, 0xbd, 0xb3, 0x99, 0x97, 0x85, 0x8b, 0xd1, 0xdf, 0xcd, 0xc3, 0xe9, 0xe7, 0xf5, 0xfb, /* 9 */
+ 0x9a, 0x94, 0x86, 0x88, 0xa2, 0xac, 0xbe, 0xb0, 0xea, 0xe4, 0xf6, 0xf8, 0xd2, 0xdc, 0xce, 0xc0, /* a */
+ 0x7a, 0x74, 0x66, 0x68, 0x42, 0x4c, 0x5e, 0x50, 0x0a, 0x04, 0x16, 0x18, 0x32, 0x3c, 0x2e, 0x20, /* b */
+ 0xec, 0xe2, 0xf0, 0xfe, 0xd4, 0xda, 0xc8, 0xc6, 0x9c, 0x92, 0x80, 0x8e, 0xa4, 0xaa, 0xb8, 0xb6, /* c */
+ 0x0c, 0x02, 0x10, 0x1e, 0x34, 0x3a, 0x28, 0x26, 0x7c, 0x72, 0x60, 0x6e, 0x44, 0x4a, 0x58, 0x56, /* d */
+ 0x37, 0x39, 0x2b, 0x25, 0x0f, 0x01, 0x13, 0x1d, 0x47, 0x49, 0x5b, 0x55, 0x7f, 0x71, 0x63, 0x6d, /* e */
+ 0xd7, 0xd9, 0xcb, 0xc5, 0xef, 0xe1, 0xf3, 0xfd, 0xa7, 0xa9, 0xbb, 0xb5, 0x9f, 0x91, 0x83, 0x8d, /* f */
+};
+
+
+/* For AES_CMAC */
+#define AES_MAC_LENGTH 16 /* 128-bit string */
+static UINT8 Const_Zero[16] = {
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00};
+static UINT8 Const_Rb[16] = {
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x87};
+
+
+/*
+========================================================================
+Routine Description:
+ AES key expansion (key schedule)
+
+Arguments:
+ Key Cipher key, it may be 16, 24, or 32 bytes (128, 192, or 256 bits)
+ KeyLength The length of cipher key in bytes
+ paes_ctx Pointer to AES_CTX_STRUC
+
+Return Value:
+ paes_ctx Retrun the KeyWordExpansion of AES_CTX_STRUC
+
+Note:
+ Pseudo code for key expansion
+ ------------------------------------------
+ Nk = (key length/4);
+
+ while (i < Nk)
+ KeyWordExpansion[i] = word(key[4*i], key[4*i + 1], key[4*i + 2], key[4*i + 3]);
+ i++;
+ end while
+
+ while (i < ((key length/4 + 6 + 1)*4) )
+ temp = KeyWordExpansion[i - 1];
+ if (i % Nk ==0)
+ temp = SubWord(RotWord(temp)) ^ Rcon[i/Nk];
+ else if ((Nk > 6) && (i % 4 == 4))
+ temp = SubWord(temp);
+ end if
+
+ KeyWordExpansion[i] = KeyWordExpansion[i - Nk]^ temp;
+ i++;
+ end while
+========================================================================
+*/
+VOID AES_KeyExpansion (
+ IN UINT8 Key[],
+ IN UINT KeyLength,
+ INOUT AES_CTX_STRUC *paes_ctx)
+{
+ UINT KeyIndex = 0;
+ UINT NumberOfWordOfKey, NumberOfWordOfKeyExpansion;
+ UINT8 TempWord[AES_KEY_ROWS], Temp;
+ UINT32 Temprcon;
+
+ NumberOfWordOfKey = KeyLength >> 2;
+ while (KeyIndex < NumberOfWordOfKey)
+ {
+ paes_ctx->KeyWordExpansion[0][KeyIndex] = Key[4*KeyIndex];
+ paes_ctx->KeyWordExpansion[1][KeyIndex] = Key[4*KeyIndex + 1];
+ paes_ctx->KeyWordExpansion[2][KeyIndex] = Key[4*KeyIndex + 2];
+ paes_ctx->KeyWordExpansion[3][KeyIndex] = Key[4*KeyIndex + 3];
+ KeyIndex++;
+ } /* End of while */
+
+ NumberOfWordOfKeyExpansion = ((UINT) AES_KEY_ROWS) * ((KeyLength >> 2) + 6 + 1);
+ while (KeyIndex < NumberOfWordOfKeyExpansion)
+ {
+ TempWord[0] = paes_ctx->KeyWordExpansion[0][KeyIndex - 1];
+ TempWord[1] = paes_ctx->KeyWordExpansion[1][KeyIndex - 1];
+ TempWord[2] = paes_ctx->KeyWordExpansion[2][KeyIndex - 1];
+ TempWord[3] = paes_ctx->KeyWordExpansion[3][KeyIndex - 1];
+ if ((KeyIndex % NumberOfWordOfKey) == 0) {
+ Temprcon = aes_rcon[KeyIndex/NumberOfWordOfKey];
+ Temp = aes_sbox_enc[TempWord[1]]^((Temprcon >> 24) & 0xff);
+ TempWord[1] = aes_sbox_enc[TempWord[2]]^((Temprcon >> 16) & 0xff);
+ TempWord[2] = aes_sbox_enc[TempWord[3]]^((Temprcon >> 8) & 0xff);
+ TempWord[3] = aes_sbox_enc[TempWord[0]]^((Temprcon ) & 0xff);
+ TempWord[0] = Temp;
+ } else if ((NumberOfWordOfKey > 6) && ((KeyIndex % NumberOfWordOfKey) == 4)) {
+ Temp = aes_sbox_enc[TempWord[0]];
+ TempWord[1] = aes_sbox_enc[TempWord[1]];
+ TempWord[2] = aes_sbox_enc[TempWord[2]];
+ TempWord[3] = aes_sbox_enc[TempWord[3]];
+ TempWord[0] = Temp;
+ }
+ paes_ctx->KeyWordExpansion[0][KeyIndex] = paes_ctx->KeyWordExpansion[0][KeyIndex - NumberOfWordOfKey]^TempWord[0];
+ paes_ctx->KeyWordExpansion[1][KeyIndex] = paes_ctx->KeyWordExpansion[1][KeyIndex - NumberOfWordOfKey]^TempWord[1];
+ paes_ctx->KeyWordExpansion[2][KeyIndex] = paes_ctx->KeyWordExpansion[2][KeyIndex - NumberOfWordOfKey]^TempWord[2];
+ paes_ctx->KeyWordExpansion[3][KeyIndex] = paes_ctx->KeyWordExpansion[3][KeyIndex - NumberOfWordOfKey]^TempWord[3];
+ KeyIndex++;
+ } /* End of while */
+} /* End of AES_KeyExpansion */
+
+
+/*
+========================================================================
+Routine Description:
+ AES encryption
+
+Arguments:
+ PlainBlock The block of plain text, 16 bytes(128 bits) each block
+ PlainBlockSize The length of block of plain text in bytes
+ Key Cipher key, it may be 16, 24, or 32 bytes (128, 192, or 256 bits)
+ KeyLength The length of cipher key in bytes
+ CipherBlockSize The length of allocated cipher block in bytes
+
+Return Value:
+ CipherBlock Return cipher text
+ CipherBlockSize Return the length of real used cipher block in bytes
+
+Note:
+ Reference to FIPS-PUB 197
+ 1. Check if block size is 16 bytes(128 bits) and if key length is 16, 24, or 32 bytes(128, 192, or 256 bits)
+ 2. Transfer the plain block to state block
+ 3. Main encryption rounds
+ 4. Transfer the state block to cipher block
+ ------------------------------------------
+ NumberOfRound = (key length / 4) + 6;
+ state block = plain block;
+
+ AddRoundKey(state block, key);
+ for round = 1 to NumberOfRound
+ SubBytes(state block)
+ ShiftRows(state block)
+ MixColumns(state block)
+ AddRoundKey(state block, key);
+ end for
+
+ SubBytes(state block)
+ ShiftRows(state block)
+ AddRoundKey(state block, key);
+
+ cipher block = state block;
+========================================================================
+*/
+VOID AES_Encrypt (
+ IN UINT8 PlainBlock[],
+ IN UINT PlainBlockSize,
+ IN UINT8 Key[],
+ IN UINT KeyLength,
+ OUT UINT8 CipherBlock[],
+ INOUT UINT *CipherBlockSize)
+{
+ AES_CTX_STRUC aes_ctx;
+ UINT RowIndex, ColumnIndex;
+ UINT RoundIndex, NumberOfRound = 0;
+ UINT8 Temp, Row0, Row1, Row2, Row3;
+
+ /*
+ * 1. Check if block size is 16 bytes(128 bits) and if key length is 16, 24, or 32 bytes(128, 192, or 256 bits)
+ */
+ if (PlainBlockSize != AES_BLOCK_SIZES) {
+ DBGPRINT(RT_DEBUG_ERROR, ("AES_Encrypt: plain block size is %d bytes, it must be %d bytes(128 bits).\n",
+ PlainBlockSize, AES_BLOCK_SIZES));
+ return;
+ } /* End of if */
+ if ((KeyLength != AES_KEY128_LENGTH) && (KeyLength != AES_KEY192_LENGTH) && (KeyLength != AES_KEY256_LENGTH)) {
+ DBGPRINT(RT_DEBUG_ERROR, ("AES_Encrypt: key length is %d bytes, it must be %d, %d, or %d bytes(128, 192, or 256 bits).\n",
+ KeyLength, AES_KEY128_LENGTH, AES_KEY192_LENGTH, AES_KEY256_LENGTH));
+ return;
+ } /* End of if */
+ if (*CipherBlockSize < AES_BLOCK_SIZES) {
+ DBGPRINT(RT_DEBUG_ERROR, ("AES_Encrypt: cipher block size is %d bytes, it must be %d bytes(128 bits).\n",
+ *CipherBlockSize, AES_BLOCK_SIZES));
+ return;
+ } /* End of if */
+
+ /*
+ * 2. Transfer the plain block to state block
+ */
+ for (RowIndex = 0; RowIndex < AES_STATE_ROWS;RowIndex++)
+ for (ColumnIndex = 0; ColumnIndex < AES_STATE_COLUMNS;ColumnIndex++)
+ aes_ctx.State[RowIndex][ColumnIndex] = PlainBlock[RowIndex + 4*ColumnIndex];
+
+ /*
+ * 3. Main encryption rounds
+ */
+ AES_KeyExpansion(Key, KeyLength, &aes_ctx);
+ NumberOfRound = (KeyLength >> 2) + 6;
+
+ /* AES_AddRoundKey */
+ RoundIndex = 0;
+ for (RowIndex = 0; RowIndex < AES_STATE_ROWS;RowIndex++)
+ for (ColumnIndex = 0; ColumnIndex < AES_STATE_COLUMNS;ColumnIndex++)
+ aes_ctx.State[RowIndex][ColumnIndex] ^= aes_ctx.KeyWordExpansion[RowIndex][(RoundIndex*((UINT) AES_STATE_COLUMNS)) + ColumnIndex];
+
+ for (RoundIndex = 1; RoundIndex < NumberOfRound;RoundIndex++)
+ {
+ /* AES_SubBytes */
+ for (RowIndex = 0; RowIndex < AES_STATE_ROWS;RowIndex++)
+ for (ColumnIndex = 0; ColumnIndex < AES_STATE_COLUMNS;ColumnIndex++)
+ aes_ctx.State[RowIndex][ColumnIndex] = aes_sbox_enc[aes_ctx.State[RowIndex][ColumnIndex]];
+
+ /* AES_ShiftRows */
+ Temp = aes_ctx.State[1][0];
+ aes_ctx.State[1][0] = aes_ctx.State[1][1];
+ aes_ctx.State[1][1] = aes_ctx.State[1][2];
+ aes_ctx.State[1][2] = aes_ctx.State[1][3];
+ aes_ctx.State[1][3] = Temp;
+ Temp = aes_ctx.State[2][0];
+ aes_ctx.State[2][0] = aes_ctx.State[2][2];
+ aes_ctx.State[2][2] = Temp;
+ Temp = aes_ctx.State[2][1];
+ aes_ctx.State[2][1] = aes_ctx.State[2][3];
+ aes_ctx.State[2][3] = Temp;
+ Temp = aes_ctx.State[3][3];
+ aes_ctx.State[3][3] = aes_ctx.State[3][2];
+ aes_ctx.State[3][2] = aes_ctx.State[3][1];
+ aes_ctx.State[3][1] = aes_ctx.State[3][0];
+ aes_ctx.State[3][0] = Temp;
+
+ /* AES_MixColumns */
+ for (ColumnIndex = 0; ColumnIndex < AES_STATE_COLUMNS;ColumnIndex++)
+ {
+ Row0 = aes_ctx.State[0][ColumnIndex];
+ Row1 = aes_ctx.State[1][ColumnIndex];
+ Row2 = aes_ctx.State[2][ColumnIndex];
+ Row3 = aes_ctx.State[3][ColumnIndex];
+ aes_ctx.State[0][ColumnIndex] = aes_mul_2[Row0]^aes_mul_3[Row1]^Row2^Row3;
+ aes_ctx.State[1][ColumnIndex] = Row0^aes_mul_2[Row1]^aes_mul_3[Row2]^Row3;
+ aes_ctx.State[2][ColumnIndex] = Row0^Row1^aes_mul_2[Row2]^aes_mul_3[Row3];
+ aes_ctx.State[3][ColumnIndex] = aes_mul_3[Row0]^Row1^Row2^aes_mul_2[Row3];
+ }
+
+ /* AES_AddRoundKey */
+ for (RowIndex = 0; RowIndex < AES_STATE_ROWS;RowIndex++)
+ for (ColumnIndex = 0; ColumnIndex < AES_STATE_COLUMNS;ColumnIndex++)
+ aes_ctx.State[RowIndex][ColumnIndex] ^= aes_ctx.KeyWordExpansion[RowIndex][(RoundIndex*((UINT) AES_STATE_COLUMNS)) + ColumnIndex];
+ } /* End of for */
+
+ /* AES_SubBytes */
+ for (RowIndex = 0; RowIndex < AES_STATE_ROWS;RowIndex++)
+ for (ColumnIndex = 0; ColumnIndex < AES_STATE_COLUMNS;ColumnIndex++)
+ aes_ctx.State[RowIndex][ColumnIndex] = aes_sbox_enc[aes_ctx.State[RowIndex][ColumnIndex]];
+ /* AES_ShiftRows */
+ Temp = aes_ctx.State[1][0];
+ aes_ctx.State[1][0] = aes_ctx.State[1][1];
+ aes_ctx.State[1][1] = aes_ctx.State[1][2];
+ aes_ctx.State[1][2] = aes_ctx.State[1][3];
+ aes_ctx.State[1][3] = Temp;
+ Temp = aes_ctx.State[2][0];
+ aes_ctx.State[2][0] = aes_ctx.State[2][2];
+ aes_ctx.State[2][2] = Temp;
+ Temp = aes_ctx.State[2][1];
+ aes_ctx.State[2][1] = aes_ctx.State[2][3];
+ aes_ctx.State[2][3] = Temp;
+ Temp = aes_ctx.State[3][3];
+ aes_ctx.State[3][3] = aes_ctx.State[3][2];
+ aes_ctx.State[3][2] = aes_ctx.State[3][1];
+ aes_ctx.State[3][1] = aes_ctx.State[3][0];
+ aes_ctx.State[3][0] = Temp;
+ /* AES_AddRoundKey */
+ for (RowIndex = 0; RowIndex < AES_STATE_ROWS;RowIndex++)
+ for (ColumnIndex = 0; ColumnIndex < AES_STATE_COLUMNS;ColumnIndex++)
+ aes_ctx.State[RowIndex][ColumnIndex] ^= aes_ctx.KeyWordExpansion[RowIndex][(RoundIndex*((UINT) AES_STATE_COLUMNS)) + ColumnIndex];
+
+ /*
+ * 4. Transfer the state block to cipher block
+ */
+ for (RowIndex = 0; RowIndex < AES_STATE_ROWS;RowIndex++)
+ for (ColumnIndex = 0; ColumnIndex < AES_STATE_COLUMNS;ColumnIndex++)
+ CipherBlock[RowIndex + 4*ColumnIndex] = aes_ctx.State[RowIndex][ColumnIndex];
+
+ *CipherBlockSize = ((UINT) AES_STATE_ROWS)*((UINT) AES_STATE_COLUMNS);
+} /* End of AES_Encrypt */
+
+
+/*
+========================================================================
+Routine Description:
+ AES decryption
+
+Arguments:
+ CipherBlock The block of cipher text, 16 bytes(128 bits) each block
+ CipherBlockSize The length of block of cipher text in bytes
+ Key Cipher key, it may be 16, 24, or 32 bytes (128, 192, or 256 bits)
+ KeyLength The length of cipher key in bytes
+ PlainBlockSize The length of allocated plain block in bytes
+
+Return Value:
+ PlainBlock Return plain text
+ PlainBlockSize Return the length of real used plain block in bytes
+
+Note:
+ Reference to FIPS-PUB 197
+ 1. Check if block size is 16 bytes(128 bits) and if key length is 16, 24, or 32 bytes(128, 192, or 256 bits)
+ 2. Transfer the cipher block to state block
+ 3. Main decryption rounds
+ 4. Transfer the state block to plain block
+ ------------------------------------------
+ NumberOfRound = (key length / 4) + 6;
+ state block = cipher block;
+
+ AddRoundKey(state block, key);
+ for round = NumberOfRound to 1
+ InvSubBytes(state block)
+ InvShiftRows(state block)
+ InvMixColumns(state block)
+ AddRoundKey(state block, key);
+ end for
+
+ InvSubBytes(state block)
+ InvShiftRows(state block)
+ AddRoundKey(state block, key);
+
+ plain block = state block;
+========================================================================
+*/
+VOID AES_Decrypt (
+ IN UINT8 CipherBlock[],
+ IN UINT CipherBlockSize,
+ IN UINT8 Key[],
+ IN UINT KeyLength,
+ OUT UINT8 PlainBlock[],
+ INOUT UINT *PlainBlockSize)
+{
+ AES_CTX_STRUC aes_ctx;
+ UINT RowIndex, ColumnIndex;
+ UINT RoundIndex, NumberOfRound = 0;
+ UINT8 Temp, Row0, Row1, Row2, Row3;
+
+ /*
+ * 1. Check if block size is 16 bytes(128 bits) and if key length is 16, 24, or 32 bytes(128, 192, or 256 bits)
+ */
+ if (*PlainBlockSize < AES_BLOCK_SIZES) {
+ DBGPRINT(RT_DEBUG_ERROR, ("AES_Decrypt: plain block size is %d bytes, it must be %d bytes(128 bits).\n",
+ *PlainBlockSize, AES_BLOCK_SIZES));
+ return;
+ } /* End of if */
+ if ((KeyLength != AES_KEY128_LENGTH) && (KeyLength != AES_KEY192_LENGTH) && (KeyLength != AES_KEY256_LENGTH)) {
+ DBGPRINT(RT_DEBUG_ERROR, ("AES_Decrypt: key length is %d bytes, it must be %d, %d, or %d bytes(128, 192, or 256 bits).\n",
+ KeyLength, AES_KEY128_LENGTH, AES_KEY192_LENGTH, AES_KEY256_LENGTH));
+ return;
+ } /* End of if */
+ if (CipherBlockSize != AES_BLOCK_SIZES) {
+ DBGPRINT(RT_DEBUG_ERROR, ("AES_Decrypt: cipher block size is %d bytes, it must be %d bytes(128 bits).\n",
+ CipherBlockSize, AES_BLOCK_SIZES));
+ return;
+ } /* End of if */
+
+ /*
+ * 2. Transfer the cipher block to state block
+ */
+ for (RowIndex = 0; RowIndex < AES_STATE_ROWS;RowIndex++)
+ for (ColumnIndex = 0; ColumnIndex < AES_STATE_COLUMNS;ColumnIndex++)
+ aes_ctx.State[RowIndex][ColumnIndex] = CipherBlock[RowIndex + 4*ColumnIndex];
+
+ /*
+ * 3. Main decryption rounds
+ */
+ AES_KeyExpansion(Key, KeyLength, &aes_ctx);
+ NumberOfRound = (KeyLength >> 2) + 6;
+
+ /* AES_AddRoundKey */
+ RoundIndex = NumberOfRound;
+ for (RowIndex = 0; RowIndex < AES_STATE_ROWS;RowIndex++)
+ for (ColumnIndex = 0; ColumnIndex < AES_STATE_COLUMNS;ColumnIndex++)
+ aes_ctx.State[RowIndex][ColumnIndex] ^= aes_ctx.KeyWordExpansion[RowIndex][(RoundIndex*((UINT) AES_STATE_COLUMNS)) + ColumnIndex];
+
+ for (RoundIndex = (NumberOfRound - 1); RoundIndex > 0 ;RoundIndex--)
+ {
+ /* AES_InvShiftRows */
+ Temp = aes_ctx.State[1][3];
+ aes_ctx.State[1][3] = aes_ctx.State[1][2];
+ aes_ctx.State[1][2] = aes_ctx.State[1][1];
+ aes_ctx.State[1][1] = aes_ctx.State[1][0];
+ aes_ctx.State[1][0] = Temp;
+ Temp = aes_ctx.State[2][0];
+ aes_ctx.State[2][0] = aes_ctx.State[2][2];
+ aes_ctx.State[2][2] = Temp;
+ Temp = aes_ctx.State[2][1];
+ aes_ctx.State[2][1] = aes_ctx.State[2][3];
+ aes_ctx.State[2][3] = Temp;
+ Temp = aes_ctx.State[3][0];
+ aes_ctx.State[3][0] = aes_ctx.State[3][1];
+ aes_ctx.State[3][1] = aes_ctx.State[3][2];
+ aes_ctx.State[3][2] = aes_ctx.State[3][3];
+ aes_ctx.State[3][3] = Temp;
+
+ /* AES_InvSubBytes */
+ for (RowIndex = 0; RowIndex < AES_STATE_ROWS;RowIndex++)
+ for (ColumnIndex = 0; ColumnIndex < AES_STATE_COLUMNS;ColumnIndex++)
+ aes_ctx.State[RowIndex][ColumnIndex] = aes_sbox_dec[aes_ctx.State[RowIndex][ColumnIndex]];
+
+ /* AES_AddRoundKey */
+ for (RowIndex = 0; RowIndex < AES_STATE_ROWS;RowIndex++)
+ for (ColumnIndex = 0; ColumnIndex < AES_STATE_COLUMNS;ColumnIndex++)
+ aes_ctx.State[RowIndex][ColumnIndex] ^= aes_ctx.KeyWordExpansion[RowIndex][(RoundIndex*((UINT) AES_STATE_COLUMNS)) + ColumnIndex];
+
+ /* AES_InvMixColumns */
+ for (ColumnIndex = 0; ColumnIndex < AES_STATE_COLUMNS;ColumnIndex++)
+ {
+ Row0 = aes_ctx.State[0][ColumnIndex];
+ Row1 = aes_ctx.State[1][ColumnIndex];
+ Row2 = aes_ctx.State[2][ColumnIndex];
+ Row3 = aes_ctx.State[3][ColumnIndex];
+ aes_ctx.State[0][ColumnIndex] = aes_mul_e[Row0]^aes_mul_b[Row1]^aes_mul_d[Row2]^aes_mul_9[Row3];
+ aes_ctx.State[1][ColumnIndex] = aes_mul_9[Row0]^aes_mul_e[Row1]^aes_mul_b[Row2]^aes_mul_d[Row3];
+ aes_ctx.State[2][ColumnIndex] = aes_mul_d[Row0]^aes_mul_9[Row1]^aes_mul_e[Row2]^aes_mul_b[Row3];
+ aes_ctx.State[3][ColumnIndex] = aes_mul_b[Row0]^aes_mul_d[Row1]^aes_mul_9[Row2]^aes_mul_e[Row3];
+ }
+ } /* End of for */
+
+ /* AES_InvShiftRows */
+ Temp = aes_ctx.State[1][3];
+ aes_ctx.State[1][3] = aes_ctx.State[1][2];
+ aes_ctx.State[1][2] = aes_ctx.State[1][1];
+ aes_ctx.State[1][1] = aes_ctx.State[1][0];
+ aes_ctx.State[1][0] = Temp;
+ Temp = aes_ctx.State[2][0];
+ aes_ctx.State[2][0] = aes_ctx.State[2][2];
+ aes_ctx.State[2][2] = Temp;
+ Temp = aes_ctx.State[2][1];
+ aes_ctx.State[2][1] = aes_ctx.State[2][3];
+ aes_ctx.State[2][3] = Temp;
+ Temp = aes_ctx.State[3][0];
+ aes_ctx.State[3][0] = aes_ctx.State[3][1];
+ aes_ctx.State[3][1] = aes_ctx.State[3][2];
+ aes_ctx.State[3][2] = aes_ctx.State[3][3];
+ aes_ctx.State[3][3] = Temp;
+ /* AES_InvSubBytes */
+ for (RowIndex = 0; RowIndex < AES_STATE_ROWS;RowIndex++)
+ for (ColumnIndex = 0; ColumnIndex < AES_STATE_COLUMNS;ColumnIndex++)
+ aes_ctx.State[RowIndex][ColumnIndex] = aes_sbox_dec[aes_ctx.State[RowIndex][ColumnIndex]];
+ /* AES_AddRoundKey */
+ for (RowIndex = 0; RowIndex < AES_STATE_ROWS;RowIndex++)
+ for (ColumnIndex = 0; ColumnIndex < AES_STATE_COLUMNS;ColumnIndex++)
+ aes_ctx.State[RowIndex][ColumnIndex] ^= aes_ctx.KeyWordExpansion[RowIndex][(RoundIndex*((UINT) AES_STATE_COLUMNS)) + ColumnIndex];
+
+ /*
+ * 4. Transfer the state block to plain block
+ */
+ for (RowIndex = 0; RowIndex < AES_STATE_ROWS;RowIndex++)
+ for (ColumnIndex = 0; ColumnIndex < AES_STATE_COLUMNS;ColumnIndex++)
+ PlainBlock[RowIndex + 4*ColumnIndex] = aes_ctx.State[RowIndex][ColumnIndex];
+
+ *PlainBlockSize = ((UINT) AES_STATE_ROWS)*((UINT) AES_STATE_COLUMNS);
+} /* End of AES_Decrypt */
+
+
+/*
+========================================================================
+Routine Description:
+ AES-CBC encryption
+
+Arguments:
+ PlainText Plain text
+ PlainTextLength The length of plain text in bytes
+ Key Cipher key, it may be 16, 24, or 32 bytes (128, 192, or 256 bits)
+ KeyLength The length of cipher key in bytes
+ IV Initialization vector, it may be 16 bytes (128 bits)
+ IVLength The length of initialization vector in bytes
+ CipherTextLength The length of allocated cipher text in bytes
+
+Return Value:
+ CipherText Return cipher text
+ CipherTextLength Return the length of real used cipher text in bytes
+
+Note:
+ Reference to RFC 3602 and NIST 800-38A
+========================================================================
+*/
+VOID AES_CBC_Encrypt (
+ IN UINT8 PlainText[],
+ IN UINT PlainTextLength,
+ IN UINT8 Key[],
+ IN UINT KeyLength,
+ IN UINT8 IV[],
+ IN UINT IVLength,
+ OUT UINT8 CipherText[],
+ INOUT UINT *CipherTextLength)
+{
+ UINT PaddingSize, PlainBlockStart, CipherBlockStart, CipherBlockSize;
+ UINT Index;
+ UINT8 Block[AES_BLOCK_SIZES];
+
+ /*
+ * 1. Check the input parameters
+ * - CipherTextLength > (PlainTextLength + Padding size), Padding size = block size - (PlainTextLength % block size)
+ * - Key length must be 16, 24, or 32 bytes(128, 192, or 256 bits)
+ * - IV length must be 16 bytes(128 bits)
+ */
+ PaddingSize = ((UINT) AES_BLOCK_SIZES) - (PlainTextLength % ((UINT)AES_BLOCK_SIZES));
+ if (*CipherTextLength < (PlainTextLength + PaddingSize)) {
+ DBGPRINT(RT_DEBUG_ERROR, ("AES_CBC_Encrypt: cipher text length is %d bytes < (plain text length %d bytes + padding size %d bytes).\n",
+ *CipherTextLength, PlainTextLength, PaddingSize));
+ return;
+ } /* End of if */
+ if ((KeyLength != AES_KEY128_LENGTH) && (KeyLength != AES_KEY192_LENGTH) && (KeyLength != AES_KEY256_LENGTH)) {
+ DBGPRINT(RT_DEBUG_ERROR, ("AES_CBC_Encrypt: key length is %d bytes, it must be %d, %d, or %d bytes(128, 192, or 256 bits).\n",
+ KeyLength, AES_KEY128_LENGTH, AES_KEY192_LENGTH, AES_KEY256_LENGTH));
+ return;
+ } /* End of if */
+ if (IVLength != AES_CBC_IV_LENGTH) {
+ DBGPRINT(RT_DEBUG_ERROR, ("AES_CBC_Encrypt: IV length is %d bytes, it must be %d bytes(128bits).\n",
+ IVLength, AES_CBC_IV_LENGTH));
+ return;
+ } /* End of if */
+
+
+ /*
+ * 2. Main algorithm
+ * - Plain text divide into serveral blocks (16 bytes/block)
+ * - If plain text is divided with no remainder by block, add a new block and padding size = block(16 bytes)
+ * - If plain text is not divided with no remainder by block, padding size = (block - remainder plain text)
+ * - Execute AES_Encrypt procedure.
+ *
+ * - Padding method: The remainder bytes will be filled with padding size (1 byte)
+ */
+ PlainBlockStart = 0;
+ CipherBlockStart = 0;
+ while ((PlainTextLength - PlainBlockStart) >= AES_BLOCK_SIZES)
+ {
+ if (CipherBlockStart == 0) {
+ for (Index = 0; Index < AES_BLOCK_SIZES; Index++)
+ Block[Index] = PlainText[PlainBlockStart + Index]^IV[Index];
+ } else {
+ for (Index = 0; Index < AES_BLOCK_SIZES; Index++)
+ Block[Index] = PlainText[PlainBlockStart + Index]^CipherText[CipherBlockStart - ((UINT) AES_BLOCK_SIZES) + Index];
+ } /* End of if */
+
+ CipherBlockSize = *CipherTextLength - CipherBlockStart;
+ AES_Encrypt(Block, AES_BLOCK_SIZES , Key, KeyLength, CipherText + CipherBlockStart, &CipherBlockSize);
+
+ PlainBlockStart += ((UINT) AES_BLOCK_SIZES);
+ CipherBlockStart += CipherBlockSize;
+ } /* End of while */
+
+ NdisMoveMemory(Block, (&PlainText[0] + PlainBlockStart), (PlainTextLength - PlainBlockStart));
+ NdisFillMemory((Block + (((UINT) AES_BLOCK_SIZES) -PaddingSize)), PaddingSize, (UINT8) PaddingSize);
+ if (CipherBlockStart == 0) {
+ for (Index = 0; Index < AES_BLOCK_SIZES; Index++)
+ Block[Index] ^= IV[Index];
+ } else {
+ for (Index = 0; Index < AES_BLOCK_SIZES; Index++)
+ Block[Index] ^= CipherText[CipherBlockStart - ((UINT) AES_BLOCK_SIZES) + Index];
+ } /* End of if */
+ CipherBlockSize = *CipherTextLength - CipherBlockStart;
+ AES_Encrypt(Block, AES_BLOCK_SIZES , Key, KeyLength, CipherText + CipherBlockStart, &CipherBlockSize);
+ CipherBlockStart += CipherBlockSize;
+ *CipherTextLength = CipherBlockStart;
+} /* End of AES_CBC_Encrypt */
+
+
+/*
+========================================================================
+Routine Description:
+ AES-CBC decryption
+
+Arguments:
+ CipherText Cipher text
+ CipherTextLength The length of cipher text in bytes
+ Key Cipher key, it may be 16, 24, or 32 bytes (128, 192, or 256 bits)
+ KeyLength The length of cipher key in bytes
+ IV Initialization vector, it may be 16 bytes (128 bits)
+ IVLength The length of initialization vector in bytes
+ PlainTextLength The length of allocated plain text in bytes
+
+Return Value:
+ PlainText Return plain text
+ PlainTextLength Return the length of real used plain text in bytes
+
+Note:
+ Reference to RFC 3602 and NIST 800-38A
+========================================================================
+*/
+VOID AES_CBC_Decrypt (
+ IN UINT8 CipherText[],
+ IN UINT CipherTextLength,
+ IN UINT8 Key[],
+ IN UINT KeyLength,
+ IN UINT8 IV[],
+ IN UINT IVLength,
+ OUT UINT8 PlainText[],
+ INOUT UINT *PlainTextLength)
+{
+ UINT PaddingSize, PlainBlockStart, CipherBlockStart, PlainBlockSize;
+ UINT Index;
+
+ /*
+ * 1. Check the input parameters
+ * - CipherTextLength must be divided with no remainder by block
+ * - Key length must be 16, 24, or 32 bytes(128, 192, or 256 bits)
+ * - IV length must be 16 bytes(128 bits)
+ */
+ if ((CipherTextLength % AES_BLOCK_SIZES) != 0) {
+ DBGPRINT(RT_DEBUG_ERROR, ("AES_CBC_Decrypt: cipher text length is %d bytes, it can't be divided with no remainder by block size(%d).\n",
+ CipherTextLength, AES_BLOCK_SIZES));
+ return;
+ } /* End of if */
+ if ((KeyLength != AES_KEY128_LENGTH) && (KeyLength != AES_KEY192_LENGTH) && (KeyLength != AES_KEY256_LENGTH)) {
+ DBGPRINT(RT_DEBUG_ERROR, ("AES_CBC_Decrypt: key length is %d bytes, it must be %d, %d, or %d bytes(128, 192, or 256 bits).\n",
+ KeyLength, AES_KEY128_LENGTH, AES_KEY192_LENGTH, AES_KEY256_LENGTH));
+ return;
+ } /* End of if */
+ if (IVLength != AES_CBC_IV_LENGTH) {
+ DBGPRINT(RT_DEBUG_ERROR, ("AES_CBC_Decrypt: IV length is %d bytes, it must be %d bytes(128bits).\n",
+ IVLength, AES_CBC_IV_LENGTH));
+ return;
+ } /* End of if */
+
+
+ /*
+ * 2. Main algorithm
+ * - Cypher text divide into serveral blocks (16 bytes/block)
+ * - Execute AES_Decrypt procedure.
+ * - Remove padding bytes, padding size is the last byte of plain text
+ */
+ CipherBlockStart = 0;
+ PlainBlockStart = 0;
+ while ((CipherTextLength - CipherBlockStart) >= AES_BLOCK_SIZES)
+ {
+ PlainBlockSize = *PlainTextLength - PlainBlockStart;
+ AES_Decrypt(CipherText + CipherBlockStart, AES_BLOCK_SIZES , Key, KeyLength, PlainText + PlainBlockStart, &PlainBlockSize);
+
+ if (PlainBlockStart == 0) {
+ for (Index = 0; Index < AES_BLOCK_SIZES; Index++)
+ PlainText[PlainBlockStart + Index] ^= IV[Index];
+ } else {
+ for (Index = 0; Index < AES_BLOCK_SIZES; Index++)
+ PlainText[PlainBlockStart + Index] ^= CipherText[CipherBlockStart + Index - ((UINT) AES_BLOCK_SIZES)];
+ } /* End of if */
+
+ CipherBlockStart += AES_BLOCK_SIZES;
+ PlainBlockStart += PlainBlockSize;
+ } /* End of while */
+
+ PaddingSize = (UINT8) PlainText[PlainBlockStart -1];
+ *PlainTextLength = PlainBlockStart - PaddingSize;
+
+} /* End of AES_CBC_Encrypt */
+
+
+
+/*
+========================================================================
+Routine Description:
+ AES-CMAC generate subkey
+
+Arguments:
+ Key Cipher key 128 bits
+ KeyLength The length of Cipher key in bytes
+
+Return Value:
+ SubKey1 SubKey 1 128 bits
+ SubKey2 SubKey 2 128 bits
+
+Note:
+ Reference to RFC 4493
+
+ Step 1. L := AES-128(K, const_Zero);
+ Step 2. if MSB(L) is equal to 0
+ then K1 := L << 1;
+ else K1 := (L << 1) XOR const_Rb;
+ Step 3. if MSB(K1) is equal to 0
+ then K2 := K1 << 1;
+ else K2 := (K1 << 1) XOR const_Rb;
+ Step 4. return K1, K2;
+========================================================================
+*/
+VOID AES_CMAC_GenerateSubKey (
+ IN UINT8 Key[],
+ IN UINT KeyLength,
+ OUT UINT8 SubKey1[],
+ OUT UINT8 SubKey2[])
+{
+ UINT8 MSB_L = 0, MSB_K1 = 0, Top_Bit = 0;
+ UINT SubKey1_Length = 0;
+ INT Index = 0;
+
+ if (KeyLength != AES_KEY128_LENGTH) {
+ DBGPRINT(RT_DEBUG_ERROR, ("AES_CMAC_GenerateSubKey: key length is %d bytes, it must be %d bytes(128 bits).\n",
+ KeyLength, AES_KEY128_LENGTH));
+ return;
+ } /* End of if */
+
+ /* Step 1: L := AES-128(K, const_Zero); */
+ SubKey1_Length = 16;
+ AES_Encrypt(Const_Zero, sizeof(Const_Zero), Key, KeyLength, SubKey1, &SubKey1_Length);
+
+ /*
+ * Step 2. if MSB(L) is equal to 0
+ * then K1 := L << 1;
+ * else K1 := (L << 1) XOR const_Rb;
+ */
+ MSB_L = SubKey1[0] & 0x80;
+ for(Index = 0; Index < 15; Index++) {
+ Top_Bit = (SubKey1[Index + 1] & 0x80)?1:0;
+ SubKey1[Index] <<= 1;
+ SubKey1[Index] |= Top_Bit;
+ }
+ SubKey1[15] <<= 1;
+ if (MSB_L > 0) {
+ for(Index = 0; Index < 16; Index++)
+ SubKey1[Index] ^= Const_Rb[Index];
+ } /* End of if */
+
+ /*
+ * Step 3. if MSB(K1) is equal to 0
+ * then K2 := K1 << 1;
+ * else K2 := (K1 << 1) XOR const_Rb;
+ */
+ MSB_K1 = SubKey1[0] & 0x80;
+ for(Index = 0; Index < 15; Index++) {
+ Top_Bit = (SubKey1[Index + 1] & 0x80)?1:0;
+ SubKey2[Index] = SubKey1[Index] << 1;
+ SubKey2[Index] |= Top_Bit;
+ }
+ SubKey2[15] = SubKey1[15] << 1;
+ if (MSB_K1 > 0) {
+ for(Index = 0; Index < 16; Index++)
+ SubKey2[Index] ^= Const_Rb[Index];
+ } /* End of if */
+} /* End of AES_CMAC_GenerateSubKey */
+
+
+/*
+========================================================================
+Routine Description:
+ AES-CMAC
+
+Arguments:
+ PlainText Plain text
+ PlainTextLength The length of plain text in bytes
+ Key Cipher key, it may be 16, 24, or 32 bytes (128, 192, or 256 bits)
+ KeyLength The length of cipher key in bytes
+ MACTextLength The length of allocated memory spaces in bytes
+
+Return Value:
+ MACText Message authentication code (128-bit string)
+ MACTextLength Return the length of Message authentication code in bytes
+
+Note:
+ Reference to RFC 4493
+========================================================================
+*/
+VOID AES_CMAC (
+ IN UINT8 PlainText[],
+ IN UINT PlainTextLength,
+ IN UINT8 Key[],
+ IN UINT KeyLength,
+ OUT UINT8 MACText[],
+ INOUT UINT *MACTextLength)
+{
+ UINT PlainBlockStart;
+ UINT8 X[AES_BLOCK_SIZES], Y[AES_BLOCK_SIZES];
+ UINT8 SubKey1[16];
+ UINT8 SubKey2[16];
+ INT X_Length, Index;
+
+ if (*MACTextLength < AES_MAC_LENGTH) {
+ DBGPRINT(RT_DEBUG_ERROR, ("AES_CMAC: MAC text length is less than %d bytes).\n",
+ AES_MAC_LENGTH));
+ return;
+ } /* End of if */
+ if (KeyLength != AES_KEY128_LENGTH) {
+ DBGPRINT(RT_DEBUG_ERROR, ("AES_CMAC: key length is %d bytes, it must be %d bytes(128 bits).\n",
+ KeyLength, AES_KEY128_LENGTH));
+ return;
+ } /* End of if */
+
+ /* Step 1. (K1,K2) := Generate_Subkey(K); */
+ NdisZeroMemory(SubKey1, 16);
+ NdisZeroMemory(SubKey2, 16);
+ AES_CMAC_GenerateSubKey(Key, KeyLength, SubKey1, SubKey2);
+
+ /*
+ * 2. Main algorithm
+ * - Plain text divide into serveral blocks (16 bytes/block)
+ * - If plain text is not divided with no remainder by block, padding size = (block - remainder plain text)
+ * - Execute AES_Encrypt procedure.
+ */
+ PlainBlockStart = 0;
+ NdisMoveMemory(X, Const_Zero, AES_BLOCK_SIZES);
+ while ((PlainTextLength - PlainBlockStart) > AES_BLOCK_SIZES)
+ {
+ for (Index = 0; Index < AES_BLOCK_SIZES; Index++)
+ Y[Index] = PlainText[PlainBlockStart + Index]^X[Index];
+
+ X_Length = sizeof(X);
+ AES_Encrypt(Y, sizeof(Y) , Key, KeyLength, X, &X_Length);
+ PlainBlockStart += ((UINT) AES_BLOCK_SIZES);
+ } /* End of while */
+ if ((PlainTextLength - PlainBlockStart) == AES_BLOCK_SIZES) {
+ for (Index = 0; Index < AES_BLOCK_SIZES; Index++)
+ Y[Index] = PlainText[PlainBlockStart + Index]^X[Index]^SubKey1[Index];
+ } else {
+ NdisZeroMemory(Y, AES_BLOCK_SIZES);
+ NdisMoveMemory(Y, &PlainText[PlainBlockStart], (PlainTextLength - PlainBlockStart));
+ Y[(PlainTextLength - PlainBlockStart)] = 0x80;
+ for (Index = 0; Index < AES_BLOCK_SIZES; Index++)
+ Y[Index] = Y[Index]^X[Index]^SubKey2[Index];
+ } /* End of if */
+ AES_Encrypt(Y, sizeof(Y) , Key, KeyLength, MACText, MACTextLength);
+} /* End of AES_CMAC */
diff --git a/drivers/staging/rt3090/common/crypt_biginteger.c b/drivers/staging/rt3090/common/crypt_biginteger.c
new file mode 100644
index 000000000000..b346c5f7fbd0
--- /dev/null
+++ b/drivers/staging/rt3090/common/crypt_biginteger.c
@@ -0,0 +1,1119 @@
+/*
+ *************************************************************************
+ * 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:
+ cmm_profile.c
+
+ Abstract:
+
+ Revision History:
+ Who When What
+ --------- ---------- ----------------------------------------------
+ */
+
+#include "crypt_biginteger.h"
+
+#ifdef __KERNEL__
+#define DEBUGPRINT(fmt, args...) printk(KERN_ERR fmt, ## args)
+#else
+#define DEBUGPRINT(fmt, args...) printf(fmt, ## args)
+#endif /* __KERNEL__ */
+
+#define UINT32_HBITS(value) (((value) >> 0x10) & 0xffff)
+#define UINT32_LBITS(value) ((value) & 0xffff)
+#define UINT32_GETBYTE(value, index) (((value) >> ((index)*8)) & 0xff)
+#define UINT64_HBITS(value) (((value) >> 0x20) & 0xffffffff)
+#define UINT64_LBITS(value) ((value) & 0xffffffff)
+
+static UINT8 WPS_DH_P_VALUE[192] =
+{
+ 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF,
+ 0xC9, 0x0F, 0xDA, 0xA2, 0x21, 0x68, 0xC2, 0x34,
+ 0xC4, 0xC6, 0x62, 0x8B, 0x80, 0xDC, 0x1C, 0xD1,
+ 0x29, 0x02, 0x4E, 0x08, 0x8A, 0x67, 0xCC, 0x74,
+ 0x02, 0x0B, 0xBE, 0xA6, 0x3B, 0x13, 0x9B, 0x22,
+ 0x51, 0x4A, 0x08, 0x79, 0x8E, 0x34, 0x04, 0xDD,
+ 0xEF, 0x95, 0x19, 0xB3, 0xCD, 0x3A, 0x43, 0x1B,
+ 0x30, 0x2B, 0x0A, 0x6D, 0xF2, 0x5F, 0x14, 0x37,
+ 0x4F, 0xE1, 0x35, 0x6D, 0x6D, 0x51, 0xC2, 0x45,
+ 0xE4, 0x85, 0xB5, 0x76, 0x62, 0x5E, 0x7E, 0xC6,
+ 0xF4, 0x4C, 0x42, 0xE9, 0xA6, 0x37, 0xED, 0x6B,
+ 0x0B, 0xFF, 0x5C, 0xB6, 0xF4, 0x06, 0xB7, 0xED,
+ 0xEE, 0x38, 0x6B, 0xFB, 0x5A, 0x89, 0x9F, 0xA5,
+ 0xAE, 0x9F, 0x24, 0x11, 0x7C, 0x4B, 0x1F, 0xE6,
+ 0x49, 0x28, 0x66, 0x51, 0xEC, 0xE4, 0x5B, 0x3D,
+ 0xC2, 0x00, 0x7C, 0xB8, 0xA1, 0x63, 0xBF, 0x05,
+ 0x98, 0xDA, 0x48, 0x36, 0x1C, 0x55, 0xD3, 0x9A,
+ 0x69, 0x16, 0x3F, 0xA8, 0xFD, 0x24, 0xCF, 0x5F,
+ 0x83, 0x65, 0x5D, 0x23, 0xDC, 0xA3, 0xAD, 0x96,
+ 0x1C, 0x62, 0xF3, 0x56, 0x20, 0x85, 0x52, 0xBB,
+ 0x9E, 0xD5, 0x29, 0x07, 0x70, 0x96, 0x96, 0x6D,
+ 0x67, 0x0C, 0x35, 0x4E, 0x4A, 0xBC, 0x98, 0x04,
+ 0xF1, 0x74, 0x6C, 0x08, 0xCA, 0x23, 0x73, 0x27,
+ 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF,
+};
+
+static UINT8 WPS_DH_R_VALUE[193] =
+{
+ 0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+ 0x00,
+};
+
+static UINT8 WPS_DH_X_VALUE[184] =
+{
+ 0x36, 0xf0, 0x25, 0x5d, 0xde, 0x97, 0x3d, 0xcb,
+ 0x3b, 0x39, 0x9d, 0x74, 0x7f, 0x23, 0xe3, 0x2e,
+ 0xd6, 0xfd, 0xb1, 0xf7, 0x75, 0x98, 0x33, 0x8b,
+ 0xfd, 0xf4, 0x41, 0x59, 0xc4, 0xec, 0x64, 0xdd,
+ 0xae, 0xb5, 0xf7, 0x86, 0x71, 0xcb, 0xfb, 0x22,
+ 0x10, 0x6a, 0xe6, 0x4c, 0x32, 0xc5, 0xbc, 0xe4,
+ 0xcf, 0xd4, 0xf5, 0x92, 0x0d, 0xa0, 0xeb, 0xc8,
+ 0xb0, 0x1e, 0xca, 0x92, 0x92, 0xae, 0x3d, 0xba,
+ 0x1b, 0x7a, 0x4a, 0x89, 0x9d, 0xa1, 0x81, 0x39,
+ 0x0b, 0xb3, 0xbd, 0x16, 0x59, 0xc8, 0x12, 0x94,
+ 0xf4, 0x00, 0xa3, 0x49, 0x0b, 0xf9, 0x48, 0x12,
+ 0x11, 0xc7, 0x94, 0x04, 0xa5, 0x76, 0x60, 0x5a,
+ 0x51, 0x60, 0xdb, 0xee, 0x83, 0xb4, 0xe0, 0x19,
+ 0xb6, 0xd7, 0x99, 0xae, 0x13, 0x1b, 0xa4, 0xc2,
+ 0x3d, 0xff, 0x83, 0x47, 0x5e, 0x9c, 0x40, 0xfa,
+ 0x67, 0x25, 0xb7, 0xc9, 0xe3, 0xaa, 0x2c, 0x65,
+ 0x96, 0xe9, 0xc0, 0x57, 0x02, 0xdb, 0x30, 0xa0,
+ 0x7c, 0x9a, 0xa2, 0xdc, 0x23, 0x5c, 0x52, 0x69,
+ 0xe3, 0x9d, 0x0c, 0xa9, 0xdf, 0x7a, 0xad, 0x44,
+ 0x61, 0x2a, 0xd6, 0xf8, 0x8f, 0x69, 0x69, 0x92,
+ 0x98, 0xf3, 0xca, 0xb1, 0xb5, 0x43, 0x67, 0xfb,
+ 0x0e, 0x8b, 0x93, 0xf7, 0x35, 0xdc, 0x8c, 0xd8,
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01,
+};
+
+static UINT8 WPS_DH_RRModP_VALUE[192] =
+{
+ 0xe3, 0xb3, 0x3c, 0x72, 0x59, 0x54, 0x1c, 0x01,
+ 0xee, 0x9c, 0x9a, 0x21, 0x6c, 0xc1, 0xeb, 0xd2,
+ 0xae, 0x59, 0x41, 0x04, 0x79, 0x29, 0xa1, 0xc7,
+ 0xe9, 0xc3, 0xfa, 0x02, 0xcc, 0x24, 0x56, 0xef,
+ 0x10, 0x26, 0x30, 0xfa, 0x9a, 0x36, 0xa5, 0x1f,
+ 0x57, 0xb5, 0x93, 0x48, 0x67, 0x98, 0x44, 0x60,
+ 0x0b, 0xe4, 0x96, 0x47, 0xa8, 0x7c, 0x7b, 0x37,
+ 0xf8, 0x05, 0x65, 0x64, 0x96, 0x9b, 0x7f, 0x02,
+ 0xdc, 0x54, 0x1a, 0x4e, 0xd4, 0x05, 0x3f, 0x54,
+ 0xd6, 0x2a, 0x0e, 0xea, 0xb2, 0x70, 0x52, 0x1b,
+ 0x22, 0xc2, 0x96, 0xe9, 0xd4, 0x6f, 0xec, 0x23,
+ 0x8e, 0x1a, 0xbd, 0x78, 0x02, 0x23, 0xb7, 0x6b,
+ 0xb8, 0xfe, 0x61, 0x21, 0x19, 0x6b, 0x7e, 0x88,
+ 0x1c, 0x72, 0x9c, 0x7e, 0x04, 0xb9, 0xf7, 0x96,
+ 0x07, 0xcd, 0x0a, 0x62, 0x8e, 0x43, 0x41, 0x30,
+ 0x04, 0xa5, 0x41, 0xff, 0x93, 0xae, 0x1c, 0xeb,
+ 0xb0, 0x04, 0xa7, 0x50, 0xdb, 0x10, 0x2d, 0x39,
+ 0xb9, 0x05, 0x2b, 0xb4, 0x7a, 0x58, 0xf1, 0x70,
+ 0x7e, 0x8c, 0xd2, 0xac, 0x98, 0xb5, 0xfb, 0x62,
+ 0x8f, 0x23, 0x31, 0xb1, 0x3b, 0x01, 0xe0, 0x18,
+ 0xf4, 0x66, 0xee, 0x5f, 0xbc, 0xd4, 0x9d, 0x68,
+ 0xd0, 0xab, 0x92, 0xe1, 0x83, 0x97, 0xf2, 0x45,
+ 0x8e, 0x0e, 0x3e, 0x21, 0x67, 0x47, 0x8c, 0x73,
+ 0xf1, 0x15, 0xd2, 0x7d, 0x32, 0xc6, 0x95, 0xe0,
+};
+
+static UINT8 Value_0[1] = {0x00};
+static UINT8 Value_1[1] = {0x01};
+static PBIG_INTEGER pBI_U = NULL, pBI_S = NULL, pBI_O = NULL;
+static UINT Bits_Of_R = 0;
+
+
+VOID BigInteger_Print (
+ IN PBIG_INTEGER pBI)
+{
+ int i = 0, j = 0;
+
+ if ((pBI == NULL) || (pBI->pIntegerArray == NULL))
+ return;
+
+ if (strlen(pBI->Name) != 0)
+ DEBUGPRINT("Name=%s\n", pBI->Name);
+ DEBUGPRINT("AllocSize=%d, ArrayLength=%d, IntegerLength=%d, Signed=%d\n", pBI->AllocSize, pBI->ArrayLength, pBI->IntegerLength, pBI->Signed);
+ for (i = (pBI->ArrayLength - 1), j = 0;i >=0;i--,j++) {
+ DEBUGPRINT("%08x, ", pBI->pIntegerArray[i]);
+ if ((j%8) == 7)
+ DEBUGPRINT("\n");
+ } /* End od for */
+ DEBUGPRINT("\n\n");
+} /* End of BigInteger_Print */
+
+
+VOID BigInteger_Init (
+ INOUT PBIG_INTEGER *pBI)
+{
+ if (*pBI != NULL)
+ BigInteger_Free(pBI);
+
+ if ((*pBI = (PBIG_INTEGER) kmalloc(sizeof(BIG_INTEGER), GFP_ATOMIC)) == NULL) {
+ DEBUGPRINT("BigInteger_Init: allocate %d bytes memory failure.\n", (sizeof(BIG_INTEGER)));
+ return;
+ } /* End of if */
+
+ NdisZeroMemory(*pBI, sizeof(BIG_INTEGER));
+ (*pBI)->pIntegerArray = NULL;
+ (*pBI)->Signed = 1;
+} /* End of BigInteger_Init */
+
+
+VOID BigInteger_Free_AllocSize (
+ IN PBIG_INTEGER *pBI)
+{
+ if ((*pBI != NULL) && ((*pBI)->pIntegerArray != NULL)) {
+ kfree((*pBI)->pIntegerArray);
+ NdisZeroMemory(*pBI, sizeof(BIG_INTEGER));
+ (*pBI)->pIntegerArray = NULL;
+ (*pBI)->Signed = 1;
+ } /* End of if */
+} /* End of BigInteger_Free_AllocSize */
+
+
+VOID BigInteger_Free (
+ IN PBIG_INTEGER *pBI)
+{
+ if (*pBI != NULL) {
+ BigInteger_Free_AllocSize(pBI);
+ kfree(*pBI);
+ } /* End of if */
+
+ *pBI = NULL;
+} /* End of BigInteger_Free */
+
+
+VOID BigInteger_AllocSize (
+ IN PBIG_INTEGER *pBI,
+ IN UINT Length)
+{
+ UINT ArrayLength = 0;
+
+ if (Length == 0)
+ return;
+
+ if (*pBI == NULL)
+ BigInteger_Init(pBI);
+
+ /* Caculate array size */
+ ArrayLength = Length >> 0x2;
+ if ((Length & 0x3) != 0)
+ ArrayLength++;
+
+ if (((*pBI)->pIntegerArray != NULL) && ((*pBI)->AllocSize < (sizeof(UINT32)*ArrayLength)))
+ BigInteger_Free_AllocSize(pBI);
+
+ if ((*pBI)->pIntegerArray == NULL) {
+ if (((*pBI)->pIntegerArray = (UINT32 *) kmalloc(sizeof(UINT32)*ArrayLength, GFP_ATOMIC)) == NULL) {
+ DEBUGPRINT("BigInteger_AllocSize: allocate %d bytes memory failure.\n", (sizeof(UINT32)*ArrayLength));
+ return;
+ } /* End of if */
+ (*pBI)->AllocSize = sizeof(UINT32)*ArrayLength;
+ } /* End of if */
+
+ NdisZeroMemory((*pBI)->pIntegerArray, (*pBI)->AllocSize);
+ (*pBI)->ArrayLength = ArrayLength;
+ (*pBI)->IntegerLength = Length;
+} /* End of BigInteger_AllocSize */
+
+
+VOID BigInteger_ClearHighBits (
+ IN PBIG_INTEGER pBI)
+{
+ INT BIArrayIndex, ShiftIndex = 0;
+ UINT8 value;
+
+ if ((pBI == NULL) || (pBI->pIntegerArray == NULL))
+ return;
+
+ BIArrayIndex = pBI->ArrayLength - 1;
+ while ((BIArrayIndex >= 0) && (pBI->pIntegerArray[BIArrayIndex] == 0))
+ BIArrayIndex--;
+
+ if (BIArrayIndex >= 0) {
+ value = 0;
+ ShiftIndex = 4;
+ while (value == 0) {
+ ShiftIndex--;
+ value = UINT32_GETBYTE(pBI->pIntegerArray[BIArrayIndex], ShiftIndex);
+ } /* End of while */
+ } /* End of if */
+
+ if ((BIArrayIndex == -1) && (ShiftIndex == -1)) {
+ pBI->IntegerLength = 1;
+ pBI->ArrayLength = 1;
+ pBI->Signed = 1;
+ } else {
+ pBI->IntegerLength = (BIArrayIndex*4) + ShiftIndex + 1;
+ pBI->ArrayLength = BIArrayIndex + 1;
+ } /* End of if */
+} /* End of BigInteger_ClearHighBits */
+
+
+VOID BigInteger_BI2Bin (
+ IN PBIG_INTEGER pBI,
+ OUT UINT8 *pValue,
+ OUT UINT *Length)
+{
+ INT ValueIndex, BIArrayIndex, ShiftIndex;
+ UINT32 Number;
+
+ if (pBI == NULL) {
+ DEBUGPRINT("BigInteger_BI2Bin: pBI is NUll\n");
+ *Length = 0;
+ return;
+ } /* End of if */
+
+ if (*Length < (sizeof(UINT8) * pBI->IntegerLength)) {
+ DEBUGPRINT("BigInteger_BI2Bin: length(%d) is not enough.\n", *Length);
+ *Length = 0;
+ return;
+ } /* End of if */
+
+ if (pBI->pIntegerArray == NULL) {
+ *Length = 0;
+ return;
+ } /* End of if */
+
+ BigInteger_ClearHighBits(pBI);
+ if ((ShiftIndex = pBI->IntegerLength & 0x3) == 0)
+ ShiftIndex = 4;
+ BIArrayIndex = pBI->ArrayLength - 1;
+ ValueIndex = 0;
+
+ Number = pBI->pIntegerArray[BIArrayIndex];
+ while (ValueIndex < pBI->IntegerLength)
+ {
+ pValue[ValueIndex++] = (UINT8) UINT32_GETBYTE(Number, ShiftIndex - 1);
+ if ((--ShiftIndex) == 0) {
+ ShiftIndex = 4;
+ BIArrayIndex--;
+ Number = pBI->pIntegerArray[BIArrayIndex];
+ } /* End of if */
+ } /* End of while */
+ *Length = pBI->IntegerLength;
+} /* End of BigInteger_BI2Bin */
+
+
+VOID BigInteger_Bin2BI (
+ IN UINT8 *pValue,
+ IN UINT Length,
+ OUT PBIG_INTEGER *pBI)
+{
+ INT ValueIndex, BIArrayIndex, ShiftIndex;
+ UINT32 Number;
+
+ BigInteger_AllocSize(pBI, Length);
+
+ if ((*pBI)->pIntegerArray != NULL) {
+ Number = 0;
+ if ((ShiftIndex = Length & 0x3) == 0)
+ ShiftIndex = 4;
+ BIArrayIndex = (*pBI)->ArrayLength - 1;
+ ValueIndex = 0;
+ while (ValueIndex < Length)
+ {
+ Number = (Number << 8) | (UINT8) pValue[ValueIndex++];
+ if ((--ShiftIndex) == 0) {
+ (*pBI)->pIntegerArray[BIArrayIndex] = Number;
+ ShiftIndex = 4;
+ BIArrayIndex--;
+ Number = 0;
+ } /* End of if */
+ } /* End of while */
+ } /* End of if */
+} /* End of BigInteger_Bin2BI */
+
+
+/* Calculate the bits of BigInteger, the highest bit is 1 */
+VOID BigInteger_BitsOfBI (
+ IN PBIG_INTEGER pBI,
+ OUT UINT *Bits_Of_P)
+{
+ UINT32 Number, Index;
+
+ Number = pBI->pIntegerArray[pBI->ArrayLength - 1];
+ Index = 0;
+ while ((!(Number & 0x80000000)) && (Index < 32)) {
+ Number <<= 1;
+ Index++;
+ } /* End of while */
+ *Bits_Of_P = (pBI->ArrayLength*sizeof(UINT32)) - Index;
+} /* End of BigInteger_BitsOfBN */
+
+
+INT BigInteger_GetBitValue (
+ IN PBIG_INTEGER pBI,
+ IN UINT Index)
+{
+ UINT Array = 0;
+ UINT Shift = 0;
+
+ if (Index > 0) {
+ Array = (Index - 1) >> 0x5;
+ Shift = (Index - 1) & 0x1F;
+ }
+ if (Array > pBI->ArrayLength)
+ return 0;
+
+ return ((pBI->pIntegerArray[Array] >> Shift) & 0x1);
+} /* End of BigInteger_GetBitValue */
+
+
+UINT8 BigInteger_GetByteValue (
+ IN PBIG_INTEGER pBI,
+ IN UINT Index)
+{
+ UINT Array = 0;
+ UINT Shift = 0;
+
+ if (Index > 0) {
+ Array = (Index - 1) >> 0x2;
+ Shift = (Index - 1) & 0x3;
+ }
+ if ((Array > pBI->ArrayLength) || (Index > pBI->IntegerLength))
+ return 0;
+
+
+ return (UINT8) UINT32_GETBYTE(pBI->pIntegerArray[Array], Shift - 1);
+} /* End of BigInteger_GetByteValue */
+
+
+VOID BigInteger_Copy (
+ IN PBIG_INTEGER pBI_Copied,
+ OUT PBIG_INTEGER *pBI_Result)
+{
+ BigInteger_AllocSize(pBI_Result, pBI_Copied->IntegerLength);
+ NdisCopyMemory((*pBI_Result)->pIntegerArray, pBI_Copied->pIntegerArray, (sizeof(UINT32)*(*pBI_Result)->ArrayLength));
+ (*pBI_Result)->ArrayLength = pBI_Copied->ArrayLength;
+ (*pBI_Result)->IntegerLength = pBI_Copied->IntegerLength;
+ (*pBI_Result)->Signed = pBI_Copied->Signed;
+} /* End of BigInteger_Copy */
+
+
+INT BigInteger_UnsignedCompare (
+ IN PBIG_INTEGER pFirstOperand,
+ IN PBIG_INTEGER pSecondOperand)
+{
+ INT BIArrayIndex;
+
+ if (pFirstOperand->IntegerLength > pSecondOperand->IntegerLength)
+ return 1;
+
+ if (pFirstOperand->IntegerLength < pSecondOperand->IntegerLength)
+ return -1;
+
+ if (pFirstOperand->IntegerLength == pSecondOperand->IntegerLength) {
+ for(BIArrayIndex = (pFirstOperand->ArrayLength - 1);BIArrayIndex >= 0 ; BIArrayIndex--)
+ {
+ if (pFirstOperand->pIntegerArray[BIArrayIndex] > pSecondOperand->pIntegerArray[BIArrayIndex])
+ return 1;
+ else if (pFirstOperand->pIntegerArray[BIArrayIndex] < pSecondOperand->pIntegerArray[BIArrayIndex])
+ return -1;
+ } /* End of for */
+ } /* End of if */
+
+ return 0;
+} /* End of BigInteger_Compare */
+
+
+VOID BigInteger_Add (
+ IN PBIG_INTEGER pFirstOperand,
+ IN PBIG_INTEGER pSecondOperand,
+ OUT PBIG_INTEGER *pBI_Result)
+{
+ INT CompareResult;
+ UINT32 BIArrayIndex;
+ UINT64 Sum, Carry;
+ PBIG_INTEGER pTempBI = NULL;
+
+ if ((pFirstOperand == NULL) || (pFirstOperand->pIntegerArray == NULL)
+ || (pSecondOperand == NULL) || (pSecondOperand->pIntegerArray == NULL)) {
+ DEBUGPRINT("BigInteger_Add: first or second operand is NULL.\n");
+ return;
+ } /* End of if */
+
+ if (*pBI_Result == NULL)
+ BigInteger_Init(pBI_Result);
+
+ CompareResult = BigInteger_UnsignedCompare(pFirstOperand, pSecondOperand);
+ if ((CompareResult == 0) & ((pFirstOperand->Signed * pSecondOperand->Signed) < 0)) {
+ BigInteger_AllocSize(pBI_Result, 1);
+ return ;
+ } /* End of if */
+
+ /*
+ * Singed table
+ * A + B || A > B || A < B
+ * ------------------------
+ * + + || + || +
+ * + - || + || -
+ * - + || - || +
+ * - - || - || -
+ */
+ if ((pFirstOperand->Signed * pSecondOperand->Signed) > 0) {
+ if (pFirstOperand->IntegerLength > pSecondOperand->IntegerLength) {
+ BigInteger_AllocSize(pBI_Result, pFirstOperand->IntegerLength + 1);
+ } else {
+ BigInteger_AllocSize(pBI_Result, pSecondOperand->IntegerLength + 1);
+ } /* End of if */
+
+ Carry = 0;
+ for (BIArrayIndex=0; BIArrayIndex < (*pBI_Result)->ArrayLength; BIArrayIndex++)
+ {
+
+ Sum = 0;
+ if (BIArrayIndex < pFirstOperand->ArrayLength)
+ Sum += (UINT64) pFirstOperand->pIntegerArray[BIArrayIndex];
+
+ if (BIArrayIndex < pSecondOperand->ArrayLength)
+ Sum += (UINT64) pSecondOperand->pIntegerArray[BIArrayIndex];
+
+ Sum += Carry;
+ Carry = Sum >> 32;
+ (*pBI_Result)->pIntegerArray[BIArrayIndex] = (UINT32) (Sum & 0xffffffffUL);
+ } /* End of for */
+ (*pBI_Result)->Signed = pFirstOperand->Signed;
+ BigInteger_ClearHighBits(*pBI_Result);
+ } else {
+ if ((pFirstOperand->Signed == 1) & (pSecondOperand->Signed == -1)) {
+ BigInteger_Copy(pSecondOperand, &pTempBI);
+ pTempBI->Signed = 1;
+ BigInteger_Sub(pFirstOperand, pTempBI, pBI_Result);
+ } else if ((pFirstOperand->Signed == -1) & (pSecondOperand->Signed == 1)) {
+ BigInteger_Copy(pFirstOperand, &pTempBI);
+ pTempBI->Signed = 1;
+ BigInteger_Sub(pSecondOperand, pTempBI, pBI_Result);
+ } /* End of if */
+ } /* End of if */
+
+ BigInteger_Free(&pTempBI);
+} /* End of BigInteger_Add */
+
+
+VOID BigInteger_Sub (
+ IN PBIG_INTEGER pFirstOperand,
+ IN PBIG_INTEGER pSecondOperand,
+ OUT PBIG_INTEGER *pBI_Result)
+{
+ INT CompareResult;
+ UINT32 BIArrayIndex, Carry;
+ PBIG_INTEGER pTempBI = NULL, pTempBI2 = NULL;
+
+ if ((pFirstOperand == NULL) || (pFirstOperand->pIntegerArray == NULL)
+ || (pSecondOperand == NULL) || (pSecondOperand->pIntegerArray == NULL)) {
+ DEBUGPRINT("BigInteger_Sub: first or second operand is NULL.\n");
+ return;
+ } /* End of if */
+
+ if (*pBI_Result == NULL)
+ BigInteger_Init(pBI_Result);
+
+ CompareResult = BigInteger_UnsignedCompare(pFirstOperand, pSecondOperand);
+ if ((CompareResult == 0) & ((pFirstOperand->Signed * pSecondOperand->Signed) > 0)) {
+ BigInteger_AllocSize(pBI_Result, 1);
+ return ;
+ } /* End of if */
+
+ BigInteger_Init(&pTempBI);
+ BigInteger_Init(&pTempBI2);
+
+ /*
+ * Singed table
+ * A - B || A > B || A < B
+ * ------------------------
+ * + + || + || -
+ * + - || + || +
+ * - + || - || -
+ * - - || - || +
+ */
+ if ((pFirstOperand->Signed * pSecondOperand->Signed) > 0) {
+ if (CompareResult == 1) {
+ BigInteger_Copy(pFirstOperand, &pTempBI);
+ BigInteger_Copy(pSecondOperand, &pTempBI2);
+ } else if (CompareResult == -1) {
+ BigInteger_Copy(pSecondOperand, &pTempBI);
+ BigInteger_Copy(pFirstOperand, &pTempBI2);
+ } /* End of if */
+
+ BigInteger_Copy(pTempBI, pBI_Result);
+ Carry = 0;
+ for (BIArrayIndex=0; BIArrayIndex < (*pBI_Result)->ArrayLength; BIArrayIndex++)
+ {
+ if (BIArrayIndex < pTempBI2->ArrayLength) {
+ if ((*pBI_Result)->pIntegerArray[BIArrayIndex] >= (pTempBI2->pIntegerArray[BIArrayIndex] - Carry)) {
+ (*pBI_Result)->pIntegerArray[BIArrayIndex] = (*pBI_Result)->pIntegerArray[BIArrayIndex] - pTempBI2->pIntegerArray[BIArrayIndex] - Carry;
+ Carry = 0;
+ } else {
+ (*pBI_Result)->pIntegerArray[BIArrayIndex] = 0xffffffffUL - pTempBI2->pIntegerArray[BIArrayIndex] - Carry + (*pBI_Result)->pIntegerArray[BIArrayIndex] + 1;
+ Carry = 1;
+ } /* End of if */
+ } else {
+ if ((*pBI_Result)->pIntegerArray[BIArrayIndex] >= Carry) {
+ (*pBI_Result)->pIntegerArray[BIArrayIndex] -= Carry;
+ Carry = 0;
+ } else {
+ (*pBI_Result)->pIntegerArray[BIArrayIndex] = 0xffffffffUL - Carry;
+ Carry = 1;
+ } /* End of if */
+ } /* End of if */
+ } /* End of for */
+
+ if (((pFirstOperand->Signed == 1) & (pSecondOperand->Signed == 1) & (CompareResult == -1))
+ || ((pFirstOperand->Signed == -1) & (pSecondOperand->Signed == -1) & (CompareResult == 1)))
+ (*pBI_Result)->Signed = -1;
+
+ BigInteger_ClearHighBits(*pBI_Result);
+ } else {
+ if ((pFirstOperand->Signed == 1) & (pSecondOperand->Signed == -1)) {
+ BigInteger_Copy(pSecondOperand, &pTempBI);
+ pTempBI->Signed = 1;
+ BigInteger_Add(pFirstOperand, pTempBI, pBI_Result);
+ } else if ((pFirstOperand->Signed == -1) & (pSecondOperand->Signed == 1)) {
+ BigInteger_Copy(pFirstOperand, &pTempBI);
+ pTempBI->Signed = 1;
+ BigInteger_Add(pTempBI, pSecondOperand, pBI_Result);
+ (*pBI_Result)->Signed = -1;
+ } /* End of if */
+ } /* End of if */
+
+ BigInteger_Free(&pTempBI);
+ BigInteger_Free(&pTempBI2);
+} /* End of BigInteger_Sub */
+
+
+VOID BigInteger_Mul (
+ IN PBIG_INTEGER pFirstOperand,
+ IN PBIG_INTEGER pSecondOperand,
+ OUT PBIG_INTEGER *pBI_Result)
+{
+
+ UINT32 BIFirstIndex, BISecondIndex;
+ UINT64 FirstValue, SecondValue, Sum, Carry;
+
+ if ((pFirstOperand == NULL) || (pFirstOperand->pIntegerArray == NULL)
+ || (pSecondOperand == NULL) || (pSecondOperand->pIntegerArray == NULL)) {
+ DEBUGPRINT("BigInteger_Mul: first or second operand is NULL.\n");
+ return;
+ } /* End of if */
+
+ /* The first or second operand is zero */
+ if (((pFirstOperand->IntegerLength == 1) && (pFirstOperand->pIntegerArray[0] == 0))
+ ||((pSecondOperand->IntegerLength == 1) && (pSecondOperand->pIntegerArray[0] == 0))) {
+ BigInteger_AllocSize(pBI_Result, 1);
+ goto output;
+ } /* End of if */
+
+ /* The first or second operand is one */
+ if ((pFirstOperand->IntegerLength == 1) && (pFirstOperand->pIntegerArray[0] == 1)) {
+ BigInteger_Copy(pSecondOperand, pBI_Result);
+ goto output;
+ } /* End of if */
+ if ((pSecondOperand->IntegerLength == 1) && (pSecondOperand->pIntegerArray[0] == 1)) {
+ BigInteger_Copy(pFirstOperand, pBI_Result);
+ goto output;
+ } /* End of if */
+
+ BigInteger_AllocSize(pBI_Result, pFirstOperand->IntegerLength + pSecondOperand->IntegerLength);
+
+ for (BIFirstIndex=0; BIFirstIndex < pFirstOperand->ArrayLength; BIFirstIndex++)
+ {
+ Carry = 0;
+ FirstValue = (UINT64) pFirstOperand->pIntegerArray[BIFirstIndex];
+ if (FirstValue == 0) {
+ continue;
+ } else {
+ for (BISecondIndex=0; BISecondIndex < pSecondOperand->ArrayLength; BISecondIndex++)
+ {
+ SecondValue = ((UINT64) pSecondOperand->pIntegerArray[BISecondIndex])*FirstValue;
+ Sum = (UINT64) ((*pBI_Result)->pIntegerArray[BIFirstIndex + BISecondIndex] + SecondValue + Carry);
+ Carry = Sum >> 32;
+ (*pBI_Result)->pIntegerArray[BIFirstIndex + BISecondIndex] = (UINT32) (Sum & 0xffffffffUL);
+ } /* End of for */
+ while (Carry != 0) {
+ Sum = (UINT64) (*pBI_Result)->pIntegerArray[BIFirstIndex + BISecondIndex];
+ Sum += Carry;
+
+ Carry = Sum >> 32;
+ (*pBI_Result)->pIntegerArray[BIFirstIndex + BISecondIndex] = (UINT32) (Sum & 0xffffffffUL);
+ BISecondIndex++;
+ } /* End of while */
+ } /* End of if */
+ } /* End of for */
+
+output:
+ (*pBI_Result)->Signed = pFirstOperand->Signed * pSecondOperand->Signed;
+ BigInteger_ClearHighBits(*pBI_Result);
+} /* End of BigInteger_Mul */
+
+
+VOID BigInteger_Square (
+ IN PBIG_INTEGER pBI,
+ OUT PBIG_INTEGER *pBI_Result)
+{
+ INT BIFirstIndex, BISecondIndex;
+ UINT32 HBITS_Value, LBITS_Value, Temp1_Value, Temp2_Value, Carry32;
+ UINT32 *Point_Of_S, *Point_Of_Result, *Point_Of_BI;
+ UINT64 Result64_1, Result64_2, Carry64, TempValue64;
+
+ if ((pBI == NULL) || (pBI->pIntegerArray == NULL)) {
+ DEBUGPRINT("\tBigInteger_Square: the operand is NULL.\n");
+ return;
+ } /* End of if */
+
+ /* The operand is zero */
+ if ((pBI->IntegerLength == 1) && (pBI->pIntegerArray[0] == 0)) {
+ BigInteger_AllocSize(pBI_Result, 1);
+ goto output;
+ } /* End of if */
+
+ BigInteger_AllocSize(pBI_Result, (pBI->IntegerLength*2) + 20);
+ BigInteger_AllocSize(&pBI_S, (pBI->IntegerLength*2) + 20);
+ BigInteger_AllocSize(&pBI_O, (pBI->IntegerLength*2) + 20);
+
+ /*
+ * Input: pBI = {a_0, a_1, a_2, a_3, ..., a_n}
+ * Step1. calculate a_0^2, a_1^2, a_2^2, a_3^2 ... a_n^2
+ */
+ Point_Of_S = pBI_S->pIntegerArray;
+ for (BIFirstIndex=0; BIFirstIndex < pBI->ArrayLength; BIFirstIndex++)
+ {
+ HBITS_Value = UINT32_HBITS(pBI->pIntegerArray[BIFirstIndex]);
+ LBITS_Value = UINT32_LBITS(pBI->pIntegerArray[BIFirstIndex]);
+ Temp1_Value = HBITS_Value*LBITS_Value;
+ Temp2_Value = (Temp1_Value & 0x7fff) << 0x11;
+ Point_Of_S[0] = (LBITS_Value*LBITS_Value) + Temp2_Value;
+ Point_Of_S[1] = (HBITS_Value*HBITS_Value) + ((Temp1_Value >> 0xf) & 0x1ffff);
+ if (Point_Of_S[0] < Temp2_Value)
+ Point_Of_S[1] += 1;
+
+ Point_Of_S += 2;
+ } /* End of for */
+
+ /*
+ * Step2. calculate a_0*{a_1, a_2, a_3, a_4, ..., a_n}
+ */
+ Point_Of_BI = pBI->pIntegerArray;
+ Point_Of_Result = (*pBI_Result)->pIntegerArray;
+ Point_Of_Result[0] = 0;
+ TempValue64 = (UINT64) Point_Of_BI[0];
+ Point_Of_Result++;
+ Carry64 = 0;
+ for (BIFirstIndex=1; BIFirstIndex < pBI->ArrayLength; BIFirstIndex++)
+ {
+ Result64_1 = (UINT64) Point_Of_BI[BIFirstIndex]*TempValue64;
+ Result64_1 += Carry64;
+ Carry64 = (Result64_1 >> 32);
+ Point_Of_Result[0] = (UINT32) (Result64_1 & 0xffffffffUL);
+ Point_Of_Result++;
+ } /* End of for */
+ if (Carry64 > 0)
+ Point_Of_Result[0] = (UINT32) (Carry64 & 0xffffffffUL);
+
+ /*
+ * Step3. calculate
+ * a_1*{a_2, a_3, a_4, ..., a_n}
+ * a_2*{a_3, a_4, a_5, ..., a_n}
+ * a_3*{a_4, a_5, a_6, ..., a_n}
+ * a_4*{a_5, a_6, a_7, ..., a_n}
+ * ...
+ * a_n-1*{a_n}
+ */
+ Point_Of_BI = pBI->pIntegerArray;
+ for (BIFirstIndex=1; BIFirstIndex < (pBI->ArrayLength - 1); BIFirstIndex++)
+ {
+ Point_Of_Result = (*pBI_Result)->pIntegerArray;
+ Point_Of_Result += (BIFirstIndex*2) + 1;
+ TempValue64 = (UINT64) Point_Of_BI[BIFirstIndex];
+ Carry64 = 0;
+ for (BISecondIndex=(BIFirstIndex + 1); BISecondIndex < pBI->ArrayLength; BISecondIndex++)
+ {
+ Result64_1 = ((UINT64) Point_Of_Result[0]) + Carry64;
+ Result64_2 = (UINT64) Point_Of_BI[BISecondIndex]*TempValue64;
+ Carry64 = (Result64_1 >> 32);
+ Result64_1 = (Result64_1 & 0xffffffffUL);
+ Result64_1 = Result64_1 + Result64_2;
+ Carry64 += (Result64_1 >> 32);
+ Point_Of_Result[0] = (UINT32) (Result64_1 & 0xffffffffUL);
+ Point_Of_Result++;
+ } /* End of for */
+ if (Carry64 > 0)
+ Point_Of_Result[0] += (UINT32) (Carry64 & 0xffffffffUL);
+ } /* End of for */
+
+ BigInteger_ClearHighBits(*pBI_Result);
+ BigInteger_Copy(*pBI_Result, &pBI_O);
+
+ Carry32 = 0;
+ for (BIFirstIndex=0; BIFirstIndex < pBI_O->ArrayLength; BIFirstIndex++) {
+ pBI_O->pIntegerArray[BIFirstIndex] = (pBI_O->pIntegerArray[BIFirstIndex] << 1) | Carry32;
+ if (pBI_O->pIntegerArray[BIFirstIndex] < (*pBI_Result)->pIntegerArray[BIFirstIndex])
+ Carry32 = 1;
+ else
+ Carry32 = 0;
+ } /* End of for */
+ pBI_O->pIntegerArray[BIFirstIndex] = Carry32;
+ pBI_O->IntegerLength++;
+ pBI_O->ArrayLength++;
+ BigInteger_ClearHighBits(pBI_O);
+
+ BigInteger_Add(pBI_O, pBI_S, pBI_Result);
+output:
+ (*pBI_Result)->Signed = 1;
+ BigInteger_ClearHighBits(*pBI_Result);
+} /* End of BigInteger_Square */
+
+
+VOID BigInteger_Div (
+ IN PBIG_INTEGER pFirstOperand,
+ IN PBIG_INTEGER pSecondOperand,
+ OUT PBIG_INTEGER *pBI_Result,
+ OUT PBIG_INTEGER *pBI_Remainder)
+{
+ INT CompareResult;
+ INT Index, MulIndex, ComputeSize;
+ UINT32 MulStart;
+ UINT AllocLength, ArrayIndex, ShiftIndex;
+ PBIG_INTEGER pTempBI = NULL, pTempBI2 = NULL, pMulBI = NULL;
+ UINT8 SecondHighByte;
+
+ if ((pFirstOperand == NULL) || (pFirstOperand->pIntegerArray == NULL)
+ || (pSecondOperand == NULL) || (pSecondOperand->pIntegerArray == NULL)) {
+ DEBUGPRINT("BigInteger_Div: first or second operand is NULL.\n");
+ return;
+ } /* End of if */
+
+ /* The second operand is zero */
+ if ((pSecondOperand->IntegerLength == 1) && (pSecondOperand->pIntegerArray[0] == 0)) {
+ DEBUGPRINT("BigInteger_Div: second operand is zero.\n");
+ return;
+ } /* End of if */
+
+ if (*pBI_Result == NULL)
+ BigInteger_Init(pBI_Result);
+ if (*pBI_Remainder == NULL)
+ BigInteger_Init(pBI_Remainder);
+
+ /* The second operand is one */
+ if ((pSecondOperand->IntegerLength == 1) && (pSecondOperand->pIntegerArray[0] == 1)) {
+ BigInteger_Copy(pFirstOperand, pBI_Result);
+ BigInteger_Bin2BI(Value_0, 1, pBI_Remainder);
+ goto output;
+ } /* End of if */
+
+ CompareResult = BigInteger_UnsignedCompare(pFirstOperand, pSecondOperand);
+ if (CompareResult == 0) {
+ BigInteger_Bin2BI(Value_1, 1, pBI_Result);
+ BigInteger_Bin2BI(Value_0, 1, pBI_Remainder);
+ goto output;
+ } else if (CompareResult == -1) {
+ BigInteger_Bin2BI(Value_0, 1, pBI_Result);
+ BigInteger_Copy(pFirstOperand, pBI_Remainder);
+ goto output;
+ } /* End of if */
+ BigInteger_AllocSize(pBI_Result, pFirstOperand->IntegerLength - pSecondOperand->IntegerLength + 1);
+ BigInteger_AllocSize(pBI_Remainder, pSecondOperand->IntegerLength);
+
+ AllocLength = (UINT) (pFirstOperand->IntegerLength << 1);
+ BigInteger_AllocSize(&pTempBI, AllocLength);
+ BigInteger_AllocSize(&pTempBI2, AllocLength);
+ BigInteger_AllocSize(&pMulBI, AllocLength);
+
+ BigInteger_Copy(pFirstOperand, pBI_Remainder);
+ SecondHighByte = BigInteger_GetByteValue(pSecondOperand, pSecondOperand->IntegerLength);
+ ComputeSize = (INT) pFirstOperand->IntegerLength - pSecondOperand->IntegerLength + 1;
+ for (Index = (INT) ComputeSize;Index >= 0;Index--) {
+ if (BigInteger_UnsignedCompare(*pBI_Remainder, pSecondOperand) == -1)
+ break;
+
+ if (((pSecondOperand->IntegerLength + Index) - (*pBI_Remainder)->IntegerLength) <= 1) {
+ BigInteger_AllocSize(&pMulBI, Index + 1);
+ ArrayIndex = 0;
+ if (Index > 0)
+ ArrayIndex = (UINT) (Index - 1) >> 2 ;
+ ShiftIndex = (Index & 0x03);
+ if (ShiftIndex == 0)
+ ShiftIndex = 4;
+ ShiftIndex--;
+ MulStart = 0;
+ MulStart = (BigInteger_GetByteValue((*pBI_Remainder), pFirstOperand->IntegerLength + Index - ComputeSize + 1) & 0xFF) << 8;
+ MulStart = MulStart | (BigInteger_GetByteValue((*pBI_Remainder), pFirstOperand->IntegerLength + Index - ComputeSize) & 0xFF);
+ if (MulStart < (UINT32) SecondHighByte)
+ continue;
+
+ MulStart = MulStart / (UINT32) SecondHighByte;
+
+ if (MulStart > 0xFF)
+ MulStart = 0x100;
+
+ for (MulIndex = (INT) MulStart;MulIndex <= 0x101;MulIndex++) { /* 0xFFFF / 0xFF = 0x101 */
+ if ((MulIndex > 0xFF) && (ShiftIndex == 3))
+ pMulBI->pIntegerArray[ArrayIndex + 1] = 0x01;
+ pMulBI->pIntegerArray[ArrayIndex] = ((UINT) MulIndex << (8*ShiftIndex));
+ BigInteger_Mul(pSecondOperand, pMulBI , &pTempBI);
+ CompareResult = BigInteger_UnsignedCompare(*pBI_Remainder, pTempBI);
+ if (CompareResult < 1) {
+ if (MulIndex > 1) {
+ if (CompareResult != 0) {
+ if ((MulIndex == 0x100) && (ShiftIndex == 3))
+ pMulBI->pIntegerArray[ArrayIndex + 1] = 0;
+ pMulBI->pIntegerArray[ArrayIndex] = ((UINT) (MulIndex - 1) << (8*ShiftIndex));
+ } /* End of if */
+
+ BigInteger_Mul(pSecondOperand, pMulBI, &pTempBI);
+ BigInteger_Sub(*pBI_Remainder, pTempBI, &pTempBI2);
+ BigInteger_Copy(pTempBI2, pBI_Remainder);
+ BigInteger_Add(*pBI_Result, pMulBI, &pTempBI2);
+ BigInteger_Copy(pTempBI2, pBI_Result);
+ } /* End of if */
+ break;
+ } /* End of if */
+
+ if ((MulIndex >= 0x100) && (ShiftIndex == 3))
+ pMulBI->pIntegerArray[ArrayIndex++] = 0;
+ pMulBI->pIntegerArray[ArrayIndex] = 0;
+ } /* End of for */
+ } /* End of if */
+ } /* End of for */
+
+ BigInteger_Free(&pTempBI);
+ BigInteger_Free(&pTempBI2);
+ BigInteger_Free(&pMulBI);
+output:
+ (*pBI_Result)->Signed = pFirstOperand->Signed * pSecondOperand->Signed;
+ (*pBI_Remainder)->Signed = pFirstOperand->Signed * pSecondOperand->Signed;
+ BigInteger_ClearHighBits(*pBI_Result);
+ BigInteger_ClearHighBits(*pBI_Remainder);
+} /* End of BigInteger_Div */
+
+
+VOID BigInteger_Montgomery_Reduction (
+ IN PBIG_INTEGER pBI_A,
+ IN PBIG_INTEGER pBI_P,
+ IN PBIG_INTEGER pBI_R,
+ OUT PBIG_INTEGER *pBI_Result)
+{
+ UINT32 *Point_P, *Point_Result;
+ UINT32 LoopCount;
+ UINT64 Result64_1, Result64_2, Carry64, TempValue64;
+ INT FirstLoop, SecondLoop;
+
+ BigInteger_AllocSize(pBI_Result, pBI_A->IntegerLength+ pBI_P->IntegerLength + 20);
+ BigInteger_Copy(pBI_A, pBI_Result);
+
+ Point_P = pBI_P->pIntegerArray;
+ Point_Result = (*pBI_Result)->pIntegerArray;
+
+ LoopCount = Bits_Of_R >> 0x5;
+ for (FirstLoop = 0;FirstLoop < LoopCount;FirstLoop++) {
+ Carry64 = 0;
+ TempValue64 = (UINT64) Point_Result[0];
+ for (SecondLoop = 0;SecondLoop < pBI_P->ArrayLength;SecondLoop++) {
+ Result64_1 = ((UINT64) Point_Result[SecondLoop]) + Carry64;
+ Result64_2 = (UINT64) Point_P[SecondLoop]*TempValue64;
+ Carry64 = (Result64_1 >> 32);
+ Result64_1 = (Result64_1 & 0xffffffffUL);
+ Result64_1 = Result64_1 + Result64_2;
+ Carry64 += (Result64_1 >> 32);
+ Point_Result[SecondLoop] = (UINT32) (Result64_1 & 0xffffffffUL);
+ } /* End of for */
+ while (Carry64 != 0) {
+ Result64_1 = ((UINT64) Point_Result[SecondLoop]) + Carry64;
+ Carry64 = Result64_1 >> 32;
+ Point_Result[SecondLoop] = (UINT32) (Result64_1 & 0xffffffffUL);
+ SecondLoop++;
+ } /* End of while */
+ Point_Result++;
+ } /* End of for */
+
+ for (FirstLoop = 0;FirstLoop <= LoopCount;FirstLoop++) {
+ (*pBI_Result)->pIntegerArray[FirstLoop] = (*pBI_Result)->pIntegerArray[FirstLoop + LoopCount];
+ } /* End of for */
+ if ((*pBI_Result)->pIntegerArray[LoopCount] != 0)
+ (*pBI_Result)->ArrayLength = LoopCount + 1;
+ else
+ (*pBI_Result)->ArrayLength = LoopCount;
+
+ (*pBI_Result)->IntegerLength = (*pBI_Result)->ArrayLength*4;
+ BigInteger_ClearHighBits(*pBI_Result);
+
+ if (BigInteger_UnsignedCompare(*pBI_Result, pBI_P) >= 0) {
+ BigInteger_Sub(*pBI_Result, pBI_P, &pBI_U);
+ BigInteger_Copy(pBI_U, pBI_Result);
+ } /* End of if */
+ BigInteger_ClearHighBits(*pBI_Result);
+} /* End of BigInteger_Montgomery_Reduction */
+
+
+VOID BigInteger_Montgomery_ExpMod (
+ IN PBIG_INTEGER pBI_G,
+ IN PBIG_INTEGER pBI_E,
+ IN PBIG_INTEGER pBI_P,
+ OUT PBIG_INTEGER *pBI_Result)
+{
+ UINT Bits_Of_P;
+ UINT32 Index, Index2, AllocLength;
+ UINT32 Sliding_Value , Sliding_HighValue, Sliding_LowValue;
+ PBIG_INTEGER pBI_Temp1 = NULL, pBI_Temp2 = NULL;
+ PBIG_INTEGER pBI_X = NULL, pBI_R = NULL, pBI_RR = NULL, pBI_1 = NULL;
+ BIG_INTEGER *pBI_A[SLIDING_WINDOW];
+ UINT8 *pRValue = NULL;
+
+ AllocLength = (pBI_G->IntegerLength + pBI_E->IntegerLength + pBI_P->IntegerLength + 300);
+ BigInteger_AllocSize(&pBI_Temp1, AllocLength);
+ BigInteger_AllocSize(&pBI_Temp2, AllocLength);
+
+ /* Calculate the bits of P and E, the highest bit is 1 */
+ BigInteger_BitsOfBI(pBI_P, &Bits_Of_P);
+
+ if ((pBI_E->IntegerLength == 1) && (pBI_E->pIntegerArray[0] == 1)) {
+ BigInteger_Div(pBI_G, pBI_P, &pBI_Temp1, pBI_Result);
+ goto memory_free;
+ } /* End of if */
+
+ if ((pBI_E->IntegerLength == 1) && (pBI_E->pIntegerArray[0] == 2)) {
+ BigInteger_Mul(pBI_G, pBI_G, &pBI_Temp1);
+ BigInteger_Div(pBI_Temp1, pBI_P, &pBI_Temp2, pBI_Result);
+ goto memory_free;
+ } /* End of if */
+
+ /*
+ * Main algorithm
+ */
+ BigInteger_Init(&pBI_R);
+ BigInteger_Init(&pBI_RR);
+ BigInteger_Bin2BI(Value_1, 1, &pBI_1);
+ BigInteger_AllocSize(&pBI_X, AllocLength);
+ BigInteger_AllocSize(&pBI_U, AllocLength); // for BigInteger_Montgomery_Reduction
+ BigInteger_AllocSize(&pBI_S, AllocLength); // for BigInteger_Square
+ BigInteger_AllocSize(&pBI_O, AllocLength); // for BigInteger_Square
+
+ for (Index = 0; Index < SLIDING_WINDOW; Index++) {
+ pBI_A[Index] = NULL;
+ BigInteger_AllocSize(&pBI_A[Index], 193);
+ } /* End of for */
+ BigInteger_Bin2BI(WPS_DH_P_VALUE, 192, &pBI_Temp1);
+ if (NdisCmpMemory(pBI_P->pIntegerArray, pBI_Temp1->pIntegerArray, pBI_P->IntegerLength) == 0) {
+ BigInteger_Bin2BI(WPS_DH_X_VALUE, 184, &pBI_X);
+ BigInteger_Bin2BI(WPS_DH_R_VALUE, 193, &pBI_R);
+ BigInteger_Bin2BI(WPS_DH_RRModP_VALUE, 192, &pBI_RR);
+ Bits_Of_R = 1537;
+ } else {
+ if ((Bits_Of_P % 8) == 0) {
+ AllocLength = pBI_P->IntegerLength + 1;
+ } else {
+ AllocLength = pBI_P->IntegerLength;
+ } /* End of if */
+ pRValue = (UINT8 *) kmalloc(sizeof(UINT8)*AllocLength, GFP_ATOMIC);
+ if (pRValue == NULL)
+ {
+ DBGPRINT(RT_DEBUG_ERROR, ("%s():Alloc memory failed\n", __FUNCTION__));
+ goto memory_free;
+ }
+ NdisZeroMemory(pRValue, sizeof(UINT8)*AllocLength);
+ pRValue[0] = (UINT8) (1 << (Bits_Of_P & 0x7));
+ BigInteger_Bin2BI(pRValue, AllocLength , &pBI_R);
+
+ BigInteger_Mul(pBI_R, pBI_R, &pBI_Temp1);
+ BigInteger_Div(pBI_Temp1, pBI_P, &pBI_A[1], &pBI_RR);
+
+ /* X = 1*R (mod P) */
+ BigInteger_Div(pBI_R, pBI_P, &pBI_Temp2, &pBI_X);
+ } /* End of if */
+
+ /* A = G*R (mod P) => A = MonMod(G, R^2 mod P) */
+ BigInteger_Mul(pBI_G, pBI_RR, &pBI_Temp1);
+ BigInteger_Montgomery_Reduction(pBI_Temp1, pBI_P , pBI_R, &pBI_A[1]);
+ for (Index = 2; Index < SLIDING_WINDOW; Index++) {
+ BigInteger_Mul(pBI_A[Index - 1], pBI_A[1], &pBI_Temp1);
+ BigInteger_Montgomery_Reduction(pBI_Temp1, pBI_P, pBI_R, &pBI_A[Index]);
+ } /* End of for */
+
+ for (Index = pBI_E->IntegerLength ; Index > 0 ; Index--) {
+ for (Index2 = 0; Index2 < 4 ; Index2++) {
+ BigInteger_Square(pBI_X, &pBI_Temp1);
+ BigInteger_Montgomery_Reduction(pBI_Temp1, pBI_P, pBI_R, &pBI_X);
+ } /* End of for */
+
+ Sliding_Value = BigInteger_GetByteValue(pBI_E, Index);
+ Sliding_HighValue = (Sliding_Value >> 4);
+ if (Sliding_HighValue != 0) {
+ BigInteger_Mul(pBI_A[Sliding_HighValue], pBI_X, &pBI_Temp1);
+ BigInteger_Montgomery_Reduction(pBI_Temp1, pBI_P, pBI_R, &pBI_X);
+ } /* End of if */
+
+ for (Index2 = 0; Index2 < 4 ; Index2++) {
+ BigInteger_Square(pBI_X, &pBI_Temp1);
+ BigInteger_Montgomery_Reduction(pBI_Temp1, pBI_P, pBI_R, &pBI_X);
+ } /* End of for */
+
+ Sliding_LowValue = Sliding_Value & 0x0f;
+ if (Sliding_LowValue != 0) {
+ BigInteger_Mul(pBI_A[Sliding_LowValue], pBI_X, &pBI_Temp1);
+ BigInteger_Montgomery_Reduction(pBI_Temp1, pBI_P, pBI_R, &pBI_X);
+ } /* End of if */
+ } /* End of for */
+ BigInteger_Montgomery_Reduction(pBI_X, pBI_P , pBI_R, pBI_Result);
+
+ BigInteger_Free(&pBI_X);
+ BigInteger_Free(&pBI_R);
+ BigInteger_Free(&pBI_RR);
+ BigInteger_Free(&pBI_1);
+ BigInteger_Free(&pBI_U);
+ BigInteger_Free(&pBI_S);
+ BigInteger_Free(&pBI_O);
+ for(Index = 0; Index < SLIDING_WINDOW; Index++)
+ BigInteger_Free(&pBI_A[Index]);
+ if (pRValue != NULL)
+ kfree(pRValue);
+
+memory_free:
+ BigInteger_Free(&pBI_Temp1);
+ BigInteger_Free(&pBI_Temp2);
+} /* End of BigInteger_Montgomery_ExpMod */
+
+/* End of crypt_biginteger.c */
diff --git a/drivers/staging/rt3090/common/crypt_dh.c b/drivers/staging/rt3090/common/crypt_dh.c
new file mode 100644
index 000000000000..0f69f2af9038
--- /dev/null
+++ b/drivers/staging/rt3090/common/crypt_dh.c
@@ -0,0 +1,234 @@
+/*
+ *************************************************************************
+ * 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:
+ crypt_dh.c
+
+ Abstract:
+
+ Revision History:
+ Who When What
+ -------- ---------- ----------------------------------------------
+ Eddy 2009/01/19 Create AES-128, AES-192, AES-256, AES-CBC
+*/
+
+#include "crypt_dh.h"
+#include "crypt_biginteger.h"
+
+/*
+========================================================================
+Routine Description:
+ Diffie-Hellman public key generation
+
+Arguments:
+ GValue Array in UINT8
+ GValueLength The length of G in bytes
+ PValue Array in UINT8
+ PValueLength The length of P in bytes
+ PrivateKey Private key
+ PrivateKeyLength The length of Private key in bytes
+
+Return Value:
+ PublicKey Public key
+ PublicKeyLength The length of public key in bytes
+
+Note:
+ Reference to RFC2631
+ PublicKey = G^PrivateKey (mod P)
+========================================================================
+*/
+void DH_PublicKey_Generate (
+ IN UINT8 GValue[],
+ IN UINT GValueLength,
+ IN UINT8 PValue[],
+ IN UINT PValueLength,
+ IN UINT8 PrivateKey[],
+ IN UINT PrivateKeyLength,
+ OUT UINT8 PublicKey[],
+ INOUT UINT *PublicKeyLength)
+{
+ PBIG_INTEGER pBI_G = NULL;
+ PBIG_INTEGER pBI_P = NULL;
+ PBIG_INTEGER pBI_PrivateKey = NULL;
+ PBIG_INTEGER pBI_PublicKey = NULL;
+
+ /*
+ * 1. Check the input parameters
+ * - GValueLength, PValueLength and PrivateLength must be large than zero
+ * - PublicKeyLength must be large or equal than PValueLength
+ * - PValue must be odd
+ *
+ * - PValue must be prime number (no implement)
+ * - GValue must be greater than 0 but less than the PValue (no implement)
+ */
+ if (GValueLength == 0) {
+ DBGPRINT(RT_DEBUG_ERROR, ("DH_PublicKey_Generate: G length is (%d)\n", GValueLength));
+ return;
+ } /* End of if */
+ if (PValueLength == 0) {
+ DBGPRINT(RT_DEBUG_ERROR, ("DH_PublicKey_Generate: P length is (%d)\n", PValueLength));
+ return;
+ } /* End of if */
+ if (PrivateKeyLength == 0) {
+ DBGPRINT(RT_DEBUG_ERROR, ("DH_PublicKey_Generate: private key length is (%d)\n", PrivateKeyLength));
+ return;
+ } /* End of if */
+ if (*PublicKeyLength < PValueLength) {
+ DBGPRINT(RT_DEBUG_ERROR, ("DH_PublicKey_Generate: public key length(%d) must be large or equal than P length(%d)\n",
+ *PublicKeyLength, PValueLength));
+ return;
+ } /* End of if */
+ if (!(PValue[PValueLength - 1] & 0x1)) {
+ DBGPRINT(RT_DEBUG_ERROR, ("DH_PublicKey_Generate: P value must be odd\n"));
+ return;
+ } /* End of if */
+
+ /*
+ * 2. Transfer parameters to BigInteger structure
+ */
+ BigInteger_Init(&pBI_G);
+ BigInteger_Init(&pBI_P);
+ BigInteger_Init(&pBI_PrivateKey);
+ BigInteger_Init(&pBI_PublicKey);
+ BigInteger_Bin2BI(GValue, GValueLength, &pBI_G);
+ BigInteger_Bin2BI(PValue, PValueLength, &pBI_P);
+ BigInteger_Bin2BI(PrivateKey, PrivateKeyLength, &pBI_PrivateKey);
+
+ /*
+ * 3. Calculate PublicKey = G^PrivateKey (mod P)
+ * - BigInteger Operation
+ * - Montgomery reduction
+ */
+ BigInteger_Montgomery_ExpMod(pBI_G, pBI_PrivateKey, pBI_P, &pBI_PublicKey);
+
+ /*
+ * 4. Transfer BigInteger structure to char array
+ */
+ BigInteger_BI2Bin(pBI_PublicKey, PublicKey, PublicKeyLength);
+
+ BigInteger_Free(&pBI_G);
+ BigInteger_Free(&pBI_P);
+ BigInteger_Free(&pBI_PrivateKey);
+ BigInteger_Free(&pBI_PublicKey);
+} /* End of DH_PublicKey_Generate */
+
+
+/*
+========================================================================
+Routine Description:
+ Diffie-Hellman secret key generation
+
+Arguments:
+ PublicKey Public key
+ PublicKeyLength The length of Public key in bytes
+ PValue Array in UINT8
+ PValueLength The length of P in bytes
+ PrivateKey Private key
+ PrivateKeyLength The length of Private key in bytes
+
+Return Value:
+ SecretKey Secret key
+ SecretKeyLength The length of secret key in bytes
+
+Note:
+ Reference to RFC2631
+ SecretKey = PublicKey^PrivateKey (mod P)
+========================================================================
+*/
+void DH_SecretKey_Generate (
+ IN UINT8 PublicKey[],
+ IN UINT PublicKeyLength,
+ IN UINT8 PValue[],
+ IN UINT PValueLength,
+ IN UINT8 PrivateKey[],
+ IN UINT PrivateKeyLength,
+ OUT UINT8 SecretKey[],
+ INOUT UINT *SecretKeyLength)
+{
+ PBIG_INTEGER pBI_P = NULL;
+ PBIG_INTEGER pBI_SecretKey = NULL;
+ PBIG_INTEGER pBI_PrivateKey = NULL;
+ PBIG_INTEGER pBI_PublicKey = NULL;
+
+ /*
+ * 1. Check the input parameters
+ * - PublicKeyLength, PValueLength and PrivateLength must be large than zero
+ * - SecretKeyLength must be large or equal than PValueLength
+ * - PValue must be odd
+ *
+ * - PValue must be prime number (no implement)
+ */
+ if (PublicKeyLength == 0) {
+ DBGPRINT(RT_DEBUG_ERROR, ("DH_SecretKey_Generate: public key length is (%d)\n", PublicKeyLength));
+ return;
+ } /* End of if */
+ if (PValueLength == 0) {
+ DBGPRINT(RT_DEBUG_ERROR, ("DH_SecretKey_Generate: P length is (%d)\n", PValueLength));
+ return;
+ } /* End of if */
+ if (PrivateKeyLength == 0) {
+ DBGPRINT(RT_DEBUG_ERROR, ("DH_SecretKey_Generate: private key length is (%d)\n", PrivateKeyLength));
+ return;
+ } /* End of if */
+ if (*SecretKeyLength < PValueLength) {
+ DBGPRINT(RT_DEBUG_ERROR, ("DH_SecretKey_Generate: secret key length(%d) must be large or equal than P length(%d)\n",
+ *SecretKeyLength, PValueLength));
+ return;
+ } /* End of if */
+ if (!(PValue[PValueLength - 1] & 0x1)) {
+ DBGPRINT(RT_DEBUG_ERROR, ("DH_SecretKey_Generate: P value must be odd\n"));
+ return;
+ } /* End of if */
+
+ /*
+ * 2. Transfer parameters to BigInteger structure
+ */
+ BigInteger_Init(&pBI_P);
+ BigInteger_Init(&pBI_PrivateKey);
+ BigInteger_Init(&pBI_PublicKey);
+ BigInteger_Init(&pBI_SecretKey);
+
+ BigInteger_Bin2BI(PublicKey, PublicKeyLength, &pBI_PublicKey);
+ BigInteger_Bin2BI(PValue, PValueLength, &pBI_P);
+ BigInteger_Bin2BI(PrivateKey, PrivateKeyLength, &pBI_PrivateKey);
+
+ /*
+ * 3. Calculate SecretKey = PublicKey^PrivateKey (mod P)
+ * - BigInteger Operation
+ * - Montgomery reduction
+ */
+ BigInteger_Montgomery_ExpMod(pBI_PublicKey, pBI_PrivateKey, pBI_P, &pBI_SecretKey);
+
+ /*
+ * 4. Transfer BigInteger structure to char array
+ */
+ BigInteger_BI2Bin(pBI_SecretKey, SecretKey, SecretKeyLength);
+
+ BigInteger_Free(&pBI_P);
+ BigInteger_Free(&pBI_PrivateKey);
+ BigInteger_Free(&pBI_PublicKey);
+ BigInteger_Free(&pBI_SecretKey);
+} /* End of DH_SecretKey_Generate */
diff --git a/drivers/staging/rt3090/common/crypt_hmac.c b/drivers/staging/rt3090/common/crypt_hmac.c
new file mode 100644
index 000000000000..e2854082f1d9
--- /dev/null
+++ b/drivers/staging/rt3090/common/crypt_hmac.c
@@ -0,0 +1,279 @@
+/*
+ *************************************************************************
+ * 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 "../crypt_hmac.h"
+
+
+#ifdef HMAC_SHA1_SUPPORT
+/*
+========================================================================
+Routine Description:
+ HMAC using SHA1 hash function
+
+Arguments:
+ key Secret key
+ key_len The length of the key in bytes
+ message Message context
+ message_len The length of message in bytes
+ macLen Request the length of message authentication code
+
+Return Value:
+ mac Message authentication code
+
+Note:
+ None
+========================================================================
+*/
+VOID HMAC_SHA1 (
+ IN const UINT8 Key[],
+ IN UINT KeyLen,
+ IN const UINT8 Message[],
+ IN UINT MessageLen,
+ OUT UINT8 MAC[],
+ IN UINT MACLen)
+{
+ SHA1_CTX_STRUC sha_ctx1;
+ SHA1_CTX_STRUC sha_ctx2;
+ UINT8 K0[SHA1_BLOCK_SIZE];
+ UINT8 Digest[SHA1_DIGEST_SIZE];
+ UINT index;
+
+ NdisZeroMemory(&sha_ctx1, sizeof(SHA1_CTX_STRUC));
+ NdisZeroMemory(&sha_ctx2, sizeof(SHA1_CTX_STRUC));
+ /*
+ * If the length of K = B(Block size): K0 = K.
+ * If the length of K > B: hash K to obtain an L byte string,
+ * then append (B-L) zeros to create a B-byte string K0 (i.e., K0 = H(K) || 00...00).
+ * If the length of K < B: append zeros to the end of K to create a B-byte string K0
+ */
+ NdisZeroMemory(K0, SHA1_BLOCK_SIZE);
+ if (KeyLen <= SHA1_BLOCK_SIZE)
+ NdisMoveMemory(K0, Key, KeyLen);
+ else
+ RT_SHA1(Key, KeyLen, K0);
+ /* End of if */
+
+ /* Exclusive-Or K0 with ipad */
+ /* ipad: Inner pad; the byte x��36�� repeated B times. */
+ for (index = 0; index < SHA1_BLOCK_SIZE; index++)
+ K0[index] ^= 0x36;
+ /* End of for */
+
+ SHA1_Init(&sha_ctx1);
+ /* H(K0^ipad) */
+ SHA1_Append(&sha_ctx1, K0, sizeof(K0));
+ /* H((K0^ipad)||text) */
+ SHA1_Append(&sha_ctx1, Message, MessageLen);
+ SHA1_End(&sha_ctx1, Digest);
+
+ /* Exclusive-Or K0 with opad and remove ipad */
+ /* opad: Outer pad; the byte x��5c�� repeated B times. */
+ for (index = 0; index < SHA1_BLOCK_SIZE; index++)
+ K0[index] ^= 0x36^0x5c;
+ /* End of for */
+
+ SHA1_Init(&sha_ctx2);
+ /* H(K0^opad) */
+ SHA1_Append(&sha_ctx2, K0, sizeof(K0));
+ /* H( (K0^opad) || H((K0^ipad)||text) ) */
+ SHA1_Append(&sha_ctx2, Digest, SHA1_DIGEST_SIZE);
+ SHA1_End(&sha_ctx2, Digest);
+
+ if (MACLen > SHA1_DIGEST_SIZE)
+ NdisMoveMemory(MAC, Digest, SHA1_DIGEST_SIZE);
+ else
+ NdisMoveMemory(MAC, Digest, MACLen);
+} /* End of HMAC_SHA1 */
+#endif /* HMAC_SHA1_SUPPORT */
+
+
+#ifdef HMAC_SHA256_SUPPORT
+/*
+========================================================================
+Routine Description:
+ HMAC using SHA256 hash function
+
+Arguments:
+ key Secret key
+ key_len The length of the key in bytes
+ message Message context
+ message_len The length of message in bytes
+ macLen Request the length of message authentication code
+
+Return Value:
+ mac Message authentication code
+
+Note:
+ None
+========================================================================
+*/
+VOID HMAC_SHA256 (
+ IN const UINT8 Key[],
+ IN UINT KeyLen,
+ IN const UINT8 Message[],
+ IN UINT MessageLen,
+ OUT UINT8 MAC[],
+ IN UINT MACLen)
+{
+ SHA256_CTX_STRUC sha_ctx1;
+ SHA256_CTX_STRUC sha_ctx2;
+ UINT8 K0[SHA256_BLOCK_SIZE];
+ UINT8 Digest[SHA256_DIGEST_SIZE];
+ UINT index;
+
+ NdisZeroMemory(&sha_ctx1, sizeof(SHA256_CTX_STRUC));
+ NdisZeroMemory(&sha_ctx2, sizeof(SHA256_CTX_STRUC));
+ /*
+ * If the length of K = B(Block size): K0 = K.
+ * If the length of K > B: hash K to obtain an L byte string,
+ * then append (B-L) zeros to create a B-byte string K0 (i.e., K0 = H(K) || 00...00).
+ * If the length of K < B: append zeros to the end of K to create a B-byte string K0
+ */
+ NdisZeroMemory(K0, SHA256_BLOCK_SIZE);
+ if (KeyLen <= SHA256_BLOCK_SIZE) {
+ NdisMoveMemory(K0, Key, KeyLen);
+ } else {
+ RT_SHA256(Key, KeyLen, K0);
+ }
+
+ /* Exclusive-Or K0 with ipad */
+ /* ipad: Inner pad; the byte x��36�� repeated B times. */
+ for (index = 0; index < SHA256_BLOCK_SIZE; index++)
+ K0[index] ^= 0x36;
+ /* End of for */
+
+ SHA256_Init(&sha_ctx1);
+ /* H(K0^ipad) */
+ SHA256_Append(&sha_ctx1, K0, sizeof(K0));
+ /* H((K0^ipad)||text) */
+ SHA256_Append(&sha_ctx1, Message, MessageLen);
+ SHA256_End(&sha_ctx1, Digest);
+
+ /* Exclusive-Or K0 with opad and remove ipad */
+ /* opad: Outer pad; the byte x��5c�� repeated B times. */
+ for (index = 0; index < SHA256_BLOCK_SIZE; index++)
+ K0[index] ^= 0x36^0x5c;
+ /* End of for */
+
+ SHA256_Init(&sha_ctx2);
+ /* H(K0^opad) */
+ SHA256_Append(&sha_ctx2, K0, sizeof(K0));
+ /* H( (K0^opad) || H((K0^ipad)||text) ) */
+ SHA256_Append(&sha_ctx2, Digest, SHA256_DIGEST_SIZE);
+ SHA256_End(&sha_ctx2, Digest);
+
+ if (MACLen > SHA256_DIGEST_SIZE)
+ NdisMoveMemory(MAC, Digest,SHA256_DIGEST_SIZE);
+ else
+ NdisMoveMemory(MAC, Digest, MACLen);
+
+} /* End of HMAC_SHA256 */
+#endif /* HMAC_SHA256_SUPPORT */
+
+
+#ifdef HMAC_MD5_SUPPORT
+/*
+========================================================================
+Routine Description:
+ HMAC using MD5 hash function
+
+Arguments:
+ key Secret key
+ key_len The length of the key in bytes
+ message Message context
+ message_len The length of message in bytes
+ macLen Request the length of message authentication code
+
+Return Value:
+ mac Message authentication code
+
+Note:
+ None
+========================================================================
+*/
+VOID HMAC_MD5(
+ IN const UINT8 Key[],
+ IN UINT KeyLen,
+ IN const UINT8 Message[],
+ IN UINT MessageLen,
+ OUT UINT8 MAC[],
+ IN UINT MACLen)
+{
+ MD5_CTX_STRUC md5_ctx1;
+ MD5_CTX_STRUC md5_ctx2;
+ UINT8 K0[MD5_BLOCK_SIZE];
+ UINT8 Digest[MD5_DIGEST_SIZE];
+ UINT index;
+
+ NdisZeroMemory(&md5_ctx1, sizeof(MD5_CTX_STRUC));
+ NdisZeroMemory(&md5_ctx2, sizeof(MD5_CTX_STRUC));
+ /*
+ * If the length of K = B(Block size): K0 = K.
+ * If the length of K > B: hash K to obtain an L byte string,
+ * then append (B-L) zeros to create a B-byte string K0 (i.e., K0 = H(K) || 00...00).
+ * If the length of K < B: append zeros to the end of K to create a B-byte string K0
+ */
+ NdisZeroMemory(K0, MD5_BLOCK_SIZE);
+ if (KeyLen <= MD5_BLOCK_SIZE) {
+ NdisMoveMemory(K0, Key, KeyLen);
+ } else {
+ RT_MD5(Key, KeyLen, K0);
+ }
+
+ /* Exclusive-Or K0 with ipad */
+ /* ipad: Inner pad; the byte x��36�� repeated B times. */
+ for (index = 0; index < MD5_BLOCK_SIZE; index++)
+ K0[index] ^= 0x36;
+ /* End of for */
+
+ MD5_Init(&md5_ctx1);
+ /* H(K0^ipad) */
+ MD5_Append(&md5_ctx1, K0, sizeof(K0));
+ /* H((K0^ipad)||text) */
+ MD5_Append(&md5_ctx1, Message, MessageLen);
+ MD5_End(&md5_ctx1, Digest);
+
+ /* Exclusive-Or K0 with opad and remove ipad */
+ /* opad: Outer pad; the byte x��5c�� repeated B times. */
+ for (index = 0; index < MD5_BLOCK_SIZE; index++)
+ K0[index] ^= 0x36^0x5c;
+ /* End of for */
+
+ MD5_Init(&md5_ctx2);
+ /* H(K0^opad) */
+ MD5_Append(&md5_ctx2, K0, sizeof(K0));
+ /* H( (K0^opad) || H((K0^ipad)||text) ) */
+ MD5_Append(&md5_ctx2, Digest, MD5_DIGEST_SIZE);
+ MD5_End(&md5_ctx2, Digest);
+
+ if (MACLen > MD5_DIGEST_SIZE)
+ NdisMoveMemory(MAC, Digest, MD5_DIGEST_SIZE);
+ else
+ NdisMoveMemory(MAC, Digest, MACLen);
+} /* End of HMAC_SHA256 */
+#endif /* HMAC_MD5_SUPPORT */
+
+/* End of crypt_hmac.c */
diff --git a/drivers/staging/rt3090/common/crypt_md5.c b/drivers/staging/rt3090/common/crypt_md5.c
new file mode 100644
index 000000000000..b09326540f5e
--- /dev/null
+++ b/drivers/staging/rt3090/common/crypt_md5.c
@@ -0,0 +1,353 @@
+/*
+ *************************************************************************
+ * 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 "../crypt_md5.h"
+
+
+#ifdef MD5_SUPPORT
+/*
+ * F, G, H and I are basic MD5 functions.
+ */
+#define F(x, y, z) (((x) & (y)) | ((~x) & (z)))
+#define G(x, y, z) (((x) & (z)) | ((y) & (~z)))
+#define H(x, y, z) ((x) ^ (y) ^ (z))
+#define I(x, y, z) ((y) ^ ((x) | (~z)))
+
+#define ROTL(x,n,w) ((x << n) | (x >> (w - n)))
+#define ROTL32(x,n) ROTL(x,n,32) /* 32 bits word */
+
+#define ROUND1(a, b, c, d, x, s, ac) { \
+ (a) += F((b),(c),(d)) + (x) + (UINT32)(ac); \
+ (a) = ROTL32((a),(s)); \
+ (a) += (b); \
+}
+#define ROUND2(a, b, c, d, x, s, ac) { \
+ (a) += G((b),(c),(d)) + (x) + (UINT32)(ac); \
+ (a) = ROTL32((a),(s)); \
+ (a) += (b); \
+}
+#define ROUND3(a, b, c, d, x, s, ac) { \
+ (a) += H((b),(c),(d)) + (x) + (UINT32)(ac); \
+ (a) = ROTL32((a),(s)); \
+ (a) += (b); \
+}
+#define ROUND4(a, b, c, d, x, s, ac) { \
+ (a) += I((b),(c),(d)) + (x) + (UINT32)(ac); \
+ (a) = ROTL32((a),(s)); \
+ (a) += (b); \
+}
+static const UINT32 MD5_DefaultHashValue[4] = {
+ 0x67452301UL, 0xefcdab89UL, 0x98badcfeUL, 0x10325476UL
+};
+#endif /* MD5_SUPPORT */
+
+
+#ifdef MD5_SUPPORT
+/*
+========================================================================
+Routine Description:
+ Initial Md5_CTX_STRUC
+
+Arguments:
+ pMD5_CTX Pointer to Md5_CTX_STRUC
+
+Return Value:
+ None
+
+Note:
+ None
+========================================================================
+*/
+VOID MD5_Init (
+ IN MD5_CTX_STRUC *pMD5_CTX)
+{
+ NdisMoveMemory(pMD5_CTX->HashValue, MD5_DefaultHashValue,
+ sizeof(MD5_DefaultHashValue));
+ NdisZeroMemory(pMD5_CTX->Block, MD5_BLOCK_SIZE);
+ pMD5_CTX->BlockLen = 0;
+ pMD5_CTX->MessageLen = 0;
+} /* End of MD5_Init */
+
+
+/*
+========================================================================
+Routine Description:
+ MD5 computation for one block (512 bits)
+
+Arguments:
+ pMD5_CTX Pointer to Md5_CTX_STRUC
+
+Return Value:
+ None
+
+Note:
+ T[i] := floor(abs(sin(i + 1)) * (2 pow 32)), i is number of round
+========================================================================
+*/
+VOID MD5_Hash (
+ IN MD5_CTX_STRUC *pMD5_CTX)
+{
+ UINT32 X_i;
+ UINT32 X[16];
+ UINT32 a,b,c,d;
+
+ /* Prepare the message schedule, {X_i} */
+ NdisMoveMemory(X, pMD5_CTX->Block, MD5_BLOCK_SIZE);
+ for (X_i = 0; X_i < 16; X_i++)
+ X[X_i] = cpu2le32(X[X_i]); /* Endian Swap */
+ /* End of for */
+
+ /* MD5 hash computation */
+ /* Initialize the working variables */
+ a = pMD5_CTX->HashValue[0];
+ b = pMD5_CTX->HashValue[1];
+ c = pMD5_CTX->HashValue[2];
+ d = pMD5_CTX->HashValue[3];
+
+ /*
+ * Round 1
+ * Let [abcd k s i] denote the operation
+ * a = b + ((a + F(b,c,d) + X[k] + T[i]) <<< s)
+ */
+ ROUND1(a, b, c, d, X[ 0], 7, 0xd76aa478); /* 1 */
+ ROUND1(d, a, b, c, X[ 1], 12, 0xe8c7b756); /* 2 */
+ ROUND1(c, d, a, b, X[ 2], 17, 0x242070db); /* 3 */
+ ROUND1(b, c, d, a, X[ 3], 22, 0xc1bdceee); /* 4 */
+ ROUND1(a, b, c, d, X[ 4], 7, 0xf57c0faf); /* 5 */
+ ROUND1(d, a, b, c, X[ 5], 12, 0x4787c62a); /* 6 */
+ ROUND1(c, d, a, b, X[ 6], 17, 0xa8304613); /* 7 */
+ ROUND1(b, c, d, a, X[ 7], 22, 0xfd469501); /* 8 */
+ ROUND1(a, b, c, d, X[ 8], 7, 0x698098d8); /* 9 */
+ ROUND1(d, a, b, c, X[ 9], 12, 0x8b44f7af); /* 10 */
+ ROUND1(c, d, a, b, X[10], 17, 0xffff5bb1); /* 11 */
+ ROUND1(b, c, d, a, X[11], 22, 0x895cd7be); /* 12 */
+ ROUND1(a, b, c, d, X[12], 7, 0x6b901122); /* 13 */
+ ROUND1(d, a, b, c, X[13], 12, 0xfd987193); /* 14 */
+ ROUND1(c, d, a, b, X[14], 17, 0xa679438e); /* 15 */
+ ROUND1(b, c, d, a, X[15], 22, 0x49b40821); /* 16 */
+
+ /*
+ * Round 2
+ * Let [abcd k s i] denote the operation
+ * a = b + ((a + G(b,c,d) + X[k] + T[i]) <<< s)
+ */
+ ROUND2(a, b, c, d, X[ 1], 5, 0xf61e2562); /* 17 */
+ ROUND2(d, a, b, c, X[ 6], 9, 0xc040b340); /* 18 */
+ ROUND2(c, d, a, b, X[11], 14, 0x265e5a51); /* 19 */
+ ROUND2(b, c, d, a, X[ 0], 20, 0xe9b6c7aa); /* 20 */
+ ROUND2(a, b, c, d, X[ 5], 5, 0xd62f105d); /* 21 */
+ ROUND2(d, a, b, c, X[10], 9, 0x2441453); /* 22 */
+ ROUND2(c, d, a, b, X[15], 14, 0xd8a1e681); /* 23 */
+ ROUND2(b, c, d, a, X[ 4], 20, 0xe7d3fbc8); /* 24 */
+ ROUND2(a, b, c, d, X[ 9], 5, 0x21e1cde6); /* 25 */
+ ROUND2(d, a, b, c, X[14], 9, 0xc33707d6); /* 26 */
+ ROUND2(c, d, a, b, X[ 3], 14, 0xf4d50d87); /* 27 */
+ ROUND2(b, c, d, a, X[ 8], 20, 0x455a14ed); /* 28 */
+ ROUND2(a, b, c, d, X[13], 5, 0xa9e3e905); /* 29 */
+ ROUND2(d, a, b, c, X[ 2], 9, 0xfcefa3f8); /* 30 */
+ ROUND2(c, d, a, b, X[ 7], 14, 0x676f02d9); /* 31 */
+ ROUND2(b, c, d, a, X[12], 20, 0x8d2a4c8a); /* 32 */
+
+ /*
+ * Round 3
+ * Let [abcd k s t] denote the operation
+ * a = b + ((a + H(b,c,d) + X[k] + T[i]) <<< s)
+ */
+ ROUND3(a, b, c, d, X[ 5], 4, 0xfffa3942); /* 33 */
+ ROUND3(d, a, b, c, X[ 8], 11, 0x8771f681); /* 34 */
+ ROUND3(c, d, a, b, X[11], 16, 0x6d9d6122); /* 35 */
+ ROUND3(b, c, d, a, X[14], 23, 0xfde5380c); /* 36 */
+ ROUND3(a, b, c, d, X[ 1], 4, 0xa4beea44); /* 37 */
+ ROUND3(d, a, b, c, X[ 4], 11, 0x4bdecfa9); /* 38 */
+ ROUND3(c, d, a, b, X[ 7], 16, 0xf6bb4b60); /* 39 */
+ ROUND3(b, c, d, a, X[10], 23, 0xbebfbc70); /* 40 */
+ ROUND3(a, b, c, d, X[13], 4, 0x289b7ec6); /* 41 */
+ ROUND3(d, a, b, c, X[ 0], 11, 0xeaa127fa); /* 42 */
+ ROUND3(c, d, a, b, X[ 3], 16, 0xd4ef3085); /* 43 */
+ ROUND3(b, c, d, a, X[ 6], 23, 0x4881d05); /* 44 */
+ ROUND3(a, b, c, d, X[ 9], 4, 0xd9d4d039); /* 45 */
+ ROUND3(d, a, b, c, X[12], 11, 0xe6db99e5); /* 46 */
+ ROUND3(c, d, a, b, X[15], 16, 0x1fa27cf8); /* 47 */
+ ROUND3(b, c, d, a, X[ 2], 23, 0xc4ac5665); /* 48 */
+
+ /*
+ * Round 4
+ * Let [abcd k s t] denote the operation
+ * a = b + ((a + I(b,c,d) + X[k] + T[i]) <<< s)
+ */
+ ROUND4(a, b, c, d, X[ 0], 6, 0xf4292244); /* 49 */
+ ROUND4(d, a, b, c, X[ 7], 10, 0x432aff97); /* 50 */
+ ROUND4(c, d, a, b, X[14], 15, 0xab9423a7); /* 51 */
+ ROUND4(b, c, d, a, X[ 5], 21, 0xfc93a039); /* 52 */
+ ROUND4(a, b, c, d, X[12], 6, 0x655b59c3); /* 53 */
+ ROUND4(d, a, b, c, X[ 3], 10, 0x8f0ccc92); /* 54 */
+ ROUND4(c, d, a, b, X[10], 15, 0xffeff47d); /* 55 */
+ ROUND4(b, c, d, a, X[ 1], 21, 0x85845dd1); /* 56 */
+ ROUND4(a, b, c, d, X[ 8], 6, 0x6fa87e4f); /* 57 */
+ ROUND4(d, a, b, c, X[15], 10, 0xfe2ce6e0); /* 58 */
+ ROUND4(c, d, a, b, X[ 6], 15, 0xa3014314); /* 59 */
+ ROUND4(b, c, d, a, X[13], 21, 0x4e0811a1); /* 60 */
+ ROUND4(a, b, c, d, X[ 4], 6, 0xf7537e82); /* 61 */
+ ROUND4(d, a, b, c, X[11], 10, 0xbd3af235); /* 62 */
+ ROUND4(c, d, a, b, X[ 2], 15, 0x2ad7d2bb); /* 63 */
+ ROUND4(b, c, d, a, X[ 9], 21, 0xeb86d391); /* 64 */
+
+ /* Compute the i^th intermediate hash value H^(i) */
+ pMD5_CTX->HashValue[0] += a;
+ pMD5_CTX->HashValue[1] += b;
+ pMD5_CTX->HashValue[2] += c;
+ pMD5_CTX->HashValue[3] += d;
+
+ NdisZeroMemory(pMD5_CTX->Block, MD5_BLOCK_SIZE);
+ pMD5_CTX->BlockLen = 0;
+} /* End of MD5_Hash */
+
+
+/*
+========================================================================
+Routine Description:
+ The message is appended to block. If block size > 64 bytes, the MD5_Hash
+will be called.
+
+Arguments:
+ pMD5_CTX Pointer to MD5_CTX_STRUC
+ message Message context
+ messageLen The length of message in bytes
+
+Return Value:
+ None
+
+Note:
+ None
+========================================================================
+*/
+VOID MD5_Append (
+ IN MD5_CTX_STRUC *pMD5_CTX,
+ IN const UINT8 Message[],
+ IN UINT MessageLen)
+{
+ UINT appendLen = 0;
+ UINT diffLen = 0;
+
+ while (appendLen != MessageLen) {
+ diffLen = MessageLen - appendLen;
+ if ((pMD5_CTX->BlockLen + diffLen) < MD5_BLOCK_SIZE) {
+ NdisMoveMemory(pMD5_CTX->Block + pMD5_CTX->BlockLen,
+ Message + appendLen, diffLen);
+ pMD5_CTX->BlockLen += diffLen;
+ appendLen += diffLen;
+ }
+ else
+ {
+ NdisMoveMemory(pMD5_CTX->Block + pMD5_CTX->BlockLen,
+ Message + appendLen, MD5_BLOCK_SIZE - pMD5_CTX->BlockLen);
+ appendLen += (MD5_BLOCK_SIZE - pMD5_CTX->BlockLen);
+ pMD5_CTX->BlockLen = MD5_BLOCK_SIZE;
+ MD5_Hash(pMD5_CTX);
+ } /* End of if */
+ } /* End of while */
+ pMD5_CTX->MessageLen += MessageLen;
+} /* End of MD5_Append */
+
+
+/*
+========================================================================
+Routine Description:
+ 1. Append bit 1 to end of the message
+ 2. Append the length of message in rightmost 64 bits
+ 3. Transform the Hash Value to digest message
+
+Arguments:
+ pMD5_CTX Pointer to MD5_CTX_STRUC
+
+Return Value:
+ digestMessage Digest message
+
+Note:
+ None
+========================================================================
+*/
+VOID MD5_End (
+ IN MD5_CTX_STRUC *pMD5_CTX,
+ OUT UINT8 DigestMessage[])
+{
+ UINT index;
+ UINT64 message_length_bits;
+
+ /* append 1 bits to end of the message */
+ NdisFillMemory(pMD5_CTX->Block + pMD5_CTX->BlockLen, 1, 0x80);
+
+ /* 55 = 64 - 8 - 1: append 1 bit(1 byte) and message length (8 bytes) */
+ if (pMD5_CTX->BlockLen > 55)
+ MD5_Hash(pMD5_CTX);
+ /* End of if */
+
+ /* Append the length of message in rightmost 64 bits */
+ message_length_bits = pMD5_CTX->MessageLen*8;
+ message_length_bits = cpu2le64(message_length_bits);
+ NdisMoveMemory(&pMD5_CTX->Block[56], &message_length_bits, 8);
+ MD5_Hash(pMD5_CTX);
+
+ /* Return message digest, transform the UINT32 hash value to bytes */
+ for (index = 0; index < 4;index++)
+ pMD5_CTX->HashValue[index] = cpu2le32(pMD5_CTX->HashValue[index]);
+ /* End of for */
+ NdisMoveMemory(DigestMessage, pMD5_CTX->HashValue, MD5_DIGEST_SIZE);
+} /* End of MD5_End */
+
+
+/*
+========================================================================
+Routine Description:
+ MD5 algorithm
+
+Arguments:
+ message Message context
+ messageLen The length of message in bytes
+
+Return Value:
+ digestMessage Digest message
+
+Note:
+ None
+========================================================================
+*/
+VOID RT_MD5 (
+ IN const UINT8 Message[],
+ IN UINT MessageLen,
+ OUT UINT8 DigestMessage[])
+{
+ MD5_CTX_STRUC md5_ctx;
+
+ NdisZeroMemory(&md5_ctx, sizeof(MD5_CTX_STRUC));
+ MD5_Init(&md5_ctx);
+ MD5_Append(&md5_ctx, Message, MessageLen);
+ MD5_End(&md5_ctx, DigestMessage);
+} /* End of RT_MD5 */
+
+#endif /* MD5_SUPPORT */
+
+/* End of crypt_md5.c */
diff --git a/drivers/staging/rt3090/common/crypt_sha2.c b/drivers/staging/rt3090/common/crypt_sha2.c
new file mode 100644
index 000000000000..c7490d0d3c44
--- /dev/null
+++ b/drivers/staging/rt3090/common/crypt_sha2.c
@@ -0,0 +1,536 @@
+/*
+ *************************************************************************
+ * 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 "../crypt_sha2.h"
+
+
+/* Basic operations */
+#define SHR(x,n) (x >> n) /* SHR(x)^n, right shift n bits , x is w-bit word, 0 <= n <= w */
+#define ROTR(x,n,w) ((x >> n) | (x << (w - n))) /* ROTR(x)^n, circular right shift n bits , x is w-bit word, 0 <= n <= w */
+#define ROTL(x,n,w) ((x << n) | (x >> (w - n))) /* ROTL(x)^n, circular left shift n bits , x is w-bit word, 0 <= n <= w */
+#define ROTR32(x,n) ROTR(x,n,32) /* 32 bits word */
+#define ROTL32(x,n) ROTL(x,n,32) /* 32 bits word */
+
+/* Basic functions */
+#define Ch(x,y,z) ((x & y) ^ ((~x) & z))
+#define Maj(x,y,z) ((x & y) ^ (x & z) ^ (y & z))
+#define Parity(x,y,z) (x ^ y ^ z)
+
+#ifdef SHA1_SUPPORT
+/* SHA1 constants */
+#define SHA1_MASK 0x0000000f
+static const UINT32 SHA1_K[4] = {
+ 0x5a827999UL, 0x6ed9eba1UL, 0x8f1bbcdcUL, 0xca62c1d6UL
+};
+static const UINT32 SHA1_DefaultHashValue[5] = {
+ 0x67452301UL, 0xefcdab89UL, 0x98badcfeUL, 0x10325476UL, 0xc3d2e1f0UL
+};
+#endif /* SHA1_SUPPORT */
+
+
+#ifdef SHA256_SUPPORT
+/* SHA256 functions */
+#define Zsigma_256_0(x) (ROTR32(x,2) ^ ROTR32(x,13) ^ ROTR32(x,22))
+#define Zsigma_256_1(x) (ROTR32(x,6) ^ ROTR32(x,11) ^ ROTR32(x,25))
+#define Sigma_256_0(x) (ROTR32(x,7) ^ ROTR32(x,18) ^ SHR(x,3))
+#define Sigma_256_1(x) (ROTR32(x,17) ^ ROTR32(x,19) ^ SHR(x,10))
+/* SHA256 constants */
+static const UINT32 SHA256_K[64] = {
+ 0x428a2f98UL, 0x71374491UL, 0xb5c0fbcfUL, 0xe9b5dba5UL,
+ 0x3956c25bUL, 0x59f111f1UL, 0x923f82a4UL, 0xab1c5ed5UL,
+ 0xd807aa98UL, 0x12835b01UL, 0x243185beUL, 0x550c7dc3UL,
+ 0x72be5d74UL, 0x80deb1feUL, 0x9bdc06a7UL, 0xc19bf174UL,
+ 0xe49b69c1UL, 0xefbe4786UL, 0x0fc19dc6UL, 0x240ca1ccUL,
+ 0x2de92c6fUL, 0x4a7484aaUL, 0x5cb0a9dcUL, 0x76f988daUL,
+ 0x983e5152UL, 0xa831c66dUL, 0xb00327c8UL, 0xbf597fc7UL,
+ 0xc6e00bf3UL, 0xd5a79147UL, 0x06ca6351UL, 0x14292967UL,
+ 0x27b70a85UL, 0x2e1b2138UL, 0x4d2c6dfcUL, 0x53380d13UL,
+ 0x650a7354UL, 0x766a0abbUL, 0x81c2c92eUL, 0x92722c85UL,
+ 0xa2bfe8a1UL, 0xa81a664bUL, 0xc24b8b70UL, 0xc76c51a3UL,
+ 0xd192e819UL, 0xd6990624UL, 0xf40e3585UL, 0x106aa070UL,
+ 0x19a4c116UL, 0x1e376c08UL, 0x2748774cUL, 0x34b0bcb5UL,
+ 0x391c0cb3UL, 0x4ed8aa4aUL, 0x5b9cca4fUL, 0x682e6ff3UL,
+ 0x748f82eeUL, 0x78a5636fUL, 0x84c87814UL, 0x8cc70208UL,
+ 0x90befffaUL, 0xa4506cebUL, 0xbef9a3f7UL, 0xc67178f2UL
+};
+static const UINT32 SHA256_DefaultHashValue[8] = {
+ 0x6a09e667UL, 0xbb67ae85UL, 0x3c6ef372UL, 0xa54ff53aUL,
+ 0x510e527fUL, 0x9b05688cUL, 0x1f83d9abUL, 0x5be0cd19UL
+};
+#endif /* SHA256_SUPPORT */
+
+
+#ifdef SHA1_SUPPORT
+/*
+========================================================================
+Routine Description:
+ Initial SHA1_CTX_STRUC
+
+Arguments:
+ pSHA_CTX Pointer to SHA1_CTX_STRUC
+
+Return Value:
+ None
+
+Note:
+ None
+========================================================================
+*/
+VOID SHA1_Init (
+ IN SHA1_CTX_STRUC *pSHA_CTX)
+{
+ NdisMoveMemory(pSHA_CTX->HashValue, SHA1_DefaultHashValue,
+ sizeof(SHA1_DefaultHashValue));
+ NdisZeroMemory(pSHA_CTX->Block, SHA1_BLOCK_SIZE);
+ pSHA_CTX->MessageLen = 0;
+ pSHA_CTX->BlockLen = 0;
+} /* End of SHA1_Init */
+
+
+/*
+========================================================================
+Routine Description:
+ SHA1 computation for one block (512 bits)
+
+Arguments:
+ pSHA_CTX Pointer to SHA1_CTX_STRUC
+
+Return Value:
+ None
+
+Note:
+ None
+========================================================================
+*/
+VOID SHA1_Hash (
+ IN SHA1_CTX_STRUC *pSHA_CTX)
+{
+ UINT32 W_i,t,s;
+ UINT32 W[16];
+ UINT32 a,b,c,d,e,T,f_t = 0;
+
+ /* Prepare the message schedule, {W_i}, 0 < t < 15 */
+ NdisMoveMemory(W, pSHA_CTX->Block, SHA1_BLOCK_SIZE);
+ for (W_i = 0; W_i < 16; W_i++)
+ W[W_i] = cpu2be32(W[W_i]); /* Endian Swap */
+ /* End of for */
+
+ /* SHA256 hash computation */
+ /* Initialize the working variables */
+ a = pSHA_CTX->HashValue[0];
+ b = pSHA_CTX->HashValue[1];
+ c = pSHA_CTX->HashValue[2];
+ d = pSHA_CTX->HashValue[3];
+ e = pSHA_CTX->HashValue[4];
+
+ /* 80 rounds */
+ for (t = 0;t < 80;t++) {
+ s = t & SHA1_MASK;
+ if (t > 15) { /* Prepare the message schedule, {W_i}, 16 < t < 79 */
+ W[s] = (W[(s+13) & SHA1_MASK]) ^ (W[(s+8) & SHA1_MASK]) ^ (W[(s+2) & SHA1_MASK]) ^ W[s];
+ W[s] = ROTL32(W[s],1);
+ } /* End of if */
+ switch (t / 20) {
+ case 0:
+ f_t = Ch(b,c,d);
+ break;
+ case 1:
+ f_t = Parity(b,c,d);
+ break;
+ case 2:
+ f_t = Maj(b,c,d);
+ break;
+ case 3:
+ f_t = Parity(b,c,d);
+ break;
+ } /* End of switch */
+ T = ROTL32(a,5) + f_t + e + SHA1_K[t / 20] + W[s];
+ e = d;
+ d = c;
+ c = ROTL32(b,30);
+ b = a;
+ a = T;
+ } /* End of for */
+
+ /* Compute the i^th intermediate hash value H^(i) */
+ pSHA_CTX->HashValue[0] += a;
+ pSHA_CTX->HashValue[1] += b;
+ pSHA_CTX->HashValue[2] += c;
+ pSHA_CTX->HashValue[3] += d;
+ pSHA_CTX->HashValue[4] += e;
+
+ NdisZeroMemory(pSHA_CTX->Block, SHA1_BLOCK_SIZE);
+ pSHA_CTX->BlockLen = 0;
+} /* End of SHA1_Hash */
+
+
+/*
+========================================================================
+Routine Description:
+ The message is appended to block. If block size > 64 bytes, the SHA1_Hash
+will be called.
+
+Arguments:
+ pSHA_CTX Pointer to SHA1_CTX_STRUC
+ message Message context
+ messageLen The length of message in bytes
+
+Return Value:
+ None
+
+Note:
+ None
+========================================================================
+*/
+VOID SHA1_Append (
+ IN SHA1_CTX_STRUC *pSHA_CTX,
+ IN const UINT8 Message[],
+ IN UINT MessageLen)
+{
+ UINT appendLen = 0;
+ UINT diffLen = 0;
+
+ while (appendLen != MessageLen) {
+ diffLen = MessageLen - appendLen;
+ if ((pSHA_CTX->BlockLen + diffLen) < SHA1_BLOCK_SIZE) {
+ NdisMoveMemory(pSHA_CTX->Block + pSHA_CTX->BlockLen,
+ Message + appendLen, diffLen);
+ pSHA_CTX->BlockLen += diffLen;
+ appendLen += diffLen;
+ }
+ else
+ {
+ NdisMoveMemory(pSHA_CTX->Block + pSHA_CTX->BlockLen,
+ Message + appendLen, SHA1_BLOCK_SIZE - pSHA_CTX->BlockLen);
+ appendLen += (SHA1_BLOCK_SIZE - pSHA_CTX->BlockLen);
+ pSHA_CTX->BlockLen = SHA1_BLOCK_SIZE;
+ SHA1_Hash(pSHA_CTX);
+ } /* End of if */
+ } /* End of while */
+ pSHA_CTX->MessageLen += MessageLen;
+} /* End of SHA1_Append */
+
+
+/*
+========================================================================
+Routine Description:
+ 1. Append bit 1 to end of the message
+ 2. Append the length of message in rightmost 64 bits
+ 3. Transform the Hash Value to digest message
+
+Arguments:
+ pSHA_CTX Pointer to SHA1_CTX_STRUC
+
+Return Value:
+ digestMessage Digest message
+
+Note:
+ None
+========================================================================
+*/
+VOID SHA1_End (
+ IN SHA1_CTX_STRUC *pSHA_CTX,
+ OUT UINT8 DigestMessage[])
+{
+ UINT index;
+ UINT64 message_length_bits;
+
+ /* Append bit 1 to end of the message */
+ NdisFillMemory(pSHA_CTX->Block + pSHA_CTX->BlockLen, 1, 0x80);
+
+ /* 55 = 64 - 8 - 1: append 1 bit(1 byte) and message length (8 bytes) */
+ if (pSHA_CTX->BlockLen > 55)
+ SHA1_Hash(pSHA_CTX);
+ /* End of if */
+
+ /* Append the length of message in rightmost 64 bits */
+ message_length_bits = pSHA_CTX->MessageLen*8;
+ message_length_bits = cpu2be64(message_length_bits);
+ NdisMoveMemory(&pSHA_CTX->Block[56], &message_length_bits, 8);
+ SHA1_Hash(pSHA_CTX);
+
+ /* Return message digest, transform the UINT32 hash value to bytes */
+ for (index = 0; index < 5;index++)
+ pSHA_CTX->HashValue[index] = cpu2be32(pSHA_CTX->HashValue[index]);
+ /* End of for */
+ NdisMoveMemory(DigestMessage, pSHA_CTX->HashValue, SHA1_DIGEST_SIZE);
+} /* End of SHA1_End */
+
+
+/*
+========================================================================
+Routine Description:
+ SHA1 algorithm
+
+Arguments:
+ message Message context
+ messageLen The length of message in bytes
+
+Return Value:
+ digestMessage Digest message
+
+Note:
+ None
+========================================================================
+*/
+VOID RT_SHA1 (
+ IN const UINT8 Message[],
+ IN UINT MessageLen,
+ OUT UINT8 DigestMessage[])
+{
+
+ SHA1_CTX_STRUC sha_ctx;
+
+ NdisZeroMemory(&sha_ctx, sizeof(SHA1_CTX_STRUC));
+ SHA1_Init(&sha_ctx);
+ SHA1_Append(&sha_ctx, Message, MessageLen);
+ SHA1_End(&sha_ctx, DigestMessage);
+} /* End of RT_SHA1 */
+#endif /* SHA1_SUPPORT */
+
+
+#ifdef SHA256_SUPPORT
+/*
+========================================================================
+Routine Description:
+ Initial SHA256_CTX_STRUC
+
+Arguments:
+ pSHA_CTX Pointer to SHA256_CTX_STRUC
+
+Return Value:
+ None
+
+Note:
+ None
+========================================================================
+*/
+VOID SHA256_Init (
+ IN SHA256_CTX_STRUC *pSHA_CTX)
+{
+ NdisMoveMemory(pSHA_CTX->HashValue, SHA256_DefaultHashValue,
+ sizeof(SHA256_DefaultHashValue));
+ NdisZeroMemory(pSHA_CTX->Block, SHA256_BLOCK_SIZE);
+ pSHA_CTX->MessageLen = 0;
+ pSHA_CTX->BlockLen = 0;
+} /* End of SHA256_Init */
+
+
+/*
+========================================================================
+Routine Description:
+ SHA256 computation for one block (512 bits)
+
+Arguments:
+ pSHA_CTX Pointer to SHA256_CTX_STRUC
+
+Return Value:
+ None
+
+Note:
+ None
+========================================================================
+*/
+VOID SHA256_Hash (
+ IN SHA256_CTX_STRUC *pSHA_CTX)
+{
+ UINT32 W_i,t;
+ UINT32 W[64];
+ UINT32 a,b,c,d,e,f,g,h,T1,T2;
+
+ /* Prepare the message schedule, {W_i}, 0 < t < 15 */
+ NdisMoveMemory(W, pSHA_CTX->Block, SHA256_BLOCK_SIZE);
+ for (W_i = 0; W_i < 16; W_i++)
+ W[W_i] = cpu2be32(W[W_i]); /* Endian Swap */
+ /* End of for */
+
+ /* SHA256 hash computation */
+ /* Initialize the working variables */
+ a = pSHA_CTX->HashValue[0];
+ b = pSHA_CTX->HashValue[1];
+ c = pSHA_CTX->HashValue[2];
+ d = pSHA_CTX->HashValue[3];
+ e = pSHA_CTX->HashValue[4];
+ f = pSHA_CTX->HashValue[5];
+ g = pSHA_CTX->HashValue[6];
+ h = pSHA_CTX->HashValue[7];
+
+ /* 64 rounds */
+ for (t = 0;t < 64;t++) {
+ if (t > 15) /* Prepare the message schedule, {W_i}, 16 < t < 63 */
+ W[t] = Sigma_256_1(W[t-2]) + W[t-7] + Sigma_256_0(W[t-15]) + W[t-16];
+ /* End of if */
+ T1 = h + Zsigma_256_1(e) + Ch(e,f,g) + SHA256_K[t] + W[t];
+ T2 = Zsigma_256_0(a) + Maj(a,b,c);
+ h = g;
+ g = f;
+ f = e;
+ e = d + T1;
+ d = c;
+ c = b;
+ b = a;
+ a = T1 + T2;
+ } /* End of for */
+
+ /* Compute the i^th intermediate hash value H^(i) */
+ pSHA_CTX->HashValue[0] += a;
+ pSHA_CTX->HashValue[1] += b;
+ pSHA_CTX->HashValue[2] += c;
+ pSHA_CTX->HashValue[3] += d;
+ pSHA_CTX->HashValue[4] += e;
+ pSHA_CTX->HashValue[5] += f;
+ pSHA_CTX->HashValue[6] += g;
+ pSHA_CTX->HashValue[7] += h;
+
+ NdisZeroMemory(pSHA_CTX->Block, SHA256_BLOCK_SIZE);
+ pSHA_CTX->BlockLen = 0;
+} /* End of SHA256_Hash */
+
+
+/*
+========================================================================
+Routine Description:
+ The message is appended to block. If block size > 64 bytes, the SHA256_Hash
+will be called.
+
+Arguments:
+ pSHA_CTX Pointer to SHA256_CTX_STRUC
+ message Message context
+ messageLen The length of message in bytes
+
+Return Value:
+ None
+
+Note:
+ None
+========================================================================
+*/
+VOID SHA256_Append (
+ IN SHA256_CTX_STRUC *pSHA_CTX,
+ IN const UINT8 Message[],
+ IN UINT MessageLen)
+{
+ UINT appendLen = 0;
+ UINT diffLen = 0;
+
+ while (appendLen != MessageLen) {
+ diffLen = MessageLen - appendLen;
+ if ((pSHA_CTX->BlockLen + diffLen) < SHA256_BLOCK_SIZE) {
+ NdisMoveMemory(pSHA_CTX->Block + pSHA_CTX->BlockLen,
+ Message + appendLen, diffLen);
+ pSHA_CTX->BlockLen += diffLen;
+ appendLen += diffLen;
+ }
+ else
+ {
+ NdisMoveMemory(pSHA_CTX->Block + pSHA_CTX->BlockLen,
+ Message + appendLen, SHA256_BLOCK_SIZE - pSHA_CTX->BlockLen);
+ appendLen += (SHA256_BLOCK_SIZE - pSHA_CTX->BlockLen);
+ pSHA_CTX->BlockLen = SHA256_BLOCK_SIZE;
+ SHA256_Hash(pSHA_CTX);
+ } /* End of if */
+ } /* End of while */
+ pSHA_CTX->MessageLen += MessageLen;
+} /* End of SHA256_Append */
+
+
+/*
+========================================================================
+Routine Description:
+ 1. Append bit 1 to end of the message
+ 2. Append the length of message in rightmost 64 bits
+ 3. Transform the Hash Value to digest message
+
+Arguments:
+ pSHA_CTX Pointer to SHA256_CTX_STRUC
+
+Return Value:
+ digestMessage Digest message
+
+Note:
+ None
+========================================================================
+*/
+VOID SHA256_End (
+ IN SHA256_CTX_STRUC *pSHA_CTX,
+ OUT UINT8 DigestMessage[])
+{
+ UINT index;
+ UINT64 message_length_bits;
+
+ /* Append bit 1 to end of the message */
+ NdisFillMemory(pSHA_CTX->Block + pSHA_CTX->BlockLen, 1, 0x80);
+
+ /* 55 = 64 - 8 - 1: append 1 bit(1 byte) and message length (8 bytes) */
+ if (pSHA_CTX->BlockLen > 55)
+ SHA256_Hash(pSHA_CTX);
+ /* End of if */
+
+ /* Append the length of message in rightmost 64 bits */
+ message_length_bits = pSHA_CTX->MessageLen*8;
+ message_length_bits = cpu2be64(message_length_bits);
+ NdisMoveMemory(&pSHA_CTX->Block[56], &message_length_bits, 8);
+ SHA256_Hash(pSHA_CTX);
+
+ /* Return message digest, transform the UINT32 hash value to bytes */
+ for (index = 0; index < 8;index++)
+ pSHA_CTX->HashValue[index] = cpu2be32(pSHA_CTX->HashValue[index]);
+ /* End of for */
+ NdisMoveMemory(DigestMessage, pSHA_CTX->HashValue, SHA256_DIGEST_SIZE);
+} /* End of SHA256_End */
+
+
+/*
+========================================================================
+Routine Description:
+ SHA256 algorithm
+
+Arguments:
+ message Message context
+ messageLen The length of message in bytes
+
+Return Value:
+ digestMessage Digest message
+
+Note:
+ None
+========================================================================
+*/
+VOID RT_SHA256 (
+ IN const UINT8 Message[],
+ IN UINT MessageLen,
+ OUT UINT8 DigestMessage[])
+{
+ SHA256_CTX_STRUC sha_ctx;
+
+ NdisZeroMemory(&sha_ctx, sizeof(SHA256_CTX_STRUC));
+ SHA256_Init(&sha_ctx);
+ SHA256_Append(&sha_ctx, Message, MessageLen);
+ SHA256_End(&sha_ctx, DigestMessage);
+} /* End of RT_SHA256 */
+#endif /* SHA256_SUPPORT */
+
+/* End of crypt_sha2.c */
diff --git a/drivers/staging/rt3090/common/dfs.c b/drivers/staging/rt3090/common/dfs.c
new file mode 100644
index 000000000000..c15704ae2f24
--- /dev/null
+++ b/drivers/staging/rt3090/common/dfs.c
@@ -0,0 +1,481 @@
+/*
+ *************************************************************************
+ * 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
+ -------- ---------- ----------------------------------------------
+*/
+
+#include "../rt_config.h"
+
+
+typedef struct _RADAR_DURATION_TABLE
+{
+ ULONG RDDurRegion;
+ ULONG RadarSignalDuration;
+ ULONG Tolerance;
+} RADAR_DURATION_TABLE, *PRADAR_DURATION_TABLE;
+
+
+
+UCHAR RdIdleTimeTable[MAX_RD_REGION][4] =
+{
+ {9, 250, 250, 250}, // CE
+#ifdef DFS_FCC_BW40_FIX
+ {1, 250, 250, 250}, // FCC
+#else
+ {4, 250, 250, 250}, // FCC
+#endif
+ {4, 250, 250, 250}, // JAP
+ {15, 250, 250, 250}, // JAP_W53
+ {4, 250, 250, 250} // JAP_W56
+};
+
+#ifdef TONE_RADAR_DETECT_SUPPORT
+static void ToneRadarProgram(PRTMP_ADAPTER pAd);
+static void ToneRadarEnable(PRTMP_ADAPTER pAd);
+#endif // TONE_RADAR_DETECT_SUPPORT //
+
+#ifdef DFS_SUPPORT
+/*
+ ========================================================================
+
+ 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);
+
+#ifdef MERGE_ARCH_TEAM
+ if ((pAd->CommonCfg.RadarDetect.RDDurRegion == JAP) || (pAd->CommonCfg.RadarDetect.RDDurRegion == JAP_W53) || (pAd->CommonCfg.RadarDetect.RDDurRegion == JAP_W56))
+ {
+ pAd->CommonCfg.RadarDetect.RDDurRegion = JAP;
+ pAd->CommonCfg.RadarDetect.RDDurRegion = JapRadarType(pAd);
+ if (pAd->CommonCfg.RadarDetect.RDDurRegion == JAP_W56)
+ {
+ pAd->CommonCfg.RadarDetect.DfsSessionTime = 13;
+ }
+ else if (pAd->CommonCfg.RadarDetect.RDDurRegion == JAP_W53)
+ {
+ pAd->CommonCfg.RadarDetect.DfsSessionTime = 15;
+ }
+#ifdef CARRIER_DETECTION_SUPPORT
+ pAd->CommonCfg.CarrierDetect.Enable = 1;
+#endif // CARRIER_DETECTION_SUPPORT //
+ }
+#endif // MERGE_ARCH_TEAM //
+
+ 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;
+
+#ifdef MERGE_ARCH_TEAM
+
+
+#else // Original RT28xx source code.
+ RTMP_IO_WRITE8(pAd, 0x7020, 0x1d);
+ RTMP_IO_WRITE8(pAd, 0x7021, 0x40);
+#endif // MERGE_ARCH_TEAM //
+
+ 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 JAP:
+ {
+ UCHAR RDDurRegion;
+ RDDurRegion = JapRadarType(pAd);
+ if (RDDurRegion == JAP_W56)
+ CtsProtect = 0x03;
+ else
+ CtsProtect = 0x02;
+ 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;
+}
+#endif // DFS_SUPPORT //
+
+
+/*
+ ========================================================================
+
+ 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)
+{
+ 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;
+}
+
+#ifdef DFS_SUPPORT
+
+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;
+}
+#endif // DFS_SUPPORT //
+
+#ifdef DFS_SUPPORT
+/*
+ ==========================================================================
+ 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 PSTRING arg)
+{
+ UINT8 Value;
+
+ Value = (UINT8) 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 PSTRING arg)
+{
+ UINT8 Value;
+
+ Value = (UINT8) 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;
+}
+#endif // DFS_SUPPORT //
diff --git a/drivers/staging/rt3090/common/ee_efuse.c b/drivers/staging/rt3090/common/ee_efuse.c
new file mode 100644
index 000000000000..c51e3059bf4c
--- /dev/null
+++ b/drivers/staging/rt3090/common/ee_efuse.c
@@ -0,0 +1,1548 @@
+/*
+ *************************************************************************
+ * 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:
+ ee_efuse.c
+
+ Abstract:
+ Miniport generic portion header file
+
+ Revision History:
+ Who When What
+ -------- ---------- ----------------------------------------------
+*/
+
+#include "../rt_config.h"
+
+
+#define EFUSE_USAGE_MAP_START 0x2d0
+#define EFUSE_USAGE_MAP_END 0x2fc
+#define EFUSE_USAGE_MAP_SIZE 45
+
+
+
+#define EFUSE_EEPROM_DEFULT_FILE "RT30xxEEPROM.bin"
+#define MAX_EEPROM_BIN_FILE_SIZE 1024
+
+
+
+#define EFUSE_TAG 0x2fe
+
+
+#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 //
+
+static UCHAR eFuseReadRegisters(
+ IN PRTMP_ADAPTER pAd,
+ IN USHORT Offset,
+ IN USHORT Length,
+ OUT USHORT* pData);
+
+static VOID eFuseReadPhysical(
+ IN PRTMP_ADAPTER pAd,
+ IN PUSHORT lpInBuffer,
+ IN ULONG nInBufferSize,
+ OUT PUSHORT lpOutBuffer,
+ IN ULONG nOutBufferSize);
+
+static VOID eFusePhysicalWriteRegisters(
+ IN PRTMP_ADAPTER pAd,
+ IN USHORT Offset,
+ IN USHORT Length,
+ OUT USHORT* pData);
+
+static NTSTATUS eFuseWriteRegisters(
+ IN PRTMP_ADAPTER pAd,
+ IN USHORT Offset,
+ IN USHORT Length,
+ IN USHORT* pData);
+
+static VOID eFuseWritePhysical(
+ IN PRTMP_ADAPTER pAd,
+ PUSHORT lpInBuffer,
+ ULONG nInBufferSize,
+ PUCHAR lpOutBuffer,
+ ULONG nOutBufferSize);
+
+
+static NTSTATUS eFuseWriteRegistersFromBin(
+ IN PRTMP_ADAPTER pAd,
+ IN USHORT Offset,
+ IN USHORT Length,
+ IN USHORT* pData);
+
+
+/*
+========================================================================
+
+ Routine Description:
+
+ Arguments:
+
+ Return Value:
+
+ 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, &eFuseCtrlStruc.word);
+
+ //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 < 500)
+ {
+ //rtmp.HwMemoryReadDword(EFUSE_CTRL, (DWORD *) &eFuseCtrlStruc, 4);
+ RTMP_IO_READ32(pAd, EFUSE_CTRL, &eFuseCtrlStruc.word);
+ 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 // RT_BIG_ENDIAN //
+
+ NdisMoveMemory(pData, &data, Length);
+ }
+
+ return (UCHAR) eFuseCtrlStruc.field.EFSROM_AOUT;
+
+}
+
+/*
+========================================================================
+
+ Routine Description:
+
+ Arguments:
+
+ Return Value:
+
+ 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, &eFuseCtrlStruc.word);
+
+ //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 < 500)
+ {
+ RTMP_IO_READ32(pAd, EFUSE_CTRL, &eFuseCtrlStruc.word);
+ 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 // RT_BIG_ENDIAN //
+
+ NdisMoveMemory(pData, &data, Length);
+
+}
+
+/*
+========================================================================
+
+ Routine Description:
+
+ Arguments:
+
+ Return Value:
+
+ Note:
+
+========================================================================
+*/
+static 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:
+
+ 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:
+
+ Note:
+
+========================================================================
+*/
+static 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, &eFuseCtrlStruc.word);
+
+ //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 < 500)
+ {
+ RTMP_IO_READ32(pAd, EFUSE_CTRL, &eFuseCtrlStruc.word);
+
+ 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.
+
+ RTMP_IO_READ32(pAd, EFUSE_CTRL, &eFuseCtrlStruc.word);
+
+ 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 < 500)
+ {
+ RTMP_IO_READ32(pAd, EFUSE_CTRL, &eFuseCtrlStruc.word);
+
+ if(eFuseCtrlStruc.field.EFSROM_KICK == 0)
+ break;
+
+ RTMPusecDelay(2);
+ i++;
+ }
+}
+
+/*
+========================================================================
+
+ Routine Description:
+
+ Arguments:
+
+ Return Value:
+
+ Note:
+
+========================================================================
+*/
+static NTSTATUS eFuseWriteRegisters(
+ IN PRTMP_ADAPTER pAd,
+ IN USHORT Offset,
+ IN USHORT Length,
+ IN USHORT* pData)
+{
+ USHORT i,Loop=0;
+ 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
+ { Loop++;
+ //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&&Loop<2);
+ if(!bWriteSuccess)
+ DBGPRINT(RT_DEBUG_ERROR,("Efsue Write Failed!!\n"));
+ return TRUE;
+}
+
+
+/*
+========================================================================
+
+ Routine Description:
+
+ Arguments:
+
+ Return Value:
+
+ Note:
+
+========================================================================
+*/
+static 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 ...
+
+ DBGPRINT(RT_DEBUG_TRACE, ("eFuseWritePhysical Offset=0x%x, length=%d\n", Offset, Length));
+
+ {
+ // 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:
+
+ 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:
+
+ Note:
+
+========================================================================
+*/
+INT set_eFuseGetFreeBlockCount_Proc(
+ IN PRTMP_ADAPTER pAd,
+ IN PSTRING 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 PSTRING 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 PSTRING arg)
+{
+ PSTRING src;
+ RTMP_OS_FD srcf;
+ RTMP_OS_FS_INFO osfsInfo;
+ INT retval, memSize;
+ PSTRING buffer, memPtr;
+ INT i = 0,j=0,k=1;
+ USHORT *PDATA;
+ USHORT DATA;
+
+ memSize = 128 + MAX_EEPROM_BIN_FILE_SIZE + sizeof(USHORT) * 8;
+ memPtr = kmalloc(memSize, MEM_ALLOC_FLAG);
+ if (memPtr == NULL)
+ return FALSE;
+
+ NdisZeroMemory(memPtr, memSize);
+ src = memPtr; // kmalloc(128, MEM_ALLOC_FLAG);
+ buffer = src + 128; // kmalloc(MAX_EEPROM_BIN_FILE_SIZE, MEM_ALLOC_FLAG);
+ PDATA = (USHORT*)(buffer + MAX_EEPROM_BIN_FILE_SIZE); // kmalloc(sizeof(USHORT)*8,MEM_ALLOC_FLAG);
+
+ if(strlen(arg)>0)
+ NdisMoveMemory(src, arg, strlen(arg));
+ else
+ NdisMoveMemory(src, EFUSE_EEPROM_DEFULT_FILE, strlen(EFUSE_EEPROM_DEFULT_FILE));
+ DBGPRINT(RT_DEBUG_TRACE, ("FileName=%s\n",src));
+
+ RtmpOSFSInfoChange(&osfsInfo, TRUE);
+
+ srcf = RtmpOSFileOpen(src, O_RDONLY, 0);
+ if (IS_FILE_OPEN_ERR(srcf))
+ {
+ DBGPRINT(RT_DEBUG_ERROR, ("--> Error opening file %s\n", src));
+ retval = FALSE;
+ goto recoverFS;
+ }
+ else
+ {
+ // The object must have a read method
+ while(RtmpOSFileRead(srcf, &buffer[i], 1)==1)
+ {
+ i++;
+ if(i>MAX_EEPROM_BIN_FILE_SIZE)
+ {
+ DBGPRINT(RT_DEBUG_ERROR, ("--> Error reading file %s, file size too large[>%d]\n", src, MAX_EEPROM_BIN_FILE_SIZE));
+ retval = FALSE;
+ goto closeFile;
+ }
+ }
+
+ retval = RtmpOSFileClose(srcf);
+ if (retval)
+ DBGPRINT(RT_DEBUG_TRACE, ("--> Error closing file %s\n", src));
+ }
+
+
+ RtmpOSFSInfoChange(&osfsInfo, FALSE);
+
+ for(j=0;j<i;j++)
+ {
+ DBGPRINT(RT_DEBUG_TRACE, ("%02X ",buffer[j]&0xff));
+ 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);
+ }
+ }
+ }
+
+ return TRUE;
+
+closeFile:
+ if (srcf)
+ RtmpOSFileClose(srcf);
+
+recoverFS:
+ RtmpOSFSInfoChange(&osfsInfo, FALSE);
+
+
+ if (memPtr)
+ kfree(memPtr);
+
+ return retval;
+}
+
+
+static 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.
+ RTMP_IO_READ32(pAd, EFUSE_CTRL, &eFuseCtrlStruc.word);
+ 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, &eFuseCtrlStruc.word);
+
+ //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 < 500)
+ {
+ 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;
+}
+
+
+int rtmp_ee_efuse_read16(
+ IN RTMP_ADAPTER *pAd,
+ IN USHORT Offset,
+ OUT USHORT *pValue)
+{
+ if(pAd->bFroceEEPROMBuffer || pAd->bEEPROMFile)
+ {
+ DBGPRINT(RT_DEBUG_TRACE, ("Read from EEPROM Buffer\n"));
+ NdisMoveMemory(pValue, &(pAd->EEPROMImage[Offset]), 2);
+ }
+ else
+ eFuseReadRegisters(pAd, Offset, 2, pValue);
+ return (*pValue);
+}
+
+
+int rtmp_ee_efuse_write16(
+ IN RTMP_ADAPTER *pAd,
+ IN USHORT Offset,
+ IN USHORT data)
+{
+ if(pAd->bFroceEEPROMBuffer||pAd->bEEPROMFile)
+ {
+ DBGPRINT(RT_DEBUG_TRACE, ("Write to EEPROM Buffer\n"));
+ NdisMoveMemory(&(pAd->EEPROMImage[Offset]), &data, 2);
+ }
+ else
+ eFuseWriteRegisters(pAd, Offset, 2, &data);
+ return 0;
+}
+
+
+int RtmpEfuseSupportCheck(
+ IN RTMP_ADAPTER *pAd)
+{
+ USHORT value;
+
+ if (IS_RT30xx(pAd))
+ {
+ eFusePhysicalReadRegisters(pAd, EFUSE_TAG, 2, &value);
+ pAd->EFuseTag = (value & 0xff);
+ }
+ return 0;
+}
+
+INT set_eFuseBufferModeWriteBack_Proc(
+ IN PRTMP_ADAPTER pAd,
+ IN PSTRING arg)
+{
+ UINT Enable;
+
+
+ if(strlen(arg)>0)
+ {
+ Enable= simple_strtol(arg, 0, 16);
+ }
+ else
+ return FALSE;
+ if(Enable==1)
+ {
+ DBGPRINT(RT_DEBUG_TRACE, ("set_eFuseBufferMode_Proc:: Call WRITEEEPROMBUF"));
+ eFuseWriteEeeppromBuf(pAd);
+ }
+ else
+ return FALSE;
+ return TRUE;
+}
+
+
+/*
+ ========================================================================
+
+ Routine Description:
+ Load EEPROM from bin file for eFuse mode
+
+ Arguments:
+ Adapter Pointer to our adapter
+
+ Return Value:
+ NDIS_STATUS_SUCCESS firmware image load ok
+ NDIS_STATUS_FAILURE image not found
+
+ IRQL = PASSIVE_LEVEL
+
+ ========================================================================
+*/
+INT eFuseLoadEEPROM(
+ IN PRTMP_ADAPTER pAd)
+{
+ PSTRING src = NULL;
+ INT retval;
+ RTMP_OS_FD srcf;
+ RTMP_OS_FS_INFO osFSInfo;
+
+
+ src=EFUSE_BUFFER_PATH;
+ DBGPRINT(RT_DEBUG_TRACE, ("FileName=%s\n",src));
+
+
+ RtmpOSFSInfoChange(&osFSInfo, TRUE);
+
+ if (src && *src)
+ {
+ srcf = RtmpOSFileOpen(src, O_RDONLY, 0);
+ if (IS_FILE_OPEN_ERR(srcf))
+ {
+ DBGPRINT(RT_DEBUG_ERROR, ("--> Error %ld opening %s\n", -PTR_ERR(srcf),src));
+ return FALSE;
+ }
+ else
+ {
+
+ memset(pAd->EEPROMImage, 0x00, MAX_EEPROM_BIN_FILE_SIZE);
+
+
+ retval =RtmpOSFileRead(srcf, (PSTRING)pAd->EEPROMImage, MAX_EEPROM_BIN_FILE_SIZE);
+ if (retval > 0)
+ {
+ RTMPSetProfileParameters(pAd, (PSTRING)pAd->EEPROMImage);
+ retval = NDIS_STATUS_SUCCESS;
+ }
+ else
+ DBGPRINT(RT_DEBUG_ERROR, ("Read file \"%s\" failed(errCode=%d)!\n", src, retval));
+
+ }
+
+
+ }
+ else
+ {
+ DBGPRINT(RT_DEBUG_ERROR, ("--> Error src or srcf is null\n"));
+ return FALSE;
+
+ }
+
+ retval=RtmpOSFileClose(srcf);
+
+ if (retval)
+ {
+ DBGPRINT(RT_DEBUG_TRACE, ("--> Error %d closing %s\n", -retval, src));
+ }
+
+
+ RtmpOSFSInfoChange(&osFSInfo, FALSE);
+
+ return TRUE;
+}
+
+INT eFuseWriteEeeppromBuf(
+ IN PRTMP_ADAPTER pAd)
+{
+
+ PSTRING src = NULL;
+ INT retval;
+ RTMP_OS_FD srcf;
+ RTMP_OS_FS_INFO osFSInfo;
+
+
+ src=EFUSE_BUFFER_PATH;
+ DBGPRINT(RT_DEBUG_TRACE, ("FileName=%s\n",src));
+
+ RtmpOSFSInfoChange(&osFSInfo, TRUE);
+
+
+
+ if (src && *src)
+ {
+ srcf = RtmpOSFileOpen(src, O_WRONLY|O_CREAT, 0);
+
+ if (IS_FILE_OPEN_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->write)
+ {
+ // The object must have a read method
+ srcf->f_op->write(srcf, pAd->EEPROMImage, 1024, &srcf->f_pos);
+
+ }
+ else
+ {
+ DBGPRINT(RT_DEBUG_ERROR, ("--> Error!! System doest not support read function\n"));
+ return FALSE;
+ }
+*/
+
+ RtmpOSFileWrite(srcf, (PSTRING)pAd->EEPROMImage,MAX_EEPROM_BIN_FILE_SIZE);
+
+ }
+
+
+ }
+ else
+ {
+ DBGPRINT(RT_DEBUG_ERROR, ("--> Error src or srcf is null\n"));
+ return FALSE;
+
+ }
+
+ retval=RtmpOSFileClose(srcf);
+
+ if (retval)
+ {
+ DBGPRINT(RT_DEBUG_TRACE, ("--> Error %d closing %s\n", -retval, src));
+ }
+
+ RtmpOSFSInfoChange(&osFSInfo, FALSE);
+ return TRUE;
+}
+
+
+VOID eFuseGetFreeBlockCount(IN PRTMP_ADAPTER pAd,
+ PUINT EfuseFreeBlock)
+{
+ USHORT i;
+ USHORT LogicalAddress;
+ if(!pAd->bUseEfuse)
+ {
+ DBGPRINT(RT_DEBUG_TRACE,("eFuseGetFreeBlockCount Only supports efuse Mode\n"));
+ return ;
+ }
+ for (i = EFUSE_USAGE_MAP_START; i <= EFUSE_USAGE_MAP_END; i+=2)
+ {
+ eFusePhysicalReadRegisters(pAd, i, 2, &LogicalAddress);
+ if( (LogicalAddress & 0xff) == 0)
+ {
+ *EfuseFreeBlock= (UCHAR) (EFUSE_USAGE_MAP_END-i+1);
+ break;
+ }
+ else if(( (LogicalAddress >> 8) & 0xff) == 0)
+ {
+ *EfuseFreeBlock = (UCHAR) (EFUSE_USAGE_MAP_END-i);
+ break;
+ }
+
+ if(i == EFUSE_USAGE_MAP_END)
+ *EfuseFreeBlock = 0;
+ }
+ DBGPRINT(RT_DEBUG_TRACE,("eFuseGetFreeBlockCount is 0x%x\n",*EfuseFreeBlock));
+}
+
+INT eFuse_init(
+ IN PRTMP_ADAPTER pAd)
+{
+ UINT EfuseFreeBlock=0;
+ DBGPRINT(RT_DEBUG_ERROR, ("NVM is Efuse and its size =%x[%x-%x] \n",EFUSE_USAGE_MAP_SIZE,EFUSE_USAGE_MAP_START,EFUSE_USAGE_MAP_END));
+ eFuseGetFreeBlockCount(pAd, &EfuseFreeBlock);
+ //If the used block of efuse is less than 5. We assume the default value
+ // of this efuse is empty and change to the buffer mode in odrder to
+ //bring up interfaces successfully.
+ if(EfuseFreeBlock > (EFUSE_USAGE_MAP_END-5))
+ {
+ DBGPRINT(RT_DEBUG_ERROR, ("NVM is Efuse and the information is too less to bring up interface. Force to use EEPROM Buffer Mode\n"));
+ pAd->bFroceEEPROMBuffer = TRUE;
+ eFuseLoadEEPROM(pAd);
+ }
+ else
+ pAd->bFroceEEPROMBuffer = FALSE;
+ DBGPRINT(RT_DEBUG_TRACE, ("NVM is Efuse and force to use EEPROM Buffer Mode=%x\n",pAd->bFroceEEPROMBuffer));
+
+ return 0;
+}
diff --git a/drivers/staging/rt3090/common/ee_prom.c b/drivers/staging/rt3090/common/ee_prom.c
new file mode 100644
index 000000000000..051cfdee2a15
--- /dev/null
+++ b/drivers/staging/rt3090/common/ee_prom.c
@@ -0,0 +1,308 @@
+/*
+ *************************************************************************
+ * 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:
+ ee_prom.c
+
+ Abstract:
+ Miniport generic portion header file
+
+ Revision History:
+ Who When What
+ -------- ---------- ----------------------------------------------
+*/
+
+#include "../rt_config.h"
+
+
+// IRQL = PASSIVE_LEVEL
+static inline 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
+static inline VOID LowerClock(
+ IN PRTMP_ADAPTER pAd,
+ IN UINT32 *x)
+{
+ *x = *x & ~EESK;
+ RTMP_IO_WRITE32(pAd, E2PROM_CSR, *x);
+ RTMPusecDelay(1);
+}
+
+// IRQL = PASSIVE_LEVEL
+static inline 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
+static inline 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
+static inline 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);
+}
+
+
+static inline 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);
+}
+
+
+static inline 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
+int rtmp_ee_prom_read16(
+ IN PRTMP_ADAPTER pAd,
+ IN USHORT Offset,
+ OUT USHORT *pValue)
+{
+ UINT32 x;
+ USHORT data;
+
+#ifdef RT30xx
+#ifdef ANT_DIVERSITY_SUPPORT
+ if (pAd->NicConfig2.field.AntDiversity)
+ {
+ pAd->EepromAccess = TRUE;
+ }
+#endif // ANT_DIVERSITY_SUPPORT //
+#endif // RT30xx //
+
+ 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) || IS_RT3572(pAd) || IS_RT3390(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);
+
+#ifdef RT30xx
+#ifdef ANT_DIVERSITY_SUPPORT
+ // 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 // ANT_DIVERSITY_SUPPORT //
+#endif // RT30xx //
+
+ *pValue = data;
+
+ return NDIS_STATUS_SUCCESS;
+}
+
+
+int rtmp_ee_prom_write16(
+ IN PRTMP_ADAPTER pAd,
+ IN USHORT Offset,
+ IN USHORT Data)
+{
+ UINT32 x;
+
+#ifdef RT30xx
+#ifdef ANT_DIVERSITY_SUPPORT
+ if (pAd->NicConfig2.field.AntDiversity)
+ {
+ pAd->EepromAccess = TRUE;
+ }
+#endif // ANT_DIVERSITY_SUPPORT //
+#endif // RT30xx //
+
+ 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) || IS_RT3572(pAd) || IS_RT3390(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);
+
+#ifdef RT30xx
+#ifdef ANT_DIVERSITY_SUPPORT
+ // 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 // ANT_DIVERSITY_SUPPORT //
+#endif // RT30xx //
+
+ return NDIS_STATUS_SUCCESS;
+
+}
diff --git a/drivers/staging/rt3090/common/eeprom.c b/drivers/staging/rt3090/common/eeprom.c
new file mode 100644
index 000000000000..2e837499e5e4
--- /dev/null
+++ b/drivers/staging/rt3090/common/eeprom.c
@@ -0,0 +1,98 @@
+/*
+ *************************************************************************
+ * 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"
+
+
+INT RtmpChipOpsEepromHook(
+ IN RTMP_ADAPTER *pAd,
+ IN INT infType)
+{
+ RTMP_CHIP_OP *pChipOps = &pAd->chipOps;
+#ifdef RT30xx
+#ifdef RTMP_EFUSE_SUPPORT
+ UINT32 eFuseCtrl, MacCsr0;
+ int index;
+
+ 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);
+
+ pAd->bUseEfuse=FALSE;
+ RTMP_IO_READ32(pAd, EFUSE_CTRL, &eFuseCtrl);
+ pAd->bUseEfuse = ( (eFuseCtrl & 0x80000000) == 0x80000000) ? 1 : 0;
+ if(pAd->bUseEfuse)
+ {
+ pChipOps->eeinit = eFuse_init;
+ pChipOps->eeread = rtmp_ee_efuse_read16;
+ pChipOps->eewrite = rtmp_ee_efuse_write16;
+ return 0 ;
+ }
+ else
+ {
+ pAd->bFroceEEPROMBuffer = FALSE;
+ DBGPRINT(RT_DEBUG_TRACE, ("NVM is EEPROM\n"));
+ }
+#endif // RTMP_EFUSE_SUPPORT //
+#endif // RT30xx //
+
+ switch(infType)
+ {
+#ifdef RTMP_PCI_SUPPORT
+ case RTMP_DEV_INF_PCI:
+ pChipOps->eeinit = NULL;
+ pChipOps->eeread = rtmp_ee_prom_read16;
+ pChipOps->eewrite = rtmp_ee_prom_write16;
+ break;
+#endif // RTMP_PCI_SUPPORT //
+
+
+ default:
+ DBGPRINT(RT_DEBUG_ERROR, ("RtmpChipOpsEepromHook() failed!\n"));
+ break;
+ }
+
+ return 0;
+}
diff --git a/drivers/staging/rt3090/common/igmp_snoop.c b/drivers/staging/rt3090/common/igmp_snoop.c
new file mode 100644
index 000000000000..680658f97f0a
--- /dev/null
+++ b/drivers/staging/rt3090/common/igmp_snoop.c
@@ -0,0 +1,1365 @@
+/*
+ *************************************************************************
+ * 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 IGMP_SNOOP_SUPPORT
+
+#include "../rt_config.h"
+#include "../ipv6.h"
+#include "../igmp_snoop.h"
+
+
+static inline void initFreeEntryList(
+ IN PMULTICAST_FILTER_TABLE pMulticastFilterTable,
+ IN PLIST_HEADER pList)
+{
+ int i;
+
+ for (i = 0; i < FREE_MEMBER_POOL_SIZE; i++)
+ insertTailList(pList, (PLIST_ENTRY)&(pMulticastFilterTable->freeMemberPool[i]));
+
+ return;
+}
+
+static inline PMEMBER_ENTRY AllocaGrpMemberEntry(
+ IN PMULTICAST_FILTER_TABLE pMulticastFilterTable)
+{
+ PMEMBER_ENTRY pMemberEntry;
+
+ RTMP_SEM_LOCK(&pMulticastFilterTable->FreeMemberPoolTabLock);
+
+ pMemberEntry = (PMEMBER_ENTRY)removeHeadList(&pMulticastFilterTable->freeEntryList);
+
+ RTMP_SEM_UNLOCK(&pMulticastFilterTable->FreeMemberPoolTabLock);
+
+ return (PMEMBER_ENTRY)pMemberEntry;
+}
+
+static inline VOID FreeGrpMemberEntry(
+ IN PMULTICAST_FILTER_TABLE pMulticastFilterTable,
+ IN PMEMBER_ENTRY pEntry)
+{
+ RTMP_SEM_LOCK(&pMulticastFilterTable->FreeMemberPoolTabLock);
+
+ insertTailList(&pMulticastFilterTable->freeEntryList, (PLIST_ENTRY)pEntry);
+
+ RTMP_SEM_UNLOCK(&pMulticastFilterTable->FreeMemberPoolTabLock);
+}
+
+static VOID IGMPTableDisplay(
+ IN PRTMP_ADAPTER pAd);
+
+static BOOLEAN isIgmpMacAddr(
+ IN PUCHAR pMacAddr);
+
+static VOID InsertIgmpMember(
+ IN PMULTICAST_FILTER_TABLE pMulticastFilterTable,
+ IN PLIST_HEADER pList,
+ IN PUCHAR pMemberAddr);
+
+static VOID DeleteIgmpMember(
+ IN PMULTICAST_FILTER_TABLE pMulticastFilterTable,
+ IN PLIST_HEADER pList,
+ IN PUCHAR pMemberAddr);
+
+static VOID DeleteIgmpMemberList(
+ IN PMULTICAST_FILTER_TABLE pMulticastFilterTable,
+ IN PLIST_HEADER pList);
+
+
+/*
+ ==========================================================================
+ Description:
+ This routine init the entire IGMP table.
+ ==========================================================================
+ */
+VOID MulticastFilterTableInit(
+ IN PMULTICAST_FILTER_TABLE *ppMulticastFilterTable)
+{
+ // Initialize MAC table and allocate spin lock
+ *ppMulticastFilterTable = kmalloc(sizeof(MULTICAST_FILTER_TABLE), MEM_ALLOC_FLAG);
+ if (*ppMulticastFilterTable == NULL)
+ {
+ DBGPRINT(RT_DEBUG_ERROR, ("%s unable to alloc memory for Multicase filter table, size=%d\n",
+ __FUNCTION__, sizeof(MULTICAST_FILTER_TABLE)));
+ return;
+ }
+
+ NdisZeroMemory(*ppMulticastFilterTable, sizeof(MULTICAST_FILTER_TABLE));
+ NdisAllocateSpinLock(&((*ppMulticastFilterTable)->MulticastFilterTabLock));
+
+ NdisAllocateSpinLock(&((*ppMulticastFilterTable)->FreeMemberPoolTabLock));
+ initList(&((*ppMulticastFilterTable)->freeEntryList));
+ initFreeEntryList(*ppMulticastFilterTable, &((*ppMulticastFilterTable)->freeEntryList));
+ return;
+}
+
+/*
+ ==========================================================================
+ Description:
+ This routine reset the entire IGMP table.
+ ==========================================================================
+ */
+VOID MultiCastFilterTableReset(
+ IN PMULTICAST_FILTER_TABLE *ppMulticastFilterTable)
+{
+ if(*ppMulticastFilterTable == NULL)
+ {
+ DBGPRINT(RT_DEBUG_ERROR, ("%s Multicase filter table is not ready.\n", __FUNCTION__));
+ return;
+ }
+
+ NdisFreeSpinLock(&((*ppMulticastFilterTable)->FreeMemberPoolTabLock));
+ NdisFreeSpinLock(&((*ppMulticastFilterTable)->MulticastFilterTabLock));
+ kfree(*ppMulticastFilterTable);
+ *ppMulticastFilterTable = NULL;
+}
+
+/*
+ ==========================================================================
+ Description:
+ Display all entrys in IGMP table
+ ==========================================================================
+ */
+static VOID IGMPTableDisplay(
+ IN PRTMP_ADAPTER pAd)
+{
+ int i;
+ MULTICAST_FILTER_TABLE_ENTRY *pEntry = NULL;
+ PMULTICAST_FILTER_TABLE pMulticastFilterTable = pAd->pMulticastFilterTable;
+
+ if (pMulticastFilterTable == NULL)
+ {
+ DBGPRINT(RT_DEBUG_OFF, ("%s Multicase filter table is not ready.\n", __FUNCTION__));
+ return;
+ }
+
+ // if FULL, return
+ if (pMulticastFilterTable->Size == 0)
+ {
+ DBGPRINT(RT_DEBUG_ERROR, ("Table empty.\n"));
+ return;
+ }
+
+ // allocate one MAC entry
+ RTMP_SEM_LOCK(&pMulticastFilterTable->MulticastFilterTabLock);
+
+ for (i = 0; i< MAX_LEN_OF_MULTICAST_FILTER_TABLE; i++)
+ {
+ // pick up the first available vacancy
+ if (pMulticastFilterTable->Content[i].Valid == TRUE)
+ {
+ PMEMBER_ENTRY pMemberEntry = NULL;
+ pEntry = &pMulticastFilterTable->Content[i];
+
+ DBGPRINT(RT_DEBUG_OFF, ("IF(%s) entry #%d, type=%s, GrpId=(%02x:%02x:%02x:%02x:%02x:%02x) memberCnt=%d\n",
+ RTMP_OS_NETDEV_GET_DEVNAME(pEntry->net_dev), i, (pEntry->type==0 ? "static":"dynamic"),
+ PRINT_MAC(pEntry->Addr), IgmpMemberCnt(&pEntry->MemberList)));
+
+ pMemberEntry = (PMEMBER_ENTRY)pEntry->MemberList.pHead;
+ while (pMemberEntry)
+ {
+ DBGPRINT(RT_DEBUG_OFF, ("member mac=(%02x:%02x:%02x:%02x:%02x:%02x)\n",
+ PRINT_MAC(pMemberEntry->Addr)));
+
+ pMemberEntry = pMemberEntry->pNext;
+ }
+ }
+ }
+
+ RTMP_SEM_UNLOCK(&pMulticastFilterTable->MulticastFilterTabLock);
+
+ return;
+}
+
+/*
+ ==========================================================================
+ Description:
+ Add and new entry into MAC table
+ ==========================================================================
+ */
+BOOLEAN MulticastFilterTableInsertEntry(
+ IN PRTMP_ADAPTER pAd,
+ IN PUCHAR pGrpId,
+ IN PUCHAR pMemberAddr,
+ IN PNET_DEV dev,
+ IN MulticastFilterEntryType type)
+{
+ UCHAR HashIdx;
+ int i;
+ MULTICAST_FILTER_TABLE_ENTRY *pEntry = NULL, *pCurrEntry, *pPrevEntry;
+ PMEMBER_ENTRY pMemberEntry;
+ PMULTICAST_FILTER_TABLE pMulticastFilterTable = pAd->pMulticastFilterTable;
+
+ if (pMulticastFilterTable == NULL)
+ {
+ DBGPRINT(RT_DEBUG_ERROR, ("%s Multicase filter table is not ready.\n", __FUNCTION__));
+ return FALSE;
+ }
+
+ // if FULL, return
+ if (pMulticastFilterTable->Size >= MAX_LEN_OF_MULTICAST_FILTER_TABLE)
+ {
+ DBGPRINT(RT_DEBUG_ERROR, ("%s Multicase filter table full. max-entries = %d\n",
+ __FUNCTION__, MAX_LEN_OF_MULTICAST_FILTER_TABLE));
+ return FALSE;
+ }
+
+ // check the rule is in table already or not.
+ if ((pEntry = MulticastFilterTableLookup(pMulticastFilterTable, pGrpId, dev)))
+ {
+ // doesn't indicate member mac address.
+ if(pMemberAddr == NULL)
+ {
+ return FALSE;
+ }
+
+ pMemberEntry = (PMEMBER_ENTRY)pEntry->MemberList.pHead;
+
+ while (pMemberEntry)
+ {
+ if (MAC_ADDR_EQUAL(pMemberAddr, pMemberEntry->Addr))
+ {
+ DBGPRINT(RT_DEBUG_ERROR, ("%s: already in Members list.\n", __FUNCTION__));
+ return FALSE;
+ }
+
+ pMemberEntry = pMemberEntry->pNext;
+ }
+ }
+
+ RTMP_SEM_LOCK(&pMulticastFilterTable->MulticastFilterTabLock);
+ do
+ {
+ ULONG Now;
+ // the multicast entry already exist but doesn't include the member yet.
+ if (pEntry != NULL && pMemberAddr != NULL)
+ {
+ InsertIgmpMember(pMulticastFilterTable, &pEntry->MemberList, pMemberAddr);
+ break;
+ }
+
+ // allocate one MAC entry
+ for (i = 0; i < MAX_LEN_OF_MULTICAST_FILTER_TABLE; i++)
+ {
+ // pick up the first available vacancy
+ pEntry = &pMulticastFilterTable->Content[i];
+ NdisGetSystemUpTime(&Now);
+ if ((pEntry->Valid == TRUE) && (pEntry->type == MCAT_FILTER_DYNAMIC)
+ && ((Now - pEntry->lastTime) > IGMPMAC_TB_ENTRY_AGEOUT_TIME))
+ {
+ PMULTICAST_FILTER_TABLE_ENTRY pHashEntry;
+
+ HashIdx = MULTICAST_ADDR_HASH_INDEX(pEntry->Addr);
+ pHashEntry = pMulticastFilterTable->Hash[HashIdx];
+
+ if ((pEntry->net_dev == pHashEntry->net_dev)
+ && MAC_ADDR_EQUAL(pEntry->Addr, pHashEntry->Addr))
+ {
+ pMulticastFilterTable->Hash[HashIdx] = pHashEntry->pNext;
+ pMulticastFilterTable->Size --;
+ DBGPRINT(RT_DEBUG_TRACE, ("MCastFilterTableDeleteEntry 1 - Total= %d\n", pMulticastFilterTable->Size));
+ } else
+ {
+ while (pHashEntry->pNext)
+ {
+ pPrevEntry = pHashEntry;
+ pHashEntry = pHashEntry->pNext;
+ if ((pEntry->net_dev == pHashEntry->net_dev)
+ && MAC_ADDR_EQUAL(pEntry->Addr, pHashEntry->Addr))
+ {
+ pPrevEntry->pNext = pHashEntry->pNext;
+ pMulticastFilterTable->Size --;
+ DBGPRINT(RT_DEBUG_TRACE, ("MCastFilterTableDeleteEntry 2 - Total= %d\n", pMulticastFilterTable->Size));
+ break;
+ }
+ }
+ }
+ pEntry->Valid = FALSE;
+ DeleteIgmpMemberList(pMulticastFilterTable, &pEntry->MemberList);
+ }
+
+ if (pEntry->Valid == FALSE)
+ {
+ NdisZeroMemory(pEntry, sizeof(MULTICAST_FILTER_TABLE_ENTRY));
+ pEntry->Valid = TRUE;
+
+ COPY_MAC_ADDR(pEntry->Addr, pGrpId);
+ pEntry->net_dev = dev;
+ NdisGetSystemUpTime(&Now);
+ pEntry->lastTime = Now;
+ pEntry->type = type;
+ initList(&pEntry->MemberList);
+ if (pMemberAddr != NULL)
+ InsertIgmpMember(pMulticastFilterTable, &pEntry->MemberList, pMemberAddr);
+
+ pMulticastFilterTable->Size ++;
+
+ DBGPRINT(RT_DEBUG_TRACE, ("MulticastFilterTableInsertEntry -IF(%s) allocate entry #%d, Total= %d\n", RTMP_OS_NETDEV_GET_DEVNAME(dev), i, pMulticastFilterTable->Size));
+ break;
+ }
+ }
+
+ // add this MAC entry into HASH table
+ if (pEntry)
+ {
+ HashIdx = MULTICAST_ADDR_HASH_INDEX(pGrpId);
+ if (pMulticastFilterTable->Hash[HashIdx] == NULL)
+ {
+ pMulticastFilterTable->Hash[HashIdx] = pEntry;
+ } else
+ {
+ pCurrEntry = pMulticastFilterTable->Hash[HashIdx];
+ while (pCurrEntry->pNext != NULL)
+ pCurrEntry = pCurrEntry->pNext;
+ pCurrEntry->pNext = pEntry;
+ }
+ }
+ }while(FALSE);
+
+ RTMP_SEM_UNLOCK(&pMulticastFilterTable->MulticastFilterTabLock);
+
+ return TRUE;
+}
+
+/*
+ ==========================================================================
+ Description:
+ Delete a specified client from MAC table
+ ==========================================================================
+ */
+BOOLEAN MulticastFilterTableDeleteEntry(
+ IN PRTMP_ADAPTER pAd,
+ IN PUCHAR pGrpId,
+ IN PUCHAR pMemberAddr,
+ IN PNET_DEV dev)
+{
+ USHORT HashIdx;
+ MULTICAST_FILTER_TABLE_ENTRY *pEntry, *pPrevEntry;
+ PMULTICAST_FILTER_TABLE pMulticastFilterTable = pAd->pMulticastFilterTable;
+ USHORT Aid = MCAST_WCID;
+ SST Sst = SST_ASSOC;
+ UCHAR PsMode = PWR_ACTIVE, Rate;
+
+ if (pMulticastFilterTable == NULL)
+ {
+ DBGPRINT(RT_DEBUG_ERROR, ("%s Multicase filter table is not ready.\n", __FUNCTION__));
+ return FALSE;
+ }
+
+ RTMP_SEM_LOCK(&pMulticastFilterTable->MulticastFilterTabLock);
+
+ do
+ {
+ HashIdx = MULTICAST_ADDR_HASH_INDEX(pGrpId);
+ pPrevEntry = pEntry = pMulticastFilterTable->Hash[HashIdx];
+
+ while (pEntry && pEntry->Valid)
+ {
+ if ((pEntry->net_dev == dev)
+ && MAC_ADDR_EQUAL(pEntry->Addr, pGrpId))
+ break;
+ else
+ {
+ pPrevEntry = pEntry;
+ pEntry = pEntry->pNext;
+ }
+ }
+
+ // check the rule is in table already or not.
+ if (pEntry && (pMemberAddr != NULL))
+ {
+ if(APSsPsInquiry(pAd, pMemberAddr, &Sst, &Aid, &PsMode, &Rate))
+ DeleteIgmpMember(pMulticastFilterTable, &pEntry->MemberList, pMemberAddr);
+ if (IgmpMemberCnt(&pEntry->MemberList) > 0)
+ break;
+ }
+
+ if (pEntry)
+ {
+ if (pEntry == pMulticastFilterTable->Hash[HashIdx])
+ {
+ pMulticastFilterTable->Hash[HashIdx] = pEntry->pNext;
+ DeleteIgmpMemberList(pMulticastFilterTable, &pEntry->MemberList);
+ NdisZeroMemory(pEntry, sizeof(MULTICAST_FILTER_TABLE_ENTRY));
+ pMulticastFilterTable->Size --;
+ DBGPRINT(RT_DEBUG_TRACE, ("MCastFilterTableDeleteEntry 1 - Total= %d\n", pMulticastFilterTable->Size));
+ }
+ else
+ {
+ pPrevEntry->pNext = pEntry->pNext;
+ DeleteIgmpMemberList(pMulticastFilterTable, &pEntry->MemberList);
+ NdisZeroMemory(pEntry, sizeof(MULTICAST_FILTER_TABLE_ENTRY));
+ pMulticastFilterTable->Size --;
+ DBGPRINT(RT_DEBUG_TRACE, ("MCastFilterTableDeleteEntry 2 - Total= %d\n", pMulticastFilterTable->Size));
+ }
+ }
+ else
+ {
+ DBGPRINT(RT_DEBUG_ERROR, ("%s: the Group doesn't exist.\n", __FUNCTION__));
+ }
+ } while(FALSE);
+
+ RTMP_SEM_UNLOCK(&pMulticastFilterTable->MulticastFilterTabLock);
+
+ return TRUE;
+}
+
+/*
+ ==========================================================================
+ Description:
+ Look up the MAC address in the IGMP table. Return NULL if not found.
+ Return:
+ pEntry - pointer to the MAC entry; NULL is not found
+ ==========================================================================
+*/
+PMULTICAST_FILTER_TABLE_ENTRY MulticastFilterTableLookup(
+ IN PMULTICAST_FILTER_TABLE pMulticastFilterTable,
+ IN PUCHAR pAddr,
+ IN PNET_DEV dev)
+{
+ ULONG HashIdx, Now;
+ PMULTICAST_FILTER_TABLE_ENTRY pEntry = NULL, pPrev = NULL;
+
+ if (pMulticastFilterTable == NULL)
+ {
+ DBGPRINT(RT_DEBUG_ERROR, ("%s Multicase filter table is not ready.\n", __FUNCTION__));
+ return NULL;
+ }
+
+ RTMP_SEM_LOCK(&pMulticastFilterTable->MulticastFilterTabLock);
+
+ HashIdx = MULTICAST_ADDR_HASH_INDEX(pAddr);
+ pEntry = pPrev = pMulticastFilterTable->Hash[HashIdx];
+
+ while (pEntry && pEntry->Valid)
+ {
+ if ((pEntry->net_dev == dev)
+ && MAC_ADDR_EQUAL(pEntry->Addr, pAddr))
+ {
+ NdisGetSystemUpTime(&Now);
+ pEntry->lastTime = Now;
+ break;
+ }
+ else
+ {
+ NdisGetSystemUpTime(&Now);
+ if ((pEntry->Valid == TRUE) && (pEntry->type == MCAT_FILTER_DYNAMIC)
+ && RTMP_TIME_AFTER(Now, pEntry->lastTime+IGMPMAC_TB_ENTRY_AGEOUT_TIME))
+ {
+ // Remove the aged entry
+ if (pEntry == pMulticastFilterTable->Hash[HashIdx])
+ {
+ pMulticastFilterTable->Hash[HashIdx] = pEntry->pNext;
+ pPrev = pMulticastFilterTable->Hash[HashIdx];
+ DeleteIgmpMemberList(pMulticastFilterTable, &pEntry->MemberList);
+ NdisZeroMemory(pEntry, sizeof(MULTICAST_FILTER_TABLE_ENTRY));
+ pMulticastFilterTable->Size --;
+ pEntry = pPrev;
+ DBGPRINT(RT_DEBUG_TRACE, ("MCastFilterTableDeleteEntry 2 - Total= %d\n", pMulticastFilterTable->Size));
+ }
+ else
+ {
+ pPrev->pNext = pEntry->pNext;
+ DeleteIgmpMemberList(pMulticastFilterTable, &pEntry->MemberList);
+ NdisZeroMemory(pEntry, sizeof(MULTICAST_FILTER_TABLE_ENTRY));
+ pMulticastFilterTable->Size --;
+ pEntry = (pPrev == NULL ? NULL: pPrev->pNext);
+ DBGPRINT(RT_DEBUG_TRACE, ("MCastFilterTableDeleteEntry 2 - Total= %d\n", pMulticastFilterTable->Size));
+ }
+ }
+ else
+ {
+ pPrev = pEntry;
+ pEntry = pEntry->pNext;
+ }
+ }
+ }
+
+ RTMP_SEM_UNLOCK(&pMulticastFilterTable->MulticastFilterTabLock);
+
+ return pEntry;
+}
+
+VOID IGMPSnooping(
+ IN PRTMP_ADAPTER pAd,
+ IN PUCHAR pDstMacAddr,
+ IN PUCHAR pSrcMacAddr,
+ IN PUCHAR pIpHeader,
+ IN PNET_DEV pDev)
+{
+ INT i;
+ INT IpHeaderLen;
+ UCHAR GroupType;
+ UINT16 numOfGroup;
+ UCHAR IgmpVerType;
+ PUCHAR pIgmpHeader;
+ PUCHAR pGroup;
+ UCHAR AuxDataLen;
+ UINT16 numOfSources;
+ PUCHAR pGroupIpAddr;
+ UCHAR GroupMacAddr[6];
+ PUCHAR pGroupMacAddr = (PUCHAR)&GroupMacAddr;
+
+ if(isIgmpPkt(pDstMacAddr, pIpHeader))
+ {
+ IpHeaderLen = (*(pIpHeader + 2) & 0x0f) * 4;
+ pIgmpHeader = pIpHeader + 2 + IpHeaderLen;
+ IgmpVerType = (UCHAR)(*(pIgmpHeader));
+
+ DBGPRINT(RT_DEBUG_TRACE, ("IGMP type=%0x\n", IgmpVerType));
+
+ switch(IgmpVerType)
+ {
+ case IGMP_V1_MEMBERSHIP_REPORT: // IGMP version 1 membership report.
+ case IGMP_V2_MEMBERSHIP_REPORT: // IGMP version 2 membership report.
+ pGroupIpAddr = (PUCHAR)(pIgmpHeader + 4);
+ ConvertMulticastIP2MAC(pGroupIpAddr, (PUCHAR *)&pGroupMacAddr, ETH_P_IP);
+ DBGPRINT(RT_DEBUG_TRACE, ("IGMP Group=%02x:%02x:%02x:%02x:%02x:%02x\n",
+ GroupMacAddr[0], GroupMacAddr[1], GroupMacAddr[2], GroupMacAddr[3], GroupMacAddr[4], GroupMacAddr[5]));
+ MulticastFilterTableInsertEntry(pAd, GroupMacAddr, pSrcMacAddr, pDev, MCAT_FILTER_DYNAMIC);
+ break;
+
+ case IGMP_LEAVE_GROUP: // IGMP version 1 and version 2 leave group.
+ pGroupIpAddr = (PUCHAR)(pIgmpHeader + 4);
+ ConvertMulticastIP2MAC(pGroupIpAddr, (PUCHAR *)&pGroupMacAddr, ETH_P_IP);
+ DBGPRINT(RT_DEBUG_TRACE, ("IGMP Group=%02x:%02x:%02x:%02x:%02x:%02x\n",
+ GroupMacAddr[0], GroupMacAddr[1], GroupMacAddr[2], GroupMacAddr[3], GroupMacAddr[4], GroupMacAddr[5]));
+ MulticastFilterTableDeleteEntry(pAd, GroupMacAddr, pSrcMacAddr, pDev);
+ break;
+
+ case IGMP_V3_MEMBERSHIP_REPORT: // IGMP version 3 membership report.
+ numOfGroup = ntohs(*((UINT16 *)(pIgmpHeader + 6)));
+ pGroup = (PUCHAR)(pIgmpHeader + 8);
+ for (i=0; i < numOfGroup; i++)
+ {
+ GroupType = (UCHAR)(*pGroup);
+ AuxDataLen = (UCHAR)(*(pGroup + 1));
+ numOfSources = ntohs(*((UINT16 *)(pGroup + 2)));
+ pGroupIpAddr = (PUCHAR)(pGroup + 4);
+ DBGPRINT(RT_DEBUG_TRACE, ("IGMPv3 Type=%d, ADL=%d, numOfSource=%d\n", GroupType, AuxDataLen, numOfSources));
+ ConvertMulticastIP2MAC(pGroupIpAddr, (PUCHAR *)&pGroupMacAddr, ETH_P_IP);
+ DBGPRINT(RT_DEBUG_TRACE, ("IGMP Group=%02x:%02x:%02x:%02x:%02x:%02x\n",
+ GroupMacAddr[0], GroupMacAddr[1], GroupMacAddr[2], GroupMacAddr[3], GroupMacAddr[4], GroupMacAddr[5]));
+
+ do
+ {
+ if((GroupType == MODE_IS_EXCLUDE) || (GroupType == CHANGE_TO_EXCLUDE_MODE) || (GroupType == ALLOW_NEW_SOURCES))
+ {
+ MulticastFilterTableInsertEntry(pAd, GroupMacAddr, pSrcMacAddr, pDev, MCAT_FILTER_DYNAMIC);
+ break;
+ }
+
+ if((GroupType == MODE_IS_INCLUDE) || (GroupType == BLOCK_OLD_SOURCES))
+ {
+ MulticastFilterTableDeleteEntry(pAd, GroupMacAddr, pSrcMacAddr, pDev);
+ break;
+ }
+
+ if((GroupType == CHANGE_TO_INCLUDE_MODE))
+ {
+ if(numOfSources == 0)
+ MulticastFilterTableDeleteEntry(pAd, GroupMacAddr, pSrcMacAddr, pDev);
+ else
+ MulticastFilterTableInsertEntry(pAd, GroupMacAddr, pSrcMacAddr, pDev, MCAT_FILTER_DYNAMIC);
+ break;
+ }
+ } while(FALSE);
+ pGroup += (8 + (numOfSources * 4) + AuxDataLen);
+ }
+ break;
+
+ default:
+ DBGPRINT(RT_DEBUG_TRACE, ("unknow IGMP Type=%d\n", IgmpVerType));
+ break;
+ }
+ }
+
+ return;
+}
+
+
+static BOOLEAN isIgmpMacAddr(
+ IN PUCHAR pMacAddr)
+{
+ if((pMacAddr[0] == 0x01)
+ && (pMacAddr[1] == 0x00)
+ && (pMacAddr[2] == 0x5e))
+ return TRUE;
+ return FALSE;
+}
+
+BOOLEAN isIgmpPkt(
+ IN PUCHAR pDstMacAddr,
+ IN PUCHAR pIpHeader)
+{
+ UINT16 IpProtocol = ntohs(*((UINT16 *)(pIpHeader)));
+ UCHAR IgmpProtocol;
+
+ if(!isIgmpMacAddr(pDstMacAddr))
+ return FALSE;
+
+ if(IpProtocol == ETH_P_IP)
+ {
+ IgmpProtocol = (UCHAR)*(pIpHeader + 11);
+ if(IgmpProtocol == IGMP_PROTOCOL_DESCRIPTOR)
+ return TRUE;
+ }
+
+ return FALSE;
+}
+
+static VOID InsertIgmpMember(
+ IN PMULTICAST_FILTER_TABLE pMulticastFilterTable,
+ IN PLIST_HEADER pList,
+ IN PUCHAR pMemberAddr)
+{
+ PMEMBER_ENTRY pMemberEntry;
+
+ if(pList == NULL)
+ {
+ DBGPRINT(RT_DEBUG_ERROR, ("%s: membert list doesn't exist.\n", __FUNCTION__));
+ return;
+ }
+
+ if (pMemberAddr == NULL)
+ {
+ DBGPRINT(RT_DEBUG_ERROR, ("%s: invalid member.\n", __FUNCTION__));
+ return;
+ }
+
+ if((pMemberEntry = (PMEMBER_ENTRY)AllocaGrpMemberEntry(pMulticastFilterTable)) != NULL)
+ {
+ NdisZeroMemory(pMemberEntry, sizeof(MEMBER_ENTRY));
+ COPY_MAC_ADDR(pMemberEntry->Addr, pMemberAddr);
+ insertTailList(pList, (PLIST_ENTRY)pMemberEntry);
+
+ DBGPRINT(RT_DEBUG_TRACE, ("%s Member Mac=%02x:%02x:%02x:%02x:%02x:%02x\n", __FUNCTION__,
+ pMemberEntry->Addr[0], pMemberEntry->Addr[1], pMemberEntry->Addr[2],
+ pMemberEntry->Addr[3], pMemberEntry->Addr[4], pMemberEntry->Addr[5]));
+ }
+ return;
+}
+
+static VOID DeleteIgmpMember(
+ IN PMULTICAST_FILTER_TABLE pMulticastFilterTable,
+ IN PLIST_HEADER pList,
+ IN PUCHAR pMemberAddr)
+{
+ PMEMBER_ENTRY pCurEntry;
+
+ if((pList == NULL) || (pList->pHead == NULL))
+ {
+ DBGPRINT(RT_DEBUG_ERROR, ("%s: membert list doesn't exist.\n", __FUNCTION__));
+ return;
+ }
+
+ if (pMemberAddr == NULL)
+ {
+ DBGPRINT(RT_DEBUG_ERROR, ("%s: invalid member.\n", __FUNCTION__));
+ return;
+ }
+
+ pCurEntry = (PMEMBER_ENTRY)pList->pHead;
+ while (pCurEntry)
+ {
+ if(MAC_ADDR_EQUAL(pMemberAddr, pCurEntry->Addr))
+ {
+ delEntryList(pList, (PLIST_ENTRY)pCurEntry);
+ FreeGrpMemberEntry(pMulticastFilterTable, pCurEntry);
+ break;
+ }
+ pCurEntry = pCurEntry->pNext;
+ }
+
+ return;
+}
+
+static VOID DeleteIgmpMemberList(
+ IN PMULTICAST_FILTER_TABLE pMulticastFilterTable,
+ IN PLIST_HEADER pList)
+{
+ PMEMBER_ENTRY pCurEntry, pPrvEntry;
+
+ if((pList == NULL) || (pList->pHead == NULL))
+ {
+ DBGPRINT(RT_DEBUG_ERROR, ("%s: membert list doesn't exist.\n", __FUNCTION__));
+ return;
+ }
+
+ pPrvEntry = pCurEntry = (PMEMBER_ENTRY)pList->pHead;
+ while (pCurEntry)
+ {
+ delEntryList(pList, (PLIST_ENTRY)pCurEntry);
+ pPrvEntry = pCurEntry;
+ pCurEntry = pCurEntry->pNext;
+ FreeGrpMemberEntry(pMulticastFilterTable, pPrvEntry);
+ }
+
+ initList(pList);
+ return;
+}
+
+
+UCHAR IgmpMemberCnt(
+ IN PLIST_HEADER pList)
+{
+ if(pList == NULL)
+ {
+ DBGPRINT(RT_DEBUG_ERROR, ("%s: membert list doesn't exist.\n", __FUNCTION__));
+ return 0;
+ }
+
+ return getListSize(pList);
+}
+
+VOID IgmpGroupDelMembers(
+ IN PRTMP_ADAPTER pAd,
+ IN PUCHAR pMemberAddr,
+ IN PNET_DEV pDev)
+{
+ INT i;
+ MULTICAST_FILTER_TABLE_ENTRY *pEntry = NULL;
+ PMULTICAST_FILTER_TABLE pMulticastFilterTable = pAd->pMulticastFilterTable;
+
+ for (i = 0; i < MAX_LEN_OF_MULTICAST_FILTER_TABLE; i++)
+ {
+ // pick up the first available vacancy
+ pEntry = &pMulticastFilterTable->Content[i];
+ if (pEntry->Valid == TRUE)
+ {
+ if(pMemberAddr != NULL)
+ {
+ RTMP_SEM_LOCK(&pMulticastFilterTable->MulticastFilterTabLock);
+ DeleteIgmpMember(pMulticastFilterTable, &pEntry->MemberList, pMemberAddr);
+ RTMP_SEM_UNLOCK(&pMulticastFilterTable->MulticastFilterTabLock);
+ }
+
+ if((pEntry->type == MCAT_FILTER_DYNAMIC)
+ && (IgmpMemberCnt(&pEntry->MemberList) == 0))
+ MulticastFilterTableDeleteEntry(pAd, pEntry->Addr, pMemberAddr, pDev);
+ }
+ }
+}
+
+INT Set_IgmpSn_Enable_Proc(
+ IN PRTMP_ADAPTER pAd,
+ IN PSTRING arg)
+{
+ UINT Enable;
+ POS_COOKIE pObj;
+ UCHAR ifIndex;
+ PNET_DEV pDev;
+
+ pObj = (POS_COOKIE) pAd->OS_Cookie;
+ ifIndex = pObj->ioctl_if;
+
+ pDev = (ifIndex == MAIN_MBSSID) ? (pAd->net_dev) : (pAd->ApCfg.MBSSID[ifIndex].MSSIDDev);
+ Enable = (UINT) simple_strtol(arg, 0, 10);
+
+ pAd->ApCfg.MBSSID[ifIndex].IgmpSnoopEnable = (BOOLEAN)(Enable == 0 ? 0 : 1);
+ DBGPRINT(RT_DEBUG_TRACE, ("%s::(%s) %s\n", __FUNCTION__, RTMP_OS_NETDEV_GET_DEVNAME(pDev), Enable == TRUE ? "Enable IGMP Snooping":"Disable IGMP Snooping"));
+
+ return TRUE;
+}
+
+INT Set_IgmpSn_AddEntry_Proc(
+ IN PRTMP_ADAPTER pAd,
+ IN PSTRING arg)
+{
+ INT i;
+ BOOLEAN bGroupId = 1;
+ PSTRING value;
+ PSTRING thisChar;
+ UCHAR IpAddr[4];
+ UCHAR Addr[ETH_LENGTH_OF_ADDRESS];
+ UCHAR GroupId[ETH_LENGTH_OF_ADDRESS];
+ PUCHAR *pAddr = (PUCHAR *)&Addr;
+ PNET_DEV pDev;
+ POS_COOKIE pObj;
+ UCHAR ifIndex;
+
+ pObj = (POS_COOKIE) pAd->OS_Cookie;
+ ifIndex = pObj->ioctl_if;
+
+ pDev = (ifIndex == MAIN_MBSSID) ? (pAd->net_dev) : (pAd->ApCfg.MBSSID[ifIndex].MSSIDDev);
+
+ while ((thisChar = strsep((char **)&arg, "-")) != NULL)
+ {
+ // refuse the Member if it's not a MAC address.
+ if((bGroupId == 0) && (strlen(thisChar) != 17))
+ continue;
+
+ if(strlen(thisChar) == 17) //Mac address acceptable format 01:02:03:04:05:06 length 17
+ {
+ for (i=0, value = rstrtok(thisChar,":"); value; value = rstrtok(NULL,":"))
+ {
+ if((strlen(value) != 2) || (!isxdigit(*value)) || (!isxdigit(*(value+1))) )
+ return FALSE; //Invalid
+
+ AtoH(value, &Addr[i++], 1);
+ }
+
+ if(i != 6)
+ return FALSE; //Invalid
+ }
+ else
+ {
+ for (i=0, value = rstrtok(thisChar,"."); value; value = rstrtok(NULL,"."))
+ {
+ if((strlen(value) > 0) && (strlen(value) <= 3))
+ {
+ int ii;
+ for(ii=0; ii<strlen(value); ii++)
+ if (!isxdigit(*(value + ii)))
+ return FALSE;
+ }
+ else
+ return FALSE; //Invalid
+
+ IpAddr[i] = (UCHAR)simple_strtol(value, NULL, 10);
+ i++;
+ }
+
+ if(i != 4)
+ return FALSE; //Invalid
+
+ ConvertMulticastIP2MAC(IpAddr, (PUCHAR *)&pAddr, ETH_P_IP);
+ }
+
+ if(bGroupId == 1)
+ COPY_MAC_ADDR(GroupId, Addr);
+
+ // Group-Id must be a MCAST address.
+ if((bGroupId == 1) && IS_MULTICAST_MAC_ADDR(Addr))
+ MulticastFilterTableInsertEntry(pAd, GroupId, NULL, pDev, MCAT_FILTER_STATIC);
+ // Group-Member must be a UCAST address.
+ else if ((bGroupId == 0) && !IS_MULTICAST_MAC_ADDR(Addr))
+ MulticastFilterTableInsertEntry(pAd, GroupId, Addr, pDev, MCAT_FILTER_STATIC);
+ else
+ {
+ DBGPRINT(RT_DEBUG_TRACE, ("%s (%2X:%2X:%2X:%2X:%2X:%2X) is not a acceptable address.\n",
+ __FUNCTION__, Addr[0], Addr[1], Addr[2], Addr[3], Addr[4], Addr[5]));
+ return FALSE;
+ }
+
+ bGroupId = 0;
+ DBGPRINT(RT_DEBUG_TRACE, ("%s (%2X:%2X:%2X:%2X:%2X:%2X)\n",
+ __FUNCTION__, Addr[0], Addr[1], Addr[2], Addr[3], Addr[4], Addr[5]));
+
+ }
+
+ return TRUE;
+}
+
+INT Set_IgmpSn_DelEntry_Proc(
+ IN PRTMP_ADAPTER pAd,
+ IN PSTRING arg)
+{
+ INT i, memberCnt = 0;
+ BOOLEAN bGroupId = 1;
+ PSTRING value;
+ PSTRING thisChar;
+ UCHAR IpAddr[4];
+ UCHAR Addr[ETH_LENGTH_OF_ADDRESS];
+ UCHAR GroupId[ETH_LENGTH_OF_ADDRESS];
+ PUCHAR *pAddr = (PUCHAR *)&Addr;
+ PNET_DEV pDev;
+ POS_COOKIE pObj;
+ UCHAR ifIndex;
+
+ pObj = (POS_COOKIE) pAd->OS_Cookie;
+ ifIndex = pObj->ioctl_if;
+
+ pDev = (ifIndex == MAIN_MBSSID) ? (pAd->net_dev) : (pAd->ApCfg.MBSSID[ifIndex].MSSIDDev);
+
+ while ((thisChar = strsep((char **)&arg, "-")) != NULL)
+ {
+ // refuse the Member if it's not a MAC address.
+ if((bGroupId == 0) && (strlen(thisChar) != 17))
+ continue;
+
+ if(strlen(thisChar) == 17) //Mac address acceptable format 01:02:03:04:05:06 length 17
+ {
+ for (i=0, value = rstrtok(thisChar,":"); value; value = rstrtok(NULL,":"))
+ {
+ if((strlen(value) != 2) || (!isxdigit(*value)) || (!isxdigit(*(value+1))) )
+ return FALSE; //Invalid
+
+ AtoH(value, &Addr[i++], 1);
+ }
+
+ if(i != 6)
+ return FALSE; //Invalid
+ }
+ else
+ {
+ for (i=0, value = rstrtok(thisChar,"."); value; value = rstrtok(NULL,"."))
+ {
+ if((strlen(value) > 0) && (strlen(value) <= 3))
+ {
+ int ii;
+ for(ii=0; ii<strlen(value); ii++)
+ if (!isxdigit(*(value + ii)))
+ return FALSE;
+ }
+ else
+ return FALSE; //Invalid
+
+ IpAddr[i] = (UCHAR)simple_strtol(value, NULL, 10);
+ i++;
+ }
+
+ if(i != 4)
+ return FALSE; //Invalid
+
+ ConvertMulticastIP2MAC(IpAddr, (PUCHAR *)&pAddr, ETH_P_IP);
+ }
+
+ if(bGroupId == 1)
+ COPY_MAC_ADDR(GroupId, Addr);
+ else
+ memberCnt++;
+
+ if (memberCnt > 0 )
+ MulticastFilterTableDeleteEntry(pAd, (PUCHAR)GroupId, Addr, pDev);
+
+ bGroupId = 0;
+ }
+
+ if(memberCnt == 0)
+ MulticastFilterTableDeleteEntry(pAd, (PUCHAR)GroupId, NULL, pDev);
+
+ DBGPRINT(RT_DEBUG_TRACE, ("%s (%2X:%2X:%2X:%2X:%2X:%2X)\n",
+ __FUNCTION__, Addr[0], Addr[1], Addr[2], Addr[3], Addr[4], Addr[5]));
+
+ return TRUE;
+}
+
+INT Set_IgmpSn_TabDisplay_Proc(
+ IN PRTMP_ADAPTER pAd,
+ IN PSTRING arg)
+{
+ IGMPTableDisplay(pAd);
+ return TRUE;
+}
+
+void rtmp_read_igmp_snoop_from_file(
+ IN PRTMP_ADAPTER pAd,
+ PSTRING tmpbuf,
+ PSTRING buffer)
+{
+ PSTRING macptr;
+ INT i=0;
+
+ //IgmpSnEnable
+ if(RTMPGetKeyParameter("IgmpSnEnable", tmpbuf, 128, buffer, TRUE))
+ {
+ for (i = 0, macptr = rstrtok(tmpbuf,";"); (macptr && i < pAd->ApCfg.BssidNum); macptr = rstrtok(NULL,";"), i++)
+ {
+ if ((strncmp(macptr, "0", 1) == 0))
+ pAd->ApCfg.MBSSID[i].IgmpSnoopEnable = FALSE;
+ else if ((strncmp(macptr, "1", 1) == 0))
+ pAd->ApCfg.MBSSID[i].IgmpSnoopEnable = TRUE;
+ else
+ pAd->ApCfg.MBSSID[i].IgmpSnoopEnable = FALSE;
+
+ DBGPRINT(RT_DEBUG_TRACE, ("MBSSID[%d].Enable=%d\n", i, pAd->ApCfg.MBSSID[i].IgmpSnoopEnable));
+ }
+ }
+}
+
+NDIS_STATUS IgmpPktInfoQuery(
+ IN PRTMP_ADAPTER pAd,
+ IN PUCHAR pSrcBufVA,
+ IN PNDIS_PACKET pPacket,
+ IN UCHAR apidx,
+ OUT BOOLEAN *pInIgmpGroup,
+ OUT PMULTICAST_FILTER_TABLE_ENTRY *ppGroupEntry)
+{
+ if(IS_MULTICAST_MAC_ADDR(pSrcBufVA))
+ {
+ BOOLEAN IgmpMldPkt = FALSE;
+ PUCHAR pIpHeader = pSrcBufVA + 12;
+
+ if(ntohs(*((UINT16 *)(pIpHeader))) == ETH_P_IPV6)
+ IgmpMldPkt = isMldPkt(pSrcBufVA, pIpHeader, NULL, NULL);
+ else
+ IgmpMldPkt = isIgmpPkt(pSrcBufVA, pIpHeader);
+
+ if (IgmpMldPkt)
+ {
+ *ppGroupEntry = NULL;
+ }
+ else if ((*ppGroupEntry = MulticastFilterTableLookup(pAd->pMulticastFilterTable, pSrcBufVA,
+ pAd->ApCfg.MBSSID[apidx].MSSIDDev)) == NULL)
+ {
+ RELEASE_NDIS_PACKET(pAd, pPacket, NDIS_STATUS_FAILURE);
+ return NDIS_STATUS_FAILURE;
+ }
+ *pInIgmpGroup = TRUE;
+ }
+ else if (IS_BROADCAST_MAC_ADDR(pSrcBufVA))
+ {
+ PUCHAR pDstIpAddr = pSrcBufVA + 30; // point to Destination of Ip address of IP header.
+ UCHAR GroupMacAddr[6];
+ PUCHAR pGroupMacAddr = (PUCHAR)&GroupMacAddr;
+
+ ConvertMulticastIP2MAC(pDstIpAddr, (PUCHAR *)&pGroupMacAddr, ETH_P_IP);
+ if ((*ppGroupEntry = MulticastFilterTableLookup(pAd->pMulticastFilterTable, pGroupMacAddr,
+ pAd->ApCfg.MBSSID[apidx].MSSIDDev)) != NULL)
+ {
+ *pInIgmpGroup = TRUE;
+ }
+ }
+ return NDIS_STATUS_SUCCESS;
+}
+
+NDIS_STATUS IgmpPktClone(
+ IN PRTMP_ADAPTER pAd,
+ IN PNDIS_PACKET pPacket,
+ IN UCHAR QueIdx,
+ IN PMULTICAST_FILTER_TABLE_ENTRY pGroupEntry)
+{
+ PNDIS_PACKET pSkbClone = NULL;
+ PMEMBER_ENTRY pMemberEntry = (PMEMBER_ENTRY)pGroupEntry->MemberList.pHead;
+ MAC_TABLE_ENTRY *pMacEntry = NULL;
+ USHORT Aid;
+ SST Sst = SST_ASSOC;
+ UCHAR PsMode = PWR_ACTIVE;
+ UCHAR Rate;
+ unsigned long IrqFlags;
+
+ // check all members of the IGMP group.
+ while(pMemberEntry != NULL)
+ {
+ pMacEntry = APSsPsInquiry(pAd, pMemberEntry->Addr, &Sst, &Aid, &PsMode, &Rate);
+
+ if (pMacEntry && (Sst == SST_ASSOC) && (PsMode != PWR_SAVE))
+ {
+ pSkbClone = skb_clone(RTPKT_TO_OSPKT(pPacket), MEM_ALLOC_FLAG);
+ if(pSkbClone)
+ {
+ RTMP_SET_PACKET_WCID(pSkbClone, (UCHAR)Aid);
+ // Pkt type must set to PKTSRC_NDIS.
+ // It cause of the deason that APHardTransmit()
+ // doesn't handle PKTSRC_DRIVER pkt type in version 1.3.0.0.
+ RTMP_SET_PACKET_SOURCE(pSkbClone, PKTSRC_NDIS);
+ }
+ else
+ {
+ pMemberEntry = pMemberEntry->pNext;
+ continue;
+ }
+
+ // insert the pkt to TxSwQueue.
+ if (pAd->TxSwQueue[QueIdx].Number >= MAX_PACKETS_IN_QUEUE)
+ {
+#ifdef BLOCK_NET_IF
+ StopNetIfQueue(pAd, QueIdx, pSkbClone);
+#endif // BLOCK_NET_IF //
+ RELEASE_NDIS_PACKET(pAd, pSkbClone, NDIS_STATUS_FAILURE);
+ return NDIS_STATUS_FAILURE;
+ }
+ else
+ {
+ RTMP_IRQ_LOCK(&pAd->irq_lock, IrqFlags);
+ InsertTailQueueAc(pAd, pMacEntry, &pAd->TxSwQueue[QueIdx], PACKET_TO_QUEUE_ENTRY(pSkbClone));
+ RTMP_IRQ_UNLOCK(&pAd->irq_lock, IrqFlags);
+ }
+ }
+ pMemberEntry = pMemberEntry->pNext;
+ }
+ return NDIS_STATUS_SUCCESS;
+}
+
+static inline BOOLEAN isMldMacAddr(
+ IN PUCHAR pMacAddr)
+{
+ return ((pMacAddr[0] == 0x33) && (pMacAddr[1] == 0x33)) ? TRUE : FALSE;
+}
+
+static inline BOOLEAN IsSupportedMldMsg(
+ IN UINT8 MsgType)
+{
+ BOOLEAN result = FALSE;
+ switch(MsgType)
+ {
+ case MLD_V1_LISTENER_REPORT:
+ case MLD_V1_LISTENER_DONE:
+ case MLD_V2_LISTERNER_REPORT:
+ result = TRUE;
+ break;
+ default:
+ result = FALSE;
+ break;
+ }
+
+ return result;
+}
+
+BOOLEAN isMldPkt(
+ IN PUCHAR pDstMacAddr,
+ IN PUCHAR pIpHeader,
+ OUT UINT8 *pProtoType,
+ OUT PUCHAR *pMldHeader)
+{
+ BOOLEAN result = FALSE;
+ UINT16 IpProtocol = ntohs(*((UINT16 *)(pIpHeader)));
+
+ if(!isMldMacAddr(pDstMacAddr))
+ return FALSE;
+
+ if(IpProtocol != ETH_P_IPV6)
+ return FALSE;
+
+ // skip protocol (2 Bytes).
+ pIpHeader += 2;
+ do
+ {
+ PRT_IPV6_HDR pIpv6Hdr = (PRT_IPV6_HDR)(pIpHeader);
+ UINT8 nextProtocol = pIpv6Hdr->nextHdr;
+ UINT32 offset = IPV6_HDR_LEN;
+
+ while(nextProtocol != IPV6_NEXT_HEADER_ICMPV6)
+ {
+ if(IPv6ExtHdrHandle((RT_IPV6_EXT_HDR *)(pIpHeader + offset), &nextProtocol, &offset) == FALSE)
+ break;
+ }
+
+ if(nextProtocol == IPV6_NEXT_HEADER_ICMPV6)
+ {
+ PRT_ICMPV6_HDR pICMPv6Hdr = (PRT_ICMPV6_HDR)(pIpHeader + offset);
+ if (IsSupportedMldMsg(pICMPv6Hdr->type) == TRUE)
+ {
+ if (pProtoType != NULL)
+ *pProtoType = pICMPv6Hdr->type;
+ if (pMldHeader != NULL)
+ *pMldHeader = (PUCHAR)pICMPv6Hdr;
+ result = TRUE;
+ }
+ }
+ }while(FALSE);
+
+ return result;
+}
+
+/* MLD v1 messages have the following format:
+ 0 1 2 3
+ 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 6 7 8 9 0 1
+ +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
+ | Type | Code | Checksum |
+ +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
+ | Maximum Response Delay | Reserved |
+ +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
+ | |
+ + +
+ | |
+ + Multicast Address +
+ | |
+ + +
+ | |
+ +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
+*/
+
+/* Version 3 Membership Report Message
+ 0 1 2 3
+ 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 6 7 8 9 0 1
+ +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
+ | Type = 143 | Reserved | Checksum |
+ +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
+ | Reserved | Number of Group Records (M) |
+ +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
+ | |
+ . .
+ . Multicast Address Record [1] .
+ . .
+ | |
+ +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
+ | |
+ . .
+ . Multicast Address Record [2] .
+ . .
+ | |
+ +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
+ | . |
+ . . .
+ | . |
+ +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
+ | |
+ . .
+ . Multicast Address Record [M] .
+ . .
+ | |
+ +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
+
+
+ where each Group Record has the following internal format:
+ +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
+ | Record Type | Aux Data Len | Number of Sources (N) |
+ +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
+ | |
+ * *
+ | |
+ * Multicast Address *
+ | |
+ * *
+ | |
+ +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
+ | |
+ * *
+ | |
+ * Source Address [1] *
+ | |
+ * *
+ | |
+ +- -+
+ | |
+ * *
+ | |
+ * Source Address [2] *
+ | |
+ * *
+ | |
+ +- -+
+ . . .
+ . . .
+ . . .
+ +- -+
+ | |
+ * *
+ | |
+ * Source Address [N] *
+ | |
+ * *
+ | |
+ +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
+ | |
+ . .
+ . Auxiliary Data .
+ . .
+ | |
+ +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
+*/
+
+VOID MLDSnooping(
+ IN PRTMP_ADAPTER pAd,
+ IN PUCHAR pDstMacAddr,
+ IN PUCHAR pSrcMacAddr,
+ IN PUCHAR pIpHeader,
+ IN PNET_DEV pDev)
+{
+ INT i;
+ UCHAR GroupType;
+ UINT16 numOfGroup;
+ PUCHAR pGroup;
+ UCHAR AuxDataLen;
+ UINT16 numOfSources;
+ PUCHAR pGroupIpAddr;
+ UCHAR GroupMacAddr[6];
+ PUCHAR pGroupMacAddr = (PUCHAR)&GroupMacAddr;
+
+ UINT8 MldType;
+ PUCHAR pMldHeader;
+
+ if(isMldPkt(pDstMacAddr, pIpHeader, &MldType, &pMldHeader) == TRUE)
+ {
+ DBGPRINT(RT_DEBUG_TRACE, ("MLD type=%0x\n", MldType));
+
+ switch(MldType)
+ {
+ case MLD_V1_LISTENER_REPORT:
+ // skip Type(1 Byte), code(1 Byte), checksum(2 Bytes), Maximum Rsp Delay(2 Bytes), Reserve(2 Bytes).
+ pGroupIpAddr = (PUCHAR)(pMldHeader + 8);
+ ConvertMulticastIP2MAC(pGroupIpAddr, (PUCHAR *)&pGroupMacAddr, ETH_P_IPV6);
+ DBGPRINT(RT_DEBUG_TRACE, ("Group Id=%02x:%02x:%02x:%02x:%02x:%02x\n",
+ GroupMacAddr[0], GroupMacAddr[1], GroupMacAddr[2], GroupMacAddr[3], GroupMacAddr[4], GroupMacAddr[5]));
+ MulticastFilterTableInsertEntry(pAd, GroupMacAddr, pSrcMacAddr, pDev, MCAT_FILTER_DYNAMIC);
+ break;
+
+ case MLD_V1_LISTENER_DONE:
+ // skip Type(1 Byte), code(1 Byte), checksum(2 Bytes), Maximum Rsp Delay(2 Bytes), Reserve(2 Bytes).
+ pGroupIpAddr = (PUCHAR)(pMldHeader + 8);
+ ConvertMulticastIP2MAC(pGroupIpAddr, (PUCHAR *)&pGroupMacAddr, ETH_P_IPV6);
+ DBGPRINT(RT_DEBUG_TRACE, ("Group Id=%02x:%02x:%02x:%02x:%02x:%02x\n",
+ GroupMacAddr[0], GroupMacAddr[1], GroupMacAddr[2], GroupMacAddr[3], GroupMacAddr[4], GroupMacAddr[5]));
+ MulticastFilterTableDeleteEntry(pAd, GroupMacAddr, pSrcMacAddr, pDev);
+ break;
+
+ case MLD_V2_LISTERNER_REPORT: // IGMP version 3 membership report.
+ numOfGroup = ntohs(*((UINT16 *)(pMldHeader + 6)));
+ pGroup = (PUCHAR)(pMldHeader + 8);
+ for (i=0; i < numOfGroup; i++)
+ {
+ GroupType = (UCHAR)(*pGroup);
+ AuxDataLen = (UCHAR)(*(pGroup + 1));
+ numOfSources = ntohs(*((UINT16 *)(pGroup + 2)));
+ pGroupIpAddr = (PUCHAR)(pGroup + 4);
+ DBGPRINT(RT_DEBUG_TRACE, ("MLDv2 Type=%d, ADL=%d, numOfSource=%d\n", GroupType, AuxDataLen, numOfSources));
+ ConvertMulticastIP2MAC(pGroupIpAddr, (PUCHAR *)&pGroupMacAddr, ETH_P_IPV6);
+ DBGPRINT(RT_DEBUG_TRACE, ("MLD Group=%02x:%02x:%02x:%02x:%02x:%02x\n",
+ GroupMacAddr[0], GroupMacAddr[1], GroupMacAddr[2], GroupMacAddr[3], GroupMacAddr[4], GroupMacAddr[5]));
+
+ do
+ {
+ if((GroupType == MODE_IS_EXCLUDE) || (GroupType == CHANGE_TO_EXCLUDE_MODE) || (GroupType == ALLOW_NEW_SOURCES))
+ {
+ MulticastFilterTableInsertEntry(pAd, GroupMacAddr, pSrcMacAddr, pDev, MCAT_FILTER_DYNAMIC);
+ break;
+ }
+
+ if((GroupType == MODE_IS_INCLUDE) || (GroupType == BLOCK_OLD_SOURCES))
+ {
+ MulticastFilterTableDeleteEntry(pAd, GroupMacAddr, pSrcMacAddr, pDev);
+ break;
+ }
+
+ if((GroupType == CHANGE_TO_INCLUDE_MODE))
+ {
+ if(numOfSources == 0)
+ MulticastFilterTableDeleteEntry(pAd, GroupMacAddr, pSrcMacAddr, pDev);
+ else
+ MulticastFilterTableInsertEntry(pAd, GroupMacAddr, pSrcMacAddr, pDev, MCAT_FILTER_DYNAMIC);
+ break;
+ }
+ } while(FALSE);
+ // skip 4 Bytes (Record Type, Aux Data Len, Number of Sources) + a IPv6 address.
+ pGroup += (4 + IPV6_ADDR_LEN + (numOfSources * 16) + AuxDataLen);
+ }
+ break;
+
+ default:
+ DBGPRINT(RT_DEBUG_TRACE, ("unknow MLD Type=%d\n", MldType));
+ break;
+ }
+ }
+
+ return;
+}
+
+
+#endif // IGMP_SNOOP_SUPPORT //
diff --git a/drivers/staging/rt3090/common/mlme.c b/drivers/staging/rt3090/common/mlme.c
new file mode 100644
index 000000000000..1613c04c5932
--- /dev/null
+++ b/drivers/staging/rt3090/common/mlme.c
@@ -0,0 +1,6550 @@
+/*
+ *************************************************************************
+ * 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)
+ 0x0c, 0x0a, 0, 0, 0, // Initial used item after association
+ 0x00, 0x00, 0, 40, 101,
+ 0x01, 0x00, 1, 40, 50,
+ 0x02, 0x00, 2, 25, 45,
+ 0x03, 0x21, 0, 20, 35,
+ 0x04, 0x21, 1, 20, 35,
+ 0x05, 0x21, 2, 20, 35,
+ 0x06, 0x21, 3, 15, 35,
+ 0x07, 0x21, 4, 15, 30,
+ 0x08, 0x21, 5, 10, 25,
+ 0x09, 0x21, 6, 8, 14,
+ 0x0a, 0x21, 7, 8, 14,
+ 0x0b, 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)
+ 0x0e, 0x0c, 0, 0, 0, // Initial used item after association
+ 0x00, 0x00, 0, 40, 101,
+ 0x01, 0x00, 1, 40, 50,
+ 0x02, 0x00, 2, 25, 45,
+ 0x03, 0x21, 0, 20, 35,
+ 0x04, 0x21, 1, 20, 35,
+ 0x05, 0x21, 2, 20, 35,
+ 0x06, 0x21, 3, 15, 35,
+ 0x07, 0x21, 4, 15, 30,
+ 0x08, 0x20, 11, 15, 30,
+ 0x09, 0x20, 12, 15, 30,
+ 0x0a, 0x20, 13, 8, 20,
+ 0x0b, 0x20, 14, 8, 20,
+ 0x0c, 0x20, 15, 8, 25,
+ 0x0d, 0x22, 15, 8, 15,
+};
+
+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)
+ 0x0b, 0x00, 0, 0, 0, // 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, 11, 15, 30, // Required by System-Alan @ 20080812
+ 0x06, 0x20, 12, 15, 30, // 0x05, 0x20, 12, 15, 30,
+ 0x07, 0x20, 13, 8, 20, // 0x06, 0x20, 13, 8, 20,
+ 0x08, 0x20, 14, 8, 20, // 0x07, 0x20, 14, 8, 20,
+ 0x09, 0x20, 15, 8, 25, // 0x08, 0x20, 15, 8, 25,
+ 0x0a, 0x22, 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)
+ 0x0c, 0x0a, 0, 0, 0, // Initial used item after association
+ 0x00, 0x00, 0, 40, 101,
+ 0x01, 0x00, 1, 40, 50,
+ 0x02, 0x00, 2, 25, 45,
+ 0x03, 0x21, 0, 20, 35,
+ 0x04, 0x21, 1, 20, 35,
+ 0x05, 0x21, 2, 20, 35,
+ 0x06, 0x21, 3, 15, 35,
+ 0x07, 0x21, 4, 15, 30,
+ 0x08, 0x21, 5, 10, 25,
+ 0x09, 0x21, 6, 8, 14,
+ 0x0a, 0x21, 7, 8, 14,
+ 0x0b, 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)
+ 0x0e, 0x0c, 0, 0, 0, // Initial used item after association
+ 0x00, 0x00, 0, 40, 101,
+ 0x01, 0x00, 1, 40, 50,
+ 0x02, 0x00, 2, 25, 45,
+ 0x03, 0x21, 0, 20, 35,
+ 0x04, 0x21, 1, 20, 35,
+ 0x05, 0x21, 2, 20, 35,
+ 0x06, 0x21, 3, 15, 35,
+ 0x07, 0x21, 4, 15, 30,
+ 0x08, 0x20, 11, 15, 30,
+ 0x09, 0x20, 12, 15, 30,
+ 0x0a, 0x20, 13, 8, 20,
+ 0x0b, 0x20, 14, 8, 20,
+ 0x0c, 0x20, 15, 8, 25,
+ 0x0d, 0x22, 15, 8, 15,
+};
+
+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,
+ 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,
+};
+
+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 //
+
+
+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 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};
+
+
+/*
+ ==========================================================================
+ 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);
+
+#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 //
+
+
+ WpaStateMachineInit(pAd, &pAd->Mlme.WpaMachine, pAd->Mlme.WpaFunc);
+
+
+ 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
+ IF_DEV_CONFIG_OPMODE_ON_STA(pAd)
+ {
+#ifdef RTMP_PCI_SUPPORT
+ if (OPSTATUS_TEST_FLAG(pAd, fOP_STATUS_PCIE_DEVICE))
+ {
+ // only PCIe cards need these two timers
+ RTMPInitTimer(pAd, &pAd->Mlme.PsPollTimer, GET_TIMER_FUNCTION(PsPollWakeExec), pAd, FALSE);
+ RTMPInitTimer(pAd, &pAd->Mlme.RadioOnOffTimer, GET_TIMER_FUNCTION(RadioOnExec), pAd, FALSE);
+ }
+#endif // RTMP_PCI_SUPPORT //
+
+ RTMPInitTimer(pAd, &pAd->Mlme.LinkDownTimer, GET_TIMER_FUNCTION(LinkDownExec), pAd, FALSE);
+
+ }
+#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;
+#ifdef APCLI_SUPPORT
+ SHORT apcliIfIndex;
+#endif // APCLI_SUPPORT //
+
+ // 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))
+ {
+
+ // 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 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;
+
+ case WPA_STATE_MACHINE:
+ StateMachinePerformAction(pAd, &pAd->Mlme.WpaMachine, 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 RTMP_MAC_PCI
+ if (OPSTATUS_TEST_FLAG(pAd, fOP_STATUS_PCIE_DEVICE)
+ &&(pAd->StaCfg.PSControl.field.EnableNewPS == TRUE))
+ {
+ RTMPCancelTimer(&pAd->Mlme.PsPollTimer, &Cancelled);
+ RTMPCancelTimer(&pAd->Mlme.RadioOnOffTimer, &Cancelled);
+ }
+#endif // RTMP_MAC_PCI //
+
+#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 //
+ RTMPCancelTimer(&pAd->Mlme.LinkDownTimer, &Cancelled);
+
+ }
+#endif // CONFIG_STA_SUPPORT //
+
+ RTMPCancelTimer(&pAd->Mlme.PeriodicTimer, &Cancelled);
+ RTMPCancelTimer(&pAd->Mlme.RxAntEvalTimer, &Cancelled);
+
+
+
+ if (!RTMP_TEST_FLAG(pAd, fRTMP_ADAPTER_NIC_NOT_EXIST))
+ {
+ RTMP_CHIP_OP *pChipOps = &pAd->chipOps;
+
+ // Set LED
+ RTMPSetLED(pAd, LED_HALT);
+ RTMPSetSignalLED(pAd, -100); // Force signal strength Led to be turned off, firmware is not done it.
+
+ if (pChipOps->AsicHaltAction)
+ pChipOps->AsicHaltAction(pAd);
+ }
+
+ 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;
+ pAd->RalinkCounters.OneSecReceivedByteCount = 0;
+ pAd->RalinkCounters.OneSecTransmittedByteCount = 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;
+}
+
+
+/*
+ ==========================================================================
+ 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;
+ SHORT realavgrssi;
+
+#ifdef CONFIG_STA_SUPPORT
+#ifdef RTMP_MAC_PCI
+ 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
+ if ((pAd->Mlme.PeriodicRound % (MLME_TASK_EXEC_MULTIPLE * 2) == 0) && (pAd->StaCfg.bHardwareRadio == TRUE) &&
+ (!RTMP_TEST_FLAG(pAd, fRTMP_ADAPTER_NIC_NOT_EXIST)) &&
+ (!RTMP_TEST_FLAG(pAd, fRTMP_ADAPTER_HALT_IN_PROGRESS))
+ /*&&(pAd->bPCIclkOff == FALSE)*/)
+ {
+ UINT32 data = 0;
+
+ // Read GPIO pin2 as Hardware controlled radio state
+#ifndef RT3090
+ RTMP_IO_READ32(pAd, GPIO_CTRL_CFG, &data);
+#endif // RT3090 //
+//KH(PCIE PS):Added based on Jane<--
+#ifdef RT3090
+// Read GPIO pin2 as Hardware controlled radio state
+// We need to Read GPIO if HW said so no mater what advance power saving
+if ((pAd->OpMode == OPMODE_STA) && (IDLE_ON(pAd))
+ && (RTMP_TEST_FLAG(pAd, fRTMP_ADAPTER_IDLE_RADIO_OFF))
+ && (pAd->StaCfg.PSControl.field.EnablePSinIdle == TRUE))
+ {
+ // Want to make sure device goes to L0 state before reading register.
+ RTMPPCIeLinkCtrlValueRestore(pAd, 0);
+ RTMP_IO_FORCE_READ32(pAd, GPIO_CTRL_CFG, &data);
+ RTMPPCIeLinkCtrlSetting(pAd, 3);
+ }
+else
+ RTMP_IO_FORCE_READ32(pAd, GPIO_CTRL_CFG, &data);
+#endif // RT3090 //
+//KH(PCIE PS):Added based on Jane-->
+
+ 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)
+ {
+ MlmeRadioOn(pAd);
+ // Update extra information
+ pAd->ExtraInfo = EXTRA_INFO_CLEAR;
+ }
+ else
+ {
+ MlmeRadioOff(pAd);
+ // Update extra information
+ pAd->ExtraInfo = HW_RADIO_OFF;
+ }
+ }
+ }
+ }
+#endif // RTMP_MAC_PCI //
+#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;
+
+ RTMP_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 //
+
+
+
+ //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 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
+#ifdef ANT_DIVERSITY_SUPPORT
+ if ((pAd->NicConfig2.field.AntDiversity) &&
+ (pAd->CommonCfg.bRxAntDiversity == ANT_DIVERSITY_ENABLE) &&
+ (!pAd->EepromAccess))
+ AsicAntennaSelect(pAd, pAd->MlmeAux.Channel);
+ else if(pAd->CommonCfg.bRxAntDiversity == ANT_FIX_ANT1 || pAd->CommonCfg.bRxAntDiversity == ANT_FIX_ANT2)
+ {
+#ifdef CONFIG_STA_SUPPORT
+ realavgrssi = (pAd->RxAnt.Pair1AvgRssi[pAd->RxAnt.Pair1PrimaryRxAnt] >> 3);
+#endif // CONFIG_STA_SUPPORT //
+ DBGPRINT(RT_DEBUG_TRACE,("Ant-realrssi0(%d), Lastrssi0(%d), EvaluateStableCnt=%d\n", realavgrssi, pAd->RxAnt.Pair1LastAvgRssi, pAd->RxAnt.EvaluateStableCnt));
+ }
+ else
+#endif // ANT_DIVERSITY_SUPPORT //
+ {
+ 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)
+ {
+#ifdef RTMP_MAC_PCI
+ if (!RTMP_TEST_FLAG(pAd, fRTMP_ADAPTER_NIC_NOT_EXIST) && (pAd->bPCIclkOff == FALSE))
+#endif // RTMP_MAC_PCI //
+ {
+ // 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 //
+
+ RTMP_MLME_HANDLER(pAd);
+ }
+
+
+ pAd->bUpdateBcnCntDone = FALSE;
+}
+
+
+/*
+ ==========================================================================
+ 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) || (pAd->OpMode == OPMODE_STA)) && (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) || (pAd->OpMode == OPMODE_STA)) && (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 || pAd->CommonCfg.PhyMode==PHY_11B)
+#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
+VOID STAMlmePeriodicExec(
+ PRTMP_ADAPTER pAd)
+{
+ ULONG TxTotalCnt;
+ int i;
+
+
+
+
+ /*
+ We return here in ATE mode, because the statistics
+ that ATE need are not collected via this routine.
+ */
+#ifdef RALINK_ATE
+ if (ATE_ON(pAd))
+ return;
+#endif // RALINK_ATE //
+
+#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 PCIE_PS_SUPPORT
+// don't perform idle-power-save mechanism within 3 min after driver initialization.
+// This can make rebooter test more robust
+if (OPSTATUS_TEST_FLAG(pAd, fOP_STATUS_PCIE_DEVICE))
+ {
+ if ((pAd->OpMode == OPMODE_STA) && (IDLE_ON(pAd))
+ && (pAd->Mlme.SyncMachine.CurrState == SYNC_IDLE)
+ && (pAd->Mlme.CntlMachine.CurrState == CNTL_IDLE)
+ && (!RTMP_TEST_FLAG(pAd, fRTMP_ADAPTER_IDLE_RADIO_OFF)))
+ {
+ if (IS_RT3090(pAd)|| IS_RT3572(pAd) || IS_RT3390(pAd))
+ {
+ if (pAd->StaCfg.PSControl.field.EnableNewPS == TRUE)
+ {
+ DBGPRINT(RT_DEBUG_TRACE, ("%s::%d\n",__FUNCTION__,__LINE__));
+
+ RT28xxPciAsicRadioOff(pAd, GUI_IDLE_POWER_SAVE, 0);
+ }
+ else
+ {
+ DBGPRINT(RT_DEBUG_TRACE, ("%s::%d\n",__FUNCTION__,__LINE__));
+ AsicSendCommandToMcu(pAd, 0x30, PowerSafeCID, 0xff, 0x2);
+ // Wait command success
+ AsicCheckCommanOk(pAd, PowerSafeCID);
+ RTMP_SET_FLAG(pAd, fRTMP_ADAPTER_IDLE_RADIO_OFF);
+ DBGPRINT(RT_DEBUG_TRACE, ("PSM - rt30xx Issue Sleep command)\n"));
+ }
+ }
+ else if (pAd->Mlme.OneSecPeriodicRound > 180)
+ {
+ if (pAd->StaCfg.PSControl.field.EnableNewPS == TRUE)
+ {
+ DBGPRINT(RT_DEBUG_TRACE, ("%s::%d\n",__FUNCTION__,__LINE__));
+ RT28xxPciAsicRadioOff(pAd, GUI_IDLE_POWER_SAVE, 0);
+ }
+ else
+ {
+ DBGPRINT(RT_DEBUG_TRACE, ("%s::%d\n",__FUNCTION__,__LINE__));
+ AsicSendCommandToMcu(pAd, 0x30, PowerSafeCID, 0xff, 0x02);
+ // Wait command success
+ AsicCheckCommanOk(pAd, PowerSafeCID);
+ RTMP_SET_FLAG(pAd, fRTMP_ADAPTER_IDLE_RADIO_OFF);
+ DBGPRINT(RT_DEBUG_TRACE, ("PSM - rt28xx Issue Sleep command)\n"));
+ }
+ }
+ }
+ else
+ {
+ DBGPRINT(RT_DEBUG_TRACE,("STAMlmePeriodicExec MMCHK - CommonCfg.Ssid[%d]=%c%c%c%c... MlmeAux.Ssid[%d]=%c%c%c%c...\n",
+ pAd->CommonCfg.SsidLen, pAd->CommonCfg.Ssid[0], pAd->CommonCfg.Ssid[1], pAd->CommonCfg.Ssid[2], pAd->CommonCfg.Ssid[3],
+ pAd->MlmeAux.SsidLen, pAd->MlmeAux.Ssid[0], pAd->MlmeAux.Ssid[1], pAd->MlmeAux.Ssid[2], pAd->MlmeAux.Ssid[3]));
+ }
+ }
+#endif // PCIE_PS_SUPPORT //
+
+
+#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 &&
+ RTMP_TIME_AFTER(pAd->Mlme.Now32, pAd->StaCfg.LastMicErrorTime + (60*OS_HZ)))
+ 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;
+ }
+
+
+
+
+ if (pAd->CommonCfg.PSPXlink && ADHOC_ON(pAd))
+ {
+ }
+ else
+ {
+ 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, NULL, 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 ((RTMP_TIME_AFTER(pAd->Mlme.Now32, pAd->StaCfg.LastBeaconRxTime + (1*OS_HZ))) &&
+ (!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));
+
+ // Lost AP, send disconnect & link down event
+ LinkDown(pAd, FALSE);
+
+#ifdef WPA_SUPPLICANT_SUPPORT
+#ifndef NATIVE_WPA_SUPPLICANT_SUPPORT
+ //send disassociate event to wpa_supplicant
+ if (pAd->StaCfg.WpaSupplicantUP) {
+ RtmpOSWrielessEventSend(pAd, IWEVCUSTOM, RT_DISASSOC_EVENT_FLAG, NULL, NULL, 0);
+ }
+#endif // NATIVE_WPA_SUPPLICANT_SUPPORT //
+#endif // WPA_SUPPLICANT_SUPPORT //
+
+#ifdef NATIVE_WPA_SUPPLICANT_SUPPORT
+ RtmpOSWrielessEventSend(pAd, SIOCGIWAP, -1, NULL, NULL, 0);
+#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);
+ }
+
+ if (pAd->StaCfg.bAutoRoaming)
+ {
+ BOOLEAN rv = FALSE;
+ CHAR dBmToRoam = pAd->StaCfg.dBmToRoam;
+ CHAR MaxRssi = RTMPMaxRssi(pAd,
+ pAd->StaCfg.RssiSample.LastRssi0,
+ pAd->StaCfg.RssiSample.LastRssi1,
+ pAd->StaCfg.RssiSample.LastRssi2);
+
+ // Scanning, ignore Roaming
+ if (!RTMP_TEST_FLAG(pAd, fRTMP_ADAPTER_BSS_SCAN_IN_PROGRESS) &&
+ (pAd->Mlme.SyncMachine.CurrState == SYNC_IDLE) &&
+ (MaxRssi <= dBmToRoam))
+ {
+ DBGPRINT(RT_DEBUG_TRACE, ("Rssi=%d, dBmToRoam=%d\n", MaxRssi, (CHAR)dBmToRoam));
+
+
+ // Add auto seamless roaming
+ if (rv == FALSE)
+ rv = MlmeCheckForFastRoaming(pAd);
+
+ if (rv == FALSE)
+ {
+ if ((pAd->StaCfg.LastScanTime + 10 * OS_HZ) < pAd->Mlme.Now32)
+ {
+ DBGPRINT(RT_DEBUG_TRACE, ("MMCHK - Roaming, No eligable entry, try new scan!\n"));
+ pAd->StaCfg.ScanCnt = 2;
+ pAd->StaCfg.LastScanTime = pAd->Mlme.Now32;
+ MlmeAutoScan(pAd);
+ }
+ }
+ }
+ }
+ }
+ else if (ADHOC_ON(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 (RTMP_TIME_AFTER(pAd->Mlme.Now32, pAd->StaCfg.LastBeaconRxTime + ADHOC_BEACON_LOST_TIME) &&
+ 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, (CHAR *)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 (RTMP_TIME_AFTER(pAd->Mlme.Now32, pEntry->LastBeaconRxTime + ADHOC_BEACON_LOST_TIME))
+ MacTableDeleteEntry(pAd, pEntry->Aid, pEntry->Addr);
+ }
+ }
+ else // no INFRA nor ADHOC connection
+ {
+
+ if (pAd->StaCfg.bScanReqIsFromWebUI &&
+ RTMP_TIME_BEFORE(pAd->Mlme.Now32, pAd->StaCfg.LastScanTime + (30 * OS_HZ)))
+ 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 (RTMP_TIME_AFTER(pAd->Mlme.Now32, pAd->StaCfg.LastScanTime + (10 * OS_HZ)))
+ {
+ DBGPRINT(RT_DEBUG_TRACE, ("STAMlmePeriodicExec():CNTL - ScanTab.BssNr==0, start a new ACTIVE scan SSID[%s]\n", pAd->MlmeAux.AutoReconnectSsid));
+ ScanParmFill(pAd, &ScanReq, (PSTRING) 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;
+
+ if (pAd != NULL)
+ {
+ MLME_DISASSOC_REQ_STRUCT DisassocReq;
+
+ if ((pAd->StaCfg.PortSecured == WPA_802_1X_PORT_NOT_SECURED) &&
+ (INFRA_ON(pAd)))
+ {
+ DBGPRINT(RT_DEBUG_TRACE, ("LinkDownExec(): 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;
+
+ 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,
+ pAd->MlmeAux.AutoReconnectSsidLen,
+ pAd->MlmeAux.AutoReconnectSsid);
+ RTMP_MLME_HANDLER(pAd);
+ }
+}
+
+// IRQL = DISPATCH_LEVEL
+VOID MlmeAutoReconnectLastSSID(
+ IN PRTMP_ADAPTER pAd)
+{
+ if (pAd->StaCfg.bAutoConnectByBssid)
+ {
+ DBGPRINT(RT_DEBUG_TRACE, ("Driver auto reconnect to last OID_802_11_BSSID setting - %02X:%02X:%02X:%02X:%02X:%02X\n",
+ pAd->MlmeAux.Bssid[0],
+ pAd->MlmeAux.Bssid[1],
+ pAd->MlmeAux.Bssid[2],
+ pAd->MlmeAux.Bssid[3],
+ pAd->MlmeAux.Bssid[4],
+ pAd->MlmeAux.Bssid[5]));
+
+ pAd->MlmeAux.Channel = pAd->CommonCfg.Channel;
+ MlmeEnqueue(pAd,
+ MLME_CNTL_STATE_MACHINE,
+ OID_802_11_BSSID,
+ MAC_ADDR_LEN,
+ pAd->MlmeAux.Bssid);
+
+ pAd->Mlme.CntlMachine.CurrState = CNTL_IDLE;
+
+ RTMP_MLME_HANDLER(pAd);
+ }
+ // check CntlMachine.CurrState to avoid collision with NDIS SetOID request
+ else 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);
+ RTMP_MLME_HANDLER(pAd);
+ }
+}
+
+
+/*
+ ==========================================================================
+ 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 + pAd->StaCfg.BeaconLostTime) < 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);
+ RTMP_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:
+ ==========================================================================
+ */
+BOOLEAN MlmeCheckForFastRoaming(
+ IN PRTMP_ADAPTER pAd)
+{
+ 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;
+ }
+
+ DBGPRINT(RT_DEBUG_TRACE, ("<== MlmeCheckForFastRoaming (BssNr=%d)\n", pRoamTab->BssNr));
+ 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);
+ RTMP_MLME_HANDLER(pAd);
+ return TRUE;
+ }
+ }
+
+ return FALSE;
+}
+
+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 = FALSE, 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;
+ RSSI_SAMPLE *pRssi = &pAd->StaCfg.RssiSample;
+
+#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,
+ pRssi->AvgRssi0,
+ pRssi->AvgRssi1,
+ pRssi->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,
+ pRssi->AvgRssi0,
+ pRssi->AvgRssi1,
+ pRssi->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;
+ }
+
+ if (TxTotalCnt)
+ {
+ /*
+ Three AdHoc connections can not work normally if one AdHoc connection is disappeared from a heavy traffic environment generated by ping tool
+ We force to set LongRtyLimit and ShortRtyLimit to 0 to stop retransmitting packet, after a while, resoring original settings
+ */
+ if (TxErrorRatio == 100)
+ {
+ TX_RTY_CFG_STRUC TxRtyCfg,TxRtyCfgtmp;
+ ULONG Index;
+ ULONG MACValue;
+
+ RTMP_IO_READ32(pAd, TX_RTY_CFG, &TxRtyCfg.word);
+ TxRtyCfgtmp.word = TxRtyCfg.word;
+ TxRtyCfg.field.LongRtyLimit = 0x0;
+ TxRtyCfg.field.ShortRtyLimit = 0x0;
+ RTMP_IO_WRITE32(pAd, TX_RTY_CFG, TxRtyCfg.word);
+
+ RTMPusecDelay(1);
+
+ Index = 0;
+ MACValue = 0;
+ do
+ {
+ RTMP_IO_READ32(pAd, TXRXQ_PCNT, &MACValue);
+ if ((MACValue & 0xffffff) == 0)
+ break;
+ Index++;
+ RTMPusecDelay(1000);
+ }while((Index < 330)&&(!RTMP_TEST_FLAG(pAd, fRTMP_ADAPTER_HALT_IN_PROGRESS)));
+
+ RTMP_IO_READ32(pAd, TX_RTY_CFG, &TxRtyCfg.word);
+ TxRtyCfg.field.LongRtyLimit = TxRtyCfgtmp.field.LongRtyLimit;
+ TxRtyCfg.field.ShortRtyLimit = TxRtyCfgtmp.field.ShortRtyLimit;
+ RTMP_IO_WRITE32(pAd, TX_RTY_CFG, TxRtyCfg.word);
+ }
+ }
+
+ 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, 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 = MCS23;
+ else if (MCS22 && (Rssi >= -72))
+ TxRateIdx = MCS22;
+ else if (MCS21 && (Rssi >= -76))
+ TxRateIdx = MCS21;
+ else if (MCS20 && (Rssi >= -78))
+ TxRateIdx = MCS20;
+ 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;
+
+ {
+ UCHAR tmpTxRate;
+
+ // to fix tcp ack issue
+ if (!bTxRateChanged && (pAd->RalinkCounters.OneSecReceivedByteCount > (pAd->RalinkCounters.OneSecTransmittedByteCount * 5)))
+ {
+ tmpTxRate = DownRateIdx;
+ DBGPRINT_RAW(RT_DEBUG_TRACE,("DRS: Rx(%d) is 5 times larger than Tx(%d), use low rate (curr=%d, tmp=%d)\n",
+ pAd->RalinkCounters.OneSecReceivedByteCount, pAd->RalinkCounters.OneSecTransmittedByteCount, pEntry->CurrTxRateIndex, tmpTxRate));
+ }
+ else
+ {
+ tmpTxRate = pEntry->CurrTxRateIndex;
+ }
+
+ pNextTxRate = (PRTMP_TX_RATE_SWITCH) &pTable[(tmpTxRate+1)*5];
+ if (bTxRateChanged && pNextTxRate)
+ {
+ MlmeSetTxRate(pAd, pEntry, pNextTxRate);
+ }
+ }
+ // reset all OneSecTx counters
+ RESET_ONE_SEC_TX_CNT(pEntry);
+ }
+}
+
+/*
+ ========================================================================
+ 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
+ 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)&&
+ RTMP_TEST_PSFLAG(pAd, fRTMP_PS_CAN_GO_SLEEP)
+ /*&&
+ (pAd->RalinkCounters.OneSecTxNoRetryOkCount == 0) &&
+ (pAd->RalinkCounters.OneSecTxRetryOkCount == 0)*/)
+ {
+ NdisGetSystemUpTime(&pAd->Mlme.LastSendNULLpsmTime);
+ pAd->RalinkCounters.RxCountSinceLastNULL = 0;
+ RTMP_SET_PSM_BIT(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 //
+
+/*
+ ==========================================================================
+ 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 PMAC_TABLE_ENTRY pMacEntry,
+ IN ULONG Now32)
+{
+ ULONG TxOkCnt, TxCnt, TxPER, TxPRR;
+ ULONG RxCnt, RxPER;
+ UCHAR NorRssi;
+ CHAR MaxRssi;
+ RSSI_SAMPLE *pRssiSample = NULL;
+ UINT32 OneSecTxNoRetryOkCount = 0;
+ UINT32 OneSecTxRetryOkCount = 0;
+ UINT32 OneSecTxFailCount = 0;
+ UINT32 OneSecRxOkCnt = 0;
+ UINT32 OneSecRxFcsErrCnt = 0;
+ ULONG ChannelQuality = 0; // 0..100, Channel Quality Indication for Roaming
+#ifdef CONFIG_STA_SUPPORT
+ ULONG BeaconLostTime = pAd->StaCfg.BeaconLostTime;
+#endif // CONFIG_STA_SUPPORT //
+
+#ifdef CONFIG_STA_SUPPORT
+#ifdef CARRIER_DETECTION_SUPPORT // Roger sync Carrier
+ // longer beacon lost time when carrier detection enabled
+ if (pAd->CommonCfg.CarrierDetect.Enable == TRUE)
+ {
+ BeaconLostTime = pAd->StaCfg.BeaconLostTime + (pAd->StaCfg.BeaconLostTime/2);
+ }
+#endif // CARRIER_DETECTION_SUPPORT //
+#endif // CONFIG_STA_SUPPORT //
+
+#ifdef CONFIG_STA_SUPPORT
+ if (pAd->OpMode == OPMODE_STA)
+ {
+ pRssiSample = &pAd->StaCfg.RssiSample;
+ OneSecTxNoRetryOkCount = pAd->RalinkCounters.OneSecTxNoRetryOkCount;
+ OneSecTxRetryOkCount = pAd->RalinkCounters.OneSecTxRetryOkCount;
+ OneSecTxFailCount = pAd->RalinkCounters.OneSecTxFailCount;
+ OneSecRxOkCnt = pAd->RalinkCounters.OneSecRxOkCnt;
+ OneSecRxFcsErrCnt = pAd->RalinkCounters.OneSecRxFcsErrCnt;
+ }
+#endif // CONFIG_STA_SUPPORT //
+
+ MaxRssi = RTMPMaxRssi(pAd, pRssiSample->LastRssi0,
+ pRssiSample->LastRssi1,
+ pRssiSample->LastRssi2);
+
+ //
+ // calculate TX packet error ratio and TX retry ratio - if too few TX samples, skip TX related statistics
+ //
+ TxOkCnt = OneSecTxNoRetryOkCount + OneSecTxRetryOkCount;
+ TxCnt = TxOkCnt + OneSecTxFailCount;
+ if (TxCnt < 5)
+ {
+ TxPER = 0;
+ TxPRR = 0;
+ }
+ else
+ {
+ TxPER = (OneSecTxFailCount * 100) / TxCnt;
+ TxPRR = ((TxCnt - OneSecTxNoRetryOkCount) * 100) / TxCnt;
+ }
+
+ //
+ // calculate RX PER - don't take RxPER into consideration if too few sample
+ //
+ RxCnt = OneSecRxOkCnt + OneSecRxFcsErrCnt;
+ if (RxCnt < 5)
+ RxPER = 0;
+ else
+ RxPER = (OneSecRxFcsErrCnt * 100) / RxCnt;
+
+ //
+ // decide ChannelQuality based on: 1)last BEACON received time, 2)last RSSI, 3)TxPER, and 4)RxPER
+ //
+#ifdef CONFIG_STA_SUPPORT
+ if ((pAd->OpMode == OPMODE_STA) &&
+ INFRA_ON(pAd) &&
+ (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));
+ ChannelQuality = 0;
+ }
+ else
+#endif // CONFIG_STA_SUPPORT //
+ {
+ // 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)
+ ChannelQuality = (RSSI_WEIGHTING * NorRssi +
+ TX_WEIGHTING * (100 - TxPRR) +
+ RX_WEIGHTING* (100 - RxPER)) / 100;
+ }
+
+
+#ifdef CONFIG_STA_SUPPORT
+ if (pAd->OpMode == OPMODE_STA)
+ pAd->Mlme.ChannelQuality = (ChannelQuality > 100) ? 100 : ChannelQuality;
+#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 (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;
+ }
+
+#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);
+
+ if (pDesireHtPhy->MCSSet[4] != 0)
+ {
+ pMaxHtPhy->field.MCS = 32;
+ }
+
+ 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"));
+}
+
+
+VOID BATableInit(
+ IN PRTMP_ADAPTER pAd,
+ IN BA_TABLE *Tab)
+{
+ int i;
+
+ Tab->numAsOriginator = 0;
+ Tab->numAsRecipient = 0;
+ Tab->numDoneOriginator = 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 //
+
+// IRQL = DISPATCH_LEVEL
+VOID MlmeRadioOff(
+ IN PRTMP_ADAPTER pAd)
+{
+ RTMP_MLME_RADIO_OFF(pAd);
+}
+
+// IRQL = DISPATCH_LEVEL
+VOID MlmeRadioOn(
+ IN PRTMP_ADAPTER pAd)
+{
+ RTMP_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
+ }
+}
+
+
+/*! \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;
+}
+
+
+ULONG BssSsidTableSearchBySSID(
+ IN BSS_TABLE *Tab,
+ IN PUCHAR pSsid,
+ IN UCHAR SsidLen)
+{
+ UCHAR i;
+
+ for (i = 0; i < Tab->BssNr; i++)
+ {
+ if (SSID_EQUAL(pSsid, SsidLen, Tab->BssEntry[i].Ssid, 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);
+ 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, (UCHAR *)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) &&
+ (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:
+ 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-enterprise mode
+ if (pBss->AuthMode == Ndis802_11AuthModeOpen)
+ pBss->AuthMode = Ndis802_11AuthModeWPA;
+ else
+ pBss->AuthModeAux = Ndis802_11AuthModeWPA;
+ break;
+ case 2:
+ // Set AP support WPA-PSK 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
+ // Parsing all AKM ciphers
+ while (Count > 0)
+ {
+ pAKM = (PAKM_SUITE_STRUCT) pTmp;
+ if (!RTMPEqualMemory(pTmp, RSN_OUI, 3))
+ break;
+
+ switch (pAKM->Type)
+ {
+ case 1:
+ // Set AP support WPA-enterprise mode
+ if (pBss->AuthMode == Ndis802_11AuthModeOpen)
+ pBss->AuthMode = Ndis802_11AuthModeWPA2;
+ else
+ pBss->AuthModeAux = Ndis802_11AuthModeWPA2;
+ break;
+ case 2:
+ // Set AP support WPA-PSK mode
+ if (pBss->AuthMode == Ndis802_11AuthModeOpen)
+ pBss->AuthMode = Ndis802_11AuthModeWPA2PSK;
+ else
+ pBss->AuthModeAux = Ndis802_11AuthModeWPA2PSK;
+ break;
+ default:
+ if (pBss->AuthMode == Ndis802_11AuthModeOpen)
+ pBss->AuthMode = Ndis802_11AuthModeMax;
+ else
+ pBss->AuthModeAux = Ndis802_11AuthModeMax;
+ break;
+ }
+ pTmp += (Count * sizeof(AKM_SUITE_STRUCT));
+ Count--;
+ }
+
+ // 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 UCHAR *Buffer,
+ OUT ULONG *FrameLen, ...)
+{
+ UCHAR *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));
+
+ RTMP_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 RTMP_MAC_PCI
+ MLME_QUEUE_ELEM *Elem = NULL;
+#endif // RTMP_MAC_PCI //
+#ifdef CONFIG_STA_SUPPORT
+ BOOLEAN Cancelled;
+#endif // CONFIG_STA_SUPPORT //
+
+ DBGPRINT(RT_DEBUG_TRACE, ("MlmeRestartStateMachine \n"));
+
+#ifdef RTMP_MAC_PCI
+ NdisAcquireSpinLock(&pAd->Mlme.TaskLock);
+ if(pAd->Mlme.bRunning)
+ {
+ NdisReleaseSpinLock(&pAd->Mlme.TaskLock);
+ return;
+ }
+ else
+ {
+ pAd->Mlme.bRunning = TRUE;
+ }
+ NdisReleaseSpinLock(&pAd->Mlme.TaskLock);
+
+ // Remove all Mlme queues elements
+ while (!MlmeQueueEmpty(&pAd->Mlme.Queue))
+ {
+ //From message type, determine which state machine I should drive
+ if (MlmeDequeue(&pAd->Mlme.Queue, &Elem))
+ {
+ // free MLME element
+ Elem->Occupied = FALSE;
+ Elem->MsgLen = 0;
+
+ }
+ else {
+ DBGPRINT_ERR(("MlmeRestartStateMachine: MlmeQueue empty\n"));
+ }
+ }
+#endif // RTMP_MAC_PCI //
+
+#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 //
+
+#ifdef RTMP_MAC_PCI
+ // Remove running state
+ NdisAcquireSpinLock(&pAd->Mlme.TaskLock);
+ pAd->Mlme.bRunning = FALSE;
+ NdisReleaseSpinLock(&pAd->Mlme.TaskLock);
+#endif // RTMP_MAC_PCI //
+}
+
+/*! \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, Alg;
+ 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)
+ {
+ {
+ *Machine = WPA_STATE_MACHINE;
+ EAPType = *((UCHAR*)pFrame + LENGTH_802_11 + LENGTH_802_1_H + 1);
+ return (WpaMsgTypeSubst(EAPType, (INT *) 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));
+ NdisMoveMemory(&Alg, &pFrame->Octet[0], sizeof(USHORT));
+ if (Seq == 1 || Seq == 3)
+ {
+ *Machine = AUTH_RSP_STATE_MACHINE;
+ *MsgType = MT2_PEER_AUTH_ODD;
+ }
+ else if (Seq == 2 || Seq == 4)
+ {
+ if (Alg == AUTH_MODE_OPEN || Alg == AUTH_MODE_KEY)
+ {
+ *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;
+}
+
+
+/*
+ ========================================================================
+
+ 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)
+{
+#ifdef CONFIG_STA_SUPPORT
+ UCHAR BBPR3 = 0;
+#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 |
+ fRTMP_ADAPTER_BSS_SCAN_IN_PROGRESS) ||
+ OPSTATUS_TEST_FLAG(pAd, fOP_STATUS_DOZE)
+#ifdef RT3090
+ || (pAd->bPCIclkOff == TRUE)
+#endif // RT3090 //
+#ifdef ANT_DIVERSITY_SUPPORT
+ || (pAd->EepromAccess)
+#endif // ANT_DIVERSITY_SUPPORT //
+ )
+ return;
+
+#ifdef ANT_DIVERSITY_SUPPORT
+ if ((pAd->NicConfig2.field.AntDiversity) && (pAd->CommonCfg.bRxAntDiversity == ANT_DIVERSITY_ENABLE))
+ {
+ // 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
+ 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
+#endif // ANT_DIVERSITY_SUPPORT //
+ {
+#ifdef CONFIG_STA_SUPPORT
+ IF_DEV_CONFIG_OPMODE_ON_STA(pAd)
+ {
+
+ 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);
+#ifdef RTMP_MAC_PCI
+ IF_DEV_CONFIG_OPMODE_ON_STA(pAd)
+ pAd->StaCfg.BBPR3 = BBPR3;
+#endif // RTMP_MAC_PCI //
+ 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;
+ }
+ }
+ }
+#endif // CONFIG_STA_SUPPORT //
+ }
+}
+
+/*
+ ========================================================================
+ 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;
+ BOOLEAN bSwapAnt = FALSE;
+#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 RT3090
+ || (pAd->bPCIclkOff == TRUE)
+#endif // RT3090 //
+#ifdef ANT_DIVERSITY_SUPPORT
+ || (pAd->EepromAccess)
+#endif // ANT_DIVERSITY_SUPPORT //
+ )
+ return;
+
+#ifdef ANT_DIVERSITY_SUPPORT
+ if ((pAd->NicConfig2.field.AntDiversity) && (pAd->CommonCfg.bRxAntDiversity == ANT_DIVERSITY_ENABLE))
+ {
+#ifdef CONFIG_STA_SUPPORT
+ IF_DEV_CONFIG_OPMODE_ON_STA(pAd)
+ if ((pAd->RxAnt.RcvPktNumWhenEvaluate != 0) && (pAd->RxAnt.Pair1AvgRssi[pAd->RxAnt.Pair1SecondaryRxAnt] >= pAd->RxAnt.Pair1AvgRssi[pAd->RxAnt.Pair1PrimaryRxAnt]))
+ bSwapAnt = TRUE;
+#endif // CONFIG_STA_SUPPORT //
+ if (bSwapAnt == TRUE)
+ {
+ 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;
+
+#ifdef CONFIG_STA_SUPPORT
+ pAd->RxAnt.Pair1LastAvgRssi = (pAd->RxAnt.Pair1AvgRssi[pAd->RxAnt.Pair1SecondaryRxAnt] >> 3);
+#endif // CONFIG_STA_SUPPORT //
+// 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
+
+#ifdef CONFIG_STA_SUPPORT
+ 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));
+#endif // CONFIG_STA_SUPPORT //
+ }
+ else
+#endif // ANT_DIVERSITY_SUPPORT //
+ {
+#ifdef CONFIG_STA_SUPPORT
+ IF_DEV_CONFIG_OPMODE_ON_STA(pAd)
+ {
+ 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);
+#ifdef RTMP_MAC_PCI
+ pAd->StaCfg.BBPR3 = BBPR3;
+#endif // RTMP_MAC_PCI //
+ }
+#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))
+#ifdef RTMP_MAC_PCI
+ && (pAd->bPCIclkOff == FALSE)
+#endif // RTMP_MAC_PCI //
+ )
+ {
+ 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_RT3070(pAd)||IS_RT3090(pAd) || IS_RT3572(pAd) || IS_RT3390(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
+#ifdef RT30xx
+ /* Gary was verified Amazon AP and find that RT307x has BBP_R66 invalid default value */
+
+ if (IS_RT3070(pAd)||IS_RT3090(pAd) || IS_RT3572(pAd) || IS_RT3390(pAd))
+ {
+ R66 = 0x1C + 2*GET_LNA_GAIN(pAd);
+ RTMP_BBP_IO_WRITE8_BY_REG_ID(pAd, BBP_R66, R66);
+ }
+ else
+#endif // RT30xx //
+ {
+ 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 //
+ }
+ }
+
+}
diff --git a/drivers/staging/rt3090/common/mlme_ex.c b/drivers/staging/rt3090/common/mlme_ex.c
new file mode 100644
index 000000000000..d7fb7f58daee
--- /dev/null
+++ b/drivers/staging/rt3090/common/mlme_ex.c
@@ -0,0 +1,215 @@
+/*
+ *************************************************************************
+ * 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_ex.c
+
+ Abstract:
+ Miniport generic portion header file
+
+ Revision History:
+ Who When What
+ -------- ---------- ----------------------------------------------
+ Fonchi 2007-06-25 Extend original mlme APIs to support multi-entries
+*/
+
+#include "../rt_config.h"
+#include "../mlme_ex_def.h"
+//#include <stdarg.h>
+
+
+// ===========================================================================================
+// state_machine
+// ===========================================================================================
+
+/*! \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
+ */
+VOID StateMachineInitEx(
+ IN STATE_MACHINE_EX *S,
+ IN STATE_MACHINE_FUNC_EX Trans[],
+ IN ULONG StNr,
+ IN ULONG MsgNr,
+ IN STATE_MACHINE_FUNC_EX 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;
+
+ return;
+}
+
+/*! \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
+ */
+VOID StateMachineSetActionEx(
+ IN STATE_MACHINE_EX *S,
+ IN ULONG St,
+ IN ULONG Msg,
+ IN STATE_MACHINE_FUNC_EX 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;
+ }
+
+ return;
+}
+
+/*! \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
+ */
+VOID StateMachinePerformActionEx(
+ IN PRTMP_ADAPTER pAd,
+ IN STATE_MACHINE_EX *S,
+ IN MLME_QUEUE_ELEM *Elem,
+ USHORT Idx,
+ PULONG pCurrState)
+{
+ if (S->TransFunc[(*pCurrState) * S->NrMsg + Elem->MsgType - S->Base])
+ (*(S->TransFunc[(*pCurrState) * S->NrMsg + Elem->MsgType - S->Base]))(pAd, Elem, pCurrState, Idx);
+
+ return;
+}
+
+/*! \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
+ */
+BOOLEAN MlmeEnqueueEx(
+ IN PRTMP_ADAPTER pAd,
+ IN ULONG Machine,
+ IN ULONG MsgType,
+ IN ULONG MsgLen,
+ IN VOID *Msg,
+ IN USHORT Idx)
+{
+ 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))
+ return FALSE;
+
+
+ // First check the size, it MUST not exceed the mlme queue size
+ if (MsgLen > MAX_LEN_OF_MLME_BUFFER)
+ {
+ DBGPRINT_ERR(("MlmeEnqueueEx: msg too large, size = %ld \n", MsgLen));
+ return FALSE;
+ }
+
+ if (MlmeQueueFull(Queue))
+ {
+
+ return FALSE;
+ }
+
+ RTMP_SEM_LOCK(&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].Idx = Idx;
+ if (Msg != NULL)
+ NdisMoveMemory(Queue->Entry[Tail].Msg, Msg, MsgLen);
+
+ RTMP_SEM_UNLOCK(&Queue->Lock);
+
+ return TRUE;
+}
+
+/*
+ ==========================================================================
+ Description:
+ The drop function, when machine executes this, the message is simply
+ ignored. This function does nothing, the message is freed in
+ StateMachinePerformAction()
+ ==========================================================================
+ */
+VOID DropEx(
+ IN PRTMP_ADAPTER pAd,
+ IN MLME_QUEUE_ELEM *Elem,
+ PULONG pCurrState,
+ USHORT Idx)
+{
+ return;
+}
diff --git a/drivers/staging/rt3090/common/netif_block.c b/drivers/staging/rt3090/common/netif_block.c
new file mode 100644
index 000000000000..2172957f4e41
--- /dev/null
+++ b/drivers/staging/rt3090/common/netif_block.c
@@ -0,0 +1,147 @@
+/*
+ *************************************************************************
+ * 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 BLOCK_NET_IF
+
+#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)
+ {
+ RTMP_OS_NETDEV_STOP_QUEUE(pNetDev);
+ pNetIfEntry->pNetDev = pNetDev;
+ insertTailList(&pBlockQueueEntry->NetIfList, (PLIST_ENTRY)pNetIfEntry);
+
+ pBlockQueueEntry->SwTxQueueBlockFlag = TRUE;
+ DBGPRINT(RT_DEBUG_TRACE, ("RTMP_OS_NETDEV_STOP_QUEUE(%s)\n", RTMP_OS_NETDEV_GET_DEVNAME(pNetDev)));
+ }
+ 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;
+ RTMP_OS_NETDEV_WAKE_QUEUE(pNetDev);
+ insertTailList(&freeNetIfEntryList, (PLIST_ENTRY)pNetIfEntry);
+
+ DBGPRINT(RT_DEBUG_TRACE, ("RTMP_OS_NETDEV_WAKE_QUEUE(%s)\n", RTMP_OS_NETDEV_GET_DEVNAME(pNetDev)));
+ }
+ 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;
+}
+
+#endif // BLOCK_NET_IF //
diff --git a/drivers/staging/rt3090/common/rt_channel.c b/drivers/staging/rt3090/common/rt_channel.c
new file mode 100644
index 000000000000..da2391e8b74b
--- /dev/null
+++ b/drivers/staging/rt3090/common/rt_channel.c
@@ -0,0 +1,1287 @@
+/*
+ *************************************************************************
+ * 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"
+
+
+CH_FREQ_MAP CH_HZ_ID_MAP[]=
+ {
+ {1, 2412},
+ {2, 2417},
+ {3, 2422},
+ {4, 2427},
+ {5, 2432},
+ {6, 2437},
+ {7, 2442},
+ {8, 2447},
+ {9, 2452},
+ {10, 2457},
+ {11, 2462},
+ {12, 2467},
+ {13, 2472},
+ {14, 2484},
+
+ /* UNII */
+ {36, 5180},
+ {40, 5200},
+ {44, 5220},
+ {48, 5240},
+ {52, 5260},
+ {56, 5280},
+ {60, 5300},
+ {64, 5320},
+ {149, 5745},
+ {153, 5765},
+ {157, 5785},
+ {161, 5805},
+ {165, 5825},
+ {167, 5835},
+ {169, 5845},
+ {171, 5855},
+ {173, 5865},
+
+ /* HiperLAN2 */
+ {100, 5500},
+ {104, 5520},
+ {108, 5540},
+ {112, 5560},
+ {116, 5580},
+ {120, 5600},
+ {124, 5620},
+ {128, 5640},
+ {132, 5660},
+ {136, 5680},
+ {140, 5700},
+
+ /* Japan MMAC */
+ {34, 5170},
+ {38, 5190},
+ {42, 5210},
+ {46, 5230},
+
+ /* Japan */
+ {184, 4920},
+ {188, 4940},
+ {192, 4960},
+ {196, 4980},
+
+ {208, 5040}, /* Japan, means J08 */
+ {212, 5060}, /* Japan, means J12 */
+ {216, 5080}, /* Japan, means J16 */
+};
+
+INT CH_HZ_ID_MAP_NUM = (sizeof(CH_HZ_ID_MAP)/sizeof(CH_FREQ_MAP));
+
+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 PCH_REGION GetChRegion(
+ IN PUCHAR CntryCode)
+{
+ INT loop = 0;
+ PCH_REGION pChRegion = NULL;
+
+ while (strcmp((PSTRING) ChRegion[loop].CountReg, "") != 0)
+ {
+ if (strncmp((PSTRING) ChRegion[loop].CountReg, (PSTRING) CntryCode, 2) == 0)
+ {
+ pChRegion = &ChRegion[loop];
+ break;
+ }
+ loop++;
+ }
+
+ if (pChRegion == NULL)
+ pChRegion = &ChRegion[loop];
+ return pChRegion;
+}
+
+static 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 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);
+ }
+ }
+}
+
+
+VOID BuildChannelListEx(
+ IN PRTMP_ADAPTER pAd)
+{
+ PCH_REGION pChReg;
+
+ pChReg = GetChRegion(pAd->CommonCfg.CountryCode);
+ CreateChList(pAd, pChReg, pAd->CommonCfg.Geography);
+}
+
+
+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 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 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;
+}
+
+
+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()
+ }
+ }
+ }
+
+
+}
+
+
+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 //
+
+
+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;
+}
diff --git a/drivers/staging/rt3090/common/rt_rf.c b/drivers/staging/rt3090/common/rt_rf.c
new file mode 100644
index 000000000000..9d638f71dbe5
--- /dev/null
+++ b/drivers/staging/rt3090/common/rt_rf.c
@@ -0,0 +1,201 @@
+/*
+ *************************************************************************
+ * 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_rf.c
+
+ Abstract:
+ Ralink Wireless driver RF related functions
+
+ Revision History:
+ Who When What
+ -------- ---------- ----------------------------------------------
+*/
+
+#include "../rt_config.h"
+
+
+#ifdef RTMP_RF_RW_SUPPORT
+/*
+ ========================================================================
+
+ Routine Description: Write RT30xx RF register through MAC
+
+ Arguments:
+
+ Return Value:
+
+ IRQL =
+
+ Note:
+
+ ========================================================================
+*/
+NDIS_STATUS 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 NDIS_STATUS_SUCCESS;
+}
+
+
+/*
+ ========================================================================
+
+ Routine Description: Read RT30xx RF register through MAC
+
+ Arguments:
+
+ Return Value:
+
+ IRQL =
+
+ Note:
+
+ ========================================================================
+*/
+NDIS_STATUS 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;
+}
+
+
+VOID NICInitRFRegisters(
+ IN RTMP_ADAPTER *pAd)
+{
+ if (pAd->chipOps.AsicRfInit)
+ pAd->chipOps.AsicRfInit(pAd);
+}
+
+
+VOID RtmpChipOpsRFHook(
+ IN RTMP_ADAPTER *pAd)
+{
+ RTMP_CHIP_OP *pChipOps = &pAd->chipOps;
+
+ pChipOps->pRFRegTable = NULL;
+ pChipOps->AsicRfInit = NULL;
+ pChipOps->AsicRfTurnOn = NULL;
+ pChipOps->AsicRfTurnOff = NULL;
+ pChipOps->AsicReverseRfFromSleepMode = NULL;
+ pChipOps->AsicHaltAction = NULL;
+#ifdef RT33xx
+if (IS_RT3390(pAd) && (pAd->infType == RTMP_DEV_INF_PCI))
+ {
+ pChipOps->pRFRegTable = RFRegTableOverRT3390;
+ pChipOps->AsicHaltAction = RT33xxHaltAction;
+ pChipOps->AsicRfTurnOff = RT33xxLoadRFSleepModeSetup;
+ pChipOps->AsicRfInit = NICInitRT3390RFRegisters;
+ pChipOps->AsicReverseRfFromSleepMode = RT33xxReverseRFSleepModeSetup;
+ }
+#else // RT33xx //
+ /* We depends on RfICType and MACVersion to assign the corresponding operation callbacks. */
+
+#ifdef RT30xx
+ if (IS_RT30xx(pAd))
+ {
+ pChipOps->pRFRegTable = RT30xx_RFRegTable;
+ pChipOps->AsicHaltAction = RT30xxHaltAction;
+#ifdef RT3090
+ if (IS_RT3090(pAd) && (pAd->infType == RTMP_DEV_INF_PCI))
+ {
+ pChipOps->AsicRfTurnOff = RT30xxLoadRFSleepModeSetup;
+ pChipOps->AsicRfInit = NICInitRT3090RFRegisters;
+ pChipOps->AsicReverseRfFromSleepMode = RT30xxReverseRFSleepModeSetup;
+ }
+#endif // RT3090 //
+ }
+#endif // RT30xx //
+#endif // RT33xx //
+}
+
+#endif // RTMP_RF_RW_SUPPORT //
diff --git a/drivers/staging/rt3090/common/rtmp_init.c b/drivers/staging/rt3090/common/rtmp_init.c
new file mode 100644
index 000000000000..48b95b75b0d5
--- /dev/null
+++ b/drivers/staging/rt3090/common/rtmp_init.c
@@ -0,0 +1,3882 @@
+/*
+ *************************************************************************
+ * 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
+ -------- ---------- ----------------------------------------------
+*/
+
+#include "../rt_config.h"
+
+
+UCHAR BIT8[] = {0x01, 0x02, 0x04, 0x08, 0x10, 0x20, 0x40, 0x80};
+char* CipherName[] = {"none","wep64","wep128","TKIP","AES","CKIP64","CKIP128"};
+
+//
+// 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.
+ {BBP_R106, 0x35}, // for ShortGI throughput
+};
+#define NUM_BBP_REG_PARMS (sizeof(BBPRegTable) / sizeof(REG_PAIR))
+
+
+//
+// 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, 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
+
+//#ifdef CONFIG_AP_SUPPORT
+// {WMM_AIFSN_CFG, 0x00001173},
+// {WMM_CWMIN_CFG, 0x00002344},
+// {WMM_CWMAX_CFG, 0x000034a6},
+// {WMM_TXOP0_CFG, 0x00100020},
+// {WMM_TXOP1_CFG, 0x002F0038},
+//#endif // CONFIG_AP_SUPPORT //
+
+//#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
+// WMM_ACM_SUPPORT
+// {TX_RTY_CFG, 0x6bb80101}, // sample
+ {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.
+ {GF20_PROT_CFG, 0x01744004}, // set 19:18 --> Short NAV for MIMO PS
+ {GF40_PROT_CFG, 0x03F44084},
+ {MM20_PROT_CFG, 0x01744004},
+#ifdef RTMP_MAC_PCI
+ {MM40_PROT_CFG, 0x03F54084},
+#endif // RTMP_MAC_PCI //
+ {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 //
+//#ifdef CONFIG_AP_SUPPORT
+// {TBTT_SYNC_CFG, 0x00422000}, // TBTT_ADJUST(7:0) == 0
+// {TBTT_SYNC_CFG, 0x00012000}, // TBTT_ADJUST(7:0) == 0
+//#endif // CONFIG_AP_SUPPORT //
+ {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 //
+
+
+/*
+ ========================================================================
+
+ 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;
+ }
+ NdisZeroMemory(pBeaconBuf, MAX_BEACON_SIZE);
+
+ Status = AdapterBlockAllocateMemory(handle, (PVOID *)&pAd);
+ if (Status != NDIS_STATUS_SUCCESS)
+ {
+ DBGPRINT_ERR(("Failed to allocate memory - ADAPTER\n"));
+ break;
+ }
+ pAd->BeaconBuf = pBeaconBuf;
+ DBGPRINT(RT_DEBUG_OFF, ("\n\n=== pAd = %p, size = %d ===\n\n", pAd, (UINT32)sizeof(RTMP_ADAPTER)));
+
+
+ // Init spin locks
+ NdisAllocateSpinLock(&pAd->MgmtRingLock);
+#ifdef RTMP_MAC_PCI
+ NdisAllocateSpinLock(&pAd->RxRingLock);
+#ifdef RT3090
+#ifdef CONFIG_STA_SUPPORT
+ NdisAllocateSpinLock(&pAd->McuCmdLock);
+#endif // CONFIG_STA_SUPPORT //
+#endif // RT3090 //
+#endif // RTMP_MAC_PCI //
+
+ 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 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);
+
+ /* For 20M/40M Power Delta issue */
+ pAd->Tx20MPwrCfgABand[i] = data;
+ pAd->Tx20MPwrCfgGBand[i] = data;
+ pAd->Tx40MPwrCfgABand[i] = Adata;
+ 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));
+ }
+}
+
+
+/*
+ ========================================================================
+
+ 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++)
+ {
+ 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++)
+ {
+ 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++)
+ {
+ 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, 167, 169; 171, 173 (including central frequency in BW 40MHz)
+ // 3.1 Fill up channel
+ choffset = 14 + 12 + 16;
+ /*for (i = 0; i < 2; i++)*/
+ for (i = 0; i < 3; 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 * 3 + choffset + 0].Channel = 171;
+ pAd->TxPower[3 * 3 + choffset + 0].Power = DEFAULT_RF_TX_POWER;
+ pAd->TxPower[3 * 3 + choffset + 0].Power2 = DEFAULT_RF_TX_POWER;
+
+ pAd->TxPower[3 * 3 + choffset + 1].Channel = 173;
+ pAd->TxPower[3 * 3 + choffset + 1].Power = DEFAULT_RF_TX_POWER;
+ pAd->TxPower[3 * 3 + choffset + 1].Power2 = DEFAULT_RF_TX_POWER;
+
+ // 3.2 Fill up power
+ /*for (i = 0; i < 4; i++)*/
+ for (i = 0; i < 6; i++)
+ {
+ 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;*/
+ choffset = 14 + 12 + 16 + 11;
+
+
+}
+
+/*
+ ========================================================================
+
+ 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;
+}
+
+
+/*
+ ========================================================================
+
+ 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"));
+
+ if (pAd->chipOps.eeinit)
+ pAd->chipOps.eeinit(pAd);
+#ifdef RTMP_EFUSE_SUPPORT
+#ifdef RT30xx
+ if(!pAd->bFroceEEPROMBuffer && pAd->bEEPROMFile)
+ {
+ DBGPRINT(RT_DEBUG_TRACE, ("--> NICReadEEPROMParameters::(Efuse)Load to EEPROM Buffer Mode\n"));
+ eFuseLoadEEPROM(pAd);
+ }
+#endif // RT30xx //
+#endif // RTMP_EFUSE_SUPPORT //
+
+ // 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((PSTRING) 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;
+ PSTRING macptr;
+
+ macptr = (PSTRING) 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",
+ PRINT_MAC(pAd->PermanentAddress)));
+ }
+ }
+
+ // 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)|| IS_RT3390(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));
+ }
+ }
+
+ // 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;
+
+ // Set the RfICType here, then we can initialize RFIC related operation callbacks
+ pAd->Mlme.RealRxPath = (UCHAR) Antenna.field.RxPath;
+ pAd->RfIcType = (UCHAR) Antenna.field.RfIcType;
+
+#ifdef RTMP_RF_RW_SUPPORT
+ RtmpChipOpsRFHook(pAd);
+#endif // RTMP_RF_RW_SUPPORT //
+
+ //
+ // 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)
+ && (Antenna.field.RfIcType != RFIC_3052))
+ {
+ 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;
+
+#ifdef RT30xx
+ //
+ // Get TX mixer gain setting
+ // 0xff are invalid value
+ // Note: RT30xX default value is 0x00 and will program to RF_R17 only when this value is not zero.
+ // RT359X default value is 0x02
+ //
+ if (IS_RT30xx(pAd) || IS_RT3572(pAd))
+ {
+ RT28xx_EEPROM_READ16(pAd, EEPROM_TXMIXER_GAIN_2_4G, value);
+ pAd->TxMixerGain24G = 0;
+ value &= 0x00ff;
+ if (value != 0xff)
+ {
+ value &= 0x07;
+ pAd->TxMixerGain24G = (UCHAR)value;
+ }
+ }
+#endif // RT30xx //
+
+ //
+ // Get LED Setting.
+ //
+ RT28xx_EEPROM_READ16(pAd, 0x3a, value);
+ pAd->LedCntl.word = (value>>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
+ RT28xx_EEPROM_READ16(pAd, EEPROM_DEFINE_MAX_TXPWR, pAd->CommonCfg.DefineMaxTxPwr);
+#endif // SINGLE_SKU //
+
+#ifdef RT30xx
+#ifdef RTMP_EFUSE_SUPPORT
+ RtmpEfuseSupportCheck(pAd);
+#endif // RTMP_EFUSE_SUPPORT //
+#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);
+ }
+ }
+
+
+ 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;
+
+#ifdef RT30xx
+ // set default antenna as main
+ if (pAd->RfIcType == RFIC_3020)
+ AsicSetRxAnt(pAd, pAd->RxAnt.Pair1PrimaryRxAnt);
+#endif // RT30xx //
+
+ //
+ // Send LED Setting to MCU.
+ //
+ if (pAd->LedCntl.word == 0xFF)
+ {
+ pAd->LedCntl.word = 0x01;
+ pAd->Led1 = 0x5555;
+ pAd->Led2 = 0x2221;
+
+#ifdef RTMP_MAC_PCI
+ pAd->Led3 = 0xA9F8;
+#endif // RTMP_MAC_PCI //
+ }
+
+ 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));
+ AsicSendCommandToMcu(pAd, 0x51, 0xff, 0, pAd->LedCntl.field.Polarity);
+
+ pAd->LedIndicatorStrength = 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);
+#ifdef RTMP_MAC_PCI
+#ifdef RT3090
+ AsicSendCommandToMcu(pAd, 0x30, PowerRadioOffCID, 0xff, 0x02);
+ AsicCheckCommanOk(pAd, PowerRadioOffCID);
+#endif // RT3090 //
+#ifndef RT3090
+ AsicSendCommandToMcu(pAd, 0x30, 0xff, 0xff, 0x02);
+#endif // RT3090 //
+ AsicSendCommandToMcu(pAd, 0x31, PowerWakeCID, 0x00, 0x00);
+ // 2-1. wait command ok.
+ AsicCheckCommanOk(pAd, PowerWakeCID);
+#endif // RTMP_MAC_PCI //
+ }
+ }
+#ifdef RTMP_MAC_PCI
+#ifdef RT30xx
+ if (IS_RT3090(pAd)|| IS_RT3572(pAd) || IS_RT3390(pAd))
+ {
+ RTMP_CHIP_OP *pChipOps = &pAd->chipOps;
+ if (pChipOps->AsicReverseRfFromSleepMode)
+ pChipOps->AsicReverseRfFromSleepMode(pAd);
+ }
+ // 3090 MCU Wakeup command needs more time to be stable.
+ // Before stable, don't issue other MCU command to prevent from firmware error.
+
+ if ((IS_RT3090(pAd)|| IS_RT3572(pAd) || IS_RT3390(pAd)) && IS_VERSION_AFTER_F(pAd)
+ && (pAd->StaCfg.PSControl.field.rt30xxPowerMode == 3)
+ && (pAd->StaCfg.PSControl.field.EnableNewPS == TRUE))
+ {
+ DBGPRINT(RT_DEBUG_TRACE,("%s::%d,release Mcu Lock\n",__FUNCTION__,__LINE__));
+ RTMP_SEM_LOCK(&pAd->McuCmdLock);
+ pAd->brt30xxBanMcuCmd = FALSE;
+ RTMP_SEM_UNLOCK(&pAd->McuCmdLock);
+ }
+#endif // RT30xx //
+#endif // RTMP_MAC_PCI //
+#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;
+#ifdef RTMP_MAC_PCI
+ UINT32 Value;
+ DELAY_INT_CFG_STRUC IntCfg;
+#endif // RTMP_MAC_PCI //
+// 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
+#ifdef RTMP_MAC_PCI
+ 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 // RTMP_MAC_PCI //
+
+ // Initialze ASIC for TX & Rx operation
+ if (NICInitializeAsic(pAd , bHardReset) != NDIS_STATUS_SUCCESS)
+ {
+ if (j++ == 0)
+ {
+ NICLoadFirmware(pAd);
+ goto retry;
+ }
+ return NDIS_STATUS_FAILURE;
+ }
+
+
+#ifdef RTMP_MAC_PCI
+ // 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);
+ DBGPRINT(RT_DEBUG_TRACE, ("--> TX_BASE_PTR1 : 0x%x\n", Value));
+
+ // Write AC_BE base address register
+ Value = RTMP_GetPhysicalAddressLow(pAd->TxRing[QID_AC_BE].Cell[0].AllocPa);
+ RTMP_IO_WRITE32(pAd, TX_BASE_PTR0, Value);
+ DBGPRINT(RT_DEBUG_TRACE, ("--> TX_BASE_PTR0 : 0x%x\n", Value));
+
+ // Write AC_VI base address register
+ Value = RTMP_GetPhysicalAddressLow(pAd->TxRing[QID_AC_VI].Cell[0].AllocPa);
+ RTMP_IO_WRITE32(pAd, TX_BASE_PTR2, Value);
+ DBGPRINT(RT_DEBUG_TRACE, ("--> TX_BASE_PTR2 : 0x%x\n", Value));
+
+ // Write AC_VO base address register
+ Value = RTMP_GetPhysicalAddressLow(pAd->TxRing[QID_AC_VO].Cell[0].AllocPa);
+ RTMP_IO_WRITE32(pAd, TX_BASE_PTR3, Value);
+ DBGPRINT(RT_DEBUG_TRACE, ("--> TX_BASE_PTR3 : 0x%x\n", Value));
+
+ // Write HCCA base address register
+ /*
+ Value = RTMP_GetPhysicalAddressLow(pAd->TxRing[QID_HCCA].Cell[0].AllocPa);
+ RTMP_IO_WRITE32(pAd, TX_BASE_PTR4, Value);
+ DBGPRINT(RT_DEBUG_TRACE, ("--> TX_BASE_PTR4 : 0x%x\n", Value));
+ */
+
+ // Write MGMT_BASE_CSR register
+ Value = RTMP_GetPhysicalAddressLow(pAd->MgmtRing.Cell[0].AllocPa);
+ RTMP_IO_WRITE32(pAd, TX_BASE_PTR5, Value);
+ DBGPRINT(RT_DEBUG_TRACE, ("--> TX_BASE_PTR5 : 0x%x\n", Value));
+
+ // Write RX_BASE_CSR register
+ Value = RTMP_GetPhysicalAddressLow(pAd->RxRing.Cell[0].AllocPa);
+ RTMP_IO_WRITE32(pAd, RX_BASE_PTR, Value);
+ DBGPRINT(RT_DEBUG_TRACE, ("--> RX_BASE_PTR : 0x%x\n", Value));
+
+ // Init RX Ring index pointer
+ pAd->RxRing.RxSwReadIdx = 0;
+ pAd->RxRing.RxCpuIdx = RX_RING_SIZE-1;
+ RTMP_IO_WRITE32(pAd, RX_CRX_IDX, pAd->RxRing.RxCpuIdx);
+
+ // Init TX rings index pointer
+ {
+ for (i=0; i<NUM_OF_TX_RING; i++)
+ {
+ pAd->TxRing[i].TxSwFreeIdx = 0;
+ pAd->TxRing[i].TxCpuIdx = 0;
+ RTMP_IO_WRITE32(pAd, (TX_CTX_IDX0 + i * 0x10) , pAd->TxRing[i].TxCpuIdx);
+ }
+ }
+
+ // init MGMT ring index pointer
+ pAd->MgmtRing.TxSwFreeIdx = 0;
+ pAd->MgmtRing.TxCpuIdx = 0;
+ RTMP_IO_WRITE32(pAd, TX_MGMTCTX_IDX, pAd->MgmtRing.TxCpuIdx);
+
+ //
+ // set each Ring's SIZE into ASIC. Descriptor Size is fixed by design.
+ //
+
+ // Write TX_RING_CSR0 register
+ Value = TX_RING_SIZE;
+ RTMP_IO_WRITE32(pAd, TX_MAX_CNT0, Value);
+ RTMP_IO_WRITE32(pAd, TX_MAX_CNT1, Value);
+ RTMP_IO_WRITE32(pAd, TX_MAX_CNT2, Value);
+ RTMP_IO_WRITE32(pAd, TX_MAX_CNT3, Value);
+ RTMP_IO_WRITE32(pAd, TX_MAX_CNT4, Value);
+ Value = MGMT_RING_SIZE;
+ RTMP_IO_WRITE32(pAd, TX_MGMTMAX_CNT, Value);
+
+ // Write RX_RING_CSR register
+ Value = RX_RING_SIZE;
+ RTMP_IO_WRITE32(pAd, RX_MAX_CNT, Value);
+#endif // RTMP_MAC_PCI //
+
+
+ // 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);
+
+
+#ifdef RTMP_MAC_PCI
+ // 3. Set DMA global configuration except TX_DMA_EN and RX_DMA_EN bits:
+ 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);
+
+ GloCfg.word &= 0xff0;
+ GloCfg.field.EnTXWriteBackDDONE =1;
+ RTMP_IO_WRITE32(pAd, WPDMA_GLO_CFG, GloCfg.word);
+
+ IntCfg.word = 0;
+ RTMP_IO_WRITE32(pAd, DELAY_INT_CFG, IntCfg.word);
+#endif // RTMP_MAC_PCI //
+
+
+ // 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 RT30xx
+ UCHAR bbpreg=0;
+ UCHAR RFValue=0;
+#endif // RT30xx //
+ USHORT KeyIdx;
+ INT i,apidx;
+
+ DBGPRINT(RT_DEBUG_TRACE, ("--> NICInitializeAsic\n"));
+
+#ifdef RTMP_MAC_PCI
+ RTMP_IO_WRITE32(pAd, PWR_PIN_CFG, 0x3); // To fix driver disable/enable hang issue when radio off
+ if (bHardReset == TRUE)
+ {
+ RTMP_IO_WRITE32(pAd, MAC_SYS_CTRL, 0x3);
+ }
+ else
+ RTMP_IO_WRITE32(pAd, MAC_SYS_CTRL, 0x1);
+
+ RTMP_IO_WRITE32(pAd, MAC_SYS_CTRL, 0x0);
+ // Initialize MAC register to default value
+ for (Index = 0; Index < NUM_MAC_REG_PARMS; Index++)
+ {
+#ifdef RT30xx
+ if ((MACRegTable[Index].Register == TX_SW_CFG0) && ( IS_RT3090(pAd) || IS_RT3390(pAd)))
+ {
+ MACRegTable[Index].Value = 0x00000400;
+ }
+#endif // RT30xx //
+ RTMP_IO_WRITE32(pAd, 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, STAMACRegTable[Index].Register, STAMACRegTable[Index].Value);
+ }
+ }
+#endif // CONFIG_STA_SUPPORT //
+#endif // RTMP_MAC_PCI //
+
+
+#ifdef RT30xx
+ // Initialize RT3070 serial MAC registers which is different from RT2870 serial
+ if (IS_RT3090(pAd) || IS_RT3572(pAd)||IS_RT3390(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, 0x2C); // 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))
+ {
+ if (((pAd->MACVersion & 0xffff) < 0x0201))
+ {
+ RTMP_IO_WRITE32(pAd, TX_SW_CFG1, 0);
+ RTMP_IO_WRITE32(pAd, TX_SW_CFG2, 0x2C); // To fix throughput drop drastically
+ }
+ else
+ {
+ RTMP_IO_WRITE32(pAd, TX_SW_CFG2, 0);
+ }
+ }
+#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);
+#ifdef RT3090
+ //2008/11/28:KH add to fix the dead rf frequency offset bug<--
+ AsicSendCommandToMcu(pAd, 0x72, 0, 0, 0);
+ //2008/11/28:KH add to fix the dead rf frequency offset bug-->
+#endif // RT3090 //
+ 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);
+ }
+
+#ifdef RTMP_MAC_PCI
+ // TODO: shiang, check MACVersion, currently, rbus-based chip use this.
+ if (pAd->MACVersion == 0x28720200)
+ {
+ //UCHAR value;
+ ULONG value2;
+
+ //disable MLD by Bruce 20080704
+ //BBP_IO_READ8_BY_REG_ID(pAd, BBP_R105, &value);
+ //BBP_IO_WRITE8_BY_REG_ID(pAd, BBP_R105, value | 4);
+
+ //Maximum PSDU length from 16K to 32K bytes
+ RTMP_IO_READ32(pAd, MAX_LEN_CFG, &value2);
+ value2 &= ~(0x3<<12);
+ value2 |= (0x2<<12);
+ RTMP_IO_WRITE32(pAd, MAX_LEN_CFG, value2);
+ }
+#endif // RTMP_MAC_PCI //
+
+ // 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.
+ //3070/71/72,3090,3090A( are included in RT30xx),3572,3390
+ if (((pAd->MACVersion & 0xffff) != 0x0101) && !(IS_RT30xx(pAd)|| IS_RT3572(pAd) || IS_RT3390(pAd)))
+ RTMP_BBP_IO_WRITE8_BY_REG_ID(pAd, BBP_R84, 0x19);
+
+#ifdef RT30xx
+// add by johnli, RF power sequence setup
+ if (IS_RT30xx(pAd) || IS_RT3572(pAd) || IS_RT3390(pAd))
+ { //update for RT3070/71/72/90/91/92,3572,3390.
+ 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)||IS_RT3390(pAd)) // RT309x, RT3071/72
+ {
+ // 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);
+ }
+ }
+ else if (IS_RT3070(pAd))
+ {
+ if ((pAd->MACVersion & 0xffff) >= 0x0201)
+ {
+ // enable DC filter
+ RTMP_BBP_IO_WRITE8_BY_REG_ID(pAd, BBP_R103, 0xc0);
+
+ // improve power consumption in RT3070 Ver.F
+ RTMP_BBP_IO_READ8_BY_REG_ID(pAd, BBP_R31, &bbpreg);
+ bbpreg &= (~0x3);
+ RTMP_BBP_IO_WRITE8_BY_REG_ID(pAd, BBP_R31, bbpreg);
+ }
+
+ // 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->NicConfig2.field.ExternalLNAForG == 0)
+ {
+ RFValue |= 0x20;
+ }
+ // set RF_R17_bit[2:0] equal to EEPROM setting at 0x48h
+ if (pAd->TxMixerGain24G >= 1)
+ {
+ RFValue &= (~0x7); // clean bit [2:0]
+ RFValue |= pAd->TxMixerGain24G;
+ }
+ RT30xxWriteRFRegister(pAd, RF_R17, RFValue);
+ }
+// end johnli
+#endif // RT30xx //
+
+ 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 CONFIG_STA_SUPPORT
+ // Add radio off control
+ 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 shared 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 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 //
+
+#ifdef RT30xx
+#ifdef NEW_FW
+ if (IS_RT3070(pAd) || IS_RT3572(pAd)||IS_RT3390(pAd)||IS_RT3090(pAd))
+ {
+ // send 0x36 mcu command after 0x72 for RT3xxx to fix Radio-Off current leakage issue
+ RTMPusecDelay(200);
+ if (pAd->buseEfuse)
+ AsicSendCommandToMcu(pAd, 0x36, 0xff, 0xff, 0);
+ else
+ AsicSendCommandToMcu(pAd, 0x36, 0xff, 0xff, 0x04);
+ RTMPusecDelay(10);
+ }
+#endif // NEW_FW //
+#endif // RT30xx //
+
+ 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++;
+
+#ifdef WDS_SUPPORT
+ // fix WDS Jam issue
+ if((pEntry->ValidAsWDS == TRUE)
+ && (pEntry->LockEntryTx == FALSE)
+ && (pEntry->ContinueTxFailCnt >= pAd->ApCfg.EntryLifeCheck))
+ {
+ DBGPRINT(RT_DEBUG_TRACE, ("Entry %02x:%02x:%02x:%02x:%02x:%02x Blocked!! (Fail Cnt = %d)\n",
+ pEntry->Addr[0],pEntry->Addr[1],pEntry->Addr[2],pEntry->Addr[3],
+ pEntry->Addr[4],pEntry->Addr[5],pEntry->ContinueTxFailCnt ));
+
+ pEntry->LockEntryTx = TRUE;
+ }
+#endif // WDS_SUPPORT //
+ }
+ 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;
+#ifdef WDS_SUPPORT
+ pEntry->LockEntryTx = FALSE;
+#endif // WDS_SUPPORT //
+ }
+
+ 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 < (TX_RING_SIZE<<1) );
+
+}
+
+/*
+ ========================================================================
+
+ 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;
+ COUNTER_RALINK *pRalinkCounters;
+
+
+ pRalinkCounters = &pAd->RalinkCounters;
+
+ 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
+ pRalinkCounters->OneSecRxFcsErrCnt += RxStaCnt0.field.CrcErr;
+ OldValue = pRalinkCounters->RealFcsErrCount.u.LowPart;
+ pRalinkCounters->RealFcsErrCount.u.LowPart += RxStaCnt0.field.CrcErr;
+ if (pRalinkCounters->RealFcsErrCount.u.LowPart < OldValue)
+ pRalinkCounters->RealFcsErrCount.u.HighPart++;
+
+ // Update Duplicate Rcv check
+ pRalinkCounters->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;
+
+
+ //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);
+ pRalinkCounters->OneSecBeaconSentCnt += TxStaCnt0.field.TxBeaconCount;
+ pRalinkCounters->OneSecTxRetryOkCount += StaTx1.field.TxRetransmit;
+ pRalinkCounters->OneSecTxNoRetryOkCount += StaTx1.field.TxSuccess;
+ pRalinkCounters->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);
+ pRalinkCounters->TxAggCount += TxAggCnt.field.AggTxCount;
+ pRalinkCounters->TxNonAggCount += TxAggCnt.field.NonAggTxCount;
+ pRalinkCounters->TxAgg1MPDUCount += TxAggCnt0.field.AggSize1Count;
+ pRalinkCounters->TxAgg2MPDUCount += TxAggCnt0.field.AggSize2Count;
+
+ pRalinkCounters->TxAgg3MPDUCount += TxAggCnt1.field.AggSize3Count;
+ pRalinkCounters->TxAgg4MPDUCount += TxAggCnt1.field.AggSize4Count;
+ pRalinkCounters->TxAgg5MPDUCount += TxAggCnt2.field.AggSize5Count;
+ pRalinkCounters->TxAgg6MPDUCount += TxAggCnt2.field.AggSize6Count;
+
+ pRalinkCounters->TxAgg7MPDUCount += TxAggCnt3.field.AggSize7Count;
+ pRalinkCounters->TxAgg8MPDUCount += TxAggCnt3.field.AggSize8Count;
+ pRalinkCounters->TxAgg9MPDUCount += TxAggCnt4.field.AggSize9Count;
+ pRalinkCounters->TxAgg10MPDUCount += TxAggCnt4.field.AggSize10Count;
+
+ pRalinkCounters->TxAgg11MPDUCount += TxAggCnt5.field.AggSize11Count;
+ pRalinkCounters->TxAgg12MPDUCount += TxAggCnt5.field.AggSize12Count;
+ pRalinkCounters->TxAgg13MPDUCount += TxAggCnt6.field.AggSize13Count;
+ pRalinkCounters->TxAgg14MPDUCount += TxAggCnt6.field.AggSize14Count;
+
+ pRalinkCounters->TxAgg15MPDUCount += TxAggCnt7.field.AggSize15Count;
+ pRalinkCounters->TxAgg16MPDUCount += TxAggCnt7.field.AggSize16Count;
+
+ // Calculate the transmitted A-MPDU count
+ pRalinkCounters->TransmittedAMPDUCount.u.LowPart += TxAggCnt0.field.AggSize1Count;
+ pRalinkCounters->TransmittedAMPDUCount.u.LowPart += (TxAggCnt0.field.AggSize2Count / 2);
+
+ pRalinkCounters->TransmittedAMPDUCount.u.LowPart += (TxAggCnt1.field.AggSize3Count / 3);
+ pRalinkCounters->TransmittedAMPDUCount.u.LowPart += (TxAggCnt1.field.AggSize4Count / 4);
+
+ pRalinkCounters->TransmittedAMPDUCount.u.LowPart += (TxAggCnt2.field.AggSize5Count / 5);
+ pRalinkCounters->TransmittedAMPDUCount.u.LowPart += (TxAggCnt2.field.AggSize6Count / 6);
+
+ pRalinkCounters->TransmittedAMPDUCount.u.LowPart += (TxAggCnt3.field.AggSize7Count / 7);
+ pRalinkCounters->TransmittedAMPDUCount.u.LowPart += (TxAggCnt3.field.AggSize8Count / 8);
+
+ pRalinkCounters->TransmittedAMPDUCount.u.LowPart += (TxAggCnt4.field.AggSize9Count / 9);
+ pRalinkCounters->TransmittedAMPDUCount.u.LowPart += (TxAggCnt4.field.AggSize10Count / 10);
+
+ pRalinkCounters->TransmittedAMPDUCount.u.LowPart += (TxAggCnt5.field.AggSize11Count / 11);
+ pRalinkCounters->TransmittedAMPDUCount.u.LowPart += (TxAggCnt5.field.AggSize12Count / 12);
+
+ pRalinkCounters->TransmittedAMPDUCount.u.LowPart += (TxAggCnt6.field.AggSize13Count / 13);
+ pRalinkCounters->TransmittedAMPDUCount.u.LowPart += (TxAggCnt6.field.AggSize14Count / 14);
+
+ pRalinkCounters->TransmittedAMPDUCount.u.LowPart += (TxAggCnt7.field.AggSize15Count / 15);
+ pRalinkCounters->TransmittedAMPDUCount.u.LowPart += (TxAggCnt7.field.AggSize16Count / 16);
+ }
+
+#ifdef DBG_DIAGNOSE
+ {
+ RtmpDiagStruct *pDiag;
+ UCHAR ArrayCurIdx, i;
+
+ pDiag = &pAd->DiagStruct;
+ 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);
+}
+
+
+NDIS_STATUS NICLoadFirmware(
+ IN PRTMP_ADAPTER pAd)
+{
+ NDIS_STATUS status = NDIS_STATUS_SUCCESS;
+ if (pAd->chipOps.loadFirmware)
+ status = pAd->chipOps.loadFirmware(pAd);
+
+ return status;
+}
+
+
+/*
+ ========================================================================
+
+ Routine Description:
+ erase 8051 firmware image in MAC ASIC
+
+ Arguments:
+ Adapter Pointer to our adapter
+
+ IRQL = PASSIVE_LEVEL
+
+ ========================================================================
+*/
+VOID NICEraseFirmware(
+ IN PRTMP_ADAPTER pAd)
+{
+ if (pAd->chipOps.eraseFirmware)
+ pAd->chipOps.eraseFirmware(pAd);
+
+}/* End of NICEraseFirmware */
+
+
+/*
+ ========================================================================
+
+ 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:
+ 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;
+ }
+}
+
+
+/*
+ ========================================================================
+
+ 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
+ //
+
+ 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->EepromAccess = FALSE;
+
+ pAd->Antenna.word = 0;
+ pAd->CommonCfg.BBPCurrentBW = BW_20;
+
+ pAd->LedCntl.word = 0;
+#ifdef RTMP_MAC_PCI
+ pAd->LedIndicatorStrength = 0;
+ pAd->RLnkCtrlOffset = 0;
+ pAd->HostLnkCtrlOffset = 0;
+#ifdef CONFIG_STA_SUPPORT
+ pAd->StaCfg.PSControl.field.EnableNewPS=TRUE;
+ pAd->CheckDmaBusyCount = 0;
+#endif // CONFIG_STA_SUPPORT //
+#endif // RTMP_MAC_PCI //
+
+ 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;
+
+
+
+#ifdef TONE_RADAR_DETECT_SUPPORT
+#ifdef CARRIER_DETECTION_SUPPORT
+ pAd->CommonCfg.CarrierDetect.delta = CARRIER_DETECT_DELTA;
+ pAd->CommonCfg.CarrierDetect.div_flag = CARRIER_DETECT_DIV_FLAG;
+ pAd->CommonCfg.CarrierDetect.criteria = CARRIER_DETECT_CRITIRIA;
+#ifdef RT3090
+ if(IS_RT3090A(pAd))
+ pAd->CommonCfg.CarrierDetect.threshold = CARRIER_DETECT_THRESHOLD_3090A;
+ else
+#endif // RT3090 //
+ pAd->CommonCfg.CarrierDetect.threshold = CARRIER_DETECT_THRESHOLD;
+#endif // CARRIER_DETECTION_SUPPORT //
+#endif // TONE_RADAR_DETECT_SUPPORT //
+
+ pAd->CommonCfg.RadarDetect.ChMovingTime = 65;
+#ifdef MERGE_ARCH_TEAM
+ pAd->CommonCfg.RadarDetect.LongPulseRadarTh = 2;
+ pAd->CommonCfg.RadarDetect.AvgRssiReq = -75;
+#else // original rt28xx source code
+ pAd->CommonCfg.RadarDetect.LongPulseRadarTh = 3;
+#endif // MERGE_ARCH_TEAM //
+ 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;
+ //2008/11/05:KH add to support Antenna power-saving of AP<--
+ pAd->CommonCfg.bGreenAPEnable=FALSE;
+ pAd->CommonCfg.bBlockAntDivforGreenAP=FALSE;
+ //2008/11/05:KH add to support Antenna power-saving of AP-->
+ pAd->CommonCfg.bBADecline = FALSE;
+ pAd->CommonCfg.bDisableReordering = FALSE;
+
+ if (pAd->MACVersion == 0x28720200)
+ {
+ pAd->CommonCfg.TxBASize = 13; //by Jerry recommend
+ }else{
+ 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 //
+#ifdef PCIE_PS_SUPPORT
+pAd->brt30xxBanMcuCmd = FALSE;
+pAd->b3090ESpecialChip = FALSE;
+//KH Debug:the following must be removed
+pAd->StaCfg.PSControl.field.rt30xxPowerMode=3;
+pAd->StaCfg.PSControl.field.rt30xxForceASPMTest=0;
+pAd->StaCfg.PSControl.field.rt30xxFollowHostASPM=1;
+#endif // PCIE_PS_SUPPORT //
+#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;
+
+ RTMPInitTimer(pAd, &pAd->StaCfg.StaQuickResponeForRateUpTimer, GET_TIMER_FUNCTION(StaQuickResponeForRateUpExec), pAd, FALSE);
+ pAd->StaCfg.StaQuickResponeForRateUpTimerRunning = FALSE;
+
+ // Patch for Ndtest
+ pAd->StaCfg.ScanCnt = 0;
+
+ 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.
+ NdisGetSystemUpTime(&pAd->StaCfg.LastScanTime);
+ if (pAd->StaCfg.LastScanTime > 10 * OS_HZ)
+ pAd->StaCfg.LastScanTime -= (10 * OS_HZ);
+
+ NdisZeroMemory(pAd->nickname, IW_ESSID_MAX_SIZE+1);
+#ifdef RTMP_MAC_PCI
+ sprintf((PSTRING) pAd->nickname, "RT2860STA");
+#endif // RTMP_MAC_PCI //
+ 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;
+ pAd->StaCfg.bRSN_IE_FromWpaSupplicant = FALSE;
+#ifdef NATIVE_WPA_SUPPLICANT_SUPPORT
+ pAd->StaCfg.WpaSupplicantUP = WPA_SUPPLICANT_ENABLE;
+#endif // NATIVE_WPA_SUPPLICANT_SUPPORT //
+#endif // WPA_SUPPLICANT_SUPPORT //
+
+ NdisZeroMemory(pAd->StaCfg.ReplayCounter, 8);
+
+
+ pAd->StaCfg.bAutoConnectByBssid = FALSE;
+ pAd->StaCfg.BeaconLostTime = BEACON_LOST_TIME;
+ NdisZeroMemory(pAd->StaCfg.WpaPassPhrase, 64);
+ pAd->StaCfg.WpaPassPhraseLen = 0;
+ pAd->StaCfg.bAutoRoaming = FALSE;
+ pAd->StaCfg.bForceTxBurst = FALSE;
+ }
+#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.TxDoneCount = 0;
+ pAd->ate.RFFreqOffset = 0;
+ 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 RTMP_MAC_PCI
+ pAd->ate.bFWLoading = FALSE;
+#endif // RTMP_MAC_PCI //
+
+
+#ifdef RALINK_28xx_QA
+ pAd->ate.TxStatus = 0;
+ pAd->ate.AtePid = THREAD_PID_INIT_VALUE;
+#endif // RALINK_28xx_QA //
+#endif // RALINK_ATE //
+
+
+ pAd->CommonCfg.bWiFiTest = FALSE;
+#ifdef RTMP_MAC_PCI
+ pAd->bPCIclkOff = FALSE;
+#endif // RTMP_MAC_PCI //
+
+#ifdef CONFIG_STA_SUPPORT
+RTMP_SET_PSFLAG(pAd, fRTMP_PS_CAN_GO_SLEEP);
+#endif // CONFIG_STA_SUPPORT //
+#ifdef ANT_DIVERSITY_SUPPORT
+ if ( pAd->CommonCfg.bRxAntDiversity == ANT_FIX_ANT2)
+ {
+ pAd->RxAnt.Pair1PrimaryRxAnt = 1;
+ pAd->RxAnt.Pair1SecondaryRxAnt = 0;
+ }
+ else // Default
+ {
+ pAd->RxAnt.Pair1PrimaryRxAnt = 0;
+ pAd->RxAnt.Pair1SecondaryRxAnt = 1;
+ }
+ pAd->RxAnt.EvaluatePeriod = 0;
+ pAd->RxAnt.RcvPktNumWhenEvaluate = 0;
+#ifdef CONFIG_STA_SUPPORT
+ pAd->RxAnt.Pair1AvgRssi[0] = pAd->RxAnt.Pair1AvgRssi[1] = 0;
+#endif // CONFIG_STA_SUPPORT //
+#endif // AP_ANTENNA_DIVERSITY_SUPPORT //
+
+ DBGPRINT(RT_DEBUG_TRACE, ("<-- UserCfgInit\n"));
+}
+
+// IRQL = PASSIVE_LEVEL
+UCHAR BtoH(STRING 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(PSTRING src, PUCHAR dest, int destlen)
+{
+ PSTRING 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++;
+ }
+}
+
+
+//+++Mark by shiang, not use now, need to remove after confirm
+//---Mark by shiang, not use now, need to remove after confirm
+
+
+/*
+ ========================================================================
+
+ 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 RTMP_TIMER_TASK_SUPPORT
+ pTimer->pAd = pAd;
+#endif // RTMP_TIMER_TASK_SUPPORT //
+
+ 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 RTMP_TIMER_TASK_SUPPORT
+ // We need to go-through the TimerQ to findout this timer handler and remove it if
+ // it's still waiting for execution.
+ RtmpTimerQRemove(pTimer->pAd, pTimer);
+#endif // RTMP_TIMER_TASK_SUPPORT //
+ }
+ else
+ {
+ 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;
+ BOOLEAN bIgnored = FALSE;
+
+#ifdef RALINK_ATE
+ /*
+ In ATE mode of RT2860 AP/STA, we have erased 8051 firmware.
+ So LED mode is not supported when ATE is running.
+ */
+ if (!IS_RT3572(pAd))
+ {
+ 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->LedIndicatorStrength = 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;
+#ifdef RALINK_ATE
+#endif // RALINK_ATE //
+ 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) && (bIgnored == FALSE))
+ 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 (pAd->LedCntl.field.LedMode == LED_MODE_SIGNAL_STREGTH)
+ {
+ 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->LedIndicatorStrength != nLed)
+ {
+ AsicSendCommandToMcu(pAd, 0x51, 0xff, nLed, pAd->LedCntl.field.Polarity);
+ pAd->LedIndicatorStrength = 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;
+ UINT32 rx_filter_flag;
+
+ DBGPRINT(RT_DEBUG_TRACE, ("==> RTMPEnableRxTx\n"));
+
+ // Enable Rx DMA.
+ RT28XXDMAEnable(pAd);
+
+ // enable RX of MAC block
+ if (pAd->OpMode == OPMODE_AP)
+ {
+ rx_filter_flag = APNORMAL;
+
+
+ RTMP_IO_WRITE32(pAd, RX_FILTR_CFG, rx_filter_flag); // enable RX of DMA block
+ }
+ else
+ {
+ if (pAd->CommonCfg.PSPXlink)
+ rx_filter_flag = PSPXLINK;
+ else
+ rx_filter_flag = STANORMAL; // Staion not drop control frame will fail WiFi Certification.
+ RTMP_IO_WRITE32(pAd, RX_FILTR_CFG, rx_filter_flag);
+ }
+
+ RTMP_IO_WRITE32(pAd, MAC_SYS_CTRL, 0xc);
+ DBGPRINT(RT_DEBUG_TRACE, ("<== RTMPEnableRxTx\n"));
+}
+
+
+//+++Add by shiang, move from os/linux/rt_main_dev.c
+void CfgInitHook(PRTMP_ADAPTER pAd)
+{
+ pAd->bBroadComHT = TRUE;
+}
+
+
+int rt28xx_init(
+ IN PRTMP_ADAPTER pAd,
+ IN PSTRING pDefaultMac,
+ IN PSTRING pHostName)
+{
+ UINT index;
+ UCHAR TmpPhy;
+ NDIS_STATUS Status;
+ UINT32 MacCsr0 = 0;
+
+#ifdef CONFIG_STA_SUPPORT
+#ifdef RTMP_MAC_PCI
+ IF_DEV_CONFIG_OPMODE_ON_STA(pAd)
+ {
+ // If dirver doesn't wake up firmware here,
+ // NICLoadFirmware will hang forever when interface is up again.
+ // RT2860 PCI
+ if (OPSTATUS_TEST_FLAG(pAd, fOP_STATUS_DOZE) &&
+ OPSTATUS_TEST_FLAG(pAd, fOP_STATUS_PCIE_DEVICE))
+ {
+ AUTO_WAKEUP_STRUC AutoWakeupCfg;
+ AsicForceWakeup(pAd, TRUE);
+ AutoWakeupCfg.word = 0;
+ RTMP_IO_WRITE32(pAd, AUTO_WAKEUP_CFG, AutoWakeupCfg.word);
+ OPSTATUS_CLEAR_FLAG(pAd, fOP_STATUS_DOZE);
+ }
+ }
+#endif // RTMP_MAC_PCI //
+#endif // CONFIG_STA_SUPPORT //
+
+
+ // reset Adapter flags
+ RTMP_CLEAR_FLAGS(pAd);
+
+ // Init BssTab & ChannelInfo tabbles for auto channel select.
+
+#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));
+
+#ifdef RTMP_MAC_PCI
+#ifdef PCIE_PS_SUPPORT
+ /*Iverson patch PCIE L1 issue to make sure that driver can be read,write ,BBP and RF register at pcie L.1 level */
+ if ((IS_RT3090(pAd) || IS_RT3572(pAd) || IS_RT3390(pAd))&&OPSTATUS_TEST_FLAG(pAd, fOP_STATUS_PCIE_DEVICE))
+ {
+ RTMP_IO_READ32(pAd, AUX_CTRL, &MacCsr0);
+ MacCsr0 |= 0x402;
+ RTMP_IO_WRITE32(pAd, AUX_CTRL, MacCsr0);
+ DBGPRINT(RT_DEBUG_TRACE, ("AUX_CTRL = 0x%x\n", MacCsr0));
+ }
+#endif // PCIE_PS_SUPPORT //
+
+ // To fix driver disable/enable hang issue when radio off
+ RTMP_IO_WRITE32(pAd, PWR_PIN_CFG, 0x2);
+#endif // RTMP_MAC_PCI //
+
+ // 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
+#ifdef RTMP_MAC_PCI
+ if (RTMP_TEST_FLAG(pAd, fRTMP_ADAPTER_INTERRUPT_ACTIVE))
+ {
+ RTMP_ASIC_INTERRUPT_DISABLE(pAd);
+ }
+#endif // RTMP_MAC_PCI //
+
+ 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 = RtmpMgmtTaskInit(pAd);
+ if (Status != NDIS_STATUS_SUCCESS)
+ goto err2;
+
+ 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);
+ Status = RtmpNetTaskInit(pAd);
+ if (Status != NDIS_STATUS_SUCCESS)
+ goto err3;
+
+// 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);
+
+ DBGPRINT(RT_DEBUG_OFF, ("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 DOT11_N_SUPPORT
+ //Init Ba Capability parameters.
+// RT28XX_BA_INIT(pAd);
+ 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;
+
+ DBGPRINT(RT_DEBUG_OFF, ("2. Phy Mode = %d\n", pAd->CommonCfg.PhyMode));
+
+ // We should read EEPROM for all cases. rt2860b
+ NICReadEEPROMParameters(pAd, (PUCHAR)pDefaultMac);
+#ifdef CONFIG_STA_SUPPORT
+#endif // CONFIG_STA_SUPPORT //
+
+ DBGPRINT(RT_DEBUG_OFF, ("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)
+ {
+ DBGPRINT(RT_DEBUG_ERROR, ("Wrong configuration. No valid channel found. Check \"ContryCode\" and \"ChannelGeography\" setting.\n"));
+ goto err4;
+ }
+
+#ifdef DOT11_N_SUPPORT
+ DBGPRINT(RT_DEBUG_OFF, ("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 RTMP_RF_RW_SUPPORT
+ //Init RT30xx RFRegisters after read RFIC type from EEPROM
+ NICInitRFRegisters(pAd);
+#endif // RTMP_RF_RW_SUPPORT //
+
+
+
+// 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.
+ //2008/11/28:KH marked the following codes to patch Frequency offset bug
+ //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"));
+
+
+ }// end of else
+
+
+ // Set up the Mac address
+ RtmpOSNetDevAddrSet(pAd->net_dev, &pAd->CurrentAddress[0]);
+
+ // Various AP function init
+
+
+
+#ifdef CONFIG_STA_SUPPORT
+ IF_DEV_CONFIG_OPMODE_ON_STA(pAd)
+ {
+#ifdef WPA_SUPPLICANT_SUPPORT
+#ifndef NATIVE_WPA_SUPPLICANT_SUPPORT
+ // send wireless event to wpa_supplicant for infroming interface up.
+ RtmpOSWrielessEventSend(pAd, IWEVCUSTOM, RT_INTERFACE_UP, NULL, NULL, 0);
+#endif // NATIVE_WPA_SUPPLICANT_SUPPORT //
+#endif // WPA_SUPPLICANT_SUPPORT //
+
+ }
+#endif // CONFIG_STA_SUPPORT //
+
+
+
+ DBGPRINT_S(Status, ("<==== rt28xx_init, Status=%x\n", Status));
+
+ return TRUE;
+
+
+err4:
+err3:
+ MlmeHalt(pAd);
+err2:
+ RTMPFreeTxRxRingMemory(pAd);
+err1:
+
+#ifdef DOT11_N_SUPPORT
+ os_free_mem(pAd, pAd->mpdu_blk_pool.mem); // free BA pool
+#endif // DOT11_N_SUPPORT //
+
+ // shall not set priv to NULL here because the priv didn't been free yet.
+ //net_dev->priv = 0;
+#ifdef INF_AMAZON_SE
+err0:
+#endif // INF_AMAZON_SE //
+#ifdef ST
+err0:
+#endif // ST //
+
+ DBGPRINT(RT_DEBUG_ERROR, ("!!! rt28xx Initialized fail !!!\n"));
+ return FALSE;
+}
+//---Add by shiang, move from os/linux/rt_main_dev.c
+
+
+static INT RtmpChipOpsRegister(
+ IN RTMP_ADAPTER *pAd,
+ IN INT infType)
+{
+ RTMP_CHIP_OP *pChipOps = &pAd->chipOps;
+ int status;
+
+ memset(pChipOps, 0, sizeof(RTMP_CHIP_OP));
+
+ /* set eeprom related hook functions */
+ status = RtmpChipOpsEepromHook(pAd, infType);
+
+ /* set mcu related hook functions */
+ switch(infType)
+ {
+#ifdef RTMP_PCI_SUPPORT
+ case RTMP_DEV_INF_PCI:
+ pChipOps->loadFirmware = RtmpAsicLoadFirmware;
+ pChipOps->eraseFirmware = RtmpAsicEraseFirmware;
+ pChipOps->sendCommandToMcu = RtmpAsicSendCommandToMcu;
+ break;
+#endif // RTMP_PCI_SUPPORT //
+
+
+ default:
+ break;
+ }
+
+ return status;
+}
+
+
+INT RtmpRaDevCtrlInit(
+ IN RTMP_ADAPTER *pAd,
+ IN RTMP_INF_TYPE infType)
+{
+ //VOID *handle;
+
+ // Assign the interface type. We need use it when do register/EEPROM access.
+ pAd->infType = infType;
+
+
+#ifdef CONFIG_STA_SUPPORT
+ pAd->OpMode = OPMODE_STA;
+ DBGPRINT(RT_DEBUG_TRACE, ("STA Driver version-%s\n", STA_DRIVER_VERSION));
+#endif // CONFIG_STA_SUPPORT //
+
+
+
+ RtmpChipOpsRegister(pAd, infType);
+
+#ifdef MULTIPLE_CARD_SUPPORT
+{
+ extern BOOLEAN RTMP_CardInfoRead(PRTMP_ADAPTER pAd);
+
+ // 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 //
+
+ return 0;
+}
+
+
+BOOLEAN RtmpRaDevCtrlExit(IN RTMP_ADAPTER *pAd)
+{
+#ifdef MULTIPLE_CARD_SUPPORT
+extern UINT8 MC_CardUsed[MAX_NUM_OF_MULTIPLE_CARD];
+
+ 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 //
+
+
+ RTMPFreeAdapter(pAd);
+
+ return TRUE;
+}
+
+
+// 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 */
+}
diff --git a/drivers/staging/rt3090/common/rtmp_mcu.c b/drivers/staging/rt3090/common/rtmp_mcu.c
new file mode 100644
index 000000000000..23f785a90e06
--- /dev/null
+++ b/drivers/staging/rt3090/common/rtmp_mcu.c
@@ -0,0 +1,560 @@
+/*
+ *************************************************************************
+ * 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_mcu.c
+
+ Abstract:
+ Miniport generic portion header file
+
+ Revision History:
+ Who When What
+ -------- ---------- ----------------------------------------------
+*/
+
+#include "../rt_config.h"
+#include "../firmware.h"
+
+//#define BIN_IN_FILE /* use *.bin firmware */
+
+
+// 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
+
+#ifdef RTMP_MAC_PCI
+#define FIRMWARE_MINOR_VERSION 2
+#endif // RTMP_MAC_PCI //
+
+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;
+}
+
+
+/*
+ ========================================================================
+
+ Routine Description:
+ erase 8051 firmware image in MAC ASIC
+
+ Arguments:
+ Adapter Pointer to our adapter
+
+ IRQL = PASSIVE_LEVEL
+
+ ========================================================================
+*/
+INT RtmpAsicEraseFirmware(
+ 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);
+
+ return 0;
+}
+
+/*
+ ========================================================================
+
+ Routine Description:
+ Load 8051 firmware 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 RtmpAsicLoadFirmware(
+ IN PRTMP_ADAPTER pAd)
+{
+#ifdef BIN_IN_FILE
+#define NICLF_DEFAULT_USE() \
+ flg_default_firm_use = TRUE; \
+ DBGPRINT(RT_DEBUG_OFF, ("%s - Use default firmware!\n", __FUNCTION__));
+
+ NDIS_STATUS Status = NDIS_STATUS_SUCCESS;
+ PUCHAR src;
+ RTMP_OS_FD srcf;
+ INT retval, i;
+ PUCHAR pFirmwareImage;
+ INT FileLength = 0;
+ UINT32 MacReg;
+ ULONG Index;
+ ULONG firm;
+ BOOLEAN flg_default_firm_use = FALSE;
+ RTMP_OS_FS_INFO osFSInfo;
+
+ DBGPRINT(RT_DEBUG_TRACE, ("===> %s\n", __FUNCTION__));
+
+ /* init */
+ pFirmwareImage = NULL;
+ src = RTMP_FIRMWARE_FILE_NAME;
+
+ RtmpOSFSInfoChange(&osFSInfo, TRUE);
+
+ 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 */
+ DBGPRINT(RT_DEBUG_ERROR, ("%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 = RtmpOSFileOpen(src, O_RDONLY, 0);
+
+ if (IS_FILE_OPEN_ERR(srcf))
+ {
+ DBGPRINT(RT_DEBUG_ERROR, ("%s - Error opening file %s\n", __FUNCTION__, src));
+ NICLF_DEFAULT_USE();
+ break;
+ }
+
+
+ /* read the firmware from the file *.bin */
+ FileLength = RtmpOSFileRead(srcf, pFirmwareImage, MAX_FIRMWARE_IMAGE_SIZE);
+ if (FileLength != MAX_FIRMWARE_IMAGE_SIZE)
+ {
+ DBGPRINT(RT_DEBUG_ERROR, ("%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 */
+ DBGPRINT(RT_DEBUG_ERROR, ("%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))
+ {
+ DBGPRINT(RT_DEBUG_ERROR, ("%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_FILE_OPEN_ERR(srcf))
+ ;
+ else
+ {
+ retval = RtmpOSFileClose(srcf);
+ if (retval)
+ {
+ DBGPRINT(RT_DEBUG_ERROR, ("--> Error %d closing %s\n", -retval, src));
+ }
+ }
+ }
+
+
+ /* 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 */
+
+ RtmpOSFSInfoChange(&osFSInfo, FALSE);
+#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
+ //DBGPRINT(RT_DEBUG_TRACE, ("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 RTMP_MAC_PCI
+ if ((Version == 0x2860) || IS_RT3090(pAd)||IS_RT3390(pAd))
+ {
+ pFirmwareImage = FirmwareImage;
+ FileLength = FIRMWAREIMAGE_LENGTH;
+ }
+#endif // RTMP_MAC_PCI //
+ }
+ else
+ {
+ DBGPRINT(RT_DEBUG_ERROR, ("KH: bin file should be 8KB.\n"));
+ Status = NDIS_STATUS_FAILURE;
+ }
+
+
+ RTMP_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)
+ {
+ DBGPRINT(RT_DEBUG_ERROR, ("NICLoadFirmware: MCU is not ready\n\n\n"));
+ Status = NDIS_STATUS_FAILURE;
+ }
+
+ DBGPRINT(RT_DEBUG_TRACE, ("<=== %s (status=%d)\n", __FUNCTION__, Status));
+
+ return Status;
+}
+
+
+INT RtmpAsicSendCommandToMcu(
+ 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;
+#ifdef RTMP_MAC_PCI
+#ifdef RALINK_ATE
+ static UINT32 j = 0;
+#endif // RALINK_ATE //
+#endif // RTMP_MAC_PCI //
+#ifdef PCIE_PS_SUPPORT
+#ifdef CONFIG_STA_SUPPORT
+ // 3090F power solution 3 has hw limitation that needs to ban all mcu command
+ // when firmware is in radio state. For other chip doesn't have this limitation.
+ if (((IS_RT3090(pAd) || IS_RT3572(pAd) || IS_RT3390(pAd)) && IS_VERSION_AFTER_F(pAd)) && IS_VERSION_AFTER_F(pAd)
+ && (pAd->StaCfg.PSControl.field.rt30xxPowerMode == 3)
+ && (pAd->StaCfg.PSControl.field.EnableNewPS == TRUE))
+ {
+ RTMP_SEM_LOCK(&pAd->McuCmdLock);
+ if ((pAd->brt30xxBanMcuCmd == TRUE)
+ && (Command != WAKE_MCU_CMD) && (Command != RFOFF_MCU_CMD))
+ {
+ RTMP_SEM_UNLOCK(&pAd->McuCmdLock);
+ DBGPRINT(RT_DEBUG_TRACE, (" Ban Mcu Cmd %x in sleep mode\n", Command));
+ return FALSE;
+ }
+ else if ((Command == SLEEP_MCU_CMD)
+ ||(Command == RFOFF_MCU_CMD))
+ {
+ pAd->brt30xxBanMcuCmd = TRUE;
+ }
+ else if (Command != WAKE_MCU_CMD)
+ {
+ pAd->brt30xxBanMcuCmd = FALSE;
+ }
+
+ RTMP_SEM_UNLOCK(&pAd->McuCmdLock);
+
+ }
+ if (((IS_RT3090(pAd) || IS_RT3572(pAd) || IS_RT3390(pAd)) && IS_VERSION_AFTER_F(pAd)) && IS_VERSION_AFTER_F(pAd)
+ && (pAd->StaCfg.PSControl.field.rt30xxPowerMode == 3)
+ && (pAd->StaCfg.PSControl.field.EnableNewPS == TRUE)
+ && (Command == WAKE_MCU_CMD))
+ {
+
+ do
+ {
+ RTMP_IO_FORCE_READ32(pAd, H2M_MAILBOX_CSR, &H2MMailbox.word);
+ if (H2MMailbox.field.Owner == 0)
+ break;
+
+ RTMPusecDelay(2);
+ DBGPRINT(RT_DEBUG_INFO, ("AsicSendCommanToMcu::Mail box is busy\n"));
+ } 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_FORCE_WRITE32(pAd, H2M_MAILBOX_CSR, H2MMailbox.word);
+
+ H2MCmd.word = 0;
+ H2MCmd.field.HostCommand = Command;
+ RTMP_IO_FORCE_WRITE32(pAd, HOST_CMD_CSR, H2MCmd.word);
+
+
+ }
+ else
+#endif // CONFIG_STA_SUPPORT //
+#endif // PCIE_PS_SUPPORT //
+ {
+ do
+ {
+ RTMP_IO_READ32(pAd, H2M_MAILBOX_CSR, &H2MMailbox.word);
+ if (H2MMailbox.field.Owner == 0)
+ break;
+
+ RTMPusecDelay(2);
+ } while(i++ < 100);
+
+ if (i >= 100)
+ {
+#ifdef RTMP_MAC_PCI
+#ifdef RALINK_ATE
+ if (pAd->ate.bFWLoading == TRUE)
+ {
+ /* reloading firmware when received iwpriv cmd "ATE=ATESTOP" */
+ if (j > 0)
+ {
+ if (j % 64 != 0)
+ {
+ ATEDBGPRINT(RT_DEBUG_ERROR, ("#"));
+ }
+ else
+ {
+ ATEDBGPRINT(RT_DEBUG_ERROR, ("\n"));
+ }
+ ++j;
+ }
+ else if (j == 0)
+ {
+ ATEDBGPRINT(RT_DEBUG_ERROR, ("Loading firmware. Please wait for a moment...\n"));
+ ++j;
+ }
+ }
+ else
+#endif // RALINK_ATE //
+#endif // RTMP_MAC_PCI //
+ {
+ DBGPRINT_ERR(("H2M_MAILBOX still hold by MCU. command fail\n"));
+ }
+ return FALSE;
+ }
+
+#ifdef RTMP_MAC_PCI
+#ifdef RALINK_ATE
+ else if (pAd->ate.bFWLoading == TRUE)
+ {
+ /* reloading of firmware is completed */
+ pAd->ate.bFWLoading = FALSE;
+ ATEDBGPRINT(RT_DEBUG_ERROR, ("\n"));
+ j = 0;
+ }
+#endif // RALINK_ATE //
+#endif // RTMP_MAC_PCI //
+
+ 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)
+ {
+ }
+}
+#ifdef PCIE_PS_SUPPORT
+#ifdef CONFIG_STA_SUPPORT
+ // 3090 MCU Wakeup command needs more time to be stable.
+ // Before stable, don't issue other MCU command to prevent from firmware error.
+ if (((IS_RT3090(pAd) || IS_RT3572(pAd) || IS_RT3390(pAd)) && IS_VERSION_AFTER_F(pAd)) && IS_VERSION_AFTER_F(pAd)
+ && (pAd->StaCfg.PSControl.field.rt30xxPowerMode == 3)
+ && (pAd->StaCfg.PSControl.field.EnableNewPS == TRUE)
+ && (Command == WAKE_MCU_CMD))
+ {
+ RTMPusecDelay(2000);
+ //Put this is after RF programming.
+ //NdisAcquireSpinLock(&pAd->McuCmdLock);
+ //pAd->brt30xxBanMcuCmd = FALSE;
+ //NdisReleaseSpinLock(&pAd->McuCmdLock);
+ }
+#endif // CONFIG_STA_SUPPORT //
+#endif // PCIE_PS_SUPPORT //
+
+ return TRUE;
+}
diff --git a/drivers/staging/rt3090/common/rtmp_timer.c b/drivers/staging/rt3090/common/rtmp_timer.c
new file mode 100644
index 000000000000..5253e8768145
--- /dev/null
+++ b/drivers/staging/rt3090/common/rtmp_timer.c
@@ -0,0 +1,327 @@
+/*
+ *************************************************************************
+ * 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_timer.c
+
+ Abstract:
+ task for timer handling
+
+ Revision History:
+ Who When What
+ -------- ---------- ----------------------------------------------
+ Name Date Modification logs
+ Shiang Tu 08-28-2008 init version
+
+*/
+
+#include "../rt_config.h"
+
+
+BUILD_TIMER_FUNCTION(MlmePeriodicExec);
+//BUILD_TIMER_FUNCTION(MlmeRssiReportExec);
+BUILD_TIMER_FUNCTION(AsicRxAntEvalTimeout);
+BUILD_TIMER_FUNCTION(APSDPeriodicExec);
+BUILD_TIMER_FUNCTION(AsicRfTuningExec);
+
+
+#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);
+BUILD_TIMER_FUNCTION(StaQuickResponeForRateUpExec);
+BUILD_TIMER_FUNCTION(WpaDisassocApAndBlockAssoc);
+#ifdef RTMP_MAC_PCI
+BUILD_TIMER_FUNCTION(PsPollWakeExec);
+BUILD_TIMER_FUNCTION(RadioOnExec);
+#endif // RTMP_MAC_PCI //
+#ifdef QOS_DLS_SUPPORT
+BUILD_TIMER_FUNCTION(DlsTimeoutAction);
+#endif // QOS_DLS_SUPPORT //
+
+
+#endif // CONFIG_STA_SUPPORT //
+
+
+
+#if defined(AP_LED) || defined(STA_LED)
+extern void LedCtrlMain(
+ IN PVOID SystemSpecific1,
+ IN PVOID FunctionContext,
+ IN PVOID SystemSpecific2,
+ IN PVOID SystemSpecific3);
+BUILD_TIMER_FUNCTION(LedCtrlMain);
+#endif
+
+
+#ifdef RTMP_TIMER_TASK_SUPPORT
+static void RtmpTimerQHandle(RTMP_ADAPTER *pAd)
+{
+#ifndef KTHREAD_SUPPORT
+ int status;
+#endif
+ RALINK_TIMER_STRUCT *pTimer;
+ RTMP_TIMER_TASK_ENTRY *pEntry;
+ unsigned long irqFlag;
+ RTMP_OS_TASK *pTask;
+
+
+ pTask = &pAd->timerTask;
+ while(!pTask->task_killed)
+ {
+ pTimer = NULL;
+
+#ifdef KTHREAD_SUPPORT
+ RTMP_WAIT_EVENT_INTERRUPTIBLE(pAd, pTask);
+#else
+ RTMP_SEM_EVENT_WAIT(&(pTask->taskSema), status);
+#endif
+
+ if (pAd->TimerQ.status == RTMP_TASK_STAT_STOPED)
+ break;
+
+ // event happened.
+ while(pAd->TimerQ.pQHead)
+ {
+ RTMP_INT_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_INT_UNLOCK(&pAd->TimerQLock, irqFlag);
+
+ if (pTimer)
+ {
+ if ((pTimer->handle != NULL) && (!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);
+ }
+ }
+
+#ifndef KTHREAD_SUPPORT
+ if (status != 0)
+ {
+ pAd->TimerQ.status = RTMP_TASK_STAT_STOPED;
+ RTMP_SET_FLAG(pAd, fRTMP_ADAPTER_HALT_IN_PROGRESS);
+ break;
+ }
+#endif
+ }
+}
+
+
+INT RtmpTimerQThread(
+ IN OUT PVOID Context)
+{
+ RTMP_OS_TASK *pTask;
+ PRTMP_ADAPTER pAd;
+
+
+ pTask = (RTMP_OS_TASK *)Context;
+ pAd = (PRTMP_ADAPTER)pTask->priv;
+
+ RtmpOSTaskCustomize(pTask);
+
+ RtmpTimerQHandle(pAd);
+
+ DBGPRINT(RT_DEBUG_TRACE,( "<---%s\n",__FUNCTION__));
+#ifndef KTHREAD_SUPPORT
+ pTask->taskPID = THREAD_PID_INIT_VALUE;
+#endif
+ /* 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().
+ */
+ RtmpOSTaskNotifyToExit(pTask);
+
+ return 0;
+
+}
+
+
+RTMP_TIMER_TASK_ENTRY *RtmpTimerQInsert(
+ IN RTMP_ADAPTER *pAd,
+ IN RALINK_TIMER_STRUCT *pTimer)
+{
+ RTMP_TIMER_TASK_ENTRY *pQNode = NULL, *pQTail;
+ unsigned long irqFlags;
+ RTMP_OS_TASK *pTask = &pAd->timerTask;
+
+ RTMP_INT_LOCK(&pAd->TimerQLock, irqFlags);
+ if (pAd->TimerQ.status & RTMP_TASK_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_INT_UNLOCK(&pAd->TimerQLock, irqFlags);
+
+ if (pQNode)
+ {
+#ifdef KTHREAD_SUPPORT
+ WAKE_UP(pTask);
+#else
+ RTMP_SEM_EVENT_UP(&pTask->taskSema);
+#endif
+ }
+
+ return pQNode;
+}
+
+
+BOOLEAN RtmpTimerQRemove(
+ IN RTMP_ADAPTER *pAd,
+ IN RALINK_TIMER_STRUCT *pTimer)
+{
+ RTMP_TIMER_TASK_ENTRY *pNode, *pPrev = NULL;
+ unsigned long irqFlags;
+
+ RTMP_INT_LOCK(&pAd->TimerQLock, irqFlags);
+ if (pAd->TimerQ.status >= RTMP_TASK_STAT_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_INT_UNLOCK(&pAd->TimerQLock, irqFlags);
+
+ return TRUE;
+}
+
+
+void RtmpTimerQExit(RTMP_ADAPTER *pAd)
+{
+ RTMP_TIMER_TASK_ENTRY *pTimerQ;
+ unsigned long irqFlags;
+
+ RTMP_INT_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;
+#ifndef KTHREAD_SUPPORT
+ pAd->TimerQ.status = RTMP_TASK_STAT_STOPED;
+#endif
+ RTMP_INT_UNLOCK(&pAd->TimerQLock, irqFlags);
+
+}
+
+
+void RtmpTimerQInit(RTMP_ADAPTER *pAd)
+{
+ int i;
+ RTMP_TIMER_TASK_ENTRY *pQNode, *pEntry;
+ unsigned long irqFlags;
+
+ NdisAllocateSpinLock(&pAd->TimerQLock);
+
+ NdisZeroMemory(&pAd->TimerQ, sizeof(pAd->TimerQ));
+
+ os_alloc_mem(pAd, &pAd->TimerQ.pTimerQPoll, sizeof(RTMP_TIMER_TASK_ENTRY) * TIMER_QUEUE_SIZE_MAX);
+ if (pAd->TimerQ.pTimerQPoll)
+ {
+ pEntry = NULL;
+ pQNode = (RTMP_TIMER_TASK_ENTRY *)pAd->TimerQ.pTimerQPoll;
+ NdisZeroMemory(pAd->TimerQ.pTimerQPoll, sizeof(RTMP_TIMER_TASK_ENTRY) * TIMER_QUEUE_SIZE_MAX);
+
+ RTMP_INT_LOCK(&pAd->TimerQLock, irqFlags);
+ 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 = RTMP_TASK_STAT_INITED;
+ RTMP_INT_UNLOCK(&pAd->TimerQLock, irqFlags);
+ }
+}
+#endif // RTMP_TIMER_TASK_SUPPORT //
diff --git a/drivers/staging/rt3090/common/spectrum.c b/drivers/staging/rt3090/common/spectrum.c
new file mode 100644
index 000000000000..12d2125148ba
--- /dev/null
+++ b/drivers/staging/rt3090/common/spectrum.c
@@ -0,0 +1,2221 @@
+/*
+ *************************************************************************
+ * 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"
+
+
+/* The regulatory information in the USA (US) */
+DOT11_REGULATORY_INFORMATION USARegulatoryInfo[] =
+{
+/* "regulatory class" "number of channels" "Max Tx Pwr" "channel list" */
+ {0, {0, 0, {0}}}, // Invlid entry
+ {1, {4, 16, {36, 40, 44, 48}}},
+ {2, {4, 23, {52, 56, 60, 64}}},
+ {3, {4, 29, {149, 153, 157, 161}}},
+ {4, {11, 23, {100, 104, 108, 112, 116, 120, 124, 128, 132, 136, 140}}},
+ {5, {5, 30, {149, 153, 157, 161, 165}}},
+ {6, {10, 14, {1, 2, 3, 4, 5, 6, 7, 8, 9, 10}}},
+ {7, {10, 27, {1, 2, 3, 4, 5, 6, 7, 8, 9, 10}}},
+ {8, {5, 17, {11, 13, 15, 17, 19}}},
+ {9, {5, 30, {11, 13, 15, 17, 19}}},
+ {10, {2, 20, {21, 25}}},
+ {11, {2, 33, {21, 25}}},
+ {12, {11, 30, {1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11}}}
+};
+#define USA_REGULATORY_INFO_SIZE (sizeof(USARegulatoryInfo) / sizeof(DOT11_REGULATORY_INFORMATION))
+
+
+/* The regulatory information in Europe */
+DOT11_REGULATORY_INFORMATION EuropeRegulatoryInfo[] =
+{
+/* "regulatory class" "number of channels" "Max Tx Pwr" "channel list" */
+ {0, {0, 0, {0}}}, // Invalid entry
+ {1, {4, 20, {36, 40, 44, 48}}},
+ {2, {4, 20, {52, 56, 60, 64}}},
+ {3, {11, 30, {100, 104, 108, 112, 116, 120, 124, 128, 132, 136, 140}}},
+ {4, {13, 20, {1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13}}}
+};
+#define EU_REGULATORY_INFO_SIZE (sizeof(EuropeRegulatoryInfo) / sizeof(DOT11_REGULATORY_INFORMATION))
+
+
+/* The regulatory information in Japan */
+DOT11_REGULATORY_INFORMATION JapanRegulatoryInfo[] =
+{
+/* "regulatory class" "number of channels" "Max Tx Pwr" "channel list" */
+ {0, {0, 0, {0}}}, // Invalid entry
+ {1, {4, 22, {34, 38, 42, 46}}},
+ {2, {3, 24, {8, 12, 16}}},
+ {3, {3, 24, {8, 12, 16}}},
+ {4, {3, 24, {8, 12, 16}}},
+ {5, {3, 24, {8, 12, 16}}},
+ {6, {3, 22, {8, 12, 16}}},
+ {7, {4, 24, {184, 188, 192, 196}}},
+ {8, {4, 24, {184, 188, 192, 196}}},
+ {9, {4, 24, {184, 188, 192, 196}}},
+ {10, {4, 24, {184, 188, 192, 196}}},
+ {11, {4, 22, {184, 188, 192, 196}}},
+ {12, {4, 24, {7, 8, 9, 11}}},
+ {13, {4, 24, {7, 8, 9, 11}}},
+ {14, {4, 24, {7, 8, 9, 11}}},
+ {15, {4, 24, {7, 8, 9, 11}}},
+ {16, {6, 24, {183, 184, 185, 187, 188, 189}}},
+ {17, {6, 24, {183, 184, 185, 187, 188, 189}}},
+ {18, {6, 24, {183, 184, 185, 187, 188, 189}}},
+ {19, {6, 24, {183, 184, 185, 187, 188, 189}}},
+ {20, {6, 17, {183, 184, 185, 187, 188, 189}}},
+ {21, {6, 24, {6, 7, 8, 9, 10, 11}}},
+ {22, {6, 24, {6, 7, 8, 9, 10, 11}}},
+ {23, {6, 24, {6, 7, 8, 9, 10, 11}}},
+ {24, {6, 24, {6, 7, 8, 9, 10, 11}}},
+ {25, {8, 24, {182, 183, 184, 185, 186, 187, 188, 189}}},
+ {26, {8, 24, {182, 183, 184, 185, 186, 187, 188, 189}}},
+ {27, {8, 24, {182, 183, 184, 185, 186, 187, 188, 189}}},
+ {28, {8, 24, {182, 183, 184, 185, 186, 187, 188, 189}}},
+ {29, {8, 17, {182, 183, 184, 185, 186, 187, 188, 189}}},
+ {30, {13, 23, {1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13}}},
+ {31, {1, 23, {14}}},
+ {32, {4, 22, {52, 56, 60, 64}}}
+};
+#define JP_REGULATORY_INFO_SIZE (sizeof(JapanRegulatoryInfo) / sizeof(DOT11_REGULATORY_INFORMATION))
+
+
+CHAR RTMP_GetTxPwr(
+ IN PRTMP_ADAPTER pAd,
+ IN HTTRANSMIT_SETTING HTTxMode)
+{
+typedef struct __TX_PWR_CFG
+{
+ UINT8 Mode;
+ UINT8 MCS;
+ UINT16 req;
+ UINT8 shift;
+ UINT32 BitMask;
+} TX_PWR_CFG;
+
+ UINT32 Value;
+ INT Idx;
+ UINT8 PhyMode;
+ CHAR CurTxPwr;
+ UINT8 TxPwrRef = 0;
+ CHAR DaltaPwr;
+ ULONG TxPwr[5];
+
+
+ TX_PWR_CFG TxPwrCfg[] = {
+ {MODE_CCK, 0, 0, 4, 0x000000f0},
+ {MODE_CCK, 1, 0, 0, 0x0000000f},
+ {MODE_CCK, 2, 0, 12, 0x0000f000},
+ {MODE_CCK, 3, 0, 8, 0x00000f00},
+
+ {MODE_OFDM, 0, 0, 20, 0x00f00000},
+ {MODE_OFDM, 1, 0, 16, 0x000f0000},
+ {MODE_OFDM, 2, 0, 28, 0xf0000000},
+ {MODE_OFDM, 3, 0, 24, 0x0f000000},
+ {MODE_OFDM, 4, 1, 4, 0x000000f0},
+ {MODE_OFDM, 5, 1, 0, 0x0000000f},
+ {MODE_OFDM, 6, 1, 12, 0x0000f000},
+ {MODE_OFDM, 7, 1, 8, 0x00000f00}
+#ifdef DOT11_N_SUPPORT
+ ,{MODE_HTMIX, 0, 1, 20, 0x00f00000},
+ {MODE_HTMIX, 1, 1, 16, 0x000f0000},
+ {MODE_HTMIX, 2, 1, 28, 0xf0000000},
+ {MODE_HTMIX, 3, 1, 24, 0x0f000000},
+ {MODE_HTMIX, 4, 2, 4, 0x000000f0},
+ {MODE_HTMIX, 5, 2, 0, 0x0000000f},
+ {MODE_HTMIX, 6, 2, 12, 0x0000f000},
+ {MODE_HTMIX, 7, 2, 8, 0x00000f00},
+ {MODE_HTMIX, 8, 2, 20, 0x00f00000},
+ {MODE_HTMIX, 9, 2, 16, 0x000f0000},
+ {MODE_HTMIX, 10, 2, 28, 0xf0000000},
+ {MODE_HTMIX, 11, 2, 24, 0x0f000000},
+ {MODE_HTMIX, 12, 3, 4, 0x000000f0},
+ {MODE_HTMIX, 13, 3, 0, 0x0000000f},
+ {MODE_HTMIX, 14, 3, 12, 0x0000f000},
+ {MODE_HTMIX, 15, 3, 8, 0x00000f00}
+#endif // DOT11_N_SUPPORT //
+ };
+#define MAX_TXPWR_TAB_SIZE (sizeof(TxPwrCfg) / sizeof(TX_PWR_CFG))
+
+#ifdef SINGLE_SKU
+ CurTxPwr = pAd->CommonCfg.DefineMaxTxPwr;
+#else
+ CurTxPwr = 19;
+#endif
+
+ /* check Tx Power setting from UI. */
+ if (pAd->CommonCfg.TxPowerPercentage > 90)
+ ;
+ else if (pAd->CommonCfg.TxPowerPercentage > 60) /* reduce Pwr for 1 dB. */
+ CurTxPwr -= 1;
+ else if (pAd->CommonCfg.TxPowerPercentage > 30) /* reduce Pwr for 3 dB. */
+ CurTxPwr -= 3;
+ else if (pAd->CommonCfg.TxPowerPercentage > 15) /* reduce Pwr for 6 dB. */
+ CurTxPwr -= 6;
+ else if (pAd->CommonCfg.TxPowerPercentage > 9) /* reduce Pwr for 9 dB. */
+ CurTxPwr -= 9;
+ else /* reduce Pwr for 12 dB. */
+ CurTxPwr -= 12;
+
+ 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];
+ }
+ }
+
+
+ switch(HTTxMode.field.MODE)
+ {
+ case MODE_CCK:
+ case MODE_OFDM:
+ Value = TxPwr[1];
+ TxPwrRef = (Value & 0x00000f00) >> 8;
+
+ break;
+
+#ifdef DOT11_N_SUPPORT
+ case MODE_HTMIX:
+ case MODE_HTGREENFIELD:
+ if (pAd->CommonCfg.TxStream == 1)
+ {
+ Value = TxPwr[2];
+ TxPwrRef = (Value & 0x00000f00) >> 8;
+ }
+ else if (pAd->CommonCfg.TxStream == 2)
+ {
+ Value = TxPwr[3];
+ TxPwrRef = (Value & 0x00000f00) >> 8;
+ }
+ break;
+#endif // DOT11_N_SUPPORT //
+ }
+
+ PhyMode =
+#ifdef DOT11_N_SUPPORT
+ (HTTxMode.field.MODE == MODE_HTGREENFIELD)
+ ? MODE_HTMIX :
+#endif // DOT11_N_SUPPORT //
+ HTTxMode.field.MODE;
+
+ for (Idx = 0; Idx < MAX_TXPWR_TAB_SIZE; Idx++)
+ {
+ if ((TxPwrCfg[Idx].Mode == PhyMode)
+ && (TxPwrCfg[Idx].MCS == HTTxMode.field.MCS))
+ {
+ Value = TxPwr[TxPwrCfg[Idx].req];
+ DaltaPwr = TxPwrRef - (CHAR)((Value & TxPwrCfg[Idx].BitMask)
+ >> TxPwrCfg[Idx].shift);
+ CurTxPwr -= DaltaPwr;
+ break;
+ }
+ }
+
+ return CurTxPwr;
+}
+
+
+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;
+}
+
+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;
+}
+
+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;
+}
+
+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:
+ Get Current Transmit Power.
+
+ Parametrs:
+
+ Return : Current Time Stamp.
+ ==========================================================================
+ */
+VOID InsertChannelRepIE(
+ IN PRTMP_ADAPTER pAd,
+ OUT PUCHAR pFrameBuf,
+ OUT PULONG pFrameLen,
+ IN PSTRING pCountry,
+ IN UINT8 RegulatoryClass)
+{
+ ULONG TempLen;
+ UINT8 Len;
+ UINT8 IEId = IE_AP_CHANNEL_REPORT;
+ PUCHAR pChListPtr = NULL;
+
+ Len = 1;
+ if (strncmp(pCountry, "US", 2) == 0)
+ {
+ if (RegulatoryClass >= USA_REGULATORY_INFO_SIZE)
+ {
+ DBGPRINT(RT_DEBUG_ERROR, ("%s: USA Unknow Requlatory class (%d)\n",
+ __FUNCTION__, RegulatoryClass));
+ return;
+ }
+
+ Len += USARegulatoryInfo[RegulatoryClass].ChannelSet.NumberOfChannels;
+ pChListPtr = USARegulatoryInfo[RegulatoryClass].ChannelSet.ChannelList;
+ }
+ else if (strncmp(pCountry, "JP", 2) == 0)
+ {
+ if (RegulatoryClass >= JP_REGULATORY_INFO_SIZE)
+ {
+ DBGPRINT(RT_DEBUG_ERROR, ("%s: JP Unknow Requlatory class (%d)\n",
+ __FUNCTION__, RegulatoryClass));
+ return;
+ }
+
+ Len += JapanRegulatoryInfo[RegulatoryClass].ChannelSet.NumberOfChannels;
+ pChListPtr = JapanRegulatoryInfo[RegulatoryClass].ChannelSet.ChannelList;
+ }
+ else
+ {
+ DBGPRINT(RT_DEBUG_ERROR, ("%s: Unknow Country (%s)\n",
+ __FUNCTION__, pCountry));
+ return;
+ }
+
+ MakeOutgoingFrame(pFrameBuf, &TempLen,
+ 1, &IEId,
+ 1, &Len,
+ 1, &RegulatoryClass,
+ Len -1, pChListPtr,
+ END_OF_ARGS);
+
+ *pFrameLen = *pFrameLen + TempLen;
+
+ return;
+}
+
+/*
+ ==========================================================================
+ Description:
+ Insert Dialog Token into frame.
+
+ Parametrs:
+ 1. frame buffer pointer.
+ 2. frame length.
+ 3. Dialog token.
+
+ Return : None.
+ ==========================================================================
+ */
+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.
+ ==========================================================================
+ */
+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 UINT8 Len,
+ IN PMEASURE_REQ_INFO pMeasureReqIE)
+{
+ ULONG TempLen;
+ UINT8 ElementID = IE_MEASUREMENT_REQUEST;
+
+ MakeOutgoingFrame(pFrameBuf, &TempLen,
+ 1, &ElementID,
+ 1, &Len,
+ sizeof(MEASURE_REQ_INFO), 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 MakeMeasurementReqFrame(
+ IN PRTMP_ADAPTER pAd,
+ OUT PUCHAR pOutBuffer,
+ OUT PULONG pFrameLen,
+ IN UINT8 TotalLen,
+ IN UINT8 Category,
+ IN UINT8 Action,
+ IN UINT8 MeasureToken,
+ IN UINT8 MeasureReqMode,
+ IN UINT8 MeasureReqType,
+ IN UINT8 NumOfRepetitions)
+{
+ ULONG TempLen;
+ MEASURE_REQ_INFO MeasureReqIE;
+
+ InsertActField(pAd, (pOutBuffer + *pFrameLen), pFrameLen, Category, Action);
+
+ // fill Dialog Token
+ InsertDialogToken(pAd, (pOutBuffer + *pFrameLen), pFrameLen, MeasureToken);
+
+ /* fill Number of repetitions. */
+ if (Category == CATEGORY_RM)
+ {
+ MakeOutgoingFrame((pOutBuffer+*pFrameLen), &TempLen,
+ 2, &NumOfRepetitions,
+ END_OF_ARGS);
+
+ *pFrameLen += TempLen;
+ }
+
+ // prepare Measurement IE.
+ NdisZeroMemory(&MeasureReqIE, sizeof(MEASURE_REQ_INFO));
+ MeasureReqIE.Token = MeasureToken;
+ MeasureReqIE.ReqMode.word = MeasureReqMode;
+ MeasureReqIE.ReqType = MeasureReqType;
+ InsertMeasureReqIE(pAd, (pOutBuffer+*pFrameLen), pFrameLen,
+ TotalLen, &MeasureReqIE);
+
+ 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 = 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,
+ OUT PMEASURE_REQ pMeasureReq)
+{
+ 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 = (PUCHAR)(eid_ptr->Octet + 3);
+ NdisMoveMemory(&pMeasureReq->ChNum, ptr, 1);
+ NdisMoveMemory(&MeasureStartTime, ptr + 1, 8);
+ pMeasureReq->MeasureStartTime = SWAP64(MeasureStartTime);
+ NdisMoveMemory(&MeasureDuration, ptr + 9, 2);
+ pMeasureReq->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 = (PUCHAR)(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 = (PUCHAR)(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 = (PUCHAR)(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_REQ MeasureReq;
+ MEASURE_REPORT_MODE ReportMode;
+
+ if(PeerMeasureReqSanity(pAd, Elem->Msg, Elem->MsgLen, &DialogToken, &MeasureReqInfo, &MeasureReq))
+ {
+ 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 PSTRING arg)
+{
+ UINT Aid = 1;
+ UINT ArgIdx;
+ PSTRING thisChar;
+
+ MEASURE_REQ_MODE MeasureReqMode;
+ UINT8 MeasureReqToken = RandomByte(pAd);
+ UINT8 MeasureReqType = RM_BASIC;
+ UINT8 MeasureCh = 1;
+ UINT64 MeasureStartTime = GetCurrentTimeStamp(pAd);
+ MEASURE_REQ MeasureReq;
+ UINT8 TotalLen;
+
+ HEADER_802_11 ActHdr;
+ PUCHAR pOutBuffer = NULL;
+ NDIS_STATUS NStatus;
+ ULONG FrameLen;
+
+ 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__));
+ goto END_OF_MEASURE_REQ;
+ }
+
+ ArgIdx = 1;
+ while ((thisChar = strsep((char **)&arg, "-")) != NULL)
+ {
+ switch(ArgIdx)
+ {
+ case 1: // Aid.
+ Aid = (UINT8) 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));
+ goto END_OF_MEASURE_REQ;
+ }
+ break;
+
+ case 3: // Measurement channel.
+ MeasureCh = (UINT8) 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));
+ goto END_OF_MEASURE_REQ;
+ }
+
+ MeasureReqMode.word = 0;
+ MeasureReqMode.field.Enable = 1;
+
+ MeasureReqInsert(pAd, MeasureReqToken);
+
+ // build action frame header.
+ MgtMacHeaderInit(pAd, &ActHdr, SUBTYPE_ACTION, 0, pAd->MacTab.Content[Aid].Addr,
+ pAd->CurrentAddress);
+
+ NdisMoveMemory(pOutBuffer, (PCHAR)&ActHdr, sizeof(HEADER_802_11));
+ FrameLen = sizeof(HEADER_802_11);
+
+ TotalLen = sizeof(MEASURE_REQ_INFO) + sizeof(MEASURE_REQ);
+
+ MakeMeasurementReqFrame(pAd, pOutBuffer, &FrameLen,
+ sizeof(MEASURE_REQ_INFO), CATEGORY_RM, RM_BASIC,
+ MeasureReqToken, MeasureReqMode.word,
+ MeasureReqType, 0);
+
+ MeasureReq.ChNum = MeasureCh;
+ MeasureReq.MeasureStartTime = cpu2le64(MeasureStartTime);
+ MeasureReq.MeasureDuration = cpu2le16(2000);
+
+ {
+ ULONG TempLen;
+ MakeOutgoingFrame( pOutBuffer+FrameLen, &TempLen,
+ sizeof(MEASURE_REQ), &MeasureReq,
+ END_OF_ARGS);
+ FrameLen += TempLen;
+ }
+
+ MiniportMMRequest(pAd, QID_AC_BE, pOutBuffer, (UINT)FrameLen);
+
+END_OF_MEASURE_REQ:
+ MlmeFreeMemory(pAd, pOutBuffer);
+
+ return TRUE;
+}
+
+INT Set_TpcReq_Proc(
+ IN PRTMP_ADAPTER pAd,
+ IN PSTRING arg)
+{
+ UINT Aid;
+
+ UINT8 TpcReqToken = RandomByte(pAd);
+
+ Aid = (UINT) 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;
+}
diff --git a/drivers/staging/rt3090/config.mk b/drivers/staging/rt3090/config.mk
new file mode 100644
index 000000000000..8a167e99bdb5
--- /dev/null
+++ b/drivers/staging/rt3090/config.mk
@@ -0,0 +1,187 @@
+# Support ATE function
+HAS_ATE=y
+
+# Support 28xx QA ATE function
+HAS_28xx_QA=n
+
+
+HAS_NINTENDO=n
+
+# Support LLTD function
+HAS_LLTD=n
+
+# Support WDS function
+HAS_WDS=n
+
+# Support AP-Client function
+HAS_APCLI=n
+
+# Support Wpa_Supplicant
+HAS_WPA_SUPPLICANT=y
+
+# Support Native WpaSupplicant for Network Maganger
+HAS_NATIVE_WPA_SUPPLICANT_SUPPORT=n
+
+#Support Net interface block while Tx-Sw queue full
+HAS_BLOCK_NET_IF=n
+
+#Support IGMP-Snooping function.
+HAS_IGMP_SNOOP_SUPPORT=n
+
+#Support DFS function
+HAS_DFS_SUPPORT=n
+
+#Support Carrier-Sense function
+HAS_CS_SUPPORT=n
+
+# Support for STA Ethernet Converter
+HAS_ETH_CONVERT_SUPPORT=n
+
+# Support user specific transmit rate of Multicast packet.
+HAS_MCAST_RATE_SPECIFIC_SUPPORT=n
+
+# Support for Multiple Cards
+HAS_MC_SUPPORT=n
+
+#Support for PCI-MSI
+HAS_MSI_SUPPORT=n
+
+
+#Support for IEEE802.11e DLS
+HAS_QOS_DLS_SUPPORT=n
+
+#Support for EXT_CHANNEL
+HAS_EXT_BUILD_CHANNEL_LIST=n
+
+#Support for IDS
+HAS_IDS_SUPPORT=n
+
+
+#Support for Net-SNMP
+HAS_SNMP_SUPPORT=n
+
+#Support features of 802.11n Draft3
+HAS_DOT11N_DRAFT3_SUPPORT=n
+
+#Support features of Single SKU.
+HAS_SINGLE_SKU_SUPPORT=n
+
+#Support features of 802.11n
+HAS_DOT11_N_SUPPORT=y
+
+
+
+#Support for 2860/2880 co-exist
+HAS_RT2880_RT2860_COEXIST=n
+
+HAS_KTHREAD_SUPPORT=n
+
+
+#Support for Auto channel select enhance
+HAS_AUTO_CH_SELECT_ENHANCE=n
+
+#Support bypass bridge
+HAS_BG_FT_SUPPORT=n
+
+#Support Antenna Diversity
+HAS_ANTENNA_DIVERSITY_SUPPORT=y
+#################################################
+
+WFLAGS := -DAGGREGATION_SUPPORT -DPIGGYBACK_SUPPORT -DWMM_SUPPORT -DLINUX -Wall -Wstrict-prototypes -Wno-trigraphs -Wpointer-sign
+
+ifeq ($(HAS_KTHREAD_SUPPORT),y)
+WFLAGS += -DKTHREAD_SUPPORT
+endif
+
+
+#################################################
+
+# config for STA mode
+
+WFLAGS += -DCONFIG_STA_SUPPORT -DDBG
+
+ifeq ($(HAS_WPA_SUPPLICANT),y)
+WFLAGS += -DWPA_SUPPLICANT_SUPPORT
+ifeq ($(HAS_NATIVE_WPA_SUPPLICANT_SUPPORT),y)
+WFLAGS += -DNATIVE_WPA_SUPPLICANT_SUPPORT
+endif
+endif
+
+
+ifeq ($(HAS_ETH_CONVERT_SUPPORT), y)
+WFLAGS += -DETH_CONVERT_SUPPORT -DMAT_SUPPORT
+endif
+
+ifeq ($(HAS_ATE),y)
+WFLAGS += -DRALINK_ATE
+ifeq ($(HAS_28xx_QA),y)
+WFLAGS += -DRALINK_28xx_QA
+endif
+endif
+
+
+ifeq ($(HAS_SNMP_SUPPORT),y)
+WFLAGS += -DSNMP_SUPPORT
+endif
+
+ifeq ($(HAS_QOS_DLS_SUPPORT),y)
+WFLAGS += -DQOS_DLS_SUPPORT
+endif
+
+ifeq ($(HAS_DOT11_N_SUPPORT),y)
+WFLAGS += -DDOT11_N_SUPPORT
+endif
+
+ifeq ($(HAS_CS_SUPPORT),y)
+WFLAGS += -DCARRIER_DETECTION_SUPPORT
+endif
+
+ifeq ($(HAS_ANTENNA_DIVERSITY_SUPPORT),y)
+WFLAGS += -DANT_DIVERSITY_SUPPORT
+endif
+
+#################################################
+
+#################################################
+
+#
+# Common compiler flag
+#
+
+
+
+
+
+ifeq ($(HAS_EXT_BUILD_CHANNEL_LIST),y)
+WFLAGS += -DEXT_BUILD_CHANNEL_LIST
+endif
+
+ifeq ($(HAS_IDS_SUPPORT),y)
+WFLAGS += -DIDS_SUPPORT
+endif
+
+
+#################################################
+# ChipSet specific definitions.
+#
+WFLAGS +=-DRTMP_MAC_PCI -DRT30xx -DRT3090 -DRTMP_PCI_SUPPORT -DRTMP_RF_RW_SUPPORT -DRTMP_EFUSE_SUPPORT
+#################################################
+
+
+ifeq ($(HAS_BLOCK_NET_IF),y)
+WFLAGS += -DBLOCK_NET_IF
+endif
+
+ifeq ($(HAS_DFS_SUPPORT),y)
+WFLAGS += -DDFS_SUPPORT
+endif
+
+ifeq ($(HAS_MC_SUPPORT),y)
+WFLAGS += -DMULTIPLE_CARD_SUPPORT
+endif
+
+ifeq ($(HAS_LLTD),y)
+WFLAGS += -DLLTD_SUPPORT
+endif
+
+EXTRA_CFLAGS := $(WFLAGS)
diff --git a/drivers/staging/rt3090/crypt_hmac.h b/drivers/staging/rt3090/crypt_hmac.h
new file mode 100644
index 000000000000..557ca733d398
--- /dev/null
+++ b/drivers/staging/rt3090/crypt_hmac.h
@@ -0,0 +1,81 @@
+/*
+ *************************************************************************
+ * 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:
+ crypt_hmac.h
+
+ Abstract:
+ Miniport generic portion header file
+
+ Revision History:
+ Who When What
+ -------- ---------- ----------------------------------------------
+ Eddy 2008/11/24 Create HMAC-SHA1, HMAC-SHA256
+*/
+
+#ifndef __CRYPT_HMAC_H__
+#define __CRYPT_HMAC_H__
+
+#ifdef CRYPT_TESTPLAN
+#include "crypt_testplan.h"
+#else
+#include "rt_config.h"
+#endif /* CRYPT_TESTPLAN */
+
+#ifdef SHA1_SUPPORT
+#define HMAC_SHA1_SUPPORT
+VOID HMAC_SHA1 (
+ IN const UINT8 Key[],
+ IN UINT KeyLen,
+ IN const UINT8 Message[],
+ IN UINT MessageLen,
+ OUT UINT8 MAC[],
+ IN UINT MACLen);
+#endif /* SHA1_SUPPORT */
+
+#ifdef SHA256_SUPPORT
+#define HMAC_SHA256_SUPPORT
+VOID HMAC_SHA256 (
+ IN const UINT8 Key[],
+ IN UINT KeyLen,
+ IN const UINT8 Message[],
+ IN UINT MessageLen,
+ OUT UINT8 MAC[],
+ IN UINT MACLen);
+#endif /* SHA256_SUPPORT */
+
+#ifdef MD5_SUPPORT
+#define HMAC_MD5_SUPPORT
+VOID HMAC_MD5 (
+ IN const UINT8 Key[],
+ IN UINT KeyLen,
+ IN const UINT8 Message[],
+ IN UINT MessageLen,
+ OUT UINT8 MAC[],
+ IN UINT MACLen);
+#endif /* MD5_SUPPORT */
+
+#endif /* __CRYPT_HMAC_H__ */
diff --git a/drivers/staging/rt3090/crypt_md5.h b/drivers/staging/rt3090/crypt_md5.h
new file mode 100644
index 000000000000..7ee3f4233fad
--- /dev/null
+++ b/drivers/staging/rt3090/crypt_md5.h
@@ -0,0 +1,78 @@
+/*
+ *************************************************************************
+ * 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:
+ crypt_md5.h
+
+ Abstract:
+ Miniport generic portion header file
+
+ Revision History:
+ Who When What
+ -------- ---------- ----------------------------------------------
+ Eddy 2008/11/24 Create md5
+*/
+
+#ifndef __CRYPT_MD5_H__
+#define __CRYPT_MD5_H__
+
+#ifdef CRYPT_TESTPLAN
+#include "crypt_testplan.h"
+#else
+#include "rt_config.h"
+#endif /* CRYPT_TESTPLAN */
+
+/* Algorithm options */
+#define MD5_SUPPORT
+
+#ifdef MD5_SUPPORT
+#define MD5_BLOCK_SIZE 64 /* 512 bits = 64 bytes */
+#define MD5_DIGEST_SIZE 16 /* 128 bits = 16 bytes */
+typedef struct {
+ UINT32 HashValue[4];
+ UINT64 MessageLen;
+ UINT8 Block[MD5_BLOCK_SIZE];
+ UINT BlockLen;
+} MD5_CTX_STRUC, *PMD5_CTX_STRUC;
+
+VOID MD5_Init (
+ IN MD5_CTX_STRUC *pMD5_CTX);
+VOID MD5_Hash (
+ IN MD5_CTX_STRUC *pMD5_CTX);
+VOID MD5_Append (
+ IN MD5_CTX_STRUC *pMD5_CTX,
+ IN const UINT8 Message[],
+ IN UINT MessageLen);
+VOID MD5_End (
+ IN MD5_CTX_STRUC *pMD5_CTX,
+ OUT UINT8 DigestMessage[]);
+VOID RT_MD5 (
+ IN const UINT8 Message[],
+ IN UINT MessageLen,
+ OUT UINT8 DigestMessage[]);
+#endif /* MD5_SUPPORT */
+
+#endif /* __CRYPT_MD5_H__ */
diff --git a/drivers/staging/rt3090/crypt_sha2.h b/drivers/staging/rt3090/crypt_sha2.h
new file mode 100644
index 000000000000..85c0403d725a
--- /dev/null
+++ b/drivers/staging/rt3090/crypt_sha2.h
@@ -0,0 +1,107 @@
+/*
+ *************************************************************************
+ * 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:
+ crypt_sha2.h
+
+ Abstract:
+ Miniport generic portion header file
+
+ Revision History:
+ Who When What
+ -------- ---------- ----------------------------------------------
+ Eddy 2008/11/24 Create SHA1
+ Eddy 2008/07/23 Create SHA256
+*/
+
+#ifndef __CRYPT_SHA2_H__
+#define __CRYPT_SHA2_H__
+
+#ifdef CRYPT_TESTPLAN
+#include "crypt_testplan.h"
+#else
+#include "rt_config.h"
+#endif /* CRYPT_TESTPLAN */
+
+/* Algorithm options */
+#define SHA1_SUPPORT
+#define SHA256_SUPPORT
+
+#ifdef SHA1_SUPPORT
+#define SHA1_BLOCK_SIZE 64 /* 512 bits = 64 bytes */
+#define SHA1_DIGEST_SIZE 20 /* 160 bits = 20 bytes */
+typedef struct _SHA1_CTX_STRUC {
+ UINT32 HashValue[5]; /* 5 = (SHA1_DIGEST_SIZE / 32) */
+ UINT64 MessageLen; /* total size */
+ UINT8 Block[SHA1_BLOCK_SIZE];
+ UINT BlockLen;
+} SHA1_CTX_STRUC, *PSHA1_CTX_STRUC;
+
+VOID SHA1_Init (
+ IN SHA1_CTX_STRUC *pSHA_CTX);
+VOID SHA1_Hash (
+ IN SHA1_CTX_STRUC *pSHA_CTX);
+VOID SHA1_Append (
+ IN SHA1_CTX_STRUC *pSHA_CTX,
+ IN const UINT8 Message[],
+ IN UINT MessageLen);
+VOID SHA1_End (
+ IN SHA1_CTX_STRUC *pSHA_CTX,
+ OUT UINT8 DigestMessage[]);
+VOID RT_SHA1 (
+ IN const UINT8 Message[],
+ IN UINT MessageLen,
+ OUT UINT8 DigestMessage[]);
+#endif /* SHA1_SUPPORT */
+
+#ifdef SHA256_SUPPORT
+#define SHA256_BLOCK_SIZE 64 /* 512 bits = 64 bytes */
+#define SHA256_DIGEST_SIZE 32 /* 256 bits = 32 bytes */
+typedef struct _SHA256_CTX_STRUC {
+ UINT32 HashValue[8]; /* 8 = (SHA256_DIGEST_SIZE / 32) */
+ UINT64 MessageLen; /* total size */
+ UINT8 Block[SHA256_BLOCK_SIZE];
+ UINT BlockLen;
+} SHA256_CTX_STRUC, *PSHA256_CTX_STRUC;
+
+VOID SHA256_Init (
+ IN SHA256_CTX_STRUC *pSHA_CTX);
+VOID SHA256_Hash (
+ IN SHA256_CTX_STRUC *pSHA_CTX);
+VOID SHA256_Append (
+ IN SHA256_CTX_STRUC *pSHA_CTX,
+ IN const UINT8 Message[],
+ IN UINT MessageLen);
+VOID SHA256_End (
+ IN SHA256_CTX_STRUC *pSHA_CTX,
+ OUT UINT8 DigestMessage[]);
+VOID RT_SHA256 (
+ IN const UINT8 Message[],
+ IN UINT MessageLen,
+ OUT UINT8 DigestMessage[]);
+#endif /* SHA256_SUPPORT */
+
+#endif /* __CRYPT_SHA2_H__ */
diff --git a/drivers/staging/rt3090/dfs.h b/drivers/staging/rt3090/dfs.h
new file mode 100644
index 000000000000..506468ea952f
--- /dev/null
+++ b/drivers/staging/rt3090/dfs.h
@@ -0,0 +1,137 @@
+/*
+ *************************************************************************
+ * 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:
+ Miniport generic portion header file
+
+ 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
+
+
+
+/*************************************************************************
+ *
+ * DFS Radar related definitions.
+ *
+ ************************************************************************/
+//#define CARRIER_DETECT_TASK_NUM 6
+//#define RADAR_DETECT_TASK_NUM 7
+
+// McuRadarState && McuCarrierState for 2880-SW-MCU
+#define FREE_FOR_TX 0
+#define WAIT_CTS_BEING_SENT 1
+#define DO_DETECTION 2
+
+// McuRadarEvent
+#define RADAR_EVENT_CTS_SENT 0x01 // Host signal MCU that CTS has been sent
+#define RADAR_EVENT_CTS_CARRIER_SENT 0x02 // Host signal MCU that CTS has been sent (Carrier)
+#define RADAR_EVENT_RADAR_DETECTING 0x04 // Radar detection is on going, carrier detection hold back
+#define RADAR_EVENT_CARRIER_DETECTING 0x08 // Carrier detection is on going, radar detection hold back
+#define RADAR_EVENT_WIDTH_RADAR 0x10 // BBP == 2 radar detected
+#define RADAR_EVENT_CTS_KICKED 0x20 // Radar detection need to sent double CTS, first CTS sent
+
+// McuRadarCmd
+#define DETECTION_STOP 0
+#define RADAR_DETECTION 1
+#define CARRIER_DETECTION 2
+
+
+
+#ifdef TONE_RADAR_DETECT_SUPPORT
+INT Set_CarrierCriteria_Proc(IN PRTMP_ADAPTER pAd, IN PSTRING arg);
+int Set_CarrierReCheck_Proc(IN PRTMP_ADAPTER pAd, IN PSTRING arg);
+INT Set_CarrierStopCheck_Proc(IN PRTMP_ADAPTER pAd, IN PSTRING arg);
+void NewCarrierDetectionStart(PRTMP_ADAPTER pAd);
+void RTMPHandleRadarInterrupt(PRTMP_ADAPTER pAd);
+VOID CSAsicDisableSync(IN PRTMP_ADAPTER pAd);
+#endif // TONE_RADAR_DETECT_SUPPORT //
+
+
+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 PSTRING arg);
+
+INT Set_LongPulseRadarTh_Proc(
+ IN PRTMP_ADAPTER pAd,
+ IN PSTRING arg);
diff --git a/drivers/staging/rt3090/eeprom.h b/drivers/staging/rt3090/eeprom.h
new file mode 100644
index 000000000000..ee0e807decb4
--- /dev/null
+++ b/drivers/staging/rt3090/eeprom.h
@@ -0,0 +1,82 @@
+/*
+ *************************************************************************
+ * 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.h
+
+ Abstract:
+ Miniport generic portion header file
+
+ Revision History:
+ Who When What
+ -------- ---------- ----------------------------------------------
+*/
+#ifndef __EEPROM_H__
+#define __EEPROM_H__
+
+
+
+#ifdef RTMP_PCI_SUPPORT
+/*************************************************************************
+ * Public function declarations for prom-based chipset
+ ************************************************************************/
+int rtmp_ee_prom_read16(
+ IN PRTMP_ADAPTER pAd,
+ IN USHORT Offset,
+ OUT USHORT *pValue);
+
+int rtmp_ee_prom_write16(
+ IN PRTMP_ADAPTER pAd,
+ IN USHORT Offset,
+ IN USHORT value);
+#endif // RTMP_PCI_SUPPORT //
+
+
+
+
+
+#ifdef RT30xx
+#ifdef RTMP_EFUSE_SUPPORT
+int rtmp_ee_efuse_read16(
+ IN RTMP_ADAPTER *pAd,
+ IN USHORT Offset,
+ OUT USHORT *pValue);
+
+int rtmp_ee_efuse_write16(
+ IN RTMP_ADAPTER *pAd,
+ IN USHORT Offset,
+ IN USHORT data);
+#endif // RTMP_EFUSE_SUPPORT //
+#endif // RT30xx //
+
+/*************************************************************************
+ * Public function declarations for prom operation callback functions setting
+ ************************************************************************/
+INT RtmpChipOpsEepromHook(
+ IN RTMP_ADAPTER *pAd,
+ IN INT infType);
+
+#endif // __EEPROM_H__ //
diff --git a/drivers/staging/rt3090/firmware.h b/drivers/staging/rt3090/firmware.h
new file mode 100644
index 000000000000..f2836a22cb8e
--- /dev/null
+++ b/drivers/staging/rt3090/firmware.h
@@ -0,0 +1,517 @@
+/* AUTO GEN PLEASE DO NOT MODIFY IT */
+/* AUTO GEN PLEASE DO NOT MODIFY IT */
+
+
+UCHAR FirmwareImage [] = {
+0x02, 0x02, 0xf3, 0x02, 0x02, 0xa1, 0x22, 0x22, 0xff, 0xff, 0xff, 0x02, 0x01, 0x27, 0xff, 0xff,
+0xff, 0xff, 0xff, 0x02, 0x00, 0x1e, 0xff, 0xff, 0xff, 0xff, 0xff, 0x02, 0x00, 0xd8, 0xc0, 0xe0,
+0xc0, 0xf0, 0xc0, 0x83, 0xc0, 0x82, 0xc0, 0xd0, 0x75, 0xd0, 0x18, 0xc2, 0xaf, 0x30, 0x45, 0x03,
+0x12, 0x10, 0x09, 0x90, 0x04, 0x16, 0xe0, 0x30, 0xe3, 0x03, 0x74, 0x08, 0xf0, 0x90, 0x04, 0x14,
+0xe0, 0x20, 0xe7, 0x03, 0x02, 0x00, 0xcb, 0x74, 0x80, 0xf0, 0x90, 0x70, 0x12, 0xe0, 0xf5, 0x36,
+0x90, 0x04, 0x04, 0xe0, 0x24, 0xcf, 0x60, 0x30, 0x14, 0x60, 0x42, 0x24, 0xe2, 0x60, 0x47, 0x14,
+0x60, 0x55, 0x24, 0x21, 0x70, 0x60, 0xe5, 0x55, 0x24, 0xfe, 0x60, 0x07, 0x14, 0x60, 0x08, 0x24,
+0x02, 0x70, 0x08, 0x7d, 0x01, 0x80, 0x28, 0x7d, 0x02, 0x80, 0x24, 0x90, 0x70, 0x10, 0xe0, 0xf5,
+0x50, 0x85, 0x36, 0x40, 0xd2, 0x01, 0x80, 0x3e, 0xe5, 0x55, 0x64, 0x03, 0x60, 0x04, 0xe5, 0x55,
+0x70, 0x04, 0x7d, 0x02, 0x80, 0x09, 0x85, 0x36, 0x41, 0xd2, 0x02, 0x80, 0x29, 0xad, 0x55, 0xaf,
+0x36, 0x12, 0x02, 0x7d, 0x80, 0x20, 0x90, 0x70, 0x10, 0xe0, 0xf5, 0x47, 0x90, 0x70, 0x11, 0xe0,
+0xf5, 0x44, 0x12, 0x10, 0x25, 0x80, 0x06, 0x90, 0x70, 0x10, 0xe0, 0xf5, 0x45, 0xe4, 0xfd, 0xaf,
+0x36, 0x12, 0x02, 0x7d, 0xd2, 0x04, 0x90, 0x70, 0x13, 0xe4, 0xf0, 0xd2, 0xaf, 0xd0, 0xd0, 0xd0,
+0x82, 0xd0, 0x83, 0xd0, 0xf0, 0xd0, 0xe0, 0x32, 0xc0, 0xe0, 0xc0, 0xf0, 0xc0, 0x83, 0xc0, 0x82,
+0xc0, 0xd0, 0xe8, 0xc0, 0xe0, 0xe9, 0xc0, 0xe0, 0xea, 0xc0, 0xe0, 0xeb, 0xc0, 0xe0, 0xec, 0xc0,
+0xe0, 0xed, 0xc0, 0xe0, 0xee, 0xc0, 0xe0, 0xef, 0xc0, 0xe0, 0xc2, 0xaf, 0x30, 0x45, 0x03, 0x12,
+0x10, 0x12, 0xd2, 0xaf, 0xd0, 0xe0, 0xff, 0xd0, 0xe0, 0xfe, 0xd0, 0xe0, 0xfd, 0xd0, 0xe0, 0xfc,
+0xd0, 0xe0, 0xfb, 0xd0, 0xe0, 0xfa, 0xd0, 0xe0, 0xf9, 0xd0, 0xe0, 0xf8, 0xd0, 0xd0, 0xd0, 0x82,
+0xd0, 0x83, 0xd0, 0xf0, 0xd0, 0xe0, 0x32, 0xc0, 0xe0, 0xc0, 0xf0, 0xc0, 0x83, 0xc0, 0x82, 0xc0,
+0xd0, 0x75, 0xd0, 0x10, 0xc2, 0xaf, 0x30, 0x45, 0x03, 0x12, 0x10, 0x0c, 0x30, 0x58, 0x0a, 0xe5,
+0x54, 0x60, 0x04, 0x15, 0x54, 0x80, 0x02, 0xc2, 0x58, 0x30, 0x59, 0x0a, 0xe5, 0x50, 0x60, 0x04,
+0x15, 0x50, 0x80, 0x02, 0xc2, 0x59, 0xd5, 0x53, 0x07, 0x30, 0x60, 0x04, 0x15, 0x46, 0xd2, 0x04,
+0x30, 0x45, 0x03, 0x12, 0x10, 0x0f, 0xc2, 0x8d, 0xd2, 0xaf, 0xd0, 0xd0, 0xd0, 0x82, 0xd0, 0x83,
+0xd0, 0xf0, 0xd0, 0xe0, 0x32, 0x90, 0x70, 0x2a, 0xe0, 0x30, 0xe1, 0x43, 0xc2, 0xaf, 0x90, 0x70,
+0x28, 0xe0, 0x90, 0x10, 0x1c, 0xf0, 0x90, 0x70, 0x29, 0xe0, 0x90, 0x10, 0x1d, 0xf0, 0x90, 0x70,
+0x2a, 0xe0, 0x90, 0x10, 0x1e, 0xf0, 0x90, 0x10, 0x1c, 0xe0, 0xf5, 0x37, 0x90, 0x10, 0x1e, 0xe0,
+0x20, 0xe1, 0xf3, 0x90, 0x10, 0x1c, 0xe0, 0x90, 0x70, 0x28, 0xf0, 0x90, 0x10, 0x1d, 0xe0, 0x90,
+0x70, 0x29, 0xf0, 0x90, 0x10, 0x1e, 0xe0, 0x90, 0x70, 0x2a, 0xf0, 0xc2, 0x05, 0xd2, 0xaf, 0x22,
+0x12, 0x02, 0xc3, 0x30, 0x45, 0x03, 0x12, 0x10, 0x03, 0x30, 0x01, 0x06, 0x20, 0x09, 0x03, 0x12,
+0x10, 0x1c, 0x30, 0x02, 0x06, 0x20, 0x0a, 0x03, 0x12, 0x10, 0x1f, 0x30, 0x03, 0x06, 0x20, 0x0b,
+0x03, 0x12, 0x10, 0x1f, 0x30, 0x04, 0x06, 0x20, 0x0c, 0x03, 0x12, 0x10, 0x22, 0x20, 0x13, 0x09,
+0x20, 0x11, 0x06, 0xe5, 0x2b, 0x45, 0x2c, 0x60, 0x03, 0xd3, 0x80, 0x01, 0xc3, 0x92, 0xa9, 0x12,
+0x03, 0x1c, 0x80, 0xbf, 0xc2, 0x43, 0xd2, 0x45, 0xe4, 0xf5, 0x20, 0xf5, 0x21, 0xf5, 0x53, 0xf5,
+0x46, 0xf5, 0x2b, 0xf5, 0x2c, 0xc2, 0x42, 0xf5, 0x51, 0xf5, 0x52, 0xf5, 0x55, 0x90, 0x04, 0x18,
+0x74, 0x80, 0xf0, 0x90, 0x04, 0x1a, 0x74, 0x08, 0xf0, 0xc2, 0x1a, 0xc2, 0x18, 0xc2, 0x1b, 0x22,
+0xc8, 0xef, 0xc8, 0xe6, 0xfa, 0x08, 0xe6, 0x4a, 0x60, 0x0c, 0xc8, 0xef, 0xc8, 0x08, 0xe6, 0x16,
+0x18, 0x70, 0x01, 0x16, 0xc3, 0x22, 0xed, 0x24, 0xff, 0xfd, 0xec, 0x34, 0xff, 0xc8, 0xef, 0xc8,
+0xf6, 0x08, 0xc6, 0xed, 0xc6, 0xd3, 0x22, 0xd0, 0x83, 0xd0, 0x82, 0xf8, 0xe4, 0x93, 0x70, 0x12,
+0x74, 0x01, 0x93, 0x70, 0x0d, 0xa3, 0xa3, 0x93, 0xf8, 0x74, 0x01, 0x93, 0xf5, 0x82, 0x88, 0x83,
+0xe4, 0x73, 0x74, 0x02, 0x93, 0x68, 0x60, 0xef, 0xa3, 0xa3, 0xa3, 0x80, 0xdf, 0xef, 0xf4, 0x60,
+0x1f, 0xe4, 0xfe, 0x12, 0x03, 0x5b, 0xe0, 0xb4, 0xff, 0x12, 0x12, 0x03, 0x5b, 0xef, 0xf0, 0x74,
+0x1c, 0x2e, 0xf5, 0x82, 0xe4, 0x34, 0x70, 0xf5, 0x83, 0xed, 0xf0, 0x22, 0x0e, 0xbe, 0x04, 0xe3,
+0x22, 0xc0, 0xe0, 0xc0, 0xf0, 0xc0, 0x83, 0xc0, 0x82, 0xc0, 0xd0, 0x75, 0xd0, 0x08, 0xc2, 0xaf,
+0x30, 0x45, 0x03, 0x12, 0x10, 0x06, 0xd2, 0xaf, 0xd0, 0xd0, 0xd0, 0x82, 0xd0, 0x83, 0xd0, 0xf0,
+0xd0, 0xe0, 0x32, 0xc2, 0xaf, 0x12, 0x00, 0x06, 0x12, 0x02, 0x04, 0x12, 0x02, 0xdc, 0xe4, 0xf5,
+0x22, 0xf5, 0x47, 0x90, 0x04, 0x00, 0x74, 0x80, 0xf0, 0xd2, 0xaf, 0x22, 0x75, 0x89, 0x02, 0xe4,
+0xf5, 0x8c, 0xf5, 0x8a, 0xf5, 0x88, 0xf5, 0xb8, 0xf5, 0xe8, 0x75, 0x90, 0x18, 0xd2, 0x8c, 0x75,
+0xa8, 0x05, 0x22, 0x78, 0x7f, 0xe4, 0xf6, 0xd8, 0xfd, 0x75, 0x81, 0x5f, 0x02, 0x01, 0xc0, 0xff,
+0xc0, 0x26, 0x74, 0x03, 0xc0, 0xe0, 0xc0, 0x82, 0xc0, 0x83, 0x75, 0x26, 0x0a, 0x22, 0xc0, 0x26,
+0x74, 0x03, 0xc0, 0xe0, 0xc0, 0x82, 0xc0, 0x83, 0x75, 0x26, 0x18, 0x22, 0x30, 0x45, 0x03, 0x12,
+0x10, 0x15, 0xe5, 0x20, 0x70, 0x03, 0x20, 0x10, 0x03, 0x30, 0x11, 0x03, 0x43, 0x87, 0x01, 0x22,
+0xce, 0xef, 0xce, 0xee, 0x60, 0x08, 0x7f, 0xff, 0x12, 0x03, 0x71, 0x1e, 0x80, 0xf5, 0x22, 0xc8,
+0xef, 0xc8, 0xe6, 0x60, 0x03, 0x16, 0xc3, 0x22, 0xed, 0x14, 0xf6, 0xd3, 0x22, 0xc8, 0xef, 0xc8,
+0xe6, 0x60, 0x06, 0x16, 0xe6, 0x24, 0xff, 0xb3, 0x22, 0xc3, 0x22, 0x74, 0x14, 0x2e, 0xf5, 0x82,
+0xe4, 0x34, 0x70, 0xf5, 0x83, 0x22, 0xef, 0x90, 0x03, 0x6f, 0x93, 0x90, 0x03, 0x00, 0x73, 0x0a,
+0x18, 0xef, 0x60, 0x03, 0x1f, 0x80, 0xfa, 0x22, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff,
+0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff,
+0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff,
+0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff,
+0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff,
+0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff,
+0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff,
+0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff,
+0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff,
+0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff,
+0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff,
+0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff,
+0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff,
+0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff,
+0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff,
+0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff,
+0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff,
+0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff,
+0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff,
+0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff,
+0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff,
+0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff,
+0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff,
+0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff,
+0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff,
+0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff,
+0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff,
+0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff,
+0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff,
+0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff,
+0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff,
+0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff,
+0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff,
+0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff,
+0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff,
+0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff,
+0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff,
+0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff,
+0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff,
+0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff,
+0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff,
+0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff,
+0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff,
+0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff,
+0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff,
+0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff,
+0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff,
+0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff,
+0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff,
+0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff,
+0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff,
+0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff,
+0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff,
+0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff,
+0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff,
+0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff,
+0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff,
+0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff,
+0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff,
+0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff,
+0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff,
+0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff,
+0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff,
+0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff,
+0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff,
+0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff,
+0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff,
+0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff,
+0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff,
+0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff,
+0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff,
+0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff,
+0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff,
+0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff,
+0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff,
+0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff,
+0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff,
+0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff,
+0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff,
+0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff,
+0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff,
+0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff,
+0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff,
+0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff,
+0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff,
+0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff,
+0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff,
+0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff,
+0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff,
+0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff,
+0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff,
+0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff,
+0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff,
+0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff,
+0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff,
+0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff,
+0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff,
+0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff,
+0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff,
+0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff,
+0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff,
+0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff,
+0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff,
+0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff,
+0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff,
+0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff,
+0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff,
+0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff,
+0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff,
+0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff,
+0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff,
+0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff,
+0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff,
+0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff,
+0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff,
+0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff,
+0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff,
+0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff,
+0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff,
+0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff,
+0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff,
+0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff,
+0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff,
+0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff,
+0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff,
+0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff,
+0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff,
+0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff,
+0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff,
+0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff,
+0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff,
+0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff,
+0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff,
+0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff,
+0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff,
+0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff,
+0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff,
+0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff,
+0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff,
+0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff,
+0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff,
+0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff,
+0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff,
+0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff,
+0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff,
+0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff,
+0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff,
+0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff,
+0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff,
+0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff,
+0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff,
+0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff,
+0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff,
+0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff,
+0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff,
+0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff,
+0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff,
+0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff,
+0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff,
+0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff,
+0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff,
+0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff,
+0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff,
+0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff,
+0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff,
+0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff,
+0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff,
+0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff,
+0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff,
+0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff,
+0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff,
+0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff,
+0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff,
+0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff,
+0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff,
+0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff,
+0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff,
+0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff,
+0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff,
+0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff,
+0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff,
+0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff,
+0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff,
+0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff,
+0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff,
+0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff,
+0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff,
+0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff,
+0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff,
+0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff,
+0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff,
+0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff,
+0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff,
+0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff,
+0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff,
+0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff,
+0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff,
+0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff,
+0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff,
+0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff,
+0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff,
+0xff, 0xff, 0xff, 0x02, 0x10, 0x28, 0x02, 0x10, 0x3b, 0x02, 0x10, 0x3c, 0x02, 0x13, 0x68, 0x02,
+0x13, 0x69, 0x02, 0x14, 0x1e, 0x02, 0x14, 0x1f, 0xc3, 0x22, 0xff, 0xff, 0x02, 0x19, 0xa1, 0x02,
+0x1b, 0x31, 0x02, 0x14, 0xea, 0x02, 0x14, 0x20, 0x30, 0x05, 0x06, 0x20, 0x0d, 0x03, 0x12, 0x01,
+0x75, 0x30, 0x06, 0x06, 0x20, 0x0e, 0x03, 0x12, 0x1c, 0x4f, 0x22, 0x22, 0x90, 0x04, 0x14, 0xe0,
+0x20, 0xe7, 0x03, 0x02, 0x13, 0x67, 0x90, 0x70, 0x12, 0xe0, 0xf5, 0x56, 0x90, 0x04, 0x04, 0xe0,
+0x12, 0x02, 0x57, 0x11, 0x11, 0x30, 0x10, 0xe2, 0x31, 0x10, 0x90, 0x33, 0x10, 0xa0, 0x34, 0x10,
+0xbe, 0x35, 0x10, 0xac, 0x36, 0x11, 0x1f, 0x50, 0x11, 0x68, 0x51, 0x11, 0x71, 0x52, 0x11, 0x71,
+0x53, 0x11, 0x71, 0x54, 0x11, 0xb3, 0x55, 0x12, 0x16, 0x70, 0x12, 0x42, 0x71, 0x12, 0x71, 0x72,
+0x12, 0xda, 0x73, 0x12, 0xfe, 0x80, 0x13, 0x29, 0x83, 0x13, 0x47, 0x84, 0x00, 0x00, 0x13, 0x67,
+0xd2, 0x18, 0xd2, 0x61, 0x75, 0x35, 0x2a, 0x75, 0x32, 0x0b, 0x75, 0x33, 0xb8, 0x02, 0x13, 0x62,
+0xc2, 0x18, 0x90, 0x01, 0x14, 0xe0, 0x54, 0xfd, 0xf0, 0x02, 0x13, 0x62, 0x90, 0x70, 0x11, 0xe0,
+0xf5, 0x3c, 0xe4, 0x90, 0x70, 0x13, 0xf0, 0x90, 0x04, 0x14, 0x74, 0x80, 0xf0, 0x22, 0xe5, 0x55,
+0xb4, 0x02, 0x0f, 0xe5, 0x59, 0xb4, 0x28, 0x06, 0x90, 0x01, 0x0d, 0x74, 0x08, 0xf0, 0x7d, 0x01,
+0x80, 0x02, 0x7d, 0x02, 0xaf, 0x56, 0x12, 0x02, 0x7d, 0x90, 0x04, 0x14, 0x74, 0x80, 0xf0, 0x02,
+0x13, 0x62, 0x20, 0x02, 0x03, 0x30, 0x03, 0x10, 0x7d, 0x02, 0xaf, 0x56, 0x12, 0x02, 0x7d, 0x90,
+0x04, 0x14, 0x74, 0x80, 0xf0, 0x02, 0x13, 0x62, 0xe5, 0x34, 0xc3, 0x94, 0x03, 0x40, 0x0c, 0x90,
+0x01, 0x0c, 0xe0, 0x44, 0x02, 0xf0, 0xa3, 0xe0, 0x44, 0x04, 0xf0, 0x85, 0x56, 0x41, 0xd2, 0x02,
+0x22, 0x90, 0x70, 0x11, 0xe0, 0xf4, 0x70, 0x03, 0x02, 0x13, 0x67, 0xe0, 0xf5, 0x30, 0x22, 0xe5,
+0x34, 0xc3, 0x94, 0x03, 0x40, 0x07, 0xe5, 0x55, 0x60, 0x03, 0x02, 0x13, 0x67, 0x90, 0x70, 0x10,
+0xe0, 0x54, 0x7f, 0xff, 0xbf, 0x0a, 0x0d, 0x90, 0x70, 0x11, 0xe0, 0xb4, 0x08, 0x06, 0x75, 0x4e,
+0x01, 0x75, 0x4f, 0x84, 0x90, 0x70, 0x10, 0xe0, 0x54, 0x7f, 0x64, 0x02, 0x60, 0x03, 0x02, 0x13,
+0x67, 0x90, 0x70, 0x11, 0xe0, 0x64, 0x08, 0x60, 0x08, 0xe0, 0x64, 0x20, 0x60, 0x03, 0x02, 0x13,
+0x67, 0x75, 0x4e, 0x03, 0x75, 0x4f, 0x20, 0x22, 0x90, 0x70, 0x11, 0xe0, 0x24, 0xff, 0x92, 0x47,
+0x22, 0xe5, 0x34, 0xc3, 0x94, 0x03, 0x40, 0x07, 0xe5, 0x55, 0x60, 0x03, 0x02, 0x13, 0x09, 0x90,
+0x04, 0x04, 0xe0, 0x25, 0xe0, 0x24, 0x5d, 0xf5, 0x57, 0x90, 0x70, 0x10, 0xe0, 0xff, 0x74, 0x47,
+0x25, 0x57, 0xf8, 0xc6, 0xef, 0xc6, 0x90, 0x70, 0x11, 0xe0, 0xff, 0x74, 0x48, 0x25, 0x57, 0xf8,
+0xc6, 0xef, 0xc6, 0xe4, 0xfd, 0xaf, 0x56, 0x12, 0x02, 0x7d, 0x90, 0x04, 0x14, 0x74, 0x80, 0xf0,
+0x02, 0x13, 0x62, 0xe5, 0x34, 0xc3, 0x94, 0x03, 0x40, 0x07, 0xe5, 0x55, 0x60, 0x03, 0x02, 0x13,
+0x09, 0xe5, 0x47, 0x64, 0x07, 0x60, 0x23, 0xe5, 0x47, 0x64, 0x08, 0x60, 0x1d, 0xe5, 0x47, 0x64,
+0x09, 0x60, 0x17, 0xe5, 0x47, 0x64, 0x0a, 0x60, 0x11, 0xe5, 0x47, 0x64, 0x0b, 0x60, 0x0b, 0xe5,
+0x47, 0x64, 0x0d, 0x60, 0x05, 0xe5, 0x47, 0xb4, 0x0d, 0x08, 0x90, 0x70, 0x11, 0xe0, 0x54, 0x0f,
+0xf5, 0x3a, 0xe5, 0x47, 0xb4, 0x09, 0x08, 0xe5, 0x3a, 0xb4, 0x03, 0x03, 0xe4, 0xf5, 0x46, 0xe5,
+0x47, 0xb4, 0x0a, 0x08, 0xe5, 0x3a, 0xb4, 0x01, 0x03, 0xe4, 0xf5, 0x46, 0xe4, 0xfd, 0xaf, 0x56,
+0x12, 0x02, 0x7d, 0xd2, 0x04, 0x22, 0xe5, 0x34, 0xc3, 0x94, 0x03, 0x40, 0x07, 0xe5, 0x55, 0x60,
+0x03, 0x02, 0x13, 0x09, 0x90, 0x70, 0x10, 0xe0, 0xfe, 0x90, 0x70, 0x11, 0xe0, 0xfd, 0xed, 0xf8,
+0xe6, 0xf5, 0x57, 0xfd, 0xaf, 0x56, 0x12, 0x02, 0x7d, 0x90, 0x04, 0x14, 0x74, 0x80, 0xf0, 0x02,
+0x13, 0x62, 0xe5, 0x34, 0xc3, 0x94, 0x03, 0x40, 0x07, 0xe5, 0x55, 0x60, 0x03, 0x02, 0x13, 0x09,
+0x90, 0x70, 0x10, 0xe0, 0xfe, 0x90, 0x70, 0x11, 0xe0, 0xfd, 0xed, 0xf5, 0x82, 0x8e, 0x83, 0xe0,
+0xf5, 0x57, 0xfd, 0xaf, 0x56, 0x12, 0x02, 0x7d, 0x90, 0x04, 0x14, 0x74, 0x80, 0xf0, 0x02, 0x13,
+0x62, 0x90, 0x10, 0x00, 0xe0, 0xf5, 0x57, 0x90, 0x10, 0x02, 0xe0, 0xf5, 0x58, 0xa3, 0xe0, 0xf5,
+0x59, 0xe5, 0x58, 0xb4, 0x70, 0x1e, 0xe5, 0x59, 0xb4, 0x30, 0x19, 0x90, 0x05, 0x08, 0xe0, 0x44,
+0x01, 0xf0, 0xfd, 0x90, 0x05, 0x05, 0xe0, 0x54, 0xfb, 0xf0, 0x44, 0x04, 0xf0, 0xed, 0x54, 0xfe,
+0x90, 0x05, 0x08, 0xf0, 0xe4, 0xf5, 0x4e, 0xf5, 0x4f, 0x75, 0x3a, 0xff, 0xc2, 0x1a, 0xc2, 0x18,
+0xc2, 0x1b, 0xf5, 0x34, 0x90, 0x05, 0xa4, 0x74, 0x11, 0xf0, 0xa3, 0x74, 0xff, 0xf0, 0xa3, 0x74,
+0x03, 0xf0, 0xe4, 0xf5, 0x30, 0xc2, 0x19, 0x75, 0x3c, 0xff, 0xad, 0x57, 0xaf, 0x56, 0x12, 0x02,
+0x7d, 0x90, 0x04, 0x14, 0x74, 0x80, 0xf0, 0x02, 0x13, 0x62, 0xe5, 0x34, 0xc3, 0x94, 0x03, 0x40,
+0x06, 0xe5, 0x55, 0x60, 0x02, 0x80, 0x22, 0x90, 0x70, 0x10, 0xe0, 0x24, 0xff, 0x92, 0x93, 0xe4,
+0xfd, 0xaf, 0x56, 0x12, 0x02, 0x7d, 0x90, 0x04, 0x14, 0x74, 0x80, 0xf0, 0x80, 0x64, 0xe5, 0x34,
+0xc3, 0x94, 0x03, 0x40, 0x0b, 0xe5, 0x55, 0x60, 0x07, 0x7d, 0x03, 0xaf, 0x56, 0x02, 0x02, 0x7d,
+0x90, 0x70, 0x10, 0xe0, 0x24, 0xff, 0x92, 0x4a, 0xd2, 0x05, 0xad, 0x57, 0xaf, 0x56, 0x12, 0x02,
+0x7d, 0x90, 0x04, 0x14, 0x74, 0x80, 0xf0, 0x80, 0x39, 0xe4, 0xf5, 0x34, 0xf5, 0x30, 0x90, 0x70,
+0x10, 0xe0, 0xf4, 0x60, 0x03, 0xe0, 0xf5, 0x34, 0xad, 0x57, 0xaf, 0x56, 0x12, 0x02, 0x7d, 0x90,
+0x04, 0x14, 0x74, 0x80, 0xf0, 0x80, 0x1b, 0xd2, 0x19, 0x05, 0x2f, 0xe5, 0x2f, 0xb4, 0x1a, 0x03,
+0xe4, 0xf5, 0x2f, 0xd2, 0x04, 0xad, 0x57, 0xaf, 0x56, 0x12, 0x02, 0x7d, 0x90, 0x04, 0x14, 0x74,
+0x80, 0xf0, 0xe4, 0x90, 0x70, 0x13, 0xf0, 0x22, 0x22, 0xe5, 0x34, 0xc3, 0x94, 0x03, 0x40, 0x17,
+0xe5, 0x55, 0xb4, 0x02, 0x12, 0xe5, 0x30, 0x60, 0x0e, 0x30, 0x60, 0x0b, 0x74, 0xfd, 0x25, 0x46,
+0xf5, 0x46, 0xd2, 0x04, 0xe4, 0xf5, 0x53, 0xe5, 0x53, 0x60, 0x03, 0x02, 0x14, 0x1d, 0x30, 0x60,
+0x21, 0xb2, 0x4d, 0x30, 0x4d, 0x1c, 0xe5, 0x34, 0xc3, 0x94, 0x03, 0x40, 0x11, 0xe5, 0x55, 0xb4,
+0x02, 0x0c, 0xe5, 0x30, 0x60, 0x08, 0x74, 0x03, 0x25, 0x46, 0xf5, 0x46, 0x80, 0x02, 0x05, 0x46,
+0xc2, 0x04, 0xe5, 0x4f, 0x45, 0x4e, 0x60, 0x08, 0xe5, 0x4f, 0x15, 0x4f, 0x70, 0x02, 0x15, 0x4e,
+0x30, 0x1a, 0x49, 0x7f, 0x32, 0x7d, 0xb8, 0x7c, 0x0b, 0x12, 0x02, 0x30, 0x50, 0x06, 0x90, 0x04,
+0x10, 0x74, 0x40, 0xf0, 0x7f, 0x35, 0x7d, 0x32, 0x12, 0x03, 0x3f, 0x50, 0x09, 0x90, 0x10, 0x04,
+0xe0, 0x54, 0xf7, 0xf0, 0xd2, 0x06, 0xe5, 0x35, 0xd3, 0x94, 0x2d, 0x40, 0x30, 0x30, 0x1b, 0x2d,
+0xc2, 0x1b, 0xa2, 0x18, 0x92, 0x1a, 0x20, 0x1a, 0x24, 0x90, 0x04, 0x09, 0xe0, 0x54, 0xdd, 0xf0,
+0x90, 0x10, 0x04, 0xe0, 0x44, 0x08, 0xf0, 0xc2, 0x61, 0xd2, 0x03, 0x22, 0xe4, 0xf5, 0x35, 0xa2,
+0x18, 0x92, 0x1a, 0x30, 0x1a, 0x07, 0x90, 0x04, 0x09, 0xe0, 0x44, 0x22, 0xf0, 0x22, 0x22, 0x22,
+0xc2, 0x4b, 0xc2, 0x4c, 0xe5, 0x44, 0x12, 0x02, 0x57, 0x14, 0x42, 0x00, 0x14, 0xd5, 0x04, 0x14,
+0xd1, 0x08, 0x14, 0xac, 0x10, 0x14, 0x56, 0x20, 0x14, 0x76, 0x60, 0x14, 0x87, 0xa0, 0x00, 0x00,
+0x14, 0xd7, 0x85, 0x48, 0x43, 0x85, 0x4a, 0x42, 0x85, 0x4c, 0x5e, 0xe5, 0x47, 0x64, 0x06, 0x60,
+0x03, 0x02, 0x14, 0xd7, 0x80, 0x1b, 0xe5, 0x48, 0xc4, 0x54, 0x0f, 0xf5, 0x43, 0xe5, 0x4a, 0xc4,
+0x54, 0x0f, 0xf5, 0x42, 0xe5, 0x4c, 0xc4, 0x54, 0x0f, 0xf5, 0x5e, 0xe5, 0x47, 0x64, 0x06, 0x70,
+0x66, 0x53, 0x43, 0x0f, 0x80, 0x61, 0x85, 0x49, 0x43, 0x85, 0x4b, 0x42, 0x85, 0x4d, 0x5e, 0xe5,
+0x47, 0x64, 0x06, 0x70, 0x52, 0x80, 0x1b, 0xe5, 0x49, 0xc4, 0x54, 0x0f, 0xf5, 0x43, 0xe5, 0x4b,
+0xc4, 0x54, 0x0f, 0xf5, 0x42, 0xe5, 0x4d, 0xc4, 0x54, 0x0f, 0xf5, 0x5e, 0xe5, 0x47, 0x64, 0x06,
+0x70, 0x35, 0xe5, 0x43, 0x54, 0x0f, 0x44, 0x10, 0xf5, 0x43, 0x80, 0x2b, 0xe5, 0x47, 0xb4, 0x04,
+0x06, 0x53, 0x5e, 0xfb, 0x75, 0x42, 0x09, 0xe5, 0x47, 0xb4, 0x05, 0x06, 0x43, 0x5e, 0x04, 0x75,
+0x42, 0x09, 0xe5, 0x47, 0xb4, 0x06, 0x10, 0xe5, 0x43, 0x54, 0x0f, 0x44, 0x30, 0xf5, 0x43, 0x80,
+0x06, 0xd2, 0x4b, 0x80, 0x02, 0xd2, 0x4c, 0xe4, 0xf5, 0x2a, 0xe5, 0x42, 0xc4, 0x54, 0xf0, 0xff,
+0xe5, 0x43, 0x54, 0x0f, 0x4f, 0xf5, 0x5f, 0xd2, 0x60, 0x22, 0xe5, 0x47, 0x60, 0x1a, 0x24, 0xc0,
+0x60, 0x0a, 0x24, 0x35, 0x70, 0x09, 0x12, 0x19, 0x5f, 0x12, 0x15, 0x09, 0x12, 0x19, 0x5f, 0x12,
+0x15, 0x09, 0xc2, 0xaf, 0xc2, 0x04, 0xd2, 0xaf, 0x22, 0xc2, 0xaf, 0x90, 0x04, 0x14, 0xe0, 0x54,
+0x0e, 0x60, 0x04, 0xd2, 0x1c, 0x80, 0x08, 0xe5, 0x4e, 0x45, 0x4f, 0x24, 0xff, 0x92, 0x1c, 0xd2,
+0xaf, 0x90, 0x04, 0x14, 0xe0, 0xa2, 0xe4, 0x92, 0x1d, 0x74, 0x1e, 0xf0, 0xe5, 0x5f, 0x54, 0x0f,
+0xf5, 0x2d, 0xe5, 0x2a, 0x70, 0x13, 0x30, 0x1c, 0x05, 0xe5, 0x5f, 0x20, 0xe5, 0x0b, 0x30, 0x1d,
+0x29, 0xe5, 0x5f, 0x54, 0x30, 0x64, 0x30, 0x70, 0x21, 0xe5, 0x2a, 0x70, 0x15, 0xe5, 0x34, 0xc3,
+0x94, 0x03, 0x40, 0x09, 0xe5, 0x30, 0x60, 0x05, 0x75, 0x2a, 0x05, 0x80, 0x07, 0x75, 0x2a, 0x0c,
+0x80, 0x02, 0x15, 0x2a, 0xd2, 0x6c, 0xd2, 0x6d, 0x80, 0x0f, 0xe5, 0x5f, 0x30, 0xe6, 0x06, 0xc2,
+0x6c, 0xd2, 0x6d, 0x80, 0x04, 0xd2, 0x6c, 0xc2, 0x6d, 0xe5, 0x47, 0x64, 0x03, 0x70, 0x21, 0x30,
+0x4b, 0x06, 0xc2, 0x6c, 0xd2, 0x6d, 0x80, 0x18, 0xe5, 0x2a, 0x70, 0x03, 0x30, 0x4c, 0x11, 0xc2,
+0x4c, 0xe5, 0x2a, 0x70, 0x05, 0x75, 0x2a, 0x07, 0x80, 0x02, 0x15, 0x2a, 0xd2, 0x6c, 0xd2, 0x6d,
+0xe5, 0x47, 0xb4, 0x09, 0x14, 0xe5, 0x44, 0x20, 0xe3, 0x0b, 0xe5, 0x3a, 0x64, 0x02, 0x60, 0x05,
+0xe5, 0x3a, 0xb4, 0x03, 0x04, 0xc2, 0x6c, 0xd2, 0x6d, 0xe5, 0x47, 0xb4, 0x0a, 0x13, 0xe5, 0x3a,
+0xb4, 0x01, 0x06, 0xc2, 0x6c, 0xd2, 0x6d, 0x80, 0x08, 0xe5, 0x3a, 0x70, 0x04, 0xd2, 0x6c, 0xc2,
+0x6d, 0x20, 0x69, 0x07, 0xe5, 0x5e, 0x20, 0xe0, 0x02, 0xb2, 0x68, 0x20, 0x6b, 0x07, 0xe5, 0x5e,
+0x20, 0xe1, 0x02, 0xb2, 0x6a, 0x20, 0x6d, 0x07, 0xe5, 0x5e, 0x20, 0xe2, 0x02, 0xb2, 0x6c, 0x75,
+0x2e, 0x40, 0x20, 0x69, 0x04, 0xa2, 0x68, 0x80, 0x45, 0x30, 0x68, 0x06, 0xe5, 0x46, 0xa2, 0xe2,
+0x80, 0x3c, 0x30, 0x19, 0x1c, 0xe5, 0x5e, 0x20, 0xe2, 0x04, 0x7f, 0x01, 0x80, 0x02, 0x7f, 0x00,
+0xe5, 0x2f, 0xb4, 0x19, 0x04, 0x7e, 0x01, 0x80, 0x02, 0x7e, 0x00, 0xee, 0x6f, 0x24, 0xff, 0x80,
+0x1d, 0xe5, 0x5e, 0x20, 0xe2, 0x04, 0x7f, 0x01, 0x80, 0x02, 0x7f, 0x00, 0xe5, 0x46, 0x54, 0xf0,
+0xfe, 0xbe, 0xf0, 0x04, 0x7e, 0x01, 0x80, 0x02, 0x7e, 0x00, 0xee, 0x6f, 0x24, 0xff, 0x92, 0x73,
+0x92, 0x72, 0x20, 0x6b, 0x04, 0xa2, 0x6a, 0x80, 0x45, 0x30, 0x6a, 0x06, 0xe5, 0x46, 0xa2, 0xe2,
+0x80, 0x3c, 0x30, 0x19, 0x1c, 0xe5, 0x5e, 0x20, 0xe0, 0x04, 0x7f, 0x01, 0x80, 0x02, 0x7f, 0x00,
+0xe5, 0x2f, 0xb4, 0x19, 0x04, 0x7e, 0x01, 0x80, 0x02, 0x7e, 0x00, 0xee, 0x6f, 0x24, 0xff, 0x80,
+0x1d, 0xe5, 0x5e, 0x20, 0xe0, 0x04, 0x7f, 0x01, 0x80, 0x02, 0x7f, 0x00, 0xe5, 0x46, 0x54, 0xf0,
+0xfe, 0xbe, 0xf0, 0x04, 0x7e, 0x01, 0x80, 0x02, 0x7e, 0x00, 0xee, 0x6f, 0x24, 0xff, 0x92, 0x75,
+0x92, 0x74, 0x20, 0x6d, 0x04, 0xa2, 0x6c, 0x80, 0x64, 0xe5, 0x47, 0x64, 0x0a, 0x70, 0x19, 0xe5,
+0x3a, 0xb4, 0x01, 0x06, 0xe5, 0x46, 0xa2, 0xe3, 0x80, 0x53, 0xe5, 0x46, 0x20, 0xe4, 0x03, 0x30,
+0xe5, 0x03, 0xd3, 0x80, 0x01, 0xc3, 0x80, 0x45, 0x30, 0x6c, 0x06, 0xe5, 0x46, 0xa2, 0xe2, 0x80,
+0x3c, 0x30, 0x19, 0x1c, 0xe5, 0x5e, 0x20, 0xe1, 0x04, 0x7f, 0x01, 0x80, 0x02, 0x7f, 0x00, 0xe5,
+0x2f, 0xb4, 0x19, 0x04, 0x7e, 0x01, 0x80, 0x02, 0x7e, 0x00, 0xee, 0x6f, 0x24, 0xff, 0x80, 0x1d,
+0xe5, 0x5e, 0x20, 0xe1, 0x04, 0x7f, 0x01, 0x80, 0x02, 0x7f, 0x00, 0xe5, 0x46, 0x54, 0xf0, 0xfe,
+0xbe, 0xf0, 0x04, 0x7e, 0x01, 0x80, 0x02, 0x7e, 0x00, 0xee, 0x6f, 0x24, 0xff, 0x92, 0x71, 0x92,
+0x70, 0x90, 0x10, 0x00, 0xe0, 0x90, 0x10, 0x2c, 0xf0, 0x90, 0x10, 0x03, 0xe0, 0xc3, 0x94, 0x30,
+0x40, 0x14, 0xa2, 0x71, 0x92, 0x77, 0xa2, 0x70, 0x92, 0x76, 0xe5, 0x2e, 0x13, 0x13, 0x54, 0x3f,
+0xf5, 0x2e, 0xc2, 0x77, 0xd2, 0x76, 0x90, 0x10, 0x2f, 0xe5, 0x2e, 0xf0, 0xe5, 0x47, 0x64, 0x06,
+0x70, 0x46, 0x90, 0x02, 0x29, 0xe0, 0x54, 0xfe, 0xf0, 0xe5, 0x43, 0xc4, 0x54, 0x0f, 0x14, 0x60,
+0x14, 0x24, 0xfe, 0x60, 0x1f, 0x24, 0x03, 0x60, 0x03, 0x02, 0x19, 0x5e, 0x90, 0x02, 0x28, 0xe0,
+0x30, 0x47, 0x0d, 0x80, 0x07, 0x90, 0x02, 0x28, 0xe0, 0x20, 0x47, 0x04, 0x54, 0xfe, 0xf0, 0x22,
+0x44, 0x01, 0xf0, 0x22, 0xe5, 0x46, 0x30, 0xe2, 0x04, 0x7f, 0x01, 0x80, 0x02, 0x7f, 0x00, 0x90,
+0x02, 0x28, 0xe0, 0x54, 0xfe, 0x4f, 0xf0, 0x22, 0xe5, 0x47, 0x64, 0x07, 0x60, 0x0f, 0xe5, 0x47,
+0x64, 0x08, 0x60, 0x09, 0xe5, 0x47, 0x64, 0x09, 0x60, 0x03, 0x02, 0x18, 0x27, 0xe4, 0xf5, 0x27,
+0x90, 0x02, 0x29, 0xe0, 0x54, 0xfc, 0xf0, 0xe5, 0x3a, 0x14, 0x60, 0x2d, 0x14, 0x60, 0x2e, 0x14,
+0x60, 0x36, 0x24, 0xfc, 0x60, 0x5f, 0x24, 0xf9, 0x60, 0x1f, 0x24, 0x0e, 0x70, 0x69, 0xe5, 0x46,
+0x13, 0x13, 0x54, 0x3f, 0x75, 0xf0, 0x03, 0x84, 0xaf, 0xf0, 0x20, 0x47, 0x04, 0x7e, 0x01, 0x80,
+0x02, 0x7e, 0x00, 0xef, 0x6e, 0x24, 0xff, 0x80, 0x45, 0xa2, 0x47, 0x80, 0x41, 0xe5, 0x46, 0x30,
+0xe2, 0x03, 0xd3, 0x80, 0x27, 0xc3, 0x80, 0x24, 0xe5, 0x46, 0x30, 0xe2, 0x0d, 0x54, 0x38, 0xc3,
+0x94, 0x30, 0x50, 0x06, 0x7e, 0x00, 0x7f, 0x01, 0x80, 0x04, 0x7e, 0x00, 0x7f, 0x00, 0x20, 0x47,
+0x04, 0x7d, 0x01, 0x80, 0x02, 0x7d, 0x00, 0xef, 0x6d, 0x4e, 0x24, 0xff, 0x92, 0x38, 0xa2, 0x47,
+0xb3, 0x92, 0x39, 0x80, 0x19, 0xe5, 0x46, 0x30, 0xe2, 0x03, 0xd3, 0x80, 0x01, 0xc3, 0x92, 0x39,
+0xa2, 0x47, 0xb3, 0x92, 0x38, 0x80, 0x07, 0xa2, 0x47, 0xb3, 0x92, 0x38, 0x92, 0x39, 0x90, 0x02,
+0x28, 0xe0, 0x54, 0xfc, 0x02, 0x19, 0x5b, 0xe5, 0x47, 0x64, 0x0c, 0x60, 0x09, 0xe5, 0x47, 0x64,
+0x0b, 0x60, 0x03, 0x02, 0x18, 0xc6, 0xe4, 0xf5, 0x27, 0x90, 0x02, 0x29, 0xe0, 0x54, 0xfd, 0xf0,
+0xe5, 0x3a, 0x14, 0x60, 0x2b, 0x14, 0x60, 0x2e, 0x14, 0x60, 0x38, 0x24, 0xfc, 0x60, 0x5c, 0x24,
+0xf9, 0x60, 0x1d, 0x24, 0x0e, 0x70, 0x61, 0xe5, 0x46, 0x13, 0x13, 0x54, 0x3f, 0x75, 0xf0, 0x03,
+0x84, 0xaf, 0xf0, 0x20, 0x47, 0x04, 0x7e, 0x01, 0x80, 0x02, 0x7e, 0x00, 0xef, 0x6e, 0x80, 0x35,
+0xa2, 0x47, 0x92, 0x39, 0x80, 0x47, 0xe5, 0x46, 0x30, 0xe2, 0x03, 0xd3, 0x80, 0x01, 0xc3, 0x92,
+0x39, 0x80, 0x3a, 0xe5, 0x46, 0x30, 0xe2, 0x0d, 0x54, 0x38, 0xc3, 0x94, 0x30, 0x50, 0x06, 0x7e,
+0x00, 0x7f, 0x01, 0x80, 0x04, 0x7e, 0x00, 0x7f, 0x00, 0x20, 0x47, 0x04, 0x7d, 0x01, 0x80, 0x02,
+0x7d, 0x00, 0xef, 0x6d, 0x4e, 0x24, 0xff, 0x92, 0x39, 0x80, 0x12, 0xe5, 0x46, 0x30, 0xe2, 0x03,
+0xd3, 0x80, 0x01, 0xc3, 0x92, 0x39, 0x80, 0x05, 0xa2, 0x47, 0xb3, 0x92, 0x39, 0x90, 0x02, 0x28,
+0xe0, 0x54, 0xfd, 0x02, 0x19, 0x5b, 0xe5, 0x47, 0x64, 0x0d, 0x60, 0x03, 0x02, 0x19, 0x5e, 0xf5,
+0x27, 0x90, 0x02, 0x29, 0xe0, 0x54, 0xef, 0xf0, 0xe5, 0x3a, 0x14, 0x60, 0x2b, 0x14, 0x60, 0x2e,
+0x14, 0x60, 0x38, 0x24, 0xfc, 0x60, 0x5c, 0x24, 0xf9, 0x60, 0x1d, 0x24, 0x0e, 0x70, 0x61, 0xe5,
+0x46, 0x13, 0x13, 0x54, 0x3f, 0x75, 0xf0, 0x03, 0x84, 0xaf, 0xf0, 0x20, 0x47, 0x04, 0x7e, 0x01,
+0x80, 0x02, 0x7e, 0x00, 0xef, 0x6e, 0x80, 0x35, 0xa2, 0x47, 0x92, 0x3c, 0x80, 0x47, 0xe5, 0x46,
+0x30, 0xe2, 0x03, 0xd3, 0x80, 0x01, 0xc3, 0x92, 0x3c, 0x80, 0x3a, 0xe5, 0x46, 0x30, 0xe2, 0x0d,
+0x54, 0x38, 0xc3, 0x94, 0x30, 0x50, 0x06, 0x7e, 0x00, 0x7f, 0x01, 0x80, 0x04, 0x7e, 0x00, 0x7f,
+0x00, 0x20, 0x47, 0x04, 0x7d, 0x01, 0x80, 0x02, 0x7d, 0x00, 0xef, 0x6d, 0x4e, 0x24, 0xff, 0x92,
+0x3c, 0x80, 0x12, 0xe5, 0x46, 0x30, 0xe2, 0x03, 0xd3, 0x80, 0x01, 0xc3, 0x92, 0x3c, 0x80, 0x05,
+0xa2, 0x47, 0xb3, 0x92, 0x3c, 0x90, 0x02, 0x28, 0xe0, 0x54, 0xef, 0x45, 0x27, 0xf0, 0x22, 0xe5,
+0x47, 0x64, 0x0b, 0x70, 0x1c, 0x90, 0x02, 0x29, 0xe0, 0x54, 0xeb, 0xf0, 0x30, 0x47, 0x04, 0xaf,
+0x45, 0x80, 0x05, 0xe5, 0x45, 0x64, 0x14, 0xff, 0x90, 0x02, 0x28, 0xe0, 0x54, 0xeb, 0x4f, 0xf0,
+0x22, 0xe4, 0x90, 0x02, 0x29, 0xf0, 0x30, 0x47, 0x04, 0xaf, 0x45, 0x80, 0x04, 0xe5, 0x45, 0xf4,
+0xff, 0x90, 0x02, 0x28, 0xef, 0xf0, 0x22, 0x8f, 0x50, 0xd2, 0x59, 0x22, 0x8f, 0x54, 0xd2, 0x58,
+0x22, 0xe4, 0xf5, 0x37, 0xc2, 0xaf, 0xe5, 0x51, 0x14, 0x60, 0x4a, 0x14, 0x60, 0x6b, 0x24, 0x02,
+0x60, 0x03, 0x02, 0x1b, 0x12, 0xd2, 0x59, 0x75, 0x55, 0x01, 0x20, 0x1a, 0x1c, 0x90, 0x02, 0x08,
+0xe0, 0x54, 0xfe, 0xf0, 0xe0, 0x20, 0xe1, 0x23, 0x90, 0x04, 0x34, 0xe0, 0xb4, 0x02, 0x1c, 0xa3,
+0xe0, 0xb4, 0x02, 0x17, 0xa3, 0xe0, 0xb4, 0x02, 0x12, 0x7f, 0x20, 0x12, 0x19, 0x97, 0x90, 0x10,
+0x04, 0xe0, 0x54, 0xf3, 0xf0, 0x75, 0x51, 0x01, 0x02, 0x1b, 0x12, 0xe5, 0x50, 0x70, 0x06, 0x75,
+0x37, 0x03, 0x02, 0x1b, 0x12, 0x90, 0x12, 0x00, 0xe0, 0x54, 0x03, 0x70, 0x15, 0x7f, 0x20, 0x12,
+0x19, 0x97, 0x20, 0x1a, 0x07, 0x90, 0x02, 0x08, 0xe0, 0x54, 0xfb, 0xf0, 0x75, 0x51, 0x02, 0x02,
+0x1b, 0x12, 0xe5, 0x50, 0x70, 0x03, 0x02, 0x1b, 0x0d, 0x20, 0x1a, 0x15, 0x90, 0x02, 0x08, 0xe0,
+0x30, 0xe3, 0x03, 0x02, 0x1b, 0x09, 0x90, 0x04, 0x37, 0xe0, 0x64, 0x22, 0x60, 0x03, 0x02, 0x1b,
+0x09, 0x90, 0x12, 0x04, 0x74, 0x0a, 0xf0, 0xe5, 0x58, 0xb4, 0x72, 0x15, 0xe5, 0x59, 0xb4, 0x35,
+0x10, 0xe4, 0x90, 0x05, 0x00, 0xf0, 0xa3, 0x74, 0x08, 0xf0, 0xa3, 0x74, 0x01, 0xf0, 0x74, 0x03,
+0xf0, 0x7f, 0x01, 0x12, 0x03, 0x30, 0x90, 0x13, 0x28, 0xe0, 0x54, 0xf0, 0xf0, 0xa3, 0xe0, 0x54,
+0xf0, 0xf0, 0xe5, 0x59, 0xb4, 0x35, 0x14, 0xe5, 0x3c, 0xf4, 0x60, 0x06, 0xa3, 0xe0, 0x54, 0xf3,
+0x80, 0x14, 0x90, 0x13, 0x2a, 0xe0, 0x54, 0xfb, 0xf0, 0x80, 0x14, 0xe5, 0x3c, 0xf4, 0x90, 0x13,
+0x2a, 0x60, 0x08, 0xe0, 0x54, 0xf2, 0x45, 0x3c, 0xf0, 0x80, 0x04, 0xe0, 0x54, 0xfa, 0xf0, 0x20,
+0x1a, 0x07, 0x90, 0x04, 0x01, 0xe0, 0x44, 0x10, 0xf0, 0xe5, 0x34, 0xc3, 0x94, 0x03, 0x40, 0x09,
+0xe5, 0x30, 0x70, 0x05, 0x75, 0x8c, 0x40, 0x80, 0x03, 0x75, 0x8c, 0x80, 0x90, 0x04, 0x01, 0xe0,
+0x54, 0xfd, 0xf0, 0x20, 0x1a, 0x07, 0x90, 0x12, 0x04, 0xe0, 0x44, 0x04, 0xf0, 0xe5, 0x59, 0xb4,
+0x28, 0x06, 0x90, 0x01, 0x0d, 0xe0, 0xf5, 0x31, 0xe5, 0x34, 0xc3, 0x94, 0x02, 0x40, 0x14, 0x90,
+0x01, 0x0d, 0xe0, 0x44, 0x01, 0xf0, 0xe5, 0x59, 0x64, 0x35, 0x60, 0x07, 0x90, 0x12, 0x04, 0xe0,
+0x54, 0xfd, 0xf0, 0xe5, 0x34, 0xc3, 0x94, 0x03, 0x40, 0x14, 0x20, 0x02, 0x11, 0x20, 0x03, 0x0e,
+0x90, 0x01, 0x0d, 0xe0, 0x54, 0xfb, 0xf0, 0x90, 0x01, 0x0c, 0xe0, 0x54, 0xfd, 0xf0, 0x75, 0x37,
+0x01, 0x75, 0x55, 0x02, 0xe4, 0xf5, 0x51, 0x80, 0x09, 0xe5, 0x50, 0x70, 0x05, 0x75, 0x37, 0x03,
+0xf5, 0x51, 0xe5, 0x37, 0x60, 0x18, 0xc2, 0x01, 0xe4, 0xf5, 0x51, 0xc2, 0x59, 0x20, 0x1a, 0x0e,
+0xad, 0x37, 0xaf, 0x40, 0x12, 0x1c, 0x1b, 0xe5, 0x37, 0xb4, 0x03, 0x02, 0xd2, 0x03, 0xd2, 0xaf,
+0x22, 0xc2, 0xaf, 0x30, 0x01, 0x0e, 0xe4, 0xf5, 0x51, 0xc2, 0x59, 0xc2, 0x01, 0x7d, 0x02, 0xaf,
+0x40, 0x12, 0x1c, 0x1b, 0xe5, 0x52, 0x14, 0x60, 0x5c, 0x14, 0x60, 0x3a, 0x24, 0x02, 0x60, 0x03,
+0x02, 0x1c, 0x18, 0xe5, 0x34, 0xc3, 0x94, 0x03, 0x40, 0x0c, 0x90, 0x01, 0x0c, 0xe0, 0x44, 0x02,
+0xf0, 0xa3, 0xe0, 0x44, 0x04, 0xf0, 0xe5, 0x34, 0xc3, 0x94, 0x02, 0x40, 0x13, 0x90, 0x12, 0x04,
+0xe0, 0x44, 0x02, 0xf0, 0x7f, 0x32, 0x12, 0x03, 0x30, 0x90, 0x01, 0x0d, 0xe0, 0x54, 0xfe, 0xf0,
+0x75, 0x52, 0x02, 0x75, 0x55, 0x03, 0xe5, 0x59, 0xb4, 0x28, 0x06, 0x90, 0x01, 0x0d, 0xe5, 0x31,
+0xf0, 0x90, 0x12, 0x04, 0xe0, 0x54, 0xfb, 0xf0, 0x7f, 0x20, 0x12, 0x19, 0x9c, 0x75, 0x52, 0x01,
+0x75, 0x55, 0x03, 0x80, 0x73, 0xe5, 0x54, 0x70, 0x6f, 0x90, 0x04, 0x01, 0xe0, 0x44, 0x0e, 0xf0,
+0x20, 0x1a, 0x04, 0xe0, 0x54, 0xef, 0xf0, 0xe4, 0xf5, 0x8c, 0x90, 0x13, 0x28, 0xe0, 0x44, 0x0f,
+0xf0, 0xa3, 0xe0, 0x44, 0x0f, 0xf0, 0xa3, 0xe0, 0x44, 0x05, 0xf0, 0x90, 0x12, 0x04, 0x74, 0x03,
+0xf0, 0xe5, 0x58, 0xb4, 0x72, 0x16, 0xe5, 0x59, 0xb4, 0x35, 0x11, 0x90, 0x05, 0x00, 0x74, 0xe2,
+0xf0, 0xa3, 0x74, 0x08, 0xf0, 0xa3, 0x74, 0x01, 0xf0, 0x74, 0x03, 0xf0, 0x7f, 0x01, 0x12, 0x03,
+0x30, 0x20, 0x1a, 0x07, 0x90, 0x02, 0x08, 0xe0, 0x44, 0x05, 0xf0, 0x90, 0x10, 0x04, 0xe0, 0x44,
+0x0c, 0xf0, 0xe4, 0xf5, 0x52, 0xf5, 0x55, 0x30, 0x02, 0x09, 0xc2, 0x02, 0x7d, 0x01, 0xaf, 0x41,
+0x12, 0x1c, 0x1b, 0x30, 0x03, 0x02, 0xc2, 0x03, 0xd2, 0xaf, 0x22, 0xef, 0xf4, 0x60, 0x2d, 0xe4,
+0xfe, 0x74, 0x14, 0x2e, 0xf5, 0x82, 0xe4, 0x34, 0x70, 0xf5, 0x83, 0xe0, 0xb4, 0xff, 0x19, 0x74,
+0x14, 0x2e, 0xf5, 0x82, 0xe4, 0x34, 0x70, 0xf5, 0x83, 0xef, 0xf0, 0x74, 0x1c, 0x2e, 0xf5, 0x82,
+0xe4, 0x34, 0x70, 0xf5, 0x83, 0xed, 0xf0, 0x22, 0x0e, 0xbe, 0x04, 0xd5, 0x22, 0x22, 0x22, 0x30,
+0x1a, 0x77, 0x90, 0x04, 0x37, 0xe0, 0x20, 0xe5, 0x6c, 0x90, 0x04, 0x28, 0xe0, 0xf5, 0x38, 0xa3,
+0xe0, 0xf5, 0x37, 0xf5, 0x39, 0xe4, 0xf5, 0x25, 0xe5, 0x39, 0x75, 0xf0, 0x80, 0xa4, 0x24, 0x00,
+0xff, 0xe5, 0xf0, 0x34, 0x80, 0xfe, 0xe5, 0x37, 0x65, 0x39, 0x70, 0x05, 0xfc, 0x7d, 0x28, 0x80,
+0x04, 0x7c, 0x00, 0x7d, 0x00, 0xef, 0x2d, 0xff, 0xee, 0x3c, 0xfe, 0x12, 0x1c, 0xca, 0x50, 0x07,
+0x90, 0x01, 0x14, 0xe0, 0x44, 0x02, 0xf0, 0xe5, 0x39, 0x65, 0x38, 0x60, 0x10, 0xe4, 0x25, 0x39,
+0xff, 0xe4, 0x34, 0x80, 0x8f, 0x82, 0xf5, 0x83, 0xe0, 0xf5, 0x39, 0x80, 0xbb, 0x90, 0x04, 0x10,
+0x74, 0x01, 0xf0, 0x90, 0x04, 0x28, 0xe5, 0x38, 0xf0, 0xa3, 0xe5, 0x37, 0xf0, 0x90, 0x04, 0x11,
+0x74, 0x01, 0xf0, 0x80, 0x8d, 0xc2, 0x06, 0xd2, 0x1b, 0x22, 0xe5, 0x25, 0xc3, 0x94, 0x06, 0x50,
+0x19, 0x8f, 0x82, 0x8e, 0x83, 0xe0, 0xb4, 0xff, 0x07, 0x05, 0x25, 0xe4, 0xf5, 0x24, 0x80, 0x2e,
+0xe4, 0xf5, 0x25, 0x8f, 0x82, 0x8e, 0x83, 0xf0, 0x80, 0x24, 0xe5, 0x24, 0x75, 0xf0, 0x06, 0x84,
+0x74, 0x08, 0x25, 0xf0, 0xf5, 0x82, 0xe4, 0x34, 0x10, 0xf5, 0x83, 0xe0, 0xfd, 0x8f, 0x82, 0x8e,
+0x83, 0xe0, 0x6d, 0x70, 0x06, 0x05, 0x25, 0x05, 0x24, 0x80, 0x03, 0xe4, 0xf5, 0x25, 0x0f, 0xbf,
+0x00, 0x01, 0x0e, 0xef, 0x54, 0x7f, 0x60, 0x07, 0xe5, 0x25, 0xc3, 0x94, 0x2a, 0x40, 0xab, 0xe5,
+0x25, 0xb4, 0x2a, 0x03, 0xd3, 0x80, 0x01, 0xc3, 0x22, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x13, 0xe3, 0x34, } ;
diff --git a/drivers/staging/rt3090/igmp_snoop.h b/drivers/staging/rt3090/igmp_snoop.h
new file mode 100644
index 000000000000..63f9692e0b35
--- /dev/null
+++ b/drivers/staging/rt3090/igmp_snoop.h
@@ -0,0 +1,152 @@
+/*
+ *************************************************************************
+ * 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:
+ igmp_snoop.h
+
+ Abstract:
+ Miniport generic portion header file
+
+ Revision History:
+ Who When What
+ -------- ---------- ----------------------------------------------
+*/
+
+
+#ifndef __RTMP_IGMP_SNOOP_H__
+#define __RTMP_IGMP_SNOOP_H__
+
+#include "link_list.h"
+
+#define IGMP_PROTOCOL_DESCRIPTOR 0x02
+#define IGMP_V1_MEMBERSHIP_REPORT 0x12
+#define IGMP_V2_MEMBERSHIP_REPORT 0x16
+#define IGMP_LEAVE_GROUP 0x17
+#define IGMP_V3_MEMBERSHIP_REPORT 0x22
+
+#define MLD_V1_LISTENER_REPORT 131
+#define MLD_V1_LISTENER_DONE 132
+#define MLD_V2_LISTERNER_REPORT 143
+
+#define IGMPMAC_TB_ENTRY_AGEOUT_TIME 120 * OS_HZ
+
+#define MULTICAST_ADDR_HASH_INDEX(Addr) (MAC_ADDR_HASH(Addr) % (MAX_LEN_OF_MULTICAST_FILTER_HASH_TABLE))
+
+#define IS_MULTICAST_MAC_ADDR(Addr) ((((Addr[0]) & 0x01) == 0x01) && ((Addr[0]) != 0xff))
+#define IS_BROADCAST_MAC_ADDR(Addr) ((((Addr[0]) & 0xff) == 0xff))
+
+VOID MulticastFilterTableInit(
+ IN PMULTICAST_FILTER_TABLE *ppMulticastFilterTable);
+
+VOID MultiCastFilterTableReset(
+ IN PMULTICAST_FILTER_TABLE *ppMulticastFilterTable);
+
+BOOLEAN MulticastFilterTableInsertEntry(
+ IN PRTMP_ADAPTER pAd,
+ IN PUCHAR pGrpId,
+ IN PUCHAR pMemberAddr,
+ IN PNET_DEV dev,
+ IN MulticastFilterEntryType type);
+
+BOOLEAN MulticastFilterTableDeleteEntry(
+ IN PRTMP_ADAPTER pAd,
+ IN PUCHAR pGrpId,
+ IN PUCHAR pMemberAddr,
+ IN PNET_DEV dev);
+
+PMULTICAST_FILTER_TABLE_ENTRY MulticastFilterTableLookup(
+ IN PMULTICAST_FILTER_TABLE pMulticastFilterTable,
+ IN PUCHAR pAddr,
+ IN PNET_DEV dev);
+
+BOOLEAN isIgmpPkt(
+ IN PUCHAR pDstMacAddr,
+ IN PUCHAR pIpHeader);
+
+VOID IGMPSnooping(
+ IN PRTMP_ADAPTER pAd,
+ IN PUCHAR pDstMacAddr,
+ IN PUCHAR pSrcMacAddr,
+ IN PUCHAR pIpHeader,
+ IN PNET_DEV pDev);
+
+BOOLEAN isMldPkt(
+ IN PUCHAR pDstMacAddr,
+ IN PUCHAR pIpHeader,
+ OUT UINT8 *pProtoType,
+ OUT PUCHAR *pMldHeader);
+
+VOID MLDSnooping(
+ IN PRTMP_ADAPTER pAd,
+ IN PUCHAR pDstMacAddr,
+ IN PUCHAR pSrcMacAddr,
+ IN PUCHAR pIpHeader,
+ IN PNET_DEV pDev);
+
+UCHAR IgmpMemberCnt(
+ IN PLIST_HEADER pList);
+
+VOID IgmpGroupDelMembers(
+ IN PRTMP_ADAPTER pAd,
+ IN PUCHAR pMemberAddr,
+ IN PNET_DEV pDev);
+
+INT Set_IgmpSn_Enable_Proc(
+ IN PRTMP_ADAPTER pAd,
+ IN PSTRING arg);
+
+INT Set_IgmpSn_AddEntry_Proc(
+ IN PRTMP_ADAPTER pAd,
+ IN PSTRING arg);
+
+INT Set_IgmpSn_DelEntry_Proc(
+ IN PRTMP_ADAPTER pAd,
+ IN PSTRING arg);
+
+INT Set_IgmpSn_TabDisplay_Proc(
+ IN PRTMP_ADAPTER pAd,
+ IN PSTRING arg);
+
+void rtmp_read_igmp_snoop_from_file(
+ IN PRTMP_ADAPTER pAd,
+ PSTRING tmpbuf,
+ PSTRING buffer);
+
+NDIS_STATUS IgmpPktInfoQuery(
+ IN PRTMP_ADAPTER pAd,
+ IN PUCHAR pSrcBufVA,
+ IN PNDIS_PACKET pPacket,
+ IN UCHAR apidx,
+ OUT BOOLEAN *pInIgmpGroup,
+ OUT PMULTICAST_FILTER_TABLE_ENTRY *ppGroupEntry);
+
+NDIS_STATUS IgmpPktClone(
+ IN PRTMP_ADAPTER pAd,
+ IN PNDIS_PACKET pPacket,
+ IN UCHAR QueIdx,
+ IN PMULTICAST_FILTER_TABLE_ENTRY pGroupEntry);
+
+#endif /* __RTMP_IGMP_SNOOP_H__ */
diff --git a/drivers/staging/rt3090/ipv6.h b/drivers/staging/rt3090/ipv6.h
new file mode 100644
index 000000000000..c34a5f2569dd
--- /dev/null
+++ b/drivers/staging/rt3090/ipv6.h
@@ -0,0 +1,215 @@
+/*
+ *************************************************************************
+ * 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:
+ ipv6.h
+
+ Abstract:
+ Miniport generic portion header file
+
+ Revision History:
+ Who When What
+ -------- ---------- ----------------------------------------------
+*/
+
+#ifndef __IPV6_HDR_H_
+#define __IPV6_HDR_H_
+
+#define IPV6_ADDR_LEN 16
+#define IPV6_HDR_LEN 40
+
+// IPv6 address definition
+#define IPV6_LINK_LOCAL_ADDR_PREFIX 0xFE8
+#define IPV6_SITE_LOCAL_ADDR_PREFIX 0xFEC
+#define IPV6_LOCAL_ADDR_PREFIX 0xFE8
+#define IPV6_MULTICAST_ADDR_PREFIX 0xFF
+#define IPV6_LOOPBACK_ADDR 0x1
+#define IPV6_UNSPECIFIED_ADDR 0x0
+
+// defined as sequence in IPv6 header
+#define IPV6_NEXT_HEADER_HOP_BY_HOP 0x00 // 0
+#define IPV6_NEXT_HEADER_DESTINATION 0x3c // 60
+#define IPV6_NEXT_HEADER_ROUTING 0x2b // 43
+#define IPV6_NEXT_HEADER_FRAGMENT 0x2c // 44
+#define IPV6_NEXT_HEADER_AUTHENTICATION 0x33 // 51
+#define IPV6_NEXT_HEADER_ENCAPSULATION 0x32 // 50, RFC-2406
+#define IPV6_NEXT_HEADER_NONE 0x3b // 59
+
+#define IPV6_NEXT_HEADER_TCP 0x06
+#define IPV6_NEXT_HEADER_UDP 0x11
+#define IPV6_NEXT_HEADER_ICMPV6 0x3a
+
+// ICMPv6 msg type definition
+#define ICMPV6_MSG_TYPE_ROUTER_SOLICITATION 0x85 // 133
+#define ROUTER_SOLICITATION_FIXED_LEN 8
+
+#define ICMPV6_MSG_TYPE_ROUTER_ADVERTISEMENT 0x86 // 134
+#define ROUTER_ADVERTISEMENT_FIXED_LEN 16
+
+#define ICMPV6_MSG_TYPE_NEIGHBOR_SOLICITATION 0x87 // 135
+#define NEIGHBOR_SOLICITATION_FIXED_LEN 24
+
+#define ICMPV6_MSG_TYPE_NEIGHBOR_ADVERTISEMENT 0x88 // 136
+#define NEIGHBOR_ADVERTISEMENT_FIXED_LEN 24
+
+#define ICMPV6_MSG_TYPE_REDIRECT 0x89 // 137
+#define REDIRECT_FIXED_LEN 40
+
+/* IPv6 Address related structures */
+typedef struct rt_ipv6_addr_
+{
+ union
+ {
+ UCHAR ipv6Addr8[16];
+ USHORT ipv6Addr16[8];
+ UINT32 ipv6Addr32[4];
+ }addr;
+#define ipv6_addr addr.ipv6Addr8
+#define ipv6_addr16 addr.ipv6Addr16
+#define ipv6_addr32 addr.ipv6Addr32
+}RT_IPV6_ADDR, *PRT_IPV6_ADDR;
+
+
+#define PRINT_IPV6_ADDR(ipv6Addr) \
+ OS_NTOHS((ipv6Addr).ipv6_addr16[0]), \
+ OS_NTOHS((ipv6Addr).ipv6_addr16[1]), \
+ OS_NTOHS((ipv6Addr).ipv6_addr16[2]), \
+ OS_NTOHS((ipv6Addr).ipv6_addr16[3]), \
+ OS_NTOHS((ipv6Addr).ipv6_addr16[4]), \
+ OS_NTOHS((ipv6Addr).ipv6_addr16[5]), \
+ OS_NTOHS((ipv6Addr).ipv6_addr16[6]), \
+ OS_NTOHS((ipv6Addr).ipv6_addr16[7])
+
+
+/*IPv6 Header related structures */
+typedef struct PACKED _rt_ipv6_hdr_
+{
+ UINT32 ver:4,
+ trafficClass:8,
+ flowLabel:20;
+ USHORT payload_len;
+ UCHAR nextHdr;
+ UCHAR hopLimit;
+ RT_IPV6_ADDR srcAddr;
+ RT_IPV6_ADDR dstAddr;
+}RT_IPV6_HDR, *PRT_IPV6_HDR;
+
+
+typedef struct PACKED _rt_ipv6_ext_hdr_
+{
+ UCHAR nextProto; // Indicate the protocol type of next extension header.
+ UCHAR extHdrLen; // optional field for msg length of this extension header which didn't include the first "nextProto" field.
+ UCHAR octets[1]; // hook to extend header message body.
+}RT_IPV6_EXT_HDR, *PRT_IPV6_EXT_HDR;
+
+
+/* ICMPv6 related structures */
+typedef struct PACKED _rt_ipv6_icmpv6_hdr_
+{
+ UCHAR type;
+ UCHAR code;
+ USHORT chksum;
+ UCHAR octets[1]; //hook to extend header message body.
+}RT_ICMPV6_HDR, *PRT_ICMPV6_HDR;
+
+
+typedef struct PACKED _rt_icmp6_option_hdr_
+{
+ UCHAR type;
+ UCHAR len;
+ UCHAR octet[1];
+}RT_ICMPV6_OPTION_HDR, *PRT_ICMPV6_OPTION_HDR;
+
+typedef enum{
+// Defined ICMPv6 Option Types.
+ TYPE_SRC_LL_ADDR = 1,
+ TYPE_TGT_LL_ADDR = 2,
+ TYPE_PREFIX_INFO = 3,
+ TYPE_REDIRECTED_HDR = 4,
+ TYPE_MTU = 5,
+}ICMPV6_OPTIONS_TYPE_DEF;
+
+
+static inline BOOLEAN IPv6ExtHdrHandle(
+ RT_IPV6_EXT_HDR *pExtHdr,
+ UCHAR *pProto,
+ UINT32 *pOffset)
+{
+ UCHAR nextProto = 0xff;
+ UINT32 extLen = 0;
+ BOOLEAN status = TRUE;
+
+ //printk("%s(): parsing the Extension Header with Protocol(0x%x):\n", __FUNCTION__, *pProto);
+ switch (*pProto)
+ {
+ case IPV6_NEXT_HEADER_HOP_BY_HOP:
+ // IPv6ExtHopByHopHandle();
+ nextProto = pExtHdr->nextProto;
+ extLen = (pExtHdr->extHdrLen + 1) * 8;
+ break;
+
+ case IPV6_NEXT_HEADER_DESTINATION:
+ // IPv6ExtDestHandle();
+ nextProto = pExtHdr->nextProto;
+ extLen = (pExtHdr->extHdrLen + 1) * 8;
+ break;
+
+ case IPV6_NEXT_HEADER_ROUTING:
+ // IPv6ExtRoutingHandle();
+ nextProto = pExtHdr->nextProto;
+ extLen = (pExtHdr->extHdrLen + 1) * 8;
+ break;
+
+ case IPV6_NEXT_HEADER_FRAGMENT:
+ // IPv6ExtFragmentHandle();
+ nextProto = pExtHdr->nextProto;
+ extLen = 8; // The Fragment header length is fixed to 8 bytes.
+ break;
+
+ case IPV6_NEXT_HEADER_AUTHENTICATION:
+ // IPV6_NEXT_HEADER_ENCAPSULATION:
+ /*
+ TODO: Not support. For encryption issue.
+ */
+ nextProto = 0xFF;
+ status = FALSE;
+ break;
+
+ default:
+ nextProto = 0xFF;
+ status = FALSE;
+ break;
+ }
+
+ *pProto = nextProto;
+ *pOffset += extLen;
+ //printk("%s(): nextProto = 0x%x!, offset=0x%x!\n", __FUNCTION__, nextProto, offset);
+
+ return status;
+
+}
+
+#endif // __IPV6_HDR_H_ //
diff --git a/drivers/staging/rt3090/link_list.h b/drivers/staging/rt3090/link_list.h
new file mode 100644
index 000000000000..205b610bfb90
--- /dev/null
+++ b/drivers/staging/rt3090/link_list.h
@@ -0,0 +1,133 @@
+/*
+ *************************************************************************
+ * 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__ //
diff --git a/drivers/staging/rt3090/mac_pci.h b/drivers/staging/rt3090/mac_pci.h
new file mode 100644
index 000000000000..bad04d43ebae
--- /dev/null
+++ b/drivers/staging/rt3090/mac_pci.h
@@ -0,0 +1,454 @@
+/*
+ *************************************************************************
+ * 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:
+ mac_pci.h
+
+ Abstract:
+
+ Revision History:
+ Who When What
+ --------- ---------- ----------------------------------------------
+ */
+
+#ifndef __MAC_PCI_H__
+#define __MAC_PCI_H__
+
+#include "rtmp_type.h"
+#include "rtmp_mac.h"
+#include "rtmp_phy.h"
+#include "rtmp_iface.h"
+#include "rtmp_dot11.h"
+
+
+//
+// Device ID & Vendor ID related definitions,
+// NOTE: you should not add the new VendorID/DeviceID here unless you not sure it belongs to what chip.
+//
+#define NIC_PCI_VENDOR_ID 0x1814
+#define PCIBUS_INTEL_VENDOR 0x8086
+
+#if !defined(PCI_CAP_ID_EXP)
+#define PCI_CAP_ID_EXP 0x10
+#endif
+#if !defined(PCI_EXP_LNKCTL)
+#define PCI_EXP_LNKCTL 0x10
+#endif
+#if !defined(PCI_CLASS_BRIDGE_PCI)
+#define PCI_CLASS_BRIDGE_PCI 0x0604
+#endif
+
+
+
+
+
+#define TXINFO_SIZE 0
+#define RTMP_PKT_TAIL_PADDING 0
+#define fRTMP_ADAPTER_NEED_STOP_TX 0
+
+#define AUX_CTRL 0x10c
+
+//
+// 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
+
+
+//
+// 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
+typedef struct PACKED _RXD_STRUC{
+ // Word 0
+ UINT32 SDP0;
+ // Word 1
+ UINT32 SDL1:14;
+ UINT32 Rsv:2;
+ UINT32 SDL0:14;
+ UINT32 LS0:1;
+ UINT32 DDONE:1;
+ // Word 2
+ UINT32 SDP1;
+ // Word 3
+ 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;
+ UINT32 Decrypted:1; // this frame is being decrypted.
+ UINT32 PlcpSignal:1; // To be moved
+ UINT32 PlcpRssil:1;// To be moved
+ UINT32 Rsv1:13;
+} RXD_STRUC, *PRXD_STRUC, RT28XX_RXD_STRUC, *PRT28XX_RXD_STRUC;
+#endif
+
+#ifdef BIG_ENDIAN
+typedef union _TX_ATTENUATION_CTRL_STRUC
+{
+ struct
+ {
+ ULONG Reserve1:20;
+ ULONG PCIE_PHY_TX_ATTEN_EN:1;
+ ULONG PCIE_PHY_TX_ATTEN_VALUE:3;
+ ULONG Reserve2:7;
+ ULONG RF_ISOLATION_ENABLE:1;
+ } field;
+
+ ULONG word;
+} TX_ATTENUATION_CTRL_STRUC, *PTX_ATTENUATION_CTRL_STRUC;
+#else
+typedef union _TX_ATTENUATION_CTRL_STRUC {
+ struct
+ {
+ ULONG RF_ISOLATION_ENABLE:1;
+ ULONG Reserve2:7;
+ ULONG PCIE_PHY_TX_ATTEN_VALUE:3;
+ ULONG PCIE_PHY_TX_ATTEN_EN:1;
+ ULONG Reserve1:20;
+ } field;
+
+ ULONG word;
+} TX_ATTENUATION_CTRL_STRUC, *PTX_ATTENUATION_CTRL_STRUC;
+#endif
+/* ----------------- EEPROM Related MACRO ----------------- */
+
+// 8051 firmware image for RT2860 - base address = 0x4000
+#define FIRMWARE_IMAGE_BASE 0x2000
+#define MAX_FIRMWARE_IMAGE_SIZE 0x2000 // 8kbyte
+
+
+/* ----------------- Frimware Related MACRO ----------------- */
+#define RTMP_WRITE_FIRMWARE(_pAd, _pFwImage, _FwLen) \
+ do{ \
+ ULONG _i, _firm; \
+ RTMP_IO_WRITE32(_pAd, PBF_SYS_CTRL, 0x10000); \
+ \
+ for(_i=0; _i<_FwLen; _i+=4) \
+ { \
+ _firm = _pFwImage[_i] + \
+ (_pFwImage[_i+3] << 24) + \
+ (_pFwImage[_i+2] << 16) + \
+ (_pFwImage[_i+1] << 8); \
+ RTMP_IO_WRITE32(_pAd, FIRMWARE_IMAGE_BASE + _i, _firm); \
+ } \
+ 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); \
+ }while(0)
+
+
+/* ----------------- TX Related MACRO ----------------- */
+#define RTMP_START_DEQUEUE(pAd, QueIdx, irqFlags) do{}while(0)
+#define RTMP_STOP_DEQUEUE(pAd, QueIdx, irqFlags) do{}while(0)
+
+
+#define RTMP_HAS_ENOUGH_FREE_DESC(pAd, pTxBlk, freeNum, pPacket) \
+ ((freeNum) >= (ULONG)(pTxBlk->TotalFragNum + RTMP_GET_PACKET_FRAGMENTS(pPacket) + 3)) /* rough estimate we will use 3 more descriptor. */
+#define RTMP_RELEASE_DESC_RESOURCE(pAd, QueIdx) \
+ do{}while(0)
+
+#define NEED_QUEUE_BACK_FOR_AGG(pAd, QueIdx, freeNum, _TxFrameType) \
+ (((freeNum != (TX_RING_SIZE-1)) && (pAd->TxSwQueue[QueIdx].Number == 0)) || (freeNum<3))
+ //(((freeNum) != (TX_RING_SIZE-1)) && (pAd->TxSwQueue[QueIdx].Number == 1 /*0*/))
+
+
+#define HAL_KickOutMgmtTx(_pAd, _QueIdx, _pPacket, _pSrcBufVA, _SrcBufLen) \
+ RtmpPCIMgmtKickOut(_pAd, _QueIdx, _pPacket, _pSrcBufVA, _SrcBufLen)
+
+#define HAL_WriteSubTxResource(pAd, pTxBlk, bIsLast, pFreeNumber) \
+ /* RtmpPCI_WriteSubTxResource(pAd, pTxBlk, bIsLast, pFreeNumber)*/
+
+#define HAL_WriteTxResource(pAd, pTxBlk,bIsLast, pFreeNumber) \
+ RtmpPCI_WriteSingleTxResource(pAd, pTxBlk, bIsLast, pFreeNumber)
+
+#define HAL_WriteFragTxResource(pAd, pTxBlk, fragNum, pFreeNumber) \
+ RtmpPCI_WriteFragTxResource(pAd, pTxBlk, fragNum, pFreeNumber)
+
+#define HAL_WriteMultiTxResource(pAd, pTxBlk,frameNum, pFreeNumber) \
+ RtmpPCI_WriteMultiTxResource(pAd, pTxBlk, frameNum, pFreeNumber)
+
+#define HAL_FinalWriteTxResource(_pAd, _pTxBlk, _TotalMPDUSize, _FirstTxIdx) \
+ RtmpPCI_FinalWriteTxResource(_pAd, _pTxBlk, _TotalMPDUSize, _FirstTxIdx)
+
+#define HAL_LastTxIdx(_pAd, _QueIdx,_LastTxIdx) \
+ /*RtmpPCIDataLastTxIdx(_pAd, _QueIdx,_LastTxIdx)*/
+
+#define HAL_KickOutTx(_pAd, _pTxBlk, _QueIdx) \
+ RTMP_IO_WRITE32((_pAd), TX_CTX_IDX0+((_QueIdx)*0x10), (_pAd)->TxRing[(_QueIdx)].TxCpuIdx)
+/* RtmpPCIDataKickOut(_pAd, _pTxBlk, _QueIdx)*/
+
+#define HAL_KickOutNullFrameTx(_pAd, _QueIdx, _pNullFrame, _frameLen) \
+ MiniportMMRequest(_pAd, _QueIdx, _pNullFrame, _frameLen)
+
+#define GET_TXRING_FREENO(_pAd, _QueIdx) \
+ (_pAd->TxRing[_QueIdx].TxSwFreeIdx > _pAd->TxRing[_QueIdx].TxCpuIdx) ? \
+ (_pAd->TxRing[_QueIdx].TxSwFreeIdx - _pAd->TxRing[_QueIdx].TxCpuIdx - 1) \
+ : \
+ (_pAd->TxRing[_QueIdx].TxSwFreeIdx + TX_RING_SIZE - _pAd->TxRing[_QueIdx].TxCpuIdx - 1);
+
+
+#define GET_MGMTRING_FREENO(_pAd) \
+ (_pAd->MgmtRing.TxSwFreeIdx > _pAd->MgmtRing.TxCpuIdx) ? \
+ (_pAd->MgmtRing.TxSwFreeIdx - _pAd->MgmtRing.TxCpuIdx - 1) \
+ : \
+ (_pAd->MgmtRing.TxSwFreeIdx + MGMT_RING_SIZE - _pAd->MgmtRing.TxCpuIdx - 1);
+
+
+/* ----------------- RX Related MACRO ----------------- */
+
+
+/* ----------------- ASIC Related MACRO ----------------- */
+// reset MAC of a station entry to 0x000000000000
+#define RTMP_STA_ENTRY_MAC_RESET(pAd, Wcid) \
+ AsicDelWcidTab(pAd, Wcid);
+
+// add this entry into ASIC RX WCID search table
+#define RTMP_STA_ENTRY_ADD(pAd, pEntry) \
+ AsicUpdateRxWCIDTable(pAd, pEntry->Aid, pEntry->Addr);
+
+// add by johnli, fix "in_interrupt" error when call "MacTableDeleteEntry" in Rx tasklet
+// Set MAC register value according operation mode
+#define RTMP_UPDATE_PROTECT(pAd) \
+ AsicUpdateProtect(pAd, 0, (ALLN_SETPROTECT), TRUE, 0);
+// end johnli
+
+// remove Pair-wise key material from ASIC
+#define RTMP_STA_ENTRY_KEY_DEL(pAd, BssIdx, Wcid) \
+ AsicRemovePairwiseKeyEntry(pAd, BssIdx, (UCHAR)Wcid);
+
+// add Client security information into ASIC WCID table and IVEIV table
+#define RTMP_STA_SECURITY_INFO_ADD(pAd, apidx, KeyID, pEntry) \
+ RTMPAddWcidAttributeEntry(pAd, apidx, KeyID, \
+ pAd->SharedKey[apidx][KeyID].CipherAlg, pEntry);
+
+#define RTMP_SECURITY_KEY_ADD(pAd, apidx, KeyID, pEntry) \
+ { /* update pairwise key information to ASIC Shared Key Table */ \
+ AsicAddSharedKeyEntry(pAd, apidx, KeyID, \
+ pAd->SharedKey[apidx][KeyID].CipherAlg, \
+ pAd->SharedKey[apidx][KeyID].Key, \
+ pAd->SharedKey[apidx][KeyID].TxMic, \
+ pAd->SharedKey[apidx][KeyID].RxMic); \
+ /* update ASIC WCID attribute table and IVEIV table */ \
+ RTMPAddWcidAttributeEntry(pAd, apidx, KeyID, \
+ pAd->SharedKey[apidx][KeyID].CipherAlg, \
+ pEntry); }
+
+
+// Insert the BA bitmap to ASIC for the Wcid entry
+#define RTMP_ADD_BA_SESSION_TO_ASIC(_pAd, _Aid, _TID) \
+ do{ \
+ UINT32 _Value = 0, _Offset; \
+ _Offset = MAC_WCID_BASE + (_Aid) * HW_WCID_ENTRY_SIZE + 4; \
+ RTMP_IO_READ32((_pAd), _Offset, &_Value);\
+ _Value |= (0x10000<<(_TID)); \
+ RTMP_IO_WRITE32((_pAd), _Offset, _Value);\
+ }while(0)
+
+
+// Remove the BA bitmap from ASIC for the Wcid entry
+// bitmap field starts at 0x10000 in ASIC WCID table
+#define RTMP_DEL_BA_SESSION_FROM_ASIC(_pAd, _Wcid, _TID) \
+ do{ \
+ UINT32 _Value = 0, _Offset; \
+ _Offset = MAC_WCID_BASE + (_Wcid) * HW_WCID_ENTRY_SIZE + 4; \
+ RTMP_IO_READ32((_pAd), _Offset, &_Value); \
+ _Value &= (~(0x10000 << (_TID))); \
+ RTMP_IO_WRITE32((_pAd), _Offset, _Value); \
+ }while(0)
+
+
+/* ----------------- Interface Related MACRO ----------------- */
+
+//
+// Enable & Disable NIC interrupt via writing interrupt mask register
+// Since it use ADAPTER structure, it have to be put after structure definition.
+//
+#define RTMP_ASIC_INTERRUPT_DISABLE(_pAd) \
+ do{ \
+ RTMP_IO_WRITE32((_pAd), INT_MASK_CSR, 0x0); /* 0: disable */ \
+ RTMP_CLEAR_FLAG((_pAd), fRTMP_ADAPTER_INTERRUPT_ACTIVE); \
+ }while(0)
+
+#define RTMP_ASIC_INTERRUPT_ENABLE(_pAd)\
+ do{ \
+ RTMP_IO_WRITE32((_pAd), INT_MASK_CSR, (_pAd)->int_enable_reg /*DELAYINTMASK*/); /* 1:enable */ \
+ RTMP_SET_FLAG((_pAd), fRTMP_ADAPTER_INTERRUPT_ACTIVE); \
+ }while(0)
+
+
+#define RTMP_IRQ_INIT(pAd) \
+ { pAd->int_enable_reg = ((DELAYINTMASK) | \
+ (RxINT|TxDataInt|TxMgmtInt)) & ~(0x03); \
+ pAd->int_disable_mask = 0; \
+ pAd->int_pending = 0; }
+
+#define RTMP_IRQ_ENABLE(pAd) \
+ { /* clear garbage ints */ \
+ RTMP_IO_WRITE32(pAd, INT_SOURCE_CSR, 0xffffffff);\
+ RTMP_ASIC_INTERRUPT_ENABLE(pAd); }
+
+
+/* ----------------- MLME Related MACRO ----------------- */
+#define RTMP_MLME_HANDLER(pAd) MlmeHandler(pAd)
+
+#define RTMP_MLME_PRE_SANITY_CHECK(pAd)
+
+#define RTMP_MLME_STA_QUICK_RSP_WAKE_UP(pAd) \
+ RTMPSetTimer(&pAd->StaCfg.StaQuickResponeForRateUpTimer, 100);
+
+#define RTMP_MLME_RESET_STATE_MACHINE(pAd) \
+ MlmeRestartStateMachine(pAd)
+
+#define RTMP_HANDLE_COUNTER_MEASURE(_pAd, _pEntry)\
+ HandleCounterMeasure(_pAd, _pEntry)
+
+/* ----------------- Power Save Related MACRO ----------------- */
+#define RTMP_PS_POLL_ENQUEUE(pAd) EnqueuePsPoll(pAd)
+
+
+// For RTMPPCIePowerLinkCtrlRestore () function
+#define RESTORE_HALT 1
+#define RESTORE_WAKEUP 2
+#define RESTORE_CLOSE 3
+
+#define PowerSafeCID 1
+#define PowerRadioOffCID 2
+#define PowerWakeCID 3
+#define CID0MASK 0x000000ff
+#define CID1MASK 0x0000ff00
+#define CID2MASK 0x00ff0000
+#define CID3MASK 0xff000000
+
+
+#ifdef CONFIG_STA_SUPPORT
+#define RTMP_STA_FORCE_WAKEUP(pAd, bFromTx) \
+ RT28xxPciStaAsicForceWakeup(pAd, bFromTx);
+
+#define RTMP_STA_SLEEP_THEN_AUTO_WAKEUP(pAd, TbttNumToNextWakeUp) \
+ RT28xxPciStaAsicSleepThenAutoWakeup(pAd, TbttNumToNextWakeUp);
+
+#define RTMP_SET_PSM_BIT(_pAd, _val) \
+ MlmeSetPsmBit(_pAd, _val);
+#endif // CONFIG_STA_SUPPORT //
+
+#define RTMP_MLME_RADIO_ON(pAd) \
+ RT28xxPciMlmeRadioOn(pAd);
+
+#define RTMP_MLME_RADIO_OFF(pAd) \
+ RT28xxPciMlmeRadioOFF(pAd);
+
+#endif //__MAC_PCI_H__ //
diff --git a/drivers/staging/rt3090/mlme.h b/drivers/staging/rt3090/mlme.h
new file mode 100644
index 000000000000..233674397a73
--- /dev/null
+++ b/drivers/staging/rt3090/mlme.h
@@ -0,0 +1,1360 @@
+/*
+ *************************************************************************
+ * 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:
+ Miniport generic portion header file
+
+ 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__
+
+#include "rtmp_dot11.h"
+
+#ifdef CONFIG_STA_SUPPORT
+#endif // CONFIG_STA_SUPPORT //
+
+
+// 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
+
+#define BEACON_LOST_TIME 4 * OS_HZ // 2048 msec = 2 sec
+
+#define DLS_TIMEOUT 1200 // unit: msec
+#define AUTH_TIMEOUT 300 // unit: msec
+#define ASSOC_TIMEOUT 300 // unit: msec
+#define JOIN_TIMEOUT 2000 // 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
+#define LINK_DOWN_TIMEOUT 20000 // unit: msec
+#define AUTO_WAKEUP_TIMEOUT 70 //unit: msec
+
+
+#ifdef CONFIG_STA_SUPPORT
+#define CW_MAX_IN_BITS 10 // actual CwMax = 2^CW_MAX_IN_BITS - 1
+#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 maximum
+ // 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];
+} 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;
+
+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;
+
+
+// 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;
+
+#ifdef CONFIG_STA_SUPPORT
+#endif // CONFIG_STA_SUPPORT //
+} 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;
+ UCHAR 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__
diff --git a/drivers/staging/rt3090/mlme_ex.h b/drivers/staging/rt3090/mlme_ex.h
new file mode 100644
index 000000000000..b3e94dc88375
--- /dev/null
+++ b/drivers/staging/rt3090/mlme_ex.h
@@ -0,0 +1,83 @@
+/*
+ *************************************************************************
+ * 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_ex.h
+
+ Abstract:
+ Miniport generic portion header file
+
+ Revision History:
+ Who When What
+ -------- ---------- ----------------------------------------------
+ Fonchi 2007-06-25 Extend original mlme APIs to support multi-entries
+*/
+#ifndef __MLME_EX_H__
+#define __MLME_EX_H__
+
+#include "mlme_ex_def.h"
+
+
+VOID StateMachineInitEx(
+ IN STATE_MACHINE_EX *S,
+ IN STATE_MACHINE_FUNC_EX Trans[],
+ IN ULONG StNr,
+ IN ULONG MsgNr,
+ IN STATE_MACHINE_FUNC_EX DefFunc,
+ IN ULONG InitState,
+ IN ULONG Base);
+
+VOID StateMachineSetActionEx(
+ IN STATE_MACHINE_EX *S,
+ IN ULONG St,
+ IN ULONG Msg,
+ IN STATE_MACHINE_FUNC_EX Func);
+
+BOOLEAN isValidApCliIf(
+ SHORT Idx);
+
+VOID StateMachinePerformActionEx(
+ IN PRTMP_ADAPTER pAd,
+ IN STATE_MACHINE_EX *S,
+ IN MLME_QUEUE_ELEM *Elem,
+ USHORT Idx,
+ PULONG pCurrState);
+
+BOOLEAN MlmeEnqueueEx(
+ IN PRTMP_ADAPTER pAd,
+ IN ULONG Machine,
+ IN ULONG MsgType,
+ IN ULONG MsgLen,
+ IN VOID *Msg,
+ IN USHORT Idx);
+
+VOID DropEx(
+ IN PRTMP_ADAPTER pAd,
+ IN MLME_QUEUE_ELEM *Elem,
+ PULONG pCurrState,
+ USHORT Idx);
+
+#endif /* __MLME_EX_H__ */
diff --git a/drivers/staging/rt3090/mlme_ex_def.h b/drivers/staging/rt3090/mlme_ex_def.h
new file mode 100644
index 000000000000..ccd60b41614a
--- /dev/null
+++ b/drivers/staging/rt3090/mlme_ex_def.h
@@ -0,0 +1,53 @@
+/*
+ *************************************************************************
+ * 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_ex_def.h
+
+ Abstract:
+ Miniport generic portion header file
+
+ Revision History:
+ Who When What
+ -------- ---------- ----------------------------------------------
+ Fonchi 2007-06-25 Extend original mlme APIs to support multi-entries
+*/
+#ifndef __MLME_EX_DEF_H__
+#define __MLME_EX_DEF_H__
+
+
+typedef VOID (*STATE_MACHINE_FUNC_EX)(VOID *Adaptor, MLME_QUEUE_ELEM *Elem, PULONG pCurrState, USHORT Idx);
+
+typedef struct _STA_STATE_MACHINE_EX
+{
+ ULONG Base;
+ ULONG NrState;
+ ULONG NrMsg;
+ ULONG CurrState;
+ STATE_MACHINE_FUNC_EX *TransFunc;
+} STATE_MACHINE_EX, *PSTA_STATE_MACHINE_EX;
+
+#endif // __MLME_EX_DEF_H__ //
diff --git a/drivers/staging/rt3090/netif_block.h b/drivers/staging/rt3090/netif_block.h
new file mode 100644
index 000000000000..9e753894f294
--- /dev/null
+++ b/drivers/staging/rt3090/netif_block.h
@@ -0,0 +1,56 @@
+/*
+ *************************************************************************
+ * 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 "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/rt3090/oid.h b/drivers/staging/rt3090/oid.h
new file mode 100644
index 000000000000..29a43401095e
--- /dev/null
+++ b/drivers/staging/rt3090/oid.h
@@ -0,0 +1,1144 @@
+/*
+ *************************************************************************
+ * 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>
+
+#ifndef TRUE
+#define TRUE 1
+#endif
+#ifndef FALSE
+#define FALSE 0
+#endif
+//
+// 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_NUM_OF_CHS 54 // 14 channels @2.4G + 12@UNII(lower/middle) + 16@HiperLAN2 + 11@UNII(upper) + 0 @Japan + 1 as NULL termination
+#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
+
+
+#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
+#define RT_QUERY_EVENT_TABLE 0x0407
+//
+// IEEE 802.11 OIDs
+//
+#define OID_GET_SET_TOGGLE 0x8000
+#define OID_GET_SET_FROM_UI 0x4000
+
+#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
+#define OID_802_11_EAP_METHOD 0x0529
+
+// 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
+
+#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
+#define OID_802_11_SET_PSPXLINK_MODE 0x0648
+/*+++ add by woody +++*/
+#define OID_802_11_SET_PASSPHRASE 0x0649
+// 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)
+#define RT_OID_802_11_SET_PSPXLINK_MODE (OID_GET_SET_TOGGLE | OID_802_11_SET_PSPXLINK_MODE)
+#define RT_OID_802_11_EAP_METHOD (OID_GET_SET_TOGGLE | OID_802_11_EAP_METHOD)
+#define RT_OID_802_11_SET_PASSPHRASE (OID_GET_SET_TOGGLE | OID_802_11_SET_PASSPHRASE)
+
+
+
+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_11OFDM24,
+ Ndis802_11Automode,
+ Ndis802_11OFDM5_N,
+ Ndis802_11OFDM24_N,
+ 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[8][IFNAMSIZ];
+ UCHAR EAPifname_len[8];
+ UCHAR PreAuthifname[8][IFNAMSIZ];
+ UCHAR PreAuthifname_len[8];
+ RADIUS_KEY_INFO RadiusInfo[8];
+} 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;
+
+typedef struct _NDIS_802_11_PASSPHRASE
+{
+ UINT KeyLength; // length of key in bytes
+ NDIS_802_11_MAC_ADDRESS BSSID;
+ UCHAR KeyMaterial[1]; // variable length depending on above field
+} NDIS_802_11_PASSPHRASE, *PNDIS_802_11_PASSPHRASE;
+#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;
+
+#ifdef LINUX
+#if WIRELESS_EXT <= 11
+#ifndef SIOCDEVPRIVATE
+#define SIOCDEVPRIVATE 0x8BE0
+#endif
+#define SIOCIWFIRSTPRIV SIOCDEVPRIVATE
+#endif
+#endif // LINUX //
+
+
+#ifdef CONFIG_STA_SUPPORT
+#define RT_PRIV_IOCTL (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)
+
+#ifdef RTMP_RF_RW_SUPPORT
+// TODO: shiang, Need to reassign the oid number. ArchTeam use (SIOCIWFIRSTPRIV + 0x19) for this oid
+#define RTPRIV_IOCTL_RF (SIOCIWFIRSTPRIV + 0x13) // edit by johnli, fix read rf register problem
+#endif // RTMP_RF_RW_SUPPORT //
+
+#define RTPRIV_IOCTL_E2P (SIOCIWFIRSTPRIV + 0x07)
+#endif // DBG //
+
+#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_EXT (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,
+ 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
+
+//#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_WSC_CONFIG_STATUS 0x074F
+#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 //
+
+
+// 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;
+
+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;
+
+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;
+ UINT ApplyProfileIdx; // add by johnli, fix WPS test plan 5.1.1
+ WSC_CREDENTIAL Profile[8]; // Support up to 8 profiles
+} WSC_PROFILE, *PWSC_PROFILE;
+
+
+
+#endif // _OID_H_
diff --git a/drivers/staging/rt3090/pci_main_dev.c b/drivers/staging/rt3090/pci_main_dev.c
new file mode 100644
index 000000000000..30753d5fa9e8
--- /dev/null
+++ b/drivers/staging/rt3090/pci_main_dev.c
@@ -0,0 +1,1194 @@
+/*
+ *************************************************************************
+ * 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:
+ pci_main_dev.c
+
+ Abstract:
+
+ Revision History:
+ Who When What
+ -------- ---------- ----------------------------------------------
+ Name Date Modification logs
+*/
+
+
+#include "rt_config.h"
+#include <linux/pci.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("Jett Chen <jett_chen@ralinktech.com>");
+MODULE_DESCRIPTION("RT3090 Wireless Lan Linux Driver");
+MODULE_LICENSE("GPL");
+
+//
+// Function declarations
+//
+extern int rt28xx_close(IN struct net_device *net_dev);
+extern int rt28xx_open(struct net_device *net_dev);
+
+static VOID __devexit rt2860_remove_one(struct pci_dev *pci_dev);
+static INT __devinit rt2860_probe(struct pci_dev *pci_dev, const struct pci_device_id *ent);
+static void __exit rt2860_cleanup_module(void);
+static int __init rt2860_init_module(void);
+
+
+ static VOID RTMPInitPCIeDevice(
+ IN struct pci_dev *pci_dev,
+ IN PRTMP_ADAPTER pAd);
+
+
+#ifdef CONFIG_PM
+#if LINUX_VERSION_CODE >= KERNEL_VERSION(2,5,0)
+#if LINUX_VERSION_CODE < KERNEL_VERSION(2,6,10)
+#define pm_message_t u32
+#endif
+
+static int rt2860_suspend(struct pci_dev *pci_dev, pm_message_t state);
+static int rt2860_resume(struct pci_dev *pci_dev);
+#endif
+#endif // CONFIG_PM //
+
+//
+// Ralink PCI device table, include all supported chipsets
+//
+static struct pci_device_id rt2860_pci_tbl[] __devinitdata =
+{
+#ifdef RT3090
+ {PCI_DEVICE(NIC_PCI_VENDOR_ID, NIC3090_PCIe_DEVICE_ID)},
+ {PCI_DEVICE(NIC_PCI_VENDOR_ID, NIC3091_PCIe_DEVICE_ID)},
+ {PCI_DEVICE(NIC_PCI_VENDOR_ID, NIC3092_PCIe_DEVICE_ID)},
+#endif // RT3090 //
+#ifdef RT3390
+ {PCI_DEVICE(NIC_PCI_VENDOR_ID, NIC3390_PCIe_DEVICE_ID)},
+ {PCI_DEVICE(NIC_PCI_VENDOR_ID, NIC3391_PCIe_DEVICE_ID)},
+ {PCI_DEVICE(NIC_PCI_VENDOR_ID, NIC3392_PCIe_DEVICE_ID)},
+#endif // RT3390 //
+ {0,} // terminate list
+};
+
+MODULE_DEVICE_TABLE(pci, rt2860_pci_tbl);
+#ifdef CONFIG_STA_SUPPORT
+#ifdef MODULE_VERSION
+MODULE_VERSION(STA_DRIVER_VERSION);
+#endif
+#endif // CONFIG_STA_SUPPORT //
+
+
+//
+// Our PCI driver structure
+//
+static struct pci_driver rt2860_driver =
+{
+ name: "rt2860",
+ id_table: rt2860_pci_tbl,
+ probe: rt2860_probe,
+#if LINUX_VERSION_CODE >= 0x20412
+ remove: __devexit_p(rt2860_remove_one),
+#else
+ remove: __devexit(rt2860_remove_one),
+#endif
+
+#if LINUX_VERSION_CODE >= KERNEL_VERSION(2,5,0)
+#ifdef CONFIG_PM
+ suspend: rt2860_suspend,
+ resume: rt2860_resume,
+#endif
+#endif
+};
+
+
+/***************************************************************************
+ *
+ * PCI device initialization related procedures.
+ *
+ ***************************************************************************/
+#if LINUX_VERSION_CODE >= KERNEL_VERSION(2,5,0)
+#ifdef CONFIG_PM
+
+VOID RT2860RejectPendingPackets(
+ IN PRTMP_ADAPTER pAd)
+{
+ // clear PS packets
+ // clear TxSw packets
+}
+
+static int rt2860_suspend(
+ struct pci_dev *pci_dev,
+ pm_message_t state)
+{
+ struct net_device *net_dev = pci_get_drvdata(pci_dev);
+ PRTMP_ADAPTER pAd = (PRTMP_ADAPTER)NULL;
+ INT32 retval = 0;
+
+
+ DBGPRINT(RT_DEBUG_TRACE, ("===> rt2860_suspend()\n"));
+
+ if (net_dev == NULL)
+ {
+ DBGPRINT(RT_DEBUG_ERROR, ("net_dev == NULL!\n"));
+ }
+ else
+ {
+ pAd = (PRTMP_ADAPTER)RTMP_OS_NETDEV_GET_PRIV(net_dev);
+
+ /* we can not use IFF_UP because ra0 down but ra1 up */
+ /* and 1 suspend/resume function for 1 module, not for each interface */
+ /* so Linux will call suspend/resume function once */
+ if (VIRTUAL_IF_NUM(pAd) > 0)
+ {
+ // avoid users do suspend after interface is down
+
+ // stop interface
+ netif_carrier_off(net_dev);
+ netif_stop_queue(net_dev);
+
+ // mark device as removed from system and therefore no longer available
+ netif_device_detach(net_dev);
+
+ // mark halt flag
+ RTMP_SET_FLAG(pAd, fRTMP_ADAPTER_HALT_IN_PROGRESS);
+ RTMP_SET_FLAG(pAd, fRTMP_ADAPTER_RADIO_OFF);
+
+ // take down the device
+ rt28xx_close((PNET_DEV)net_dev);
+
+ RT_MOD_DEC_USE_COUNT();
+ }
+ }
+
+#if LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,10)
+ // reference to http://vovo2000.com/type-lab/linux/kernel-api/linux-kernel-api.html
+ // enable device to generate PME# when suspended
+ // pci_choose_state(): Choose the power state of a PCI device to be suspended
+ retval = pci_enable_wake(pci_dev, pci_choose_state(pci_dev, state), 1);
+ // save the PCI configuration space of a device before suspending
+ pci_save_state(pci_dev);
+ // disable PCI device after use
+ pci_disable_device(pci_dev);
+
+ retval = pci_set_power_state(pci_dev, pci_choose_state(pci_dev, state));
+#endif
+
+ DBGPRINT(RT_DEBUG_TRACE, ("<=== rt2860_suspend()\n"));
+ return retval;
+}
+
+static int rt2860_resume(
+ struct pci_dev *pci_dev)
+{
+ struct net_device *net_dev = pci_get_drvdata(pci_dev);
+ PRTMP_ADAPTER pAd = (PRTMP_ADAPTER)NULL;
+
+#if LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,10)
+ INT32 retval;
+
+
+ // set the power state of a PCI device
+ // PCI has 4 power states, DO (normal) ~ D3(less power)
+ // in include/linux/pci.h, you can find that
+ // #define PCI_D0 ((pci_power_t __force) 0)
+ // #define PCI_D1 ((pci_power_t __force) 1)
+ // #define PCI_D2 ((pci_power_t __force) 2)
+ // #define PCI_D3hot ((pci_power_t __force) 3)
+ // #define PCI_D3cold ((pci_power_t __force) 4)
+ // #define PCI_UNKNOWN ((pci_power_t __force) 5)
+ // #define PCI_POWER_ERROR ((pci_power_t __force) -1)
+ retval = pci_set_power_state(pci_dev, PCI_D0);
+
+ // restore the saved state of a PCI device
+ pci_restore_state(pci_dev);
+
+ // initialize device before it's used by a driver
+ if (pci_enable_device(pci_dev))
+ {
+ printk("pci enable fail!\n");
+ return 0;
+ }
+#endif
+
+ DBGPRINT(RT_DEBUG_TRACE, ("===> rt2860_resume()\n"));
+
+ if (net_dev == NULL)
+ {
+ DBGPRINT(RT_DEBUG_ERROR, ("net_dev == NULL!\n"));
+ }
+ else
+ pAd = (PRTMP_ADAPTER)RTMP_OS_NETDEV_GET_PRIV(net_dev);
+
+ if (pAd != NULL)
+ {
+ /* we can not use IFF_UP because ra0 down but ra1 up */
+ /* and 1 suspend/resume function for 1 module, not for each interface */
+ /* so Linux will call suspend/resume function once */
+ if (VIRTUAL_IF_NUM(pAd) > 0)
+ {
+ // mark device as attached from system and restart if needed
+ netif_device_attach(net_dev);
+
+ if (rt28xx_open((PNET_DEV)net_dev) != 0)
+ {
+ // open fail
+ DBGPRINT(RT_DEBUG_TRACE, ("<=== rt2860_resume()\n"));
+ return 0;
+ }
+
+ // increase MODULE use count
+ RT_MOD_INC_USE_COUNT();
+
+ RTMP_CLEAR_FLAG(pAd, fRTMP_ADAPTER_HALT_IN_PROGRESS);
+ RTMP_CLEAR_FLAG(pAd, fRTMP_ADAPTER_RADIO_OFF);
+
+ netif_start_queue(net_dev);
+ netif_carrier_on(net_dev);
+ netif_wake_queue(net_dev);
+ }
+ }
+
+ DBGPRINT(RT_DEBUG_TRACE, ("<=== rt2860_resume()\n"));
+ return 0;
+}
+#endif // CONFIG_PM //
+#endif
+
+
+static INT __init rt2860_init_module(VOID)
+{
+#if LINUX_VERSION_CODE >= KERNEL_VERSION(2,5,0)
+ return pci_register_driver(&rt2860_driver);
+#else
+ return pci_module_init(&rt2860_driver);
+#endif
+}
+
+
+//
+// Driver module unload function
+//
+static VOID __exit rt2860_cleanup_module(VOID)
+{
+ pci_unregister_driver(&rt2860_driver);
+}
+
+module_init(rt2860_init_module);
+module_exit(rt2860_cleanup_module);
+
+
+//
+// PCI device probe & initialization function
+//
+static INT __devinit rt2860_probe(
+ IN struct pci_dev *pci_dev,
+ IN const struct pci_device_id *pci_id)
+{
+ PRTMP_ADAPTER pAd = (PRTMP_ADAPTER)NULL;
+ struct net_device *net_dev;
+ PVOID handle;
+ PSTRING print_name;
+ ULONG csr_addr;
+ INT rv = 0;
+ RTMP_OS_NETDEV_OP_HOOK netDevHook;
+
+ DBGPRINT(RT_DEBUG_TRACE, ("===> rt2860_probe\n"));
+
+//PCIDevInit==============================================
+ // wake up and enable device
+ if ((rv = pci_enable_device(pci_dev))!= 0)
+ {
+ DBGPRINT(RT_DEBUG_ERROR, ("Enable PCI device failed, errno=%d!\n", rv));
+ return rv;
+ }
+
+#if LINUX_VERSION_CODE >= KERNEL_VERSION(2,5,0)
+ print_name = pci_dev ? pci_name(pci_dev) : "rt2860";
+#else
+ print_name = pci_dev ? pci_dev->slot_name : "rt2860";
+#endif // LINUX_VERSION_CODE //
+
+ if ((rv = pci_request_regions(pci_dev, print_name)) != 0)
+ {
+ DBGPRINT(RT_DEBUG_ERROR, ("Request PCI resource failed, errno=%d!\n", rv));
+ goto err_out;
+ }
+
+ // map physical address to virtual address for accessing register
+ csr_addr = (unsigned long) ioremap(pci_resource_start(pci_dev, 0), pci_resource_len(pci_dev, 0));
+ if (!csr_addr)
+ {
+ DBGPRINT(RT_DEBUG_ERROR, ("ioremap failed for device %s, region 0x%lX @ 0x%lX\n",
+ print_name, (ULONG)pci_resource_len(pci_dev, 0), (ULONG)pci_resource_start(pci_dev, 0)));
+ goto err_out_free_res;
+ }
+ else
+ {
+ DBGPRINT(RT_DEBUG_TRACE, ("%s: at 0x%lx, VA 0x%lx, IRQ %d. \n", print_name,
+ (ULONG)pci_resource_start(pci_dev, 0), (ULONG)csr_addr, pci_dev->irq));
+ }
+
+ // Set DMA master
+ pci_set_master(pci_dev);
+
+
+//RtmpDevInit==============================================
+ // Allocate RTMP_ADAPTER adapter structure
+ handle = kmalloc(sizeof(struct os_cookie), GFP_KERNEL);
+ if (handle == NULL)
+ {
+ DBGPRINT(RT_DEBUG_ERROR, ("%s(): Allocate memory for os handle failed!\n", __FUNCTION__));
+ goto err_out_iounmap;
+ }
+
+ ((POS_COOKIE)handle)->pci_dev = pci_dev;
+
+ rv = RTMPAllocAdapterBlock(handle, &pAd); //shiang: we may need the pci_dev for allocate structure of "RTMP_ADAPTER"
+ if (rv != NDIS_STATUS_SUCCESS)
+ goto err_out_iounmap;
+ // Here are the RTMP_ADAPTER structure with pci-bus specific parameters.
+ pAd->CSRBaseAddress = (PUCHAR)csr_addr;
+ DBGPRINT(RT_DEBUG_ERROR, ("pAd->CSRBaseAddress =0x%lx, csr_addr=0x%lx!\n", (ULONG)pAd->CSRBaseAddress, csr_addr));
+ RtmpRaDevCtrlInit(pAd, RTMP_DEV_INF_PCI);
+
+
+//NetDevInit==============================================
+ net_dev = RtmpPhyNetDevInit(pAd, &netDevHook);
+ if (net_dev == NULL)
+ goto err_out_free_radev;
+
+ // Here are the net_device structure with pci-bus specific parameters.
+ net_dev->irq = pci_dev->irq; // Interrupt IRQ number
+ net_dev->base_addr = csr_addr; // Save CSR virtual address and irq to device structure
+ pci_set_drvdata(pci_dev, net_dev); // Set driver data
+
+#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, &(pci_dev->dev));
+#endif
+#endif // NATIVE_WPA_SUPPLICANT_SUPPORT //
+
+
+//All done, it's time to register the net device to linux kernel.
+ // Register this device
+ rv = RtmpOSNetDevAttach(net_dev, &netDevHook);
+ if (rv)
+ goto err_out_free_netdev;
+
+#ifdef CONFIG_STA_SUPPORT
+ pAd->StaCfg.OriDevType = net_dev->type;
+#endif // CONFIG_STA_SUPPORT //
+RTMPInitPCIeDevice(pci_dev, pAd);
+
+ DBGPRINT(RT_DEBUG_TRACE, ("<=== rt2860_probe\n"));
+
+ return 0; // probe ok
+
+
+ /* --------------------------- ERROR HANDLE --------------------------- */
+err_out_free_netdev:
+ RtmpOSNetDevFree(net_dev);
+
+err_out_free_radev:
+ /* free RTMP_ADAPTER strcuture and os_cookie*/
+ RTMPFreeAdapter(pAd);
+
+err_out_iounmap:
+ iounmap((void *)(csr_addr));
+ release_mem_region(pci_resource_start(pci_dev, 0), pci_resource_len(pci_dev, 0));
+
+err_out_free_res:
+ pci_release_regions(pci_dev);
+
+err_out:
+ pci_disable_device(pci_dev);
+
+ DBGPRINT(RT_DEBUG_ERROR, ("<=== rt2860_probe failed with rv = %d!\n", rv));
+
+ return -ENODEV; /* probe fail */
+}
+
+
+static VOID __devexit rt2860_remove_one(
+ IN struct pci_dev *pci_dev)
+{
+ PNET_DEV net_dev = pci_get_drvdata(pci_dev);
+ RTMP_ADAPTER *pAd = RTMP_OS_NETDEV_GET_PRIV(net_dev);
+ ULONG csr_addr = net_dev->base_addr; // pAd->CSRBaseAddress;
+
+ DBGPRINT(RT_DEBUG_TRACE, ("===> rt2860_remove_one\n"));
+
+ if (pAd != NULL)
+ {
+ // Unregister/Free all allocated net_device.
+ RtmpPhyNetDevExit(pAd, net_dev);
+
+ // Unmap CSR base address
+ iounmap((char *)(csr_addr));
+
+ // release memory region
+ release_mem_region(pci_resource_start(pci_dev, 0), pci_resource_len(pci_dev, 0));
+
+ // Free RTMP_ADAPTER related structures.
+ RtmpRaDevCtrlExit(pAd);
+
+ }
+ else
+ {
+ // Unregister network device
+ RtmpOSNetDevDetach(net_dev);
+
+ // Unmap CSR base address
+ iounmap((char *)(net_dev->base_addr));
+
+ // release memory region
+ release_mem_region(pci_resource_start(pci_dev, 0), pci_resource_len(pci_dev, 0));
+ }
+
+ // Free the root net_device
+ RtmpOSNetDevFree(net_dev);
+
+}
+
+
+/*
+========================================================================
+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)
+{
+ /* always TRUE */
+ return TRUE;
+}
+
+
+
+/***************************************************************************
+ *
+ * PCIe device initialization related procedures.
+ *
+ ***************************************************************************/
+ static VOID RTMPInitPCIeDevice(
+ IN struct pci_dev *pci_dev,
+ IN PRTMP_ADAPTER pAd)
+{
+ USHORT device_id;
+ POS_COOKIE pObj;
+
+ pObj = (POS_COOKIE) pAd->OS_Cookie;
+ pci_read_config_word(pci_dev, PCI_DEVICE_ID, &device_id);
+ device_id = le2cpu16(device_id);
+ pObj->DeviceID = device_id;
+ if (
+#ifdef RT3090
+ (device_id == NIC3090_PCIe_DEVICE_ID) ||
+ (device_id == NIC3091_PCIe_DEVICE_ID) ||
+ (device_id == NIC3092_PCIe_DEVICE_ID) ||
+#endif // RT3090 //
+ 0)
+ {
+ UINT32 MacCsr0 = 0, Index= 0;
+ do
+ {
+ RTMP_IO_READ32(pAd, MAC_CSR0, &MacCsr0);
+
+ if ((MacCsr0 != 0x00) && (MacCsr0 != 0xFFFFFFFF))
+ break;
+
+ RTMPusecDelay(10);
+ } while (Index++ < 100);
+
+ // Support advanced power save after 2892/2790.
+ // MAC version at offset 0x1000 is 0x2872XXXX/0x2870XXXX(PCIe, USB, SDIO).
+ if ((MacCsr0&0xffff0000) != 0x28600000)
+ {
+ OPSTATUS_SET_FLAG(pAd, fOP_STATUS_PCIE_DEVICE);
+ }
+ }
+}
+
+#ifdef CONFIG_STA_SUPPORT
+VOID RTMPInitPCIeLinkCtrlValue(
+ IN PRTMP_ADAPTER pAd)
+{
+ INT pos;
+ USHORT reg16, data2, PCIePowerSaveLevel, Configuration;
+ UINT32 MacValue;
+ BOOLEAN bFindIntel = FALSE;
+ POS_COOKIE pObj;
+
+ pObj = (POS_COOKIE) pAd->OS_Cookie;
+
+ if (!OPSTATUS_TEST_FLAG(pAd, fOP_STATUS_PCIE_DEVICE))
+ return;
+
+ DBGPRINT(RT_DEBUG_TRACE, ("%s.===>\n", __FUNCTION__));
+ // Init EEPROM, and save settings
+ if (!(IS_RT3090(pAd) || IS_RT3572(pAd) || IS_RT3390(pAd)))
+ {
+ RT28xx_EEPROM_READ16(pAd, 0x22, PCIePowerSaveLevel);
+ pAd->PCIePowerSaveLevel = PCIePowerSaveLevel & 0xff;
+ pAd->LnkCtrlBitMask = 0;
+ if ((PCIePowerSaveLevel&0xff) == 0xff)
+ {
+ OPSTATUS_CLEAR_FLAG(pAd, fOP_STATUS_PCIE_DEVICE);
+ DBGPRINT(RT_DEBUG_TRACE, ("====> PCIePowerSaveLevel = 0x%x.\n", PCIePowerSaveLevel));
+ return;
+ }
+ else
+ {
+ PCIePowerSaveLevel &= 0x3;
+ RT28xx_EEPROM_READ16(pAd, 0x24, data2);
+
+ if( !(((data2&0xff00) == 0x9200) && ((data2&0x80) !=0)) )
+ {
+ if (PCIePowerSaveLevel > 1 )
+ PCIePowerSaveLevel = 1;
+ }
+
+ DBGPRINT(RT_DEBUG_TRACE, ("====> Write 0x83 = 0x%x.\n", PCIePowerSaveLevel));
+ AsicSendCommandToMcu(pAd, 0x83, 0xff, (UCHAR)PCIePowerSaveLevel, 0x00);
+ RT28xx_EEPROM_READ16(pAd, 0x22, PCIePowerSaveLevel);
+ PCIePowerSaveLevel &= 0xff;
+ PCIePowerSaveLevel = PCIePowerSaveLevel >> 6;
+ switch(PCIePowerSaveLevel)
+ {
+ case 0: // Only support L0
+ pAd->LnkCtrlBitMask = 0;
+ break;
+ case 1: // Only enable L0s
+ pAd->LnkCtrlBitMask = 1;
+ break;
+ case 2: // enable L1, L0s
+ pAd->LnkCtrlBitMask = 3;
+ break;
+ case 3: // sync with host clk and enable L1, L0s
+ pAd->LnkCtrlBitMask = 0x103;
+ break;
+ }
+ RT28xx_EEPROM_READ16(pAd, 0x24, data2);
+ if ((PCIePowerSaveLevel&0xff) != 0xff)
+ {
+ PCIePowerSaveLevel &= 0x3;
+
+ if( !(((data2&0xff00) == 0x9200) && ((data2&0x80) !=0)) )
+ {
+ if (PCIePowerSaveLevel > 1 )
+ PCIePowerSaveLevel = 1;
+ }
+
+ DBGPRINT(RT_DEBUG_TRACE, ("====> rt28xx Write 0x83 Command = 0x%x.\n", PCIePowerSaveLevel));
+ printk("\n\n\n%s:%d\n",__FUNCTION__,__LINE__);
+
+ AsicSendCommandToMcu(pAd, 0x83, 0xff, (UCHAR)PCIePowerSaveLevel, 0x00);
+ }
+ DBGPRINT(RT_DEBUG_TRACE, ("====> LnkCtrlBitMask = 0x%x.\n", pAd->LnkCtrlBitMask));
+ }
+ }
+ else if (IS_RT3090(pAd) || IS_RT3572(pAd) || IS_RT3390(pAd))
+ {
+ UCHAR LinkCtrlSetting = 0;
+
+ // Check 3090E special setting chip.
+ RT28xx_EEPROM_READ16(pAd, 0x24, data2);
+ if ((data2 == 0x9280) && ((pAd->MACVersion&0xffff) == 0x0211))
+ {
+ pAd->b3090ESpecialChip = TRUE;
+ DBGPRINT_RAW(RT_DEBUG_ERROR,("Special 3090E chip \n"));
+ }
+
+ RTMP_IO_READ32(pAd, AUX_CTRL, &MacValue);
+ //enable WAKE_PCIE function, which forces to enable PCIE clock when mpu interrupt asserting.
+ //Force PCIE 125MHz CLK to toggle
+ MacValue |= 0x402;
+ RTMP_IO_WRITE32(pAd, AUX_CTRL, MacValue);
+ DBGPRINT_RAW(RT_DEBUG_ERROR,(" AUX_CTRL = 0x%32x\n", MacValue));
+
+
+
+ // for RT30xx F and after, PCIe infterface, and for power solution 3
+ if ((IS_VERSION_AFTER_F(pAd))
+ && (pAd->StaCfg.PSControl.field.rt30xxPowerMode >= 2)
+ && (pAd->StaCfg.PSControl.field.rt30xxPowerMode <= 3))
+ {
+ RTMP_IO_READ32(pAd, AUX_CTRL, &MacValue);
+ DBGPRINT_RAW(RT_DEBUG_ERROR,(" Read AUX_CTRL = 0x%x\n", MacValue));
+ // turn on bit 12.
+ //enable 32KHz clock mode for power saving
+ MacValue |= 0x1000;
+ if (MacValue != 0xffffffff)
+ {
+ RTMP_IO_WRITE32(pAd, AUX_CTRL, MacValue);
+ DBGPRINT_RAW(RT_DEBUG_ERROR,(" Write AUX_CTRL = 0x%x\n", MacValue));
+ // 1. if use PCIePowerSetting is 2 or 3, need to program OSC_CTRL to 0x3ff11.
+ MacValue = 0x3ff11;
+ RTMP_IO_WRITE32(pAd, OSC_CTRL, MacValue);
+ DBGPRINT_RAW(RT_DEBUG_ERROR,(" OSC_CTRL = 0x%x\n", MacValue));
+ // 2. Write PCI register Clk ref bit
+ RTMPrt3xSetPCIePowerLinkCtrl(pAd);
+ }
+ else
+ {
+ // Error read Aux_Ctrl value. Force to use solution 1
+ DBGPRINT(RT_DEBUG_ERROR,(" Error Value in AUX_CTRL = 0x%x\n", MacValue));
+ pAd->StaCfg.PSControl.field.rt30xxPowerMode = 1;
+ DBGPRINT(RT_DEBUG_ERROR,(" Force to use power solution1 \n"));
+ }
+ }
+ // 1. read setting from inf file.
+
+ PCIePowerSaveLevel = (USHORT)pAd->StaCfg.PSControl.field.rt30xxPowerMode;
+ DBGPRINT(RT_DEBUG_ERROR, ("====> rt30xx Read PowerLevelMode = 0x%x.\n", PCIePowerSaveLevel));
+ // 2. Check EnableNewPS.
+ if (pAd->StaCfg.PSControl.field.EnableNewPS == FALSE)
+ PCIePowerSaveLevel = 1;
+
+ if (IS_VERSION_BEFORE_F(pAd) && (pAd->b3090ESpecialChip == FALSE))
+ {
+ // Chip Version E only allow 1, So force set 1.
+ PCIePowerSaveLevel &= 0x1;
+ pAd->PCIePowerSaveLevel = (USHORT)PCIePowerSaveLevel;
+ DBGPRINT(RT_DEBUG_TRACE, ("====> rt30xx E Write 0x83 Command = 0x%x.\n", PCIePowerSaveLevel));
+
+ AsicSendCommandToMcu(pAd, 0x83, 0xff, (UCHAR)PCIePowerSaveLevel, 0x00);
+ }
+ else
+ {
+ // Chip Version F and after only allow 1 or 2 or 3. This might be modified after new chip version come out.
+ if (!((PCIePowerSaveLevel == 1) || (PCIePowerSaveLevel == 3)))
+ PCIePowerSaveLevel = 1;
+ DBGPRINT(RT_DEBUG_ERROR, ("====> rt30xx F Write 0x83 Command = 0x%x.\n", PCIePowerSaveLevel));
+ pAd->PCIePowerSaveLevel = (USHORT)PCIePowerSaveLevel;
+ // for 3090F , we need to add high-byte arg for 0x83 command to indicate the link control setting in
+ // PCI Configuration Space. Because firmware can't read PCI Configuration Space
+ if ((pAd->Rt3xxRalinkLinkCtrl & 0x2) && (pAd->Rt3xxHostLinkCtrl & 0x2))
+ {
+ LinkCtrlSetting = 1;
+ }
+ DBGPRINT(RT_DEBUG_TRACE, ("====> rt30xxF LinkCtrlSetting = 0x%x.\n", LinkCtrlSetting));
+ AsicSendCommandToMcu(pAd, 0x83, 0xff, (UCHAR)PCIePowerSaveLevel, LinkCtrlSetting);
+ }
+
+ }
+
+ // Find Ralink PCIe Device's Express Capability Offset
+ pos = pci_find_capability(pObj->pci_dev, PCI_CAP_ID_EXP);
+
+ if (pos != 0)
+ {
+ // Ralink PCIe Device's Link Control Register Offset
+ pAd->RLnkCtrlOffset = pos + PCI_EXP_LNKCTL;
+ pci_read_config_word(pObj->pci_dev, pAd->RLnkCtrlOffset, &reg16);
+ Configuration = le2cpu16(reg16);
+ DBGPRINT(RT_DEBUG_TRACE, ("Read (Ralink PCIe Link Control Register) offset 0x%x = 0x%x\n",
+ pAd->RLnkCtrlOffset, Configuration));
+ pAd->RLnkCtrlConfiguration = (Configuration & 0x103);
+ Configuration &= 0xfefc;
+ Configuration |= (0x0);
+
+ RTMPFindHostPCIDev(pAd);
+ if (pObj->parent_pci_dev)
+ {
+ USHORT vendor_id;
+
+ pci_read_config_word(pObj->parent_pci_dev, PCI_VENDOR_ID, &vendor_id);
+ vendor_id = le2cpu16(vendor_id);
+ if (vendor_id == PCIBUS_INTEL_VENDOR)
+ {
+ bFindIntel = TRUE;
+ RTMP_SET_PSFLAG(pAd, fRTMP_PS_TOGGLE_L1);
+ }
+ /*
+ else if ((vendor_id == PCIBUS_AMD_VENDOR1)
+ && (DeviceID == 0x96000000))
+ {
+ //Verified 2792 Aspire 8530 AMD NB (S3/S4/CBoot/WBoot/Chariot) by customer and ourselves.
+ // So use L1 Toggle method in this NB.
+ bFindIntel = TRUE;
+ RTMP_SET_PSFLAG(pAd, fRTMP_PS_TOGGLE_L1);
+ DBGPRINT(RT_DEBUG_TRACE, ("PSM : Aspire 8530 AMD NB. Use L1 Toggle. \n"));
+ }
+ */
+ // Find PCI-to-PCI Bridge Express Capability Offset
+ pos = pci_find_capability(pObj->parent_pci_dev, PCI_CAP_ID_EXP);
+
+ if (pos != 0)
+ {
+ BOOLEAN bChange = FALSE;
+ // PCI-to-PCI Bridge Link Control Register Offset
+ pAd->HostLnkCtrlOffset = pos + PCI_EXP_LNKCTL;
+ pci_read_config_word(pObj->parent_pci_dev, pAd->HostLnkCtrlOffset, &reg16);
+ Configuration = le2cpu16(reg16);
+ DBGPRINT(RT_DEBUG_TRACE, ("Read (Host PCI-to-PCI Bridge Link Control Register) offset 0x%x = 0x%x\n",
+ pAd->HostLnkCtrlOffset, Configuration));
+ pAd->HostLnkCtrlConfiguration = (Configuration & 0x103);
+ Configuration &= 0xfefc;
+ Configuration |= (0x0);
+
+ switch (pObj->DeviceID)
+ {
+#ifdef RT3090
+ case NIC3090_PCIe_DEVICE_ID:
+ case NIC3091_PCIe_DEVICE_ID:
+ case NIC3092_PCIe_DEVICE_ID:
+ if (bFindIntel == FALSE)
+ bChange = TRUE;
+ break;
+#endif // RT3090 //
+ default:
+ break;
+ }
+
+ if (bChange)
+ {
+ reg16 = cpu2le16(Configuration);
+ pci_write_config_word(pObj->parent_pci_dev, pAd->HostLnkCtrlOffset, reg16);
+ DBGPRINT(RT_DEBUG_TRACE, ("Write (Host PCI-to-PCI Bridge Link Control Register) offset 0x%x = 0x%x\n",
+ pAd->HostLnkCtrlOffset, Configuration));
+ }
+ }
+ else
+ {
+ pAd->HostLnkCtrlOffset = 0;
+ DBGPRINT(RT_DEBUG_ERROR, ("%s: cannot find PCI-to-PCI Bridge PCI Express Capability!\n", __FUNCTION__));
+ }
+ }
+ }
+ else
+ {
+ pAd->RLnkCtrlOffset = 0;
+ pAd->HostLnkCtrlOffset = 0;
+ DBGPRINT(RT_DEBUG_ERROR, ("%s: cannot find Ralink PCIe Device's PCI Express Capability!\n", __FUNCTION__));
+ }
+
+ if (bFindIntel == FALSE)
+ {
+ DBGPRINT(RT_DEBUG_TRACE, ("Doesn't find Intel PCI host controller. \n"));
+ // Doesn't switch L0, L1, So set PCIePowerSaveLevel to 0xff
+ pAd->PCIePowerSaveLevel = 0xff;
+ if ((pAd->RLnkCtrlOffset != 0)
+#ifdef RT3090
+ && ((pObj->DeviceID == NIC3090_PCIe_DEVICE_ID)
+ ||(pObj->DeviceID == NIC3091_PCIe_DEVICE_ID)
+ ||(pObj->DeviceID == NIC3092_PCIe_DEVICE_ID))
+#endif // RT3090 //
+ )
+ {
+ pci_read_config_word(pObj->pci_dev, pAd->RLnkCtrlOffset, &reg16);
+ Configuration = le2cpu16(reg16);
+ DBGPRINT(RT_DEBUG_TRACE, ("Read (Ralink 30xx PCIe Link Control Register) offset 0x%x = 0x%x\n",
+ pAd->RLnkCtrlOffset, Configuration));
+ pAd->RLnkCtrlConfiguration = (Configuration & 0x103);
+ Configuration &= 0xfefc;
+ Configuration |= (0x0);
+ reg16 = cpu2le16(Configuration);
+ pci_write_config_word(pObj->pci_dev, pAd->RLnkCtrlOffset, reg16);
+ DBGPRINT(RT_DEBUG_TRACE, ("Write (Ralink PCIe Link Control Register) offset 0x%x = 0x%x\n",
+ pos + PCI_EXP_LNKCTL, Configuration));
+ }
+ }
+}
+
+VOID RTMPFindHostPCIDev(
+ IN PRTMP_ADAPTER pAd)
+{
+ USHORT reg16;
+ UCHAR reg8;
+ UINT DevFn;
+ PPCI_DEV pPci_dev;
+ POS_COOKIE pObj;
+
+ pObj = (POS_COOKIE) pAd->OS_Cookie;
+
+ if (!OPSTATUS_TEST_FLAG(pAd, fOP_STATUS_PCIE_DEVICE))
+ return;
+
+ DBGPRINT(RT_DEBUG_TRACE, ("%s.===>\n", __FUNCTION__));
+
+ pObj->parent_pci_dev = NULL;
+ if (pObj->pci_dev->bus->parent)
+ {
+ for (DevFn = 0; DevFn < 255; DevFn++)
+ {
+#if LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,0)
+ pPci_dev = pci_get_slot(pObj->pci_dev->bus->parent, DevFn);
+#else
+ pPci_dev = pci_find_slot(pObj->pci_dev->bus->parent->number, DevFn);
+#endif
+ if (pPci_dev)
+ {
+ pci_read_config_word(pPci_dev, PCI_CLASS_DEVICE, &reg16);
+ reg16 = le2cpu16(reg16);
+ pci_read_config_byte(pPci_dev, PCI_CB_CARD_BUS, &reg8);
+ if ((reg16 == PCI_CLASS_BRIDGE_PCI) &&
+ (reg8 == pObj->pci_dev->bus->number))
+ {
+ pObj->parent_pci_dev = pPci_dev;
+ }
+ }
+ }
+ }
+}
+
+/*
+ ========================================================================
+
+ Routine Description:
+
+ Arguments:
+ Level = RESTORE_HALT : Restore PCI host and Ralink PCIe Link Control field to its default value.
+ Level = Other Value : Restore from dot11 power save or radio off status. And force PCI host Link Control fields to 0x1
+
+ ========================================================================
+*/
+VOID RTMPPCIeLinkCtrlValueRestore(
+ IN PRTMP_ADAPTER pAd,
+ IN UCHAR Level)
+{
+ USHORT PCIePowerSaveLevel, reg16;
+ USHORT Configuration;
+ POS_COOKIE pObj;
+
+ pObj = (POS_COOKIE) pAd->OS_Cookie;
+
+ if (!OPSTATUS_TEST_FLAG(pAd, fOP_STATUS_PCIE_DEVICE))
+ return;
+
+ // Check PSControl Configuration
+ if (pAd->StaCfg.PSControl.field.EnableNewPS == FALSE)
+ return TRUE;
+
+ //3090 will not execute the following codes.
+ // Check interface : If not PCIe interface, return.
+
+#ifdef RT3090
+ if ((pObj->DeviceID == NIC3090_PCIe_DEVICE_ID)
+ ||(pObj->DeviceID == NIC3091_PCIe_DEVICE_ID)
+ ||(pObj->DeviceID == NIC3092_PCIe_DEVICE_ID))
+ return;
+#endif // RT3090 //
+ DBGPRINT(RT_DEBUG_TRACE, ("%s.===>\n", __FUNCTION__));
+ PCIePowerSaveLevel = pAd->PCIePowerSaveLevel;
+ if ((PCIePowerSaveLevel&0xff) == 0xff)
+ {
+ DBGPRINT(RT_DEBUG_TRACE,("return \n"));
+ return;
+ }
+
+ if (pObj->parent_pci_dev && (pAd->HostLnkCtrlOffset != 0))
+ {
+ PCI_REG_READ_WORD(pObj->parent_pci_dev, pAd->HostLnkCtrlOffset, Configuration);
+ if ((Configuration != 0) &&
+ (Configuration != 0xFFFF))
+ {
+ Configuration &= 0xfefc;
+ // If call from interface down, restore to orginial setting.
+ if (Level == RESTORE_CLOSE)
+ {
+ Configuration |= pAd->HostLnkCtrlConfiguration;
+ }
+ else
+ Configuration |= 0x0;
+ PCI_REG_WIRTE_WORD(pObj->parent_pci_dev, pAd->HostLnkCtrlOffset, Configuration);
+ DBGPRINT(RT_DEBUG_TRACE, ("Restore PCI host : offset 0x%x = 0x%x\n", pAd->HostLnkCtrlOffset, Configuration));
+ }
+ else
+ DBGPRINT(RT_DEBUG_ERROR, ("Restore PCI host : PCI_REG_READ_WORD failed (Configuration = 0x%x)\n", Configuration));
+ }
+
+ if (pObj->pci_dev && (pAd->RLnkCtrlOffset != 0))
+ {
+ PCI_REG_READ_WORD(pObj->pci_dev, pAd->RLnkCtrlOffset, Configuration);
+ if ((Configuration != 0) &&
+ (Configuration != 0xFFFF))
+ {
+ Configuration &= 0xfefc;
+ // If call from interface down, restore to orginial setting.
+ if (Level == RESTORE_CLOSE)
+ Configuration |= pAd->RLnkCtrlConfiguration;
+ else
+ Configuration |= 0x0;
+ PCI_REG_WIRTE_WORD(pObj->pci_dev, pAd->RLnkCtrlOffset, Configuration);
+ DBGPRINT(RT_DEBUG_TRACE, ("Restore Ralink : offset 0x%x = 0x%x\n", pAd->RLnkCtrlOffset, Configuration));
+ }
+ else
+ DBGPRINT(RT_DEBUG_ERROR, ("Restore Ralink : PCI_REG_READ_WORD failed (Configuration = 0x%x)\n", Configuration));
+ }
+
+ DBGPRINT(RT_DEBUG_TRACE,("%s <===\n", __FUNCTION__));
+}
+
+/*
+ ========================================================================
+
+ Routine Description:
+
+ Arguments:
+ Max : limit Host PCI and Ralink PCIe device's LINK CONTROL field's value.
+ Because now frequently set our device to mode 1 or mode 3 will cause problem.
+
+ ========================================================================
+*/
+VOID RTMPPCIeLinkCtrlSetting(
+ IN PRTMP_ADAPTER pAd,
+ IN USHORT Max)
+{
+ USHORT PCIePowerSaveLevel, reg16;
+ USHORT Configuration;
+ POS_COOKIE pObj;
+
+ pObj = (POS_COOKIE) pAd->OS_Cookie;
+
+ if (!OPSTATUS_TEST_FLAG(pAd, fOP_STATUS_PCIE_DEVICE))
+ return;
+
+ // Check PSControl Configuration
+ if (pAd->StaCfg.PSControl.field.EnableNewPS == FALSE)
+ return TRUE;
+
+ // Check interface : If not PCIe interface, return.
+ //Block 3090 to enter the following function
+
+#ifdef RT3090
+ if ((pObj->DeviceID == NIC3090_PCIe_DEVICE_ID)
+ ||(pObj->DeviceID == NIC3091_PCIe_DEVICE_ID)
+ ||(pObj->DeviceID == NIC3092_PCIe_DEVICE_ID))
+ return;
+#endif // RT3090 //
+ if (!RTMP_TEST_PSFLAG(pAd, fRTMP_PS_CAN_GO_SLEEP))
+ {
+ DBGPRINT(RT_DEBUG_INFO, ("RTMPPCIePowerLinkCtrl return on fRTMP_PS_CAN_GO_SLEEP flag\n"));
+ return;
+ }
+ DBGPRINT(RT_DEBUG_TRACE,("%s===>\n", __FUNCTION__));
+ PCIePowerSaveLevel = pAd->PCIePowerSaveLevel;
+ if ((PCIePowerSaveLevel&0xff) == 0xff)
+ {
+ DBGPRINT(RT_DEBUG_TRACE,("return \n"));
+ return;
+ }
+ PCIePowerSaveLevel = PCIePowerSaveLevel>>6;
+
+ // Skip non-exist deice right away
+ if (pObj->parent_pci_dev && (pAd->HostLnkCtrlOffset != 0))
+ {
+ PCI_REG_READ_WORD(pObj->parent_pci_dev, pAd->HostLnkCtrlOffset, Configuration);
+ switch (PCIePowerSaveLevel)
+ {
+ case 0:
+ // Set b0 and b1 of LinkControl (both 2892 and PCIe bridge) to 00
+ Configuration &= 0xfefc;
+ break;
+ case 1:
+ // Set b0 and b1 of LinkControl (both 2892 and PCIe bridge) to 01
+ Configuration &= 0xfefc;
+ Configuration |= 0x1;
+ break;
+ case 2:
+ // Set b0 and b1 of LinkControl (both 2892 and PCIe bridge) to 11
+ Configuration &= 0xfefc;
+ Configuration |= 0x3;
+ break;
+ case 3:
+ // Set b0 and b1 of LinkControl (both 2892 and PCIe bridge) to 11 and bit 8 of LinkControl of 2892 to 1
+ Configuration &= 0xfefc;
+ Configuration |= 0x103;
+ break;
+ }
+ PCI_REG_WIRTE_WORD(pObj->parent_pci_dev, pAd->HostLnkCtrlOffset, Configuration);
+ DBGPRINT(RT_DEBUG_TRACE, ("Write PCI host offset 0x%x = 0x%x\n", pAd->HostLnkCtrlOffset, Configuration));
+ }
+
+ if (pObj->pci_dev && (pAd->RLnkCtrlOffset != 0))
+ {
+ // first 2892 chip not allow to frequently set mode 3. will cause hang problem.
+ if (PCIePowerSaveLevel > Max)
+ PCIePowerSaveLevel = Max;
+
+ PCI_REG_READ_WORD(pObj->pci_dev, pAd->RLnkCtrlOffset, Configuration);
+ switch (PCIePowerSaveLevel)
+ {
+ case 0:
+ // No PCI power safe
+ // Set b0 and b1 of LinkControl (both 2892 and PCIe bridge) to 00 .
+ Configuration &= 0xfefc;
+ break;
+ case 1:
+ // L0
+ // Set b0 and b1 of LinkControl (both 2892 and PCIe bridge) to 01 .
+ Configuration &= 0xfefc;
+ Configuration |= 0x1;
+ break;
+ case 2:
+ // L0 and L1
+ // Set b0 and b1 of LinkControl (both 2892 and PCIe bridge) to 11
+ Configuration &= 0xfefc;
+ Configuration |= 0x3;
+ break;
+ case 3:
+ // L0 , L1 and clock management.
+ // Set b0 and b1 of LinkControl (both 2892 and PCIe bridge) to 11 and bit 8 of LinkControl of 2892 to 1
+ Configuration &= 0xfefc;
+ Configuration |= 0x103;
+ pAd->bPCIclkOff = TRUE;
+ break;
+ }
+ PCI_REG_WIRTE_WORD(pObj->pci_dev, pAd->RLnkCtrlOffset, Configuration);
+ DBGPRINT(RT_DEBUG_TRACE, ("Write Ralink device : offset 0x%x = 0x%x\n", pAd->RLnkCtrlOffset, Configuration));
+ }
+
+ DBGPRINT(RT_DEBUG_TRACE,("RTMPPCIePowerLinkCtrl <==============\n"));
+}
+/*
+ ========================================================================
+
+ Routine Description:
+ 1. Write a PCI register for rt30xx power solution 3
+
+ ========================================================================
+*/
+VOID RTMPrt3xSetPCIePowerLinkCtrl(
+ IN PRTMP_ADAPTER pAd)
+{
+
+ ULONG HostConfiguration;
+ ULONG Configuration;
+ ULONG Vendor;
+ ULONG offset;
+ POS_COOKIE pObj;
+ INT pos;
+ USHORT reg16;
+
+ pObj = (POS_COOKIE) pAd->OS_Cookie;
+
+ DBGPRINT(RT_DEBUG_INFO, ("RTMPrt3xSetPCIePowerLinkCtrl.===> %x\n", pAd->StaCfg.PSControl.word));
+
+ // Check PSControl Configuration
+ if (pAd->StaCfg.PSControl.field.EnableNewPS == FALSE)
+ return;
+ RTMPFindHostPCIDev(pAd);
+ if (pObj->parent_pci_dev)
+ {
+ USHORT vendor_id;
+ // Find PCI-to-PCI Bridge Express Capability Offset
+ pos = pci_find_capability(pObj->parent_pci_dev, PCI_CAP_ID_EXP);
+
+ if (pos != 0)
+ {
+ pAd->HostLnkCtrlOffset = pos + PCI_EXP_LNKCTL;
+ }
+ // If configurared to turn on L1.
+ HostConfiguration = 0;
+ if (pAd->StaCfg.PSControl.field.rt30xxForceASPMTest == 1)
+ {
+ DBGPRINT(RT_DEBUG_TRACE, ("Enter,PSM : Force ASPM \n"));
+
+ // Skip non-exist deice right away
+ if ((pAd->HostLnkCtrlOffset != 0))
+ {
+ PCI_REG_READ_WORD(pObj->parent_pci_dev, pAd->HostLnkCtrlOffset, HostConfiguration);
+ // Prepare Configuration to write to Host
+ HostConfiguration |= 0x3;
+ PCI_REG_WIRTE_WORD(pObj->parent_pci_dev, pAd->HostLnkCtrlOffset, HostConfiguration);
+ pAd->Rt3xxHostLinkCtrl = HostConfiguration;
+ // Because in rt30xxForceASPMTest Mode, Force turn on L0s, L1.
+ // Fix HostConfiguration bit0:1 = 0x3 for later use.
+ HostConfiguration = 0x3;
+ DBGPRINT(RT_DEBUG_TRACE, ("PSM : Force ASPM : Host device L1/L0s Value = 0x%x\n", HostConfiguration));
+ }
+ }
+ else if (pAd->StaCfg.PSControl.field.rt30xxFollowHostASPM == 1)
+ {
+
+ // Skip non-exist deice right away
+ if ((pAd->HostLnkCtrlOffset != 0))
+ {
+ PCI_REG_READ_WORD(pObj->parent_pci_dev, pAd->HostLnkCtrlOffset, HostConfiguration);
+ pAd->Rt3xxHostLinkCtrl = HostConfiguration;
+ HostConfiguration &= 0x3;
+ DBGPRINT(RT_DEBUG_TRACE, ("PSM : Follow Host ASPM : Host device L1/L0s Value = 0x%x\n", HostConfiguration));
+ }
+ }
+ }
+ // Prepare to write Ralink setting.
+ // Find Ralink PCIe Device's Express Capability Offset
+ pos = pci_find_capability(pObj->pci_dev, PCI_CAP_ID_EXP);
+
+ if (pos != 0)
+ {
+ // Ralink PCIe Device's Link Control Register Offset
+ pAd->RLnkCtrlOffset = pos + PCI_EXP_LNKCTL;
+ pci_read_config_word(pObj->pci_dev, pAd->RLnkCtrlOffset, &reg16);
+ Configuration = le2cpu16(reg16);
+ DBGPRINT(RT_DEBUG_TRACE, ("Read (Ralink PCIe Link Control Register) offset 0x%x = 0x%x\n",
+ pAd->RLnkCtrlOffset, Configuration));
+ Configuration |= 0x100;
+ if ((pAd->StaCfg.PSControl.field.rt30xxFollowHostASPM == 1)
+ || (pAd->StaCfg.PSControl.field.rt30xxForceASPMTest == 1))
+ {
+ switch(HostConfiguration)
+ {
+ case 0:
+ Configuration &= 0xffffffc;
+ break;
+ case 1:
+ Configuration &= 0xffffffc;
+ Configuration |= 0x1;
+ break;
+ case 2:
+ Configuration &= 0xffffffc;
+ Configuration |= 0x2;
+ break;
+ case 3:
+ Configuration |= 0x3;
+ break;
+ }
+ }
+ reg16 = cpu2le16(Configuration);
+ pci_write_config_word(pObj->pci_dev, pAd->RLnkCtrlOffset, reg16);
+ pAd->Rt3xxRalinkLinkCtrl = Configuration;
+ DBGPRINT(RT_DEBUG_TRACE, ("PSM :Write Ralink device L1/L0s Value = 0x%x\n", Configuration));
+ }
+ DBGPRINT(RT_DEBUG_INFO,("PSM :RTMPrt3xSetPCIePowerLinkCtrl <==============\n"));
+
+}
+
+#endif // CONFIG_STA_SUPPORT //
diff --git a/drivers/staging/rt3090/rt3090.h b/drivers/staging/rt3090/rt3090.h
new file mode 100644
index 000000000000..d325cb028c05
--- /dev/null
+++ b/drivers/staging/rt3090/rt3090.h
@@ -0,0 +1,77 @@
+/*
+ *************************************************************************
+ * 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:
+ rt3090.h
+
+ Abstract:
+
+ Revision History:
+ Who When What
+ --------- ---------- ----------------------------------------------
+ */
+
+#ifndef __RT3090_H__
+#define __RT3090_H__
+
+#ifdef RT3090
+
+#ifndef RTMP_PCI_SUPPORT
+#error "For RT3090, you should define the compile flag -DRTMP_PCI_SUPPORT"
+#endif
+
+#ifndef RTMP_MAC_PCI
+#error "For RT3090, you should define the compile flag -DRTMP_MAC_PCI"
+#endif
+
+#ifndef RTMP_RF_RW_SUPPORT
+#error "For RT3090, you should define the compile flag -DRTMP_RF_RW_SUPPORT"
+#endif
+
+#ifndef RT30xx
+#error "For RT3090, you should define the compile flag -DRT30xx"
+#endif
+
+#ifdef CARRIER_DETECTION_SUPPORT
+#define TONE_RADAR_DETECT_SUPPORT
+#define CARRIER_SENSE_NEW_ALGO
+#endif // CARRIER_DETECTION_SUPPORT //
+
+#define PCIE_PS_SUPPORT
+
+#include "mac_pci.h"
+#include "rt30xx.h"
+
+//
+// Device ID & Vendor ID, these values should match EEPROM value
+//
+#define NIC3090_PCIe_DEVICE_ID 0x3090 // 1T/1R miniCard
+#define NIC3091_PCIe_DEVICE_ID 0x3091 // 1T/2R miniCard
+#define NIC3092_PCIe_DEVICE_ID 0x3092 // 2T/2R miniCard
+
+#endif // RT3090 //
+
+#endif //__RT3090_H__ //
diff --git a/drivers/staging/rt2860/md4.h b/drivers/staging/rt3090/rt30xx.h
index f1e5b526350a..70971a062607 100644
--- a/drivers/staging/rt2860/md4.h
+++ b/drivers/staging/rt3090/rt30xx.h
@@ -23,20 +23,26 @@
* 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. *
* *
*************************************************************************
+
+ Module Name:
+ rt30xx.h
+
+ Abstract:
+
+ Revision History:
+ Who When What
+ --------- ---------- ----------------------------------------------
*/
-#ifndef __MD4_H__
-#define __MD4_H__
+#ifndef __RT30XX_H__
+#define __RT30XX_H__
+
+#ifdef RT30xx
+
-/* MD4 context. */
-typedef struct _MD4_CTX_ {
- ULONG state[4]; /* state (ABCD) */
- ULONG count[2]; /* number of bits, modulo 2^64 (lsb first) */
- UCHAR buffer[64]; /* input buffer */
-} MD4_CTX;
+extern REG_PAIR RT30xx_RFRegTable[];
+extern UCHAR NUM_RF_REG_PARMS;
-VOID MD4Init (MD4_CTX *);
-VOID MD4Update (MD4_CTX *, PUCHAR, UINT);
-VOID MD4Final (UCHAR [16], MD4_CTX *);
+#endif // RT30xx //
-#endif //__MD4_H__ \ No newline at end of file
+#endif //__RT30XX_H__ //
diff --git a/drivers/staging/rt3090/rt3370.h b/drivers/staging/rt3090/rt3370.h
new file mode 100644
index 000000000000..bfa9006d059a
--- /dev/null
+++ b/drivers/staging/rt3090/rt3370.h
@@ -0,0 +1,64 @@
+/*
+ *************************************************************************
+ * 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:
+ rt3370.h
+
+ Abstract:
+
+ Revision History:
+ Who When What
+ --------- ---------- ----------------------------------------------
+ */
+
+#ifndef __RT3370_H__
+#define __RT3370_H__
+
+#ifdef RT3370
+
+
+#error "For RT3070, you should define the compile flag -DRTMP_USB_SUPPORT"
+
+#error "For RT3070, you should define the compile flag -DRTMP_MAC_USB"
+
+#ifndef RTMP_RF_RW_SUPPORT
+#error "For RT3070, you should define the compile flag -DRTMP_RF_RW_SUPPORT"
+#endif
+
+#ifndef RT33xx
+#error "For RT3070, you should define the compile flag -DRT30xx"
+#endif
+
+#include "mac_usb.h"
+#include "rt33xx.h"
+
+//
+// Device ID & Vendor ID, these values should match EEPROM value
+//
+
+#endif // RT3370 //
+
+#endif //__RT3370_H__ //
diff --git a/drivers/staging/rt3090/rt3390.h b/drivers/staging/rt3090/rt3390.h
new file mode 100644
index 000000000000..412ab3d32ab5
--- /dev/null
+++ b/drivers/staging/rt3090/rt3390.h
@@ -0,0 +1,77 @@
+/*
+ *************************************************************************
+ * 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:
+ rt3390.h
+
+ Abstract:
+
+ Revision History:
+ Who When What
+ --------- ---------- ----------------------------------------------
+ */
+
+#ifndef __RT3390_H__
+#define __RT3390_H__
+
+#ifdef RT3390
+
+#ifndef RTMP_PCI_SUPPORT
+#error "For RT3390, you should define the compile flag -DRTMP_PCI_SUPPORT"
+#endif
+
+#ifndef RTMP_MAC_PCI
+#error "For RT3390, you should define the compile flag -DRTMP_MAC_PCI"
+#endif
+
+#ifndef RTMP_RF_RW_SUPPORT
+#error "For RT3390, you should define the compile flag -DRTMP_RF_RW_SUPPORT"
+#endif
+
+#ifndef RT30xx
+#error "For RT3390, you should define the compile flag -DRT30xx"
+#endif
+
+#ifdef CARRIER_DETECTION_SUPPORT
+#define TONE_RADAR_DETECT_SUPPORT
+#define CARRIER_SENSE_NEW_ALGO
+#endif // CARRIER_DETECTION_SUPPORT //
+
+#define PCIE_PS_SUPPORT
+
+#include "mac_pci.h"
+#include "rt33xx.h"
+
+//
+// Device ID & Vendor ID, these values should match EEPROM value
+//
+#define NIC3390_PCIe_DEVICE_ID 0x3090 // 1T/1R miniCard
+#define NIC3391_PCIe_DEVICE_ID 0x3091 // 1T/2R miniCard
+#define NIC3392_PCIe_DEVICE_ID 0x3092 // 2T/2R miniCard
+
+#endif // RT3390 //
+
+#endif //__RT3390_H__ //
diff --git a/drivers/staging/rt2870/md4.h b/drivers/staging/rt3090/rt33xx.h
index f1e5b526350a..6eb938860b77 100644
--- a/drivers/staging/rt2870/md4.h
+++ b/drivers/staging/rt3090/rt33xx.h
@@ -23,20 +23,26 @@
* 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. *
* *
*************************************************************************
+
+ Module Name:
+ rt33xx.h
+
+ Abstract:
+
+ Revision History:
+ Who When What
+ --------- ---------- ----------------------------------------------
*/
-#ifndef __MD4_H__
-#define __MD4_H__
+#ifndef __RT33XX_H__
+#define __RT33XX_H__
+
+#ifdef RT33xx
+
-/* MD4 context. */
-typedef struct _MD4_CTX_ {
- ULONG state[4]; /* state (ABCD) */
- ULONG count[2]; /* number of bits, modulo 2^64 (lsb first) */
- UCHAR buffer[64]; /* input buffer */
-} MD4_CTX;
+extern REG_PAIR RFRegTableOverRT3390[];
+extern UCHAR NUM_RF_REG_PARMS_OVER_RT3390;
-VOID MD4Init (MD4_CTX *);
-VOID MD4Update (MD4_CTX *, PUCHAR, UINT);
-VOID MD4Final (UCHAR [16], MD4_CTX *);
+#endif // RT33xx //
-#endif //__MD4_H__ \ No newline at end of file
+#endif //__RT33XX_H__ //
diff --git a/drivers/staging/rt3090/rt_ate.c b/drivers/staging/rt3090/rt_ate.c
new file mode 100644
index 000000000000..259aae411628
--- /dev/null
+++ b/drivers/staging/rt3090/rt_ate.c
@@ -0,0 +1,6089 @@
+/*
+ *************************************************************************
+ * 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
+
+#ifdef RT30xx
+#define ATE_BBP_REG_NUM 168
+UCHAR restore_BBP[ATE_BBP_REG_NUM]={0};
+#endif // RT30xx //
+
+// 802.11 MAC Header, Type:Data, Length:24bytes
+UCHAR TemplateFrame[24] = {0x08,0x00,0x00,0x00,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,
+ 0x00,0xAA,0xBB,0x12,0x34,0x56,0x00,0x11,0x22,0xAA,0xBB,0xCC,0x00,0x00};
+
+extern RTMP_RF_REGS RF2850RegTable[];
+extern UCHAR NUM_OF_2850_CHNL;
+
+extern FREQUENCY_ITEM FreqItems3020[];
+extern UCHAR NUM_OF_3020_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 PSTRING arg);
+
+#ifndef RT30xx
+static int CheckMCSValid(
+ IN UCHAR Mode,
+ IN UCHAR Mcs);
+#endif // RT30xx //
+
+#ifdef RT30xx
+static int CheckMCSValid(
+ IN UCHAR Mode,
+ IN UCHAR Mcs,
+ IN BOOLEAN bRT2070);
+#endif // RT30xx //
+
+#ifdef RTMP_MAC_PCI
+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);
+#endif // RTMP_MAC_PCI //
+
+
+static VOID SetJapanFilter(
+ IN PRTMP_ADAPTER pAd);
+
+
+#ifdef RALINK_28xx_QA
+static inline INT DO_RACFG_CMD_ATE_START(
+ IN PRTMP_ADAPTER pAdapter,
+ IN struct iwreq *wrq,
+ IN struct ate_racfghdr *pRaCfg
+);
+
+static inline INT DO_RACFG_CMD_ATE_STOP(
+ IN PRTMP_ADAPTER pAdapter,
+ IN struct iwreq *wrq,
+ IN struct ate_racfghdr *pRaCfg
+);
+
+static inline INT DO_RACFG_CMD_RF_WRITE_ALL(
+ IN PRTMP_ADAPTER pAdapter,
+ IN struct iwreq *wrq,
+ IN struct ate_racfghdr *pRaCfg
+);
+
+static inline INT DO_RACFG_CMD_E2PROM_READ16(
+ IN PRTMP_ADAPTER pAdapter,
+ IN struct iwreq *wrq,
+ IN struct ate_racfghdr *pRaCfg
+);
+
+static inline INT DO_RACFG_CMD_E2PROM_WRITE16(
+ IN PRTMP_ADAPTER pAdapter,
+ IN struct iwreq *wrq,
+ IN struct ate_racfghdr *pRaCfg
+);
+
+static inline INT DO_RACFG_CMD_E2PROM_READ_ALL
+(
+ IN PRTMP_ADAPTER pAdapter,
+ IN struct iwreq *wrq,
+ IN struct ate_racfghdr *pRaCfg
+);
+
+static inline INT DO_RACFG_CMD_E2PROM_WRITE_ALL(
+ IN PRTMP_ADAPTER pAdapter,
+ IN struct iwreq *wrq,
+ IN struct ate_racfghdr *pRaCfg
+);
+
+static inline INT DO_RACFG_CMD_IO_READ(
+ IN PRTMP_ADAPTER pAdapter,
+ IN struct iwreq *wrq,
+ IN struct ate_racfghdr *pRaCfg
+);
+
+static inline INT DO_RACFG_CMD_IO_WRITE(
+ IN PRTMP_ADAPTER pAdapter,
+ IN struct iwreq *wrq,
+ IN struct ate_racfghdr *pRaCfg
+);
+
+static inline INT DO_RACFG_CMD_IO_READ_BULK(
+ IN PRTMP_ADAPTER pAdapter,
+ IN struct iwreq *wrq,
+ IN struct ate_racfghdr *pRaCfg
+);
+
+static inline INT DO_RACFG_CMD_BBP_READ8(
+ IN PRTMP_ADAPTER pAdapter,
+ IN struct iwreq *wrq,
+ IN struct ate_racfghdr *pRaCfg
+);
+
+static inline INT DO_RACFG_CMD_BBP_WRITE8(
+ IN PRTMP_ADAPTER pAdapter,
+ IN struct iwreq *wrq,
+ IN struct ate_racfghdr *pRaCfg
+);
+
+static inline INT DO_RACFG_CMD_BBP_READ_ALL(
+ IN PRTMP_ADAPTER pAdapter,
+ IN struct iwreq *wrq,
+ IN struct ate_racfghdr *pRaCfg
+);
+
+static inline INT DO_RACFG_CMD_GET_NOISE_LEVEL(
+ IN PRTMP_ADAPTER pAdapter,
+ IN struct iwreq *wrq,
+ IN struct ate_racfghdr *pRaCfg
+);
+
+static inline INT DO_RACFG_CMD_GET_COUNTER(
+ IN PRTMP_ADAPTER pAdapter,
+ IN struct iwreq *wrq,
+ IN struct ate_racfghdr *pRaCfg
+);
+
+static inline INT DO_RACFG_CMD_CLEAR_COUNTER(
+ IN PRTMP_ADAPTER pAdapter,
+ IN struct iwreq *wrq,
+ IN struct ate_racfghdr *pRaCfg
+);
+
+static inline INT DO_RACFG_CMD_TX_START(
+ IN PRTMP_ADAPTER pAdapter,
+ IN struct iwreq *wrq,
+ IN struct ate_racfghdr *pRaCfg
+);
+
+static inline INT DO_RACFG_CMD_GET_TX_STATUS(
+ IN PRTMP_ADAPTER pAdapter,
+ IN struct iwreq *wrq,
+ IN struct ate_racfghdr *pRaCfg
+);
+
+static inline INT DO_RACFG_CMD_TX_STOP(
+ IN PRTMP_ADAPTER pAdapter,
+ IN struct iwreq *wrq,
+ IN struct ate_racfghdr *pRaCfg
+);
+
+static inline INT DO_RACFG_CMD_RX_START(
+ IN PRTMP_ADAPTER pAdapter,
+ IN struct iwreq *wrq,
+ IN struct ate_racfghdr *pRaCfg
+);
+
+static inline INT DO_RACFG_CMD_RX_STOP(
+ IN PRTMP_ADAPTER pAdapter,
+ IN struct iwreq *wrq,
+ IN struct ate_racfghdr *pRaCfg
+);
+
+static inline INT DO_RACFG_CMD_RX_STOP(
+ IN PRTMP_ADAPTER pAdapter,
+ IN struct iwreq *wrq,
+ IN struct ate_racfghdr *pRaCfg
+);
+
+static inline INT DO_RACFG_CMD_ATE_START_TX_CARRIER(
+ IN PRTMP_ADAPTER pAdapter,
+ IN struct iwreq *wrq,
+ IN struct ate_racfghdr *pRaCfg
+);
+
+static inline INT DO_RACFG_CMD_ATE_START_TX_CONT(
+ IN PRTMP_ADAPTER pAdapter,
+ IN struct iwreq *wrq,
+ IN struct ate_racfghdr *pRaCfg
+);
+
+static inline INT DO_RACFG_CMD_ATE_START_TX_FRAME(
+ IN PRTMP_ADAPTER pAdapter,
+ IN struct iwreq *wrq,
+ IN struct ate_racfghdr *pRaCfg
+);
+
+static inline INT DO_RACFG_CMD_ATE_SET_BW(
+ IN PRTMP_ADAPTER pAdapter,
+ IN struct iwreq *wrq,
+ IN struct ate_racfghdr *pRaCfg
+);
+
+static inline INT DO_RACFG_CMD_ATE_SET_TX_POWER0(
+ IN PRTMP_ADAPTER pAdapter,
+ IN struct iwreq *wrq,
+ IN struct ate_racfghdr *pRaCfg
+);
+
+static inline INT DO_RACFG_CMD_ATE_SET_TX_POWER1(
+ IN PRTMP_ADAPTER pAdapter,
+ IN struct iwreq *wrq,
+ IN struct ate_racfghdr *pRaCfg
+);
+
+static inline INT DO_RACFG_CMD_ATE_SET_FREQ_OFFSET(
+ IN PRTMP_ADAPTER pAdapter,
+ IN struct iwreq *wrq,
+ IN struct ate_racfghdr *pRaCfg
+);
+
+static inline INT DO_RACFG_CMD_ATE_GET_STATISTICS(
+ IN PRTMP_ADAPTER pAdapter,
+ IN struct iwreq *wrq,
+ IN struct ate_racfghdr *pRaCfg
+);
+
+static inline INT DO_RACFG_CMD_ATE_RESET_COUNTER(
+ IN PRTMP_ADAPTER pAdapter,
+ IN struct iwreq *wrq,
+ IN struct ate_racfghdr *pRaCfg
+);
+
+static inline INT DO_RACFG_CMD_ATE_SEL_TX_ANTENNA(
+ IN PRTMP_ADAPTER pAdapter,
+ IN struct iwreq *wrq,
+ IN struct ate_racfghdr *pRaCfg
+);
+
+static inline INT DO_RACFG_CMD_ATE_SEL_RX_ANTENNA(
+ IN PRTMP_ADAPTER pAdapter,
+ IN struct iwreq *wrq,
+ IN struct ate_racfghdr *pRaCfg
+);
+
+static inline INT DO_RACFG_CMD_ATE_SET_PREAMBLE(
+ IN PRTMP_ADAPTER pAdapter,
+ IN struct iwreq *wrq,
+ IN struct ate_racfghdr *pRaCfg
+);
+
+static inline INT DO_RACFG_CMD_ATE_SET_CHANNEL(
+ IN PRTMP_ADAPTER pAdapter,
+ IN struct iwreq *wrq,
+ IN struct ate_racfghdr *pRaCfg
+);
+
+static inline INT DO_RACFG_CMD_ATE_SET_ADDR1(
+ IN PRTMP_ADAPTER pAdapter,
+ IN struct iwreq *wrq,
+ IN struct ate_racfghdr *pRaCfg
+);
+
+static inline INT DO_RACFG_CMD_ATE_SET_ADDR2(
+ IN PRTMP_ADAPTER pAdapter,
+ IN struct iwreq *wrq,
+ IN struct ate_racfghdr *pRaCfg
+);
+
+static inline INT DO_RACFG_CMD_ATE_SET_ADDR3(
+ IN PRTMP_ADAPTER pAdapter,
+ IN struct iwreq *wrq,
+ IN struct ate_racfghdr *pRaCfg
+);
+
+static inline INT DO_RACFG_CMD_ATE_SET_RATE(
+ IN PRTMP_ADAPTER pAdapter,
+ IN struct iwreq *wrq,
+ IN struct ate_racfghdr *pRaCfg
+);
+
+static inline INT DO_RACFG_CMD_ATE_SET_TX_FRAME_LEN(
+ IN PRTMP_ADAPTER pAdapter,
+ IN struct iwreq *wrq,
+ IN struct ate_racfghdr *pRaCfg
+);
+
+static inline INT DO_RACFG_CMD_ATE_SET_TX_FRAME_COUNT(
+ IN PRTMP_ADAPTER pAdapter,
+ IN struct iwreq *wrq,
+ IN struct ate_racfghdr *pRaCfg
+);
+
+static inline INT DO_RACFG_CMD_ATE_START_RX_FRAME(
+ IN PRTMP_ADAPTER pAdapter,
+ IN struct iwreq *wrq,
+ IN struct ate_racfghdr *pRaCfg
+);
+
+static inline INT DO_RACFG_CMD_ATE_E2PROM_READ_BULK(
+ IN PRTMP_ADAPTER pAdapter,
+ IN struct iwreq *wrq,
+ IN struct ate_racfghdr *pRaCfg
+);
+
+static inline INT DO_RACFG_CMD_ATE_E2PROM_WRITE_BULK(
+ IN PRTMP_ADAPTER pAdapter,
+ IN struct iwreq *wrq,
+ IN struct ate_racfghdr *pRaCfg
+);
+
+static inline INT DO_RACFG_CMD_ATE_IO_WRITE_BULK(
+ IN PRTMP_ADAPTER pAdapter,
+ IN struct iwreq *wrq,
+ IN struct ate_racfghdr *pRaCfg
+);
+
+static inline INT DO_RACFG_CMD_ATE_BBP_READ_BULK(
+ IN PRTMP_ADAPTER pAdapter,
+ IN struct iwreq *wrq,
+ IN struct ate_racfghdr *pRaCfg
+);
+
+static inline INT DO_RACFG_CMD_ATE_BBP_WRITE_BULK(
+ IN PRTMP_ADAPTER pAdapter,
+ IN struct iwreq *wrq,
+ IN struct ate_racfghdr *pRaCfg
+);
+
+#endif // RALINK_28xx_QA //
+
+
+#ifdef RTMP_MAC_PCI
+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;
+}
+#endif // RTMP_MAC_PCI //
+
+
+
+
+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;
+}
+
+
+#ifdef RT30xx
+static int CheckMCSValid(
+ UCHAR Mode,
+ UCHAR Mcs,
+ BOOLEAN bRT2070)
+#endif // RT30xx //
+#ifndef RT30xx
+static int CheckMCSValid(
+ IN UCHAR Mode,
+ IN UCHAR Mcs)
+#endif // RT30xx //
+{
+ INT i;
+ PCHAR pRateTab;
+
+ switch (Mode)
+ {
+ case 0:
+ pRateTab = CCKRateTable;
+ break;
+ case 1:
+ pRateTab = OFDMRateTable;
+ break;
+ case 2:
+ case 3:
+#ifdef RT30xx
+ if (bRT2070)
+ pRateTab = OFDMRateTable;
+ else
+#endif // RT30xx //
+ 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;
+}
+
+
+static INT ATETxPwrHandler(
+ IN PRTMP_ADAPTER pAd,
+ IN char index)
+{
+ ULONG R;
+ CHAR TxPower;
+ UCHAR Bbp94 = 0;
+ BOOLEAN bPowerReduce = FALSE;
+#ifdef RTMP_RF_RW_SUPPORT
+ UCHAR RFValue;
+#endif // RTMP_RF_RW_SUPPORT //
+#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.
+ */
+ 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 RTMP_RF_RW_SUPPORT
+ if (IS_RT30xx(pAd))
+ {
+ // Set Tx Power
+ ATE_RF_IO_READ8_BY_REG_ID(pAd, RF_R12, (PUCHAR)&RFValue);
+ RFValue = (RFValue & 0xE0) | TxPower;
+ ATE_RF_IO_WRITE8_BY_REG_ID(pAd, RF_R12, (UCHAR)RFValue);
+ ATEDBGPRINT(RT_DEBUG_TRACE, ("3070 or 2070:%s (TxPower=%d, RFValue=%x)\n", __FUNCTION__, TxPower, RFValue));
+ }
+ else
+#endif // RTMP_RF_RW_SUPPORT //
+ {
+ if (pAd->ate.Channel <= 14)
+ {
+ if (index == 0)
+ {
+ // shift TX power control to correct RF(R3) register bit position
+ R = R << 9;
+ R |= (pAd->LatchRfRegs.R3 & 0xffffc1ff);
+ pAd->LatchRfRegs.R3 = R;
+ }
+ else
+ {
+ // shift TX power control to correct RF(R4) register bit position
+ R = R << 6;
+ R |= (pAd->LatchRfRegs.R4 & 0xfffff83f);
+ pAd->LatchRfRegs.R4 = R;
+ }
+ }
+ else /* 5.5GHz */
+ {
+ if (bPowerReduce == FALSE)
+ {
+ if (index == 0)
+ {
+ // shift TX power control to correct RF(R3) register bit position
+ R = (R << 10) | (1 << 9);
+ R |= (pAd->LatchRfRegs.R3 & 0xffffc1ff);
+ pAd->LatchRfRegs.R3 = R;
+ }
+ else
+ {
+ // shift TX power control to correct RF(R4) register bit position
+ R = (R << 7) | (1 << 6);
+ R |= (pAd->LatchRfRegs.R4 & 0xfffff83f);
+ pAd->LatchRfRegs.R4 = R;
+ }
+ }
+ else
+ {
+ if (index == 0)
+ {
+ // shift TX power control to correct RF(R3) register bit position
+ R = (R << 10);
+ R |= (pAd->LatchRfRegs.R3 & 0xffffc1ff);
+
+ /* Clear bit 9 of R3 to reduce 7dB. */
+ pAd->LatchRfRegs.R3 = (R & (~(1 << 9)));
+ }
+ else
+ {
+ // shift TX power control to correct RF(R4) register bit position
+ R = (R << 7);
+ 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;
+ }
+}
+
+
+/*
+==========================================================================
+ 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
+==========================================================================
+*/
+#ifdef RTMP_MAC_PCI
+static INT ATECmdHandler(
+ IN PRTMP_ADAPTER pAd,
+ IN PSTRING arg)
+{
+ UINT32 Value = 0;
+ UCHAR BbpData;
+ UINT32 MacData = 0;
+ PTXD_STRUC pTxD;
+ INT index;
+ UINT i = 0, atemode = 0;
+ PRXD_STRUC pRxD;
+ PRTMP_TX_RING pTxRing = &pAd->TxRing[QID_AC_BE];
+ NDIS_STATUS Status = NDIS_STATUS_SUCCESS;
+#ifdef RT_BIG_ENDIAN
+ PTXD_STRUC pDestTxD;
+ TXD_STRUC TxD;
+#endif
+
+ ATEDBGPRINT(RT_DEBUG_TRACE, ("===> ATECmdHandler()\n"));
+
+ ATEAsicSwitchChannel(pAd);
+
+ /* empty function */
+ 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;
+
+ // Enter ATE mode and set Tx/Rx Idle
+ if (!strcmp(arg, "ATESTART"))
+ {
+ ATEDBGPRINT(RT_DEBUG_TRACE, ("ATE: ATESTART\n"));
+
+#if defined(LINUX) || defined(VXWORKS)
+ // check if we have removed the firmware
+ if (!(ATE_ON(pAd)))
+ {
+ NICEraseFirmware(pAd);
+ }
+#endif // defined(LINUX) || defined(VXWORKS) //
+
+ atemode = pAd->ate.Mode;
+ pAd->ate.Mode = ATE_START;
+ 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;
+ // TxStatus : 0 --> task is idle, 1 --> task is running
+ pAd->ate.TxStatus = 0;
+#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);
+
+#if defined(LINUX) || defined(VXWORKS)
+ RTMP_OS_NETDEV_STOP_QUEUE(pAd->net_dev);
+#endif // defined(LINUX) || defined(VXWORKS) //
+
+ /*
+ 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);
+
+ // recover the MAC_SYS_CTRL register back
+ RTMP_IO_WRITE32(pAd, MAC_SYS_CTRL, MacData);
+
+ // 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);
+
+#ifdef LINUX
+ 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 // LINUX //
+ pAd->ate.Mode = ATE_STOP;
+
+ /*
+ Even the firmware has been loaded,
+ we still could use ATE_BBP_IO_READ8_BY_REG_ID().
+ But this is not suggested.
+ */
+ BbpSoftReset(pAd);
+
+ RTMP_ASIC_INTERRUPT_DISABLE(pAd);
+
+ NICInitializeAdapter(pAd, TRUE);
+
+ /*
+ Reinitialize Rx Ring before Rx DMA is enabled.
+ >>>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);
+
+ /* empty function */
+ AsicLockChannel(pAd, pAd->CommonCfg.Channel);
+
+ /* clear garbage interrupts */
+ RTMP_IO_WRITE32(pAd, INT_SOURCE_CSR, 0xffffffff);
+ /* Enable Interrupt */
+ RTMP_ASIC_INTERRUPT_ENABLE(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 //
+
+#if defined(LINUX) || defined(VXWORKS)
+ RTMP_OS_NETDEV_START_QUEUE(pAd->net_dev);
+#endif // defined(LINUX) || defined(VXWORKS) //
+ }
+ else if (!strcmp(arg, "TXCARR"))
+ {
+ 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"))
+ {
+ 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;
+ }
+#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;
+ }
+#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"))
+ {
+ 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;
+ }
+#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 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
+ }
+ // Enable Tx, Rx DMA
+ RtmpDmaEnable(pAd, 1);
+
+ }
+
+ // TxStatus : 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, &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)
+ {
+ ;
+ }
+ }
+
+ // 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"))
+ {
+ 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 RTMP_MAC_PCI =======================*/
+#endif // RTMP_MAC_PCI //
+
+
+
+
+INT Set_ATE_Proc(
+ IN PRTMP_ADAPTER pAd,
+ IN PSTRING 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 PSTRING arg)
+{
+ PSTRING value;
+ INT i;
+
+ // Mac address acceptable format 01:02:03:04:05:06 length 17
+ if (strlen(arg) != 17)
+ return FALSE;
+
+ for (i = 0, value = rstrtok(arg, ":"); value; value = rstrtok(NULL, ":"))
+ {
+ /* sanity check */
+ if ((strlen(value) != 2) || (!isxdigit(*value)) || (!isxdigit(*(value+1))))
+ {
+ return FALSE;
+ }
+
+#ifdef CONFIG_STA_SUPPORT
+ AtoH(value, &pAd->ate.Addr3[i++], 1);
+#endif // CONFIG_STA_SUPPORT //
+ }
+
+ /* sanity check */
+ if (i != 6)
+ {
+ return FALSE;
+ }
+
+#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 PSTRING arg)
+{
+ PSTRING value;
+ INT i;
+
+ // Mac address acceptable format 01:02:03:04:05:06 length 17
+ if (strlen(arg) != 17)
+ return FALSE;
+
+ for (i=0, value = rstrtok(arg, ":"); value; value = rstrtok(NULL, ":"))
+ {
+ /* sanity check */
+ if ((strlen(value) != 2) || (!isxdigit(*value)) || (!isxdigit(*(value+1))))
+ {
+ return FALSE;
+ }
+
+#ifdef CONFIG_STA_SUPPORT
+ AtoH(value, &pAd->ate.Addr2[i++], 1);
+#endif // CONFIG_STA_SUPPORT //
+ }
+
+ /* sanity check */
+ if (i != 6)
+ {
+ return FALSE;
+ }
+
+#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 PSTRING arg)
+{
+ PSTRING value;
+ INT i;
+
+ // Mac address acceptable format 01:02:03:04:05:06 length 17
+ if (strlen(arg) != 17)
+ return FALSE;
+
+ for (i=0, value = rstrtok(arg, ":"); value; value = rstrtok(NULL, ":"))
+ {
+ /* sanity check */
+ if ((strlen(value) != 2) || (!isxdigit(*value)) || (!isxdigit(*(value+1))))
+ {
+ return FALSE;
+ }
+
+#ifdef CONFIG_STA_SUPPORT
+ AtoH(value, &pAd->ate.Addr1[i++], 1);
+#endif // CONFIG_STA_SUPPORT //
+ }
+
+ /* sanity check */
+ if(i != 6)
+ {
+ return FALSE;
+ }
+
+#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 PSTRING arg)
+{
+ UCHAR channel;
+
+ channel = simple_strtol(arg, 0, 10);
+
+ // to allow A band channel : ((channel < 1) || (channel > 14))
+ if ((channel < 1) || (channel > 216))
+ {
+ 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 PSTRING 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.5 GHz */
+ {
+ 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 PSTRING 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 PSTRING 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"));
+
+ // calibration power unbalance issues, merged from Arch Team
+ ATEAsicSwitchChannel(pAd);
+
+
+ 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 PSTRING 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"));
+
+ // calibration power unbalance issues, merged from Arch Team
+ ATEAsicSwitchChannel(pAd);
+
+
+ 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 PSTRING arg)
+{
+ UCHAR RFFreqOffset = 0;
+ ULONG R4 = 0;
+
+ RFFreqOffset = simple_strtol(arg, 0, 10);
+#ifndef RTMP_RF_RW_SUPPORT
+ if (RFFreqOffset >= 64)
+#endif // RTMP_RF_RW_SUPPORT //
+ /* RT35xx ATE will reuse this code segment. */
+#ifdef RTMP_RF_RW_SUPPORT
+//2008/08/06: KH modified the limit of offset value from 65 to 95(0x5F)
+ if (RFFreqOffset >= 95)
+#endif // RTMP_RF_RW_SUPPORT //
+ {
+ 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 RTMP_RF_RW_SUPPORT
+ if (IS_RT30xx(pAd) || IS_RT3572(pAd))
+ {
+ // Set RF offset
+ UCHAR RFValue;
+ ATE_RF_IO_READ8_BY_REG_ID(pAd, RF_R23, (PUCHAR)&RFValue);
+//2008/08/06: KH modified "pAd->RFFreqOffset" to "pAd->ate.RFFreqOffset"
+ RFValue = ((RFValue & 0x80) | pAd->ate.RFFreqOffset);
+ ATE_RF_IO_WRITE8_BY_REG_ID(pAd, RF_R23, (UCHAR)RFValue);
+ }
+ else
+#endif // RTMP_RF_RW_SUPPORT //
+ {
+ // RT28xx
+ // shift TX power control to correct RF register bit position
+ R4 = pAd->ate.RFFreqOffset << 15;
+ 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 PSTRING arg)
+{
+ INT i;
+ UCHAR value = 0;
+ UCHAR BBPCurrentBW;
+
+ BBPCurrentBW = simple_strtol(arg, 0, 10);
+
+ if ((BBPCurrentBW == 0)
+#ifdef RT30xx
+ || IS_RT2070(pAd)
+#endif // RT30xx //
+ )
+ {
+ pAd->ate.TxWI.BW = BW_20;
+ }
+ else
+ {
+ pAd->ate.TxWI.BW = BW_40;
+ }
+
+ /* RT35xx ATE will reuse this code segment. */
+ // Fix the error spectrum of CCK-40MHZ
+ // Turn on BBP 20MHz mode by request here.
+ if ((pAd->ate.TxWI.PHYMODE == MODE_CCK) && (pAd->ate.TxWI.BW == BW_40))
+ {
+ ATEDBGPRINT(RT_DEBUG_ERROR, ("Set_ATE_TX_BW_Proc!! Warning!! CCK only supports 20MHZ!!\nBandwidth switch to 20\n"));
+ pAd->ate.TxWI.BW = BW_20;
+ }
+
+ 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
+ (to set 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);
+ }
+ }
+
+#ifdef RT30xx
+ // set BW = 20 MHz
+ if (IS_RT30xx(pAd))
+ ATE_RF_IO_WRITE8_BY_REG_ID(pAd, RF_R24, (UCHAR) pAd->Mlme.CaliBW20RfR24);
+ else
+#endif // RT30xx //
+ // set BW = 20 MHz
+ {
+ pAd->LatchRfRegs.R4 &= ~0x00200000;
+ RtmpRfIoWrite(pAd);
+ }
+
+ }
+ // If bandwidth = 40M, set RF Reg4 bit 21 = 0.
+ 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 = 40 MHz
+ if(IS_RT30xx(pAd))
+ ATE_RF_IO_WRITE8_BY_REG_ID(pAd, RF_R24, (UCHAR) pAd->Mlme.CaliBW40RfR24);
+ else
+#endif // RT30xx //
+ // set BW = 40 MHz
+ {
+ 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 PSTRING 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 PSTRING 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 PSTRING arg)
+{
+ UCHAR MCS;
+ INT result;
+
+ MCS = simple_strtol(arg, 0, 10);
+#ifndef RT30xx
+ result = CheckMCSValid(pAd->ate.TxWI.PHYMODE, MCS);
+#endif // RT30xx //
+
+ /* RT35xx ATE will reuse this code segment. */
+#ifdef RT30xx
+ result = CheckMCSValid(pAd->ate.TxWI.PHYMODE, MCS, IS_RT2070(pAd));
+#endif // RT30xx //
+
+
+ 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 PSTRING arg)
+{
+ UCHAR BbpData = 0;
+
+ 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.\nIt 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;
+ }
+
+ // Turn on BBP 20MHz mode by request here.
+ if (pAd->ate.TxWI.PHYMODE == MODE_CCK)
+ {
+ ATE_BBP_IO_READ8_BY_REG_ID(pAd, BBP_R4, &BbpData);
+ BbpData &= (~0x18);
+ ATE_BBP_IO_WRITE8_BY_REG_ID(pAd, BBP_R4, BbpData);
+ pAd->ate.TxWI.BW = BW_20;
+ ATEDBGPRINT(RT_DEBUG_ERROR, ("Set_ATE_TX_MODE_Proc::CCK Only support 20MHZ. Switch to 20MHZ.\n"));
+ }
+
+ 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 PSTRING 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;
+}
+
+
+INT Set_ATE_RX_FER_Proc(
+ IN PRTMP_ADAPTER pAd,
+ IN PSTRING 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 PSTRING arg)
+{
+#ifdef RTMP_RF_RW_SUPPORT
+//2008/07/10:KH add to support RT30xx ATE<--
+ if (IS_RT30xx(pAd) || IS_RT3572(pAd))
+ {
+ /* modify by WY for Read RF Reg. error */
+ UCHAR RFValue;
+ INT index=0;
+
+ for (index = 0; index < 32; index++)
+ {
+ ATE_RF_IO_READ8_BY_REG_ID(pAd, index, (PUCHAR)&RFValue);
+ ate_print("R%d=%d\n",index,RFValue);
+ }
+ }
+ else
+//2008/07/10:KH add to support RT30xx ATE-->
+#endif // RTMP_RF_RW_SUPPORT //
+ {
+ 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 PSTRING arg)
+{
+ UINT32 value = (UINT32) simple_strtol(arg, 0, 16);
+
+#ifdef RTMP_RF_RW_SUPPORT
+//2008/07/10:KH add to support 3070 ATE<--
+ if (IS_RT30xx(pAd) || IS_RT3572(pAd))
+ {
+ ate_print("Warning!! RT3xxx Don't Support !\n");
+ return FALSE;
+
+ }
+ else
+//2008/07/10:KH add to support 3070 ATE-->
+#endif // RTMP_RF_RW_SUPPORT //
+ {
+ pAd->LatchRfRegs.R1 = value;
+ RtmpRfIoWrite(pAd);
+ }
+ return TRUE;
+}
+
+
+INT Set_ATE_Write_RF2_Proc(
+ IN PRTMP_ADAPTER pAd,
+ IN PSTRING arg)
+{
+ UINT32 value = (UINT32) simple_strtol(arg, 0, 16);
+
+#ifdef RTMP_RF_RW_SUPPORT
+//2008/07/10:KH add to support 3070 ATE<--
+ if (IS_RT30xx(pAd) || IS_RT3572(pAd))
+ {
+ ate_print("Warning!! RT3xxx Don't Support !\n");
+ return FALSE;
+
+ }
+ else
+//2008/07/10:KH add to support 3070 ATE-->
+#endif // RTMP_RF_RW_SUPPORT //
+ {
+ pAd->LatchRfRegs.R2 = value;
+ RtmpRfIoWrite(pAd);
+ }
+ return TRUE;
+}
+
+
+INT Set_ATE_Write_RF3_Proc(
+ IN PRTMP_ADAPTER pAd,
+ IN PSTRING arg)
+{
+ UINT32 value = simple_strtol(arg, 0, 16);
+
+#ifdef RTMP_RF_RW_SUPPORT
+//2008/07/10:KH add to support 3070 ATE<--
+ if (IS_RT30xx(pAd) || IS_RT3572(pAd))
+ {
+ ate_print("Warning!! RT3xxx Don't Support !\n");
+ return FALSE;
+
+ }
+ else
+//2008/07/10:KH add to support 3070 ATE-->
+#endif // RTMP_RF_RW_SUPPORT //
+ {
+ pAd->LatchRfRegs.R3 = value;
+ RtmpRfIoWrite(pAd);
+ }
+ return TRUE;
+}
+
+
+INT Set_ATE_Write_RF4_Proc(
+ IN PRTMP_ADAPTER pAd,
+ IN PSTRING arg)
+{
+ UINT32 value = (UINT32) simple_strtol(arg, 0, 16);
+
+#ifdef RTMP_RF_RW_SUPPORT
+//2008/07/10:KH add to support 3070 ATE<--
+ if (IS_RT30xx(pAd) || IS_RT3572(pAd))
+ {
+ ate_print("Warning!! RT3xxx Don't Support !\n");
+ return FALSE;
+
+ }
+ else
+//2008/07/10:KH add to support 3070 ATE-->
+#endif // RTMP_RF_RW_SUPPORT //
+ {
+ 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
+==========================================================================
+*/
+#if defined(LINUX) || defined(VXWORKS)
+INT Set_ATE_Load_E2P_Proc(
+ IN PRTMP_ADAPTER pAd,
+ IN PSTRING arg)
+{
+ BOOLEAN ret = FALSE;
+ PSTRING src = EEPROM_BIN_FILE_NAME;
+ RTMP_OS_FD srcf;
+ INT32 retval;
+ USHORT WriteEEPROM[(EEPROM_SIZE/2)];
+ INT FileLength = 0;
+ UINT32 value = (UINT32) simple_strtol(arg, 0, 10);
+ RTMP_OS_FS_INFO osFSInfo;
+
+ ATEDBGPRINT(RT_DEBUG_ERROR, ("===> %s (value=%d)\n\n", __FUNCTION__, value));
+
+ if (value > 0)
+ {
+ /* zero the e2p buffer */
+ NdisZeroMemory((PUCHAR)WriteEEPROM, EEPROM_SIZE);
+
+ RtmpOSFSInfoChange(&osFSInfo, TRUE);
+
+ do
+ {
+ /* open the bin file */
+ srcf = RtmpOSFileOpen(src, O_RDONLY, 0);
+
+ if (IS_FILE_OPEN_ERR(srcf))
+ {
+ ate_print("%s - Error opening file %s\n", __FUNCTION__, src);
+ break;
+ }
+
+ /* read the firmware from the file *.bin */
+ FileLength = RtmpOSFileRead(srcf, (PSTRING)WriteEEPROM, EEPROM_SIZE);
+
+ 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_FILE_OPEN_ERR(srcf))
+ {
+ ;
+ }
+ else
+ {
+ retval = RtmpOSFileClose(srcf);
+
+ if (retval)
+ {
+ ATEDBGPRINT(RT_DEBUG_ERROR, ("--> Error %d closing %s\n", -retval, src));
+
+ }
+ }
+
+ /* restore */
+ RtmpOSFSInfoChange(&osFSInfo, FALSE);
+ }
+
+ ATEDBGPRINT(RT_DEBUG_ERROR, ("<=== %s (ret=%d)\n", __FUNCTION__, ret));
+
+ return ret;
+
+}
+#endif // defined(LINUX) || defined(VXWORKS) //
+
+
+
+
+INT Set_ATE_Read_E2P_Proc(
+ IN PRTMP_ADAPTER pAd,
+ IN PSTRING 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 PSTRING 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 PSTRING 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 = 0, BbpValue = 0, R66 = 0x30;
+ RTMP_RF_REGS *RFRegTable;
+ UCHAR Channel = 0;
+
+ RFRegTable = NULL;
+
+#ifdef RALINK_28xx_QA
+ // for QA mode, TX power values are passed from UI
+ 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 for RT3090
+ 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 = 0;
+
+ for (index = 0; index < NUM_OF_3020_CHNL; index++)
+ {
+ if (Channel == FreqItems3020[index].Channel)
+ {
+ // Programming channel parameters.
+ ATE_RF_IO_WRITE8_BY_REG_ID(pAd, RF_R02, FreqItems3020[index].N);
+ ATE_RF_IO_WRITE8_BY_REG_ID(pAd, RF_R03, FreqItems3020[index].K);
+
+ ATE_RF_IO_READ8_BY_REG_ID(pAd, RF_R06, (PUCHAR)&RFValue);
+ RFValue = (RFValue & 0xFC) | FreqItems3020[index].R;
+ ATE_RF_IO_WRITE8_BY_REG_ID(pAd, RF_R06, (UCHAR)RFValue);
+
+ // Set Tx Power.
+ ATE_RF_IO_READ8_BY_REG_ID(pAd, RF_R12, (PUCHAR)&RFValue);
+ RFValue = (RFValue & 0xE0) | TxPwer;
+ ATE_RF_IO_WRITE8_BY_REG_ID(pAd, RF_R12, (UCHAR)RFValue);
+
+ // Set RF offset.
+ ATE_RF_IO_READ8_BY_REG_ID(pAd, RF_R23, (PUCHAR)&RFValue);
+ //2008/08/06: KH modified "pAd->RFFreqOffset" to "pAd->ate.RFFreqOffset"
+ RFValue = (RFValue & 0x80) | pAd->ate.RFFreqOffset;
+ ATE_RF_IO_WRITE8_BY_REG_ID(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;
+ }
+ ATE_RF_IO_WRITE8_BY_REG_ID(pAd, RF_R24, (UCHAR)RFValue);
+
+ // Enable RF tuning
+ ATE_RF_IO_READ8_BY_REG_ID(pAd, RF_R07, (PUCHAR)&RFValue);
+ RFValue = RFValue | 0x1;
+ ATE_RF_IO_WRITE8_BY_REG_ID(pAd, RF_R07, (UCHAR)RFValue);
+
+ // latch channel for future usage
+ pAd->LatchRfRegs.Channel = Channel;
+
+ break;
+ }
+ }
+
+ ATEDBGPRINT(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 //
+ {
+ /* RT28xx */
+ 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 TX path is 1, bit 14 = 1;
+ if (pAd->Antenna.field.TxPath == 1)
+ {
+ R2 |= 0x4000;
+ }
+
+ 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)
+ {
+ // write 1 to off RxPath
+ R2 |= 0x20040;
+ }
+
+ if (pAd->Antenna.field.TxPath == 2)
+ {
+ if (pAd->ate.TxAntennaSel == 1)
+ {
+ // If TX Antenna select is 1 , bit 14 = 1; Disable Ant 2
+ R2 |= 0x4000;
+ 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)
+ {
+ // If TX Antenna select is 2 , bit 15 = 1; Disable Ant 1
+ R2 |= 0x8000;
+ 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
+ {
+ // Set TX power0.
+ R3 = (RFRegTable[index].R3 & 0xffffc1ff) | (TxPwer << 9);
+ // Set frequency offset and TX power1.
+ R4 = (RFRegTable[index].R4 & (~0x001f87c0)) | (pAd->ate.RFFreqOffset << 15) | (TxPwer2 <<6);
+ }
+
+ // 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)
+ {
+ UINT32 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);// may be removed for RT35xx ++
+
+ ASSERT((BbpValue == 0x00));
+ if ((BbpValue != 0x00))
+ {
+ ATE_BBP_IO_WRITE8_BY_REG_ID(pAd, BBP_R86, 0x00);
+ }// may be removed for RT35xx --
+
+ // 5.5 GHz 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;
+ }
+
+ // calibration power unbalance issues
+ if (pAd->Antenna.field.TxPath == 2)
+ {
+ if (pAd->ate.TxAntennaSel == 1)
+ {
+ TxPinCfg &= 0xFFFFFFF7;
+ }
+ else if (pAd->ate.TxAntennaSel == 2)
+ {
+ TxPinCfg &= 0xFFFFFFFD;
+ }
+ }
+
+ RTMP_IO_WRITE32(pAd, TX_PIN_CFG, TxPinCfg);
+ }
+ else
+ {
+ UINT32 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);// may be removed for RT35xx ++
+
+ 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));// may be removed for RT35xx --
+
+ // 5.5 GHz 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);
+
+#ifndef RTMP_RF_RW_SUPPORT
+ 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));
+ }
+#endif // RTMP_RF_RW_SUPPORT //
+}
+
+
+
+/* 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++)
+ {
+ // Found the range.
+ if (BbpR49 <= pTssiMinusBoundary[idx])
+ 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++)
+ {
+ // Found the range.
+ if (BbpR49 >= pTssiPlusBoundary[idx])
+ 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 RTMP_MAC_PCI
+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;
+}
+#endif // RTMP_MAC_PCI //
+
+
+
+
+/*
+========================================================================
+
+ 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 */
+/* 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);
+}
+
+
+/*
+========================================================================
+
+ 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. */
+// 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 ++;
+}
+
+
+#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"));
+
+#ifdef RTMP_MAC_PCI
+ pAd->Mlme.CntlMachine.CurrState = CNTL_IDLE;
+
+ /* We did not cancel this timer when entering ATE mode. */
+// RTMPSetTimer(&pAd->Mlme.PeriodicTimer, MLME_TASK_EXEC_INTV);
+#endif // RTMP_MAC_PCI //
+
+ 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 RTMP_MAC_PCI
+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)
+ {
+ pPacket = RTMP_AllocateRxPacketBuffer(pAd, pAd->ate.DLen + 0x100, FALSE, &AllocVa, &AllocPa);
+ }
+ else
+#endif // RALINK_28xx_QA //
+ {
+ 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", __FUNCTION__));
+ 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 RTMP_MAC_PCI =======================*/
+#endif // RTMP_MAC_PCI //
+
+
+
+
+VOID rt_ee_read_all(PRTMP_ADAPTER pAd, USHORT *Data)
+{
+ USHORT i;
+ USHORT value;
+
+
+ for (i = 0 ; i < EEPROM_SIZE/2 ; )
+ {
+ /* "value" is especially 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 especially 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
+
+
+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);
+
+
+
+VOID RtmpDoAte(
+ IN PRTMP_ADAPTER pAdapter,
+ IN struct iwreq *wrq)
+{
+ USHORT Command_Id;
+ INT Status = NDIS_STATUS_SUCCESS;
+ struct ate_racfghdr *pRaCfg;
+
+
+ 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:
+ Status=DO_RACFG_CMD_ATE_START(pAdapter,wrq,pRaCfg);
+ break;
+
+ /* We will get this command either QA is closed or ated is killed by user. */
+ case RACFG_CMD_ATE_STOP:
+ Status=DO_RACFG_CMD_ATE_STOP(pAdapter,wrq,pRaCfg);
+ break;
+
+ case RACFG_CMD_RF_WRITE_ALL:
+ Status=DO_RACFG_CMD_RF_WRITE_ALL(pAdapter,wrq,pRaCfg);
+ break;
+
+ case RACFG_CMD_E2PROM_READ16:
+ Status=DO_RACFG_CMD_E2PROM_READ16(pAdapter,wrq,pRaCfg);
+ break;
+
+ case RACFG_CMD_E2PROM_WRITE16:
+ Status=DO_RACFG_CMD_E2PROM_WRITE16(pAdapter,wrq,pRaCfg);
+ break;
+
+ case RACFG_CMD_E2PROM_READ_ALL:
+ Status=DO_RACFG_CMD_E2PROM_READ_ALL(pAdapter,wrq,pRaCfg);
+ break;
+
+ case RACFG_CMD_E2PROM_WRITE_ALL:
+ Status=DO_RACFG_CMD_E2PROM_WRITE_ALL(pAdapter,wrq,pRaCfg);
+ break;
+
+ case RACFG_CMD_IO_READ:
+ Status=DO_RACFG_CMD_IO_READ(pAdapter,wrq,pRaCfg);
+ break;
+
+ case RACFG_CMD_IO_WRITE:
+ Status=DO_RACFG_CMD_IO_WRITE(pAdapter,wrq,pRaCfg);
+ break;
+
+ case RACFG_CMD_IO_READ_BULK:
+ Status=DO_RACFG_CMD_IO_READ_BULK(pAdapter,wrq,pRaCfg);
+ break;
+
+ case RACFG_CMD_BBP_READ8:
+ Status=DO_RACFG_CMD_BBP_READ8(pAdapter,wrq,pRaCfg);
+ break;
+ case RACFG_CMD_BBP_WRITE8:
+ Status=DO_RACFG_CMD_BBP_WRITE8(pAdapter,wrq,pRaCfg);
+ break;
+
+ case RACFG_CMD_BBP_READ_ALL:
+ Status=DO_RACFG_CMD_BBP_READ_ALL(pAdapter,wrq,pRaCfg);
+ break;
+
+ case RACFG_CMD_ATE_E2PROM_READ_BULK:
+ Status=DO_RACFG_CMD_ATE_E2PROM_READ_BULK(pAdapter,wrq,pRaCfg);
+ break;
+
+ case RACFG_CMD_ATE_E2PROM_WRITE_BULK:
+ Status=DO_RACFG_CMD_ATE_E2PROM_WRITE_BULK(pAdapter,wrq,pRaCfg);
+ break;
+
+ case RACFG_CMD_ATE_IO_WRITE_BULK:
+ Status=DO_RACFG_CMD_ATE_IO_WRITE_BULK(pAdapter,wrq,pRaCfg);
+ break;
+
+ case RACFG_CMD_ATE_BBP_READ_BULK:
+ Status=DO_RACFG_CMD_ATE_BBP_READ_BULK(pAdapter,wrq,pRaCfg);
+ break;
+
+ case RACFG_CMD_ATE_BBP_WRITE_BULK:
+ Status=DO_RACFG_CMD_ATE_BBP_WRITE_BULK(pAdapter,wrq,pRaCfg);
+ break;
+
+
+ case RACFG_CMD_GET_NOISE_LEVEL:
+ Status=DO_RACFG_CMD_GET_NOISE_LEVEL(pAdapter,wrq,pRaCfg);
+ break;
+
+ case RACFG_CMD_GET_COUNTER:
+ Status=DO_RACFG_CMD_GET_COUNTER(pAdapter,wrq,pRaCfg);
+ break;
+
+ case RACFG_CMD_CLEAR_COUNTER:
+ Status=DO_RACFG_CMD_CLEAR_COUNTER(pAdapter,wrq,pRaCfg);
+ break;
+
+ case RACFG_CMD_TX_START:
+ Status=DO_RACFG_CMD_TX_START(pAdapter,wrq,pRaCfg);
+ break;
+
+ case RACFG_CMD_GET_TX_STATUS:
+ Status=DO_RACFG_CMD_GET_TX_STATUS(pAdapter,wrq,pRaCfg);
+ break;
+
+ case RACFG_CMD_TX_STOP:
+ Status=DO_RACFG_CMD_TX_STOP(pAdapter,wrq,pRaCfg);
+ break;
+
+ case RACFG_CMD_RX_START:
+ Status=DO_RACFG_CMD_RX_START(pAdapter,wrq,pRaCfg);
+ break;
+
+ case RACFG_CMD_RX_STOP:
+ Status=DO_RACFG_CMD_RX_STOP(pAdapter,wrq,pRaCfg);
+ break;
+
+ /* The following cases are for new ATE GUI(not QA). */
+ /*==================================================*/
+ case RACFG_CMD_ATE_START_TX_CARRIER:
+ Status=DO_RACFG_CMD_ATE_START_TX_CARRIER(pAdapter,wrq,pRaCfg);
+ break;
+
+ case RACFG_CMD_ATE_START_TX_CONT:
+ Status=DO_RACFG_CMD_ATE_START_TX_CONT(pAdapter,wrq,pRaCfg);
+ break;
+
+ case RACFG_CMD_ATE_START_TX_FRAME:
+ Status=DO_RACFG_CMD_ATE_START_TX_FRAME(pAdapter,wrq,pRaCfg);
+ break;
+
+ case RACFG_CMD_ATE_SET_BW:
+ Status=DO_RACFG_CMD_ATE_SET_BW(pAdapter,wrq,pRaCfg);
+ break;
+
+ case RACFG_CMD_ATE_SET_TX_POWER0:
+ Status=DO_RACFG_CMD_ATE_SET_TX_POWER0(pAdapter,wrq,pRaCfg);
+ break;
+
+ case RACFG_CMD_ATE_SET_TX_POWER1:
+ Status=DO_RACFG_CMD_ATE_SET_TX_POWER1(pAdapter,wrq,pRaCfg);
+ break;
+
+ case RACFG_CMD_ATE_SET_FREQ_OFFSET:
+ Status=DO_RACFG_CMD_ATE_SET_TX_POWER1(pAdapter,wrq,pRaCfg);
+ break;
+
+ case RACFG_CMD_ATE_GET_STATISTICS:
+ Status=DO_RACFG_CMD_ATE_GET_STATISTICS(pAdapter,wrq,pRaCfg);
+ break;
+
+ case RACFG_CMD_ATE_RESET_COUNTER:
+ Status=DO_RACFG_CMD_ATE_RESET_COUNTER(pAdapter,wrq,pRaCfg);
+ break;
+
+ case RACFG_CMD_ATE_SEL_TX_ANTENNA:
+ Status=DO_RACFG_CMD_ATE_SEL_TX_ANTENNA(pAdapter,wrq,pRaCfg);
+ break;
+
+ case RACFG_CMD_ATE_SEL_RX_ANTENNA:
+ Status=DO_RACFG_CMD_ATE_SEL_TX_ANTENNA(pAdapter,wrq,pRaCfg);
+ break;
+
+ case RACFG_CMD_ATE_SET_PREAMBLE:
+ Status=DO_RACFG_CMD_ATE_SET_PREAMBLE(pAdapter,wrq,pRaCfg);
+ break;
+
+ case RACFG_CMD_ATE_SET_CHANNEL:
+ Status=DO_RACFG_CMD_ATE_SET_CHANNEL(pAdapter,wrq,pRaCfg);
+ break;
+
+ case RACFG_CMD_ATE_SET_ADDR1:
+ Status=DO_RACFG_CMD_ATE_SET_ADDR1(pAdapter,wrq,pRaCfg);
+ break;
+
+ case RACFG_CMD_ATE_SET_ADDR2:
+ Status=DO_RACFG_CMD_ATE_SET_ADDR2(pAdapter,wrq,pRaCfg);
+ break;
+
+ case RACFG_CMD_ATE_SET_ADDR3:
+ Status=DO_RACFG_CMD_ATE_SET_ADDR3(pAdapter,wrq,pRaCfg);
+ break;
+
+ case RACFG_CMD_ATE_SET_RATE:
+ Status=DO_RACFG_CMD_ATE_SET_RATE(pAdapter,wrq,pRaCfg);
+ break;
+
+ case RACFG_CMD_ATE_SET_TX_FRAME_LEN:
+ Status=DO_RACFG_CMD_ATE_SET_TX_FRAME_LEN(pAdapter,wrq,pRaCfg);
+ break;
+
+ case RACFG_CMD_ATE_SET_TX_FRAME_COUNT:
+ Status=DO_RACFG_CMD_ATE_SET_TX_FRAME_COUNT(pAdapter,wrq,pRaCfg);
+ break;
+
+ case RACFG_CMD_ATE_START_RX_FRAME:
+ Status=DO_RACFG_CMD_ATE_START_RX_FRAME(pAdapter,wrq,pRaCfg);
+ 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 synchronize 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 synchronize 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 PSTRING 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 PSTRING arg)
+{
+ ATEDBGPRINT(RT_DEBUG_TRACE,("Set_RxStop_Proc\n"));
+
+ if (Set_ATE_Proc(pAd, "RXSTOP"))
+ {
+ return TRUE;
+ }
+ else
+ {
+ return FALSE;
+ }
+}
+
+
+#ifdef DBG
+INT Set_EERead_Proc(
+ IN PRTMP_ADAPTER pAd,
+ IN PSTRING 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(KERN_EMERG "%4.4x ", *p);
+ if (((i+1) % 16) == 0)
+ ate_print(KERN_EMERG "\n");
+ p++;
+ }
+
+ return TRUE;
+}
+
+
+INT Set_EEWrite_Proc(
+ IN PRTMP_ADAPTER pAd,
+ IN PSTRING arg)
+{
+ USHORT offset = 0, value;
+ PSTRING 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(KERN_EMERG "Offset can not exceed EEPROM_SIZE( == 0x%04x)\n", EEPROM_SIZE);
+ return FALSE;
+ }
+
+ RT28xx_EEPROM_WRITE16(pAd, offset, value);
+
+ return TRUE;
+}
+
+
+INT Set_BBPRead_Proc(
+ IN PRTMP_ADAPTER pAd,
+ IN PSTRING 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(KERN_EMERG "%x\n", value);
+
+ return TRUE;
+}
+
+
+INT Set_BBPWrite_Proc(
+ IN PRTMP_ADAPTER pAd,
+ IN PSTRING arg)
+{
+ USHORT offset = 0;
+ PSTRING 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
+ {
+ RTMP_BBP_IO_WRITE8_BY_REG_ID(pAd, offset, value);
+ }
+
+ return TRUE;
+}
+
+
+INT Set_RFWrite_Proc(
+ IN PRTMP_ADAPTER pAd,
+ IN PSTRING arg)
+{
+ PSTRING p2, p3, p4;
+ UINT32 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 // DBG //
+#endif // RALINK_28xx_QA //
+
+
+
+
+#ifdef RALINK_28xx_QA
+#define LEN_OF_ARG 16
+
+#define RESPONSE_TO_GUI(__pRaCfg, __pwrq, __Length, __Status) \
+ (__pRaCfg)->length = htons((__Length)); \
+ (__pRaCfg)->status = htons((__Status)); \
+ (__pwrq)->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", (__pwrq)->u.data.length)); \
+ if (copy_to_user((__pwrq)->u.data.pointer, (UCHAR *)(__pRaCfg), (__pwrq)->u.data.length)) \
+ { \
+ ATEDBGPRINT(RT_DEBUG_ERROR, ("copy_to_user() fail in %s\n", __FUNCTION__)); \
+ return (-EFAULT); \
+ } \
+ else \
+ { \
+ ATEDBGPRINT(RT_DEBUG_TRACE, ("%s is done !\n", __FUNCTION__)); \
+ }
+
+static inline INT DO_RACFG_CMD_ATE_START(
+ IN PRTMP_ADAPTER pAdapter,
+ IN struct iwreq *wrq,
+ IN struct ate_racfghdr *pRaCfg)
+{
+ ATEDBGPRINT(RT_DEBUG_TRACE,("RACFG_CMD_ATE_START\n"));
+
+ /* Prepare feedback as soon as we can to avoid QA timeout. */
+ RESPONSE_TO_GUI(pRaCfg, wrq, sizeof(pRaCfg->status), NDIS_STATUS_SUCCESS);
+ Set_ATE_Proc(pAdapter, "ATESTART");
+
+ return NDIS_STATUS_SUCCESS;
+}
+
+
+static inline INT DO_RACFG_CMD_ATE_STOP(
+ IN PRTMP_ADAPTER pAdapter,
+ IN struct iwreq *wrq,
+ IN struct ate_racfghdr *pRaCfg)
+{
+ INT32 ret;
+
+ ATEDBGPRINT(RT_DEBUG_TRACE,("RACFG_CMD_ATE_STOP\n"));
+
+ /*
+ Distinguish this command came from QA(via ate agent)
+ or ate agent according to the existence of pid in payload.
+
+ No need to prepare feedback if this cmd came directly from ate agent,
+ not from QA.
+ */
+ pRaCfg->length = ntohs(pRaCfg->length);
+
+ if (pRaCfg->length == sizeof(pAdapter->ate.AtePid))
+ {
+ /*
+ This command came from QA.
+ Get the pid of ATE agent.
+ */
+ memcpy((UCHAR *)&pAdapter->ate.AtePid,
+ (&pRaCfg->data[0]) - 2/* == sizeof(pRaCfg->status) */,
+ sizeof(pAdapter->ate.AtePid));
+
+ /* Prepare feedback as soon as we can to avoid QA timeout. */
+ RESPONSE_TO_GUI(pRaCfg, wrq, sizeof(pRaCfg->status), NDIS_STATUS_SUCCESS);
+
+ /*
+ Kill ATE agent when leaving ATE mode.
+
+ We must kill ATE agent first before setting ATESTOP,
+ or Microsoft will report sth. wrong.
+ */
+ ret = KILL_THREAD_PID(pAdapter->ate.AtePid, SIGTERM, 1);
+
+ if (ret)
+ {
+ ATEDBGPRINT(RT_DEBUG_ERROR, ("%s: unable to kill ate thread\n", pAdapter->net_dev->name));
+ }
+ }
+
+
+ /* AP/STA might have in ATE_STOP mode due to cmd from QA. */
+ if (ATE_ON(pAdapter))
+ {
+ /* Someone has killed ate agent while QA GUI is still open. */
+ Set_ATE_Proc(pAdapter, "ATESTOP");
+ ATEDBGPRINT(RT_DEBUG_TRACE, ("RACFG_CMD_AP_START is done !\n"));
+ }
+
+ return NDIS_STATUS_SUCCESS;
+}
+
+
+static inline INT DO_RACFG_CMD_RF_WRITE_ALL(
+ IN PRTMP_ADAPTER pAdapter,
+ IN struct iwreq *wrq,
+ IN struct ate_racfghdr *pRaCfg)
+{
+ 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);
+
+ RESPONSE_TO_GUI(pRaCfg, wrq, sizeof(pRaCfg->status), NDIS_STATUS_SUCCESS);
+
+ return NDIS_STATUS_SUCCESS;
+}
+
+
+static inline INT DO_RACFG_CMD_E2PROM_READ16(
+ IN PRTMP_ADAPTER pAdapter,
+ IN struct iwreq *wrq,
+ IN struct ate_racfghdr *pRaCfg)
+{
+ UINT16 offset=0, value=0;
+ USHORT tmp=0;
+
+ offset = ntohs(pRaCfg->status);
+
+ /* "tmp" is especially 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));
+ memcpy(pRaCfg->data, &value, 2);
+
+ RESPONSE_TO_GUI(pRaCfg, wrq, sizeof(pRaCfg->status)+2, NDIS_STATUS_SUCCESS);
+
+ return NDIS_STATUS_SUCCESS;
+}
+
+
+static inline INT DO_RACFG_CMD_E2PROM_WRITE16(
+ IN PRTMP_ADAPTER pAdapter,
+ IN struct iwreq *wrq,
+ IN struct ate_racfghdr *pRaCfg)
+{
+ USHORT offset, value;
+
+ offset = ntohs(pRaCfg->status);
+ memcpy(&value, pRaCfg->data, 2);
+ value = ntohs(value);
+ RT28xx_EEPROM_WRITE16(pAdapter, offset, value);
+
+ RESPONSE_TO_GUI(pRaCfg, wrq, sizeof(pRaCfg->status), NDIS_STATUS_SUCCESS);
+
+ return NDIS_STATUS_SUCCESS;
+}
+
+
+static inline INT DO_RACFG_CMD_E2PROM_READ_ALL(
+ IN PRTMP_ADAPTER pAdapter,
+ IN struct iwreq *wrq,
+ IN struct ate_racfghdr *pRaCfg)
+{
+ USHORT buffer[EEPROM_SIZE/2];
+
+ rt_ee_read_all(pAdapter,(USHORT *)buffer);
+ memcpy_exs(pAdapter, pRaCfg->data, (UCHAR *)buffer, EEPROM_SIZE);
+
+ RESPONSE_TO_GUI(pRaCfg, wrq, sizeof(pRaCfg->status)+EEPROM_SIZE, NDIS_STATUS_SUCCESS);
+
+ return NDIS_STATUS_SUCCESS;
+}
+
+
+static inline INT DO_RACFG_CMD_E2PROM_WRITE_ALL(
+ IN PRTMP_ADAPTER pAdapter,
+ IN struct iwreq *wrq,
+ IN struct ate_racfghdr *pRaCfg)
+{
+ 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);
+
+ RESPONSE_TO_GUI(pRaCfg, wrq, sizeof(pRaCfg->status), NDIS_STATUS_SUCCESS);
+
+ return NDIS_STATUS_SUCCESS;
+}
+
+
+static inline INT DO_RACFG_CMD_IO_READ(
+ IN PRTMP_ADAPTER pAdapter,
+ IN struct iwreq *wrq,
+ IN struct ate_racfghdr *pRaCfg)
+{
+ 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);
+ memcpy(pRaCfg->data, &value, 4);
+
+ RESPONSE_TO_GUI(pRaCfg, wrq, sizeof(pRaCfg->status)+4, NDIS_STATUS_SUCCESS);
+
+ return NDIS_STATUS_SUCCESS;
+}
+
+
+static inline INT DO_RACFG_CMD_IO_WRITE(
+ IN PRTMP_ADAPTER pAdapter,
+ IN struct iwreq *wrq,
+ IN struct ate_racfghdr *pRaCfg)
+{
+ 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 the offset out.
+ */
+ 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);
+
+ RESPONSE_TO_GUI(pRaCfg, wrq, sizeof(pRaCfg->status), NDIS_STATUS_SUCCESS);
+
+ return NDIS_STATUS_SUCCESS;
+}
+
+
+static inline INT DO_RACFG_CMD_IO_READ_BULK(
+ IN PRTMP_ADAPTER pAdapter,
+ IN struct iwreq *wrq,
+ IN struct ate_racfghdr *pRaCfg)
+{
+ UINT32 offset;
+ USHORT len;
+
+ memcpy(&offset, &pRaCfg->status, 4);
+ offset = ntohl(offset);
+
+ /*
+ We do not need the base address.
+ So just extract the offset out.
+ */
+ offset &= 0x0000FFFF;
+ memcpy(&len, pRaCfg->data+2, 2);
+ len = ntohs(len);
+
+ if (len > 371)
+ {
+ ATEDBGPRINT(RT_DEBUG_TRACE,("length requested is too large, make it smaller\n"));
+ pRaCfg->length = htons(2);
+ pRaCfg->status = htons(1);
+ return -EFAULT;
+ }
+
+ RTMP_IO_READ_BULK(pAdapter, pRaCfg->data, (UCHAR *)offset, len*4);// unit in four bytes
+
+ RESPONSE_TO_GUI(pRaCfg, wrq, sizeof(pRaCfg->status)+(len*4), NDIS_STATUS_SUCCESS);
+
+ return NDIS_STATUS_SUCCESS;
+}
+
+
+static inline INT DO_RACFG_CMD_BBP_READ8(
+ IN PRTMP_ADAPTER pAdapter,
+ IN struct iwreq *wrq,
+ IN struct ate_racfghdr *pRaCfg)
+{
+ 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);
+ }
+
+ pRaCfg->data[0] = value;
+
+ RESPONSE_TO_GUI(pRaCfg, wrq, sizeof(pRaCfg->status)+1, NDIS_STATUS_SUCCESS);
+
+ return NDIS_STATUS_SUCCESS;
+}
+
+
+static inline INT DO_RACFG_CMD_BBP_WRITE8(
+ IN PRTMP_ADAPTER pAdapter,
+ IN struct iwreq *wrq,
+ IN struct ate_racfghdr *pRaCfg)
+{
+ 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);
+ }
+
+ RESPONSE_TO_GUI(pRaCfg, wrq, sizeof(pRaCfg->status), NDIS_STATUS_SUCCESS);
+
+ return NDIS_STATUS_SUCCESS;
+}
+
+
+static inline INT DO_RACFG_CMD_BBP_READ_ALL(
+ IN PRTMP_ADAPTER pAdapter,
+ IN struct iwreq *wrq,
+ IN struct ate_racfghdr *pRaCfg)
+{
+ USHORT bbp_reg_index;
+
+ for (bbp_reg_index = 0; bbp_reg_index < MAX_BBP_ID+1; bbp_reg_index++)
+ {
+ pRaCfg->data[bbp_reg_index] = 0;
+
+ if (ATE_ON(pAdapter))
+ {
+ ATE_BBP_IO_READ8_BY_REG_ID(pAdapter, bbp_reg_index, &pRaCfg->data[bbp_reg_index]);
+ }
+ else
+ {
+ RTMP_BBP_IO_READ8_BY_REG_ID(pAdapter, bbp_reg_index, &pRaCfg->data[bbp_reg_index]);
+ }
+ }
+
+ RESPONSE_TO_GUI(pRaCfg, wrq, sizeof(pRaCfg->status)+MAX_BBP_ID+1, NDIS_STATUS_SUCCESS);
+
+ return NDIS_STATUS_SUCCESS;
+}
+
+
+static inline INT DO_RACFG_CMD_GET_NOISE_LEVEL(
+ IN PRTMP_ADAPTER pAdapter,
+ IN struct iwreq *wrq,
+ IN struct ate_racfghdr *pRaCfg)
+{
+ 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));
+
+ RESPONSE_TO_GUI(pRaCfg, wrq, sizeof(pRaCfg->status)+(sizeof(INT32)*3*10), NDIS_STATUS_SUCCESS);
+
+ return NDIS_STATUS_SUCCESS;
+}
+
+
+static inline INT DO_RACFG_CMD_GET_COUNTER(
+ IN PRTMP_ADAPTER pAdapter,
+ IN struct iwreq *wrq,
+ IN struct ate_racfghdr *pRaCfg)
+{
+ 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);
+
+ RESPONSE_TO_GUI(pRaCfg, wrq, sizeof(pRaCfg->status)+60, NDIS_STATUS_SUCCESS);
+
+ return NDIS_STATUS_SUCCESS;
+}
+
+
+static inline INT DO_RACFG_CMD_CLEAR_COUNTER(
+ IN PRTMP_ADAPTER pAdapter,
+ IN struct iwreq *wrq,
+ IN struct ate_racfghdr *pRaCfg)
+{
+ 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;
+
+ RESPONSE_TO_GUI(pRaCfg, wrq, sizeof(pRaCfg->status), NDIS_STATUS_SUCCESS);
+
+ return NDIS_STATUS_SUCCESS;
+}
+
+
+static inline INT DO_RACFG_CMD_TX_START(
+ IN PRTMP_ADAPTER pAdapter,
+ IN struct iwreq *wrq,
+ IN struct ate_racfghdr *pRaCfg)
+{
+ 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.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]);
+
+ /* always use QID_AC_BE */
+ pAdapter->ate.QID = 0;
+
+ p = (USHORT *)(&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)
+ {
+#ifdef RTMP_MAC_PCI
+ pAdapter->ate.TxCount = 0xFFFFFFFF;
+#endif // RTMP_MAC_PCI //
+ }
+ 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, BBP_R24, &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 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)
+ {
+ RESPONSE_TO_GUI(pRaCfg, wrq, sizeof(pRaCfg->status), NDIS_STATUS_SUCCESS);
+ return NDIS_STATUS_SUCCESS;
+ }
+
+TX_START_ERROR:
+ RESPONSE_TO_GUI(pRaCfg, wrq, sizeof(pRaCfg->status), err);
+
+ return err;
+}
+
+
+static inline INT DO_RACFG_CMD_GET_TX_STATUS(
+ IN PRTMP_ADAPTER pAdapter,
+ IN struct iwreq *wrq,
+ IN struct ate_racfghdr *pRaCfg)
+{
+ UINT32 count=0;
+
+ count = htonl(pAdapter->ate.TxDoneCount);
+ NdisMoveMemory(pRaCfg->data, &count, 4);
+
+ RESPONSE_TO_GUI(pRaCfg, wrq, sizeof(pRaCfg->status)+4, NDIS_STATUS_SUCCESS);
+
+ return NDIS_STATUS_SUCCESS;
+}
+
+
+static inline INT DO_RACFG_CMD_TX_STOP(
+ IN PRTMP_ADAPTER pAdapter,
+ IN struct iwreq *wrq,
+ IN struct ate_racfghdr *pRaCfg)
+{
+ ATEDBGPRINT(RT_DEBUG_TRACE,("RACFG_CMD_TX_STOP\n"));
+
+ Set_ATE_Proc(pAdapter, "TXSTOP");
+
+ RESPONSE_TO_GUI(pRaCfg, wrq, sizeof(pRaCfg->status), NDIS_STATUS_SUCCESS);
+
+ return NDIS_STATUS_SUCCESS;
+}
+
+
+static inline INT DO_RACFG_CMD_RX_START(
+ IN PRTMP_ADAPTER pAdapter,
+ IN struct iwreq *wrq,
+ IN struct ate_racfghdr *pRaCfg)
+{
+ ATEDBGPRINT(RT_DEBUG_TRACE,("RACFG_CMD_RX_START\n"));
+
+ pAdapter->ate.bQARxStart = TRUE;
+ Set_ATE_Proc(pAdapter, "RXFRAME");
+
+ RESPONSE_TO_GUI(pRaCfg, wrq, sizeof(pRaCfg->status), NDIS_STATUS_SUCCESS);
+
+ return NDIS_STATUS_SUCCESS;
+}
+
+
+static inline INT DO_RACFG_CMD_RX_STOP(
+ IN PRTMP_ADAPTER pAdapter,
+ IN struct iwreq *wrq,
+ IN struct ate_racfghdr *pRaCfg)
+{
+ ATEDBGPRINT(RT_DEBUG_TRACE,("RACFG_CMD_RX_STOP\n"));
+
+ Set_ATE_Proc(pAdapter, "RXSTOP");
+
+ RESPONSE_TO_GUI(pRaCfg, wrq, sizeof(pRaCfg->status), NDIS_STATUS_SUCCESS);
+
+ return NDIS_STATUS_SUCCESS;
+}
+
+
+static inline INT DO_RACFG_CMD_ATE_START_TX_CARRIER(
+ IN PRTMP_ADAPTER pAdapter,
+ IN struct iwreq *wrq,
+ IN struct ate_racfghdr *pRaCfg)
+{
+ ATEDBGPRINT(RT_DEBUG_TRACE,("RACFG_CMD_ATE_START_TX_CARRIER\n"));
+
+ Set_ATE_Proc(pAdapter, "TXCARR");
+
+ RESPONSE_TO_GUI(pRaCfg, wrq, sizeof(pRaCfg->status), NDIS_STATUS_SUCCESS);
+
+ return NDIS_STATUS_SUCCESS;
+}
+
+
+static inline INT DO_RACFG_CMD_ATE_START_TX_CONT(
+ IN PRTMP_ADAPTER pAdapter,
+ IN struct iwreq *wrq,
+ IN struct ate_racfghdr *pRaCfg)
+{
+ ATEDBGPRINT(RT_DEBUG_TRACE,("RACFG_CMD_ATE_START_TX_CONT\n"));
+
+ Set_ATE_Proc(pAdapter, "TXCONT");
+
+ RESPONSE_TO_GUI(pRaCfg, wrq, sizeof(pRaCfg->status), NDIS_STATUS_SUCCESS);
+
+ return NDIS_STATUS_SUCCESS;
+}
+
+
+static inline INT DO_RACFG_CMD_ATE_START_TX_FRAME(
+ IN PRTMP_ADAPTER pAdapter,
+ IN struct iwreq *wrq,
+ IN struct ate_racfghdr *pRaCfg)
+{
+ ATEDBGPRINT(RT_DEBUG_TRACE,("RACFG_CMD_ATE_START_TX_FRAME\n"));
+
+ Set_ATE_Proc(pAdapter, "TXFRAME");
+
+ RESPONSE_TO_GUI(pRaCfg, wrq, sizeof(pRaCfg->status), NDIS_STATUS_SUCCESS);
+
+ return NDIS_STATUS_SUCCESS;
+}
+
+
+static inline INT DO_RACFG_CMD_ATE_SET_BW(
+ IN PRTMP_ADAPTER pAdapter,
+ IN struct iwreq *wrq,
+ IN struct ate_racfghdr *pRaCfg)
+{
+ SHORT value = 0;
+ STRING 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((char *)str, "%d", value);
+
+ Set_ATE_TX_BW_Proc(pAdapter, str);
+
+ RESPONSE_TO_GUI(pRaCfg, wrq, sizeof(pRaCfg->status), NDIS_STATUS_SUCCESS);
+
+ return NDIS_STATUS_SUCCESS;
+}
+
+
+static inline INT DO_RACFG_CMD_ATE_SET_TX_POWER0(
+ IN PRTMP_ADAPTER pAdapter,
+ IN struct iwreq *wrq,
+ IN struct ate_racfghdr *pRaCfg)
+{
+ SHORT value = 0;
+ STRING 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((char *)str, "%d", value);
+ Set_ATE_TX_POWER0_Proc(pAdapter, str);
+
+ RESPONSE_TO_GUI(pRaCfg, wrq, sizeof(pRaCfg->status), NDIS_STATUS_SUCCESS);
+
+ return NDIS_STATUS_SUCCESS;
+}
+
+
+static inline INT DO_RACFG_CMD_ATE_SET_TX_POWER1(
+ IN PRTMP_ADAPTER pAdapter,
+ IN struct iwreq *wrq,
+ IN struct ate_racfghdr *pRaCfg)
+{
+ SHORT value = 0;
+ STRING 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((char *)str, "%d", value);
+ Set_ATE_TX_POWER1_Proc(pAdapter, str);
+
+ RESPONSE_TO_GUI(pRaCfg, wrq, sizeof(pRaCfg->status), NDIS_STATUS_SUCCESS);
+
+ return NDIS_STATUS_SUCCESS;
+}
+
+
+static inline INT DO_RACFG_CMD_ATE_SET_FREQ_OFFSET(
+ IN PRTMP_ADAPTER pAdapter,
+ IN struct iwreq *wrq,
+ IN struct ate_racfghdr *pRaCfg)
+{
+ SHORT value = 0;
+ STRING 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((char *)str, "%d", value);
+ Set_ATE_TX_FREQOFFSET_Proc(pAdapter, str);
+
+ RESPONSE_TO_GUI(pRaCfg, wrq, sizeof(pRaCfg->status), NDIS_STATUS_SUCCESS);
+
+ return NDIS_STATUS_SUCCESS;
+}
+
+
+static inline INT DO_RACFG_CMD_ATE_GET_STATISTICS(
+ IN PRTMP_ADAPTER pAdapter,
+ IN struct iwreq *wrq,
+ IN struct ate_racfghdr *pRaCfg)
+{
+ 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);
+ RESPONSE_TO_GUI(pRaCfg, wrq, sizeof(pRaCfg->status)+52, NDIS_STATUS_SUCCESS);
+ }
+ else
+ {
+ INT32 RSSI0 = 0;
+
+ RSSI0 = (INT32)(pAdapter->ate.LastRssi0 - pAdapter->BbpRssiToDbmDelta);
+ memcpy_exl(pAdapter, &pRaCfg->data[40], (UCHAR *)&RSSI0, 4);
+ RESPONSE_TO_GUI(pRaCfg, wrq, sizeof(pRaCfg->status)+44, NDIS_STATUS_SUCCESS);
+ }
+
+ return NDIS_STATUS_SUCCESS;
+}
+
+
+static inline INT DO_RACFG_CMD_ATE_RESET_COUNTER(
+ IN PRTMP_ADAPTER pAdapter,
+ IN struct iwreq *wrq,
+ IN struct ate_racfghdr *pRaCfg)
+{
+ SHORT value = 1;
+ STRING str[LEN_OF_ARG];
+
+ NdisZeroMemory(str, LEN_OF_ARG);
+
+ ATEDBGPRINT(RT_DEBUG_TRACE,("RACFG_CMD_ATE_RESET_COUNTER\n"));
+
+ sprintf((char *)str, "%d", value);
+ Set_ResetStatCounter_Proc(pAdapter, str);
+
+ pAdapter->ate.TxDoneCount = 0;
+
+ RESPONSE_TO_GUI(pRaCfg, wrq, sizeof(pRaCfg->status), NDIS_STATUS_SUCCESS);
+
+ return NDIS_STATUS_SUCCESS;
+}
+
+
+static inline INT DO_RACFG_CMD_ATE_SEL_TX_ANTENNA(
+ IN PRTMP_ADAPTER pAdapter,
+ IN struct iwreq *wrq,
+ IN struct ate_racfghdr *pRaCfg)
+{
+ SHORT value = 0;
+ STRING 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((char *)str, "%d", value);
+ Set_ATE_TX_Antenna_Proc(pAdapter, str);
+
+ RESPONSE_TO_GUI(pRaCfg, wrq, sizeof(pRaCfg->status), NDIS_STATUS_SUCCESS);
+
+ return NDIS_STATUS_SUCCESS;
+}
+
+
+static inline INT DO_RACFG_CMD_ATE_SEL_RX_ANTENNA(
+ IN PRTMP_ADAPTER pAdapter,
+ IN struct iwreq *wrq,
+ IN struct ate_racfghdr *pRaCfg)
+{
+ SHORT value = 0;
+ STRING 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((char *)str, "%d", value);
+ Set_ATE_RX_Antenna_Proc(pAdapter, str);
+
+ RESPONSE_TO_GUI(pRaCfg, wrq, sizeof(pRaCfg->status), NDIS_STATUS_SUCCESS);
+
+ return NDIS_STATUS_SUCCESS;
+}
+
+
+static inline INT DO_RACFG_CMD_ATE_SET_PREAMBLE(
+ IN PRTMP_ADAPTER pAdapter,
+ IN struct iwreq *wrq,
+ IN struct ate_racfghdr *pRaCfg)
+{
+ SHORT value = 0;
+ STRING 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((char *)str, "%d", value);
+ Set_ATE_TX_MODE_Proc(pAdapter, str);
+
+ RESPONSE_TO_GUI(pRaCfg, wrq, sizeof(pRaCfg->status), NDIS_STATUS_SUCCESS);
+
+ return NDIS_STATUS_SUCCESS;
+}
+
+
+static inline INT DO_RACFG_CMD_ATE_SET_CHANNEL(
+ IN PRTMP_ADAPTER pAdapter,
+ IN struct iwreq *wrq,
+ IN struct ate_racfghdr *pRaCfg)
+{
+ SHORT value = 0;
+ STRING 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((char *)str, "%d", value);
+ Set_ATE_CHANNEL_Proc(pAdapter, str);
+
+ RESPONSE_TO_GUI(pRaCfg, wrq, sizeof(pRaCfg->status), NDIS_STATUS_SUCCESS);
+
+ return NDIS_STATUS_SUCCESS;
+}
+
+
+static inline INT DO_RACFG_CMD_ATE_SET_ADDR1(
+ IN PRTMP_ADAPTER pAdapter,
+ IN struct iwreq *wrq,
+ IN struct ate_racfghdr *pRaCfg)
+{
+ 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);
+
+ RESPONSE_TO_GUI(pRaCfg, wrq, sizeof(pRaCfg->status), NDIS_STATUS_SUCCESS);
+
+ return NDIS_STATUS_SUCCESS;
+}
+
+
+static inline INT DO_RACFG_CMD_ATE_SET_ADDR2(
+ IN PRTMP_ADAPTER pAdapter,
+ IN struct iwreq *wrq,
+ IN struct ate_racfghdr *pRaCfg)
+{
+ 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);
+
+ RESPONSE_TO_GUI(pRaCfg, wrq, sizeof(pRaCfg->status), NDIS_STATUS_SUCCESS);
+
+ return NDIS_STATUS_SUCCESS;
+}
+
+
+static inline INT DO_RACFG_CMD_ATE_SET_ADDR3(
+ IN PRTMP_ADAPTER pAdapter,
+ IN struct iwreq *wrq,
+ IN struct ate_racfghdr *pRaCfg)
+{
+ 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);
+
+ RESPONSE_TO_GUI(pRaCfg, wrq, sizeof(pRaCfg->status), NDIS_STATUS_SUCCESS);
+
+ return NDIS_STATUS_SUCCESS;
+}
+
+
+static inline INT DO_RACFG_CMD_ATE_SET_RATE(
+ IN PRTMP_ADAPTER pAdapter,
+ IN struct iwreq *wrq,
+ IN struct ate_racfghdr *pRaCfg)
+{
+ SHORT value = 0;
+ STRING 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((char *)str, "%d", value);
+ Set_ATE_TX_MCS_Proc(pAdapter, str);
+
+ RESPONSE_TO_GUI(pRaCfg, wrq, sizeof(pRaCfg->status), NDIS_STATUS_SUCCESS);
+
+ return NDIS_STATUS_SUCCESS;
+}
+
+
+static inline INT DO_RACFG_CMD_ATE_SET_TX_FRAME_LEN(
+ IN PRTMP_ADAPTER pAdapter,
+ IN struct iwreq *wrq,
+ IN struct ate_racfghdr *pRaCfg)
+{
+ SHORT value = 0;
+ STRING 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((char *)str, "%d", value);
+ Set_ATE_TX_LENGTH_Proc(pAdapter, str);
+
+ RESPONSE_TO_GUI(pRaCfg, wrq, sizeof(pRaCfg->status), NDIS_STATUS_SUCCESS);
+
+ return NDIS_STATUS_SUCCESS;
+}
+
+
+static inline INT DO_RACFG_CMD_ATE_SET_TX_FRAME_COUNT(
+ IN PRTMP_ADAPTER pAdapter,
+ IN struct iwreq *wrq,
+ IN struct ate_racfghdr *pRaCfg)
+{
+ USHORT value = 0;
+ STRING 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);
+
+#ifdef RTMP_MAC_PCI
+ /* 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
+#endif // RTMP_MAC_PCI //
+ {
+ sprintf((char *)str, "%d", value);
+ Set_ATE_TX_COUNT_Proc(pAdapter, str);
+ }
+
+ RESPONSE_TO_GUI(pRaCfg, wrq, sizeof(pRaCfg->status), NDIS_STATUS_SUCCESS);
+
+ return NDIS_STATUS_SUCCESS;
+}
+
+
+static inline INT DO_RACFG_CMD_ATE_START_RX_FRAME(
+ IN PRTMP_ADAPTER pAdapter,
+ IN struct iwreq *wrq,
+ IN struct ate_racfghdr *pRaCfg)
+{
+ ATEDBGPRINT(RT_DEBUG_TRACE,("RACFG_CMD_RX_START\n"));
+
+ Set_ATE_Proc(pAdapter, "RXFRAME");
+
+ RESPONSE_TO_GUI(pRaCfg, wrq, sizeof(pRaCfg->status), NDIS_STATUS_SUCCESS);
+
+ return NDIS_STATUS_SUCCESS;
+}
+
+
+static inline INT DO_RACFG_CMD_ATE_E2PROM_READ_BULK(
+ IN PRTMP_ADAPTER pAdapter,
+ IN struct iwreq *wrq,
+ IN struct ate_racfghdr *pRaCfg)
+{
+ 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"));
+
+ RESPONSE_TO_GUI(pRaCfg, wrq, sizeof(pRaCfg->status)+len, NDIS_STATUS_SUCCESS);
+
+ return NDIS_STATUS_SUCCESS;
+}
+
+
+static inline INT DO_RACFG_CMD_ATE_E2PROM_WRITE_BULK(
+ IN PRTMP_ADAPTER pAdapter,
+ IN struct iwreq *wrq,
+ IN struct ate_racfghdr *pRaCfg)
+{
+ 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);
+
+ RESPONSE_TO_GUI(pRaCfg, wrq, sizeof(pRaCfg->status), NDIS_STATUS_SUCCESS);
+
+ return NDIS_STATUS_SUCCESS;
+}
+
+
+static inline INT DO_RACFG_CMD_ATE_IO_WRITE_BULK(
+ IN PRTMP_ADAPTER pAdapter,
+ IN struct iwreq *wrq,
+ IN struct ate_racfghdr *pRaCfg)
+{
+ 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);
+ ATEDBGPRINT(RT_DEBUG_TRACE,("Write %x %x\n", offset + i, value));
+ RTMP_IO_WRITE32(pAdapter, ((offset+i) & (0xffff)), value);
+ }
+
+ RESPONSE_TO_GUI(pRaCfg, wrq, sizeof(pRaCfg->status), NDIS_STATUS_SUCCESS);
+
+ return NDIS_STATUS_SUCCESS;
+}
+
+
+static inline INT DO_RACFG_CMD_ATE_BBP_READ_BULK(
+ IN PRTMP_ADAPTER pAdapter,
+ IN struct iwreq *wrq,
+ IN struct ate_racfghdr *pRaCfg)
+{
+ 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]);
+ }
+ }
+
+ RESPONSE_TO_GUI(pRaCfg, wrq, sizeof(pRaCfg->status)+len, NDIS_STATUS_SUCCESS);
+
+ return NDIS_STATUS_SUCCESS;
+}
+
+
+static inline INT DO_RACFG_CMD_ATE_BBP_WRITE_BULK(
+ IN PRTMP_ADAPTER pAdapter,
+ IN struct iwreq *wrq,
+ IN struct ate_racfghdr *pRaCfg)
+{
+ 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);
+ }
+ }
+
+ RESPONSE_TO_GUI(pRaCfg, wrq, sizeof(pRaCfg->status), NDIS_STATUS_SUCCESS);
+
+ return NDIS_STATUS_SUCCESS;
+}
+
+
+#endif // RALINK_28xx_QA //
+#endif // RALINK_ATE //
diff --git a/drivers/staging/rt3090/rt_ate.h b/drivers/staging/rt3090/rt_ate.h
new file mode 100644
index 000000000000..38d596162e74
--- /dev/null
+++ b/drivers/staging/rt3090/rt_ate.h
@@ -0,0 +1,314 @@
+/*
+ *************************************************************************
+ * 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__
+
+
+#ifdef LINUX
+#define ate_print printk
+#define ATEDBGPRINT DBGPRINT
+#ifdef RTMP_MAC_PCI
+#define EEPROM_SIZE 0x200
+#ifdef CONFIG_STA_SUPPORT
+#define EEPROM_BIN_FILE_NAME "/etc/Wireless/RT2860STA/e2p.bin"
+#endif // CONFIG_STA_SUPPORT //
+#endif // RTMP_MAC_PCI //
+#endif // LINUX //
+
+
+#define ATE_ON(_p) (((_p)->ate.Mode) != ATE_STOP)
+
+#ifdef RTMP_MAC_PCI
+#define ATE_BBP_IO_READ8_BY_REG_ID(_A, _I, _pV) \
+{ \
+ BBP_CSR_CFG_STRUC BbpCsr; \
+ int j, k; \
+ for (j=0; j<MAX_BUSY_COUNT; j++) \
+ { \
+ 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)); \
+ } \
+}
+#endif // RTMP_MAC_PCI //
+
+
+#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 PSTRING arg);
+
+INT Set_ATE_DA_Proc(
+ IN PRTMP_ADAPTER pAd,
+ IN PSTRING arg);
+
+INT Set_ATE_SA_Proc(
+ IN PRTMP_ADAPTER pAd,
+ IN PSTRING arg);
+
+INT Set_ATE_BSSID_Proc(
+ IN PRTMP_ADAPTER pAd,
+ IN PSTRING arg);
+
+INT Set_ATE_CHANNEL_Proc(
+ IN PRTMP_ADAPTER pAd,
+ IN PSTRING arg);
+
+INT Set_ATE_TX_POWER0_Proc(
+ IN PRTMP_ADAPTER pAd,
+ IN PSTRING arg);
+
+INT Set_ATE_TX_POWER1_Proc(
+ IN PRTMP_ADAPTER pAd,
+ IN PSTRING arg);
+
+INT Set_ATE_TX_Antenna_Proc(
+ IN PRTMP_ADAPTER pAd,
+ IN PSTRING arg);
+
+INT Set_ATE_RX_Antenna_Proc(
+ IN PRTMP_ADAPTER pAd,
+ IN PSTRING arg);
+
+INT Set_ATE_TX_FREQOFFSET_Proc(
+ IN PRTMP_ADAPTER pAd,
+ IN PSTRING arg);
+
+INT Set_ATE_TX_BW_Proc(
+ IN PRTMP_ADAPTER pAd,
+ IN PSTRING arg);
+
+INT Set_ATE_TX_LENGTH_Proc(
+ IN PRTMP_ADAPTER pAd,
+ IN PSTRING arg);
+
+INT Set_ATE_TX_COUNT_Proc(
+ IN PRTMP_ADAPTER pAd,
+ IN PSTRING arg);
+
+INT Set_ATE_TX_MCS_Proc(
+ IN PRTMP_ADAPTER pAd,
+ IN PSTRING arg);
+
+INT Set_ATE_TX_MODE_Proc(
+ IN PRTMP_ADAPTER pAd,
+ IN PSTRING arg);
+
+INT Set_ATE_TX_GI_Proc(
+ IN PRTMP_ADAPTER pAd,
+ IN PSTRING arg);
+
+
+INT Set_ATE_RX_FER_Proc(
+ IN PRTMP_ADAPTER pAd,
+ IN PSTRING arg);
+
+INT Set_ATE_Read_RF_Proc(
+ IN PRTMP_ADAPTER pAd,
+ IN PSTRING arg);
+
+INT Set_ATE_Write_RF1_Proc(
+ IN PRTMP_ADAPTER pAd,
+ IN PSTRING arg);
+
+INT Set_ATE_Write_RF2_Proc(
+ IN PRTMP_ADAPTER pAd,
+ IN PSTRING arg);
+
+INT Set_ATE_Write_RF3_Proc(
+ IN PRTMP_ADAPTER pAd,
+ IN PSTRING arg);
+
+INT Set_ATE_Write_RF4_Proc(
+ IN PRTMP_ADAPTER pAd,
+ IN PSTRING arg);
+
+INT Set_ATE_Load_E2P_Proc(
+ IN PRTMP_ADAPTER pAd,
+ IN PSTRING arg);
+
+INT Set_ATE_Read_E2P_Proc(
+ IN PRTMP_ADAPTER pAd,
+ IN PSTRING arg);
+
+
+INT Set_ATE_Show_Proc(
+ IN PRTMP_ADAPTER pAd,
+ IN PSTRING arg);
+
+INT Set_ATE_Help_Proc(
+ IN PRTMP_ADAPTER pAd,
+ IN PSTRING arg);
+
+#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 PSTRING arg);
+
+INT Set_RxStop_Proc(
+ IN PRTMP_ADAPTER pAd,
+ IN PSTRING arg);
+
+#ifdef DBG
+INT Set_EERead_Proc(
+ IN PRTMP_ADAPTER pAd,
+ IN PSTRING arg);
+
+INT Set_EEWrite_Proc(
+ IN PRTMP_ADAPTER pAd,
+ IN PSTRING arg);
+
+INT Set_BBPRead_Proc(
+ IN PRTMP_ADAPTER pAd,
+ IN PSTRING arg);
+
+INT Set_BBPWrite_Proc(
+ IN PRTMP_ADAPTER pAd,
+ IN PSTRING arg);
+
+INT Set_RFWrite_Proc(
+ IN PRTMP_ADAPTER pAd,
+ IN PSTRING arg);
+#endif // DBG //
+#endif // RALINK_28xx_QA //
+
+
+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/rt3090/rt_config.h b/drivers/staging/rt3090/rt_config.h
new file mode 100644
index 000000000000..005142dfa257
--- /dev/null
+++ b/drivers/staging/rt3090/rt_config.h
@@ -0,0 +1,126 @@
+/*
+ *************************************************************************
+ * 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"
+#include "rtmp_os.h"
+
+#include "rtmp_def.h"
+#include "rtmp_chip.h"
+#include "rtmp_timer.h"
+
+#include "oid.h"
+#include "mlme.h"
+#include "wpa.h"
+#include "crypt_md5.h"
+#include "crypt_sha2.h"
+#include "crypt_hmac.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 //
+
+#include "eeprom.h"
+#if defined(RTMP_PCI_SUPPORT) || defined(RTMP_USB_SUPPORT)
+#include "rtmp_mcu.h"
+#endif
+
+
+
+#undef AP_WSC_INCLUDED
+#undef STA_WSC_INCLUDED
+#undef WSC_INCLUDED
+
+
+
+#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 //
+
+#ifdef RALINK_28xx_QA
+#ifndef RALINK_ATE
+#error "For supporting QA GUI, please set HAS_ATE=y and HAS_28xx_QA=y."
+#endif // RALINK_ATE //
+#endif // RALINK_28xx_QA //
+
+
+
+
+#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__
diff --git a/drivers/staging/rt3090/rt_linux.c b/drivers/staging/rt3090/rt_linux.c
new file mode 100644
index 000000000000..375d0b77cad0
--- /dev/null
+++ b/drivers/staging/rt3090/rt_linux.c
@@ -0,0 +1,1623 @@
+/*
+ *************************************************************************
+ * 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;
+
+
+// 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*OS_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*OS_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*OS_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 RTMP_ADAPTER *pAd,
+ OUT UCHAR **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 PVOID mem)
+{
+
+ ASSERT(mem);
+ kfree(mem);
+ return (NDIS_STATUS_SUCCESS);
+}
+
+
+
+
+PNDIS_PACKET RtmpOSNetPktAlloc(
+ IN RTMP_ADAPTER *pAd,
+ IN int size)
+{
+ struct sk_buff *skb;
+ /* Add 2 more bytes for ip header alignment*/
+ skb = dev_alloc_skb(size+2);
+
+ return ((PNDIS_PACKET)skb);
+}
+
+
+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;
+
+ if (pAd->BeaconBuf)
+ kfree(pAd->BeaconBuf);
+
+
+ NdisFreeSpinLock(&pAd->MgmtRingLock);
+
+#ifdef RTMP_MAC_PCI
+ NdisFreeSpinLock(&pAd->RxRingLock);
+#ifdef RT3090
+NdisFreeSpinLock(&pAd->McuCmdLock);
+#endif // RT3090 //
+#endif // RTMP_MAC_PCI //
+
+ 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);
+ if (os_cookie)
+ 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 + RTMP_PKT_TAIL_PADDING);
+ 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 = (PNDIS_BUFFER)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 = (PNDIS_BUFFER)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;
+ }
+}
+
+
+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;
+#ifdef INF_AMAZON_PPA
+ int ret = 0;
+ unsigned int ppa_flags = 0; /* reserved for now */
+#endif // INF_AMAZON_PPA //
+
+ 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
+#ifdef INF_AMAZON_SE
+#ifdef BG_FT_SUPPORT
+ BG_FTPH_PacketFromApHandle(pRxPkt);
+ return;
+#endif // BG_FT_SUPPORT //
+#endif // INF_AMAZON_SE //
+ pRxPkt->protocol = eth_type_trans(pRxPkt, pRxPkt->dev);
+
+#ifdef INF_AMAZON_PPA
+ if (ppa_hook_directpath_send_fn && pAd->PPAEnable==TRUE )
+ {
+ memset(pRxPkt->head,0,pRxPkt->data-pRxPkt->head-14);
+ DBGPRINT(RT_DEBUG_TRACE, ("ppa_hook_directpath_send_fn rx :ret:%d headroom:%d dev:%s pktlen:%d<===\n",ret,skb_headroom(pRxPkt)
+ ,pRxPkt->dev->name,pRxPkt->len));
+ hex_dump("rx packet", pRxPkt->data, 32);
+ ret = ppa_hook_directpath_send_fn(pAd->g_if_id, pRxPkt, pRxPkt->len, ppa_flags);
+ pRxPkt=NULL;
+ return;
+
+ }
+#endif // INF_AMAZON_PPA //
+
+//#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;
+ PSTRING 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;
+
+ RtmpOSWrielessEventSend(pAd, IWEVCUSTOM, Event_flag, NULL, (PUCHAR)pBuf, BufLen);
+ //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((PSTRING) ph->devname, (PSTRING) 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 //
+
+
+
+/*******************************************************************************
+
+ File open/close related functions.
+
+ *******************************************************************************/
+RTMP_OS_FD RtmpOSFileOpen(char *pPath, int flag, int mode)
+{
+ struct file *filePtr;
+
+ filePtr = filp_open(pPath, flag, 0);
+ if (IS_ERR(filePtr))
+ {
+ DBGPRINT(RT_DEBUG_ERROR, ("%s(): Error %ld opening %s\n", __FUNCTION__, -PTR_ERR(filePtr), pPath));
+ }
+
+ return (RTMP_OS_FD)filePtr;
+}
+
+int RtmpOSFileClose(RTMP_OS_FD osfd)
+{
+ filp_close(osfd, NULL);
+ return 0;
+}
+
+
+void RtmpOSFileSeek(RTMP_OS_FD osfd, int offset)
+{
+ osfd->f_pos = offset;
+}
+
+
+int RtmpOSFileRead(RTMP_OS_FD osfd, char *pDataPtr, int readLen)
+{
+ // The object must have a read method
+ if (osfd->f_op && osfd->f_op->read)
+ {
+ return osfd->f_op->read(osfd, pDataPtr, readLen, &osfd->f_pos);
+ }
+ else
+ {
+ DBGPRINT(RT_DEBUG_ERROR, ("no file read method\n"));
+ return -1;
+ }
+}
+
+
+int RtmpOSFileWrite(RTMP_OS_FD osfd, char *pDataPtr, int writeLen)
+{
+ return osfd->f_op->write(osfd, pDataPtr, (size_t)writeLen, &osfd->f_pos);
+}
+
+
+void RtmpOSFSInfoChange(RTMP_OS_FS_INFO *pOSFSInfo, BOOLEAN bSet)
+{
+ if (bSet)
+ {
+ // Save uid and gid used for filesystem access.
+ // Set user and group to 0 (root)
+#if LINUX_VERSION_CODE < KERNEL_VERSION(2,6,29)
+ pOSFSInfo->fsuid= current->fsuid;
+ pOSFSInfo->fsgid = current->fsgid;
+ current->fsuid = current->fsgid = 0;
+#else
+ pOSFSInfo->fsuid = current_fsuid();
+ pOSFSInfo->fsgid = current_fsgid();
+#endif
+ pOSFSInfo->fs = get_fs();
+ set_fs(KERNEL_DS);
+ }
+ else
+ {
+ set_fs(pOSFSInfo->fs);
+#if LINUX_VERSION_CODE < KERNEL_VERSION(2,6,29)
+ current->fsuid = pOSFSInfo->fsuid;
+ current->fsgid = pOSFSInfo->fsgid;
+#endif
+ }
+}
+
+
+
+/*******************************************************************************
+
+ Task create/management/kill related functions.
+
+ *******************************************************************************/
+NDIS_STATUS RtmpOSTaskKill(
+ IN RTMP_OS_TASK *pTask)
+{
+ RTMP_ADAPTER *pAd;
+ int ret = NDIS_STATUS_FAILURE;
+
+ pAd = (RTMP_ADAPTER *)pTask->priv;
+
+#ifdef KTHREAD_SUPPORT
+ if (pTask->kthread_task)
+ {
+ kthread_stop(pTask->kthread_task);
+ ret = NDIS_STATUS_SUCCESS;
+ }
+#else
+ CHECK_PID_LEGALITY(pTask->taskPID)
+ {
+ printk("Terminate the task(%s) with pid(%d)!\n", pTask->taskName, GET_PID_NUMBER(pTask->taskPID));
+ mb();
+ pTask->task_killed = 1;
+ mb();
+ ret = KILL_THREAD_PID(pTask->taskPID, SIGTERM, 1);
+ if (ret)
+ {
+ printk(KERN_WARNING "kill task(%s) with pid(%d) failed(retVal=%d)!\n",
+ pTask->taskName, GET_PID_NUMBER(pTask->taskPID), ret);
+ }
+ else
+ {
+ wait_for_completion(&pTask->taskComplete);
+ pTask->taskPID = THREAD_PID_INIT_VALUE;
+ pTask->task_killed = 0;
+ ret = NDIS_STATUS_SUCCESS;
+ }
+ }
+#endif
+
+ return ret;
+
+}
+
+
+INT RtmpOSTaskNotifyToExit(
+ IN RTMP_OS_TASK *pTask)
+{
+
+#ifndef KTHREAD_SUPPORT
+ complete_and_exit(&pTask->taskComplete, 0);
+#endif
+
+ return 0;
+}
+
+
+void RtmpOSTaskCustomize(
+ IN RTMP_OS_TASK *pTask)
+{
+
+#ifndef KTHREAD_SUPPORT
+
+#if LINUX_VERSION_CODE >= KERNEL_VERSION(2,5,0)
+ daemonize((PSTRING)&pTask->taskName[0]/*"%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, &pTask->taskName[0]);
+
+ 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(&pTask->taskComplete);
+
+#endif
+}
+
+
+NDIS_STATUS RtmpOSTaskAttach(
+ IN RTMP_OS_TASK *pTask,
+ IN int (*fn)(void *),
+ IN void *arg)
+{
+ NDIS_STATUS status = NDIS_STATUS_SUCCESS;
+ pid_t pid_number = -1;
+
+#ifdef KTHREAD_SUPPORT
+ pTask->task_killed = 0;
+ pTask->kthread_task = NULL;
+ pTask->kthread_task = kthread_run(fn, arg, pTask->taskName);
+ if (IS_ERR(pTask->kthread_task))
+ status = NDIS_STATUS_FAILURE;
+#else
+ pid_number = kernel_thread(fn, arg, RTMP_OS_MGMT_TASK_FLAGS);
+ if (pid_number < 0)
+ {
+ DBGPRINT (RT_DEBUG_ERROR, ("Attach task(%s) failed!\n", pTask->taskName));
+ status = NDIS_STATUS_FAILURE;
+ }
+ else
+ {
+ pTask->taskPID = GET_PID(pid_number);
+
+ // Wait for the thread to start
+ wait_for_completion(&pTask->taskComplete);
+ status = NDIS_STATUS_SUCCESS;
+ }
+#endif
+ return status;
+}
+
+
+NDIS_STATUS RtmpOSTaskInit(
+ IN RTMP_OS_TASK *pTask,
+ IN PSTRING pTaskName,
+ IN VOID *pPriv)
+{
+ int len;
+
+ ASSERT(pTask);
+
+#ifndef KTHREAD_SUPPORT
+ NdisZeroMemory((PUCHAR)(pTask), sizeof(RTMP_OS_TASK));
+#endif
+
+ len = strlen(pTaskName);
+ len = len > (RTMP_OS_TASK_NAME_LEN -1) ? (RTMP_OS_TASK_NAME_LEN-1) : len;
+ NdisMoveMemory(&pTask->taskName[0], pTaskName, len);
+ pTask->priv = pPriv;
+
+#ifndef KTHREAD_SUPPORT
+ RTMP_SEM_EVENT_INIT_LOCKED(&(pTask->taskSema));
+ pTask->taskPID = THREAD_PID_INIT_VALUE;
+
+ init_completion (&pTask->taskComplete);
+#endif
+
+ return NDIS_STATUS_SUCCESS;
+}
+
+
+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);
+ }
+ }
+}
+
+
+#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 //
+
+
+int RtmpOSWrielessEventSend(
+ IN RTMP_ADAPTER *pAd,
+ IN UINT32 eventType,
+ IN INT flags,
+ IN PUCHAR pSrcMac,
+ IN PUCHAR pData,
+ IN UINT32 dataLen)
+{
+ union iwreq_data wrqu;
+
+ memset(&wrqu, 0, sizeof(wrqu));
+
+ if (flags>-1)
+ wrqu.data.flags = flags;
+
+ if (pSrcMac)
+ memcpy(wrqu.ap_addr.sa_data, pSrcMac, MAC_ADDR_LEN);
+
+ if ((pData!= NULL) && (dataLen > 0))
+ wrqu.data.length = dataLen;
+
+ wireless_send_event(pAd->net_dev, eventType, &wrqu, (char *)pData);
+ return 0;
+}
+
+
+int RtmpOSNetDevAddrSet(
+ IN PNET_DEV pNetDev,
+ IN PUCHAR pMacAddr)
+{
+ struct net_device *net_dev;
+ RTMP_ADAPTER *pAd;
+
+ net_dev = pNetDev;
+ //pAd = (RTMP_ADAPTER *)net_dev->priv;
+ pAd=RTMP_OS_NETDEV_GET_PRIV(pNetDev);
+
+#ifdef CONFIG_STA_SUPPORT
+ // work-around for the SuSE due to it has it's own interface name management system.
+ 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 //
+
+ NdisMoveMemory(net_dev->dev_addr, pMacAddr, 6);
+
+ return 0;
+}
+
+
+
+/*
+ * Assign the network dev name for created Ralink WiFi interface.
+ */
+static int RtmpOSNetDevRequestName(
+ IN RTMP_ADAPTER *pAd,
+ IN PNET_DEV dev,
+ IN PSTRING pPrefixStr,
+ IN INT devIdx)
+{
+ PNET_DEV existNetDev;
+ STRING suffixName[IFNAMSIZ];
+ STRING desiredName[IFNAMSIZ];
+ int ifNameIdx, prefixLen, slotNameLen;
+ int Status;
+
+
+ prefixLen = strlen(pPrefixStr);
+ ASSERT((prefixLen < IFNAMSIZ));
+
+ for (ifNameIdx = devIdx; ifNameIdx < 32; ifNameIdx++)
+ {
+ memset(suffixName, 0, IFNAMSIZ);
+ memset(desiredName, 0, IFNAMSIZ);
+ strncpy(&desiredName[0], pPrefixStr, prefixLen);
+
+#ifdef MULTIPLE_CARD_SUPPORT
+ if (pAd->MC_RowID >= 0)
+ sprintf(suffixName, "%02d_%d", pAd->MC_RowID, ifNameIdx);
+ else
+#endif // MULTIPLE_CARD_SUPPORT //
+ sprintf(suffixName, "%d", ifNameIdx);
+
+ slotNameLen = strlen(suffixName);
+ ASSERT(((slotNameLen + prefixLen) < IFNAMSIZ));
+ strcat(desiredName, suffixName);
+
+ existNetDev = RtmpOSNetDevGetByName(dev, &desiredName[0]);
+ if (existNetDev == NULL)
+ break;
+ else
+ RtmpOSNetDeviceRefPut(existNetDev);
+ }
+
+ if(ifNameIdx < 32)
+ {
+ strcpy(&dev->name[0], &desiredName[0]);
+ Status = NDIS_STATUS_SUCCESS;
+ }
+ else
+ {
+ DBGPRINT(RT_DEBUG_ERROR,
+ ("Cannot request DevName with preifx(%s) and in range(0~32) as suffix from OS!\n", pPrefixStr));
+ Status = NDIS_STATUS_FAILURE;
+ }
+
+ return Status;
+}
+
+
+void RtmpOSNetDevClose(
+ IN PNET_DEV pNetDev)
+{
+ dev_close(pNetDev);
+}
+
+
+void RtmpOSNetDevFree(PNET_DEV pNetDev)
+{
+ ASSERT(pNetDev);
+
+#if LINUX_VERSION_CODE >= KERNEL_VERSION(2,5,0)
+ free_netdev(pNetDev);
+#else
+ kfree(pNetDev);
+#endif
+}
+
+
+INT RtmpOSNetDevAlloc(
+ IN PNET_DEV *new_dev_p,
+ IN UINT32 privDataSize)
+{
+ // assign it as null first.
+ *new_dev_p = NULL;
+
+ DBGPRINT(RT_DEBUG_TRACE, ("Allocate a net device with private data size=%d!\n", privDataSize));
+#if LINUX_VERSION_CODE <= 0x20402 // Red Hat 7.1
+ *new_dev_p = alloc_netdev(privDataSize, "eth%d", ether_setup);
+#else
+ *new_dev_p = alloc_etherdev(privDataSize);
+#endif // LINUX_VERSION_CODE //
+
+ if (*new_dev_p)
+ return NDIS_STATUS_SUCCESS;
+ else
+ return NDIS_STATUS_FAILURE;
+}
+
+
+PNET_DEV RtmpOSNetDevGetByName(PNET_DEV pNetDev, PSTRING pDevName)
+{
+ PNET_DEV pTargetNetDev = NULL;
+
+
+#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)
+ pTargetNetDev = dev_get_by_name(dev_net(pNetDev), pDevName);
+#else
+ ASSERT(pNetDev);
+ pTargetNetDev = dev_get_by_name(pNetDev->nd_net, pDevName);
+#endif
+#else
+ pTargetNetDev = dev_get_by_name(pDevName);
+#endif // KERNEL_VERSION(2,6,24) //
+
+#else
+ int devNameLen;
+
+ devNameLen = strlen(pDevName);
+ ASSERT((devNameLen <= IFNAMSIZ));
+
+ for(pTargetNetDev=dev_base; pTargetNetDev!=NULL; pTargetNetDev=pTargetNetDev->next)
+ {
+ if (strncmp(pTargetNetDev->name, pDevName, devNameLen) == 0)
+ break;
+ }
+#endif // KERNEL_VERSION(2,5,0) //
+
+ return pTargetNetDev;
+}
+
+
+void RtmpOSNetDeviceRefPut(PNET_DEV pNetDev)
+{
+#if LINUX_VERSION_CODE >= KERNEL_VERSION(2,5,0)
+ /*
+ every time dev_get_by_name is called, and it has returned a valid struct
+ net_device*, dev_put should be called afterwards, because otherwise the
+ machine hangs when the device is unregistered (since dev->refcnt > 1).
+ */
+ if(pNetDev)
+ dev_put(pNetDev);
+#endif // LINUX_VERSION_CODE //
+}
+
+
+INT RtmpOSNetDevDestory(
+ IN RTMP_ADAPTER *pAd,
+ IN PNET_DEV pNetDev)
+{
+
+ // TODO: Need to fix this
+ printk("WARNING: This function(%s) not implement yet!!!\n", __FUNCTION__);
+ return 0;
+}
+
+
+void RtmpOSNetDevDetach(PNET_DEV pNetDev)
+{
+ unregister_netdev(pNetDev);
+}
+
+
+int RtmpOSNetDevAttach(
+ IN PNET_DEV pNetDev,
+ IN RTMP_OS_NETDEV_OP_HOOK *pDevOpHook)
+{
+ int ret, rtnl_locked = FALSE;
+
+ DBGPRINT(RT_DEBUG_TRACE, ("RtmpOSNetDevAttach()--->\n"));
+ // If we need hook some callback function to the net device structrue, now do it.
+ if (pDevOpHook)
+ {
+ PRTMP_ADAPTER pAd = RTMP_OS_NETDEV_GET_PRIV(pNetDev);
+
+ pNetDev->netdev_ops = pDevOpHook->netdev_ops;
+
+ /* OS specific flags, here we used to indicate if we are virtual interface */
+ pNetDev->priv_flags = pDevOpHook->priv_flags;
+
+#if (WIRELESS_EXT < 21) && (WIRELESS_EXT >= 12)
+ pNetDev->get_wireless_stats = rt28xx_get_wireless_stats;
+#endif
+
+#ifdef CONFIG_STA_SUPPORT
+#if WIRELESS_EXT >= 12
+ if (pAd->OpMode == OPMODE_STA)
+ {
+ pNetDev->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)
+ {
+ pNetDev->wireless_handlers = &rt28xx_ap_iw_handler_def;
+ }
+#endif //WIRELESS_EXT >= 12
+#endif // CONFIG_APSTA_MIXED_SUPPORT //
+
+ // copy the net device mac address to the net_device structure.
+ NdisMoveMemory(pNetDev->dev_addr, &pDevOpHook->devAddr[0], MAC_ADDR_LEN);
+
+ rtnl_locked = pDevOpHook->needProtcted;
+ }
+
+ if (rtnl_locked)
+ ret = register_netdevice(pNetDev);
+ else
+ ret = register_netdev(pNetDev);
+
+ DBGPRINT(RT_DEBUG_TRACE, ("<---RtmpOSNetDevAttach(), ret=%d\n", ret));
+ if (ret == 0)
+ return NDIS_STATUS_SUCCESS;
+ else
+ return NDIS_STATUS_FAILURE;
+}
+
+
+PNET_DEV RtmpOSNetDevCreate(
+ IN RTMP_ADAPTER *pAd,
+ IN INT devType,
+ IN INT devNum,
+ IN INT privMemSize,
+ IN PSTRING pNamePrefix)
+{
+ struct net_device *pNetDev = NULL;
+ int status;
+
+
+ /* allocate a new network device */
+ status = RtmpOSNetDevAlloc(&pNetDev, 0 /*privMemSize*/);
+ if (status != NDIS_STATUS_SUCCESS)
+ {
+ /* allocation fail, exit */
+ DBGPRINT(RT_DEBUG_ERROR, ("Allocate network device fail (%s)...\n", pNamePrefix));
+ return NULL;
+ }
+
+
+ /* find a available interface name, max 32 interfaces */
+ status = RtmpOSNetDevRequestName(pAd, pNetDev, pNamePrefix, devNum);
+ if (status != NDIS_STATUS_SUCCESS)
+ {
+ /* error! no any available ra name can be used! */
+ DBGPRINT(RT_DEBUG_ERROR, ("Assign interface name (%s with suffix 0~32) failed...\n", pNamePrefix));
+ RtmpOSNetDevFree(pNetDev);
+
+ return NULL;
+ }
+ else
+ {
+ DBGPRINT(RT_DEBUG_TRACE, ("The name of the new %s interface is %s...\n", pNamePrefix, pNetDev->name));
+ }
+
+ return pNetDev;
+}
diff --git a/drivers/staging/rt3090/rt_linux.h b/drivers/staging/rt3090/rt_linux.h
new file mode 100644
index 000000000000..a970e780ef27
--- /dev/null
+++ b/drivers/staging/rt3090/rt_linux.h
@@ -0,0 +1,1034 @@
+/*
+ *************************************************************************
+ * 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_linux.h
+
+ Abstract:
+
+ Revision History:
+ Who When What
+ --------- ---------- ----------------------------------------------
+*/
+
+#ifndef __RT_LINUX_H__
+#define __RT_LINUX_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>
+
+#ifdef INF_AMAZON_PPA
+#include <asm/amazon_se/ifx_ppa_interface.h>
+#include <asm/amazon_se/ifx_ppa_hook.h>
+#endif // INF_AMAZON_PPA //
+
+// load firmware
+#define __KERNEL_SYSCALLS__
+#include <linux/unistd.h>
+#include <asm/uaccess.h>
+#include <asm/types.h>
+#include <asm/unaligned.h> // for get_unaligned()
+
+#ifdef KTHREAD_SUPPORT
+#include <linux/err.h>
+#include <linux/kthread.h>
+#endif // KTHREAD_SUPPORT //
+
+#undef AP_WSC_INCLUDED
+#undef STA_WSC_INCLUDED
+#undef WSC_INCLUDED
+
+
+#ifdef CONFIG_STA_SUPPORT
+#endif // CONFIG_STA_SUPPORT //
+
+
+#ifdef KTHREAD_SUPPORT
+#if LINUX_VERSION_CODE < KERNEL_VERSION(2,6,4)
+#error "This kerne version doesn't support kthread!!"
+#endif
+#endif // KTHREAD_SUPPORT //
+
+/***********************************************************************************
+ * Profile related sections
+ ***********************************************************************************/
+
+
+#ifdef CONFIG_STA_SUPPORT
+#ifdef RTMP_MAC_PCI
+#define STA_PROFILE_PATH "/etc/Wireless/RT2860STA/RT2860STA.dat"
+#define STA_DRIVER_VERSION "2.1.0.0"
+#ifdef MULTIPLE_CARD_SUPPORT
+#define CARD_INFO_PATH "/etc/Wireless/RT2860STA/RT2860STACard.dat"
+#endif // MULTIPLE_CARD_SUPPORT //
+#endif // RTMP_MAC_PCI //
+
+
+
+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 //
+
+/***********************************************************************************
+ * Compiler related definitions
+ ***********************************************************************************/
+#undef __inline
+#define __inline static inline
+#define IN
+#define OUT
+#define INOUT
+#define NDIS_STATUS INT
+
+
+/***********************************************************************************
+ * OS Specific definitions and data structures
+ ***********************************************************************************/
+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 void * NDIS_HANDLE;
+typedef char * PNDIS_BUFFER;
+
+#if LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,27)
+typedef struct pid * RTMP_OS_PID;
+#else
+typedef pid_t RTMP_OS_PID;
+#endif
+
+typedef struct semaphore RTMP_OS_SEM;
+
+#ifdef RTMP_MAC_PCI
+#ifndef PCI_DEVICE
+#define PCI_DEVICE(vend,dev) \
+ .vendor = (vend), .device = (dev), \
+ .subvendor = PCI_ANY_ID, .subdevice = PCI_ANY_ID
+#endif // PCI_DEVICE //
+#endif // RTMP_MAC_PCI //
+
+#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 RTMP_INC_REF(_A) 0
+#define RTMP_DEC_REF(_A) 0
+#define RTMP_GET_REF(_A) 0
+
+
+#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
+
+
+/***********************************************************************************
+ * Network related constant definitions
+ ***********************************************************************************/
+#ifndef IFNAMSIZ
+#define IFNAMSIZ 16
+#endif
+
+#define ETH_LENGTH_OF_ADDRESS 6
+
+#define NDIS_STATUS_SUCCESS 0x00
+#define NDIS_STATUS_FAILURE 0x01
+#define NDIS_STATUS_INVALID_DATA 0x02
+#define NDIS_STATUS_RESOURCES 0x03
+
+#define NDIS_SET_PACKET_STATUS(_p, _status) do{} while(0)
+#define NdisWriteErrorLogEntry(_a, _b, _c, _d) do{} while(0)
+
+/* 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)
+
+
+/***********************************************************************************
+ * Ralink Specific network related constant definitions
+ ***********************************************************************************/
+#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 //
+#define NET_DEVICE_REAL_IDX_MASK 0x0f // for each operation mode, we maximum support 15 entities.
+
+
+#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
+#define NDIS_PACKET_TYPE_PROMISCUOUS 4
+#endif // CONFIG_STA_SUPPORT //
+
+
+/***********************************************************************************
+ * OS signaling related constant definitions
+ ***********************************************************************************/
+
+
+/***********************************************************************************
+ * OS file operation related data structure definitions
+ ***********************************************************************************/
+typedef struct file* RTMP_OS_FD;
+
+typedef struct _RTMP_OS_FS_INFO_
+{
+ int fsuid;
+ int fsgid;
+ mm_segment_t fs;
+}RTMP_OS_FS_INFO;
+
+#define IS_FILE_OPEN_ERR(_fd) IS_ERR((_fd))
+
+
+/***********************************************************************************
+ * OS semaphore related data structure and definitions
+ ***********************************************************************************/
+struct os_lock {
+ spinlock_t lock;
+ unsigned long flags;
+};
+
+typedef spinlock_t NDIS_SPIN_LOCK;
+
+//
+// spin_lock enhanced for Nested spin lock
+//
+#define NdisAllocateSpinLock(__lock) \
+{ \
+ spin_lock_init((spinlock_t *)(__lock)); \
+}
+
+#define NdisFreeSpinLock(lock) \
+ do{}while(0)
+
+
+#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)); \
+}
+
+#define NdisAcquireSpinLock RTMP_SEM_LOCK
+#define NdisReleaseSpinLock RTMP_SEM_UNLOCK
+
+#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 RTMP_SEM_EVENT_INIT_LOCKED(_pSema) sema_init((_pSema), 0)
+#define RTMP_SEM_EVENT_INIT(_pSema) sema_init((_pSema), 1)
+#define RTMP_SEM_EVENT_WAIT(_pSema, _status) ((_status) = down_interruptible((_pSema)))
+#define RTMP_SEM_EVENT_UP(_pSema) up(_pSema)
+
+#ifdef KTHREAD_SUPPORT
+#define RTMP_WAIT_EVENT_INTERRUPTIBLE(_pAd, _pTask) \
+{ \
+ wait_event_interruptible(_pTask->kthread_q, \
+ _pTask->kthread_running || kthread_should_stop()); \
+ _pTask->kthread_running = FALSE; \
+ if (kthread_should_stop()) \
+ { \
+ RTMP_SET_FLAG(_pAd, fRTMP_ADAPTER_HALT_IN_PROGRESS); \
+ break; \
+ } \
+}
+#endif
+
+#ifdef KTHREAD_SUPPORT
+#define WAKE_UP(_pTask) \
+ do{ \
+ if ((_pTask)->kthread_task) \
+ { \
+ (_pTask)->kthread_running = TRUE; \
+ wake_up(&(_pTask)->kthread_q); \
+ } \
+ }while(0)
+#endif
+
+/***********************************************************************************
+ * OS Memory Access related data structure and definitions
+ ***********************************************************************************/
+#define MEM_ALLOC_FLAG (GFP_ATOMIC) //(GFP_DMA | GFP_ATOMIC)
+
+#define NdisMoveMemory(Destination, Source, Length) memmove(Destination, Source, Length)
+#define NdisCopyMemory(Destination, Source, Length) memcpy(Destination, Source, Length)
+#define NdisZeroMemory(Destination, Length) memset(Destination, 0, Length)
+#define NdisFillMemory(Destination, Length, Fill) memset(Destination, Fill, Length)
+#define NdisCmpMemory(Destination, Source, Length) memcmp(Destination, Source, Length)
+#define NdisEqualMemory(Source1, Source2, Length) (!memcmp(Source1, Source2, Length))
+#define RTMPEqualMemory(Source1, Source2, Length) (!memcmp(Source1, Source2, Length))
+
+#define MlmeAllocateMemory(_pAd, _ppVA) os_alloc_mem(_pAd, _ppVA, MGMT_DMA_BUFFER_SIZE)
+#define MlmeFreeMemory(_pAd, _pVA) os_free_mem(_pAd, _pVA)
+
+#define COPY_MAC_ADDR(Addr1, Addr2) memcpy((Addr1), (Addr2), MAC_ADDR_LEN)
+
+
+/***********************************************************************************
+ * OS task related data structure and definitions
+ ***********************************************************************************/
+#define RTMP_OS_MGMT_TASK_FLAGS CLONE_VM
+
+#if LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,27)
+typedef struct pid * THREAD_PID;
+#define THREAD_PID_INIT_VALUE NULL
+#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 THREAD_PID_INIT_VALUE -1
+#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
+
+typedef struct tasklet_struct RTMP_NET_TASK_STRUCT;
+typedef struct tasklet_struct *PRTMP_NET_TASK_STRUCT;
+
+
+/***********************************************************************************
+ * Timer related definitions and data structures.
+ **********************************************************************************/
+#define OS_HZ HZ
+
+typedef struct timer_list NDIS_MINIPORT_TIMER;
+typedef struct timer_list RTMP_OS_TIMER;
+typedef void (*TIMER_FUNCTION)(unsigned long);
+
+
+#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); }
+
+#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 typecheck(type,x) \
+({ type __dummy; \
+ typeof(x) __dummy2; \
+ (void)(&__dummy == &__dummy2); \
+ 1; \
+})
+#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)
+#define RTMP_TIME_AFTER(a,b) time_after(a, b)
+#endif
+
+#define ONE_TICK 1
+
+static inline void NdisGetSystemUpTime(ULONG *time)
+{
+ *time = jiffies;
+}
+
+
+/***********************************************************************************
+ * OS specific cookie data structure binding to RTMP_ADAPTER
+ ***********************************************************************************/
+
+struct os_cookie {
+#ifdef RTMP_MAC_PCI
+ struct pci_dev *pci_dev;
+ struct pci_dev *parent_pci_dev;
+ USHORT DeviceID;
+ dma_addr_t pAd_pa;
+#endif // RTMP_MAC_PCI //
+
+
+ RTMP_NET_TASK_STRUCT rx_done_task;
+ RTMP_NET_TASK_STRUCT mgmt_dma_done_task;
+ RTMP_NET_TASK_STRUCT ac0_dma_done_task;
+ RTMP_NET_TASK_STRUCT ac1_dma_done_task;
+ RTMP_NET_TASK_STRUCT ac2_dma_done_task;
+ RTMP_NET_TASK_STRUCT ac3_dma_done_task;
+ /*RTMP_NET_TASK_STRUCT hcca_dma_done_task;*/
+ RTMP_NET_TASK_STRUCT tbtt_task;
+#ifdef RTMP_MAC_PCI
+ RTMP_NET_TASK_STRUCT fifo_statistic_full_task;
+#endif // RTMP_MAC_PCI //
+
+
+
+ unsigned long apd_pid; //802.1x daemon pid
+ INT ioctl_if_type;
+ INT ioctl_if;
+};
+
+typedef struct os_cookie * POS_COOKIE;
+
+
+
+/***********************************************************************************
+ * OS debugging and printing related definitions and data structure
+ ***********************************************************************************/
+#define PRINT_MAC(addr) \
+ addr[0], addr[1], addr[2], addr[3], addr[4], addr[5]
+
+#ifdef DBG
+extern ULONG RTDebugLevel;
+
+#define DBGPRINT_RAW(Level, Fmt) \
+do{ \
+ if (Level <= RTDebugLevel) \
+ { \
+ printk Fmt; \
+ } \
+}while(0)
+
+#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
+
+#undef ASSERT
+#define ASSERT(x) \
+{ \
+ if (!(x)) \
+ { \
+ printk(KERN_WARNING __FILE__ ":%d assert " #x "failed\n", __LINE__); \
+ } \
+}
+
+void hex_dump(char *str, unsigned char *pSrcBufVA, unsigned int SrcBufLen);
+
+
+/*********************************************************************************************************
+ The following code are not revised, temporary put it here.
+ *********************************************************************************************************/
+
+
+/***********************************************************************************
+ * Device DMA Access related definitions and data structures.
+ **********************************************************************************/
+#ifdef RTMP_MAC_PCI
+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);
+
+#define PCI_MAP_SINGLE(_handle, _ptr, _size, _sd_idx, _dir) \
+ linux_pci_map_single(_handle, _ptr, _size, _sd_idx, _dir)
+
+#define PCI_UNMAP_SINGLE(_handle, _ptr, _size, _dir) \
+ linux_pci_unmap_single(_handle, _ptr, _size, _dir)
+
+#define PCI_ALLOC_CONSISTENT(_pci_dev, _size, _ptr) \
+ pci_alloc_consistent(_pci_dev, _size, _ptr)
+
+#define PCI_FREE_CONSISTENT(_pci_dev, _size, _virtual_addr, _physical_addr) \
+ pci_free_consistent(_pci_dev, _size, _virtual_addr, _physical_addr)
+
+#define DEV_ALLOC_SKB(_length) \
+ dev_alloc_skb(_length)
+#endif // RTMP_MAC_PCI //
+
+
+
+/*
+ * 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)
+
+#define NdisMIndicateStatus(_w, _x, _y, _z)
+
+
+
+/***********************************************************************************
+ * Device Register I/O Access related definitions and data structures.
+ **********************************************************************************/
+#ifdef RTMP_MAC_PCI
+#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) \
+{ \
+ if ((_A)->bPCIclkOff == FALSE) \
+ { \
+ (*_pV = readl((void *)((_A)->CSRBaseAddress + MAC_CSR0))); \
+ (*_pV = readl((void *)((_A)->CSRBaseAddress + (_R)))); \
+ (*_pV = SWAP32(*((UINT32 *)(_pV)))); \
+ } \
+}
+
+#define RTMP_IO_READ8(_A, _R, _pV) \
+{ \
+ (*_pV = readl((void *)((_A)->CSRBaseAddress + MAC_CSR0))); \
+ (*_pV = readb((void *)((_A)->CSRBaseAddress + (_R)))); \
+}
+
+#define RTMP_IO_WRITE32(_A, _R, _V) \
+{ \
+ if ((_A)->bPCIclkOff == FALSE) \
+ { \
+ UINT32 _Val; \
+ _Val = readl((void *)((_A)->CSRBaseAddress + MAC_CSR0)); \
+ _Val = SWAP32(_V); \
+ writel(_Val, (void *)((_A)->CSRBaseAddress + (_R))); \
+ } \
+}
+
+#define RTMP_IO_WRITE8(_A, _R, _V) \
+{ \
+ UINT Val; \
+ Val = readl((void *)((_A)->CSRBaseAddress + MAC_CSR0)); \
+ writeb((_V), (PUCHAR)((_A)->CSRBaseAddress + (_R))); \
+}
+
+#define RTMP_IO_WRITE16(_A, _R, _V) \
+{ \
+ UINT Val; \
+ Val = readl((void *)((_A)->CSRBaseAddress + MAC_CSR0)); \
+ writew(SWAP16((_V)), (PUSHORT)((_A)->CSRBaseAddress + (_R))); \
+}
+#else
+//Patch for ASIC turst read/write bug, needs to remove after metel fix
+#define RTMP_IO_READ32(_A, _R, _pV) \
+{ \
+ if ((_A)->bPCIclkOff == FALSE) \
+ { \
+ (*_pV = readl((void *)((_A)->CSRBaseAddress + MAC_CSR0))); \
+ (*_pV = readl((void *)((_A)->CSRBaseAddress + (_R)))); \
+ } \
+ else \
+ *_pV = 0; \
+}
+
+#define RTMP_IO_FORCE_READ32(_A, _R, _pV) \
+{ \
+ (*_pV = readl((void *)((_A)->CSRBaseAddress + MAC_CSR0))); \
+ (*_pV = readl((void *)((_A)->CSRBaseAddress + (_R)))); \
+}
+
+#define RTMP_IO_READ8(_A, _R, _pV) \
+{ \
+ (*_pV = readl((void *)((_A)->CSRBaseAddress + MAC_CSR0))); \
+ (*_pV = readb((void *)((_A)->CSRBaseAddress + (_R)))); \
+}
+
+#define RTMP_IO_WRITE32(_A, _R, _V) \
+{ \
+ if ((_A)->bPCIclkOff == FALSE) \
+ { \
+ UINT Val; \
+ Val = readl((void *)((_A)->CSRBaseAddress + MAC_CSR0)); \
+ writel((_V), (void *)((_A)->CSRBaseAddress + (_R))); \
+ } \
+}
+
+#define RTMP_IO_FORCE_WRITE32(_A, _R, _V) \
+{ \
+ UINT Val; \
+ Val = readl((void *)((_A)->CSRBaseAddress + MAC_CSR0)); \
+ writel(_V, (void *)((_A)->CSRBaseAddress + (_R))); \
+}
+
+
+
+#if defined(BRCM_6358) || defined(RALINK_2880) || defined(RALINK_3052)
+#define RTMP_IO_WRITE8(_A, _R, _V) \
+{ \
+ ULONG Val; \
+ UCHAR _i; \
+ _i = ((_R) & 0x3); \
+ Val = readl((void *)((_A)->CSRBaseAddress + ((_R) - _i))); \
+ Val = Val & (~(0x000000ff << ((_i)*8))); \
+ Val = Val | ((ULONG)(_V) << ((_i)*8)); \
+ writel((Val), (void *)((_A)->CSRBaseAddress + ((_R) - _i))); \
+}
+#else
+#define RTMP_IO_WRITE8(_A, _R, _V) \
+{ \
+ UINT Val; \
+ Val = readl((void *)((_A)->CSRBaseAddress + MAC_CSR0)); \
+ writeb((_V), (PUCHAR)((_A)->CSRBaseAddress + (_R))); \
+}
+#endif // #if defined(BRCM_6358) || defined(RALINK_2880) //
+
+#define RTMP_IO_WRITE16(_A, _R, _V) \
+{ \
+ UINT Val; \
+ Val = readl((void *)((_A)->CSRBaseAddress + MAC_CSR0)); \
+ writew((_V), (PUSHORT)((_A)->CSRBaseAddress + (_R))); \
+}
+#endif // #if defined(INF_TWINPASS) || defined(INF_DANUBE) || defined(IKANOS_VX_1X0) //
+#endif // RTMP_MAC_PCI //
+
+
+
+/***********************************************************************************
+ * Network Related data structure and marco definitions
+ ***********************************************************************************/
+#define PKTSRC_NDIS 0x7f
+#define PKTSRC_DRIVER 0x0f
+
+
+#if LINUX_VERSION_CODE < KERNEL_VERSION(2,6,29)
+#define RTMP_OS_NETDEV_SET_PRIV(_pNetDev, _pPriv) ((_pNetDev)->priv = (_pPriv))
+#define RTMP_OS_NETDEV_GET_PRIV(_pNetDev) ((_pNetDev)->priv)
+#else
+#define RTMP_OS_NETDEV_SET_PRIV(_pNetDev, _pPriv) ((_pNetDev)->ml_priv = (_pPriv))
+#define RTMP_OS_NETDEV_GET_PRIV(_pNetDev) ((_pNetDev)->ml_priv)
+#endif
+#define RTMP_OS_NETDEV_GET_DEVNAME(_pNetDev) ((_pNetDev)->name)
+#define RTMP_OS_NETDEV_GET_PHYADDR(_PNETDEV) ((_PNETDEV)->dev_addr)
+
+#define RTMP_OS_NETDEV_START_QUEUE(_pNetDev) netif_start_queue((_pNetDev))
+#define RTMP_OS_NETDEV_STOP_QUEUE(_pNetDev) netif_stop_queue((_pNetDev))
+#define RTMP_OS_NETDEV_WAKE_QUEUE(_pNetDev) netif_wake_queue((_pNetDev))
+#define RTMP_OS_NETDEV_CARRIER_OFF(_pNetDev) netif_carrier_off((_pNetDev))
+
+#define QUEUE_ENTRY_TO_PACKET(pEntry) \
+ (PNDIS_PACKET)(pEntry)
+
+#define PACKET_TO_QUEUE_ENTRY(pPacket) \
+ (PQUEUE_ENTRY)(pPacket)
+
+#ifdef CONFIG_5VT_ENHANCE
+#define BRIDGE_TAG 0x35564252 // depends on 5VT define in br_input.c
+#endif
+
+#define GET_SG_LIST_FROM_PACKET(_p, _sc) \
+ rt_get_sg_list_from_packet(_p, _sc)
+
+#define RELEASE_NDIS_PACKET(_pAd, _pPacket, _Status) \
+{ \
+ RTMPFreeNdisPacket(_pAd, _pPacket); \
+}
+
+/*
+ * 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 SET_OS_PKT_DATAPTR(_pkt, _dataPtr) \
+ (RTPKT_TO_OSPKT(_pkt)->data) = (_dataPtr)
+
+#define GET_OS_PKT_LEN(_pkt) \
+ (RTPKT_TO_OSPKT(_pkt)->len)
+#define SET_OS_PKT_LEN(_pkt, _len) \
+ (RTPKT_TO_OSPKT(_pkt)->len) = (_len)
+
+#define GET_OS_PKT_DATATAIL(_pkt) \
+ (RTPKT_TO_OSPKT(_pkt)->tail)
+#define SET_OS_PKT_DATATAIL(_pkt, _start, _len) \
+ ((RTPKT_TO_OSPKT(_pkt))->tail) = (PUCHAR)((_start) + (_len))
+
+#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 SET_OS_PKT_NETDEV(_pkt, _pNetDev) \
+ (RTPKT_TO_OSPKT(_pkt)->dev) = (_pNetDev)
+
+#define GET_OS_PKT_TYPE(_pkt) \
+ (RTPKT_TO_OSPKT(_pkt))
+
+#define GET_OS_PKT_NEXT(_pkt) \
+ (RTPKT_TO_OSPKT(_pkt)->next)
+
+
+#define OS_PKT_CLONED(_pkt) skb_cloned(RTPKT_TO_OSPKT(_pkt))
+
+#define OS_NTOHS(_Val) \
+ (ntohs(_Val))
+#define OS_HTONS(_Val) \
+ (htons(_Val))
+#define OS_NTOHL(_Val) \
+ (ntohl(_Val))
+#define OS_HTONL(_Val) \
+ (htonl(_Val))
+
+#define CB_OFF 10
+
+// 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])
+
+
+
+
+
+//
+// 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])
+
+
+
+/* use bit3 of cb[CB_OFF+16] */
+
+#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
+/* [CB_OFF+28], 1B, 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+28] = _morebit)
+#define RTMP_GET_PACKET_NOBULKOUT(_p) (RTPKT_TO_OSPKT(_p)->cb[CB_OFF+28])
+#endif // INF_AMAZON_SE //
+/* Max skb->cb = 48B = [CB_OFF+38] */
+
+
+
+/***********************************************************************************
+ * Other function prototypes definitions
+ ***********************************************************************************/
+void RTMP_GetCurrentSystemTime(LARGE_INTEGER *time);
+int rt28xx_packet_xmit(struct sk_buff *skb);
+
+
+void FlashWrite(UCHAR * p, ULONG a, ULONG b);
+void FlashRead(UCHAR * p, ULONG a, ULONG b);
+
+#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 //
+
+
+#ifdef RTMP_MAC_PCI
+/* function declarations */
+#if LINUX_VERSION_CODE >= KERNEL_VERSION(2,5,0)
+#define IRQ_HANDLE_TYPE irqreturn_t
+#else
+#define IRQ_HANDLE_TYPE void
+#endif
+
+IRQ_HANDLE_TYPE
+#if (LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,19))
+rt2860_interrupt(int irq, void *dev_instance);
+#else
+rt2860_interrupt(int irq, void *dev_instance, struct pt_regs *regs);
+#endif
+
+#endif // RTMP_MAC_PCI //
+
+INT rt28xx_ioctl(
+ IN PNET_DEV net_dev,
+ IN OUT struct ifreq *rq,
+ IN INT cmd);
+
+
+#ifdef CONFIG_STA_SUPPORT
+INT rt28xx_sta_ioctl(
+ IN PNET_DEV net_dev,
+ IN OUT struct ifreq *rq,
+ IN INT cmd);
+#endif // CONFIG_STA_SUPPORT //
+
+extern int ra_mtd_write(int num, loff_t to, size_t len, const u_char *buf);
+extern int ra_mtd_read(int num, loff_t from, size_t len, u_char *buf);
+
+#endif // __RT_LINUX_H__ //
diff --git a/drivers/staging/rt3090/rt_main_dev.c b/drivers/staging/rt3090/rt_main_dev.c
new file mode 100644
index 000000000000..3307a5f36847
--- /dev/null
+++ b/drivers/staging/rt3090/rt_main_dev.c
@@ -0,0 +1,897 @@
+/*
+ *************************************************************************
+ * 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
+ -------- ---------- ----------------------------------------------
+*/
+
+#include "rt_config.h"
+
+
+#ifdef CONFIG_APSTA_MIXED_SUPPORT
+UINT32 CW_MAX_IN_BITS;
+#endif // CONFIG_APSTA_MIXED_SUPPORT //
+
+/*---------------------------------------------------------------------*/
+/* Private Variables Used */
+/*---------------------------------------------------------------------*/
+
+PSTRING mac = ""; // default 00:00:00:00:00:00
+PSTRING 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 */
+/*---------------------------------------------------------------------*/
+
+// public function prototype
+int rt28xx_close(IN struct net_device *net_dev);
+int rt28xx_open(struct net_device *net_dev);
+
+// private function prototype
+static INT rt28xx_send_packets(IN struct sk_buff *skb_p, IN struct net_device *net_dev);
+
+
+static 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 = RTMP_OS_NETDEV_GET_PRIV(net_dev);
+
+ // Sanity check for pAd
+ if (pAd == NULL)
+ return 0; // close ok
+
+ netif_carrier_off(pAd->net_dev);
+ netif_stop_queue(pAd->net_dev);
+
+
+
+
+#ifdef CONFIG_STA_SUPPORT
+ IF_DEV_CONFIG_OPMODE_ON_STA(pAd)
+ {
+ BOOLEAN Cancelled;
+#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;
+ }
+ }
+ RTMP_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);
+
+ if (MsgElem)
+ {
+ 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);
+ }
+
+ RTMPCancelTimer(&pAd->StaCfg.StaQuickResponeForRateUpTimer, &Cancelled);
+ RTMPCancelTimer(&pAd->StaCfg.WpaDisassocAndBlockAssocTimer, &Cancelled);
+
+#ifdef WPA_SUPPLICANT_SUPPORT
+#ifndef NATIVE_WPA_SUPPLICANT_SUPPORT
+ // send wireless event to wpa_supplicant for infroming interface down.
+ RtmpOSWrielessEventSend(pAd, IWEVCUSTOM, RT_INTERFACE_DOWN, NULL, NULL, 0);
+#endif // NATIVE_WPA_SUPPLICANT_SUPPORT //
+#endif // WPA_SUPPLICANT_SUPPORT //
+
+
+ }
+#endif // CONFIG_STA_SUPPORT //
+
+ 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 = RTMP_OS_NETDEV_GET_PRIV(net_dev);
+
+ // 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 = RTMP_OS_NETDEV_GET_PRIV(net_dev);
+ BOOLEAN Cancelled;
+ UINT32 i = 0;
+
+
+ DBGPRINT(RT_DEBUG_TRACE, ("===> rt28xx_close\n"));
+
+ Cancelled = FALSE;
+ // 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)
+ {
+#ifdef RTMP_MAC_PCI
+ RTMPPCIeLinkCtrlValueRestore(pAd, RESTORE_CLOSE);
+#endif // RTMP_MAC_PCI //
+
+ // 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);
+ }
+
+
+ MlmeRadioOff(pAd);
+#ifdef RTMP_MAC_PCI
+ pAd->bPCIclkOff = FALSE;
+#endif // RTMP_MAC_PCI //
+ }
+#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)
+ {
+ DBGPRINT(RT_DEBUG_TRACE, ("Waiting for TxQueue[%d] done..........\n", i));
+ RTMPusecDelay(1000);
+ }
+ }
+
+
+
+ // Stop Mlme state machine
+ MlmeHalt(pAd);
+
+ // Close net tasklets
+ RtmpNetTaskExit(pAd);
+
+
+#ifdef CONFIG_STA_SUPPORT
+ IF_DEV_CONFIG_OPMODE_ON_STA(pAd)
+ {
+ MacTableReset(pAd);
+ }
+#endif // CONFIG_STA_SUPPORT //
+
+
+ MeasureReqTabExit(pAd);
+ TpcReqTabExit(pAd);
+
+
+ // Close kernel threads
+ RtmpMgmtTaskExit(pAd);
+
+#ifdef RTMP_MAC_PCI
+ {
+ BOOLEAN brc;
+ // ULONG Value;
+
+ if (RTMP_TEST_FLAG(pAd, fRTMP_ADAPTER_INTERRUPT_ACTIVE))
+ {
+ RTMP_ASIC_INTERRUPT_DISABLE(pAd);
+ }
+
+ // Receive packets to clear DMA index after disable interrupt.
+ //RTMPHandleRxDoneInterrupt(pAd);
+ // put to radio off to save power when driver unload. After radiooff, can't write /read register. So need to finish all
+ // register access before Radio off.
+
+
+ brc=RT28xxPciAsicRadioOff(pAd, RTMP_HALT, 0);
+
+//In solution 3 of 3090F, the bPCIclkOff will be set to TRUE after calling RT28xxPciAsicRadioOff
+ pAd->bPCIclkOff = FALSE;
+
+ if (brc==FALSE)
+ {
+ DBGPRINT(RT_DEBUG_ERROR,("%s call RT28xxPciAsicRadioOff fail !!\n", __FUNCTION__));
+ }
+ }
+
+
+/*
+ if (RTMP_TEST_FLAG(pAd, fRTMP_ADAPTER_INTERRUPT_ACTIVE))
+ {
+ RTMP_ASIC_INTERRUPT_DISABLE(pAd);
+ }
+
+ // Disable Rx, register value supposed will remain after reset
+ NICIssueReset(pAd);
+*/
+#endif // RTMP_MAC_PCI //
+
+ // Free IRQ
+ if (RTMP_TEST_FLAG(pAd, fRTMP_ADAPTER_INTERRUPT_IN_USE))
+ {
+#ifdef RTMP_MAC_PCI
+ // Deregister interrupt function
+ RTMP_IRQ_RELEASE(net_dev)
+#endif // RTMP_MAC_PCI //
+ RTMP_CLEAR_FLAG(pAd, fRTMP_ADAPTER_INTERRUPT_IN_USE);
+ }
+
+ // 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 CONFIG_STA_SUPPORT
+#endif // CONFIG_STA_SUPPORT //
+
+ RTMP_CLEAR_FLAG(pAd, fRTMP_ADAPTER_START_UP);
+
+/*+++Modify by woody to solve the bulk fail+++*/
+#ifdef CONFIG_STA_SUPPORT
+ IF_DEV_CONFIG_OPMODE_ON_STA(pAd)
+ {
+ }
+#endif // CONFIG_STA_SUPPORT //
+
+ DBGPRINT(RT_DEBUG_TRACE, ("<=== rt28xx_close\n"));
+ return 0; // close ok
+} /* End of rt28xx_close */
+
+
+/*
+========================================================================
+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 = RTMP_OS_NETDEV_GET_PRIV(net_dev);
+ 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->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;
+ }
+#endif // CONFIG_APSTA_MIXED_SUPPORT //
+
+#if WIRELESS_EXT >= 12
+ if (net_dev->priv_flags == INT_MAIN)
+ {
+#ifdef CONFIG_APSTA_MIXED_SUPPORT
+ if (pAd->OpMode == OPMODE_AP)
+ net_dev->wireless_handlers = (struct iw_handler_def *) &rt28xx_ap_iw_handler_def;
+#endif // CONFIG_APSTA_MIXED_SUPPORT //
+#ifdef CONFIG_STA_SUPPORT
+ if (pAd->OpMode == OPMODE_STA)
+ net_dev->wireless_handlers = (struct iw_handler_def *) &rt28xx_iw_handler_def;
+#endif // CONFIG_STA_SUPPORT //
+ }
+#endif // WIRELESS_EXT >= 12 //
+
+ // Request interrupt service routine for PCI device
+ // register the interrupt routine with the os
+ RTMP_IRQ_REQUEST(net_dev);
+
+ // Init IRQ parameters stored in pAd
+ RTMP_IRQ_INIT(pAd);
+
+ // Chip & other init
+ if (rt28xx_init(pAd, mac, hostname) == FALSE)
+ goto err;
+
+#ifdef CONFIG_STA_SUPPORT
+#endif // CONFIG_STA_SUPPORT //
+
+ // Enable Interrupt
+ RTMP_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;
+// UINT8 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
+#ifdef RTMP_MAC_PCI
+ IF_DEV_CONFIG_OPMODE_ON_STA(pAd)
+ RTMPInitPCIeLinkCtrlValue(pAd);
+#endif // RTMP_MAC_PCI //
+#endif // CONFIG_STA_SUPPORT //
+
+ return (retval);
+
+err:
+//+++Add by shiang, move from rt28xx_init() to here.
+ RTMP_IRQ_RELEASE(net_dev);
+//---Add by shiang, move from rt28xx_init() to here.
+ return (-1);
+} /* End of rt28xx_open */
+
+static const struct net_device_ops rt3090_netdev_ops = {
+ .ndo_open = MainVirtualIF_open,
+ .ndo_stop = MainVirtualIF_close,
+ .ndo_do_ioctl = rt28xx_ioctl,
+ .ndo_get_stats = RT28xx_get_ether_stats,
+ .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
+};
+
+PNET_DEV RtmpPhyNetDevInit(
+ IN RTMP_ADAPTER *pAd,
+ IN RTMP_OS_NETDEV_OP_HOOK *pNetDevHook)
+{
+ struct net_device *net_dev = NULL;
+// NDIS_STATUS Status;
+
+ net_dev = RtmpOSNetDevCreate(pAd, INT_MAIN, 0, sizeof(PRTMP_ADAPTER), INF_MAIN_DEV_NAME);
+ if (net_dev == NULL)
+ {
+ printk("RtmpPhyNetDevInit(): creation failed for main physical net device!\n");
+ return NULL;
+ }
+
+ NdisZeroMemory((unsigned char *)pNetDevHook, sizeof(RTMP_OS_NETDEV_OP_HOOK));
+ pNetDevHook->netdev_ops = &rt3090_netdev_ops;
+ pNetDevHook->priv_flags = INT_MAIN;
+ pNetDevHook->needProtcted = FALSE;
+
+ RTMP_OS_NETDEV_SET_PRIV(net_dev, pAd);
+ //net_dev->priv = (PVOID)pAd;
+ pAd->net_dev = net_dev;
+
+
+
+#if LINUX_VERSION_CODE < KERNEL_VERSION(2,6,24)
+ SET_MODULE_OWNER(net_dev);
+#endif
+
+ netif_stop_queue(net_dev);
+
+ return net_dev;
+
+}
+
+
+/*
+========================================================================
+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 = RTMP_OS_NETDEV_GET_PRIV(net_dev);
+ 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:
+========================================================================
+*/
+static int rt28xx_send_packets(
+ IN struct sk_buff *skb_p,
+ IN struct net_device *net_dev)
+{
+ RTMP_ADAPTER *pAd = RTMP_OS_NETDEV_GET_PRIV(net_dev);
+
+ 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);
+}
+
+
+#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 = RTMP_OS_NETDEV_GET_PRIV(net_dev);
+
+
+
+ DBGPRINT(RT_DEBUG_TRACE, ("rt28xx_get_wireless_stats --->\n"));
+
+ pAd->iw_stats.status = 0; // Status - device dependent for now
+
+ // link quality
+#ifdef CONFIG_STA_SUPPORT
+ if (pAd->OpMode == OPMODE_STA)
+ pAd->iw_stats.qual.qual = ((pAd->Mlme.ChannelQuality * 12)/10 + 10);
+#endif // CONFIG_STA_SUPPORT //
+
+ 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;
+}
+#endif // WIRELESS_EXT //
+
+
+void tbtt_tasklet(unsigned long data)
+{
+//#define MAX_TX_IN_TBTT (16)
+
+}
+
+INT rt28xx_ioctl(
+ IN PNET_DEV net_dev,
+ IN OUT struct ifreq *rq,
+ IN INT cmd)
+{
+ RTMP_ADAPTER *pAd = NULL;
+ INT ret = 0;
+
+ pAd = RTMP_OS_NETDEV_GET_PRIV(net_dev);
+ if (pAd == NULL)
+ {
+ /* if 1st open fail, pAd will be free;
+ So the net_dev->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:
+
+ ========================================================================
+*/
+static struct net_device_stats *RT28xx_get_ether_stats(
+ IN struct net_device *net_dev)
+{
+ RTMP_ADAPTER *pAd = NULL;
+
+ if (net_dev)
+ pAd = RTMP_OS_NETDEV_GET_PRIV(net_dev);
+
+ 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;
+}
+
+
+BOOLEAN RtmpPhyNetDevExit(
+ IN RTMP_ADAPTER *pAd,
+ IN PNET_DEV net_dev)
+{
+
+
+
+#ifdef INF_AMAZON_PPA
+ if (ppa_hook_directpath_register_dev_fn && pAd->PPAEnable==TRUE)
+ {
+ UINT status;
+ status=ppa_hook_directpath_register_dev_fn(&pAd->g_if_id, pAd->net_dev, NULL, PPA_F_DIRECTPATH_DEREGISTER);
+ printk("unregister PPA:g_if_id=%d status=%d\n",pAd->g_if_id,status);
+ }
+ kfree(pAd->pDirectpathCb);
+#endif // INF_AMAZON_PPA //
+
+ // Unregister network device
+ if (net_dev != NULL)
+ {
+ printk("RtmpOSNetDevDetach(): RtmpOSNetDeviceDetach(), dev->name=%s!\n", net_dev->name);
+ RtmpOSNetDevDetach(net_dev);
+ }
+
+ return TRUE;
+
+}
+
+
+/*
+========================================================================
+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)
+{
+
+ *ppAd = (PVOID)vmalloc(sizeof(RTMP_ADAPTER)); //pci_alloc_consistent(pci_dev, sizeof(RTMP_ADAPTER), phy_addr);
+
+ if (*ppAd)
+ {
+ NdisZeroMemory(*ppAd, sizeof(RTMP_ADAPTER));
+ ((PRTMP_ADAPTER)*ppAd)->OS_Cookie = handle;
+ return (NDIS_STATUS_SUCCESS);
+ } else {
+ return (NDIS_STATUS_FAILURE);
+ }
+}
diff --git a/drivers/staging/rt3090/rt_pci_rbus.c b/drivers/staging/rt3090/rt_pci_rbus.c
new file mode 100644
index 000000000000..29913191273b
--- /dev/null
+++ b/drivers/staging/rt3090/rt_pci_rbus.c
@@ -0,0 +1,989 @@
+/*
+ *************************************************************************
+ * 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_pci_rbus.c
+
+ Abstract:
+ Create and register network interface.
+
+ Revision History:
+ Who When What
+ -------- ---------- ----------------------------------------------
+*/
+
+#include "rt_config.h"
+#include <linux/pci.h>
+
+
+IRQ_HANDLE_TYPE
+#if (LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,19))
+rt2860_interrupt(int irq, void *dev_instance);
+#else
+rt2860_interrupt(int irq, void *dev_instance, struct pt_regs *regs);
+#endif
+
+
+static void rx_done_tasklet(unsigned long data);
+static void mgmt_dma_done_tasklet(unsigned long data);
+static void ac0_dma_done_tasklet(unsigned long data);
+static void ac1_dma_done_tasklet(unsigned long data);
+static void ac2_dma_done_tasklet(unsigned long data);
+static void ac3_dma_done_tasklet(unsigned long data);
+/*static void hcca_dma_done_tasklet(unsigned long data);*/
+static void fifo_statistic_full_tasklet(unsigned long data);
+
+
+
+/*---------------------------------------------------------------------*/
+/* Symbol & Macro Definitions */
+/*---------------------------------------------------------------------*/
+#define RT2860_INT_RX_DLY (1<<0) // bit 0
+#define RT2860_INT_TX_DLY (1<<1) // bit 1
+#define RT2860_INT_RX_DONE (1<<2) // bit 2
+#define RT2860_INT_AC0_DMA_DONE (1<<3) // bit 3
+#define RT2860_INT_AC1_DMA_DONE (1<<4) // bit 4
+#define RT2860_INT_AC2_DMA_DONE (1<<5) // bit 5
+#define RT2860_INT_AC3_DMA_DONE (1<<6) // bit 6
+#define RT2860_INT_HCCA_DMA_DONE (1<<7) // bit 7
+#define RT2860_INT_MGMT_DONE (1<<8) // bit 8
+#ifdef TONE_RADAR_DETECT_SUPPORT
+#define RT2860_INT_TONE_RADAR (1<<20) // bit 20
+#endif // TONE_RADAR_DETECT_SUPPORT //
+
+#define INT_RX RT2860_INT_RX_DONE
+
+#define INT_AC0_DLY (RT2860_INT_AC0_DMA_DONE) //| RT2860_INT_TX_DLY)
+#define INT_AC1_DLY (RT2860_INT_AC1_DMA_DONE) //| RT2860_INT_TX_DLY)
+#define INT_AC2_DLY (RT2860_INT_AC2_DMA_DONE) //| RT2860_INT_TX_DLY)
+#define INT_AC3_DLY (RT2860_INT_AC3_DMA_DONE) //| RT2860_INT_TX_DLY)
+#define INT_HCCA_DLY (RT2860_INT_HCCA_DMA_DONE) //| RT2860_INT_TX_DLY)
+#define INT_MGMT_DLY RT2860_INT_MGMT_DONE
+#ifdef TONE_RADAR_DETECT_SUPPORT
+#define INT_TONE_RADAR (RT2860_INT_TONE_RADAR)
+#endif // TONE_RADAR_DETECT_SUPPORT //
+
+
+/***************************************************************************
+ *
+ * Interface-depended memory allocation/Free related procedures.
+ * Mainly for Hardware TxDesc/RxDesc/MgmtDesc, DMA Memory for TxData/RxData, etc.,
+ *
+ **************************************************************************/
+// Function for TxDesc Memory allocation.
+void RTMP_AllocateTxDescMemory(
+ IN PRTMP_ADAPTER pAd,
+ IN UINT Index,
+ IN ULONG Length,
+ IN BOOLEAN Cached,
+ OUT PVOID *VirtualAddress,
+ OUT PNDIS_PHYSICAL_ADDRESS PhysicalAddress)
+{
+ POS_COOKIE pObj = (POS_COOKIE)pAd->OS_Cookie;
+
+ *VirtualAddress = (PVOID)pci_alloc_consistent(pObj->pci_dev,sizeof(char)*Length, PhysicalAddress);
+
+}
+
+
+// Function for MgmtDesc Memory allocation.
+void RTMP_AllocateMgmtDescMemory(
+ IN PRTMP_ADAPTER pAd,
+ IN ULONG Length,
+ IN BOOLEAN Cached,
+ OUT PVOID *VirtualAddress,
+ OUT PNDIS_PHYSICAL_ADDRESS PhysicalAddress)
+{
+ POS_COOKIE pObj = (POS_COOKIE)pAd->OS_Cookie;
+
+ *VirtualAddress = (PVOID)pci_alloc_consistent(pObj->pci_dev,sizeof(char)*Length, PhysicalAddress);
+
+}
+
+
+// Function for RxDesc Memory allocation.
+void RTMP_AllocateRxDescMemory(
+ IN PRTMP_ADAPTER pAd,
+ IN ULONG Length,
+ IN BOOLEAN Cached,
+ OUT PVOID *VirtualAddress,
+ OUT PNDIS_PHYSICAL_ADDRESS PhysicalAddress)
+{
+ POS_COOKIE pObj = (POS_COOKIE)pAd->OS_Cookie;
+
+ *VirtualAddress = (PVOID)pci_alloc_consistent(pObj->pci_dev,sizeof(char)*Length, PhysicalAddress);
+
+}
+
+
+// Function for free allocated Desc Memory.
+void RTMP_FreeDescMemory(
+ IN PRTMP_ADAPTER pAd,
+ IN ULONG Length,
+ IN PVOID VirtualAddress,
+ IN NDIS_PHYSICAL_ADDRESS PhysicalAddress)
+{
+ POS_COOKIE pObj = (POS_COOKIE)pAd->OS_Cookie;
+
+ pci_free_consistent(pObj->pci_dev, Length, VirtualAddress, PhysicalAddress);
+}
+
+
+// Function for TxData DMA Memory allocation.
+void RTMP_AllocateFirstTxBuffer(
+ IN PRTMP_ADAPTER pAd,
+ IN UINT Index,
+ IN ULONG Length,
+ IN BOOLEAN Cached,
+ OUT PVOID *VirtualAddress,
+ OUT PNDIS_PHYSICAL_ADDRESS PhysicalAddress)
+{
+ POS_COOKIE pObj = (POS_COOKIE)pAd->OS_Cookie;
+
+ *VirtualAddress = (PVOID)pci_alloc_consistent(pObj->pci_dev,sizeof(char)*Length, PhysicalAddress);
+}
+
+
+void RTMP_FreeFirstTxBuffer(
+ IN PRTMP_ADAPTER pAd,
+ IN ULONG Length,
+ IN BOOLEAN Cached,
+ IN PVOID VirtualAddress,
+ IN NDIS_PHYSICAL_ADDRESS PhysicalAddress)
+{
+ POS_COOKIE pObj = (POS_COOKIE)pAd->OS_Cookie;
+
+ pci_free_consistent(pObj->pci_dev, Length, VirtualAddress, PhysicalAddress);
+}
+
+
+/*
+ * FUNCTION: Allocate a common buffer for DMA
+ * ARGUMENTS:
+ * AdapterHandle: AdapterHandle
+ * Length: Number of bytes to allocate
+ * Cached: Whether or not the memory can be cached
+ * VirtualAddress: Pointer to memory is returned here
+ * PhysicalAddress: Physical address corresponding to virtual address
+ */
+void RTMP_AllocateSharedMemory(
+ IN PRTMP_ADAPTER pAd,
+ IN ULONG Length,
+ IN BOOLEAN Cached,
+ OUT PVOID *VirtualAddress,
+ OUT PNDIS_PHYSICAL_ADDRESS PhysicalAddress)
+{
+ POS_COOKIE pObj = (POS_COOKIE)pAd->OS_Cookie;
+
+ *VirtualAddress = (PVOID)pci_alloc_consistent(pObj->pci_dev,sizeof(char)*Length, PhysicalAddress);
+}
+
+
+/*
+ * FUNCTION: Allocate a packet buffer for DMA
+ * ARGUMENTS:
+ * AdapterHandle: AdapterHandle
+ * Length: Number of bytes to allocate
+ * Cached: Whether or not the memory can be cached
+ * VirtualAddress: Pointer to memory is returned here
+ * PhysicalAddress: Physical address corresponding to virtual address
+ * Notes:
+ * Cached is ignored: always cached memory
+ */
+PNDIS_PACKET RTMP_AllocateRxPacketBuffer(
+ IN PRTMP_ADAPTER pAd,
+ IN ULONG Length,
+ IN BOOLEAN Cached,
+ OUT PVOID *VirtualAddress,
+ OUT PNDIS_PHYSICAL_ADDRESS PhysicalAddress)
+{
+ struct sk_buff *pkt;
+
+ pkt = dev_alloc_skb(Length);
+
+ if (pkt == NULL) {
+ DBGPRINT(RT_DEBUG_ERROR, ("can't allocate rx %ld size packet\n",Length));
+ }
+
+ if (pkt) {
+ RTMP_SET_PACKET_SOURCE(OSPKT_TO_RTPKT(pkt), PKTSRC_NDIS);
+ *VirtualAddress = (PVOID) pkt->data;
+//#ifdef CONFIG_5VT_ENHANCE
+// *PhysicalAddress = PCI_MAP_SINGLE(pAd, *VirtualAddress, 1600, PCI_DMA_FROMDEVICE);
+//#else
+ *PhysicalAddress = PCI_MAP_SINGLE(pAd, *VirtualAddress, Length, -1, PCI_DMA_FROMDEVICE);
+//#endif
+ } else {
+ *VirtualAddress = (PVOID) NULL;
+ *PhysicalAddress = (NDIS_PHYSICAL_ADDRESS) NULL;
+ }
+
+ return (PNDIS_PACKET) pkt;
+}
+
+
+VOID Invalid_Remaining_Packet(
+ IN PRTMP_ADAPTER pAd,
+ IN ULONG VirtualAddress)
+{
+ NDIS_PHYSICAL_ADDRESS PhysicalAddress;
+
+ PhysicalAddress = PCI_MAP_SINGLE(pAd, (void *)(VirtualAddress+1600), RX_BUFFER_NORMSIZE-1600, -1, PCI_DMA_FROMDEVICE);
+}
+
+
+int RtmpOSIRQRequest(IN struct net_device *net_dev)
+{
+ PRTMP_ADAPTER pAd = (PRTMP_ADAPTER)(RTMP_OS_NETDEV_GET_PRIV(net_dev));
+ int retval = 0;
+
+ ASSERT(pAd);
+
+ if (pAd->infType != RTMP_DEV_INF_RBUS)
+ {
+ POS_COOKIE _pObj = (POS_COOKIE)(pAd->OS_Cookie);
+ RTMP_MSI_ENABLE(pAd);
+ retval = request_irq(_pObj->pci_dev->irq, rt2860_interrupt, SA_SHIRQ, (net_dev)->name, (net_dev));
+ if (retval != 0)
+ printk("RT2860: request_irq ERROR(%d)\n", retval);
+ }
+ else
+ {
+#if LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,22)
+ if ((retval = request_irq(net_dev->irq, rt2860_interrupt, IRQF_SHARED, net_dev->name ,net_dev)))
+#else
+ if ((retval = request_irq(net_dev->irq,rt2860_interrupt, SA_INTERRUPT, net_dev->name ,net_dev)))
+#endif
+ {
+ printk("RT2860: request_irq ERROR(%d)\n", retval);
+ }
+ }
+
+ return retval;
+
+}
+
+
+int RtmpOSIRQRelease(IN struct net_device *net_dev)
+{
+ PRTMP_ADAPTER pAd = (PRTMP_ADAPTER)(RTMP_OS_NETDEV_GET_PRIV(net_dev));
+
+ ASSERT(pAd);
+ if (pAd->infType != RTMP_DEV_INF_RBUS)
+ {
+ POS_COOKIE pObj = (POS_COOKIE)(pAd->OS_Cookie);
+#if LINUX_VERSION_CODE >= KERNEL_VERSION(2,5,0)
+ synchronize_irq(pObj->pci_dev->irq);
+#endif
+ free_irq(pObj->pci_dev->irq, (net_dev));
+ RTMP_MSI_DISABLE(pAd);
+ }
+ else
+ {
+#if LINUX_VERSION_CODE >= KERNEL_VERSION(2,5,0)
+ synchronize_irq(net_dev->irq);
+#endif
+ free_irq(net_dev->irq, (net_dev));
+ }
+
+ return 0;
+}
+
+
+NDIS_STATUS RtmpNetTaskInit(IN RTMP_ADAPTER *pAd)
+{
+ POS_COOKIE pObj;
+
+ pObj = (POS_COOKIE) pAd->OS_Cookie;
+
+ tasklet_init(&pObj->rx_done_task, rx_done_tasklet, (unsigned long)pAd);
+ tasklet_init(&pObj->mgmt_dma_done_task, mgmt_dma_done_tasklet, (unsigned long)pAd);
+ tasklet_init(&pObj->ac0_dma_done_task, ac0_dma_done_tasklet, (unsigned long)pAd);
+ tasklet_init(&pObj->ac1_dma_done_task, ac1_dma_done_tasklet, (unsigned long)pAd);
+ tasklet_init(&pObj->ac2_dma_done_task, ac2_dma_done_tasklet, (unsigned long)pAd);
+ tasklet_init(&pObj->ac3_dma_done_task, ac3_dma_done_tasklet, (unsigned long)pAd);
+ /*tasklet_init(&pObj->hcca_dma_done_task, hcca_dma_done_tasklet, (unsigned long)pAd);*/
+ tasklet_init(&pObj->tbtt_task, tbtt_tasklet, (unsigned long)pAd);
+ tasklet_init(&pObj->fifo_statistic_full_task, fifo_statistic_full_tasklet, (unsigned long)pAd);
+
+ return NDIS_STATUS_SUCCESS;
+}
+
+
+void RtmpNetTaskExit(IN RTMP_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);
+ tasklet_kill(&pObj->fifo_statistic_full_task);
+}
+
+
+NDIS_STATUS RtmpMgmtTaskInit(IN RTMP_ADAPTER *pAd)
+{
+
+
+ return NDIS_STATUS_SUCCESS;
+}
+
+
+/*
+========================================================================
+Routine Description:
+ Close kernel threads.
+
+Arguments:
+ *pAd the raxx interface data pointer
+
+Return Value:
+ NONE
+
+Note:
+========================================================================
+*/
+VOID RtmpMgmtTaskExit(
+ IN RTMP_ADAPTER *pAd)
+{
+
+
+ return;
+}
+
+
+static inline void rt2860_int_enable(PRTMP_ADAPTER pAd, unsigned int mode)
+{
+ u32 regValue;
+
+ pAd->int_disable_mask &= ~(mode);
+ regValue = pAd->int_enable_reg & ~(pAd->int_disable_mask);
+ //if (!OPSTATUS_TEST_FLAG(pAd, fOP_STATUS_DOZE))
+ {
+ RTMP_IO_WRITE32(pAd, INT_MASK_CSR, regValue); // 1:enable
+ }
+ //else
+ // DBGPRINT(RT_DEBUG_TRACE, ("fOP_STATUS_DOZE !\n"));
+
+ if (regValue != 0)
+ RTMP_SET_FLAG(pAd, fRTMP_ADAPTER_INTERRUPT_ACTIVE);
+}
+
+
+static inline void rt2860_int_disable(PRTMP_ADAPTER pAd, unsigned int mode)
+{
+ u32 regValue;
+
+ pAd->int_disable_mask |= mode;
+ regValue = pAd->int_enable_reg & ~(pAd->int_disable_mask);
+ RTMP_IO_WRITE32(pAd, INT_MASK_CSR, regValue); // 0: disable
+
+ if (regValue == 0)
+ {
+ RTMP_CLEAR_FLAG(pAd, fRTMP_ADAPTER_INTERRUPT_ACTIVE);
+ }
+}
+
+
+/***************************************************************************
+ *
+ * tasklet related procedures.
+ *
+ **************************************************************************/
+static void mgmt_dma_done_tasklet(unsigned long data)
+{
+ unsigned long flags;
+ PRTMP_ADAPTER pAd = (PRTMP_ADAPTER) data;
+ INT_SOURCE_CSR_STRUC IntSource;
+ POS_COOKIE pObj;
+
+ // 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;
+
+ pObj = (POS_COOKIE) pAd->OS_Cookie;
+
+// printk("mgmt_dma_done_process\n");
+ IntSource.word = 0;
+ IntSource.field.MgmtDmaDone = 1;
+ pAd->int_pending &= ~INT_MGMT_DLY;
+
+ RTMPHandleMgmtRingDmaDoneInterrupt(pAd);
+
+ // if you use RTMP_SEM_LOCK, sometimes kernel will hang up, no any
+ // bug report output
+ RTMP_INT_LOCK(&pAd->irq_lock, flags);
+ /*
+ * double check to avoid lose of interrupts
+ */
+ if (pAd->int_pending & INT_MGMT_DLY)
+ {
+ tasklet_hi_schedule(&pObj->mgmt_dma_done_task);
+ RTMP_INT_UNLOCK(&pAd->irq_lock, flags);
+ return;
+ }
+
+ /* enable TxDataInt again */
+ rt2860_int_enable(pAd, INT_MGMT_DLY);
+ RTMP_INT_UNLOCK(&pAd->irq_lock, flags);
+}
+
+
+static void rx_done_tasklet(unsigned long data)
+{
+ unsigned long flags;
+ PRTMP_ADAPTER pAd = (PRTMP_ADAPTER) data;
+ BOOLEAN bReschedule = 0;
+ POS_COOKIE pObj;
+
+ // 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;
+
+#ifdef UAPSD_AP_SUPPORT
+ UAPSD_TIMING_RECORD(pAd, UAPSD_TIMING_RECORD_TASKLET);
+#endif // UAPSD_AP_SUPPORT //
+
+ 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 //
+
+#ifdef UAPSD_AP_SUPPORT
+ UAPSD_TIMING_RECORD_STOP();
+#endif // UAPSD_AP_SUPPORT //
+
+ RTMP_INT_LOCK(&pAd->irq_lock, flags);
+ /*
+ * double check to avoid rotting packet
+ */
+ if (pAd->int_pending & INT_RX || bReschedule)
+ {
+ tasklet_hi_schedule(&pObj->rx_done_task);
+ RTMP_INT_UNLOCK(&pAd->irq_lock, flags);
+ return;
+ }
+
+ /* enable RxINT again */
+ rt2860_int_enable(pAd, INT_RX);
+ RTMP_INT_UNLOCK(&pAd->irq_lock, flags);
+
+}
+
+
+void fifo_statistic_full_tasklet(unsigned long data)
+{
+ unsigned long flags;
+ PRTMP_ADAPTER pAd = (PRTMP_ADAPTER) data;
+ POS_COOKIE pObj;
+
+ // 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;
+
+ pObj = (POS_COOKIE) pAd->OS_Cookie;
+
+ pAd->int_pending &= ~(FifoStaFullInt);
+ NICUpdateFifoStaCounters(pAd);
+
+ RTMP_INT_LOCK(&pAd->irq_lock, flags);
+ /*
+ * double check to avoid rotting packet
+ */
+ if (pAd->int_pending & FifoStaFullInt)
+ {
+ tasklet_hi_schedule(&pObj->fifo_statistic_full_task);
+ RTMP_INT_UNLOCK(&pAd->irq_lock, flags);
+ return;
+ }
+
+ /* enable RxINT again */
+
+ rt2860_int_enable(pAd, FifoStaFullInt);
+ RTMP_INT_UNLOCK(&pAd->irq_lock, flags);
+
+}
+
+
+
+
+static void ac3_dma_done_tasklet(unsigned long data)
+{
+ unsigned long flags;
+ PRTMP_ADAPTER pAd = (PRTMP_ADAPTER) data;
+ INT_SOURCE_CSR_STRUC IntSource;
+ POS_COOKIE pObj;
+ BOOLEAN bReschedule = 0;
+
+ // 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;
+
+ pObj = (POS_COOKIE) pAd->OS_Cookie;
+
+// printk("ac0_dma_done_process\n");
+ IntSource.word = 0;
+ IntSource.field.Ac3DmaDone = 1;
+ pAd->int_pending &= ~INT_AC3_DLY;
+
+ bReschedule = RTMPHandleTxRingDmaDoneInterrupt(pAd, IntSource);
+
+ RTMP_INT_LOCK(&pAd->irq_lock, flags);
+ /*
+ * double check to avoid lose of interrupts
+ */
+ if ((pAd->int_pending & INT_AC3_DLY) || bReschedule)
+ {
+ tasklet_hi_schedule(&pObj->ac3_dma_done_task);
+ RTMP_INT_UNLOCK(&pAd->irq_lock, flags);
+ return;
+ }
+
+ /* enable TxDataInt again */
+ rt2860_int_enable(pAd, INT_AC3_DLY);
+ RTMP_INT_UNLOCK(&pAd->irq_lock, flags);
+}
+
+
+static void ac2_dma_done_tasklet(unsigned long data)
+{
+ unsigned long flags;
+ PRTMP_ADAPTER pAd = (PRTMP_ADAPTER) data;
+ INT_SOURCE_CSR_STRUC IntSource;
+ POS_COOKIE pObj;
+ BOOLEAN bReschedule = 0;
+
+ // 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;
+
+ pObj = (POS_COOKIE) pAd->OS_Cookie;
+
+ IntSource.word = 0;
+ IntSource.field.Ac2DmaDone = 1;
+ pAd->int_pending &= ~INT_AC2_DLY;
+
+ bReschedule = RTMPHandleTxRingDmaDoneInterrupt(pAd, IntSource);
+
+ RTMP_INT_LOCK(&pAd->irq_lock, flags);
+
+ /*
+ * double check to avoid lose of interrupts
+ */
+ if ((pAd->int_pending & INT_AC2_DLY) || bReschedule)
+ {
+ tasklet_hi_schedule(&pObj->ac2_dma_done_task);
+ RTMP_INT_UNLOCK(&pAd->irq_lock, flags);
+ return;
+ }
+
+ /* enable TxDataInt again */
+ rt2860_int_enable(pAd, INT_AC2_DLY);
+ RTMP_INT_UNLOCK(&pAd->irq_lock, flags);
+}
+
+
+static void ac1_dma_done_tasklet(unsigned long data)
+{
+ unsigned long flags;
+ PRTMP_ADAPTER pAd = (PRTMP_ADAPTER) data;
+ INT_SOURCE_CSR_STRUC IntSource;
+ POS_COOKIE pObj;
+ BOOLEAN bReschedule = 0;
+
+ // 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;
+
+ pObj = (POS_COOKIE) pAd->OS_Cookie;
+
+// printk("ac0_dma_done_process\n");
+ IntSource.word = 0;
+ IntSource.field.Ac1DmaDone = 1;
+ pAd->int_pending &= ~INT_AC1_DLY;
+
+ bReschedule = RTMPHandleTxRingDmaDoneInterrupt(pAd, IntSource);
+
+ RTMP_INT_LOCK(&pAd->irq_lock, flags);
+ /*
+ * double check to avoid lose of interrupts
+ */
+ if ((pAd->int_pending & INT_AC1_DLY) || bReschedule)
+ {
+ tasklet_hi_schedule(&pObj->ac1_dma_done_task);
+ RTMP_INT_UNLOCK(&pAd->irq_lock, flags);
+ return;
+ }
+
+ /* enable TxDataInt again */
+ rt2860_int_enable(pAd, INT_AC1_DLY);
+ RTMP_INT_UNLOCK(&pAd->irq_lock, flags);
+}
+
+
+static void ac0_dma_done_tasklet(unsigned long data)
+{
+ unsigned long flags;
+ PRTMP_ADAPTER pAd = (PRTMP_ADAPTER) data;
+ INT_SOURCE_CSR_STRUC IntSource;
+ POS_COOKIE pObj;
+ BOOLEAN bReschedule = 0;
+
+ // 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;
+
+ pObj = (POS_COOKIE) pAd->OS_Cookie;
+
+// printk("ac0_dma_done_process\n");
+ IntSource.word = 0;
+ IntSource.field.Ac0DmaDone = 1;
+ pAd->int_pending &= ~INT_AC0_DLY;
+
+// RTMPHandleMgmtRingDmaDoneInterrupt(pAd);
+ bReschedule = RTMPHandleTxRingDmaDoneInterrupt(pAd, IntSource);
+
+ RTMP_INT_LOCK(&pAd->irq_lock, flags);
+ /*
+ * double check to avoid lose of interrupts
+ */
+ if ((pAd->int_pending & INT_AC0_DLY) || bReschedule)
+ {
+ tasklet_hi_schedule(&pObj->ac0_dma_done_task);
+ RTMP_INT_UNLOCK(&pAd->irq_lock, flags);
+ return;
+ }
+
+ /* enable TxDataInt again */
+ rt2860_int_enable(pAd, INT_AC0_DLY);
+ RTMP_INT_UNLOCK(&pAd->irq_lock, flags);
+}
+
+
+
+
+/***************************************************************************
+ *
+ * interrupt handler related procedures.
+ *
+ **************************************************************************/
+int print_int_count;
+
+IRQ_HANDLE_TYPE
+#if (LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,19))
+rt2860_interrupt(int irq, void *dev_instance)
+#else
+rt2860_interrupt(int irq, void *dev_instance, struct pt_regs *regs)
+#endif
+{
+ struct net_device *net_dev = (struct net_device *) dev_instance;
+ PRTMP_ADAPTER pAd = (PRTMP_ADAPTER) RTMP_OS_NETDEV_GET_PRIV(net_dev);
+ INT_SOURCE_CSR_STRUC IntSource;
+ POS_COOKIE pObj;
+
+ pObj = (POS_COOKIE) pAd->OS_Cookie;
+
+
+ /* Note 03312008: we can not return here before
+ RTMP_IO_READ32(pAd, INT_SOURCE_CSR, &IntSource.word);
+ RTMP_IO_WRITE32(pAd, INT_SOURCE_CSR, IntSource.word);
+ Or kernel will panic after ifconfig ra0 down sometimes */
+
+
+ //
+ // Inital the Interrupt source.
+ //
+ IntSource.word = 0x00000000L;
+// McuIntSource.word = 0x00000000L;
+
+ //
+ // Get the interrupt sources & saved to local variable
+ //
+ //RTMP_IO_READ32(pAd, where, &McuIntSource.word);
+ //RTMP_IO_WRITE32(pAd, , McuIntSource.word);
+
+ //
+ // Flag fOP_STATUS_DOZE On, means ASIC put to sleep, elase means ASICK WakeUp
+ // And at the same time, clock maybe turned off that say there is no DMA service.
+ // when ASIC get to sleep.
+ // To prevent system hang on power saving.
+ // We need to check it before handle the INT_SOURCE_CSR, ASIC must be wake up.
+ //
+ // RT2661 => when ASIC is sleeping, MAC register cannot be read and written.
+ // RT2860 => when ASIC is sleeping, MAC register can be read and written.
+// if (!OPSTATUS_TEST_FLAG(pAd, fOP_STATUS_DOZE))
+ {
+ RTMP_IO_READ32(pAd, INT_SOURCE_CSR, &IntSource.word);
+ RTMP_IO_WRITE32(pAd, INT_SOURCE_CSR, IntSource.word); // write 1 to clear
+ }
+// else
+// DBGPRINT(RT_DEBUG_TRACE, (">>>fOP_STATUS_DOZE<<<\n"));
+
+// RTMP_IO_READ32(pAd, INT_SOURCE_CSR, &IsrAfterClear);
+// RTMP_IO_READ32(pAd, MCU_INT_SOURCE_CSR, &McuIsrAfterClear);
+// DBGPRINT(RT_DEBUG_INFO, ("====> RTMPHandleInterrupt(ISR=%08x,Mcu ISR=%08x, After clear ISR=%08x, MCU ISR=%08x)\n",
+// IntSource.word, McuIntSource.word, IsrAfterClear, McuIsrAfterClear));
+
+ // Do nothing if Reset in progress
+ if (RTMP_TEST_FLAG(pAd, (fRTMP_ADAPTER_RESET_IN_PROGRESS |fRTMP_ADAPTER_HALT_IN_PROGRESS)))
+ {
+#if LINUX_VERSION_CODE >= KERNEL_VERSION(2,5,0)
+ return IRQ_HANDLED;
+#else
+ return;
+#endif
+ }
+
+ //
+ // Handle interrupt, walk through all bits
+ // Should start from highest priority interrupt
+ // The priority can be adjust by altering processing if statement
+ //
+
+#ifdef DBG
+
+#endif
+
+
+ pAd->bPCIclkOff = FALSE;
+
+ // If required spinlock, each interrupt service routine has to acquire
+ // and release itself.
+ //
+
+ // Do nothing if NIC doesn't exist
+ if (IntSource.word == 0xffffffff)
+ {
+ RTMP_SET_FLAG(pAd, (fRTMP_ADAPTER_NIC_NOT_EXIST | fRTMP_ADAPTER_HALT_IN_PROGRESS));
+#if LINUX_VERSION_CODE >= KERNEL_VERSION(2,5,0)
+ return IRQ_HANDLED;
+#else
+ return;
+#endif
+ }
+
+ if (IntSource.word & TxCoherent)
+ {
+ DBGPRINT(RT_DEBUG_ERROR, (">>>TxCoherent<<<\n"));
+ RTMPHandleRxCoherentInterrupt(pAd);
+ }
+
+ if (IntSource.word & RxCoherent)
+ {
+ DBGPRINT(RT_DEBUG_ERROR, (">>>RxCoherent<<<\n"));
+ RTMPHandleRxCoherentInterrupt(pAd);
+ }
+
+ if (IntSource.word & FifoStaFullInt)
+ {
+ if ((pAd->int_disable_mask & FifoStaFullInt) == 0)
+ {
+ /* mask FifoStaFullInt */
+ rt2860_int_disable(pAd, FifoStaFullInt);
+ tasklet_hi_schedule(&pObj->fifo_statistic_full_task);
+ }
+ pAd->int_pending |= FifoStaFullInt;
+ }
+
+ if (IntSource.word & INT_MGMT_DLY)
+ {
+ if ((pAd->int_disable_mask & INT_MGMT_DLY) ==0 )
+ {
+ rt2860_int_disable(pAd, INT_MGMT_DLY);
+ tasklet_hi_schedule(&pObj->mgmt_dma_done_task);
+ }
+ pAd->int_pending |= INT_MGMT_DLY ;
+ }
+
+ if (IntSource.word & INT_RX)
+ {
+ if ((pAd->int_disable_mask & INT_RX) == 0)
+ {
+
+ /* mask RxINT */
+ rt2860_int_disable(pAd, INT_RX);
+ tasklet_hi_schedule(&pObj->rx_done_task);
+ }
+ pAd->int_pending |= INT_RX;
+ }
+
+
+ if (IntSource.word & INT_AC3_DLY)
+ {
+
+ if ((pAd->int_disable_mask & INT_AC3_DLY) == 0)
+ {
+ /* mask TxDataInt */
+ rt2860_int_disable(pAd, INT_AC3_DLY);
+ tasklet_hi_schedule(&pObj->ac3_dma_done_task);
+ }
+ pAd->int_pending |= INT_AC3_DLY;
+ }
+
+ if (IntSource.word & INT_AC2_DLY)
+ {
+
+ if ((pAd->int_disable_mask & INT_AC2_DLY) == 0)
+ {
+ /* mask TxDataInt */
+ rt2860_int_disable(pAd, INT_AC2_DLY);
+ tasklet_hi_schedule(&pObj->ac2_dma_done_task);
+ }
+ pAd->int_pending |= INT_AC2_DLY;
+ }
+
+ if (IntSource.word & INT_AC1_DLY)
+ {
+
+ pAd->int_pending |= INT_AC1_DLY;
+
+ if ((pAd->int_disable_mask & INT_AC1_DLY) == 0)
+ {
+ /* mask TxDataInt */
+ rt2860_int_disable(pAd, INT_AC1_DLY);
+ tasklet_hi_schedule(&pObj->ac1_dma_done_task);
+ }
+
+ }
+
+ if (IntSource.word & INT_AC0_DLY)
+ {
+
+/*
+ if (IntSource.word & 0x2) {
+ u32 reg;
+ RTMP_IO_READ32(pAd, DELAY_INT_CFG, &reg);
+ printk("IntSource.word = %08x, DELAY_REG = %08x\n", IntSource.word, reg);
+ }
+*/
+ pAd->int_pending |= INT_AC0_DLY;
+
+ if ((pAd->int_disable_mask & INT_AC0_DLY) == 0)
+ {
+ /* mask TxDataInt */
+ rt2860_int_disable(pAd, INT_AC0_DLY);
+ tasklet_hi_schedule(&pObj->ac0_dma_done_task);
+ }
+
+ }
+
+
+ if (IntSource.word & PreTBTTInt)
+ {
+ RTMPHandlePreTBTTInterrupt(pAd);
+ }
+
+ if (IntSource.word & TBTTInt)
+ {
+ RTMPHandleTBTTInterrupt(pAd);
+ }
+
+
+
+
+#ifdef CONFIG_STA_SUPPORT
+ IF_DEV_CONFIG_OPMODE_ON_STA(pAd)
+ {
+ if (IntSource.word & AutoWakeupInt)
+ RTMPHandleTwakeupInterrupt(pAd);
+ }
+#endif // CONFIG_STA_SUPPORT //
+
+#if LINUX_VERSION_CODE >= KERNEL_VERSION(2,5,0)
+ return IRQ_HANDLED;
+#endif
+
+}
+
+/*
+ * invaild or writeback cache
+ * and convert virtual address to physical address
+ */
+dma_addr_t linux_pci_map_single(void *handle, void *ptr, size_t size, int sd_idx, int direction)
+{
+ PRTMP_ADAPTER pAd;
+ POS_COOKIE pObj;
+
+ /*
+ ------ Porting Information ------
+ > For Tx Alloc:
+ mgmt packets => sd_idx = 0
+ SwIdx: pAd->MgmtRing.TxCpuIdx
+ pTxD : pAd->MgmtRing.Cell[SwIdx].AllocVa;
+
+ data packets => sd_idx = 1
+ TxIdx : pAd->TxRing[pTxBlk->QueIdx].TxCpuIdx
+ QueIdx: pTxBlk->QueIdx
+ pTxD : pAd->TxRing[pTxBlk->QueIdx].Cell[TxIdx].AllocVa;
+
+ > For Rx Alloc:
+ sd_idx = -1
+ */
+
+ pAd = (PRTMP_ADAPTER)handle;
+ pObj = (POS_COOKIE)pAd->OS_Cookie;
+
+ if (sd_idx == 1)
+ {
+ PTX_BLK pTxBlk;
+ pTxBlk = (PTX_BLK)ptr;
+ return pci_map_single(pObj->pci_dev, pTxBlk->pSrcBufData, pTxBlk->SrcBufLen, direction);
+ }
+ else
+ {
+ return pci_map_single(pObj->pci_dev, ptr, size, direction);
+ }
+
+}
+
+void linux_pci_unmap_single(void *handle, dma_addr_t dma_addr, size_t size, int direction)
+{
+ PRTMP_ADAPTER pAd;
+ POS_COOKIE pObj;
+
+ pAd=(PRTMP_ADAPTER)handle;
+ pObj = (POS_COOKIE)pAd->OS_Cookie;
+
+ pci_unmap_single(pObj->pci_dev, dma_addr, size, direction);
+
+}
diff --git a/drivers/staging/rt3090/rt_profile.c b/drivers/staging/rt3090/rt_profile.c
new file mode 100644
index 000000000000..49a05901bad4
--- /dev/null
+++ b/drivers/staging/rt3090/rt_profile.c
@@ -0,0 +1,101 @@
+/*
+ *************************************************************************
+ * 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_profile.c
+
+ Abstract:
+
+ Revision History:
+ Who When What
+ --------- ---------- ----------------------------------------------
+ */
+
+#include "rt_config.h"
+
+
+NDIS_STATUS RTMPReadParametersHook(
+ IN PRTMP_ADAPTER pAd)
+{
+ PSTRING src = NULL;
+ RTMP_OS_FD srcf;
+ RTMP_OS_FS_INFO osFSInfo;
+ INT retval = NDIS_STATUS_FAILURE;
+ PSTRING buffer;
+
+ buffer = kmalloc(MAX_INI_BUFFER_SIZE, MEM_ALLOC_FLAG);
+ if(buffer == NULL)
+ return NDIS_STATUS_FAILURE;
+ memset(buffer, 0x00, MAX_INI_BUFFER_SIZE);
+
+ {
+
+#ifdef CONFIG_STA_SUPPORT
+ IF_DEV_CONFIG_OPMODE_ON_STA(pAd)
+ {
+ src = STA_PROFILE_PATH;
+ }
+#endif // CONFIG_STA_SUPPORT //
+#ifdef MULTIPLE_CARD_SUPPORT
+ src = (PSTRING)pAd->MC_FileName;
+#endif // MULTIPLE_CARD_SUPPORT //
+ }
+
+ if (src && *src)
+ {
+ RtmpOSFSInfoChange(&osFSInfo, TRUE);
+ srcf = RtmpOSFileOpen(src, O_RDONLY, 0);
+ if (IS_FILE_OPEN_ERR(srcf))
+ {
+ DBGPRINT(RT_DEBUG_ERROR, ("Open file \"%s\" failed!\n", src));
+ }
+ else
+ {
+ retval =RtmpOSFileRead(srcf, buffer, MAX_INI_BUFFER_SIZE);
+ if (retval > 0)
+ {
+ RTMPSetProfileParameters(pAd, buffer);
+ retval = NDIS_STATUS_SUCCESS;
+ }
+ else
+ DBGPRINT(RT_DEBUG_ERROR, ("Read file \"%s\" failed(errCode=%d)!\n", src, retval));
+
+ retval = RtmpOSFileClose(srcf);
+ if ( retval != 0)
+ {
+ retval = NDIS_STATUS_FAILURE;
+ DBGPRINT(RT_DEBUG_ERROR, ("Close file \"%s\" failed(errCode=%d)!\n", src, retval));
+ }
+ }
+
+ RtmpOSFSInfoChange(&osFSInfo, FALSE);
+ }
+
+ kfree(buffer);
+
+ return (retval);
+
+}
diff --git a/drivers/staging/rt3090/rtmp.h b/drivers/staging/rt3090/rtmp.h
new file mode 100644
index 000000000000..8ef6d0bfdee6
--- /dev/null
+++ b/drivers/staging/rt3090/rtmp.h
@@ -0,0 +1,6873 @@
+/*
+ *************************************************************************
+ * 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"
+
+#include "rtmp_dot11.h"
+
+#ifdef MLME_EX
+#include "mlme_ex_def.h"
+#endif // MLME_EX //
+
+#ifdef CONFIG_STA_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
+
+
+
+
+
+#include "rtmp_chip.h"
+
+
+
+typedef struct _RTMP_ADAPTER RTMP_ADAPTER;
+typedef struct _RTMP_ADAPTER *PRTMP_ADAPTER;
+
+typedef struct _RTMP_CHIP_OP_ RTMP_CHIP_OP;
+
+
+//#define DBG 1
+
+//#define DBG_DIAGNOSE 1
+
+
+//+++Add by shiang for merge MiniportMMRequest() and MiniportDataMMRequest() into one function
+#define MAX_DATAMM_RETRY 3
+#define MGMT_USE_QUEUE_FLAG 0x80
+//---Add by shiang for merge MiniportMMRequest() and MiniportDataMMRequest() into one function
+
+#define MAXSEQ (0xFFF)
+
+
+#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
+
+extern unsigned char SNAP_AIRONET[];
+extern unsigned char CISCO_OUI[];
+extern UCHAR BaSizeArray[4];
+
+extern UCHAR BROADCAST_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 //
+
+
+#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; // Show Rx Frame Error Rate
+ BOOLEAN bQATxStart; // Have compiled QA in and use it to ATE tx.
+ BOOLEAN bQARxStart; // Have compiled QA in and use it to ATE rx.
+#ifdef RTMP_MAC_PCI
+ BOOLEAN bFWLoading; // Reload firmware when ATE is done.
+#endif // RTMP_MAC_PCI //
+ 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;
+ RTMP_OS_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;
+ // TxStatus : 0 --> task is idle, 1 --> task is running
+ UCHAR TxStatus;
+#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 //
+
+
+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->Next = NULL; \
+ (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++; \
+}
+
+#define InsertTailQueueAc(pAd, pEntry, 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))
+// 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))
+
+#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); \
+}
+
+
+#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)
+//
+
+
+//
+// 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); \
+ } \
+}
+
+
+// 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 RTMP_MAC_PCI
+#define REPORT_MGMT_FRAME_TO_MLME(_pAd, Wcid, _pFrame, _FrameSize, _Rssi0, _Rssi1, _Rssi2, _PlcpSignal) \
+{ \
+ UINT32 High32TSF, Low32TSF; \
+ RTMP_IO_READ32(_pAd, TSF_TIMER_DW1, &High32TSF); \
+ RTMP_IO_READ32(_pAd, TSF_TIMER_DW0, &Low32TSF); \
+ MlmeEnqueueForRecv(_pAd, Wcid, High32TSF, Low32TSF, (UCHAR)_Rssi0, (UCHAR)_Rssi1,(UCHAR)_Rssi2,_FrameSize, _pFrame, (UCHAR)_PlcpSignal); \
+}
+#endif // RTMP_MAC_PCI //
+
+#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_EXTRA_SETTING(_pAd)
+
+#define STA_PORT_SECURED(_pAd) \
+{ \
+ BOOLEAN Cancelled; \
+ (_pAd)->StaCfg.PortSecured = WPA_802_1X_PORT_SECURED; \
+ NdisAcquireSpinLock(&((_pAd)->MacTabLock)); \
+ (_pAd)->MacTab.Content[BSSID_WCID].PortSecured = (_pAd)->StaCfg.PortSecured; \
+ (_pAd)->MacTab.Content[BSSID_WCID].PrivacyFilter = Ndis802_11PrivFilterAcceptAll;\
+ NdisReleaseSpinLock(&(_pAd)->MacTabLock); \
+ RTMPCancelTimer(&((_pAd)->Mlme.LinkDownTimer), &Cancelled);\
+ STA_EXTRA_SETTING(_pAd); \
+}
+#endif // CONFIG_STA_SUPPORT //
+
+
+
+//
+// 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;
+
+
+//
+// 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_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 OneSecReceivedByteCount;
+ UINT32 OneSecFrameDuplicateCount;
+
+ UINT32 OneSecTransmittedByteCount; // both successful and failure, used to calculate TX throughput
+ 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 _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;
+
+
+
+
+/***************************************************************************
+ * security key related data structure
+ **************************************************************************/
+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;
+
+
+// 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 {
+ 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;
+
+//
+// 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;
+
+
+/*
+ * 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;
+
+
+//
+// Arcfour Structure Added by PaulWu
+//
+typedef struct _ARCFOUR
+{
+ UINT X;
+ UINT Y;
+ UCHAR STATE[256];
+} ARCFOURCONTEXT, *PARCFOURCONTEXT;
+
+
+//
+// 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;
+
+
+/***************************************************************************
+ * Channel and BBP related data structures
+ **************************************************************************/
+// 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 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
+#ifdef CONFIG_STA_SUPPORT
+ SHORT Pair1AvgRssi[2]; // AvgRssi[0]:E1, AvgRssi[1]:E2
+ SHORT Pair2AvgRssi[2]; // AvgRssi[0]:E3, AvgRssi[1]:E4
+#endif // CONFIG_STA_SUPPORT //
+ SHORT Pair1LastAvgRssi; //
+ SHORT Pair2LastAvgRssi; //
+ ULONG RcvPktNumWhenEvaluate;
+ BOOLEAN FirstPktArrivedWhenEvaluate;
+ RALINK_TIMER_STRUCT RxAntDiversityTimer;
+} SOFT_RX_ANT_DIVERSITY, *PSOFT_RX_ANT_DIVERSITY;
+
+
+/***************************************************************************
+ * 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;
+#ifdef DFS_FCC_BW40_FIX
+ CHAR DfsSessionFccOff;
+#endif
+ BOOLEAN bFastDfs;
+ UINT8 ChMovingTime;
+ UINT8 LongPulseRadarTh;
+#ifdef MERGE_ARCH_TEAM
+ CHAR AvgRssiReq;
+ ULONG DfsLowerLimit;
+ ULONG DfsUpperLimit;
+ UINT8 FixDfsLimit;
+ ULONG upperlimit;
+ ULONG lowerlimit;
+#endif // MERGE_ARCH_TEAM //
+} RADAR_DETECT_STRUCT, *PRADAR_DETECT_STRUCT;
+
+#ifdef CARRIER_DETECTION_SUPPORT
+typedef enum CD_STATE_n
+{
+ CD_NORMAL,
+ CD_SILENCE,
+ CD_MAX_STATE
+} CD_STATE;
+
+#ifdef TONE_RADAR_DETECT_SUPPORT
+#define CARRIER_DETECT_RECHECK_TIME 3
+
+
+#ifdef CARRIER_SENSE_NEW_ALGO
+#define CARRIER_DETECT_CRITIRIA 400
+#define CARRIER_DETECT_STOP_RATIO 0x11
+#define CARRIER_DETECT_STOP_RATIO_OLD_3090 2
+#endif // CARRIER_SENSE_NEW_ALGO //
+
+
+#define CARRIER_DETECT_STOP_RECHECK_TIME 4
+#define CARRIER_DETECT_CRITIRIA_A 230
+#define CARRIER_DETECT_DELTA 7
+#define CARRIER_DETECT_DIV_FLAG 0
+#ifdef RT3090
+#define CARRIER_DETECT_THRESHOLD_3090A 0x1fffffff
+#endif // RT3090 //
+#ifdef RT3390
+#define CARRIER_DETECT_THRESHOLD 0x0fffffff
+#endif // RT3390 //
+#ifndef RT3390
+#define CARRIER_DETECT_THRESHOLD 0x0fffffff
+#endif // RT3390 //
+#endif // TONE_RADAR_DETECT_SUPPORT //
+
+typedef struct CARRIER_DETECTION_s
+{
+ BOOLEAN Enable;
+ UINT8 CDSessionTime;
+ UINT8 CDPeriod;
+ CD_STATE CD_State;
+#ifdef TONE_RADAR_DETECT_SUPPORT
+ UINT8 delta;
+ UINT8 div_flag;
+ UINT32 threshold;
+ UINT8 recheck;
+ UINT8 recheck1;
+ UINT8 recheck2;
+ UINT32 TimeStamp;
+ UINT32 criteria;
+ UINT32 CarrierDebug;
+ ULONG idle_time;
+ ULONG busy_time;
+ ULONG Debug;
+#endif // TONE_RADAR_DETECT_SUPPORT //
+}CARRIER_DETECTION_STRUCT, *PCARRIER_DETECTION_STRUCT;
+#endif // CARRIER_DETECTION_SUPPORT //
+
+
+#ifdef NEW_DFS
+typedef struct _NewDFSDebug
+{
+ UCHAR channel;
+ ULONG wait_time;
+ UCHAR delta_delay_range;
+ UCHAR delta_delay_step;
+ UCHAR EL_range;
+ UCHAR EL_step;
+ UCHAR EH_range;
+ UCHAR EH_step;
+ UCHAR WL_range;
+ UCHAR WL_step;
+ UCHAR WH_range;
+ UCHAR WH_step;
+ ULONG T_expected;
+ ULONG T_margin;
+ UCHAR start;
+ ULONG count;
+ ULONG idx;
+
+}NewDFSDebug, *pNewDFSDebug;
+
+#define NEW_DFS_FCC_5_ENT_NUM 5
+#define NEW_DFS_DBG_PORT_ENT_NUM_POWER 8
+#define NEW_DFS_DBG_PORT_ENT_NUM (1 << NEW_DFS_DBG_PORT_ENT_NUM_POWER) // CE Debug Port entry number, 256
+#define NEW_DFS_DBG_PORT_MASK 0xff
+
+// Matched Period definition
+#define NEW_DFS_MPERIOD_ENT_NUM_POWER 8
+#define NEW_DFS_MPERIOD_ENT_NUM (1 << NEW_DFS_MPERIOD_ENT_NUM_POWER) // CE Period Table entry number, 512
+#define NEW_DFS_MAX_CHANNEL 4
+
+typedef struct _NewDFSDebugPort{
+ ULONG counter;
+ ULONG timestamp;
+ USHORT width;
+ USHORT start_idx; // start index to period table
+ USHORT end_idx; // end index to period table
+}NewDFSDebugPort, *pNewDFSDebugPort;
+
+// Matched Period Table
+typedef struct _NewDFSMPeriod{
+ USHORT idx;
+ USHORT width;
+ USHORT idx2;
+ USHORT width2;
+ ULONG period;
+}NewDFSMPeriod, *pNewDFSMPeriod;
+
+#endif // NEW_DFS //
+
+
+typedef enum _ABGBAND_STATE_ {
+ UNKNOWN_BAND,
+ BG_BAND,
+ A_BAND,
+} ABGBAND_STATE;
+
+#ifdef RTMP_MAC_PCI
+#ifdef CONFIG_STA_SUPPORT
+// Power save method control
+typedef union _PS_CONTROL {
+ struct {
+ ULONG EnablePSinIdle:1; // Enable radio off when not connect to AP. radio on only when sitesurvey,
+ ULONG EnableNewPS:1; // Enable new Chip power save fucntion . New method can only be applied in chip version after 2872. and PCIe.
+ ULONG rt30xxPowerMode:2; // Power Level Mode for rt30xx chip
+ ULONG rt30xxFollowHostASPM:1; // Card Follows Host's setting for rt30xx chip.
+ ULONG rt30xxForceASPMTest:1; // Force enable L1 for rt30xx chip. This has higher priority than rt30xxFollowHostASPM Mode.
+ ULONG rsv:26; // Radio Measurement Enable
+ } field;
+ ULONG word;
+} PS_CONTROL, *PPS_CONTROL;
+#endif // CONFIG_STA_SUPPORT //
+#endif // RTMP_MAC_PCI //
+/***************************************************************************
+ * structure for MLME state machine
+ **************************************************************************/
+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_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];
+#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 //
+
+
+ // common WPA state machine
+ STATE_MACHINE WpaMachine;
+ STATE_MACHINE_FUNC WpaFunc[WPA_FUNC_SIZE];
+
+
+
+ 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;
+#ifdef RTMP_MAC_PCI
+ UCHAR bPsPollTimerRunning;
+ RALINK_TIMER_STRUCT PsPollTimer;
+ RALINK_TIMER_STRUCT RadioOnOffTimer;
+#endif // RTMP_MAC_PCI //
+ 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;
+
+
+#ifdef DOT11_N_SUPPORT
+/***************************************************************************
+ * 802.11 N related data structures
+ **************************************************************************/
+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;
+};
+
+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;
+
+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[]
+ ULONG numDoneOriginator; // count Done Originator sessions
+ 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;
+
+
+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;
+
+
+#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 //
+
+#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 //
+
+
+//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;
+
+
+
+
+/***************************************************************************
+ * Multiple SSID related data structures
+ **************************************************************************/
+#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]; }
+
+
+// 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
+ UCHAR DesiredPhyMode; // PHY_11A, PHY_11B, PHY_11BG_MIXED, PHY_ABG_MIXED
+ USHORT Dsifs; // in units of usec
+ ULONG PacketFilter; // Packet filter for receiving
+ UINT8 RegulatoryClass[MAX_NUM_OF_REGULATORY_CLASS];
+
+ 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;
+
+ /* because TSPEC can modify the APSD flag, we need to keep the APSD flag
+ requested in association stage from the station;
+ we need to recover the APSD flag after the TSPEC is deleted. */
+ BOOLEAN bACMAPSDBackup[4]; /* for delivery-enabled & trigger-enabled both */
+ BOOLEAN bACMAPSDTr[4]; /* no use */
+
+ 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
+ UINT8 PwrConstraint;
+
+#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 (when BA is established or AP is not a legacy WMM AP), 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.
+#ifdef ANT_DIVERSITY_SUPPORT
+ UCHAR bRxAntDiversity; // 0:disable, 1:enable Software Rx Antenna Diversity.
+#endif // ANT_DIVERSITY_SUPPORT //
+
+ // IEEE802.11H--DFS.
+ RADAR_DETECT_STRUCT RadarDetect;
+
+#ifdef CARRIER_DETECTION_SUPPORT
+ CARRIER_DETECTION_STRUCT 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;
+//2008/11/05: KH add to support Antenna power-saving of AP<--
+ BOOLEAN bGreenAPEnable;
+ BOOLEAN bBlockAntDivforGreenAP;
+//2008/11/05: KH add to support Antenna power-saving of AP-->
+ 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
+
+
+
+ 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 //
+
+
+ BOOLEAN PSPXlink; // 0: Disable. 1: Enable
+
+
+#if defined(RT305x)||defined(RT30xx)
+ // request by Gary, for High Power issue
+ UCHAR HighPowerPatchDisabled;
+#endif
+
+ BOOLEAN HT_DisallowTKIP; /* Restrict the encryption type in 11n HT mode */
+} 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 WpaPassPhrase[64]; // WPA PSK pass phrase
+ UINT WpaPassPhraseLen; // the length of WPA PSK pass phrase
+ 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.
+
+ ULONG CLBusyBytes; // Save the total bytes received durning channel load scan time
+ USHORT RPIDensity[8]; // Array for RPI density collection
+
+ 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
+ // Hack for channel load and noise histogram parameters
+ UCHAR NHFactor; // Parameter for Noise histogram
+ UCHAR CLFactor; // Parameter for channel load
+
+ 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 bAutoRoaming; // 0:disable auto roaming by RSSI, 1:enable auto roaming by RSSI
+ 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;
+ BOOLEAN bRSN_IE_FromWpaSupplicant;
+#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 RTMP_MAC_PCI
+ UCHAR BBPR3;
+ // PS Control has 2 meanings for advanced power save function.
+ // 1. EnablePSinIdle : When no connection, always radio off except need to do site survey.
+ // 2. EnableNewPS : will save more current in sleep or radio off mode.
+ PS_CONTROL PSControl;
+#endif // RTMP_MAC_PCI //
+
+#ifdef EXT_BUILD_CHANNEL_LIST
+ UCHAR IEEE80211dClientMode;
+ UCHAR StaOriCountryCode[3];
+ UCHAR StaOriGeography;
+#endif // EXT_BUILD_CHANNEL_LIST //
+
+
+
+ BOOLEAN bAutoConnectByBssid;
+ ULONG BeaconLostTime; // seconds
+ BOOLEAN bForceTxBurst; // 1: force enble TX PACKET BURST, 0: disable
+} 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 //
+
+
+
+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 SNonce[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;
+ NDIS_802_11_WEP_STATUS GroupKeyWepStatus;
+ 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
+// 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 WDS_SUPPORT
+ BOOLEAN LockEntryTx; // TRUE = block to WDS Entry traffic, FALSE = not.
+ UINT32 TimeStamp_toTxRing;
+#endif // WDS_SUPPORT //
+
+//====================================================
+
+
+
+#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;
+
+ 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 //
+
+
+
+ ULONG AssocDeadLine;
+
+
+
+ ULONG ChannelQuality; // 0..100, Channel Quality Indication for Roaming
+
+} 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
+//2008/10/28: KH add to support Antenna power-saving of AP<--
+//2008/10/28: KH add to support Antenna power-saving of AP-->
+#endif // DOT11_N_SUPPORT //
+} MAC_TABLE, *PMAC_TABLE;
+
+
+
+
+#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 _RTMP_DEV_INFO_
+{
+ UCHAR chipName[16];
+ RTMP_INF_TYPE infType;
+}RTMP_DEV_INFO;
+
+
+#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 //
+
+
+struct _RTMP_CHIP_OP_
+{
+ /* Calibration access related callback functions */
+ int (*eeinit)(RTMP_ADAPTER *pAd); /* int (*eeinit)(RTMP_ADAPTER *pAd); */
+ int (*eeread)(RTMP_ADAPTER *pAd, USHORT offset, PUSHORT pValue); /* int (*eeread)(RTMP_ADAPTER *pAd, int offset, PUSHORT pValue); */
+ int (*eewrite)(RTMP_ADAPTER *pAd, USHORT offset, USHORT value);; /* int (*eewrite)(RTMP_ADAPTER *pAd, int offset, USHORT value); */
+
+ /* MCU related callback functions */
+ int (*loadFirmware)(RTMP_ADAPTER *pAd); /* int (*loadFirmware)(RTMP_ADAPTER *pAd); */
+ int (*eraseFirmware)(RTMP_ADAPTER *pAd); /* int (*eraseFirmware)(RTMP_ADAPTER *pAd); */
+ int (*sendCommandToMcu)(RTMP_ADAPTER *pAd, UCHAR cmd, UCHAR token, UCHAR arg0, UCHAR arg1);; /* int (*sendCommandToMcu)(RTMP_ADAPTER *pAd, UCHAR cmd, UCHAR token, UCHAR arg0, UCHAR arg1); */
+
+ /* RF access related callback functions */
+ REG_PAIR *pRFRegTable;
+ void (*AsicRfInit)(RTMP_ADAPTER *pAd);
+ void (*AsicRfTurnOn)(RTMP_ADAPTER *pAd);
+ void (*AsicRfTurnOff)(RTMP_ADAPTER *pAd);
+ void (*AsicReverseRfFromSleepMode)(RTMP_ADAPTER *pAd);
+ void (*AsicHaltAction)(RTMP_ADAPTER *pAd);
+};
+
+
+//
+// The miniport adapter structure
+//
+struct _RTMP_ADAPTER
+{
+ PVOID OS_Cookie; // save specific structure relative to OS
+ PNET_DEV net_dev;
+ ULONG VirtualIfCnt;
+
+ RTMP_CHIP_OP chipOps;
+ USHORT ThisTbttNumToNextWakeUp;
+
+#ifdef INF_AMAZON_PPA
+ UINT32 g_if_id;
+ BOOLEAN PPAEnable;
+ PPA_DIRECTPATH_CB *pDirectpathCb;
+#endif // INF_AMAZON_PPA //
+
+#ifdef RTMP_MAC_PCI
+/*****************************************************************************************/
+/* PCI related parameters */
+/*****************************************************************************************/
+ PUCHAR CSRBaseAddress; // PCI MMIO Base Address, all access will use
+ unsigned int irq_num;
+
+ USHORT LnkCtrlBitMask;
+ USHORT RLnkCtrlConfiguration;
+ USHORT RLnkCtrlOffset;
+ USHORT HostLnkCtrlConfiguration;
+ USHORT HostLnkCtrlOffset;
+ USHORT PCIePowerSaveLevel;
+ ULONG Rt3xxHostLinkCtrl; // USed for 3090F chip
+ ULONG Rt3xxRalinkLinkCtrl; // USed for 3090F chip
+ USHORT DeviceID; // Read from PCI config
+ ULONG AccessBBPFailCount;
+ BOOLEAN bPCIclkOff; // flag that indicate if the PICE power status in Configuration SPace..
+ BOOLEAN bPCIclkOffDisableTx; //
+
+ BOOLEAN brt30xxBanMcuCmd; //when = 0xff means all commands are ok to set .
+ BOOLEAN b3090ESpecialChip; //3090E special chip that write EEPROM 0x24=0x9280.
+ ULONG CheckDmaBusyCount; // Check Interrupt Status Register Count.
+
+ UINT int_enable_reg;
+ UINT int_disable_mask;
+ UINT int_pending;
+
+
+ RTMP_DMABUF TxBufSpace[NUM_OF_TX_RING]; // Shared memory of all 1st pre-allocated TxBuf associated with each TXD
+ 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 // RTMP_MAC_PCI //
+
+
+ NDIS_SPIN_LOCK irq_lock;
+ UCHAR irq_disabled;
+
+
+/*****************************************************************************************/
+/* RBUS related parameters */
+/*****************************************************************************************/
+
+
+/*****************************************************************************************/
+/* Both PCI/USB related parameters */
+/*****************************************************************************************/
+ //RTMP_DEV_INFO chipInfo;
+ RTMP_INF_TYPE infType;
+
+/*****************************************************************************************/
+/* Driver Mgmt related parameters */
+/*****************************************************************************************/
+ RTMP_OS_TASK mlmeTask;
+#ifdef RTMP_TIMER_TASK_SUPPORT
+ // If you want use timer task to handle the timer related jobs, enable this.
+ RTMP_TIMER_TASK_QUEUE TimerQ;
+ NDIS_SPIN_LOCK TimerQLock;
+ RTMP_OS_TASK timerTask;
+#endif // RTMP_TIMER_TASK_SUPPORT //
+
+
+/*****************************************************************************************/
+/* Tx related parameters */
+/*****************************************************************************************/
+ BOOLEAN DeQueueRunning[NUM_OF_TX_RING]; // for ensuring RTUSBDeQueuePacket get call once
+ NDIS_SPIN_LOCK DeQueueLock[NUM_OF_TX_RING];
+
+
+ // 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 RTMP_MAC_PCI
+ RTMP_RX_RING RxRing;
+ NDIS_SPIN_LOCK RxRingLock; // Rx Ring spinlock
+#ifdef RT3090
+ NDIS_SPIN_LOCK McuCmdLock; //MCU Command Queue spinlock
+#endif // RT3090 //
+#endif // RTMP_MAC_PCI //
+
+
+
+/*****************************************************************************************/
+/* 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
+ ULONG FirmwareVersion; // byte 0: Minor version, byte 1: Major version, otherwise unused.
+ USHORT EEPROMDefaultValue[NUM_EEPROM_BBP_PARMS];
+ UCHAR EEPROMAddressNum; // 93c46=6 93c66=8
+ BOOLEAN EepromAccess;
+ UCHAR EFuseTag;
+
+
+ // ---------------------------
+ // BBP Control
+ // ---------------------------
+#ifdef MERGE_ARCH_TEAM
+ UCHAR BbpWriteLatch[256]; // record last BBP register value written via BBP_IO_WRITE/BBP_IO_WRITE_VY_REG_ID
+#else
+ UCHAR BbpWriteLatch[140]; // record last BBP register value written via BBP_IO_WRITE/BBP_IO_WRITE_VY_REG_ID
+#endif // MERGE_ARCH_TEAM //
+ CHAR BbpRssiToDbmDelta; // change from UCHAR to CHAR for high power
+ 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))
+
+ 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
+
+ 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
+#ifdef RT30xx
+ // for 3572
+ UCHAR Bbp25;
+ UCHAR Bbp26;
+
+ UCHAR TxMixerGain24G; // Tx mixer gain value from EEPROM to improve Tx EVM / Tx DAC, 2.4G
+ UCHAR TxMixerGain5G;
+#endif // RT30xx //
+ // ----------------------------
+ // LED control
+ // ----------------------------
+ MCU_LEDCS_STRUC LedCntl;
+ USHORT Led1; // read from EEPROM 0x3c
+ USHORT Led2; // EEPROM 0x3e
+ USHORT Led3; // EEPROM 0x40
+ UCHAR LedIndicatorStrength;
+ 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;
+
+
+
+
+//=========AP===========
+
+
+//=======STA===========
+#ifdef CONFIG_STA_SUPPORT
+ // -----------------------------------------------
+ // 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;
+ NDIS_SPIN_LOCK BATabLock;
+ RALINK_TIMER_STRUCT RECBATimer;
+#endif // DOT11_N_SUPPORT //
+
+ // 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
+ ULONG PSFlags; // Power Save operation flag.
+
+ // 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 */
+ /*****************************************************************************************/
+
+ 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;
+#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
+
+#ifdef LINUX
+#if WIRELESS_EXT >= 12
+ struct iw_statistics iw_stats;
+#endif
+
+ struct net_device_stats stats;
+#endif // LINUX //
+
+#ifdef BLOCK_NET_IF
+ BLOCK_QUEUE_ENTRY blockQueueTab[NUM_OF_TX_RING];
+#endif // BLOCK_NET_IF //
+
+
+
+#ifdef MULTIPLE_CARD_SUPPORT
+ INT32 MC_RowID;
+ STRING 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 FlgCtsEnabled;
+ UINT8 PM_FlgSuspend;
+
+#ifdef RT30xx
+#ifdef RTMP_EFUSE_SUPPORT
+ BOOLEAN bUseEfuse;
+ BOOLEAN bEEPROMFile;
+ BOOLEAN bFroceEEPROMBuffer;
+ UCHAR EEPROMImage[1024];
+#endif // RTMP_EFUSE_SUPPORT //
+#endif // RT30xx //
+
+#ifdef CONFIG_STA_SUPPORT
+#endif // CONFIG_STA_SUPPORT //
+
+};
+
+
+
+#ifdef TONE_RADAR_DETECT_SUPPORT
+#define DELAYINTMASK 0x0013fffb
+#define INTMASK 0x0013fffb
+#define IndMask 0x0013fffc
+#define RadarInt 0x00100000
+#else
+#define DELAYINTMASK 0x0003fffb
+#define INTMASK 0x0003fffb
+#define IndMask 0x0003fffc
+#endif // TONE_RADAR_DETECT_SUPPORT //
+
+#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
+
+
+/***************************************************************************
+ * Rx Path software control block related data structures
+ **************************************************************************/
+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
+
+
+/***************************************************************************
+ * Tx Path software control block related data structures
+ **************************************************************************/
+#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[96]; // 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_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_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
+/***************************************************************************
+ * Endian conversion related functions
+ **************************************************************************/
+/*
+ ========================================================================
+
+ 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));
+ }
+}
+
+
+#ifdef RTMP_MAC_PCI
+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
+}
+#endif // RTMP_MAC_PCI //
+
+
+/*
+ ========================================================================
+
+ 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 RTMP_MAC_PCI
+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
+}
+#endif // RTMP_MAC_PCI //
+
+/*
+ ========================================================================
+
+ 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 //
+
+
+/***************************************************************************
+ * Other static inline function definitions
+ **************************************************************************/
+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;
+}
+
+
+char *GetPhyMode(int Mode);
+char* GetBW(int BW);
+
+
+
+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);
+
+NDIS_STATUS RTMPSetProfileParameters(
+ IN RTMP_ADAPTER *pAd,
+ IN PSTRING pBuffer);
+
+INT RTMPGetKeyParameter(
+ IN PSTRING key,
+ OUT PSTRING dest,
+ IN INT destsize,
+ IN PSTRING buffer,
+ IN BOOLEAN bTrimSpace);
+
+VOID RTMPFreeAdapter(
+ IN PRTMP_ADAPTER pAd);
+
+NDIS_STATUS NICReadRegParameters(
+ IN PRTMP_ADAPTER pAd,
+ IN NDIS_HANDLE WrapperConfigurationContext);
+
+#ifdef RTMP_RF_RW_SUPPORT
+VOID NICInitRFRegisters(
+ IN PRTMP_ADAPTER pAd);
+
+VOID RtmpChipOpsRFHook(
+ IN RTMP_ADAPTER *pAd);
+
+NDIS_STATUS RT30xxWriteRFRegister(
+ IN PRTMP_ADAPTER pAd,
+ IN UCHAR regID,
+ IN UCHAR value);
+
+NDIS_STATUS RT30xxReadRFRegister(
+ IN PRTMP_ADAPTER pAd,
+ IN UCHAR regID,
+ IN PUCHAR pValue);
+#endif // RTMP_RF_RW_SUPPORT //
+
+VOID NICReadEEPROMParameters(
+ IN PRTMP_ADAPTER pAd,
+ IN PUCHAR mac_addr);
+
+VOID NICInitAsicFromEEPROM(
+ 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);
+
+NDIS_STATUS NICLoadFirmware(
+ IN PRTMP_ADAPTER pAd);
+
+VOID NICEraseFirmware(
+ 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);
+
+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(
+ PSTRING src,
+ PUCHAR 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);
+
+
+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);
+
+#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 //
+#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);
+
+#ifdef RTMP_MAC_PCI
+NDIS_STATUS MlmeHardTransmitTxRing(
+ IN PRTMP_ADAPTER pAd,
+ IN UCHAR QueIdx,
+ IN PNDIS_PACKET pPacket);
+
+NDIS_STATUS MlmeDataHardTransmit(
+ IN PRTMP_ADAPTER pAd,
+ IN UCHAR QueIdx,
+ IN PNDIS_PACKET pPacket);
+
+VOID RTMPWriteTxDescriptor(
+ IN PRTMP_ADAPTER pAd,
+ IN PTXD_STRUC pTxD,
+ IN BOOLEAN bWIV,
+ IN UCHAR QSEL);
+#endif // RTMP_MAC_PCI //
+
+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 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);
+
+//+++mark by shiang, now this function merge to MiniportMMRequest()
+//---mark by shiang, now this function merge to MiniportMMRequest()
+
+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);
+
+VOID WpaStaPairwiseKeySetting(
+ IN PRTMP_ADAPTER pAd);
+
+VOID WpaStaGroupKeySetting(
+ IN PRTMP_ADAPTER pAd);
+
+#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 AsicResetBBPAgent(
+ IN PRTMP_ADAPTER pAd);
+
+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);
+
+
+#ifdef RTMP_MAC_PCI
+BOOLEAN AsicCheckCommanOk(
+ IN PRTMP_ADAPTER pAd,
+ IN UCHAR Command);
+#endif // RTMP_MAC_PCI //
+
+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);
+
+ULONG BssSsidTableSearchBySSID(
+ IN BSS_TABLE *Tab,
+ IN PUCHAR pSsid,
+ IN UCHAR SsidLen);
+
+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 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);
+
+
+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 PSTRING arg);
+
+INT Set_DlsTearDownEntry_Proc(
+ IN PRTMP_ADAPTER pAd,
+ IN PSTRING 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 STRING 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 UCHAR *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);
+
+BOOLEAN MlmeCheckForFastRoaming(
+ IN PRTMP_ADAPTER pAd);
+
+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 PMAC_TABLE_ENTRY pMacEntry,
+ 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);
+
+#ifdef RT30xx
+VOID AsicSetRxAnt(
+ IN PRTMP_ADAPTER pAd,
+ IN UCHAR Ant);
+
+VOID RTMPFilterCalibration(
+ IN PRTMP_ADAPTER pAd);
+
+#ifdef RTMP_EFUSE_SUPPORT
+//2008/09/11:KH add to support efuse<--
+INT set_eFuseGetFreeBlockCount_Proc(
+ IN PRTMP_ADAPTER pAd,
+ IN PSTRING arg);
+
+INT set_eFusedump_Proc(
+ IN PRTMP_ADAPTER pAd,
+ IN PSTRING arg);
+
+INT set_eFuseLoadFromBin_Proc(
+ IN PRTMP_ADAPTER pAd,
+ IN PSTRING arg);
+
+VOID eFusePhysicalReadRegisters(
+ IN PRTMP_ADAPTER pAd,
+ IN USHORT Offset,
+ IN USHORT Length,
+ OUT USHORT* pData);
+
+int RtmpEfuseSupportCheck(
+ IN RTMP_ADAPTER *pAd);
+
+INT set_eFuseBufferModeWriteBack_Proc(
+ IN PRTMP_ADAPTER pAd,
+ IN PSTRING arg);
+
+INT eFuseLoadEEPROM(
+ IN PRTMP_ADAPTER pAd);
+
+INT eFuseWriteEeeppromBuf(
+ IN PRTMP_ADAPTER pAd);
+
+VOID eFuseGetFreeBlockCount(IN PRTMP_ADAPTER pAd,
+ PUINT EfuseFreeBlock);
+
+INT eFuse_init(
+ IN PRTMP_ADAPTER pAd);
+
+NTSTATUS eFuseRead(
+ IN PRTMP_ADAPTER pAd,
+ IN USHORT Offset,
+ OUT PUCHAR pData,
+ IN USHORT Length);
+
+NTSTATUS eFuseWrite(
+ IN PRTMP_ADAPTER pAd,
+ IN USHORT Offset,
+ IN PUCHAR pData,
+ IN USHORT length);
+//2008/09/11:KH add to support efuse-->
+#endif // RTMP_EFUSE_SUPPORT //
+
+// 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
+
+
+#ifdef RT3090
+VOID NICInitRT3090RFRegisters(
+ IN RTMP_ADAPTER *pAd);
+#endif // RT3090 //
+
+VOID RT30xxHaltAction(
+ IN PRTMP_ADAPTER pAd);
+
+VOID RT30xxSetRxAnt(
+ IN PRTMP_ADAPTER pAd,
+ IN UCHAR Ant);
+#endif // RT30xx //
+#ifdef RT33xx
+VOID RT33xxLoadRFNormalModeSetup(
+ IN PRTMP_ADAPTER pAd);
+
+VOID RT33xxLoadRFSleepModeSetup(
+ IN PRTMP_ADAPTER pAd);
+
+VOID RT33xxReverseRFSleepModeSetup(
+ IN PRTMP_ADAPTER pAd);
+
+#ifdef RT3370
+VOID NICInitRT3370RFRegisters(
+ IN RTMP_ADAPTER *pAd);
+#endif // RT3070 //
+
+#ifdef RT3390
+VOID NICInitRT3390RFRegisters(
+ IN RTMP_ADAPTER *pAd);
+#endif // RT3090 //
+
+VOID RT33xxHaltAction(
+ IN PRTMP_ADAPTER pAd);
+
+VOID RT33xxSetRxAnt(
+ IN PRTMP_ADAPTER pAd,
+ IN UCHAR Ant);
+
+#endif // RT33xx //
+
+
+
+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);
+
+//
+// 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
+//
+INT RT_CfgSetCountryRegion(
+ IN PRTMP_ADAPTER pAd,
+ IN PSTRING arg,
+ IN INT band);
+
+INT RT_CfgSetWirelessMode(
+ IN PRTMP_ADAPTER pAd,
+ IN PSTRING arg);
+
+INT RT_CfgSetShortSlot(
+ IN PRTMP_ADAPTER pAd,
+ IN PSTRING arg);
+
+INT RT_CfgSetWepKey(
+ IN PRTMP_ADAPTER pAd,
+ IN PSTRING keyString,
+ IN CIPHER_KEY *pSharedKey,
+ IN INT keyIdx);
+
+INT RT_CfgSetWPAPSKKey(
+ IN RTMP_ADAPTER *pAd,
+ IN PSTRING keyString,
+ IN UCHAR *pHashStr,
+ IN INT hashStrLen,
+ OUT PUCHAR pPMKBuf);
+
+
+
+//
+// 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);
+
+PSTRING GetEncryptType(
+ CHAR enc);
+
+PSTRING GetAuthMode(
+ CHAR auth);
+
+
+VOID RTMPIndicateWPA2Status(
+ IN PRTMP_ADAPTER pAdapter);
+
+VOID RTMPOPModeSwitching(
+ IN PRTMP_ADAPTER pAd);
+
+
+#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);
+
+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);
+
+#ifdef ANT_DIVERSITY_SUPPORT
+VOID APAsicAntennaAvg(
+ IN PRTMP_ADAPTER pAd,
+ IN UCHAR AntSelect,
+ IN SHORT *RssiAvg);
+#endif // ANT_DIVERSITY_SUPPORT //
+
+VOID APAsicRxAntEvalTimeout(
+ IN PRTMP_ADAPTER pAd);
+
+/*===================================
+ Function prototype in cmm_wpa.c
+ =================================== */
+VOID RTMPToWirelessSta(
+ IN PRTMP_ADAPTER pAd,
+ IN PMAC_TABLE_ENTRY pEntry,
+ IN PUCHAR pHeader802_3,
+ IN UINT HdrLen,
+ IN PUCHAR pData,
+ IN UINT DataLen,
+ IN BOOLEAN bClearFrame);
+
+VOID WpaDerivePTK(
+ 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);
+
+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 UINT32 c_len,
+ IN UCHAR *ciphertext);
+
+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 PMAC_TABLE_ENTRY pEntry,
+ IN UCHAR GroupKeyWepStatus,
+ IN UCHAR MsgType,
+ IN UCHAR DefaultKeyIdx,
+ IN UCHAR *KeyNonce,
+ IN UCHAR *TxRSC,
+ IN UCHAR *GTK,
+ IN UCHAR *RSNIE,
+ IN UCHAR RSNIE_Len,
+ 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 RTMPMakeRSNIE(
+ IN PRTMP_ADAPTER pAd,
+ IN UINT AuthMode,
+ IN UINT WepStatus,
+ IN UCHAR apidx);
+
+//
+// function prototype in ap_wpa.c
+//
+VOID RTMPGetTxTscFromAsic(
+ IN PRTMP_ADAPTER pAd,
+ IN UCHAR apidx,
+ OUT PUCHAR pTxTsc);
+
+VOID APInstallPairwiseKey(
+ PRTMP_ADAPTER pAd,
+ PMAC_TABLE_ENTRY pEntry);
+
+MAC_TABLE_ENTRY *PACInquiry(
+ IN PRTMP_ADAPTER pAd,
+ IN ULONG Wcid);
+
+UINT APValidateRSNIE(
+ IN PRTMP_ADAPTER pAd,
+ IN PMAC_TABLE_ENTRY pEntry,
+ IN PUCHAR pRsnIe,
+ IN UCHAR rsnie_len);
+
+VOID HandleCounterMeasure(
+ IN PRTMP_ADAPTER pAd,
+ 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 PeerPairMsg1Action(
+ IN PRTMP_ADAPTER pAd,
+ IN MAC_TABLE_ENTRY *pEntry,
+ IN MLME_QUEUE_ELEM *Elem);
+
+VOID PeerPairMsg2Action(
+ IN PRTMP_ADAPTER pAd,
+ IN MAC_TABLE_ENTRY *pEntry,
+ IN MLME_QUEUE_ELEM *Elem);
+
+VOID PeerPairMsg3Action(
+ 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 PeerGroupMsg1Action(
+ IN PRTMP_ADAPTER pAd,
+ IN PMAC_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 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 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 WpaDeriveGTK(
+ IN UCHAR *PMK,
+ IN UCHAR *GNonce,
+ IN UCHAR *AA,
+ OUT UCHAR *output,
+ IN UINT len);
+
+VOID AES_GTK_KEY_WRAP(
+ IN UCHAR *key,
+ IN UCHAR *plaintext,
+ IN UINT32 p_len,
+ OUT UCHAR *ciphertext);
+
+VOID AES_128_CMAC(
+ IN PUCHAR key,
+ IN PUCHAR input,
+ IN INT len,
+ OUT PUCHAR mac);
+
+VOID WpaSend(
+ IN PRTMP_ADAPTER pAdapter,
+ IN PUCHAR pPacket,
+ IN ULONG Len);
+
+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 RTMP_ADAPTER *pAd,
+ OUT UCHAR **mem,
+ IN ULONG size);
+
+NDIS_STATUS os_free_mem(
+ IN PRTMP_ADAPTER pAd,
+ IN PVOID 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_FreeFirstTxBuffer(
+ IN PRTMP_ADAPTER pAd,
+ IN ULONG Length,
+ IN BOOLEAN Cached,
+ IN PVOID VirtualAddress,
+ IN NDIS_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);
+
+void RTMP_FreeDescMemory(
+ IN PRTMP_ADAPTER pAd,
+ IN ULONG Length,
+ IN PVOID VirtualAddress,
+ IN NDIS_PHYSICAL_ADDRESS PhysicalAddress);
+
+PNDIS_PACKET RtmpOSNetPktAlloc(
+ IN RTMP_ADAPTER *pAd,
+ IN int size);
+
+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);
+
+
+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);
+
+
+
+#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 PSTRING s1,
+ IN PSTRING s2);
+
+BOOLEAN rtstrcasecmp(
+ IN PSTRING s1,
+ IN PSTRING s2);
+
+PSTRING rtstrstruncasecmp(
+ IN PSTRING s1,
+ IN PSTRING s2);
+
+PSTRING rtstrstr(
+ IN const PSTRING s1,
+ IN const PSTRING s2);
+
+PSTRING rstrtok(
+ IN PSTRING s,
+ IN const PSTRING ct);
+
+int rtinet_aton(
+ const PSTRING cp,
+ unsigned int *addr);
+
+////////// common ioctl functions //////////
+INT Set_DriverVersion_Proc(
+ IN PRTMP_ADAPTER pAd,
+ IN PSTRING arg);
+
+INT Set_CountryRegion_Proc(
+ IN PRTMP_ADAPTER pAd,
+ IN PSTRING arg);
+
+INT Set_CountryRegionABand_Proc(
+ IN PRTMP_ADAPTER pAd,
+ IN PSTRING arg);
+
+INT Set_WirelessMode_Proc(
+ IN PRTMP_ADAPTER pAd,
+ IN PSTRING arg);
+
+INT Set_Channel_Proc(
+ IN PRTMP_ADAPTER pAd,
+ IN PSTRING arg);
+
+INT Set_ShortSlot_Proc(
+ IN PRTMP_ADAPTER pAd,
+ IN PSTRING arg);
+
+INT Set_TxPower_Proc(
+ IN PRTMP_ADAPTER pAd,
+ IN PSTRING arg);
+
+INT Set_BGProtection_Proc(
+ IN PRTMP_ADAPTER pAd,
+ IN PSTRING arg);
+
+INT Set_TxPreamble_Proc(
+ IN PRTMP_ADAPTER pAd,
+ IN PSTRING arg);
+
+INT Set_RTSThreshold_Proc(
+ IN PRTMP_ADAPTER pAd,
+ IN PSTRING arg);
+
+INT Set_FragThreshold_Proc(
+ IN PRTMP_ADAPTER pAd,
+ IN PSTRING arg);
+
+INT Set_TxBurst_Proc(
+ IN PRTMP_ADAPTER pAd,
+ IN PSTRING arg);
+
+#ifdef AGGREGATION_SUPPORT
+INT Set_PktAggregate_Proc(
+ IN PRTMP_ADAPTER pAd,
+ IN PSTRING arg);
+#endif // AGGREGATION_SUPPORT //
+
+#ifdef INF_AMAZON_PPA
+INT Set_INF_AMAZON_SE_PPA_Proc(
+ IN PRTMP_ADAPTER pAd,
+ IN PUCHAR arg);
+
+#endif // INF_AMAZON_PPA //
+
+INT Set_IEEE80211H_Proc(
+ IN PRTMP_ADAPTER pAd,
+ IN PSTRING arg);
+
+#ifdef DBG
+INT Set_Debug_Proc(
+ IN PRTMP_ADAPTER pAd,
+ IN PSTRING arg);
+#endif
+
+INT Show_DescInfo_Proc(
+ IN PRTMP_ADAPTER pAd,
+ IN PSTRING arg);
+
+INT Set_ResetStatCounter_Proc(
+ IN PRTMP_ADAPTER pAd,
+ IN PSTRING arg);
+
+#ifdef DOT11_N_SUPPORT
+INT Set_BASetup_Proc(
+ IN PRTMP_ADAPTER pAd,
+ IN PSTRING arg);
+
+INT Set_BADecline_Proc(
+ IN PRTMP_ADAPTER pAd,
+ IN PSTRING arg);
+
+INT Set_BAOriTearDown_Proc(
+ IN PRTMP_ADAPTER pAd,
+ IN PSTRING arg);
+
+INT Set_BARecTearDown_Proc(
+ IN PRTMP_ADAPTER pAd,
+ IN PSTRING arg);
+
+INT Set_HtBw_Proc(
+ IN PRTMP_ADAPTER pAd,
+ IN PSTRING arg);
+
+INT Set_HtMcs_Proc(
+ IN PRTMP_ADAPTER pAd,
+ IN PSTRING arg);
+
+INT Set_HtGi_Proc(
+ IN PRTMP_ADAPTER pAd,
+ IN PSTRING arg);
+
+INT Set_HtOpMode_Proc(
+ IN PRTMP_ADAPTER pAd,
+ IN PSTRING arg);
+
+INT Set_HtStbc_Proc(
+ IN PRTMP_ADAPTER pAd,
+ IN PSTRING arg);
+
+INT Set_HtHtc_Proc(
+ IN PRTMP_ADAPTER pAd,
+ IN PSTRING arg);
+
+INT Set_HtExtcha_Proc(
+ IN PRTMP_ADAPTER pAd,
+ IN PSTRING arg);
+
+INT Set_HtMpduDensity_Proc(
+ IN PRTMP_ADAPTER pAd,
+ IN PSTRING arg);
+
+INT Set_HtBaWinSize_Proc(
+ IN PRTMP_ADAPTER pAd,
+ IN PSTRING arg);
+
+INT Set_HtRdg_Proc(
+ IN PRTMP_ADAPTER pAd,
+ IN PSTRING arg);
+
+INT Set_HtLinkAdapt_Proc(
+ IN PRTMP_ADAPTER pAd,
+ IN PSTRING arg);
+
+INT Set_HtAmsdu_Proc(
+ IN PRTMP_ADAPTER pAd,
+ IN PSTRING arg);
+
+INT Set_HtAutoBa_Proc(
+ IN PRTMP_ADAPTER pAd,
+ IN PSTRING arg);
+
+INT Set_HtProtect_Proc(
+ IN PRTMP_ADAPTER pAd,
+ IN PSTRING arg);
+
+INT Set_HtMimoPs_Proc(
+ IN PRTMP_ADAPTER pAd,
+ IN PSTRING arg);
+
+
+INT Set_ForceShortGI_Proc(
+ IN PRTMP_ADAPTER pAd,
+ IN PSTRING arg);
+
+INT Set_ForceGF_Proc(
+ IN PRTMP_ADAPTER pAd,
+ IN PSTRING arg);
+
+INT SetCommonHT(
+ IN PRTMP_ADAPTER pAd);
+
+INT Set_SendPSMPAction_Proc(
+ IN PRTMP_ADAPTER pAd,
+ IN PSTRING arg);
+
+INT Set_HtMIMOPSmode_Proc(
+ IN PRTMP_ADAPTER pAd,
+ IN PSTRING arg);
+
+
+INT Set_HtTxBASize_Proc(
+ IN PRTMP_ADAPTER pAd,
+ IN PSTRING arg);
+
+INT Set_HtDisallowTKIP_Proc(
+ IN PRTMP_ADAPTER pAd,
+ IN PSTRING 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);
+
+////////////////////////////////////////
+
+VOID RTMPIoctlGetSiteSurvey(
+ IN PRTMP_ADAPTER pAdapter,
+ IN struct iwreq *wrq);
+
+
+
+
+
+#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);
+
+
+VOID RTMPSetDesiredRates(
+ IN PRTMP_ADAPTER pAdapter,
+ IN LONG Rates);
+#endif // CONFIG_STA_SUPPORT //
+
+INT Set_FixedTxMode_Proc(
+ IN PRTMP_ADAPTER pAd,
+ IN PSTRING arg);
+
+#ifdef CONFIG_APSTA_MIXED_SUPPORT
+INT Set_OpMode_Proc(
+ IN PRTMP_ADAPTER pAd,
+ IN PSTRING arg);
+#endif // CONFIG_APSTA_MIXED_SUPPORT //
+
+INT Set_LongRetryLimit_Proc(
+ IN PRTMP_ADAPTER pAdapter,
+ IN PSTRING arg);
+
+INT Set_ShortRetryLimit_Proc(
+ IN PRTMP_ADAPTER pAdapter,
+ IN PSTRING arg);
+
+BOOLEAN RT28XXChipsetCheck(
+ IN void *_dev_p);
+
+
+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_init(
+ IN PRTMP_ADAPTER pAd,
+ IN PSTRING pDefaultMac,
+ IN PSTRING pHostName);
+
+BOOLEAN RT28XXSecurityKeyAdd(
+ IN PRTMP_ADAPTER pAd,
+ IN ULONG apidx,
+ IN ULONG KeyIdx,
+ IN MAC_TABLE_ENTRY *pEntry);
+
+NDIS_STATUS RtmpNetTaskInit(
+ IN RTMP_ADAPTER *pAd);
+
+VOID RtmpNetTaskExit(
+ IN PRTMP_ADAPTER pAd);
+
+NDIS_STATUS RtmpMgmtTaskInit(
+ IN RTMP_ADAPTER *pAd);
+
+VOID RtmpMgmtTaskExit(
+ IN RTMP_ADAPTER *pAd);
+
+void tbtt_tasklet(unsigned long data);
+
+
+PNET_DEV RtmpPhyNetDevInit(
+ IN RTMP_ADAPTER *pAd,
+ IN RTMP_OS_NETDEV_OP_HOOK *pNetHook);
+
+BOOLEAN RtmpPhyNetDevExit(
+ IN RTMP_ADAPTER *pAd,
+ IN PNET_DEV net_dev);
+
+INT RtmpRaDevCtrlInit(
+ IN RTMP_ADAPTER *pAd,
+ IN RTMP_INF_TYPE infType);
+
+BOOLEAN RtmpRaDevCtrlExit(
+ IN RTMP_ADAPTER *pAd);
+
+
+#ifdef RTMP_MAC_PCI
+//
+// Function Prototype in cmm_data_pci.c
+//
+USHORT RtmpPCI_WriteTxResource(
+ IN PRTMP_ADAPTER pAd,
+ IN TX_BLK *pTxBlk,
+ IN BOOLEAN bIsLast,
+ OUT USHORT *FreeNumber);
+
+USHORT RtmpPCI_WriteSingleTxResource(
+ IN PRTMP_ADAPTER pAd,
+ IN TX_BLK *pTxBlk,
+ IN BOOLEAN bIsLast,
+ OUT USHORT *FreeNumber);
+
+USHORT RtmpPCI_WriteMultiTxResource(
+ IN PRTMP_ADAPTER pAd,
+ IN TX_BLK *pTxBlk,
+ IN UCHAR frameNum,
+ OUT USHORT *FreeNumber);
+
+USHORT RtmpPCI_WriteFragTxResource(
+ IN PRTMP_ADAPTER pAd,
+ IN TX_BLK *pTxBlk,
+ IN UCHAR fragNum,
+ OUT USHORT *FreeNumber);
+
+USHORT RtmpPCI_WriteSubTxResource(
+ IN PRTMP_ADAPTER pAd,
+ IN TX_BLK *pTxBlk,
+ IN BOOLEAN bIsLast,
+ OUT USHORT *FreeNumber);
+
+VOID RtmpPCI_FinalWriteTxResource(
+ IN PRTMP_ADAPTER pAd,
+ IN TX_BLK *pTxBlk,
+ IN USHORT totalMPDUSize,
+ IN USHORT FirstTxIdx);
+
+VOID RtmpPCIDataLastTxIdx(
+ IN PRTMP_ADAPTER pAd,
+ IN UCHAR QueIdx,
+ IN USHORT LastTxIdx);
+
+VOID RtmpPCIDataKickOut(
+ IN PRTMP_ADAPTER pAd,
+ IN TX_BLK *pTxBlk,
+ IN UCHAR QueIdx);
+
+
+int RtmpPCIMgmtKickOut(
+ IN RTMP_ADAPTER *pAd,
+ IN UCHAR QueIdx,
+ IN PNDIS_PACKET pPacket,
+ IN PUCHAR pSrcBufVA,
+ IN UINT SrcBufLen);
+
+
+NDIS_STATUS RTMPCheckRxError(
+ IN PRTMP_ADAPTER pAd,
+ IN PHEADER_802_11 pHeader,
+ IN PRXWI_STRUC pRxWI,
+ IN PRT28XX_RXD_STRUC pRxD);
+
+BOOLEAN RT28xxPciAsicRadioOff(
+ IN PRTMP_ADAPTER pAd,
+ IN UCHAR Level,
+ IN USHORT TbttNumToNextWakeUp);
+
+BOOLEAN RT28xxPciAsicRadioOn(
+ IN PRTMP_ADAPTER pAd,
+ IN UCHAR Level);
+
+#ifdef CONFIG_STA_SUPPORT
+VOID RTMPInitPCIeLinkCtrlValue(
+ IN PRTMP_ADAPTER pAd);
+
+VOID RTMPFindHostPCIDev(
+ IN PRTMP_ADAPTER pAd);
+
+VOID RTMPPCIeLinkCtrlValueRestore(
+ IN PRTMP_ADAPTER pAd,
+ IN UCHAR Level);
+
+VOID RTMPPCIeLinkCtrlSetting(
+ IN PRTMP_ADAPTER pAd,
+ IN USHORT Max);
+
+VOID RTMPrt3xSetPCIePowerLinkCtrl(
+ IN PRTMP_ADAPTER pAd);
+
+
+VOID RT28xxPciStaAsicForceWakeup(
+ IN PRTMP_ADAPTER pAd,
+ IN BOOLEAN bFromTx);
+
+VOID RT28xxPciStaAsicSleepThenAutoWakeup(
+ IN PRTMP_ADAPTER pAd,
+ IN USHORT TbttNumToNextWakeUp);
+
+VOID PsPollWakeExec(
+ IN PVOID SystemSpecific1,
+ IN PVOID FunctionContext,
+ IN PVOID SystemSpecific2,
+ IN PVOID SystemSpecific3);
+
+VOID RadioOnExec(
+ IN PVOID SystemSpecific1,
+ 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 // RTMP_MAC_PCI //
+
+VOID AsicTurnOffRFClk(
+ IN PRTMP_ADAPTER pAd,
+ IN UCHAR Channel);
+
+VOID AsicTurnOnRFClk(
+ IN PRTMP_ADAPTER pAd,
+ IN UCHAR Channel);
+
+
+
+#ifdef RTMP_TIMER_TASK_SUPPORT
+INT RtmpTimerQThread(
+ IN OUT PVOID Context);
+
+RTMP_TIMER_TASK_ENTRY *RtmpTimerQInsert(
+ IN RTMP_ADAPTER *pAd,
+ IN RALINK_TIMER_STRUCT *pTimer);
+
+BOOLEAN RtmpTimerQRemove(
+ IN RTMP_ADAPTER *pAd,
+ IN RALINK_TIMER_STRUCT *pTimer);
+
+void RtmpTimerQExit(
+ IN RTMP_ADAPTER *pAd);
+
+void RtmpTimerQInit(
+ IN RTMP_ADAPTER *pAd);
+#endif // RTMP_TIMER_TASK_SUPPORT //
+
+
+
+////////////////////////////////////////
+
+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 PSTRING pName,
+ IN PSTRING pBuf);
+
+PSTRING RTMPGetRalinkAuthModeStr(
+ IN NDIS_802_11_AUTHENTICATION_MODE authMode);
+
+PSTRING 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 ADD_HT_INFO_IE *pAddHtInfo,
+ IN UCHAR AddHtInfoLen,
+ IN USHORT CapabilityInfo);
+
+
+BOOLEAN AUTH_ReqSend(
+ IN PRTMP_ADAPTER pAd,
+ IN PMLME_QUEUE_ELEM pElem,
+ IN PRALINK_TIMER_STRUCT pAuthTimer,
+ IN PSTRING pSMName,
+ IN USHORT SeqNo,
+ IN PUCHAR pNewElement,
+ IN ULONG ElementLen);
+#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);
+
+
+#define VIRTUAL_IF_INC(__pAd) ((__pAd)->VirtualIfCnt++)
+#define VIRTUAL_IF_DEC(__pAd) ((__pAd)->VirtualIfCnt--)
+#define VIRTUAL_IF_NUM(__pAd) ((__pAd)->VirtualIfCnt)
+
+
+#ifdef LINUX
+__inline INT VIRTUAL_IF_UP(PRTMP_ADAPTER pAd)
+{
+ if (VIRTUAL_IF_NUM(pAd) == 0)
+ {
+ if (rt28xx_open(pAd->net_dev) != 0)
+ {
+ DBGPRINT(RT_DEBUG_TRACE, ("rt28xx_open return fail!\n"));
+ 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 // LINUX //
+
+
+
+
+/*
+ OS Related funciton prototype definitions.
+ TODO: Maybe we need to move these function prototypes to other proper place.
+*/
+int RtmpOSWrielessEventSend(
+ IN RTMP_ADAPTER *pAd,
+ IN UINT32 eventType,
+ IN INT flags,
+ IN PUCHAR pSrcMac,
+ IN PUCHAR pData,
+ IN UINT32 dataLen);
+
+int RtmpOSNetDevAddrSet(
+ IN PNET_DEV pNetDev,
+ IN PUCHAR pMacAddr);
+
+int RtmpOSNetDevAttach(
+ IN PNET_DEV pNetDev,
+ IN RTMP_OS_NETDEV_OP_HOOK *pDevOpHook);
+
+void RtmpOSNetDevClose(
+ IN PNET_DEV pNetDev);
+
+void RtmpOSNetDevDetach(
+ IN PNET_DEV pNetDev);
+
+INT RtmpOSNetDevAlloc(
+ IN PNET_DEV *pNewNetDev,
+ IN UINT32 privDataSize);
+
+void RtmpOSNetDevFree(
+ IN PNET_DEV pNetDev);
+
+PNET_DEV RtmpOSNetDevGetByName(
+ IN PNET_DEV pNetDev,
+ IN PSTRING pDevName);
+
+void RtmpOSNetDeviceRefPut(
+ IN PNET_DEV pNetDev);
+
+PNET_DEV RtmpOSNetDevCreate(
+ IN RTMP_ADAPTER *pAd,
+ IN INT devType,
+ IN INT devNum,
+ IN INT privMemSize,
+ IN PSTRING pNamePrefix);
+
+/*
+ Task operation related function prototypes
+*/
+void RtmpOSTaskCustomize(
+ IN RTMP_OS_TASK *pTask);
+
+INT RtmpOSTaskNotifyToExit(
+ IN RTMP_OS_TASK *pTask);
+
+NDIS_STATUS RtmpOSTaskKill(
+ IN RTMP_OS_TASK *pTask);
+
+NDIS_STATUS RtmpOSTaskInit(
+ IN RTMP_OS_TASK *pTask,
+ PSTRING pTaskName,
+ VOID *pPriv);
+
+NDIS_STATUS RtmpOSTaskAttach(
+ IN RTMP_OS_TASK *pTask,
+ IN int (*fn)(void *),
+ IN void *arg);
+
+
+/*
+ File operation related function prototypes
+*/
+RTMP_OS_FD RtmpOSFileOpen(
+ IN char *pPath,
+ IN int flag,
+ IN int mode);
+
+int RtmpOSFileClose(
+ IN RTMP_OS_FD osfd);
+
+void RtmpOSFileSeek(
+ IN RTMP_OS_FD osfd,
+ IN int offset);
+
+int RtmpOSFileRead(
+ IN RTMP_OS_FD osfd,
+ IN char *pDataPtr,
+ IN int readLen);
+
+int RtmpOSFileWrite(
+ IN RTMP_OS_FD osfd,
+ IN char *pDataPtr,
+ IN int writeLen);
+
+void RtmpOSFSInfoChange(
+ IN RTMP_OS_FS_INFO *pOSFSInfo,
+ IN BOOLEAN bSet);
+
+
+#endif // __RTMP_H__
diff --git a/drivers/staging/rt3090/rtmp_chip.h b/drivers/staging/rt3090/rtmp_chip.h
new file mode 100644
index 000000000000..a0b4bf06cca0
--- /dev/null
+++ b/drivers/staging/rt3090/rtmp_chip.h
@@ -0,0 +1,355 @@
+/*
+ *************************************************************************
+ * 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_chip.h
+
+ Abstract:
+ Ralink Wireless Chip related definition & structures
+
+ Revision History:
+ Who When What
+ -------- ---------- ----------------------------------------------
+*/
+
+#ifndef __RTMP_CHIP_H__
+#define __RTMP_CHIP_H__
+
+#include "rtmp_type.h"
+
+#ifdef RT3090
+#include "rt3090.h"
+#endif // RT3090 //
+
+#ifdef RT3370
+#include "rt3370.h"
+#endif // RT3370 //
+
+#ifdef RT3390
+#include "rt3390.h"
+#endif // RT3390 //
+
+// We will have a cost down version which mac version is 0x3090xxxx
+//
+// RT3090A facts
+//
+// a) 2.4 GHz
+// b) Replacement for RT3090
+// c) Internal LNA
+// d) Interference over channel #14
+// e) New BBP features (e.g., SIG re-modulation)
+//
+#define IS_RT3090A(_pAd) ((((_pAd)->MACVersion & 0xffff0000) == 0x30900000))
+
+// We will have a cost down version which mac version is 0x3090xxxx
+#define IS_RT3090(_pAd) ((((_pAd)->MACVersion & 0xffff0000) == 0x30710000) || (IS_RT3090A(_pAd)))
+
+#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||IS_RT3090A(_pAd))
+//#define IS_RT305X(_pAd) ((_pAd)->MACVersion == 0x28720200)
+
+/* RT3572, 3592, 3562, 3062 share the same MAC version */
+#define IS_RT3572(_pAd) (((_pAd)->MACVersion & 0xffff0000) == 0x35720000)
+#define IS_VERSION_BEFORE_F(_pAd) (((_pAd)->MACVersion&0xffff) <= 0x0211)
+// F version is 0x0212, E version is 0x0211. 309x can save more power after F version.
+#define IS_VERSION_AFTER_F(_pAd) ((((_pAd)->MACVersion&0xffff) >= 0x0212) || (((_pAd)->b3090ESpecialChip == TRUE)))
+//
+// RT3390 facts
+//
+// a) Base on RT3090 (RF IC: RT3020)
+// b) 2.4 GHz
+// c) 1x1
+// d) Single chip
+// e) Internal components: PA and LNA
+//
+//RT3390,RT3370
+#define IS_RT3390(_pAd) (((_pAd)->MACVersion & 0xFFFF0000) == 0x33900000)
+
+// ------------------------------------------------------
+// PCI registers - base address 0x0000
+// ------------------------------------------------------
+#define CHIP_PCI_CFG 0x0000
+#define CHIP_PCI_EECTRL 0x0004
+#define CHIP_PCI_MCUCTRL 0x0008
+
+#define OPT_14 0x114
+
+#define RETRY_LIMIT 10
+
+
+
+// ------------------------------------------------------
+// BBP & RF definition
+// ------------------------------------------------------
+#define BUSY 1
+#define IDLE 0
+
+
+//-------------------------------------------------------------------------
+// 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_TXMIXER_GAIN_2_4G 0x48
+#define EEPROM_RSSI_A_OFFSET 0x4a
+#define EEPROM_TXMIXER_GAIN_5G 0x4c
+#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
+
+
+/*
+ * EEPROM operation related marcos
+ */
+#define RT28xx_EEPROM_READ16(_pAd, _offset, _value) \
+ (_pAd)->chipOps.eeread((RTMP_ADAPTER *)(_pAd), (USHORT)(_offset), (PUSHORT)&(_value))
+
+#define RT28xx_EEPROM_WRITE16(_pAd, _offset, _value) \
+ (_pAd)->chipOps.eewrite((RTMP_ADAPTER *)(_pAd), (USHORT)(_offset), (USHORT)(_value))
+
+
+
+// -------------------------------------------------------------------
+// E2PROM data layout
+// -------------------------------------------------------------------
+
+//
+// MCU_LEDCS: MCU LED Control Setting.
+//
+typedef union _MCU_LEDCS_STRUC {
+ struct {
+#ifdef RT_BIG_ENDIAN
+ UCHAR Polarity:1;
+ UCHAR LedMode:7;
+#else
+ UCHAR LedMode:7;
+ UCHAR Polarity:1;
+#endif // RT_BIG_ENDIAN //
+ } field;
+ UCHAR word;
+} MCU_LEDCS_STRUC, *PMCU_LEDCS_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
+ 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
+
+#endif // __RTMP_CHIP_H__ //
diff --git a/drivers/staging/rt3090/rtmp_def.h b/drivers/staging/rt3090/rtmp_def.h
new file mode 100644
index 000000000000..cf0d5a138ea2
--- /dev/null
+++ b/drivers/staging/rt3090/rtmp_def.h
@@ -0,0 +1,1650 @@
+/*
+ *************************************************************************
+ * 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)
+
+#define MAX_RX_PKT_LEN 1520
+
+//
+// Entry number for each DMA descriptor ring
+//
+
+#ifdef RTMP_MAC_PCI
+#define TX_RING_SIZE 64 //64
+#define MGMT_RING_SIZE 128
+#define RX_RING_SIZE 128 //64
+#define MAX_TX_PROCESS TX_RING_SIZE //8
+#define MAX_DMA_DONE_PROCESS TX_RING_SIZE
+#define MAX_TX_DONE_PROCESS TX_RING_SIZE //8
+#define LOCAL_TXBUF_SIZE 2
+#endif // RTMP_MAC_PCI //
+
+#define PCI_VIRT_TO_PHYS(__Addr) (((UINT32)(__Addr)) & 0x0FFFFFFF)
+
+
+#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)
+
+
+/*
+ WMM Note: If memory of your system is not much, please reduce the definition;
+ or when you do WMM test, the queue for low priority AC will be full, i.e.
+ TX_RING_SIZE + MAX_PACKETS_IN_QUEUE packets for the AC will be buffered in
+ WLAN, maybe no any packet buffer can be got in Ethernet driver.
+
+ Sometimes no packet buffer can be got in Ethernet driver, the system will
+ send flow control packet to the sender to slow down its sending rate.
+ So no WMM can be saw in the air.
+*/
+
+/*
+ Need to use 64 in vxworks for test case WMM A5-T07
+ Two dnlink (10Mbps) from a WMM station to a non-WMM station.
+ If use 256, queue is not enough.
+ And in rt_main_end.c, clConfig.clNum = RX_RING_SIZE * 3; is changed to
+ clConfig.clNum = RX_RING_SIZE * 4;
+*/
+// TODO: For VxWorks the size is 256. Shall we cahnge the value as 256 for all OS?????
+#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 */
+
+
+#ifdef RTMP_EFUSE_SUPPORT
+//2008/09/11:KH add to support efuse<--
+#define MAX_EEPROM_BIN_FILE_SIZE 1024
+#define EFUSE_BUFFER_PATH "/tmp/RT30xxEEPROM.bin"
+//2008/09/11:KH add to support efuse-->
+#endif // RTMP_EFUSE_SUPPORT //
+
+// RxFilter
+#define STANORMAL 0x17f97
+#define APNORMAL 0x15f97
+#define PSPXLINK 0x17f93
+//
+// 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_PCIE_DEVICE 0x00020000
+
+//
+// RTMP_ADAPTER PSFlags : related to advanced power save.
+//
+// Indicate whether driver can go to sleep mode from now. This flag is useful AFTER link up
+#define fRTMP_PS_CAN_GO_SLEEP 0x00000001
+// Indicate whether driver has issue a LinkControl command to PCIe L1
+#define fRTMP_PS_SET_PCI_CLK_OFF_COMMAND 0x00000002
+// Indicate driver should disable kick off hardware to send packets from now.
+#define fRTMP_PS_DISABLE_TX 0x00000004
+// 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
+#define fRTMP_PS_TOGGLE_L1 0x00000010 // Use Toggle L1 mechanism for rt28xx PCIe
+#ifdef RT3090
+#define WAKE_MCU_CMD 0x31
+#define SLEEP_MCU_CMD 0x30
+#define RFOFF_MCU_CMD 0x35
+#endif // RT3090 //
+#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
+#define fRX_FILTER_ACCEPT_PROMISCUOUS NDIS_PACKET_TYPE_PROMISCUOUS
+
+//
+// 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
+#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) { \
+ DBGPRINT(RT_DEBUG_ERROR, ("%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_NUM_OF_REGULATORY_CLASS 16
+#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
+#define MAX_NUM_OF_BBP_LATCH 140
+//============================================================
+// 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_INVALID_GROUP_CIPHER 41
+#define MLME_INVALID_PAIRWISE_CIPHER 42
+#define MLME_INVALID_AKMP 43
+#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_SYNC_STATE_MACHINE 14
+#define AP_CNTL_STATE_MACHINE 15
+#define WSC_STATE_MACHINE 17
+#define WSC_UPNP_STATE_MACHINE 18
+
+
+#define WPA_STATE_MACHINE 23
+
+
+#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
+
+#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_FT_OTD_CONF 46
+#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
+/* "FT_CATEGORY_BSS_TRANSITION equal to 6" is defined file of "dot11r_ft.h" */
+#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)
+
+//
+// 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 APMT2_PEER_DEAUTH 2
+#define APMT2_PEER_AUTH_REQ 3
+#define APMT2_PEER_AUTH_CONFIRM 4
+#define AP_MAX_AUTH_MSG 5
+
+#define AP_AUTH_FUNC_SIZE (AP_MAX_AUTH_STATE * AP_MAX_AUTH_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)
+
+//
+// Common WPA state machine: states, events, total function #
+//
+#define WPA_PTK 0
+#define MAX_WPA_PTK_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_MSG 5
+
+#define WPA_FUNC_SIZE (MAX_WPA_PTK_STATE * 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
+#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, 169, 173
+#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_12_A_BAND 12 // 36, 40, 44, 48, 52, 56, 60, 64, 100, 104, 108, 112, 116, 120, 124, 128, 132, 136, 140
+#define REGION_13_A_BAND 13 // 52, 56, 60, 64, 100, 104, 108, 112, 116, 120, 124, 128, 132, 136, 140, 149, 153, 157, 161
+#define REGION_14_A_BAND 14 // 36, 40, 44, 48, 52, 56, 60, 64, 100, 104, 108, 112, 116, 136, 140, 149, 153, 157, 161, 165
+#define REGION_15_A_BAND 15 // 149, 153, 157, 161, 165, 169, 173
+#define REGION_MAXIMUM_A_BAND 15
+
+// 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
+
+
+// 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
+#define LED_MODE_SIGNAL_STREGTH 0x40 // EEPROM define = 64
+
+// 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
+
+#define INF_MAIN_DEV_NAME "ra"
+#define INF_MBSSID_DEV_NAME "ra"
+#define INF_WDS_DEV_NAME "wds"
+#define INF_APCLI_DEV_NAME "apcli"
+#define INF_MESH_DEV_NAME "mesh"
+
+// 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, kathy
+#define MAX_TX_REORDERBUF 64
+#define MAX_RX_REORDERBUF 64
+#define DEFAULT_TX_TIMEOUT 30
+#define DEFAULT_RX_TIMEOUT 30
+#define MAX_BARECI_SESSION 8
+
+#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
+
+// definition for Antenna Diversity flag
+#ifdef ANT_DIVERSITY_SUPPORT
+enum ANT_DIVERSITY_TYPE {
+ ANT_DIVERSITY_DISABLE = 0,
+ ANT_DIVERSITY_ENABLE = 1,
+ ANT_FIX_ANT1 = 2,
+ ANT_FIX_ANT2 = 3
+};
+#endif // ANT_DIVERSITY_SUPPORT //
+
+// 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
+
+#define ABS(_x, _y) ((_x) > (_y)) ? ((_x) -(_y)) : ((_y) -(_x))
+
+
+#define A2Dec(_X, _p) \
+{ \
+ UCHAR *p; \
+ _X = 0; \
+ p = _p; \
+ while (((*p >= '0') && (*p <= '9'))) \
+ { \
+ if ((*p >= '0') && (*p <= '9')) \
+ _X = _X * 10 + *p - 48; \
+ p++; \
+ } \
+}
+
+
+#define A2Hex(_X, _p) \
+do{ \
+ char *__p; \
+ (_X) = 0; \
+ __p = (char *)(_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++; \
+ } \
+}while(0)
+
+#endif // __RTMP_DEF_H__
diff --git a/drivers/staging/rt3090/rtmp_dot11.h b/drivers/staging/rt3090/rtmp_dot11.h
new file mode 100644
index 000000000000..a637825afe9c
--- /dev/null
+++ b/drivers/staging/rt3090/rtmp_dot11.h
@@ -0,0 +1,146 @@
+/*
+ *************************************************************************
+ * 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 __DOT11_BASE_H__
+#define __DOT11_BASE_H__
+
+#include "rtmp_type.h"
+
+
+// 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 _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;
+
+#endif // __DOT11_BASE_H__ //
diff --git a/drivers/staging/rt3090/rtmp_iface.h b/drivers/staging/rt3090/rtmp_iface.h
new file mode 100644
index 000000000000..168d0797fb6a
--- /dev/null
+++ b/drivers/staging/rt3090/rtmp_iface.h
@@ -0,0 +1,81 @@
+/*
+ *************************************************************************
+ * 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_iface.h
+
+ Abstract:
+
+ Revision History:
+ Who When What
+ --------- ---------- ----------------------------------------------
+ */
+
+#ifndef __RTMP_IFACE_H__
+#define __RTMP_IFACE_H__
+
+#ifdef RTMP_PCI_SUPPORT
+#include "rtmp_pci.h"
+#endif // RTMP_PCI_SUPPORT //
+
+
+typedef struct _INF_PCI_CONFIG_
+{
+ unsigned long CSRBaseAddress; // PCI MMIO Base Address, all access will use
+ unsigned int irq_num;
+}INF_PCI_CONFIG;
+
+
+typedef struct _INF_USB_CONFIG_
+{
+ UINT8 BulkInEpAddr; // bulk-in endpoint address
+ UINT8 BulkOutEpAddr[6]; // bulk-out endpoint address
+}INF_USB_CONFIG;
+
+
+typedef struct _INF_RBUS_CONFIG_
+{
+ unsigned long csr_addr;
+ unsigned int irq;
+}INF_RBUS_CONFIG;
+
+
+typedef enum _RTMP_INF_TYPE_
+{
+ RTMP_DEV_INF_UNKNOWN = 0,
+ RTMP_DEV_INF_PCI = 1,
+ RTMP_DEV_INF_USB = 2,
+ RTMP_DEV_INF_RBUS = 4,
+}RTMP_INF_TYPE;
+
+
+typedef union _RTMP_INF_CONFIG_{
+ struct _INF_PCI_CONFIG_ pciConfig;
+ struct _INF_USB_CONFIG_ usbConfig;
+ struct _INF_RBUS_CONFIG_ rbusConfig;
+}RTMP_INF_CONFIG;
+
+#endif // __RTMP_IFACE_H__ //
diff --git a/drivers/staging/rt3090/rtmp_mac.h b/drivers/staging/rt3090/rtmp_mac.h
new file mode 100644
index 000000000000..c57b2959777e
--- /dev/null
+++ b/drivers/staging/rt3090/rtmp_mac.h
@@ -0,0 +1,2304 @@
+/*
+ *************************************************************************
+ * 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_mac.h
+
+ Abstract:
+ Ralink Wireless Chip MAC related definition & structures
+
+ Revision History:
+ Who When What
+ -------- ---------- ----------------------------------------------
+*/
+
+#ifndef __RTMP_MAC_H__
+#define __RTMP_MAC_H__
+
+
+
+// =================================================================================
+// 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
+
+
+//
+// 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
+ // ex: 00 03 00 40 means txop = 3, PHYMODE = 1
+ 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;
+ // Word1
+ // ex: 1c ff 38 00 means ACK=0, BAWinSize=7, MPDUtotalByteCount = 0x38
+ 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
+
+
+//
+// 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 rsv2:8;
+ UINT32 FOFFSET:8; // RT35xx
+ 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 FOFFSET:8; // RT35xx
+ UINT32 rsv2:8;
+ /*UINT32 rsv2:16;*/
+} RXWI_STRUC, *PRXWI_STRUC;
+#endif
+
+
+// =================================================================================
+// Register format
+// =================================================================================
+
+
+//
+// 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 {
+#ifdef TONE_RADAR_DETECT_SUPPORT
+ UINT32 :11;
+ UINT32 RadarINT:1;
+ UINT32 rsv:2;
+#else // original source code
+ UINT32 :14;
+#endif // TONE_RADAR_DETECT_SUPPORT //
+ 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;
+#ifdef TONE_RADAR_DETECT_SUPPORT
+ UINT32 rsv:2;
+ UINT32 RadarINT:1;
+ UINT32 :11;
+#else
+ UINT32 :14;
+#endif // TONE_RADAR_DETECT_SUPPORT //
+ } 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;
+#ifdef TONE_RADAR_DETECT_SUPPORT
+ UINT32 :9;
+ UINT32 RadarINT:1;
+ UINT32 rsv:10;
+#else
+ UINT32 :20;
+#endif // TONE_RADAR_DETECT_SUPPORT //
+ 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;
+#ifdef TONE_RADAR_DETECT_SUPPORT
+ UINT32 rsv:10;
+ UINT32 RadarINT:1;
+ UINT32 :9;
+#else
+ UINT32 :20;
+#endif // TONE_RADAR_DETECT_SUPPORT //
+ 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
+
+#ifdef RT30xx
+#ifdef RTMP_EFUSE_SUPPORT
+// eFuse registers
+#define EFUSE_CTRL 0x0580
+#define EFUSE_DATA0 0x0590
+#define EFUSE_DATA1 0x0594
+#define EFUSE_DATA2 0x0598
+#define EFUSE_DATA3 0x059c
+#endif // RTMP_EFUSE_SUPPORT //
+#endif // RT30xx //
+
+#define OSC_CTRL 0x5a4
+#define PCIE_PHY_TX_ATTENUATION_CTRL 0x05C8
+#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;
+
+
+// =================================================================================
+// 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
+
+
+// =================================================================================
+// 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
+
+
+//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
+
+//
+// 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
+
+
+//
+// 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
+
+
+
+// ================================================================
+// 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 NUM_OF_TX_RING 4
+#define QID_MGMT 13
+#define QID_RX 14
+#define QID_OTHER 15
+
+#endif // __RTMP_MAC_H__ //
diff --git a/drivers/staging/rt3090/rtmp_mcu.h b/drivers/staging/rt3090/rtmp_mcu.h
new file mode 100644
index 000000000000..e1b2fee9e105
--- /dev/null
+++ b/drivers/staging/rt3090/rtmp_mcu.h
@@ -0,0 +1,55 @@
+/*
+ *************************************************************************
+ * 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_mcu.h
+
+ Abstract:
+ Miniport header file for mcu related information
+
+ Revision History:
+ Who When What
+ -------- ---------- ----------------------------------------------
+*/
+
+#ifndef __RTMP_MCU_H__
+#define __RTMP_MCU_H__
+
+
+INT RtmpAsicEraseFirmware(
+ IN PRTMP_ADAPTER pAd);
+
+NDIS_STATUS RtmpAsicLoadFirmware(
+ IN PRTMP_ADAPTER pAd);
+
+INT RtmpAsicSendCommandToMcu(
+ IN PRTMP_ADAPTER pAd,
+ IN UCHAR Command,
+ IN UCHAR Token,
+ IN UCHAR Arg0,
+ IN UCHAR Arg1);
+
+#endif // __RTMP_MCU_H__ //
diff --git a/drivers/staging/rt3090/rtmp_os.h b/drivers/staging/rt3090/rtmp_os.h
new file mode 100644
index 000000000000..5646b2dfd6a8
--- /dev/null
+++ b/drivers/staging/rt3090/rtmp_os.h
@@ -0,0 +1,93 @@
+/*
+ *************************************************************************
+ * 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_os.h
+
+ Abstract:
+
+ Revision History:
+ Who When What
+ --------- ---------- ----------------------------------------------
+ */
+
+
+#ifndef __RTMP_OS_H__
+#define __RTMP_OS_H__
+
+#ifdef LINUX
+#include "rt_linux.h"
+#endif // LINUX //
+
+
+/*
+ This data structure mainly strip some callback function defined in
+ "struct net_device" in kernel source "include/linux/netdevice.h".
+
+ The definition of this data structure may various depends on different
+ OS. Use it carefully.
+*/
+typedef struct _RTMP_OS_NETDEV_OP_HOOK_
+{
+ const struct net_device_ops *netdev_ops;
+ void *priv;
+ int priv_flags;
+ unsigned char devAddr[6];
+ unsigned char devName[16];
+ unsigned char needProtcted;
+}RTMP_OS_NETDEV_OP_HOOK, *PRTMP_OS_NETDEV_OP_HOOK;
+
+
+typedef enum _RTMP_TASK_STATUS_
+{
+ RTMP_TASK_STAT_UNKNOWN = 0,
+ RTMP_TASK_STAT_INITED = 1,
+ RTMP_TASK_STAT_RUNNING = 2,
+ RTMP_TASK_STAT_STOPED = 4,
+}RTMP_TASK_STATUS;
+#define RTMP_TASK_CAN_DO_INSERT (RTMP_TASK_STAT_INITED |RTMP_TASK_STAT_RUNNING)
+
+#define RTMP_OS_TASK_NAME_LEN 16
+typedef struct _RTMP_OS_TASK_
+{
+ char taskName[RTMP_OS_TASK_NAME_LEN];
+ void *priv;
+ //unsigned long taskFlags;
+ RTMP_TASK_STATUS taskStatus;
+#ifndef KTHREAD_SUPPORT
+ RTMP_OS_SEM taskSema;
+ RTMP_OS_PID taskPID;
+ struct completion taskComplete;
+#endif
+ unsigned char task_killed;
+#ifdef KTHREAD_SUPPORT
+ struct task_struct *kthread_task;
+ wait_queue_head_t kthread_q;
+ BOOLEAN kthread_running;
+#endif
+}RTMP_OS_TASK;
+
+#endif // __RMTP_OS_H__ //
diff --git a/drivers/staging/rt3090/rtmp_pci.h b/drivers/staging/rt3090/rtmp_pci.h
new file mode 100644
index 000000000000..c2fed29058f4
--- /dev/null
+++ b/drivers/staging/rt3090/rtmp_pci.h
@@ -0,0 +1,110 @@
+/*
+ *************************************************************************
+ * 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 __RTMP_PCI_H__
+#define __RTMP_PCI_H__
+
+#define RT28XX_HANDLE_DEV_ASSIGN(handle, dev_p) \
+ ((POS_COOKIE)handle)->pci_dev = dev_p;
+
+
+#ifdef LINUX
+// set driver data
+#define RT28XX_DRVDATA_SET(_a) pci_set_drvdata(_a, net_dev);
+
+#define RT28XX_PUT_DEVICE(dev_p)
+
+#if LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,24)
+#define SA_SHIRQ IRQF_SHARED
+#endif
+
+#ifdef PCI_MSI_SUPPORT
+#define RTMP_MSI_ENABLE(_pAd) \
+{ POS_COOKIE _pObj = (POS_COOKIE)(_pAd->OS_Cookie); \
+ (_pAd)->HaveMsi = pci_enable_msi(_pObj->pci_dev) == 0 ? TRUE : FALSE; }
+
+#define RTMP_MSI_DISABLE(_pAd) \
+{ POS_COOKIE _pObj = (POS_COOKIE)(_pAd->OS_Cookie); \
+ if (_pAd->HaveMsi == TRUE) \
+ pci_disable_msi(_pObj->pci_dev); \
+ _pAd->HaveMsi = FALSE; }
+#else
+#define RTMP_MSI_ENABLE(_pAd)
+#define RTMP_MSI_DISABLE(_pAd)
+#endif // PCI_MSI_SUPPORT //
+
+
+#define RTMP_PCI_DEV_UNMAP() \
+{ if (net_dev->base_addr) { \
+ iounmap((void *)(net_dev->base_addr)); \
+ release_mem_region(pci_resource_start(dev_p, 0), \
+ pci_resource_len(dev_p, 0)); } \
+ if (net_dev->irq) pci_release_regions(dev_p); }
+
+
+#define RTMP_IRQ_REQUEST(net_dev) \
+{ PRTMP_ADAPTER _pAd = (PRTMP_ADAPTER)(RTMP_OS_NETDEV_GET_PRIV(net_dev)); \
+ POS_COOKIE _pObj = (POS_COOKIE)(_pAd->OS_Cookie); \
+ RTMP_MSI_ENABLE(_pAd); \
+ if ((retval = request_irq(_pObj->pci_dev->irq, \
+ rt2860_interrupt, SA_SHIRQ, \
+ (net_dev)->name, (net_dev)))) { \
+ DBGPRINT(RT_DEBUG_ERROR, ("request_irq error(%d)\n", retval)); \
+ return retval; } }
+
+#if LINUX_VERSION_CODE >= KERNEL_VERSION(2,5,0)
+#define RTMP_IRQ_RELEASE(net_dev) \
+{ PRTMP_ADAPTER _pAd = (PRTMP_ADAPTER)(RTMP_OS_NETDEV_GET_PRIV(net_dev)); \
+ POS_COOKIE _pObj = (POS_COOKIE)(_pAd->OS_Cookie); \
+ synchronize_irq(_pObj->pci_dev->irq); \
+ free_irq(_pObj->pci_dev->irq, (net_dev)); \
+ RTMP_MSI_DISABLE(_pAd); }
+#else
+#define RTMP_IRQ_RELEASE(net_dev) \
+{ PRTMP_ADAPTER _pAd = (PRTMP_ADAPTER)(RTMP_OS_NETDEV_GET_PRIV(net_dev)); \
+ POS_COOKIE _pObj = (POS_COOKIE)(_pAd->OS_Cookie); \
+ free_irq(_pObj->pci_dev->irq, (net_dev)); \
+ RTMP_MSI_DISABLE(_pAd); }
+#endif
+
+#define PCI_REG_READ_WORD(pci_dev, offset, Configuration) \
+ if (pci_read_config_word(pci_dev, offset, &reg16) == 0) \
+ Configuration = le2cpu16(reg16); \
+ else \
+ Configuration = 0;
+
+#define PCI_REG_WIRTE_WORD(pci_dev, offset, Configuration) \
+ reg16 = cpu2le16(Configuration); \
+ pci_write_config_word(pci_dev, offset, reg16); \
+
+#endif // LINUX //
+
+
+
+
+#endif // __RTMP_PCI_H__ //
diff --git a/drivers/staging/rt3090/rtmp_phy.h b/drivers/staging/rt3090/rtmp_phy.h
new file mode 100644
index 000000000000..b9848cac282e
--- /dev/null
+++ b/drivers/staging/rt3090/rtmp_phy.h
@@ -0,0 +1,631 @@
+/*
+ *************************************************************************
+ * 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_phy.h
+
+ Abstract:
+ Ralink Wireless Chip PHY(BBP/RF) related definition & structures
+
+ Revision History:
+ Who When What
+ -------- ---------- ----------------------------------------------
+*/
+
+#ifndef __RTMP_PHY_H__
+#define __RTMP_PHY_H__
+
+
+/*
+ RF sections
+*/
+#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
+
+
+// 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
+#define RFIC_3052 9 // 2.4G/5G 2T2R
+
+/*
+ BBP sections
+*/
+#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_R26 26
+#define BBP_R27 27
+#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_R78 78
+#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_R106 106
+#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
+
+
+#ifdef MERGE_ARCH_TEAM
+ #define MAX_BBP_ID 200
+ #define MAX_BBP_MSG_SIZE 4096
+#else
+#ifdef RT30xx
+ // edit by johnli, RF power sequence setup, add BBP R138 for ADC dynamic on/off control
+ #define MAX_BBP_ID 138
+#endif // RT30xx //
+#ifndef RT30xx
+ #define MAX_BBP_ID 136
+#endif // RT30xx //
+ #define MAX_BBP_MSG_SIZE 2048
+#endif // MERGE_ARCH_TEAM //
+
+
+//
+// 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
+
+//#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
+
+/*****************************************************************************
+ RF register Read/Write marco definition
+ *****************************************************************************/
+#ifdef RTMP_MAC_PCI
+#define RTMP_RF_IO_WRITE32(_A, _V) \
+{ \
+ if ((_A)->bPCIclkOff == FALSE) \
+ { \
+ PHY_CSR4_STRUC _value; \
+ ULONG _busyCnt = 0; \
+ \
+ do { \
+ RTMP_IO_READ32((_A), RF_CSR_CFG0, &_value.word); \
+ if (_value.field.Busy == IDLE) \
+ break; \
+ _busyCnt++; \
+ }while (_busyCnt < MAX_BUSY_COUNT); \
+ if(_busyCnt < MAX_BUSY_COUNT) \
+ { \
+ RTMP_IO_WRITE32((_A), RF_CSR_CFG0, (_V)); \
+ } \
+ } \
+}
+#endif // RTMP_MAC_PCI //
+
+
+
+#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 //
+
+
+/*****************************************************************************
+ BBP register Read/Write marco definitions.
+ we read/write the bbp value by register's ID.
+ Generate PER to test BA
+ *****************************************************************************/
+#ifdef RTMP_MAC_PCI
+/*
+ basic marco for BBP read operation.
+ _pAd: the data structure pointer of RTMP_ADAPTER
+ _bbpID : the bbp register ID
+ _pV: data pointer used to save the value of queried bbp register.
+ _bViaMCU: if we need access the bbp via the MCU.
+*/
+#define RTMP_BBP_IO_READ8(_pAd, _bbpID, _pV, _bViaMCU) \
+ do{ \
+ BBP_CSR_CFG_STRUC BbpCsr; \
+ int _busyCnt, _secCnt, _regID; \
+ \
+ _regID = ((_bViaMCU) == TRUE ? H2M_BBP_AGENT : BBP_CSR_CFG); \
+ for (_busyCnt=0; _busyCnt<MAX_BUSY_COUNT; _busyCnt++) \
+ { \
+ RTMP_IO_READ32(_pAd, _regID, &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 = _bbpID; \
+ RTMP_IO_WRITE32(_pAd, _regID, BbpCsr.word); \
+ if ((_bViaMCU) == TRUE) \
+ { \
+ AsicSendCommandToMcu(_pAd, 0x80, 0xff, 0x0, 0x0); \
+ RTMPusecDelay(1000); \
+ } \
+ for (_secCnt=0; _secCnt<MAX_BUSY_COUNT; _secCnt++) \
+ { \
+ RTMP_IO_READ32(_pAd, _regID, &BbpCsr.word); \
+ if (BbpCsr.field.Busy == IDLE) \
+ break; \
+ } \
+ if ((BbpCsr.field.Busy == IDLE) && \
+ (BbpCsr.field.RegNum == _bbpID)) \
+ { \
+ *(_pV) = (UCHAR)BbpCsr.field.Value; \
+ break; \
+ } \
+ } \
+ if (BbpCsr.field.Busy == BUSY) \
+ { \
+ DBGPRINT_ERR(("BBP(viaMCU=%d) read R%d fail\n", (_bViaMCU), _bbpID)); \
+ *(_pV) = (_pAd)->BbpWriteLatch[_bbpID]; \
+ if ((_bViaMCU) == TRUE) \
+ { \
+ RTMP_IO_READ32(_pAd, _regID, &BbpCsr.word); \
+ BbpCsr.field.Busy = 0; \
+ RTMP_IO_WRITE32(_pAd, _regID, BbpCsr.word); \
+ } \
+ } \
+ }while(0)
+
+/*
+ This marco used for the BBP read operation which didn't need via MCU.
+*/
+#define BBP_IO_READ8_BY_REG_ID(_A, _I, _pV) \
+ RTMP_BBP_IO_READ8((_A), (_I), (_pV), FALSE)
+
+/*
+ This marco used for the BBP read operation which need via MCU.
+ But for some chipset which didn't have mcu (e.g., RBUS based chipset), we
+ will use this function too and didn't access the bbp register via the MCU.
+*/
+#ifndef CONFIG_STA_SUPPORT
+#define RTMP_BBP_IO_READ8_BY_REG_ID(_A, _I, _pV) \
+ do{ \
+ if ((_A)->bPCIclkOff == FALSE) \
+ { \
+ if ((_A)->infType == RTMP_DEV_INF_RBUS) \
+ RTMP_BBP_IO_READ8((_A), (_I), (_pV), FALSE); \
+ else \
+ RTMP_BBP_IO_READ8((_A), (_I), (_pV), TRUE); \
+ } \
+ }while(0)
+#endif // CONFIG_STA_SUPPORT //
+#ifdef CONFIG_STA_SUPPORT
+// Read BBP register by register's ID. Generate PER to test BA
+#define RTMP_BBP_IO_READ8_BY_REG_ID(_A, _I, _pV) \
+{ \
+ BBP_CSR_CFG_STRUC BbpCsr; \
+ int i, k; \
+ BOOLEAN brc; \
+ BbpCsr.field.Busy = IDLE; \
+ if ((IS_RT3090((_A)) || IS_RT3572((_A)) || IS_RT3390((_A))) && ((_A)->StaCfg.PSControl.field.rt30xxPowerMode == 3) \
+ && ((_A)->StaCfg.PSControl.field.EnableNewPS == TRUE) \
+ && ((_A)->bPCIclkOff == FALSE) \
+ && ((_A)->brt30xxBanMcuCmd == FALSE)) \
+ { \
+ for (i=0; i<MAX_BUSY_COUNT; i++) \
+ { \
+ RTMP_IO_READ32(_A, 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 = _I; \
+ RTMP_IO_WRITE32(_A, H2M_BBP_AGENT, BbpCsr.word); \
+ brc = AsicSendCommandToMcu(_A, 0x80, 0xff, 0x0, 0x0); \
+ if (brc == TRUE) \
+ { \
+ for (k=0; k<MAX_BUSY_COUNT; k++) \
+ { \
+ RTMP_IO_READ32(_A, H2M_BBP_AGENT, &BbpCsr.word); \
+ if (BbpCsr.field.Busy == IDLE) \
+ break; \
+ } \
+ if ((BbpCsr.field.Busy == IDLE) && \
+ (BbpCsr.field.RegNum == _I)) \
+ { \
+ *(_pV) = (UCHAR)BbpCsr.field.Value; \
+ break; \
+ } \
+ } \
+ else \
+ { \
+ BbpCsr.field.Busy = 0; \
+ RTMP_IO_WRITE32(_A, H2M_BBP_AGENT, BbpCsr.word); \
+ } \
+ } \
+ } \
+ else if (!((IS_RT3090((_A)) || IS_RT3572((_A)) || IS_RT3390((_A))) && ((_A)->StaCfg.PSControl.field.rt30xxPowerMode == 3) \
+ && ((_A)->StaCfg.PSControl.field.EnableNewPS == TRUE)) \
+ && ((_A)->bPCIclkOff == FALSE)) \
+ { \
+ for (i=0; i<MAX_BUSY_COUNT; i++) \
+ { \
+ RTMP_IO_READ32(_A, 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 = _I; \
+ RTMP_IO_WRITE32(_A, H2M_BBP_AGENT, BbpCsr.word); \
+ AsicSendCommandToMcu(_A, 0x80, 0xff, 0x0, 0x0); \
+ for (k=0; k<MAX_BUSY_COUNT; k++) \
+ { \
+ RTMP_IO_READ32(_A, H2M_BBP_AGENT, &BbpCsr.word); \
+ if (BbpCsr.field.Busy == IDLE) \
+ break; \
+ } \
+ if ((BbpCsr.field.Busy == IDLE) && \
+ (BbpCsr.field.RegNum == _I)) \
+ { \
+ *(_pV) = (UCHAR)BbpCsr.field.Value; \
+ break; \
+ } \
+ } \
+ } \
+ else \
+ { \
+ DBGPRINT_ERR((" , brt30xxBanMcuCmd = %d, Read BBP %d \n", (_A)->brt30xxBanMcuCmd, (_I))); \
+ *(_pV) = (_A)->BbpWriteLatch[_I]; \
+ } \
+ if ((BbpCsr.field.Busy == BUSY) || ((_A)->bPCIclkOff == TRUE)) \
+ { \
+ DBGPRINT_ERR(("BBP read R%d=0x%x fail\n", _I, BbpCsr.word)); \
+ *(_pV) = (_A)->BbpWriteLatch[_I]; \
+ } \
+}
+#endif // CONFIG_STA_SUPPORT //
+
+/*
+ basic marco for BBP write operation.
+ _pAd: the data structure pointer of RTMP_ADAPTER
+ _bbpID : the bbp register ID
+ _pV: data used to save the value of queried bbp register.
+ _bViaMCU: if we need access the bbp via the MCU.
+*/
+#define RTMP_BBP_IO_WRITE8(_pAd, _bbpID, _pV, _bViaMCU) \
+ do{ \
+ BBP_CSR_CFG_STRUC BbpCsr; \
+ int _busyCnt, _regID; \
+ \
+ _regID = ((_bViaMCU) == TRUE ? H2M_BBP_AGENT : BBP_CSR_CFG); \
+ for (_busyCnt=0; _busyCnt<MAX_BUSY_COUNT; _busyCnt++) \
+ { \
+ RTMP_IO_READ32((_pAd), 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 = _pV; \
+ BbpCsr.field.RegNum = _bbpID; \
+ RTMP_IO_WRITE32((_pAd), BBP_CSR_CFG, BbpCsr.word); \
+ if ((_bViaMCU) == TRUE) \
+ { \
+ AsicSendCommandToMcu(_pAd, 0x80, 0xff, 0x0, 0x0); \
+ if ((_pAd)->OpMode == OPMODE_AP) \
+ RTMPusecDelay(1000); \
+ } \
+ (_pAd)->BbpWriteLatch[_bbpID] = _pV; \
+ break; \
+ } \
+ if (_busyCnt == MAX_BUSY_COUNT) \
+ { \
+ DBGPRINT_ERR(("BBP write R%d fail\n", _bbpID)); \
+ if((_bViaMCU) == TRUE) \
+ { \
+ RTMP_IO_READ32(_pAd, H2M_BBP_AGENT, &BbpCsr.word); \
+ BbpCsr.field.Busy = 0; \
+ RTMP_IO_WRITE32(_pAd, H2M_BBP_AGENT, BbpCsr.word); \
+ } \
+ } \
+ }while(0)
+
+
+/*
+ This marco used for the BBP write operation which didn't need via MCU.
+*/
+#define BBP_IO_WRITE8_BY_REG_ID(_A, _I, _pV) \
+ RTMP_BBP_IO_WRITE8((_A), (_I), (_pV), FALSE)
+
+/*
+ This marco used for the BBP write operation which need via MCU.
+ But for some chipset which didn't have mcu (e.g., RBUS based chipset), we
+ will use this function too and didn't access the bbp register via the MCU.
+*/
+#ifndef CONFIG_STA_SUPPORT
+#define RTMP_BBP_IO_WRITE8_BY_REG_ID(_A, _I, _pV) \
+ do{ \
+ if ((_A)->bPCIclkOff == FALSE) \
+ { \
+ if ((_A)->infType == RTMP_DEV_INF_RBUS) \
+ RTMP_BBP_IO_WRITE8((_A), (_I), (_pV), FALSE); \
+ else \
+ RTMP_BBP_IO_WRITE8((_A), (_I), (_pV), TRUE); \
+ } \
+ }while(0)
+#endif // CONFIG_STA_SUPPORT //
+#ifdef CONFIG_STA_SUPPORT
+// Write BBP register by register's ID & value
+#define RTMP_BBP_IO_WRITE8_BY_REG_ID(_A, _I, _V) \
+{ \
+ BBP_CSR_CFG_STRUC BbpCsr; \
+ INT BusyCnt = 0; \
+ BOOLEAN brc; \
+ if (_I < MAX_NUM_OF_BBP_LATCH) \
+ { \
+ if ((IS_RT3090((_A)) || IS_RT3572((_A)) || IS_RT3390((_A))) && ((_A)->StaCfg.PSControl.field.rt30xxPowerMode == 3) \
+ && ((_A)->StaCfg.PSControl.field.EnableNewPS == TRUE) \
+ && ((_A)->bPCIclkOff == FALSE) \
+ && ((_A)->brt30xxBanMcuCmd == FALSE)) \
+ { \
+ if (_A->AccessBBPFailCount > 20) \
+ { \
+ AsicResetBBPAgent(_A); \
+ _A->AccessBBPFailCount = 0; \
+ } \
+ for (BusyCnt=0; BusyCnt<MAX_BUSY_COUNT; BusyCnt++) \
+ { \
+ RTMP_IO_READ32(_A, 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 = _V; \
+ BbpCsr.field.RegNum = _I; \
+ RTMP_IO_WRITE32(_A, H2M_BBP_AGENT, BbpCsr.word); \
+ brc = AsicSendCommandToMcu(_A, 0x80, 0xff, 0x0, 0x0); \
+ if (brc == TRUE) \
+ { \
+ (_A)->BbpWriteLatch[_I] = _V; \
+ } \
+ else \
+ { \
+ BbpCsr.field.Busy = 0; \
+ RTMP_IO_WRITE32(_A, H2M_BBP_AGENT, BbpCsr.word); \
+ } \
+ break; \
+ } \
+ } \
+ else if (!((IS_RT3090((_A)) || IS_RT3572((_A)) || IS_RT3390((_A))) && ((_A)->StaCfg.PSControl.field.rt30xxPowerMode == 3) \
+ && ((_A)->StaCfg.PSControl.field.EnableNewPS == TRUE)) \
+ && ((_A)->bPCIclkOff == FALSE)) \
+ { \
+ if (_A->AccessBBPFailCount > 20) \
+ { \
+ AsicResetBBPAgent(_A); \
+ _A->AccessBBPFailCount = 0; \
+ } \
+ for (BusyCnt=0; BusyCnt<MAX_BUSY_COUNT; BusyCnt++) \
+ { \
+ RTMP_IO_READ32(_A, 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 = _V; \
+ BbpCsr.field.RegNum = _I; \
+ RTMP_IO_WRITE32(_A, H2M_BBP_AGENT, BbpCsr.word); \
+ AsicSendCommandToMcu(_A, 0x80, 0xff, 0x0, 0x0); \
+ (_A)->BbpWriteLatch[_I] = _V; \
+ break; \
+ } \
+ } \
+ else \
+ { \
+ DBGPRINT_ERR((" brt30xxBanMcuCmd = %d. Write BBP %d \n", (_A)->brt30xxBanMcuCmd, (_I))); \
+ } \
+ if ((BusyCnt == MAX_BUSY_COUNT) || ((_A)->bPCIclkOff == TRUE)) \
+ { \
+ if (BusyCnt == MAX_BUSY_COUNT) \
+ (_A)->AccessBBPFailCount++; \
+ DBGPRINT_ERR(("BBP write R%d=0x%x fail. BusyCnt= %d.bPCIclkOff = %d. \n", _I, BbpCsr.word, BusyCnt, (_A)->bPCIclkOff )); \
+ } \
+ } \
+ else \
+ { \
+ DBGPRINT_ERR(("****** BBP_Write_Latch Buffer exceeds max boundry ****** \n")); \
+ } \
+}
+#endif // CONFIG_STA_SUPPORT //
+#endif // RTMP_MAC_PCI //
+
+
+
+#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++; \
+ } \
+}
+
+#define RTMP_ASIC_MMPS_DISABLE(_pAd) \
+ do{ \
+ UCHAR _bbpData; \
+ UINT32 _macData; \
+ /* 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); \
+ }while(0)
+
+
+#define RTMP_ASIC_MMPS_ENABLE(_pAd) \
+ do{ \
+ UCHAR _bbpData; \
+ UINT32 _macData; \
+ /* 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); \
+ }while(0)
+
+#endif // RT30xx //
+
+#endif // __RTMP_PHY_H__ //
diff --git a/drivers/staging/rt3090/rtmp_timer.h b/drivers/staging/rt3090/rtmp_timer.h
new file mode 100644
index 000000000000..dfac124ebf14
--- /dev/null
+++ b/drivers/staging/rt3090/rtmp_timer.h
@@ -0,0 +1,162 @@
+/*
+ *************************************************************************
+ * 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_timer.h
+
+ Abstract:
+ Ralink Wireless Driver timer related data structures and delcarations
+
+ Revision History:
+ Who When What
+ -------- ---------- ----------------------------------------------
+ Name Date Modification logs
+ Shiang Tu Aug-28-2008 init version
+
+*/
+
+#ifndef __RTMP_TIMER_H__
+#define __RTMP_TIMER_H__
+
+#include "rtmp_os.h"
+
+
+#define DECLARE_TIMER_FUNCTION(_func) \
+ void rtmp_timer_##_func(unsigned long data)
+
+#define GET_TIMER_FUNCTION(_func) \
+ rtmp_timer_##_func
+
+
+/* ----------------- Timer Related MARCO ---------------*/
+// In some os or chipset, 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.
+
+#ifdef RTMP_TIMER_TASK_SUPPORT
+typedef VOID (*RTMP_TIMER_TASK_HANDLE)(
+ IN PVOID SystemSpecific1,
+ IN PVOID FunctionContext,
+ IN PVOID SystemSpecific2,
+ IN PVOID SystemSpecific3);
+#endif // RTMP_TIMER_TASK_SUPPORT //
+
+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 RTMP_TIMER_TASK_SUPPORT
+ RTMP_TIMER_TASK_HANDLE handle;
+ void *pAd;
+#endif // RTMP_TIMER_TASK_SUPPORT //
+}RALINK_TIMER_STRUCT, *PRALINK_TIMER_STRUCT;
+
+
+#ifdef RTMP_TIMER_TASK_SUPPORT
+typedef struct _RTMP_TIMER_TASK_ENTRY_
+{
+ RALINK_TIMER_STRUCT *pRaTimer;
+ struct _RTMP_TIMER_TASK_ENTRY_ *pNext;
+}RTMP_TIMER_TASK_ENTRY;
+
+
+#define TIMER_QUEUE_SIZE_MAX 128
+typedef struct _RTMP_TIMER_TASK_QUEUE_
+{
+ unsigned int status;
+ unsigned char *pTimerQPoll;
+ RTMP_TIMER_TASK_ENTRY *pQPollFreeList;
+ RTMP_TIMER_TASK_ENTRY *pQHead;
+ RTMP_TIMER_TASK_ENTRY *pQTail;
+}RTMP_TIMER_TASK_QUEUE;
+
+#define BUILD_TIMER_FUNCTION(_func) \
+void rtmp_timer_##_func(unsigned long data) \
+{ \
+ PRALINK_TIMER_STRUCT _pTimer = (PRALINK_TIMER_STRUCT)data; \
+ RTMP_TIMER_TASK_ENTRY *_pQNode; \
+ RTMP_ADAPTER *_pAd; \
+ \
+ _pTimer->handle = _func; \
+ _pAd = (RTMP_ADAPTER *)_pTimer->pAd; \
+ _pQNode = RtmpTimerQInsert(_pAd, _pTimer); \
+ if ((_pQNode == NULL) && (_pAd->TimerQ.status & RTMP_TASK_CAN_DO_INSERT)) \
+ RTMP_OS_Add_Timer(&_pTimer->TimerObj, OS_HZ); \
+}
+#else
+#define BUILD_TIMER_FUNCTION(_func) \
+void rtmp_timer_##_func(unsigned long data) \
+{ \
+ PRALINK_TIMER_STRUCT pTimer = (PRALINK_TIMER_STRUCT) data; \
+ \
+ _func(NULL, (PVOID) pTimer->cookie, NULL, pTimer); \
+ if (pTimer->Repeat) \
+ RTMP_OS_Add_Timer(&pTimer->TimerObj, pTimer->TimerValue); \
+}
+#endif // RTMP_TIMER_TASK_SUPPORT //
+
+
+DECLARE_TIMER_FUNCTION(MlmePeriodicExec);
+DECLARE_TIMER_FUNCTION(MlmeRssiReportExec);
+DECLARE_TIMER_FUNCTION(AsicRxAntEvalTimeout);
+DECLARE_TIMER_FUNCTION(APSDPeriodicExec);
+DECLARE_TIMER_FUNCTION(AsicRfTuningExec);
+
+
+#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);
+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 //
+
+
+
+
+#if defined(AP_LED) || defined(STA_LED)
+DECLARE_TIMER_FUNCTION(LedCtrlMain);
+#endif
+
+
+
+#endif // __RTMP_TIMER_H__ //
diff --git a/drivers/staging/rt3090/rtmp_type.h b/drivers/staging/rt3090/rtmp_type.h
new file mode 100644
index 000000000000..d8b571e6f801
--- /dev/null
+++ b/drivers/staging/rt3090/rtmp_type.h
@@ -0,0 +1,147 @@
+/*
+ *************************************************************************
+ * 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))
+
+#ifdef LINUX
+// 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;
+#endif // LINUX //
+
+typedef unsigned char * PUINT8;
+typedef unsigned short * PUINT16;
+typedef unsigned int * PUINT32;
+typedef unsigned long long * PUINT64;
+typedef int * PINT32;
+typedef long long * PINT64;
+
+// modified for fixing compile warning on Sigma 8634 platform
+typedef char STRING;
+typedef signed char CHAR;
+
+typedef signed short SHORT;
+typedef signed int INT;
+typedef signed long LONG;
+typedef signed long long LONGLONG;
+
+
+#ifdef LINUX
+typedef unsigned char UCHAR;
+typedef unsigned short USHORT;
+typedef unsigned int UINT;
+typedef unsigned long ULONG;
+#endif // LINUX //
+typedef unsigned long long ULONGLONG;
+
+typedef unsigned char BOOLEAN;
+#ifdef LINUX
+typedef void VOID;
+#endif // LINUX //
+
+typedef char * PSTRING;
+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;
+
+
+//
+// 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;
+
+
+typedef int NTSTATUS;
+
+
+#define STATUS_SUCCESS 0x00
+#define STATUS_UNSUCCESSFUL 0x01
+
+#endif // __RTMP_TYPE_H__ //
diff --git a/drivers/staging/rt3090/spectrum.h b/drivers/staging/rt3090/spectrum.h
new file mode 100644
index 000000000000..be9bae5b88c2
--- /dev/null
+++ b/drivers/staging/rt3090/spectrum.h
@@ -0,0 +1,234 @@
+/*
+ *************************************************************************
+ * 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"
+
+
+CHAR RTMP_GetTxPwr(
+ IN PRTMP_ADAPTER pAd,
+ IN HTTRANSMIT_SETTING HTTxMode);
+
+/*
+ ==========================================================================
+ 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 MakeMeasurementReqFrame(
+ IN PRTMP_ADAPTER pAd,
+ OUT PUCHAR pOutBuffer,
+ OUT PULONG pFrameLen,
+ IN UINT8 TotalLen,
+ IN UINT8 Category,
+ IN UINT8 Action,
+ IN UINT8 MeasureToken,
+ IN UINT8 MeasureReqMode,
+ IN UINT8 MeasureReqType,
+ IN UINT8 NumOfRepetitions);
+
+/*
+ ==========================================================================
+ 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 PSTRING arg);
+
+INT Set_TpcReq_Proc(
+ IN PRTMP_ADAPTER pAd,
+ IN PSTRING arg);
+
+INT Set_PwrConstraint(
+ IN PRTMP_ADAPTER pAd,
+ IN PSTRING arg);
+
+
+VOID MeasureReqTabInit(
+ IN PRTMP_ADAPTER pAd);
+
+VOID MeasureReqTabExit(
+ IN PRTMP_ADAPTER pAd);
+
+PMEASURE_REQ_ENTRY MeasureReqLookUp(
+ IN PRTMP_ADAPTER pAd,
+ IN UINT8 DialogToken);
+
+PMEASURE_REQ_ENTRY MeasureReqInsert(
+ IN PRTMP_ADAPTER pAd,
+ IN UINT8 DialogToken);
+
+VOID MeasureReqDelete(
+ IN PRTMP_ADAPTER pAd,
+ IN UINT8 DialogToken);
+
+VOID InsertChannelRepIE(
+ IN PRTMP_ADAPTER pAd,
+ OUT PUCHAR pFrameBuf,
+ OUT PULONG pFrameLen,
+ IN PSTRING pCountry,
+ IN UINT8 RegulatoryClass);
+
+VOID InsertTpcReportIE(
+ IN PRTMP_ADAPTER pAd,
+ OUT PUCHAR pFrameBuf,
+ OUT PULONG pFrameLen,
+ IN UINT8 TxPwr,
+ IN UINT8 LinkMargin);
+
+VOID InsertDialogToken(
+ IN PRTMP_ADAPTER pAd,
+ OUT PUCHAR pFrameBuf,
+ OUT PULONG pFrameLen,
+ IN UINT8 DialogToken);
+
+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);
+
+VOID RguClass_BuildBcnChList(
+ IN PRTMP_ADAPTER pAd,
+ OUT PUCHAR pBuf,
+ OUT PULONG pBufLen);
+#endif // __SPECTRUM_H__ //
diff --git a/drivers/staging/rt3090/spectrum_def.h b/drivers/staging/rt3090/spectrum_def.h
new file mode 100644
index 000000000000..0389b0921486
--- /dev/null
+++ b/drivers/staging/rt3090/spectrum_def.h
@@ -0,0 +1,257 @@
+/*
+ *************************************************************************
+ * 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 32
+#define MAX_HASH_MEASURE_REQ_TAB_SIZE MAX_MEASURE_REQ_TAB_SIZE
+
+#define MAX_TPC_REQ_TAB_SIZE 32
+#define MAX_HASH_TPC_REQ_TAB_SIZE MAX_TPC_REQ_TAB_SIZE
+
+#define MIN_RCV_PWR 100 /* Negative value ((dBm) */
+
+#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;
+
+
+/* The regulatory information */
+typedef struct _DOT11_CHANNEL_SET
+{
+ UCHAR NumberOfChannels;
+ UINT8 MaxTxPwr;
+ UCHAR ChannelList[16];
+} DOT11_CHANNEL_SET, *PDOT11_CHANNEL_SET;
+
+typedef struct _DOT11_REGULATORY_INFORMATION
+{
+ UCHAR RegulatoryClass;
+ DOT11_CHANNEL_SET ChannelSet;
+} DOT11_REGULATORY_INFORMATION, *PDOT11_REGULATORY_INFORMATION;
+
+
+
+#define RM_TPC_REQ 0
+#define RM_MEASURE_REQ 1
+
+#define RM_BASIC 0
+#define RM_CCA 1
+#define RM_RPI_HISTOGRAM 2
+#define RM_CH_LOAD 3
+#define RM_NOISE_HISTOGRAM 4
+
+
+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 :3;
+ UINT8 DurationMandatory:1;
+ UINT8 Report:1;
+ UINT8 Request:1;
+ UINT8 Enable:1;
+ UINT8 Parallel:1;
+ } field;
+#else
+ struct PACKED
+ {
+ UINT8 Parallel:1;
+ UINT8 Enable:1;
+ UINT8 Request:1;
+ UINT8 Report:1;
+ UINT8 DurationMandatory:1;
+ UINT8 :3;
+ } 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;
+ UINT8 Oct[0];
+} 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;
+ UINT8 ReportMode;
+ UINT8 ReportType;
+ UINT8 Octect[0];
+} MEASURE_REPORT_INFO, *PMEASURE_REPORT_INFO;
+
+typedef struct PACKED _QUIET_INFO
+{
+ UINT8 QuietCnt;
+ UINT8 QuietPeriod;
+ UINT16 QuietDuration;
+ UINT16 QuietOffset;
+} QUIET_INFO, *PQUIET_INFO;
+
+#endif // __SPECTRUM_DEF_H__ //
diff --git a/drivers/staging/rt3090/sta/assoc.c b/drivers/staging/rt3090/sta/assoc.c
new file mode 100644
index 000000000000..012ed2b06083
--- /dev/null
+++ b/drivers/staging/rt3090/sta/assoc.c
@@ -0,0 +1,1673 @@
+/*
+ *************************************************************************
+ * 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);
+ RTMP_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);
+ RTMP_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);
+ RTMP_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 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;
+ 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 != WPA_SUPPLICANT_ENABLE) &&
+ (pAd->StaCfg.bRSN_IE_FromWpaSupplicant == FALSE))
+#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 == WPA_SUPPLICANT_ENABLE) &&
+ (pAd->StaCfg.bRSN_IE_FromWpaSupplicant == TRUE))
+ {
+ 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 != WPA_SUPPLICANT_ENABLE) ||
+ (pAd->StaCfg.bRSN_IE_FromWpaSupplicant == FALSE))
+#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;
+ }
+
+
+ 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 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;
+ 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;
+ }
+
+ 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 = 500;
+ 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)
+ {
+ //send disassociate event to wpa_supplicant
+ RtmpOSWrielessEventSend(pAd, IWEVCUSTOM, RT_DISASSOC_EVENT_FLAG, NULL, NULL, 0);
+ }
+#endif // NATIVE_WPA_SUPPLICANT_SUPPORT //
+#endif // WPA_SUPPLICANT_SUPPORT //
+
+#ifdef NATIVE_WPA_SUPPLICANT_SUPPORT
+ RtmpOSWrielessEventSend(pAd, SIOCGIWAP, -1, NULL, NULL, 0);
+#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,
+ &AddHtInfo,
+ AddHtInfoLen,
+ CapabilityInfo);
+ }
+ 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)
+ {
+ SendAssocIEsToWpaSupplicant(pAd);
+ RtmpOSWrielessEventSend(pAd, IWEVCUSTOM, RT_ASSOC_EVENT_FLAG, NULL, NULL, 0);
+ }
+#endif // NATIVE_WPA_SUPPLICANT_SUPPORT //
+#endif // WPA_SUPPLICANT_SUPPORT //
+
+#ifdef NATIVE_WPA_SUPPLICANT_SUPPORT
+ {
+ wext_notify_event_assoc(pAd);
+ RtmpOSWrielessEventSend(pAd, SIOCGIWAP, -1, &pAd->MlmeAux.Bssid[0], NULL, 0);
+ }
+#endif // NATIVE_WPA_SUPPLICANT_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;
+ //KH need to check again
+ // Don't allow to go to sleep mode if authmode is WPA-related.
+ //This can make Authentication process more smoothly.
+ RTMP_CLEAR_PSFLAG(pAd, fRTMP_PS_CAN_GO_SLEEP);
+
+ 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);
+ }
+
+
+ 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)
+ {
+ //send disassociate event to wpa_supplicant
+ RtmpOSWrielessEventSend(pAd, IWEVCUSTOM, RT_DISASSOC_EVENT_FLAG, NULL, NULL, 0);
+ }
+#endif // NATIVE_WPA_SUPPLICANT_SUPPORT //
+#endif // WPA_SUPPLICANT_SUPPORT //
+
+#ifdef NATIVE_WPA_SUPPLICANT_SUPPORT
+ RtmpOSWrielessEventSend(pAd, SIOCGIWAP, -1, NULL, NULL, 0);
+#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);
+}
+
+#ifdef WPA_SUPPLICANT_SUPPORT
+#ifndef NATIVE_WPA_SUPPLICANT_SUPPORT
+VOID SendAssocIEsToWpaSupplicant(
+ IN PRTMP_ADAPTER pAd)
+{
+ STRING 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);
+ RtmpOSWrielessEventSend(pAd, IWEVCUSTOM, RT_REQIE_EVENT_FLAG, NULL, (PUCHAR)custom, pAd->StaCfg.ReqVarIELen + 17);
+
+ RtmpOSWrielessEventSend(pAd, IWEVCUSTOM, RT_ASSOCINFO_EVENT_FLAG, NULL, NULL, 0);
+ }
+ 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)
+{
+ char custom[IW_CUSTOM_MAX] = {0};
+
+#if WIRELESS_EXT > 17
+ if (pAd->StaCfg.ReqVarIELen <= IW_CUSTOM_MAX)
+ {
+ NdisMoveMemory(custom, pAd->StaCfg.ReqVarIEs, pAd->StaCfg.ReqVarIELen);
+ RtmpOSWrielessEventSend(pAd, IWEVASSOCREQIE, -1, NULL, custom, pAd->StaCfg.ReqVarIELen);
+ }
+ else
+ DBGPRINT(RT_DEBUG_TRACE, ("pAd->StaCfg.ReqVarIELen > MAX_CUSTOM_LEN\n"));
+#else
+ int len;
+
+ len = (pAd->StaCfg.ReqVarIELen*2) + 17;
+ if (len <= IW_CUSTOM_MAX)
+ {
+ UCHAR idx;
+ sprintf(custom, "ASSOCINFO(ReqIEs=");
+ for (idx=0; idx<pAd->StaCfg.ReqVarIELen; idx++)
+ sprintf(custom, "%s%02x", custom, pAd->StaCfg.ReqVarIEs[idx]);
+ RtmpOSWrielessEventSend(pAd, IWEVCUSTOM, -1, NULL, custom, len);
+ }
+ else
+ DBGPRINT(RT_DEBUG_TRACE, ("len(%d) > MAX_CUSTOM_LEN\n", len));
+#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 ADD_HT_INFO_IE *pAddHtInfo,
+ IN UCHAR AddHtInfoLen,
+ 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
+ NdisZeroMemory(&pEntry->HTCapability, sizeof(pEntry->HTCapability));
+ // 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) &&
+ ((pAd->StaCfg.BssType == BSS_INFRA) || ((pAd->StaCfg.BssType == BSS_ADHOC) && (pAddHtInfo->AddHtInfo.ExtChanOffset == pAd->CommonCfg.AddHTInfo.AddHtInfo.ExtChanOffset))))
+ {
+ 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);
+ NdisMoveMemory(&pEntry->HTCapability, pHtCapability, HtCapabilityLen);
+ }
+ else
+ {
+ pAd->MacTab.fAnyStationIsLegacy = TRUE;
+ }
+#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;
+}
diff --git a/drivers/staging/rt3090/sta/auth.c b/drivers/staging/rt3090/sta/auth.c
new file mode 100644
index 000000000000..157e2999fa19
--- /dev/null
+++ b/drivers/staging/rt3090/sta/auth.c
@@ -0,0 +1,491 @@
+/*
+ *************************************************************************
+ * 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);
+ RTMP_MLME_HANDLER(pAd);
+}
+
+
+/*
+ ==========================================================================
+ Description:
+
+ IRQL = DISPATCH_LEVEL
+
+ ==========================================================================
+ */
+VOID MlmeAuthReqAction(
+ IN PRTMP_ADAPTER pAd,
+ IN MLME_QUEUE_ELEM *Elem)
+{
+ if (AUTH_ReqSend(pAd, Elem, &pAd->MlmeAux.AuthTimer, "AUTH", 1, NULL, 0))
+ pAd->Mlme.AuthMachine.CurrState = AUTH_WAIT_SEQ2;
+ else
+ {
+ USHORT Status;
+
+ 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, (PCHAR)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)
+ {
+ pAd->Mlme.AuthMachine.CurrState = AUTH_REQ_IDLE;
+ 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
+ {
+ 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);
+}
+
+BOOLEAN AUTH_ReqSend(
+ IN PRTMP_ADAPTER pAd,
+ IN PMLME_QUEUE_ELEM pElem,
+ IN PRALINK_TIMER_STRUCT pAuthTimer,
+ IN PSTRING pSMName,
+ IN USHORT SeqNo,
+ IN PUCHAR pNewElement,
+ IN ULONG ElementLen)
+{
+ USHORT Alg, Seq, Status;
+ UCHAR Addr[6];
+ ULONG Timeout;
+ HEADER_802_11 AuthHdr;
+ BOOLEAN TimerCancelled;
+ NDIS_STATUS NStatus;
+ PUCHAR pOutBuffer = NULL;
+ ULONG FrameLen = 0, tmp = 0;
+
+ // Block all authentication request durning WPA block period
+ if (pAd->StaCfg.bBlockAssoc == TRUE)
+ {
+ DBGPRINT(RT_DEBUG_TRACE, ("%s - Block Auth request durning WPA block period!\n", pSMName));
+ 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, pElem->Msg, pElem->MsgLen, Addr, &Timeout, &Alg))
+ {
+ /* reset timer */
+ RTMPCancelTimer(pAuthTimer, &TimerCancelled);
+
+ COPY_MAC_ADDR(pAd->MlmeAux.Bssid, Addr);
+ pAd->MlmeAux.Alg = Alg;
+ Seq = SeqNo;
+ Status = MLME_SUCCESS;
+
+ NStatus = MlmeAllocateMemory(pAd, &pOutBuffer); //Get an unused nonpaged memory
+ if(NStatus != NDIS_STATUS_SUCCESS)
+ {
+ DBGPRINT(RT_DEBUG_TRACE, ("%s - MlmeAuthReqAction(Alg:%d) allocate memory failed\n", pSMName, 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 FALSE;
+ }
+
+ DBGPRINT(RT_DEBUG_TRACE, ("%s - Send AUTH request seq#1 (Alg=%d)...\n", pSMName, 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);
+
+ if (pNewElement && ElementLen)
+ {
+ MakeOutgoingFrame(pOutBuffer+FrameLen, &tmp,
+ ElementLen, pNewElement,
+ END_OF_ARGS);
+ FrameLen += tmp;
+ }
+
+ MiniportMMRequest(pAd, 0, pOutBuffer, FrameLen);
+ MlmeFreeMemory(pAd, pOutBuffer);
+
+ RTMPSetTimer(pAuthTimer, Timeout);
+ return TRUE;
+ }
+ else
+ {
+ DBGPRINT_ERR(("%s - MlmeAuthReqAction() sanity check failed\n", pSMName));
+ return FALSE;
+ }
+
+ return TRUE;
+}
diff --git a/drivers/staging/rt3090/sta/auth_rsp.c b/drivers/staging/rt3090/sta/auth_rsp.c
new file mode 100644
index 000000000000..207bfeada1e4
--- /dev/null
+++ b/drivers/staging/rt3090/sta/auth_rsp.c
@@ -0,0 +1,151 @@
+/*
+ *************************************************************************
+ * 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
+ RtmpOSWrielessEventSend(pAd, SIOCGIWAP, -1, NULL, NULL, 0);
+#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);
+ }
+ }
+ else
+ {
+ DBGPRINT(RT_DEBUG_TRACE,("AUTH_RSP - PeerDeauthAction() sanity check fail\n"));
+ }
+}
diff --git a/drivers/staging/rt3090/sta/connect.c b/drivers/staging/rt3090/sta/connect.c
new file mode 100644
index 000000000000..4aa35ee3ade1
--- /dev/null
+++ b/drivers/staging/rt3090/sta/connect.c
@@ -0,0 +1,2759 @@
+/*
+ *************************************************************************
+ * 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) \
+{ \
+ NdisZeroMemory((_pAd)->CommonCfg.Ssid, MAX_LEN_OF_SSID); \
+ (_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);
+
+ 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;
+ 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:
+ 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, (PUCHAR)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, (PSTRING) Elem->Msg, Elem->MsgLen, 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;
+
+ pAd->StaCfg.bAutoConnectByBssid = FALSE;
+
+ //
+ // 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, (PCHAR)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)
+ ) &&
+ (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
+ RtmpOSWrielessEventSend(pAd, SIOCGIWAP, -1, &pAd->MlmeAux.Bssid[0], NULL, 0);
+#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, (PSTRING) 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;
+
+ // find the desired BSS in the latest SCAN result table
+ BssIdx = BssTableSearch(&pAd->ScanTab, pOidBssid, pAd->MlmeAux.Channel);
+ if (BssIdx == BSS_NOT_FOUND)
+ {
+ MLME_SCAN_REQ_STRUCT ScanReq;
+
+ DBGPRINT(RT_DEBUG_TRACE, ("CNTL - BSSID not found. reply NDIS_STATUS_NOT_ACCEPTED\n"));
+ //pAd->Mlme.CntlMachine.CurrState = CNTL_IDLE;
+
+ DBGPRINT(RT_DEBUG_TRACE, ("CNTL - BSSID not found. start a new scan\n"));
+ ScanParmFill(pAd, &ScanReq, (PSTRING) 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
+ NdisGetSystemUpTime(&pAd->StaCfg.LastScanTime);
+ return;
+ }
+
+ //
+ // Update Reconnect Ssid, that user desired to connect.
+ //
+ NdisZeroMemory(pAd->MlmeAux.AutoReconnectSsid, MAX_LEN_OF_SSID);
+ pAd->MlmeAux.AutoReconnectSsidLen = pAd->ScanTab.BssEntry[BssIdx].SsidLen;
+ NdisMoveMemory(pAd->MlmeAux.AutoReconnectSsid, pAd->ScanTab.BssEntry[BssIdx].Ssid, pAd->ScanTab.BssEntry[BssIdx].SsidLen);
+
+ // 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));
+
+ // 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);
+
+ {
+ 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)
+{
+ UCHAR BBPValue = 0;
+
+ DBGPRINT(RT_DEBUG_TRACE,("CNTL - Roaming in MlmeAux.RoamTab...\n"));
+
+ {
+ //Let BBP register at 20MHz to do (fast) roaming.
+ RTMP_BBP_IO_READ8_BY_REG_ID(pAd, BBP_R4, &BBPValue);
+ BBPValue &= (~0x18);
+ RTMP_BBP_IO_WRITE8_BY_REG_ID(pAd, BBP_R4, BBPValue);
+
+ 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, (PCHAR)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
+ {
+ {
+ // 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, AUTH_MODE_KEY);
+ }
+ else
+ {
+ AuthParmFill(pAd, &AuthReq, pAd->MlmeAux.Bssid, AUTH_MODE_OPEN);
+ }
+ 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
+ NdisZeroMemory(&pAd->StaActive.SupportedPhyInfo.MCSSet[0], 16);
+ 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;
+ 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);
+
+ {
+ 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"));
+ {
+ 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, AUTH_MODE_KEY);
+ }
+ else
+ {
+ AuthParmFill(pAd, &AuthReq, pAd->MlmeAux.Bssid, AUTH_MODE_OPEN);
+ }
+ 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
+ {
+ 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)
+ {
+ if (pAd->CommonCfg.bWirelessEvent)
+ {
+ RTMPSendWirelessEvent(pAd, IW_ASSOC_EVENT_FLAG, pAd->MacTab.Content[BSSID_WCID].Addr, BSS0, 0);
+ }
+
+ LinkUp(pAd, BSS_INFRA);
+ pAd->Mlme.CntlMachine.CurrState = CNTL_IDLE;
+ DBGPRINT(RT_DEBUG_TRACE, ("CNTL - Association successful on BSS #%ld\n",pAd->MlmeAux.BssIdx));
+ }
+ 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)
+ {
+ // send wireless event - for association
+ if (pAd->CommonCfg.bWirelessEvent)
+ RTMPSendWirelessEvent(pAd, IW_ASSOC_EVENT_FLAG, pAd->MacTab.Content[BSSID_WCID].Addr, BSS0, 0);
+
+ //
+ // NDIS requires a new Link UP indication but no Link Down for RE-ASSOC
+ //
+ LinkUp(pAd, BSS_INFRA);
+
+ 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 = 0, HashIdx = 0;
+ MAC_TABLE_ENTRY *pEntry = NULL, *pCurrEntry = NULL;
+
+ // Init ChannelQuality to prevent DEAD_CQI at initial LinkUp
+ pAd->Mlme.ChannelQuality = 50;
+
+ pEntry = MacTableLookup(pAd, pAd->CommonCfg.Bssid);
+ if (pEntry)
+ {
+ MacTableDeleteEntry(pAd, pEntry->Aid, pEntry->Addr);
+ pEntry = NULL;
+ }
+
+
+ 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 //
+
+#ifdef RTMP_MAC_PCI
+ // 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);
+ if(pAd->Antenna.field.RxPath == 3)
+ {
+ Value |= (0x10);
+ }
+ else if(pAd->Antenna.field.RxPath == 2)
+ {
+ Value |= (0x8);
+ }
+ else if(pAd->Antenna.field.RxPath == 1)
+ {
+ Value |= (0x0);
+ }
+ RTMP_BBP_IO_WRITE8_BY_REG_ID(pAd, BBP_R3, Value);
+ pAd->StaCfg.BBPR3 = Value;
+#endif // RTMP_MAC_PCI //
+
+ 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);
+#ifdef RTMP_MAC_PCI
+ pAd->StaCfg.BBPR3 = Value;
+#endif // RTMP_MAC_PCI //
+
+ 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);
+#ifdef RTMP_MAC_PCI
+ pAd->StaCfg.BBPR3 = Value;
+#endif // RTMP_MAC_PCI //
+
+ 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);
+#ifdef RTMP_MAC_PCI
+ pAd->StaCfg.BBPR3 = Value;
+#endif // RTMP_MAC_PCI //
+
+ 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
+ RTMP_CLEAR_PSFLAG(pAd, fRTMP_PS_CAN_GO_SLEEP);
+ 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 = 1;
+ IV |= (pAd->StaCfg.DefaultKeyId << 30);
+ AsicUpdateWCIDIVEIV(pAd, BSSID_WCID, IV, 0);
+ //RTMP_CLEAR_PSFLAG(pAd, fRTMP_PS_CAN_GO_SLEEP);
+ }
+
+ // 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);
+
+ // 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);
+
+ pEntry->Aid = BSSID_WCID;
+ // 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);
+ }
+ else if ((pAd->StaCfg.AuthMode == Ndis802_11AuthModeWPAPSK) ||
+ (pAd->StaCfg.AuthMode == Ndis802_11AuthModeWPA2PSK))
+ {
+#ifdef WPA_SUPPLICANT_SUPPORT
+ if (pAd->StaCfg.WpaSupplicantUP == WPA_SUPPLICANT_DISABLE)
+#endif // WPA_SUPPLICANT_SUPPORT //
+ RTMPSetTimer(&pAd->Mlme.LinkDownTimer, LINK_DOWN_TIMEOUT);
+ }
+ // --
+
+ // Add BSSID in my MAC Table.
+ NdisAcquireSpinLock(&pAd->MacTabLock);
+ // add this MAC entry into HASH table
+ if (pEntry)
+ {
+ 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;
+ }
+ }
+ RTMPMoveMemory(pEntry->Addr, pAd->CommonCfg.Bssid, MAC_ADDR_LEN);
+ pEntry->Aid = BSSID_WCID;
+ pEntry->pAd = pAd;
+ pEntry->ValidAsCLI = TRUE; //Although this is bssid..still set ValidAsCl
+ pAd->MacTab.Size = 1; // infra mode always set MACtab size =1.
+ pEntry->Sst = SST_ASSOC;
+ pEntry->AuthState = SST_ASSOC;
+ pEntry->AuthMode = pAd->StaCfg.AuthMode;
+ pEntry->WepStatus = pAd->StaCfg.WepStatus;
+ if (pEntry->AuthMode < Ndis802_11AuthModeWPA)
+ {
+ pEntry->WpaState = AS_NOTUSE;
+ pEntry->PrivacyFilter = Ndis802_11PrivFilterAcceptAll;
+ }
+ else
+ {
+ pEntry->WpaState = AS_PTKSTART;
+ pEntry->PrivacyFilter = Ndis802_11PrivFilter8021xWEP;
+ }
+ 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 //
+
+
+ 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);
+ CLIENT_STATUS_SET_FLAG(pEntry, fCLIENT_STATUS_AGGREGATION_CAPABLE);
+ CLIENT_STATUS_SET_FLAG(pEntry, fCLIENT_STATUS_PIGGYBACK_CAPABLE);
+ RTMPSetPiggyBack(pAd, TRUE);
+ DBGPRINT(RT_DEBUG_TRACE, ("Turn on Piggy-Back\n"));
+ }
+ else if (pAd->MlmeAux.APRalinkIe & 0x00000001)
+ {
+ CLIENT_STATUS_SET_FLAG(pEntry, fCLIENT_STATUS_AGGREGATION_CAPABLE);
+ 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->CommonCfg.RxStream == 1)&&(pAd->CommonCfg.TxStream == 1)) &&
+ (pAd->StaCfg.bForceTxBurst == FALSE) &&
+ (((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)
+ {
+#ifdef WPA_SUPPLICANT_SUPPORT
+ if (pAd->StaCfg.WpaSupplicantUP &&
+ (pAd->StaCfg.WepStatus == Ndis802_11WEPEnabled) &&
+ (pAd->StaCfg.IEEE8021X == TRUE))
+ ;
+ else
+#endif // WPA_SUPPLICANT_SUPPORT //
+ {
+ 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);
+ 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 //
+}
+
+/*
+ ==========================================================================
+
+ 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;
+
+ BOOLEAN Cancelled;
+
+ // 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 //
+ RTMP_CLEAR_PSFLAG(pAd, fRTMP_PS_GO_TO_SLEEP_NOW);
+ //Comment the codes, beasue the line 2291 call the same function.
+ //RTMPCancelTimer(&pAd->Mlme.PsPollTimer, &Cancelled);
+ // Not allow go to sleep within linkdown function.
+ RTMP_CLEAR_PSFLAG(pAd, fRTMP_PS_CAN_GO_SLEEP);
+
+ 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);
+
+#ifdef RTMP_MAC_PCI
+ if (OPSTATUS_TEST_FLAG(pAd, fOP_STATUS_PCIE_DEVICE))
+ {
+ BOOLEAN Cancelled;
+ pAd->Mlme.bPsPollTimerRunning = FALSE;
+ RTMPCancelTimer(&pAd->Mlme.PsPollTimer, &Cancelled);
+ }
+
+ pAd->bPCIclkOff = FALSE;
+#endif // RTMP_MAC_PCI //
+
+ if (OPSTATUS_TEST_FLAG(pAd, fOP_STATUS_DOZE)
+|| RTMP_TEST_PSFLAG(pAd, fRTMP_PS_SET_PCI_CLK_OFF_COMMAND)
+ || RTMP_TEST_FLAG(pAd, fRTMP_ADAPTER_IDLE_RADIO_OFF))
+ {
+ AUTO_WAKEUP_STRUC AutoWakeupCfg;
+ AsicForceWakeup(pAd, TRUE);
+ AutoWakeupCfg.word = 0;
+ RTMP_IO_WRITE32(pAd, AUTO_WAKEUP_CFG, AutoWakeupCfg.word);
+ OPSTATUS_CLEAR_FLAG(pAd, fOP_STATUS_DOZE);
+ }
+#ifdef RTMP_MAC_PCI
+ pAd->bPCIclkOff = FALSE;
+#endif // RTMP_MAC_PCI //
+ 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);
+
+#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);
+ }
+
+ AsicSetSlotTime(pAd, TRUE); //FALSE);
+ AsicSetEdcaParm(pAd, NULL);
+
+ // Set LED
+ RTMPSetLED(pAd, LED_LINK_DOWN);
+ pAd->LedIndicatorStrength = 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);
+ NdisZeroMemory(&pAd->MacTab, sizeof(MAC_TABLE));
+ pAd->MacTab.Content[BSSID_WCID].PortSecured = pAd->StaCfg.PortSecured;
+ NdisReleaseSpinLock(&pAd->MacTabLock);
+
+ pAd->StaCfg.MicErrCnt = 0;
+
+ pAd->IndicateMediaState = NdisMediaStateDisconnected;
+ // Update extra information to link is up
+ pAd->ExtraInfo = GENERAL_LINK_DOWN;
+
+ pAd->StaActive.SupportedPhyInfo.bHtEnable = FALSE;
+
+
+ // 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);
+// Allow go to sleep after linkdown steps.
+ RTMP_SET_PSFLAG(pAd, fRTMP_PS_CAN_GO_SLEEP);
+#ifdef WPA_SUPPLICANT_SUPPORT
+#ifndef NATIVE_WPA_SUPPLICANT_SUPPORT
+ if (pAd->StaCfg.WpaSupplicantUP) {
+ //send disassociate event to wpa_supplicant
+ RtmpOSWrielessEventSend(pAd, IWEVCUSTOM, RT_DISASSOC_EVENT_FLAG, NULL, NULL, 0);
+ }
+#endif // NATIVE_WPA_SUPPLICANT_SUPPORT //
+#endif // WPA_SUPPLICANT_SUPPORT //
+
+#ifdef NATIVE_WPA_SUPPLICANT_SUPPORT
+ RtmpOSWrielessEventSend(pAd, SIOCGIWAP, -1, NULL, NULL, 0);
+#endif // NATIVE_WPA_SUPPLICANT_SUPPORT //
+
+#ifdef RT30xx
+ if ((IS_RT30xx(pAd) || IS_RT3090(pAd)||IS_RT3390(pAd))
+ &&(pAd->Antenna.field.RxPath>1||pAd->Antenna.field.TxPath>1))
+ {
+ RTMP_ASIC_MMPS_DISABLE(pAd);
+ }
+#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, (PCHAR)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
+ {
+
+#ifdef DOT11_N_SUPPORT
+#endif // DOT11_N_SUPPORT //
+ {
+ AsicSwitchChannel(pAd, pAd->CommonCfg.Channel, FALSE);
+ AsicLockChannel(pAd, pAd->CommonCfg.Channel);
+ DBGPRINT(RT_DEBUG_TRACE, ("CNTL - All roaming failed, restore to channel %d, Total BSS[%02d]\n",pAd->CommonCfg.Channel, pAd->ScanTab.BssNr));
+ }
+
+ 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
+ {
+
+#ifdef DOT11_N_SUPPORT
+#endif // DOT11_N_SUPPORT //
+ {
+ AsicSwitchChannel(pAd, pAd->CommonCfg.Channel, FALSE);
+ AsicLockChannel(pAd, pAd->CommonCfg.Channel);
+ DBGPRINT(RT_DEBUG_TRACE, ("CNTL - All roaming failed, restore to channel %d, Total BSS[%02d]\n",pAd->CommonCfg.Channel, pAd->ScanTab.BssNr));
+ }
+
+ 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 STRING 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 RTMP_MAC_PCI
+VOID ComposePsPoll(
+ IN PRTMP_ADAPTER pAd)
+{
+ NdisZeroMemory(&pAd->PsPollFrame, sizeof(PSPOLL_FRAME));
+ 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);
+}
+
+// IRQL = DISPATCH_LEVEL
+VOID ComposeNullFrame(
+ IN PRTMP_ADAPTER pAd)
+{
+ 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);
+}
+#endif // RTMP_MAC_PCI //
+
+
+
+
+/*
+ ==========================================================================
+ 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;
+ UCHAR *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;
+}
diff --git a/drivers/staging/rt3090/sta/dls.c b/drivers/staging/rt3090/sta/dls.c
new file mode 100644
index 000000000000..306e16fdeeae
--- /dev/null
+++ b/drivers/staging/rt3090/sta/dls.c
@@ -0,0 +1,2207 @@
+/*
+ *************************************************************************
+ * 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_TRACE, ("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)
+ {
+
+ DBGPRINT(RT_DEBUG_OFF, ("@@@ 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_TRACE, ("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)
+ {
+ DBGPRINT(RT_DEBUG_OFF, ("@@@ 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 (Len < LENGTH_802_11 + 6 + 2) /* LENGTH_802_11 + LLC + EAPOL protocol type */
+ return bSTAKeyFrame;
+
+ pProto = (PUCHAR)pHeader + LENGTH_802_11;
+
+ if ((pHeader->FC.SubType & 0x08))
+ pProto += 2; /* QOS Control field */
+
+ /* Skip 4-bytes for HTC */
+ if (pHeader->FC.Order && (!OPSTATUS_TEST_FLAG(pAd, fOP_STATUS_AGGREGATION_INUSED)))
+ {
+ pProto += 4;
+ }
+
+ /* L2PAD bit on will pad 2 bytes at LLC */
+ if (pRxD->L2PAD)
+ {
+ pProto += 2;
+ }
+
+ pProto += 6; /* 0xAA 0xAA 0xAA 0x00 0x00 0x00 */
+
+ if ((!(pHeader->FC.SubType & 0x08)) && (!RTMPEqualMemory(EAPOL, pProto, 2)))
+ return bSTAKeyFrame;
+
+ pAddr = pHeader->Addr2;
+
+ 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);
+ WpaDerivePTK(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(DlsPTK, LEN_EAP_MICK, (PUCHAR) pEap, pEap->Body_Len[1] + 4, digest, SHA1_DIGEST_SIZE);
+ NdisMoveMemory(Mic, digest, LEN_KEY_DESC_MIC);
+ }
+ else
+ {
+ HMAC_MD5(DlsPTK, LEN_EAP_MICK, (PUCHAR) pEap, pEap->Body_Len[1] + 4, Mic, MD5_DIGEST_SIZE);
+ }
+
+ 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 ((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 (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;
+ if (pAd->StaCfg.PairCipher == Ndis802_11Encryption2Enabled)
+ PairwiseKey.CipherAlg = CIPHER_TKIP;
+ else if (pAd->StaCfg.PairCipher == Ndis802_11Encryption3Enabled)
+ PairwiseKey.CipherAlg = CIPHER_AES;
+
+ 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 RTMP_MAC_PCI
+ AsicAddPairwiseKeyEntry(pAd,
+ pAd->StaCfg.DLSEntry[i].MacAddr,
+ (UCHAR)pAd->StaCfg.DLSEntry[i].MacTabMatchWCID,
+ &PairwiseKey);
+
+ RTMPAddWcidAttributeEntry(pAd,
+ BSS0,
+ 0,
+ PairwiseKey.CipherAlg,
+ pEntry);
+
+#endif // RTMP_MAC_PCI //
+ 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;
+ if (pAd->StaCfg.PairCipher == Ndis802_11Encryption2Enabled)
+ PairwiseKey.CipherAlg = CIPHER_TKIP;
+ else if (pAd->StaCfg.PairCipher == Ndis802_11Encryption3Enabled)
+ PairwiseKey.CipherAlg = CIPHER_AES;
+
+ 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 RTMP_MAC_PCI
+ AsicAddPairwiseKeyEntry(pAd,
+ pAd->StaCfg.DLSEntry[i].MacAddr,
+ (UCHAR)pAd->StaCfg.DLSEntry[i].MacTabMatchWCID,
+ &PairwiseKey);
+
+ RTMPAddWcidAttributeEntry(pAd,
+ BSS0,
+ 0,
+ PairwiseKey.CipherAlg,
+ pEntry);
+#endif // RTMP_MAC_PCI //
+ 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);
+ WpaDerivePTK(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(DlsPTK, LEN_EAP_MICK, pOutBuffer, FrameLen, digest, SHA1_DIGEST_SIZE);
+ NdisMoveMemory(Packet.KeyDesc.KeyMic, digest, LEN_KEY_DESC_MIC);
+ }
+ else
+ {
+ NdisZeroMemory(Mic, sizeof(Mic));
+ HMAC_MD5(DlsPTK, LEN_EAP_MICK, pOutBuffer, FrameLen, Mic, MD5_DIGEST_SIZE);
+ 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);
+ WpaDerivePTK(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(DlsPTK, LEN_EAP_MICK, pOutBuffer, FrameLen, digest, SHA1_DIGEST_SIZE);
+ NdisMoveMemory(Packet.KeyDesc.KeyMic, digest, LEN_KEY_DESC_MIC);
+ }
+ else
+ {
+ NdisZeroMemory(Mic, sizeof(Mic));
+ HMAC_MD5(DlsPTK, LEN_EAP_MICK, pOutBuffer, FrameLen, Mic, MD5_DIGEST_SIZE);
+ 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);
+ RTMP_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) && (pAd->StaCfg.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;
+
+ DBGPRINT(RT_DEBUG_OFF, ("\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];
+
+ DBGPRINT(RT_DEBUG_OFF, ("%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]));
+ DBGPRINT(RT_DEBUG_OFF, ("%-8d\n", pAd->StaCfg.DLSEntry[i].TimeOut));
+
+ DBGPRINT(RT_DEBUG_OFF, ("\n"));
+ DBGPRINT(RT_DEBUG_OFF, ("\n%-19s%-4s%-4s%-4s%-4s%-7s%-7s%-7s","MAC", "AID", "BSS", "PSM", "WMM", "RSSI0", "RSSI1", "RSSI2"));
+#ifdef DOT11_N_SUPPORT
+ DBGPRINT(RT_DEBUG_OFF, ("%-8s%-10s%-6s%-6s%-6s%-6s", "MIMOPS", "PhMd", "BW", "MCS", "SGI", "STBC"));
+#endif // DOT11_N_SUPPORT //
+ DBGPRINT(RT_DEBUG_OFF, ("\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]));
+ DBGPRINT(RT_DEBUG_OFF, ("%-4d", (int)pEntry->Aid));
+ DBGPRINT(RT_DEBUG_OFF, ("%-4d", (int)pEntry->apidx));
+ DBGPRINT(RT_DEBUG_OFF, ("%-4d", (int)pEntry->PsMode));
+ DBGPRINT(RT_DEBUG_OFF, ("%-4d", (int)CLIENT_STATUS_TEST_FLAG(pEntry, fCLIENT_STATUS_WMM_CAPABLE)));
+ DBGPRINT(RT_DEBUG_OFF, ("%-7d", pEntry->RssiSample.AvgRssi0));
+ DBGPRINT(RT_DEBUG_OFF, ("%-7d", pEntry->RssiSample.AvgRssi1));
+ DBGPRINT(RT_DEBUG_OFF, ("%-7d", pEntry->RssiSample.AvgRssi2));
+#ifdef DOT11_N_SUPPORT
+ DBGPRINT(RT_DEBUG_OFF, ("%-8d", (int)pEntry->MmpsMode));
+ DBGPRINT(RT_DEBUG_OFF, ("%-10s", GetPhyMode(pEntry->HTPhyMode.field.MODE)));
+ DBGPRINT(RT_DEBUG_OFF, ("%-6s", GetBW(pEntry->HTPhyMode.field.BW)));
+ DBGPRINT(RT_DEBUG_OFF, ("%-6d", pEntry->HTPhyMode.field.MCS));
+ DBGPRINT(RT_DEBUG_OFF, ("%-6d", pEntry->HTPhyMode.field.ShortGI));
+ DBGPRINT(RT_DEBUG_OFF, ("%-6d", pEntry->HTPhyMode.field.STBC));
+#endif // DOT11_N_SUPPORT //
+ DBGPRINT(RT_DEBUG_OFF, ("%-10d, %d, %d%%\n", pEntry->DebugFIFOCount, pEntry->DebugTxCount,
+ (pEntry->DebugTxCount) ? ((pEntry->DebugTxCount-pEntry->DebugFIFOCount)*100/pEntry->DebugTxCount) : 0));
+ DBGPRINT(RT_DEBUG_OFF, ("\n"));
+
+ }
+ }
+
+ return TRUE;
+}
+
+INT Set_DlsAddEntry_Proc(
+ IN PRTMP_ADAPTER pAd,
+ IN PSTRING arg)
+{
+ UCHAR mac[MAC_ADDR_LEN];
+ USHORT Timeout;
+ PSTRING token;
+ STRING 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 = (USHORT) 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, (&mac[i]), 1);
+ }
+ if(i != 6)
+ return FALSE;
+
+ DBGPRINT(RT_DEBUG_OFF, ("\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 PSTRING arg)
+{
+ UCHAR macAddr[MAC_ADDR_LEN];
+ PSTRING 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);
+ }
+
+ DBGPRINT(RT_DEBUG_OFF, ("\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/rt3090/sta/rtmp_ckipmic.c b/drivers/staging/rt3090/sta/rtmp_ckipmic.c
new file mode 100644
index 000000000000..5f6dbd7cf057
--- /dev/null
+++ b/drivers/staging/rt3090/sta/rtmp_ckipmic.c
@@ -0,0 +1,579 @@
+/*
+ *************************************************************************
+ * 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.c
+
+ Abstract:
+ Data path subroutines
+
+ Revision History:
+ Who When What
+ -------- ---------- ----------------------------------------------
+*/
+
+#include "../rt_config.h"
+#include "../rtmp_ckipmic.h"
+
+
+#define MIC_ACCUM(v) pContext->accum += (ULONGLONG)v * RTMPMicGetCoefficient(pContext)
+#define GB(p,i,s) ( ((ULONG) *((UCHAR*)(p)+i) ) << (s) )
+#define GETBIG32(p) GB(p,0,24)|GB(p,1,16)|GB(p,2,8)|GB(p,3,0)
+
+/*****************************/
+/******** 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
+};
+
+/*===========================================================================*/
+/*=================== CKIP KEY PERMUTATION ==================================*/
+/*===========================================================================*/
+
+/* 2-byte by 2-byte subset of the full AES table */
+static const USHORT 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
+ };
+
+#define Lo8(v16) ((v16) & 0xFF)
+#define Hi8(v16) (((v16) >> 8) & 0xFF)
+#define u16Swap(i) ( (((i) >> 8) & 0xFF) | (((i) << 8) & 0xFF00) )
+#define _S_(i) (Sbox[Lo8(i)] ^ u16Swap(Sbox[Hi8(i)]))
+
+#define rotLeft_1(x) ((((x) << 1) | ((x) >> 15)) & 0xFFFF)
+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 */
+ )
+{
+ int i;
+ USHORT H[2], tmp; /* H=32-bits of per-packet hash value */
+ USHORT L[8], R[8]; /* L=u16 array of CK, R=u16 array of PK */
+
+ /* build L from input key */
+ memset(L, 0, sizeof(L));
+ for (i=0; i<16; i++) {
+ L[i>>1] |= ( ((USHORT)(CK[i])) << ( i & 1 ? 8 : 0) );
+ }
+
+ H[0] = (((USHORT)piv[0]) << 8) + piv[1];
+ H[1] = ( ((USHORT)toDsFromDs) << 8) | piv[2];
+
+ for (i=0; i<8; i++) {
+ H[0] ^= L[i]; /* 16-bits of key material */
+ tmp = _S_(H[0]); /* 16x16 permutation */
+ H[0] = tmp ^ H[1]; /* set up for next round */
+ H[1] = tmp;
+ R[i] = H[0]; /* store into key array */
+ }
+
+ /* sweep in the other direction */
+ tmp=L[0];
+ for (i=7; i>0; i--) {
+ R[i] = tmp = rotLeft_1(tmp) + R[i];
+ }
+
+ /* IV of the permuted key is unchanged */
+ PK[0] = piv[0];
+ PK[1] = piv[1];
+ PK[2] = piv[2];
+
+ /* key portion of the permuted key is changed */
+ for (i=3; i<16; i++) {
+ PK[i] = (UCHAR) (R[i>>1] >> (i & 1 ? 8 : 0));
+ }
+}
+
+/* prepare for calculation of a new mic */
+VOID RTMPCkipMicInit(
+ IN PMIC_CONTEXT pContext,
+ IN PUCHAR CK)
+{
+ /* prepare for new mic calculation */
+ NdisMoveMemory(pContext->CK, CK, sizeof(pContext->CK));
+ pContext->accum = 0;
+ pContext->position = 0;
+}
+
+/* add some bytes to the mic calculation */
+VOID RTMPMicUpdate(
+ IN PMIC_CONTEXT pContext,
+ IN PUCHAR pOctets,
+ IN INT len)
+{
+ INT byte_position;
+ ULONG val;
+
+ byte_position = (pContext->position & 3);
+ while (len > 0) {
+ /* build a 32-bit word for MIC multiply accumulate */
+ do {
+ if (len == 0) return;
+ pContext->part[byte_position++] = *pOctets++;
+ pContext->position++;
+ len--;
+ } while (byte_position < 4);
+ /* have a full 32-bit word to process */
+ val = GETBIG32(&pContext->part[0]);
+ MIC_ACCUM(val);
+ byte_position = 0;
+ }
+}
+
+ULONG RTMPMicGetCoefficient(
+ IN PMIC_CONTEXT pContext)
+{
+ UCHAR aes_counter[16];
+ INT coeff_position;
+ UCHAR *p;
+
+ coeff_position = (pContext->position - 1) >> 2;
+ if ( (coeff_position & 3) == 0) {
+ /* fetching the first coefficient -- get new 16-byte aes counter output */
+ u32 counter = (coeff_position >> 2);
+
+ /* new counter value */
+ memset(&aes_counter[0], 0, sizeof(aes_counter));
+ aes_counter[15] = (UINT8)(counter >> 0);
+ aes_counter[14] = (UINT8)(counter >> 8);
+ aes_counter[13] = (UINT8)(counter >> 16);
+ aes_counter[12] = (UINT8)(counter >> 24);
+
+ RTMPAesEncrypt(&pContext->CK[0], &aes_counter[0], pContext->coefficient);
+ }
+ p = &(pContext->coefficient[ (coeff_position & 3) << 2 ]);
+ return GETBIG32(p);
+}
+
+/****************************************/
+/* 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];
+ }
+}
+
+UCHAR RTMPCkipSbox(
+ IN UCHAR a)
+{
+ return SboxTable[(int)a];
+}
+
+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 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 byte_sub(
+ IN PUCHAR in,
+ OUT PUCHAR out)
+{
+ INT i;
+
+ for (i=0; i< 16; i++)
+ {
+ out[i] = RTMPCkipSbox(in[i]);
+ }
+}
+
+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);
+}
+
+VOID RTMPAesEncrypt(
+ IN PUCHAR key,
+ IN PUCHAR data,
+ IN PUCHAR ciphertext)
+{
+ INT round;
+ INT i;
+ UCHAR intermediatea[16];
+ UCHAR intermediateb[16];
+ UCHAR 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);
+ }
+ }
+
+}
+
+/* calculate the mic */
+VOID RTMPMicFinal(
+ IN PMIC_CONTEXT pContext,
+ OUT UCHAR digest[4])
+{
+ INT byte_position;
+ ULONG val;
+ ULONGLONG sum, utmp;
+ LONGLONG stmp;
+
+ /* deal with partial 32-bit word left over from last update */
+ if ( (byte_position = (pContext->position & 3)) != 0) {
+ /* have a partial word in part to deal with -- zero unused bytes */
+ do {
+ pContext->part[byte_position++] = 0;
+ pContext->position++;
+ } while (byte_position < 4);
+ val = GETBIG32(&pContext->part[0]);
+ MIC_ACCUM(val);
+ }
+
+ /* reduce the accumulated u64 to a 32-bit MIC */
+ sum = pContext->accum;
+ stmp = (sum & 0xffffffffL) - ((sum >> 32) * 15);
+ utmp = (stmp & 0xffffffffL) - ((stmp >> 32) * 15);
+ sum = utmp & 0xffffffffL;
+ if (utmp > 0x10000000fL)
+ sum -= 15;
+
+ val = (ULONG)sum;
+ digest[0] = (UCHAR)((val>>24) & 0xFF);
+ digest[1] = (UCHAR) ((val>>16) & 0xFF);
+ digest[2] = (UCHAR) ((val>>8) & 0xFF);
+ digest[3] = (UCHAR)((val>>0) & 0xFF);
+}
+
+VOID RTMPCkipInsertCMIC(
+ IN PRTMP_ADAPTER pAd,
+ OUT PUCHAR pMIC,
+ IN PUCHAR p80211hdr,
+ IN PNDIS_PACKET pPacket,
+ IN PCIPHER_KEY pKey,
+ IN PUCHAR mic_snap)
+{
+ PACKET_INFO PacketInfo;
+ PUCHAR pSrcBufVA;
+ ULONG SrcBufLen;
+ PUCHAR pDA, pSA, pProto;
+ UCHAR bigethlen[2];
+ UCHAR ckip_ck[16];
+ MIC_CONTEXT mic_ctx;
+ USHORT payloadlen;
+ UCHAR i;
+
+ if (pKey == NULL)
+ {
+ DBGPRINT_ERR(("RTMPCkipInsertCMIC, Before to form the CKIP key (CK), pKey can't be NULL\n"));
+ return;
+ }
+
+ switch (*(p80211hdr+1) & 3)
+ {
+ case 0: /* FromDs=0, ToDs=0 */
+ pDA = p80211hdr+4;
+ pSA = p80211hdr+10;
+ break;
+ case 1: /* FromDs=0, ToDs=1 */
+ pDA = p80211hdr+16;
+ pSA = p80211hdr+10;
+ break;
+ case 2: /* FromDs=1, ToDs=0 */
+ pDA = p80211hdr+4;
+ pSA = p80211hdr+16;
+ break;
+ case 3: /* FromDs=1, ToDs=1 */
+ pDA = p80211hdr+16;
+ pSA = p80211hdr+24;
+ break;
+ }
+
+ RTMP_QueryPacketInfo(pPacket, &PacketInfo, &pSrcBufVA, &SrcBufLen);
+
+ if (SrcBufLen < LENGTH_802_3)
+ return;
+
+ pProto = pSrcBufVA + 12;
+ payloadlen = PacketInfo.TotalPacketLength - LENGTH_802_3 + 18; // CKIP_LLC(8)+CMIC(4)+TxSEQ(4)+PROTO(2)=18
+
+ bigethlen[0] = (unsigned char)(payloadlen >> 8);
+ bigethlen[1] = (unsigned char)payloadlen;
+
+ //
+ // Encryption Key expansion to form the CKIP Key (CKIP_CK).
+ //
+ if (pKey->KeyLen < 16)
+ {
+ for(i = 0; i < (16 / pKey->KeyLen); i++)
+ {
+ NdisMoveMemory(ckip_ck + i * pKey->KeyLen,
+ pKey->Key,
+ pKey->KeyLen);
+ }
+ NdisMoveMemory(ckip_ck + i * pKey->KeyLen,
+ pKey->Key,
+ 16 - (i * pKey->KeyLen));
+ }
+ else
+ {
+ NdisMoveMemory(ckip_ck, pKey->Key, pKey->KeyLen);
+ }
+ RTMPCkipMicInit(&mic_ctx, ckip_ck);
+ RTMPMicUpdate(&mic_ctx, pDA, MAC_ADDR_LEN); // MIC <-- DA
+ RTMPMicUpdate(&mic_ctx, pSA, MAC_ADDR_LEN); // MIC <-- SA
+ RTMPMicUpdate(&mic_ctx, bigethlen, 2); // MIC <-- payload length starting from CKIP SNAP
+ RTMPMicUpdate(&mic_ctx, mic_snap, 8); // MIC <-- snap header
+ RTMPMicUpdate(&mic_ctx, pAd->StaCfg.TxSEQ, 4); // MIC <-- TxSEQ
+ RTMPMicUpdate(&mic_ctx, pProto, 2); // MIC <-- Protocol
+
+ pSrcBufVA += LENGTH_802_3;
+ SrcBufLen -= LENGTH_802_3;
+
+ // Mic <-- original payload. loop until all payload processed
+ do
+ {
+ if (SrcBufLen > 0)
+ RTMPMicUpdate(&mic_ctx, pSrcBufVA, SrcBufLen);
+
+ NdisGetNextBuffer(PacketInfo.pFirstBuffer, &PacketInfo.pFirstBuffer);
+ if (PacketInfo.pFirstBuffer)
+ {
+ NDIS_QUERY_BUFFER(PacketInfo.pFirstBuffer, &pSrcBufVA, &SrcBufLen);
+ }
+ else
+ break;
+ } while (TRUE);
+
+ RTMPMicFinal(&mic_ctx, pMIC); // update MIC
+}
diff --git a/drivers/staging/rt3090/sta/rtmp_data.c b/drivers/staging/rt3090/sta/rtmp_data.c
new file mode 100644
index 000000000000..559136409ff2
--- /dev/null
+++ b/drivers/staging/rt3090/sta/rtmp_data.c
@@ -0,0 +1,2661 @@
+/*
+ *************************************************************************
+ * 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
+ -------- ---------- ----------------------------------------------
+*/
+
+#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 RTMP_MAC_PCI
+ MAC_TABLE_ENTRY *pEntry = &pAd->MacTab.Content[BSSID_WCID];
+
+ // Set key material and cipherAlg to Asic
+ AsicAddSharedKeyEntry(pAd, BSS0, idx, CipherAlg, Key, NULL, NULL);
+
+ // Assign group key info
+ RTMPAddWcidAttributeEntry(pAd, BSS0, idx, CipherAlg, NULL);
+
+ // Assign pairwise key info
+ RTMPAddWcidAttributeEntry(pAd, BSS0, idx, CipherAlg, pEntry);
+
+ pAd->IndicateMediaState = NdisMediaStateConnected;
+ pAd->ExtraInfo = GENERAL_LINK_UP;
+#endif // RTMP_MAC_PCI //
+ // 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_INFO,("bAPSDCapable\n"));
+
+ // Qos bit 4
+ pData = (PUCHAR)pHeader + LENGTH_802_11;
+ if ((*pData >> 4) & 0x01)
+ {
+ DBGPRINT(RT_DEBUG_INFO,("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;
+
+ RTMP_SET_PSM_BIT(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;
+
+ /* check if need to resend PS Poll when received packet with MoreData = 1 */
+ if ((pAd->StaCfg.Psm == PWR_SAVE) && (pHeader->FC.MoreData == 1))
+ {
+ if ((((UserPriority == 0) || (UserPriority == 3)) &&
+ pAd->CommonCfg.bAPSDAC_BE == 0) ||
+ (((UserPriority == 1) || (UserPriority == 2)) &&
+ pAd->CommonCfg.bAPSDAC_BK == 0) ||
+ (((UserPriority == 4) || (UserPriority == 5)) &&
+ pAd->CommonCfg.bAPSDAC_VI == 0) ||
+ (((UserPriority == 6) || (UserPriority == 7)) &&
+ pAd->CommonCfg.bAPSDAC_VO == 0))
+ {
+ /* non-UAPSD delivery-enabled AC */
+ RTMP_PS_POLL_ENQUEUE(pAd);
+ }
+ }
+
+ // 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 // AGGREGATION_SUPPORT //
+ {
+#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
+ {
+
+
+ /* check if need to resend PS Poll when received packet with MoreData = 1 */
+ if ((pAd->StaCfg.Psm == PWR_SAVE) && (pHeader->FC.MoreData == 1))
+ {
+ /* for UAPSD, all management frames will be VO priority */
+ if (pAd->CommonCfg.bAPSDAC_VO == 0)
+ {
+ /* non-UAPSD delivery-enabled AC */
+ RTMP_PS_POLL_ENQUEUE(pAd);
+ }
+ }
+
+ /* TODO: if MoreData == 0, station can go to sleep */
+
+
+ // 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
+#ifdef ANT_DIVERSITY_SUPPORT
+ // collect rssi information for antenna diversity
+ if ((pAd->NicConfig2.field.AntDiversity) &&
+ (pAd->CommonCfg.bRxAntDiversity != ANT_DIVERSITY_DISABLE))
+ {
+ 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 // ANT_DIVERSITY_SUPPORT //
+#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;
+ }
+
+#ifdef RTMP_MAC_PCI
+ if (RxProcessed++ > MAX_RX_PROCESS_CNT)
+ {
+ // need to reschedule rx handle
+ bReschedule = TRUE;
+ break;
+ }
+#endif // RTMP_MAC_PCI //
+
+ 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.OneSecReceivedByteCount += 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;
+ }
+
+ /* STARxDoneInterruptHandle() is called 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 //
+ )
+ && ((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);
+ if (NumberOfFrag > 1)
+ RTSRequired = (pAd->CommonCfg.FragmentThreshold > pAd->CommonCfg.RtsThreshold) ? 1 : 0;
+ else
+ RTSRequired = (PacketInfo.TotalPacketLength > pAd->CommonCfg.RtsThreshold) ? 1 : 0;
+
+ // Save RTS requirement to Ndis packet reserved field
+ RTMP_SET_PACKET_RTS(pPacket, RTSRequired);
+ 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
+ /*
+ Under WMM ACM control, we dont need to check the bit;
+ Or when a TSPEC is built for VO but we will change to issue
+ BA session for BE here, so we will not use BA to send VO packets.
+ */
+ 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
+ {
+ InsertTailQueueAc(pAd, pEntry, &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_11WEPEnabled && pEntry->WepStatus != Ndis802_11Encryption2Enabled))
+ )
+ {
+ BAOriSessionSetUp(pAd, pEntry, UserPriority, 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 RTMP_MAC_PCI
+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;
+
+ switch (QueIdx)
+ {
+ case QID_AC_BK:
+ case QID_AC_BE:
+ case QID_AC_VI:
+ case QID_AC_VO:
+ /*case QID_HCCA:*/
+ if (pAd->TxRing[QueIdx].TxSwFreeIdx > pAd->TxRing[QueIdx].TxCpuIdx)
+ FreeNumber = pAd->TxRing[QueIdx].TxSwFreeIdx - pAd->TxRing[QueIdx].TxCpuIdx - 1;
+ else
+ FreeNumber = pAd->TxRing[QueIdx].TxSwFreeIdx + TX_RING_SIZE - pAd->TxRing[QueIdx].TxCpuIdx - 1;
+
+ if (FreeNumber >= NumberRequired)
+ Status = NDIS_STATUS_SUCCESS;
+ break;
+
+ case QID_MGMT:
+ if (pAd->MgmtRing.TxSwFreeIdx > pAd->MgmtRing.TxCpuIdx)
+ FreeNumber = pAd->MgmtRing.TxSwFreeIdx - pAd->MgmtRing.TxCpuIdx - 1;
+ else
+ FreeNumber = pAd->MgmtRing.TxSwFreeIdx + MGMT_RING_SIZE - pAd->MgmtRing.TxCpuIdx - 1;
+
+ if (FreeNumber >= NumberRequired)
+ Status = NDIS_STATUS_SUCCESS;
+ break;
+
+ default:
+ DBGPRINT(RT_DEBUG_ERROR,("RTMPFreeTXDRequest::Invalid QueIdx(=%d)\n", QueIdx));
+ break;
+ }
+ *FreeNumberIs = (UCHAR)FreeNumber;
+
+ return (Status);
+}
+#endif // RTMP_MAC_PCI //
+
+
+
+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)
+ {
+ 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 = (PUCHAR)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_PACKET(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 = (PUCHAR) 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 = (PUCHAR) 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
+ //
+ if (!RTMP_TEST_PSFLAG(pAd, fRTMP_PS_DISABLE_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
+ //
+ if (!RTMP_TEST_PSFLAG(pAd, fRTMP_PS_DISABLE_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) | (pAd->CommonCfg.AckPolicy[pTxBlk->QueIdx]<<5));
+ *(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 = (PUCHAR) 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
+ //
+ if (!RTMP_TEST_PSFLAG(pAd, fRTMP_PS_DISABLE_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
+ //
+ if (!RTMP_TEST_PSFLAG(pAd, fRTMP_PS_DISABLE_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;
+ HTTRANSMIT_SETTING *pTransmit;
+
+
+ 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 = (PUCHAR) 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)
+ {
+ RTMPCalculateMICValue(pAd, pTxBlk->pPacket, pTxBlk->pExtraLlcSnapEncap, pTxBlk->pKey, 0);
+
+ // 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;
+
+ pTransmit = pTxBlk->pTransmit;
+ // Decide the TX rate
+ if (pTransmit->field.MODE == MODE_CCK)
+ pTxBlk->TxRate = pTransmit->field.MCS;
+ else if (pTransmit->field.MODE == MODE_OFDM)
+ pTxBlk->TxRate = pTransmit->field.MCS + RATE_FIRST_OFDM_RATE;
+ else
+ pTxBlk->TxRate = RATE_6_5;
+
+ // decide how much time an ACK/CTS frame will consume in the air
+ if (pTxBlk->TxRate <= RATE_LAST_OFDM_RATE)
+ AckDuration = RTMPCalcDuration(pAd, pAd->CommonCfg.ExpectedACKRate[pTxBlk->TxRate], 14);
+ else
+ AckDuration = RTMPCalcDuration(pAd, RATE_6_5, 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
+ //
+ if (!RTMP_TEST_PSFLAG(pAd, fRTMP_PS_DISABLE_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_INFO, ("AsicForceWakeup At HardTx\n"));
+#ifdef RTMP_MAC_PCI
+ AsicForceWakeup(pAd, TRUE);
+#endif // RTMP_MAC_PCI //
+ }
+
+ // 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))
+ RTMP_SET_PSM_BIT(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);
+ }
+}
diff --git a/drivers/staging/rt3090/sta/sanity.c b/drivers/staging/rt3090/sta/sanity.c
new file mode 100644
index 000000000000..aeda15bd5bca
--- /dev/null
+++ b/drivers/staging/rt3090/sta/sanity.c
@@ -0,0 +1,382 @@
+/*
+ *************************************************************************
+ * 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 = (PCHAR)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_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 = (PUCHAR)&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
+ }
+ }
+ 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);
+ }
+
+
+ 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;
+}
diff --git a/drivers/staging/rt3090/sta/sync.c b/drivers/staging/rt3090/sta/sync.c
new file mode 100644
index 000000000000..2520e038cb82
--- /dev/null
+++ b/drivers/staging/rt3090/sta/sync.c
@@ -0,0 +1,1840 @@
+/*
+ *************************************************************************
+ * 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);
+ RTMP_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))
+ {
+ RTMP_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++;
+
+#ifdef RTMP_MAC_PCI
+ if ((OPSTATUS_TEST_FLAG(pAd, fOP_STATUS_PCIE_DEVICE)) &&
+ (IDLE_ON(pAd)) &&
+ (pAd->StaCfg.bRadio == TRUE) &&
+ (RTMP_TEST_FLAG(pAd, fRTMP_ADAPTER_IDLE_RADIO_OFF)))
+ {
+ if (pAd->StaCfg.PSControl.field.EnableNewPS == FALSE)
+ {
+ AsicSendCommandToMcu(pAd, 0x31, PowerWakeCID, 0x00, 0x02);
+ AsicCheckCommanOk(pAd, PowerWakeCID);
+ RTMP_CLEAR_FLAG(pAd, fRTMP_ADAPTER_IDLE_RADIO_OFF);
+ DBGPRINT(RT_DEBUG_TRACE, ("PSM - Issue Wake up command \n"));
+ }
+ else
+ {
+ RT28xxPciAsicRadioOn(pAd, GUI_IDLE_POWER_SAVE);
+ }
+ }
+#endif // RTMP_MAC_PCI //
+
+ // first check the parameter sanity
+ if (MlmeScanReqSanity(pAd,
+ Elem->Msg,
+ Elem->MsgLen,
+ &BssType,
+ (PCHAR)Ssid,
+ &SsidLen,
+ &ScanType))
+ {
+
+ // Check for channel load and noise hist request
+ // Suspend MSDU only at scan request, not the last two mentioned
+ // 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);
+
+ // 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));
+
+#ifdef RTMP_MAC_PCI
+ if ((OPSTATUS_TEST_FLAG(pAd, fOP_STATUS_PCIE_DEVICE)) &&
+ (IDLE_ON(pAd)) &&
+ (pAd->StaCfg.bRadio == TRUE) &&
+ (RTMP_TEST_FLAG(pAd, fRTMP_ADAPTER_IDLE_RADIO_OFF)))
+ {
+ RT28xxPciAsicRadioOn(pAd, GUI_IDLE_POWER_SAVE);
+ }
+#endif // RTMP_MAC_PCI //
+
+ // 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)
+ {
+ RTMPZeroMemory(pAd->MlmeAux.Ssid, MAX_LEN_OF_SSID);
+ 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, (PCHAR)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;
+ NdisZeroMemory(&pAd->StaActive.SupportedPhyInfo.MCSSet[0], 16);
+ }
+ // 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,
+ (PCHAR)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 //
+
+ Idx = BssTableSetEntry(pAd, &pAd->ScanTab, Bssid, (PCHAR)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;
+ BOOLEAN bAllowNrate = FALSE;
+#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,
+ (PCHAR)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)
+ {
+ CHAR Rssi = 0;
+ Rssi = RTMPMaxRssi(pAd, ConvertToRssi(pAd, Elem->Rssi0, RSSI_0), ConvertToRssi(pAd, Elem->Rssi1, RSSI_1), ConvertToRssi(pAd, Elem->Rssi2, RSSI_2));
+ Idx = BssTableSetEntry(pAd, &pAd->ScanTab, Bssid, (CHAR *) Ssid, SsidLen, BssType, BeaconPeriod,
+ &Cf, 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->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);
+ CapabilityInfo = pAd->ScanTab.BssEntry[Idx].CapabilityInfo;
+ }
+ }
+ else
+ {
+ //
+ // 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
+ if (((pAd->StaCfg.WepStatus != Ndis802_11WEPEnabled) && (pAd->StaCfg.WepStatus != Ndis802_11Encryption2Enabled))
+ || (pAd->CommonCfg.HT_DisallowTKIP == FALSE))
+ {
+ bAllowNrate = TRUE;
+ }
+
+ pAd->MlmeAux.NewExtChannelOffset = NewExtChannelOffset;
+ pAd->MlmeAux.HtCapabilityLen = HtCapabilityLen;
+
+ RTMPZeroMemory(&pAd->MlmeAux.HtCapability, SIZE_HT_CAP_IE);
+ // filter out un-supported ht rates
+ if (((HtCapabilityLen > 0) || (PreNHtCapabilityLen > 0)) &&
+ ((pAd->CommonCfg.PhyMode >= PHY_11ABGN_MIXED) && (bAllowNrate)))
+ {
+ 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;
+ pAd->MlmeAux.NewExtChannelOffset = 0xff;
+ RTMPZeroMemory(&pAd->MlmeAux.HtCapability, SIZE_HT_CAP_IE);
+ pAd->MlmeAux.HtCapabilityLen = 0;
+ 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));
+
+ 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,
+ &AddHtInfo,
+ AddHtInfoLen,
+ CapabilityInfo) == FALSE)
+ {
+ DBGPRINT(RT_DEBUG_TRACE, ("ADHOC - Add Entry failed.\n"));
+ return;
+ }
+
+ if (pEntry &&
+ (Elem->Wcid == RESERVED_WCID))
+ {
+ idx = pAd->StaCfg.DefaultKeyId;
+ RTMP_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)
+ {
+#ifdef RTMP_MAC_PCI
+ if (OPSTATUS_TEST_FLAG(pAd, fOP_STATUS_PCIE_DEVICE))
+ {
+ // Restore to correct BBP R3 value
+ if (pAd->Antenna.field.RxPath > 1)
+ RTMP_BBP_IO_WRITE8_BY_REG_ID(pAd, BBP_R3, pAd->StaCfg.BBPR3);
+ // Turn clk to 80Mhz.
+ }
+#endif // RTMP_MAC_PCI //
+ 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
+ RTMP_PS_POLL_ENQUEUE(pAd);
+ }
+ else if (BcastFlag && (DtimCount == 0) && OPSTATUS_TEST_FLAG(pAd, fOP_STATUS_RECEIVE_DTIM))
+ {
+#ifdef RTMP_MAC_PCI
+ if (OPSTATUS_TEST_FLAG(pAd, fOP_STATUS_PCIE_DEVICE))
+ {
+ if (pAd->Antenna.field.RxPath > 1)
+ RTMP_BBP_IO_WRITE8_BY_REG_ID(pAd, BBP_R3, pAd->StaCfg.BBPR3);
+ }
+#endif // RTMP_MAC_PCI //
+ }
+ 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?
+#ifdef RTMP_MAC_PCI
+ if (OPSTATUS_TEST_FLAG(pAd, fOP_STATUS_PCIE_DEVICE))
+ {
+ if (pAd->Antenna.field.RxPath > 1)
+ RTMP_BBP_IO_WRITE8_BY_REG_ID(pAd, BBP_R3, pAd->StaCfg.BBPR3);
+ }
+#endif // RTMP_MAC_PCI //
+ }
+ else
+ {
+ if ((pAd->CommonCfg.bACMAPSDTr[QID_AC_VO]) ||
+ (pAd->CommonCfg.bACMAPSDTr[QID_AC_VI]) ||
+ (pAd->CommonCfg.bACMAPSDTr[QID_AC_BK]) ||
+ (pAd->CommonCfg.bACMAPSDTr[QID_AC_BE]))
+ {
+ /*
+ WMM Spec v1.0 3.6.2.4,
+ The WMM STA shall remain awake until it receives a
+ QoS Data or Null frame addressed to it, with the
+ EOSP subfield in QoS Control field set to 1.
+
+ So we can not sleep here or we will suffer a case:
+
+ PS Management Frame -->
+ Trigger frame -->
+ Beacon (TIM=0) (Beacon is closer to Trig frame) -->
+ Station goes to sleep -->
+ AP delivery queued UAPSD packets -->
+ Station can NOT receive the reply
+
+ Maybe we need a timeout timer to avoid that we do
+ NOT receive the EOSP frame.
+
+ We can not use More Data to check if SP is ended
+ due to MaxSPLength.
+ */
+ }
+ 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))
+ {
+ // Set a flag to go to sleep . Then after parse this RxDoneInterrupt, will go to sleep mode.
+ pAd->ThisTbttNumToNextWakeUp = TbttNumToNextWakeUp;
+ AsicSleepThenAutoWakeup(pAd, pAd->ThisTbttNumToNextWakeUp);
+
+ }
+ }
+ }
+ }
+ }
+ // 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;
+}
diff --git a/drivers/staging/rt3090/sta/wpa.c b/drivers/staging/rt3090/sta/wpa.c
new file mode 100644
index 000000000000..2dbdba541c3f
--- /dev/null
+++ b/drivers/staging/rt3090/sta/wpa.c
@@ -0,0 +1,396 @@
+/*
+ *************************************************************************
+ * 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"
+
+
+void inc_byte_array(UCHAR *counter, int len);
+
+/*
+ ========================================================================
+
+ 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
+ NdisGetSystemUpTime(&Now);
+ 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)
+{
+ char custom[IW_CUSTOM_MAX] = {0};
+
+ sprintf(custom, "MLME-MICHAELMICFAILURE.indication");
+ if(bUnicast)
+ sprintf(custom, "%s unicast", custom);
+
+ RtmpOSWrielessEventSend(pAd, IWEVCUSTOM, -1, NULL, (PUCHAR)custom, strlen(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
+ SET_UINT16_TO_ARRARY(Packet.Body_Len, LEN_EAPOL_KEY_MSG)
+
+ // 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,
+ CONV_ARRARY_TO_UINT16(Packet.Body_Len) + 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(pAd->StaCfg.PTK, LEN_EAP_MICK, pOutBuffer, FrameLen, digest, SHA1_DIGEST_SIZE);
+ NdisMoveMemory(Mic, digest, LEN_KEY_DESC_MIC);
+ }
+ else
+ { // TKIP
+ HMAC_MD5(pAd->StaCfg.PTK, LEN_EAP_MICK, pOutBuffer, FrameLen, Mic, MD5_DIGEST_SIZE);
+ }
+ NdisMoveMemory(Packet.KeyDesc.KeyMic, Mic, LEN_KEY_DESC_MIC);
+
+ // copy frame to Tx ring and send MIC failure report frame to authenticator
+ RTMPToWirelessSta(pAd, &pAd->MacTab.Content[BSSID_WCID],
+ Header802_3, LENGTH_802_3,
+ (PUCHAR)&Packet,
+ CONV_ARRARY_TO_UINT16(Packet.Body_Len) + 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;
+}
+
+VOID WpaStaPairwiseKeySetting(
+ IN PRTMP_ADAPTER pAd)
+{
+ PCIPHER_KEY pSharedKey;
+ PMAC_TABLE_ENTRY pEntry;
+
+ pEntry = &pAd->MacTab.Content[BSSID_WCID];
+
+ // Pairwise key shall use key#0
+ pSharedKey = &pAd->SharedKey[BSS0][0];
+
+ NdisMoveMemory(pAd->StaCfg.PTK, pEntry->PTK, LEN_PTK);
+
+ // Prepare pair-wise key information into shared key table
+ NdisZeroMemory(pSharedKey, sizeof(CIPHER_KEY));
+ pSharedKey->KeyLen = LEN_TKIP_EK;
+ NdisMoveMemory(pSharedKey->Key, &pAd->StaCfg.PTK[32], LEN_TKIP_EK);
+ NdisMoveMemory(pSharedKey->RxMic, &pAd->StaCfg.PTK[48], LEN_TKIP_RXMICK);
+ NdisMoveMemory(pSharedKey->TxMic, &pAd->StaCfg.PTK[48+LEN_TKIP_RXMICK], LEN_TKIP_TXMICK);
+
+ // Decide its ChiperAlg
+ if (pAd->StaCfg.PairCipher == Ndis802_11Encryption2Enabled)
+ pSharedKey->CipherAlg = CIPHER_TKIP;
+ else if (pAd->StaCfg.PairCipher == Ndis802_11Encryption3Enabled)
+ pSharedKey->CipherAlg = CIPHER_AES;
+ else
+ pSharedKey->CipherAlg = CIPHER_NONE;
+
+ // Update these related information to MAC_TABLE_ENTRY
+ 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 = pSharedKey->CipherAlg;
+
+ // Update pairwise key information to ASIC Shared Key Table
+ AsicAddSharedKeyEntry(pAd,
+ BSS0,
+ 0,
+ pSharedKey->CipherAlg,
+ pSharedKey->Key,
+ pSharedKey->TxMic,
+ pSharedKey->RxMic);
+
+ // Update ASIC WCID attribute table and IVEIV table
+ RTMPAddWcidAttributeEntry(pAd,
+ BSS0,
+ 0,
+ pSharedKey->CipherAlg,
+ pEntry);
+ STA_PORT_SECURED(pAd);
+ pAd->IndicateMediaState = NdisMediaStateConnected;
+
+ DBGPRINT(RT_DEBUG_TRACE, ("%s : AID(%d) port secured\n", __FUNCTION__, pEntry->Aid));
+
+}
+
+VOID WpaStaGroupKeySetting(
+ IN PRTMP_ADAPTER pAd)
+{
+ PCIPHER_KEY pSharedKey;
+
+ pSharedKey = &pAd->SharedKey[BSS0][pAd->StaCfg.DefaultKeyId];
+
+ // Prepare pair-wise key information into shared key table
+ NdisZeroMemory(pSharedKey, sizeof(CIPHER_KEY));
+ pSharedKey->KeyLen = LEN_TKIP_EK;
+ NdisMoveMemory(pSharedKey->Key, pAd->StaCfg.GTK, LEN_TKIP_EK);
+ NdisMoveMemory(pSharedKey->RxMic, &pAd->StaCfg.GTK[16], LEN_TKIP_RXMICK);
+ NdisMoveMemory(pSharedKey->TxMic, &pAd->StaCfg.GTK[24], LEN_TKIP_TXMICK);
+
+ // Update Shared Key CipherAlg
+ pSharedKey->CipherAlg = CIPHER_NONE;
+ if (pAd->StaCfg.GroupCipher == Ndis802_11Encryption2Enabled)
+ pSharedKey->CipherAlg = CIPHER_TKIP;
+ else if (pAd->StaCfg.GroupCipher == Ndis802_11Encryption3Enabled)
+ pSharedKey->CipherAlg = CIPHER_AES;
+ else if (pAd->StaCfg.GroupCipher == Ndis802_11GroupWEP40Enabled)
+ pSharedKey->CipherAlg = CIPHER_WEP64;
+ else if (pAd->StaCfg.GroupCipher == Ndis802_11GroupWEP104Enabled)
+ pSharedKey->CipherAlg = CIPHER_WEP128;
+
+ // Update group key information to ASIC Shared Key Table
+ AsicAddSharedKeyEntry(pAd,
+ BSS0,
+ pAd->StaCfg.DefaultKeyId,
+ pSharedKey->CipherAlg,
+ pSharedKey->Key,
+ pSharedKey->TxMic,
+ pSharedKey->RxMic);
+
+ // Update ASIC WCID attribute table and IVEIV table
+ RTMPAddWcidAttributeEntry(pAd,
+ BSS0,
+ pAd->StaCfg.DefaultKeyId,
+ pSharedKey->CipherAlg,
+ NULL);
+
+}
diff --git a/drivers/staging/rt3090/sta_ioctl.c b/drivers/staging/rt3090/sta_ioctl.c
new file mode 100644
index 000000000000..93efd7f5bf3f
--- /dev/null
+++ b/drivers/staging/rt3090/sta_ioctl.c
@@ -0,0 +1,7559 @@
+/*
+ *************************************************************************
+ * 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[];
+
+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, IW_PRIV_TYPE_CHAR | 1024, IW_PRIV_TYPE_CHAR | IW_PRIV_SIZE_MASK,
+ ""},
+/* --- sub-ioctls definitions --- */
+ { SHOW_CONN_STATUS,
+ IW_PRIV_TYPE_CHAR | 1024, IW_PRIV_TYPE_CHAR | IW_PRIV_SIZE_MASK, "connStatus" },
+ { SHOW_DRVIER_VERION,
+ IW_PRIV_TYPE_CHAR | 1024, IW_PRIV_TYPE_CHAR | IW_PRIV_SIZE_MASK, "driverVer" },
+ { SHOW_BA_INFO,
+ IW_PRIV_TYPE_CHAR | 1024, IW_PRIV_TYPE_CHAR | IW_PRIV_SIZE_MASK, "bainfo" },
+ { SHOW_DESC_INFO,
+ IW_PRIV_TYPE_CHAR | 1024, IW_PRIV_TYPE_CHAR | IW_PRIV_SIZE_MASK, "descinfo" },
+ { RAIO_OFF,
+ IW_PRIV_TYPE_CHAR | 1024, IW_PRIV_TYPE_CHAR | IW_PRIV_SIZE_MASK, "radio_off" },
+ { RAIO_ON,
+ IW_PRIV_TYPE_CHAR | 1024, IW_PRIV_TYPE_CHAR | IW_PRIV_SIZE_MASK, "radio_on" },
+#ifdef QOS_DLS_SUPPORT
+ { SHOW_DLS_ENTRY_INFO,
+ IW_PRIV_TYPE_CHAR | 1024, 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,
+ IW_PRIV_TYPE_CHAR | 1024, 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"},
+#ifdef RTMP_RF_RW_SUPPORT
+{ RTPRIV_IOCTL_RF,
+ IW_PRIV_TYPE_CHAR | IW_PRIV_SIZE_MASK, IW_PRIV_TYPE_CHAR | IW_PRIV_SIZE_MASK,
+ "rf"},
+#endif // RTMP_RF_RW_SUPPORT //
+{ 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"},
+
+
+};
+
+static __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};
+
+
+
+INT Set_SSID_Proc(
+ IN PRTMP_ADAPTER pAdapter,
+ IN PSTRING arg);
+
+#ifdef WMM_SUPPORT
+INT Set_WmmCapable_Proc(
+ IN PRTMP_ADAPTER pAd,
+ IN PSTRING arg);
+#endif
+
+INT Set_NetworkType_Proc(
+ IN PRTMP_ADAPTER pAdapter,
+ IN PSTRING arg);
+
+INT Set_AuthMode_Proc(
+ IN PRTMP_ADAPTER pAdapter,
+ IN PSTRING arg);
+
+INT Set_EncrypType_Proc(
+ IN PRTMP_ADAPTER pAdapter,
+ IN PSTRING arg);
+
+INT Set_DefaultKeyID_Proc(
+ IN PRTMP_ADAPTER pAdapter,
+ IN PSTRING arg);
+
+INT Set_Key1_Proc(
+ IN PRTMP_ADAPTER pAdapter,
+ IN PSTRING arg);
+
+INT Set_Key2_Proc(
+ IN PRTMP_ADAPTER pAdapter,
+ IN PSTRING arg);
+
+INT Set_Key3_Proc(
+ IN PRTMP_ADAPTER pAdapter,
+ IN PSTRING arg);
+
+INT Set_Key4_Proc(
+ IN PRTMP_ADAPTER pAdapter,
+ IN PSTRING arg);
+
+INT Set_WPAPSK_Proc(
+ IN PRTMP_ADAPTER pAdapter,
+ IN PSTRING arg);
+
+
+INT Set_PSMode_Proc(
+ IN PRTMP_ADAPTER pAdapter,
+ IN PSTRING arg);
+
+#ifdef RT3090
+INT Set_PCIePSLevel_Proc(
+IN PRTMP_ADAPTER pAdapter,
+IN PUCHAR arg);
+#endif // RT3090 //
+#ifdef WPA_SUPPLICANT_SUPPORT
+INT Set_Wpa_Support(
+ IN PRTMP_ADAPTER pAd,
+ IN PSTRING 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);
+#endif // DBG //
+
+
+NDIS_STATUS RTMPWPANoneAddKeyProc(
+ IN PRTMP_ADAPTER pAd,
+ IN PVOID pBuf);
+
+INT Set_FragTest_Proc(
+ IN PRTMP_ADAPTER pAdapter,
+ IN PSTRING arg);
+
+#ifdef DOT11_N_SUPPORT
+INT Set_TGnWifiTest_Proc(
+ IN PRTMP_ADAPTER pAd,
+ IN PSTRING arg);
+#endif // DOT11_N_SUPPORT //
+
+INT Set_LongRetryLimit_Proc(
+ IN PRTMP_ADAPTER pAdapter,
+ IN PSTRING arg);
+
+INT Set_ShortRetryLimit_Proc(
+ IN PRTMP_ADAPTER pAdapter,
+ IN PSTRING arg);
+
+#ifdef EXT_BUILD_CHANNEL_LIST
+INT Set_Ieee80211dClientMode_Proc(
+ IN PRTMP_ADAPTER pAdapter,
+ IN PSTRING arg);
+#endif // EXT_BUILD_CHANNEL_LIST //
+
+#ifdef CARRIER_DETECTION_SUPPORT
+INT Set_CarrierDetect_Proc(
+ IN PRTMP_ADAPTER pAd,
+ IN PSTRING arg);
+#endif // CARRIER_DETECTION_SUPPORT //
+
+INT Show_Adhoc_MacTable_Proc(
+ IN PRTMP_ADAPTER pAd,
+ IN PSTRING extra);
+
+#ifdef RTMP_RF_RW_SUPPORT
+VOID RTMPIoctlRF(
+ IN PRTMP_ADAPTER pAdapter,
+ IN struct iwreq *wrq);
+#endif // RTMP_RF_RW_SUPPORT //
+
+
+INT Set_BeaconLostTime_Proc(
+ IN PRTMP_ADAPTER pAd,
+ IN PSTRING arg);
+
+INT Set_AutoRoaming_Proc(
+ IN PRTMP_ADAPTER pAd,
+ IN PSTRING arg);
+
+INT Set_SiteSurvey_Proc(
+ IN PRTMP_ADAPTER pAd,
+ IN PSTRING arg);
+
+INT Set_ForceTxBurst_Proc(
+ IN PRTMP_ADAPTER pAd,
+ IN PSTRING arg);
+
+#ifdef ANT_DIVERSITY_SUPPORT
+INT Set_Antenna_Proc(
+ IN PRTMP_ADAPTER pAd,
+ IN PUCHAR arg);
+#endif // ANT_DIVERSITY_SUPPORT //
+
+static struct {
+ PSTRING name;
+ INT (*set_proc)(PRTMP_ADAPTER pAdapter, PSTRING 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},
+ {"HtDisallowTKIP", Set_HtDisallowTKIP_Proc},
+#endif // DOT11_N_SUPPORT //
+
+#ifdef AGGREGATION_SUPPORT
+ {"PktAggregate", Set_PktAggregate_Proc},
+#endif // AGGREGATION_SUPPORT //
+
+#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 // DBG //
+
+#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
+#ifdef RTMP_EFUSE_SUPPORT
+ {"efuseFreeNumber", set_eFuseGetFreeBlockCount_Proc},
+ {"efuseDump", set_eFusedump_Proc},
+ {"efuseLoadFromBin", set_eFuseLoadFromBin_Proc},
+ {"efuseBufferModeWriteBack", set_eFuseBufferModeWriteBack_Proc},
+#endif // RTMP_EFUSE_SUPPORT //
+#ifdef ANT_DIVERSITY_SUPPORT
+ {"ant", Set_Antenna_Proc},
+#endif // ANT_DIVERSITY_SUPPORT //
+#endif // RT30xx //
+//2008/09/11:KH add to support efuse-->
+
+ {"BeaconLostTime", Set_BeaconLostTime_Proc},
+ {"AutoRoaming", Set_AutoRoaming_Proc},
+ {"SiteSurvey", Set_SiteSurvey_Proc},
+ {"ForceTxBurst", Set_ForceTxBurst_Proc},
+
+ {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)
+{
+
+#ifdef RTMP_MAC_PCI
+ strncpy(name, "RT2860 Wireless", IFNAMSIZ);
+#endif // RTMP_MAC_PCI //
+ return 0;
+}
+
+int rt_ioctl_siwfreq(struct net_device *dev,
+ struct iw_request_info *info,
+ struct iw_freq *freq, char *extra)
+{
+ PRTMP_ADAPTER pAdapter = RTMP_OS_NETDEV_GET_PRIV(dev);
+ 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)
+{
+ PRTMP_ADAPTER pAdapter = NULL;
+ UCHAR ch;
+ ULONG m = 2412000;
+
+ pAdapter = RTMP_OS_NETDEV_GET_PRIV(dev);
+ 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 = RTMP_OS_NETDEV_GET_PRIV(dev);
+
+ //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 = RTMP_OS_NETDEV_GET_PRIV(dev);
+
+ 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 = RTMP_OS_NETDEV_GET_PRIV(dev);
+
+ //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 = RTMP_OS_NETDEV_GET_PRIV(dev);
+ struct iw_range *range = (struct iw_range *) extra;
+ u16 val;
+ int i;
+
+ 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 = 2412000;
+ 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; /* OS_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 = RTMP_OS_NETDEV_GET_PRIV(dev);
+ 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)
+ {
+ RTMP_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 = RTMP_OS_NETDEV_GET_PRIV(dev);
+
+ 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 = RTMP_OS_NETDEV_GET_PRIV(dev);
+
+ 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 = RTMP_OS_NETDEV_GET_PRIV(dev);
+
+ 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 NDIS_STATUS_SUCCESS;
+ 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)
+ {
+ RTMP_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;
+ RTMP_MLME_HANDLER(pAdapter);
+ }while(0);
+ return NDIS_STATUS_SUCCESS;
+}
+
+int rt_ioctl_giwscan(struct net_device *dev,
+ struct iw_request_info *info,
+ struct iw_point *data, char *extra)
+{
+
+ PRTMP_ADAPTER pAdapter = RTMP_OS_NETDEV_GET_PRIV(dev);
+ int i=0;
+ PSTRING current_ev = extra, previous_ev = extra;
+ PSTRING end_buf;
+ PSTRING current_val;
+ STRING custom[MAX_CUSTOM_LEN] = {0};
+#ifndef IWEVGENIE
+ unsigned 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, (PSTRING) 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;
+
+ if (tmpRate == 0x6c && pAdapter->ScanTab.BssEntry[i].HtCapabilityLen > 0)
+ {
+ int rate_count = sizeof(ralinkrate)/sizeof(__s32);
+ HT_CAP_INFO capInfo = pAdapter->ScanTab.BssEntry[i].HtCapability.HtCapInfo;
+ int shortGI = capInfo.ChannelWidth ? capInfo.ShortGIfor40 : capInfo.ShortGIfor20;
+ int maxMCS = pAdapter->ScanTab.BssEntry[i].HtCapability.MCSSet[1] ? 15 : 7;
+ int rate_index = 12 + ((UCHAR)capInfo.ChannelWidth * 24) + ((UCHAR)shortGI *48) + ((UCHAR)maxMCS);
+ if (rate_index < 0)
+ rate_index = 0;
+ if (rate_index > rate_count)
+ rate_index = rate_count;
+ iwe.u.bitrate.value = ralinkrate[rate_index] * 500000;
+ }
+
+ 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 = RTMP_OS_NETDEV_GET_PRIV(dev);
+
+ //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)
+ {
+ PSTRING pSsidString = NULL;
+
+ // Includes null character.
+ if (data->length > (IW_ESSID_MAX_SIZE + 1))
+ return -E2BIG;
+
+ pSsidString = 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 = RTMP_OS_NETDEV_GET_PRIV(dev);
+
+ 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);
+ }
+ 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 = RTMP_OS_NETDEV_GET_PRIV(dev);
+
+ //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 = RTMP_OS_NETDEV_GET_PRIV(dev);
+
+ 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((PSTRING) pAdapter->nickname) + 1)
+ data->length = strlen((PSTRING) 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 = RTMP_OS_NETDEV_GET_PRIV(dev);
+ 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 = RTMP_OS_NETDEV_GET_PRIV(dev);
+
+ 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 = RTMP_OS_NETDEV_GET_PRIV(dev);
+ 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 = RTMP_OS_NETDEV_GET_PRIV(dev);
+
+ 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 = RTMP_OS_NETDEV_GET_PRIV(dev);
+
+ //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)
+{
+ int kid;
+ PRTMP_ADAPTER pAdapter = RTMP_OS_NETDEV_GET_PRIV(dev);
+
+ 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)
+{
+ PRTMP_ADAPTER pAdapter;
+ POS_COOKIE pObj;
+ PSTRING this_char = extra;
+ PSTRING value;
+ int Status=0;
+
+ pAdapter = RTMP_OS_NETDEV_GET_PRIV(dev);
+ 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 = (POS_COOKIE) pAdapter->OS_Cookie;
+ {
+ 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 && (strcmp(this_char, "SiteSurvey") != 0))
+ return -EINVAL;
+ else
+ goto SET_PROC;
+
+ // reject setting nothing besides ANY ssid(ssidLen=0)
+ if (!*value && (strcmp(this_char, "SSID") != 0))
+ return -EINVAL;
+
+SET_PROC:
+ 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 = RTMP_OS_NETDEV_GET_PRIV(dev);
+
+ 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 PSTRING 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, PSTRING extra)
+{
+ INT Status = 0;
+ PRTMP_ADAPTER pAd;
+ POS_COOKIE pObj;
+ u32 subcmd = wrq->flags;
+
+ pAd = RTMP_OS_NETDEV_GET_PRIV(dev);
+ if (pAd == NULL)
+ {
+ /* if 1st open fail, pAd will be free;
+ So the net_dev->priv will be NULL in 2rd open */
+ return -ENETDOWN;
+ }
+
+ pObj = (POS_COOKIE) pAd->OS_Cookie;
+ 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))
+ {
+ if (pAd->Mlme.CntlMachine.CurrState != CNTL_IDLE)
+ {
+ RTMP_MLME_RESET_STATE_MACHINE(pAd);
+ DBGPRINT(RT_DEBUG_TRACE, ("!!! MLME busy, reset MLME state machine !!!\n"));
+ }
+ }
+ 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:
+ 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, (PSTRING) 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", __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 = RTMP_OS_NETDEV_GET_PRIV(dev);
+ 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 = RTMP_OS_NETDEV_GET_PRIV(dev);
+ 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 = RTMP_OS_NETDEV_GET_PRIV(dev);
+ 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 = RTMP_OS_NETDEV_GET_PRIV(dev);
+ 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);
+
+ 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", __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);
+ pAdapter->IndicateMediaState = NdisMediaStateConnected;
+ }
+ }
+ 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);
+ pAdapter->IndicateMediaState = NdisMediaStateConnected;
+ }
+ }
+ 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);
+ pAdapter->IndicateMediaState = NdisMediaStateConnected;
+ }
+ 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);
+ pAdapter->IndicateMediaState = NdisMediaStateConnected;
+ }
+ 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 = RTMP_OS_NETDEV_GET_PRIV(dev);
+ 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 = (PCHAR)&(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 = (PCHAR)&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 = RTMP_OS_NETDEV_GET_PRIV(dev);
+
+ DBGPRINT(RT_DEBUG_TRACE ,("===> rt_ioctl_siwgenie\n"));
+#ifdef NATIVE_WPA_SUPPLICANT_SUPPORT
+ pAd->StaCfg.bRSN_IE_FromWpaSupplicant = FALSE;
+#endif // NATIVE_WPA_SUPPLICANT_SUPPORT //
+ 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);
+#ifdef NATIVE_WPA_SUPPLICANT_SUPPORT
+ pAd->StaCfg.bRSN_IE_FromWpaSupplicant = TRUE;
+#endif // NATIVE_WPA_SUPPLICANT_SUPPORT //
+ }
+ 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 = RTMP_OS_NETDEV_GET_PRIV(dev);
+
+ 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 = RTMP_OS_NETDEV_GET_PRIV(dev);
+ 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)
+ {
+ PSTRING this_char;
+ PSTRING value = NULL;
+ UCHAR regBBP = 0;
+// CHAR arg[255]={0};
+ UINT32 bbpId;
+ UINT32 bbpValue;
+ BOOLEAN bIsPrintAllBBP = FALSE;
+ INT Status = 0;
+ PRTMP_ADAPTER pAdapter = RTMP_OS_NETDEV_GET_PRIV(dev);
+
+
+ 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 <= MAX_BBP_ID)
+ {
+#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, 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 <= MAX_BBP_ID)
+ {
+#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, 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 <= MAX_BBP_ID; bbpId++)
+ {
+ if (strlen(extra) >= (IW_PRIV_SIZE_MASK - 20))
+ 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, regBBP);
+ if (bbpId%5 == 4)
+ 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 = RTMP_OS_NETDEV_GET_PRIV(dev);
+ 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 = RTMP_OS_NETDEV_GET_PRIV(dev);
+ int rate_index = 0, rate_count = 0;
+ HTTRANSMIT_SETTING ht_setting;
+/* Remove to global variable
+ __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 */
+ (iw_handler) rt_ioctl_setparam, /* + 0x02 */
+#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, /* + 0x14 */
+ (iw_handler) NULL, /* + 0x15 */
+ (iw_handler) NULL, /* + 0x16 */
+ (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 pAd,
+ 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;
+ PNDIS_802_11_PASSPHRASE ppassphrase = NULL;
+#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 (!(pAd->CommonCfg.CountryRegion & 0x80) && !(pAd->CommonCfg.CountryRegionForABand & 0x80))
+ {
+ ULONG Country;
+ UCHAR TmpPhy;
+
+ Status = copy_from_user(&Country, wrq->u.data.pointer, wrq->u.data.length);
+ pAd->CommonCfg.CountryRegion = (UCHAR)(Country & 0x000000FF);
+ pAd->CommonCfg.CountryRegionForABand = (UCHAR)((Country >> 8) & 0x000000FF);
+ TmpPhy = pAd->CommonCfg.PhyMode;
+ pAd->CommonCfg.PhyMode = 0xff;
+ // Build all corresponding channel information
+ RTMPSetPhyMode(pAd, TmpPhy);
+#ifdef DOT11_N_SUPPORT
+ SetCommonHT(pAd);
+#endif // DOT11_N_SUPPORT //
+ DBGPRINT(RT_DEBUG_TRACE, ("Set::RT_OID_802_11_COUNTRY_REGION (A:%d B/G:%d)\n", pAd->CommonCfg.CountryRegionForABand,
+ pAd->CommonCfg.CountryRegion));
+ }
+ break;
+ case OID_802_11_BSSID_LIST_SCAN:
+ Now = jiffies;
+ DBGPRINT(RT_DEBUG_TRACE, ("Set::OID_802_11_BSSID_LIST_SCAN, TxCnt = %d \n", pAd->RalinkCounters.LastOneSecTotalTxCount));
+
+ if (MONITOR_ON(pAd))
+ {
+ 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(pAd, fRTMP_ADAPTER_RADIO_OFF))
+ break;
+
+ if (RTMP_TEST_FLAG(pAd, fRTMP_ADAPTER_BSS_SCAN_IN_PROGRESS))
+ {
+ DBGPRINT(RT_DEBUG_TRACE, ("!!! Driver is scanning now !!!\n"));
+ pAd->StaCfg.bScanReqIsFromWebUI = TRUE;
+ Status = NDIS_STATUS_SUCCESS;
+ break;
+ }
+
+ if (pAd->RalinkCounters.LastOneSecTotalTxCount > 100)
+ {
+ DBGPRINT(RT_DEBUG_TRACE, ("!!! Link UP, ignore this set::OID_802_11_BSSID_LIST_SCAN\n"));
+ Status = NDIS_STATUS_SUCCESS;
+ pAd->StaCfg.ScanCnt = 99; // Prevent auto scan triggered by this OID
+ break;
+ }
+
+ if ((OPSTATUS_TEST_FLAG(pAd, fOP_STATUS_MEDIA_STATE_CONNECTED)) &&
+ ((pAd->StaCfg.AuthMode == Ndis802_11AuthModeWPA) ||
+ (pAd->StaCfg.AuthMode == Ndis802_11AuthModeWPAPSK) ||
+ (pAd->StaCfg.AuthMode == Ndis802_11AuthModeWPA2) ||
+ (pAd->StaCfg.AuthMode == Ndis802_11AuthModeWPA2PSK)) &&
+ (pAd->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;
+ pAd->StaCfg.ScanCnt = 99; // Prevent auto scan triggered by this OID
+ break;
+ }
+
+
+ if (pAd->Mlme.CntlMachine.CurrState != CNTL_IDLE)
+ {
+ RTMP_MLME_RESET_STATE_MACHINE(pAd);
+ 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.
+ pAd->MlmeAux.CurrReqIsFromNdis = FALSE;
+ // Reset allowed scan retries
+ pAd->StaCfg.ScanCnt = 0;
+ pAd->StaCfg.LastScanTime = Now;
+
+ pAd->StaCfg.bScanReqIsFromWebUI = TRUE;
+ RTMP_SET_FLAG(pAd, fRTMP_ADAPTER_BSS_SCAN_IN_PROGRESS);
+ MlmeEnqueue(pAd,
+ 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
+ {
+ PSTRING 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(pAd, "");
+ }
+ else
+ {
+ pSsidString = (PSTRING)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(pAd, pSsidString);
+ kfree(pSsidString);
+ }
+ else
+ Status = -ENOMEM;
+ }
+ }
+ }
+ break;
+ case OID_802_11_SET_PASSPHRASE:
+ ppassphrase= kmalloc(wrq->u.data.length, MEM_ALLOC_FLAG);
+
+ if(ppassphrase== NULL)
+ {
+ Status = -ENOMEM;
+ DBGPRINT(RT_DEBUG_TRACE, ("Set::OID_802_11_SET_PASSPHRASE, Failed!!\n"));
+ break;
+ }
+ else
+ {
+ Status = copy_from_user(ppassphrase, wrq->u.data.pointer, wrq->u.data.length);
+
+ if (Status)
+ {
+ Status = -EINVAL;
+ DBGPRINT(RT_DEBUG_TRACE, ("Set::OID_802_11_SET_PASSPHRASE, Failed (length mismatch)!!\n"));
+ }
+ else
+ {
+ if(ppassphrase->KeyLength < 8 || ppassphrase->KeyLength > 64)
+ {
+ Status = -EINVAL;
+ DBGPRINT(RT_DEBUG_TRACE, ("Set::OID_802_11_SET_PASSPHRASE, Failed (len less than 8 or greater than 64)!!\n"));
+ }
+ else
+ {
+ // set key passphrase and length
+ NdisZeroMemory(pAd->StaCfg.WpaPassPhrase, 64);
+ NdisMoveMemory(pAd->StaCfg.WpaPassPhrase, &ppassphrase->KeyMaterial, ppassphrase->KeyLength);
+ pAd->StaCfg.WpaPassPhraseLen = ppassphrase->KeyLength;
+ hex_dump("pAd->StaCfg.WpaPassPhrase", pAd->StaCfg.WpaPassPhrase, 64);
+ printk("WpaPassPhrase=%s\n",pAd->StaCfg.WpaPassPhrase);
+ }
+ }
+ }
+ kfree(ppassphrase);
+ break;
+
+ case OID_802_11_BSSID:
+ 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.
+ pAd->MlmeAux.CurrReqIsFromNdis = FALSE;
+
+ // Prevent to connect AP again in STAMlmePeriodicExec
+ pAd->MlmeAux.AutoReconnectSsidLen= 32;
+
+ // Reset allowed scan retries
+ pAd->StaCfg.ScanCnt = 0;
+
+ if (pAd->Mlme.CntlMachine.CurrState != CNTL_IDLE)
+ {
+ RTMP_MLME_RESET_STATE_MACHINE(pAd);
+ DBGPRINT(RT_DEBUG_TRACE, ("!!! MLME busy, reset MLME state machine !!!\n"));
+ }
+ MlmeEnqueue(pAd,
+ 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 (pAd->StaCfg.bSwRadio != RadioState)
+ {
+ pAd->StaCfg.bSwRadio = RadioState;
+ 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;
+ }
+ else
+ {
+ if (RTMP_TEST_FLAG(pAd, fRTMP_ADAPTER_BSS_SCAN_IN_PROGRESS))
+ {
+ if (pAd->Mlme.CntlMachine.CurrState != CNTL_IDLE)
+ {
+ RTMP_MLME_RESET_STATE_MACHINE(pAd);
+ DBGPRINT(RT_DEBUG_TRACE, ("!!! MLME busy, reset MLME state machine !!!\n"));
+ }
+ }
+
+ MlmeRadioOff(pAd);
+ // Update extra information
+ pAd->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(pAd, PhyMode);
+#ifdef DOT11_N_SUPPORT
+ SetCommonHT(pAd);
+#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
+ {
+ UINT32 Value;
+
+ Status = copy_from_user(&StaConfig, wrq->u.data.pointer, wrq->u.data.length);
+ pAd->CommonCfg.bEnableTxBurst = StaConfig.EnableTxBurst;
+ pAd->CommonCfg.UseBGProtection = StaConfig.UseBGProtection;
+ pAd->CommonCfg.bUseShortSlotTime = 1; // 2003-10-30 always SHORT SLOT capable
+ if ((pAd->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 (pAd->StaCfg.BssType == BSS_ADHOC)
+ {
+ pAd->CommonCfg.PhyMode = StaConfig.AdhocMode;
+ RTMPSetPhyMode(pAd, PhyMode);
+ MlmeUpdateTxRates(pAd, FALSE, 0);
+ MakeIbssBeacon(pAd); // re-build BEACON frame
+ AsicEnableIbssSync(pAd); // copy to on-chip memory
+ }
+ }
+ DBGPRINT(RT_DEBUG_TRACE, ("Set::RT_OID_802_11_SET_STA_CONFIG (Burst=%d, Protection=%ld,ShortSlot=%d\n",
+ pAd->CommonCfg.bEnableTxBurst,
+ pAd->CommonCfg.UseBGProtection,
+ pAd->CommonCfg.bUseShortSlotTime));
+
+ if (pAd->CommonCfg.PSPXlink)
+ Value = PSPXLINK;
+ else
+ Value = STANORMAL;
+ RTMP_IO_WRITE32(pAd, RX_FILTR_CFG, Value);
+ Value = 0;
+ RTMP_IO_READ32(pAd, MAC_SYS_CTRL, &Value);
+ Value &= (~0x80);
+ RTMP_IO_WRITE32(pAd, MAC_SYS_CTRL, Value);
+ }
+ 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(pAd->CommonCfg.DesireRate, MAX_LEN_OF_SUPPORTED_RATES);
+ NdisMoveMemory(pAd->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",
+ pAd->CommonCfg.DesireRate[0],pAd->CommonCfg.DesireRate[1],
+ pAd->CommonCfg.DesireRate[2],pAd->CommonCfg.DesireRate[3],
+ pAd->CommonCfg.DesireRate[4],pAd->CommonCfg.DesireRate[5],
+ pAd->CommonCfg.DesireRate[6],pAd->CommonCfg.DesireRate[7] ));
+ // Changing DesiredRate may affect the MAX TX rate we used to TX frames out
+ MlmeUpdateTxRates(pAd, 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)
+ {
+ pAd->CommonCfg.TxPreamble = Preamble;
+ MlmeSetTxPreamble(pAd, 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.
+ pAd->CommonCfg.TxPreamble = Preamble;
+ MlmeSetTxPreamble(pAd, 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 (pAd->StaCfg.WepStatus != WepStatus)
+ {
+ // Config has changed
+ pAd->bConfigChanged = TRUE;
+ }
+ pAd->StaCfg.WepStatus = WepStatus;
+ pAd->StaCfg.OrigWepStatus = WepStatus;
+ pAd->StaCfg.PairCipher = WepStatus;
+ pAd->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 (pAd->StaCfg.AuthMode != AuthMode)
+ {
+ // Config has changed
+ pAd->bConfigChanged = TRUE;
+ }
+ pAd->StaCfg.AuthMode = AuthMode;
+ }
+ pAd->StaCfg.PortSecured = WPA_802_1X_PORT_NOT_SECURED;
+ DBGPRINT(RT_DEBUG_TRACE, ("Set::OID_802_11_AUTHENTICATION_MODE (=%d) \n",pAd->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(pAd, "Adhoc");
+ else if (BssType == Ndis802_11Infrastructure)
+ Set_NetworkType_Proc(pAd, "Infra");
+ else if (BssType == Ndis802_11Monitor)
+ Set_NetworkType_Proc(pAd, "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
+ {
+ pAd->SharedKey[BSS0][KeyIdx].KeyLen = 0;
+ pAd->SharedKey[BSS0][KeyIdx].CipherAlg = CIPHER_NONE;
+ AsicRemoveSharedKeyEntry(pAd, 0, (UCHAR)KeyIdx);
+ }
+ }
+ }
+ break;
+ case RT_OID_802_11_RESET_COUNTERS:
+ NdisZeroMemory(&pAd->WlanCounters, sizeof(COUNTER_802_11));
+ NdisZeroMemory(&pAd->Counters8023, sizeof(COUNTER_802_3));
+ NdisZeroMemory(&pAd->RalinkCounters, sizeof(COUNTER_RALINK));
+ pAd->Counters8023.RxNoBuffer = 0;
+ pAd->Counters8023.GoodReceives = 0;
+ pAd->Counters8023.RxNoBuffer = 0;
+ 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
+ pAd->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);
+ pAd->CommonCfg.bUseZeroToDisableFragment = FALSE;
+ if (FragThresh > MAX_FRAG_THRESHOLD || FragThresh < MIN_FRAG_THRESHOLD)
+ {
+ if (FragThresh == 0)
+ {
+ pAd->CommonCfg.FragmentThreshold = MAX_FRAG_THRESHOLD;
+ pAd->CommonCfg.bUseZeroToDisableFragment = TRUE;
+ }
+ else
+ Status = -EINVAL;
+ }
+ else
+ pAd->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(pAd, "CAM");
+ else if (PowerMode == Ndis802_11PowerModeMAX_PSP)
+ Set_PSMode_Proc(pAd, "Max_PSP");
+ else if (PowerMode == Ndis802_11PowerModeFast_PSP)
+ Set_PSMode_Proc(pAd, "Fast_PSP");
+ else if (PowerMode == Ndis802_11PowerModeLegacy_PSP)
+ Set_PSMode_Proc(pAd, "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
+ pAd->CommonCfg.TxPowerDefault = PowerTemp; //keep current setting.
+ pAd->CommonCfg.TxPowerPercentage = pAd->CommonCfg.TxPowerDefault;
+ DBGPRINT(RT_DEBUG_TRACE, ("Set::RT_OID_802_11_TX_POWER_LEVEL_1 (=%ld)\n", pAd->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(pAd, PHY_11B);
+ else if (NetType == Ndis802_11OFDM24)
+ RTMPSetPhyMode(pAd, PHY_11BG_MIXED);
+ else if (NetType == Ndis802_11OFDM5)
+ RTMPSetPhyMode(pAd, PHY_11A);
+ else
+ Status = -EINVAL;
+#ifdef DOT11_N_SUPPORT
+ if (Status == NDIS_STATUS_SUCCESS)
+ SetCommonHT(pAd);
+#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 ((pAd->StaCfg.AuthMode != Ndis802_11AuthModeWPAPSK) &&
+ (pAd->StaCfg.AuthMode != Ndis802_11AuthModeWPA2PSK) &&
+ (pAd->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 ((pAd->StaCfg.AuthMode == Ndis802_11AuthModeWPAPSK) ||
+ (pAd->StaCfg.AuthMode == Ndis802_11AuthModeWPA2PSK) ||
+ (pAd->StaCfg.AuthMode == Ndis802_11AuthModeWPANone) ) // Only for WPA PSK mode
+ {
+ NdisMoveMemory(pAd->StaCfg.PMK, &pKey->KeyMaterial, pKey->KeyLength);
+ // Use RaConfig as PSK agent.
+ // Start STA supplicant state machine
+ if (pAd->StaCfg.AuthMode != Ndis802_11AuthModeWPANone)
+ pAd->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
+ {
+ pAd->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 (pAd->StaCfg.AuthMode >= Ndis802_11AuthModeWPA)
+ {
+ RTMPWPARemoveKeyProc(pAd, 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
+ {
+ pAd->SharedKey[BSS0][KeyIdx].KeyLen = 0;
+ pAd->SharedKey[BSS0][KeyIdx].CipherAlg = CIPHER_NONE;
+ AsicRemoveSharedKeyEntry(pAd, 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(pAd, 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))
+ pAd->CommonCfg.BeaconPeriod = (USHORT) pConfig->BeaconPeriod;
+
+ pAd->StaActive.AtimWin = (USHORT) pConfig->ATIMWindow;
+ MAP_KHZ_TO_CHANNEL_ID(pConfig->DSConfig, pAd->CommonCfg.Channel);
+ //
+ // Save the channel on MlmeAux for CntlOidRTBssidProc used.
+ //
+ pAd->MlmeAux.Channel = pAd->CommonCfg.Channel;
+
+ DBGPRINT(RT_DEBUG_TRACE, ("Set::OID_802_11_CONFIGURATION (BeacnPeriod=%ld,AtimW=%ld,Ch=%d)\n",
+ pConfig->BeaconPeriod, pConfig->ATIMWindow, pAd->CommonCfg.Channel));
+ // Config has changed
+ pAd->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 (pAd->CommonCfg.PhyMode >= PHY_11ABGN_MIXED)
+ RTMPSetHT(pAd, pHTPhyMode);
+ }
+ DBGPRINT(RT_DEBUG_TRACE, ("Set::RT_OID_802_11_SET_HT_PHYMODE(MCS=%d,BW=%d,SGI=%d,STBC=%d)\n",
+ pAd->StaCfg.HTPhyMode.field.MCS, pAd->StaCfg.HTPhyMode.field.BW, pAd->StaCfg.HTPhyMode.field.ShortGI,
+ pAd->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 |
+ ---------------------------------------------------------------------*/
+ pAd->CommonCfg.bAPSDCapable = (apsd & 0x00000001) ? TRUE : FALSE;
+ pAd->CommonCfg.bAPSDAC_BE = ((apsd & 0x00000002) >> 1) ? TRUE : FALSE;
+ pAd->CommonCfg.bAPSDAC_BK = ((apsd & 0x00000004) >> 2) ? TRUE : FALSE;
+ pAd->CommonCfg.bAPSDAC_VI = ((apsd & 0x00000008) >> 3) ? TRUE : FALSE;
+ pAd->CommonCfg.bAPSDAC_VO = ((apsd & 0x00000010) >> 4) ? TRUE : FALSE;
+ pAd->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, pAd->CommonCfg.bAPSDCapable,
+ pAd->CommonCfg.bAPSDAC_BE, pAd->CommonCfg.bAPSDAC_BK, pAd->CommonCfg.bAPSDAC_VI, pAd->CommonCfg.bAPSDAC_VO, pAd->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(&pAd->CommonCfg.bAPSDForcePowerSave, wrq->u.data.pointer, wrq->u.data.length);
+ if (pAd->CommonCfg.bAPSDForcePowerSave != pAd->StaCfg.Psm)
+ {
+ RTMP_SET_PSM_BIT(pAd, pAd->CommonCfg.bAPSDForcePowerSave);
+ RTMPSendNullFrame(pAd, pAd->CommonCfg.TxRate, TRUE);
+ }
+ DBGPRINT(RT_DEBUG_TRACE, ("Set::RT_OID_802_11_SET_APSD_PSM (bAPSDForcePowerSave:%d)\n", pAd->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 = pAd->CommonCfg.bDLSCapable;
+ Status = copy_from_user(&pAd->CommonCfg.bDLSCapable, wrq->u.data.pointer, wrq->u.data.length);
+ if (oldvalue && !pAd->CommonCfg.bDLSCapable)
+ {
+ int 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))
+ {
+ pAd->StaCfg.DLSEntry[i].Status = DLS_NONE;
+ pAd->StaCfg.DLSEntry[i].Valid = FALSE;
+ 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;
+ pAd->StaCfg.DLSEntry[i].Valid = FALSE;
+ RTMPSendDLSTearDownFrame(pAd, pAd->StaCfg.DLSEntry[i].MacAddr);
+ }
+ }
+ }
+
+ DBGPRINT(RT_DEBUG_TRACE,("Set::RT_OID_802_11_SET_DLS (=%d)\n", pAd->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(pAd,
+ 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(&pAd->CommonCfg.bWmmCapable, wrq->u.data.pointer, wrq->u.data.length);
+ DBGPRINT(RT_DEBUG_TRACE, ("Set::RT_OID_802_11_SET_WMM (=%d) \n", pAd->CommonCfg.bWmmCapable));
+ }
+ break;
+
+ case OID_802_11_DISASSOCIATE:
+ //
+ // 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.
+ //
+ pAd->CommonCfg.NdisRadioStateOff = TRUE;
+ // Set to immediately send the media disconnect event
+ pAd->MlmeAux.CurrReqIsFromNdis = TRUE;
+ DBGPRINT(RT_DEBUG_TRACE, ("Set::OID_802_11_DISASSOCIATE \n"));
+
+
+ if (INFRA_ON(pAd))
+ {
+ if (pAd->Mlme.CntlMachine.CurrState != CNTL_IDLE)
+ {
+ RTMP_MLME_RESET_STATE_MACHINE(pAd);
+ DBGPRINT(RT_DEBUG_TRACE, ("!!! MLME busy, reset MLME state machine !!!\n"));
+ }
+
+ MlmeEnqueue(pAd,
+ 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)
+ {
+ pAd->CommonCfg.BACapability.field.Policy = BA_NOTUSE;
+ pAd->CommonCfg.BACapability.field.MpduDensity = Orde.MpduDensity;
+ pAd->CommonCfg.DesiredHtPhy.MpduDensity = Orde.MpduDensity;
+ pAd->CommonCfg.DesiredHtPhy.AmsduEnable = Orde.AmsduEnable;
+ pAd->CommonCfg.DesiredHtPhy.AmsduSize= Orde.AmsduSize;
+ pAd->CommonCfg.DesiredHtPhy.MimoPs= Orde.MMPSmode;
+ pAd->CommonCfg.BACapability.field.MMPSmode = Orde.MMPSmode;
+ // UPdata to HT IE
+ pAd->CommonCfg.HtCapability.HtCapInfo.MimoPs = Orde.MMPSmode;
+ pAd->CommonCfg.HtCapability.HtCapInfo.AMsduSize = Orde.AmsduSize;
+ pAd->CommonCfg.HtCapability.HtCapParm.MpduDensity = Orde.MpduDensity;
+ }
+ else
+ {
+ pAd->CommonCfg.BACapability.field.AutoBA = Orde.AutoBA;
+ pAd->CommonCfg.BACapability.field.Policy = IMMED_BA; // we only support immediate BA.
+ pAd->CommonCfg.BACapability.field.MpduDensity = Orde.MpduDensity;
+ pAd->CommonCfg.DesiredHtPhy.MpduDensity = Orde.MpduDensity;
+ pAd->CommonCfg.DesiredHtPhy.AmsduEnable = Orde.AmsduEnable;
+ pAd->CommonCfg.DesiredHtPhy.AmsduSize= Orde.AmsduSize;
+ pAd->CommonCfg.DesiredHtPhy.MimoPs = Orde.MMPSmode;
+ pAd->CommonCfg.BACapability.field.MMPSmode = Orde.MMPSmode;
+
+ // UPdata to HT IE
+ pAd->CommonCfg.HtCapability.HtCapInfo.MimoPs = Orde.MMPSmode;
+ pAd->CommonCfg.HtCapability.HtCapInfo.AMsduSize = Orde.AmsduSize;
+ pAd->CommonCfg.HtCapability.HtCapParm.MpduDensity = Orde.MpduDensity;
+
+ if (pAd->CommonCfg.BACapability.field.RxBAWinLimit > MAX_RX_REORDERBUF)
+ pAd->CommonCfg.BACapability.field.RxBAWinLimit = MAX_RX_REORDERBUF;
+
+ }
+
+ pAd->CommonCfg.REGBACapability.word = pAd->CommonCfg.BACapability.word;
+ DBGPRINT(RT_DEBUG_TRACE, ("Set::(Orde.AutoBA = %d) (Policy=%d)(ReBAWinLimit=%d)(TxBAWinLimit=%d)(AutoMode=%d)\n",Orde.AutoBA, pAd->CommonCfg.BACapability.field.Policy,
+ pAd->CommonCfg.BACapability.field.RxBAWinLimit,pAd->CommonCfg.BACapability.field.TxBAWinLimit, pAd->CommonCfg.BACapability.field.AutoBA));
+ DBGPRINT(RT_DEBUG_TRACE, ("Set::(MimoPs = %d)(AmsduEnable = %d) (AmsduSize=%d)(MpduDensity=%d)\n",pAd->CommonCfg.DesiredHtPhy.MimoPs, pAd->CommonCfg.DesiredHtPhy.AmsduEnable,
+ pAd->CommonCfg.DesiredHtPhy.AmsduSize, pAd->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(pAd, 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)
+ pAd->CommonCfg.BACapability.field.RxBAWinLimit = 0x10;
+
+ BAOriSessionSetUp(pAd, pEntry, index, 0, 100, TRUE);
+ }
+ else
+ {
+ //BATableInsertEntry(pAd, 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(pAd, pBA->MACAddr);
+ DBGPRINT(RT_DEBUG_TRACE, (" pBA->IsRecipient == FALSE\n"));
+ if (pEntry)
+ {
+ DBGPRINT(RT_DEBUG_TRACE, (" pBA->pEntry\n"));
+ BAOriSessionTearDown(pAd, pEntry->Aid, pBA->TID, FALSE, TRUE);
+ }
+ else
+ DBGPRINT(RT_DEBUG_TRACE, ("Set :: Not found pEntry \n"));
+ }
+ else
+ {
+ pEntry = MacTableLookup(pAd, pBA->MACAddr);
+ if (pEntry)
+ {
+ BARecSessionTearDown( pAd, (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(pAd->SharedKey[BSS0][KeyIdx].Key, 16);
+ pAd->SharedKey[BSS0][KeyIdx].KeyLen = (UCHAR) pWepKey->KeyLength;
+ NdisMoveMemory(pAd->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;
+ }
+ pAd->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(pAd->StaCfg.DesireSharedKey[KeyIdx].Key, 16);
+ pAd->StaCfg.DesireSharedKey[KeyIdx].KeyLen = (UCHAR) pWepKey->KeyLength;
+ NdisMoveMemory(pAd->StaCfg.DesireSharedKey[KeyIdx].Key, &pWepKey->KeyMaterial, pWepKey->KeyLength);
+ pAd->StaCfg.DesireSharedKeyId = KeyIdx;
+ pAd->StaCfg.DesireSharedKey[KeyIdx].CipherAlg = CipherAlg;
+#endif // WPA_SUPPLICANT_SUPPORT //
+ pAd->StaCfg.DefaultKeyId = (UCHAR) KeyIdx;
+ }
+
+#ifdef WPA_SUPPLICANT_SUPPORT
+ if ((pAd->StaCfg.WpaSupplicantUP != WPA_SUPPLICANT_DISABLE) &&
+ (pAd->StaCfg.AuthMode >= Ndis802_11AuthModeWPA))
+ {
+ Key = pWepKey->KeyMaterial;
+
+ // 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);
+
+ STA_PORT_SECURED(pAd);
+
+ // Indicate Connected for GUI
+ pAd->IndicateMediaState = NdisMediaStateConnected;
+ }
+ else if (pAd->StaCfg.PortSecured == WPA_802_1X_PORT_SECURED)
+#endif // WPA_SUPPLICANT_SUPPORT
+ {
+ Key = pAd->SharedKey[BSS0][KeyIdx].Key;
+
+ // Set key material and cipherAlg to Asic
+ AsicAddSharedKeyEntry(pAd, BSS0, KeyIdx, CipherAlg, Key, NULL, NULL);
+
+ if (pWepKey->KeyIndex & 0x80000000)
+ {
+ PMAC_TABLE_ENTRY pEntry = &pAd->MacTab.Content[BSSID_WCID];
+ // Assign group key info
+ RTMPAddWcidAttributeEntry(pAd, BSS0, KeyIdx, CipherAlg, NULL);
+ // Assign pairwise key info
+ RTMPAddWcidAttributeEntry(pAd, 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, (pAd->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)
+ pAd->StaCfg.bBlockAssoc = TRUE;
+ else
+ // WPA MIC error should block association attempt for 60 seconds
+ pAd->StaCfg.bBlockAssoc = FALSE;
+ DBGPRINT(RT_DEBUG_TRACE, ("Set::OID_SET_COUNTERMEASURES bBlockAssoc=%s\n", pAd->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);
+ pAd->StaCfg.WpaSupplicantUP = wpa_supplicant_enable;
+ DBGPRINT(RT_DEBUG_TRACE, ("Set::RT_OID_WPA_SUPPLICANT_SUPPORT (=%d)\n", pAd->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);
+ if (MsgElem == NULL)
+ {
+ DBGPRINT(RT_DEBUG_ERROR, ("%s():alloc memory failed!\n", __FUNCTION__));
+ return -EINVAL;
+ }
+
+ pInfo = (MLME_DEAUTH_REQ_STRUCT *) MsgElem->Msg;
+ Status = copy_from_user(pInfo, wrq->u.data.pointer, wrq->u.data.length);
+ MlmeDeauthReqAction(pAd, MsgElem);
+ kfree(MsgElem);
+
+ if (INFRA_ON(pAd))
+ {
+ LinkDown(pAd, FALSE);
+ pAd->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)
+ pAd->StaCfg.PortSecured = WPA_802_1X_PORT_NOT_SECURED;
+ else
+ pAd->StaCfg.PortSecured = WPA_802_1X_PORT_SECURED;
+ NdisAcquireSpinLock(&pAd->MacTabLock);
+ pAd->MacTab.Content[BSSID_WCID].PortSecured = pAd->StaCfg.PortSecured;
+ NdisReleaseSpinLock(&pAd->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);
+ pAd->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);
+ pAd->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(pAd->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 < pAd->StaCfg.SavedPMKNum; CachedIdx++)
+ {
+ // compare the BSSID
+ if (NdisEqualMemory(pBssIdInfo->BSSID, pAd->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(&pAd->StaCfg.SavedPMK[CachedIdx], pBssIdInfo, sizeof(BSSID_INFO));
+ pAd->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(&pAd->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(pAd, TX_RTY_CFG, &tx_rty_cfg.word);
+ tx_rty_cfg.field.ShortRtyLimit = ShortRetryLimit;
+ RTMP_IO_WRITE32(pAd, 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(pAd, TX_RTY_CFG, &tx_rty_cfg.word);
+ tx_rty_cfg.field.LongRtyLimit = LongRetryLimit;
+ RTMP_IO_WRITE32(pAd, 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
+ {
+ pAd->SharedKey[BSS0][pAd->StaCfg.DefaultKeyId].KeyLen = (UCHAR) pKey->KeyLength;
+ NdisMoveMemory(&pAd->SharedKey[BSS0][pAd->StaCfg.DefaultKeyId].Key, &pKey->KeyMaterial, pKey->KeyLength);
+ if (pKey->KeyIndex & 0x80000000)
+ {
+ // Default key for tx (shared key)
+ pAd->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(&pAd->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((PSTRING)&ctmp,"%d", ctmp);
+ Set_Channel_Proc(pAd, (PSTRING)&ctmp);
+ }
+ break;
+#endif
+
+
+
+ case RT_OID_802_11_SET_PSPXLINK_MODE:
+ if (wrq->u.data.length != sizeof(BOOLEAN))
+ Status = -EINVAL;
+ else
+ {
+ Status = copy_from_user(&pAd->CommonCfg.PSPXlink, wrq->u.data.pointer, wrq->u.data.length);
+ /*if (pAd->CommonCfg.PSPXlink)
+ RX_FILTER_SET_FLAG(pAd, fRX_FILTER_ACCEPT_PROMISCUOUS)*/
+ DBGPRINT(RT_DEBUG_TRACE,("Set::RT_OID_802_11_SET_PSPXLINK_MODE(=%d) \n", pAd->CommonCfg.PSPXlink));
+ }
+ break;
+
+
+ default:
+ DBGPRINT(RT_DEBUG_TRACE, ("Set::unknown IOCTL's subcmd = 0x%08x\n", cmd));
+ Status = -EOPNOTSUPP;
+ break;
+ }
+
+
+ return Status;
+}
+
+INT RTMPQueryInformation(
+ IN PRTMP_ADAPTER pAd,
+ 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;
+ STRING 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(pAd->nickname);
+ Status = copy_to_user(wrq->u.data.pointer, pAd->nickname, 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(CHAR);
+ sprintf(&driverVersion[0], "%s", STA_DRIVER_VERSION);
+ driverVersion[7] = '\0';
+ if (copy_to_user(wrq->u.data.pointer, &driverVersion[0], wrq->u.data.length))
+ {
+ Status = -EFAULT;
+ }
+ break;
+
+ case OID_802_11_BSSID_LIST:
+ if (RTMP_TEST_FLAG(pAd, 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",pAd->ScanTab.BssNr));
+ pAd->StaCfg.bScanReqIsFromWebUI = FALSE;
+ // Claculate total buffer size required
+ BssBufSize = sizeof(ULONG);
+
+ for (i = 0; i < pAd->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) + pAd->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 = pAd->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 < pAd->ScanTab.BssNr; i++)
+ {
+ pBss = (PNDIS_WLAN_BSSID_EX) pPtr;
+ NdisMoveMemory(&pBss->MacAddress, &pAd->ScanTab.BssEntry[i].Bssid, MAC_ADDR_LEN);
+ if ((pAd->ScanTab.BssEntry[i].Hidden == 1) && (pAd->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 ((pAd->StaCfg.AuthMode >= Ndis802_11AuthModeWPA) && (pAd->StaCfg.PortSecured != WPA_802_1X_PORT_SECURED))
+ {
+ pBss->Ssid.SsidLength = pAd->ScanTab.BssEntry[i].SsidLen;
+ NdisMoveMemory(pBss->Ssid.Ssid, pAd->ScanTab.BssEntry[i].Ssid, pAd->ScanTab.BssEntry[i].SsidLen);
+ }
+ else
+ pBss->Ssid.SsidLength = 0;
+ }
+ else
+ {
+ pBss->Ssid.SsidLength = pAd->ScanTab.BssEntry[i].SsidLen;
+ NdisMoveMemory(pBss->Ssid.Ssid, pAd->ScanTab.BssEntry[i].Ssid, pAd->ScanTab.BssEntry[i].SsidLen);
+ }
+ pBss->Privacy = pAd->ScanTab.BssEntry[i].Privacy;
+ pBss->Rssi = pAd->ScanTab.BssEntry[i].Rssi - pAd->BbpRssiToDbmDelta;
+ pBss->NetworkTypeInUse = NetworkTypeInUseSanity(&pAd->ScanTab.BssEntry[i]);
+ pBss->Configuration.Length = sizeof(NDIS_802_11_CONFIGURATION);
+ pBss->Configuration.BeaconPeriod = pAd->ScanTab.BssEntry[i].BeaconPeriod;
+ pBss->Configuration.ATIMWindow = pAd->ScanTab.BssEntry[i].AtimWin;
+
+ MAP_CHANNEL_ID_TO_KHZ(pAd->ScanTab.BssEntry[i].Channel, pBss->Configuration.DSConfig);
+
+ if (pAd->ScanTab.BssEntry[i].BssType == BSS_INFRA)
+ pBss->InfrastructureMode = Ndis802_11Infrastructure;
+ else
+ pBss->InfrastructureMode = Ndis802_11IBSS;
+
+ NdisMoveMemory(pBss->SupportedRates, pAd->ScanTab.BssEntry[i].SupRate, pAd->ScanTab.BssEntry[i].SupRateLen);
+ NdisMoveMemory(pBss->SupportedRates + pAd->ScanTab.BssEntry[i].SupRateLen,
+ pAd->ScanTab.BssEntry[i].ExtRate,
+ pAd->ScanTab.BssEntry[i].ExtRateLen);
+
+ if (pAd->ScanTab.BssEntry[i].VarIELen == 0)
+ {
+ pBss->IELength = sizeof(NDIS_802_11_FIXED_IEs);
+ NdisMoveMemory(pBss->IEs, &pAd->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) + pAd->ScanTab.BssEntry[i].VarIELen);
+ pPtr = pPtr + sizeof(NDIS_WLAN_BSSID_EX) - 1 + sizeof(NDIS_802_11_FIXED_IEs);
+ NdisMoveMemory(pBss->IEs, &pAd->ScanTab.BssEntry[i].FixIEs, sizeof(NDIS_802_11_FIXED_IEs));
+ NdisMoveMemory(pBss->IEs + sizeof(NDIS_802_11_FIXED_IEs), pAd->ScanTab.BssEntry[i].VarIEs, pAd->ScanTab.BssEntry[i].VarIELen);
+ pPtr += pAd->ScanTab.BssEntry[i].VarIELen;
+ }
+ pBss->Length = (ULONG)(sizeof(NDIS_WLAN_BSSID_EX) - 1 + sizeof(NDIS_802_11_FIXED_IEs) + pAd->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, &pAd->CurrentAddress, wrq->u.data.length);
+ break;
+ case OID_GEN_MEDIA_CONNECT_STATUS:
+ if (pAd->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:
+ if (INFRA_ON(pAd) || ADHOC_ON(pAd))
+ {
+ Status = copy_to_user(wrq->u.data.pointer, &pAd->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 = pAd->CommonCfg.SsidLen;
+ memcpy(Ssid.Ssid, pAd->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[pAd->CommonCfg.TxRate]; // unit : 500 kbps
+ pLinkStatus->ChannelQuality = pAd->Mlme.ChannelQuality;
+ pLinkStatus->RxByteCount = pAd->RalinkCounters.ReceivedByteCount;
+ pLinkStatus->TxByteCount = pAd->RalinkCounters.TransmittedByteCount;
+ pLinkStatus->CentralChannel = pAd->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 = pAd->CommonCfg.BeaconPeriod;
+ pConfiguration->ATIMWindow = pAd->StaActive.AtimWin;
+ MAP_CHANNEL_ID_TO_KHZ(pAd->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, pAd->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 ((pAd->StaCfg.LastSNR0 > 0))
+ {
+ ulInfo = ((0xeb - pAd->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 ((pAd->Antenna.field.RxPath > 1) &&
+ (pAd->StaCfg.LastSNR1 > 0))
+ {
+ ulInfo = ((0xeb - pAd->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(pAd->StaCfg.LastSNR1=%d)\n",pAd->StaCfg.LastSNR1));
+ break;
+ case OID_802_11_RSSI_TRIGGER:
+ ulInfo = pAd->StaCfg.RssiSample.LastRssi0 - pAd->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 = pAd->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 = pAd->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 = pAd->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(pAd);
+
+ // Sanity check for calculation of sucessful count
+ if (pAd->WlanCounters.TransmittedFragmentCount.QuadPart < pAd->WlanCounters.RetryCount.QuadPart)
+ pAd->WlanCounters.TransmittedFragmentCount.QuadPart = pAd->WlanCounters.RetryCount.QuadPart;
+
+ pStatistics->TransmittedFragmentCount.QuadPart = pAd->WlanCounters.TransmittedFragmentCount.QuadPart;
+ pStatistics->MulticastTransmittedFrameCount.QuadPart = pAd->WlanCounters.MulticastTransmittedFrameCount.QuadPart;
+ pStatistics->FailedCount.QuadPart = pAd->WlanCounters.FailedCount.QuadPart;
+ pStatistics->RetryCount.QuadPart = pAd->WlanCounters.RetryCount.QuadPart;
+ pStatistics->MultipleRetryCount.QuadPart = pAd->WlanCounters.MultipleRetryCount.QuadPart;
+ pStatistics->RTSSuccessCount.QuadPart = pAd->WlanCounters.RTSSuccessCount.QuadPart;
+ pStatistics->RTSFailureCount.QuadPart = pAd->WlanCounters.RTSFailureCount.QuadPart;
+ pStatistics->ACKFailureCount.QuadPart = pAd->WlanCounters.ACKFailureCount.QuadPart;
+ pStatistics->FrameDuplicateCount.QuadPart = pAd->WlanCounters.FrameDuplicateCount.QuadPart;
+ pStatistics->ReceivedFragmentCount.QuadPart = pAd->WlanCounters.ReceivedFragmentCount.QuadPart;
+ pStatistics->MulticastReceivedFrameCount.QuadPart = pAd->WlanCounters.MulticastReceivedFrameCount.QuadPart;
+#ifdef DBG
+ pStatistics->FCSErrorCount = pAd->RalinkCounters.RealFcsErrCount;
+#else
+ pStatistics->FCSErrorCount.QuadPart = pAd->WlanCounters.FCSErrorCount.QuadPart;
+ pStatistics->FrameDuplicateCount.u.LowPart = pAd->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 = pAd->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 = pAd->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)pAd->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 = pAd->CommonCfg.bEnableTxBurst;
+ pStaConfig->EnableTurboRate = 0;
+ pStaConfig->UseBGProtection = pAd->CommonCfg.UseBGProtection;
+ pStaConfig->UseShortSlotTime = pAd->CommonCfg.bUseShortSlotTime;
+ //pStaConfig->AdhocMode = pAd->StaCfg.AdhocMode;
+ pStaConfig->HwRadioStatus = (pAd->StaCfg.bHwRadio == TRUE) ? 1 : 0;
+ pStaConfig->Rsv1 = 0;
+ pStaConfig->SystemErrorBitmap = pAd->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 = pAd->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 = pAd->CommonCfg.FragmentThreshold;
+ if (pAd->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 = pAd->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) pAd->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 (pAd->StaCfg.BssType == BSS_ADHOC)
+ BssType = Ndis802_11IBSS;
+ else if (pAd->StaCfg.BssType == BSS_INFRA)
+ BssType = Ndis802_11Infrastructure;
+ else if (pAd->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 = pAd->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 = pAd->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 = pAd->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, &pAd->CommonCfg.TxPower, wrq->u.data.length);
+ DBGPRINT(RT_DEBUG_TRACE, ("Query::OID_802_11_TX_POWER_LEVEL %x\n",pAd->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, &pAd->CommonCfg.TxPowerPercentage, wrq->u.data.length);
+ DBGPRINT(RT_DEBUG_TRACE, ("Query::RT_OID_802_11_TX_POWER_LEVEL_1 (=%ld)\n", pAd->CommonCfg.TxPowerPercentage));
+ break;
+ case OID_802_11_NETWORK_TYPES_SUPPORTED:
+ if ((pAd->RfIcType == RFIC_2850) || (pAd->RfIcType == RFIC_2750) || (pAd->RfIcType == RFIC_3052))
+ {
+ 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 (pAd->CommonCfg.PhyMode == PHY_11A)
+ ulInfo = Ndis802_11OFDM5;
+ else if ((pAd->CommonCfg.PhyMode == PHY_11BG_MIXED) || (pAd->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)pAd->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)pAd->LastTxRate;
+ ulInfo = (ULONG)pAd->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, &pAd->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, &pAd->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, &pAd->BbpWriteLatch[66], wrq->u.data.length);
+ DBGPRINT(RT_DEBUG_TRACE, ("Query::RT_OID_802_11_QUERY_NOISE_LEVEL (=%d)\n", pAd->BbpWriteLatch[66]));
+ break;
+ case RT_OID_802_11_EXTRA_INFO:
+ wrq->u.data.length = sizeof(ULONG);
+ Status = copy_to_user(wrq->u.data.pointer, &pAd->ExtraInfo, wrq->u.data.length);
+ DBGPRINT(RT_DEBUG_TRACE, ("Query::RT_OID_802_11_EXTRA_INFO (=%ld)\n", pAd->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 = (pAd->CommonCfg.bAPSDCapable | (pAd->CommonCfg.bAPSDAC_BE << 1) | (pAd->CommonCfg.bAPSDAC_BK << 2)
+ | (pAd->CommonCfg.bAPSDAC_VI << 3) | (pAd->CommonCfg.bAPSDAC_VO << 4) | (pAd->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,pAd->CommonCfg.bAPSDCapable,pAd->CommonCfg.bAPSDAC_BE,pAd->CommonCfg.bAPSDAC_BK,pAd->CommonCfg.bAPSDAC_VI,pAd->CommonCfg.bAPSDAC_VO,pAd->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, &pAd->CommonCfg.bAPSDForcePowerSave, wrq->u.data.length);
+ DBGPRINT(RT_DEBUG_TRACE, ("Query::RT_OID_802_11_QUERY_APSD_PSM (=%d)\n", pAd->CommonCfg.bAPSDForcePowerSave));
+ break;
+ case RT_OID_802_11_QUERY_WMM:
+ wrq->u.data.length = sizeof(BOOLEAN);
+ Status = copy_to_user(wrq->u.data.pointer, &pAd->CommonCfg.bWmmCapable, wrq->u.data.length);
+ DBGPRINT(RT_DEBUG_TRACE, ("Query::RT_OID_802_11_QUERY_WMM (=%d)\n", pAd->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, &pAd->StaCfg.WpaSupplicantUP, wrq->u.data.length);
+ DBGPRINT(RT_DEBUG_TRACE, ("Query::RT_OID_WPA_SUPPLICANT_SUPPORT (=%d)\n", pAd->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, pAd->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 = pAd->CommonCfg.PhyMode;
+ pHTPhyMode->HtMode = (UCHAR)pAd->MacTab.Content[BSSID_WCID].HTPhyMode.field.MODE;
+ pHTPhyMode->BW = (UCHAR)pAd->MacTab.Content[BSSID_WCID].HTPhyMode.field.BW;
+ pHTPhyMode->MCS= (UCHAR)pAd->MacTab.Content[BSSID_WCID].HTPhyMode.field.MCS;
+ pHTPhyMode->SHORTGI= (UCHAR)pAd->MacTab.Content[BSSID_WCID].HTPhyMode.field.ShortGI;
+ pHTPhyMode->STBC= (UCHAR)pAd->MacTab.Content[BSSID_WCID].HTPhyMode.field.STBC;
+
+ pHTPhyMode->ExtOffset = ((pAd->CommonCfg.CentralChannel < pAd->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", pAd->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 = pAd->CommonCfg.CountryRegionForABand;
+ ulInfo = (ulInfo << 8)|(pAd->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 = pAd->CommonCfg.PhyMode;
+ pHTPhyMode->HtMode = (UCHAR)pAd->CommonCfg.RegTransmitSetting.field.HTMODE;
+ pHTPhyMode->BW = (UCHAR)pAd->CommonCfg.RegTransmitSetting.field.BW;
+ pHTPhyMode->MCS= (UCHAR)pAd->StaCfg.DesiredTransmitSetting.field.MCS;
+ pHTPhyMode->SHORTGI= (UCHAR)pAd->CommonCfg.RegTransmitSetting.field.ShortGI;
+ pHTPhyMode->STBC= (UCHAR)pAd->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", pAd->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, &pAd->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, &pAd->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 (pAd->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 = pAd->SharedKey[BSS0][pAd->StaCfg.DefaultKeyId].KeyLen;
+ NdisMoveMemory(pKeyIdxValue->Value,
+ &pAd->SharedKey[BSS0][pAd->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",
+ pAd->StaCfg.DefaultKeyId,
+ wrq->u.data.length,
+ pAd->SharedKey[BSS0][pAd->StaCfg.DefaultKeyId].KeyLen,
+ pAd->SharedKey[BSS0][0].Key[0],
+ pAd->SharedKey[BSS0][1].Key[0],
+ pAd->SharedKey[BSS0][2].Key[0],
+ pAd->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, &pAd->StaCfg.DefaultKeyId, wrq->u.data.length);
+ DBGPRINT(RT_DEBUG_TRACE, ("DefaultKeyId =%d \n", pAd->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,
+ &pAd->SharedKey[BSS0][pAd->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(pAd, 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(pAd, 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 RTMP_MAC_PCI
+ {
+
+ USHORT device_id;
+ if (((POS_COOKIE)pAd->OS_Cookie)->pci_dev != NULL)
+ pci_read_config_word(((POS_COOKIE)pAd->OS_Cookie)->pci_dev, PCI_DEVICE_ID, &device_id);
+ else
+ DBGPRINT(RT_DEBUG_TRACE, (" pci_dev = NULL\n"));
+ sprintf((PSTRING)tmp, "%04x %04x\n", NIC_PCI_VENDOR_ID, device_id);
+ }
+#endif // RTMP_MAC_PCI //
+ wrq->u.data.length = strlen((PSTRING)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), pAd->CommonCfg.Channel));
+ Status = copy_to_user(wrq->u.data.pointer, &pAd->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 (pAd->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 = pAd->ChannelListNum;
+ for (i = 0; i < pChListBuf->ChannelListNum; i++)
+ pChListBuf->ChannelList[i] = pAd->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, &pAd->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, &pAd->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, &pAd->CommonCfg.bDLSCapable, wrq->u.data.length);
+ DBGPRINT(RT_DEBUG_TRACE, ("Query::RT_OID_802_11_QUERY_DLS(=%d)\n", pAd->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], &pAd->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 //
+
+ case OID_802_11_SET_PSPXLINK_MODE:
+ wrq->u.data.length = sizeof(BOOLEAN);
+ Status = copy_to_user(wrq->u.data.pointer, &pAd->CommonCfg.PSPXlink, wrq->u.data.length);
+ DBGPRINT(RT_DEBUG_TRACE, ("Query::OID_802_11_SET_PSPXLINK_MODE(=%d)\n", pAd->CommonCfg.PSPXlink));
+ break;
+
+
+ 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;
+ RTMP_ADAPTER *pAd = NULL;
+ struct iwreq *wrq = (struct iwreq *) rq;
+ BOOLEAN StateMachineTouched = FALSE;
+ INT Status = NDIS_STATUS_SUCCESS;
+ USHORT subcmd;
+
+
+ pAd = RTMP_OS_NETDEV_GET_PRIV(net_dev);
+ if (pAd == NULL)
+ {
+ /* if 1st open fail, pAd will be free;
+ So the net_dev->priv will be NULL in 2rd open */
+ return -ENETDOWN;
+ }
+ pObj = (POS_COOKIE) pAd->OS_Cookie;
+
+ //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 *erq = NULL;
+ erq = &wrq->u.data;
+ erq->length = strlen((PSTRING) pAd->nickname);
+ Status = copy_to_user(erq->pointer, pAd->nickname, erq->length);
+ 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)
+ 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)
+ 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 RTMP_RF_RW_SUPPORT
+ case RTPRIV_IOCTL_RF:
+ RTMPIoctlRF(pAd, wrq);
+ break;
+#endif // RTMP_RF_RW_SUPPORT //
+#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
+ RTMP_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 PSTRING 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)
+ {
+ RTMP_MLME_RESET_STATE_MACHINE(pAdapter);
+ DBGPRINT(RT_DEBUG_TRACE, ("!!! MLME busy, reset MLME state machine !!!\n"));
+ }
+
+ if ((pAdapter->StaCfg.WpaPassPhraseLen >= 8) &&
+ (pAdapter->StaCfg.WpaPassPhraseLen <= 64))
+ {
+ STRING passphrase_str[65] = {0};
+ UCHAR keyMaterial[40];
+
+ RTMPMoveMemory(passphrase_str, pAdapter->StaCfg.WpaPassPhrase, pAdapter->StaCfg.WpaPassPhraseLen);
+ RTMPZeroMemory(pAdapter->StaCfg.PMK, 32);
+ if (pAdapter->StaCfg.WpaPassPhraseLen == 64)
+ {
+ AtoH((PSTRING) pAdapter->StaCfg.WpaPassPhrase, pAdapter->StaCfg.PMK, 32);
+ }
+ else
+ {
+ PasswordHash((PSTRING) pAdapter->StaCfg.WpaPassPhrase, Ssid.Ssid, Ssid.SsidLength, keyMaterial);
+ NdisMoveMemory(pAdapter->StaCfg.PMK, keyMaterial, 32);
+ }
+ }
+
+ 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
+ RTMP_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 PSTRING arg)
+{
+ BOOLEAN bWmmCapable;
+
+ bWmmCapable = simple_strtol(arg, 0, 10);
+
+ if ((bWmmCapable == 1)
+ )
+ 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 PSTRING 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"));
+ }
+ 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
+ RTMP_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 PSTRING 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 PSTRING 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 PSTRING 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 PSTRING 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 PSTRING 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 PSTRING 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 PSTRING 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 pAd,
+ IN PSTRING arg)
+{
+ int status;
+
+ if ((pAd->StaCfg.AuthMode != Ndis802_11AuthModeWPAPSK) &&
+ (pAd->StaCfg.AuthMode != Ndis802_11AuthModeWPA2PSK) &&
+ (pAd->StaCfg.AuthMode != Ndis802_11AuthModeWPANone)
+ )
+ return TRUE; // do nothing
+
+ DBGPRINT(RT_DEBUG_TRACE, ("Set_WPAPSK_Proc::(WPAPSK=%s)\n", arg));
+
+ status = RT_CfgSetWPAPSKKey(pAd, arg, pAd->MlmeAux.Ssid, pAd->MlmeAux.SsidLen, pAd->StaCfg.PMK);
+ if (status == FALSE)
+ {
+ DBGPRINT(RT_DEBUG_TRACE, ("Set_WPAPSK_Proc(): Set key failed!\n"));
+ return FALSE;
+ }
+ NdisZeroMemory(pAd->StaCfg.WpaPassPhrase, 64);
+ NdisMoveMemory(pAd->StaCfg.WpaPassPhrase, arg, strlen(arg));
+ pAd->StaCfg.WpaPassPhraseLen = (UINT)strlen(arg);
+
+
+
+ if(pAd->StaCfg.BssType == BSS_ADHOC &&
+ pAd->StaCfg.AuthMode == Ndis802_11AuthModeWPANone)
+ {
+ pAd->StaCfg.WpaState = SS_NOTUSE;
+ }
+ else
+ {
+ // Start STA supplicant state machine
+ pAd->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 PSTRING 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 MlmeCheckPsmChange()
+ // 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 MlmeCheckPsmChange()
+ // 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 MlmeCheckPsmChange()
+ // 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
+ RTMP_SET_PSM_BIT(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;
+}
+//Add to suport the function which clould dynamicallly enable/disable PCIe Power Saving
+
+#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 PSTRING 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)
+{
+ PSTRING this_char;
+ PSTRING value;
+ INT j = 0, k = 0;
+ STRING msg[1024];
+ STRING arg[255];
+ ULONG macAddr = 0;
+ UCHAR temp[16];
+ STRING 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;
+ PSTRING 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)
+{
+ PSTRING this_char;
+ PSTRING value;
+ INT j = 0, k = 0;
+ STRING msg[1024];
+ STRING arg[255];
+ USHORT eepAddr = 0;
+ UCHAR temp[16];
+ STRING 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;
+ PSTRING 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;
+ STRING 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((PSTRING) this_char, "%d", &(rfId)) == 1)
+ {
+ if (rfId <= 31)
+ {
+#ifdef RALINK_ATE
+ /*
+ 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.
+ */
+ 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, 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((PSTRING) this_char, "%d", &(rfId)) == 1) && (sscanf((PSTRING) value, "%lx", &(rfValue)) == 1))
+ {
+ if (rfId <= 31)
+ {
+#ifdef RALINK_ATE
+ /*
+ 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.
+ */
+ 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, 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, 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++)
+ {
+#ifdef RALINK_ATE
+ /*
+ 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.
+ */
+ 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 PSTRING 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;
+}
+
+#ifdef EXT_BUILD_CHANNEL_LIST
+INT Set_Ieee80211dClientMode_Proc(
+ IN PRTMP_ADAPTER pAdapter,
+ IN PSTRING 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 PSTRING 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 PSTRING 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;
+}
+
+
+INT Set_BeaconLostTime_Proc(
+ IN PRTMP_ADAPTER pAd,
+ IN PSTRING arg)
+{
+ ULONG ltmp = (ULONG)simple_strtol(arg, 0, 10);
+
+ if ((ltmp != 0) && (ltmp <= 60))
+ pAd->StaCfg.BeaconLostTime = (ltmp * OS_HZ);
+
+ DBGPRINT(RT_DEBUG_TRACE, ("IF Set_BeaconLostTime_Proc::(BeaconLostTime=%ld)\n", pAd->StaCfg.BeaconLostTime));
+ return TRUE;
+}
+
+INT Set_AutoRoaming_Proc(
+ IN PRTMP_ADAPTER pAd,
+ IN PSTRING arg)
+{
+ if (simple_strtol(arg, 0, 10) == 0)
+ pAd->StaCfg.bAutoRoaming = FALSE;
+ else
+ pAd->StaCfg.bAutoRoaming = TRUE;
+
+ DBGPRINT(RT_DEBUG_TRACE, ("IF Set_AutoRoaming_Proc::(bAutoRoaming=%d)\n", pAd->StaCfg.bAutoRoaming));
+ return TRUE;
+}
+
+
+/*
+ ==========================================================================
+ Description:
+ Issue a site survey command to driver
+ Arguments:
+ pAdapter Pointer to our adapter
+ wrq Pointer to the ioctl argument
+
+ Return Value:
+ None
+
+ Note:
+ Usage:
+ 1.) iwpriv ra0 set site_survey
+ ==========================================================================
+*/
+INT Set_SiteSurvey_Proc(
+ IN PRTMP_ADAPTER pAd,
+ IN PSTRING arg)
+{
+ NDIS_802_11_SSID Ssid;
+
+ //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 (MONITOR_ON(pAd))
+ {
+ DBGPRINT(RT_DEBUG_TRACE, ("!!! Driver is in Monitor Mode now !!!\n"));
+ return -EINVAL;
+ }
+
+ RTMPZeroMemory(&Ssid, sizeof(NDIS_802_11_SSID));
+ Ssid.SsidLength = 0;
+ if ((arg != NULL) &&
+ (strlen(arg) <= MAX_LEN_OF_SSID))
+ {
+ RTMPMoveMemory(Ssid.Ssid, arg, strlen(arg));
+ Ssid.SsidLength = strlen(arg);
+ }
+
+ pAd->StaCfg.bScanReqIsFromWebUI = TRUE;
+
+ if (pAd->Mlme.CntlMachine.CurrState != CNTL_IDLE)
+ {
+ RTMP_MLME_RESET_STATE_MACHINE(pAd);
+ 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.
+ pAd->MlmeAux.CurrReqIsFromNdis = FALSE;
+ // Reset allowed scan retries
+ pAd->StaCfg.ScanCnt = 0;
+ NdisGetSystemUpTime(&pAd->StaCfg.LastScanTime);
+
+ MlmeEnqueue(pAd,
+ MLME_CNTL_STATE_MACHINE,
+ OID_802_11_BSSID_LIST_SCAN,
+ Ssid.SsidLength,
+ Ssid.Ssid);
+
+ RTMP_MLME_HANDLER(pAd);
+
+ DBGPRINT(RT_DEBUG_TRACE, ("Set_SiteSurvey_Proc\n"));
+
+ return TRUE;
+}
+
+INT Set_ForceTxBurst_Proc(
+ IN PRTMP_ADAPTER pAd,
+ IN PSTRING arg)
+{
+ if (simple_strtol(arg, 0, 10) == 0)
+ pAd->StaCfg.bForceTxBurst = FALSE;
+ else
+ pAd->StaCfg.bForceTxBurst = TRUE;
+
+ DBGPRINT(RT_DEBUG_TRACE, ("IF Set_ForceTxBurst_Proc::(bForceTxBurst=%d)\n", pAd->StaCfg.bForceTxBurst));
+ return TRUE;
+}
+
+#ifdef ANT_DIVERSITY_SUPPORT
+INT Set_Antenna_Proc(
+ IN PRTMP_ADAPTER pAd,
+ IN PUCHAR arg)
+{
+ UCHAR UsedAnt;
+ DBGPRINT(RT_DEBUG_TRACE, ("==> Set_Antenna_Proc *******************\n"));
+
+ if(simple_strtol(arg, 0, 10) <= 3)
+ UsedAnt = simple_strtol(arg, 0, 10);
+
+ pAd->CommonCfg.bRxAntDiversity = UsedAnt; // Auto switch
+ if (UsedAnt == ANT_DIVERSITY_ENABLE)
+ {
+ pAd->RxAnt.EvaluateStableCnt = 0;
+ DBGPRINT(RT_DEBUG_TRACE, ("<== Set_Antenna_Proc(Auto Switch Mode), (%d,%d)\n", pAd->RxAnt.Pair1PrimaryRxAnt, pAd->RxAnt.Pair1SecondaryRxAnt));
+ }
+ /* 2: Fix in the PHY Antenna CON1*/
+ if (UsedAnt == ANT_FIX_ANT1)
+ {
+ AsicSetRxAnt(pAd, 0);
+ DBGPRINT(RT_DEBUG_TRACE, ("<== Set_Antenna_Proc(Fix in Ant CON1), (%d,%d)\n", pAd->RxAnt.Pair1PrimaryRxAnt, pAd->RxAnt.Pair1SecondaryRxAnt));
+ }
+ /* 3: Fix in the PHY Antenna CON2*/
+ if (UsedAnt == ANT_FIX_ANT2)
+ {
+ AsicSetRxAnt(pAd, 1);
+ DBGPRINT(RT_DEBUG_TRACE, ("<== Set_Antenna_Proc(Fix in Ant CON2), (%d,%d)\n", pAd->RxAnt.Pair1PrimaryRxAnt, pAd->RxAnt.Pair1SecondaryRxAnt));
+ }
+
+ return TRUE;
+}
+#endif // ANT_DIVERSITY_SUPPORT // \ No newline at end of file
diff --git a/drivers/staging/rt3090/vr_ikans.h b/drivers/staging/rt3090/vr_ikans.h
new file mode 100644
index 000000000000..16bff3bec43b
--- /dev/null
+++ b/drivers/staging/rt3090/vr_ikans.h
@@ -0,0 +1,71 @@
+/*
+ *************************************************************************
+ * 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:
+ vr_ikans.h
+
+ Abstract:
+ Handle association related requests either from WSTA or from local MLME
+
+ Revision History:
+ Who When What
+ --------- ---------- ----------------------------------------------
+ Sample Lin 01-28-2008 Created
+ */
+
+#ifndef __VR_IKANS_H__
+#define __VR_IKANS_H__
+
+#ifndef MODULE_IKANOS
+#define IKANOS_EXTERN extern
+#else
+#define IKANOS_EXTERN
+#endif // MODULE_IKANOS //
+
+#ifdef IKANOS_VX_1X0
+ typedef void (*IkanosWlanTxCbFuncP)(void *, void *);
+
+ struct IKANOS_TX_INFO
+ {
+ struct net_device *netdev;
+ IkanosWlanTxCbFuncP *fp;
+ };
+#endif // IKANOS_VX_1X0 //
+
+
+IKANOS_EXTERN void VR_IKANOS_FP_Init(UINT8 BssNum, UINT8 *pApMac);
+
+IKANOS_EXTERN INT32 IKANOS_DataFramesTx(struct sk_buff *pSkb,
+ struct net_device *pNetDev);
+
+IKANOS_EXTERN void IKANOS_DataFrameRx(PRTMP_ADAPTER pAd,
+ void *pRxParam,
+ struct sk_buff *pSkb,
+ UINT32 Length);
+
+#endif // __VR_IKANS_H__ //
+
+/* End of vr_ikans.h */
diff --git a/drivers/staging/rt3090/wpa.h b/drivers/staging/rt3090/wpa.h
new file mode 100644
index 000000000000..8baa28774e30
--- /dev/null
+++ b/drivers/staging/rt3090/wpa.h
@@ -0,0 +1,447 @@
+/*
+ *************************************************************************
+ * 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 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
+#define LEN_PMK 32
+#define LEN_PMK_NAME 16
+#define LEN_NONCE 32
+
+// RSN IE Length definition
+#define MAX_LEN_OF_RSNIE 255
+#define MIN_LEN_OF_RSNIE 8
+
+#define KEY_LIFETIME 3600
+
+//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
+
+// WPA mechanism retry timer interval
+#define PEER_MSG1_RETRY_EXEC_INTV 1000 // 1 sec
+#define PEER_MSG3_RETRY_EXEC_INTV 3000 // 3 sec
+#define GROUP_KEY_UPDATE_EXEC_INTV 1000 // 1 sec
+#define PEER_GROUP_KEY_UPDATE_INIV 2000 // 2 sec
+
+#define ENQUEUE_EAPOL_START_TIMER 200 // 200 ms
+
+// group rekey interval
+#define TIME_REKEY 0
+#define PKT_REKEY 1
+#define DISABLE_REKEY 2
+#define MAX_REKEY 2
+
+#define MAX_REKEY_INTER 0x3ffffff
+
+#define GROUP_SUITE 0
+#define PAIRWISE_SUITE 1
+#define AKM_SUITE 2
+#define PMKID_LIST 3
+
+
+#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)
+
+#ifndef ROUND_UP
+#define ROUND_UP(__x, __y) \
+ (((ULONG)((__x)+((__y)-1))) & ((ULONG)~((__y)-1)))
+#endif
+
+#define SET_UINT16_TO_ARRARY(_V, _LEN) \
+{ \
+ _V[0] = (_LEN & 0xFF00) >> 8; \
+ _V[1] = (_LEN & 0xFF); \
+}
+
+#define INC_UINT16_TO_ARRARY(_V, _LEN) \
+{ \
+ UINT16 var_len; \
+ \
+ var_len = (_V[0]<<8) | (_V[1]); \
+ var_len += _LEN; \
+ \
+ _V[0] = (var_len & 0xFF00) >> 8; \
+ _V[1] = (var_len & 0xFF); \
+}
+
+#define CONV_ARRARY_TO_UINT16(_V) ((_V[0]<<8) | (_V[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;
+
+
+/*========================================
+ The prototype is defined in cmm_wpa.c
+ ========================================*/
+BOOLEAN WpaMsgTypeSubst(
+ IN UCHAR EAPType,
+ OUT INT *MsgType);
+
+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 PasswordHash(
+ char *password,
+ unsigned char *ssid,
+ int ssidlength,
+ unsigned char *output);
+
+PUINT8 GetSuiteFromRSNIE(
+ IN PUINT8 rsnie,
+ IN UINT rsnie_len,
+ IN UINT8 type,
+ OUT UINT8 *count);
+
+VOID WpaShowAllsuite(
+ IN PUINT8 rsnie,
+ IN UINT rsnie_len);
+
+VOID RTMPInsertRSNIE(
+ IN PUCHAR pFrameBuf,
+ OUT PULONG pFrameLen,
+ IN PUINT8 rsnie_ptr,
+ IN UINT8 rsnie_len,
+ IN PUINT8 pmkid_ptr,
+ IN UINT8 pmkid_len);
+
+
+#endif
diff --git a/drivers/staging/rtl8187se/Makefile b/drivers/staging/rtl8187se/Makefile
index 6bc7e29771c3..98b230082071 100644
--- a/drivers/staging/rtl8187se/Makefile
+++ b/drivers/staging/rtl8187se/Makefile
@@ -1,12 +1,8 @@
#EXTRA_CFLAGS += -DCONFIG_IEEE80211_NOWEP=y
-#EXTRA_CFLAGS += -DCONFIG_RTL8180_IOMAP
#EXTRA_CFLAGS += -std=gnu89
#EXTRA_CFLAGS += -O2
#CC = gcc
-EXTRA_CFLAGS += -DTHOMAS_TURBO
-#CFLAGS += -DCONFIG_RTL8185B
-#CFLAGS += -DCONFIG_RTL818x_S
#added for EeePC testing
EXTRA_CFLAGS += -DENABLE_IPS
@@ -15,10 +11,6 @@ EXTRA_CFLAGS += -DTX_TRACK
EXTRA_CFLAGS += -DHIGH_POWER
EXTRA_CFLAGS += -DSW_DIG
EXTRA_CFLAGS += -DRATE_ADAPT
-EXTRA_CFLAGS += -DCONFIG_RTL8180_PM
-
-#+YJ,080626
-EXTRA_CFLAGS += -DENABLE_DOT11D
#enable it for legacy power save, disable it for leisure power save
EXTRA_CFLAGS += -DENABLE_LPS
@@ -28,17 +20,11 @@ EXTRA_CFLAGS += -DENABLE_LPS
rtl8187se-objs := \
r8180_core.o \
- r8180_sa2400.o \
r8180_93cx6.o \
r8180_wx.o \
- r8180_max2820.o \
- r8180_gct.o \
- r8180_rtl8225.o \
- r8180_rtl8255.o \
r8180_rtl8225z2.o \
r8185b_init.o \
r8180_dm.o \
- r8180_pm.o \
ieee80211/dot11d.o \
ieee80211/ieee80211_softmac.o \
ieee80211/ieee80211_rx.o \
diff --git a/drivers/staging/rtl8187se/TODO b/drivers/staging/rtl8187se/TODO
new file mode 100644
index 000000000000..74e79c7c794f
--- /dev/null
+++ b/drivers/staging/rtl8187se/TODO
@@ -0,0 +1,21 @@
+TODO:
+- prepare private ieee80211 stack for merge with rtl8192su's version:
+ - remove [IN]_OPENSUSE_SLED definitions
+ - remove ENABLE_IPS ifdefs
+ - rename struct ieee80211_hdr to struct ieee80211_hdr_4addr
+ - rename struct ieee80211_hdr_3addr_QOS to struct ieee80211_hdr_3addrqos
+ - rename struct ieee80211_hdr_QOS to struct ieee80211_hdr_4addrqos
+ - add hwsec_active flag to struct ieee80211_device
+ - add bHwSec flag to cb_desc structure
+ - switch ieee80211.h to use <linux/ieee80211.h>
+- switch to use shared "librtl" instead of private ieee80211 stack
+- switch to use LIB80211
+- switch to use MAC80211
+- switch to use EEPROM_93CX6
+- use kernel coding style
+- checkpatch.pl fixes
+- sparse fixes
+- integrate with drivers/net/wireless/rtl818x
+
+Please send any patches to Greg Kroah-Hartman <greg@kroah.com> and
+Bartlomiej Zolnierkiewicz <bzolnier@gmail.com>.
diff --git a/drivers/staging/rtl8187se/dot11d.h b/drivers/staging/rtl8187se/dot11d.h
deleted file mode 100644
index 2417da99529f..000000000000
--- a/drivers/staging/rtl8187se/dot11d.h
+++ /dev/null
@@ -1,101 +0,0 @@
-#ifndef __INC_DOT11D_H
-#define __INC_DOT11D_H
-
-#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 // #ifndef __INC_DOT11D_H
diff --git a/drivers/staging/rtl8187se/ieee80211.h b/drivers/staging/rtl8187se/ieee80211.h
deleted file mode 100644
index 58336080ad50..000000000000
--- a/drivers/staging/rtl8187se/ieee80211.h
+++ /dev/null
@@ -1,1755 +0,0 @@
-/*
- * 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/jiffies.h>
-#include <linux/timer.h>
-#include <linux/sched.h>
-
-#if (LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,13))
-#include <linux/wireless.h>
-#endif
-
-/*
-#ifndef bool
-#define bool int
-#endif
-
-#ifndef true
-#define true 1
-#endif
-
-#ifndef false
-#define false 0
-#endif
-*/
-#if (LINUX_VERSION_CODE < KERNEL_VERSION(2,6,20))
-#ifndef bool
-typedef enum{false = 0, true} bool;
-#endif
-#endif
-//#ifdef JOHN_HWSEC
-#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
-//#endif
-
-
-#define aSifsTime 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
-
-#if (LINUX_VERSION_CODE > KERNEL_VERSION(2,6,10))
-#define ieee80211_wx_get_scan ieee80211_wx_get_scan_rtl
-#define ieee80211_wx_set_encode ieee80211_wx_set_encode_rtl
-#define ieee80211_wx_get_encode ieee80211_wx_get_encode_rtl
-////////////////////////////////
-// added for kernel conflict under FC5
-#define ieee80211_wx_get_name ieee80211_wx_get_name_rtl
-#define free_ieee80211 free_ieee80211_rtl
-#define alloc_ieee80211 alloc_ieee80211_rtl
-///////////////////////////////
-#endif
-//error in ubuntu2.6.22,so add these
-#define ieee80211_wake_queue ieee80211_wake_queue_rtl
-#define ieee80211_stop_queue ieee80211_stop_queue_rtl
-
-#define ieee80211_rx ieee80211_rx_rtl
-
-#define ieee80211_register_crypto_ops ieee80211_register_crypto_ops_rtl
-#define ieee80211_unregister_crypto_ops ieee80211_unregister_crypto_ops_rtl
-#define ieee80211_get_crypto_ops ieee80211_get_crypto_ops_rtl
-#define ieee80211_crypt_deinit_entries ieee80211_crypt_deinit_entries_rtl
-#define ieee80211_crypt_deinit_handler ieee80211_crypt_deinit_handler_rtl
-#define ieee80211_crypt_delayed_deinit ieee80211_crypt_delayed_deinit_rtl
-
-#define ieee80211_txb_free ieee80211_txb_free_rtl
-#define ieee80211_wx_get_essid ieee80211_wx_get_essid_rtl
-#define ieee80211_wx_set_essid ieee80211_wx_set_essid_rtl
-#define ieee80211_wx_set_rate ieee80211_wx_set_rate_rtl
-#define ieee80211_wx_get_rate ieee80211_wx_get_rate_rtl
-#define ieee80211_wx_set_wap ieee80211_wx_set_wap_rtl
-#define ieee80211_wx_get_wap ieee80211_wx_get_wap_rtl
-#define ieee80211_wx_set_mode ieee80211_wx_set_mode_rtl
-#define ieee80211_wx_get_mode ieee80211_wx_get_mode_rtl
-#define ieee80211_wx_set_scan ieee80211_wx_set_scan_rtl
-#define ieee80211_wx_get_freq ieee80211_wx_get_freq_rtl
-#define ieee80211_wx_set_freq ieee80211_wx_set_freq_rtl
-#define ieee80211_wx_set_rawtx ieee80211_wx_set_rawtx_rtl
-#define ieee80211_wx_set_power ieee80211_wx_set_power_rtl
-#define ieee80211_wx_get_power ieee80211_wx_get_power_rtl
-#define ieee80211_wlan_frequencies ieee80211_wlan_frequencies_rtl
-#define ieee80211_softmac_stop_protocol ieee80211_softmac_stop_protocol_rtl
-#define ieee80211_softmac_start_protocol ieee80211_softmac_start_protocol_rtl
-#define ieee80211_start_protocol ieee80211_start_protocol_rtl
-#define ieee80211_stop_protocol ieee80211_stop_protocol_rtl
-#define ieee80211_rx_mgt ieee80211_rx_mgt_rtl
-
-#define ieee80211_wx_set_auth ieee80211_wx_set_auth_rtl
-//by amy for ps
-#define notify_wx_assoc_event notify_wx_assoc_event_rtl
-#define ieee80211_stop_send_beacons ieee80211_stop_send_beacons_rtl
-#define ieee80211_disassociate ieee80211_disassociate_rtl
-#define ieee80211_start_scan ieee80211_start_scan_rtl
-//by amy for ps
-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
-
-// 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)
-static inline unsigned long msleep_interruptible_rtl(unsigned int msecs)
-{
- unsigned long timeout = MSECS(msecs) + 1;
-
- while (timeout) {
- set_current_state(TASK_UNINTERRUPTIBLE);
- timeout = schedule_timeout(timeout);
- }
- return timeout;
-}
-#else
-#define MSECS(t) msecs_to_jiffies(t)
-#define msleep_interruptible_rtl 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_HLEN 30
-#define IEEE80211_FRAME_LEN (IEEE80211_DATA_LEN + IEEE80211_HLEN)
-
-/* 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;
-};
-
-struct ieee80211_hdr {
- u16 frame_ctl;
- u16 duration_id;
- u8 addr1[ETH_ALEN];
- u8 addr2[ETH_ALEN];
- u8 addr3[ETH_ALEN];
- u16 seq_ctl;
- u8 addr4[ETH_ALEN];
-} __attribute__ ((packed));
-
-struct ieee80211_hdr_QOS {
- u16 frame_ctl;
- u16 duration_id;
- u8 addr1[ETH_ALEN];
- u8 addr2[ETH_ALEN];
- u8 addr3[ETH_ALEN];
- u16 seq_ctl;
- u8 addr4[ETH_ALEN];
- u16 QOS_ctl;
-} __attribute__ ((packed));
-
-struct ieee80211_hdr_3addr {
- u16 frame_ctl;
- u16 duration_id;
- u8 addr1[ETH_ALEN];
- u8 addr2[ETH_ALEN];
- u8 addr3[ETH_ALEN];
- u16 seq_ctl;
-} __attribute__ ((packed));
-
-struct ieee80211_hdr_3addr_QOS {
- u16 frame_ctl;
- u16 duration_id;
- u8 addr1[ETH_ALEN];
- u8 addr2[ETH_ALEN];
- u8 addr3[ETH_ALEN];
- u16 seq_ctl;
- u16 QOS_ctl;
-} __attribute__ ((packed));
-
-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 (type >= ARRAY_SIZE(eap_types)) ? "Unknown" : eap_types[type];
-}
-
-struct eapol {
- u8 snap[6];
- u16 ethertype;
- u8 version;
- u8 type;
- u16 length;
-} __attribute__ ((packed));
-
-#define IEEE80211_3ADDR_LEN 24
-#define IEEE80211_4ADDR_LEN 30
-#define IEEE80211_FCS_LEN 4
-
-#define MIN_FRAG_THRESHOLD 256U
-#define MAX_FRAG_THRESHOLD 2346U
-
-/* Frame control field constants */
-#define IEEE80211_FCTL_VERS 0x0002
-#define IEEE80211_FCTL_FTYPE 0x000c
-#define IEEE80211_FCTL_STYPE 0x00f0
-#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
-
-/* 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
-
-
-/* debug macros */
-
-#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: %c %s " fmt, \
- in_interrupt() ? 'I' : 'U', __func__ , ## args); } while (0)
-#else
-#define IEEE80211_DEBUG(level, fmt, args...) do {} while (0)
-#endif /* CONFIG_IEEE80211_DEBUG */
-
-/*
- * 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_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 IEEE_DEBUG_SCAN IEEE80211_WARNING
-#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)
-#include <linux/netdevice.h>
-#include <linux/wireless.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_TYPE(fc) ((fc) & IEEE80211_FCTL_FTYPE)
-#define WLAN_FC_GET_STYPE(fc) ((fc) & IEEE80211_FCTL_STYPE)
-
-#define WLAN_GET_SEQ_FRAG(seq) ((seq) & IEEE80211_SCTL_FRAG)
-#define WLAN_GET_SEQ_SEQ(seq) ((seq) & IEEE80211_SCTL_SEQ)
-
-/* Authentication algorithms */
-#define WLAN_AUTH_OPEN 0
-#define WLAN_AUTH_SHARED_KEY 1
-
-#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_SHORT_SLOT (1<<10)
-
-/* Status codes */
-#define WLAN_STATUS_SUCCESS 0
-#define WLAN_STATUS_UNSPECIFIED_FAILURE 1
-#define WLAN_STATUS_CAPS_UNSUPPORTED 10
-#define WLAN_STATUS_REASSOC_NO_ASSOC 11
-#define WLAN_STATUS_ASSOC_DENIED_UNSPEC 12
-#define WLAN_STATUS_NOT_SUPPORTED_AUTH_ALG 13
-#define WLAN_STATUS_UNKNOWN_AUTH_TRANSACTION 14
-#define WLAN_STATUS_CHALLENGE_FAIL 15
-#define WLAN_STATUS_AUTH_TIMEOUT 16
-#define WLAN_STATUS_AP_UNABLE_TO_HANDLE_NEW_STA 17
-#define WLAN_STATUS_ASSOC_DENIED_RATES 18
-/* 802.11b */
-#define WLAN_STATUS_ASSOC_DENIED_NOSHORT 19
-#define WLAN_STATUS_ASSOC_DENIED_NOPBCC 20
-#define WLAN_STATUS_ASSOC_DENIED_NOAGILITY 21
-
-/* Reason codes */
-#define WLAN_REASON_UNSPECIFIED 1
-#define WLAN_REASON_PREV_AUTH_NOT_VALID 2
-#define WLAN_REASON_DEAUTH_LEAVING 3
-#define WLAN_REASON_DISASSOC_DUE_TO_INACTIVITY 4
-#define WLAN_REASON_DISASSOC_AP_BUSY 5
-#define WLAN_REASON_CLASS2_FRAME_FROM_NONAUTH_STA 6
-#define WLAN_REASON_CLASS3_FRAME_FROM_NONASSOC_STA 7
-#define WLAN_REASON_DISASSOC_STA_HAS_LEFT 8
-#define WLAN_REASON_STA_REQ_ASSOC_WITHOUT_AUTH 9
-
-
-/* Information Element IDs */
-#define WLAN_EID_SSID 0
-#define WLAN_EID_SUPP_RATES 1
-#define WLAN_EID_FH_PARAMS 2
-#define WLAN_EID_DS_PARAMS 3
-#define WLAN_EID_CF_PARAMS 4
-#define WLAN_EID_TIM 5
-#define WLAN_EID_IBSS_PARAMS 6
-#define WLAN_EID_CHALLENGE 16
-#define WLAN_EID_RSN 48
-#define WLAN_EID_GENERIC 221
-
-#define IEEE80211_MGMT_HDR_LEN 24
-#define IEEE80211_DATA_HDR3_LEN 24
-#define IEEE80211_DATA_HDR4_LEN 30
-
-
-#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
-
-
-
-
-/* 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 {
- u32 mac_time[2];
- u8 signalstrength;
- s8 rssi;
- u8 signal;
- u8 noise;
- u16 rate; /* in 100 kbps */
- u8 received_channel;
- u8 control;
- u8 mask;
- u8 freq;
- u16 len;
- u8 nic_type;
-};
-
-/* 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_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;
-};
-
-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_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 WEP_KEYS 4
-#define WEP_KEY_LEN 13
-
-#define WEP_KEY_LEN_MODIF 32
-
-struct ieee80211_security {
- u16 active_key:2,
- enabled:1,
- auth_mode:2,
- auth_algo:4,
- unicast_uses_group:1;
- u8 key_sizes[WEP_KEYS];
- u8 keys[WEP_KEYS][WEP_KEY_LEN_MODIF];
- 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
-
-*/
-
-struct ieee80211_header_data {
- u16 frame_ctl;
- u16 duration_id;
- u8 addr1[6];
- u8 addr2[6];
- u8 addr3[6];
- u16 seq_ctrl;
-};
-
-#define BEACON_PROBE_SSID_ID_POSITION 12
-
-/* Management Frame Information Element Types */
-#define MFIE_TYPE_SSID 0
-#define MFIE_TYPE_RATES 1
-#define MFIE_TYPE_FH_SET 2
-#define MFIE_TYPE_DS_SET 3
-#define MFIE_TYPE_CF_SET 4
-#define MFIE_TYPE_TIM 5
-#define MFIE_TYPE_IBSS_SET 6
-#define MFIE_TYPE_COUNTRY 7 //+YJ,080625
-#define MFIE_TYPE_CHALLENGE 16
-#define MFIE_TYPE_ERP 42
-#define MFIE_TYPE_RSN 48
-#define MFIE_TYPE_RATES_EX 50
-#define MFIE_TYPE_GENERIC 221
-
-#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 = 8,
- COUNTRY_CODE_GLOBAL_DOMAIN = 9,
- COUNTRY_CODE_WORLD_WIDE_13_INDEX = 10
-}country_code_type_t;
-#endif
-
-struct ieee80211_info_element_hdr {
- u8 id;
- u8 len;
-} __attribute__ ((packed));
-
-struct ieee80211_info_element {
- u8 id;
- u8 len;
- u8 data[0];
-} __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 10
-
-struct ieee80211_authentication {
- struct ieee80211_header_data header;
- u16 algorithm;
- u16 transaction;
- u16 status;
- //struct ieee80211_info_element_hdr info_element;
-} __attribute__ ((packed));
-
-
-struct ieee80211_probe_response {
- struct ieee80211_header_data header;
- u32 time_stamp[2];
- u16 beacon_interval;
- u16 capability;
- struct ieee80211_info_element info_element;
-} __attribute__ ((packed));
-
-struct ieee80211_probe_request {
- struct ieee80211_header_data header;
- /*struct ieee80211_info_element info_element;*/
-} __attribute__ ((packed));
-
-struct ieee80211_assoc_request_frame {
- struct ieee80211_hdr_3addr header;
- u16 capability;
- u16 listen_interval;
- //u8 current_ap[ETH_ALEN];
- struct ieee80211_info_element_hdr info_element;
-} __attribute__ ((packed));
-
-struct ieee80211_assoc_response_frame {
- struct ieee80211_hdr_3addr header;
- u16 capability;
- u16 status;
- u16 aid;
- struct ieee80211_info_element info_element; /* supported rates */
-} __attribute__ ((packed));
-
-struct ieee80211_disassoc_frame{
- struct ieee80211_hdr_3addr header;
- u16 reasoncode;
-}__attribute__ ((packed));
-
-struct ieee80211_txb {
- u8 nr_frags;
- u8 encrypted;
- u16 reserved;
- u16 frag_size;
- u16 payload_size;
- struct sk_buff *fragments[0];
-};
-
-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));
-
-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)
-
-/* 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 MAX_CHANNEL_NUMBER 165 //YJ,modified,080625
-#define MAX_IE_LEN 0xFF //+YJ,080625
-
-typedef struct _CHANNEL_LIST{
- u8 Channel[MAX_CHANNEL_NUMBER + 1];
- u8 Len;
-}CHANNEL_LIST, *PCHANNEL_LIST;
-
-#define IEEE80211_SOFTMAC_SCAN_TIME 100//400
-//(HZ / 2)
-//by amy for ps
-#define IEEE80211_WATCH_DOG_TIME 2000
-//by amy for ps
-//by amy for antenna
-#define ANTENNA_DIVERSITY_TIMER_PERIOD 1000 // 1000 m
-//by amy for antenna
-#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)
-
-#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
-#define IEEE80211_PS_ENABLE IEEE80211_DTIM_VALID
-//added by David for QoS 2006/6/30
-//#define WMM_Hang_8187
-#ifdef WMM_Hang_8187
-#undef WMM_Hang_8187
-#endif
-
-#define WME_AC_BE 0x00
-#define WME_AC_BK 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
-
-//UP Mapping to AC, using in MgntQuery_SequenceNumber() and maybe for DSCP
-//#define UP2AC(up) ((up<3) ? ((up==0)?1:0) : (up>>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)
-//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 */
-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
-
-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;
-
- /* 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;
- u8 flags;
- u32 last_associate;
- u32 time_stamp[2];
- u16 beacon_interval;
- u16 listen_interval;
- u16 atim_window;
- u8 wpa_ie[MAX_WPA_IE_LEN];
- size_t wpa_ie_len;
- u8 rsn_ie[MAX_WPA_IE_LEN];
- size_t rsn_ie_len;
- u8 dtim_period;
- u8 dtim_data;
- u32 last_dtim_sta_time[2];
- struct list_head list;
- //appeded for QoS
- u8 wmm_info;
- struct ieee80211_wmm_ac_param wmm_param[4];
- u8 QoS_Enable;
- u8 SignalStrength;
-//by amy 080312
- u8 HighestOperaRate;
-//by amy 080312
-#ifdef THOMAS_TURBO
- u8 Turbo_Enable;//enable turbo mode, added by thomas
-#endif
-#ifdef ENABLE_DOT11D
- u16 CountryIeLen;
- u8 CountryIeBuf[MAX_IE_LEN];
-#endif
-};
-
-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,
-
-};
-
-#define DEFAULT_MAX_SCAN_AGE (15 * HZ)
-#define DEFAULT_FTS 2346
-#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]
-
-
-#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
-
-#define CFG_IEEE80211_RESERVE_FCS (1<<0)
-#define CFG_IEEE80211_COMPUTE_FCS (1<<1)
-
-typedef struct tx_pending_t{
- int frag;
- struct ieee80211_txb *txb;
-}tx_pending_t;
-
-
-struct ieee80211_device {
- struct net_device *dev;
-
- /* 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_*) */
-
- 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 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_decrypt;
- int ieee802_1x; /* is IEEE 802.1X used */
-
- /* WPA data */
- 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 broadcast_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 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 */
-
- /* 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 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;
-
-#ifdef ENABLE_DOT11D
- void * pDot11dInfo;
- bool bGlobalDomain;
-
- // For Liteon Ch12~13 passive scan
- u8 MinPassiveChnlNum;
- u8 IbssStartChnl;
-#else
- /* map of allowed channels. 0 is dummy */
- // FIXME: remeber to default to a basic channel plan depending of the PHY type
- 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*/
- short ps;
- short sta_sleep;
- int ps_timeout;
- 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;
-
- /* 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;
-
-
- /* 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;
-
- struct work_struct associate_complete_wq;
-// struct work_struct associate_retry_wq;
- struct work_struct associate_procedure_wq;
-// struct work_struct softmac_scan_wq;
- struct work_struct wx_sync_scan_wq;
- struct work_struct wmm_param_update_wq;
- struct work_struct ps_request_tx_ack_wq;//for ps
-// struct work_struct hw_wakeup_wq;
-// struct work_struct hw_sleep_wq;
-// struct work_struct watch_dog_wq;
- bool bInactivePs;
- bool actscanning;
- bool beinretry;
- u16 ListenInterval;
- unsigned long NumRxDataInPeriod; //YJ,add,080828
- unsigned long NumRxBcnInPeriod; //YJ,add,080828
- unsigned long NumRxOkTotal;
- unsigned long NumRxUnicast;//YJ,add,080828,for keep alive
- bool bHwRadioOff;
-#if LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,20)
- struct delayed_work softmac_scan_wq;
- struct delayed_work associate_retry_wq;
- struct delayed_work hw_wakeup_wq;
- struct delayed_work hw_sleep_wq;//+by amy 080324
- struct delayed_work watch_dog_wq;
- struct delayed_work sw_antenna_wq;
- struct delayed_work start_ibss_wq;
-//by amy for rate adaptive 080312
- struct delayed_work rate_adapter_wq;
-//by amy for rate adaptive
- struct delayed_work hw_dig_wq;
- struct delayed_work tx_pw_wq;
-
-//Added for RF power on power off by lizhaoming 080512
- struct delayed_work GPIOChangeRFWorkItem;
-#else
-
- struct work_struct start_ibss_wq;
- struct work_struct softmac_scan_wq;
- struct work_struct associate_retry_wq;
- struct work_struct hw_wakeup_wq;
- struct work_struct hw_sleep_wq;
- struct work_struct watch_dog_wq;
- struct work_struct sw_antenna_wq;
-//by amy for rate adaptive 080312
- struct work_struct rate_adapter_wq;
-//by amy for rate adaptive
- struct work_struct hw_dig_wq;
- struct work_struct tx_pw_wq;
-
-//Added for RF power on power off by lizhaoming 080512
- struct work_struct GPIOChangeRFWorkItem;
-#endif
- struct workqueue_struct *wq;
-
- /* 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);
-
- /* 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);
-
- /* QoS related */
- //void (*wmm_param_update) (struct net_device *dev, u8 *ac_param);
- //void (*wmm_param_update) (struct ieee80211_device *ieee);
-
- /* 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_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)
-{
- return ((struct ieee80211_device *)netdev_priv(dev))->priv;
-}
-
-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 = 24;
-
- switch (WLAN_FC_GET_TYPE(fc)) {
- case IEEE80211_FTYPE_DATA:
- if ((fc & IEEE80211_FCTL_FROMDS) && (fc & IEEE80211_FCTL_TODS))
- hdrlen = 30; /* 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 = 10;
- break;
- default:
- hdrlen = 16;
- break;
- }
- break;
- }
-
- return hdrlen;
-}
-
-
-
-/* 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 *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);
-extern int ieee80211_wx_set_encode_ext(struct ieee80211_device *ieee,
- struct iw_request_info *info,
- union iwreq_data* wrqu, char *extra);
-int ieee80211_wx_set_auth(struct ieee80211_device *ieee,
- struct iw_request_info *info,
- struct iw_param *data, char *extra);
-int ieee80211_wx_set_mlme(struct ieee80211_device *ieee,
- struct iw_request_info *info,
- union iwreq_data *wrqu, char *extra);
-
-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);
-
-extern void ieee80211_softmac_xmit(struct ieee80211_txb *txb, 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 SendDisassociation(struct ieee80211_device *ieee,u8* asSta,u8 asRsn);
-extern void ieee80211_start_scan(struct ieee80211_device *ieee);
-
-//Add for RF power on power off by lizhaoming 080512
-extern void SendDisassociation(struct ieee80211_device *ieee,
- u8* asSta,
- u8 asRsn);
-
-/* 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);
-#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 void ieee80211_wx_sync_scan_wq(struct ieee80211_device *ieee);
-
-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 void ieee80211_softmac_ips_scan_syncro(struct ieee80211_device *ieee);
-
-extern void ieee80211_sta_ps_send_null_frame(struct ieee80211_device *ieee, short pwr);
-
-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;
-}
-#endif /* IEEE80211_H */
diff --git a/drivers/staging/rtl8187se/ieee80211/dot11d.c b/drivers/staging/rtl8187se/ieee80211/dot11d.c
index 54bcdcf1d330..309bb8bf287e 100644
--- a/drivers/staging/rtl8187se/ieee80211/dot11d.c
+++ b/drivers/staging/rtl8187se/ieee80211/dot11d.c
@@ -1,4 +1,3 @@
-#ifdef ENABLE_DOT11D
//-----------------------------------------------------------------------------
// File:
// Dot11d.c
@@ -130,16 +129,6 @@ Dot11d_UpdateCountryIe(
pDot11dInfo->State = DOT11D_STATE_LEARNED;
}
-void dump_chnl_map(u8 * channel_map)
-{
- int i;
- printk("Channel List:");
- for(i=1; i<= MAX_CHANNEL_NUMBER; i++)
- if(channel_map[i] > 0)
- printk(" %d(%d)", i, channel_map[i]);
- printk("\n");
-}
-
u8
DOT11D_GetMaxTxPwrInDbm(
struct ieee80211_device *dev,
@@ -233,14 +222,3 @@ int ToLegalChannel(
return default_chn;
}
-
-#if 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);
-#endif
-#endif
diff --git a/drivers/staging/rtl8187se/ieee80211/dot11d.h b/drivers/staging/rtl8187se/ieee80211/dot11d.h
index 82576b519cc5..029c2cab1e00 100644
--- a/drivers/staging/rtl8187se/ieee80211/dot11d.h
+++ b/drivers/staging/rtl8187se/ieee80211/dot11d.h
@@ -97,6 +97,4 @@ int ToLegalChannel(
struct ieee80211_device * dev,
u8 channel
);
-
-void dump_chnl_map(u8 * channel_map);
#endif // #ifndef __INC_DOT11D_H
diff --git a/drivers/staging/rtl8187se/ieee80211/ieee80211.h b/drivers/staging/rtl8187se/ieee80211/ieee80211.h
index 58336080ad50..0a5e7158d66b 100644
--- a/drivers/staging/rtl8187se/ieee80211/ieee80211.h
+++ b/drivers/staging/rtl8187se/ieee80211/ieee80211.h
@@ -29,10 +29,7 @@
#include <linux/jiffies.h>
#include <linux/timer.h>
#include <linux/sched.h>
-
-#if (LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,13))
#include <linux/wireless.h>
-#endif
/*
#ifndef bool
@@ -47,19 +44,12 @@
#define false 0
#endif
*/
-#if (LINUX_VERSION_CODE < KERNEL_VERSION(2,6,20))
-#ifndef bool
-typedef enum{false = 0, true} bool;
-#endif
-#endif
-//#ifdef JOHN_HWSEC
+
#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
-//#endif
-
#define aSifsTime 10
@@ -112,58 +102,6 @@ typedef enum{false = 0, true} bool;
#define IEEE_CRYPT_ALG_NAME_LEN 16
-#if (LINUX_VERSION_CODE > KERNEL_VERSION(2,6,10))
-#define ieee80211_wx_get_scan ieee80211_wx_get_scan_rtl
-#define ieee80211_wx_set_encode ieee80211_wx_set_encode_rtl
-#define ieee80211_wx_get_encode ieee80211_wx_get_encode_rtl
-////////////////////////////////
-// added for kernel conflict under FC5
-#define ieee80211_wx_get_name ieee80211_wx_get_name_rtl
-#define free_ieee80211 free_ieee80211_rtl
-#define alloc_ieee80211 alloc_ieee80211_rtl
-///////////////////////////////
-#endif
-//error in ubuntu2.6.22,so add these
-#define ieee80211_wake_queue ieee80211_wake_queue_rtl
-#define ieee80211_stop_queue ieee80211_stop_queue_rtl
-
-#define ieee80211_rx ieee80211_rx_rtl
-
-#define ieee80211_register_crypto_ops ieee80211_register_crypto_ops_rtl
-#define ieee80211_unregister_crypto_ops ieee80211_unregister_crypto_ops_rtl
-#define ieee80211_get_crypto_ops ieee80211_get_crypto_ops_rtl
-#define ieee80211_crypt_deinit_entries ieee80211_crypt_deinit_entries_rtl
-#define ieee80211_crypt_deinit_handler ieee80211_crypt_deinit_handler_rtl
-#define ieee80211_crypt_delayed_deinit ieee80211_crypt_delayed_deinit_rtl
-
-#define ieee80211_txb_free ieee80211_txb_free_rtl
-#define ieee80211_wx_get_essid ieee80211_wx_get_essid_rtl
-#define ieee80211_wx_set_essid ieee80211_wx_set_essid_rtl
-#define ieee80211_wx_set_rate ieee80211_wx_set_rate_rtl
-#define ieee80211_wx_get_rate ieee80211_wx_get_rate_rtl
-#define ieee80211_wx_set_wap ieee80211_wx_set_wap_rtl
-#define ieee80211_wx_get_wap ieee80211_wx_get_wap_rtl
-#define ieee80211_wx_set_mode ieee80211_wx_set_mode_rtl
-#define ieee80211_wx_get_mode ieee80211_wx_get_mode_rtl
-#define ieee80211_wx_set_scan ieee80211_wx_set_scan_rtl
-#define ieee80211_wx_get_freq ieee80211_wx_get_freq_rtl
-#define ieee80211_wx_set_freq ieee80211_wx_set_freq_rtl
-#define ieee80211_wx_set_rawtx ieee80211_wx_set_rawtx_rtl
-#define ieee80211_wx_set_power ieee80211_wx_set_power_rtl
-#define ieee80211_wx_get_power ieee80211_wx_get_power_rtl
-#define ieee80211_wlan_frequencies ieee80211_wlan_frequencies_rtl
-#define ieee80211_softmac_stop_protocol ieee80211_softmac_stop_protocol_rtl
-#define ieee80211_softmac_start_protocol ieee80211_softmac_start_protocol_rtl
-#define ieee80211_start_protocol ieee80211_start_protocol_rtl
-#define ieee80211_stop_protocol ieee80211_stop_protocol_rtl
-#define ieee80211_rx_mgt ieee80211_rx_mgt_rtl
-
-#define ieee80211_wx_set_auth ieee80211_wx_set_auth_rtl
-//by amy for ps
-#define notify_wx_assoc_event notify_wx_assoc_event_rtl
-#define ieee80211_stop_send_beacons ieee80211_stop_send_beacons_rtl
-#define ieee80211_disassociate ieee80211_disassociate_rtl
-#define ieee80211_start_scan ieee80211_start_scan_rtl
//by amy for ps
typedef struct ieee_param {
u32 cmd;
@@ -196,32 +134,8 @@ typedef struct ieee_param {
}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
-
-// 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)
-static inline unsigned long msleep_interruptible_rtl(unsigned int msecs)
-{
- unsigned long timeout = MSECS(msecs) + 1;
-
- while (timeout) {
- set_current_state(TASK_UNINTERRUPTIBLE);
- timeout = schedule_timeout(timeout);
- }
- return timeout;
-}
-#else
#define MSECS(t) msecs_to_jiffies(t)
#define msleep_interruptible_rtl msleep_interruptible
-#endif
#define IEEE80211_DATA_LEN 2304
/* Maximum size for the MA-UNITDATA primitive, 802.11 standard section
@@ -780,7 +694,6 @@ struct ieee80211_header_data {
#define MFIE_TYPE_RATES_EX 50
#define MFIE_TYPE_GENERIC 221
-#ifdef ENABLE_DOT11D
typedef enum
{
COUNTRY_CODE_FCC = 0,
@@ -795,7 +708,6 @@ typedef enum
COUNTRY_CODE_GLOBAL_DOMAIN = 9,
COUNTRY_CODE_WORLD_WIDE_13_INDEX = 10
}country_code_type_t;
-#endif
struct ieee80211_info_element_hdr {
u8 id;
@@ -1044,13 +956,9 @@ struct ieee80211_network {
//by amy 080312
u8 HighestOperaRate;
//by amy 080312
-#ifdef THOMAS_TURBO
u8 Turbo_Enable;//enable turbo mode, added by thomas
-#endif
-#ifdef ENABLE_DOT11D
u16 CountryIeLen;
u8 CountryIeBuf[MAX_IE_LEN];
-#endif
};
enum ieee80211_state {
@@ -1097,22 +1005,6 @@ enum ieee80211_state {
#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]
-
-#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
-
#define CFG_IEEE80211_RESERVE_FCS (1<<0)
#define CFG_IEEE80211_COMPUTE_FCS (1<<1)
@@ -1207,18 +1099,12 @@ struct ieee80211_device {
*/
short sync_scan_hurryup;
-#ifdef ENABLE_DOT11D
void * pDot11dInfo;
bool bGlobalDomain;
// For Liteon Ch12~13 passive scan
u8 MinPassiveChnlNum;
u8 IbssStartChnl;
-#else
- /* map of allowed channels. 0 is dummy */
- // FIXME: remeber to default to a basic channel plan depending of the PHY type
- int channel_map[MAX_CHANNEL_NUMBER+1];
-#endif
int rate; /* current rate */
int basic_rate;
@@ -1313,7 +1199,6 @@ struct ieee80211_device {
unsigned long NumRxOkTotal;
unsigned long NumRxUnicast;//YJ,add,080828,for keep alive
bool bHwRadioOff;
-#if LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,20)
struct delayed_work softmac_scan_wq;
struct delayed_work associate_retry_wq;
struct delayed_work hw_wakeup_wq;
@@ -1329,24 +1214,7 @@ struct ieee80211_device {
//Added for RF power on power off by lizhaoming 080512
struct delayed_work GPIOChangeRFWorkItem;
-#else
- struct work_struct start_ibss_wq;
- struct work_struct softmac_scan_wq;
- struct work_struct associate_retry_wq;
- struct work_struct hw_wakeup_wq;
- struct work_struct hw_sleep_wq;
- struct work_struct watch_dog_wq;
- struct work_struct sw_antenna_wq;
-//by amy for rate adaptive 080312
- struct work_struct rate_adapter_wq;
-//by amy for rate adaptive
- struct work_struct hw_dig_wq;
- struct work_struct tx_pw_wq;
-
-//Added for RF power on power off by lizhaoming 080512
- struct work_struct GPIOChangeRFWorkItem;
-#endif
struct workqueue_struct *wq;
/* Callback functions */
@@ -1690,12 +1558,8 @@ extern int ieee80211_wx_set_freq(struct ieee80211_device *ieee, struct iw_reques
extern int ieee80211_wx_get_freq(struct ieee80211_device *ieee, struct iw_request_info *a,
union iwreq_data *wrqu, char *b);
-#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 void ieee80211_wx_sync_scan_wq(struct ieee80211_device *ieee);
extern int ieee80211_wx_set_rawtx(struct ieee80211_device *ieee,
struct iw_request_info *info,
diff --git a/drivers/staging/rtl8187se/ieee80211/ieee80211_crypt.c b/drivers/staging/rtl8187se/ieee80211/ieee80211_crypt.c
index 7370296225e1..013c3e19ae25 100644
--- a/drivers/staging/rtl8187se/ieee80211/ieee80211_crypt.c
+++ b/drivers/staging/rtl8187se/ieee80211/ieee80211_crypt.c
@@ -19,10 +19,6 @@
#include <asm/string.h>
#include <asm/errno.h>
-#if (LINUX_VERSION_CODE<KERNEL_VERSION(2,6,18))
-#include<linux/config.h>
-#endif
-
#include "ieee80211.h"
MODULE_AUTHOR("Jouni Malinen");
@@ -251,16 +247,3 @@ void ieee80211_crypto_deinit(void)
}
kfree(hcrypt);
}
-
-#if 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);
-#endif
-
-//module_init(ieee80211_crypto_init);
-//module_exit(ieee80211_crypto_deinit);
diff --git a/drivers/staging/rtl8187se/ieee80211/ieee80211_crypt_ccmp.c b/drivers/staging/rtl8187se/ieee80211/ieee80211_crypt_ccmp.c
index 08add385790f..39fcabc12bef 100644
--- a/drivers/staging/rtl8187se/ieee80211/ieee80211_crypt_ccmp.c
+++ b/drivers/staging/rtl8187se/ieee80211/ieee80211_crypt_ccmp.c
@@ -24,18 +24,8 @@
#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>
+#include <linux/scatterlist.h>
MODULE_AUTHOR("Jouni Malinen");
MODULE_DESCRIPTION("Host AP crypt: CCMP");
@@ -77,21 +67,7 @@ struct ieee80211_ccmp_data {
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))||(IN_OPENSUSE_SLED))
crypto_cipher_encrypt_one((void *)tfm, ct, pt);
- #else
- 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);
- #endif
}
static void * ieee80211_ccmp_init(int key_idx)
@@ -104,33 +80,20 @@ static void * ieee80211_ccmp_init(int key_idx)
memset(priv, 0, sizeof(*priv));
priv->key_idx = key_idx;
- #if((LINUX_VERSION_CODE < KERNEL_VERSION(2,6,21)) && (!IN_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);
+ 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))
- #if((LINUX_VERSION_CODE < KERNEL_VERSION(2,6,21)) && (!IN_OPENSUSE_SLED))
- crypto_free_tfm(priv->tfm);
- #else
crypto_free_cipher((void *)priv->tfm);
- #endif
kfree(priv);
}
@@ -141,13 +104,9 @@ fail:
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))
- #if((LINUX_VERSION_CODE < KERNEL_VERSION(2,6,21)) && (!IN_OPENSUSE_SLED))
- crypto_free_tfm(_priv->tfm);
- #else
crypto_free_cipher((void *)_priv->tfm);
- #endif
kfree(priv);
}
@@ -159,7 +118,6 @@ static inline void xor_block(u8 *b, u8 *a, size_t len)
b[i] ^= a[i];
}
-#ifndef JOHN_CCMP
static void ccmp_init_blocks(struct crypto_tfm *tfm,
struct ieee80211_hdr *hdr,
u8 *pn, size_t dlen, u8 *b0, u8 *auth,
@@ -237,7 +195,6 @@ static void ccmp_init_blocks(struct crypto_tfm *tfm,
b0[14] = b0[15] = 0;
ieee80211_ccmp_aes_encrypt(tfm, b0, s0);
}
-#endif
static int ieee80211_ccmp_encrypt(struct sk_buff *skb, int hdr_len, void *priv)
{
@@ -245,14 +202,13 @@ static int ieee80211_ccmp_encrypt(struct sk_buff *skb, int hdr_len, void *priv)
int data_len, i;
u8 *pos;
struct ieee80211_hdr *hdr;
-#ifndef JOHN_CCMP
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;
-#endif
+
if (skb_headroom(skb) < CCMP_HDR_LEN ||
skb_tailroom(skb) < CCMP_MIC_LEN ||
skb->len < hdr_len)
@@ -282,7 +238,6 @@ static int ieee80211_ccmp_encrypt(struct sk_buff *skb, int hdr_len, void *priv)
*pos++ = key->tx_pn[0];
hdr = (struct ieee80211_hdr *) skb->data;
-#ifndef JOHN_CCMP
//mic is moved to here by john
mic = skb_put(skb, CCMP_MIC_LEN);
@@ -306,7 +261,7 @@ static int ieee80211_ccmp_encrypt(struct sk_buff *skb, int hdr_len, void *priv)
for (i = 0; i < CCMP_MIC_LEN; i++)
mic[i] = b[i] ^ s0[i];
-#endif
+
return 0;
}
@@ -317,14 +272,13 @@ static int ieee80211_ccmp_decrypt(struct sk_buff *skb, int hdr_len, void *priv)
u8 keyidx, *pos;
struct ieee80211_hdr *hdr;
u8 pn[6];
-#ifndef JOHN_CCMP
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;
-#endif
+
if (skb->len < hdr_len + CCMP_HDR_LEN + CCMP_MIC_LEN) {
key->dot11RSNAStatsCCMPFormatErrors++;
return -1;
@@ -376,7 +330,6 @@ static int ieee80211_ccmp_decrypt(struct sk_buff *skb, int hdr_len, void *priv)
return -4;
}
-#ifndef JOHN_CCMP
ccmp_init_blocks(key->tfm, hdr, pn, data_len, b0, a, b);
xor_block(mic, b, CCMP_MIC_LEN);
@@ -407,7 +360,6 @@ static int ieee80211_ccmp_decrypt(struct sk_buff *skb, int hdr_len, void *priv)
memcpy(key->rx_pn, pn, CCMP_PN_LEN);
-#endif
/* Remove hdr and MIC */
memmove(skb->data + CCMP_HDR_LEN, skb->data, hdr_len);
skb_pull(skb, CCMP_HDR_LEN);
@@ -520,14 +472,3 @@ void ieee80211_crypto_ccmp_exit(void)
{
ieee80211_unregister_crypto_ops(&ieee80211_crypt_ccmp);
}
-
-#if 0
-#if (LINUX_VERSION_CODE > KERNEL_VERSION(2,5,0))
-EXPORT_SYMBOL(ieee80211_ccmp_null);
-#else
-EXPORT_SYMBOL_NOVERS(ieee80211_ccmp_null);
-#endif
-#endif
-
-//module_init(ieee80211_crypto_ccmp_init);
-//module_exit(ieee80211_crypto_ccmp_exit);
diff --git a/drivers/staging/rtl8187se/ieee80211/ieee80211_crypt_tkip.c b/drivers/staging/rtl8187se/ieee80211/ieee80211_crypt_tkip.c
index de97bbec0da5..369a283af9ce 100644
--- a/drivers/staging/rtl8187se/ieee80211/ieee80211_crypt_tkip.c
+++ b/drivers/staging/rtl8187se/ieee80211/ieee80211_crypt_tkip.c
@@ -23,18 +23,8 @@
#include "ieee80211.h"
-#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/scatterlist.h>
#include <linux/crc32.h>
MODULE_AUTHOR("Jouni Malinen");
@@ -70,13 +60,10 @@ struct ieee80211_tkip_data {
int key_idx;
- #if((LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,21))||(IN_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;
- #endif
-
+ struct crypto_blkcipher *rx_tfm_arc4;
+ struct crypto_hash *rx_tfm_michael;
+ struct crypto_blkcipher *tx_tfm_arc4;
+ struct crypto_hash *tx_tfm_michael;
struct crypto_tfm *tfm_arc4;
struct crypto_tfm *tfm_michael;
@@ -94,22 +81,6 @@ static void * ieee80211_tkip_init(int key_idx)
memset(priv, 0, sizeof(*priv));
priv->key_idx = key_idx;
- #if((LINUX_VERSION_CODE < KERNEL_VERSION(2,6,21))&&(!IN_OPENSUSE_SLED))
- priv->tfm_arc4 = crypto_alloc_tfm("arc4", 0);
- if (priv->tfm_arc4 == NULL) {
- printk(KERN_DEBUG "ieee80211_crypt_tkip: could not allocate "
- "crypto API arc4\n");
- goto fail;
- }
-
- priv->tfm_michael = crypto_alloc_tfm("michael_mic", 0);
- if (priv->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)) {
@@ -145,17 +116,11 @@ static void * ieee80211_tkip_init(int key_idx)
priv->rx_tfm_michael = NULL;
goto fail;
}
- #endif
+
return priv;
fail:
if (priv) {
- #if((LINUX_VERSION_CODE < KERNEL_VERSION(2,6,21))&&(!IN_OPENSUSE_SLED))
- if (priv->tfm_michael)
- crypto_free_tfm(priv->tfm_michael);
- if (priv->tfm_arc4)
- crypto_free_tfm(priv->tfm_arc4);
- #else
if (priv->tx_tfm_michael)
crypto_free_hash(priv->tx_tfm_michael);
if (priv->tx_tfm_arc4)
@@ -164,7 +129,6 @@ fail:
crypto_free_hash(priv->rx_tfm_michael);
if (priv->rx_tfm_arc4)
crypto_free_blkcipher(priv->rx_tfm_arc4);
- #endif
kfree(priv);
}
@@ -175,12 +139,7 @@ fail:
static void ieee80211_tkip_deinit(void *priv)
{
struct ieee80211_tkip_data *_priv = priv;
- #if((LINUX_VERSION_CODE < KERNEL_VERSION(2,6,21))&&(!IN_OPENSUSE_SLED))
- if (_priv && _priv->tfm_michael)
- crypto_free_tfm(_priv->tfm_michael);
- if (_priv && _priv->tfm_arc4)
- crypto_free_tfm(_priv->tfm_arc4);
- #else
+
if (_priv) {
if (_priv->tx_tfm_michael)
crypto_free_hash(_priv->tx_tfm_michael);
@@ -191,7 +150,6 @@ static void ieee80211_tkip_deinit(void *priv)
if (_priv->rx_tfm_arc4)
crypto_free_blkcipher(_priv->rx_tfm_arc4);
}
- #endif
kfree(priv);
}
@@ -281,7 +239,6 @@ static inline u16 _S_(u16 v)
return Sbox[Lo8(v)] ^ ((t << 8) | (t >> 8));
}
-#ifndef JOHN_TKIP
#define PHASE1_LOOP_COUNT 8
static void tkip_mixing_phase1(u16 *TTAK, const u8 *TK, const u8 *TA, u32 IV32)
@@ -351,21 +308,17 @@ static void tkip_mixing_phase2(u8 *WEPSeed, const u8 *TK, const u16 *TTAK,
}
#endif
}
-#endif
+
static int ieee80211_tkip_encrypt(struct sk_buff *skb, int hdr_len, void *priv)
{
struct ieee80211_tkip_data *tkey = priv;
- #if((LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,21))||(IN_OPENSUSE_SLED))
struct blkcipher_desc desc = {.tfm = tkey->tx_tfm_arc4};
- #endif
int len;
u8 *pos;
struct ieee80211_hdr *hdr;
-#ifndef JOHN_TKIP
u8 rc4key[16],*icv;
u32 crc;
struct scatterlist sg;
-#endif
int ret;
ret = 0;
@@ -374,19 +327,7 @@ static int ieee80211_tkip_encrypt(struct sk_buff *skb, int hdr_len, void *priv)
return -1;
hdr = (struct ieee80211_hdr *) 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
-#ifndef JOHN_TKIP
if (!tkey->tx_phase1_done) {
tkip_mixing_phase1(tkey->tx_ttak, tkey->key, hdr->addr2,
tkey->tx_iv32);
@@ -394,91 +335,52 @@ printk("%x\n", ((u32*)tkey->key)[7]);
}
tkip_mixing_phase2(rc4key, tkey->key, tkey->tx_ttak, tkey->tx_iv16);
-#else
- tkey->tx_phase1_done = 1;
-#endif /*JOHN_TKIP*/
-
len = skb->len - hdr_len;
pos = skb_push(skb, 8);
memmove(pos, pos + 8, hdr_len);
pos += hdr_len;
-#ifdef JOHN_TKIP
- *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];
-#endif
*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;
-#ifndef JOHN_TKIP
+
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))&&(!IN_OPENSUSE_SLED))
- crypto_cipher_setkey(tkey->tfm_arc4, rc4key, 16);
- sg.page = virt_to_page(pos);
- sg.offset = offset_in_page(pos);
- sg.length = len + 4;
- crypto_cipher_encrypt(tkey->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
+ sg_init_one(&sg, pos, len + 4);
ret= crypto_blkcipher_encrypt(&desc, &sg, &sg, len + 4);
- #endif
-#endif
+
tkey->tx_iv16++;
if (tkey->tx_iv16 == 0) {
tkey->tx_phase1_done = 0;
tkey->tx_iv32++;
}
-#ifndef JOHN_TKIP
- #if((LINUX_VERSION_CODE <KERNEL_VERSION(2,6,21))&&(!IN_OPENSUSE_SLED))
- return 0;
- #else
return ret;
- #endif
-#else
- return 0;
-#endif
}
static int ieee80211_tkip_decrypt(struct sk_buff *skb, int hdr_len, void *priv)
{
- struct ieee80211_tkip_data *tkey = priv;
- #if((LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,21)) ||(IN_OPENSUSE_SLED))
- struct blkcipher_desc desc = {.tfm = tkey->rx_tfm_arc4};
- #endif
+ struct ieee80211_tkip_data *tkey = priv;
+ struct blkcipher_desc desc = { .tfm = tkey->rx_tfm_arc4 };
u8 keyidx, *pos;
u32 iv32;
u16 iv16;
struct ieee80211_hdr *hdr;
-#ifndef JOHN_TKIP
u8 icv[4];
u32 crc;
struct scatterlist sg;
u8 rc4key[16];
int plen;
-#endif
+
if (skb->len < hdr_len + 8 + 4)
return -1;
@@ -509,7 +411,6 @@ static int ieee80211_tkip_decrypt(struct sk_buff *skb, int hdr_len, void *priv)
iv16 = (pos[0] << 8) | pos[2];
iv32 = pos[4] | (pos[5] << 8) | (pos[6] << 16) | (pos[7] << 24);
pos += 8;
-#ifndef JOHN_TKIP
if (iv32 < tkey->rx_iv32 ||
(iv32 == tkey->rx_iv32 && iv16 <= tkey->rx_iv16)) {
@@ -530,21 +431,8 @@ static int ieee80211_tkip_decrypt(struct sk_buff *skb, int hdr_len, void *priv)
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))&&(!IN_OPENSUSE_SLED))
- crypto_cipher_setkey(tkey->tfm_arc4, rc4key, 16);
- sg.page = virt_to_page(pos);
- sg.offset = offset_in_page(pos);
- sg.length = plen + 4;
- crypto_cipher_decrypt(tkey->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
+ sg_init_one(&sg, pos, plen + 4);
if (crypto_blkcipher_decrypt(&desc, &sg, &sg, plen + 4)) {
if (net_ratelimit()) {
printk(KERN_DEBUG ": TKIP: failed to decrypt "
@@ -553,13 +441,8 @@ static int ieee80211_tkip_decrypt(struct sk_buff *skb, int hdr_len, void *priv)
}
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;
@@ -578,8 +461,6 @@ static int ieee80211_tkip_decrypt(struct sk_buff *skb, int hdr_len, void *priv)
return -5;
}
-#endif /* JOHN_TKIP */
-
/* Update real counters only after Michael MIC verification has
* completed */
tkey->rx_iv32_new = iv32;
@@ -590,67 +471,9 @@ static int ieee80211_tkip_decrypt(struct sk_buff *skb, int hdr_len, void *priv)
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)) && (!IN_OPENSUSE_SLED))
-static int michael_mic(struct ieee80211_tkip_data *tkey, 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 (tkey->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;
-
- //crypto_digest_init(tkey->tfm_michael);
- //crypto_digest_setkey(tkey->tfm_michael, key, 8);
- //crypto_digest_update(tkey->tfm_michael, sg, 2);
- //crypto_digest_final(tkey->tfm_michael, mic);
-
- //return 0;
-#if LINUX_VERSION_CODE < KERNEL_VERSION(2,6,20)
- crypto_digest_init(tkey->tfm_michael);
- crypto_digest_setkey(tkey->tfm_michael, key, 8);
- crypto_digest_update(tkey->tfm_michael, sg, 2);
- crypto_digest_final(tkey->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)
{
@@ -661,18 +484,10 @@ static int michael_mic(struct crypto_hash *tfm_michael, u8 * key, u8 * hdr,
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
+
+ sg_init_table(sg, 2);
+ sg_set_buf(&sg[0], hdr, 16);
+ sg_set_buf(&sg[1], data, data_len);
if (crypto_hash_setkey(tfm_michael, key, 8))
return -1;
@@ -681,9 +496,6 @@ static int michael_mic(struct crypto_hash *tfm_michael, u8 * key, u8 * hdr,
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)
{
@@ -740,20 +552,14 @@ static int ieee80211_michael_mic_add(struct sk_buff *skb, int hdr_len, void *pri
}
// }
pos = skb_put(skb, 8);
- #if((LINUX_VERSION_CODE < KERNEL_VERSION(2,6,21))&&(!IN_OPENSUSE_SLED))
- if (michael_mic(tkey, &tkey->key[16], tkey->tx_hdr,
+
+ 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 *hdr,
int keyidx)
@@ -774,30 +580,6 @@ static void ieee80211_michael_mic_failure(struct net_device *dev,
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 *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 *hdr,
- int keyidx)
-{
-}
-#endif /* WIRELESS_EXT >= 15 */
-
static int ieee80211_michael_mic_verify(struct sk_buff *skb, int keyidx,
int hdr_len, void *priv)
@@ -818,14 +600,11 @@ static int ieee80211_michael_mic_verify(struct sk_buff *skb, int keyidx,
tkey->rx_hdr[12] = *(skb->data + hdr_len - 2) & 0x07;
}
// }
- #if((LINUX_VERSION_CODE < KERNEL_VERSION(2,6,21))&&(!IN_OPENSUSE_SLED))
- if (michael_mic(tkey, &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;
+ skb->data + hdr_len, skb->len - 8 - hdr_len, mic))
+ return -1;
+
if (memcmp(mic, skb->data + skb->len - 8, 8) != 0) {
struct ieee80211_hdr *hdr;
hdr = (struct ieee80211_hdr *) skb->data;
@@ -854,29 +633,19 @@ 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))&&(!IN_OPENSUSE_SLED))
- struct crypto_tfm *tfm = tkey->tfm_michael;
- struct crypto_tfm *tfm2 = tkey->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))&&(!IN_OPENSUSE_SLED))
- tkey->tfm_michael = tfm;
- tkey->tfm_arc4 = tfm2;
- #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);
@@ -987,15 +756,3 @@ void ieee80211_tkip_null(void)
// printk("============>%s()\n", __func__);
return;
}
-
-#if 0
-#if (LINUX_VERSION_CODE > KERNEL_VERSION(2,5,0))
-EXPORT_SYMBOL(ieee80211_tkip_null);
-#else
-EXPORT_SYMBOL_NOVERS(ieee80211_tkip_null);
-#endif
-#endif
-
-
-//module_init(ieee80211_crypto_tkip_init);
-//module_exit(ieee80211_crypto_tkip_exit);
diff --git a/drivers/staging/rtl8187se/ieee80211/ieee80211_crypt_wep.c b/drivers/staging/rtl8187se/ieee80211/ieee80211_crypt_wep.c
index 68a22b32fcf0..3841ef96f110 100644
--- a/drivers/staging/rtl8187se/ieee80211/ieee80211_crypt_wep.c
+++ b/drivers/staging/rtl8187se/ieee80211/ieee80211_crypt_wep.c
@@ -20,18 +20,8 @@
#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>
+#include <linux/scatterlist.h>
#include <linux/crc32.h>
MODULE_AUTHOR("Jouni Malinen");
@@ -51,12 +41,8 @@ struct prism2_wep_data {
u8 key[WEP_KEY_LEN + 1];
u8 key_len;
u8 key_idx;
- #if((LINUX_VERSION_CODE < KERNEL_VERSION(2,6,21))&&(!IN_OPENSUSE_SLED))
- struct crypto_tfm *tfm;
- #else
struct crypto_blkcipher *tx_tfm;
struct crypto_blkcipher *rx_tfm;
- #endif
};
@@ -69,14 +55,6 @@ static void * prism2_wep_init(int keyidx)
goto fail;
memset(priv, 0, sizeof(*priv));
priv->key_idx = keyidx;
- #if((LINUX_VERSION_CODE < KERNEL_VERSION(2,6,21))&&(!IN_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 "
@@ -91,7 +69,6 @@ static void * prism2_wep_init(int keyidx)
priv->rx_tfm = NULL;
goto fail;
}
- #endif
/* start WEP IV from a random value */
get_random_bytes(&priv->iv, 4);
@@ -99,14 +76,6 @@ static void * prism2_wep_init(int keyidx)
return priv;
fail:
- //#if(LINUX_VERSION_CODE < KERNEL_VERSION(2,6,21))
- #if((LINUX_VERSION_CODE < KERNEL_VERSION(2,6,21))&&(!IN_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);
@@ -114,7 +83,7 @@ fail:
crypto_free_blkcipher(priv->rx_tfm);
kfree(priv);
}
- #endif
+
return NULL;
}
@@ -122,18 +91,14 @@ fail:
static void prism2_wep_deinit(void *priv)
{
struct prism2_wep_data *_priv = priv;
- //#if(LINUX_VERSION_CODE < KERNEL_VERSION(2,6,21))
- #if((LINUX_VERSION_CODE < KERNEL_VERSION(2,6,21))&&(!IN_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);
}
@@ -147,18 +112,14 @@ static void prism2_wep_deinit(void *priv)
static int prism2_wep_encrypt(struct sk_buff *skb, int hdr_len, void *priv)
{
struct prism2_wep_data *wep = priv;
-//#if(LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,21))
-#if((LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,21))||(IN_OPENSUSE_SLED))
- struct blkcipher_desc desc = {.tfm = wep->tx_tfm};
-#endif
+ struct blkcipher_desc desc = { .tfm = wep->tx_tfm };
u32 klen, len;
u8 key[WEP_KEY_LEN + 3];
u8 *pos;
-#ifndef JOHN_HWSEC
u32 crc;
u8 *icv;
struct scatterlist sg;
-#endif
+
if (skb_headroom(skb) < 4 || skb_tailroom(skb) < 4 ||
skb->len < hdr_len)
return -1;
@@ -190,41 +151,18 @@ static int prism2_wep_encrypt(struct sk_buff *skb, int hdr_len, void *priv)
/* Copy rest of the WEP key (the secret part) */
memcpy(key + 3, wep->key, wep->key_len);
-#ifndef JOHN_HWSEC
/* 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))
- #if((LINUX_VERSION_CODE < KERNEL_VERSION(2,6,21))&&(!IN_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
+ sg_init_one(&sg, pos, len + 4);
+
return crypto_blkcipher_encrypt(&desc, &sg, &sg, len + 4);
- #endif
-#endif /* JOHN_HWSEC */
- return 0;
}
@@ -238,18 +176,14 @@ static int prism2_wep_encrypt(struct sk_buff *skb, int hdr_len, void *priv)
static int prism2_wep_decrypt(struct sk_buff *skb, int hdr_len, void *priv)
{
struct prism2_wep_data *wep = priv;
- //#if(LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,21))
- #if((LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,21))||(IN_OPENSUSE_SLED))
- struct blkcipher_desc desc = {.tfm = wep->rx_tfm};
- #endif
+ struct blkcipher_desc desc = { .tfm = wep->rx_tfm };
u32 klen, plen;
u8 key[WEP_KEY_LEN + 3];
u8 keyidx, *pos;
-#ifndef JOHN_HWSEC
u32 crc;
u8 icv[4];
struct scatterlist sg;
-#endif
+
if (skb->len < hdr_len + 8)
return -1;
@@ -268,32 +202,14 @@ static int prism2_wep_decrypt(struct sk_buff *skb, int hdr_len, void *priv)
/* Apply RC4 to data and compute CRC32 over decrypted data */
plen = skb->len - hdr_len - 8;
-#ifndef JOHN_HWSEC
-//#if (LINUX_VERSION_CODE < KERNEL_VERSION(2,6,21))
-#if((LINUX_VERSION_CODE < KERNEL_VERSION(2,6,21))&&(!IN_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
+ sg_init_one(&sg, pos, plen + 4);
+
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;
@@ -303,7 +219,6 @@ static int prism2_wep_decrypt(struct sk_buff *skb, int hdr_len, void *priv)
/* ICV mismatch - drop frame */
return -2;
}
-#endif /* JOHN_HWSEC */
/* Remove IV and ICV */
memmove(skb->data + 4, skb->data, hdr_len);
@@ -383,12 +298,3 @@ void ieee80211_wep_null(void)
// printk("============>%s()\n", __func__);
return;
}
-#if 0
-#if (LINUX_VERSION_CODE > KERNEL_VERSION(2,5,0))
-EXPORT_SYMBOL(ieee80211_wep_null);
-#else
-EXPORT_SYMBOL_NOVERS(ieee80211_wep_null);
-#endif
-#endif
-//module_init(ieee80211_crypto_wep_init);
-//module_exit(ieee80211_crypto_wep_exit);
diff --git a/drivers/staging/rtl8187se/ieee80211/ieee80211_module.c b/drivers/staging/rtl8187se/ieee80211/ieee80211_module.c
index c2b61e648e4e..6fbe4890cb66 100644
--- a/drivers/staging/rtl8187se/ieee80211/ieee80211_module.c
+++ b/drivers/staging/rtl8187se/ieee80211/ieee80211_module.c
@@ -210,91 +210,3 @@ void free_ieee80211(struct net_device *dev)
free_netdev(dev);
}
-
-//#ifdef CONFIG_IEEE80211_DEBUG
-#if 0
-
-static int debug = 0;
-u32 ieee80211_debug_level = 0;
-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;
- ieee80211_proc = create_proc_entry(DRV_NAME, S_IFDIR, proc_net);
- 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) {
- remove_proc_entry(DRV_NAME, proc_net);
- 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);
- remove_proc_entry(DRV_NAME, proc_net);
- ieee80211_proc = NULL;
- }
-}
-
-#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
-
-#if 0
-EXPORT_SYMBOL(alloc_ieee80211);
-EXPORT_SYMBOL(free_ieee80211);
-#endif
diff --git a/drivers/staging/rtl8187se/ieee80211/ieee80211_rx.c b/drivers/staging/rtl8187se/ieee80211/ieee80211_rx.c
index 4d4ee563275e..c76ffb131449 100644
--- a/drivers/staging/rtl8187se/ieee80211/ieee80211_rx.c
+++ b/drivers/staging/rtl8187se/ieee80211/ieee80211_rx.c
@@ -44,9 +44,7 @@
#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)
@@ -55,11 +53,7 @@ static inline void ieee80211_monitor_rx(struct ieee80211_device *ieee,
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_reset_mac_header(skb);
skb_pull(skb, ieee80211_get_hdrlen(fc));
skb->pkt_type = PACKET_OTHERHOST;
skb->protocol = __constant_htons(ETH_P_80211_RAW);
@@ -113,13 +107,6 @@ ieee80211_frag_cache_get(struct ieee80211_device *ieee,
struct ieee80211_hdr_QOS *hdr_4addr_QoS;
u8 tid;
-#ifdef _RTL8187_EXT_PATCH_
- if(ieee->iw_mode == ieee->iw_ext_mode)
- {
- tid = (hdr->addr2[ETH_ALEN-2] ^ hdr->addr2[ETH_ALEN-1]) & IEEE80211_QOS_TID;
- }
- else
-#endif
if (((fc & IEEE80211_FCTL_DSTODS) == IEEE80211_FCTL_DSTODS)&&IEEE80211_QOS_HAS_SEQ(fc)) {
hdr_4addr_QoS = (struct ieee80211_hdr_QOS *)hdr;
tid = le16_to_cpu(hdr_4addr_QoS->QOS_ctl) & IEEE80211_QOS_TID;
@@ -187,13 +174,6 @@ static int ieee80211_frag_cache_invalidate(struct ieee80211_device *ieee,
struct ieee80211_hdr_QOS *hdr_4addr_QoS;
u8 tid;
-#ifdef _RTL8187_EXT_PATCH_
- if(ieee->iw_mode == ieee->iw_ext_mode)
- {
- tid = (hdr->addr2[ETH_ALEN-2] ^ hdr->addr2[ETH_ALEN-1]) & IEEE80211_QOS_TID;
- }
- else
-#endif
if(((fc & IEEE80211_FCTL_DSTODS) == IEEE80211_FCTL_DSTODS)&&IEEE80211_QOS_HAS_SEQ(fc)) {
hdr_4addr_QoS = (struct ieee80211_hdr_QOS *)hdr;
tid = le16_to_cpu(hdr_4addr_QoS->QOS_ctl) & IEEE80211_QOS_TID;
@@ -368,13 +348,6 @@ ieee80211_rx_frame_decrypt(struct ieee80211_device* ieee, struct sk_buff *skb,
return 0;
hdr = (struct ieee80211_hdr *) skb->data;
-#ifdef _RTL8187_EXT_PATCH_
- if((ieee->iw_mode == ieee->iw_ext_mode) && (ieee->ext_patch_ieee80211_rx_frame_get_hdrlen))
- {
- hdrlen = ieee->ext_patch_ieee80211_rx_frame_get_hdrlen(ieee, skb);
- }
- else
-#endif
hdrlen = ieee80211_get_hdrlen(le16_to_cpu(hdr->frame_ctl));
#ifdef CONFIG_IEEE80211_CRYPT_TKIP
@@ -420,13 +393,6 @@ ieee80211_rx_frame_decrypt_msdu(struct ieee80211_device* ieee, struct sk_buff *s
return 0;
hdr = (struct ieee80211_hdr *) skb->data;
-#ifdef _RTL8187_EXT_PATCH_
- if((ieee->iw_mode == ieee->iw_ext_mode) && (ieee->ext_patch_ieee80211_rx_frame_get_hdrlen))
- {
- hdrlen = ieee->ext_patch_ieee80211_rx_frame_get_hdrlen(ieee, skb);
- }
- else
-#endif
hdrlen = ieee80211_get_hdrlen(le16_to_cpu(hdr->frame_ctl));
atomic_inc(&crypt->refcnt);
@@ -458,13 +424,6 @@ static int is_duplicate_packet(struct ieee80211_device *ieee,
struct ieee80211_hdr_QOS *hdr_4addr_QoS;
u8 tid;
-#ifdef _RTL8187_EXT_PATCH_
- if(ieee->iw_mode == ieee->iw_ext_mode)
- {
- tid = (header->addr2[ETH_ALEN-2] ^ header->addr2[ETH_ALEN-1]) & IEEE80211_QOS_TID;
- }
- else
-#endif
//TO2DS and QoS
if(((fc & IEEE80211_FCTL_DSTODS) == IEEE80211_FCTL_DSTODS)&&IEEE80211_QOS_HAS_SEQ(fc)) {
hdr_4addr_QoS = (struct ieee80211_hdr_QOS *)header;
@@ -519,16 +478,6 @@ static int is_duplicate_packet(struct ieee80211_device *ieee,
break;
default:
-#ifdef _RTL8187_EXT_PATCH_
- if(ieee->iw_mode == ieee->iw_ext_mode)
- {
- last_seq = &ieee->last_rxseq_num[tid];
- last_frag = &ieee->last_rxfrag_num[tid];
- last_time = &ieee->last_packet_time[tid];
- break;
- }
- else
-#endif
return 0;
}
@@ -593,11 +542,6 @@ int ieee80211_rx(struct ieee80211_device *ieee, struct sk_buff *skb,
struct ieee80211_crypt_data *crypt = NULL;
int keyidx = 0;
- //Added for mesh by Lawrence.
-#ifdef _RTL8187_EXT_PATCH_
- u8 status;
- u32 flags;
-#endif
// cheat the the hdr type
hdr = (struct ieee80211_hdr *)skb->data;
stats = &ieee->stats;
@@ -632,19 +576,9 @@ int ieee80211_rx(struct ieee80211_device *ieee, struct sk_buff *skb,
}
//YJ,add,080828,for keep alive,end
-#ifdef _RTL8187_EXT_PATCH_
- if((ieee->iw_mode == ieee->iw_ext_mode) && (ieee->ext_patch_ieee80211_rx_frame_get_hdrlen))
- {
- hdrlen = ieee->ext_patch_ieee80211_rx_frame_get_hdrlen(ieee, skb);
- if(skb->len < hdrlen)
- goto rx_dropped;
- }
- else
-#endif
hdrlen = ieee80211_get_hdrlen(fc);
#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 */
@@ -658,18 +592,16 @@ int ieee80211_rx(struct ieee80211_device *ieee, struct sk_buff *skb,
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)
@@ -712,47 +644,17 @@ int ieee80211_rx(struct ieee80211_device *ieee, struct sk_buff *skb,
if (skb->len < IEEE80211_DATA_HDR3_LEN)
goto rx_dropped;
-#ifdef _RTL8187_EXT_PATCH_
- if( ieee->iw_mode == ieee->iw_ext_mode && ieee->ext_patch_ieee80211_rx_mgt_update_expire )
- ieee->ext_patch_ieee80211_rx_mgt_update_expire( ieee, skb );
-#endif
-
// if QoS enabled, should check the sequence for each of the AC
if (is_duplicate_packet(ieee, hdr))
goto rx_dropped;
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
-
-
if (ieee80211_rx_frame_mgmt(ieee, skb, rx_stats, type, stype))
goto rx_dropped;
else
goto rx_exit;
}
-#ifdef _RTL8187_EXT_PATCH_
- if((ieee->iw_mode == ieee->iw_ext_mode) && ieee->ext_patch_ieee80211_rx_on_rx)
- {
- if(ieee->ext_patch_ieee80211_rx_on_rx(ieee, skb, rx_stats, type, stype)==0)
- {
- goto rx_exit;
- }
- }
-#endif
/* Data frame - extract src/dst addresses */
switch (fc & (IEEE80211_FCTL_FROMDS | IEEE80211_FCTL_TODS)) {
@@ -821,14 +723,6 @@ int ieee80211_rx(struct ieee80211_device *ieee, struct sk_buff *skb,
}
#endif
-#ifdef _RTL8187_EXT_PATCH_
- if((ieee->iw_mode == ieee->iw_ext_mode) && ieee->ext_patch_ieee80211_rx_is_valid_framectl)
- {
- if(ieee->ext_patch_ieee80211_rx_is_valid_framectl(ieee, fc, type, stype)==0)
- goto rx_dropped;
- }
- else
-#endif
/* 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 &&
@@ -996,22 +890,6 @@ int ieee80211_rx(struct ieee80211_device *ieee, struct sk_buff *skb,
}
#endif
-#ifdef _RTL8187_EXT_PATCH_
- if((ieee->iw_mode == ieee->iw_ext_mode) && ieee->ext_patch_ieee80211_rx_process_dataframe)
- {
- //Added for mesh rx interrupt.
- //spin_lock_irqsave(&ieee->lock,flags);
- status = ieee->ext_patch_ieee80211_rx_process_dataframe(ieee, skb, rx_stats);
- //spin_unlock_irqrestore(&ieee->lock,flags);
-
- if(status)
-// if(ieee->ext_patch_ieee80211_rx_process_dataframe(ieee, skb, rx_stats))
- goto rx_exit;
- else
- goto rx_dropped;
- }
-#endif
-
/* convert hdr + possible LLC headers into Ethernet header */
if (skb->len - hdrlen >= 8 &&
((memcmp(payload, rfc1042_header, SNAP_SIZE) == 0 &&
@@ -1102,41 +980,6 @@ int ieee80211_rx(struct ieee80211_device *ieee, struct sk_buff *skb,
return 0;
}
-#ifdef _RTL8187_EXT_PATCH_
-int ieee_ext_skb_p80211_to_ether(struct sk_buff *skb, int hdrlen, u8 *dst, u8 *src)
-{
- u8 *payload;
- u16 ethertype;
-
- /* skb: hdr + (possible reassembled) full plaintext payload */
- payload = skb->data + hdrlen;
- ethertype = (payload[6] << 8) | payload[7];
-
- /* convert hdr + possible LLC headers into Ethernet header */
- if (skb->len - hdrlen >= 8 &&
- ((memcmp(payload, rfc1042_header, SNAP_SIZE) == 0 &&
- ethertype != ETH_P_AARP && ethertype != ETH_P_IPX) ||
- memcmp(payload, bridge_tunnel_header, SNAP_SIZE) == 0)) {
- /* remove RFC1042 or Bridge-Tunnel encapsulation and
- * replace EtherType */
- skb_pull(skb, hdrlen + SNAP_SIZE);
- memcpy(skb_push(skb, ETH_ALEN), src, ETH_ALEN);
- memcpy(skb_push(skb, ETH_ALEN), dst, ETH_ALEN);
- } else {
- u16 len;
- /* Leave Ethernet header part of hdr and full payload */
- skb_pull(skb, hdrlen);
- len = htons(skb->len);
- memcpy(skb_push(skb, 2), &len, 2);
- memcpy(skb_push(skb, ETH_ALEN), src, ETH_ALEN);
- memcpy(skb_push(skb, ETH_ALEN), dst, ETH_ALEN);
- }
-
- return 1;
-}
-#endif // _RTL8187_EXT_PATCH_
-
-
#define MGMT_FRAME_FIXED_PART_LENGTH 0x24
static inline int ieee80211_is_ofdm_rate(u8 rate)
@@ -1211,7 +1054,6 @@ static inline int ieee80211_SignalStrengthTranslate(
return RetSS;
}
-#ifdef ENABLE_DOT11D
static inline void ieee80211_extract_country_ie(
struct ieee80211_device *ieee,
struct ieee80211_info_element *info_element,
@@ -1219,15 +1061,6 @@ static inline void ieee80211_extract_country_ie(
u8 * addr2
)
{
-#if 0
- u32 i = 0;
- u8 * p = (u8*)info_element->data;
- printk("-----------------------\n");
- printk("%s Country IE:", network->ssid);
- for(i=0; i<info_element->len; i++)
- printk("\t%2.2x", *(p+i));
- printk("\n-----------------------\n");
-#endif
if(IS_DOT11D_ENABLE(ieee))
{
if(info_element->len!= 0)
@@ -1253,7 +1086,6 @@ static inline void ieee80211_extract_country_ie(
}
}
-#endif
int
ieee80211_TranslateToDbm(
@@ -1302,13 +1134,9 @@ inline int ieee80211_network_init(
//by amy 080312
network->HighestOperaRate = 0;
//by amy 080312
-#ifdef THOMAS_TURBO
network->Turbo_Enable = 0;
-#endif
-#ifdef ENABLE_DOT11D
network->CountryIeLen = 0;
memset(network->CountryIeBuf, 0, MAX_IE_LEN);
-#endif
if (stats->freq == IEEE80211_52GHZ_BAND) {
/* for A band (No DS info) */
@@ -1424,11 +1252,8 @@ inline int ieee80211_network_init(
if(ieee->state != IEEE80211_LINKED)
break;
-#if 0
- network->last_dtim_sta_time[0] = stats->mac_time[0];
-#else
+
network->last_dtim_sta_time[0] = jiffies;
-#endif
network->last_dtim_sta_time[1] = stats->mac_time[1];
network->dtim_data = IEEE80211_DTIM_VALID;
@@ -1483,7 +1308,6 @@ inline int ieee80211_network_init(
network->wpa_ie_len);
}
-#ifdef THOMAS_TURBO
if (info_element->len == 7 &&
info_element->data[0] == 0x00 &&
info_element->data[1] == 0xe0 &&
@@ -1492,7 +1316,6 @@ inline int ieee80211_network_init(
info_element->data[4] == 0x02) {
network->Turbo_Enable = 1;
}
-#endif
if (1 == stats->nic_type) {//nic 87
break;
}
@@ -1533,14 +1356,12 @@ inline int ieee80211_network_init(
memcpy(network->rsn_ie, info_element,
network->rsn_ie_len);
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, beacon->header.addr2);
break;
-#endif
default:
IEEE80211_DEBUG_SCAN("unsupported IE %d\n",
info_element->id);
@@ -1576,9 +1397,7 @@ inline int ieee80211_network_init(
if (ieee80211_is_empty_essid(network->ssid, network->ssid_len))
network->flags |= NETWORK_EMPTY_ESSID;
-#if 0
- stats->signal = ieee80211_SignalStrengthTranslate(stats->signal);
-#endif
+
stats->signal = ieee80211_TranslateToDbm(stats->signalstrength);
//stats->noise = stats->signal - stats->noise;
stats->noise = ieee80211_TranslateToDbm(100 - stats->signalstrength) - 25;
@@ -1688,13 +1507,9 @@ inline void update_network(struct ieee80211_network *dst,
dst->QoS_Enable = 1;//for Rtl8187 simulation
#endif
dst->SignalStrength = src->SignalStrength;
-#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
}
@@ -1715,13 +1530,6 @@ inline void ieee80211_process_probe_response(
u8 is_beacon = (WLAN_FC_GET_STYPE(beacon->header.frame_ctl) == IEEE80211_STYPE_BEACON)? 1:0; //YJ,add,080819,for hidden ap
memset(&network, 0, sizeof(struct ieee80211_network));
-//rz
-#ifdef _RTL8187_EXT_PATCH_
- if((ieee->iw_mode == ieee->iw_ext_mode) && ieee->ext_patch_ieee80211_process_probe_response_1) {
- ieee->ext_patch_ieee80211_process_probe_response_1(ieee, beacon, stats);
- return;
- }
-#endif
IEEE80211_DEBUG_SCAN(
"'%s' (" MAC_FMT "): %c%c%c%c %c%c%c%c-%c%c%c%c %c%c%c%c\n",
@@ -1743,21 +1551,7 @@ inline void ieee80211_process_probe_response(
(beacon->capability & (1<<0x2)) ? '1' : '0',
(beacon->capability & (1<<0x1)) ? '1' : '0',
(beacon->capability & (1<<0x0)) ? '1' : '0');
-#if 0
- if(strcmp(escape_essid(beacon->info_element.data, beacon->info_element.len), "rtl_softap") == 0)
- {
- if(WLAN_FC_GET_STYPE(beacon->header.frame_ctl) == IEEE80211_STYPE_BEACON)
- {
- u32 i = 0, len = stats->len;
- u8 * p = (u8*)beacon;
- printk("-----------------------\n");
- printk("rtl_softap Beacon:");
- for(i=0; i<len; i++)
- printk("\t%2.2x", *(p+i));
- printk("\n-----------------------\n");
- }
- }
-#endif
+
if (ieee80211_network_init(ieee, beacon, &network, stats)) {
IEEE80211_DEBUG_SCAN("Dropped '%s' (" MAC_FMT ") via %s.\n",
escape_essid(info_element->data,
@@ -1769,7 +1563,6 @@ inline void ieee80211_process_probe_response(
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.
@@ -1823,7 +1616,6 @@ inline void ieee80211_process_probe_response(
}
}
}
-#endif
/* The network parsed correctly -- so now we scan our known networks
* to see if we can find it in our list.
*
@@ -1886,9 +1678,6 @@ inline void ieee80211_process_probe_response(
"PROBE RESPONSE" : "BEACON");
#endif
-#ifdef _RTL8187_EXT_PATCH_
- network.ext_entry = target->ext_entry;
-#endif
memcpy(target, &network, sizeof(*target));
list_add_tail(&target->list, &ieee->network_list);
if(ieee->softmac_features & IEEE_SOFTMAC_ASSOCIATE)
@@ -1946,26 +1735,5 @@ void ieee80211_rx_mgt(struct ieee80211_device *ieee,
ieee80211_process_probe_response(
ieee, (struct ieee80211_probe_response *)header, stats);
break;
-//rz
-#ifdef _RTL8187_EXT_PATCH_
- case IEEE80211_STYPE_PROBE_REQ:
- IEEE80211_DEBUG_MGMT("received PROBE REQUEST (%d)\n",
- WLAN_FC_GET_STYPE(header->frame_ctl));
- IEEE80211_DEBUG_SCAN("Probe request\n");
- ///
- if( ieee->iw_mode == ieee->iw_ext_mode && ieee->ext_patch_ieee80211_rx_mgt_on_probe_req )
- ieee->ext_patch_ieee80211_rx_mgt_on_probe_req( ieee, (struct ieee80211_probe_request *)header, stats);
- break;
-#endif // _RTL8187_EXT_PATCH_
-
}
}
-
-#if 0
-EXPORT_SYMBOL(ieee80211_rx_mgt);
-EXPORT_SYMBOL(ieee80211_rx);
-EXPORT_SYMBOL(ieee80211_network_init);
-#ifdef _RTL8187_EXT_PATCH_
-EXPORT_SYMBOL(ieee_ext_skb_p80211_to_ether);
-#endif
-#endif
diff --git a/drivers/staging/rtl8187se/ieee80211/ieee80211_softmac.c b/drivers/staging/rtl8187se/ieee80211/ieee80211_softmac.c
index 80f9cc7137c2..02b0b4e06fe7 100644
--- a/drivers/staging/rtl8187se/ieee80211/ieee80211_softmac.c
+++ b/drivers/staging/rtl8187se/ieee80211/ieee80211_softmac.c
@@ -21,9 +21,7 @@
#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
@@ -129,7 +127,6 @@ void ieee80211_WMM_Info(struct ieee80211_device *ieee, u8 **tag_p) {
*tag_p = tag;
}
-#ifdef THOMAS_TURBO
void ieee80211_TURBO_Info(struct ieee80211_device *ieee, u8 **tag_p) {
u8 *tag = *tag_p;
@@ -146,7 +143,6 @@ void ieee80211_TURBO_Info(struct ieee80211_device *ieee, u8 **tag_p) {
*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)
{
@@ -325,27 +321,12 @@ inline struct sk_buff *ieee80211_probe_req(struct ieee80211_device *ieee)
struct sk_buff *skb;
struct ieee80211_probe_request *req;
-#ifdef _RTL8187_EXT_PATCH_
- short extMore = 0;
- if(ieee->ext_patch_ieee80211_probe_req_1)
- extMore = ieee->ext_patch_ieee80211_probe_req_1(ieee);
-#endif
-
len = ieee->current_network.ssid_len;
rate_len = ieee80211_MFIE_rate_len(ieee);
-#ifdef _RTL8187_EXT_PATCH_
- if(!extMore)
-#endif
skb = dev_alloc_skb(sizeof(struct ieee80211_probe_request) +
2 + len + rate_len);
-#ifdef _RTL8187_EXT_PATCH_
- else
- skb = dev_alloc_skb(sizeof(struct ieee80211_probe_request) +
- 2 + len + rate_len+128); // MESHID + CAP
-#endif
-
if (!skb)
return NULL;
@@ -366,24 +347,13 @@ inline struct sk_buff *ieee80211_probe_req(struct ieee80211_device *ieee)
ieee80211_MFIE_Brate(ieee,&tag);
ieee80211_MFIE_Grate(ieee,&tag);
-#ifdef _RTL8187_EXT_PATCH_
- if(extMore)
- ieee->ext_patch_ieee80211_probe_req_2(ieee, skb, tag);
-#endif
return skb;
}
struct sk_buff *ieee80211_get_beacon_(struct ieee80211_device *ieee);
-//#if LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,20)
-//void ext_ieee80211_send_beacon_wq(struct work_struct *work)
-//{
-// struct ieee80211_device *ieee = container_of(work, struct ieee80211_device, ext_send_beacon_wq);
-//#else
void ext_ieee80211_send_beacon_wq(struct ieee80211_device *ieee)
{
-//#endif
-
struct sk_buff *skb;
//unsigned long flags;
@@ -443,79 +413,10 @@ void ieee80211_send_beacon_cb(unsigned long _ieee)
spin_unlock_irqrestore(&ieee->beacon_lock, flags);
}
-#ifdef _RTL8187_EXT_PATCH_
-
-inline struct sk_buff *ieee80211_probe_req_with_SSID(struct ieee80211_device *ieee, char *ssid, int len_ssid)
-{
- unsigned int len,rate_len;
- u8 *tag;
- struct sk_buff *skb;
- struct ieee80211_probe_request *req;
-
-#ifdef _RTL8187_EXT_PATCH_
- short extMore = 0;
- if(ieee->ext_patch_ieee80211_probe_req_1)
- extMore = ieee->ext_patch_ieee80211_probe_req_1(ieee);
-#endif
-
- len = len_ssid;
-
- rate_len = ieee80211_MFIE_rate_len(ieee);
-
-#ifdef _RTL8187_EXT_PATCH_
- if(!extMore)
-#endif
- skb = dev_alloc_skb(sizeof(struct ieee80211_probe_request) +
- 2 + len + rate_len);
-#ifdef _RTL8187_EXT_PATCH_
- else
- skb = dev_alloc_skb(sizeof(struct ieee80211_probe_request) +
- 2 + len + rate_len+128); // MESHID + CAP
-#endif
-
- if (!skb)
- return NULL;
-
- 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;
- if(len)
- {
- memcpy(tag, ssid, len);
- tag += len;
- }
-
- ieee80211_MFIE_Brate(ieee,&tag);
- ieee80211_MFIE_Grate(ieee,&tag);
-
-#ifdef _RTL8187_EXT_PATCH_
- if(extMore)
- ieee->ext_patch_ieee80211_probe_req_2(ieee, skb, tag);
-#endif
- return skb;
-}
-
-#endif // _RTL8187_EXT_PATCH_
-
-
void ieee80211_send_probe(struct ieee80211_device *ieee)
{
struct sk_buff *skb;
-#ifdef _RTL8187_EXT_PATCH_
- if(ieee->iw_mode == ieee->iw_ext_mode)
- skb = ieee80211_probe_req_with_SSID(ieee, NULL, 0);
- else
-#endif
skb = ieee80211_probe_req(ieee);
if (skb){
softmac_mgmt_xmit(skb, ieee);
@@ -538,13 +439,10 @@ void ieee80211_send_probe_requests(struct ieee80211_device *ieee)
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
down(&ieee->scan_sem);
// printk("==================> Sync scan\n");
-// dump_chnl_map(channel_map);
while(1)
{
@@ -554,11 +452,7 @@ void ieee80211_softmac_scan_syncro(struct ieee80211_device *ieee)
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
@@ -583,9 +477,7 @@ void ieee80211_softmac_scan_syncro(struct ieee80211_device *ieee)
ieee->set_chan(ieee->dev, ch);
// printk("=====>channel=%d ",ch);
-#ifdef ENABLE_DOT11D
if(channel_map[ch] == 1)
-#endif
{
// printk("====send probe request\n");
ieee80211_send_probe_requests(ieee);
@@ -603,20 +495,16 @@ void ieee80211_softmac_scan_syncro(struct ieee80211_device *ieee)
out:
ieee->sync_scan_hurryup = 0;
up(&ieee->scan_sem);
-#ifdef ENABLE_DOT11D
if(IS_DOT11D_ENABLE(ieee))
DOT11D_ScanComplete(ieee);
-#endif
}
void ieee80211_softmac_ips_scan_syncro(struct ieee80211_device *ieee)
{
int ch;
unsigned int watch_dog = 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
down(&ieee->scan_sem);
ch = ieee->current_network.channel;
// if(ieee->sync_scan_hurryup)
@@ -650,16 +538,12 @@ void ieee80211_softmac_ips_scan_syncro(struct ieee80211_device *ieee)
{
goto out;
}
-#ifdef ENABLE_DOT11D
if(channel_map[ieee->current_network.channel] > 0)
-#endif
{
ieee->set_chan(ieee->dev, ieee->current_network.channel);
// printk("======>channel=%d ",ieee->current_network.channel);
}
-#ifdef ENABLE_DOT11D
if(channel_map[ieee->current_network.channel] == 1)
-#endif
{
// printk("====send probe request\n");
ieee80211_send_probe_requests(ieee);
@@ -678,11 +562,7 @@ void ieee80211_softmac_ips_scan_syncro(struct ieee80211_device *ieee)
goto out; /* scan completed */
ieee->current_network.channel = (ieee->current_network.channel + 1)%MAX_CHANNEL_NUMBER;
-#ifdef ENABLE_DOT11D
}while(!channel_map[ieee->current_network.channel]);
-#else
- }while(!ieee->channel_map[ieee->current_network.channel]);
-#endif
}
out:
//ieee->sync_scan_hurryup = 0;
@@ -690,46 +570,18 @@ out:
//ieee->current_network.channel = ch;
ieee->actscanning = false;
up(&ieee->scan_sem);
-#ifdef ENABLE_DOT11D
if(IS_DOT11D_ENABLE(ieee))
DOT11D_ScanComplete(ieee);
-#endif
}
-
-#if 0
-/* called both by wq with ieee->lock held */
-void ieee80211_softmac_scan(struct ieee80211_device *ieee)
-{
- 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]);
-
-
- schedule_work(&ieee->softmac_scan_wq);
-}
-#endif
#ifdef ENABLE_IPS
-#if (LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,20))
void ieee80211_softmac_scan_wq(struct work_struct *work)
{
struct delayed_work *dwork = to_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
static short watchdog = 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
// printk("ieee80211_softmac_scan_wq ENABLE_IPS\n");
// printk("in %s\n",__func__);
down(&ieee->scan_sem);
@@ -740,11 +592,7 @@ void ieee80211_softmac_scan_wq(struct ieee80211_device *ieee)
if (watchdog++ > MAX_CHANNEL_NUMBER)
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
//printk("current_network.channel:%d\n", ieee->current_network.channel);
if (ieee->scanning == 0 )
@@ -753,9 +601,7 @@ void ieee80211_softmac_scan_wq(struct ieee80211_device *ieee)
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);
queue_delayed_work(ieee->wq, &ieee->softmac_scan_wq, IEEE80211_SOFTMAC_SCAN_TIME);
@@ -767,28 +613,18 @@ out:
ieee->scanning = 0;
up(&ieee->scan_sem);
-#ifdef ENABLE_DOT11D
if(IS_DOT11D_ENABLE(ieee))
DOT11D_ScanComplete(ieee);
-#endif
return;
}
#else
-#if (LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,20))
void ieee80211_softmac_scan_wq(struct work_struct *work)
{
struct delayed_work *dwork = to_delayed_work(work);
struct ieee80211_device *ieee = container_of(work, struct ieee80211_device, softmac_scan_wq);
-#else
-void ieee80211_softmac_scan_wq(struct ieee80211_device *ieee)
-{
-#endif
-
short watchdog = 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
// printk("enter scan wq,watchdog is %d\n",watchdog);
down(&ieee->scan_sem);
@@ -798,11 +634,7 @@ void ieee80211_softmac_scan_wq(struct ieee80211_device *ieee)
if (watchdog++ > MAX_CHANNEL_NUMBER)
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
// printk("current_network.channel:%d\n", ieee->current_network.channel);
if (ieee->scanning == 0 )
@@ -811,33 +643,17 @@ void ieee80211_softmac_scan_wq(struct ieee80211_device *ieee)
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);
queue_delayed_work(ieee->wq, &ieee->softmac_scan_wq, IEEE80211_SOFTMAC_SCAN_TIME);
out:
up(&ieee->scan_sem);
-#ifdef ENABLE_DOT11D
if(IS_DOT11D_ENABLE(ieee))
DOT11D_ScanComplete(ieee);
-#endif
}
#endif
-#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)
{
@@ -913,7 +729,6 @@ void ieee80211_stop_scan(struct ieee80211_device *ieee)
/* 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))
@@ -921,7 +736,6 @@ void ieee80211_start_scan(struct ieee80211_device *ieee)
RESET_CIE_WATCHDOG(ieee);
}
}
-#endif
if (ieee->softmac_features & IEEE_SOFTMAC_SCAN){
if (ieee->scanning == 0)
{
@@ -941,7 +755,6 @@ void ieee80211_start_scan(struct ieee80211_device *ieee)
/* 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))
@@ -949,7 +762,6 @@ void ieee80211_start_scan_syncro(struct ieee80211_device *ieee)
RESET_CIE_WATCHDOG(ieee);
}
}
-#endif
ieee->sync_scan_hurryup = 0;
if (ieee->softmac_features & IEEE_SOFTMAC_SCAN)
@@ -1110,138 +922,6 @@ static struct sk_buff* ieee80211_probe_resp(struct ieee80211_device *ieee, u8 *d
skb->dev = ieee->dev;
return skb;
}
-#ifdef _RTL8187_EXT_PATCH_
-struct sk_buff* ieee80211_ext_probe_resp_by_net(struct ieee80211_device *ieee, u8 *dest, struct ieee80211_network *net)
-{
- u8 *tag;
- int beacon_size;
- struct ieee80211_probe_response *beacon_buf;
- struct sk_buff *skb;
- int encrypt;
- int atim_len,erp_len;
- struct ieee80211_crypt_data* crypt;
- u8 broadcast_addr[] = {0xff,0xff,0xff,0xff,0xff,0xff};
- int wpa_ie_len = ieee->wpa_ie_len;
- char *ssid = net->ssid;
- int ssid_len = net->ssid_len;
-
- int rate_len = ieee->current_network.rates_len+2;
- int rate_ex_len = ieee->current_network.rates_ex_len;
- if(rate_ex_len > 0) rate_ex_len+=2;
-
- if( ieee->meshScanMode&4)
- ieee->current_network.channel = ieee->ext_patch_ieee80211_ext_stop_scan_wq_set_channel(ieee);
- if( ieee->meshScanMode&6)
- {
-
-#if LINUX_VERSION_CODE > KERNEL_VERSION(2,5,0)
- queue_work(ieee->wq, &ieee->ext_stop_scan_wq);
-#else
- schedule_task(&ieee->ext_stop_scan_wq);
-#endif
- }
- if(ieee->current_network.capability & WLAN_CAPABILITY_IBSS) // use current_network here
- atim_len = 4;
- else
- atim_len = 0;
-
- if(ieee80211_is_54g(*net))
- erp_len = 3;
- else
- erp_len = 0;
-
- beacon_size = sizeof(struct ieee80211_probe_response)+
- ssid_len
- +3 //channel
- +rate_len
- +rate_ex_len
- +atim_len
- +erp_len;
-//b
- skb = dev_alloc_skb(beacon_size+196);
-
- if (!skb)
- return NULL;
-
- beacon_buf = (struct ieee80211_probe_response*) skb_put(skb, beacon_size);
-
- 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); // use current_network here
- beacon_buf->capability =
- cpu_to_le16(ieee->current_network.capability & WLAN_CAPABILITY_IBSS);
-
- 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];
-
- encrypt = ieee->host_encrypt && crypt && crypt->ops &&
- ((0 == strcmp(crypt->ops->name, "WEP"))||wpa_ie_len);
-
- 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.id = MFIE_TYPE_SSID;
- beacon_buf->info_element.len = ssid_len;
-
- tag = (u8*) beacon_buf->info_element.data;
-
- // brocad cast / probe rsp
- if(memcmp(dest, broadcast_addr, ETH_ALEN ))
- memcpy(tag, ssid, ssid_len);
- else
- ssid_len=0;
-
- tag += ssid_len;
-
-//get_bssrate_set(priv, _SUPPORTEDRATES_IE_, &pbssrate, &bssrate_len);
-//pbuf = set_ie(pbuf, _SUPPORTEDRATES_IE_, bssrate_len, pbssrate, &frlen);
-
- *(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; // use current_network here
-
-
- if(atim_len){
- *(tag++) = MFIE_TYPE_IBSS_SET;
- *(tag++) = 2;
- *((u16*)(tag)) = cpu_to_le16(ieee->current_network.atim_window); // use current_network here
- tag+=2;
- }
-
- if(erp_len){
- *(tag++) = MFIE_TYPE_ERP;
- *(tag++) = 1;
- *(tag++) = 0;
- }
-
- 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 (wpa_ie_len)
- memcpy(tag, ieee->wpa_ie, ieee->wpa_ie_len);
-
- skb->dev = ieee->dev;
- return skb;
-}
-#endif // _RTL8187_EXT_PATCH_
struct sk_buff* ieee80211_assoc_resp(struct ieee80211_device *ieee, u8 *dest)
{
@@ -1314,12 +994,7 @@ struct sk_buff* ieee80211_auth_resp(struct ieee80211_device *ieee,int status, u8
auth->transaction = cpu_to_le16(2);
auth->algorithm = cpu_to_le16(WLAN_AUTH_OPEN);
-#ifdef _RTL8187_EXT_PATCH_
- if(ieee->iw_mode == ieee->iw_ext_mode)
- memcpy(auth->header.addr3, dest, ETH_ALEN);
-#else
memcpy(auth->header.addr3, ieee->dev->dev_addr, ETH_ALEN);
-#endif
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);
@@ -1412,9 +1087,7 @@ inline struct sk_buff *ieee80211_association_req(struct ieee80211_network *beaco
#endif
unsigned int rate_len = ieee80211_MFIE_rate_len(ieee);
unsigned int wmm_info_len = beacon->QoS_Enable?9:0;
-#ifdef THOMAS_TURBO
unsigned int turbo_info_len = beacon->Turbo_Enable?9:0;
-#endif
u8 encry_proto = ieee->wpax_type_notify & 0xff;
//u8 pairwise_type = (ieee->wpax_type_notify >> 8) & 0xff;
@@ -1432,7 +1105,6 @@ inline struct sk_buff *ieee80211_association_req(struct ieee80211_network *beaco
wpa_len = 0;
}
}
-#ifdef THOMAS_TURBO
len = sizeof(struct ieee80211_assoc_request_frame)+
+ beacon->ssid_len//essid tagged val
+ rate_len//rates tagged val
@@ -1440,20 +1112,7 @@ inline struct sk_buff *ieee80211_association_req(struct ieee80211_network *beaco
+ rsn_len
+ wmm_info_len
+ turbo_info_len;
-#else
- len = sizeof(struct ieee80211_assoc_request_frame)+
- + beacon->ssid_len//essid tagged val
- + rate_len//rates tagged val
- + wpa_len
- + rsn_len
- + wmm_info_len;
-#endif
-#ifdef _RTL8187_EXT_PATCH_
- if(ieee->iw_mode == ieee->iw_ext_mode)
- skb = dev_alloc_skb(len+256); // stanley
- else
-#endif
skb = dev_alloc_skb(len);
if (!skb)
@@ -1479,11 +1138,6 @@ inline struct sk_buff *ieee80211_association_req(struct ieee80211_network *beaco
if(ieee->short_slot)
hdr->capability |= cpu_to_le16(WLAN_CAPABILITY_SHORT_SLOT);
-#ifdef _RTL8187_EXT_PATCH_
- if((ieee->iw_mode == ieee->iw_ext_mode) && ieee->ext_patch_ieee80211_association_req_1)
- ieee->ext_patch_ieee80211_association_req_1(hdr);
-#endif
-
hdr->listen_interval = 0xa; //FIXME
hdr->info_element.id = MFIE_TYPE_SSID;
@@ -1499,221 +1153,18 @@ inline struct sk_buff *ieee80211_association_req(struct ieee80211_network *beaco
//add rsn==0 condition for ap's mix security mode(wpa+wpa2), john2007.8.9
//choose AES encryption as default algorithm while using mixed mode
-#if 0
- if(rsn_len == 0){
-
- tag = skb_put(skb,wpa_len);
- if(wpa_len) {
-
-
- //{add by david. 2006.8.31
- //fix linksys compatibility bug
- //}
- if(wpa_len > 24) {//22+2, mean include the capability
- beacon->wpa_ie[wpa_len - 2] = 0;
- }
- //multicast cipher OUI
- if( beacon->wpa_ie[11]==0x2 ){ //0x0050f202 is the oui of tkip
- ieee->broadcast_key_type = KEY_TYPE_TKIP;
- }
- else if( beacon->wpa_ie[11]==0x4 ){//0x0050f204 is the oui of ccmp
- ieee->broadcast_key_type = KEY_TYPE_CCMP;
- }
- //unicast cipher OUI
- if( beacon->wpa_ie[14]==0
- && beacon->wpa_ie[15]==0x50
- && beacon->wpa_ie[16]==0xf2
- && beacon->wpa_ie[17]==0x2 ){ //0x0050f202 is the oui of tkip
- ieee->pairwise_key_type = KEY_TYPE_TKIP;
- }
-
- else if( beacon->wpa_ie[14]==0
- && beacon->wpa_ie[15]==0x50
- && beacon->wpa_ie[16]==0xf2
- && beacon->wpa_ie[17]==0x4 ){//0x0050f204 is the oui of ccmp
- ieee->pairwise_key_type = KEY_TYPE_CCMP;
- }
- //indicate the wpa_ie content to WPA_SUPPLICANT
- buff = kmalloc(IW_CUSTOM_MAX, GFP_ATOMIC);
- memset(buff, 0, IW_CUSTOM_MAX);
- p=buff;
- p += sprintf(p, "ASSOCINFO(ReqIEs=");
- for(i=0;i<wpa_len;i++){
- p += sprintf(p, "%02x", beacon->wpa_ie[i]);
- }
- p += sprintf(p, ")");
- memset(&wrqu, 0, sizeof(wrqu) );
- wrqu.data.length = p - buff;
-
- wireless_send_event(dev, IWEVCUSTOM, &wrqu, buff);
- memcpy(tag,beacon->wpa_ie,wpa_len);
- }
-
- }
-
- if(rsn_len > 22) {
-
- if( beacon->rsn_ie[4]==0x0 &&
- beacon->rsn_ie[5]==0xf &&
- beacon->rsn_ie[6]==0xac){
-
- switch(beacon->rsn_ie[7]){
- case 0x1:
- ieee->broadcast_key_type = KEY_TYPE_WEP40;
- break;
- case 0x2:
- ieee->broadcast_key_type = KEY_TYPE_TKIP;
- break;
- case 0x4:
- ieee->broadcast_key_type = KEY_TYPE_CCMP;
- break;
- case 0x5:
- ieee->broadcast_key_type = KEY_TYPE_WEP104;
- break;
- default:
- printk("fault suite type in RSN broadcast key\n");
- break;
- }
- }
-
- if( beacon->rsn_ie[10]==0x0 &&
- beacon->rsn_ie[11]==0xf &&
- beacon->rsn_ie[12]==0xac){
- if(beacon->rsn_ie[8]==1){//not mixed mode
- switch(beacon->rsn_ie[13]){
- case 0x2:
- ieee->pairwise_key_type = KEY_TYPE_TKIP;
- break;
- case 0x4:
- ieee->pairwise_key_type = KEY_TYPE_CCMP;
- break;
- default:
- printk("fault suite type in RSN pairwise key\n");
- break;
- }
- }
- else if(beacon->rsn_ie[8]==2){//mixed mode
- ieee->pairwise_key_type = KEY_TYPE_CCMP;
- }
- }
-
-
-
- tag = skb_put(skb,22);
- memcpy(tag,(beacon->rsn_ie + info_addr),8);
- tag[1] = 20;
- tag += 8;
- info_addr += 8;
-
- spin_lock_irqsave(&ieee->wpax_suitlist_lock,flags);
- for (i = 0; i < 2; i++) {
- tag[0] = 1;
- tag[1] = 0;
- tag += 2;
- suite_count = beacon->rsn_ie[info_addr] + \
- (beacon->rsn_ie[info_addr + 1] << 8);
- info_addr += 2;
- if(1 == suite_count) {
- memcpy(tag,(beacon->rsn_ie + info_addr),4);
- info_addr += 4;
- } else {
- // if the wpax_type_notify has been set by the application,
- // just use it, otherwise just use the default one.
- if(ieee->wpax_type_set) {
- suit_select = ((0 == i) ? pairwise_type:authen_type)&0x0f ;
- memcpy(tag,rsn_authen_cipher_suite[suit_select],4);
- } else {
- //default set as ccmp, or none authentication
- if(i == 0) {
- memcpy(tag,rsn_authen_cipher_suite[4],4);
- } else {
- memcpy(tag,rsn_authen_cipher_suite[2],4);
- }
-
- }
-
- info_addr += (suite_count * 4);
- }
- tag += 4;
- }
- spin_unlock_irqrestore(&ieee->wpax_suitlist_lock,flags);
-
- tag[0] = 0;
- tag[1] = beacon->rsn_ie[info_addr+1];
-
- } else {
- tag = skb_put(skb,rsn_len);
- if(rsn_len) {
-
-
- if( beacon->rsn_ie[4]==0x0 &&
- beacon->rsn_ie[5]==0xf &&
- beacon->rsn_ie[6]==0xac){
- switch(beacon->rsn_ie[7]){
- case 0x1:
- ieee->broadcast_key_type = KEY_TYPE_WEP40;
- break;
- case 0x2:
- ieee->broadcast_key_type = KEY_TYPE_TKIP;
- break;
- case 0x4:
- ieee->broadcast_key_type = KEY_TYPE_CCMP;
- break;
- case 0x5:
- ieee->broadcast_key_type = KEY_TYPE_WEP104;
- break;
- default:
- printk("fault suite type in RSN broadcast key\n");
- break;
- }
- }
- if( beacon->rsn_ie[10]==0x0 &&
- beacon->rsn_ie[11]==0xf &&
- beacon->rsn_ie[12]==0xac){
- if(beacon->rsn_ie[8]==1){//not mixed mode
- switch(beacon->rsn_ie[13]){
- case 0x2:
- ieee->pairwise_key_type = KEY_TYPE_TKIP;
- break;
- case 0x4:
- ieee->pairwise_key_type = KEY_TYPE_CCMP;
- break;
- default:
- printk("fault suite type in RSN pairwise key\n");
- break;
- }
-
- }
- else if(beacon->rsn_ie[8]==2){//mixed mode
- ieee->pairwise_key_type = KEY_TYPE_CCMP;
- }
- }
-
-
- beacon->rsn_ie[rsn_len - 2] = 0;
- memcpy(tag,beacon->rsn_ie,rsn_len);
- }
- }
-#else
tag = skb_put(skb,ieee->wpa_ie_len);
memcpy(tag,ieee->wpa_ie,ieee->wpa_ie_len);
-#endif
+
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
-
-#ifdef _RTL8187_EXT_PATCH_
- if((ieee->iw_mode == ieee->iw_ext_mode) && ieee->ext_patch_ieee80211_association_req_2)
- ieee->ext_patch_ieee80211_association_req_2(ieee, beacon, skb);
-#endif
return skb;
}
@@ -1761,13 +1212,6 @@ void ieee80211_associate_step1(struct ieee80211_device *ieee)
IEEE80211_DEBUG_MGMT("Stopping scan\n");
ieee->softmac_stats.tx_auth_rq++;
skb=ieee80211_authentication_req(beacon, ieee, 0);
-#ifdef _RTL8187_EXT_PATCH_
- if(ieee->iw_mode == ieee->iw_ext_mode ) {
- if(skb)
- softmac_mgmt_xmit(skb, ieee);
- return;
- }else
-#endif
if (!skb){
ieee80211_associate_abort(ieee);
@@ -1824,105 +1268,6 @@ void ieee80211_auth_challenge(struct ieee80211_device *ieee, u8 *challenge, int
kfree(challenge);
}
-#ifdef _RTL8187_EXT_PATCH_
-
-// based on ieee80211_assoc_resp
-struct sk_buff* ieee80211_assoc_resp_by_net(struct ieee80211_device *ieee, u8 *dest, unsigned short status, struct ieee80211_network *pstat, int pkt_type)
-{
- 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;
-
- if(ieee->iw_mode == ieee->iw_ext_mode)
- skb = dev_alloc_skb(len+256); // stanley
- else
- skb = dev_alloc_skb(len);
-
- if (!skb)
- return NULL;
-
- assoc = (struct ieee80211_assoc_response_frame *)
- skb_put(skb,sizeof(struct ieee80211_assoc_response_frame));
-
- assoc->header.frame_ctl = cpu_to_le16(pkt_type);
-
- 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->iw_mode == ieee->iw_ext_mode) && ieee->ext_patch_ieee80211_assoc_resp_by_net_1)
- ieee->ext_patch_ieee80211_assoc_resp_by_net_1(assoc);
-
- 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++;
-
- assoc->info_element.id = 230; // Stanley, an unused id (just a hot fix)
- assoc->info_element.len = 0;
-
- tag = (u8*) skb_put(skb, rate_len);
-
- ieee80211_MFIE_Brate(ieee, &tag);
- ieee80211_MFIE_Grate(ieee, &tag);
-
- if((ieee->iw_mode == ieee->iw_ext_mode) && ieee->ext_patch_ieee80211_assoc_resp_by_net_2)
- ieee->ext_patch_ieee80211_assoc_resp_by_net_2(ieee, pstat, pkt_type, skb);
-
- return skb;
-}
-
-// based on ieee80211_resp_to_assoc_rq
-void ieee80211_ext_issue_assoc_rsp(struct ieee80211_device *ieee, u8 *dest, unsigned short status, struct ieee80211_network *pstat, int pkt_type)
-{
- struct sk_buff *buf = ieee80211_assoc_resp_by_net(ieee, dest, status, pstat, pkt_type);
-
- if (buf)
- softmac_mgmt_xmit(buf, ieee);
-}
-
-// based on ieee80211_associate_step2
-void ieee80211_ext_issue_assoc_req(struct ieee80211_device *ieee, struct ieee80211_network *pstat)
-{
-
- struct sk_buff* skb;
-
- // printk("@@@@@ ieee80211_ext_issue_assoc_req on channel: %d\n", ieee->current_network.channel);
-
- ieee->softmac_stats.tx_ass_rq++;
- skb=ieee80211_association_req(pstat, ieee);
- if (skb)
- softmac_mgmt_xmit(skb, ieee);
-}
-
-void ieee80211_ext_issue_disassoc(struct ieee80211_device *ieee, struct ieee80211_network *pstat, int reason, unsigned char extReason)
-{
- // do nothing
- // printk("@@@@@ ieee80211_ext_issue_disassoc\n");
- return;
-}
-#endif // _RTL8187_EXT_PATCH_
-
void ieee80211_associate_step2(struct ieee80211_device *ieee)
{
struct sk_buff* skb;
@@ -1945,14 +1290,10 @@ void ieee80211_associate_step2(struct ieee80211_device *ieee)
}
}
-#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");
if(ieee80211_is_54g(ieee->current_network) &&
(ieee->modulation & IEEE80211_OFDM_MODULATION)){
@@ -1984,14 +1325,10 @@ void ieee80211_associate_complete(struct ieee80211_device *ieee)
queue_work(ieee->wq, &ieee->associate_complete_wq);
}
-#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);
@@ -2006,55 +1343,6 @@ void ieee80211_associate_procedure_wq(struct ieee80211_device *ieee)
up(&ieee->wx_sem);
}
-#ifdef _RTL8187_EXT_PATCH_
-// based on ieee80211_associate_procedure_wq
-
-#if LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,20)
-void ieee80211_ext_stop_scan_wq(struct work_struct *work)
-{
- struct ieee80211_device *ieee = container_of(work, struct ieee80211_device, ext_stop_scan_wq);
-#else
-void ieee80211_ext_stop_scan_wq(struct ieee80211_device *ieee)
-{
-#endif
- if (ieee->scanning == 0)
- {
- if((ieee->iw_mode == ieee->iw_ext_mode) && ieee->ext_patch_ieee80211_ext_stop_scan_wq_set_channel
- && ( ieee->current_network.channel == ieee->ext_patch_ieee80211_ext_stop_scan_wq_set_channel(ieee) ) )
- return;
- }
-
- ieee->sync_scan_hurryup = 1;
-
- down(&ieee->wx_sem);
-
- // printk("@@@@@@@@@@ ieee80211_ext_stop_scan_wq\n");
- if (ieee->data_hard_stop)
- ieee->data_hard_stop(ieee->dev);
-
- ieee80211_stop_scan(ieee);
-
- // set channel
- if((ieee->iw_mode == ieee->iw_ext_mode) && ieee->ext_patch_ieee80211_ext_stop_scan_wq_set_channel)
- ieee->set_chan(ieee->dev, ieee->ext_patch_ieee80211_ext_stop_scan_wq_set_channel(ieee));
- else
- ieee->set_chan(ieee->dev, ieee->current_network.channel);
- //
- up(&ieee->wx_sem);
-}
-
-
-void ieee80211_ext_send_11s_beacon(struct ieee80211_device *ieee)
-{
- #if LINUX_VERSION_CODE > KERNEL_VERSION(2,5,0)
- queue_work(ieee->wq, &ieee->ext_send_beacon_wq);
- #else
- schedule_task(&ieee->ext_send_beacon_wq);
- #endif
-
-}
-
-#endif // _RTL8187_EXT_PATCH_
inline void ieee80211_softmac_new_net(struct ieee80211_device *ieee, struct ieee80211_network *net)
{
@@ -2324,12 +1612,6 @@ ieee80211_rx_assoc_rq(struct ieee80211_device *ieee, struct sk_buff *skb)
}
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
}
@@ -2347,11 +1629,8 @@ void ieee80211_sta_ps_send_null_frame(struct ieee80211_device *ieee, short pwr)
short ieee80211_sta_ps_sleep(struct ieee80211_device *ieee, u32 *time_h, u32 *time_l)
{
-#if 0
- int timeout = ieee->ps_timeout;
-#else
int timeout = 0;
-#endif
+
u8 dtim;
/*if(ieee->ps == IEEE80211_PS_DISABLED ||
ieee->iw_mode != IW_MODE_INFRA ||
@@ -2382,13 +1661,7 @@ short ieee80211_sta_ps_sleep(struct ieee80211_device *ieee, u32 *time_h, u32 *ti
if((ieee->softmac_features & IEEE_SOFTMAC_SINGLE_QUEUE ) &&
(ieee->mgmt_queue_tail != ieee->mgmt_queue_head))
return 0;
-#if 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;
- }
-#else
+
if(time_l){
*time_l = ieee->current_network.last_dtim_sta_time[0]
+ MSECS((ieee->current_network.beacon_interval));
@@ -2396,7 +1669,6 @@ short ieee80211_sta_ps_sleep(struct ieee80211_device *ieee, u32 *time_h, u32 *ti
//printk("beacon_interval:%x, dtim_period:%x, totol to Msecs:%x, HZ:%x\n", ieee->current_network.beacon_interval, ieee->current_network.dtim_period, MSECS(((ieee->current_network.beacon_interval * ieee->current_network.dtim_period))), HZ);
}
-#endif
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])
@@ -2638,12 +1910,6 @@ associate_complete:
ieee80211_associate_abort(ieee);
}
}
-#ifdef _RTL8187_EXT_PATCH_
- else if ((ieee->iw_mode == ieee->iw_ext_mode) && ieee->ext_patch_ieee80211_rx_frame_softmac_on_assoc_rsp)
- {
- ieee->ext_patch_ieee80211_rx_frame_softmac_on_assoc_rsp(ieee, skb);
- }
-#endif
break;
case IEEE80211_STYPE_ASSOC_REQ:
@@ -2653,21 +1919,10 @@ associate_complete:
ieee->iw_mode == IW_MODE_MASTER)
ieee80211_rx_assoc_rq(ieee, skb);
-#ifdef _RTL8187_EXT_PATCH_
- else if ((ieee->iw_mode == ieee->iw_ext_mode) && ieee->ext_patch_ieee80211_rx_frame_softmac_on_assoc_req)
- {
- ieee->ext_patch_ieee80211_rx_frame_softmac_on_assoc_req(ieee, skb);
- }
-#endif
break;
case IEEE80211_STYPE_AUTH:
-#ifdef _RTL8187_EXT_PATCH_
-printk("IEEE80211_STYPE_AUTH\n");
- if((ieee->iw_mode == ieee->iw_ext_mode) && ieee->ext_patch_ieee80211_rx_frame_softmac_on_auth)
- if( ieee->ext_patch_ieee80211_rx_frame_softmac_on_auth(ieee, skb, rx_stats) );
-#endif
if (ieee->softmac_features & IEEE_SOFTMAC_ASSOCIATE){
if (ieee->state == IEEE80211_ASSOCIATING_AUTHENTICATING &&
ieee->iw_mode == IW_MODE_INFRA){
@@ -2707,11 +1962,6 @@ printk("IEEE80211_STYPE_AUTH\n");
case IEEE80211_STYPE_DISASSOC:
case IEEE80211_STYPE_DEAUTH:
-#ifdef _RTL8187_EXT_PATCH_
-printk("IEEE80211_STYPE_DEAUTH\n");
- if((ieee->iw_mode == ieee->iw_ext_mode) && ieee->ext_patch_ieee80211_rx_frame_softmac_on_deauth)
- if( ieee->ext_patch_ieee80211_rx_frame_softmac_on_deauth(ieee, skb, rx_stats) ) ;
-#endif
/* FIXME for now repeat all the association procedure
* both for disassociation and deauthentication
*/
@@ -2764,41 +2014,9 @@ void ieee80211_softmac_xmit(struct ieee80211_txb *txb, struct ieee80211_device *
unsigned long flags;
int i;
-#ifdef _RTL8187_EXT_PATCH_
- int rate = ieee->rate;
-#endif
spin_lock_irqsave(&ieee->lock,flags);
- #if 0
- if(ieee->queue_stop){
- IEEE80211DMESG("EE: IEEE hard_start_xmit invoked when kernel queue should be stopped");
- netif_stop_queue(ieee->dev);
- ieee->ieee_stats.swtxstop++;
- //dev_kfree_skb_any(skb);
- err = 1;
- goto exit;
- }
-
- ieee->stats.tx_bytes+=skb->len;
-
-
- txb=ieee80211_skb_to_txb(ieee,skb);
-
- if(txb==NULL){
- IEEE80211DMESG("WW: IEEE stack failed to provide txb");
- //dev_kfree_skb_any(skb);
- err = 1;
- goto exit;
- }
- #endif
-
-#ifdef _RTL8187_EXT_PATCH_
- if((ieee->iw_mode == ieee->iw_ext_mode) && ieee->ext_patch_ieee80211_softmac_xmit_get_rate && txb->nr_frags)
- {
- rate = ieee->ext_patch_ieee80211_softmac_xmit_get_rate(ieee, txb->fragments[0]);
- }
-#endif
/* called with 2nd parm 0, no tx mgmt lock required */
ieee80211_sta_wakeup(ieee,0);
@@ -2811,11 +2029,7 @@ void ieee80211_softmac_xmit(struct ieee80211_txb *txb, struct ieee80211_device *
}else{
ieee->softmac_data_hard_start_xmit(
txb->fragments[i],
-#ifdef _RTL8187_EXT_PATCH_
- ieee->dev, rate);
-#else
ieee->dev,ieee->rate);
-#endif
//(i+1)<txb->nr_frags);
ieee->stats.tx_packets++;
ieee->stats.tx_bytes += txb->fragments[i]->len;
@@ -2977,15 +2191,11 @@ void ieee80211_start_monitor_mode(struct ieee80211_device *ieee)
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 = to_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
@@ -3007,10 +2217,8 @@ void ieee80211_start_ibss_wq(struct ieee80211_device *ieee)
/* check if we have this cell in our network list */
ieee80211_softmac_check_all_nets(ieee);
-#ifdef ENABLE_DOT11D
if(ieee->state == IEEE80211_NOLINK)
ieee->current_network.channel = 10;
-#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
@@ -3099,7 +2307,6 @@ inline void ieee80211_start_ibss(struct ieee80211_device *ieee)
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.
@@ -3111,7 +2318,6 @@ void ieee80211_start_bss(struct ieee80211_device *ieee)
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
@@ -3150,24 +2356,17 @@ void ieee80211_disassociate(struct ieee80211_device *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->link_change(ieee->dev);
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 = to_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)
@@ -3217,16 +2416,7 @@ struct sk_buff *ieee80211_get_beacon_(struct ieee80211_device *ieee)
struct sk_buff *skb = NULL;
struct ieee80211_probe_response *b;
-//rz
-#ifdef _RTL8187_EXT_PATCH_
- if((ieee->iw_mode == ieee->iw_ext_mode) && ieee->ext_patch_get_beacon_get_probersp )
- skb = ieee->ext_patch_get_beacon_get_probersp(ieee, broadcast_addr, &(ieee->current_network));
- else
- skb = ieee80211_probe_resp(ieee, broadcast_addr);
-#else
skb = ieee80211_probe_resp(ieee, broadcast_addr);
-#endif
-//
if (!skb)
return NULL;
@@ -3273,17 +2463,6 @@ void ieee80211_stop_protocol(struct ieee80211_device *ieee)
ieee->proto_started = 0;
-#ifdef _RTL8187_EXT_PATCH_
- if(ieee->ext_patch_ieee80211_stop_protocol)
- ieee->ext_patch_ieee80211_stop_protocol(ieee);
-//if call queue_delayed_work,can call this,or do nothing..
-//edit by lawrence,20071118
-#if LINUX_VERSION_CODE > KERNEL_VERSION(2,5,0)
-// cancel_delayed_work(&ieee->ext_stop_scan_wq);
-// cancel_delayed_work(&ieee->ext_send_beacon_wq);
-#endif
-#endif // _RTL8187_EXT_PATCH_
-
ieee80211_stop_send_beacons(ieee);
if((ieee->iw_mode == IW_MODE_INFRA)&&(ieee->state == IEEE80211_LINKED)) {
SendDisassociation(ieee,NULL,WLAN_REASON_DISASSOC_STA_HAS_LEFT);
@@ -3320,11 +2499,7 @@ void ieee80211_start_protocol(struct ieee80211_device *ieee)
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;
}
@@ -3368,92 +2543,8 @@ void ieee80211_start_protocol(struct ieee80211_device *ieee)
break;
default:
-#ifdef _RTL8187_EXT_PATCH_
- if((ieee->iw_mode == ieee->iw_ext_mode) &&\
- ieee->ext_patch_ieee80211_start_protocol &&\
- ieee->ext_patch_ieee80211_start_protocol(ieee)) {
-#if LINUX_VERSION_CODE > KERNEL_VERSION(2,5,0)
- queue_work(ieee->wq, &ieee->ext_stop_scan_wq);
-#endif
- // By default, WMM function will be disabled in
- // EXTENSION mode
- ieee->current_network.QoS_Enable = 0;
-
- 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 = 540;
- }else{
- ieee->current_network.rates_ex_len = 0;
- ieee->rate = 110;
- }
-
- /*
- spin_lock_irqsave(&ieee->lock, flags);
- if (ieee->state == IEEE80211_NOLINK)
- ieee80211_start_scan(ieee);
- // ieee->set_chan(ieee->dev, 8);
-
- spin_unlock_irqrestore(&ieee->lock, flags);
- */
- memcpy(ieee->current_network.bssid, ieee->dev->dev_addr,\
- ETH_ALEN);
- 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);
- } else {
- ieee->iw_mode = IW_MODE_INFRA;
- ieee80211_start_bss(ieee);
- }
-#else
ieee->iw_mode = IW_MODE_INFRA;
ieee80211_start_bss(ieee);
-
-#endif
break;
}
}
@@ -3497,16 +2588,9 @@ void ieee80211_softmac_init(struct ieee80211_device *ieee)
ieee->beinretry = false;
ieee->bHwRadioOff = false;
//by amy
-#ifdef _RTL8187_EXT_PATCH_
- ieee->iw_ext_mode = 999;
-#endif
init_mgmt_queue(ieee);
-#if 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);
@@ -3522,7 +2606,6 @@ void ieee80211_softmac_init(struct ieee80211_device *ieee)
#else
ieee->wq = create_workqueue(DRV_NAME);
#endif
-#if LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,20)//added by lawrence,070702
INIT_DELAYED_WORK(&ieee->start_ibss_wq,(void*) ieee80211_start_ibss_wq);
INIT_WORK(&ieee->associate_complete_wq,(void*) ieee80211_associate_complete_wq);
INIT_WORK(&ieee->associate_procedure_wq,(void*) ieee80211_associate_procedure_wq);
@@ -3530,26 +2613,7 @@ void ieee80211_softmac_init(struct ieee80211_device *ieee)
INIT_DELAYED_WORK(&ieee->associate_retry_wq,(void*) ieee80211_associate_retry_wq);
INIT_WORK(&ieee->wx_sync_scan_wq,(void*) ieee80211_wx_sync_scan_wq);
// INIT_WORK(&ieee->watch_dog_wq,(void*) ieee80211_watch_dog_wq);
-//added by lawrence,20071118
-#ifdef _RTL8187_EXT_PATCH_
- INIT_WORK(&ieee->ext_stop_scan_wq,(void*) ieee80211_ext_stop_scan_wq);
- //INIT_WORK(&ieee->ext_send_beacon_wq,(void*) ieee80211_beacons_start,ieee);
- INIT_WORK(&ieee->ext_send_beacon_wq,(void*) ext_ieee80211_send_beacon_wq);
-#endif //_RTL8187_EXT_PATCH_
-#else
- INIT_WORK(&ieee->start_ibss_wq,(void*) ieee80211_start_ibss_wq,ieee);
- INIT_WORK(&ieee->associate_retry_wq,(void*) ieee80211_associate_retry_wq,ieee);
- INIT_WORK(&ieee->associate_complete_wq,(void*) ieee80211_associate_complete_wq,ieee);
- INIT_WORK(&ieee->associate_procedure_wq,(void*) ieee80211_associate_procedure_wq,ieee);
- INIT_WORK(&ieee->softmac_scan_wq,(void*) ieee80211_softmac_scan_wq,ieee);
- INIT_WORK(&ieee->wx_sync_scan_wq,(void*) ieee80211_wx_sync_scan_wq,ieee);
-// INIT_WORK(&ieee->watch_dog_wq,(void*) ieee80211_watch_dog_wq,ieee);
-#ifdef _RTL8187_EXT_PATCH_
- INIT_WORK(&ieee->ext_stop_scan_wq,(void*) ieee80211_ext_stop_scan_wq,ieee);
- //INIT_WORK(&ieee->ext_send_beacon_wq,(void*) ieee80211_beacons_start,ieee);
- INIT_WORK(&ieee->ext_send_beacon_wq,(void*) ext_ieee80211_send_beacon_wq,ieee);
-#endif
-#endif
+
sema_init(&ieee->wx_sem, 1);
sema_init(&ieee->scan_sem, 1);
@@ -3559,9 +2623,7 @@ void ieee80211_softmac_init(struct ieee80211_device *ieee)
tasklet_init(&ieee->ps_task,
(void(*)(unsigned long)) ieee80211_sta_ps,
(unsigned long)ieee);
-#ifdef ENABLE_DOT11D
ieee->pDot11dInfo = kmalloc(sizeof(RT_DOT11D_INFO), GFP_ATOMIC);
-#endif
}
void ieee80211_softmac_free(struct ieee80211_device *ieee)
@@ -3575,15 +2637,9 @@ void ieee80211_softmac_free(struct ieee80211_device *ieee)
//add for RF power on power of by lizhaoming 080512
cancel_delayed_work(&ieee->GPIOChangeRFWorkItem);
-#ifdef _RTL8187_EXT_PATCH_
- cancel_delayed_work(&ieee->ext_stop_scan_wq);
- cancel_delayed_work(&ieee->ext_send_beacon_wq);
-#endif
destroy_workqueue(ieee->wq);
-#ifdef ENABLE_DOT11D
if(NULL != ieee->pDot11dInfo)
kfree(ieee->pDot11dInfo);
-#endif
up(&ieee->wx_sem);
}
@@ -3992,38 +3048,3 @@ void notify_wx_assoc_event(struct ieee80211_device *ieee)
memset(wrqu.ap_addr.sa_data, 0, ETH_ALEN);
wireless_send_event(ieee->dev, SIOCGIWAP, &wrqu, NULL);
}
-
-
-#if 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_start_protocol);
-EXPORT_SYMBOL(ieee80211_stop_protocol);
-EXPORT_SYMBOL(notify_wx_assoc_event);
-EXPORT_SYMBOL(ieee80211_stop_send_beacons);
-EXPORT_SYMBOL(SendDisassociation);
-EXPORT_SYMBOL(ieee80211_disassociate);
-EXPORT_SYMBOL(ieee80211_start_scan);
-EXPORT_SYMBOL(ieee80211_softmac_ips_scan_syncro);
-#ifdef _RTL8187_EXT_PATCH_
-EXPORT_SYMBOL(ieee80211_ext_issue_assoc_req);
-EXPORT_SYMBOL(ieee80211_ext_issue_disassoc);
-EXPORT_SYMBOL(ieee80211_ext_issue_assoc_rsp);
-EXPORT_SYMBOL(softmac_mgmt_xmit);
-EXPORT_SYMBOL(ieee80211_ext_probe_resp_by_net);
-EXPORT_SYMBOL(ieee80211_start_scan);
-EXPORT_SYMBOL(ieee80211_stop_scan);
-EXPORT_SYMBOL(ieee80211_ext_send_11s_beacon);
-EXPORT_SYMBOL(ieee80211_rx_auth_rq);
-EXPORT_SYMBOL(ieee80211_associate_step1);
-#endif // _RTL8187_EXT_PATCH_
-EXPORT_SYMBOL(ieee80211_sta_ps_send_null_frame);
-#endif
diff --git a/drivers/staging/rtl8187se/ieee80211/ieee80211_softmac_wx.c b/drivers/staging/rtl8187se/ieee80211/ieee80211_softmac_wx.c
index 93af37e2d31a..f1d6cb452563 100644
--- a/drivers/staging/rtl8187se/ieee80211/ieee80211_softmac_wx.c
+++ b/drivers/staging/rtl8187se/ieee80211/ieee80211_softmac_wx.c
@@ -270,16 +270,9 @@ out:
}
-#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
-//void ieee80211_wx_sync_scan_wq(struct ieee80211_device *ieee)
-//{
short chan;
chan = ieee->current_network.channel;
@@ -379,11 +372,7 @@ int ieee80211_wx_set_essid(struct ieee80211_device *ieee,
if (wrqu->essid.flags && wrqu->essid.length) {
//YJ,modified,080819
-#if LINUX_VERSION_CODE < KERNEL_VERSION(2,6,20)
- len = ((wrqu->essid.length-1) < IW_ESSID_MAX_SIZE) ? (wrqu->essid.length-1) : IW_ESSID_MAX_SIZE;
-#else
len = (wrqu->essid.length < IW_ESSID_MAX_SIZE) ? (wrqu->essid.length) : IW_ESSID_MAX_SIZE;
-#endif
memset(ieee->current_network.ssid, 0, ieee->current_network.ssid_len); //YJ,add,080819
strncpy(ieee->current_network.ssid, extra, len);
ieee->current_network.ssid_len = len;
@@ -461,19 +450,19 @@ 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");
+ strlcpy(wrqu->name, "802.11", IFNAMSIZ);
if(ieee->modulation & IEEE80211_CCK_MODULATION){
- strcat(wrqu->name, "b");
+ strlcat(wrqu->name, "b", IFNAMSIZ);
if(ieee->modulation & IEEE80211_OFDM_MODULATION)
- strcat(wrqu->name, "/g");
+ strlcat(wrqu->name, "/g", IFNAMSIZ);
}else if(ieee->modulation & IEEE80211_OFDM_MODULATION)
- strcat(wrqu->name, "g");
+ strlcat(wrqu->name, "g", IFNAMSIZ);
if((ieee->state == IEEE80211_LINKED) ||
(ieee->state == IEEE80211_LINKED_SCANNING))
- strcat(wrqu->name," linked");
+ strlcat(wrqu->name," link", IFNAMSIZ);
else if(ieee->state != IEEE80211_NOLINK)
- strcat(wrqu->name," link..");
+ strlcat(wrqu->name," .....", IFNAMSIZ);
return 0;
@@ -581,22 +570,3 @@ exit:
return ret;
}
-
-#if 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);
-#endif
diff --git a/drivers/staging/rtl8187se/ieee80211/ieee80211_tx.c b/drivers/staging/rtl8187se/ieee80211/ieee80211_tx.c
index 1b774601b4a3..f520652954af 100644
--- a/drivers/staging/rtl8187se/ieee80211/ieee80211_tx.c
+++ b/drivers/staging/rtl8187se/ieee80211/ieee80211_tx.c
@@ -304,224 +304,6 @@ ieee80211_classify(struct sk_buff *skb, struct ieee80211_network *network)
return(wme_UP);
}
-#ifdef _RTL8187_EXT_PATCH_
-// based on part of ieee80211_xmit. Mainly allocate txb. ieee->lock is held
-struct ieee80211_txb *ieee80211_ext_alloc_txb(struct sk_buff *skb, struct net_device *dev, struct ieee80211_hdr_3addr *header, int hdr_len, u8 isQoS, u16 *pQOS_ctl, int isEncrypt, struct ieee80211_crypt_data* crypt)
-{
-#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_3addr *frag_hdr;
- int i, bytes_per_frag, nr_frags, bytes_last_frag, frag_size;
- int ether_type;
- int bytes, QOS_ctl;
- struct sk_buff *skb_frag;
-
- ether_type = ntohs(((struct ethhdr *)skb->data)->h_proto);
-
- /* 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);
-
- /* Determine fragmentation size based on destination (multicast
- * and broadcast are not fragmented) */
- // if (is_multicast_ether_addr(dest) ||
- // is_broadcast_ether_addr(dest)) {
- 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 {
- //printk(KERN_WARNING "&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&frag_size = %d\n", frag_size);
- frag_size = ieee->fts;//default:392
- QOS_ctl = 0;
- }
-
- if(isQoS) {
- QOS_ctl |= skb->priority; //set in the ieee80211_classify
- *pQOS_ctl = cpu_to_le16(QOS_ctl);
- }
- //printk(KERN_WARNING "header size = %d, QOS_ctl = %x\n", hdr_len,QOS_ctl);
- /* 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 - (IEEE80211_3ADDR_LEN + (ieee->current_network->QoS_Enable ? 2:0));
- 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 (isEncrypt)
- 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, GFP_ATOMIC);
- if (unlikely(!txb)) {
- printk(KERN_WARNING "%s: Could not allocate TXB\n",
- ieee->dev->name);
- return NULL;
- }
- txb->encrypted = isEncrypt;
- txb->payload_size = bytes;
-
- for (i = 0; i < nr_frags; i++) {
- skb_frag = txb->fragments[i];
- skb_frag->priority = UP2AC(skb->priority);
- if (isEncrypt)
- skb_reserve(skb_frag, crypt->ops->extra_prefix_len);
-
- frag_hdr = (struct ieee80211_hdr_3addr *)skb_put(skb_frag, hdr_len);
- memcpy(frag_hdr, (void *)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(
- header->frame_ctl | IEEE80211_FCTL_MOREFRAGS);
- bytes = bytes_per_frag;
-
- } else {
- /* The last fragment takes the remaining length */
- bytes = bytes_last_frag;
- }
-
- frag_hdr->seq_ctl = cpu_to_le16(ieee->seq_ctrl[0]<<4 | i);
- //frag_hdr->seq_ctl = cpu_to_le16(ieee->seq_ctrl<<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 (isEncrypt)
- ieee80211_encrypt_fragment(ieee, skb_frag, hdr_len);
- if (ieee->config &
- (CFG_IEEE80211_COMPUTE_FCS | CFG_IEEE80211_RESERVE_FCS))
- skb_put(skb_frag, 4);
- }
- // Advance sequence number in data frame.
- //printk(KERN_WARNING "QoS Enalbed? %s\n", ieee->current_network.QoS_Enable?"Y":"N");
- if (ieee->seq_ctrl[0] == 0xFFF)
- ieee->seq_ctrl[0] = 0;
- else
- ieee->seq_ctrl[0]++;
- // stanley, just for debug
-/*
-{
- int j=0;
- for(j=0;j<nr_frags;j++)
- {
- int i;
- struct sk_buff *skb = txb->fragments[j];
- printk("send(%d): ", j);
- for (i=0;i<skb->len;i++)
- printk("%02X ", skb->data[i]&0xff);
- printk("\n");
- }
-}
-*/
-
- return txb;
-}
-
-
-// based on part of ieee80211_xmit. Mainly allocate txb. ieee->lock is held
-// Assume no encryption, no FCS computing
-struct ieee80211_txb *ieee80211_ext_reuse_txb(struct sk_buff *skb, struct net_device *dev, struct ieee80211_hdr_3addr *header, int hdr_len, u8 isQoS, u16 *pQOS_ctl, int isEncrypt, struct ieee80211_crypt_data* crypt)
-{
-#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_3addr *frag_hdr;
- int ether_type;
- int bytes, QOS_ctl;
-
- ether_type = ntohs(((struct ethhdr *)skb->data)->h_proto);
-
- /* 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 (is_multicast_ether_addr(header->addr1) ||
- is_broadcast_ether_addr(header->addr1)) {
- QOS_ctl = QOS_CTL_NOTCONTAIN_ACK;
- }
- else {
- QOS_ctl = 0;
- }
-
- if(isQoS) {
- QOS_ctl |= skb->priority; //set in the ieee80211_classify
- *pQOS_ctl = cpu_to_le16(QOS_ctl);
- }
-
- txb = kmalloc( sizeof(struct ieee80211_txb) + sizeof(u8*), GFP_ATOMIC );
- if (unlikely(!txb)) {
- printk(KERN_WARNING "%s: Could not allocate TXB\n",
- ieee->dev->name);
- return NULL;
- }
-
- txb->nr_frags = 1;
- txb->frag_size = bytes;
- txb->encrypted = isEncrypt;
- txb->payload_size = bytes;
-
- txb->fragments[0] = skb;
- ieee80211_put_snap(
- skb_push(skb, SNAP_SIZE + sizeof(u16)), ether_type);
- frag_hdr = (struct ieee80211_hdr_3addr *)skb_push(skb, hdr_len);
- memcpy(frag_hdr, (void *)header, hdr_len);
- frag_hdr->seq_ctl = cpu_to_le16(ieee->seq_ctrl[0]<<4 | 0);
- skb->priority = UP2AC(skb->priority);
-
- // Advance sequence number in data frame.
- //printk(KERN_WARNING "QoS Enalbed? %s\n", ieee->current_network.QoS_Enable?"Y":"N");
- if (ieee->seq_ctrl[0] == 0xFFF)
- ieee->seq_ctrl[0] = 0;
- else
- ieee->seq_ctrl[0]++;
-
- return txb;
-}
-
-#endif // _RTL8187_EXT_PATCH_
-
/* SKBs are added to the ieee->tx_queue. */
int ieee80211_xmit(struct sk_buff *skb,
struct net_device *dev)
@@ -569,16 +351,6 @@ int ieee80211_xmit(struct sk_buff *skb,
goto success;
}
-
-#ifdef _RTL8187_EXT_PATCH_
- // note, skb->priority which was set by ieee80211_classify, and used by physical tx
- if((ieee->iw_mode == ieee->iw_ext_mode) && (ieee->ext_patch_ieee80211_xmit))
- {
- txb = ieee->ext_patch_ieee80211_xmit(skb, dev);
- goto success;
- }
-#endif
-
ether_type = ntohs(((struct ethhdr *)skb->data)->h_proto);
crypt = ieee->crypt[ieee->tx_keyidx];
@@ -790,10 +562,6 @@ int ieee80211_xmit(struct sk_buff *skb,
success:
spin_unlock_irqrestore(&ieee->lock, flags);
-#ifdef _RTL8187_EXT_PATCH_
- // Sometimes, extension mode can reuse skb (by txb->fragments[0])
- if( ! ((ieee->iw_mode == ieee->iw_ext_mode) && txb && (txb->fragments[0] == skb)) )
-#endif
dev_kfree_skb_any(skb);
if (txb) {
if (ieee->softmac_features & IEEE_SOFTMAC_TX_QUEUE){
@@ -817,12 +585,3 @@ int ieee80211_xmit(struct sk_buff *skb,
return NETDEV_TX_BUSY;
}
-
-#if 0
-EXPORT_SYMBOL(ieee80211_txb_free);
-#ifdef _RTL8187_EXT_PATCH_
-EXPORT_SYMBOL(ieee80211_alloc_txb);
-EXPORT_SYMBOL(ieee80211_ext_alloc_txb);
-EXPORT_SYMBOL(ieee80211_ext_reuse_txb);
-#endif // _RTL8187_EXT_PATCH_
-#endif
diff --git a/drivers/staging/rtl8187se/ieee80211/ieee80211_wx.c b/drivers/staging/rtl8187se/ieee80211/ieee80211_wx.c
index d1295e56fd42..ed62146c54f2 100644
--- a/drivers/staging/rtl8187se/ieee80211/ieee80211_wx.c
+++ b/drivers/staging/rtl8187se/ieee80211/ieee80211_wx.c
@@ -61,11 +61,7 @@ static inline char *rtl818x_translate_scan(struct ieee80211_device *ieee,
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))||IN_FEDORACORE_9)
start = iwe_stream_add_event(info, start, stop, &iwe, IW_EV_ADDR_LEN);
-#else
- start = iwe_stream_add_event(start, stop, &iwe, IW_EV_ADDR_LEN);
-#endif
/* Remaining entries will be displayed in the order we provide them */
@@ -77,28 +73,16 @@ static inline char *rtl818x_translate_scan(struct ieee80211_device *ieee,
if (network->ssid_len == 0) {
//YJ,modified,080903,end
iwe.u.data.length = sizeof("<hidden>");
-#if((LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,27))||IN_FEDORACORE_9)
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))||IN_FEDORACORE_9)
start = iwe_stream_add_point(info, start, stop, &iwe, network->ssid);
-#else
- start = iwe_stream_add_point(start, stop, &iwe, network->ssid);
-#endif
}
//printk("ESSID: %s\n",network->ssid);
/* Add the protocol name */
iwe.cmd = SIOCGIWNAME;
snprintf(iwe.u.name, IFNAMSIZ, "IEEE 802.11%s", ieee80211_modes[network->mode]);
-#if((LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,27))||IN_FEDORACORE_9)
start = iwe_stream_add_event(info, start, stop, &iwe, IW_EV_CHAR_LEN);
-#else
- start = iwe_stream_add_event(start, stop, &iwe, IW_EV_CHAR_LEN);
-#endif
/* Add mode */
iwe.cmd = SIOCGIWMODE;
@@ -109,11 +93,7 @@ static inline char *rtl818x_translate_scan(struct ieee80211_device *ieee,
else
iwe.u.mode = IW_MODE_ADHOC;
-#if((LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,27))||IN_FEDORACORE_9)
start = iwe_stream_add_event(info, start, stop, &iwe, IW_EV_UINT_LEN);
-#else
- start = iwe_stream_add_event(start, stop, &iwe, IW_EV_UINT_LEN);
-#endif
}
/* Add frequency/channel */
@@ -123,11 +103,7 @@ static inline char *rtl818x_translate_scan(struct ieee80211_device *ieee,
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))||IN_FEDORACORE_9)
start = iwe_stream_add_event(info, start, stop, &iwe, IW_EV_FREQ_LEN);
-#else
- start = iwe_stream_add_event(start, stop, &iwe, IW_EV_FREQ_LEN);
-#endif
/* Add encryption capability */
iwe.cmd = SIOCGIWENCODE;
@@ -136,11 +112,7 @@ static inline char *rtl818x_translate_scan(struct ieee80211_device *ieee,
else
iwe.u.data.flags = IW_ENCODE_DISABLED;
iwe.u.data.length = 0;
-#if((LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,27))||IN_FEDORACORE_9)
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;
@@ -169,20 +141,12 @@ static inline char *rtl818x_translate_scan(struct ieee80211_device *ieee,
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))||IN_FEDORACORE_9)
start = iwe_stream_add_event(info, start, stop, &iwe, IW_EV_PARAM_LEN);
-#else
- start = iwe_stream_add_event(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))||IN_FEDORACORE_9)
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... */
@@ -201,92 +165,35 @@ static inline char *rtl818x_translate_scan(struct ieee80211_device *ieee,
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))||IN_FEDORACORE_9)
start = iwe_stream_add_event(info, start, stop, &iwe, IW_EV_QUAL_LEN);
-#else
- start = iwe_stream_add_event(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))||IN_FEDORACORE_9)
start = iwe_stream_add_point(info, start, stop, &iwe, custom);
-#else
- start = iwe_stream_add_point(start, stop, &iwe, custom);
-#endif
-
-#if 0
- 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))||IN_FEDORACORE_9)
- 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]);
- }
-
-
-#else
- memset(&iwe, 0, sizeof(iwe));
if (network->wpa_ie_len) {
// printk("wpa_ie_len:%d\n", 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))||IN_FEDORACORE_9)
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) {
// printk("=====>rsn_ie_len:\n", network->rsn_ie_len);
- #if 0
- {
- int i;
- for (i=0; i<network->rsn_ie_len; i++);
- printk("%2x ", network->rsn_ie[i]);
- printk("\n");
- }
- #endif
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))||IN_FEDORACORE_9)
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;
@@ -295,11 +202,7 @@ static inline char *rtl818x_translate_scan(struct ieee80211_device *ieee,
" 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))||IN_FEDORACORE_9)
start = iwe_stream_add_point(info, start, stop, &iwe, custom);
-#else
- start = iwe_stream_add_point(start, stop, &iwe, custom);
-#endif
return start;
}
@@ -638,12 +541,7 @@ int ieee80211_wx_set_encode_ext(struct ieee80211_device *ieee,
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";
@@ -829,15 +727,6 @@ int ieee80211_wx_set_auth(struct ieee80211_device *ieee,
#if 1
int ieee80211_wx_set_gen_ie(struct ieee80211_device *ieee, u8 *ie, size_t len)
{
-#if 0
- printk("====>%s()\n", __func__);
- {
- int i;
- for (i=0; i<len; i++)
- printk("%2x ", ie[i]&0xff);
- printk("\n");
- }
-#endif
u8 *buf = NULL;
if (len>MAX_WPA_IE_LEN || (len && ie == NULL))
@@ -872,13 +761,3 @@ int ieee80211_wx_set_gen_ie(struct ieee80211_device *ieee, u8 *ie, size_t len)
}
#endif
-
-#if 0
-EXPORT_SYMBOL(ieee80211_wx_set_gen_ie);
-EXPORT_SYMBOL(ieee80211_wx_set_mlme);
-EXPORT_SYMBOL(ieee80211_wx_set_auth);
-EXPORT_SYMBOL(ieee80211_wx_set_encode_ext);
-EXPORT_SYMBOL(ieee80211_wx_get_scan);
-EXPORT_SYMBOL(ieee80211_wx_set_encode);
-EXPORT_SYMBOL(ieee80211_wx_get_encode);
-#endif
diff --git a/drivers/staging/rtl8187se/ieee80211/internal.h b/drivers/staging/rtl8187se/ieee80211/internal.h
deleted file mode 100644
index ddc22350d006..000000000000
--- a/drivers/staging/rtl8187se/ieee80211/internal.h
+++ /dev/null
@@ -1,115 +0,0 @@
-/*
- * 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/rtl8187se/ieee80211/rtl_crypto.h b/drivers/staging/rtl8187se/ieee80211/rtl_crypto.h
deleted file mode 100644
index 9ed0ca420857..000000000000
--- a/drivers/staging/rtl8187se/ieee80211/rtl_crypto.h
+++ /dev/null
@@ -1,399 +0,0 @@
-/*
- * 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_rtl
-#define crypto_unregister_alg crypto_unregister_alg_rtl
-#define crypto_alloc_tfm crypto_alloc_tfm_rtl
-#define crypto_free_tfm crypto_free_tfm_rtl
-#define crypto_alg_available crypto_alg_available_rtl
-
-/*
- * 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/rtl8187se/ieee80211_crypt.h b/drivers/staging/rtl8187se/ieee80211_crypt.h
deleted file mode 100644
index b58a3bcc0dc0..000000000000
--- a/drivers/staging/rtl8187se/ieee80211_crypt.h
+++ /dev/null
@@ -1,86 +0,0 @@
-/*
- * 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/rtl8187se/r8180.h b/drivers/staging/rtl8187se/r8180.h
index db446b7e2e08..8216d7e96d60 100644
--- a/drivers/staging/rtl8187se/r8180.h
+++ b/drivers/staging/rtl8187se/r8180.h
@@ -41,7 +41,7 @@
#include <linux/timer.h>
#include <linux/proc_fs.h> // Necessary because we use the proc fs
#include <linux/if_arp.h>
-#include "ieee80211.h"
+#include "ieee80211/ieee80211.h"
#include <asm/io.h>
//#include <asm/semaphore.h>
@@ -52,31 +52,16 @@
#define DEFAULT_FRAG_THRESHOLD 2342U
#define MIN_FRAG_THRESHOLD 256U
-//#define MAX_FRAG_THRESHOLD 2342U
#define DEFAULT_RTS_THRESHOLD 2342U
#define MIN_RTS_THRESHOLD 0U
#define MAX_RTS_THRESHOLD 2342U
#define DEFAULT_BEACONINTERVAL 0x64U
-#define DEFAULT_BEACON_ESSID "Rtl8180"
-#define DEFAULT_SSID ""
#define DEFAULT_RETRY_RTS 7
#define DEFAULT_RETRY_DATA 7
-#define PRISM_HDR_SIZE 64
-#ifdef CONFIG_RTL8185B
-
-#define MGNT_QUEUE 0
-#define BK_QUEUE 1
-#define BE_QUEUE 2
-#define VI_QUEUE 3
-#define VO_QUEUE 4
-#define HIGH_QUEUE 5
#define BEACON_QUEUE 6
-#define LOW_QUEUE BE_QUEUE
-#define NORMAL_QUEUE MGNT_QUEUE
-
#define aSifsTime 10
#define sCrcLng 4
@@ -199,7 +184,6 @@ typedef union _ThreeWire{
u16 longData;
}ThreeWireReg;
-#endif
typedef struct buffer
{
@@ -659,7 +643,6 @@ typedef struct r8180_priv
short ack_tx_to_ieee;
u8 PowerProfile;
-#ifdef CONFIG_RTL8185B
u32 CSMethod;
u8 cck_txpwr_base;
u8 ofdm_txpwr_base;
@@ -675,7 +658,6 @@ typedef struct r8180_priv
u32 IntrMask;
struct ChnlAccessSetting ChannelAccessSetting;
-#endif
}r8180_priv;
#define MANAGE_PRIORITY 0
@@ -750,11 +732,7 @@ void rtl8185b_irq_enable(struct net_device *dev);
void fix_rx_fifo(struct net_device *dev);
void fix_tx_fifo(struct net_device *dev);
void rtl8225z2_SetTXPowerLevel(struct net_device *dev, short ch);
-#if LINUX_VERSION_CODE >=KERNEL_VERSION(2,6,20)
void rtl8180_rate_adapter(struct work_struct * work);
-#else
-void rtl8180_rate_adapter(struct net_device *dev);
-#endif
//#endif
bool MgntActSet_RF_State(struct net_device *dev, RT_RF_POWER_STATE StateToSet, u32 ChangeSource);
diff --git a/drivers/staging/rtl8187se/r8180_93cx6.h b/drivers/staging/rtl8187se/r8180_93cx6.h
index a028a51b23f0..36ae100f3f16 100644
--- a/drivers/staging/rtl8187se/r8180_93cx6.h
+++ b/drivers/staging/rtl8187se/r8180_93cx6.h
@@ -28,11 +28,9 @@
#define RFCHIPID_MAXIM 4
#define RFCHIPID_GCT 5
#define RFCHIPID_RTL8225 9
-#ifdef CONFIG_RTL8185B
#define RF_ZEBRA2 11
#define EPROM_TXPW_BASE 0x05
#define RF_ZEBRA4 12
-#endif
#define RFCHIPID_RTL8255 0xa
#define RF_PARAM 0x19
#define RF_PARAM_DIGPHY_SHIFT 0
diff --git a/drivers/staging/rtl8187se/r8180_core.c b/drivers/staging/rtl8187se/r8180_core.c
index 26a59118d34c..08e00347bb61 100644
--- a/drivers/staging/rtl8187se/r8180_core.c
+++ b/drivers/staging/rtl8187se/r8180_core.c
@@ -22,69 +22,24 @@
A big big thanks goes also to Realtek corp. for their help in my attempt to
add RTL8185 and RTL8225 support, and to David Young also.
-*/
-
-#if 0
-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
+ Power management interface routines.
+ Written by Mariusz Matuszek.
+*/
-#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 DEBUG_TX
-//#define DEBUG_TX_DESC2
-//#define DEBUG_RX
-//#define DEBUG_RX_SKB
-
-//#define CONFIG_RTL8180_IO_MAP
+
#include <linux/syscalls.h>
-//#include <linux/fcntl.h>
-//#include <asm/uaccess.h>
+
#include "r8180_hw.h"
#include "r8180.h"
-#include "r8180_sa2400.h" /* PHILIPS Radio frontend */
-#include "r8180_max2820.h" /* MAXIM Radio frontend */
-#include "r8180_gct.h" /* GCT Radio frontend */
#include "r8180_rtl8225.h" /* RTL8225 Radio frontend */
-#include "r8180_rtl8255.h" /* RTL8255 Radio frontend */
#include "r8180_93cx6.h" /* Card EEPROM */
#include "r8180_wx.h"
#include "r8180_dm.h"
-#ifdef CONFIG_RTL8180_PM
-#include "r8180_pm.h"
-#endif
-
-#ifdef ENABLE_DOT11D
-#include "dot11d.h"
-#endif
-
-#ifdef CONFIG_RTL8185B
-//#define CONFIG_RTL8180_IO_MAP
-#endif
+#include "ieee80211/dot11d.h"
#ifndef PCI_VENDOR_ID_BELKIN
#define PCI_VENDOR_ID_BELKIN 0x1799
@@ -96,42 +51,11 @@ double __extendsfdf2(float a) {return a;}
static struct pci_device_id rtl8180_pci_id_tbl[] __devinitdata = {
{
.vendor = PCI_VENDOR_ID_REALTEK,
-// .device = 0x8180,
.device = 0x8199,
.subvendor = PCI_ANY_ID,
.subdevice = PCI_ANY_ID,
.driver_data = 0,
},
-#if 0
- {
- .vendor = PCI_VENDOR_ID_BELKIN,
- .device = 0x6001,
- .subvendor = PCI_ANY_ID,
- .subdevice = PCI_ANY_ID,
- .driver_data = 1,
- },
- { /* Belkin F5D6020 v3 */
- .vendor = PCI_VENDOR_ID_BELKIN,
- .device = 0x6020,
- .subvendor = PCI_ANY_ID,
- .subdevice = PCI_ANY_ID,
- .driver_data = 2,
- },
- { /* D-Link DWL-610 */
- .vendor = PCI_VENDOR_ID_DLINK,
- .device = 0x3300,
- .subvendor = PCI_ANY_ID,
- .subdevice = PCI_ANY_ID,
- .driver_data = 3,
- },
- {
- .vendor = PCI_VENDOR_ID_REALTEK,
- .device = 0x8185,
- .subvendor = PCI_ANY_ID,
- .subdevice = PCI_ANY_ID,
- .driver_data = 4,
- },
-#endif
{
.vendor = 0,
.device = 0,
@@ -144,7 +68,6 @@ static struct pci_device_id rtl8180_pci_id_tbl[] __devinitdata = {
static char* ifname = "wlan%d";
static int hwseqnum = 0;
-//static char* ifname = "ath%d";
static int hwwep = 0;
static int channels = 0x3fff;
@@ -156,35 +79,12 @@ MODULE_AUTHOR("Andrea Merello <andreamrl@tiscali.it>");
MODULE_DESCRIPTION("Linux driver for Realtek RTL8180 / RTL8185 WiFi cards");
-
-/*
-MODULE_PARM(ifname, "s");
-MODULE_PARM_DESC(devname," Net interface name, wlan%d=default");
-
-MODULE_PARM(hwseqnum,"i");
-MODULE_PARM_DESC(hwseqnum," Try to use hardware 802.11 header sequence numbers. Zero=default");
-
-MODULE_PARM(hwwep,"i");
-MODULE_PARM_DESC(hwwep," Try to use hardware WEP support. Still broken and not available on all cards");
-
-MODULE_PARM(channels,"i");
-MODULE_PARM_DESC(channels," Channel bitmask for specific locales. NYI");
-*/
-
-#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(devname," Net interface name, wlan%d=default");
-//MODULE_PARM_DESC(devname," Net interface name, ath%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 WEP support. Still broken and not available on all cards");
MODULE_PARM_DESC(channels," Channel bitmask for specific locales. NYI");
@@ -203,56 +103,73 @@ static void rtl8180_shutdown (struct pci_dev *pdev)
pci_disable_device(pdev);
}
-static struct pci_driver rtl8180_pci_driver = {
- .name = RTL8180_MODULE_NAME, /* Driver name */
- .id_table = rtl8180_pci_id_tbl, /* PCI_ID table */
- .probe = rtl8180_pci_probe, /* probe fn */
- .remove = __devexit_p(rtl8180_pci_remove),/* remove fn */
-#ifdef CONFIG_RTL8180_PM
- .suspend = rtl8180_suspend, /* PM suspend fn */
- .resume = rtl8180_resume, /* PM resume fn */
-#else
- .suspend = NULL, /* PM suspend fn */
- .resume = NULL, /* PM resume fn */
-#endif
- .shutdown = rtl8180_shutdown,
-};
+static int rtl8180_suspend(struct pci_dev *pdev, pm_message_t state)
+{
+ struct net_device *dev = pci_get_drvdata(pdev);
+ if (!netif_running(dev))
+ goto out_pci_suspend;
+ if (dev->netdev_ops->ndo_stop)
+ dev->netdev_ops->ndo_stop(dev);
-#ifdef CONFIG_RTL8180_IO_MAP
+ netif_device_detach(dev);
-u8 read_nic_byte(struct net_device *dev, int x)
-{
- return 0xff&inb(dev->base_addr +x);
+out_pci_suspend:
+ pci_save_state(pdev);
+ pci_disable_device(pdev);
+ pci_set_power_state(pdev, pci_choose_state(pdev, state));
+ return 0;
}
-u32 read_nic_dword(struct net_device *dev, int x)
+static int rtl8180_resume(struct pci_dev *pdev)
{
- return inl(dev->base_addr +x);
-}
+ struct net_device *dev = pci_get_drvdata(pdev);
+ int err;
+ u32 val;
-u16 read_nic_word(struct net_device *dev, int x)
-{
- return inw(dev->base_addr +x);
-}
+ pci_set_power_state(pdev, PCI_D0);
-void write_nic_byte(struct net_device *dev, int x,u8 y)
-{
- outb(y&0xff,dev->base_addr +x);
-}
+ err = pci_enable_device(pdev);
+ if (err) {
+ printk(KERN_ERR "%s: pci_enable_device failed on resume\n",
+ dev->name);
-void write_nic_word(struct net_device *dev, int x,u16 y)
-{
- outw(y,dev->base_addr +x);
-}
+ return err;
+ }
-void write_nic_dword(struct net_device *dev, int x,u32 y)
-{
- outl(y,dev->base_addr +x);
+ pci_restore_state(pdev);
+
+ /*
+ * Suspend/Resume resets the PCI configuration space, so we have to
+ * re-disable the RETRY_TIMEOUT register (0x41) to keep PCI Tx retries
+ * from interfering with C3 CPU state. pci_restore_state won't help
+ * here since it only restores the first 64 bytes pci config header.
+ */
+ pci_read_config_dword(pdev, 0x40, &val);
+ if ((val & 0x0000ff00) != 0)
+ pci_write_config_dword(pdev, 0x40, val & 0xffff00ff);
+
+ if (!netif_running(dev))
+ goto out;
+
+ if (dev->netdev_ops->ndo_open)
+ dev->netdev_ops->ndo_open(dev);
+
+ netif_device_attach(dev);
+out:
+ return 0;
}
-#else /* RTL_IO_MAP */
+static struct pci_driver rtl8180_pci_driver = {
+ .name = RTL8180_MODULE_NAME,
+ .id_table = rtl8180_pci_id_tbl,
+ .probe = rtl8180_pci_probe,
+ .remove = __devexit_p(rtl8180_pci_remove),
+ .suspend = rtl8180_suspend,
+ .resume = rtl8180_resume,
+ .shutdown = rtl8180_shutdown,
+};
u8 read_nic_byte(struct net_device *dev, int x)
{
@@ -287,21 +204,12 @@ void write_nic_word(struct net_device *dev, int x,u16 y)
udelay(20);
}
-#endif /* RTL_IO_MAP */
-
-
-
-
-
inline void force_pci_posting(struct net_device *dev)
{
read_nic_byte(dev,EPROM_CMD);
-#ifndef CONFIG_RTL8180_IO_MAP
mb();
-#endif
}
-
irqreturn_t rtl8180_interrupt(int irq, void *netdev, struct pt_regs *regs);
void set_nic_rxring(struct net_device *dev);
void set_nic_txring(struct net_device *dev);
@@ -309,10 +217,6 @@ static struct net_device_stats *rtl8180_stats(struct net_device *dev);
void rtl8180_commit(struct net_device *dev);
void rtl8180_start_tx_beacon(struct net_device *dev);
-/****************************************************************************
- -----------------------------PROCFS STUFF-------------------------
-*****************************************************************************/
-
static struct proc_dir_entry *rtl8180_proc = NULL;
static int proc_get_registers(char *page, char **start,
@@ -320,33 +224,22 @@ static int proc_get_registers(char *page, char **start,
int *eof, void *data)
{
struct net_device *dev = data;
-// struct r8180_priv *priv = (struct r8180_priv *)ieee80211_priv(dev);
-
int len = 0;
int i,n;
-
- int max=0xff;
+ int max = 0xff;
/* 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 (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,
- "%2x ",read_nic_byte(dev,n));
-
- // printk("%2x ",read_nic_byte(dev,n));
+ for (i = 0; i < 16 && n <= max; i++, n++)
+ len += snprintf(page + len, count - len, "%2x ",
+ read_nic_byte(dev, n));
}
len += snprintf(page + len, count - len,"\n");
-
-
*eof = 1;
return len;
-
}
int get_curr_tx_free_desc(struct net_device *dev, int priority);
@@ -355,56 +248,12 @@ 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 r8180_priv *priv = (struct r8180_priv *)ieee80211_priv(dev);
-
int len = 0;
-#ifdef CONFIG_RTL8185B
-#else
- len += snprintf(page + len, count - len,
- "NIC int: %lu\n"
- "Total int: %lu\n"
- "--------------------\n"
- "LP avail desc %d\n"
- "NP avail desc %d\n"
- "--------------------\n"
- "LP phys dma addr %x\n"
- "LP NIC ptr %x\n"
- "LP virt 32base %x\n"
- "LP virt 32tail %x\n"
- "--------------------\n"
- "NP phys dma addr %x\n"
- "NP NIC ptr %x\n"
- "NP virt 32base %x\n"
- "NP virt 32tail %x\n"
- "--------------------\n"
- "BP phys dma addr %x\n"
- "BP NIC ptr %x\n"
- "BP virt 32base %x\n"
- "BP virt 32tail %x\n",
- priv->stats.ints,
- priv->stats.shints,
- get_curr_tx_free_desc(dev,LOW_PRIORITY),
- get_curr_tx_free_desc(dev,NORM_PRIORITY),
- (u32)priv->txvipringdma,
- read_nic_dword(dev,TLPDA),
- (u32)priv->txvipring,
- (u32)priv->txvipringtail,
- (u32)priv->txvopringdma,
- read_nic_dword(dev,TNPDA),
- (u32)priv->txvopring,
- (u32)priv->txvopringtail,
- (u32)priv->txbeaconringdma,
- read_nic_dword(dev,TBDA),
- (u32)priv->txbeaconring,
- (u32)priv->txbeaconringtail);
-#endif
*eof = 1;
return len;
}
-
static int proc_get_stats_rx(char *page, char **start,
off_t offset, int count,
int *eof, void *data)
@@ -415,30 +264,6 @@ static int proc_get_stats_rx(char *page, char **start,
int len = 0;
len += snprintf(page + len, count - len,
- /* "RX descriptor not available: %lu\n"
- "RX incomplete (missing last descriptor): %lu\n"
- "RX not data: %lu\n"
- //"RX descriptor pointer reset: %lu\n"
- "RX descriptor pointer lost: %lu\n"
- //"RX pointer workaround: %lu\n"
- "RX error int: %lu\n"
- "RX fifo overflow: %lu\n"
- "RX int: %lu\n"
- "RX packet: %lu\n"
- "RX bytes: %lu\n"
- "RX DMA fail: %lu\n",
- priv->stats.rxrdu,
- priv->stats.rxnolast,
- priv->stats.rxnodata,
- //priv->stats.rxreset,
- priv->stats.rxnopointer,
- //priv->stats.rxwrkaround,
- priv->stats.rxerr,
- priv->stats.rxoverflow,
- priv->stats.rxint,
- priv->ieee80211->stats.rx_packets,
- priv->ieee80211->stats.rx_bytes,
- priv->stats.rxdmafail */
"RX OK: %lu\n"
"RX Retry: %lu\n"
"RX CRC Error(0-500): %lu\n"
@@ -457,82 +282,6 @@ static int proc_get_stats_rx(char *page, char **start,
return len;
}
-#if 0
-static int proc_get_stats_ieee(char *page, char **start,
- off_t offset, int count,
- int *eof, void *data)
-{
- struct net_device *dev = data;
- struct r8180_priv *priv = (struct r8180_priv *)ieee80211_priv(dev);
-
- int len = 0;
-
- len += snprintf(page + len, count - len,
- "TXed association requests: %u\n"
- "TXed authentication requests: %u\n"
- "RXed successful association response: %u\n"
- "RXed failed association response: %u\n"
- "RXed successful authentication response: %u\n"
- "RXed failed authentication response: %u\n"
- "Association requests without response: %u\n"
- "Authentication requests without response: %u\n"
- "TX probe response: %u\n"
- "RX probe request: %u\n"
- "TX probe request: %lu\n"
- "RX authentication requests: %lu\n"
- "RX association requests: %lu\n"
- "Reassociations: %lu\n",
- priv->ieee80211->ieee_stats.tx_ass,
- priv->ieee80211->ieee_stats.tx_aut,
- priv->ieee80211->ieee_stats.rx_ass_ok,
- priv->ieee80211->ieee_stats.rx_ass_err,
- priv->ieee80211->ieee_stats.rx_aut_ok,
- priv->ieee80211->ieee_stats.rx_aut_err,
- priv->ieee80211->ieee_stats.ass_noresp,
- priv->ieee80211->ieee_stats.aut_noresp,
- priv->ieee80211->ieee_stats.tx_probe,
- priv->ieee80211->ieee_stats.rx_probe,
- priv->ieee80211->ieee_stats.tx_probe_rq,
- priv->ieee80211->ieee_stats.rx_auth_rq,
- priv->ieee80211->ieee_stats.rx_assoc_rq,
- priv->ieee80211->ieee_stats.reassoc);
-
- *eof = 1;
- return len;
-}
-#endif
-#if 0
-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 r8180_priv *priv = (struct r8180_priv *)ieee80211_priv(dev);
- struct mac_htable_t *list;
- int i;
- int len = 0;
-
- if(priv->ieee80211->iw_mode != IW_MODE_MASTER){
- len += snprintf(page + len, count - len,
- "Card is not acting as AP...\n"
- );
- }else{
- len += snprintf(page + len, count - len,
- "List of associated STA:\n"
- );
-
- for(i=0;i<MAC_HTABLE_ENTRY;i++)
- for (list = priv->ieee80211->assoc_htable[i]; list!=NULL; list = list->next){
- len += snprintf(page + len, count - len,
- MACSTR"\n",MAC2STR(list->adr));
- }
-
- }
- *eof = 1;
- return len;
-}
-#endif
-
static int proc_get_stats_tx(char *page, char **start,
off_t offset, int count,
int *eof, void *data)
@@ -545,36 +294,6 @@ static int proc_get_stats_tx(char *page, char **start,
totalOK=priv->stats.txnpokint+priv->stats.txhpokint+priv->stats.txlpokint;
len += snprintf(page + len, count - len,
- /* "TX normal priority ok int: %lu\n"
- "TX normal priority error int: %lu\n"
- "TX high priority ok int: %lu\n"
- "TX high priority failed error int: %lu\n"
- "TX low priority ok int: %lu\n"
- "TX low priority failed error int: %lu\n"
- "TX bytes: %lu\n"
- "TX packets: %lu\n"
- "TX queue resume: %lu\n"
- "TX queue stopped?: %d\n"
- "TX fifo overflow: %lu\n"
- //"SW TX stop: %lu\n"
- //"SW TX wake: %lu\n"
- "TX beacon: %lu\n"
- "TX beacon aborted: %lu\n",
- priv->stats.txnpokint,
- priv->stats.txnperr,
- priv->stats.txhpokint,
- priv->stats.txhperr,
- priv->stats.txlpokint,
- priv->stats.txlperr,
- priv->ieee80211->stats.tx_bytes,
- priv->ieee80211->stats.tx_packets,
- priv->stats.txresumed,
- netif_queue_stopped(dev),
- priv->stats.txoverflow,
- //priv->ieee80211->ieee_stats.swtxstop,
- //priv->ieee80211->ieee_stats.swtxawake,
- priv->stats.txbeacon,
- priv->stats.txbeaconerr */
"TX OK: %lu\n"
"TX Error: %lu\n"
"TX Retry: %lu\n"
@@ -591,36 +310,17 @@ static int proc_get_stats_tx(char *page, char **start,
return len;
}
-
-#if WIRELESS_EXT < 17
-static struct iw_statistics *r8180_get_wireless_stats(struct net_device *dev)
-{
- struct r8180_priv *priv = ieee80211_priv(dev);
-
- return &priv->wstats;
-}
-#endif
void rtl8180_proc_module_init(void)
{
DMESG("Initializing proc filesystem");
-#if LINUX_VERSION_CODE < KERNEL_VERSION(2,6,24)
- rtl8180_proc=create_proc_entry(RTL8180_MODULE_NAME, S_IFDIR, proc_net);
-#else
rtl8180_proc=create_proc_entry(RTL8180_MODULE_NAME, S_IFDIR, init_net.proc_net);
-#endif
}
-
void rtl8180_proc_module_remove(void)
{
-#if LINUX_VERSION_CODE < KERNEL_VERSION(2,6,24)
- remove_proc_entry(RTL8180_MODULE_NAME, proc_net);
-#else
remove_proc_entry(RTL8180_MODULE_NAME, init_net.proc_net);
-#endif
}
-
void rtl8180_proc_remove_one(struct net_device *dev)
{
struct r8180_priv *priv = (struct r8180_priv *)ieee80211_priv(dev);
@@ -628,19 +328,17 @@ void rtl8180_proc_remove_one(struct net_device *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(dev->name, rtl8180_proc);
priv->dir_dev = NULL;
}
}
-
void rtl8180_proc_init_one(struct net_device *dev)
{
struct proc_dir_entry *e;
struct r8180_priv *priv = (struct r8180_priv *)ieee80211_priv(dev);
+
priv->dir_dev = rtl8180_proc;
if (!priv->dir_dev) {
DMESGE("Unable to initialize /proc/net/r8180/%s\n",
@@ -650,7 +348,6 @@ void rtl8180_proc_init_one(struct net_device *dev)
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/r8180/%s/stats-hw\n",
@@ -659,7 +356,6 @@ void rtl8180_proc_init_one(struct net_device *dev)
e = create_proc_read_entry("stats-rx", S_IFREG | S_IRUGO,
priv->dir_dev, proc_get_stats_rx, dev);
-
if (!e) {
DMESGE("Unable to initialize "
"/proc/net/r8180/%s/stats-rx\n",
@@ -669,45 +365,21 @@ void rtl8180_proc_init_one(struct net_device *dev)
e = create_proc_read_entry("stats-tx", S_IFREG | S_IRUGO,
priv->dir_dev, proc_get_stats_tx, dev);
-
if (!e) {
DMESGE("Unable to initialize "
"/proc/net/r8180/%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/rtl8180/%s/stats-ieee\n",
- dev->name);
- }
- #endif
- #if 0
- e = create_proc_read_entry("stats-ap", S_IFREG | S_IRUGO,
- priv->dir_dev, proc_get_stats_ap, dev);
-
- if (!e) {
- DMESGE("Unable to initialize "
- "/proc/net/rtl8180/%s/stats-ap\n",
- dev->name);
- }
- #endif
e = create_proc_read_entry("registers", S_IFREG | S_IRUGO,
priv->dir_dev, proc_get_registers, dev);
-
if (!e) {
DMESGE("Unable to initialize "
"/proc/net/r8180/%s/registers\n",
dev->name);
}
}
-/****************************************************************************
- -----------------------------MISC STUFF-------------------------
-*****************************************************************************/
+
/*
FIXME: check if we can use some standard already-existent
data type+functions in kernel
@@ -716,10 +388,6 @@ void rtl8180_proc_init_one(struct net_device *dev)
short buffer_add(struct buffer **buffer, u32 *buf, dma_addr_t dma,
struct buffer **bufferhead)
{
-#ifdef DEBUG_RING
- DMESG("adding buffer to TX/RX struct");
-#endif
-
struct buffer *tmp;
if(! *buffer){
@@ -751,7 +419,6 @@ short buffer_add(struct buffer **buffer, u32 *buf, dma_addr_t dma,
return 0;
}
-
void buffer_free(struct net_device *dev,struct buffer **buffer,int len,short
consistent)
{
@@ -759,14 +426,12 @@ consistent)
struct buffer *tmp,*next;
struct r8180_priv *priv = (struct r8180_priv *)ieee80211_priv(dev);
struct pci_dev *pdev=priv->pdev;
- //int i;
- if(! *buffer) return;
+ if (!*buffer)
+ return;
- /*for(tmp=*buffer; tmp->next != *buffer; tmp=tmp->next)
+ tmp = *buffer;
- */
- tmp=*buffer;
do{
next=tmp->next;
if(consistent){
@@ -785,7 +450,6 @@ consistent)
*buffer=NULL;
}
-
void print_buffer(u32 *buffer, int len)
{
int i;
@@ -804,7 +468,6 @@ void print_buffer(u32 *buffer, int len)
printk("\n");
}
-
int get_curr_tx_free_desc(struct net_device *dev, int priority)
{
struct r8180_priv *priv = ieee80211_priv(dev);
@@ -841,39 +504,33 @@ int get_curr_tx_free_desc(struct net_device *dev, int priority)
return -1;
}
- //DMESG("%x %x", head, tail);
-
- /* FIXME FIXME FIXME FIXME */
-
-#if 0
- if( head <= tail ) return priv->txringcount-1 - (tail - head)/8;
- return (head - tail)/8/4;
-#else
- if( head <= tail )
+ if (head <= tail)
ret = priv->txringcount - (tail - head)/8;
else
ret = (head - tail)/8;
- if(ret > priv->txringcount ) DMESG("BUG");
+ if (ret > priv->txringcount)
+ DMESG("BUG");
+
return ret;
-#endif
}
-
short check_nic_enought_desc(struct net_device *dev, int priority)
{
struct r8180_priv *priv = ieee80211_priv(dev);
struct ieee80211_device *ieee = netdev_priv(dev);
-
int requiredbyte, required;
+
requiredbyte = priv->ieee80211->fts + sizeof(struct ieee80211_header_data);
- if(ieee->current_network.QoS_Enable) {
+ if (ieee->current_network.QoS_Enable)
requiredbyte += 2;
- };
required = requiredbyte / (priv->txbuffsize-4);
- if (requiredbyte % priv->txbuffsize) required++;
+
+ if (requiredbyte % priv->txbuffsize)
+ required++;
+
/* for now we keep two free descriptor as a safety boundary
* between the tail and the head
*/
@@ -881,172 +538,12 @@ short check_nic_enought_desc(struct net_device *dev, int priority)
return (required+2 < get_curr_tx_free_desc(dev,priority));
}
-
-/* This function is only for debuging purpose */
-void check_tx_ring(struct net_device *dev, int pri)
-{
- static int maxlog =3;
- struct r8180_priv *priv = (struct r8180_priv *)ieee80211_priv(dev);
- u32* tmp;
- struct buffer *buf;
- int i;
- int nic;
- u32* tail;
- u32* head;
- u32* begin;
- u32 nicbegin;
- struct buffer* buffer;
-
- maxlog --;
- if (maxlog <0 ) return;
-
- switch(pri) {
- case MANAGE_PRIORITY:
- tail = priv->txmapringtail;
- begin = priv->txmapring;
- head = priv->txmapringhead;
- nic = read_nic_dword(dev,TX_MANAGEPRIORITY_RING_ADDR);
- buffer = priv->txmapbufs;
- nicbegin = priv->txmapringdma;
- break;
-
-
- case BK_PRIORITY:
- tail = priv->txbkpringtail;
- begin = priv->txbkpring;
- head = priv->txbkpringhead;
- nic = read_nic_dword(dev,TX_BKPRIORITY_RING_ADDR);
- buffer = priv->txbkpbufs;
- nicbegin = priv->txbkpringdma;
- break;
-
- case BE_PRIORITY:
- tail = priv->txbepringtail;
- begin = priv->txbepring;
- head = priv->txbepringhead;
- nic = read_nic_dword(dev,TX_BEPRIORITY_RING_ADDR);
- buffer = priv->txbepbufs;
- nicbegin = priv->txbepringdma;
- break;
-
- case VI_PRIORITY:
- tail = priv->txvipringtail;
- begin = priv->txvipring;
- head = priv->txvipringhead;
- nic = read_nic_dword(dev,TX_VIPRIORITY_RING_ADDR);
- buffer = priv->txvipbufs;
- nicbegin = priv->txvipringdma;
- break;
-
-
- case VO_PRIORITY:
- tail = priv->txvopringtail;
- begin = priv->txvopring;
- head = priv->txvopringhead;
- nic = read_nic_dword(dev,TX_VOPRIORITY_RING_ADDR);
- buffer = priv->txvopbufs;
- nicbegin = priv->txvopringdma;
- break;
-
- case HI_PRIORITY:
- tail = priv->txhpringtail;
- begin = priv->txhpring;
- head = priv->txhpringhead;
- nic = read_nic_dword(dev,TX_HIGHPRIORITY_RING_ADDR);
- buffer = priv->txhpbufs;
- nicbegin = priv->txhpringdma;
- break;
-
- default:
- return ;
- break;
- }
-
- if(!priv->txvopbufs)
- DMESGE ("NIC TX ack, but TX queue corrupted!");
- else{
-
- for(i=0,buf=buffer, tmp=begin;
- tmp<begin+(priv->txringcount)*8;
- tmp+=8,buf=buf->next,i++)
-
- DMESG("BUF%d %s %x %s. Next : %x",i,
- *tmp & (1<<31) ? "filled" : "empty",
- *(buf->buf),
- *tmp & (1<<15)? "ok": "err", *(tmp+4));
- }
-
- return;
-}
-
-
-
-/* this function is only for debugging purpose */
-void check_rxbuf(struct net_device *dev)
-{
- struct r8180_priv *priv = (struct r8180_priv *)ieee80211_priv(dev);
- u32* tmp;
- struct buffer *buf;
- u8 rx_desc_size;
-
-#ifdef CONFIG_RTL8185B
- rx_desc_size = 8;
-#else
- rx_desc_size = 4;
-#endif
-
- if(!priv->rxbuffer)
- DMESGE ("NIC RX ack, but RX queue corrupted!");
-
- else{
-
- for(buf=priv->rxbuffer, tmp=priv->rxring;
- tmp < priv->rxring+(priv->rxringcount)*rx_desc_size;
- tmp+=rx_desc_size, buf=buf->next)
-
- DMESG("BUF %s %x",
- *tmp & (1<<31) ? "empty" : "filled",
- *(buf->buf));
- }
-
- return;
-}
-
-
-void dump_eprom(struct net_device *dev)
-{
- int i;
- for(i=0; i<63; i++)
- DMESG("EEPROM addr %x : %x", i, eprom_read(dev,i));
-}
-
-
-void rtl8180_dump_reg(struct net_device *dev)
-{
- int i;
- int n;
- int max=0xff;
-
- DMESG("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");
-}
-
-
void fix_tx_fifo(struct net_device *dev)
{
struct r8180_priv *priv = (struct r8180_priv *)ieee80211_priv(dev);
u32 *tmp;
int i;
-#ifdef DEBUG_TX_ALLOC
- DMESG("FIXING TX FIFOs");
-#endif
+
for (tmp=priv->txmapring, i=0;
i < priv->txringcount;
tmp+=8, i++){
@@ -1087,9 +584,7 @@ void fix_tx_fifo(struct net_device *dev)
tmp+=8, i++){
*tmp = *tmp &~ (1<<31);
}
-#ifdef DEBUG_TX_ALLOC
- DMESG("TX FIFOs FIXED");
-#endif
+
priv->txmapringtail = priv->txmapring;
priv->txmapringhead = priv->txmapring;
priv->txmapbufstail = priv->txmapbufs;
@@ -1122,7 +617,6 @@ void fix_tx_fifo(struct net_device *dev)
priv->ack_tx_to_ieee = 0;
}
-
void fix_rx_fifo(struct net_device *dev)
{
struct r8180_priv *priv = (struct r8180_priv *)ieee80211_priv(dev);
@@ -1130,16 +624,7 @@ void fix_rx_fifo(struct net_device *dev)
struct buffer *rxbuf;
u8 rx_desc_size;
-#ifdef CONFIG_RTL8185B
rx_desc_size = 8; // 4*8 = 32 bytes
-#else
- rx_desc_size = 4;
-#endif
-
-#ifdef DEBUG_RXALLOC
- DMESG("FIXING RX FIFO");
- check_rxbuf(dev);
-#endif
for (tmp=priv->rxring, rxbuf=priv->rxbufferhead;
(tmp < (priv->rxring)+(priv->rxringcount)*rx_desc_size);
@@ -1150,50 +635,40 @@ void fix_rx_fifo(struct net_device *dev)
*tmp |= (1<<31);
}
-#ifdef DEBUG_RXALLOC
- DMESG("RX FIFO FIXED");
- check_rxbuf(dev);
-#endif
-
priv->rxringtail=priv->rxring;
priv->rxbuffer=priv->rxbufferhead;
priv->rx_skb_complete=1;
set_nic_rxring(dev);
}
-
-/****************************************************************************
- ------------------------------HW STUFF---------------------------
-*****************************************************************************/
-
unsigned char QUALITY_MAP[] = {
- 0x64, 0x64, 0x64, 0x63, 0x63, 0x62, 0x62, 0x61,
- 0x61, 0x60, 0x60, 0x5f, 0x5f, 0x5e, 0x5d, 0x5c,
- 0x5b, 0x5a, 0x59, 0x57, 0x56, 0x54, 0x52, 0x4f,
- 0x4c, 0x49, 0x45, 0x41, 0x3c, 0x37, 0x31, 0x29,
- 0x24, 0x22, 0x22, 0x22, 0x22, 0x22, 0x22, 0x22,
- 0x22, 0x22, 0x21, 0x21, 0x21, 0x21, 0x21, 0x20,
- 0x20, 0x20, 0x20, 0x1f, 0x1f, 0x1e, 0x1e, 0x1e,
- 0x1d, 0x1d, 0x1c, 0x1c, 0x1b, 0x1a, 0x19, 0x19,
- 0x18, 0x17, 0x16, 0x15, 0x14, 0x12, 0x11, 0x0f,
- 0x0e, 0x0c, 0x0a, 0x08, 0x06, 0x04, 0x01, 0x00
+ 0x64, 0x64, 0x64, 0x63, 0x63, 0x62, 0x62, 0x61,
+ 0x61, 0x60, 0x60, 0x5f, 0x5f, 0x5e, 0x5d, 0x5c,
+ 0x5b, 0x5a, 0x59, 0x57, 0x56, 0x54, 0x52, 0x4f,
+ 0x4c, 0x49, 0x45, 0x41, 0x3c, 0x37, 0x31, 0x29,
+ 0x24, 0x22, 0x22, 0x22, 0x22, 0x22, 0x22, 0x22,
+ 0x22, 0x22, 0x21, 0x21, 0x21, 0x21, 0x21, 0x20,
+ 0x20, 0x20, 0x20, 0x1f, 0x1f, 0x1e, 0x1e, 0x1e,
+ 0x1d, 0x1d, 0x1c, 0x1c, 0x1b, 0x1a, 0x19, 0x19,
+ 0x18, 0x17, 0x16, 0x15, 0x14, 0x12, 0x11, 0x0f,
+ 0x0e, 0x0c, 0x0a, 0x08, 0x06, 0x04, 0x01, 0x00
};
unsigned char STRENGTH_MAP[] = {
- 0x64, 0x64, 0x63, 0x62, 0x61, 0x60, 0x5f, 0x5e,
- 0x5d, 0x5c, 0x5b, 0x5a, 0x57, 0x54, 0x52, 0x50,
- 0x4e, 0x4c, 0x4a, 0x48, 0x46, 0x44, 0x41, 0x3f,
- 0x3c, 0x3a, 0x37, 0x36, 0x36, 0x1c, 0x1c, 0x1b,
- 0x1b, 0x1a, 0x1a, 0x19, 0x19, 0x18, 0x18, 0x17,
- 0x17, 0x16, 0x16, 0x15, 0x15, 0x14, 0x14, 0x13,
- 0x13, 0x12, 0x12, 0x11, 0x11, 0x10, 0x10, 0x0f,
- 0x0f, 0x0e, 0x0e, 0x0d, 0x0d, 0x0c, 0x0c, 0x0b,
- 0x0b, 0x0a, 0x0a, 0x09, 0x09, 0x08, 0x08, 0x07,
- 0x07, 0x06, 0x06, 0x05, 0x04, 0x03, 0x02, 0x00
+ 0x64, 0x64, 0x63, 0x62, 0x61, 0x60, 0x5f, 0x5e,
+ 0x5d, 0x5c, 0x5b, 0x5a, 0x57, 0x54, 0x52, 0x50,
+ 0x4e, 0x4c, 0x4a, 0x48, 0x46, 0x44, 0x41, 0x3f,
+ 0x3c, 0x3a, 0x37, 0x36, 0x36, 0x1c, 0x1c, 0x1b,
+ 0x1b, 0x1a, 0x1a, 0x19, 0x19, 0x18, 0x18, 0x17,
+ 0x17, 0x16, 0x16, 0x15, 0x15, 0x14, 0x14, 0x13,
+ 0x13, 0x12, 0x12, 0x11, 0x11, 0x10, 0x10, 0x0f,
+ 0x0f, 0x0e, 0x0e, 0x0d, 0x0d, 0x0c, 0x0c, 0x0b,
+ 0x0b, 0x0a, 0x0a, 0x09, 0x09, 0x08, 0x08, 0x07,
+ 0x07, 0x06, 0x06, 0x05, 0x04, 0x03, 0x02, 0x00
};
-void rtl8180_RSSI_calc(struct net_device *dev, u8 *rssi, u8 *qual){
- //void Mlme_UpdateRssiSQ(struct net_device *dev, u8 *rssi, u8 *qual){
+void rtl8180_RSSI_calc(struct net_device *dev, u8 *rssi, u8 *qual)
+{
struct r8180_priv *priv = (struct r8180_priv *)ieee80211_priv(dev);
u32 temp;
u32 temp2;
@@ -1289,8 +764,6 @@ void rtl8180_RSSI_calc(struct net_device *dev, u8 *rssi, u8 *qual){
}
}
break;
-
- /* case 4 */
case RFCHIPID_MAXIM:
lsb = temp2 & 1;
temp2 &= 0x7e;
@@ -1315,38 +788,27 @@ void rtl8180_RSSI_calc(struct net_device *dev, u8 *rssi, u8 *qual){
return;
}
-
void rtl8180_irq_enable(struct net_device *dev)
{
struct r8180_priv *priv = (struct r8180_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 rtl8180_irq_disable(struct net_device *dev)
{
struct r8180_priv *priv = (struct r8180_priv *)ieee80211_priv(dev);
-#ifdef CONFIG_RTL8185B
write_nic_dword(dev,IMR,0);
-#else
- write_nic_word(dev,INTA_MASK,0);
-#endif
force_pci_posting(dev);
priv->irq_enabled = 0;
}
-
void rtl8180_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);
@@ -1388,28 +850,21 @@ void rtl8180_update_msr(struct net_device *dev)
write_nic_byte(dev, MSR, msr);
write_nic_dword(dev, RX_CONF, rxconf);
-
}
-
-
void rtl8180_set_chan(struct net_device *dev,short ch)
{
struct r8180_priv *priv = (struct r8180_priv *)ieee80211_priv(dev);
- if((ch > 14) || (ch < 1))
- {
+ if ((ch > 14) || (ch < 1)) {
printk("In %s: Invalid chnanel %d\n", __func__, ch);
return;
}
priv->chan=ch;
- //printk("in %s:channel is %d\n",__func__,ch);
priv->rf_set_chan(dev,priv->chan);
-
}
-
void rtl8180_rx_enable(struct net_device *dev)
{
u8 cmd;
@@ -1423,8 +878,8 @@ void rtl8180_rx_enable(struct net_device *dev)
rxconf = rxconf | (1<<ACCEPT_DATA_FRAME_SHIFT);
rxconf = rxconf | (1<<ACCEPT_BCAST_FRAME_SHIFT);
rxconf = rxconf | (1<<ACCEPT_MCAST_FRAME_SHIFT);
-// rxconf = rxconf | (1<<ACCEPT_CRCERR_FRAME_SHIFT);
- if (dev->flags & IFF_PROMISC) DMESG ("NIC in promisc mode");
+ if (dev->flags & IFF_PROMISC)
+ DMESG("NIC in promisc mode");
if(priv->ieee80211->iw_mode == IW_MODE_MONITOR || \
dev->flags & IFF_PROMISC){
@@ -1435,11 +890,6 @@ void rtl8180_rx_enable(struct net_device *dev)
rxconf = rxconf | (1<<RX_CHECK_BSSID_SHIFT);
}
- /*if(priv->ieee80211->iw_mode == IW_MODE_MASTER){
- rxconf = rxconf | (1<<ACCEPT_ALLMAC_FRAME_SHIFT);
- rxconf = rxconf | (1<<RX_CHECK_BSSID_SHIFT);
- }*/
-
if(priv->ieee80211->iw_mode == IW_MODE_MONITOR){
rxconf = rxconf | (1<<ACCEPT_CTL_FRAME_SHIFT);
rxconf = rxconf | (1<<ACCEPT_ICVERR_FRAME_SHIFT);
@@ -1449,84 +899,61 @@ void rtl8180_rx_enable(struct net_device *dev)
if( priv->crcmon == 1 && priv->ieee80211->iw_mode == IW_MODE_MONITOR)
rxconf = rxconf | (1<<ACCEPT_CRCERR_FRAME_SHIFT);
- //if(!priv->card_8185){
- rxconf = rxconf &~ RX_FIFO_THRESHOLD_MASK;
- rxconf = rxconf | (RX_FIFO_THRESHOLD_NONE<<RX_FIFO_THRESHOLD_SHIFT);
- //}
+ rxconf = rxconf & ~RX_FIFO_THRESHOLD_MASK;
+ rxconf = rxconf | (RX_FIFO_THRESHOLD_NONE << RX_FIFO_THRESHOLD_SHIFT);
rxconf = rxconf | (1<<RX_AUTORESETPHY_SHIFT);
rxconf = rxconf &~ MAX_RX_DMA_MASK;
rxconf = rxconf | (MAX_RX_DMA_2048<<MAX_RX_DMA_SHIFT);
- //if(!priv->card_8185)
- rxconf = rxconf | RCR_ONLYERLPKT;
+ rxconf = rxconf | RCR_ONLYERLPKT;
rxconf = rxconf &~ RCR_CS_MASK;
- if(!priv->card_8185)
+
+ if (!priv->card_8185)
rxconf |= (priv->rcr_csense<<RCR_CS_SHIFT);
-// rxconf &=~ 0xfff00000;
-// rxconf |= 0x90100000;//9014f76f;
+
write_nic_dword(dev, RX_CONF, rxconf);
fix_rx_fifo(dev);
-#ifdef DEBUG_RX
- DMESG("rxconf: %x %x",rxconf ,read_nic_dword(dev,RX_CONF));
-#endif
cmd=read_nic_byte(dev,CMD);
write_nic_byte(dev,CMD,cmd | (1<<CMD_RX_ENABLE_SHIFT));
-
- /* In rtl8139 driver seems that DMA threshold has to be written
- * after enabling RX, so we rewrite RX_CONFIG register
- */
- //mdelay(100);
-// write_nic_dword(dev, RX_CONF, rxconf);
-
}
-
void set_nic_txring(struct net_device *dev)
{
struct r8180_priv *priv = (struct r8180_priv *)ieee80211_priv(dev);
-// DMESG("ring %x %x", priv->txlpringdma,read_nic_dword(dev,TLPDA));
write_nic_dword(dev, TX_MANAGEPRIORITY_RING_ADDR, priv->txmapringdma);
-// DMESG("ring %x %x", priv->txlpringdma,read_nic_dword(dev,TLPDA));
write_nic_dword(dev, TX_BKPRIORITY_RING_ADDR, priv->txbkpringdma);
-// DMESG("ring %x %x", priv->txlpringdma,read_nic_dword(dev,TLPDA));
write_nic_dword(dev, TX_BEPRIORITY_RING_ADDR, priv->txbepringdma);
-// DMESG("ring %x %x", priv->txlpringdma,read_nic_dword(dev,TLPDA));
write_nic_dword(dev, TX_VIPRIORITY_RING_ADDR, priv->txvipringdma);
-// DMESG("ring %x %x", priv->txlpringdma,read_nic_dword(dev,TLPDA));
write_nic_dword(dev, TX_VOPRIORITY_RING_ADDR, priv->txvopringdma);
-// DMESG("ring %x %x", priv->txlpringdma,read_nic_dword(dev,TLPDA));
write_nic_dword(dev, TX_HIGHPRIORITY_RING_ADDR, priv->txhpringdma);
-// DMESG("ring %x %x", priv->txlpringdma,read_nic_dword(dev,TLPDA));
-
write_nic_dword(dev, TX_BEACON_RING_ADDR, priv->txbeaconringdma);
}
-
void rtl8180_conttx_enable(struct net_device *dev)
{
u32 txconf;
+
txconf = read_nic_dword(dev,TX_CONF);
txconf = txconf &~ TX_LOOPBACK_MASK;
txconf = txconf | (TX_LOOPBACK_CONTINUE <<TX_LOOPBACK_SHIFT);
write_nic_dword(dev,TX_CONF,txconf);
}
-
void rtl8180_conttx_disable(struct net_device *dev)
{
u32 txconf;
+
txconf = read_nic_dword(dev,TX_CONF);
txconf = txconf &~ TX_LOOPBACK_MASK;
txconf = txconf | (TX_LOOPBACK_NONE <<TX_LOOPBACK_SHIFT);
write_nic_dword(dev,TX_CONF,txconf);
}
-
void rtl8180_tx_enable(struct net_device *dev)
{
u8 cmd;
@@ -1534,12 +961,10 @@ void rtl8180_tx_enable(struct net_device *dev)
u8 byte;
u32 txconf;
struct r8180_priv *priv = (struct r8180_priv *)ieee80211_priv(dev);
- txconf= read_nic_dword(dev,TX_CONF);
-
-
- if(priv->card_8185){
+ txconf = read_nic_dword(dev, TX_CONF);
+ if (priv->card_8185) {
byte = read_nic_byte(dev,CW_CONF);
byte &= ~(1<<CW_CONF_PERPACKET_CW_SHIFT);
byte &= ~(1<<CW_CONF_PERPACKET_RETRY_SHIFT);
@@ -1550,26 +975,12 @@ void rtl8180_tx_enable(struct net_device *dev)
tx_agc_ctl &= ~(1<<TX_AGC_CTL_PERPACKET_ANTSEL_SHIFT);
tx_agc_ctl |=(1<<TX_AGC_CTL_FEEDBACK_ANT);
write_nic_byte(dev, TX_AGC_CTL, tx_agc_ctl);
- /*
- write_nic_word(dev, 0x5e, 0x01);
- force_pci_posting(dev);
- mdelay(1);
- write_nic_word(dev, 0xfe, 0x10);
- force_pci_posting(dev);
- mdelay(1);
- write_nic_word(dev, 0x5e, 0x00);
- force_pci_posting(dev);
- mdelay(1);
- */
write_nic_byte(dev, 0xec, 0x3f); /* Disable early TX */
}
- if(priv->card_8185){
-
+ if (priv->card_8185)
txconf = txconf &~ (1<<TCR_PROBE_NOTIMESTAMP_SHIFT);
-
- }else{
-
+ else {
if(hwseqnum)
txconf= txconf &~ (1<<TX_CONF_HEADER_AUTOICREMENT_SHIFT);
else
@@ -1584,80 +995,52 @@ void rtl8180_tx_enable(struct net_device *dev)
txconf = txconf | (priv->retry_rts<<TX_RTSRETRY_SHIFT);
txconf = txconf &~ (1<<TX_NOCRC_SHIFT);
- if(priv->card_8185){
- if(priv->hw_plcp_len)
+ if (priv->card_8185) {
+ if (priv->hw_plcp_len)
txconf = txconf &~ TCR_PLCP_LEN;
else
txconf = txconf | TCR_PLCP_LEN;
- }else{
+ } else
txconf = txconf &~ TCR_SAT;
- }
+
txconf = txconf &~ TCR_MXDMA_MASK;
txconf = txconf | (TCR_MXDMA_2048<<TCR_MXDMA_SHIFT);
txconf = txconf | TCR_CWMIN;
txconf = txconf | TCR_DISCW;
-// if(priv->ieee80211->hw_wep)
-// txconf=txconf &~ (1<<TX_NOICV_SHIFT);
-// else
- txconf=txconf | (1<<TX_NOICV_SHIFT);
+ txconf = txconf | (1 << TX_NOICV_SHIFT);
write_nic_dword(dev,TX_CONF,txconf);
-
fix_tx_fifo(dev);
-#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));
-// mdelay(100);
write_nic_dword(dev,TX_CONF,txconf);
-// #endif
-/*
- rtl8180_set_mode(dev,EPROM_CMD_CONFIG);
- write_nic_byte(dev, TX_DMA_POLLING, priv->dma_poll_mask);
- rtl8180_set_mode(dev,EPROM_CMD_NORMAL);
- */
}
-
void rtl8180_beacon_tx_enable(struct net_device *dev)
{
struct r8180_priv *priv = (struct r8180_priv *)ieee80211_priv(dev);
rtl8180_set_mode(dev,EPROM_CMD_CONFIG);
-#ifdef CONFIG_RTL8185B
priv->dma_poll_stop_mask &= ~(TPPOLLSTOP_BQ);
write_nic_byte(dev,TPPollStop, priv->dma_poll_mask);
-#else
- priv->dma_poll_mask &=~(1<<TX_DMA_STOP_BEACON_SHIFT);
- write_nic_byte(dev,TX_DMA_POLLING,priv->dma_poll_mask);
-#endif
rtl8180_set_mode(dev,EPROM_CMD_NORMAL);
}
-
void rtl8180_beacon_tx_disable(struct net_device *dev)
{
struct r8180_priv *priv = (struct r8180_priv *)ieee80211_priv(dev);
rtl8180_set_mode(dev,EPROM_CMD_CONFIG);
-#ifdef CONFIG_RTL8185B
priv->dma_poll_stop_mask |= TPPOLLSTOP_BQ;
write_nic_byte(dev,TPPollStop, priv->dma_poll_stop_mask);
-#else
- priv->dma_poll_mask |= (1<<TX_DMA_STOP_BEACON_SHIFT);
- write_nic_byte(dev,TX_DMA_POLLING,priv->dma_poll_mask);
-#endif
rtl8180_set_mode(dev,EPROM_CMD_NORMAL);
}
-
void rtl8180_rtx_disable(struct net_device *dev)
{
u8 cmd;
@@ -1668,42 +1051,11 @@ void rtl8180_rtx_disable(struct net_device *dev)
((1<<CMD_RX_ENABLE_SHIFT)|(1<<CMD_TX_ENABLE_SHIFT)));
force_pci_posting(dev);
mdelay(10);
- /*while (read_nic_byte(dev,CMD) & (1<<CMD_RX_ENABLE_SHIFT))
- udelay(10);
- */
if(!priv->rx_skb_complete)
dev_kfree_skb_any(priv->rx_skb);
}
-#if 0
-int alloc_tx_beacon_desc_ring(struct net_device *dev, int count)
-{
- int i;
- u32 *tmp;
- struct r8180_priv *priv = (struct r8180_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;
- }
- return 0;
-}
-#endif
-
short alloc_tx_desc_ring(struct net_device *dev, int bufsize, int count,
int addr)
{
@@ -1721,51 +1073,30 @@ short alloc_tx_desc_ring(struct net_device *dev, int bufsize, int count,
}
desc = (u32*)pci_alloc_consistent(pdev,
sizeof(u32)*8*count+256, &dma_desc);
- if(desc==NULL) return -1;
- if(dma_desc & 0xff){
+ if (desc == NULL)
+ return -1;
+ if (dma_desc & 0xff)
/*
* descriptor's buffer must be 256 byte aligned
* we shouldn't be here, since we set DMA mask !
*/
WARN(1, "DMA buffer is not aligned\n");
- }
- tmp=desc;
- for (i=0;i<count;i++)
- {
- buf = (void*)pci_alloc_consistent(pdev,bufsize,&dma_tmp);
- if (buf == NULL) return -ENOMEM;
- switch(addr) {
-#if 0
- case TX_NORMPRIORITY_RING_ADDR:
- if(-1 == buffer_add(&(priv->txnpbufs),buf,dma_tmp,NULL)){
- DMESGE("Unable to allocate mem for buffer NP");
- return -ENOMEM;
- }
- break;
+ tmp = desc;
- case TX_LOWPRIORITY_RING_ADDR:
- if(-1 == buffer_add(&(priv->txlpbufs),buf,dma_tmp,NULL)){
- DMESGE("Unable to allocate mem for buffer LP");
- return -ENOMEM;
- }
- break;
+ for (i = 0; i < count; i++) {
+ buf = (void *)pci_alloc_consistent(pdev, bufsize, &dma_tmp);
+ if (buf == NULL)
+ return -ENOMEM;
- case TX_HIGHPRIORITY_RING_ADDR:
- if(-1 == buffer_add(&(priv->txhpbufs),buf,dma_tmp,NULL)){
- DMESGE("Unable to allocate mem for buffer HP");
- return -ENOMEM;
- }
- break;
-#else
+ switch(addr) {
case TX_MANAGEPRIORITY_RING_ADDR:
if(-1 == buffer_add(&(priv->txmapbufs),buf,dma_tmp,NULL)){
DMESGE("Unable to allocate mem for buffer NP");
return -ENOMEM;
}
break;
-
case TX_BKPRIORITY_RING_ADDR:
if(-1 == buffer_add(&(priv->txbkpbufs),buf,dma_tmp,NULL)){
DMESGE("Unable to allocate mem for buffer LP");
@@ -1778,7 +1109,6 @@ short alloc_tx_desc_ring(struct net_device *dev, int bufsize, int count,
return -ENOMEM;
}
break;
-
case TX_VIPRIORITY_RING_ADDR:
if(-1 == buffer_add(&(priv->txvipbufs),buf,dma_tmp,NULL)){
DMESGE("Unable to allocate mem for buffer LP");
@@ -1791,7 +1121,6 @@ short alloc_tx_desc_ring(struct net_device *dev, int bufsize, int count,
return -ENOMEM;
}
break;
-#endif
case TX_HIGHPRIORITY_RING_ADDR:
if(-1 == buffer_add(&(priv->txhpbufs),buf,dma_tmp,NULL)){
DMESGE("Unable to allocate mem for buffer HP");
@@ -1822,32 +1151,26 @@ short alloc_tx_desc_ring(struct net_device *dev, int bufsize, int count,
priv->txmapringdma=dma_desc;
priv->txmapring=desc;
break;
-
case TX_BKPRIORITY_RING_ADDR:
priv->txbkpringdma=dma_desc;
priv->txbkpring=desc;
break;
-
case TX_BEPRIORITY_RING_ADDR:
priv->txbepringdma=dma_desc;
priv->txbepring=desc;
break;
-
case TX_VIPRIORITY_RING_ADDR:
priv->txvipringdma=dma_desc;
priv->txvipring=desc;
break;
-
case TX_VOPRIORITY_RING_ADDR:
priv->txvopringdma=dma_desc;
priv->txvopring=desc;
break;
-
case TX_HIGHPRIORITY_RING_ADDR:
priv->txhpringdma=dma_desc;
priv->txhpring=desc;
break;
-
case TX_BEACON_RING_ADDR:
priv->txbeaconringdma=dma_desc;
priv->txbeaconring=desc;
@@ -1855,17 +1178,11 @@ short alloc_tx_desc_ring(struct net_device *dev, int bufsize, int count,
}
-#ifdef DEBUG_TX
- DMESG("Tx dma physical address: %x",dma_desc);
-#endif
-
return 0;
}
-
void free_tx_desc_rings(struct net_device *dev)
{
-
struct r8180_priv *priv = (struct r8180_priv *)ieee80211_priv(dev);
struct pci_dev *pdev=priv->pdev;
int count = priv->txringcount;
@@ -1900,41 +1217,18 @@ void free_tx_desc_rings(struct net_device *dev)
buffer_free(dev,&(priv->txbeaconbufs),priv->txbuffsize,1);
}
-#if 0
-void free_beacon_desc_ring(struct net_device *dev,int count)
-{
-
- struct r8180_priv *priv = (struct r8180_priv *)ieee80211_priv(dev);
- struct pci_dev *pdev=priv->pdev;
-
- pci_free_consistent(pdev, sizeof(u32)*8*count+256,
- priv->txbeaconring, priv->txbeaconringdma);
-
- if (priv->beacon_buf)
- pci_free_consistent(priv->pdev,
- priv->master_beaconsize,priv->beacon_buf,priv->beacondmabuf);
-
-}
-#endif
void free_rx_desc_ring(struct net_device *dev)
{
struct r8180_priv *priv = (struct r8180_priv *)ieee80211_priv(dev);
struct pci_dev *pdev = priv->pdev;
-
int count = priv->rxringcount;
-#ifdef CONFIG_RTL8185B
pci_free_consistent(pdev, sizeof(u32)*8*count+256,
priv->rxring, priv->rxringdma);
-#else
- pci_free_consistent(pdev, sizeof(u32)*4*count+256,
- priv->rxring, priv->rxringdma);
-#endif
buffer_free(dev,&(priv->rxbuffer),priv->rxbuffersize,0);
}
-
short alloc_rx_desc_ring(struct net_device *dev, u16 bufsize, int count)
{
int i;
@@ -1946,11 +1240,7 @@ short alloc_rx_desc_ring(struct net_device *dev, u16 bufsize, int count)
void *buf;
u8 rx_desc_size;
-#ifdef CONFIG_RTL8185B
rx_desc_size = 8; // 4*8 = 32 bytes
-#else
- rx_desc_size = 4;
-#endif
if((bufsize & 0xfff) != bufsize){
DMESGE ("RX buffer allocation too large");
@@ -1960,21 +1250,18 @@ short alloc_rx_desc_ring(struct net_device *dev, u16 bufsize, int count)
desc = (u32*)pci_alloc_consistent(pdev,sizeof(u32)*rx_desc_size*count+256,
&dma_desc);
- if(dma_desc & 0xff){
-
+ if (dma_desc & 0xff)
/*
* descriptor's buffer must be 256 byte aligned
* should never happen since we specify the DMA mask
*/
WARN(1, "DMA buffer is not aligned\n");
- }
priv->rxring=desc;
priv->rxringdma=dma_desc;
tmp=desc;
- for (i=0;i<count;i++){
-
+ for (i = 0; i < count; i++) {
if ((buf= kmalloc(bufsize * sizeof(u8),GFP_ATOMIC)) == NULL){
DMESGE("Failed to kmalloc RX buffer");
return -1;
@@ -1983,12 +1270,6 @@ short alloc_rx_desc_ring(struct net_device *dev, u16 bufsize, int count)
dma_tmp = pci_map_single(pdev,buf,bufsize * sizeof(u8),
PCI_DMA_FROMDEVICE);
-#ifdef DEBUG_ZERO_RX
- int j;
- for(j=0;j<bufsize;j++) ((u8*)buf)[i] = 0;
-#endif
-
- //buf = (void*)pci_alloc_consistent(pdev,bufsize,&dma_tmp);
if(-1 == buffer_add(&(priv->rxbuffer), buf,dma_tmp,
&(priv->rxbufferhead))){
DMESGE("Unable to allocate mem RX buf");
@@ -1999,21 +1280,11 @@ short alloc_rx_desc_ring(struct net_device *dev, u16 bufsize, int count)
*(tmp+2) = (u32)dma_tmp;
*tmp = *tmp |(1<<31); // descriptor void, owned by the NIC
-#ifdef DEBUG_RXALLOC
- DMESG("Alloc %x size buffer, DMA mem @ %x, virtual mem @ %x",
- (u32)(bufsize&0xfff), (u32)dma_tmp, (u32)buf);
-#endif
-
tmp=tmp+rx_desc_size;
}
*(tmp-rx_desc_size) = *(tmp-rx_desc_size) | (1<<30); // this is the last descriptor
-
-#ifdef DEBUG_RXALLOC
- DMESG("RX DMA physical address: %x",dma_desc);
-#endif
-
return 0;
}
@@ -2023,24 +1294,16 @@ void set_nic_rxring(struct net_device *dev)
u8 pgreg;
struct r8180_priv *priv = (struct r8180_priv *)ieee80211_priv(dev);
- //rtl8180_set_mode(dev, EPROM_CMD_CONFIG);
-
pgreg=read_nic_byte(dev, PGSELECT);
write_nic_byte(dev, PGSELECT, pgreg &~ (1<<PGSELECT_PG_SHIFT));
- //rtl8180_set_mode(dev, EPROM_CMD_NORMAL);
-
write_nic_dword(dev, RXRING_ADDR,priv->rxringdma);
}
-
void rtl8180_reset(struct net_device *dev)
{
- //u32 txconf = 0x80e00707; //FIXME: Make me understandable
u8 cr;
- //write_nic_dword(dev,TX_CONF,txconf);
-
rtl8180_irq_disable(dev);
cr=read_nic_byte(dev,CMD);
@@ -2057,83 +1320,80 @@ void rtl8180_reset(struct net_device *dev)
else
DMESG("Card successfully reset");
-//#ifndef CONFIG_RTL8185B
rtl8180_set_mode(dev,EPROM_CMD_LOAD);
force_pci_posting(dev);
mdelay(200);
-//#endif
}
inline u16 ieeerate2rtlrate(int rate)
{
switch(rate){
case 10:
- return 0;
+ return 0;
case 20:
- return 1;
+ return 1;
case 55:
- return 2;
+ return 2;
case 110:
- return 3;
+ return 3;
case 60:
- return 4;
+ return 4;
case 90:
- return 5;
+ return 5;
case 120:
- return 6;
+ return 6;
case 180:
- return 7;
+ return 7;
case 240:
- return 8;
+ return 8;
case 360:
- return 9;
+ return 9;
case 480:
- return 10;
+ return 10;
case 540:
- return 11;
+ return 11;
default:
- return 3;
-
+ return 3;
}
}
static u16 rtl_rate[] = {10,20,55,110,60,90,120,180,240,360,480,540,720};
+
inline u16 rtl8180_rate2rate(short rate)
{
- if (rate >12) return 10;
+ if (rate > 12)
+ return 10;
return rtl_rate[rate];
}
+
inline u8 rtl8180_IsWirelessBMode(u16 rate)
{
if( ((rate <= 110) && (rate != 60) && (rate != 90)) || (rate == 220) )
return 1;
- else return 0;
+ else
+ return 0;
}
+
u16 N_DBPSOfRate(u16 DataRate);
-u16 ComputeTxTime(
- u16 FrameLength,
- u16 DataRate,
- u8 bManagementFrame,
- u8 bShortPreamble
-)
+
+u16 ComputeTxTime(u16 FrameLength, u16 DataRate, u8 bManagementFrame,
+ u8 bShortPreamble)
{
u16 FrameTime;
u16 N_DBPS;
u16 Ceiling;
- if( rtl8180_IsWirelessBMode(DataRate) )
- {
- if( bManagementFrame || !bShortPreamble || DataRate == 10 )
- { // long preamble
+ if (rtl8180_IsWirelessBMode(DataRate)) {
+ if (bManagementFrame || !bShortPreamble || DataRate == 10)
+ /* long preamble */
FrameTime = (u16)(144+48+(FrameLength*8/(DataRate/10)));
- }
else
- { // Short preamble
+ /* 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.
+
+ 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);
@@ -2141,49 +1401,41 @@ u16 ComputeTxTime(
}
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;
- }
+ 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;
+ return N_DBPS;
}
//{by amy 080312
@@ -2192,76 +1444,46 @@ u16 N_DBPSOfRate(u16 DataRate)
// For Netgear case, they want good-looking singal strength.
// 2004.12.05, by rcnjko.
//
-long
-NetgearSignalStrengthTranslate(
- long LastSS,
- long CurrSS
- )
+long NetgearSignalStrengthTranslate(long LastSS, long CurrSS)
{
long RetSS;
// Step 1. Scale mapping.
- if(CurrSS >= 71 && CurrSS <= 100)
- {
+ if (CurrSS >= 71 && CurrSS <= 100)
RetSS = 90 + ((CurrSS - 70) / 3);
- }
- else if(CurrSS >= 41 && CurrSS <= 70)
- {
+ else if (CurrSS >= 41 && CurrSS <= 70)
RetSS = 78 + ((CurrSS - 40) / 3);
- }
- else if(CurrSS >= 31 && CurrSS <= 40)
- {
+ else if (CurrSS >= 31 && CurrSS <= 40)
RetSS = 66 + (CurrSS - 30);
- }
- else if(CurrSS >= 21 && CurrSS <= 30)
- {
+ else if (CurrSS >= 21 && CurrSS <= 30)
RetSS = 54 + (CurrSS - 20);
- }
- else if(CurrSS >= 5 && CurrSS <= 20)
- {
+ else if (CurrSS >= 5 && CurrSS <= 20)
RetSS = 42 + (((CurrSS - 5) * 2) / 3);
- }
- else if(CurrSS == 4)
- {
+ else if (CurrSS == 4)
RetSS = 36;
- }
- else if(CurrSS == 3)
- {
+ else if (CurrSS == 3)
RetSS = 27;
- }
- else if(CurrSS == 2)
- {
+ else if (CurrSS == 2)
RetSS = 18;
- }
- else if(CurrSS == 1)
- {
+ 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.
if(LastSS > 0)
- {
RetSS = ((LastSS * 5) + (RetSS)+ 5) / 6;
- }
- //RT_TRACE(COMP_DBG, DBG_LOUD, ("$$$$$ After Smoothing: LastSS: %d, CurrSS: %d, RetSS: %d\n", LastSS, CurrSS, RetSS));
return RetSS;
}
+
//
// Description:
// Translate 0-100 signal strength index into dBm.
//
-long
-TranslateToDbm8185(
- u8 SignalStrengthIndex // 0-100 index.
- )
+long TranslateToDbm8185(u8 SignalStrengthIndex)
{
- long SignalPower; // in dBm.
+ long SignalPower;
// Translate to dBm (x=0.5y-95).
SignalPower = (long)((SignalStrengthIndex + 1) >> 1);
@@ -2269,6 +1491,7 @@ TranslateToDbm8185(
return SignalPower;
}
+
//
// Description:
// Perform signal smoothing for dynamic mechanism.
@@ -2277,53 +1500,23 @@ TranslateToDbm8185(
// of correctness. Ported from 8187B.
// 2007-02-26, by Bruce.
//
-void
-PerformUndecoratedSignalSmoothing8185(
- struct r8180_priv *priv,
- bool bCckRate
- )
+void PerformUndecoratedSignalSmoothing8185(struct r8180_priv *priv,
+ bool bCckRate)
{
-
-
// Determin the current packet is CCK rate.
priv->bCurCCKPkt = bCckRate;
- if(priv->UndecoratedSmoothedSS >= 0)
- {
+ if (priv->UndecoratedSmoothedSS >= 0)
priv->UndecoratedSmoothedSS = ( (priv->UndecoratedSmoothedSS * 5) + (priv->SignalStrength * 10) ) / 6;
- }
else
- {
priv->UndecoratedSmoothedSS = priv->SignalStrength * 10;
- }
priv->UndercorateSmoothedRxPower = ( (priv->UndercorateSmoothedRxPower * 50) + (priv->RxPower* 11)) / 60;
-// printk("Sommthing SignalSterngth (%d) => UndecoratedSmoothedSS (%d)\n", priv->SignalStrength, priv->UndecoratedSmoothedSS);
-// printk("Sommthing RxPower (%d) => UndecoratedRxPower (%d)\n", priv->RxPower, priv->UndercorateSmoothedRxPower);
-
- //if(priv->CurCCKRSSI >= 0 && bCckRate)
- if(bCckRate)
- {
+ if (bCckRate)
priv->CurCCKRSSI = priv->RSSI;
- }
else
- {
priv->CurCCKRSSI = 0;
- }
-
- // Boundary checking.
- // TODO: The overflow condition does happen, if we want to fix,
- // we shall recalculate thresholds first.
- if(priv->UndecoratedSmoothedSS > 100)
- {
-// printk("UndecoratedSmoothedSS(%d) overflow, SignalStrength(%d)\n", priv->UndecoratedSmoothedSS, priv->SignalStrength);
- }
- if(priv->UndecoratedSmoothedSS < 0)
- {
-// printk("UndecoratedSmoothedSS(%d) underflow, SignalStrength(%d)\n", priv->UndecoratedSmoothedSS, priv->SignalStrength);
- }
-
}
//by amy 080312}
@@ -2333,108 +1526,47 @@ void rtl8180_rx(struct net_device *dev)
{
struct r8180_priv *priv = (struct r8180_priv *)ieee80211_priv(dev);
struct sk_buff *tmp_skb;
-
- //struct sk_buff *skb;
short first,last;
u32 len;
int lastlen;
unsigned char quality, signal;
u8 rate;
- //u32 *prism_hdr;
u32 *tmp,*tmp2;
u8 rx_desc_size;
u8 padding;
- //u32 count=0;
char rxpower = 0;
u32 RXAGC = 0;
long RxAGC_dBm = 0;
u8 LNA=0, BB=0;
u8 LNA_gain[4]={02, 17, 29, 39};
u8 Antenna = 0;
- struct ieee80211_hdr *hdr;//by amy
+ struct ieee80211_hdr *hdr;
u16 fc,type;
u8 bHwError = 0,bCRC = 0,bICV = 0;
- //bHwError = 0;
- //bCRC = 0;
- //bICV = 0;
bool bCckRate = false;
u8 RSSI = 0;
- long SignalStrengthIndex = 0;//+by amy 080312
-// u8 SignalStrength = 0;
+ long SignalStrengthIndex = 0;
struct ieee80211_rx_stats stats = {
.signal = 0,
.noise = -98,
.rate = 0,
- // .mac_time = jiffies,
.freq = IEEE80211_24GHZ_BAND,
};
-#ifdef CONFIG_RTL8185B
stats.nic_type = NIC_8185B;
rx_desc_size = 8;
-#else
- stats.nic_type = NIC_8185;
- rx_desc_size = 4;
-#endif
- //printk("receive frame!%d\n",count++);
- //if (!priv->rxbuffer) DMESG ("EE: NIC RX ack, but RX queue corrupted!");
- //else {
-
if ((*(priv->rxringtail)) & (1<<31)) {
-
/* we have got an RX int, but the descriptor
* we are pointing is empty*/
priv->stats.rxnodata++;
priv->ieee80211->stats.rx_errors++;
- /* if (! *(priv->rxring) & (1<<31)) {
-
- priv->stats.rxreset++;
- priv->rxringtail=priv->rxring;
- priv->rxbuffer=priv->rxbufferhead;
-
- }else{*/
-
- #if 0
- /* Maybe it is possible that the NIC has skipped some descriptors or
- * it has reset its internal pointer to the beginning of the ring
- * we search for the first filled descriptor in the ring, or we break
- * putting again the pointer in the old location if we do not found any.
- * This is quite dangerous, what does happen if the nic writes
- * two descriptor (say A and B) when we have just checked the descriptor
- * A and we are going to check the descriptor B..This might happen if the
- * interrupt was dummy, there was not really filled descriptors and
- * the NIC didn't lose pointer
- */
-
- //priv->stats.rxwrkaround++;
-
- tmp = priv->rxringtail;
- while (*(priv->rxringtail) & (1<<31)){
-
- priv->rxringtail+=4;
-
- if(priv->rxringtail >=
- (priv->rxring)+(priv->rxringcount )*4)
- priv->rxringtail=priv->rxring;
-
- priv->rxbuffer=(priv->rxbuffer->next);
-
- if(priv->rxringtail == tmp ){
- //DMESG("EE: Could not find RX pointer");
- priv->stats.rxnopointer++;
- break;
- }
- }
- #else
-
tmp2 = NULL;
tmp = priv->rxringtail;
do{
if(tmp == priv->rxring)
- //tmp = priv->rxring + (priv->rxringcount )*rx_desc_size; xiong-2006-11-15
tmp = priv->rxring + (priv->rxringcount - 1)*rx_desc_size;
else
tmp -= rx_desc_size;
@@ -2444,8 +1576,6 @@ void rtl8180_rx(struct net_device *dev)
}while(tmp != priv->rxring);
if(tmp2) priv->rxringtail = tmp2;
- #endif
- //}
}
/* while there are filled descriptors */
@@ -2487,7 +1617,6 @@ void rtl8180_rx(struct net_device *dev)
len=lastlen-priv->rx_prevlen;
if(*(priv->rxringtail) & (1<<13)) {
-//lastlen=((*priv->rxringtail) &0xfff);
if ((*(priv->rxringtail) & 0xfff) <500)
priv->stats.rxcrcerrmin++;
else if ((*(priv->rxringtail) & 0x0fff) >1000)
@@ -2501,7 +1630,6 @@ void rtl8180_rx(struct net_device *dev)
len = priv->rxbuffersize;
}
-#ifdef CONFIG_RTL8185B
if(first && last) {
padding = ((*(priv->rxringtail+3))&(0x04000000))>>26;
}else if(first) {
@@ -2512,10 +1640,7 @@ void rtl8180_rx(struct net_device *dev)
}else {
padding = 0;
}
-#ifdef CONFIG_RTL818X_S
padding = 0;
-#endif
-#endif
priv->rx_prevlen+=len;
if(priv->rx_prevlen > MAX_FRAG_THRESHOLD + 100){
@@ -2529,17 +1654,6 @@ void rtl8180_rx(struct net_device *dev)
priv->rx_skb_complete = 1;
}
-#ifdef DEBUG_RX_FRAG
- DMESG("Iteration.. len %x",len);
- if(first) DMESG ("First descriptor");
- if(last) DMESG("Last descriptor");
-
-#endif
-#ifdef DEBUG_RX_VERBOSE
- print_buffer( priv->rxbuffer->buf, len);
-#endif
-
-#ifdef CONFIG_RTL8185B
signal=(unsigned char)(((*(priv->rxringtail+3))& (0x00ff0000))>>16);
signal=(signal&0xfe)>>1; // Modify by hikaru 6.6
@@ -2550,22 +1664,11 @@ void rtl8180_rx(struct net_device *dev)
rxpower =((char)(((*(priv->rxringtail+4))& (0x00ff0000))>>16))/2 - 42;
RSSI = ((u8)(((*(priv->rxringtail+3)) & (0x0000ff00))>> 8)) & (0x7f);
-#else
- signal=((*(priv->rxringtail+1))& (0xff0000))>>16;
- signal=(signal&0xfe)>>1; // Modify by hikaru 6.6
-
- quality=((*(priv->rxringtail+1)) & (0xff));
-
- stats.mac_time[0] = *(priv->rxringtail+2);
- stats.mac_time[1] = *(priv->rxringtail+3);
-#endif
rate=((*(priv->rxringtail)) &
((1<<23)|(1<<22)|(1<<21)|(1<<20)))>>20;
stats.rate = rtl8180_rate2rate(rate);
- //DMESG("%d",rate);
Antenna = (((*(priv->rxringtail +3))& (0x00008000)) == 0 )? 0:1 ;
-// printk("in rtl8180_rx():Antenna is %d\n",Antenna);
//by amy for antenna
if(!rtl8180_IsWirelessBMode(stats.rate))
{ // OFDM rate.
@@ -2670,59 +1773,20 @@ void rtl8180_rx(struct net_device *dev)
}
//by amy for antenna
-
-
-
-
-
-
#ifndef DUMMY_RX
if(first){
if(!priv->rx_skb_complete){
/* seems that HW sometimes fails to reiceve and
doesn't provide the last descriptor */
-#ifdef DEBUG_RX_SKB
- DMESG("going to free incomplete skb");
-#endif
dev_kfree_skb_any(priv->rx_skb);
priv->stats.rxnolast++;
-#ifdef DEBUG_RX_SKB
- DMESG("free incomplete skb OK");
-#endif
}
/* support for prism header has been originally added by Christian */
if(priv->prism_hdr && priv->ieee80211->iw_mode == IW_MODE_MONITOR){
-#if 0
- priv->rx_skb = dev_alloc_skb(len+2+PRISM_HDR_SIZE);
- if(! priv->rx_skb) goto drop;
-
- prism_hdr = (u32*) skb_put(priv->rx_skb,PRISM_HDR_SIZE);
- prism_hdr[0]=htonl(0x80211001); //version
- prism_hdr[1]=htonl(0x40); //length
- prism_hdr[2]=htonl(stats.mac_time[1]); //mactime (HIGH)
- prism_hdr[3]=htonl(stats.mac_time[0]); //mactime (LOW)
- rdtsc(prism_hdr[5], prism_hdr[4]); //hostime (LOW+HIGH)
- prism_hdr[4]=htonl(prism_hdr[4]); //Byte-Order aendern
- prism_hdr[5]=htonl(prism_hdr[5]); //Byte-Order aendern
- prism_hdr[6]=0x00; //phytype
- prism_hdr[7]=htonl(priv->chan); //channel
- prism_hdr[8]=htonl(stats.rate); //datarate
- prism_hdr[9]=0x00; //antenna
- prism_hdr[10]=0x00; //priority
- prism_hdr[11]=0x00; //ssi_type
- prism_hdr[12]=htonl(stats.signal); //ssi_signal
- prism_hdr[13]=htonl(stats.noise); //ssi_noise
- prism_hdr[14]=0x00; //preamble
- prism_hdr[15]=0x00; //encoding
-
-#endif
}else{
priv->rx_skb = dev_alloc_skb(len+2);
if( !priv->rx_skb) goto drop;
-#ifdef DEBUG_RX_SKB
- DMESG("Alloc initial skb %x",len+2);
-#endif
}
priv->rx_skb_complete=0;
@@ -2741,91 +1805,50 @@ void rtl8180_rx(struct net_device *dev)
if(!tmp_skb) goto drop;
tmp_skb->dev=dev;
-#ifdef DEBUG_RX_SKB
- DMESG("Realloc skb %x",len+2);
-#endif
-#ifdef DEBUG_RX_SKB
- DMESG("going copy prev frag %x",priv->rx_skb->len);
-#endif
memcpy(skb_put(tmp_skb,priv->rx_skb->len),
priv->rx_skb->data,
priv->rx_skb->len);
-#ifdef DEBUG_RX_SKB
- DMESG("skb copy prev frag complete");
-#endif
dev_kfree_skb_any(priv->rx_skb);
-#ifdef DEBUG_RX_SKB
- DMESG("prev skb free ok");
-#endif
priv->rx_skb=tmp_skb;
}
}
-#ifdef DEBUG_RX_SKB
- DMESG("going to copy current payload %x",len);
-#endif
+
if(!priv->rx_skb_complete) {
-#ifdef CONFIG_RTL8185B
if(padding) {
memcpy(skb_put(priv->rx_skb,len),
(((unsigned char *)priv->rxbuffer->buf) + 2),len);
} else {
-#endif
memcpy(skb_put(priv->rx_skb,len),
priv->rxbuffer->buf,len);
-#ifdef CONFIG_RTL8185B
}
-#endif
}
-#ifdef DEBUG_RX_SKB
- DMESG("current fragment skb copy complete");
-#endif
if(last && !priv->rx_skb_complete){
-
-#ifdef DEBUG_RX_SKB
- DMESG("Got last fragment");
-#endif
-
if(priv->rx_skb->len > 4)
skb_trim(priv->rx_skb,priv->rx_skb->len-4);
-#ifdef DEBUG_RX_SKB
- DMESG("yanked out crc, passing to the upper layer");
-#endif
-
#ifndef RX_DONT_PASS_UL
if(!ieee80211_rx(priv->ieee80211,
priv->rx_skb, &stats)){
-#ifdef DEBUG_RX
- DMESGW("Packet not consumed");
-#endif
#endif // RX_DONT_PASS_UL
dev_kfree_skb_any(priv->rx_skb);
#ifndef RX_DONT_PASS_UL
}
#endif
-#ifdef DEBUG_RX
- else{
- DMESG("Rcv frag");
- }
-#endif
priv->rx_skb_complete=1;
}
#endif //DUMMY_RX
-
pci_dma_sync_single_for_device(priv->pdev,
priv->rxbuffer->dma,
priv->rxbuffersize * \
sizeof(u8),
PCI_DMA_FROMDEVICE);
-
drop: // this is used when we have not enought mem
-
/* restore the descriptor */
*(priv->rxringtail+2)=priv->rxbuffer->dma;
*(priv->rxringtail)=*(priv->rxringtail) &~ 0xfff;
@@ -2834,35 +1857,14 @@ drop: // this is used when we have not enought mem
*(priv->rxringtail)=
*(priv->rxringtail) | (1<<31);
- //^empty descriptor
-
- //wmb();
-
-#ifdef DEBUG_RX
- DMESG("Current descriptor: %x",(u32)priv->rxringtail);
-#endif
- //unsigned long flags;
- //spin_lock_irqsave(&priv->irq_lock,flags);
priv->rxringtail+=rx_desc_size;
if(priv->rxringtail >=
(priv->rxring)+(priv->rxringcount )*rx_desc_size)
priv->rxringtail=priv->rxring;
- //spin_unlock_irqrestore(&priv->irq_lock,flags);
-
-
priv->rxbuffer=(priv->rxbuffer->next);
-
}
-
-
-
-// if(get_curr_tx_free_desc(dev,priority))
-// ieee80211_sta_ps_sleep(priv->ieee80211, &tmp, &tmp2);
-
-
-
}
@@ -2871,33 +1873,6 @@ void rtl8180_dma_kick(struct net_device *dev, int priority)
struct r8180_priv *priv = (struct r8180_priv *)ieee80211_priv(dev);
rtl8180_set_mode(dev,EPROM_CMD_CONFIG);
-/*
-
- switch(priority){
-
- case LOW_PRIORITY:
-
- write_nic_byte(dev,TX_DMA_POLLING,
- (1<< TX_DMA_POLLING_LOWPRIORITY_SHIFT) |
- priv->dma_poll_mask);
- break;
-
- case NORM_PRIORITY:
-
- write_nic_byte(dev,TX_DMA_POLLING,
- (1<< TX_DMA_POLLING_NORMPRIORITY_SHIFT) |
- priv->dma_poll_mask);
- break;
-
- case HI_PRIORITY:
-
- write_nic_byte(dev,TX_DMA_POLLING,
- (1<< TX_DMA_POLLING_HIPRIORITY_SHIFT) |
- priv->dma_poll_mask);
- break;
-
- }
-*/
write_nic_byte(dev, TX_DMA_POLLING,
(1 << (priority + 1)) | priv->dma_poll_mask);
rtl8180_set_mode(dev,EPROM_CMD_NORMAL);
@@ -2905,53 +1880,26 @@ void rtl8180_dma_kick(struct net_device *dev, int priority)
force_pci_posting(dev);
}
-#if 0
-void rtl8180_tx_queues_stop(struct net_device *dev)
-{
- //struct r8180_priv *priv = (struct r8180_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);
-
- rtl8180_set_mode(dev,EPROM_CMD_CONFIG);
- write_nic_byte(dev,TX_DMA_POLLING,dma_poll_mask);
- rtl8180_set_mode(dev,EPROM_CMD_NORMAL);
-}
-#endif
-
void rtl8180_data_hard_stop(struct net_device *dev)
{
struct r8180_priv *priv = (struct r8180_priv *)ieee80211_priv(dev);
rtl8180_set_mode(dev,EPROM_CMD_CONFIG);
-#ifdef CONFIG_RTL8185B
priv->dma_poll_stop_mask |= TPPOLLSTOP_AC_VIQ;
write_nic_byte(dev,TPPollStop, priv->dma_poll_stop_mask);
-#else
- priv->dma_poll_mask |= (1<<TX_DMA_STOP_LOWPRIORITY_SHIFT);
- write_nic_byte(dev,TX_DMA_POLLING,priv->dma_poll_mask);
-#endif
rtl8180_set_mode(dev,EPROM_CMD_NORMAL);
}
-
void rtl8180_data_hard_resume(struct net_device *dev)
{
struct r8180_priv *priv = (struct r8180_priv *)ieee80211_priv(dev);
rtl8180_set_mode(dev,EPROM_CMD_CONFIG);
-#ifdef CONFIG_RTL8185B
priv->dma_poll_stop_mask &= ~(TPPOLLSTOP_AC_VIQ);
write_nic_byte(dev,TPPollStop, priv->dma_poll_stop_mask);
-#else
- priv->dma_poll_mask &= ~(1<<TX_DMA_STOP_LOWPRIORITY_SHIFT);
- write_nic_byte(dev,TX_DMA_POLLING,priv->dma_poll_mask);
-#endif
rtl8180_set_mode(dev,EPROM_CMD_NORMAL);
}
-
/* 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
*/
@@ -2964,7 +1912,6 @@ rate)
short morefrag = (h->frame_ctl) & IEEE80211_FCTL_MOREFRAGS;
unsigned long flags;
int priority;
- //static int count = 0;
mode = priv->ieee80211->iw_mode;
@@ -2976,11 +1923,7 @@ rate)
* the ieee stack, or from the try_wake_queue (again trought
* the ieee stack.
*/
-#ifdef CONFIG_RTL8185B
priority = AC2Q(skb->priority);
-#else
- priority = LOW_PRIORITY;
-#endif
spin_lock_irqsave(&priv->tx_lock,flags);
if(priv->ieee80211->bHwRadioOff)
@@ -2990,22 +1933,16 @@ rate)
return;
}
- //printk(KERN_WARNING "priority = %d@%d\n", priority, count++);
if (!check_nic_enought_desc(dev, priority)){
- //DMESG("Error: no descriptor left by previous TX (avail %d) ",
- // get_curr_tx_free_desc(dev, priority));
DMESGW("Error: no descriptor left by previous TX (avail %d) ",
get_curr_tx_free_desc(dev, priority));
- //printk(KERN_WARNING "==============================================================> \n");
ieee80211_stop_queue(priv->ieee80211);
}
rtl8180_tx(dev, skb->data, skb->len, priority, morefrag,0,rate);
if (!check_nic_enought_desc(dev, priority))
ieee80211_stop_queue(priv->ieee80211);
- //dev_kfree_skb_any(skb);
spin_unlock_irqrestore(&priv->tx_lock,flags);
-
}
/* This is a rough attempt to TX a frame
@@ -3022,23 +1959,15 @@ rate)
int rtl8180_hard_start_xmit(struct sk_buff *skb,struct net_device *dev)
{
struct r8180_priv *priv = (struct r8180_priv *)ieee80211_priv(dev);
-
unsigned long flags;
-
int priority;
-#ifdef CONFIG_RTL8185B
priority = MANAGE_PRIORITY;
-#else
- priority = NORM_PRIORITY;
-#endif
spin_lock_irqsave(&priv->tx_lock,flags);
- if(priv->ieee80211->bHwRadioOff)
- {
+ if (priv->ieee80211->bHwRadioOff) {
spin_unlock_irqrestore(&priv->tx_lock,flags);
-
dev_kfree_skb_any(skb);
return NETDEV_TX_OK;
}
@@ -3069,7 +1998,6 @@ u16 rtl8180_len2duration(u32 len, short rate,short* ext)
if(drift ==0 ) break;
duration++;
break;
-
case 1://2mbps
*ext=0;
duration = ((len+4)<<4) /0x4;
@@ -3077,7 +2005,6 @@ u16 rtl8180_len2duration(u32 len, short rate,short* ext)
if(drift ==0 ) break;
duration++;
break;
-
case 2: //5.5mbps
*ext=0;
duration = ((len+4)<<4) /0xb;
@@ -3086,7 +2013,6 @@ u16 rtl8180_len2duration(u32 len, short rate,short* ext)
break;
duration++;
break;
-
default:
case 3://11mbps
*ext=0;
@@ -3104,12 +2030,9 @@ u16 rtl8180_len2duration(u32 len, short rate,short* ext)
return duration;
}
-
void rtl8180_prepare_beacon(struct net_device *dev)
{
-
struct r8180_priv *priv = (struct r8180_priv *)ieee80211_priv(dev);
-
struct sk_buff *skb;
u16 word = read_nic_word(dev, BcnItv);
@@ -3117,46 +2040,12 @@ void rtl8180_prepare_beacon(struct net_device *dev)
word |= cpu_to_le16(priv->ieee80211->current_network.beacon_interval);//0x64;
write_nic_word(dev, BcnItv, word);
-
skb = ieee80211_get_beacon(priv->ieee80211);
if(skb){
rtl8180_tx(dev,skb->data,skb->len,BEACON_PRIORITY,
0,0,ieeerate2rtlrate(priv->ieee80211->basic_rate));
dev_kfree_skb_any(skb);
}
- #if 0
- //DMESG("size %x",len);
- if(*tail & (1<<31)){
-
- //DMESG("No more beacon TX desc");
- return ;
-
- }
- //while(! (*tail & (1<<31))){
- *tail= 0; // zeroes header
-
- *tail = *tail| (1<<29) ; //fist segment of the packet
- *tail = (*tail) | (1<<28); // last segment
- // *tail = *tail | (1<<18); // this is a beacon frame
- *(tail+3)=*(tail+3) &~ 0xfff;
- *(tail+3)=*(tail+3) | len; // buffer lenght
- *tail = *tail |len;
- // zeroes the second 32-bits dword of the descriptor
- *(tail+1)= 0;
- *tail = *tail | (rate << 24);
-
- duration = rtl8180_len2duration(len,rate,&ext);
-
- *(tail+1) = *(tail+1) | ((duration & 0x7fff)<<16);
-
- *tail = *tail | (1<<31);
- //^ descriptor ready to be txed
- if((tail - begin)/8 == priv->txbeaconcount-1)
- tail=begin;
- else
- tail=tail+8;
- //}
-#endif
}
/* This function do the real dirty work: it enqueues a TX command
@@ -3174,26 +2063,19 @@ short rtl8180_tx(struct net_device *dev, u8* txbuf, int len, int priority,
int remain;
int buflen;
int count;
- //u16 AckCtsTime;
- //u16 FrameTime;
u16 duration;
short ext;
struct buffer* buflist;
- //unsigned long flags;
-#ifdef CONFIG_RTL8185B
struct ieee80211_hdr_3addr *frag_hdr = (struct ieee80211_hdr_3addr *)txbuf;
u8 dest[ETH_ALEN];
u8 bUseShortPreamble = 0;
u8 bCTSEnable = 0;
u8 bRTSEnable = 0;
- //u16 RTSRate = 22;
- //u8 RetryLimit = 0;
u16 Duration = 0;
u16 RtsDur = 0;
u16 ThisFrameTime = 0;
u16 TxDescDuration = 0;
u8 ownbit_flag = false; //added by david woo for sync Tx, 2007.12.14
-#endif
switch(priority) {
case MANAGE_PRIORITY:
@@ -3202,56 +2084,47 @@ short rtl8180_tx(struct net_device *dev, u8* txbuf, int len, int priority,
buflist = priv->txmapbufstail;
count = priv->txringcount;
break;
-
case BK_PRIORITY:
tail=priv->txbkpringtail;
begin=priv->txbkpring;
buflist = priv->txbkpbufstail;
count = priv->txringcount;
break;
-
case BE_PRIORITY:
tail=priv->txbepringtail;
begin=priv->txbepring;
buflist = priv->txbepbufstail;
count = priv->txringcount;
break;
-
case VI_PRIORITY:
tail=priv->txvipringtail;
begin=priv->txvipring;
buflist = priv->txvipbufstail;
count = priv->txringcount;
break;
-
case VO_PRIORITY:
tail=priv->txvopringtail;
begin=priv->txvopring;
buflist = priv->txvopbufstail;
count = priv->txringcount;
break;
-
case HI_PRIORITY:
tail=priv->txhpringtail;
begin=priv->txhpring;
buflist = priv->txhpbufstail;
count = priv->txringcount;
break;
-
case BEACON_PRIORITY:
tail=priv->txbeaconringtail;
begin=priv->txbeaconring;
buflist = priv->txbeaconbufstail;
count = priv->txbeaconcount;
break;
-
default:
return -1;
break;
}
- //printk("in rtl8180_tx(): rate is %d\n",priv->ieee80211->rate);
-#if 1
memcpy(&dest, frag_hdr->addr1, ETH_ALEN);
if (is_multicast_ether_addr(dest) ||
is_broadcast_ether_addr(dest))
@@ -3264,20 +2137,13 @@ short rtl8180_tx(struct net_device *dev, u8* txbuf, int len, int priority,
ThisFrameTime = ComputeTxTime(len + sCrcLng, rtl8180_rate2rate(rate), 0, bUseShortPreamble);
TxDescDuration = ThisFrameTime;
} else {// Unicast packet
- //u8 AckRate;
u16 AckTime;
//YJ,add,080828,for Keep alive
priv->NumTxUnicast++;
// Figure out ACK rate according to BSS basic rate and Tx rate, 2006.03.08 by rcnjko.
- //AckRate = ComputeAckRate( pMgntInfo->mBrates, (u1Byte)(pTcb->DataRate) );
- // Figure out ACK time according to the AckRate and assume long preamble is used on receiver, 2006.03.08, by rcnjko.
- //AckTime = ComputeTxTime( sAckCtsLng/8, AckRate, FALSE, FALSE);
- //For simplicity, just use the 1M basic rate
- //AckTime = ComputeTxTime(14, 540,0, 0); // AckCTSLng = 14 use 1M bps send
AckTime = ComputeTxTime(14, 10,0, 0); // AckCTSLng = 14 use 1M bps send
- //AckTime = ComputeTxTime(14, 2,false, false); // AckCTSLng = 14 use 1M bps send
if ( ((len + sCrcLng) > priv->rts) && priv->rts )
{ // RTS/CTS.
@@ -3328,41 +2194,24 @@ short rtl8180_tx(struct net_device *dev, u8* txbuf, int len, int priority,
} // End of Unicast packet
frag_hdr->duration_id = Duration;
-#endif
buflen=priv->txbuffsize;
remain=len;
temp_tail = tail;
-//printk("================================>buflen = %d, remain = %d!\n", buflen,remain);
+
while(remain!=0){
-#ifdef DEBUG_TX_FRAG
- DMESG("TX iteration");
-#endif
-#ifdef DEBUG_TX
- DMESG("TX: filling descriptor %x",(u32)tail);
-#endif
mb();
if(!buflist){
DMESGE("TX buffer error, cannot TX frames. pri %d.", priority);
- //spin_unlock_irqrestore(&priv->tx_lock,flags);
return -1;
}
buf=buflist->buf;
- if( (*tail & (1<<31)) && (priority != BEACON_PRIORITY)){
-
- DMESGW("No more TX desc, returning %x of %x",
- remain,len);
- priv->stats.txrdu++;
-#ifdef DEBUG_TX_DESC
- check_tx_ring(dev,priority);
- // netif_stop_queue(dev);
- // netif_carrier_off(dev);
-#endif
- // spin_unlock_irqrestore(&priv->tx_lock,flags);
-
+ if ((*tail & (1 << 31)) && (priority != BEACON_PRIORITY)) {
+ DMESGW("No more TX desc, returning %x of %x",
+ remain, len);
+ priv->stats.txrdu++;
return remain;
-
}
*tail= 0; // zeroes header
@@ -3375,14 +2224,10 @@ short rtl8180_tx(struct net_device *dev, u8* txbuf, int len, int priority,
if(priv->card_8185){
//FIXME: this should be triggered by HW encryption parameters.
*tail |= (1<<15); //no encrypt
-// *tail |= (1<<30); //raise int when completed
}
- // *tail = *tail | (1<<16);
+
if(remain==len && !descfrag) {
ownbit_flag = false; //added by david woo,2007.12.14
-#ifdef DEBUG_TX_FRAG
- DMESG("First descriptor");
-#endif
*tail = *tail| (1<<29) ; //fist segment of the packet
*tail = *tail |(len);
} else {
@@ -3403,7 +2248,6 @@ short rtl8180_tx(struct net_device *dev, u8* txbuf, int len, int priority,
if (priv->plcp_preamble_mode==1 && rate!=0) // short mode now, not long!
// *tail |= (1<<16); // enable short preamble mode.
-#ifdef CONFIG_RTL8185B
if(bCTSEnable) {
*tail |= (1<<18);
}
@@ -3417,60 +2261,13 @@ short rtl8180_tx(struct net_device *dev, u8* txbuf, int len, int priority,
*(tail+3) |= ((TxDescDuration&0xffff)<<16); //DURATION
// *(tail+3) |= (0xe6<<16);
*(tail+5) |= (11<<8);//(priv->retry_data<<8); //retry lim ;
-#else
- //Use RTS or not
-#ifdef CONFIG_RTL8187B
- if ( (len>priv->rts) && priv->rts && priority!=MANAGE_PRIORITY){
-#else
- if ( (len>priv->rts) && priv->rts && priority==LOW_PRIORITY){
-#endif
- *tail |= (1<<23); //enalbe RTS function
- *tail |= (0<<19); //use 1M bps send RTS packet
- AckCtsTime = ComputeTxTime(14, 10,0, 0); // AckCTSLng = 14 use 1M bps send
- FrameTime = ComputeTxTime(len + 4, rtl8180_rate2rate(rate), 0, *tail&(1<<16));
- // RTS/CTS time is calculate as follow
- duration = FrameTime + 3*10 + 2*AckCtsTime; //10us is the SifsTime;
- *(tail+1) |= duration; //Need to edit here! ----hikaru
- }else{
- *(tail+1)= 0; // zeroes the second 32-bits dword of the descriptor
- }
-#endif
*tail = *tail | ((rate&0xf) << 24);
- //DMESG("rate %d",rate);
-
- if(priv->card_8185){
-
- #if 0
- *(tail+5)&= ~(1<<24); /* tx ant 0 */
-
- *(tail+5) &= ~(1<<23); /* random tx agc 23-16 */
- *(tail+5) |= (1<<22)|(1<<21)|(1<<20)|(1<<19)|(1<<18)|(1<<17)|(1<<16);
-
- *(tail+5) &=
-~((1<<15)|(1<<14)|(1<<13)|(1<<12)|(1<<11)|(1<<10)|(1<<9)|(1<<8));
- *(tail+5) |= (7<<8); // Max retry limit
-
- *(tail+5) &= ~((1<<7)|(1<<6)|(1<<5)|(1<<4)|(1<<3)|(1<<2)|(1<<1)|(1<<0));
- *(tail+5) |= (8<<4); // Max contention window
- *(tail+6) |= 4; // Min contention window
- #endif
- // *(tail+5) = 0;
- }
/* hw_plcp_len is not used for rtl8180 chip */
/* FIXME */
if(priv->card_8185 == 0 || !priv->hw_plcp_len){
-
- duration = rtl8180_len2duration(len,
- rate,&ext);
-
-
-#ifdef DEBUG_TX
- DMESG("PLCP duration %d",duration );
- //DMESG("drift %d",drift);
- DMESG("extension %s", (ext==1) ? "on":"off");
-#endif
+ duration = rtl8180_len2duration(len, rate, &ext);
*(tail+1) = *(tail+1) | ((duration & 0x7fff)<<16);
if(ext) *(tail+1) = *(tail+1) |(1<<31); //plcp length extension
}
@@ -3478,10 +2275,6 @@ short rtl8180_tx(struct net_device *dev, u8* txbuf, int len, int priority,
if(morefrag) *tail = (*tail) | (1<<17); // more fragment
if(!remain) *tail = (*tail) | (1<<28); // last segment of frame
-#ifdef DEBUG_TX_FRAG
- if(!remain)DMESG("Last descriptor");
- if(morefrag)DMESG("More frag");
-#endif
*(tail+5) = *(tail+5)|(2<<27);
*(tail+7) = *(tail+7)|(1<<4);
@@ -3491,15 +2284,8 @@ short rtl8180_tx(struct net_device *dev, u8* txbuf, int len, int priority,
*tail = *tail | (1<<31); // descriptor ready to be txed
}
-#ifdef DEBUG_TX_DESC2
- printk("tx desc is:\n");
- DMESG("%8x %8x %8x %8x %8x %8x %8x %8x", tail[0], tail[1], tail[2], tail[3],
- tail[4], tail[5], tail[6], tail[7]);
-#endif
-
if((tail - begin)/8 == count-1)
tail=begin;
-
else
tail=tail+8;
@@ -3512,75 +2298,56 @@ short rtl8180_tx(struct net_device *dev, u8* txbuf, int len, int priority,
priv->txmapringtail=tail;
priv->txmapbufstail=buflist;
break;
-
case BK_PRIORITY:
priv->txbkpringtail=tail;
priv->txbkpbufstail=buflist;
break;
-
case BE_PRIORITY:
priv->txbepringtail=tail;
priv->txbepbufstail=buflist;
break;
-
case VI_PRIORITY:
priv->txvipringtail=tail;
priv->txvipbufstail=buflist;
break;
-
case VO_PRIORITY:
priv->txvopringtail=tail;
priv->txvopbufstail=buflist;
break;
-
case HI_PRIORITY:
priv->txhpringtail=tail;
priv->txhpbufstail = buflist;
break;
-
case BEACON_PRIORITY:
/* the HW seems to be happy with the 1st
* descriptor filled and the 2nd empty...
* So always update descriptor 1 and never
* touch 2nd
*/
- // priv->txbeaconringtail=tail;
- // priv->txbeaconbufstail=buflist;
-
break;
-
}
-
- //rtl8180_dma_kick(dev,priority);
}
*temp_tail = *temp_tail | (1<<31); // descriptor ready to be txed
rtl8180_dma_kick(dev,priority);
- //spin_unlock_irqrestore(&priv->tx_lock,flags);
return 0;
-
}
-
void rtl8180_irq_rx_tasklet(struct r8180_priv * priv);
-
void rtl8180_link_change(struct net_device *dev)
{
struct r8180_priv *priv = ieee80211_priv(dev);
u16 beacon_interval;
-
struct ieee80211_network *net = &priv->ieee80211->current_network;
-// rtl8180_adapter_start(dev);
- rtl8180_update_msr(dev);
+ rtl8180_update_msr(dev);
rtl8180_set_mode(dev,EPROM_CMD_CONFIG);
write_nic_dword(dev,BSSID,((u32*)net->bssid)[0]);
write_nic_word(dev,BSSID+4,((u16*)net->bssid)[2]);
-
beacon_interval = read_nic_dword(dev,BEACON_INTERVAL);
beacon_interval &= ~ BEACON_INTERVAL_MASK;
beacon_interval |= net->beacon_interval;
@@ -3588,46 +2355,14 @@ void rtl8180_link_change(struct net_device *dev)
rtl8180_set_mode(dev, EPROM_CMD_NORMAL);
-
- /*
- u16 atim = read_nic_dword(dev,ATIM);
- u16 = u16 &~ ATIM_MASK;
- u16 = u16 | beacon->atim;
- */
-#if 0
- if (net->capability & WLAN_CAPABILITY_PRIVACY) {
- if (priv->hw_wep) {
- DMESG("Enabling hardware WEP support");
- rtl8180_set_hw_wep(dev);
- priv->ieee80211->host_encrypt=0;
- priv->ieee80211->host_decrypt=0;
- }
-#ifndef CONFIG_IEEE80211_NOWEP
- else {
- priv->ieee80211->host_encrypt=1;
- priv->ieee80211->host_decrypt=1;
- }
-#endif
- }
-#ifndef CONFIG_IEEE80211_NOWEP
- else{
- priv->ieee80211->host_encrypt=0;
- priv->ieee80211->host_decrypt=0;
- }
-#endif
-#endif
-
-
if(priv->card_8185)
rtl8180_set_chan(dev, priv->chan);
-
-
}
void rtl8180_rq_tx_ack(struct net_device *dev){
struct r8180_priv *priv = ieee80211_priv(dev);
-// printk("====================>%s\n",__func__);
+
write_nic_byte(dev,CONFIG4,read_nic_byte(dev,CONFIG4)|CONFIG4_PWRMGT);
priv->ack_tx_to_ieee = 1;
}
@@ -3668,39 +2403,29 @@ short rtl8180_is_tx_queue_empty(struct net_device *dev){
void rtl8180_hw_wakeup(struct net_device *dev)
{
unsigned long flags;
-
struct r8180_priv *priv = ieee80211_priv(dev);
spin_lock_irqsave(&priv->ps_lock,flags);
- //DMESG("Waken up!");
write_nic_byte(dev,CONFIG4,read_nic_byte(dev,CONFIG4)&~CONFIG4_PWRMGT);
-
- if(priv->rf_wakeup)
+ if (priv->rf_wakeup)
priv->rf_wakeup(dev);
-// mdelay(HW_WAKE_DELAY);
spin_unlock_irqrestore(&priv->ps_lock,flags);
}
void rtl8180_hw_sleep_down(struct net_device *dev)
{
unsigned long flags;
-
struct r8180_priv *priv = ieee80211_priv(dev);
spin_lock_irqsave(&priv->ps_lock,flags);
- //DMESG("Sleep!");
-
if(priv->rf_sleep)
priv->rf_sleep(dev);
spin_unlock_irqrestore(&priv->ps_lock,flags);
}
-
void rtl8180_hw_sleep(struct net_device *dev, u32 th, u32 tl)
{
-
struct r8180_priv *priv = ieee80211_priv(dev);
-
u32 rb = jiffies;
unsigned long flags;
@@ -3711,14 +2436,6 @@ void rtl8180_hw_sleep(struct net_device *dev, u32 th, u32 tl)
*/
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
*/
@@ -3729,13 +2446,9 @@ void rtl8180_hw_sleep(struct net_device *dev, u32 th, u32 tl)
return;
}
-// write_nic_dword(dev, TimerInt, tl);
-// rb = read_nic_dword(dev, TSFTR);
{
u32 tmp = (tl>rb)?(tl-rb):(rb-tl);
- // if (tl<rb)
- //lzm,add,080828
priv->DozePeriodInPast2Sec += jiffies_to_msecs(tmp);
queue_delayed_work(priv->ieee80211->wq, &priv->ieee80211->hw_wakeup_wq, tmp); //as tl may be less than rb
@@ -3743,34 +2456,21 @@ void rtl8180_hw_sleep(struct net_device *dev, u32 th, u32 tl)
/* 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)))) {
spin_unlock_irqrestore(&priv->ps_lock,flags);
return;
}
-#endif
-// if(priv->rf_sleep)
-// priv->rf_sleep(dev);
queue_work(priv->ieee80211->wq, (void *)&priv->ieee80211->hw_sleep_wq);
spin_unlock_irqrestore(&priv->ps_lock,flags);
}
-
-//void rtl8180_wmm_param_update(struct net_device *dev,u8 *ac_param)
-#if LINUX_VERSION_CODE >=KERNEL_VERSION(2,6,20)
void rtl8180_wmm_param_update(struct work_struct * work)
{
struct ieee80211_device * ieee = container_of(work, struct ieee80211_device,wmm_param_update_wq);
- //struct r8180_priv *priv = (struct r8180_priv*)(ieee->priv);
- struct net_device *dev = ieee->dev;
-#else
-void rtl8180_wmm_param_update(struct ieee80211_device *ieee)
-{
struct net_device *dev = ieee->dev;
- struct r8180_priv *priv = ieee80211_priv(dev);
-#endif
u8 *ac_param = (u8 *)(ieee->current_network.wmm_param);
u8 mode = ieee->current_network.mode;
AC_CODING eACI;
@@ -3778,10 +2478,6 @@ void rtl8180_wmm_param_update(struct ieee80211_device *ieee)
PAC_PARAM pAcParam;
u8 i;
-#ifndef CONFIG_RTL8185B
- //for legacy 8185 keep the PARAM unchange.
- return;
-#else
if(!ieee->current_network.QoS_Enable){
//legacy ac_xx_param update
AcParam.longData = 0;
@@ -3806,19 +2502,15 @@ void rtl8180_wmm_param_update(struct ieee80211_device *ieee)
case AC1_BK:
write_nic_dword(dev, AC_BK_PARAM, u4bAcParam);
break;
-
case AC0_BE:
write_nic_dword(dev, AC_BE_PARAM, u4bAcParam);
break;
-
case AC2_VI:
write_nic_dword(dev, AC_VI_PARAM, u4bAcParam);
break;
-
case AC3_VO:
write_nic_dword(dev, AC_VO_PARAM, u4bAcParam);
break;
-
default:
printk(KERN_WARNING "SetHwReg8185():invalid ACI: %d!\n", eACI);
break;
@@ -3849,19 +2541,15 @@ void rtl8180_wmm_param_update(struct ieee80211_device *ieee)
case AC1_BK:
write_nic_dword(dev, AC_BK_PARAM, u4bAcParam);
break;
-
case AC0_BE:
write_nic_dword(dev, AC_BE_PARAM, u4bAcParam);
break;
-
case AC2_VI:
write_nic_dword(dev, AC_VI_PARAM, u4bAcParam);
break;
-
case AC3_VO:
write_nic_dword(dev, AC_VO_PARAM, u4bAcParam);
break;
-
default:
printk(KERN_WARNING "SetHwReg8185(): invalid ACI: %d !\n", eACI);
break;
@@ -3869,63 +2557,26 @@ void rtl8180_wmm_param_update(struct ieee80211_device *ieee)
}
ac_param += (sizeof(AC_PARAM));
}
-#endif
}
-#if (LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,20))
void rtl8180_tx_irq_wq(struct work_struct *work);
-#else
-void rtl8180_tx_irq_wq(struct net_device *dev);
-#endif
-
-
-
-
-#if (LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,20))
void rtl8180_restart_wq(struct work_struct *work);
//void rtl8180_rq_tx_ack(struct work_struct *work);
-#else
- void rtl8180_restart_wq(struct net_device *dev);
-//void rtl8180_rq_tx_ack(struct net_device *dev);
-#endif
-#if (LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,20))
void rtl8180_watch_dog_wq(struct work_struct *work);
-#else
-void rtl8180_watch_dog_wq(struct net_device *dev);
-#endif
-#if (LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,20))
void rtl8180_hw_wakeup_wq(struct work_struct *work);
-#else
-void rtl8180_hw_wakeup_wq(struct net_device *dev);
-#endif
-
-#if (LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,20))
void rtl8180_hw_sleep_wq(struct work_struct *work);
-#else
-void rtl8180_hw_sleep_wq(struct net_device *dev);
-#endif
-
-
-
-#if (LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,20))
void rtl8180_sw_antenna_wq(struct work_struct *work);
-#else
-void rtl8180_sw_antenna_wq(struct net_device *dev);
-#endif
- void rtl8180_watch_dog(struct net_device *dev);
+void rtl8180_watch_dog(struct net_device *dev);
+
void watch_dog_adaptive(unsigned long data)
{
- struct r8180_priv* priv = ieee80211_priv((struct net_device *)data);
-// DMESG("---->watch_dog_adaptive()\n");
- if(!priv->up)
- {
+ struct r8180_priv* priv = ieee80211_priv((struct net_device *)data);
+
+ if (!priv->up) {
DMESG("<----watch_dog_adaptive():driver is not up!\n");
return;
}
- // queue_work(priv->ieee80211->wq,&priv->ieee80211->watch_dog_wq);
-//{by amy 080312
-#if 1
// Tx High Power Mechanism.
#ifdef HIGH_POWER
if(CheckHighPower((struct net_device *)data))
@@ -3934,14 +2585,12 @@ void watch_dog_adaptive(unsigned long data)
}
#endif
-#ifdef CONFIG_RTL818X_S
// Tx Power Tracking on 87SE.
#ifdef TX_TRACK
//if( priv->bTxPowerTrack ) //lzm mod 080826
if( CheckTxPwrTracking((struct net_device *)data));
TxPwrTracking87SE((struct net_device *)data);
#endif
-#endif
// Perform DIG immediately.
#ifdef SW_DIG
@@ -3950,20 +2599,14 @@ void watch_dog_adaptive(unsigned long data)
queue_work(priv->ieee80211->wq, (void *)&priv->ieee80211->hw_dig_wq);
}
#endif
-#endif
-//by amy 080312}
rtl8180_watch_dog((struct net_device *)data);
-
queue_work(priv->ieee80211->wq, (void *)&priv->ieee80211->GPIOChangeRFWorkItem);
priv->watch_dog_timer.expires = jiffies + MSECS(IEEE80211_WATCH_DOG_TIME);
add_timer(&priv->watch_dog_timer);
-// DMESG("<----watch_dog_adaptive()\n");
}
-#ifdef ENABLE_DOT11D
-
static CHANNEL_LIST ChannelPlan[] = {
{{1,2,3,4,5,6,7,8,9,10,11,36,40,44,48,52,56,60,64},19}, //FCC
{{1,2,3,4,5,6,7,8,9,10,11},11}, //IC
@@ -4038,20 +2681,15 @@ static void rtl8180_set_channel_map(u8 channel_plan, struct ieee80211_device *ie
}
}
}
-#endif
-//Add for RF power on power off by lizhaoming 080512
-#if (LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,20))
void GPIOChangeRFWorkItemCallBack(struct work_struct *work);
-#else
-void GPIOChangeRFWorkItemCallBack(struct ieee80211_device *ieee);
-#endif
//YJ,add,080828
static void rtl8180_statistics_init(struct Stats *pstats)
{
memset(pstats, 0, sizeof(struct Stats));
}
+
static void rtl8180_link_detect_init(plink_detect_t plink_detect)
{
memset(plink_detect, 0, sizeof(link_detect_t));
@@ -4070,40 +2708,14 @@ short rtl8180_init(struct net_device *dev)
u16 tmpu16;
int i, j;
-#ifdef ENABLE_DOT11D
-#if 0
- for(i=0;i<0xFF;i++) {
- if(i%16 == 0)
- printk("\n[%x]: ", i/16);
- printk("\t%4.4x", eprom_read(dev,i));
- }
-#endif
priv->channel_plan = eprom_read(dev, EEPROM_COUNTRY_CODE>>1) & 0xFF;
if(priv->channel_plan > COUNTRY_CODE_GLOBAL_DOMAIN){
printk("rtl8180_init:Error channel plan! Set to default.\n");
priv->channel_plan = 0;
}
- //priv->channel_plan = 9; //Global Domain
DMESG("Channel plan is %d\n",priv->channel_plan);
rtl8180_set_channel_map(priv->channel_plan, priv->ieee80211);
-#else
- int ch;
- //Set Default Channel Plan
- if(!channels){
- DMESG("No channels, aborting");
- return -1;
- }
- ch=channels;
- priv->channel_plan = 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
-
- //memcpy(priv->stats,0,sizeof(struct Stats));
//FIXME: these constants are placed in a bad pleace.
priv->txbuffsize = 2048;//1024;
@@ -4112,20 +2724,9 @@ short rtl8180_init(struct net_device *dev)
priv->rxringcount = 64;//32;
priv->txbeaconcount = 2;
priv->rx_skb_complete = 1;
- //priv->txnp_pending.ispending=0;
- /* ^^ the SKB does not containt a partial RXed
- * packet (is empty)
- */
-#ifdef CONFIG_RTL8185B
-#ifdef CONFIG_RTL818X_S
priv->RegThreeWireMode = HW_THREE_WIRE_SI;
-#else
- priv->RegThreeWireMode = SW_THREE_WIRE;
-#endif
-#endif
-//Add for RF power on power off by lizhaoming 080512
priv->RFChangeInProgress = false;
priv->SetRFPowerStateInProgress = false;
priv->RFProgType = 0;
@@ -4133,42 +2734,8 @@ short rtl8180_init(struct net_device *dev)
priv->irq_enabled=0;
-//YJ,modified,080828
-#if 0
- priv->stats.rxdmafail=0;
- priv->stats.txrdu=0;
- priv->stats.rxrdu=0;
- priv->stats.rxnolast=0;
- priv->stats.rxnodata=0;
- //priv->stats.rxreset=0;
- //priv->stats.rxwrkaround=0;
- priv->stats.rxnopointer=0;
- priv->stats.txnperr=0;
- priv->stats.txresumed=0;
- priv->stats.rxerr=0;
- priv->stats.rxoverflow=0;
- priv->stats.rxint=0;
- priv->stats.txnpokint=0;
- priv->stats.txhpokint=0;
- priv->stats.txhperr=0;
- priv->stats.ints=0;
- priv->stats.shints=0;
- priv->stats.txoverflow=0;
- priv->stats.txbeacon=0;
- priv->stats.txbeaconerr=0;
- priv->stats.txlperr=0;
- priv->stats.txlpokint=0;
- priv->stats.txretry=0;//tony 20060601
- priv->stats.rxcrcerrmin=0;
- priv->stats.rxcrcerrmid=0;
- priv->stats.rxcrcerrmax=0;
- priv->stats.rxicverr=0;
-#else
rtl8180_statistics_init(&priv->stats);
rtl8180_link_detect_init(&priv->link_detect);
-#endif
-//YJ,modified,080828,end
-
priv->ack_tx_to_ieee = 0;
priv->ieee80211->current_network.beacon_interval = DEFAULT_BEACONINTERVAL;
@@ -4201,8 +2768,6 @@ short rtl8180_init(struct net_device *dev)
priv->eRFPowerState = eRfOff;
priv->RfOffReason = 0;
priv->LedStrategy = SW_LED_MODE0;
- //priv->NumRxOkInPeriod = 0; //YJ,del,080828
- //priv->NumTxOkInPeriod = 0; //YJ,del,080828
priv->TxPollingTimes = 0;//lzm add 080826
priv->bLeisurePs = true;
priv->dot11PowerSaveMode = eActive;
@@ -4258,13 +2823,10 @@ short rtl8180_init(struct net_device *dev)
priv->CurCCKRSSI = 0;
priv->RxPower = 0;
priv->RSSI = 0;
- //YJ,add,080828
priv->NumTxOkTotal = 0;
priv->NumTxUnicast = 0;
priv->keepAliveLevel = DEFAULT_KEEP_ALIVE_LEVEL;
priv->PowerProfile = POWER_PROFILE_AC;
- //YJ,add,080828,end
-//by amy for rate adaptive
priv->CurrRetryCnt=0;
priv->LastRetryCnt=0;
priv->LastTxokCnt=0;
@@ -4285,8 +2847,6 @@ short rtl8180_init(struct net_device *dev)
priv->ForcedDataRate = 0;
priv->RegBModeGainStage = 1;
-//by amy for rate adaptive
-//by amy 080312}
priv->promisc = (dev->flags & IFF_PROMISC) ? 1:0;
spin_lock_init(&priv->irq_lock);
spin_lock_init(&priv->irq_th_lock);
@@ -4295,59 +2855,30 @@ short rtl8180_init(struct net_device *dev)
spin_lock_init(&priv->rf_ps_lock);
sema_init(&priv->wx_sem,1);
sema_init(&priv->rf_state,1);
-#if (LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,20))
INIT_WORK(&priv->reset_wq,(void*) rtl8180_restart_wq);
INIT_WORK(&priv->tx_irq_wq,(void*) rtl8180_tx_irq_wq);
INIT_DELAYED_WORK(&priv->ieee80211->hw_wakeup_wq,(void*) rtl8180_hw_wakeup_wq);
INIT_DELAYED_WORK(&priv->ieee80211->hw_sleep_wq,(void*) rtl8180_hw_sleep_wq);
- //INIT_DELAYED_WORK(&priv->ieee80211->watch_dog_wq,(void*) rtl8180_watch_dog_wq);
- //INIT_DELAYED_WORK(&priv->ieee80211->sw_antenna_wq,(void*) rtl8180_sw_antenna_wq);
INIT_WORK(&priv->ieee80211->wmm_param_update_wq,(void*) rtl8180_wmm_param_update);
INIT_DELAYED_WORK(&priv->ieee80211->rate_adapter_wq,(void*)rtl8180_rate_adapter);//+by amy 080312
INIT_DELAYED_WORK(&priv->ieee80211->hw_dig_wq,(void*)rtl8180_hw_dig_wq);//+by amy 080312
INIT_DELAYED_WORK(&priv->ieee80211->tx_pw_wq,(void*)rtl8180_tx_pw_wq);//+by amy 080312
- //add for RF power on power off by lizhaoming 080512
INIT_DELAYED_WORK(&priv->ieee80211->GPIOChangeRFWorkItem,(void*) GPIOChangeRFWorkItemCallBack);
-#else
- INIT_WORK(&priv->reset_wq,(void*) rtl8180_restart_wq,dev);
- INIT_WORK(&priv->tx_irq_wq,(void*) rtl8180_tx_irq_wq,dev);
- //INIT_WORK(&priv->ieee80211->watch_dog_wq,(void*) rtl8180_watch_dog_wq,dev);
- INIT_WORK(&priv->ieee80211->hw_wakeup_wq,(void*) rtl8180_hw_wakeup_wq,dev);
- INIT_WORK(&priv->ieee80211->hw_sleep_wq,(void*) rtl8180_hw_sleep_wq,dev);
- //INIT_WORK(&priv->ieee80211->sw_antenna_wq,(void*) rtl8180_sw_antenna_wq,dev);
- INIT_WORK(&priv->ieee80211->wmm_param_update_wq,(void*) rtl8180_wmm_param_update,priv->ieee80211);
- INIT_WORK(&priv->ieee80211->rate_adapter_wq,(void*)rtl8180_rate_adapter,dev);//+by amy 080312
- INIT_WORK(&priv->ieee80211->hw_dig_wq,(void*)rtl8180_hw_dig_wq,dev);//+by amy 080312
- INIT_WORK(&priv->ieee80211->tx_pw_wq,(void*)rtl8180_tx_pw_wq,dev);//+by amy 080312
-
- //add for RF power on power off by lizhaoming 080512
- INIT_WORK(&priv->ieee80211->GPIOChangeRFWorkItem,(void*) GPIOChangeRFWorkItemCallBack, priv->ieee80211);
-#endif
- //INIT_WORK(&priv->reset_wq,(void*) rtl8180_restart_wq,dev);
tasklet_init(&priv->irq_rx_tasklet,
(void(*)(unsigned long)) rtl8180_irq_rx_tasklet,
(unsigned long)priv);
-//by amy
+
init_timer(&priv->watch_dog_timer);
priv->watch_dog_timer.data = (unsigned long)dev;
priv->watch_dog_timer.function = watch_dog_adaptive;
-//by amy
-//{by amy 080312
-//by amy for rate adaptive
init_timer(&priv->rateadapter_timer);
priv->rateadapter_timer.data = (unsigned long)dev;
priv->rateadapter_timer.function = timer_rate_adaptive;
priv->RateAdaptivePeriod= RATE_ADAPTIVE_TIMER_PERIOD;
priv->bEnhanceTxPwr=false;
-//by amy for rate adaptive
-//by amy 080312}
- //priv->ieee80211->func =
- // kmalloc(sizeof(struct ieee80211_helper_functions),GFP_KERNEL);
- //memset(priv->ieee80211->func, 0,
- // sizeof(struct ieee80211_helper_functions));
priv->ieee80211->softmac_hard_start_xmit = rtl8180_hard_start_xmit;
priv->ieee80211->set_chan = rtl8180_set_chan;
@@ -4362,7 +2893,6 @@ short rtl8180_init(struct net_device *dev)
priv->ieee80211->stop_send_beacons = rtl8180_beacon_tx_disable;
priv->ieee80211->fts = DEFAULT_FRAG_THRESHOLD;
-#ifdef CONFIG_RTL8185B
priv->MWIEnable = 0;
priv->ShortRetryLimit = 7;
@@ -4379,15 +2909,9 @@ short rtl8180_init(struct net_device *dev)
(0 ? TCR_SAT : 0); // FALSE: HW provies PLCP length and LENGEXT, TURE: SW proiveds them
priv->ReceiveConfig =
-#ifdef CONFIG_RTL818X_S
-#else
- priv->CSMethod |
-#endif
-// RCR_ENMARP |
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
(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);
@@ -4403,49 +2927,35 @@ short rtl8180_init(struct net_device *dev)
IMR_RQoSOK; // <NOTE> ROK and RQoSOK are mutually exclusive, so, we must handle RQoSOK interrupt to receive QoS frames, 2005.12.09, by rcnjko.
priv->InitialGain = 6;
-#endif
hw_version =( read_nic_dword(dev, TCR) & TCR_HWVERID_MASK)>>TCR_HWVERID_SHIFT;
switch (hw_version){
-#ifdef CONFIG_RTL8185B
case HW_VERID_R8185B_B:
-#ifdef CONFIG_RTL818X_S
priv->card_8185 = VERSION_8187S_C;
DMESG("MAC controller is a RTL8187SE b/g");
priv->phy_ver = 2;
break;
-#else
- DMESG("MAC controller is a RTL8185B b/g");
- priv->card_8185 = 3;
- priv->phy_ver = 2;
- break;
-#endif
-#endif
case HW_VERID_R8185_ABC:
DMESG("MAC controller is a RTL8185 b/g");
priv->card_8185 = 1;
/* you should not find a card with 8225 PHY ver < C*/
priv->phy_ver = 2;
break;
-
case HW_VERID_R8185_D:
DMESG("MAC controller is a RTL8185 b/g (V. D)");
priv->card_8185 = 2;
/* you should not find a card with 8225 PHY ver < C*/
priv->phy_ver = 2;
break;
-
case HW_VERID_R8180_ABCD:
DMESG("MAC controller is a RTL8180");
priv->card_8185 = 0;
break;
-
case HW_VERID_R8180_F:
DMESG("MAC controller is a RTL8180 (v. F)");
priv->card_8185 = 0;
break;
-
default:
DMESGW("MAC chip not recognized: version %x. Assuming RTL8180",hw_version);
priv->card_8185 = 0;
@@ -4459,98 +2969,50 @@ short rtl8180_init(struct net_device *dev)
/* you should not found any 8185 Ver B Card */
priv->card_8185_Bversion = 0;
-#ifdef CONFIG_RTL8185B
-#ifdef CONFIG_RTL818X_S
// just for sync 85
priv->card_type = PCI;
DMESG("This is a PCI NIC");
-#else
- config3 = read_nic_byte(dev, CONFIG3);
- if(config3 & 0x8){
- priv->card_type = CARDBUS;
- DMESG("This is a CARDBUS NIC");
- }
- else if( config3 & 0x4){
- priv->card_type = MINIPCI;
- DMESG("This is a MINI-PCI NIC");
- }else{
- priv->card_type = PCI;
- DMESG("This is a PCI NIC");
- }
-#endif
-#endif
priv->enable_gpio0 = 0;
-//by amy for antenna
-#ifdef CONFIG_RTL8185B
usValue = eprom_read(dev, EEPROM_SW_REVD_OFFSET);
DMESG("usValue is 0x%x\n",usValue);
-#ifdef CONFIG_RTL818X_S
//3Read AntennaDiversity
+
// SW Antenna Diversity.
- if( (usValue & EEPROM_SW_AD_MASK) != EEPROM_SW_AD_ENABLE )
- {
+ if ((usValue & EEPROM_SW_AD_MASK) != EEPROM_SW_AD_ENABLE)
priv->EEPROMSwAntennaDiversity = false;
- //printk("EEPROM Disable SW Antenna Diversity\n");
- }
else
- {
priv->EEPROMSwAntennaDiversity = true;
- //printk("EEPROM Enable SW Antenna Diversity\n");
- }
+
// Default Antenna to use.
- if( (usValue & EEPROM_DEF_ANT_MASK) != EEPROM_DEF_ANT_1 )
- {
+ if ((usValue & EEPROM_DEF_ANT_MASK) != EEPROM_DEF_ANT_1)
priv->EEPROMDefaultAntenna1 = false;
- //printk("EEPROM Default Antenna 0\n");
- }
else
- {
priv->EEPROMDefaultAntenna1 = true;
- //printk("EEPROM Default Antenna 1\n");
- }
- //
- // Antenna diversity mechanism. Added by Roger, 2007.11.05.
- //
if( priv->RegSwAntennaDiversityMechanism == 0 ) // Auto
- {// 0: default from EEPROM.
+ /* 0: default from EEPROM. */
priv->bSwAntennaDiverity = priv->EEPROMSwAntennaDiversity;
- }
else
- {// 1:disable antenna diversity, 2: enable antenna diversity.
+ /* 1:disable antenna diversity, 2: enable antenna diversity. */
priv->bSwAntennaDiverity = ((priv->RegSwAntennaDiversityMechanism == 1)? false : true);
- }
- //printk("bSwAntennaDiverity = %d\n", priv->bSwAntennaDiverity);
-
- //
- // Default antenna settings. Added by Roger, 2007.11.05.
- //
- if( priv->RegDefaultAntenna == 0)
- {// 0: default from EEPROM.
+ if (priv->RegDefaultAntenna == 0)
+ /* 0: default from EEPROM. */
priv->bDefaultAntenna1 = priv->EEPROMDefaultAntenna1;
- }
else
- {// 1: main, 2: aux.
+ /* 1: main, 2: aux. */
priv->bDefaultAntenna1 = ((priv->RegDefaultAntenna== 2) ? true : false);
- }
- //printk("bDefaultAntenna1 = %d\n", priv->bDefaultAntenna1);
-#endif
-#endif
-//by amy for antenna
+
/* rtl8185 can calc plcp len in HW.*/
priv->hw_plcp_len = 1;
priv->plcp_preamble_mode = 2;
/*the eeprom type is stored in RCR register bit #6 */
- if (RCR_9356SEL & read_nic_dword(dev, RCR)){
+ if (RCR_9356SEL & read_nic_dword(dev, RCR))
priv->epromtype=EPROM_93c56;
- //DMESG("Reported EEPROM chip is a 93c56 (2Kbit)");
- }else{
+ else
priv->epromtype=EPROM_93c46;
- //DMESG("Reported EEPROM chip is a 93c46 (1Kbit)");
- }
dev->dev_addr[0]=eprom_read(dev,MAC_ADR) & 0xff;
dev->dev_addr[1]=(eprom_read(dev,MAC_ADR) & 0xff00)>>8;
@@ -4558,42 +3020,26 @@ short rtl8180_init(struct net_device *dev)
dev->dev_addr[3]=(eprom_read(dev,MAC_ADR+1) & 0xff00)>>8;
dev->dev_addr[4]=eprom_read(dev,MAC_ADR+2) & 0xff;
dev->dev_addr[5]=(eprom_read(dev,MAC_ADR+2) & 0xff00)>>8;
- //DMESG("Card MAC address is "MAC_FMT, MAC_ARG(dev->dev_addr));
-
for(i=1,j=0; i<14; i+=2,j++){
-
word = eprom_read(dev,EPROM_TXPW_CH1_2 + j);
priv->chtxpwr[i]=word & 0xff;
priv->chtxpwr[i+1]=(word & 0xff00)>>8;
-#ifdef DEBUG_EPROM
- DMESG("tx word %x:%x",j,word);
- DMESG("ch %d pwr %x",i,priv->chtxpwr[i]);
- DMESG("ch %d pwr %x",i+1,priv->chtxpwr[i+1]);
-#endif
}
if(priv->card_8185){
for(i=1,j=0; i<14; i+=2,j++){
-
word = eprom_read(dev,EPROM_TXPW_OFDM_CH1_2 + j);
priv->chtxpwr_ofdm[i]=word & 0xff;
priv->chtxpwr_ofdm[i+1]=(word & 0xff00)>>8;
-#ifdef DEBUG_EPROM
- DMESG("ofdm tx word %x:%x",j,word);
- DMESG("ofdm ch %d pwr %x",i,priv->chtxpwr_ofdm[i]);
- DMESG("ofdm ch %d pwr %x",i+1,priv->chtxpwr_ofdm[i+1]);
-#endif
}
}
-//{by amy 080312
+
//3Read crystal calibtration and thermal meter indication on 87SE.
// By SD3 SY's request. Added by Roger, 2007.12.11.
tmpu16 = eprom_read(dev, EEPROM_RSV>>1);
- //printk("ReadAdapterInfo8185(): EEPROM_RSV(%04x)\n", tmpu16);
-
// Crystal calibration for Xin and Xout resp.
priv->XtalCal_Xout = tmpu16 & EEPROM_XTAL_CAL_XOUT_MASK; // 0~7.5pF
priv->XtalCal_Xin = (tmpu16 & EEPROM_XTAL_CAL_XIN_MASK)>>4; // 0~7.5pF
@@ -4605,12 +3051,9 @@ short rtl8180_init(struct net_device *dev)
if((tmpu16 & EEPROM_THERMAL_METER_ENABLE)>>13)
priv->bTxPowerTrack = true;
-//by amy 080312}
-#ifdef CONFIG_RTL8185B
word = eprom_read(dev,EPROM_TXPW_BASE);
priv->cck_txpwr_base = word & 0xf;
priv->ofdm_txpwr_base = (word>>4) & 0xf;
-#endif
version = eprom_read(dev,EPROM_VERSION);
DMESG("EEPROM version %x",version);
@@ -4646,142 +3089,15 @@ DMESG output to andreamrl@tiscali.it THANKS");
priv->rf_chip = 0xff & eprom_read(dev,RFCHIPID);
}
-#ifdef CONFIG_RTL8185B
-#ifdef CONFIG_RTL818X_S
priv->rf_chip = RF_ZEBRA4;
priv->rf_sleep = rtl8225z4_rf_sleep;
priv->rf_wakeup = rtl8225z4_rf_wakeup;
-#else
- priv->rf_chip = RF_ZEBRA2;
-#endif
- //DMESG("Card reports RF frontend Realtek 8225z2");
- //DMESGW("This driver has EXPERIMENTAL support for this chipset.");
- //DMESGW("use it with care and at your own risk and");
DMESGW("**PLEASE** REPORT SUCCESSFUL/UNSUCCESSFUL TO Realtek!");
priv->rf_close = rtl8225z2_rf_close;
priv->rf_init = rtl8225z2_rf_init;
priv->rf_set_chan = rtl8225z2_rf_set_chan;
priv->rf_set_sens = NULL;
- //priv->rf_sleep = rtl8225_rf_sleep;
- //priv->rf_wakeup = rtl8225_rf_wakeup;
-
-#else
- /* check RF frontend chipset */
- switch (priv->rf_chip) {
-
- case RFCHIPID_RTL8225:
-
- if(priv->card_8185){
- DMESG("Card reports RF frontend Realtek 8225");
- DMESGW("This driver has EXPERIMENTAL support for this chipset.");
- DMESGW("use it with care and at your own risk and");
- DMESGW("**PLEASE** REPORT SUCCESS/INSUCCESS TO andreamrl@tiscali.it");
-
- priv->rf_close = rtl8225_rf_close;
- priv->rf_init = rtl8225_rf_init;
- priv->rf_set_chan = rtl8225_rf_set_chan;
- priv->rf_set_sens = NULL;
- priv->rf_sleep = rtl8225_rf_sleep;
- priv->rf_wakeup = rtl8225_rf_wakeup;
-
- }else{
- DMESGW("Detected RTL8225 radio on a card recognized as RTL8180");
- DMESGW("This could not be... something went wrong....");
- return -ENODEV;
- }
- break;
-
- case RFCHIPID_RTL8255:
- if(priv->card_8185){
- DMESG("Card reports RF frontend Realtek 8255");
- DMESGW("This driver has EXPERIMENTAL support for this chipset.");
- DMESGW("use it with care and at your own risk and");
- DMESGW("**PLEASE** REPORT SUCCESS/INSUCCESS TO andreamrl@tiscali.it");
-
- priv->rf_close = rtl8255_rf_close;
- priv->rf_init = rtl8255_rf_init;
- priv->rf_set_chan = rtl8255_rf_set_chan;
- priv->rf_set_sens = NULL;
- priv->rf_sleep = NULL;
- priv->rf_wakeup = NULL;
-
- }else{
- DMESGW("Detected RTL8255 radio on a card recognized as RTL8180");
- DMESGW("This could not be... something went wrong....");
- return -ENODEV;
- }
- break;
-
-
- case RFCHIPID_INTERSIL:
- DMESGW("Card reports RF frontend by Intersil.");
- DMESGW("This driver has NO support for this chipset.");
- return -ENODEV;
- break;
-
- case RFCHIPID_RFMD:
- DMESGW("Card reports RF frontend by RFMD.");
- DMESGW("This driver has NO support for this chipset.");
- return -ENODEV;
- break;
-
- case RFCHIPID_GCT:
- DMESGW("Card reports RF frontend by GCT.");
- DMESGW("This driver has EXPERIMENTAL support for this chipset.");
- DMESGW("use it with care and at your own risk and");
- DMESGW("**PLEASE** REPORT SUCCESS/INSUCCESS TO andreamrl@tiscali.it");
- priv->rf_close = gct_rf_close;
- priv->rf_init = gct_rf_init;
- priv->rf_set_chan = gct_rf_set_chan;
- priv->rf_set_sens = NULL;
- priv->rf_sleep = NULL;
- priv->rf_wakeup = NULL;
- break;
-
- case RFCHIPID_MAXIM:
- DMESGW("Card reports RF frontend by MAXIM.");
- DMESGW("This driver has EXPERIMENTAL support for this chipset.");
- DMESGW("use it with care and at your own risk and");
- DMESGW("**PLEASE** REPORT SUCCESS/INSUCCESS TO andreamrl@tiscali.it");
- priv->rf_close = maxim_rf_close;
- priv->rf_init = maxim_rf_init;
- priv->rf_set_chan = maxim_rf_set_chan;
- priv->rf_set_sens = NULL;
- priv->rf_sleep = NULL;
- priv->rf_wakeup = NULL;
- break;
-
- case RFCHIPID_PHILIPS:
- DMESG("Card reports RF frontend by Philips.");
- DMESG("OK! Philips SA2400 radio chipset is supported.");
- priv->rf_close = sa2400_rf_close;
- priv->rf_init = sa2400_rf_init;
- priv->rf_set_chan = sa2400_rf_set_chan;
- priv->rf_set_sens = sa2400_rf_set_sens;
- priv->sens = SA2400_RF_DEF_SENS; /* default sensitivity */
- priv->max_sens = SA2400_RF_MAX_SENS; /* maximum sensitivity */
- priv->rf_sleep = NULL;
- priv->rf_wakeup = NULL;
-
- if(priv->digphy){
- DMESGW("Digital PHY found");
- DMESGW("Philips DIGITAL PHY is untested! *Please*\
- report success/failure to <andreamrl@tiscali.it>");
- }else{
- DMESG ("Analog PHY found");
- }
-
- break;
-
- default:
- DMESGW("Unknown RF module %x",priv->rf_chip);
- DMESGW("Exiting...");
- return -1;
-
- }
-#endif
-
if(!priv->card_8185){
if(priv->antb)
@@ -4828,11 +3144,7 @@ DMESG output to andreamrl@tiscali.it THANKS");
TX_BEACON_RING_ADDR))
return -ENOMEM;
-
- //priv->beacon_buf=NULL;
-
if(!priv->card_8185){
-
if(read_nic_byte(dev, CONFIG0) & (1<<CONFIG0_WEP40_SHIFT))
DMESG ("40-bit WEP is supported in hardware");
else
@@ -4855,21 +3167,14 @@ DMESG output to andreamrl@tiscali.it THANKS");
DMESG("IRQ %d",dev->irq);
}
-#ifdef DEBUG_EPROM
- dump_eprom(dev);
-#endif
-
return 0;
-
}
-
void rtl8180_no_hw_wep(struct net_device *dev)
{
struct r8180_priv *priv = ieee80211_priv(dev);
- if(!priv->card_8185)
- {
+ if (!priv->card_8185) {
u8 security;
security = read_nic_byte(dev, SECURITY);
@@ -4877,19 +3182,9 @@ void rtl8180_no_hw_wep(struct net_device *dev)
security &=~(1<<SECURITY_WEP_RX_ENABLE_SHIFT);
write_nic_byte(dev, SECURITY, security);
-
- }else{
-
- //FIXME!!!
}
- /*
- write_nic_dword(dev,TX_CONF,read_nic_dword(dev,TX_CONF) |
- (1<<TX_NOICV_SHIFT) );
- */
-// priv->ieee80211->hw_wep=0;
}
-
void rtl8180_set_hw_wep(struct net_device *dev)
{
struct r8180_priv *priv = ieee80211_priv(dev);
@@ -4908,10 +3203,6 @@ void rtl8180_set_hw_wep(struct net_device *dev)
write_nic_dword(dev,KEY0+4+4,(priv->key0[2]));
write_nic_dword(dev,KEY0+4+4+4,(key0_word4));
- /*
- TX_CONF,read_nic_dword(dev,TX_CONF) &~(1<<TX_NOICV_SHIFT));
- */
-
security = read_nic_byte(dev,SECURITY);
security |= (1<<SECURITY_WEP_TX_ENABLE_SHIFT);
security |= (1<<SECURITY_WEP_RX_ENABLE_SHIFT);
@@ -4923,8 +3214,6 @@ void rtl8180_set_hw_wep(struct net_device *dev)
DMESG("key %x %x %x %x",read_nic_dword(dev,KEY0+4+4+4),
read_nic_dword(dev,KEY0+4+4),read_nic_dword(dev,KEY0+4),
read_nic_dword(dev,KEY0));
-
- //priv->ieee80211->hw_wep=1;
}
@@ -4933,10 +3222,8 @@ void rtl8185_rf_pins_enable(struct net_device *dev)
// u16 tmp;
// tmp = read_nic_word(dev, RFPinsEnable);
write_nic_word(dev, RFPinsEnable, 0x1fff);// | tmp);
-// write_nic_word(dev, RFPinsEnable,7 | tmp);
}
-
void rtl8185_set_anaparam2(struct net_device *dev, u32 a)
{
u8 conf3;
@@ -4950,10 +3237,8 @@ void rtl8185_set_anaparam2(struct net_device *dev, u32 a)
conf3 = read_nic_byte(dev, CONFIG3);
write_nic_byte(dev, CONFIG3, conf3 &~(1<<CONFIG3_ANAPARAM_W_SHIFT));
rtl8180_set_mode(dev, EPROM_CMD_NORMAL);
-
}
-
void rtl8180_set_anaparam(struct net_device *dev, u32 a)
{
u8 conf3;
@@ -4969,7 +3254,6 @@ void rtl8180_set_anaparam(struct net_device *dev, u32 a)
rtl8180_set_mode(dev, EPROM_CMD_NORMAL);
}
-
void rtl8185_tx_antenna(struct net_device *dev, u8 ant)
{
write_nic_byte(dev, TX_ANTENNA, ant);
@@ -4977,55 +3261,38 @@ void rtl8185_tx_antenna(struct net_device *dev, u8 ant)
mdelay(1);
}
-
void rtl8185_write_phy(struct net_device *dev, u8 adr, u32 data)
{
- //u8 phyr;
u32 phyw;
- //int i;
adr |= 0x80;
phyw= ((data<<8) | adr);
-#if 0
-
- write_nic_dword(dev, PHY_ADR, phyw);
-
- //read_nic_dword(dev, PHY_ADR);
- for(i=0;i<10;i++){
- write_nic_dword(dev, PHY_ADR, 0xffffff7f & phyw);
- phyr = read_nic_byte(dev, PHY_READ);
- if(phyr == (data&0xff)) break;
- }
-#else
// Note that, we must write 0xff7c after 0x7d-0x7f to write BB register.
write_nic_byte(dev, 0x7f, ((phyw & 0xff000000) >> 24));
write_nic_byte(dev, 0x7e, ((phyw & 0x00ff0000) >> 16));
write_nic_byte(dev, 0x7d, ((phyw & 0x0000ff00) >> 8));
write_nic_byte(dev, 0x7c, ((phyw & 0x000000ff) ));
-#endif
+
/* this is ok to fail when we write AGC table. check for AGC table might be
* done by masking with 0x7f instead of 0xff
*/
//if(phyr != (data&0xff)) DMESGW("Phy write timeout %x %x %x", phyr, data,adr);
}
-
inline void write_phy_ofdm (struct net_device *dev, u8 adr, u32 data)
{
data = data & 0xff;
rtl8185_write_phy(dev, adr, data);
}
-
void write_phy_cck (struct net_device *dev, u8 adr, u32 data)
{
data = data & 0xff;
rtl8185_write_phy(dev, adr, data | 0x10000);
}
-
/* 70*3 = 210 ms
* I hope this is enougth
*/
@@ -5054,9 +3321,6 @@ void write_phy(struct net_device *dev, u8 adr, u8 data)
if(phy == data){ //SUCCESS!
force_pci_posting(dev);
mdelay(3); //random value
-#ifdef DEBUG_BB
- DMESG("Phy wr %x,%x",adr,data);
-#endif
return;
}else{
force_pci_posting(dev);
@@ -5072,55 +3336,32 @@ void rtl8185_set_rate(struct net_device *dev)
u16 word;
int basic_rate,min_rr_rate,max_rr_rate;
-// struct r8180_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 &= ~BRSR_MBR_8185;
-
for(i=0;i<=basic_rate;i++)
word |= (1<<i);
write_nic_word(dev, BRSR, word);
- //DMESG("RR:%x BRSR: %x", read_nic_byte(dev,RESP_RATE),read_nic_word(dev,BRSR));
}
-
-
void rtl8180_adapter_start(struct net_device *dev)
{
struct r8180_priv *priv = ieee80211_priv(dev);
u32 anaparam;
u16 word;
u8 config3;
-// int i;
rtl8180_rtx_disable(dev);
rtl8180_reset(dev);
- /* seems that 0xffff or 0xafff will cause
- * HW interrupt line crash
- */
-
- //priv->irq_mask = 0xafff;
-// priv->irq_mask = 0x4fcf;
-
/* enable beacon timeout, beacon TX ok and err
* LP tx ok and err, HP TX ok and err, NP TX ok and err,
* RX ok and ERR, and GP timer */
@@ -5152,8 +3393,6 @@ void rtl8180_adapter_start(struct net_device *dev)
/* These might be unnecessary since we do in rx_enable / tx_enable */
fix_rx_fifo(dev);
fix_tx_fifo(dev);
- /*set_nic_rxring(dev);
- set_nic_txring(dev);*/
rtl8180_set_mode(dev, EPROM_CMD_CONFIG);
@@ -5174,9 +3413,6 @@ void rtl8180_adapter_start(struct net_device *dev)
rtl8180_set_mode(dev,EPROM_CMD_NORMAL);
write_nic_dword(dev,INT_TIMEOUT,0);
-#ifdef DEBUG_REGISTERS
- rtl8180_dump_reg(dev);
-#endif
if(!priv->card_8185)
{
@@ -5191,7 +3427,6 @@ void rtl8180_adapter_start(struct net_device *dev)
write_nic_byte(dev, CONFIG5,
read_nic_byte(dev, CONFIG5) &~ (1<<AGCRESET_SHIFT));
}else{
-
write_nic_byte(dev, WPA_CONFIG, 0);
//write_nic_byte(dev, TESTR, 0xd);
}
@@ -5201,28 +3436,23 @@ void rtl8180_adapter_start(struct net_device *dev)
if(priv->card_8185){
rtl8185_set_rate(dev);
write_nic_byte(dev, RATE_FALLBACK, 0x81);
- // write_nic_byte(dev, 0xdf, 0x15);
}else{
word = read_nic_word(dev, BRSR);
word &= ~BRSR_MBR;
word &= ~BRSR_BPLCP;
word |= ieeerate2rtlrate(priv->ieee80211->basic_rate);
-//by amy
- word |= 0x0f;
-//by amy
+ word |= 0x0f;
write_nic_word(dev, BRSR, word);
}
-
if(priv->card_8185){
write_nic_byte(dev, GP_ENABLE,read_nic_byte(dev, GP_ENABLE) & ~(1<<6));
//FIXME cfg 3 ClkRun enable - isn't it ReadOnly ?
rtl8180_set_mode(dev, EPROM_CMD_CONFIG);
write_nic_byte(dev,CONFIG3, read_nic_byte(dev, CONFIG3)
-|(1<<CONFIG3_CLKRUN_SHIFT));
+ | (1 << CONFIG3_CLKRUN_SHIFT));
rtl8180_set_mode(dev, EPROM_CMD_NORMAL);
-
}
priv->rf_init(dev);
@@ -5232,51 +3462,23 @@ void rtl8180_adapter_start(struct net_device *dev)
rtl8180_irq_enable(dev);
netif_start_queue(dev);
- /*DMESG ("lfree %d",get_curr_tx_free_desc(dev,LOW_PRIORITY));
-
- DMESG ("nfree %d",get_curr_tx_free_desc(dev,NORM_PRIORITY));
-
- DMESG ("hfree %d",get_curr_tx_free_desc(dev,HI_PRIORITY));
- if(check_nic_enought_desc(dev,NORM_PRIORITY)) DMESG("NORM OK");
- if(check_nic_enought_desc(dev,HI_PRIORITY)) DMESG("HI OK");
- if(check_nic_enought_desc(dev,LOW_PRIORITY)) DMESG("LOW OK");*/
}
-
-
/* this configures registers for beacon tx and enables it via
* rtl8180_beacon_tx_enable(). rtl8180_beacon_tx_disable() might
* be used to stop beacon transmission
*/
void rtl8180_start_tx_beacon(struct net_device *dev)
{
-// struct r8180_priv *priv = (struct r8180_priv *)ieee80211_priv(dev);
u16 word;
-// DMESG("ring %x %x", priv->txlpringdma,read_nic_dword(dev,TLPDA));
DMESG("Enabling beacon TX");
- //write_nic_byte(dev, 0x42,0xe6);// TCR
-// set_nic_txring(dev);
-// fix_tx_fifo(dev);
rtl8180_prepare_beacon(dev);
rtl8180_irq_disable(dev);
rtl8180_beacon_tx_enable(dev);
-#if 0
- rtl8180_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);
-#if 0
- word = read_nic_word(dev, BcnItv);
- word &= ~BcnItv_BcnItv; // clear Bcn_Itv
- word |= priv->ieee80211->current_network.beacon_interval;//0x64;
- write_nic_word(dev, BcnItv, word);
-#endif
-#endif
word = read_nic_word(dev, AtimWnd) &~ AtimWnd_AtimWnd;
write_nic_word(dev, AtimWnd,word);// word |=
-//priv->ieee80211->current_network.atim_window);
word = read_nic_word(dev, BintrItv);
word &= ~BintrItv_BintrItv;
@@ -5286,30 +3488,11 @@ void rtl8180_start_tx_beacon(struct net_device *dev)
*/
write_nic_word(dev, BintrItv, word);
-
rtl8180_set_mode(dev, EPROM_CMD_NORMAL);
-// rtl8180_beacon_tx_enable(dev);
-#ifdef CONFIG_RTL8185B
rtl8185b_irq_enable(dev);
-#else
- rtl8180_irq_enable(dev);
-#endif
- /* VV !!!!!!!!!! VV*/
- /*
- rtl8180_set_mode(dev,EPROM_CMD_CONFIG);
- write_nic_byte(dev,0x9d,0x00);
- rtl8180_set_mode(dev,EPROM_CMD_NORMAL);
-*/
-// DMESG("ring %x %x", priv->txlpringdma,read_nic_dword(dev,TLPDA));
-
}
-
-
-/***************************************************************************
- -------------------------------NET STUFF---------------------------
-***************************************************************************/
static struct net_device_stats *rtl8180_stats(struct net_device *dev)
{
struct r8180_priv *priv = ieee80211_priv(dev);
@@ -5326,121 +3509,49 @@ MgntActSet_802_11_PowerSaveMode(
RT_PS_MODE rtPsMode
)
{
-
// Currently, we do not change power save mode on IBSS mode.
if(priv->ieee80211->iw_mode == IW_MODE_ADHOC)
- {
return false;
- }
- //
- // <RJ_NOTE> If we make HW to fill up the PwrMgt bit for us,
- // some AP will not response to our mgnt frames with PwrMgt bit set,
- // e.g. cannot associate the AP.
- // So I commented out it. 2005.02.16, by rcnjko.
- //
-// // Change device's power save mode.
-// Adapter->HalFunc.SetPSModeHandler( Adapter, rtPsMode );
-
- // Update power save mode configured.
-// priv->dot11PowerSaveMode = rtPsMode;
priv->ieee80211->ps = rtPsMode;
- // Determine ListenInterval.
-#if 0
- if(priv->dot11PowerSaveMode == eMaxPs)
- {
- priv->ieee80211->ListenInterval = 10;
- }
- else
- {
- priv->ieee80211->ListenInterval = 2;
- }
-#endif
+
return true;
}
-//================================================================================
-// Leisure Power Save in linked state.
-//================================================================================
-
-//
-// Description:
-// Enter the leisure power save mode.
-//
-void
-LeisurePSEnter(
- struct r8180_priv *priv
- )
+void LeisurePSEnter(struct r8180_priv *priv)
{
- if (priv->bLeisurePs)
- {
+ if (priv->bLeisurePs) {
if (priv->ieee80211->ps == IEEE80211_PS_DISABLED)
- {
- //printk("----Enter PS\n");
MgntActSet_802_11_PowerSaveMode(priv, IEEE80211_PS_MBCAST|IEEE80211_PS_UNICAST);//IEEE80211_PS_ENABLE
- }
}
}
-
-//
-// Description:
-// Leave the leisure power save mode.
-//
-void
-LeisurePSLeave(
- struct r8180_priv *priv
- )
+void LeisurePSLeave(struct r8180_priv *priv)
{
- if (priv->bLeisurePs)
- {
+ if (priv->bLeisurePs) {
if (priv->ieee80211->ps != IEEE80211_PS_DISABLED)
- {
- //printk("----Leave PS\n");
MgntActSet_802_11_PowerSaveMode(priv, IEEE80211_PS_DISABLED);
- }
}
}
-#if (LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,20))
+
void rtl8180_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 = to_delayed_work(work);
struct ieee80211_device *ieee = container_of(dwork,struct ieee80211_device,hw_wakeup_wq);
struct net_device *dev = ieee->dev;
-#else
-void rtl8180_hw_wakeup_wq(struct net_device *dev)
-{
- struct r8180_priv *priv = ieee80211_priv(dev);
-#endif
-// printk("dev is %d\n",dev);
-// printk("&*&(^*(&(&=========>%s()\n", __func__);
rtl8180_hw_wakeup(dev);
-
}
-#if (LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,20))
void rtl8180_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 = to_delayed_work(work);
struct ieee80211_device *ieee = container_of(dwork,struct ieee80211_device,hw_sleep_wq);
struct net_device *dev = ieee->dev;
-#else
-void rtl8180_hw_sleep_wq(struct net_device *dev)
-{
- struct r8180_priv *priv = ieee80211_priv(dev);
-#endif
rtl8180_hw_sleep_down(dev);
}
-//YJ,add,080828,for KeepAlive
static void MgntLinkKeepAlive(struct r8180_priv *priv )
{
if (priv->keepAliveLevel == 0)
@@ -5451,7 +3562,6 @@ static void MgntLinkKeepAlive(struct r8180_priv *priv )
//
// Keep-Alive.
//
- //printk("LastTx:%d Tx:%d LastRx:%d Rx:%ld Idle:%d\n",priv->link_detect.LastNumTxUnicast,priv->NumTxUnicast, priv->link_detect.LastNumRxUnicast, priv->ieee80211->NumRxUnicast, priv->link_detect.IdleCount);
if ( (priv->keepAliveLevel== 2) ||
(priv->link_detect.LastNumTxUnicast == priv->NumTxUnicast &&
@@ -5477,9 +3587,9 @@ static void MgntLinkKeepAlive(struct r8180_priv *priv )
priv->link_detect.LastNumRxUnicast = priv->ieee80211->NumRxUnicast;
}
}
-//YJ,add,080828,for KeepAlive,end
static u8 read_acadapter_file(char *filename);
+
void rtl8180_watch_dog(struct net_device *dev)
{
struct r8180_priv *priv = ieee80211_priv(dev);
@@ -5501,7 +3611,7 @@ void rtl8180_watch_dog(struct net_device *dev)
priv->link_detect.RxFrameNum[SlotIndex] = priv->ieee80211->NumRxDataInPeriod + priv->ieee80211->NumRxBcnInPeriod;
for( i=0; i<priv->link_detect.SlotNum; i++ )
TotalRxNum+= priv->link_detect.RxFrameNum[i];
- //printk("&&&&&=== TotalRxNum = %d\n", TotalRxNum);
+
if(TotalRxNum == 0){
priv->ieee80211->state = IEEE80211_ASSOCIATING;
queue_work(priv->ieee80211->wq, &priv->ieee80211->associate_procedure_wq);
@@ -5513,47 +3623,13 @@ void rtl8180_watch_dog(struct net_device *dev)
//YJ,add,080828,for LPS
#ifdef ENABLE_LPS
- if(priv->PowerProfile == POWER_PROFILE_BATTERY )
- {
- //Turn on LeisurePS on battery power
- //printk("!!!!!On battery power\n");
+ if (priv->PowerProfile == POWER_PROFILE_BATTERY)
priv->bLeisurePs = true;
- }
- else if(priv->PowerProfile == POWER_PROFILE_AC )
- {
- // Turn off LeisurePS on AC power
- //printk("----On AC power\n");
+ else if (priv->PowerProfile == POWER_PROFILE_AC) {
LeisurePSLeave(priv);
priv->bLeisurePs= false;
}
-#endif
-#if 0
-#ifndef ENABLE_LPS
- if(priv->ieee80211->state == IEEE80211_LINKED){
- if( priv->NumRxOkInPeriod> 666 ||
- priv->NumTxOkInPeriod > 666 ) {
- bBusyTraffic = true;
- }
- if((priv->ieee80211->NumRxData + priv->NumTxOkInPeriod)<8) {
- bEnterPS= true;
- }
- if(bEnterPS) {
- LeisurePSEnter(priv);
- }
- else {
- LeisurePSLeave(priv);
- }
- }
- else {
- LeisurePSLeave(priv);
- }
-#endif
- priv->NumRxOkInPeriod = 0;
- priv->NumTxOkInPeriod = 0;
- priv->ieee80211->NumRxData = 0;
-#else
-#ifdef ENABLE_LPS
if(priv->ieee80211->state == IEEE80211_LINKED){
priv->link_detect.NumRxOkInPeriod = priv->ieee80211->NumRxDataInPeriod;
//printk("TxOk=%d RxOk=%d\n", priv->link_detect.NumTxOkInPeriod, priv->link_detect.NumRxOkInPeriod);
@@ -5564,74 +3640,52 @@ void rtl8180_watch_dog(struct net_device *dev)
if(((priv->link_detect.NumRxOkInPeriod + priv->link_detect.NumTxOkInPeriod) > 8)
|| (priv->link_detect.NumRxOkInPeriod > 2)) {
bEnterPS= false;
- }
- else {
+ } else
bEnterPS= true;
- }
- if(bEnterPS) {
+ if (bEnterPS)
LeisurePSEnter(priv);
- }
- else {
+ else
LeisurePSLeave(priv);
- }
- }
- else{
+ } else
LeisurePSLeave(priv);
- }
#endif
priv->link_detect.bBusyTraffic = bBusyTraffic;
priv->link_detect.NumRxOkInPeriod = 0;
priv->link_detect.NumTxOkInPeriod = 0;
priv->ieee80211->NumRxDataInPeriod = 0;
priv->ieee80211->NumRxBcnInPeriod = 0;
-#endif
}
+
int _rtl8180_up(struct net_device *dev)
{
struct r8180_priv *priv = ieee80211_priv(dev);
- //int i;
priv->up=1;
DMESG("Bringing up iface");
-#ifdef CONFIG_RTL8185B
rtl8185b_adapter_start(dev);
rtl8185b_rx_enable(dev);
rtl8185b_tx_enable(dev);
-#else
- rtl8180_adapter_start(dev);
- rtl8180_rx_enable(dev);
- rtl8180_tx_enable(dev);
-#endif
#ifdef ENABLE_IPS
if(priv->bInactivePs){
if(priv->ieee80211->iw_mode == IW_MODE_ADHOC)
IPSLeave(dev);
}
#endif
-//by amy 080312
#ifdef RATE_ADAPT
timer_rate_adaptive((unsigned long)dev);
#endif
-//by amy 080312
watch_dog_adaptive((unsigned long)dev);
#ifdef SW_ANTE
if(priv->bSwAntennaDiverity)
SwAntennaDiversityTimerCallback(dev);
#endif
-// IPSEnter(dev);
ieee80211_softmac_start_protocol(priv->ieee80211);
-//Add for RF power on power off by lizhaoming 080512
-// priv->eRFPowerState = eRfOn;
-// printk("\n--------Start queue_work:GPIOChangeRFWorkItem");
-// queue_delayed_work(priv->ieee80211->wq,&priv->ieee80211->GPIOChangeRFWorkItem,1000);
-
return 0;
}
-
int rtl8180_open(struct net_device *dev)
{
struct r8180_priv *priv = ieee80211_priv(dev);
@@ -5641,10 +3695,8 @@ int rtl8180_open(struct net_device *dev)
ret = rtl8180_up(dev);
up(&priv->wx_sem);
return ret;
-
}
-
int rtl8180_up(struct net_device *dev)
{
struct r8180_priv *priv = ieee80211_priv(dev);
@@ -5654,7 +3706,6 @@ int rtl8180_up(struct net_device *dev)
return _rtl8180_up(dev);
}
-
int rtl8180_close(struct net_device *dev)
{
struct r8180_priv *priv = ieee80211_priv(dev);
@@ -5665,14 +3716,14 @@ int rtl8180_close(struct net_device *dev)
up(&priv->wx_sem);
return ret;
-
}
int rtl8180_down(struct net_device *dev)
{
struct r8180_priv *priv = ieee80211_priv(dev);
- if (priv->up == 0) return -1;
+ if (priv->up == 0)
+ return -1;
priv->up=0;
@@ -5683,33 +3734,24 @@ int rtl8180_down(struct net_device *dev)
rtl8180_rtx_disable(dev);
rtl8180_irq_disable(dev);
del_timer_sync(&priv->watch_dog_timer);
- //cancel_delayed_work(&priv->ieee80211->watch_dog_wq);
-//{by amy 080312
- del_timer_sync(&priv->rateadapter_timer);
- cancel_delayed_work(&priv->ieee80211->rate_adapter_wq);
-//by amy 080312}
+ del_timer_sync(&priv->rateadapter_timer);
+ cancel_delayed_work(&priv->ieee80211->rate_adapter_wq);
cancel_delayed_work(&priv->ieee80211->hw_wakeup_wq);
cancel_delayed_work(&priv->ieee80211->hw_sleep_wq);
cancel_delayed_work(&priv->ieee80211->hw_dig_wq);
cancel_delayed_work(&priv->ieee80211->tx_pw_wq);
del_timer_sync(&priv->SwAntennaDiversityTimer);
SetZebraRFPowerState8185(dev,eRfOff);
- //ieee80211_softmac_stop_protocol(priv->ieee80211);
memset(&(priv->ieee80211->current_network),0,sizeof(struct ieee80211_network));
priv->ieee80211->state = IEEE80211_NOLINK;
return 0;
}
-#if (LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,20))
void rtl8180_restart_wq(struct work_struct *work)
{
struct r8180_priv *priv = container_of(work, struct r8180_priv, reset_wq);
struct net_device *dev = priv->dev;
-#else
-void rtl8180_restart_wq(struct net_device *dev)
-{
- struct r8180_priv *priv = ieee80211_priv(dev);
-#endif
+
down(&priv->wx_sem);
rtl8180_commit(dev);
@@ -5720,26 +3762,20 @@ void rtl8180_restart_wq(struct net_device *dev)
void rtl8180_restart(struct net_device *dev)
{
struct r8180_priv *priv = ieee80211_priv(dev);
- //rtl8180_commit(dev);
+
schedule_work(&priv->reset_wq);
- //DMESG("TXTIMEOUT");
}
-
void rtl8180_commit(struct net_device *dev)
{
struct r8180_priv *priv = ieee80211_priv(dev);
- if (priv->up == 0) return ;
-//+by amy 080312
+ if (priv->up == 0)
+ return ;
+
del_timer_sync(&priv->watch_dog_timer);
- //cancel_delayed_work(&priv->ieee80211->watch_dog_wq);
-//{by amy 080312
-//by amy for rate adaptive
- del_timer_sync(&priv->rateadapter_timer);
- cancel_delayed_work(&priv->ieee80211->rate_adapter_wq);
-//by amy for rate adaptive
-//by amy 080312}
+ del_timer_sync(&priv->rateadapter_timer);
+ cancel_delayed_work(&priv->ieee80211->rate_adapter_wq);
cancel_delayed_work(&priv->ieee80211->hw_wakeup_wq);
cancel_delayed_work(&priv->ieee80211->hw_sleep_wq);
cancel_delayed_work(&priv->ieee80211->hw_dig_wq);
@@ -5751,39 +3787,19 @@ void rtl8180_commit(struct net_device *dev)
_rtl8180_up(dev);
}
-
static void r8180_set_multicast(struct net_device *dev)
{
struct r8180_priv *priv = ieee80211_priv(dev);
short promisc;
- //down(&priv->wx_sem);
-
promisc = (dev->flags & IFF_PROMISC) ? 1:0;
if (promisc != priv->promisc)
rtl8180_restart(dev);
priv->promisc = promisc;
-
- //up(&priv->wx_sem);
}
-#if 0
-/* this is called by the kernel when it needs to TX a 802.3 encapsulated frame*/
-int rtl8180_8023_hard_start_xmit(struct sk_buff *skb, struct net_device *dev)
-{
- struct r8180_priv *priv = ieee80211_priv(dev);
- int ret;
- unsigned long flags;
-
- spin_lock_irqsave(&priv->tx_lock,flags);
- ret = ieee80211_r8180_8023_hardstartxmit(skb,priv->ieee80211);
- spin_unlock_irqrestore(&priv->tx_lock,flags);
- return ret;
-}
-#endif
-
int r8180_set_mac_adr(struct net_device *dev, void *mac)
{
struct r8180_priv *priv = ieee80211_priv(dev);
@@ -5810,27 +3826,20 @@ int r8180_set_mac_adr(struct net_device *dev, void *mac)
int rtl8180_ioctl(struct net_device *dev, struct ifreq *rq, int cmd)
{
struct r8180_priv *priv = (struct r8180_priv *)ieee80211_priv(dev);
-
struct iwreq *wrq = (struct iwreq *) rq;
int ret=-1;
+
switch (cmd) {
- case RTL_IOCTL_WPA_SUPPLICANT:
+ case RTL_IOCTL_WPA_SUPPLICANT:
ret = ieee80211_wpa_supplicant_ioctl(priv->ieee80211, &wrq->u.data);
return ret;
-
- default:
+ default:
return -EOPNOTSUPP;
}
return -EOPNOTSUPP;
}
-
-
-/****************************************************************************
- -----------------------------PCI STUFF---------------------------
-*****************************************************************************/
-
static const struct net_device_ops rtl8180_netdev_ops = {
.ndo_open = rtl8180_open,
.ndo_stop = rtl8180_close,
@@ -5850,14 +3859,9 @@ static int __devinit rtl8180_pci_probe(struct pci_dev *pdev,
unsigned long ioaddr = 0;
struct net_device *dev = NULL;
struct r8180_priv *priv= NULL;
- //u8 *ptr;
u8 unit = 0;
-#ifdef CONFIG_RTL8180_IO_MAP
- unsigned long pio_start, pio_len, pio_flags;
-#else
unsigned long pmem_start, pmem_len, pmem_flags;
-#endif //end #ifdef RTL_IO_MAP
DMESG("Configuring chip resources");
@@ -5867,7 +3871,6 @@ static int __devinit rtl8180_pci_probe(struct pci_dev *pdev,
}
pci_set_master(pdev);
- //pci_set_wmi(pdev);
pci_set_dma_mask(pdev, 0xffffff00ULL);
pci_set_consistent_dma_mask(pdev,0xffffff00ULL);
dev = alloc_ieee80211(sizeof(struct r8180_priv));
@@ -5876,38 +3879,11 @@ static int __devinit rtl8180_pci_probe(struct pci_dev *pdev,
priv = ieee80211_priv(dev);
priv->ieee80211 = netdev_priv(dev);
-#if LINUX_VERSION_CODE < KERNEL_VERSION(2,6,24)
- SET_MODULE_OWNER(dev);
-#endif
pci_set_drvdata(pdev, dev);
SET_NETDEV_DEV(dev, &pdev->dev);
priv = ieee80211_priv(dev);
-// memset(priv,0,sizeof(struct r8180_priv));
- priv->pdev=pdev;
-
-
-#ifdef CONFIG_RTL8180_IO_MAP
-
- pio_start = (unsigned long)pci_resource_start (pdev, 0);
- pio_len = (unsigned long)pci_resource_len (pdev, 0);
- pio_flags = (unsigned long)pci_resource_flags (pdev, 0);
-
- if (!(pio_flags & IORESOURCE_IO)) {
- DMESG("region #0 not a PIO resource, aborting");
- goto fail;
- }
-
- //DMESG("IO space @ 0x%08lx", pio_start );
- if( ! request_region( pio_start, pio_len, RTL8180_MODULE_NAME ) ){
- DMESG("request_region failed!");
- goto fail;
- }
-
- ioaddr = pio_start;
- dev->base_addr = ioaddr; // device I/O address
-
-#else
+ priv->pdev = pdev;
pmem_start = pci_resource_start(pdev, 1);
pmem_len = pci_resource_len(pdev, 1);
@@ -5918,31 +3894,22 @@ static int __devinit rtl8180_pci_probe(struct pci_dev *pdev,
goto fail;
}
- //DMESG("Memory mapped space @ 0x%08lx ", pmem_start);
if( ! request_mem_region(pmem_start, pmem_len, RTL8180_MODULE_NAME)) {
DMESG("request_mem_region failed!");
goto fail;
}
-
ioaddr = (unsigned long)ioremap_nocache( pmem_start, pmem_len);
if( ioaddr == (unsigned long)NULL ){
DMESG("ioremap failed!");
- // release_mem_region( pmem_start, pmem_len );
goto fail1;
}
dev->mem_start = ioaddr; // shared mem start
dev->mem_end = ioaddr + pci_resource_len(pdev, 0); // shared mem end
-#endif //end #ifdef RTL_IO_MAP
-
-#ifdef CONFIG_RTL8185B
- //pci_read_config_byte(pdev, 0x05, ptr);
- //pci_write_config_byte(pdev, 0x05, (*ptr) & (~0x04));
pci_read_config_byte(pdev, 0x05, &unit);
pci_write_config_byte(pdev, 0x05, unit & (~0x04));
-#endif
dev->irq = pdev->irq;
priv->irq = 0;
@@ -5950,24 +3917,15 @@ static int __devinit rtl8180_pci_probe(struct pci_dev *pdev,
dev->netdev_ops = &rtl8180_netdev_ops;
dev->wireless_handlers = &r8180_wx_handlers_def;
-#if WIRELESS_EXT >= 12
-#if WIRELESS_EXT < 17
- dev->get_wireless_stats = r8180_get_wireless_stats;
-#endif
- dev->wireless_handlers = (struct iw_handler_def *) &r8180_wx_handlers_def;
-#endif
-
dev->type=ARPHRD_ETHER;
dev->watchdog_timeo = HZ*3; //added by david woo, 2007.12.13
if (dev_alloc_name(dev, ifname) < 0){
DMESG("Oops: devname already taken! Trying wlan%%d...\n");
ifname = "wlan%d";
- // ifname = "ath%d";
dev_alloc_name(dev, ifname);
}
-
if(rtl8180_init(dev)!=0){
DMESG("Initialization failed");
goto fail1;
@@ -5981,28 +3939,14 @@ static int __devinit rtl8180_pci_probe(struct pci_dev *pdev,
DMESG("Driver probe completed\n");
return 0;
-
fail1:
-
-#ifdef CONFIG_RTL8180_IO_MAP
-
- if( dev->base_addr != 0 ){
-
- release_region(dev->base_addr,
- pci_resource_len(pdev, 0) );
- }
-#else
if( dev->mem_start != (unsigned long)NULL ){
iounmap( (void *)dev->mem_start );
release_mem_region( pci_resource_start(pdev, 1),
pci_resource_len(pdev, 1) );
}
-#endif //end #ifdef RTL_IO_MAP
-
-
fail:
if(dev){
-
if (priv->irq) {
free_irq(dev->irq, dev);
dev->irq=0;
@@ -6015,57 +3959,38 @@ fail:
DMESG("wlan driver load failed\n");
pci_set_drvdata(pdev, NULL);
return -ENODEV;
-
}
-
static void __devexit rtl8180_pci_remove(struct pci_dev *pdev)
{
struct r8180_priv *priv;
struct net_device *dev = pci_get_drvdata(pdev);
- if(dev){
+ if (dev) {
unregister_netdev(dev);
- priv=ieee80211_priv(dev);
+ priv = ieee80211_priv(dev);
rtl8180_proc_remove_one(dev);
rtl8180_down(dev);
priv->rf_close(dev);
rtl8180_reset(dev);
- //rtl8180_rtx_disable(dev);
- //rtl8180_irq_disable(dev);
mdelay(10);
- //write_nic_word(dev,INTA,read_nic_word(dev,INTA));
- //force_pci_posting(dev);
- //mdelay(10);
if(priv->irq){
-
DMESG("Freeing irq %d",dev->irq);
free_irq(dev->irq, dev);
priv->irq=0;
-
}
free_rx_desc_ring(dev);
free_tx_desc_rings(dev);
- // free_beacon_desc_ring(dev,priv->txbeaconcount);
-
-#ifdef CONFIG_RTL8180_IO_MAP
- if( dev->base_addr != 0 ){
-
- release_region(dev->base_addr,
- pci_resource_len(pdev, 0) );
- }
-#else
if( dev->mem_start != (unsigned long)NULL ){
iounmap( (void *)dev->mem_start );
release_mem_region( pci_resource_start(pdev, 1),
pci_resource_len(pdev, 1) );
}
-#endif /*end #ifdef RTL_IO_MAP*/
free_ieee80211(dev);
}
@@ -6074,7 +3999,6 @@ static void __devexit rtl8180_pci_remove(struct pci_dev *pdev)
DMESG("wlan driver removed\n");
}
-
/* fun with the built-in ieee80211 stack... */
extern int ieee80211_crypto_init(void);
extern void ieee80211_crypto_deinit(void);
@@ -6117,21 +4041,13 @@ static int __init rtl8180_pci_module_init(void)
DMESG("Wireless extensions version %d", WIRELESS_EXT);
rtl8180_proc_module_init();
-#if(LINUX_VERSION_CODE < KERNEL_VERSION(2,6,22))
- if(0!=pci_module_init(&rtl8180_pci_driver))
-#else
- if(0!=pci_register_driver(&rtl8180_pci_driver))
-#endif
- //if(0!=pci_module_init(&rtl8180_pci_driver))
- {
+ if (pci_register_driver(&rtl8180_pci_driver)) {
DMESG("No device found");
- /*pci_unregister_driver (&rtl8180_pci_driver);*/
return -ENODEV;
}
return 0;
}
-
static void __exit rtl8180_pci_module_exit(void)
{
pci_unregister_driver (&rtl8180_pci_driver);
@@ -6143,7 +4059,6 @@ static void __exit rtl8180_pci_module_exit(void)
DMESG("Exiting");
}
-
void rtl8180_try_wake_queue(struct net_device *dev, int pri)
{
unsigned long flags;
@@ -6158,25 +4073,17 @@ void rtl8180_try_wake_queue(struct net_device *dev, int pri)
ieee80211_wake_queue(priv->ieee80211);
}
-/*****************************************************************************
- -----------------------------IRQ STUFF---------------------------
-******************************************************************************/
-
void rtl8180_tx_isr(struct net_device *dev, int pri,short error)
{
struct r8180_priv *priv = (struct r8180_priv *)ieee80211_priv(dev);
-
u32 *tail; //tail virtual addr
u32 *head; //head virtual addr
u32 *begin;//start of ring virtual addr
u32 *nicv; //nic pointer virtual addr
-// u32 *txdv; //packet just TXed
u32 nic; //nic pointer physical addr
u32 nicbegin;// start of ring physical addr
-// short txed;
unsigned long flag;
/* physical addr are ok on 32 bits since we set DMA mask*/
-
int offs;
int j,i;
int hd;
@@ -6190,7 +4097,6 @@ void rtl8180_tx_isr(struct net_device *dev, int pri,short error)
nic = read_nic_dword(dev,TX_MANAGEPRIORITY_RING_ADDR);
nicbegin = priv->txmapringdma;
break;
-
case BK_PRIORITY:
tail = priv->txbkpringtail;
begin = priv->txbkpring;
@@ -6198,7 +4104,6 @@ void rtl8180_tx_isr(struct net_device *dev, int pri,short error)
nic = read_nic_dword(dev,TX_BKPRIORITY_RING_ADDR);
nicbegin = priv->txbkpringdma;
break;
-
case BE_PRIORITY:
tail = priv->txbepringtail;
begin = priv->txbepring;
@@ -6206,7 +4111,6 @@ void rtl8180_tx_isr(struct net_device *dev, int pri,short error)
nic = read_nic_dword(dev,TX_BEPRIORITY_RING_ADDR);
nicbegin = priv->txbepringdma;
break;
-
case VI_PRIORITY:
tail = priv->txvipringtail;
begin = priv->txvipring;
@@ -6214,7 +4118,6 @@ void rtl8180_tx_isr(struct net_device *dev, int pri,short error)
nic = read_nic_dword(dev,TX_VIPRIORITY_RING_ADDR);
nicbegin = priv->txvipringdma;
break;
-
case VO_PRIORITY:
tail = priv->txvopringtail;
begin = priv->txvopring;
@@ -6222,7 +4125,6 @@ void rtl8180_tx_isr(struct net_device *dev, int pri,short error)
nic = read_nic_dword(dev,TX_VOPRIORITY_RING_ADDR);
nicbegin = priv->txvopringdma;
break;
-
case HI_PRIORITY:
tail = priv->txhpringtail;
begin = priv->txhpring;
@@ -6235,21 +4137,11 @@ void rtl8180_tx_isr(struct net_device *dev, int pri,short error)
spin_unlock_irqrestore(&priv->tx_lock,flag);
return ;
}
-/* DMESG("%x %s %x %x",((int)nic & 0xfff)/8/4,
- *(priv->txnpring + ((int)nic&0xfff)/4/8) & (1<<31) ? "filled" : "empty",
- (priv->txnpringtail - priv->txnpring)/8,(priv->txnpringhead -
-priv->txnpring)/8);
-*/
- //nicv = (u32*) ((nic - nicbegin) + (int)begin);
+
nicv = (u32*) ((nic - nicbegin) + (u8*)begin);
if((head <= tail && (nicv > tail || nicv < head)) ||
(head > tail && (nicv > tail && nicv < head))){
-
DMESGW("nic has lost pointer");
-#ifdef DEBUG_TX_DESC
- //check_tx_ring(dev,NORM_PRIORITY);
- check_tx_ring(dev,pri);
-#endif
spin_unlock_irqrestore(&priv->tx_lock,flag);
rtl8180_restart(dev);
return;
@@ -6259,69 +4151,39 @@ priv->txnpring)/8);
* but not the currenly pointed by the nic (the next to be txed)
* and the previous of the pointed (might be in process ??)
*/
- //if (head == nic) return;
- //DMESG("%x %x",head,nic);
offs = (nic - nicbegin);
- //DMESG("%x %x %x",nic ,(u32)nicbegin, (int)nic -nicbegin);
-
offs = offs / 8 /4;
-
hd = (head - begin) /8;
if(offs >= hd)
j = offs - hd;
else
j = offs + (priv->txringcount -1 -hd);
- // j= priv->txringcount -1- (hd - offs);
j-=2;
if(j<0) j=0;
-
for(i=0;i<j;i++)
{
-// printk("+++++++++++++check status desc\n");
if((*head) & (1<<31))
break;
if(((*head)&(0x10000000)) != 0){
-// printk("++++++++++++++last desc,retry count is %d\n",((*head) & (0x000000ff)));
priv->CurrRetryCnt += (u16)((*head) & (0x000000ff));
-#if 1
- if(!error)
- {
+ if (!error)
priv->NumTxOkTotal++;
-// printk("NumTxOkTotal is %d\n",priv->NumTxOkTotal++);
- }
-#endif
- // printk("in function %s:curr_retry_count is %d\n",__func__,((*head) & (0x000000ff)));
}
- if(!error){
+
+ if (!error)
priv->NumTxOkBytesTotal += (*(head+3)) & (0x00000fff);
- }
-// printk("in function %s:curr_txokbyte_count is %d\n",__func__,(*(head+3)) & (0x00000fff));
+
*head = *head &~ (1<<31);
if((head - begin)/8 == priv->txringcount-1)
head=begin;
-
else
head+=8;
}
-#if 0
- if(nicv == begin)
- txdv = begin + (priv->txringcount -1)*8;
- else
- txdv = nicv - 8;
-
- txed = !(txdv[0] &(1<<31));
- if(txed){
- if(!(txdv[0] & (1<<15))) error = 1;
- //if(!(txdv[0] & (1<<30))) error = 1;
- if(error)DMESG("%x",txdv[0]);
- }
-#endif
- //DMESG("%x",txdv[0]);
/* the head has been moved to the last certainly TXed
* (or at least processed by the nic) packet.
* The driver take forcefully owning of all these packets
@@ -6334,63 +4196,41 @@ priv->txnpring)/8);
switch(pri) {
case MANAGE_PRIORITY:
priv->txmapringhead = head;
- //printk("1==========================================> priority check!\n");
+
if(priv->ack_tx_to_ieee){
- // try to implement power-save mode 2008.1.22
- // printk("2==========================================> priority check!\n");
-#if 1
if(rtl8180_is_tx_queue_empty(dev)){
- // printk("tx queue empty, after send null sleep packet, try to sleep !\n");
priv->ack_tx_to_ieee = 0;
ieee80211_ps_tx_ack(priv->ieee80211,!error);
}
-#endif
}
break;
-
case BK_PRIORITY:
priv->txbkpringhead = head;
break;
-
case BE_PRIORITY:
priv->txbepringhead = head;
break;
-
case VI_PRIORITY:
priv->txvipringhead = head;
break;
-
case VO_PRIORITY:
priv->txvopringhead = head;
break;
-
case HI_PRIORITY:
priv->txhpringhead = head;
break;
}
- /*DMESG("%x %x %x", (priv->txnpringhead - priv->txnpring) /8 ,
- (priv->txnpringtail - priv->txnpring) /8,
- offs );
- */
-
spin_unlock_irqrestore(&priv->tx_lock,flag);
-
}
-#if (LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,20))
void rtl8180_tx_irq_wq(struct work_struct *work)
{
- //struct r8180_priv *priv = container_of(work, struct r8180_priv, reset_wq);
struct delayed_work *dwork = to_delayed_work(work);
struct ieee80211_device * ieee = (struct ieee80211_device*)
container_of(dwork, struct ieee80211_device, watch_dog_wq);
struct net_device *dev = ieee->dev;
-#else
-void rtl8180_tx_irq_wq(struct net_device *dev)
-{
- //struct r8180_priv *priv = ieee80211_priv(dev);
-#endif
+
rtl8180_tx_isr(dev,MANAGE_PRIORITY,0);
}
irqreturn_t rtl8180_interrupt(int irq, void *netdev, struct pt_regs *regs)
@@ -6405,19 +4245,12 @@ irqreturn_t rtl8180_interrupt(int irq, void *netdev, struct pt_regs *regs)
spin_lock_irqsave(&priv->irq_th_lock,flags);
-#ifdef CONFIG_RTL8185B
//ISR: 4bytes
inta = read_nic_dword(dev, ISR);// & priv->IntrMask;
write_nic_dword(dev,ISR,inta); // reset int situation
-#else
- inta = read_nic_word(dev,INTA) & priv->irq_mask;
- write_nic_word(dev,INTA,inta); // reset int situation
-#endif
priv->stats.shints++;
- //DMESG("Enter interrupt, ISR value = 0x%08x", inta);
-
if(!inta){
spin_unlock_irqrestore(&priv->irq_th_lock,flags);
return IRQ_HANDLED;
@@ -6427,60 +4260,38 @@ irqreturn_t rtl8180_interrupt(int irq, void *netdev, struct pt_regs *regs)
*/
}
- if(inta == 0xffff){
- /* HW disappared */
- spin_unlock_irqrestore(&priv->irq_th_lock,flags);
- return IRQ_HANDLED;
+ if (inta == 0xffff) {
+ /* HW disappared */
+ spin_unlock_irqrestore(&priv->irq_th_lock, flags);
+ return IRQ_HANDLED;
}
priv->stats.ints++;
-#ifdef DEBUG_IRQ
- DMESG("NIC irq %x",inta);
-#endif
- //priv->irqpending = inta;
-
if(!netif_running(dev)) {
spin_unlock_irqrestore(&priv->irq_th_lock,flags);
return IRQ_HANDLED;
}
- if(inta & ISR_TimeOut){
+ if (inta & ISR_TimeOut)
write_nic_dword(dev, TimerInt, 0);
- //DMESG("=================>waking up");
-// rtl8180_hw_wakeup(dev);
- }
- if(inta & ISR_TBDOK){
+ if (inta & ISR_TBDOK)
priv->stats.txbeacon++;
- }
- if(inta & ISR_TBDER){
+ if (inta & ISR_TBDER)
priv->stats.txbeaconerr++;
- }
- if(inta & IMR_TMGDOK ) {
-// priv->NumTxOkTotal++;
+ if (inta & IMR_TMGDOK)
rtl8180_tx_isr(dev,MANAGE_PRIORITY,0);
-// schedule_work(&priv->tx_irq_wq);
-
- }
if(inta & ISR_THPDER){
-#ifdef DEBUG_TX
- DMESG ("TX high priority ERR");
-#endif
priv->stats.txhperr++;
rtl8180_tx_isr(dev,HI_PRIORITY,1);
priv->ieee80211->stats.tx_errors++;
}
if(inta & ISR_THPDOK){ //High priority tx ok
-#ifdef DEBUG_TX
- DMESG ("TX high priority OK");
-#endif
-// priv->NumTxOkTotal++;
- //priv->NumTxOkInPeriod++; //YJ,del,080828
priv->link_detect.NumTxOkInPeriod++; //YJ,add,080828
priv->stats.txhpokint++;
rtl8180_tx_isr(dev,HI_PRIORITY,0);
@@ -6488,18 +4299,10 @@ irqreturn_t rtl8180_interrupt(int irq, void *netdev, struct pt_regs *regs)
if(inta & ISR_RER) {
priv->stats.rxerr++;
-#ifdef DEBUG_RX
- DMESGW("RX error int");
-#endif
}
-#ifdef CONFIG_RTL8185B
if(inta & ISR_TBKDER){ //corresponding to BK_PRIORITY
priv->stats.txbkperr++;
priv->ieee80211->stats.tx_errors++;
-#ifdef DEBUG_TX
- DMESGW("TX bkp error int");
-#endif
- //tasklet_schedule(&priv->irq_tx_tasklet);
rtl8180_tx_isr(dev,BK_PRIORITY,1);
rtl8180_try_wake_queue(dev, BE_PRIORITY);
}
@@ -6507,113 +4310,65 @@ irqreturn_t rtl8180_interrupt(int irq, void *netdev, struct pt_regs *regs)
if(inta & ISR_TBEDER){ //corresponding to BE_PRIORITY
priv->stats.txbeperr++;
priv->ieee80211->stats.tx_errors++;
-#ifdef DEBUG_TX
- DMESGW("TX bep error int");
-#endif
rtl8180_tx_isr(dev,BE_PRIORITY,1);
- //tasklet_schedule(&priv->irq_tx_tasklet);
rtl8180_try_wake_queue(dev, BE_PRIORITY);
}
-#endif
if(inta & ISR_TNPDER){ //corresponding to VO_PRIORITY
priv->stats.txnperr++;
priv->ieee80211->stats.tx_errors++;
-#ifdef DEBUG_TX
- DMESGW("TX np error int");
-#endif
- //tasklet_schedule(&priv->irq_tx_tasklet);
rtl8180_tx_isr(dev,NORM_PRIORITY,1);
-#ifdef CONFIG_RTL8185B
rtl8180_try_wake_queue(dev, NORM_PRIORITY);
-#endif
}
if(inta & ISR_TLPDER){ //corresponding to VI_PRIORITY
priv->stats.txlperr++;
priv->ieee80211->stats.tx_errors++;
-#ifdef DEBUG_TX
- DMESGW("TX lp error int");
-#endif
rtl8180_tx_isr(dev,LOW_PRIORITY,1);
- //tasklet_schedule(&priv->irq_tx_tasklet);
rtl8180_try_wake_queue(dev, LOW_PRIORITY);
}
if(inta & ISR_ROK){
-#ifdef DEBUG_RX
- DMESG("Frame arrived !");
-#endif
- //priv->NumRxOkInPeriod++; //YJ,del,080828
priv->stats.rxint++;
tasklet_schedule(&priv->irq_rx_tasklet);
}
if(inta & ISR_RQoSOK ){
-#ifdef DEBUG_RX
- DMESG("QoS Frame arrived !");
-#endif
- //priv->NumRxOkInPeriod++; //YJ,del,080828
priv->stats.rxint++;
tasklet_schedule(&priv->irq_rx_tasklet);
}
if(inta & ISR_BcnInt) {
- //DMESG("Preparing Beacons");
rtl8180_prepare_beacon(dev);
}
if(inta & ISR_RDU){
-//#ifdef DEBUG_RX
DMESGW("No RX descriptor available");
priv->stats.rxrdu++;
-//#endif
tasklet_schedule(&priv->irq_rx_tasklet);
- /*queue_work(priv->workqueue ,&priv->restart_work);*/
-
}
+
if(inta & ISR_RXFOVW){
-#ifdef DEBUG_RX
- DMESGW("RX fifo overflow");
-#endif
priv->stats.rxoverflow++;
tasklet_schedule(&priv->irq_rx_tasklet);
- //queue_work(priv->workqueue ,&priv->restart_work);
}
- if(inta & ISR_TXFOVW) priv->stats.txoverflow++;
+ if (inta & ISR_TXFOVW)
+ priv->stats.txoverflow++;
if(inta & ISR_TNPDOK){ //Normal priority tx ok
-#ifdef DEBUG_TX
- DMESG ("TX normal priority OK");
-#endif
-// priv->NumTxOkTotal++;
- //priv->NumTxOkInPeriod++; //YJ,del,080828
priv->link_detect.NumTxOkInPeriod++; //YJ,add,080828
- // priv->ieee80211->stats.tx_packets++;
priv->stats.txnpokint++;
rtl8180_tx_isr(dev,NORM_PRIORITY,0);
}
if(inta & ISR_TLPDOK){ //Low priority tx ok
-#ifdef DEBUG_TX
- DMESG ("TX low priority OK");
-#endif
-// priv->NumTxOkTotal++;
- //priv->NumTxOkInPeriod++; //YJ,del,080828
priv->link_detect.NumTxOkInPeriod++; //YJ,add,080828
- // priv->ieee80211->stats.tx_packets++;
priv->stats.txlpokint++;
rtl8180_tx_isr(dev,LOW_PRIORITY,0);
rtl8180_try_wake_queue(dev, LOW_PRIORITY);
}
-#ifdef CONFIG_RTL8185B
if(inta & ISR_TBKDOK){ //corresponding to BK_PRIORITY
priv->stats.txbkpokint++;
-#ifdef DEBUG_TX
- DMESGW("TX bk priority ok");
-#endif
-// priv->NumTxOkTotal++;
- //priv->NumTxOkInPeriod++; //YJ,del,080828
priv->link_detect.NumTxOkInPeriod++; //YJ,add,080828
rtl8180_tx_isr(dev,BK_PRIORITY,0);
rtl8180_try_wake_queue(dev, BE_PRIORITY);
@@ -6621,63 +4376,26 @@ irqreturn_t rtl8180_interrupt(int irq, void *netdev, struct pt_regs *regs)
if(inta & ISR_TBEDOK){ //corresponding to BE_PRIORITY
priv->stats.txbeperr++;
-#ifdef DEBUG_TX
- DMESGW("TX be priority ok");
-#endif
-// priv->NumTxOkTotal++;
- //priv->NumTxOkInPeriod++; //YJ,del,080828
priv->link_detect.NumTxOkInPeriod++; //YJ,add,080828
rtl8180_tx_isr(dev,BE_PRIORITY,0);
rtl8180_try_wake_queue(dev, BE_PRIORITY);
}
-#endif
force_pci_posting(dev);
spin_unlock_irqrestore(&priv->irq_th_lock,flags);
return IRQ_HANDLED;
}
-
void rtl8180_irq_rx_tasklet(struct r8180_priv* priv)
{
-// unsigned long flags;
-
-/* spin_lock_irqsave(&priv->irq_lock, flags);
- priv->irq_mask &=~IMR_ROK;
- priv->irq_mask &=~IMR_RDU;
-
- rtl8180_irq_enable(priv->dev);
- spin_unlock_irqrestore(&priv->irq_lock, flags);
-*/
rtl8180_rx(priv->dev);
-
-/* spin_lock_irqsave(&priv->irq_lock, flags);
- priv->irq_mask |= IMR_ROK;
- priv->irq_mask |= IMR_RDU;
- rtl8180_irq_enable(priv->dev);
- spin_unlock_irqrestore(&priv->irq_lock, flags);
-*/
}
-/****************************************************************************
-lizhaoming--------------------------- RF power on/power off -----------------
-*****************************************************************************/
-
-#if (LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,20))
void GPIOChangeRFWorkItemCallBack(struct work_struct *work)
{
- //struct delayed_work *dwork = to_delayed_work(work);
struct ieee80211_device *ieee = container_of(work, struct ieee80211_device, GPIOChangeRFWorkItem.work);
struct net_device *dev = ieee->dev;
struct r8180_priv *priv = ieee80211_priv(dev);
-#else
-void GPIOChangeRFWorkItemCallBack(struct ieee80211_device *ieee)
-{
- struct net_device *dev = ieee->dev;
- struct r8180_priv *priv = ieee80211_priv(dev);
-#endif
-
- //u16 tmp2byte;
u8 btPSR;
u8 btConfig0;
RT_RF_POWER_STATE eRfPowerStateToSet;
@@ -6687,7 +4405,6 @@ void GPIOChangeRFWorkItemCallBack(struct ieee80211_device *ieee)
static char *RadioPowerPath = "/etc/acpi/events/RadioPower.sh";
static char *envp[] = {"HOME=/", "TERM=linux", "PATH=/usr/bin:/bin", NULL};
static int readf_count = 0;
- //printk("============>%s in \n", __func__);
#ifdef ENABLE_LPS
if(readf_count % 10 == 0)
@@ -6695,14 +4412,6 @@ void GPIOChangeRFWorkItemCallBack(struct ieee80211_device *ieee)
readf_count = (readf_count+1)%0xffff;
#endif
-#if 0
- if(priv->up == 0)//driver stopped
- {
- printk("\nDo nothing...");
- goto out;
- }
- else
-#endif
{
// We should turn off LED before polling FF51[4].
@@ -6750,54 +4459,13 @@ void GPIOChangeRFWorkItemCallBack(struct ieee80211_device *ieee)
call_usermodehelper(RadioPowerPath,argv,envp,1);
}
-
}
-
}
static u8 read_acadapter_file(char *filename)
{
-//#if (LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,21))
-#if 0
- int fd;
- char buf[1];
- char ret[50];
- int i = 0;
- int n = 0;
- mm_segment_t old_fs = get_fs();
- set_fs(KERNEL_DS);
-
- fd = sys_open(filename, O_RDONLY, 0);
- if (fd >= 0) {
- while (sys_read(fd, buf, 1) == 1)
- {
- i++;
- if(i>10)
- {
- if(buf[0]!=' ')
- {
- ret[n]=buf[0];
- n++;
- }
- }
- }
- sys_close(fd);
- }
- ret[n]='\0';
-// printk("%s \n", ret);
- set_fs(old_fs);
-
- if(strncmp(ret, "off-line",8) == 0)
- {
- return 1;
- }
-#endif
return 0;
}
-/***************************************************************************
- ------------------- module init / exit stubs ----------------
-****************************************************************************/
module_init(rtl8180_pci_module_init);
module_exit(rtl8180_pci_module_exit);
-
diff --git a/drivers/staging/rtl8187se/r8180_dm.c b/drivers/staging/rtl8187se/r8180_dm.c
index e772f0f6b67c..b6eeeeccff9e 100644
--- a/drivers/staging/rtl8187se/r8180_dm.c
+++ b/drivers/staging/rtl8187se/r8180_dm.c
@@ -126,7 +126,6 @@ DoTxHighPower(
// Because of some event happend, e.g. CCX TPC, High Power Mechanism,
// We update Tx power of current channel again.
//
-#if (LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,20))
void rtl8180_tx_pw_wq (struct work_struct *work)
{
// struct r8180_priv *priv = container_of(work, struct r8180_priv, watch_dog_wq);
@@ -135,11 +134,6 @@ void rtl8180_tx_pw_wq (struct work_struct *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
-void rtl8180_tx_pw_wq(struct net_device *dev)
-{
- // struct r8180_priv *priv = ieee80211_priv(dev);
-#endif
// printk("----> UpdateTxPowerWorkItemCallback()\n");
@@ -308,7 +302,6 @@ DynamicInitGain(
}
}
-#if (LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,20))
void rtl8180_hw_dig_wq (struct work_struct *work)
{
// struct r8180_priv *priv = container_of(work, struct r8180_priv, watch_dog_wq);
@@ -317,11 +310,6 @@ void rtl8180_hw_dig_wq (struct work_struct *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
-void rtl8180_hw_dig_wq(struct net_device *dev)
-{
-
-#endif
struct r8180_priv *priv = ieee80211_priv(dev);
// Read CCK and OFDM False Alarm.
@@ -529,7 +517,6 @@ MgntIsCckRate(
return bReturn;
}
-#ifdef CONFIG_RTL818X_S
//
// Description:
// Tx Power tracking mechanism routine on 87SE.
@@ -1246,18 +1233,11 @@ SetInitialGain:
priv->ieee80211->rate = priv->CurrentOperaRate * 5;
}
-#endif
-#if LINUX_VERSION_CODE >=KERNEL_VERSION(2,6,20)
void rtl8180_rate_adapter(struct work_struct * 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
-void rtl8180_rate_adapter(struct net_device *dev)
-{
-
-#endif
//struct r8180_priv *priv = ieee80211_priv(dev);
// DMESG("---->rtl8180_rate_adapter");
StaRateAdaptive87SE(dev);
@@ -1277,10 +1257,8 @@ void timer_rate_adaptive(unsigned long data)
(priv->ForcedDataRate == 0) )
{
// DMESG("timer_rate_adaptive():schedule rate_adapter_wq\n");
-#ifdef CONFIG_RTL818X_S
queue_work(priv->ieee80211->wq, (void *)&priv->ieee80211->rate_adapter_wq);
// StaRateAdaptive87SE((struct net_device *)data);
-#endif
}
priv->rateadapter_timer.expires = jiffies + MSECS(priv->RateAdaptivePeriod);
add_timer(&priv->rateadapter_timer);
@@ -1337,22 +1315,12 @@ SetAntenna8185(
{
case RF_ZEBRA2:
case RF_ZEBRA4:
-#ifdef CONFIG_RTL8185B
-#ifdef CONFIG_RTL818X_S
// Mac register, main antenna
write_nic_byte(dev, ANTSEL, 0x03);
//base band
write_phy_cck(dev,0x11, 0x9b); // Config CCK RX antenna.
write_phy_ofdm(dev, 0x0d, 0x5c); // Config OFDM RX antenna.
-#else
- // Mac register, main antenna
- write_nic_byte(dev, ANTSEL, 0x03);
- //base band
- write_phy_cck(dev, 0x10, 0x9b); // Config CCK RX antenna.
- write_phy_ofdm(dev, 0x0d, 0x5c); // Config OFDM RX antenna.
-#endif
-#endif
bAntennaSwitched = true;
break;
@@ -1368,21 +1336,11 @@ SetAntenna8185(
{
case RF_ZEBRA2:
case RF_ZEBRA4:
-#ifdef CONFIG_RTL8185B
-#ifdef CONFIG_RTL818X_S
// Mac register, aux antenna
write_nic_byte(dev, ANTSEL, 0x00);
//base band
write_phy_cck(dev, 0x11, 0xbb); // Config CCK RX antenna.
write_phy_ofdm(dev, 0x0d, 0x54); // Config OFDM RX antenna.
-#else
- // Mac register, aux antenna
- write_nic_byte(dev, ANTSEL, 0x00);
- //base band
- write_phy_cck(dev, 0x10, 0xbb); // Config CCK RX antenna.
- write_phy_ofdm(dev, 0x0d, 0x54); // Config OFDM RX antenna.
-#endif
-#endif
bAntennaSwitched = true;
break;
@@ -1422,14 +1380,6 @@ SwitchAntenna(
if(priv->CurrAntennaIndex == 0)
{
-#if 0//lzm del 080826
-//by amy 080312
-#ifdef CONFIG_RTL818X_S
- if(priv->bSwAntennaDiverity)
- bResult = SetAntennaConfig87SE(dev, 1, true);
- else
-#endif
-#endif
bResult = SetAntenna8185(dev, 1);
//by amy 080312
// printk("SwitchAntenna(): switching to antenna 1 ......\n");
@@ -1437,14 +1387,6 @@ SwitchAntenna(
}
else
{
-#if 0//lzm del 080826
-//by amy 080312
-#ifdef CONFIG_RTL818X_S
- if(priv->bSwAntennaDiverity)
- bResult = SetAntennaConfig87SE(dev, 0, true);
- else
-#endif
-#endif
bResult = SetAntenna8185(dev, 0);
//by amy 080312
// printk("SwitchAntenna(): switching to antenna 0 ......\n");
diff --git a/drivers/staging/rtl8187se/r8180_dm.h b/drivers/staging/rtl8187se/r8180_dm.h
index b2736c8e521d..84f46728c3de 100644
--- a/drivers/staging/rtl8187se/r8180_dm.h
+++ b/drivers/staging/rtl8187se/r8180_dm.h
@@ -11,30 +11,12 @@ void SwAntennaDiversity(struct net_device *dev );
void SwAntennaDiversityTimerCallback(struct net_device *dev);
bool CheckDig(struct net_device *dev);
bool CheckHighPower(struct net_device *dev);
-#if (LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,20))
void rtl8180_hw_dig_wq (struct work_struct *work);
-#else
-void rtl8180_hw_dig_wq(struct net_device *dev);
-#endif
-#if (LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,20))
void rtl8180_tx_pw_wq (struct work_struct *work);
-#else
-void rtl8180_tx_pw_wq(struct net_device *dev);
-#endif
-#if LINUX_VERSION_CODE >=KERNEL_VERSION(2,6,20)
void rtl8180_rate_adapter(struct work_struct * work);
-
-#else
-void rtl8180_rate_adapter(struct net_device *dev);
-
-#endif
void TxPwrTracking87SE(struct net_device *dev);
bool CheckTxPwrTracking(struct net_device *dev);
-#if LINUX_VERSION_CODE >=KERNEL_VERSION(2,6,20)
void rtl8180_rate_adapter(struct work_struct * work);
-#else
-void rtl8180_rate_adapter(struct net_device *dev);
-#endif
void timer_rate_adaptive(unsigned long data);
diff --git a/drivers/staging/rtl8187se/r8180_gct.c b/drivers/staging/rtl8187se/r8180_gct.c
deleted file mode 100644
index 86cb427a7a40..000000000000
--- a/drivers/staging/rtl8187se/r8180_gct.c
+++ /dev/null
@@ -1,296 +0,0 @@
-/*
- This files contains GCT radio frontend programming routines.
-
- 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.
-
- Code from Rtw8180 NetBSD driver by David Young has been really useful to
- understand some things and gets some ideas
-
- Code from rtl8181 project has been useful to me to understand some things.
-
- Some code from 'Deuce' work
-
- We want to tanks the Authors of such projects and the Ndiswrapper
- project Authors.
-*/
-
-
-#include "r8180.h"
-#include "r8180_hw.h"
-#include "r8180_gct.h"
-
-
-//#define DEBUG_GCT
-
-/* the following experiment are just experiments.
- * this means if you enable them you can have every kind
- * of result, included damage the RF chip, so don't
- * touch them if you don't know what you are doing.
- * In any case, if you do it, do at your own risk
- */
-
-//#define GCT_EXPERIMENT1 //improve RX sensivity
-
-//#define GCT_EXPERIMENT2
-
-//#define GCT_EXPERIMENT3 //iprove a bit RX signal quality ?
-
-//#define GCT_EXPERIMENT4 //maybe solve some brokeness with experiment1 ?
-
-//#define GCT_EXPERIMENT5
-
-//#define GCT_EXPERIMENT6 //not good
-
-
-u32 gct_chan[] = {
- 0x0, //dummy channel 0
- 0x0, //1
- 0x1, //2
- 0x2, //3
- 0x3, //4
- 0x4, //5
- 0x5, //6
- 0x6, //7
- 0x7, //8
- 0x8, //9
- 0x9, //10
- 0xa, //11
- 0xb, //12
- 0xc, //13
- 0xd, //14
-};
-
-int gct_encode[16] = {
- 0, 8, 4, 0xC,
- 2, 0xA, 6, 0xE,
- 1, 9, 5, 0xD,
- 3, 0xB, 7, 0xF
-};
-
-void gct_rf_stabilize(struct net_device *dev)
-{
- force_pci_posting(dev);
- mdelay(3); //for now use a great value.. we may optimize in future
-}
-
-
-void write_gct(struct net_device *dev, u8 adr, u32 data)
-{
-// struct r8180_priv *priv = ieee80211_priv(dev);
- u32 phy_config;
-
- phy_config = gct_encode[(data & 0xf00) >> 8];
- phy_config |= gct_encode[(data & 0xf0) >> 4 ] << 4;
- phy_config |= gct_encode[(data & 0xf) ] << 8;
- phy_config |= gct_encode[(adr >> 1) & 0xf ] << 12;
- phy_config |= (adr & 1 ) << 16;
- phy_config |= gct_encode[(data & 0xf000)>>12] << 24;
-
- phy_config |= 0x90000000; // MAC will bang bits to the chip
-
-
- write_nic_dword(dev,PHY_CONFIG,phy_config);
-#ifdef DEBUG_GCT
- DMESG("Writing GCT: %x (adr %x)",phy_config,adr);
-#endif
- gct_rf_stabilize(dev);
-}
-
-
-
-void gct_write_phy_antenna(struct net_device *dev,short ch)
-{
- struct r8180_priv *priv = ieee80211_priv(dev);
- u8 ant;
-
- ant = GCT_ANTENNA;
- if(priv->antb) /*default antenna is antenna B */
- ant |= BB_ANTENNA_B;
- if(ch == 14)
- ant |= BB_ANTATTEN_CHAN14;
- write_phy(dev,0x10,ant);
- //DMESG("BB antenna %x ",ant);
-}
-
-
-void gct_rf_set_chan(struct net_device *dev, short ch)
-{
- struct r8180_priv *priv = ieee80211_priv(dev);
- u32 txpw = 0xff & priv->chtxpwr[ch];
- u32 chan = gct_chan[ch];
-
- //write_phy(dev,3,txpw);
-#ifdef DEBUG_GCT
- DMESG("Gct set channel");
-#endif
- /* set TX power */
- write_gct(dev,0x15,0);
- write_gct(dev,6, txpw);
- write_gct(dev,0x15, 0x10);
- write_gct(dev,0x15,0);
-
- /*set frequency*/
- write_gct(dev,7, 0);
- write_gct(dev,0xB, chan);
- write_gct(dev,7, 0x1000);
-
-#ifdef DEBUG_GCT
- DMESG("Gct set channel > write phy antenna");
-#endif
-
-
- gct_write_phy_antenna(dev,ch);
-
-}
-
-
-void gct_rf_close(struct net_device *dev)
-{
- u32 anaparam;
-
- anaparam = read_nic_dword(dev,ANAPARAM);
- anaparam &= 0x000fffff;
- anaparam |= 0x3f900000;
- rtl8180_set_anaparam(dev, anaparam);
-
- write_gct(dev, 0x7, 0);
- write_gct(dev, 0x1f, 0x45);
- write_gct(dev, 0x1f, 0x5);
- write_gct(dev, 0x0, 0x8e4);
-}
-
-
-void gct_rf_init(struct net_device *dev)
-{
- struct r8180_priv *priv = ieee80211_priv(dev);
- //u32 anaparam;
-
-
- write_nic_byte(dev,PHY_DELAY,0x6); //this is general
- write_nic_byte(dev,CARRIER_SENSE_COUNTER,0x4c); //this is general
-
- //DMESG("%x", read_nic_dword(dev,ANAPARAM));
- /* we should set anaparm here*/
- //rtl8180_set_anaparam(dev,anaparam);
-
- write_gct(dev,0x1f,0);
- write_gct(dev,0x1f,0);
- write_gct(dev,0x1f,0x40);
- write_gct(dev,0x1f,0x60);
- write_gct(dev,0x1f,0x61);
- write_gct(dev,0x1f,0x61);
- write_gct(dev,0x0,0xae4);
- write_gct(dev,0x1f,0x1);
- write_gct(dev,0x1f,0x41);
- write_gct(dev,0x1f,0x61);
- write_gct(dev,0x1,0x1a23);
- write_gct(dev,0x2,0x4971);
- write_gct(dev,0x3,0x41de);
- write_gct(dev,0x4,0x2d80);
-#ifdef GCT_EXPERIMENT1
- //write_gct(dev,0x5,0x6810); // from zydas driver. sens+ but quite slow
- //write_gct(dev,0x5,0x681f); //good+ (somewhat stable, better sens, performance decent)
- write_gct(dev,0x5,0x685f); //good performances, not sure sens is really so beeter
- //write_gct(dev,0x5,0x687f); //good performances, maybe sens is not improved
- //write_gct(dev,0x5,0x689f); //like above
- //write_gct(dev,0x5,0x685e); //bad
- //write_gct(dev,0x5,0x68ff); //good+ (somewhat stable, better sens(?), performance decent)
- //write_gct(dev,0x5,0x68f0); //bad
- //write_gct(dev,0x5,0x6cff); //sens+ but not so good
- //write_gct(dev,0x5,0x6dff); //sens+,apparentely very good but broken
- //write_gct(dev,0x5,0x65ff); //sens+,good
- //write_gct(dev,0x5,0x78ff); //sens + but almost broken
- //write_gct(dev,0x5,0x7810); //- //snes + but broken
- //write_gct(dev,0x5,0x781f); //-- //sens +
- //write_gct(dev,0x5,0x78f0); //low sens
-#else
- write_gct(dev,0x5,0x61ff); //best performance but weak sensitivity
-#endif
-#ifdef GCT_EXPERIMENT2
- write_gct(dev,0x6,0xe);
-#else
- write_gct(dev,0x6,0x0);
-#endif
- write_gct(dev,0x7,0x0);
- write_gct(dev,0x8,0x7533);
- write_gct(dev,0x9,0xc401);
- write_gct(dev,0xa,0x0);
- write_gct(dev,0xc,0x1c7);
- write_gct(dev,0xd,0x29d3);
- write_gct(dev,0xe,0x2e8);
- write_gct(dev,0x10,0x192);
-#ifdef GCT_EXPERIMENT3
- write_gct(dev,0x11,0x246);
-#else
- write_gct(dev,0x11,0x248);
-#endif
- write_gct(dev,0x12,0x0);
- write_gct(dev,0x13,0x20c4);
-#ifdef GCT_EXPERIMENT4
- write_gct(dev,0x14,0xf488);
-#else
- write_gct(dev,0x14,0xf4fc);
-#endif
-#ifdef GCT_EXPERIMENT5
- write_gct(dev,0x15,0xb152);
-#else
- write_gct(dev,0x15,0x0);
-#endif
-#ifdef GCT_EXPERIMENT6
- write_gct(dev,0x1e,0x1);
-#endif
- write_gct(dev,0x16,0x1500);
-
- write_gct(dev,0x7,0x1000);
- /*write_gct(dev,0x15,0x0);
- write_gct(dev,0x6,0x15);
- write_gct(dev,0x15,0x8);
- write_gct(dev,0x15,0x0);
-*/
- write_phy(dev,0,0xa8);
-
-/* write_gct(dev,0x15,0x0);
- write_gct(dev,0x6,0x12);
- write_gct(dev,0x15,0x8);
- write_gct(dev,0x15,0x0);
-*/
- write_phy(dev,3,0x0);
- write_phy(dev,4,0xc0); /* lna det*/
- write_phy(dev,5,0x90);
- write_phy(dev,6,0x1e);
- write_phy(dev,7,0x64);
-
-#ifdef DEBUG_GCT
- DMESG("Gct init> write phy antenna");
-#endif
-
- gct_write_phy_antenna(dev,priv->chan);
-
- write_phy(dev,0x11,0x88);
- if(!priv->diversity)
- write_phy(dev,0x12,0xc0);
- else
- write_phy(dev,0x12,0x40);
-
- write_phy(dev,0x13,0x90 | priv->cs_treshold );
-
- write_phy(dev,0x19,0x0);
- write_phy(dev,0x1a,0xa0);
- write_phy(dev,0x1b,0x44);
-
-#ifdef DEBUG_GCT
- DMESG("Gct init > set channel2");
-#endif
-
- gct_rf_set_chan(dev,priv->chan);
-}
diff --git a/drivers/staging/rtl8187se/r8180_gct.h b/drivers/staging/rtl8187se/r8180_gct.h
deleted file mode 100644
index fe965ca64304..000000000000
--- a/drivers/staging/rtl8187se/r8180_gct.h
+++ /dev/null
@@ -1,25 +0,0 @@
-/*
- This is part of rtl8180 OpenSource driver - v 0.20
- 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.
-*/
-
-#define GCT_ANTENNA 0xA3
-
-
-// we use the untouched eeprom value- cross your finger ;-)
-#define GCT_ANAPARAM_PWR1_ON ??
-#define GCT_ANAPARAM_PWR0_ON ??
-
-
-
-void gct_rf_init(struct net_device *dev);
-void gct_rf_set_chan(struct net_device *dev,short ch);
-
-void gct_rf_close(struct net_device *dev);
diff --git a/drivers/staging/rtl8187se/r8180_hw.h b/drivers/staging/rtl8187se/r8180_hw.h
index bf38934bc090..db296911ec77 100644
--- a/drivers/staging/rtl8187se/r8180_hw.h
+++ b/drivers/staging/rtl8187se/r8180_hw.h
@@ -20,8 +20,6 @@
#ifndef R8180_HW
#define R8180_HW
-#define CONFIG_RTL8185B //support for rtl8185B, xiong-2006-11-15
-#define CONFIG_RTL818X_S
#define BIT0 0x00000001
#define BIT1 0x00000002
@@ -31,18 +29,10 @@
#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
@@ -59,29 +49,14 @@
#define MAX_SLEEP_TIME (10000)
#define MIN_SLEEP_TIME (50)
-#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_DATA 1
-
-#define ANAPARAM_TXDACOFF_SHIFT 27
-#define ANAPARAM_PWR0_MASK ((1<<30)|(1<<29)|(1<<28))
-#define ANAPARAM_PWR0_SHIFT 28
-#define ANAPARAM_PWR1_MASK ((1<<26)|(1<<25)|(1<<24)|(1<<23)|(1<<22)|(1<<21)|(1<<20))
-#define ANAPARAM_PWR1_SHIFT 20
#define MAC0 0
-#define MAC1 1
-#define MAC2 2
-#define MAC3 3
#define MAC4 4
-#define MAC5 5
+
#define CMD 0x37
#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
@@ -98,13 +73,9 @@
#define EPROM_W_SHIFT 1
#define EPROM_R_SHIFT 0
#define CONFIG2_DMA_POLLING_MODE_SHIFT 3
-#define INTA 0x3e
+
#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)
@@ -113,9 +84,9 @@
#define INTA_RXDESCERR (1<<4)
#define INTA_LOWPRIORITYDESCERR (1<<3)
#define INTA_LOWPRIORITYDESCOK (1<<2)
-#define INTA_RXCRCERR (1<<1)
#define INTA_RXOK (1)
#define INTA_MASK 0x3c
+
#define RXRING_ADDR 0xe4 // page 0
#define PGSELECT 0x5e
#define PGSELECT_PG_SHIFT 0
@@ -133,20 +104,15 @@
#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 EPROM_TYPE_SHIFT 6
+
#define TX_CONF 0x40
#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))
@@ -160,21 +126,12 @@
#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
#define TX_MANAGEPRIORITY_RING_ADDR 0x0C
#define TX_BKPRIORITY_RING_ADDR 0x10
#define TX_BEPRIORITY_RING_ADDR 0x14
#define TX_VIPRIORITY_RING_ADDR 0x20
#define TX_VOPRIORITY_RING_ADDR 0x24
#define TX_HIGHPRIORITY_RING_ADDR 0x28
-//AC_VI and Low priority share the sane queue
-#define TX_LOWPRIORITY_RING_ADDR TX_VIPRIORITY_RING_ADDR
-//AC_VO and Norm priority share the same queue
-#define TX_NORMPRIORITY_RING_ADDR TX_VOPRIORITY_RING_ADDR
-
#define MAX_RX_DMA_MASK ((1<<8) | (1<<9) | (1<<10))
#define MAX_RX_DMA_2048 7
#define MAX_RX_DMA_1024 6
@@ -191,11 +148,7 @@
#define ATIM 0x72
#define EPROM_CS_SHIFT 3
#define EPROM_CK_SHIFT 2
-#define PHY_DELAY 0x78
-#define PHY_CONFIG 0x80
#define PHY_ADR 0x7c
-#define PHY_READ 0x7e
-#define CARRIER_SENSE_COUNTER 0x79 //byte
#define SECURITY 0x5f //1209 this is sth wrong
#define SECURITY_WEP_TX_ENABLE_SHIFT 1
#define SECURITY_WEP_RX_ENABLE_SHIFT 0
@@ -216,91 +169,38 @@
* RealTek names are used.
*/
-#define IDR0 0x0000
-#define IDR1 0x0001
-#define IDR2 0x0002
-#define IDR3 0x0003
-#define IDR4 0x0004
-#define IDR5 0x0005
-
-/* 0x0006 - 0x0007 - reserved */
-
-#define MAR0 0x0008
-#define MAR1 0x0009
-#define MAR2 0x000A
-#define MAR3 0x000B
-#define MAR4 0x000C
-#define MAR5 0x000D
-#define MAR6 0x000E
-#define MAR7 0x000F
-
-/* 0x0010 - 0x0017 - reserved */
-
#define TSFTR 0x0018
-#define TSFTR_END 0x001F
#define TLPDA 0x0020
-#define TLPDA_END 0x0023
-#define TNPDA 0x0024
-#define TNPDA_END 0x0027
-#define THPDA 0x0028
-#define THPDA_END 0x002B
#define BSSID 0x002E
-#define BSSID_END 0x0033
#define CR 0x0037
-#ifdef CONFIG_RTL8185B
#define RF_SW_CONFIG 0x8 // store data which is transmitted to RF for driver
#define RF_SW_CFG_SI BIT1
-#define PIFS 0x2C // PCF InterFrame Spacing Timer Setting.
#define EIFS 0x2D // Extended InterFrame Space Timer, in unit of 4 us.
#define BRSR 0x34 // Basic rate set
#define IMR 0x006C
#define ISR 0x003C
-#else
-#define BRSR 0x002C
-#define BRSR_END 0x002D
-
-/* 0x0034 - 0x0034 - reserved */
-#define EIFS 0x0035
-
-#define IMR 0x003C
-#define IMR_END 0x003D
-#define ISR 0x003E
-#define ISR_END 0x003F
-#endif
#define TCR 0x0040
-#define TCR_END 0x0043
#define RCR 0x0044
-#define RCR_END 0x0047
#define TimerInt 0x0048
-#define TimerInt_END 0x004B
-
-#define TBDA 0x004C
-#define TBDA_END 0x004F
#define CR9346 0x0050
#define CONFIG0 0x0051
-#define CONFIG1 0x0052
#define CONFIG2 0x0053
-#define ANA_PARM 0x0054
-#define ANA_PARM_END 0x0x0057
-
#define MSR 0x0058
#define CONFIG3 0x0059
#define CONFIG4 0x005A
-#ifdef CONFIG_RTL8185B
-#ifdef CONFIG_RTL818X_S
// SD3 szuyitasi: Mac0x57= CC -> B0 Mac0x60= D1 -> C6
// Mac0x60 = 0x000004C6 power save parameters
#define ANAPARM_ASIC_ON 0xB0054D00
@@ -308,49 +208,20 @@
#define ANAPARM_ON ANAPARM_ASIC_ON
#define ANAPARM2_ON ANAPARM2_ASIC_ON
-#else
- // SD3 CMLin:
- #define ANAPARM_ASIC_ON 0x45090658
- #define ANAPARM2_ASIC_ON 0x727f3f52
-
- #define ANAPARM_ON ANAPARM_ASIC_ON
- #define ANAPARM2_ON ANAPARM2_ASIC_ON
-#endif
-#endif
#define TESTR 0x005B
-/* 0x005C - 0x005D - reserved */
-
#define PSR 0x005E
-/* 0x0060 - 0x006F - reserved */
-
#define BcnItv 0x0070
-#define BcnItv_END 0x0071
#define AtimWnd 0x0072
-#define AtimWnd_END 0x0073
#define BintrItv 0x0074
-#define BintrItv_END 0x0075
-
-#define AtimtrItv 0x0076
-#define AtimtrItv_END 0x0077
-
-#define PhyDelay 0x0078
-
-#define CRCount 0x0079
-
-/* 0x007A - 0x007B - reserved */
#define PhyAddr 0x007C
-#define PhyDataW 0x007D
#define PhyDataR 0x007E
-#define PhyCFG 0x0080
-#define PhyCFG_END 0x0083
-
/* following are for rtl8185 */
#define RFPinsOutput 0x80
#define RFPinsEnable 0x82
@@ -382,108 +253,12 @@
#define MAX_RESP_RATE_SHIFT 4
#define MIN_RESP_RATE_SHIFT 0
#define RATE_FALLBACK 0xbe
-/*
- * 0x0084 - 0x00D3 is selected to page 1 when PSEn bit (bit0, PSR)
- * is set to 1
- */
-
-#define Wakeup0 0x0084
-#define Wakeup0_END 0x008B
-
-#define Wakeup1 0x008C
-#define Wakeup1_END 0x0093
-
-#define Wakeup2LD 0x0094
-#define Wakeup2LD_END 0x009B
-#define Wakeup2HD 0x009C
-#define Wakeup2HD_END 0x00A3
-
-#define Wakeup3LD 0x00A4
-#define Wakeup3LD_END 0x00AB
-#define Wakeup3HD 0x00AC
-#define Wakeup3HD_END 0x00B3
-
-#define Wakeup4LD 0x00B4
-#define Wakeup4LD_END 0x00BB
-#define Wakeup4HD 0x00BC
-#define Wakeup4HD_END 0x00C3
-
-#define CRC0 0x00C4
-#define CRC0_END 0x00C5
-#define CRC1 0x00C6
-#define CRC1_END 0x00C7
-#define CRC2 0x00C8
-#define CRC2_END 0x00C9
-#define CRC3 0x00CA
-#define CRC3_END 0x00CB
-#define CRC4 0x00CC
-#define CRC4_END 0x00CD
-
-/* 0x00CE - 0x00D3 - reserved */
-
-
-
-/*
- * 0x0084 - 0x00D3 is selected to page 0 when PSEn bit (bit0, PSR)
- * is set to 0
- */
-
-/* 0x0084 - 0x008F - reserved */
-
-#define DK0 0x0090
-#define DK0_END 0x009F
-#define DK1 0x00A0
-#define DK1_END 0x00AF
-#define DK2 0x00B0
-#define DK2_END 0x00BF
-#define DK3 0x00C0
-#define DK3_END 0x00CF
-
-/* 0x00D0 - 0x00D3 - reserved */
-
-
-
-
-
-/* 0x00D4 - 0x00D7 - reserved */
#define CONFIG5 0x00D8
-#define TPPoll 0x00D9
-
-/* 0x00DA - 0x00DB - reserved */
-
-#ifdef CONFIG_RTL818X_S
#define PHYPR 0xDA //0xDA - 0x0B PHY Parameter Register.
-#endif
-
-#define CWR 0x00DC
-#define CWR_END 0x00DD
-
-#define RetryCTR 0x00DE
-
-/* 0x00DF - 0x00E3 - reserved */
-
-#define RDSAR 0x00E4
-#define RDSAR_END 0x00E7
-/* 0x00E8 - 0x00EF - reserved */
-#ifdef CONFIG_RTL818X_S
-#define LED_CONTROL 0xED
-#endif
-
-#define FER 0x00F0
-#define FER_END 0x00F3
-
-#ifdef CONFIG_RTL8185B
#define FEMR 0x1D4 // Function Event Mask register
-#else
-#define FEMR 0x00F4
-#define FEMR_END 0x00F7
-#endif
-
-#define FPSR 0x00F8
-#define FPSR_END 0x00FB
#define FFER 0x00FC
#define FFER_END 0x00FF
@@ -510,7 +285,6 @@
#define CR_TE ((1<< 2))
#define CR_MulRW ((1<< 0))
-#ifdef CONFIG_RTL8185B
#define IMR_Dot11hInt ((1<< 25)) // 802.11h Measurement Interrupt
#define IMR_BcnDmaInt ((1<< 24)) // Beacon DMA Interrupt // What differenct between BcnDmaInt and BcnInt???
#define IMR_WakeInt ((1<< 23)) // Wake Up Interrupt
@@ -573,49 +347,12 @@
#define ISR_TimeOut ISR_TimeOut1
#define ISR_RXFOVW ISR_FOVW
-#else
-#define IMR_TXFOVW ((1<<15))
-#define IMR_TimeOut ((1<<14))
-#define IMR_BcnInt ((1<<13))
-#define IMR_ATIMInt ((1<<12))
-#define IMR_TBDER ((1<<11))
-#define IMR_TBDOK ((1<<10))
-#define IMR_THPDER ((1<< 9))
-#define IMR_THPDOK ((1<< 8))
-#define IMR_TNPDER ((1<< 7))
-#define IMR_TNPDOK ((1<< 6))
-#define IMR_RXFOVW ((1<< 5))
-#define IMR_RDU ((1<< 4))
-#define IMR_TLPDER ((1<< 3))
-#define IMR_TLPDOK ((1<< 2))
-#define IMR_RER ((1<< 1))
-#define IMR_ROK ((1<< 0))
-
-#define ISR_TXFOVW ((1<<15))
-#define ISR_TimeOut ((1<<14))
-#define ISR_BcnInt ((1<<13))
-#define ISR_ATIMInt ((1<<12))
-#define ISR_TBDER ((1<<11))
-#define ISR_TBDOK ((1<<10))
-#define ISR_THPDER ((1<< 9))
-#define ISR_THPDOK ((1<< 8))
-#define ISR_TNPDER ((1<< 7))
-#define ISR_TNPDOK ((1<< 6))
-#define ISR_RXFOVW ((1<< 5))
-#define ISR_RDU ((1<< 4))
-#define ISR_TLPDER ((1<< 3))
-#define ISR_TLPDOK ((1<< 2))
-#define ISR_RER ((1<< 1))
-#define ISR_ROK ((1<< 0))
-#endif
#define HW_VERID_R8180_F 3
#define HW_VERID_R8180_ABCD 2
#define HW_VERID_R8185_ABC 4
#define HW_VERID_R8185_D 5
-#ifdef CONFIG_RTL8185B
#define HW_VERID_R8185B_B 6
-#endif
#define TCR_CWMIN ((1<<31))
#define TCR_SWSEQ ((1<<30))
@@ -671,53 +408,10 @@
#define CR9346_EED1 ((1<<1))
#define CR9346_EED0 ((1<<0))
-#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))
-
-#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))
-
-#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))
-
-#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 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))
-
-#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))
#define MSR_LINK_MASK ((1<<2)|(1<<3))
#define MSR_LINK_MANAGED 2
@@ -726,54 +420,19 @@
#define MSR_LINK_ADHOC 1
#define MSR_LINK_MASTER 3
-#define PSR_GPO ((1<<7))
-#define PSR_GPI ((1<<6))
-#define PSR_LEDGPO1 ((1<<5))
-#define PSR_LEDGPO0 ((1<<4))
-#define PSR_UWF ((1<<1))
-#define PSR_PSEn ((1<<0))
-
-#define SCR_KM ((1<<5)|(1<<4))
-#define SCR_KM1 ((1<<5))
-#define SCR_KM0 ((1<<4))
-#define SCR_TXSECON ((1<<1))
-#define SCR_RXSECON ((1<<0))
-
#define BcnItv_BcnItv (0x01FF)
#define AtimWnd_AtimWnd (0x01FF)
#define BintrItv_BintrItv (0x01FF)
-#define AtimtrItv_AtimtrItv (0x01FF)
-
-#define PhyDelay_PhyDelay ((1<<2)|(1<<1)|(1<<0))
-
-#define TPPoll_BQ ((1<<7))
-#define TPPoll_HPQ ((1<<6))
-#define TPPoll_NPQ ((1<<5))
-#define TPPoll_LPQ ((1<<4))
-#define TPPoll_SBQ ((1<<3))
-#define TPPoll_SHPQ ((1<<2))
-#define TPPoll_SNPQ ((1<<1))
-#define TPPoll_SLPQ ((1<<0))
-
-#define CWR_CW (0x01FF)
-
-#define FER_INTR ((1<<15))
-#define FER_GWAKE ((1<< 4))
-
#define FEMR_INTR ((1<<15))
#define FEMR_WKUP ((1<<14))
#define FEMR_GWAKE ((1<< 4))
-#define FPSR_INTR ((1<<15))
-#define FPSR_GWAKE ((1<< 4))
-
#define FFER_INTR ((1<<15))
#define FFER_GWAKE ((1<< 4))
-#ifdef CONFIG_RTL8185B
// Three wire mode.
#define SW_THREE_WIRE 0
#define HW_THREE_WIRE 2
@@ -790,17 +449,6 @@
#define RCR_MXDMA_OFFSET 8
#define RCR_FIFO_OFFSET 13
-#define TMGDS 0x0C // Tx Management Descriptor Address
-#define TBKDS 0x10 // Tx AC_BK Descriptor Address
-#define TBEDS 0x14 // Tx AC_BE Descriptor Address
-#define TLPDS 0x20 // Tx AC_VI Descriptor Address
-#define TNPDS 0x24 // Tx AC_VO Descriptor Address
-#define THPDS 0x28 // Tx Hign Priority Descriptor Address
-
-#define TBDS 0x4c // Beacon descriptor queue start address
-
-#define RDSA 0xE4 // Receive descriptor queue start address
-
#define AckTimeOutReg 0x79 // ACK timeout register, in unit of 4 us.
#define RFTiming 0x8C
@@ -814,8 +462,6 @@
#define ACM_CONTROL 0x00BF // ACM Control Registe
-#define RTL8185B_VER_REG 0xE1
-
#define IntMig 0xE2 // Interrupt Migration (0xE2 ~ 0xE3)
#define TID_AC_MAP 0xE8 // TID to AC Mapping Register
@@ -827,11 +473,7 @@
#define AC_BE_PARAM 0xF8 // AC_BE Parameters Record
#define AC_BK_PARAM 0xFC // AC_BK Parameters Record
-#ifdef CONFIG_RTL818X_S
-#define BcnTimingAdjust 0x16A // Beacon Timing Adjust Register.
#define GPIOCtrl 0x16B // GPIO Control Register.
-#define PSByGC 0x180 // 0x180 - 0x183 Power Saving by Gated Clock.
-#endif
#define ARFR 0x1E0 // Auto Rate Fallback Register (0x1e0 ~ 0x1e2)
#define RFSW_CTRL 0x272 // 0x272-0x273.
@@ -840,33 +482,14 @@
#define SW_3W_CMD0 0x27C // Software 3-wire Control/Status Register.
#define SW_3W_CMD1 0x27D // Software 3-wire Control/Status Register.
-#ifdef CONFIG_RTL818X_S
#define PI_DATA_READ 0X360 // 0x360 - 0x361 Parallel Interface Data Register.
#define SI_DATA_READ 0x362 // 0x362 - 0x363 Serial Interface Data Register.
-#endif
-
-//----------------------------------------------------------------------------
-// 8185B TPPoll bits (offset 0xd9, 1 byte)
-//----------------------------------------------------------------------------
-#define TPPOLL_BQ (0x01 << 7)
-#define TPPOLL_HPQ (0x01 << 6)
-#define TPPOLL_AC_VOQ (0x01 << 5)
-#define TPPOLL_AC_VIQ (0x01 << 4)
-#define TPPOLL_AC_BEQ (0x01 << 3)
-#define TPPOLL_AC_BKQ (0x01 << 2)
-#define TPPOLL_AC_MGQ (0x01 << 1)
//----------------------------------------------------------------------------
// 8185B TPPollStop bits (offset 0x93, 1 byte)
//----------------------------------------------------------------------------
#define TPPOLLSTOP_BQ (0x01 << 7)
-#define TPPOLLSTOP_HPQ (0x01 << 6)
-#define TPPOLLSTOP_AC_VOQ (0x01 << 5)
#define TPPOLLSTOP_AC_VIQ (0x01 << 4)
-#define TPPOLLSTOP_AC_BEQ (0x01 << 3)
-#define TPPOLLSTOP_AC_BKQ (0x01 << 2)
-#define TPPOLLSTOP_AC_MGQ (0x01 << 1)
-
#define MSR_LINK_ENEDCA (1<<4)
@@ -885,7 +508,6 @@
#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
@@ -916,7 +538,6 @@
#define RTL8225z2_ANAPARAM_OFF 0x55480658
#define RTL8225z2_ANAPARAM2_OFF 0x72003f70
//by amy for power save
-#define RF_CHANGE_BY_SW BIT31
#define RF_CHANGE_BY_HW BIT30
#define RF_CHANGE_BY_PS BIT29
#define RF_CHANGE_BY_IPS BIT28
@@ -934,23 +555,19 @@
//{by amy 080312
//0x7C, 0x7D Crystal calibration and Tx Power tracking mechanism. Added by Roger. 2007.12.10.
#define EEPROM_RSV 0x7C
-#define EEPROM_XTAL_CAL_MASK 0x00FF // 0x7C[7:0], Crystal calibration mask.
#define EEPROM_XTAL_CAL_XOUT_MASK 0x0F // 0x7C[3:0], Crystal calibration for Xout.
#define EEPROM_XTAL_CAL_XIN_MASK 0xF0 // 0x7C[7:4], Crystal calibration for Xin.
#define EEPROM_THERMAL_METER_MASK 0x0F00 // 0x7D[3:0], Thermal meter reference level.
#define EEPROM_XTAL_CAL_ENABLE 0x1000 // 0x7D[4], Crystal calibration enabled/disabled BIT.
#define EEPROM_THERMAL_METER_ENABLE 0x2000 // 0x7D[5], Thermal meter enabled/disabled BIT.
-#define EEPROM_CID_RSVD1 0x3F
#define EN_LPF_CAL 0x238 // Enable LPF Calibration.
#define PWR_METER_EN BIT1
// <RJ_TODO_8185B> where are false alarm counters in 8185B?
#define CCK_FALSE_ALARM 0xD0
-#define OFDM_FALSE_ALARM 0xD2
//by amy 080312}
//YJ,add for Country IE, 080630
#define EEPROM_COUNTRY_CODE 0x2E
//YJ,add,080630,end
-#endif
#endif
diff --git a/drivers/staging/rtl8187se/r8180_max2820.c b/drivers/staging/rtl8187se/r8180_max2820.c
deleted file mode 100644
index cea08463d5ee..000000000000
--- a/drivers/staging/rtl8187se/r8180_max2820.c
+++ /dev/null
@@ -1,240 +0,0 @@
-/*
- This files contains MAXIM MAX2820 radio frontend programming routines.
-
- 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.
-
- NetBSD rtl8180 driver from Dave Young has been really useful to
- understand how to program the MAXIM radio. Thanks a lot!!!
-
- 'The Deuce' tested this and fixed some bugs.
-
- Code from rtl8181 project has been useful to me to understand some things.
-
- We want to tanks the Authors of such projects and the Ndiswrapper
- project Authors.
-*/
-
-
-#include "r8180.h"
-#include "r8180_hw.h"
-#include "r8180_max2820.h"
-
-
-//#define DEBUG_MAXIM
-
-u32 maxim_chan[] = {
- 0, //dummy channel 0
- 12, //1
- 17, //2
- 22, //3
- 27, //4
- 32, //5
- 37, //6
- 42, //7
- 47, //8
- 52, //9
- 57, //10
- 62, //11
- 67, //12
- 72, //13
- 84, //14
-};
-
-#if 0
-/* maxim expects 4 bit address MSF, then 12 bit data MSF*/
-void write_maxim(struct net_device *dev,u8 adr, u32 data)
-{
-
- int shift;
- short bit;
- u16 word;
-
- adr = adr &0xf;
- word = (u16)data & 0xfff;
- word |= (adr<<12);
- /*write_nic_dword(dev,PHY_CONFIG,BB_HOST_BANG | BB_HOST_BANG_EN);
- read_nic_dword(dev,PHY_CONFIG);
- mdelay(1);
-
- write_nic_dword(dev,PHY_CONFIG,BB_HOST_BANG | BB_HOST_BANG_EN | BB_HOST_BANG_CLK);
- read_nic_dword(dev,PHY_CONFIG);
- mdelay(1);
- */
-
- /* MAX2820 will sample data on rising edge of clock */
- for(shift = 15;shift >=0; shift--){
- bit = word>>shift & 1;
-
- write_nic_dword(dev,PHY_CONFIG,BB_HOST_BANG | (bit<<BB_HOST_BANG_DATA));
-
- read_nic_dword(dev,PHY_CONFIG);
- mdelay(2);
-
- write_nic_dword(dev,PHY_CONFIG,BB_HOST_BANG |
- (bit<<BB_HOST_BANG_DATA) | BB_HOST_BANG_CLK); /* sample data */
-
- read_nic_dword(dev,PHY_CONFIG);
- mdelay(1);
-
- write_nic_dword(dev,PHY_CONFIG,BB_HOST_BANG |
- (bit<<BB_HOST_BANG_DATA));
-
- read_nic_dword(dev,PHY_CONFIG);
- mdelay(2);
-
- }
- write_nic_dword(dev,PHY_CONFIG,BB_HOST_BANG | (bit<<BB_HOST_BANG_DATA)|
- BB_HOST_BANG_EN);
- read_nic_dword(dev,PHY_CONFIG);
- mdelay(2);
-
- /* The shift register fill flush to the requested register the
- * last 12 bits data shifted in
- */
- write_nic_dword(dev,PHY_CONFIG,BB_HOST_BANG | (bit<<BB_HOST_BANG_DATA)|
- BB_HOST_BANG_EN | BB_HOST_BANG_CLK);
- read_nic_dword(dev,PHY_CONFIG);
- mdelay(2);
-
- write_nic_dword(dev,PHY_CONFIG,BB_HOST_BANG | (bit<<BB_HOST_BANG_DATA)|
- BB_HOST_BANG_EN);
- read_nic_dword(dev,PHY_CONFIG);
- mdelay(2);
-
-
-#ifdef DEBUG_MAXIM
- DMESG("Writing maxim: %x (adr %x)",phy_config,adr);
-#endif
-
-}
-#endif
-
-void write_maxim(struct net_device *dev,u8 adr, u32 data) {
- u32 temp;
- temp = 0x90 + (data & 0xf);
- temp <<= 16;
- temp += adr;
- temp <<= 8;
- temp += (data >> 4) & 0xff;
-#ifdef DEBUG_MAXIM
- DMESG("write_maxim: %08x", temp);
-#endif
- write_nic_dword(dev, PHY_CONFIG, temp);
- force_pci_posting(dev);
- mdelay(1);
-}
-
-
-void maxim_write_phy_antenna(struct net_device *dev,short ch)
-{
- struct r8180_priv *priv = ieee80211_priv(dev);
- u8 ant;
-
- ant = MAXIM_ANTENNA;
- if(priv->antb) /*default antenna is antenna B */
- ant |= BB_ANTENNA_B;
- if(ch == 14)
- ant |= BB_ANTATTEN_CHAN14;
- write_phy(dev,0x10,ant);
- //DMESG("BB antenna %x ",ant);
-}
-
-
-void maxim_rf_set_chan(struct net_device *dev, short ch)
-{
- struct r8180_priv *priv = ieee80211_priv(dev);
- u32 txpw = 0xff & priv->chtxpwr[ch];
- u32 chan = maxim_chan[ch];
-
- /*While philips SA2400 drive the PA bias
- *seems that for MAXIM we delegate this
- *to the BB
- */
-
- //write_maxim(dev,5,txpw);
- write_phy(dev,3,txpw);
-
- maxim_write_phy_antenna(dev,ch);
- write_maxim(dev,3,chan);
-}
-
-
-void maxim_rf_close(struct net_device *dev)
-{
- write_phy(dev, 3, 0x8);
- write_maxim(dev, 1, 0);
-}
-
-
-void maxim_rf_init(struct net_device *dev)
-{
- struct r8180_priv *priv = ieee80211_priv(dev);
- u32 anaparam;
-
- write_nic_byte(dev,PHY_DELAY,0x6); //this is general
- write_nic_byte(dev,CARRIER_SENSE_COUNTER,0x4c); //this is general
-
- /*these are maxim specific*/
- anaparam = read_nic_dword(dev,ANAPARAM);
- anaparam = anaparam &~ (ANAPARAM_TXDACOFF_SHIFT);
- anaparam = anaparam &~ANAPARAM_PWR1_MASK;
- anaparam = anaparam &~ANAPARAM_PWR0_MASK;
- anaparam |= (MAXIM_ANAPARAM_PWR1_ON<<ANAPARAM_PWR1_SHIFT);
- anaparam |= (MAXIM_ANAPARAM_PWR0_ON<<ANAPARAM_PWR0_SHIFT);
-
- //rtl8180_set_anaparam(dev,anaparam);
-
- /* MAXIM from netbsd driver */
-
- write_maxim(dev,0, 7); /* test mode as indicated in datasheet*/
- write_maxim(dev,1, 0x1e); /* enable register*/
- write_maxim(dev,2, 1); /* synt register */
-
-
- maxim_rf_set_chan(dev,priv->chan);
-
- write_maxim(dev,4, 0x313); /* rx register*/
-
- /* PA is driven directly by the BB, we keep the MAXIM bias
- * at the highest value in the boubt tha pleacing it to lower
- * values may introduce some further attenuation somewhere..
- */
-
- write_maxim(dev,5, 0xf);
-
-
- /*baseband configuration*/
- write_phy(dev,0,0x88); //sys1
- write_phy(dev,3,0x8); //txagc
- write_phy(dev,4,0xf8); // lnadet
- write_phy(dev,5,0x90); // ifagcinit
- write_phy(dev,6,0x1a); // ifagclimit
- write_phy(dev,7,0x64); // ifagcdet
-
- /*Should be done something more here??*/
-
- maxim_write_phy_antenna(dev,priv->chan);
-
- write_phy(dev,0x11,0x88); //trl
- if(priv->diversity)
- write_phy(dev,0x12,0xc7);
- else
- write_phy(dev,0x12,0x47);
-
- write_phy(dev,0x13,0x9b);
-
- write_phy(dev,0x19,0x0); //CHESTLIM
- write_phy(dev,0x1a,0x9f); //CHSQLIM
-
- maxim_rf_set_chan(dev,priv->chan);
-}
diff --git a/drivers/staging/rtl8187se/r8180_max2820.h b/drivers/staging/rtl8187se/r8180_max2820.h
deleted file mode 100644
index 5d4fb5504841..000000000000
--- a/drivers/staging/rtl8187se/r8180_max2820.h
+++ /dev/null
@@ -1,21 +0,0 @@
-/*
- 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 such projects and the Ndiswrapper project Authors.
-*/
-
-#define MAXIM_ANTENNA 0xb3
-#define MAXIM_ANAPARAM_PWR1_ON 0x8
-#define MAXIM_ANAPARAM_PWR0_ON 0x0
-
-
-void maxim_rf_init(struct net_device *dev);
-void maxim_rf_set_chan(struct net_device *dev,short ch);
-
-void maxim_rf_close(struct net_device *dev);
diff --git a/drivers/staging/rtl8187se/r8180_pm.c b/drivers/staging/rtl8187se/r8180_pm.c
deleted file mode 100644
index 2b3d642db77f..000000000000
--- a/drivers/staging/rtl8187se/r8180_pm.c
+++ /dev/null
@@ -1,92 +0,0 @@
-/*
- 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_RTL8180_PM
-
-
-#include "r8180_hw.h"
-#include "r8180_pm.h"
-#include "r8180.h"
-
-int rtl8180_save_state (struct pci_dev *dev, u32 state)
-{
- printk(KERN_NOTICE "r8180 save state call (state %u).\n", state);
- return(-EAGAIN);
-}
-
-int rtl8180_suspend (struct pci_dev *pdev, pm_message_t state)
-{
- struct net_device *dev = pci_get_drvdata(pdev);
-// struct r8180_priv *priv = ieee80211_priv(dev);
-
- if (!netif_running(dev))
- goto out_pci_suspend;
-
- if (dev->netdev_ops->ndo_stop)
- dev->netdev_ops->ndo_stop(dev);
-
- netif_device_detach(dev);
-
-out_pci_suspend:
- pci_save_state(pdev);
- pci_disable_device(pdev);
- pci_set_power_state(pdev,pci_choose_state(pdev,state));
- return 0;
-}
-
-int rtl8180_resume (struct pci_dev *pdev)
-{
- struct net_device *dev = pci_get_drvdata(pdev);
-// struct r8180_priv *priv = ieee80211_priv(dev);
- int err;
- u32 val;
-
- pci_set_power_state(pdev, PCI_D0);
-
- err = pci_enable_device(pdev);
- if(err) {
- printk(KERN_ERR "%s: pci_enable_device failed on resume\n",
- dev->name);
-
- return err;
- }
- pci_restore_state(pdev);
- /*
- * Suspend/Resume resets the PCI configuration space, so we have to
- * re-disable the RETRY_TIMEOUT register (0x41) to keep PCI Tx retries
- * from interfering with C3 CPU state. pci_restore_state won't help
- * here since it only restores the first 64 bytes pci config header.
- */
- pci_read_config_dword(pdev, 0x40, &val);
- if ((val & 0x0000ff00) != 0)
- pci_write_config_dword(pdev, 0x40, val & 0xffff00ff);
-
- if(!netif_running(dev))
- goto out;
-
- if (dev->netdev_ops->ndo_open)
- dev->netdev_ops->ndo_open(dev);
- netif_device_attach(dev);
-out:
- return 0;
-}
-
-
-int rtl8180_enable_wake (struct pci_dev *dev, u32 state, int enable)
-{
- printk(KERN_NOTICE "r8180 enable wake call (state %u, enable %d).\n",
- state, enable);
- return(-EAGAIN);
-}
-
-
-
-#endif //CONFIG_RTL8180_PM
diff --git a/drivers/staging/rtl8187se/r8180_pm.h b/drivers/staging/rtl8187se/r8180_pm.h
deleted file mode 100644
index 7958b3a734db..000000000000
--- a/drivers/staging/rtl8187se/r8180_pm.h
+++ /dev/null
@@ -1,28 +0,0 @@
-/*
- 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_RTL8180_PM
-
-#ifndef R8180_PM_H
-#define R8180_PM_H
-
-#include <linux/types.h>
-#include <linux/pci.h>
-
-int rtl8180_save_state (struct pci_dev *dev, u32 state);
-int rtl8180_suspend (struct pci_dev *pdev, pm_message_t state);
-int rtl8180_resume (struct pci_dev *pdev);
-int rtl8180_enable_wake (struct pci_dev *dev, u32 state, int enable);
-
-#endif //R8180_PM_H
-
-#endif // CONFIG_RTL8180_PM
diff --git a/drivers/staging/rtl8187se/r8180_rtl8225.c b/drivers/staging/rtl8187se/r8180_rtl8225.c
deleted file mode 100644
index 96ed029ed64a..000000000000
--- a/drivers/staging/rtl8187se/r8180_rtl8225.c
+++ /dev/null
@@ -1,933 +0,0 @@
-/*
- 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 rtl8225
- radio frontend.
-
- *Many* thanks to Realtek Corp. for their great support!
-
-*/
-
-
-
-#include "r8180_hw.h"
-#include "r8180_rtl8225.h"
-
-
-u8 rtl8225_gain[]={
- 0x23,0x88,0x7c,0xa5,// -82dbm
- 0x23,0x88,0x7c,0xb5,// -82dbm
- 0x23,0x88,0x7c,0xc5,// -82dbm
- 0x33,0x80,0x79,0xc5,// -78dbm
- 0x43,0x78,0x76,0xc5,// -74dbm
- 0x53,0x60,0x73,0xc5,// -70dbm
- 0x63,0x58,0x70,0xc5,// -66dbm
-};
-
-#if 0
-u8 rtl8225_init_gain[]={
- //0x00,0x00,0x00,0x00,//0x00,0x00,0x00,0x00,
- 0x33,0x80,0x6c,0xc5,//0x00,0x49,0x06,0xb5,//Gain = 0 ~ -78dbm
- 0x43,0x78,0x69,0xc5,//0x00,0x45,0x06,0xb1,//Gain = 1 ~ -74dbm
- 0x53,0x60,0x66,0xc5,//0x00,0x41,0x06,0xab,//Gain = 2 ~ -70dbm
- 0x63,0x58,0x63,0xc5,//0x00,0x3d,0x06,0xa5,//Gain = 3 ~ -66dbm
- 0x73,0x50,0x62,0xc5,//0x00,0x39,0x06,0xa1,//Gain = 4 ~ -62dbm
- 0x83,0x43,0x61,0xc5,//0x00,0x35,0x06,0x9b,//Gain = 5 ~ -58dbm
- 0x93,0x38,0x5a,0xc5,//0x00,0x31,0x06,0x99,//Gain = 6 ~ -54dbm
-};
-#endif
-#ifdef CONFIG_RTL818X_S
-u32 rtl8225_chan[] ={
- 0,
- 0x0080, //ch1
- 0x0100, //ch2
- 0x0180, //ch3
- 0x0200, //ch4
- 0x0280,
- 0x0300,
- 0x0380,
- 0x0400,
- 0x0480,
- 0x0500,
- 0x0580,
- 0x0600,
- 0x0680,
- 0x074A, //ch14
-};
-#else
-u32 rtl8225_chan[] = {
- 0, //dummy channel 0
- 0x085c, //1
- 0x08dc, //2
- 0x095c, //3
- 0x09dc, //4
- 0x0a5c, //5
- 0x0adc, //6
- 0x0b5c, //7
- 0x0bdc, //8
- 0x0c5c, //9
- 0x0cdc, //10
- 0x0d5c, //11
- 0x0ddc, //12
- 0x0e5c, //13
- //0x0f5c, //14
- 0x0f72, // 14
-};
-#endif
-
-u16 rtl8225bcd_rxgain[]={
- 0x0400, 0x0401, 0x0402, 0x0403, 0x0404, 0x0405, 0x0408, 0x0409,
- 0x040a, 0x040b, 0x0502, 0x0503, 0x0504, 0x0505, 0x0540, 0x0541,
- 0x0542, 0x0543, 0x0544, 0x0545, 0x0580, 0x0581, 0x0582, 0x0583,
- 0x0584, 0x0585, 0x0588, 0x0589, 0x058a, 0x058b, 0x0643, 0x0644,
- 0x0645, 0x0680, 0x0681, 0x0682, 0x0683, 0x0684, 0x0685, 0x0688,
- 0x0689, 0x068a, 0x068b, 0x068c, 0x0742, 0x0743, 0x0744, 0x0745,
- 0x0780, 0x0781, 0x0782, 0x0783, 0x0784, 0x0785, 0x0788, 0x0789,
- 0x078a, 0x078b, 0x078c, 0x078d, 0x0790, 0x0791, 0x0792, 0x0793,
- 0x0794, 0x0795, 0x0798, 0x0799, 0x079a, 0x079b, 0x079c, 0x079d,
- 0x07a0, 0x07a1, 0x07a2, 0x07a3, 0x07a4, 0x07a5, 0x07a8, 0x07a9,
- 0x07aa, 0x07ab, 0x07ac, 0x07ad, 0x07b0, 0x07b1, 0x07b2, 0x07b3,
- 0x07b4, 0x07b5, 0x07b8, 0x07b9, 0x07ba, 0x07bb, 0x07bb
-
-};
-
-
-#if 0
-u16 rtl8225bc_rxgain[]={
- 0x0400, 0x0401, 0x0402, 0x0403, 0x0404, 0x0405, 0x0408, 0x0409,
- 0x040a, 0x040b, 0x0502, 0x0503, 0x0504, 0x0505, 0x0540, 0x0541,
- 0x0542, 0x0543, 0x0544, 0x0545, 0x0580, 0x0581, 0x0582, 0x0583,
- 0x0584, 0x0585, 0x0588, 0x0589, 0x058a, 0x058b, 0x0643, 0x0644,
- 0x0645, 0x0680, 0x0681, 0x0682, 0x0683, 0x0684, 0x0685, 0x0688,
- 0x0689, 0x068a, 0x068b, 0x068c, 0x0742, 0x0743, 0x0744, 0x0745,
- 0x0780, 0x0781, 0x0782, 0x0783, 0x0784, 0x0785, 0x0788, 0x0789,
- 0x078a, 0x078b, 0x078c, 0x078d, 0x0790, 0x0791, 0x0792, 0x0793,
- 0x0794, 0x0795, 0x0798, 0x0799, 0x039a, 0x039b, 0x039c, 0x039d,
- 0x03a0, 0x03a1, 0x03a2, 0x03a3, 0x03a4, 0x03a5, 0x03a8, 0x03a9,
- 0x03aa, 0x03ab, 0x03ac, 0x03ad, 0x03b0, 0x03b1, 0x03b2, 0x03b3,
- 0x03b4, 0x03b5, 0x03b8, 0x03b9, 0x03ba, 0x03bb, 0x03bb
-
-};
-
-
-u16 rtl8225a_rxgain[]={
- 0x0400, 0x0401, 0x0402, 0x0403, 0x0404, 0x0405, 0x0408, 0x0409,
- 0x040a, 0x040b, 0x0502, 0x0503, 0x0504, 0x0505, 0x0540, 0x0541,
- 0x0542, 0x0543, 0x0544, 0x0545, 0x0580, 0x0581, 0x0582, 0x0583,
- 0x0584, 0x0585, 0x0588, 0x0589, 0x058a, 0x058b, 0x0643, 0x0644,
- 0x0645, 0x0680, 0x0681, 0x0682, 0x0683, 0x0684, 0x0685, 0x0688,
- 0x0689, 0x068a, 0x068b, 0x068c, 0x0742, 0x0743, 0x0744, 0x0745,
- 0x0780, 0x0781, 0x0782, 0x0783, 0x0784, 0x0785, 0x0788, 0x0789,
- 0x078a, 0x078b, 0x078c, 0x078d, 0x0790, 0x0791, 0x0792, 0x0793,
- 0x0794, 0x0795, 0x0798, 0x0799, 0x079a, 0x079b, 0x079c, 0x079d,
- 0x07a0, 0x07a1, 0x07a2, 0x07a3, 0x07a4, 0x07a5, 0x07a8, 0x07a9,
- 0x07aa, 0x07ab, 0x07ac, 0x07ad, 0x07ad, 0x07ad, 0x07ad, 0x07ad,
- 0x07ad, 0x07ad, 0x07ad, 0x07ad, 0x07ad, 0x07ad, 0x07ad
-};
-#endif
-
-u8 rtl8225_agc[]={
- 0x9e,0x9e,0x9e,0x9e,0x9e,0x9e,0x9e,0x9e,0x9d,0x9c,0x9b,0x9a,0x99,0x98,0x97,0x96,
- 0x95,0x94,0x93,0x92,0x91,0x90,0x8f,0x8e,0x8d,0x8c,0x8b,0x8a,0x89,0x88,0x87,0x86,
- 0x85,0x84,0x83,0x82,0x81,0x80,0x3f,0x3e,0x3d,0x3c,0x3b,0x3a,0x39,0x38,0x37,0x36,
- 0x35,0x34,0x33,0x32,0x31,0x30,0x2f,0x2e,0x2d,0x2c,0x2b,0x2a,0x29,0x28,0x27,0x26,
- 0x25,0x24,0x23,0x22,0x21,0x20,0x1f,0x1e,0x1d,0x1c,0x1b,0x1a,0x19,0x18,0x17,0x16,
- 0x15,0x14,0x13,0x12,0x11,0x10,0x0f,0x0e,0x0d,0x0c,0x0b,0x0a,0x09,0x08,0x07,0x06,
- 0x05,0x04,0x03,0x02,0x01,0x01,0x01,0x01,0x01,0x01,0x01,0x01,0x01,0x01,0x01,0x01,
- 0x01,0x01,0x01,0x01,0x01,0x01,0x01,0x01,0x01,0x01,0x01,0x01,0x01,0x01,0x01,0x01,
-};
-
-
-u8 rtl8225_tx_gain_cck_ofdm[]={
- 0x02,0x06,0x0e,0x1e,0x3e,0x7e
-};
-
-
-u8 rtl8225_tx_power_ofdm[]={
- 0x80,0x90,0xa2,0xb5,0xcb,0xe4
-};
-
-
-u8 rtl8225_tx_power_cck_ch14[]={
- 0x18,0x17,0x15,0x0c,0x00,0x00,0x00,0x00,
- 0x1b,0x1a,0x17,0x0e,0x00,0x00,0x00,0x00,
- 0x1f,0x1e,0x1a,0x0f,0x00,0x00,0x00,0x00,
- 0x22,0x21,0x1d,0x11,0x00,0x00,0x00,0x00,
- 0x26,0x25,0x21,0x13,0x00,0x00,0x00,0x00,
- 0x2b,0x2a,0x25,0x15,0x00,0x00,0x00,0x00
-};
-
-
-u8 rtl8225_tx_power_cck[]={
- 0x18,0x17,0x15,0x11,0x0c,0x08,0x04,0x02,
- 0x1b,0x1a,0x17,0x13,0x0e,0x09,0x04,0x02,
- 0x1f,0x1e,0x1a,0x15,0x10,0x0a,0x05,0x02,
- 0x22,0x21,0x1d,0x18,0x11,0x0b,0x06,0x02,
- 0x26,0x25,0x21,0x1b,0x14,0x0d,0x06,0x03,
- 0x2b,0x2a,0x25,0x1e,0x16,0x0e,0x07,0x03
-};
-
-
-void rtl8225_set_gain(struct net_device *dev, short gain)
-{
- write_phy_ofdm(dev, 0x0d, rtl8225_gain[gain * 4]);
- write_phy_ofdm(dev, 0x23, rtl8225_gain[gain * 4 + 1]);
- write_phy_ofdm(dev, 0x1b, rtl8225_gain[gain * 4 + 2]);
- write_phy_ofdm(dev, 0x1d, rtl8225_gain[gain * 4 + 3]);
-}
-#if 0
-
-void rtl8225_set_gain(struct net_device *dev, short gain)
-{
- struct r8180_priv *priv = ieee80211_priv(dev);
-
- rtl8180_set_anaparam(dev, RTL8225_ANAPARAM_ON);
-
- if(priv->card_8185 == 2)
- write_phy_ofdm(dev, 0x21, 0x27);
- else
- write_phy_ofdm(dev, 0x21, 0x37);
-
- write_phy_ofdm(dev, 0x25, 0x20);
- write_phy_ofdm(dev, 0x11, 0x6);
-
- if(priv->card_8185 == 1 && priv->card_8185_Bversion)
- write_phy_ofdm(dev, 0x27, 0x8);
- else
- write_phy_ofdm(dev, 0x27, 0x88);
-
- write_phy_ofdm(dev, 0x14, 0);
- write_phy_ofdm(dev, 0x16, 0);
- write_phy_ofdm(dev, 0x15, 0x40);
- write_phy_ofdm(dev, 0x17, 0x40);
-
- write_phy_ofdm(dev, 0x0d, rtl8225_gain[gain * 4]);
- write_phy_ofdm(dev, 0x23, rtl8225_gain[gain * 4 + 1]);
- write_phy_ofdm(dev, 0x1b, rtl8225_gain[gain * 4 + 2]);
- write_phy_ofdm(dev, 0x1d, rtl8225_gain[gain * 4 + 3]);
- //rtl8225_set_gain_usb(dev, gain);
-}
-#endif
-
-
-void write_rtl8225(struct net_device *dev, u8 adr, u16 data)
-{
- int i;
- u16 out,select;
- u8 bit;
- u32 bangdata = (data << 4) | (adr & 0xf);
- struct r8180_priv *priv = ieee80211_priv(dev);
-
- out = read_nic_word(dev, RFPinsOutput) & 0xfff3;
-
- write_nic_word(dev,RFPinsEnable,
- (read_nic_word(dev,RFPinsEnable) | 0x7));
-
- select = read_nic_word(dev, RFPinsSelect);
-
- write_nic_word(dev, RFPinsSelect, select | 0x7 |
- ((priv->card_type == USB) ? 0 : SW_CONTROL_GPIO));
-
- force_pci_posting(dev);
- udelay(10);
-
- write_nic_word(dev, RFPinsOutput, out | BB_HOST_BANG_EN );//| 0x1fff);
-
- force_pci_posting(dev);
- udelay(2);
-
- write_nic_word(dev, RFPinsOutput, out);
-
- force_pci_posting(dev);
- udelay(10);
-
-
- for(i=15; i>=0;i--){
-
- bit = (bangdata & (1<<i)) >> i;
-
- write_nic_word(dev, RFPinsOutput, bit | out);
-
- write_nic_word(dev, RFPinsOutput, bit | out | BB_HOST_BANG_CLK);
- write_nic_word(dev, RFPinsOutput, bit | out | BB_HOST_BANG_CLK);
-
- i--;
- bit = (bangdata & (1<<i)) >> i;
-
- write_nic_word(dev, RFPinsOutput, bit | out | BB_HOST_BANG_CLK);
- write_nic_word(dev, RFPinsOutput, bit | out | BB_HOST_BANG_CLK);
-
- write_nic_word(dev, RFPinsOutput, bit | out);
-
- }
-
- write_nic_word(dev, RFPinsOutput, out | BB_HOST_BANG_EN);
-
- force_pci_posting(dev);
- udelay(10);
-
- write_nic_word(dev, RFPinsOutput, out |
- ((priv->card_type == USB) ? 4 : BB_HOST_BANG_EN));
-
- write_nic_word(dev, RFPinsSelect, select |
- ((priv->card_type == USB) ? 0 : SW_CONTROL_GPIO));
-
- if(priv->card_type == USB)
- mdelay(2);
- else
- rtl8185_rf_pins_enable(dev);
-}
-
-void rtl8225_rf_close(struct net_device *dev)
-{
- write_rtl8225(dev, 0x4, 0x1f);
-
- force_pci_posting(dev);
- mdelay(1);
-
- rtl8180_set_anaparam(dev, RTL8225_ANAPARAM_OFF);
- rtl8185_set_anaparam2(dev, RTL8225_ANAPARAM2_OFF);
-}
-
-void rtl8225_SetTXPowerLevel(struct net_device *dev, short ch)
-{
- struct r8180_priv *priv = ieee80211_priv(dev);
-
- int GainIdx;
- int GainSetting;
- int i;
- u8 power;
- u8 *cck_power_table;
- u8 max_cck_power_level;
- u8 max_ofdm_power_level;
- u8 min_ofdm_power_level;
- u8 cck_power_level = 0xff & priv->chtxpwr[ch];
- u8 ofdm_power_level = 0xff & priv->chtxpwr_ofdm[ch];
-
- if(priv->card_type == USB){
- max_cck_power_level = 11;
- max_ofdm_power_level = 25; // 12 -> 25
- min_ofdm_power_level = 10;
- }else{
- max_cck_power_level = 35;
- max_ofdm_power_level = 35;
- min_ofdm_power_level = 0;
- }
- /* CCK power setting */
- if(cck_power_level > max_cck_power_level)
- cck_power_level = max_cck_power_level;
- GainIdx=cck_power_level % 6;
- GainSetting=cck_power_level / 6;
-
- if(ch == 14)
- cck_power_table = rtl8225_tx_power_cck_ch14;
- else
- cck_power_table = rtl8225_tx_power_cck;
-
-// if(priv->card_8185 == 1 && priv->card_8185_Bversion ){
- /*Ver B*/
-// write_nic_byte(dev, TX_GAIN_CCK, rtl8225_tx_gain_cck_ofdm[GainSetting]);
-// }else{
- /*Ver C - D */
- write_nic_byte(dev, TX_GAIN_CCK, rtl8225_tx_gain_cck_ofdm[GainSetting]>>1);
-// }
-
- for(i=0;i<8;i++){
-
- power = cck_power_table[GainIdx * 8 + i];
- write_phy_cck(dev, 0x44 + i, power);
- }
-
- /* FIXME Is this delay really needeed ? */
- force_pci_posting(dev);
- mdelay(1);
-
- /* OFDM power setting */
-// Old:
-// if(ofdm_power_level > max_ofdm_power_level)
-// ofdm_power_level = 35;
-// ofdm_power_level += min_ofdm_power_level;
-// Latest:
- if(ofdm_power_level > (max_ofdm_power_level - min_ofdm_power_level))
- ofdm_power_level = max_ofdm_power_level;
- else
- ofdm_power_level += min_ofdm_power_level;
- if(ofdm_power_level > 35)
- ofdm_power_level = 35;
-//
-
- GainIdx=ofdm_power_level % 6;
- GainSetting=ofdm_power_level / 6;
-#if 1
-// if(priv->card_type == USB){
- rtl8185_set_anaparam2(dev,RTL8225_ANAPARAM2_ON);
-
- write_phy_ofdm(dev,2,0x42);
- write_phy_ofdm(dev,6,0);
- write_phy_ofdm(dev,8,0);
-// }
-#endif
-// if(priv->card_8185 == 1 && priv->card_8185_Bversion){
-// /*Ver B*/
-// write_nic_byte(dev, TX_GAIN_OFDM, rtl8225_tx_gain_cck_ofdm[GainSetting]);
-// }else{
- /*Ver C - D */
- write_nic_byte(dev, TX_GAIN_OFDM, rtl8225_tx_gain_cck_ofdm[GainSetting]>>1);
-// }
-
-
- power = rtl8225_tx_power_ofdm[GainIdx];
-
- write_phy_ofdm(dev, 0x5, power);
- write_phy_ofdm(dev, 0x7, power);
-
- force_pci_posting(dev);
- mdelay(1);
- //write_nic_byte(dev, TX_AGC_CONTROL,4);
-}
-#if 0
-/* switch between mode B and G */
-void rtl8225_set_mode(struct net_device *dev, short modeb)
-{
- write_phy_ofdm(dev, 0x15, (modeb ? 0x0 : 0x40));
- write_phy_ofdm(dev, 0x17, (modeb ? 0x0 : 0x40));
-}
-#endif
-void rtl8225_rf_set_chan(struct net_device *dev, short ch)
-{
- struct r8180_priv *priv = ieee80211_priv(dev);
- short gset = (priv->ieee80211->state == IEEE80211_LINKED &&
- ieee80211_is_54g(priv->ieee80211->current_network)) ||
- priv->ieee80211->iw_mode == IW_MODE_MONITOR;
-
- rtl8225_SetTXPowerLevel(dev, ch);
-
- write_rtl8225(dev, 0x7, rtl8225_chan[ch]);
-
- force_pci_posting(dev);
- mdelay(10);
-
- // A mode sifs 0x44, difs 34-14, slot 9, eifs 23, cwm 3, cwM 7, ctstoself 0x10
- if(gset){
- write_nic_byte(dev,SIFS,0x22);// SIFS: 0x22
- write_nic_byte(dev,DIFS,0x14); //DIFS: 20
- //write_nic_byte(dev,DIFS,20); //DIFS: 20
- }else{
- write_nic_byte(dev,SIFS,0x44);// SIFS: 0x22
- write_nic_byte(dev,DIFS,50 - 14); //DIFS: 36
- }
- if(priv->ieee80211->state == IEEE80211_LINKED &&
- ieee80211_is_shortslot(priv->ieee80211->current_network))
- write_nic_byte(dev,SLOT,0x9); //SLOT: 9
-
- else
- write_nic_byte(dev,SLOT,0x14); //SLOT: 20 (0x14)
-
-
- if(gset){
- write_nic_byte(dev,EIFS,81);//91 - 20); // EIFS: 91 (0x5B)
- write_nic_byte(dev,CW_VAL,0x73); //CW VALUE: 0x37
- //DMESG("using G net params");
- }else{
- write_nic_byte(dev,EIFS,81); // EIFS: 91 (0x5B)
- write_nic_byte(dev,CW_VAL,0xa5); //CW VALUE: 0x37
- //DMESG("using B net params");
- }
-
-
-}
-
-void rtl8225_host_pci_init(struct net_device *dev)
-{
- write_nic_word(dev, RFPinsOutput, 0x480);
-
- rtl8185_rf_pins_enable(dev);
-
- //if(priv->card_8185 == 2 && priv->enable_gpio0 ) /* version D */
- //write_nic_word(dev, RFPinsSelect, 0x88);
- //else
- write_nic_word(dev, RFPinsSelect, 0x88 | SW_CONTROL_GPIO); /* 0x488 | SW_CONTROL_GPIO */
-
- write_nic_byte(dev, GP_ENABLE, 0);
-
- force_pci_posting(dev);
- mdelay(200);
-
- write_nic_word(dev, GP_ENABLE, 0xff & (~(1<<6))); /* bit 6 is for RF on/off detection */
-
-
-}
-
-void rtl8225_host_usb_init(struct net_device *dev)
-{
- #if 0
- write_nic_byte(dev,RFPinsSelect+1,0);
-
- write_nic_byte(dev,GPIO,0);
-
- write_nic_byte_E(dev,0x53,read_nic_byte_E(dev,0x53) | (1<<7));
-
- write_nic_byte(dev,RFPinsSelect+1,4);
-
- write_nic_byte(dev,GPIO,0x20);
-
- write_nic_byte(dev,GP_ENABLE,0);
-
-
- /* Config BB & RF */
- write_nic_word(dev, RFPinsOutput, 0x80);
-
- write_nic_word(dev, RFPinsSelect, 0x80);
-
- write_nic_word(dev, RFPinsEnable, 0x80);
-
-
- mdelay(100);
-
- mdelay(1000);
-#endif
-
-}
-
-void rtl8225_rf_sleep(struct net_device *dev)
-{
- write_rtl8225(dev,0x4,0xdff);
- force_pci_posting(dev);
- mdelay(1);
- rtl8180_set_anaparam(dev, RTL8225_ANAPARAM_SLEEP);
- rtl8185_set_anaparam2(dev, RTL8225_ANAPARAM2_SLEEP);
- force_pci_posting(dev);
-}
-
-void rtl8225_rf_wakeup(struct net_device *dev)
-{
- write_rtl8225(dev,0x4,0x9ff);
- rtl8180_set_anaparam(dev, RTL8225_ANAPARAM_ON);
- rtl8185_set_anaparam2(dev, RTL8225_ANAPARAM2_ON);
- force_pci_posting(dev);
-}
-
-void rtl8225_rf_init(struct net_device *dev)
-{
- struct r8180_priv *priv = ieee80211_priv(dev);
- int i;
- short channel = 1;
- u16 brsr;
-
- priv->chan = channel;
-
- rtl8180_set_anaparam(dev, RTL8225_ANAPARAM_ON);
-
-
- if(priv->card_type == USB)
- rtl8225_host_usb_init(dev);
- else
- rtl8225_host_pci_init(dev);
-
- write_nic_dword(dev, RF_TIMING, 0x000a8008);
-
- brsr = read_nic_word(dev, BRSR);
-
- write_nic_word(dev, BRSR, 0xffff);
-
- #if 0
- if(priv->card_8185 == 1){/* version C or B */
- if(priv->card_8185_Bversion) /* version B*/
- write_nic_dword(dev, RF_PARA, 0x44);
- else /* version C */
- write_nic_dword(dev, RF_PARA, 0x100044);
- }else{ /* version D */
- if(priv->enable_gpio0)
- write_nic_dword(dev, RF_PARA, 0x20100044);
- else /* also USB */
- write_nic_dword(dev, RF_PARA, 0x100044);
- }
- #endif
-
- write_nic_dword(dev, RF_PARA, 0x100044);
-
- #if 1 //0->1
- rtl8180_set_mode(dev, EPROM_CMD_CONFIG);
- write_nic_byte(dev, CONFIG3, 0x44);
- rtl8180_set_mode(dev, EPROM_CMD_NORMAL);
- #endif
-
- if(priv->card_type == USB){
- rtl8185_rf_pins_enable(dev);
-
- mdelay(1000);
- }
-
- write_rtl8225(dev, 0x0, 0x67); mdelay(1);
-
-
- write_rtl8225(dev, 0x1, 0xfe0); mdelay(1);
-
- write_rtl8225(dev, 0x2, 0x44d); mdelay(1);
-
- write_rtl8225(dev, 0x3, 0x441); mdelay(1);
-
- if(priv->card_type == USB)
- write_rtl8225(dev, 0x4, 0x486);
- else
- write_rtl8225(dev, 0x4, 0x8be);
-
- mdelay(1);
-
-
- #if 0
- }else if(priv->phy_ver == 1){
- /* version A */
- write_rtl8225(dev, 0x5, 0xbc0 + 2);
- }else{
- #endif
- /* version B & C */
-
- if(priv->card_type == USB)
- write_rtl8225(dev, 0x5, 0xbc0);
- else if(priv->card_type == MINIPCI)
- write_rtl8225(dev, 0x5, 0xbc0 + 3 +(6<<3));
- else
- write_rtl8225(dev, 0x5, 0xbc0 + (6<<3));
-
- mdelay(1);
-// }
-
- write_rtl8225(dev, 0x6, 0xae6); mdelay(1);
-
- write_rtl8225(dev, 0x7, ((priv->card_type == USB)? 0x82a : rtl8225_chan[channel])); mdelay(1);
-
- write_rtl8225(dev, 0x8, 0x1f); mdelay(1);
-
- write_rtl8225(dev, 0x9, 0x334); mdelay(1);
-
- write_rtl8225(dev, 0xa, 0xfd4); mdelay(1);
-
- write_rtl8225(dev, 0xb, 0x391); mdelay(1);
-
- write_rtl8225(dev, 0xc, 0x50); mdelay(1);
-
-
- write_rtl8225(dev, 0xd, 0x6db); mdelay(1);
-
- write_rtl8225(dev, 0xe, 0x29); mdelay(1);
-
- write_rtl8225(dev, 0xf, 0x914);
-
- if(priv->card_type == USB){
- //force_pci_posting(dev);
- mdelay(100);
- }
-
- write_rtl8225(dev, 0x2, 0xc4d);
-
- if(priv->card_type == USB){
- // force_pci_posting(dev);
- mdelay(200);
-
- write_rtl8225(dev, 0x2, 0x44d);
-
- // force_pci_posting(dev);
- mdelay(100);
-
- }//End of if(priv->card_type == USB)
- /* FIXME!! rtl8187 we have to check if calibrarion
- * is successful and eventually cal. again (repeat
- * the two write on reg 2)
- */
- force_pci_posting(dev);
-
- mdelay(100); //200 for 8187
-
- //if(priv->card_type != USB) /* maybe not needed even for 8185 */
-// write_rtl8225(dev, 0x7, rtl8225_chan[channel]);
-
- write_rtl8225(dev, 0x0, 0x127);
-
- for(i=0;i<95;i++){
- write_rtl8225(dev, 0x1, (u8)(i+1));
-
- #if 0
- if(priv->phy_ver == 1)
- /* version A */
- write_rtl8225(dev, 0x2, rtl8225a_rxgain[i]);
- else
- #endif
- /* version B & C & D*/
-
- write_rtl8225(dev, 0x2, rtl8225bcd_rxgain[i]);
- }
-
- write_rtl8225(dev, 0x0, 0x27);
-
-
-// //if(priv->card_type != USB){
-// write_rtl8225(dev, 0x2, 0x44d);
-// write_rtl8225(dev, 0x7, rtl8225_chan[channel]);
-// write_rtl8225(dev, 0x2, 0x47d);
-//
-// force_pci_posting(dev);
-// mdelay(100);
-//
-// write_rtl8225(dev, 0x2, 0x44d);
-// //}
-
- write_rtl8225(dev, 0x0, 0x22f);
-
- if(priv->card_type != USB)
- rtl8185_rf_pins_enable(dev);
-
- for(i=0;i<128;i++){
- write_phy_ofdm(dev, 0xb, rtl8225_agc[i]);
-
- mdelay(1);
- write_phy_ofdm(dev, 0xa, (u8)i+ 0x80);
-
- mdelay(1);
- }
-
- force_pci_posting(dev);
- mdelay(1);
-
- write_phy_ofdm(dev, 0x0, 0x1); mdelay(1);
- write_phy_ofdm(dev, 0x1, 0x2); mdelay(1);
- write_phy_ofdm(dev, 0x2, ((priv->card_type == USB)? 0x42 : 0x62)); mdelay(1);
- write_phy_ofdm(dev, 0x3, 0x0); mdelay(1);
- write_phy_ofdm(dev, 0x4, 0x0); mdelay(1);
- write_phy_ofdm(dev, 0x5, 0x0); mdelay(1);
- write_phy_ofdm(dev, 0x6, 0x40); mdelay(1);
- write_phy_ofdm(dev, 0x7, 0x0); mdelay(1);
- write_phy_ofdm(dev, 0x8, 0x40); mdelay(1);
- write_phy_ofdm(dev, 0x9, 0xfe); mdelay(1);
-
- #if 0
- if(priv->card_type == USB){
- write_phy_ofdm(dev, 0xa, 0x9);
- }else{
- if(priv->card_8185 == 1 && priv->card_8185_Bversion){
- /* Ver B
- * maybe later version can accept this also?
- */
- write_phy_ofdm(dev, 0xa, 0x6);
- write_phy_ofdm(dev, 0x18, 0x6f);
- }else{
- #endif
- /* ver C & D */
- write_phy_ofdm(dev, 0xa, 0x9); mdelay(1);
-
- //write_phy_ofdm(dev, 0x18, 0xef);
- // }
- //}
- write_phy_ofdm(dev, 0xb, 0x80); mdelay(1);
-
- write_phy_ofdm(dev, 0xc, 0x1);mdelay(1);
-
-
- //if(priv->card_type != USB)
- //write_phy_ofdm(dev, 0xd, 0x33); // <>
-
- write_phy_ofdm(dev, 0xe, 0xd3);mdelay(1);
-
-
- #if 0
- if(priv->card_8185 == 1){
- if(priv->card_8185_Bversion)
- write_phy_ofdm(dev, 0xf, 0x20);/*ver B*/
- else
- write_phy_ofdm(dev, 0xf, 0x28);/*ver C*/
- }else{
- #endif
- write_phy_ofdm(dev, 0xf, 0x38);mdelay(1);
-/*ver D & 8187*/
-// }
-
-// if(priv->card_8185 == 1 && priv->card_8185_Bversion)
-// write_phy_ofdm(dev, 0x10, 0x04);/*ver B*/
-// else
- write_phy_ofdm(dev, 0x10, 0x84);mdelay(1);
-/*ver C & D & 8187*/
-
- write_phy_ofdm(dev, 0x11, 0x06);mdelay(1);
-/*agc resp time 700*/
-
-
-// if(priv->card_8185 == 2){
- /* Ver D & 8187*/
- write_phy_ofdm(dev, 0x12, 0x20);mdelay(1);
-
- write_phy_ofdm(dev, 0x13, 0x20);mdelay(1);
-
-#if 0
- }else{
- /* Ver B & C*/
- write_phy_ofdm(dev, 0x12, 0x0);
- write_phy_ofdm(dev, 0x13, 0x0);
- }
-#endif
- write_phy_ofdm(dev, 0x14, 0x0); mdelay(1);
- write_phy_ofdm(dev, 0x15, 0x40); mdelay(1);
- write_phy_ofdm(dev, 0x16, 0x0); mdelay(1);
- write_phy_ofdm(dev, 0x17, 0x40); mdelay(1);
-
-// if (priv->card_type == USB)
-// write_phy_ofdm(dev, 0x18, 0xef);
-
- write_phy_ofdm(dev, 0x18, 0xef);mdelay(1);
-
-
- write_phy_ofdm(dev, 0x19, 0x19); mdelay(1);
- write_phy_ofdm(dev, 0x1a, 0x20); mdelay(1);
-
-// if (priv->card_type != USB){
-// if(priv->card_8185 == 1 && priv->card_8185_Bversion)
-// write_phy_ofdm(dev, 0x1b, 0x66); /* Ver B */
-// else
- write_phy_ofdm(dev, 0x1b, 0x76);mdelay(1);
- /* Ver C & D */ //FIXME:MAYBE not needed
-// }
-
- write_phy_ofdm(dev, 0x1c, 0x4);mdelay(1);
-
-#if 0
- if(priv->card_8185 == 1){
- if(priv->card_8185_Bversion){
- /*ver B*/
- write_phy_ofdm(dev, 0x1e, 0x95);
- write_phy_ofdm(dev, 0x1f, 0x55);
- }else{
- /*ver C*/
- write_phy_ofdm(dev, 0x1e, 0x90);
- write_phy_ofdm(dev, 0x1f, 0x34);
-
- }
- }else{
-#endif
- /*ver D & 8187*/
- write_phy_ofdm(dev, 0x1e, 0x95);mdelay(1);
-
- write_phy_ofdm(dev, 0x1f, 0x75); mdelay(1);
-
-// }
-
- write_phy_ofdm(dev, 0x20, 0x1f);mdelay(1);
-
- write_phy_ofdm(dev, 0x21, 0x27);mdelay(1);
-
- write_phy_ofdm(dev, 0x22, 0x16);mdelay(1);
-
-// if(priv->card_type != USB)
- //write_phy_ofdm(dev, 0x23, 0x43); //FIXME maybe not needed // <>
-
- write_phy_ofdm(dev, 0x24, 0x46); mdelay(1);
- write_phy_ofdm(dev, 0x25, 0x20); mdelay(1);
- write_phy_ofdm(dev, 0x26, 0x90); mdelay(1);
-#if 0
- if(priv->card_8185 == 1 && priv->card_8185_Bversion)
- write_phy_ofdm(dev, 0x27, 0x08); /* Ver B. might work also fo ver C&D ?*/
- else
-#endif
- write_phy_ofdm(dev, 0x27, 0x88); mdelay(1);
-/* Ver C & D & 8187*/
-
- // <> Set init. gain to m74dBm.
- write_phy_ofdm(dev, 0x0d, 0x43); mdelay(1);
- write_phy_ofdm(dev, 0x1b, 0x76); mdelay(1);
- write_phy_ofdm(dev, 0x1d, 0xc5); mdelay(1);
- write_phy_ofdm(dev, 0x23, 0x78); mdelay(1);
-
- //if(priv->card_type == USB);
- // rtl8225_set_gain_usb(dev, 1); /* FIXME this '2' is random */
-
- write_phy_cck(dev, 0x0, 0x98); mdelay(1);
- write_phy_cck(dev, 0x3, 0x20); mdelay(1);
- write_phy_cck(dev, 0x4, 0x7e); mdelay(1);
- write_phy_cck(dev, 0x5, 0x12); mdelay(1);
- write_phy_cck(dev, 0x6, 0xfc); mdelay(1);
-#if 0
- if(priv->card_8185 == 1 && priv->card_8185_Bversion)
- write_phy_cck(dev, 0x7, 0xd8); /* Ver B */
- else
-#endif
- write_phy_cck(dev, 0x7, 0x78);mdelay(1);
- /* Ver C & D & 8187*/
-
- write_phy_cck(dev, 0x8, 0x2e);mdelay(1);
-
- write_phy_cck(dev, 0x10, ((priv->card_type == USB) ? 0x9b: 0x93)); mdelay(1);
- write_phy_cck(dev, 0x11, 0x88); mdelay(1);
- write_phy_cck(dev, 0x12, 0x47); mdelay(1);
-#if 0
- if(priv->card_8185 == 1 && priv->card_8185_Bversion)
- write_phy_cck(dev, 0x13, 0x98); /* Ver B */
- else
-#endif
- write_phy_cck(dev, 0x13, 0xd0); /* Ver C & D & 8187*/
-
- write_phy_cck(dev, 0x19, 0x0);
- write_phy_cck(dev, 0x1a, 0xa0);
- write_phy_cck(dev, 0x1b, 0x8);
- write_phy_cck(dev, 0x40, 0x86); /* CCK Carrier Sense Threshold */
-
- write_phy_cck(dev, 0x41, 0x8d);mdelay(1);
-
-
- write_phy_cck(dev, 0x42, 0x15); mdelay(1);
- write_phy_cck(dev, 0x43, 0x18); mdelay(1);
- write_phy_cck(dev, 0x44, 0x1f); mdelay(1);
- write_phy_cck(dev, 0x45, 0x1e); mdelay(1);
- write_phy_cck(dev, 0x46, 0x1a); mdelay(1);
- write_phy_cck(dev, 0x47, 0x15); mdelay(1);
- write_phy_cck(dev, 0x48, 0x10); mdelay(1);
- write_phy_cck(dev, 0x49, 0xa); mdelay(1);
- write_phy_cck(dev, 0x4a, 0x5); mdelay(1);
- write_phy_cck(dev, 0x4b, 0x2); mdelay(1);
- write_phy_cck(dev, 0x4c, 0x5);mdelay(1);
-
-
- write_nic_byte(dev, 0x5b, 0x0d); mdelay(1);
-
-
-
-// <>
-// // TESTR 0xb 8187
-// write_phy_cck(dev, 0x10, 0x93);// & 0xfb);
-//
-// //if(priv->card_type != USB){
-// write_phy_ofdm(dev, 0x2, 0x62);
-// write_phy_ofdm(dev, 0x6, 0x0);
-// write_phy_ofdm(dev, 0x8, 0x0);
-// //}
-
- rtl8225_SetTXPowerLevel(dev, channel);
-
- write_phy_cck(dev, 0x10, 0x9b); mdelay(1); /* Rx ant A, 0xdb for B */
- write_phy_ofdm(dev, 0x26, 0x90); mdelay(1); /* Rx ant A, 0x10 for B */
-
- rtl8185_tx_antenna(dev, 0x3); /* TX ant A, 0x0 for B */
-
- /* switch to high-speed 3-wire
- * last digit. 2 for both cck and ofdm
- */
- if(priv->card_type == USB)
- write_nic_dword(dev, 0x94, 0x3dc00002);
- else{
- write_nic_dword(dev, 0x94, 0x15c00002);
- rtl8185_rf_pins_enable(dev);
- }
-
-// if(priv->card_type != USB)
-// rtl8225_set_gain(dev, 4); /* FIXME this '1' is random */ // <>
-// rtl8225_set_mode(dev, 1); /* FIXME start in B mode */ // <>
-//
-// /* make sure is waken up! */
-// write_rtl8225(dev,0x4, 0x9ff);
-// rtl8180_set_anaparam(dev, RTL8225_ANAPARAM_ON);
-// rtl8185_set_anaparam2(dev, RTL8225_ANAPARAM2_ON);
-
- rtl8225_rf_set_chan(dev, priv->chan);
-
- write_nic_word(dev,BRSR,brsr);
-
-}
diff --git a/drivers/staging/rtl8187se/r8180_rtl8225.h b/drivers/staging/rtl8187se/r8180_rtl8225.h
index 458de6629ad0..ed35db59e1f3 100644
--- a/drivers/staging/rtl8187se/r8180_rtl8225.h
+++ b/drivers/staging/rtl8187se/r8180_rtl8225.h
@@ -19,23 +19,13 @@
#define RTL8225_ANAPARAM_SLEEP 0xa00bab59
#define RTL8225_ANAPARAM2_SLEEP 0x840dec11
-#ifdef CONFIG_RTL8185B
void rtl8225z2_rf_init(struct net_device *dev);
void rtl8225z2_rf_set_chan(struct net_device *dev,short ch);
void rtl8225z2_rf_close(struct net_device *dev);
-void rtl8225_host_pci_init(struct net_device *dev);
-void rtl8225_host_usb_init(struct net_device *dev);
-
-void write_rtl8225(struct net_device *dev, u8 adr, u16 data);
void RF_WriteReg(struct net_device *dev, u8 offset, u32 data);
u32 RF_ReadReg(struct net_device *dev, u8 offset);
-#endif
-void rtl8225_rf_init(struct net_device *dev);
-void rtl8225_rf_set_chan(struct net_device *dev,short ch);
-void rtl8225_rf_close(struct net_device *dev);
-void rtl8225_rf_sleep(struct net_device *dev);
-void rtl8225_rf_wakeup(struct net_device *dev);
+
void rtl8180_set_mode(struct net_device *dev,int mode);
void rtl8180_set_mode(struct net_device *dev,int mode);
bool SetZebraRFPowerState8185(struct net_device *dev,RT_RF_POWER_STATE eRFPowerState);
diff --git a/drivers/staging/rtl8187se/r8180_rtl8225z2.c b/drivers/staging/rtl8187se/r8180_rtl8225z2.c
index 4136b9429597..b648751cdaa3 100644
--- a/drivers/staging/rtl8187se/r8180_rtl8225z2.c
+++ b/drivers/staging/rtl8187se/r8180_rtl8225z2.c
@@ -14,64 +14,76 @@
#include "r8180_rtl8225.h"
#include "r8180_93cx6.h"
-#ifdef ENABLE_DOT11D
-#include "dot11d.h"
-#endif
+#include "ieee80211/dot11d.h"
-#ifdef CONFIG_RTL8185B
-extern u8 rtl8225_agc[];
+static void write_rtl8225(struct net_device *dev, u8 adr, u16 data)
+{
+ int i;
+ u16 out, select;
+ u8 bit;
+ u32 bangdata = (data << 4) | (adr & 0xf);
+ struct r8180_priv *priv = ieee80211_priv(dev);
-extern u32 rtl8225_chan[];
+ out = read_nic_word(dev, RFPinsOutput) & 0xfff3;
-//2005.11.16
-u8 rtl8225z2_threshold[]={
- 0x8d, 0x8d, 0x8d, 0x8d, 0x9d, 0xad, 0xbd,
-};
+ write_nic_word(dev, RFPinsEnable,
+ (read_nic_word(dev, RFPinsEnable) | 0x7));
-// 0xd 0x19 0x1b 0x21
-u8 rtl8225z2_gain_bg[]={
- 0x23, 0x15, 0xa5, // -82-1dbm
- 0x23, 0x15, 0xb5, // -82-2dbm
- 0x23, 0x15, 0xc5, // -82-3dbm
- 0x33, 0x15, 0xc5, // -78dbm
- 0x43, 0x15, 0xc5, // -74dbm
- 0x53, 0x15, 0xc5, // -70dbm
- 0x63, 0x15, 0xc5, // -66dbm
-};
+ select = read_nic_word(dev, RFPinsSelect);
-u8 rtl8225z2_gain_a[]={
- 0x13,0x27,0x5a,//,0x37,// -82dbm
- 0x23,0x23,0x58,//,0x37,// -82dbm
- 0x33,0x1f,0x56,//,0x37,// -82dbm
- 0x43,0x1b,0x54,//,0x37,// -78dbm
- 0x53,0x17,0x51,//,0x37,// -74dbm
- 0x63,0x24,0x4f,//,0x37,// -70dbm
- 0x73,0x0f,0x4c,//,0x37,// -66dbm
-};
-#if 0
-u32 rtl8225_chan[] = {
- 0, //dummy channel 0
- 0x085c, //1
- 0x08dc, //2
- 0x095c, //3
- 0x09dc, //4
- 0x0a5c, //5
- 0x0adc, //6
- 0x0b5c, //7
- 0x0bdc, //8
- 0x0c5c, //9
- 0x0cdc, //10
- 0x0d5c, //11
- 0x0ddc, //12
- 0x0e5c, //13
- //0x0f5c, //14
- 0x0f72, // 14
-};
-#endif
+ write_nic_word(dev, RFPinsSelect, select | 0x7 |
+ ((priv->card_type == USB) ? 0 : SW_CONTROL_GPIO));
+
+ force_pci_posting(dev);
+ udelay(10);
+
+ write_nic_word(dev, RFPinsOutput, out | BB_HOST_BANG_EN);
+
+ force_pci_posting(dev);
+ udelay(2);
+
+ write_nic_word(dev, RFPinsOutput, out);
+
+ force_pci_posting(dev);
+ udelay(10);
+
+ for (i = 15; i >= 0; i--) {
+ bit = (bangdata & (1 << i)) >> i;
+
+ write_nic_word(dev, RFPinsOutput, bit | out);
-//-
-u16 rtl8225z2_rxgain[]={
+ write_nic_word(dev, RFPinsOutput, bit | out | BB_HOST_BANG_CLK);
+ write_nic_word(dev, RFPinsOutput, bit | out | BB_HOST_BANG_CLK);
+
+ i--;
+ bit = (bangdata & (1 << i)) >> i;
+
+ write_nic_word(dev, RFPinsOutput, bit | out | BB_HOST_BANG_CLK);
+ write_nic_word(dev, RFPinsOutput, bit | out | BB_HOST_BANG_CLK);
+
+ write_nic_word(dev, RFPinsOutput, bit | out);
+
+ }
+
+ write_nic_word(dev, RFPinsOutput, out | BB_HOST_BANG_EN);
+
+ force_pci_posting(dev);
+ udelay(10);
+
+ write_nic_word(dev, RFPinsOutput, out |
+ ((priv->card_type == USB) ? 4 : BB_HOST_BANG_EN));
+
+ write_nic_word(dev, RFPinsSelect, select |
+ ((priv->card_type == USB) ? 0 : SW_CONTROL_GPIO));
+
+ if (priv->card_type == USB)
+ mdelay(2);
+ else
+ rtl8185_rf_pins_enable(dev);
+}
+
+static const u16 rtl8225bcd_rxgain[] = {
0x0400, 0x0401, 0x0402, 0x0403, 0x0404, 0x0405, 0x0408, 0x0409,
0x040a, 0x040b, 0x0502, 0x0503, 0x0504, 0x0505, 0x0540, 0x0541,
0x0542, 0x0543, 0x0544, 0x0545, 0x0580, 0x0581, 0x0582, 0x0583,
@@ -82,127 +94,234 @@ u16 rtl8225z2_rxgain[]={
0x078a, 0x078b, 0x078c, 0x078d, 0x0790, 0x0791, 0x0792, 0x0793,
0x0794, 0x0795, 0x0798, 0x0799, 0x079a, 0x079b, 0x079c, 0x079d,
0x07a0, 0x07a1, 0x07a2, 0x07a3, 0x07a4, 0x07a5, 0x07a8, 0x07a9,
- 0x03aa, 0x03ab, 0x03ac, 0x03ad, 0x03b0, 0x03b1, 0x03b2, 0x03b3,
- 0x03b4, 0x03b5, 0x03b8, 0x03b9, 0x03ba, 0x03bb, 0x03bb
+ 0x07aa, 0x07ab, 0x07ac, 0x07ad, 0x07b0, 0x07b1, 0x07b2, 0x07b3,
+ 0x07b4, 0x07b5, 0x07b8, 0x07b9, 0x07ba, 0x07bb, 0x07bb
};
-//2005.11.16,
-u8 ZEBRA2_CCK_OFDM_GAIN_SETTING[]={
- 0x00,0x01,0x02,0x03,0x04,0x05,
- 0x06,0x07,0x08,0x09,0x0a,0x0b,
- 0x0c,0x0d,0x0e,0x0f,0x10,0x11,
- 0x12,0x13,0x14,0x15,0x16,0x17,
- 0x18,0x19,0x1a,0x1b,0x1c,0x1d,
- 0x1e,0x1f,0x20,0x21,0x22,0x23,
+static const u8 rtl8225_agc[] = {
+ 0x9e, 0x9e, 0x9e, 0x9e, 0x9e, 0x9e, 0x9e, 0x9e,
+ 0x9d, 0x9c, 0x9b, 0x9a, 0x99, 0x98, 0x97, 0x96,
+ 0x95, 0x94, 0x93, 0x92, 0x91, 0x90, 0x8f, 0x8e,
+ 0x8d, 0x8c, 0x8b, 0x8a, 0x89, 0x88, 0x87, 0x86,
+ 0x85, 0x84, 0x83, 0x82, 0x81, 0x80, 0x3f, 0x3e,
+ 0x3d, 0x3c, 0x3b, 0x3a, 0x39, 0x38, 0x37, 0x36,
+ 0x35, 0x34, 0x33, 0x32, 0x31, 0x30, 0x2f, 0x2e,
+ 0x2d, 0x2c, 0x2b, 0x2a, 0x29, 0x28, 0x27, 0x26,
+ 0x25, 0x24, 0x23, 0x22, 0x21, 0x20, 0x1f, 0x1e,
+ 0x1d, 0x1c, 0x1b, 0x1a, 0x19, 0x18, 0x17, 0x16,
+ 0x15, 0x14, 0x13, 0x12, 0x11, 0x10, 0x0f, 0x0e,
+ 0x0d, 0x0c, 0x0b, 0x0a, 0x09, 0x08, 0x07, 0x06,
+ 0x05, 0x04, 0x03, 0x02, 0x01, 0x01, 0x01, 0x01,
+ 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01,
+ 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01,
+ 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01,
};
-#if 0
-//-
-u8 rtl8225_agc[]={
- 0x9e,0x9e,0x9e,0x9e,0x9e,0x9e,0x9e,0x9e,0x9d,0x9c,0x9b,0x9a,0x99,0x98,0x97,0x96,
- 0x95,0x94,0x93,0x92,0x91,0x90,0x8f,0x8e,0x8d,0x8c,0x8b,0x8a,0x89,0x88,0x87,0x86,
- 0x85,0x84,0x83,0x82,0x81,0x80,0x3f,0x3e,0x3d,0x3c,0x3b,0x3a,0x39,0x38,0x37,0x36,
- 0x35,0x34,0x33,0x32,0x31,0x30,0x2f,0x2e,0x2d,0x2c,0x2b,0x2a,0x29,0x28,0x27,0x26,
- 0x25,0x24,0x23,0x22,0x21,0x20,0x1f,0x1e,0x1d,0x1c,0x1b,0x1a,0x19,0x18,0x17,0x16,
- 0x15,0x14,0x13,0x12,0x11,0x10,0x0f,0x0e,0x0d,0x0c,0x0b,0x0a,0x09,0x08,0x07,0x06,
- 0x05,0x04,0x03,0x02,0x01,0x01,0x01,0x01,0x01,0x01,0x01,0x01,0x01,0x01,0x01,0x01,
- 0x01,0x01,0x01,0x01,0x01,0x01,0x01,0x01,0x01,0x01,0x01,0x01,0x01,0x01,0x01,0x01,
-};
-#endif
-/*
- from 0 to 0x23
-u8 rtl8225_tx_gain_cck_ofdm[]={
- 0x02,0x06,0x0e,0x1e,0x3e,0x7e
+static const u8 rtl8225_gain[] = {
+ 0x23, 0x88, 0x7c, 0xa5, /* -82dBm */
+ 0x23, 0x88, 0x7c, 0xb5, /* -82dBm */
+ 0x23, 0x88, 0x7c, 0xc5, /* -82dBm */
+ 0x33, 0x80, 0x79, 0xc5, /* -78dBm */
+ 0x43, 0x78, 0x76, 0xc5, /* -74dBm */
+ 0x53, 0x60, 0x73, 0xc5, /* -70dBm */
+ 0x63, 0x58, 0x70, 0xc5, /* -66dBm */
};
-*/
-//-
-u8 rtl8225z2_tx_power_ofdm[]={
- 0x42,0x00,0x40,0x00,0x40
+static const u8 rtl8225_tx_gain_cck_ofdm[] = {
+ 0x02, 0x06, 0x0e, 0x1e, 0x3e, 0x7e
};
-
-//-
-u8 rtl8225z2_tx_power_cck_ch14[]={
- 0x36,0x35,0x2e,0x1b,0x00,0x00,0x00,0x00
+static const u8 rtl8225_tx_power_cck[] = {
+ 0x18, 0x17, 0x15, 0x11, 0x0c, 0x08, 0x04, 0x02,
+ 0x1b, 0x1a, 0x17, 0x13, 0x0e, 0x09, 0x04, 0x02,
+ 0x1f, 0x1e, 0x1a, 0x15, 0x10, 0x0a, 0x05, 0x02,
+ 0x22, 0x21, 0x1d, 0x18, 0x11, 0x0b, 0x06, 0x02,
+ 0x26, 0x25, 0x21, 0x1b, 0x14, 0x0d, 0x06, 0x03,
+ 0x2b, 0x2a, 0x25, 0x1e, 0x16, 0x0e, 0x07, 0x03
};
+static const u8 rtl8225_tx_power_cck_ch14[] = {
+ 0x18, 0x17, 0x15, 0x0c, 0x00, 0x00, 0x00, 0x00,
+ 0x1b, 0x1a, 0x17, 0x0e, 0x00, 0x00, 0x00, 0x00,
+ 0x1f, 0x1e, 0x1a, 0x0f, 0x00, 0x00, 0x00, 0x00,
+ 0x22, 0x21, 0x1d, 0x11, 0x00, 0x00, 0x00, 0x00,
+ 0x26, 0x25, 0x21, 0x13, 0x00, 0x00, 0x00, 0x00,
+ 0x2b, 0x2a, 0x25, 0x15, 0x00, 0x00, 0x00, 0x00
+};
-//-
-u8 rtl8225z2_tx_power_cck[]={
- 0x36,0x35,0x2e,0x25,0x1c,0x12,0x09,0x04
+static const u8 rtl8225_tx_power_ofdm[] = {
+ 0x80, 0x90, 0xa2, 0xb5, 0xcb, 0xe4
};
+static const u32 rtl8225_chan[] = {
+ 0,
+ 0x0080, 0x0100, 0x0180, 0x0200, 0x0280, 0x0300, 0x0380,
+ 0x0400, 0x0480, 0x0500, 0x0580, 0x0600, 0x0680, 0x074A,
+};
-void rtl8225z2_set_gain(struct net_device *dev, short gain)
+static void rtl8225_SetTXPowerLevel(struct net_device *dev, short ch)
{
- u8* rtl8225_gain;
struct r8180_priv *priv = ieee80211_priv(dev);
+ int GainIdx;
+ int GainSetting;
+ int i;
+ u8 power;
+ const u8 *cck_power_table;
+ u8 max_cck_power_level;
+ u8 max_ofdm_power_level;
+ u8 min_ofdm_power_level;
+ u8 cck_power_level = 0xff & priv->chtxpwr[ch];
+ u8 ofdm_power_level = 0xff & priv->chtxpwr_ofdm[ch];
+
+ if (priv->card_type == USB) {
+ max_cck_power_level = 11;
+ max_ofdm_power_level = 25;
+ min_ofdm_power_level = 10;
+ } else {
+ max_cck_power_level = 35;
+ max_ofdm_power_level = 35;
+ min_ofdm_power_level = 0;
+ }
- u8 mode = priv->ieee80211->mode;
+ if (cck_power_level > max_cck_power_level)
+ cck_power_level = max_cck_power_level;
- if(mode == IEEE_B || mode == IEEE_G)
- rtl8225_gain = rtl8225z2_gain_bg;
+ GainIdx = cck_power_level % 6;
+ GainSetting = cck_power_level / 6;
+
+ if (ch == 14)
+ cck_power_table = rtl8225_tx_power_cck_ch14;
else
- rtl8225_gain = rtl8225z2_gain_a;
+ cck_power_table = rtl8225_tx_power_cck;
- //write_phy_ofdm(dev, 0x0d, rtl8225_gain[gain * 3]);
- //write_phy_ofdm(dev, 0x19, rtl8225_gain[gain * 3 + 1]);
- //write_phy_ofdm(dev, 0x1b, rtl8225_gain[gain * 3 + 2]);
- //2005.11.17, by ch-hsu
- write_phy_ofdm(dev, 0x0b, rtl8225_gain[gain * 3]);
- write_phy_ofdm(dev, 0x1b, rtl8225_gain[gain * 3 + 1]);
- write_phy_ofdm(dev, 0x1d, rtl8225_gain[gain * 3 + 2]);
- write_phy_ofdm(dev, 0x21, 0x37);
+ write_nic_byte(dev, TX_GAIN_CCK,
+ rtl8225_tx_gain_cck_ofdm[GainSetting] >> 1);
+
+ for (i = 0; i < 8; i++) {
+ power = cck_power_table[GainIdx * 8 + i];
+ write_phy_cck(dev, 0x44 + i, power);
+ }
+
+ /* FIXME Is this delay really needeed ? */
+ force_pci_posting(dev);
+ mdelay(1);
+
+ if (ofdm_power_level > (max_ofdm_power_level - min_ofdm_power_level))
+ ofdm_power_level = max_ofdm_power_level;
+ else
+ ofdm_power_level += min_ofdm_power_level;
+ if (ofdm_power_level > 35)
+ ofdm_power_level = 35;
+
+ GainIdx = ofdm_power_level % 6;
+ GainSetting = ofdm_power_level / 6;
+
+ rtl8185_set_anaparam2(dev, RTL8225_ANAPARAM2_ON);
+
+ write_phy_ofdm(dev, 2, 0x42);
+ write_phy_ofdm(dev, 6, 0x00);
+ write_phy_ofdm(dev, 8, 0x00);
+
+ write_nic_byte(dev, TX_GAIN_OFDM,
+ rtl8225_tx_gain_cck_ofdm[GainSetting] >> 1);
+
+ power = rtl8225_tx_power_ofdm[GainIdx];
+
+ write_phy_ofdm(dev, 5, power);
+ write_phy_ofdm(dev, 7, power);
+
+ force_pci_posting(dev);
+ mdelay(1);
}
-#if 0
+static const u8 rtl8225z2_threshold[] = {
+ 0x8d, 0x8d, 0x8d, 0x8d, 0x9d, 0xad, 0xbd,
+};
-void rtl8225_set_gain(struct net_device *dev, short gain)
-{
- struct r8180_priv *priv = ieee80211_priv(dev);
+static const u8 rtl8225z2_gain_bg[] = {
+ 0x23, 0x15, 0xa5, /* -82-1dBm */
+ 0x23, 0x15, 0xb5, /* -82-2dBm */
+ 0x23, 0x15, 0xc5, /* -82-3dBm */
+ 0x33, 0x15, 0xc5, /* -78dBm */
+ 0x43, 0x15, 0xc5, /* -74dBm */
+ 0x53, 0x15, 0xc5, /* -70dBm */
+ 0x63, 0x15, 0xc5, /* -66dBm */
+};
- rtl8180_set_anaparam(dev, RTL8225_ANAPARAM_ON);
+static const u8 rtl8225z2_gain_a[] = {
+ 0x13, 0x27, 0x5a, /* -82dBm */
+ 0x23, 0x23, 0x58, /* -82dBm */
+ 0x33, 0x1f, 0x56, /* -82dBm */
+ 0x43, 0x1b, 0x54, /* -78dBm */
+ 0x53, 0x17, 0x51, /* -74dBm */
+ 0x63, 0x24, 0x4f, /* -70dBm */
+ 0x73, 0x0f, 0x4c, /* -66dBm */
+};
- if(priv->card_8185 == 2)
- write_phy_ofdm(dev, 0x21, 0x27);
- else
- write_phy_ofdm(dev, 0x21, 0x37);
+static const u16 rtl8225z2_rxgain[] = {
+ 0x0400, 0x0401, 0x0402, 0x0403, 0x0404, 0x0405, 0x0408, 0x0409,
+ 0x040a, 0x040b, 0x0502, 0x0503, 0x0504, 0x0505, 0x0540, 0x0541,
+ 0x0542, 0x0543, 0x0544, 0x0545, 0x0580, 0x0581, 0x0582, 0x0583,
+ 0x0584, 0x0585, 0x0588, 0x0589, 0x058a, 0x058b, 0x0643, 0x0644,
+ 0x0645, 0x0680, 0x0681, 0x0682, 0x0683, 0x0684, 0x0685, 0x0688,
+ 0x0689, 0x068a, 0x068b, 0x068c, 0x0742, 0x0743, 0x0744, 0x0745,
+ 0x0780, 0x0781, 0x0782, 0x0783, 0x0784, 0x0785, 0x0788, 0x0789,
+ 0x078a, 0x078b, 0x078c, 0x078d, 0x0790, 0x0791, 0x0792, 0x0793,
+ 0x0794, 0x0795, 0x0798, 0x0799, 0x079a, 0x079b, 0x079c, 0x079d,
+ 0x07a0, 0x07a1, 0x07a2, 0x07a3, 0x07a4, 0x07a5, 0x07a8, 0x07a9,
+ 0x03aa, 0x03ab, 0x03ac, 0x03ad, 0x03b0, 0x03b1, 0x03b2, 0x03b3,
+ 0x03b4, 0x03b5, 0x03b8, 0x03b9, 0x03ba, 0x03bb, 0x03bb
- write_phy_ofdm(dev, 0x25, 0x20);
- write_phy_ofdm(dev, 0x11, 0x6);
+};
+
+static const u8 ZEBRA2_CCK_OFDM_GAIN_SETTING[] = {
+ 0x00, 0x01, 0x02, 0x03, 0x04, 0x05,
+ 0x06, 0x07, 0x08, 0x09, 0x0a, 0x0b,
+ 0x0c, 0x0d, 0x0e, 0x0f, 0x10, 0x11,
+ 0x12, 0x13, 0x14, 0x15, 0x16, 0x17,
+ 0x18, 0x19, 0x1a, 0x1b, 0x1c, 0x1d,
+ 0x1e, 0x1f, 0x20, 0x21, 0x22, 0x23,
+};
+
+static const u8 rtl8225z2_tx_power_ofdm[] = {
+ 0x42, 0x00, 0x40, 0x00, 0x40
+};
+
+static const u8 rtl8225z2_tx_power_cck_ch14[] = {
+ 0x36, 0x35, 0x2e, 0x1b, 0x00, 0x00, 0x00, 0x00
+};
- if(priv->card_8185 == 1 && priv->card_8185_Bversion)
- write_phy_ofdm(dev, 0x27, 0x8);
+static const u8 rtl8225z2_tx_power_cck[] = {
+ 0x36, 0x35, 0x2e, 0x25, 0x1c, 0x12, 0x09, 0x04
+};
+
+void rtl8225z2_set_gain(struct net_device *dev, short gain)
+{
+ const u8 *rtl8225_gain;
+ struct r8180_priv *priv = ieee80211_priv(dev);
+ u8 mode = priv->ieee80211->mode;
+
+ if (mode == IEEE_B || mode == IEEE_G)
+ rtl8225_gain = rtl8225z2_gain_bg;
else
- write_phy_ofdm(dev, 0x27, 0x88);
-
- write_phy_ofdm(dev, 0x14, 0);
- write_phy_ofdm(dev, 0x16, 0);
- write_phy_ofdm(dev, 0x15, 0x40);
- write_phy_ofdm(dev, 0x17, 0x40);
-
- write_phy_ofdm(dev, 0x0d, rtl8225_gain[gain * 4]);
- write_phy_ofdm(dev, 0x23, rtl8225_gain[gain * 4 + 1]);
- write_phy_ofdm(dev, 0x1b, rtl8225_gain[gain * 4 + 2]);
- write_phy_ofdm(dev, 0x1d, rtl8225_gain[gain * 4 + 3]);
- //rtl8225_set_gain_usb(dev, gain);
+ rtl8225_gain = rtl8225z2_gain_a;
+
+ write_phy_ofdm(dev, 0x0b, rtl8225_gain[gain * 3]);
+ write_phy_ofdm(dev, 0x1b, rtl8225_gain[gain * 3 + 1]);
+ write_phy_ofdm(dev, 0x1d, rtl8225_gain[gain * 3 + 2]);
+ write_phy_ofdm(dev, 0x21, 0x37);
}
-#endif
-u32 read_rtl8225(struct net_device *dev, u8 adr)
+static u32 read_rtl8225(struct net_device *dev, u8 adr)
{
u32 data2Write = ((u32)(adr & 0x1f)) << 27;
u32 dataRead;
u32 mask;
u16 oval,oval2,oval3,tmp;
-// ThreeWireReg twreg;
-// ThreeWireReg tdata;
int i;
short bit, rw;
-
u8 wLength = 6;
u8 rLength = 12;
u8 low2high = 0;
@@ -225,8 +344,8 @@ u32 read_rtl8225(struct net_device *dev, u8 adr)
rw = 0;
mask = (low2high) ? 0x01 : (((u32)0x01)<<(32-1));
- for(i = 0; i < wLength/2; i++)
- {
+
+ for (i = 0; i < wLength/2; i++) {
bit = ((data2Write&mask) != 0) ? 1 : 0;
write_nic_word(dev, RFPinsOutput, bit|oval | rw); udelay(1);
@@ -235,8 +354,7 @@ u32 read_rtl8225(struct net_device *dev, u8 adr)
mask = (low2high) ? (mask<<1): (mask>>1);
- if(i == 2)
- {
+ if (i == 2) {
rw = BB_HOST_BANG_RW;
write_nic_word(dev, RFPinsOutput, bit|oval | BB_HOST_BANG_CLK | rw); udelay(2);
write_nic_word(dev, RFPinsOutput, bit|oval | rw); udelay(2);
@@ -253,17 +371,16 @@ u32 read_rtl8225(struct net_device *dev, u8 adr)
mask = (low2high) ? (mask<<1) : (mask>>1);
}
- //twreg.struc.clk = 0;
- //twreg.struc.data = 0;
write_nic_word(dev, RFPinsOutput, rw|oval); udelay(2);
mask = (low2high) ? 0x01 : (((u32)0x01) << (12-1));
- // We must set data pin to HW controled, otherwise RF can't driver it and
- // value RF register won't be able to read back properly. 2006.06.13, by rcnjko.
+ /*
+ * We must set data pin to HW controled, otherwise RF can't driver it
+ * and value RF register won't be able to read back properly.
+ */
write_nic_word(dev, RFPinsEnable, (oval2 & (~0x01)));
- for(i = 0; i < rLength; i++)
- {
+ for (i = 0; i < rLength; i++) {
write_nic_word(dev, RFPinsOutput, rw|oval); udelay(1);
write_nic_word(dev, RFPinsOutput, rw|oval|BB_HOST_BANG_CLK); udelay(2);
@@ -281,144 +398,27 @@ u32 read_rtl8225(struct net_device *dev, u8 adr)
write_nic_word(dev, RFPinsOutput, BB_HOST_BANG_EN|BB_HOST_BANG_RW|oval); udelay(2);
write_nic_word(dev, RFPinsEnable, oval2);
- write_nic_word(dev, RFPinsSelect, oval3); // Set To SW Switch
+ write_nic_word(dev, RFPinsSelect, oval3); /* Set To SW Switch */
write_nic_word(dev, RFPinsOutput, 0x3a0);
return dataRead;
-
-}
-#if 0
-void write_rtl8225(struct net_device *dev, u8 adr, u16 data)
-{
- int i;
- u16 out,select;
- u8 bit;
- u32 bangdata = (data << 4) | (adr & 0xf);
- struct r8180_priv *priv = ieee80211_priv(dev);
-
- out = read_nic_word(dev, RFPinsOutput) & 0xfff3;
-
- write_nic_word(dev,RFPinsEnable,
- (read_nic_word(dev,RFPinsEnable) | 0x7));
-
- select = read_nic_word(dev, RFPinsSelect);
-
- write_nic_word(dev, RFPinsSelect, select | 0x7 |
- ((priv->card_type == USB) ? 0 : SW_CONTROL_GPIO));
-
- force_pci_posting(dev);
- udelay(10);
-
- write_nic_word(dev, RFPinsOutput, out | BB_HOST_BANG_EN );//| 0x1fff);
-
- force_pci_posting(dev);
- udelay(2);
-
- write_nic_word(dev, RFPinsOutput, out);
-
- force_pci_posting(dev);
- udelay(10);
-
-
- for(i=15; i>=0;i--){
-
- bit = (bangdata & (1<<i)) >> i;
-
- write_nic_word(dev, RFPinsOutput, bit | out);
-
- write_nic_word(dev, RFPinsOutput, bit | out | BB_HOST_BANG_CLK);
- write_nic_word(dev, RFPinsOutput, bit | out | BB_HOST_BANG_CLK);
-
- i--;
- bit = (bangdata & (1<<i)) >> i;
-
- write_nic_word(dev, RFPinsOutput, bit | out | BB_HOST_BANG_CLK);
- write_nic_word(dev, RFPinsOutput, bit | out | BB_HOST_BANG_CLK);
-
- write_nic_word(dev, RFPinsOutput, bit | out);
-
- }
-
- write_nic_word(dev, RFPinsOutput, out | BB_HOST_BANG_EN);
-
- force_pci_posting(dev);
- udelay(10);
-
- write_nic_word(dev, RFPinsOutput, out |
- ((priv->card_type == USB) ? 4 : BB_HOST_BANG_EN));
-
- write_nic_word(dev, RFPinsSelect, select |
- ((priv->card_type == USB) ? 0 : SW_CONTROL_GPIO));
-
- if(priv->card_type == USB)
- mdelay(2);
- else
- rtl8185_rf_pins_enable(dev);
}
-#endif
short rtl8225_is_V_z2(struct net_device *dev)
{
short vz2 = 1;
- //int i;
- /* sw to reg pg 1 */
- //write_rtl8225(dev, 0, 0x1b7);
- //write_rtl8225(dev, 0, 0x0b7);
-
- /* reg 8 pg 1 = 23*/
- //printk(KERN_WARNING "RF Rigisters:\n");
-#if 0
- for(i = 0; i <= 0xf; i++)
- printk(KERN_WARNING "%08x,", read_rtl8225(dev, i));
- //printk(KERN_WARNING "reg[9]@pg1 = 0x%x\n", read_rtl8225(dev, 0x0F));
-
-// printk(KERN_WARNING "RF:\n");
-#endif
- if( read_rtl8225(dev, 8) != 0x588)
- vz2 = 0;
+ if (read_rtl8225(dev, 8) != 0x588)
+ vz2 = 0;
else /* reg 9 pg 1 = 24 */
- if( read_rtl8225(dev, 9) != 0x700)
+ if (read_rtl8225(dev, 9) != 0x700)
vz2 = 0;
/* sw back to pg 0 */
write_rtl8225(dev, 0, 0xb7);
return vz2;
-
-}
-
-#if 0
-void rtl8225_rf_close(struct net_device *dev)
-{
- write_rtl8225(dev, 0x4, 0x1f);
-
- force_pci_posting(dev);
- mdelay(1);
-
- rtl8180_set_anaparam(dev, RTL8225_ANAPARAM_OFF);
- rtl8185_set_anaparam2(dev, RTL8225_ANAPARAM2_OFF);
}
-#endif
-#if 0
-short rtl8225_rf_set_sens(struct net_device *dev, short sens)
-{
- if (sens <0 || sens > 6) return -1;
-
- if(sens > 4)
- write_rtl8225(dev, 0x0c, 0x850);
- else
- write_rtl8225(dev, 0x0c, 0x50);
-
- sens= 6-sens;
- rtl8225_set_gain(dev, sens);
-
- write_phy_cck(dev, 0x41, rtl8225_threshold[sens]);
- return 0;
-
-}
-#endif
-
void rtl8225z2_rf_close(struct net_device *dev)
{
@@ -431,70 +431,55 @@ void rtl8225z2_rf_close(struct net_device *dev)
rtl8185_set_anaparam2(dev, RTL8225z2_ANAPARAM2_OFF);
}
-#ifdef ENABLE_DOT11D
-//
-// Description:
-// Map dBm into Tx power index according to
-// current HW model, for example, RF and PA, and
-// current wireless mode.
-//
-s8
-DbmToTxPwrIdx(
- struct r8180_priv *priv,
- WIRELESS_MODE WirelessMode,
- s32 PowerInDbm
- )
+/*
+ * Map dBm into Tx power index according to current HW model, for example,
+ * RF and PA, and current wireless mode.
+ */
+s8 DbmToTxPwrIdx(struct r8180_priv *priv, WIRELESS_MODE WirelessMode,
+ s32 PowerInDbm)
{
bool bUseDefault = true;
s8 TxPwrIdx = 0;
-#ifdef CONFIG_RTL818X_S
- //
- // 071011, SD3 SY:
- // OFDM Power in dBm = Index * 0.5 + 0
- // CCK Power in dBm = Index * 0.25 + 13
- //
- if(priv->card_8185 >= VERSION_8187S_B)
- {
+ /*
+ * OFDM Power in dBm = Index * 0.5 + 0
+ * CCK Power in dBm = Index * 0.25 + 13
+ */
+ if (priv->card_8185 >= VERSION_8187S_B) {
s32 tmp = 0;
- if(WirelessMode == WIRELESS_MODE_G)
- {
+ if (WirelessMode == WIRELESS_MODE_G) {
bUseDefault = false;
tmp = (2 * PowerInDbm);
- if(tmp < 0)
+ if (tmp < 0)
TxPwrIdx = 0;
- else if(tmp > 40) // 40 means 20 dBm.
+ else if (tmp > 40) /* 40 means 20 dBm. */
TxPwrIdx = 40;
else
TxPwrIdx = (s8)tmp;
- }
- else if(WirelessMode == WIRELESS_MODE_B)
- {
+ } else if (WirelessMode == WIRELESS_MODE_B) {
bUseDefault = false;
tmp = (4 * PowerInDbm) - 52;
if(tmp < 0)
TxPwrIdx = 0;
- else if(tmp > 28) // 28 means 20 dBm.
+ else if (tmp > 28) /* 28 means 20 dBm. */
TxPwrIdx = 28;
else
TxPwrIdx = (s8)tmp;
}
}
-#endif
-
- //
- // TRUE if we want to use a default implementation.
- // We shall set it to FALSE when we have exact translation formular
- // for target IC. 070622, by rcnjko.
- //
- if(bUseDefault)
- {
- if(PowerInDbm < 0)
+
+ /*
+ * TRUE if we want to use a default implementation.
+ * We shall set it to FALSE when we have exact translation formular
+ * for target IC. 070622, by rcnjko.
+ */
+ if (bUseDefault) {
+ if (PowerInDbm < 0)
TxPwrIdx = 0;
- else if(PowerInDbm > 35)
+ else if (PowerInDbm > 35)
TxPwrIdx = 35;
else
TxPwrIdx = (u8)PowerInDbm;
@@ -502,302 +487,140 @@ DbmToTxPwrIdx(
return TxPwrIdx;
}
-#endif
void rtl8225z2_SetTXPowerLevel(struct net_device *dev, short ch)
{
struct r8180_priv *priv = ieee80211_priv(dev);
-
-// int GainIdx;
-// int GainSetting;
- //int i;
- //u8 power;
- //u8 *cck_power_table;
u8 max_cck_power_level;
- //u8 min_cck_power_level;
u8 max_ofdm_power_level;
u8 min_ofdm_power_level;
-// u8 cck_power_level = 0xff & priv->chtxpwr[ch];//-by amy 080312
-// u8 ofdm_power_level = 0xff & priv->chtxpwr_ofdm[ch];//-by amy 080312
- char cck_power_level = (char)(0xff & priv->chtxpwr[ch]);//+by amy 080312
- char ofdm_power_level = (char)(0xff & priv->chtxpwr_ofdm[ch]);//+by amy 080312
-#if 0
- //
- // 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.
- //
- if( priv->OpMode == RT_OP_MODE_INFRASTRUCTURE &&
- priv->bWithCcxCellPwr &&
- ch == priv->dot11CurrentChannelNumber)
- {
- u8 CckCellPwrIdx = DbmToTxPwrIdx(dev, WIRELESS_MODE_B, pMgntInfo->CcxCellPwr);
- u8 OfdmCellPwrIdx = DbmToTxPwrIdx(dev, WIRELESS_MODE_G, pMgntInfo->CcxCellPwr);
-
- printk("CCX Cell Limit: %d dBm => CCK Tx power index : %d, OFDM Tx power index: %d\n",
- priv->CcxCellPwr, CckCellPwrIdx, OfdmCellPwrIdx);
- printk("EEPROM channel(%d) => CCK Tx power index: %d, OFDM Tx power index: %d\n",
- channel, CckTxPwrIdx, OfdmTxPwrIdx);
-
- if(cck_power_level > CckCellPwrIdx)
- cck_power_level = CckCellPwrIdx;
- if(ofdm_power_level > OfdmCellPwrIdx)
- ofdm_power_level = OfdmCellPwrIdx;
-
- printk("Altered CCK Tx power index : %d, OFDM Tx power index: %d\n",
- CckTxPwrIdx, OfdmTxPwrIdx);
- }
-#endif
-#ifdef ENABLE_DOT11D
- if(IS_DOT11D_ENABLE(priv->ieee80211) &&
- IS_DOT11D_STATE_DONE(priv->ieee80211) )
- {
- //PRT_DOT11D_INFO pDot11dInfo = GET_DOT11D_INFO(priv->ieee80211);
+ char cck_power_level = (char)(0xff & priv->chtxpwr[ch]);
+ char ofdm_power_level = (char)(0xff & priv->chtxpwr_ofdm[ch]);
+
+ if (IS_DOT11D_ENABLE(priv->ieee80211) &&
+ IS_DOT11D_STATE_DONE(priv->ieee80211)) {
u8 MaxTxPwrInDbm = DOT11D_GetMaxTxPwrInDbm(priv->ieee80211, ch);
u8 CckMaxPwrIdx = DbmToTxPwrIdx(priv, WIRELESS_MODE_B, MaxTxPwrInDbm);
u8 OfdmMaxPwrIdx = DbmToTxPwrIdx(priv, WIRELESS_MODE_G, MaxTxPwrInDbm);
- //printk("Max Tx Power dBm (%d) => CCK Tx power index : %d, OFDM Tx power index: %d\n", MaxTxPwrInDbm, CckMaxPwrIdx, OfdmMaxPwrIdx);
-
- //printk("EEPROM channel(%d) => CCK Tx power index: %d, OFDM Tx power index: %d\n",
- // ch, cck_power_level, ofdm_power_level);
-
- if(cck_power_level > CckMaxPwrIdx)
+ if (cck_power_level > CckMaxPwrIdx)
cck_power_level = CckMaxPwrIdx;
- if(ofdm_power_level > OfdmMaxPwrIdx)
+ if (ofdm_power_level > OfdmMaxPwrIdx)
ofdm_power_level = OfdmMaxPwrIdx;
}
- //priv->CurrentCckTxPwrIdx = cck_power_level;
- //priv->CurrentOfdmTxPwrIdx = ofdm_power_level;
-#endif
-
max_cck_power_level = 15;
- max_ofdm_power_level = 25; // 12 -> 25
+ max_ofdm_power_level = 25;
min_ofdm_power_level = 10;
-#ifdef CONFIG_RTL8185B
-#ifdef CONFIG_RTL818X_S
-
- if(cck_power_level > 35)
- {
+ if (cck_power_level > 35)
cck_power_level = 35;
- }
- //
- // Set up CCK TXAGC. suggested by SD3 SY.
- //
- write_nic_byte(dev, CCK_TXAGC, (ZEBRA2_CCK_OFDM_GAIN_SETTING[(u8)cck_power_level]) );
- //printk("CCK TX power is %x\n", (ZEBRA2_CCK_OFDM_GAIN_SETTING[cck_power_level]));
- force_pci_posting(dev);
- mdelay(1);
-#else
-
- /* CCK power setting */
- if(cck_power_level > max_cck_power_level)
- cck_power_level = max_cck_power_level;
-
- cck_power_level += priv->cck_txpwr_base;
-
- if(cck_power_level > 35)
- cck_power_level = 35;
-
- if(ch == 14)
- cck_power_table = rtl8225z2_tx_power_cck_ch14;
- else
- cck_power_table = rtl8225z2_tx_power_cck;
-
-
- for(i=0;i<8;i++){
-
- power = cck_power_table[i];
- write_phy_cck(dev, 0x44 + i, power);
- }
-
- //write_nic_byte(dev, TX_GAIN_CCK, power);
- //2005.11.17,
- write_nic_byte(dev, CCK_TXAGC, ZEBRA2_CCK_OFDM_GAIN_SETTING[(u8)cck_power_level]);
+ write_nic_byte(dev, CCK_TXAGC,
+ (ZEBRA2_CCK_OFDM_GAIN_SETTING[(u8)cck_power_level]));
force_pci_posting(dev);
mdelay(1);
-#endif
-#endif
- /* OFDM power setting */
-// Old:
-// if(ofdm_power_level > max_ofdm_power_level)
-// ofdm_power_level = 35;
-// ofdm_power_level += min_ofdm_power_level;
-// Latest:
-/* if(ofdm_power_level > (max_ofdm_power_level - min_ofdm_power_level))
- ofdm_power_level = max_ofdm_power_level;
- else
- ofdm_power_level += min_ofdm_power_level;
- ofdm_power_level += priv->ofdm_txpwr_base;
-*/
- if(ofdm_power_level > 35)
+ if (ofdm_power_level > 35)
ofdm_power_level = 35;
-// rtl8185_set_anaparam2(dev,RTL8225_ANAPARAM2_ON);
-
- //rtl8185_set_anaparam2(dev, ANAPARM2_ASIC_ON);
-
if (priv->up == 0) {
- //must add these for rtl8185B down, xiong-2006-11-21
- write_phy_ofdm(dev,2,0x42);
- write_phy_ofdm(dev,5,0);
- write_phy_ofdm(dev,6,0x40);
- write_phy_ofdm(dev,7,0);
- write_phy_ofdm(dev,8,0x40);
+ write_phy_ofdm(dev, 2, 0x42);
+ write_phy_ofdm(dev, 5, 0x00);
+ write_phy_ofdm(dev, 6, 0x40);
+ write_phy_ofdm(dev, 7, 0x00);
+ write_phy_ofdm(dev, 8, 0x40);
}
- //write_nic_byte(dev, TX_GAIN_OFDM, ofdm_power_level);
- //2005.11.17,
-#ifdef CONFIG_RTL818X_S
- write_nic_byte(dev, OFDM_TXAGC, ZEBRA2_CCK_OFDM_GAIN_SETTING[(u8)ofdm_power_level]);
-#else
- write_nic_byte(dev, OFDM_TXAGC, ZEBRA2_CCK_OFDM_GAIN_SETTING[(u8)ofdm_power_level]*2);
-#endif
- if(ofdm_power_level<=11)
- {
-// write_nic_dword(dev,PHY_ADR,0x00005c87);
-// write_nic_dword(dev,PHY_ADR,0x00005c89);
- write_phy_ofdm(dev,0x07,0x5c);
- write_phy_ofdm(dev,0x09,0x5c);
- }
- if(ofdm_power_level<=17)
- {
-// write_nic_dword(dev,PHY_ADR,0x00005487);
-// write_nic_dword(dev,PHY_ADR,0x00005489);
- write_phy_ofdm(dev,0x07,0x54);
- write_phy_ofdm(dev,0x09,0x54);
- }
- else
- {
-// write_nic_dword(dev,PHY_ADR,0x00005087);
-// write_nic_dword(dev,PHY_ADR,0x00005089);
- write_phy_ofdm(dev,0x07,0x50);
- write_phy_ofdm(dev,0x09,0x50);
+ write_nic_byte(dev, OFDM_TXAGC,
+ ZEBRA2_CCK_OFDM_GAIN_SETTING[(u8)ofdm_power_level]);
+
+ if (ofdm_power_level <= 11) {
+ write_phy_ofdm(dev, 0x07, 0x5c);
+ write_phy_ofdm(dev, 0x09, 0x5c);
}
+
+ if (ofdm_power_level <= 17) {
+ write_phy_ofdm(dev, 0x07, 0x54);
+ write_phy_ofdm(dev, 0x09, 0x54);
+ } else {
+ write_phy_ofdm(dev, 0x07, 0x50);
+ write_phy_ofdm(dev, 0x09, 0x50);
+ }
+
force_pci_posting(dev);
mdelay(1);
-
-}
-#if 0
-/* switch between mode B and G */
-void rtl8225_set_mode(struct net_device *dev, short modeb)
-{
- write_phy_ofdm(dev, 0x15, (modeb ? 0x0 : 0x40));
- write_phy_ofdm(dev, 0x17, (modeb ? 0x0 : 0x40));
}
-#endif
void rtl8225z2_rf_set_chan(struct net_device *dev, short ch)
{
-/*
- short gset = (priv->ieee80211->state == IEEE80211_LINKED &&
- ieee80211_is_54g(priv->ieee80211->current_network)) ||
- priv->ieee80211->iw_mode == IW_MODE_MONITOR;
-*/
rtl8225z2_SetTXPowerLevel(dev, ch);
RF_WriteReg(dev, 0x7, rtl8225_chan[ch]);
- //YJ,add,080828, if set channel failed, write again
- if((RF_ReadReg(dev, 0x7) & 0x0F80) != rtl8225_chan[ch])
- {
+ if ((RF_ReadReg(dev, 0x7) & 0x0F80) != rtl8225_chan[ch])
RF_WriteReg(dev, 0x7, rtl8225_chan[ch]);
- }
mdelay(1);
force_pci_posting(dev);
mdelay(10);
-//deleted by David : 2006/8/9
-#if 0
- write_nic_byte(dev,SIFS,0x22);// SIFS: 0x22
-
- if(gset)
- write_nic_byte(dev,DIFS,20); //DIFS: 20
- else
- write_nic_byte(dev,DIFS,0x24); //DIFS: 36
-
- if(priv->ieee80211->state == IEEE80211_LINKED &&
- ieee80211_is_shortslot(priv->ieee80211->current_network))
- write_nic_byte(dev,SLOT,0x9); //SLOT: 9
-
- else
- write_nic_byte(dev,SLOT,0x14); //SLOT: 20 (0x14)
-
-
- if(gset){
- write_nic_byte(dev,EIFS,91 - 20); // EIFS: 91 (0x5B)
- write_nic_byte(dev,CW_VAL,0x73); //CW VALUE: 0x37
- //DMESG("using G net params");
- }else{
- write_nic_byte(dev,EIFS,91 - 0x24); // EIFS: 91 (0x5B)
- write_nic_byte(dev,CW_VAL,0xa5); //CW VALUE: 0x37
- //DMESG("using B net params");
- }
-#endif
-
}
-#if 0
-void rtl8225_host_pci_init(struct net_device *dev)
+
+static void rtl8225_host_pci_init(struct net_device *dev)
{
write_nic_word(dev, RFPinsOutput, 0x480);
rtl8185_rf_pins_enable(dev);
- //if(priv->card_8185 == 2 && priv->enable_gpio0 ) /* version D */
- //write_nic_word(dev, RFPinsSelect, 0x88);
- //else
- write_nic_word(dev, RFPinsSelect, 0x88 | SW_CONTROL_GPIO); /* 0x488 | SW_CONTROL_GPIO */
+ write_nic_word(dev, RFPinsSelect, 0x88 | SW_CONTROL_GPIO);
write_nic_byte(dev, GP_ENABLE, 0);
force_pci_posting(dev);
mdelay(200);
- write_nic_word(dev, GP_ENABLE, 0xff & (~(1<<6))); /* bit 6 is for RF on/off detection */
-
-
+ /* bit 6 is for RF on/off detection */
+ write_nic_word(dev, GP_ENABLE, 0xff & (~(1 << 6)));
}
-void rtl8225_host_usb_init(struct net_device *dev)
+static void rtl8225_rf_set_chan(struct net_device *dev, short ch)
{
- write_nic_byte(dev,RFPinsSelect+1,0);
-
- write_nic_byte(dev,GPIO,0);
-
- write_nic_byte_E(dev,0x53,read_nic_byte_E(dev,0x53) | (1<<7));
-
- write_nic_byte(dev,RFPinsSelect+1,4);
-
- write_nic_byte(dev,GPIO,0x20);
-
- write_nic_byte(dev,GP_ENABLE,0);
-
-
- /* Config BB & RF */
- write_nic_word(dev, RFPinsOutput, 0x80);
-
- write_nic_word(dev, RFPinsSelect, 0x80);
+ struct r8180_priv *priv = ieee80211_priv(dev);
+ short gset = (priv->ieee80211->state == IEEE80211_LINKED &&
+ ieee80211_is_54g(priv->ieee80211->current_network)) ||
+ priv->ieee80211->iw_mode == IW_MODE_MONITOR;
- write_nic_word(dev, RFPinsEnable, 0x80);
+ rtl8225_SetTXPowerLevel(dev, ch);
+ write_rtl8225(dev, 0x7, rtl8225_chan[ch]);
- mdelay(100);
+ force_pci_posting(dev);
+ mdelay(10);
- mdelay(1000);
+ if (gset) {
+ write_nic_byte(dev, SIFS, 0x22);
+ write_nic_byte(dev, DIFS, 0x14);
+ } else {
+ write_nic_byte(dev, SIFS, 0x44);
+ write_nic_byte(dev, DIFS, 0x24);
+ }
+ if (priv->ieee80211->state == IEEE80211_LINKED &&
+ ieee80211_is_shortslot(priv->ieee80211->current_network))
+ write_nic_byte(dev, SLOT, 0x9);
+ else
+ write_nic_byte(dev, SLOT, 0x14);
+
+ if (gset) {
+ write_nic_byte(dev, EIFS, 81);
+ write_nic_byte(dev, CW_VAL, 0x73);
+ } else {
+ write_nic_byte(dev, EIFS, 81);
+ write_nic_byte(dev, CW_VAL, 0xa5);
+ }
}
-#endif
+
void rtl8225z2_rf_init(struct net_device *dev)
{
struct r8180_priv *priv = ieee80211_priv(dev);
@@ -808,12 +631,7 @@ void rtl8225z2_rf_init(struct net_device *dev)
priv->chan = channel;
-// rtl8180_set_anaparam(dev, RTL8225_ANAPARAM_ON);
-
-
- if(priv->card_type == USB)
- rtl8225_host_usb_init(dev);
- else
+ if (priv->card_type != USB)
rtl8225_host_pci_init(dev);
write_nic_dword(dev, RF_TIMING, 0x000a8008);
@@ -822,80 +640,40 @@ void rtl8225z2_rf_init(struct net_device *dev)
write_nic_word(dev, BRSR, 0xffff);
-
write_nic_dword(dev, RF_PARA, 0x100044);
- #if 1 //0->1
rtl8180_set_mode(dev, EPROM_CMD_CONFIG);
write_nic_byte(dev, CONFIG3, 0x44);
rtl8180_set_mode(dev, EPROM_CMD_NORMAL);
- #endif
-
rtl8185_rf_pins_enable(dev);
-// mdelay(1000);
-
write_rtl8225(dev, 0x0, 0x2bf); mdelay(1);
-
-
write_rtl8225(dev, 0x1, 0xee0); mdelay(1);
-
write_rtl8225(dev, 0x2, 0x44d); mdelay(1);
-
write_rtl8225(dev, 0x3, 0x441); mdelay(1);
-
-
- write_rtl8225(dev, 0x4, 0x8c3);mdelay(1);
-
-
-
- write_rtl8225(dev, 0x5, 0xc72);mdelay(1);
-// }
-
+ write_rtl8225(dev, 0x4, 0x8c3); mdelay(1);
+ write_rtl8225(dev, 0x5, 0xc72); mdelay(1);
write_rtl8225(dev, 0x6, 0xe6); mdelay(1);
-
write_rtl8225(dev, 0x7, ((priv->card_type == USB)? 0x82a : rtl8225_chan[channel])); mdelay(1);
-
write_rtl8225(dev, 0x8, 0x3f); mdelay(1);
-
- write_rtl8225(dev, 0x9, 0x335); mdelay(1);
-
- write_rtl8225(dev, 0xa, 0x9d4); mdelay(1);
-
- write_rtl8225(dev, 0xb, 0x7bb); mdelay(1);
-
- write_rtl8225(dev, 0xc, 0x850); mdelay(1);
-
-
- write_rtl8225(dev, 0xd, 0xcdf); mdelay(1);
-
+ write_rtl8225(dev, 0x9, 0x335); mdelay(1);
+ write_rtl8225(dev, 0xa, 0x9d4); mdelay(1);
+ write_rtl8225(dev, 0xb, 0x7bb); mdelay(1);
+ write_rtl8225(dev, 0xc, 0x850); mdelay(1);
+ write_rtl8225(dev, 0xd, 0xcdf); mdelay(1);
write_rtl8225(dev, 0xe, 0x2b); mdelay(1);
-
write_rtl8225(dev, 0xf, 0x114);
-
mdelay(100);
-
- //if(priv->card_type != USB) /* maybe not needed even for 8185 */
-// write_rtl8225(dev, 0x7, rtl8225_chan[channel]);
-
write_rtl8225(dev, 0x0, 0x1b7);
- for(i=0;i<95;i++){
- write_rtl8225(dev, 0x1, (u8)(i+1));
-
- #if 0
- if(priv->phy_ver == 1)
- /* version A */
- write_rtl8225(dev, 0x2, rtl8225a_rxgain[i]);
- else
- #endif
- /* version B & C & D*/
-
+ for (i = 0; i < 95; i++) {
+ write_rtl8225(dev, 0x1, (u8)(i + 1));
write_rtl8225(dev, 0x2, rtl8225z2_rxgain[i]);
}
+
write_rtl8225(dev, 0x3, 0x80);
write_rtl8225(dev, 0x5, 0x4);
@@ -903,185 +681,90 @@ void rtl8225z2_rf_init(struct net_device *dev)
write_rtl8225(dev, 0x2, 0xc4d);
- if(priv->card_type == USB){
- // force_pci_posting(dev);
+ if (priv->card_type == USB) {
mdelay(200);
write_rtl8225(dev, 0x2, 0x44d);
-
- // force_pci_posting(dev);
mdelay(100);
+ }
- }//End of if(priv->card_type == USB)
/* FIXME!! rtl8187 we have to check if calibrarion
* is successful and eventually cal. again (repeat
* the two write on reg 2)
- */
- // Check for calibration status, 2005.11.17,
- data = read_rtl8225(dev, 6);
- if (!(data&0x00000080))
- {
- write_rtl8225(dev, 0x02, 0x0c4d);
- force_pci_posting(dev); mdelay(200);
- write_rtl8225(dev, 0x02, 0x044d);
- force_pci_posting(dev); mdelay(100);
- data = read_rtl8225(dev, 6);
- if (!(data&0x00000080))
- {
- DMESGW("RF Calibration Failed!!!!\n");
- }
- }
- //force_pci_posting(dev);
-
- mdelay(200); //200 for 8187
-
+ */
+ data = read_rtl8225(dev, 6);
+ if (!(data & 0x00000080)) {
+ write_rtl8225(dev, 0x02, 0x0c4d);
+ force_pci_posting(dev); mdelay(200);
+ write_rtl8225(dev, 0x02, 0x044d);
+ force_pci_posting(dev); mdelay(100);
+ data = read_rtl8225(dev, 6);
+ if (!(data & 0x00000080))
+ DMESGW("RF Calibration Failed!!!!\n");
+ }
-// //if(priv->card_type != USB){
-// write_rtl8225(dev, 0x2, 0x44d);
-// write_rtl8225(dev, 0x7, rtl8225_chan[channel]);
-// write_rtl8225(dev, 0x2, 0x47d);
-//
-// force_pci_posting(dev);
-// mdelay(100);
-//
-// write_rtl8225(dev, 0x2, 0x44d);
-// //}
+ mdelay(200);
write_rtl8225(dev, 0x0, 0x2bf);
- if(priv->card_type != USB)
+ if (priv->card_type != USB)
rtl8185_rf_pins_enable(dev);
- //set up ZEBRA AGC table, 2005.11.17,
- for(i=0;i<128;i++){
- data = rtl8225_agc[i];
-
- addr = i + 0x80; //enable writing AGC table
- write_phy_ofdm(dev, 0xb, data);
- mdelay(1);
- write_phy_ofdm(dev, 0xa, addr);
-
- mdelay(1);
- }
-#if 0
- for(i=0;i<128;i++){
- write_phy_ofdm(dev, 0xb, rtl8225_agc[i]);
+ for (i = 0; i < 128; i++) {
+ data = rtl8225_agc[i];
+ addr = i + 0x80; /* enable writing AGC table */
+ write_phy_ofdm(dev, 0xb, data);
mdelay(1);
- write_phy_ofdm(dev, 0xa, (u8)i+ 0x80);
+ write_phy_ofdm(dev, 0xa, addr);
mdelay(1);
}
-#endif
force_pci_posting(dev);
mdelay(1);
- write_phy_ofdm(dev, 0x0, 0x1); mdelay(1);
- write_phy_ofdm(dev, 0x1, 0x2); mdelay(1);
- write_phy_ofdm(dev, 0x2, ((priv->card_type == USB)? 0x42 : 0x62)); mdelay(1);
- write_phy_ofdm(dev, 0x3, 0x0); mdelay(1);
- write_phy_ofdm(dev, 0x4, 0x0); mdelay(1);
- write_phy_ofdm(dev, 0x5, 0x0); mdelay(1);
- write_phy_ofdm(dev, 0x6, 0x40); mdelay(1);
- write_phy_ofdm(dev, 0x7, 0x0); mdelay(1);
- write_phy_ofdm(dev, 0x8, 0x40); mdelay(1);
- write_phy_ofdm(dev, 0x9, 0xfe); mdelay(1);
-
- write_phy_ofdm(dev, 0xa, 0x8); mdelay(1);
-
- //write_phy_ofdm(dev, 0x18, 0xef);
- // }
- //}
- write_phy_ofdm(dev, 0xb, 0x80); mdelay(1);
-
- write_phy_ofdm(dev, 0xc, 0x1);mdelay(1);
-
-
- //if(priv->card_type != USB)
- write_phy_ofdm(dev, 0xd, 0x43);
-
- write_phy_ofdm(dev, 0xe, 0xd3);mdelay(1);
-
-
- #if 0
- if(priv->card_8185 == 1){
- if(priv->card_8185_Bversion)
- write_phy_ofdm(dev, 0xf, 0x20);/*ver B*/
- else
- write_phy_ofdm(dev, 0xf, 0x28);/*ver C*/
- }else{
- #endif
- write_phy_ofdm(dev, 0xf, 0x38);mdelay(1);
-/*ver D & 8187*/
-// }
-
-// if(priv->card_8185 == 1 && priv->card_8185_Bversion)
-// write_phy_ofdm(dev, 0x10, 0x04);/*ver B*/
-// else
- write_phy_ofdm(dev, 0x10, 0x84);mdelay(1);
-/*ver C & D & 8187*/
-
- write_phy_ofdm(dev, 0x11, 0x07);mdelay(1);
-/*agc resp time 700*/
-
-
-// if(priv->card_8185 == 2){
- /* Ver D & 8187*/
- write_phy_ofdm(dev, 0x12, 0x20);mdelay(1);
-
- write_phy_ofdm(dev, 0x13, 0x20);mdelay(1);
-
-#if 0
- }else{
- /* Ver B & C*/
- write_phy_ofdm(dev, 0x12, 0x0);
- write_phy_ofdm(dev, 0x13, 0x0);
- }
-#endif
- write_phy_ofdm(dev, 0x14, 0x0); mdelay(1);
+ write_phy_ofdm(dev, 0x00, 0x01); mdelay(1);
+ write_phy_ofdm(dev, 0x01, 0x02); mdelay(1);
+ write_phy_ofdm(dev, 0x02, ((priv->card_type == USB) ? 0x42 : 0x62)); mdelay(1);
+ write_phy_ofdm(dev, 0x03, 0x00); mdelay(1);
+ write_phy_ofdm(dev, 0x04, 0x00); mdelay(1);
+ write_phy_ofdm(dev, 0x05, 0x00); mdelay(1);
+ write_phy_ofdm(dev, 0x06, 0x40); mdelay(1);
+ write_phy_ofdm(dev, 0x07, 0x00); mdelay(1);
+ write_phy_ofdm(dev, 0x08, 0x40); mdelay(1);
+ write_phy_ofdm(dev, 0x09, 0xfe); mdelay(1);
+ write_phy_ofdm(dev, 0x0a, 0x08); mdelay(1);
+ write_phy_ofdm(dev, 0x0b, 0x80); mdelay(1);
+ write_phy_ofdm(dev, 0x0c, 0x01); mdelay(1);
+ write_phy_ofdm(dev, 0x0d, 0x43);
+ write_phy_ofdm(dev, 0x0e, 0xd3); mdelay(1);
+ write_phy_ofdm(dev, 0x0f, 0x38); mdelay(1);
+ write_phy_ofdm(dev, 0x10, 0x84); mdelay(1);
+ write_phy_ofdm(dev, 0x11, 0x07); mdelay(1);
+ write_phy_ofdm(dev, 0x12, 0x20); mdelay(1);
+ write_phy_ofdm(dev, 0x13, 0x20); mdelay(1);
+ write_phy_ofdm(dev, 0x14, 0x00); mdelay(1);
write_phy_ofdm(dev, 0x15, 0x40); mdelay(1);
- write_phy_ofdm(dev, 0x16, 0x0); mdelay(1);
+ write_phy_ofdm(dev, 0x16, 0x00); mdelay(1);
write_phy_ofdm(dev, 0x17, 0x40); mdelay(1);
-
-// if (priv->card_type == USB)
-// write_phy_ofdm(dev, 0x18, 0xef);
-
- write_phy_ofdm(dev, 0x18, 0xef);mdelay(1);
-
-
+ write_phy_ofdm(dev, 0x18, 0xef); mdelay(1);
write_phy_ofdm(dev, 0x19, 0x19); mdelay(1);
write_phy_ofdm(dev, 0x1a, 0x20); mdelay(1);
- write_phy_ofdm(dev, 0x1b, 0x15);mdelay(1);
-
- write_phy_ofdm(dev, 0x1c, 0x4);mdelay(1);
-
- write_phy_ofdm(dev, 0x1d, 0xc5);mdelay(1); //2005.11.17,
-
- write_phy_ofdm(dev, 0x1e, 0x95);mdelay(1);
-
- write_phy_ofdm(dev, 0x1f, 0x75); mdelay(1);
-
-// }
-
- write_phy_ofdm(dev, 0x20, 0x1f);mdelay(1);
-
- write_phy_ofdm(dev, 0x21, 0x17);mdelay(1);
-
- write_phy_ofdm(dev, 0x22, 0x16);mdelay(1);
-
-// if(priv->card_type != USB)
- write_phy_ofdm(dev, 0x23, 0x80);mdelay(1); //FIXME maybe not needed // <>
-
+ write_phy_ofdm(dev, 0x1b, 0x15); mdelay(1);
+ write_phy_ofdm(dev, 0x1c, 0x04); mdelay(1);
+ write_phy_ofdm(dev, 0x1d, 0xc5); mdelay(1);
+ write_phy_ofdm(dev, 0x1e, 0x95); mdelay(1);
+ write_phy_ofdm(dev, 0x1f, 0x75); mdelay(1);
+ write_phy_ofdm(dev, 0x20, 0x1f); mdelay(1);
+ write_phy_ofdm(dev, 0x21, 0x17); mdelay(1);
+ write_phy_ofdm(dev, 0x22, 0x16); mdelay(1);
+ write_phy_ofdm(dev, 0x23, 0x80); mdelay(1); /* FIXME maybe not needed */
write_phy_ofdm(dev, 0x24, 0x46); mdelay(1);
write_phy_ofdm(dev, 0x25, 0x00); mdelay(1);
write_phy_ofdm(dev, 0x26, 0x90); mdelay(1);
-
write_phy_ofdm(dev, 0x27, 0x88); mdelay(1);
-
- // <> Set init. gain to m74dBm.
-
rtl8225z2_set_gain(dev,4);
write_phy_cck(dev, 0x0, 0x98); mdelay(1);
@@ -1089,101 +772,57 @@ void rtl8225z2_rf_init(struct net_device *dev)
write_phy_cck(dev, 0x4, 0x7e); mdelay(1);
write_phy_cck(dev, 0x5, 0x12); mdelay(1);
write_phy_cck(dev, 0x6, 0xfc); mdelay(1);
-
- write_phy_cck(dev, 0x7, 0x78);mdelay(1);
- /* Ver C & D & 8187*/
-
- write_phy_cck(dev, 0x8, 0x2e);mdelay(1);
-
+ write_phy_cck(dev, 0x7, 0x78); mdelay(1);
+ write_phy_cck(dev, 0x8, 0x2e); mdelay(1);
write_phy_cck(dev, 0x10, ((priv->card_type == USB) ? 0x9b: 0x93)); mdelay(1);
write_phy_cck(dev, 0x11, 0x88); mdelay(1);
write_phy_cck(dev, 0x12, 0x47); mdelay(1);
-#if 0
- if(priv->card_8185 == 1 && priv->card_8185_Bversion)
- write_phy_cck(dev, 0x13, 0x98); /* Ver B */
- else
-#endif
- write_phy_cck(dev, 0x13, 0xd0); /* Ver C & D & 8187*/
-
- write_phy_cck(dev, 0x19, 0x0);
+ write_phy_cck(dev, 0x13, 0xd0);
+ write_phy_cck(dev, 0x19, 0x00);
write_phy_cck(dev, 0x1a, 0xa0);
- write_phy_cck(dev, 0x1b, 0x8);
+ write_phy_cck(dev, 0x1b, 0x08);
write_phy_cck(dev, 0x40, 0x86); /* CCK Carrier Sense Threshold */
-
- write_phy_cck(dev, 0x41, 0x8d);mdelay(1);
-
-
+ write_phy_cck(dev, 0x41, 0x8d); mdelay(1);
write_phy_cck(dev, 0x42, 0x15); mdelay(1);
write_phy_cck(dev, 0x43, 0x18); mdelay(1);
-
-
write_phy_cck(dev, 0x44, 0x36); mdelay(1);
write_phy_cck(dev, 0x45, 0x35); mdelay(1);
write_phy_cck(dev, 0x46, 0x2e); mdelay(1);
write_phy_cck(dev, 0x47, 0x25); mdelay(1);
write_phy_cck(dev, 0x48, 0x1c); mdelay(1);
write_phy_cck(dev, 0x49, 0x12); mdelay(1);
- write_phy_cck(dev, 0x4a, 0x9); mdelay(1);
- write_phy_cck(dev, 0x4b, 0x4); mdelay(1);
- write_phy_cck(dev, 0x4c, 0x5);mdelay(1);
-
+ write_phy_cck(dev, 0x4a, 0x09); mdelay(1);
+ write_phy_cck(dev, 0x4b, 0x04); mdelay(1);
+ write_phy_cck(dev, 0x4c, 0x05); mdelay(1);
write_nic_byte(dev, 0x5b, 0x0d); mdelay(1);
-
-
-// <>
-// // TESTR 0xb 8187
-// write_phy_cck(dev, 0x10, 0x93);// & 0xfb);
-//
-// //if(priv->card_type != USB){
-// write_phy_ofdm(dev, 0x2, 0x62);
-// write_phy_ofdm(dev, 0x6, 0x0);
-// write_phy_ofdm(dev, 0x8, 0x0);
-// //}
-
rtl8225z2_SetTXPowerLevel(dev, channel);
-#ifdef CONFIG_RTL818X_S
- write_phy_cck(dev, 0x11, 0x9b); mdelay(1); /* Rx ant A, 0xdb for B */
-#else
- write_phy_cck(dev, 0x10, 0x9b); mdelay(1); /* Rx ant A, 0xdb for B */
-#endif
- write_phy_ofdm(dev, 0x26, 0x90); mdelay(1); /* Rx ant A, 0x10 for B */
- rtl8185_tx_antenna(dev, 0x3); /* TX ant A, 0x0 for B */
+ /* RX antenna default to A */
+ write_phy_cck(dev, 0x11, 0x9b); mdelay(1); /* B: 0xDB */
+ write_phy_ofdm(dev, 0x26, 0x90); mdelay(1); /* B: 0x10 */
+
+ rtl8185_tx_antenna(dev, 0x03); /* B: 0x00 */
/* switch to high-speed 3-wire
* last digit. 2 for both cck and ofdm
*/
- if(priv->card_type == USB)
+ if (priv->card_type == USB)
write_nic_dword(dev, 0x94, 0x3dc00002);
- else{
+ else {
write_nic_dword(dev, 0x94, 0x15c00002);
rtl8185_rf_pins_enable(dev);
}
-// if(priv->card_type != USB)
-// rtl8225_set_gain(dev, 4); /* FIXME this '1' is random */ // <>
-// rtl8225_set_mode(dev, 1); /* FIXME start in B mode */ // <>
-//
-// /* make sure is waken up! */
-// write_rtl8225(dev,0x4, 0x9ff);
-// rtl8180_set_anaparam(dev, RTL8225_ANAPARAM_ON);
-// rtl8185_set_anaparam2(dev, RTL8225_ANAPARAM2_ON);
-
rtl8225_rf_set_chan(dev, priv->chan);
-
- //write_nic_word(dev,BRSR,brsr);
-
- //rtl8225z2_rf_set_mode(dev);
}
void rtl8225z2_rf_set_mode(struct net_device *dev)
{
struct r8180_priv *priv = ieee80211_priv(dev);
- if(priv->ieee80211->mode == IEEE_A)
- {
+ if (priv->ieee80211->mode == IEEE_A) {
write_rtl8225(dev, 0x5, 0x1865);
write_nic_dword(dev, RF_PARA, 0x10084);
write_nic_dword(dev, RF_TIMING, 0xa8008);
@@ -1199,8 +838,7 @@ void rtl8225z2_rf_set_mode(struct net_device *dev)
write_phy_ofdm(dev,0x17, 0x40);
write_nic_dword(dev, 0x94,0x10000000);
- }else{
-
+ } else {
write_rtl8225(dev, 0x5, 0x1864);
write_nic_dword(dev, RF_PARA, 0x10044);
write_nic_dword(dev, RF_TIMING, 0xa8008);
@@ -1219,46 +857,35 @@ void rtl8225z2_rf_set_mode(struct net_device *dev)
}
}
-//lzm mod 080826
-//#define MAX_DOZE_WAITING_TIMES_85B 64
-//#define MAX_POLLING_24F_TIMES_87SE 5
#define MAX_DOZE_WAITING_TIMES_85B 20
-#define MAX_POLLING_24F_TIMES_87SE 10
+#define MAX_POLLING_24F_TIMES_87SE 10
#define LPS_MAX_SLEEP_WAITING_TIMES_87SE 5
-bool
-SetZebraRFPowerState8185(
- struct net_device *dev,
- RT_RF_POWER_STATE eRFPowerState
- )
+bool SetZebraRFPowerState8185(struct net_device *dev,
+ RT_RF_POWER_STATE eRFPowerState)
{
struct r8180_priv *priv = ieee80211_priv(dev);
u8 btCR9346, btConfig3;
- bool bActionAllowed= true, bTurnOffBB = true;//lzm mod 080826
- //u32 DWordContent;
+ bool bActionAllowed = true, bTurnOffBB = true;
u8 u1bTmp;
int i;
- //u16 u2bTFPC = 0;
bool bResult = true;
u8 QueueID;
- if(priv->SetRFPowerStateInProgress == true)
+ if (priv->SetRFPowerStateInProgress == true)
return false;
priv->SetRFPowerStateInProgress = true;
- // enable EEM0 and EEM1 in 9346CR
btCR9346 = read_nic_byte(dev, CR9346);
- write_nic_byte(dev, CR9346, (btCR9346|0xC0) );
- // enable PARM_En in Config3
+ write_nic_byte(dev, CR9346, (btCR9346 | 0xC0));
+
btConfig3 = read_nic_byte(dev, CONFIG3);
- write_nic_byte(dev, CONFIG3, (btConfig3|CONFIG3_PARM_En) );
+ write_nic_byte(dev, CONFIG3, (btConfig3 | CONFIG3_PARM_En));
- switch( priv->rf_chip )
- {
+ switch (priv->rf_chip) {
case RF_ZEBRA2:
- switch( eRFPowerState )
- {
+ switch (eRFPowerState) {
case eRfOn:
RF_WriteReg(dev,0x4,0x9FF);
@@ -1267,247 +894,168 @@ SetZebraRFPowerState8185(
write_nic_byte(dev, CONFIG4, priv->RFProgType);
- //Follow 87B, Isaiah 2007-04-27
+ /* turn on CCK and OFDM */
u1bTmp = read_nic_byte(dev, 0x24E);
- write_nic_byte(dev, 0x24E, (u1bTmp & (~(BIT5|BIT6))) );// 070124 SD1 Alex: turn on CCK and OFDM.
+ write_nic_byte(dev, 0x24E, (u1bTmp & (~(BIT5 | BIT6))));
break;
-
case eRfSleep:
break;
-
case eRfOff:
break;
-
default:
bResult = false;
break;
}
break;
-
case RF_ZEBRA4:
- switch( eRFPowerState )
- {
+ switch (eRFPowerState) {
case eRfOn:
- //printk("===================================power on@jiffies:%d\n",jiffies);
write_nic_word(dev, 0x37C, 0x00EC);
- //turn on AFE
+ /* turn on AFE */
write_nic_byte(dev, 0x54, 0x00);
write_nic_byte(dev, 0x62, 0x00);
- //lzm mod 080826
- //turn on RF
- //RF_WriteReg(dev, 0x0, 0x009f); //mdelay(1);
- //RF_WriteReg(dev, 0x4, 0x0972); //mdelay(1);
+ /* turn on RF */
RF_WriteReg(dev, 0x0, 0x009f); udelay(500);
RF_WriteReg(dev, 0x4, 0x0972); udelay(500);
- //turn on RF again, suggested by SD3 stevenl.
+
+ /* turn on RF again */
RF_WriteReg(dev, 0x0, 0x009f); udelay(500);
RF_WriteReg(dev, 0x4, 0x0972); udelay(500);
- //turn on BB
-// write_nic_dword(dev, PhyAddr, 0x4090); //ofdm 10=00
-// write_nic_dword(dev, PhyAddr, 0x4092); //ofdm 12=00
+ /* turn on BB */
write_phy_ofdm(dev,0x10,0x40);
write_phy_ofdm(dev,0x12,0x40);
- //Avoid power down at init time.
+
+ /* Avoid power down at init time. */
write_nic_byte(dev, CONFIG4, priv->RFProgType);
u1bTmp = read_nic_byte(dev, 0x24E);
- write_nic_byte(dev, 0x24E, (u1bTmp & (~(BIT5|BIT6))) );
-
+ write_nic_byte(dev, 0x24E, (u1bTmp & (~(BIT5 | BIT6))));
break;
-
case eRfSleep:
- // Make sure BusyQueue is empty befor turn off RFE pwoer.
- //printk("===================================power sleep@jiffies:%d\n",jiffies);
-
- for(QueueID = 0, i = 0; QueueID < 6; )
- {
- if(get_curr_tx_free_desc(dev,QueueID) == priv->txringcount)
- {
+ for (QueueID = 0, i = 0; QueueID < 6;) {
+ if (get_curr_tx_free_desc(dev, QueueID) == priv->txringcount) {
QueueID++;
continue;
- }
-#if 0 //reserved amy
- else if(priv->NdisAdapter.CurrentPowerState != NdisDeviceStateD0)
- {
- RT_TRACE(COMP_POWER, DBG_LOUD, ("eRfSleep: %d times TcbBusyQueue[%d] !=0 but lower power state!\n", (pMgntInfo->TxPollingTimes+1), QueueID));
- break;
- }
-#endif
- else//lzm mod 080826
- {
+ } else {
priv->TxPollingTimes ++;
- if(priv->TxPollingTimes >= LPS_MAX_SLEEP_WAITING_TIMES_87SE)
- {
- //RT_TRACE(COMP_POWER, DBG_WARNING, ("\n\n\n SetZebraRFPowerState8185B():eRfSleep: %d times TcbBusyQueue[%d] != 0 !!!\n\n\n", LPS_MAX_SLEEP_WAITING_TIMES_87SE, QueueID));
- bActionAllowed=false;
- break;
- }
- else
- {
- udelay(10); // Windows may delay 3~16ms actually.
- //RT_TRACE(COMP_POWER, DBG_LOUD, ("eRfSleep: %d times TcbBusyQueue[%d] !=0 before doze!\n", (pMgntInfo->TxPollingTimes), QueueID));
- }
+ if (priv->TxPollingTimes >= LPS_MAX_SLEEP_WAITING_TIMES_87SE) {
+ bActionAllowed = false;
+ break;
+ } else
+ udelay(10);
}
-
- //lzm del 080826
- //if(i >= MAX_DOZE_WAITING_TIMES_85B)
- //{
- //printk("\n\n\n SetZebraRFPowerState8185B(): %d times BusyQueue[%d] != 0 !!!\n\n\n", MAX_DOZE_WAITING_TIMES_85B, QueueID);
- //break;
- //}
}
- if(bActionAllowed)//lzm add 080826
- {
- //turn off BB RXIQ matrix to cut off rx signal
-// write_nic_dword(dev, PhyAddr, 0x0090); //ofdm 10=00
-// write_nic_dword(dev, PhyAddr, 0x0092); //ofdm 12=00
- write_phy_ofdm(dev,0x10,0x00);
- write_phy_ofdm(dev,0x12,0x00);
- //turn off RF
- RF_WriteReg(dev, 0x4, 0x0000); //mdelay(1);
- RF_WriteReg(dev, 0x0, 0x0000); //mdelay(1);
- //turn off AFE except PLL
+ if (bActionAllowed) {
+ /* turn off BB RXIQ matrix to cut off rx signal */
+ write_phy_ofdm(dev, 0x10, 0x00);
+ write_phy_ofdm(dev, 0x12, 0x00);
+
+ /* turn off RF */
+ RF_WriteReg(dev, 0x4, 0x0000);
+ RF_WriteReg(dev, 0x0, 0x0000);
+
+ /* turn off AFE except PLL */
write_nic_byte(dev, 0x62, 0xff);
write_nic_byte(dev, 0x54, 0xec);
-// mdelay(10);
-#if 1
mdelay(1);
+
{
int i = 0;
- while (true)
- {
+ while (true) {
u8 tmp24F = read_nic_byte(dev, 0x24f);
- if ((tmp24F == 0x01) || (tmp24F == 0x09))
- {
+
+ if ((tmp24F == 0x01) || (tmp24F == 0x09)) {
bTurnOffBB = true;
break;
- }
- else//lzm mod 080826
- {
+ } else {
udelay(10);
i++;
priv->TxPollingTimes++;
- if(priv->TxPollingTimes >= LPS_MAX_SLEEP_WAITING_TIMES_87SE)
- {
- //RT_TRACE(COMP_POWER, DBG_WARNING, ("\n\n\n SetZebraRFPowerState8185B(): eRfOff: %d times Rx Mac0x24F=0x%x !!!\n\n\n", i, u1bTmp24F));
- bTurnOffBB=false;
+ if (priv->TxPollingTimes >= LPS_MAX_SLEEP_WAITING_TIMES_87SE) {
+ bTurnOffBB = false;
break;
- }
- else
- {
- udelay(10);// Windows may delay 3~16ms actually.
- //RT_TRACE(COMP_POWER, DBG_LOUD,("(%d)eRfSleep- u1bTmp24F= 0x%X\n", i, u1bTmp24F));
-
- }
+ } else
+ udelay(10);
}
-
- //lzm del 080826
- //if (i > MAX_POLLING_24F_TIMES_87SE)
- // break;
}
}
-#endif
- if (bTurnOffBB)//lzm mod 080826
- {
- //turn off BB
- u1bTmp = read_nic_byte(dev, 0x24E);
- write_nic_byte(dev, 0x24E, (u1bTmp|BIT5|BIT6));
- //turn off AFE PLL
- //write_nic_byte(dev, 0x54, 0xec);
- //write_nic_word(dev, 0x37C, 0x00ec);
- write_nic_byte(dev, 0x54, 0xFC); //[ECS] FC-> EC->FC, asked by SD3 Stevenl
- write_nic_word(dev, 0x37C, 0x00FC);//[ECS] FC-> EC->FC, asked by SD3 Stevenl
+ if (bTurnOffBB) {
+ /* turn off BB */
+ u1bTmp = read_nic_byte(dev, 0x24E);
+ write_nic_byte(dev, 0x24E, (u1bTmp | BIT5 | BIT6));
+
+ /* turn off AFE PLL */
+ write_nic_byte(dev, 0x54, 0xFC);
+ write_nic_word(dev, 0x37C, 0x00FC);
}
}
break;
-
case eRfOff:
- // Make sure BusyQueue is empty befor turn off RFE pwoer.
- //printk("===================================power off@jiffies:%d\n",jiffies);
- for(QueueID = 0, i = 0; QueueID < 6; )
- {
- if(get_curr_tx_free_desc(dev,QueueID) == priv->txringcount)
- {
+ for (QueueID = 0, i = 0; QueueID < 6;) {
+ if (get_curr_tx_free_desc(dev, QueueID) == priv->txringcount) {
QueueID++;
continue;
- }
-#if 0
- else if(Adapter->NdisAdapter.CurrentPowerState != NdisDeviceStateD0)
- {
- RT_TRACE(COMP_POWER, DBG_LOUD, ("%d times TcbBusyQueue[%d] !=0 but lower power state!\n", (i+1), QueueID));
- break;
- }
-#endif
- else
- {
+ } else {
udelay(10);
i++;
}
- if(i >= MAX_DOZE_WAITING_TIMES_85B)
- {
- //printk("\n\n\n SetZebraRFPowerState8185B(): %d times BusyQueue[%d] != 0 !!!\n\n\n", MAX_DOZE_WAITING_TIMES_85B, QueueID);
+ if (i >= MAX_DOZE_WAITING_TIMES_85B)
break;
- }
}
- //turn off BB RXIQ matrix to cut off rx signal
-// write_nic_dword(dev, PhyAddr, 0x0090); //ofdm 10=00
-// write_nic_dword(dev, PhyAddr, 0x0092); //ofdm 12=00
- write_phy_ofdm(dev,0x10,0x00);
- write_phy_ofdm(dev,0x12,0x00);
- //turn off RF
- RF_WriteReg(dev, 0x4, 0x0000); //mdelay(1);
- RF_WriteReg(dev, 0x0, 0x0000); //mdelay(1);
- //turn off AFE except PLL
+ /* turn off BB RXIQ matrix to cut off rx signal */
+ write_phy_ofdm(dev, 0x10, 0x00);
+ write_phy_ofdm(dev, 0x12, 0x00);
+
+ /* turn off RF */
+ RF_WriteReg(dev, 0x4, 0x0000);
+ RF_WriteReg(dev, 0x0, 0x0000);
+
+ /* turn off AFE except PLL */
write_nic_byte(dev, 0x62, 0xff);
write_nic_byte(dev, 0x54, 0xec);
-// mdelay(10);
-#if 1
+
mdelay(1);
+
{
int i = 0;
+
while (true)
{
u8 tmp24F = read_nic_byte(dev, 0x24f);
- if ((tmp24F == 0x01) || (tmp24F == 0x09))
- {
+
+ if ((tmp24F == 0x01) || (tmp24F == 0x09)) {
bTurnOffBB = true;
break;
- }
- else
- {
+ } else {
bTurnOffBB = false;
udelay(10);
i++;
}
+
if (i > MAX_POLLING_24F_TIMES_87SE)
break;
}
}
-#endif
- if (bTurnOffBB)//lzm mod 080826
- {
- //turn off BB
- u1bTmp = read_nic_byte(dev, 0x24E);
- write_nic_byte(dev, 0x24E, (u1bTmp|BIT5|BIT6));
- //turn off AFE PLL (80M)
- //write_nic_byte(dev, 0x54, 0xec);
- //write_nic_word(dev, 0x37C, 0x00ec);
- write_nic_byte(dev, 0x54, 0xFC); //[ECS] FC-> EC->FC, asked by SD3 Stevenl
- write_nic_word(dev, 0x37C, 0x00FC); //[ECS] FC-> EC->FC, asked by SD3 Stevenl
- }
+ if (bTurnOffBB) {
+ /* turn off BB */
+ u1bTmp = read_nic_byte(dev, 0x24E);
+ write_nic_byte(dev, 0x24E, (u1bTmp | BIT5 | BIT6));
+ /* turn off AFE PLL (80M) */
+ write_nic_byte(dev, 0x54, 0xFC);
+ write_nic_word(dev, 0x37C, 0x00FC);
+ }
break;
-
default:
bResult = false;
printk("SetZebraRFPowerState8185(): unknow state to set: 0x%X!!!\n", eRFPowerState);
@@ -1516,72 +1064,26 @@ SetZebraRFPowerState8185(
break;
}
- // disable PARM_En in Config3
btConfig3 &= ~(CONFIG3_PARM_En);
write_nic_byte(dev, CONFIG3, btConfig3);
- // disable EEM0 and EEM1 in 9346CR
+
btCR9346 &= ~(0xC0);
write_nic_byte(dev, CR9346, btCR9346);
- if(bResult && bActionAllowed)//lzm mod 080826
- {
- // Update current RF state variable.
+ if (bResult && bActionAllowed)
priv->eRFPowerState = eRFPowerState;
-#if 0
- switch(priv->eRFPowerState)
- {
- case eRfOff:
- //
- //If Rf off reason is from IPS, Led should blink with no link, by Maddest 071015
- //
- if(priv->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);
- }
- break;
-
- default:
- // do nothing.
- break;
- }
-#endif
-
- }
priv->SetRFPowerStateInProgress = false;
- return (bResult && bActionAllowed) ;
+ return bResult && bActionAllowed;
}
+
void rtl8225z4_rf_sleep(struct net_device *dev)
{
- //
- // Turn off RF power.
- //
- //printk("=========>%s()\n", __func__);
MgntActSet_RF_State(dev, eRfSleep, RF_CHANGE_BY_PS);
- //mdelay(2); //FIXME
}
+
void rtl8225z4_rf_wakeup(struct net_device *dev)
{
- //
- // Turn on RF power.
- //
- //printk("=========>%s()\n", __func__);
MgntActSet_RF_State(dev, eRfOn, RF_CHANGE_BY_PS);
}
-#endif
-
diff --git a/drivers/staging/rtl8187se/r8180_rtl8255.c b/drivers/staging/rtl8187se/r8180_rtl8255.c
deleted file mode 100644
index 1a62444dcc50..000000000000
--- a/drivers/staging/rtl8187se/r8180_rtl8255.c
+++ /dev/null
@@ -1,1838 +0,0 @@
-/*
- 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 rtl8255
- radio frontend.
-
- *Many* thanks to Realtek Corp. for their great support!
-
-*/
-
-#define BAND_A 1
-#define BAND_BG 2
-
-#include "r8180.h"
-#include "r8180_hw.h"
-#include "r8180_rtl8255.h"
-
-u32 rtl8255_chan[] = {
- 0, //dummy channel 0
- 0x13, //1
- 0x115, //2
- 0x217, //3
- 0x219, //4
- 0x31b, //5
- 0x41d, //6
- 0x41f, //7
- 0x621, //8
- 0x623, //9
- 0x625, //10
- 0x627, //11
- 0x829, //12
- 0x82b, //13
- 0x92f, // 14
-};
-
-static short rtl8255_gain_2G[]={
- 0x33, 0x17, 0x7c, 0xc5,//-78
- 0x43, 0x17, 0x7a, 0xc5,//-74
- 0x53, 0x17, 0x78, 0xc5,//-70
- 0x63, 0x17, 0x76, 0xc5,//-66
-};
-
-
-static short rtl8255_agc[]={
- 0x1, 0x1, 0x1, 0x1, 0x1, 0x1, 0x1, 0x1, 0x1, 0x1,
-
- 0x1, 0x1, 0x2, 0x2, 0x3, 0x3, 0x4, 0x4, 0x5, 0x5,
- 0x6, 0x6, 0x7, 0x7, 0x8, 0x8, 0x9, 0x9, 0xa, 0xa,
- 0xb, 0xb, 0xc, 0xc, 0xd, 0xd, 0xe, 0xe, 0xf, 0xf,
-
- 0x10, 0x10, 0x11, 0x11, 0x12, 0x12, 0x13, 0x13, 0x14, 0x14,
- 0x15, 0x15, 0x16, 0x16, 0x17, 0x17, 0x18, 0x18, 0x19, 0x19,
- 0x1a, 0x1a, 0x1b, 0x1b, 0x1c, 0x1c, 0x1d, 0x1d, 0x1e, 0x1e,
- 0x1f, 0x1f,
-
- 0x20, 0x20, 0x21, 0x21, 0x22, 0x22, 0x23, 0x23, 0x24, 0x24,
- 0x25, 0x25, 0x26, 0x26, 0x27, 0x27, 0x28, 0x28, 0x29, 0x29,
- 0x2a, 0x2a,
-
- 0x2a, 0x2a, 0x2a, 0x2a, 0x2a, 0x2a, 0x2a, 0x2a, 0x2a, 0x2a,
- 0x2a, 0x2a, 0x2a, 0x2a, 0x2a, 0x2a, 0x2a, 0x2a, 0x2a, 0x2a,
- 0x2a, 0x2a, 0x2a, 0x2a, 0x2a, 0x2a, 0x2a, 0x2a, 0x2a, 0x2a,
- 0x2a, 0x2a, 0x2a, 0x2a
-
-};
-
-void rtl8255_set_gain(struct net_device *dev, short gain)
-{
-
-// struct r8180_priv *priv = ieee80211_priv(dev);
-
- write_phy_ofdm(dev, 0x0d, rtl8255_gain_2G[gain * 4]);
- write_phy_ofdm(dev, 0x23, rtl8255_gain_2G[gain * 4 + 1]);
- write_phy_ofdm(dev, 0x1b, rtl8255_gain_2G[gain * 4 + 2]);
- write_phy_ofdm(dev, 0x1d, rtl8255_gain_2G[gain * 4 + 3]);
- //rtl8225_set_gain_usb(dev, gain);
-}
-
-void write_rtl8255_reg0c(struct net_device *dev, u32 d1, u32 d2, u32 d3, u32 d4,
-u32 d5, u32 d6, u32 d7, u32 d8, u32 d9, u32 d10)
-{
- int i,j;
- u16 out,select;
- u8 bit;
- u32 bangdata;
-// struct r8180_priv *priv = ieee80211_priv(dev);
-
- write_nic_word(dev,RFPinsEnable,
- (read_nic_word(dev,RFPinsEnable) | 0x7));
-
- select = read_nic_word(dev, RFPinsSelect);
-
- write_nic_word(dev, RFPinsSelect, select | 0x7 | SW_CONTROL_GPIO);
-
- out = read_nic_word(dev, RFPinsOutput) & 0xfff3;
-
- write_nic_word(dev, RFPinsOutput, out | BB_HOST_BANG_EN );//| 0x1fff);
-
- force_pci_posting(dev);
- udelay(2);
-
- write_nic_word(dev, RFPinsOutput, out);
-
- force_pci_posting(dev);
- udelay(2);
-
- for(j=0;j<10;j++)
- {
- switch(j)
- {
- case 9:
- bangdata = d10 | 0x0c;
- break;
- case 8:
- bangdata = d9;
- break;
- case 7:
- bangdata = d8;
- break;
- case 6:
- bangdata = d7;
- break;
- case 5:
- bangdata = d6;
- break;
- case 4:
- bangdata = d5;
- break;
- case 3:
- bangdata = d4;
- break;
- case 2:
- bangdata = d3;
- break;
- case 1:
- bangdata = d2;
- break;
- case 0:
- bangdata = d1;
- break;
- default:
- bangdata=0xbadc0de; /* avoid gcc complaints */
- break;
- }
-
- for(i=31; i>=0;i--){
-
- bit = (bangdata & (1<<i)) >> i;
-
- write_nic_word(dev, RFPinsOutput, bit | out);
- force_pci_posting(dev);
- udelay(1);
- write_nic_word(dev, RFPinsOutput, bit | out | BB_HOST_BANG_CLK);
- force_pci_posting(dev);
- udelay(1);
- // write_nic_word(dev, RFPinsOutput, bit | out | BB_HOST_BANG_CLK);
- i--;
- bit = (bangdata & (1<<i)) >> i;
-
- write_nic_word(dev, RFPinsOutput, bit | out | BB_HOST_BANG_CLK);
- force_pci_posting(dev);
- udelay(1);
- // write_nic_word(dev, RFPinsOutput, bit | out | BB_HOST_BANG_CLK);
- write_nic_word(dev, RFPinsOutput, bit | out);
- force_pci_posting(dev);
- udelay(1);
- }
- }
-
- write_nic_word(dev, RFPinsOutput, out | BB_HOST_BANG_EN);
- force_pci_posting(dev);
- udelay(10);
-
-// write_nic_word(dev, RFPinsOutput, out | BB_HOST_BANG_EN);
- write_nic_word(dev, RFPinsSelect, select | SW_CONTROL_GPIO);
-// rtl8185_rf_pins_enable(dev);
-
-}
-
-void write_rtl8255(struct net_device *dev, u8 adr, u16 data)
-{
- int i;
- u16 out,select;
- u8 bit;
- u32 bangdata = (data << 4) | (adr & 0xf);
-// struct r8180_priv *priv = ieee80211_priv(dev);
-
- out = read_nic_word(dev, RFPinsOutput) & 0xfff3;
-
- write_nic_word(dev,RFPinsEnable,
- (read_nic_word(dev,RFPinsEnable) | 0x7));
-
- select = read_nic_word(dev, RFPinsSelect);
-
- write_nic_word(dev, RFPinsSelect, select | 0x7 | SW_CONTROL_GPIO);
-
- force_pci_posting(dev);
- udelay(10);
-
- write_nic_word(dev, RFPinsOutput, out | BB_HOST_BANG_EN );//| 0x1fff);
-
- force_pci_posting(dev);
- udelay(2);
-
- write_nic_word(dev, RFPinsOutput, out);
-
- force_pci_posting(dev);
- udelay(10);
-
-
- for(i=15; i>=0;i--){
-
- bit = (bangdata & (1<<i)) >> i;
-
- write_nic_word(dev, RFPinsOutput, bit | out);
- write_nic_word(dev, RFPinsOutput, bit | out | BB_HOST_BANG_CLK);
- write_nic_word(dev, RFPinsOutput, bit | out | BB_HOST_BANG_CLK);
- i--;
- bit = (bangdata & (1<<i)) >> i;
-
- write_nic_word(dev, RFPinsOutput, bit | out | BB_HOST_BANG_CLK);
- write_nic_word(dev, RFPinsOutput, bit | out | BB_HOST_BANG_CLK);
- write_nic_word(dev, RFPinsOutput, bit | out);
- }
-
-
- write_nic_word(dev, RFPinsOutput, out | BB_HOST_BANG_EN);
-
- force_pci_posting(dev);
- udelay(10);
-
- write_nic_word(dev, RFPinsOutput, out | BB_HOST_BANG_EN);
- write_nic_word(dev, RFPinsSelect, select | SW_CONTROL_GPIO);
-
- rtl8185_rf_pins_enable(dev);
-}
-
-void rtl8255_rf_close(struct net_device *dev)
-{
-
-// rtl8180_set_anaparam(dev, RTL8225_ANAPARAM_OFF);
-// rtl8185_set_anaparam2(dev, RTL8225_ANAPARAM2_OFF);
-}
-
-void rtl8255_SetTXPowerLevel(struct net_device *dev, short ch)
-{
- struct r8180_priv *priv = ieee80211_priv(dev);
-
- u8 cck_power_level = 0xff & priv->chtxpwr[ch];
- u8 ofdm_power_level = 0xff & priv->chtxpwr_ofdm[ch];
- write_nic_byte(dev, TX_GAIN_OFDM, ofdm_power_level);
- write_nic_byte(dev, TX_GAIN_CCK, cck_power_level);
- force_pci_posting(dev);
- mdelay(1);
- //write_nic_byte(dev, TX_AGC_CONTROL,4);
-}
-#if 0
-/* switch between mode B and G */
-void rtl8255_set_mode(struct net_device *dev, short modeb)
-{
- write_phy_ofdm(dev, 0x15, (modeb ? 0x0 : 0x40));
- write_phy_ofdm(dev, 0x17, (modeb ? 0x0 : 0x40));
-}
-#endif
-
-void rtl8255_rf_set_chan(struct net_device *dev, short ch)
-{
- //write_rtl8225(dev, 0x7, rtl8225_chan[1]);
- write_rtl8255(dev, 0x5, 0x65);
- write_rtl8255(dev, 0x6, rtl8255_chan[ch]);
- write_rtl8255(dev, 0x7, 0x7c);
- write_rtl8255(dev, 0x8, 0x6);
-
-
- force_pci_posting(dev);
- set_current_state(TASK_INTERRUPTIBLE);
- schedule_timeout(HZ);
-// rtl8225_set_mode_B(dev);
-
- rtl8255_SetTXPowerLevel(dev, ch);
- /* FIXME FIXME FIXME */
-
- #if 0
- write_nic_byte(dev,DIFS,0xe); //DIFS
- write_nic_byte(dev,SLOT,0x14); //SLOT
- write_nic_byte(dev,EIFS,0x5b); // EIFS
- //write_nic_byte(dev,0xbc,0); //CW CONFIG
- write_nic_byte(dev,0xbd,0xa4); //CW VALUE
- //write_nic_byte(dev,TX_AGC_CONTROL,4);
- //write_nic_byte(dev, 0x9d,7);
-//Apr 20 13:25:03 localhost kernel: w8. 409d<-7 // CCK AGC
- /*write_nic_word(dev,0x84,0x488);
- write_nic_byte(dev,0x91,0x3e);
- write_nic_byte(dev,0x90,0x30);
- write_nic_word(dev,0x84,0x488);
- write_nic_byte(dev,0x91,0x3e);
- write_nic_byte(dev,0x90,0x20);
- */
- //mdelay(100);
- #endif
-}
-
-void rtl8255_init_BGband(struct net_device *dev)
-{
- write_rtl8255(dev, 0x3, 0x0);
- write_rtl8255(dev, 0x1, 0x807);
- write_rtl8255_reg0c(dev, 0x1554, 0xa800403b, 0xf6d44278, 0x804187cf, 0x40000027,
- 0x92402ac0, 0xf0009, 0x28000, 0xc00, 0x0);
- write_rtl8255(dev, 0x1, 0x807);
- write_rtl8255(dev, 0x4, 0xc00);
- write_rtl8255(dev, 0x4, 0xe00);
- write_rtl8255(dev, 0x4, 0xc00);
- write_rtl8255(dev, 0x1, 0x0);
- write_rtl8255(dev, 0x4, 0x800);
- write_rtl8255(dev, 0x3, 0x0);
- write_rtl8255(dev, 0x2, 0x0);
- write_rtl8255(dev, 0x4, 0xa00);
- write_rtl8255(dev, 0x4, 0x800);
- write_rtl8255(dev, 0x4, 0x400);
- write_rtl8255(dev, 0x3, 0x26);
- write_rtl8255(dev, 0x2, 0x27);
- write_rtl8255(dev, 0x4, 0x600);
- write_rtl8255(dev, 0x4, 0x400);
- write_rtl8255(dev, 0x4, 0x400);
- write_rtl8255(dev, 0x3, 0x100);
- write_rtl8255(dev, 0x4, 0x600);
- write_rtl8255(dev, 0x4, 0x400);
- write_rtl8255_reg0c(dev, 0x1554, 0xa800403b, 0xf6d44278, 0x804187ce, 0x80000027,
- 0x92402ac0, 0xf0009, 0x28000, 0xc00, 0x0);
- write_rtl8255(dev, 0x1, 0x807);
- write_rtl8255(dev, 0x4, 0xc01);
- write_rtl8255(dev, 0x4, 0xe01);
- write_rtl8255(dev, 0x4, 0xc01);
- write_rtl8255(dev, 0x1, 0x0);
- write_rtl8255(dev, 0x4, 0x801);
- write_rtl8255(dev, 0x3, 0x0);
- write_rtl8255(dev, 0x2, 0x0);
- write_rtl8255(dev, 0x4, 0xa01);
- write_rtl8255(dev, 0x4, 0x801);
- write_rtl8255(dev, 0x4, 0x401);
- write_rtl8255(dev, 0x3, 0x26);
- write_rtl8255(dev, 0x2, 0x27);
- write_rtl8255(dev, 0x4, 0x601);
- write_rtl8255(dev, 0x4, 0x401);
- write_rtl8255(dev, 0x4, 0x401);
- write_rtl8255(dev, 0x3, 0x100);
- write_rtl8255(dev, 0x4, 0x601);
- write_rtl8255(dev, 0x4, 0x401);
- write_rtl8255_reg0c(dev, 0x1554, 0xa800403b, 0xf6d44278, 0x80418bdf, 0x40000027,
- 0x92402ac4, 0xf0009, 0x28000, 0xc00, 0x0);
- write_rtl8255(dev, 0x1, 0x807);
- write_rtl8255(dev, 0x4, 0xc02);
- write_rtl8255(dev, 0x4, 0xe02);
- write_rtl8255(dev, 0x4, 0xc02);
- write_rtl8255(dev, 0x1, 0x0);
- write_rtl8255(dev, 0x4, 0x802);
- write_rtl8255(dev, 0x3, 0x0);
- write_rtl8255(dev, 0x2, 0x0);
- write_rtl8255(dev, 0x4, 0xa02);
- write_rtl8255(dev, 0x4, 0x802);
- write_rtl8255(dev, 0x4, 0x402);
- write_rtl8255(dev, 0x3, 0x26);
- write_rtl8255(dev, 0x2, 0x26);
- write_rtl8255(dev, 0x4, 0x602);
- write_rtl8255(dev, 0x4, 0x402);
- write_rtl8255(dev, 0x4, 0x402);
- write_rtl8255(dev, 0x3, 0x100);
- write_rtl8255(dev, 0x4, 0x602);
- write_rtl8255(dev, 0x4, 0x402);
- write_rtl8255_reg0c(dev, 0x1554, 0xa800403b, 0xf6d44278, 0x80418bbf, 0x40000027,
- 0x92402ac4, 0xf0009, 0x28000, 0xc00, 0x0);
- write_rtl8255(dev, 0x1, 0x807);
- write_rtl8255(dev, 0x4, 0xc03);
- write_rtl8255(dev, 0x4, 0xe03);
- write_rtl8255(dev, 0x4, 0xc03);
- write_rtl8255(dev, 0x1, 0x0);
- write_rtl8255(dev, 0x4, 0x803);
- write_rtl8255(dev, 0x3, 0x0);
- write_rtl8255(dev, 0x2, 0x0);
- write_rtl8255(dev, 0x4, 0xa03);
- write_rtl8255(dev, 0x4, 0x803);
- write_rtl8255(dev, 0x4, 0x403);
- write_rtl8255(dev, 0x3, 0x26);
- write_rtl8255(dev, 0x2, 0x26);
- write_rtl8255(dev, 0x4, 0x603);
- write_rtl8255(dev, 0x4, 0x403);
- write_rtl8255(dev, 0x4, 0x403);
- write_rtl8255(dev, 0x3, 0x100);
- write_rtl8255(dev, 0x4, 0x603);
- write_rtl8255(dev, 0x4, 0x403);
- write_rtl8255_reg0c(dev, 0x1554, 0xa800403b, 0xf6d44278, 0x80418b9f, 0x40000027,
- 0x92402ac8, 0xf0009, 0x28000, 0xc00, 0x0);
- write_rtl8255(dev, 0x1, 0x807);
- write_rtl8255(dev, 0x4, 0xc04);
- write_rtl8255(dev, 0x4, 0xe04);
- write_rtl8255(dev, 0x4, 0xc04);
- write_rtl8255(dev, 0x1, 0x0);
- write_rtl8255(dev, 0x4, 0x804);
- write_rtl8255(dev, 0x3, 0x0);
- write_rtl8255(dev, 0x2, 0x0);
- write_rtl8255(dev, 0x4, 0xa04);
- write_rtl8255(dev, 0x4, 0x804);
- write_rtl8255(dev, 0x4, 0x404);
- write_rtl8255(dev, 0x3, 0x26);
- write_rtl8255(dev, 0x2, 0x26);
- write_rtl8255(dev, 0x4, 0x604);
- write_rtl8255(dev, 0x4, 0x404);
- write_rtl8255(dev, 0x4, 0x404);
- write_rtl8255(dev, 0x3, 0x100);
- write_rtl8255(dev, 0x4, 0x604);
- write_rtl8255(dev, 0x4, 0x404);
- write_rtl8255_reg0c(dev, 0x1554, 0xa800403b, 0xf6d44278, 0x804183df, 0x40000027,
- 0x92402ac8, 0xf0009, 0x28000, 0xc00, 0x0);
- write_rtl8255(dev, 0x1, 0x807);
- write_rtl8255(dev, 0x4, 0xc05);
- write_rtl8255(dev, 0x4, 0xe05);
- write_rtl8255(dev, 0x4, 0xc05);
- write_rtl8255(dev, 0x1, 0x0);
- write_rtl8255(dev, 0x4, 0x805);
- write_rtl8255(dev, 0x3, 0x0);
- write_rtl8255(dev, 0x2, 0x0);
- write_rtl8255(dev, 0x4, 0xa05);
- write_rtl8255(dev, 0x4, 0x805);
- write_rtl8255(dev, 0x4, 0x405);
- write_rtl8255(dev, 0x3, 0x26);
- write_rtl8255(dev, 0x2, 0x26);
- write_rtl8255(dev, 0x4, 0x605);
- write_rtl8255(dev, 0x4, 0x405);
- write_rtl8255(dev, 0x4, 0x405);
- write_rtl8255(dev, 0x3, 0x100);
- write_rtl8255(dev, 0x4, 0x605);
- write_rtl8255(dev, 0x4, 0x405);
- write_rtl8255_reg0c(dev, 0x1554, 0xa800403b, 0xf6d44278, 0x804183cf, 0x27,
- 0x92402acc, 0xf0009, 0x28000, 0xc00, 0x0);
- write_rtl8255(dev, 0x1, 0x807);
- write_rtl8255(dev, 0x4, 0xc06);
- write_rtl8255(dev, 0x4, 0xe06);
- write_rtl8255(dev, 0x4, 0xc06);
- write_rtl8255(dev, 0x1, 0x0);
- write_rtl8255(dev, 0x4, 0x806);
- write_rtl8255(dev, 0x3, 0x0);
- write_rtl8255(dev, 0x2, 0x0);
- write_rtl8255(dev, 0x4, 0xa06);
- write_rtl8255(dev, 0x4, 0x806);
- write_rtl8255(dev, 0x4, 0x406);
- write_rtl8255(dev, 0x3, 0x25);
- write_rtl8255(dev, 0x2, 0x26);
- write_rtl8255(dev, 0x4, 0x606);
- write_rtl8255(dev, 0x4, 0x406);
- write_rtl8255(dev, 0x4, 0x406);
- write_rtl8255(dev, 0x3, 0x100);
- write_rtl8255(dev, 0x4, 0x606);
- write_rtl8255(dev, 0x4, 0x406);
- write_rtl8255_reg0c(dev, 0x1554, 0xa800403b, 0xf6d44278, 0x804183af, 0x27,
- 0x92402acc, 0xf0009, 0x28000, 0xc00, 0x0);
- write_rtl8255(dev, 0x1, 0x807);
- write_rtl8255(dev, 0x4, 0xc07);
- write_rtl8255(dev, 0x4, 0xe07);
- write_rtl8255(dev, 0x4, 0xc07);
- write_rtl8255(dev, 0x1, 0x0);
- write_rtl8255(dev, 0x4, 0x807);
- write_rtl8255(dev, 0x3, 0x0);
- write_rtl8255(dev, 0x2, 0x0);
- write_rtl8255(dev, 0x4, 0xa07);
- write_rtl8255(dev, 0x4, 0x807);
- write_rtl8255(dev, 0x4, 0x407);
- write_rtl8255(dev, 0x3, 0x25);
- write_rtl8255(dev, 0x2, 0x26);
- write_rtl8255(dev, 0x4, 0x607);
- write_rtl8255(dev, 0x4, 0x407);
- write_rtl8255(dev, 0x4, 0x407);
- write_rtl8255(dev, 0x3, 0x100);
- write_rtl8255(dev, 0x4, 0x607);
- write_rtl8255(dev, 0x4, 0x407);
- write_rtl8255_reg0c(dev, 0x1554, 0xa800403b, 0xf6d44278, 0x804083d7, 0x40000027,
- 0x92402ad0, 0xf0009, 0x28000, 0xc00, 0x0);
- write_rtl8255(dev, 0x1, 0x807);
- write_rtl8255(dev, 0x4, 0xc08);
- write_rtl8255(dev, 0x4, 0xe08);
- write_rtl8255(dev, 0x4, 0xc08);
- write_rtl8255(dev, 0x1, 0x0);
- write_rtl8255(dev, 0x4, 0x808);
- write_rtl8255(dev, 0x3, 0x0);
- write_rtl8255(dev, 0x2, 0x0);
- write_rtl8255(dev, 0x4, 0xa08);
- write_rtl8255(dev, 0x4, 0x808);
- write_rtl8255(dev, 0x4, 0x408);
- write_rtl8255(dev, 0x3, 0x25);
- write_rtl8255(dev, 0x2, 0x26);
- write_rtl8255(dev, 0x4, 0x608);
- write_rtl8255(dev, 0x4, 0x408);
- write_rtl8255(dev, 0x4, 0x408);
- write_rtl8255(dev, 0x3, 0x100);
- write_rtl8255(dev, 0x4, 0x608);
- write_rtl8255(dev, 0x4, 0x408);
- write_rtl8255_reg0c(dev, 0x1554, 0xa800403b, 0xf6d44278, 0x804083c7, 0x27,
- 0x92402ad0, 0xf0009, 0x28000, 0xc00, 0x0);
- write_rtl8255(dev, 0x1, 0x807);
- write_rtl8255(dev, 0x4, 0xc09);
- write_rtl8255(dev, 0x4, 0xe09);
- write_rtl8255(dev, 0x4, 0xc09);
- write_rtl8255(dev, 0x1, 0x0);
- write_rtl8255(dev, 0x4, 0x809);
- write_rtl8255(dev, 0x3, 0x0);
- write_rtl8255(dev, 0x2, 0x0);
- write_rtl8255(dev, 0x4, 0xa09);
- write_rtl8255(dev, 0x4, 0x809);
- write_rtl8255(dev, 0x4, 0x409);
- write_rtl8255(dev, 0x3, 0x25);
- write_rtl8255(dev, 0x2, 0x26);
- write_rtl8255(dev, 0x4, 0x609);
- write_rtl8255(dev, 0x4, 0x409);
- write_rtl8255(dev, 0x4, 0x409);
- write_rtl8255(dev, 0x3, 0x100);
- write_rtl8255(dev, 0x4, 0x609);
- write_rtl8255(dev, 0x4, 0x409);
- write_rtl8255_reg0c(dev, 0x1554, 0xa800403b, 0xf6d44278, 0x804043d7, 0x40000027,
- 0x92402ad4, 0xf0009, 0x28000, 0xc00, 0x0);
- write_rtl8255(dev, 0x1, 0x807);
- write_rtl8255(dev, 0x4, 0xc0a);
- write_rtl8255(dev, 0x4, 0xe0a);
- write_rtl8255(dev, 0x4, 0xc0a);
- write_rtl8255(dev, 0x1, 0x0);
- write_rtl8255(dev, 0x4, 0x80a);
- write_rtl8255(dev, 0x3, 0x0);
- write_rtl8255(dev, 0x2, 0x0);
- write_rtl8255(dev, 0x4, 0xa0a);
- write_rtl8255(dev, 0x4, 0x80a);
- write_rtl8255(dev, 0x4, 0x40a);
- write_rtl8255(dev, 0x3, 0x25);
- write_rtl8255(dev, 0x2, 0x26);
- write_rtl8255(dev, 0x4, 0x60a);
- write_rtl8255(dev, 0x4, 0x40a);
- write_rtl8255(dev, 0x4, 0x40a);
- write_rtl8255(dev, 0x3, 0x100);
- write_rtl8255(dev, 0x4, 0x60a);
- write_rtl8255(dev, 0x4, 0x40a);
- write_rtl8255_reg0c(dev, 0x1554, 0xa800403b, 0xf6d44278, 0x804043d7, 0x40000027,
- 0x92402ad4, 0xf0009, 0x28000, 0xc00, 0x0);
- write_rtl8255(dev, 0x1, 0x807);
- write_rtl8255(dev, 0x4, 0xc0b);
- write_rtl8255(dev, 0x4, 0xe0b);
- write_rtl8255(dev, 0x4, 0xc0b);
- write_rtl8255(dev, 0x1, 0x0);
- write_rtl8255(dev, 0x4, 0x80b);
- write_rtl8255(dev, 0x3, 0x0);
- write_rtl8255(dev, 0x2, 0x0);
- write_rtl8255(dev, 0x4, 0xa0b);
- write_rtl8255(dev, 0x4, 0x80b);
- write_rtl8255(dev, 0x4, 0x40b);
- write_rtl8255(dev, 0x3, 0x25);
- write_rtl8255(dev, 0x2, 0x26);
- write_rtl8255(dev, 0x4, 0x60b);
- write_rtl8255(dev, 0x4, 0x40b);
- write_rtl8255(dev, 0x4, 0x40b);
- write_rtl8255(dev, 0x3, 0x100);
- write_rtl8255(dev, 0x4, 0x60b);
- write_rtl8255(dev, 0x4, 0x40b);
- write_rtl8255_reg0c(dev, 0x1554, 0xa800403b, 0xf6d44278, 0x804043c7, 0x27,
- 0x92402ad8, 0xf0009, 0x28000, 0xc00, 0x0);
- write_rtl8255(dev, 0x1, 0x807);
- write_rtl8255(dev, 0x4, 0xc0c);
- write_rtl8255(dev, 0x4, 0xe0c);
- write_rtl8255(dev, 0x4, 0xc0c);
- write_rtl8255(dev, 0x1, 0x0);
- write_rtl8255(dev, 0x4, 0x80c);
- write_rtl8255(dev, 0x3, 0x0);
- write_rtl8255(dev, 0x2, 0x0);
- write_rtl8255(dev, 0x4, 0xa0c);
- write_rtl8255(dev, 0x4, 0x80c);
- write_rtl8255(dev, 0x4, 0x40c);
- write_rtl8255(dev, 0x3, 0x25);
- write_rtl8255(dev, 0x2, 0x26);
- write_rtl8255(dev, 0x4, 0x60c);
- write_rtl8255(dev, 0x4, 0x40c);
- write_rtl8255(dev, 0x4, 0x40c);
- write_rtl8255(dev, 0x3, 0x100);
- write_rtl8255(dev, 0x4, 0x60c);
- write_rtl8255(dev, 0x4, 0x40c);
- write_rtl8255_reg0c(dev, 0x1554, 0xa800403b, 0xf6d44278, 0x804043a7, 0x27,
- 0x92402ad8, 0xf0009, 0x28000, 0xc00, 0x0);
- write_rtl8255(dev, 0x1, 0x807);
- write_rtl8255(dev, 0x4, 0xc0d);
- write_rtl8255(dev, 0x4, 0xe0d);
- write_rtl8255(dev, 0x4, 0xc0d);
- write_rtl8255(dev, 0x1, 0x0);
- write_rtl8255(dev, 0x4, 0x80d);
- write_rtl8255(dev, 0x3, 0x0);
- write_rtl8255(dev, 0x2, 0x0);
- write_rtl8255(dev, 0x4, 0xa0d);
- write_rtl8255(dev, 0x4, 0x80d);
- write_rtl8255(dev, 0x4, 0x40d);
- write_rtl8255(dev, 0x3, 0x25);
- write_rtl8255(dev, 0x2, 0x26);
- write_rtl8255(dev, 0x4, 0x60d);
- write_rtl8255(dev, 0x4, 0x40d);
- write_rtl8255(dev, 0x4, 0x40d);
- write_rtl8255(dev, 0x3, 0x100);
- write_rtl8255(dev, 0x4, 0x60d);
- write_rtl8255(dev, 0x4, 0x40d);
- write_rtl8255_reg0c(dev, 0x1554, 0xa800403b, 0xf6d44278, 0x80404387, 0x27,
- 0x92402aa8, 0xf0009, 0x28000, 0xc00, 0x0);
- write_rtl8255(dev, 0x1, 0x807);
- write_rtl8255(dev, 0x4, 0xc0e);
- write_rtl8255(dev, 0x4, 0xe0e);
- write_rtl8255(dev, 0x4, 0xc0e);
- write_rtl8255(dev, 0x1, 0x0);
- write_rtl8255(dev, 0x4, 0x80e);
- write_rtl8255(dev, 0x3, 0x0);
- write_rtl8255(dev, 0x2, 0x0);
- write_rtl8255(dev, 0x4, 0xa0e);
- write_rtl8255(dev, 0x4, 0x80e);
- write_rtl8255(dev, 0x4, 0x40e);
- write_rtl8255(dev, 0x3, 0x25);
- write_rtl8255(dev, 0x2, 0x26);
- write_rtl8255(dev, 0x4, 0x60e);
- write_rtl8255(dev, 0x4, 0x40e);
- write_rtl8255(dev, 0x4, 0x40e);
- write_rtl8255(dev, 0x3, 0x100);
- write_rtl8255(dev, 0x4, 0x60e);
- write_rtl8255(dev, 0x4, 0x40e);
- write_rtl8255_reg0c(dev, 0x1554, 0xa800403b, 0xf6d44278, 0x804041c7, 0x27,
- 0x92402aa8, 0xf0009, 0x28000, 0xc00, 0x0);
- write_rtl8255(dev, 0x1, 0x807);
- write_rtl8255(dev, 0x4, 0xc0f);
- write_rtl8255(dev, 0x4, 0xe0f);
- write_rtl8255(dev, 0x4, 0xc0f);
- write_rtl8255(dev, 0x1, 0x0);
- write_rtl8255(dev, 0x4, 0x80f);
- write_rtl8255(dev, 0x3, 0x0);
- write_rtl8255(dev, 0x2, 0x0);
- write_rtl8255(dev, 0x4, 0xa0f);
- write_rtl8255(dev, 0x4, 0x80f);
- write_rtl8255(dev, 0x4, 0x40f);
- write_rtl8255(dev, 0x3, 0x25);
- write_rtl8255(dev, 0x2, 0x26);
- write_rtl8255(dev, 0x4, 0x60f);
- write_rtl8255(dev, 0x4, 0x40f);
- write_rtl8255(dev, 0x4, 0x40f);
- write_rtl8255(dev, 0x3, 0x100);
- write_rtl8255(dev, 0x4, 0x60f);
- write_rtl8255(dev, 0x4, 0x40f);
- write_rtl8255_reg0c(dev, 0x1554, 0xa800403b, 0xf6d44278, 0x804041a7, 0x27,
- 0x92402aac, 0xf0009, 0x28000, 0xc00, 0x0);
- write_rtl8255(dev, 0x1, 0x807);
- write_rtl8255(dev, 0x4, 0xc10);
- write_rtl8255(dev, 0x4, 0xe10);
- write_rtl8255(dev, 0x4, 0xc10);
- write_rtl8255(dev, 0x1, 0x0);
- write_rtl8255(dev, 0x4, 0x810);
- write_rtl8255(dev, 0x3, 0x0);
- write_rtl8255(dev, 0x2, 0x0);
- write_rtl8255(dev, 0x4, 0xa10);
- write_rtl8255(dev, 0x4, 0x810);
- write_rtl8255(dev, 0x4, 0x410);
- write_rtl8255(dev, 0x3, 0x25);
- write_rtl8255(dev, 0x2, 0x26);
- write_rtl8255(dev, 0x4, 0x610);
- write_rtl8255(dev, 0x4, 0x410);
- write_rtl8255(dev, 0x4, 0x410);
- write_rtl8255(dev, 0x3, 0x100);
- write_rtl8255(dev, 0x4, 0x610);
- write_rtl8255(dev, 0x4, 0x410);
- write_rtl8255_reg0c(dev, 0x1554, 0xa800403b, 0xf6d44278, 0x80404187, 0x27,
- 0x92402aac, 0xf0009, 0x28000, 0xc00, 0x0);
- write_rtl8255(dev, 0x1, 0x807);
- write_rtl8255(dev, 0x4, 0xc11);
- write_rtl8255(dev, 0x4, 0xe11);
- write_rtl8255(dev, 0x4, 0xc11);
- write_rtl8255(dev, 0x1, 0x0);
- write_rtl8255(dev, 0x4, 0x811);
- write_rtl8255(dev, 0x3, 0x0);
- write_rtl8255(dev, 0x2, 0x0);
- write_rtl8255(dev, 0x4, 0xa11);
- write_rtl8255(dev, 0x4, 0x811);
- write_rtl8255(dev, 0x4, 0x411);
- write_rtl8255(dev, 0x3, 0x25);
- write_rtl8255(dev, 0x2, 0x26);
- write_rtl8255(dev, 0x4, 0x611);
- write_rtl8255(dev, 0x4, 0x411);
- write_rtl8255(dev, 0x4, 0x411);
- write_rtl8255(dev, 0x3, 0x100);
- write_rtl8255(dev, 0x4, 0x611);
- write_rtl8255(dev, 0x4, 0x411);
- write_rtl8255_reg0c(dev, 0x1554, 0xa800403b, 0xf6d44278, 0x80404186, 0x80000027,
- 0x92402ab0, 0xf0009, 0x28000, 0xc00, 0x0);
- write_rtl8255(dev, 0x1, 0x807);
- write_rtl8255(dev, 0x4, 0xc12);
- write_rtl8255(dev, 0x4, 0xe12);
- write_rtl8255(dev, 0x4, 0xc12);
- write_rtl8255(dev, 0x1, 0x0);
- write_rtl8255(dev, 0x4, 0x812);
- write_rtl8255(dev, 0x3, 0x0);
- write_rtl8255(dev, 0x2, 0x0);
- write_rtl8255(dev, 0x4, 0xa12);
- write_rtl8255(dev, 0x4, 0x812);
- write_rtl8255(dev, 0x4, 0x412);
- write_rtl8255(dev, 0x3, 0x25);
- write_rtl8255(dev, 0x2, 0x26);
- write_rtl8255(dev, 0x4, 0x612);
- write_rtl8255(dev, 0x4, 0x412);
- write_rtl8255(dev, 0x4, 0x412);
- write_rtl8255(dev, 0x3, 0x100);
- write_rtl8255(dev, 0x4, 0x612);
- write_rtl8255(dev, 0x4, 0x412);
- write_rtl8255_reg0c(dev, 0x1554, 0xa800403b, 0xf6d44278, 0x80404186, 0x27,
- 0x92402ab0, 0xf0009, 0x28000, 0xc00, 0x0);
- write_rtl8255(dev, 0x1, 0x807);
- write_rtl8255(dev, 0x4, 0xc13);
- write_rtl8255(dev, 0x4, 0xe13);
- write_rtl8255(dev, 0x4, 0xc13);
- write_rtl8255(dev, 0x1, 0x0);
- write_rtl8255(dev, 0x4, 0x813);
- write_rtl8255(dev, 0x3, 0x0);
- write_rtl8255(dev, 0x2, 0x0);
- write_rtl8255(dev, 0x4, 0xa13);
- write_rtl8255(dev, 0x4, 0x813);
- write_rtl8255(dev, 0x4, 0x413);
- write_rtl8255(dev, 0x3, 0x25);
- write_rtl8255(dev, 0x2, 0x26);
- write_rtl8255(dev, 0x4, 0x613);
- write_rtl8255(dev, 0x4, 0x413);
- write_rtl8255(dev, 0x4, 0x413);
- write_rtl8255(dev, 0x3, 0x100);
- write_rtl8255(dev, 0x4, 0x613);
- write_rtl8255(dev, 0x4, 0x413);
- write_rtl8255_reg0c(dev, 0x1554, 0xa800403b, 0xf6d44278, 0x80404146, 0x27,
- 0x92402ab4, 0xf0009, 0x28000, 0xc00, 0x0);
- write_rtl8255(dev, 0x1, 0x807);
- write_rtl8255(dev, 0x4, 0xc14);
- write_rtl8255(dev, 0x4, 0xe14);
- write_rtl8255(dev, 0x4, 0xc14);
- write_rtl8255(dev, 0x1, 0x0);
- write_rtl8255(dev, 0x4, 0x814);
- write_rtl8255(dev, 0x3, 0x0);
- write_rtl8255(dev, 0x2, 0x0);
- write_rtl8255(dev, 0x4, 0xa14);
- write_rtl8255(dev, 0x4, 0x814);
- write_rtl8255(dev, 0x4, 0x414);
- write_rtl8255(dev, 0x3, 0x25);
- write_rtl8255(dev, 0x2, 0x26);
- write_rtl8255(dev, 0x4, 0x614);
- write_rtl8255(dev, 0x4, 0x414);
- write_rtl8255(dev, 0x4, 0x414);
- write_rtl8255(dev, 0x3, 0x100);
- write_rtl8255(dev, 0x4, 0x614);
- write_rtl8255(dev, 0x4, 0x414);
- write_rtl8255_reg0c(dev, 0x1554, 0xa800403b, 0xf6d44278, 0x80404126, 0x27,
- 0x92402ab4, 0xf0009, 0x28000, 0xc00, 0x0);
- write_rtl8255(dev, 0x1, 0x807);
- write_rtl8255(dev, 0x4, 0xc15);
- write_rtl8255(dev, 0x4, 0xe15);
- write_rtl8255(dev, 0x4, 0xc15);
- write_rtl8255(dev, 0x1, 0x0);
- write_rtl8255(dev, 0x4, 0x815);
- write_rtl8255(dev, 0x3, 0x0);
- write_rtl8255(dev, 0x2, 0x0);
- write_rtl8255(dev, 0x4, 0xa15);
- write_rtl8255(dev, 0x4, 0x815);
- write_rtl8255(dev, 0x4, 0x415);
- write_rtl8255(dev, 0x3, 0x25);
- write_rtl8255(dev, 0x2, 0x26);
- write_rtl8255(dev, 0x4, 0x615);
- write_rtl8255(dev, 0x4, 0x415);
- write_rtl8255(dev, 0x4, 0x415);
- write_rtl8255(dev, 0x3, 0x100);
- write_rtl8255(dev, 0x4, 0x615);
- write_rtl8255(dev, 0x4, 0x415);
- write_rtl8255_reg0c(dev, 0x1554, 0xa800403b, 0xf6d44278, 0x80404106, 0x27,
- 0x92402ab8, 0xf0009, 0x28000, 0xc00, 0x0);
- write_rtl8255(dev, 0x1, 0x807);
- write_rtl8255(dev, 0x4, 0xc16);
- write_rtl8255(dev, 0x4, 0xe16);
- write_rtl8255(dev, 0x4, 0xc16);
- write_rtl8255(dev, 0x1, 0x0);
- write_rtl8255(dev, 0x4, 0x816);
- write_rtl8255(dev, 0x3, 0x0);
- write_rtl8255(dev, 0x2, 0x0);
- write_rtl8255(dev, 0x4, 0xa16);
- write_rtl8255(dev, 0x4, 0x816);
- write_rtl8255(dev, 0x4, 0x416);
- write_rtl8255(dev, 0x3, 0x25);
- write_rtl8255(dev, 0x2, 0x26);
- write_rtl8255(dev, 0x4, 0x616);
- write_rtl8255(dev, 0x4, 0x416);
- write_rtl8255(dev, 0x4, 0x416);
- write_rtl8255(dev, 0x3, 0x100);
- write_rtl8255(dev, 0x4, 0x616);
- write_rtl8255(dev, 0x4, 0x416);
- write_rtl8255_reg0c(dev, 0x1554, 0xa800403b, 0xf6d44278, 0x80404105, 0x27,
- 0x92402ab8, 0xf0009, 0x28000, 0xc00, 0x0);
- write_rtl8255(dev, 0x1, 0x807);
- write_rtl8255(dev, 0x4, 0xc17);
- write_rtl8255(dev, 0x4, 0xe17);
- write_rtl8255(dev, 0x4, 0xc17);
- write_rtl8255(dev, 0x1, 0x0);
- write_rtl8255(dev, 0x4, 0x817);
- write_rtl8255(dev, 0x3, 0x0);
- write_rtl8255(dev, 0x2, 0x0);
- write_rtl8255(dev, 0x4, 0xa17);
- write_rtl8255(dev, 0x4, 0x817);
- write_rtl8255(dev, 0x4, 0x417);
- write_rtl8255(dev, 0x3, 0x25);
- write_rtl8255(dev, 0x2, 0x26);
- write_rtl8255(dev, 0x4, 0x617);
- write_rtl8255(dev, 0x4, 0x417);
- write_rtl8255(dev, 0x4, 0x417);
- write_rtl8255(dev, 0x3, 0x100);
- write_rtl8255(dev, 0x4, 0x617);
- write_rtl8255(dev, 0x4, 0x417);
- write_rtl8255_reg0c(dev, 0x1554, 0xa800403b, 0xf6d44278, 0x80404104, 0x80000027,
- 0x92402a88, 0xf0009, 0x28000, 0xc00, 0x0);
- write_rtl8255(dev, 0x1, 0x807);
- write_rtl8255(dev, 0x4, 0xc18);
- write_rtl8255(dev, 0x4, 0xe18);
- write_rtl8255(dev, 0x4, 0xc18);
- write_rtl8255(dev, 0x1, 0x0);
- write_rtl8255(dev, 0x4, 0x818);
- write_rtl8255(dev, 0x3, 0x0);
- write_rtl8255(dev, 0x2, 0x0);
- write_rtl8255(dev, 0x4, 0xa18);
- write_rtl8255(dev, 0x4, 0x818);
- write_rtl8255(dev, 0x4, 0x418);
- write_rtl8255(dev, 0x3, 0x25);
- write_rtl8255(dev, 0x2, 0x26);
- write_rtl8255(dev, 0x4, 0x618);
- write_rtl8255(dev, 0x4, 0x418);
- write_rtl8255(dev, 0x4, 0x418);
- write_rtl8255(dev, 0x3, 0x100);
- write_rtl8255(dev, 0x4, 0x618);
- write_rtl8255(dev, 0x4, 0x418);
- write_rtl8255_reg0c(dev, 0x1554, 0xa800403b, 0xf6d44278, 0x80404104, 0x27,
- 0x92402a88, 0xf0009, 0x28000, 0xc00, 0x0);
- write_rtl8255(dev, 0x1, 0x807);
- write_rtl8255(dev, 0x4, 0xc19);
- write_rtl8255(dev, 0x4, 0xe19);
- write_rtl8255(dev, 0x4, 0xc19);
- write_rtl8255(dev, 0x1, 0x0);
- write_rtl8255(dev, 0x4, 0x819);
- write_rtl8255(dev, 0x3, 0x0);
- write_rtl8255(dev, 0x2, 0x0);
- write_rtl8255(dev, 0x4, 0xa19);
- write_rtl8255(dev, 0x4, 0x819);
- write_rtl8255(dev, 0x4, 0x419);
- write_rtl8255(dev, 0x3, 0x25);
- write_rtl8255(dev, 0x2, 0x26);
- write_rtl8255(dev, 0x4, 0x619);
- write_rtl8255(dev, 0x4, 0x419);
- write_rtl8255(dev, 0x4, 0x419);
- write_rtl8255(dev, 0x3, 0x100);
- write_rtl8255(dev, 0x4, 0x619);
- write_rtl8255(dev, 0x4, 0x419);
- write_rtl8255_reg0c(dev, 0x1554, 0xa800403b, 0xf6d44278, 0x80404044, 0x27,
- 0x92402a8c, 0xf0009, 0x28000, 0xc00, 0x0);
- write_rtl8255(dev, 0x1, 0x807);
- write_rtl8255(dev, 0x4, 0xc1a);
- write_rtl8255(dev, 0x4, 0xe1a);
- write_rtl8255(dev, 0x4, 0xc1a);
- write_rtl8255(dev, 0x1, 0x0);
- write_rtl8255(dev, 0x4, 0x81a);
- write_rtl8255(dev, 0x3, 0x0);
- write_rtl8255(dev, 0x2, 0x0);
- write_rtl8255(dev, 0x4, 0xa1a);
- write_rtl8255(dev, 0x4, 0x81a);
- write_rtl8255(dev, 0x4, 0x41a);
- write_rtl8255(dev, 0x3, 0x25);
- write_rtl8255(dev, 0x2, 0x26);
- write_rtl8255(dev, 0x4, 0x61a);
- write_rtl8255(dev, 0x4, 0x41a);
- write_rtl8255(dev, 0x4, 0x41a);
- write_rtl8255(dev, 0x3, 0x100);
- write_rtl8255(dev, 0x4, 0x61a);
- write_rtl8255(dev, 0x4, 0x41a);
- write_rtl8255_reg0c(dev, 0x1554, 0xa800403b, 0xf6d44278, 0x80404024, 0x27,
- 0x92402a8c, 0xf0009, 0x28000, 0xc00, 0x0);
- write_rtl8255(dev, 0x1, 0x807);
- write_rtl8255(dev, 0x4, 0xc1b);
- write_rtl8255(dev, 0x4, 0xe1b);
- write_rtl8255(dev, 0x4, 0xc1b);
- write_rtl8255(dev, 0x1, 0x0);
- write_rtl8255(dev, 0x4, 0x81b);
- write_rtl8255(dev, 0x3, 0x0);
- write_rtl8255(dev, 0x2, 0x0);
- write_rtl8255(dev, 0x4, 0xa1b);
- write_rtl8255(dev, 0x4, 0x81b);
- write_rtl8255(dev, 0x4, 0x41b);
- write_rtl8255(dev, 0x3, 0x25);
- write_rtl8255(dev, 0x2, 0x26);
- write_rtl8255(dev, 0x4, 0x61b);
- write_rtl8255(dev, 0x4, 0x41b);
- write_rtl8255(dev, 0x4, 0x41b);
- write_rtl8255(dev, 0x3, 0x100);
- write_rtl8255(dev, 0x4, 0x61b);
- write_rtl8255(dev, 0x4, 0x41b);
- write_rtl8255_reg0c(dev, 0x1554, 0xa800403b, 0xf6d44278, 0x80404004, 0x27,
- 0x92402a90, 0xf0009, 0x28000, 0xc00, 0x0);
- write_rtl8255(dev, 0x1, 0x807);
- write_rtl8255(dev, 0x4, 0xc1c);
- write_rtl8255(dev, 0x4, 0xe1c);
- write_rtl8255(dev, 0x4, 0xc1c);
- write_rtl8255(dev, 0x1, 0x0);
- write_rtl8255(dev, 0x4, 0x81c);
- write_rtl8255(dev, 0x3, 0x0);
- write_rtl8255(dev, 0x2, 0x0);
- write_rtl8255(dev, 0x4, 0xa1c);
- write_rtl8255(dev, 0x4, 0x81c);
- write_rtl8255(dev, 0x4, 0x41c);
- write_rtl8255(dev, 0x3, 0x25);
- write_rtl8255(dev, 0x2, 0x26);
- write_rtl8255(dev, 0x4, 0x61c);
- write_rtl8255(dev, 0x4, 0x41c);
- write_rtl8255(dev, 0x4, 0x41c);
- write_rtl8255(dev, 0x3, 0x100);
- write_rtl8255(dev, 0x4, 0x61c);
- write_rtl8255(dev, 0x4, 0x41c);
- write_rtl8255_reg0c(dev, 0x1554, 0xa800403b, 0xf6d44278, 0x80404001, 0x27,
- 0x92402a90, 0xf0009, 0x28000, 0xc00, 0x0);
- write_rtl8255(dev, 0x1, 0x807);
- write_rtl8255(dev, 0x4, 0xc1d);
- write_rtl8255(dev, 0x4, 0xe1d);
- write_rtl8255(dev, 0x4, 0xc1d);
- write_rtl8255(dev, 0x1, 0x0);
- write_rtl8255(dev, 0x4, 0x81d);
- write_rtl8255(dev, 0x3, 0x0);
- write_rtl8255(dev, 0x2, 0x0);
- write_rtl8255(dev, 0x4, 0xa1d);
- write_rtl8255(dev, 0x4, 0x81d);
- write_rtl8255(dev, 0x4, 0x41d);
- write_rtl8255(dev, 0x3, 0x25);
- write_rtl8255(dev, 0x2, 0x26);
- write_rtl8255(dev, 0x4, 0x61d);
- write_rtl8255(dev, 0x4, 0x41d);
- write_rtl8255(dev, 0x4, 0x41d);
- write_rtl8255(dev, 0x3, 0x100);
- write_rtl8255(dev, 0x4, 0x61d);
- write_rtl8255(dev, 0x4, 0x41d);
- write_rtl8255_reg0c(dev, 0x1554, 0xa800403b, 0xf6d44278, 0x80404000, 0x80000027,
- 0x92402a94, 0xf0009, 0x28000, 0xc00, 0x0);
- write_rtl8255(dev, 0x1, 0x807);
- write_rtl8255(dev, 0x4, 0xc1e);
- write_rtl8255(dev, 0x4, 0xe1e);
- write_rtl8255(dev, 0x4, 0xc1e);
- write_rtl8255(dev, 0x1, 0x0);
- write_rtl8255(dev, 0x4, 0x81e);
- write_rtl8255(dev, 0x3, 0x0);
- write_rtl8255(dev, 0x2, 0x0);
- write_rtl8255(dev, 0x4, 0xa1e);
- write_rtl8255(dev, 0x4, 0x81e);
- write_rtl8255(dev, 0x4, 0x41e);
- write_rtl8255(dev, 0x3, 0x25);
- write_rtl8255(dev, 0x2, 0x26);
- write_rtl8255(dev, 0x4, 0x61e);
- write_rtl8255(dev, 0x4, 0x41e);
- write_rtl8255(dev, 0x4, 0x41e);
- write_rtl8255(dev, 0x3, 0x100);
- write_rtl8255(dev, 0x4, 0x61e);
- write_rtl8255(dev, 0x4, 0x41e);
- write_rtl8255_reg0c(dev, 0x1554, 0xa800403b, 0xf6d44278, 0x80404000, 0x27,
- 0x92402a94, 0xf0009, 0x28000, 0xc00, 0x0);
- write_rtl8255(dev, 0x1, 0x807);
- write_rtl8255(dev, 0x4, 0xc1f);
- write_rtl8255(dev, 0x4, 0xe1f);
- write_rtl8255(dev, 0x4, 0xc1f);
- write_rtl8255(dev, 0x1, 0x0);
- write_rtl8255(dev, 0x4, 0x81f);
- write_rtl8255(dev, 0x3, 0x0);
- write_rtl8255(dev, 0x2, 0x0);
- write_rtl8255(dev, 0x4, 0xa1f);
- write_rtl8255(dev, 0x4, 0x81f);
- write_rtl8255(dev, 0x4, 0x41f);
- write_rtl8255(dev, 0x3, 0x25);
- write_rtl8255(dev, 0x2, 0x26);
- write_rtl8255(dev, 0x4, 0x61f);
- write_rtl8255(dev, 0x4, 0x41f);
- write_rtl8255(dev, 0x4, 0x41f);
- write_rtl8255(dev, 0x3, 0x100);
- write_rtl8255(dev, 0x4, 0x61f);
- write_rtl8255(dev, 0x4, 0x41f);
- write_rtl8255_reg0c(dev, 0x1554, 0xa800403b, 0xf6d44278, 0x80404020, 0x80000027,
- 0x92402a98, 0xf8009, 0x28000, 0xc00, 0x0);
- write_rtl8255(dev, 0x1, 0x807);
- write_rtl8255(dev, 0x4, 0xc20);
- write_rtl8255(dev, 0x4, 0xe20);
- write_rtl8255(dev, 0x4, 0xc20);
- write_rtl8255(dev, 0x1, 0x0);
- write_rtl8255(dev, 0x4, 0x820);
- write_rtl8255(dev, 0x3, 0x0);
- write_rtl8255(dev, 0x2, 0x0);
- write_rtl8255(dev, 0x4, 0xa20);
- write_rtl8255(dev, 0x4, 0x820);
- write_rtl8255(dev, 0x4, 0x420);
- write_rtl8255(dev, 0x3, 0x25);
- write_rtl8255(dev, 0x2, 0x26);
- write_rtl8255(dev, 0x4, 0x620);
- write_rtl8255(dev, 0x4, 0x420);
- write_rtl8255(dev, 0x4, 0x420);
- write_rtl8255(dev, 0x3, 0x100);
- write_rtl8255(dev, 0x4, 0x620);
- write_rtl8255(dev, 0x4, 0x420);
- write_rtl8255_reg0c(dev, 0x1554, 0xa800403b, 0xf6d44278, 0x80404020, 0x27,
- 0x92402a98, 0xf8009, 0x28000, 0xc00, 0x0);
- write_rtl8255(dev, 0x1, 0x807);
- write_rtl8255(dev, 0x4, 0xc21);
- write_rtl8255(dev, 0x4, 0xe21);
- write_rtl8255(dev, 0x4, 0xc21);
- write_rtl8255(dev, 0x1, 0x0);
- write_rtl8255(dev, 0x4, 0x821);
- write_rtl8255(dev, 0x3, 0x0);
- write_rtl8255(dev, 0x2, 0x0);
- write_rtl8255(dev, 0x4, 0xa21);
- write_rtl8255(dev, 0x4, 0x821);
- write_rtl8255(dev, 0x4, 0x421);
- write_rtl8255(dev, 0x3, 0x25);
- write_rtl8255(dev, 0x2, 0x26);
- write_rtl8255(dev, 0x4, 0x621);
- write_rtl8255(dev, 0x4, 0x421);
- write_rtl8255(dev, 0x4, 0x421);
- write_rtl8255(dev, 0x3, 0x100);
- write_rtl8255(dev, 0x4, 0x621);
- write_rtl8255(dev, 0x4, 0x421);
- write_rtl8255_reg0c(dev, 0x1554, 0xa800403b, 0xf6d44278, 0x80404000, 0x80000027,
- 0x92402a68, 0xf0009, 0x10028000, 0xc00, 0x0);
- write_rtl8255(dev, 0x1, 0x807);
- write_rtl8255(dev, 0x4, 0xc22);
- write_rtl8255(dev, 0x4, 0xe22);
- write_rtl8255(dev, 0x4, 0xc22);
- write_rtl8255(dev, 0x1, 0x0);
- write_rtl8255(dev, 0x4, 0x822);
- write_rtl8255(dev, 0x3, 0x0);
- write_rtl8255(dev, 0x2, 0x0);
- write_rtl8255(dev, 0x4, 0xa22);
- write_rtl8255(dev, 0x4, 0x822);
- write_rtl8255(dev, 0x4, 0x422);
- write_rtl8255(dev, 0x3, 0x25);
- write_rtl8255(dev, 0x2, 0x26);
- write_rtl8255(dev, 0x4, 0x622);
- write_rtl8255(dev, 0x4, 0x422);
- write_rtl8255(dev, 0x4, 0x422);
- write_rtl8255(dev, 0x3, 0x100);
- write_rtl8255(dev, 0x4, 0x622);
- write_rtl8255(dev, 0x4, 0x422);
- write_rtl8255_reg0c(dev, 0x1554, 0xa800403b, 0xf6d44278, 0x80404010, 0x80000027,
- 0x92402a68, 0xf0009, 0x20028000, 0xc00, 0x0);
- write_rtl8255(dev, 0x1, 0x807);
- write_rtl8255(dev, 0x4, 0xc23);
- write_rtl8255(dev, 0x4, 0xe23);
- write_rtl8255(dev, 0x4, 0xc23);
- write_rtl8255(dev, 0x1, 0x0);
- write_rtl8255(dev, 0x4, 0x823);
- write_rtl8255(dev, 0x3, 0x0);
- write_rtl8255(dev, 0x2, 0x0);
- write_rtl8255(dev, 0x4, 0xa23);
- write_rtl8255(dev, 0x4, 0x823);
- write_rtl8255(dev, 0x4, 0x423);
- write_rtl8255(dev, 0x3, 0x25);
- write_rtl8255(dev, 0x2, 0x26);
- write_rtl8255(dev, 0x4, 0x623);
- write_rtl8255(dev, 0x4, 0x423);
- write_rtl8255(dev, 0x4, 0x423);
- write_rtl8255(dev, 0x3, 0x100);
- write_rtl8255(dev, 0x4, 0x623);
- write_rtl8255(dev, 0x4, 0x423);
- write_rtl8255_reg0c(dev, 0x1554, 0xa800403b, 0xf6d44278, 0x80404010, 0x80000027,
- 0x92402a6c, 0xf0009, 0x30028000, 0xc00, 0x0);
- write_rtl8255(dev, 0x1, 0x807);
- write_rtl8255(dev, 0x4, 0xc24);
- write_rtl8255(dev, 0x4, 0xe24);
- write_rtl8255(dev, 0x4, 0xc24);
- write_rtl8255(dev, 0x1, 0x0);
- write_rtl8255(dev, 0x4, 0x824);
- write_rtl8255(dev, 0x3, 0x0);
- write_rtl8255(dev, 0x2, 0x0);
- write_rtl8255(dev, 0x4, 0xa24);
- write_rtl8255(dev, 0x4, 0x824);
- write_rtl8255(dev, 0x4, 0x424);
- write_rtl8255(dev, 0x3, 0x25);
- write_rtl8255(dev, 0x2, 0x26);
- write_rtl8255(dev, 0x4, 0x624);
- write_rtl8255(dev, 0x4, 0x424);
- write_rtl8255(dev, 0x4, 0x424);
- write_rtl8255(dev, 0x3, 0x100);
- write_rtl8255(dev, 0x4, 0x624);
- write_rtl8255(dev, 0x4, 0x424);
- write_rtl8255_reg0c(dev, 0x1554, 0xa800403b, 0xf6d44278, 0x80404010, 0x80000027,
- 0x92402a6c, 0xf0009, 0x40028000, 0xc00, 0x0);
- write_rtl8255(dev, 0x1, 0x807);
- write_rtl8255(dev, 0x4, 0xc25);
- write_rtl8255(dev, 0x4, 0xe25);
- write_rtl8255(dev, 0x4, 0xc25);
- write_rtl8255(dev, 0x1, 0x0);
- write_rtl8255(dev, 0x4, 0x825);
- write_rtl8255(dev, 0x3, 0x0);
- write_rtl8255(dev, 0x2, 0x0);
- write_rtl8255(dev, 0x4, 0xa25);
- write_rtl8255(dev, 0x4, 0x825);
- write_rtl8255(dev, 0x4, 0x425);
- write_rtl8255(dev, 0x3, 0x25);
- write_rtl8255(dev, 0x2, 0x26);
- write_rtl8255(dev, 0x4, 0x625);
- write_rtl8255(dev, 0x4, 0x425);
- write_rtl8255(dev, 0x4, 0x425);
- write_rtl8255(dev, 0x3, 0x100);
- write_rtl8255(dev, 0x4, 0x625);
- write_rtl8255(dev, 0x4, 0x425);
- write_rtl8255_reg0c(dev, 0x1554, 0xa800403b, 0xf6d44278, 0x80404000, 0x80000027,
- 0x92402a70, 0xf0009, 0x60028000, 0xc00, 0x0);
- write_rtl8255(dev, 0x1, 0x807);
- write_rtl8255(dev, 0x4, 0xc26);
- write_rtl8255(dev, 0x4, 0xe26);
- write_rtl8255(dev, 0x4, 0xc26);
- write_rtl8255(dev, 0x1, 0x0);
- write_rtl8255(dev, 0x4, 0x826);
- write_rtl8255(dev, 0x3, 0x0);
- write_rtl8255(dev, 0x2, 0x0);
- write_rtl8255(dev, 0x4, 0xa26);
- write_rtl8255(dev, 0x4, 0x826);
- write_rtl8255(dev, 0x4, 0x426);
- write_rtl8255(dev, 0x3, 0x25);
- write_rtl8255(dev, 0x2, 0x26);
- write_rtl8255(dev, 0x4, 0x626);
- write_rtl8255(dev, 0x4, 0x426);
- write_rtl8255(dev, 0x4, 0x426);
- write_rtl8255(dev, 0x3, 0x100);
- write_rtl8255(dev, 0x4, 0x626);
- write_rtl8255(dev, 0x4, 0x426);
- write_rtl8255_reg0c(dev, 0x1554, 0xa800403b, 0xf6d44278, 0x80404031, 0x40000027,
- 0x92402a70, 0xf0011, 0x60028000, 0xc00, 0x0);
- write_rtl8255(dev, 0x1, 0x807);
- write_rtl8255(dev, 0x4, 0xc27);
- write_rtl8255(dev, 0x4, 0xe27);
- write_rtl8255(dev, 0x4, 0xc27);
- write_rtl8255(dev, 0x1, 0x0);
- write_rtl8255(dev, 0x4, 0x827);
- write_rtl8255(dev, 0x3, 0x0);
- write_rtl8255(dev, 0x2, 0x0);
- write_rtl8255(dev, 0x4, 0xa27);
- write_rtl8255(dev, 0x4, 0x827);
- write_rtl8255(dev, 0x4, 0x427);
- write_rtl8255(dev, 0x3, 0x25);
- write_rtl8255(dev, 0x2, 0x26);
- write_rtl8255(dev, 0x4, 0x627);
- write_rtl8255(dev, 0x4, 0x427);
- write_rtl8255(dev, 0x4, 0x427);
- write_rtl8255(dev, 0x3, 0x100);
- write_rtl8255(dev, 0x4, 0x627);
- write_rtl8255(dev, 0x4, 0x427);
- write_rtl8255_reg0c(dev, 0x1554, 0xa800403b, 0xf6d44278, 0x80404011, 0x40000027,
- 0x92402a74, 0xf0011, 0x60028000, 0xc00, 0x0);
- write_rtl8255(dev, 0x1, 0x807);
- write_rtl8255(dev, 0x4, 0xc28);
- write_rtl8255(dev, 0x4, 0xe28);
- write_rtl8255(dev, 0x4, 0xc28);
- write_rtl8255(dev, 0x1, 0x0);
- write_rtl8255(dev, 0x4, 0x828);
- write_rtl8255(dev, 0x3, 0x0);
- write_rtl8255(dev, 0x2, 0x0);
- write_rtl8255(dev, 0x4, 0xa28);
- write_rtl8255(dev, 0x4, 0x828);
- write_rtl8255(dev, 0x4, 0x428);
- write_rtl8255(dev, 0x3, 0x25);
- write_rtl8255(dev, 0x2, 0x26);
- write_rtl8255(dev, 0x4, 0x628);
- write_rtl8255(dev, 0x4, 0x428);
- write_rtl8255(dev, 0x4, 0x428);
- write_rtl8255(dev, 0x3, 0x100);
- write_rtl8255(dev, 0x4, 0x628);
- write_rtl8255(dev, 0x4, 0x428);
- write_rtl8255_reg0c(dev, 0x1554, 0xa800403b, 0xf6d44278, 0x80404010, 0xc0000027,
- 0x92402a74, 0xf0011, 0x60028000, 0xc00, 0x0);
- write_rtl8255(dev, 0x1, 0x807);
- write_rtl8255(dev, 0x4, 0xc29);
- write_rtl8255(dev, 0x4, 0xe29);
- write_rtl8255(dev, 0x4, 0xc29);
- write_rtl8255(dev, 0x1, 0x0);
- write_rtl8255(dev, 0x4, 0x829);
- write_rtl8255(dev, 0x3, 0x0);
- write_rtl8255(dev, 0x2, 0x0);
- write_rtl8255(dev, 0x4, 0xa29);
- write_rtl8255(dev, 0x4, 0x829);
- write_rtl8255(dev, 0x4, 0x429);
- write_rtl8255(dev, 0x3, 0x25);
- write_rtl8255(dev, 0x2, 0x26);
- write_rtl8255(dev, 0x4, 0x629);
- write_rtl8255(dev, 0x4, 0x429);
- write_rtl8255(dev, 0x4, 0x429);
- write_rtl8255(dev, 0x3, 0x100);
- write_rtl8255(dev, 0x4, 0x629);
- write_rtl8255(dev, 0x4, 0x429);
- write_rtl8255_reg0c(dev, 0x1554, 0xa800403b, 0xf6d44278, 0x80404000, 0x80000027,
- 0x92402a78, 0xf0011, 0x60028000, 0xc00, 0x0);
- write_rtl8255(dev, 0x1, 0x807);
- write_rtl8255(dev, 0x4, 0xc2a);
- write_rtl8255(dev, 0x4, 0xe2a);
- write_rtl8255(dev, 0x4, 0xc2a);
- write_rtl8255(dev, 0x1, 0x0);
- write_rtl8255(dev, 0x4, 0x82a);
- write_rtl8255(dev, 0x3, 0x0);
- write_rtl8255(dev, 0x2, 0x0);
- write_rtl8255(dev, 0x4, 0xa2a);
- write_rtl8255(dev, 0x4, 0x82a);
- write_rtl8255(dev, 0x4, 0x42a);
- write_rtl8255(dev, 0x3, 0x24);
- write_rtl8255(dev, 0x2, 0x26);
- write_rtl8255(dev, 0x4, 0x62a);
- write_rtl8255(dev, 0x4, 0x42a);
- write_rtl8255(dev, 0x4, 0x42a);
- write_rtl8255(dev, 0x3, 0x100);
- write_rtl8255(dev, 0x4, 0x62a);
- write_rtl8255(dev, 0x4, 0x42a);
- write_rtl8255_reg0c(dev, 0x1554, 0xa800403b, 0xf6d44278, 0x80404000, 0x80000027,
- 0x92402a78, 0xf0011, 0x70028000, 0xc00, 0x0);
- write_rtl8255(dev, 0x1, 0x807);
- write_rtl8255(dev, 0x4, 0xc2b);
- write_rtl8255(dev, 0x4, 0xe2b);
- write_rtl8255(dev, 0x4, 0xc2b);
- write_rtl8255(dev, 0x1, 0x0);
- write_rtl8255(dev, 0x4, 0x82b);
- write_rtl8255(dev, 0x3, 0x0);
- write_rtl8255(dev, 0x2, 0x0);
- write_rtl8255(dev, 0x4, 0xa2b);
- write_rtl8255(dev, 0x4, 0x82b);
- write_rtl8255(dev, 0x4, 0x42b);
- write_rtl8255(dev, 0x3, 0x24);
- write_rtl8255(dev, 0x2, 0x26);
- write_rtl8255(dev, 0x4, 0x62b);
- write_rtl8255(dev, 0x4, 0x42b);
- write_rtl8255(dev, 0x4, 0x42b);
- write_rtl8255(dev, 0x3, 0x100);
- write_rtl8255(dev, 0x4, 0x62b);
- write_rtl8255(dev, 0x4, 0x42b);
- write_rtl8255_reg0c(dev, 0x1554, 0xa800403b, 0xf6d44278, 0x80404000, 0x80000027,
- 0x92402a48, 0xf0019, 0x70028000, 0xc00, 0x0);
- write_rtl8255(dev, 0x1, 0x807);
- write_rtl8255(dev, 0x4, 0xc2c);
- write_rtl8255(dev, 0x4, 0xe2c);
- write_rtl8255(dev, 0x4, 0xc2c);
- write_rtl8255(dev, 0x1, 0x0);
- write_rtl8255(dev, 0x4, 0x82c);
- write_rtl8255(dev, 0x3, 0x0);
- write_rtl8255(dev, 0x2, 0x0);
- write_rtl8255(dev, 0x4, 0xa2c);
- write_rtl8255(dev, 0x4, 0x82c);
- write_rtl8255(dev, 0x4, 0x42c);
- write_rtl8255(dev, 0x3, 0x24);
- write_rtl8255(dev, 0x2, 0x26);
- write_rtl8255(dev, 0x4, 0x62c);
- write_rtl8255(dev, 0x4, 0x42c);
- write_rtl8255(dev, 0x4, 0x42c);
- write_rtl8255(dev, 0x3, 0x100);
- write_rtl8255(dev, 0x4, 0x62c);
- write_rtl8255(dev, 0x4, 0x42c);
- write_rtl8255_reg0c(dev, 0x1554, 0xa800403b, 0xf6d44278, 0x80404000, 0x80000027,
- 0x92402a48, 0xf8019, 0x70028000, 0xc00, 0x0);
- write_rtl8255(dev, 0x1, 0x807);
- write_rtl8255(dev, 0x4, 0xc2d);
- write_rtl8255(dev, 0x4, 0xe2d);
- write_rtl8255(dev, 0x4, 0xc2d);
- write_rtl8255(dev, 0x1, 0x0);
- write_rtl8255(dev, 0x4, 0x82d);
- write_rtl8255(dev, 0x3, 0x0);
- write_rtl8255(dev, 0x2, 0x0);
- write_rtl8255(dev, 0x4, 0xa2d);
- write_rtl8255(dev, 0x4, 0x82d);
- write_rtl8255(dev, 0x4, 0x42d);
- write_rtl8255(dev, 0x3, 0x24);
- write_rtl8255(dev, 0x2, 0x26);
- write_rtl8255(dev, 0x4, 0x62d);
- write_rtl8255(dev, 0x4, 0x42d);
- write_rtl8255(dev, 0x4, 0x42d);
- write_rtl8255(dev, 0x3, 0x100);
- write_rtl8255(dev, 0x4, 0x62d);
- write_rtl8255(dev, 0x4, 0x42d);
- write_rtl8255_reg0c(dev, 0x1554, 0xa800403b, 0xf6d44278, 0x80404000, 0x80000027,
- 0x92402a4c, 0xf8019, 0x70028000, 0xc00, 0x0);
- write_rtl8255(dev, 0x1, 0x807);
- write_rtl8255(dev, 0x4, 0xc2e);
- write_rtl8255(dev, 0x4, 0xe2e);
- write_rtl8255(dev, 0x4, 0xc2e);
- write_rtl8255(dev, 0x1, 0x0);
- write_rtl8255(dev, 0x4, 0x82e);
- write_rtl8255(dev, 0x3, 0x0);
- write_rtl8255(dev, 0x2, 0x0);
- write_rtl8255(dev, 0x4, 0xa2e);
- write_rtl8255(dev, 0x4, 0x82e);
- write_rtl8255(dev, 0x4, 0x42e);
- write_rtl8255(dev, 0x3, 0x24);
- write_rtl8255(dev, 0x2, 0x26);
- write_rtl8255(dev, 0x4, 0x62e);
- write_rtl8255(dev, 0x4, 0x42e);
- write_rtl8255(dev, 0x4, 0x42e);
- write_rtl8255(dev, 0x3, 0x100);
- write_rtl8255(dev, 0x4, 0x62e);
- write_rtl8255(dev, 0x4, 0x42e);
- write_rtl8255_reg0c(dev, 0x1554, 0xa800403b, 0xf6d44278, 0x80404000, 0x80000027,
- 0x92402a4c, 0xf8019, 0x70028000, 0xc00, 0x0);
- write_rtl8255(dev, 0x1, 0x807);
- write_rtl8255(dev, 0x4, 0xc2f);
- write_rtl8255(dev, 0x4, 0xe2f);
- write_rtl8255(dev, 0x4, 0xc2f);
- write_rtl8255(dev, 0x1, 0x0);
- write_rtl8255(dev, 0x4, 0x82f);
- write_rtl8255(dev, 0x3, 0x0);
- write_rtl8255(dev, 0x2, 0x0);
- write_rtl8255(dev, 0x4, 0xa2f);
- write_rtl8255(dev, 0x4, 0x82f);
- write_rtl8255(dev, 0x4, 0x42f);
- write_rtl8255(dev, 0x3, 0x24);
- write_rtl8255(dev, 0x2, 0x26);
- write_rtl8255(dev, 0x4, 0x62f);
- write_rtl8255(dev, 0x4, 0x42f);
- write_rtl8255(dev, 0x4, 0x42f);
- write_rtl8255(dev, 0x3, 0x100);
- write_rtl8255(dev, 0x4, 0x62f);
- write_rtl8255(dev, 0x4, 0x42f);
- write_rtl8255_reg0c(dev, 0x1554, 0xa800403b, 0xf6d44278, 0x80404000, 0x80000027,
- 0x92402a50, 0xf8019, 0x70028000, 0xc00, 0x0);
- write_rtl8255(dev, 0x1, 0x807);
- write_rtl8255(dev, 0x4, 0xc30);
- write_rtl8255(dev, 0x4, 0xe30);
- write_rtl8255(dev, 0x4, 0xc30);
- write_rtl8255(dev, 0x1, 0x0);
- write_rtl8255(dev, 0x4, 0x830);
- write_rtl8255(dev, 0x3, 0x0);
- write_rtl8255(dev, 0x2, 0x0);
- write_rtl8255(dev, 0x4, 0xa30);
- write_rtl8255(dev, 0x4, 0x830);
- write_rtl8255(dev, 0x4, 0x430);
- write_rtl8255(dev, 0x3, 0x24);
- write_rtl8255(dev, 0x2, 0x26);
- write_rtl8255(dev, 0x4, 0x630);
- write_rtl8255(dev, 0x4, 0x430);
- write_rtl8255(dev, 0x4, 0x430);
- write_rtl8255(dev, 0x3, 0x100);
- write_rtl8255(dev, 0x4, 0x630);
- write_rtl8255(dev, 0x4, 0x430);
- write_rtl8255_reg0c(dev, 0x1554, 0xa800403b, 0xf6d44278, 0x80404000, 0x80000027,
- 0x92402a50, 0xf8019, 0x70028000, 0xc00, 0x0);
- write_rtl8255(dev, 0x1, 0x807);
- write_rtl8255(dev, 0x4, 0xc31);
- write_rtl8255(dev, 0x4, 0xe31);
- write_rtl8255(dev, 0x4, 0xc31);
- write_rtl8255(dev, 0x1, 0x0);
- write_rtl8255(dev, 0x4, 0x831);
- write_rtl8255(dev, 0x3, 0x0);
- write_rtl8255(dev, 0x2, 0x0);
- write_rtl8255(dev, 0x4, 0xa31);
- write_rtl8255(dev, 0x4, 0x831);
- write_rtl8255(dev, 0x4, 0x431);
- write_rtl8255(dev, 0x3, 0x24);
- write_rtl8255(dev, 0x2, 0x26);
- write_rtl8255(dev, 0x4, 0x631);
- write_rtl8255(dev, 0x4, 0x431);
- write_rtl8255(dev, 0x4, 0x431);
- write_rtl8255(dev, 0x3, 0x100);
- write_rtl8255(dev, 0x4, 0x631);
- write_rtl8255(dev, 0x4, 0x431);
- write_rtl8255_reg0c(dev, 0x1554, 0xa800403b, 0xf6d44278, 0x80404000, 0x80000027,
- 0x92402a54, 0xf8019, 0x70028000, 0xc00, 0x0);
- write_rtl8255(dev, 0x1, 0x807);
- write_rtl8255(dev, 0x4, 0xc32);
- write_rtl8255(dev, 0x4, 0xe32);
- write_rtl8255(dev, 0x4, 0xc32);
- write_rtl8255(dev, 0x1, 0x0);
- write_rtl8255(dev, 0x4, 0x832);
- write_rtl8255(dev, 0x3, 0x0);
- write_rtl8255(dev, 0x2, 0x0);
- write_rtl8255(dev, 0x4, 0xa32);
- write_rtl8255(dev, 0x4, 0x832);
- write_rtl8255(dev, 0x4, 0x432);
- write_rtl8255(dev, 0x3, 0x24);
- write_rtl8255(dev, 0x2, 0x26);
- write_rtl8255(dev, 0x4, 0x632);
- write_rtl8255(dev, 0x4, 0x432);
- write_rtl8255(dev, 0x4, 0x432);
- write_rtl8255(dev, 0x3, 0x100);
- write_rtl8255(dev, 0x4, 0x632);
- write_rtl8255(dev, 0x4, 0x432);
- write_rtl8255_reg0c(dev, 0x1554, 0xa800403b, 0xf6d44278, 0x80404000, 0x80000027,
- 0x92402a54, 0xf8019, 0x70028000, 0xc00, 0x0);
- write_rtl8255(dev, 0x1, 0x807);
- write_rtl8255(dev, 0x4, 0xc33);
- write_rtl8255(dev, 0x4, 0xe33);
- write_rtl8255(dev, 0x4, 0xc33);
- write_rtl8255(dev, 0x1, 0x0);
- write_rtl8255(dev, 0x4, 0x833);
- write_rtl8255(dev, 0x3, 0x0);
- write_rtl8255(dev, 0x2, 0x0);
- write_rtl8255(dev, 0x4, 0xa33);
- write_rtl8255(dev, 0x4, 0x833);
- write_rtl8255(dev, 0x4, 0x433);
- write_rtl8255(dev, 0x3, 0x24);
- write_rtl8255(dev, 0x2, 0x26);
- write_rtl8255(dev, 0x4, 0x633);
- write_rtl8255(dev, 0x4, 0x433);
- write_rtl8255(dev, 0x4, 0x433);
- write_rtl8255(dev, 0x3, 0x100);
- write_rtl8255(dev, 0x4, 0x633);
- write_rtl8255(dev, 0x4, 0x433);
- write_rtl8255_reg0c(dev, 0x1554, 0xa800403b, 0xf6d44278, 0x80404000, 0x80000027,
- 0x92402a58, 0xf8019, 0x70028000, 0xc00, 0x0);
- write_rtl8255(dev, 0x1, 0x807);
- write_rtl8255(dev, 0x4, 0xc34);
- write_rtl8255(dev, 0x4, 0xe34);
- write_rtl8255(dev, 0x4, 0xc34);
- write_rtl8255(dev, 0x1, 0x0);
- write_rtl8255(dev, 0x4, 0x834);
- write_rtl8255(dev, 0x3, 0x0);
- write_rtl8255(dev, 0x2, 0x0);
- write_rtl8255(dev, 0x4, 0xa34);
- write_rtl8255(dev, 0x4, 0x834);
- write_rtl8255(dev, 0x4, 0x434);
- write_rtl8255(dev, 0x3, 0x24);
- write_rtl8255(dev, 0x2, 0x26);
- write_rtl8255(dev, 0x4, 0x634);
- write_rtl8255(dev, 0x4, 0x434);
- write_rtl8255(dev, 0x4, 0x434);
- write_rtl8255(dev, 0x3, 0x100);
- write_rtl8255(dev, 0x4, 0x634);
- write_rtl8255(dev, 0x4, 0x434);
- write_rtl8255_reg0c(dev, 0x1554, 0xa800403b, 0xf6d44278, 0x80404000, 0x80000027,
- 0x92402a58, 0xf8019, 0x70028000, 0xc00, 0x0);
- write_rtl8255(dev, 0x1, 0x807);
- write_rtl8255(dev, 0x4, 0xc35);
- write_rtl8255(dev, 0x4, 0xe35);
- write_rtl8255(dev, 0x4, 0xc35);
- write_rtl8255(dev, 0x1, 0x0);
- write_rtl8255(dev, 0x4, 0x835);
- write_rtl8255(dev, 0x3, 0x0);
- write_rtl8255(dev, 0x2, 0x0);
- write_rtl8255(dev, 0x4, 0xa35);
- write_rtl8255(dev, 0x4, 0x835);
- write_rtl8255(dev, 0x4, 0x435);
- write_rtl8255(dev, 0x3, 0x24);
- write_rtl8255(dev, 0x2, 0x26);
- write_rtl8255(dev, 0x4, 0x635);
- write_rtl8255(dev, 0x4, 0x435);
- write_rtl8255(dev, 0x4, 0x435);
- write_rtl8255(dev, 0x3, 0x100);
- write_rtl8255(dev, 0x4, 0x635);
- write_rtl8255(dev, 0x4, 0x435);
- write_rtl8255_reg0c(dev, 0x1554, 0xa800403b, 0xf6d44278, 0x80404000, 0x80000027,
- 0x92402a24, 0xf8019, 0x70028000, 0xc00, 0x0);
- write_rtl8255(dev, 0x1, 0x807);
- write_rtl8255(dev, 0x4, 0xc36);
- write_rtl8255(dev, 0x4, 0xe36);
- write_rtl8255(dev, 0x4, 0xc36);
- write_rtl8255(dev, 0x1, 0x0);
- write_rtl8255(dev, 0x4, 0x836);
- write_rtl8255(dev, 0x3, 0x0);
- write_rtl8255(dev, 0x2, 0x0);
- write_rtl8255(dev, 0x4, 0xa36);
- write_rtl8255(dev, 0x4, 0x836);
- write_rtl8255(dev, 0x4, 0x436);
- write_rtl8255(dev, 0x3, 0x24);
- write_rtl8255(dev, 0x2, 0x25);
- write_rtl8255(dev, 0x4, 0x636);
- write_rtl8255(dev, 0x4, 0x436);
- write_rtl8255(dev, 0x4, 0x436);
- write_rtl8255(dev, 0x3, 0x100);
- write_rtl8255(dev, 0x4, 0x636);
- write_rtl8255(dev, 0x4, 0x436);
- write_rtl8255_reg0c(dev, 0x1554, 0xa800403b, 0xf6d44278, 0x80404000, 0x80000027,
- 0x92402a24, 0xf8019, 0x70028000, 0xc00, 0x0);
- write_rtl8255(dev, 0x1, 0x807);
- write_rtl8255(dev, 0x4, 0xc37);
- write_rtl8255(dev, 0x4, 0xe37);
- write_rtl8255(dev, 0x4, 0xc37);
- write_rtl8255(dev, 0x1, 0x0);
- write_rtl8255(dev, 0x4, 0x837);
- write_rtl8255(dev, 0x3, 0x0);
- write_rtl8255(dev, 0x2, 0x0);
- write_rtl8255(dev, 0x4, 0xa37);
- write_rtl8255(dev, 0x4, 0x837);
- write_rtl8255(dev, 0x4, 0x437);
- write_rtl8255(dev, 0x3, 0x24);
- write_rtl8255(dev, 0x2, 0x25);
- write_rtl8255(dev, 0x4, 0x637);
- write_rtl8255(dev, 0x4, 0x437);
- write_rtl8255(dev, 0x4, 0x437);
- write_rtl8255(dev, 0x3, 0x100);
- write_rtl8255(dev, 0x4, 0x637);
- write_rtl8255(dev, 0x4, 0x437);
- write_rtl8255_reg0c(dev, 0x1554, 0xa800403b, 0xf6d44278, 0x80404000, 0x80000027,
- 0x92402a28, 0xf8019, 0x70028000, 0xc00, 0x0);
- write_rtl8255(dev, 0x1, 0x807);
- write_rtl8255(dev, 0x4, 0xc38);
- write_rtl8255(dev, 0x4, 0xe38);
- write_rtl8255(dev, 0x4, 0xc38);
- write_rtl8255(dev, 0x1, 0x0);
- write_rtl8255(dev, 0x4, 0x838);
- write_rtl8255(dev, 0x3, 0x0);
- write_rtl8255(dev, 0x2, 0x0);
- write_rtl8255(dev, 0x4, 0xa38);
- write_rtl8255(dev, 0x4, 0x838);
- write_rtl8255(dev, 0x4, 0x438);
- write_rtl8255(dev, 0x3, 0x24);
- write_rtl8255(dev, 0x2, 0x25);
- write_rtl8255(dev, 0x4, 0x638);
- write_rtl8255(dev, 0x4, 0x438);
- write_rtl8255(dev, 0x4, 0x438);
- write_rtl8255(dev, 0x3, 0x100);
- write_rtl8255(dev, 0x4, 0x638);
- write_rtl8255(dev, 0x4, 0x438);
- write_rtl8255_reg0c(dev, 0x1554, 0xa800403b, 0xf6d44278, 0x80404000, 0x80000027,
- 0x92402a28, 0xf8019, 0x70028000, 0xc00, 0x0);
- write_rtl8255(dev, 0x1, 0x807);
- write_rtl8255(dev, 0x4, 0xc39);
- write_rtl8255(dev, 0x4, 0xe39);
- write_rtl8255(dev, 0x4, 0xc39);
- write_rtl8255(dev, 0x1, 0x0);
- write_rtl8255(dev, 0x4, 0x839);
- write_rtl8255(dev, 0x3, 0x0);
- write_rtl8255(dev, 0x2, 0x0);
- write_rtl8255(dev, 0x4, 0xa39);
- write_rtl8255(dev, 0x4, 0x839);
- write_rtl8255(dev, 0x4, 0x439);
- write_rtl8255(dev, 0x3, 0x24);
- write_rtl8255(dev, 0x2, 0x25);
- write_rtl8255(dev, 0x4, 0x639);
- write_rtl8255(dev, 0x4, 0x439);
- write_rtl8255(dev, 0x4, 0x439);
- write_rtl8255(dev, 0x3, 0x100);
- write_rtl8255(dev, 0x4, 0x639);
- write_rtl8255(dev, 0x4, 0x439);
- write_rtl8255_reg0c(dev, 0x1554, 0xa800403b, 0xf6d44278, 0x80404000, 0x80000027,
- 0x92402a00, 0xf8019, 0x70028000, 0xc00, 0x0);
- write_rtl8255(dev, 0x1, 0x807);
- write_rtl8255(dev, 0x4, 0xc3a);
- write_rtl8255(dev, 0x4, 0xe3a);
- write_rtl8255(dev, 0x4, 0xc3a);
- write_rtl8255(dev, 0x1, 0x0);
- write_rtl8255(dev, 0x4, 0x83a);
- write_rtl8255(dev, 0x3, 0x0);
- write_rtl8255(dev, 0x2, 0x0);
- write_rtl8255(dev, 0x4, 0xa3a);
- write_rtl8255(dev, 0x4, 0x83a);
- write_rtl8255(dev, 0x4, 0x43a);
- write_rtl8255(dev, 0x3, 0x0);
- write_rtl8255(dev, 0x2, 0x0);
- write_rtl8255(dev, 0x4, 0x63a);
- write_rtl8255(dev, 0x4, 0x43a);
- write_rtl8255(dev, 0x4, 0x43a);
- write_rtl8255(dev, 0x3, 0x100);
- write_rtl8255(dev, 0x4, 0x63a);
- write_rtl8255(dev, 0x4, 0x43a);
- write_rtl8255_reg0c(dev, 0x1554, 0xa800403b, 0xf6d44278, 0x80404000, 0x80000027,
- 0x92402a00, 0xf8019, 0x70028000, 0xc00, 0x0);
- write_rtl8255(dev, 0x1, 0x807);
- write_rtl8255(dev, 0x4, 0xc3b);
- write_rtl8255(dev, 0x4, 0xe3b);
- write_rtl8255(dev, 0x4, 0xc3b);
- write_rtl8255(dev, 0x1, 0x0);
- write_rtl8255(dev, 0x4, 0x83b);
- write_rtl8255(dev, 0x3, 0x0);
- write_rtl8255(dev, 0x2, 0x0);
- write_rtl8255(dev, 0x4, 0xa3b);
- write_rtl8255(dev, 0x4, 0x83b);
- write_rtl8255(dev, 0x4, 0x43b);
- write_rtl8255(dev, 0x3, 0x0);
- write_rtl8255(dev, 0x2, 0x0);
- write_rtl8255(dev, 0x4, 0x63b);
- write_rtl8255(dev, 0x4, 0x43b);
- write_rtl8255(dev, 0x4, 0x43b);
- write_rtl8255(dev, 0x3, 0x100);
- write_rtl8255(dev, 0x4, 0x63b);
- write_rtl8255(dev, 0x4, 0x43b);
- write_rtl8255_reg0c(dev, 0x1554, 0xa800403b, 0xf6d44278, 0x80404000, 0x80000027,
- 0x92402a00, 0xf8019, 0x70028000, 0xc00, 0x0);
- write_rtl8255(dev, 0x1, 0x807);
- write_rtl8255(dev, 0x4, 0xc3c);
- write_rtl8255(dev, 0x4, 0xe3c);
- write_rtl8255(dev, 0x4, 0xc3c);
- write_rtl8255(dev, 0x1, 0x0);
- write_rtl8255(dev, 0x4, 0x83c);
- write_rtl8255(dev, 0x3, 0x0);
- write_rtl8255(dev, 0x2, 0x0);
- write_rtl8255(dev, 0x4, 0xa3c);
- write_rtl8255(dev, 0x4, 0x83c);
- write_rtl8255(dev, 0x4, 0x43c);
- write_rtl8255(dev, 0x3, 0x0);
- write_rtl8255(dev, 0x2, 0x0);
- write_rtl8255(dev, 0x4, 0x63c);
- write_rtl8255(dev, 0x4, 0x43c);
- write_rtl8255(dev, 0x4, 0x43c);
- write_rtl8255(dev, 0x3, 0x100);
- write_rtl8255(dev, 0x4, 0x63c);
- write_rtl8255(dev, 0x4, 0x43c);
- write_rtl8255_reg0c(dev, 0x1554, 0xa800403b, 0xf6d44278, 0x80404000, 0x80000027,
- 0x92402a00, 0xf8019, 0x70028000, 0xc00, 0x0);
- write_rtl8255(dev, 0x1, 0x807);
- write_rtl8255(dev, 0x4, 0xc3d);
- write_rtl8255(dev, 0x4, 0xe3d);
- write_rtl8255(dev, 0x4, 0xc3d);
- write_rtl8255(dev, 0x1, 0x0);
- write_rtl8255(dev, 0x4, 0x83d);
- write_rtl8255(dev, 0x3, 0x0);
- write_rtl8255(dev, 0x2, 0x0);
- write_rtl8255(dev, 0x4, 0xa3d);
- write_rtl8255(dev, 0x4, 0x83d);
- write_rtl8255(dev, 0x4, 0x43d);
- write_rtl8255(dev, 0x3, 0x0);
- write_rtl8255(dev, 0x2, 0x0);
- write_rtl8255(dev, 0x4, 0x63d);
- write_rtl8255(dev, 0x4, 0x43d);
- write_rtl8255(dev, 0x4, 0x43d);
- write_rtl8255(dev, 0x3, 0x100);
- write_rtl8255(dev, 0x4, 0x63d);
- write_rtl8255(dev, 0x4, 0x43d);
- write_rtl8255_reg0c(dev, 0x1554, 0xa800403b, 0xf6d44278, 0x80404000, 0x80000027,
- 0x92402a00, 0xf8019, 0x70028000, 0xc00, 0x0);
- write_rtl8255(dev, 0x1, 0x807);
- write_rtl8255(dev, 0x4, 0xc3e);
- write_rtl8255(dev, 0x4, 0xe3e);
- write_rtl8255(dev, 0x4, 0xc3e);
- write_rtl8255(dev, 0x1, 0x0);
- write_rtl8255(dev, 0x4, 0x83e);
- write_rtl8255(dev, 0x3, 0x0);
- write_rtl8255(dev, 0x2, 0x0);
- write_rtl8255(dev, 0x4, 0xa3e);
- write_rtl8255(dev, 0x4, 0x83e);
- write_rtl8255(dev, 0x4, 0x43e);
- write_rtl8255(dev, 0x3, 0x0);
- write_rtl8255(dev, 0x2, 0x0);
- write_rtl8255(dev, 0x4, 0x63e);
- write_rtl8255(dev, 0x4, 0x43e);
- write_rtl8255(dev, 0x4, 0x43e);
- write_rtl8255(dev, 0x3, 0x100);
- write_rtl8255(dev, 0x4, 0x63e);
- write_rtl8255(dev, 0x4, 0x43e);
- write_rtl8255_reg0c(dev, 0x1554, 0xa800403b, 0xf6d44278, 0x80404000, 0x80000027,
- 0x92402a00, 0xf8011, 0x70028000, 0xc00, 0x0);
- write_rtl8255(dev, 0x1, 0x807);
- write_rtl8255(dev, 0x4, 0xc3f);
- write_rtl8255(dev, 0x4, 0xe3f);
- write_rtl8255(dev, 0x4, 0xc3f);
- write_rtl8255(dev, 0x1, 0x0);
- write_rtl8255(dev, 0x4, 0x83f);
- write_rtl8255(dev, 0x3, 0x0);
- write_rtl8255(dev, 0x2, 0x0);
- write_rtl8255(dev, 0x4, 0xa3f);
- write_rtl8255(dev, 0x4, 0x83f);
- write_rtl8255(dev, 0x4, 0x43f);
- write_rtl8255(dev, 0x3, 0x0);
- write_rtl8255(dev, 0x2, 0x0);
- write_rtl8255(dev, 0x4, 0x63f);
- write_rtl8255(dev, 0x4, 0x43f);
- write_rtl8255(dev, 0x4, 0x43f);
- write_rtl8255(dev, 0x3, 0x100);
- write_rtl8255(dev, 0x4, 0x63f);
- write_rtl8255(dev, 0x4, 0x43f);
- write_rtl8255(dev, 0x4, 0x0);
- write_rtl8255(dev, 0x1, 0x0);
- write_rtl8255_reg0c(dev, 0x3539, 0x70000c03, 0xfef46178, 0x408000, 0x403307,
- 0x924f80c0, 0xf955c, 0x8400, 0x429200, 0x1ce20);
- write_rtl8255(dev, 0x1, 0x1c7);
- write_rtl8255(dev, 0x2, 0x26);
- write_rtl8255(dev, 0x3, 0x27);
- write_rtl8255(dev, 0x1, 0x47);
- write_rtl8255(dev, 0x4, 0x98c);
- write_rtl8255(dev, 0x5, 0x65);
- write_rtl8255(dev, 0x6, 0x13);
- write_rtl8255(dev, 0x7, 0x7c);
- write_rtl8255(dev, 0x8, 0x6);
- write_rtl8255(dev, 0x8, 0x7);
- write_rtl8255(dev, 0x8, 0x6);
- write_rtl8255(dev, 0x9, 0xce2);
- write_rtl8255(dev, 0xb, 0x1c5);
- write_rtl8255(dev, 0xd, 0xd7f);
- write_rtl8255(dev, 0xe, 0x369);
- write_rtl8255(dev, 0xa, 0xd56);
- write_rtl8255(dev, 0xa, 0xd57);
- mdelay(20);
- write_rtl8255(dev, 0xd, 0xd7e);
-
-}
-
-
-void rtl8255_set_band_param(struct net_device *dev, short band)
-{
- if(band != BAND_A){
- write_nic_dword(dev, 0x94, 0x3dc00002);
- write_nic_dword(dev, 0x88, 0x00100040);
-
- write_phy_cck(dev, 0x13, 0xd0);
-
- write_phy_cck(dev, 0x41, 0x9d);
- write_nic_dword(dev, 0x8c, 0x00082205);
- write_nic_byte(dev, 0xb4, 0x66);
- }
-}
-
-void rtl8255_rf_init(struct net_device *dev)
-{
- struct r8180_priv *priv = ieee80211_priv(dev);
- int i;
- u16 brsr;
-// short channel /*= priv->chan*/ = 1;
- priv->chan = 1;
-
- write_nic_word(dev, RFPinsOutput, 0x80);
- write_nic_word(dev, RFPinsSelect, 0x80 | SW_CONTROL_GPIO);
- write_nic_word(dev, RFPinsEnable, 0x80);
- write_nic_word(dev, RFPinsSelect, SW_CONTROL_GPIO);
-
- write_nic_dword(dev, RF_TIMING, 0x000f800f);
-
- brsr = read_nic_word(dev, BRSR);
-
- write_nic_word(dev, 0x2c, 0xffff);
-
-
- rtl8180_set_anaparam(dev, RTL8255_ANAPARAM_ON);
- rtl8185_set_anaparam2(dev, RTL8255_ANAPARAM2_ON);
-
- write_nic_dword(dev, 0x94, 0x11c00002);
-
- write_nic_dword(dev, RF_PARA, 0x100040);
-
- rtl8185_rf_pins_enable(dev);
-
- rtl8255_init_BGband(dev);
- rtl8255_set_band_param(dev,BAND_BG);
-
- write_phy_cck(dev, 0x0, 0x98);
- write_phy_cck(dev, 0x3, 0x20);
- write_phy_cck(dev, 0x4, 0x2e);
- write_phy_cck(dev, 0x5, 0x12);
- write_phy_cck(dev, 0x6, 0xfc);
- write_phy_cck(dev, 0x7, 0xd8);
- write_phy_cck(dev, 0x8, 0x2e);
- write_phy_cck(dev, 0x10, 0xd3);
- write_phy_cck(dev, 0x11, 0x88);
- write_phy_cck(dev, 0x12, 0x47);
- write_phy_cck(dev, 0x13, 0xd0); /* Ver C & D & 8187*/
-
- write_phy_cck(dev, 0x19, 0x0);
- write_phy_cck(dev, 0x1a, 0xa0);
- write_phy_cck(dev, 0x1b, 0x8);
- write_phy_cck(dev, 0x40, 0x86); /* CCK Carrier Sense Threshold */
- write_phy_cck(dev, 0x41, 0x9d); /* Energy Threshold */
- //write_phy_cck(dev, 0x42, 0x0);
- write_phy_cck(dev, 0x43, 0x8);
-
- write_nic_byte(dev, TESTR,0x8);
-
- for(i=0;i<128;i++){
- write_phy_ofdm(dev, 0x4b, rtl8255_agc[i]);
- write_phy_ofdm(dev, 0x4a, (u8)i+ 0x80);
- }
-
-
- write_phy_ofdm(dev, 0x0, 0x1);
- write_phy_ofdm(dev, 0x1, 0x2);
- write_phy_ofdm(dev, 0x2, 0x43);
- write_phy_ofdm(dev, 0x3, 0x0);
- write_phy_ofdm(dev, 0x4, 0x0);
- write_phy_ofdm(dev, 0x5, 0x0);
- write_phy_ofdm(dev, 0x6, 0x40);
- write_phy_ofdm(dev, 0x7, 0x0);
- write_phy_ofdm(dev, 0x8, 0x40);
- write_phy_ofdm(dev, 0x9, 0xfe);
- write_phy_ofdm(dev, 0xa, 0x9);
- write_phy_ofdm(dev, 0xb, 0x80);
- write_phy_ofdm(dev, 0xc, 0x1);
- write_phy_ofdm(dev, 0xd, 0x43);
- write_phy_ofdm(dev, 0xe, 0xd3);
- write_phy_ofdm(dev, 0xf, 0x38);
- write_phy_ofdm(dev, 0x10, 0x4);
- write_phy_ofdm(dev, 0x11, 0x06);/*agc resp time 700*/
- write_phy_ofdm(dev, 0x12, 0x20);
- write_phy_ofdm(dev, 0x13, 0x20);
- write_phy_ofdm(dev, 0x14, 0x0);
- write_phy_ofdm(dev, 0x15, 0x40);
- write_phy_ofdm(dev, 0x16, 0x0);
- write_phy_ofdm(dev, 0x17, 0x40);
- write_phy_ofdm(dev, 0x18, 0xef);
- write_phy_ofdm(dev, 0x19, 0x25);
- write_phy_ofdm(dev, 0x1a, 0x20);
- write_phy_ofdm(dev, 0x1b, 0x7a);
- write_phy_ofdm(dev, 0x1c, 0x84);
- write_phy_ofdm(dev, 0x1e, 0x95);
- write_phy_ofdm(dev, 0x1f, 0x75);
- write_phy_ofdm(dev, 0x20, 0x1f);
- write_phy_ofdm(dev, 0x21, 0x17);
- write_phy_ofdm(dev, 0x22, 0x16);
- write_phy_ofdm(dev, 0x23, 0x70); //FIXME maybe not needed
- write_phy_ofdm(dev, 0x24, 0x70);
- write_phy_ofdm(dev, 0x25, 0x0);
- write_phy_ofdm(dev, 0x26, 0x10);
- write_phy_ofdm(dev, 0x27, 0x88);
-
-
- write_nic_dword(dev, 0x94, 0x3dc00002); //BAND DEPEND.
-// write_nic_dword(dev, 0x94, 0x15c00002); //BAND DEPEND.
-
- write_phy_cck(dev, 0x4, 0x18);
- write_phy_cck(dev, 0x43, 0x18);
- write_phy_cck(dev, 0x6, 0xdc);
- write_phy_cck(dev, 0x44, 0x2b);
- write_phy_cck(dev, 0x45, 0x2b);
- write_phy_cck(dev, 0x46, 0x25);
- write_phy_cck(dev, 0x47, 0x15);
- write_phy_cck(dev, 0x48, 0x0);
- write_phy_cck(dev, 0x49, 0x0);
- write_phy_cck(dev, 0x4a, 0x0);
- write_phy_cck(dev, 0x4b, 0x0);
-// write_phy_cck(dev, 0x4c, 0x5);
-#if 0
- write_phy_cck(dev, 0x41, 0x9d); /* Energy Threshold */
- // TESTR 0xb 8187
- write_phy_cck(dev, 0x10, 0x93);// & 0xfb);
-#endif
- //rtl8255_set_gain(dev, 1); /* FIXME this '1' is random */
-
- rtl8255_SetTXPowerLevel(dev, priv->chan);
-
- write_phy_cck(dev, 0x10, 0x93 |0x4); /* Rx ant B, 0xd3 for A */
- write_phy_ofdm(dev, 0x26, 0x90); /* Rx ant B, 0x10 for A */
-
- rtl8185_tx_antenna(dev, 0x3); /* TX ant B, 0x0 for A*/
- /* make sure is waken up! */
- rtl8180_set_anaparam(dev, RTL8255_ANAPARAM_ON);
- rtl8185_set_anaparam2(dev, RTL8255_ANAPARAM2_ON);
-
- rtl8255_set_band_param(dev,BAND_BG);
-
- write_phy_cck(dev, 0x41, 0x9d);
-
- rtl8255_set_gain(dev, 4);
- //rtl8255_set_energy_threshold(dev);
- write_phy_cck(dev, 0x41, 0x9d);
- rtl8255_rf_set_chan(dev, priv->chan);
-
- write_nic_word(dev, BRSR, brsr);
-}
-
diff --git a/drivers/staging/rtl8187se/r8180_rtl8255.h b/drivers/staging/rtl8187se/r8180_rtl8255.h
deleted file mode 100644
index be44ca6eb1d3..000000000000
--- a/drivers/staging/rtl8187se/r8180_rtl8255.h
+++ /dev/null
@@ -1,19 +0,0 @@
-/*
- 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 rtl8255
- radio frontend.
-
- *Many* thanks to Realtek Corp. for their great support!
-
-*/
-
-#define RTL8255_ANAPARAM_ON 0xa0000b59
-#define RTL8255_ANAPARAM2_ON 0x840cf311
-
-
-void rtl8255_rf_init(struct net_device *dev);
-void rtl8255_rf_set_chan(struct net_device *dev,short ch);
-void rtl8255_rf_close(struct net_device *dev);
diff --git a/drivers/staging/rtl8187se/r8180_sa2400.c b/drivers/staging/rtl8187se/r8180_sa2400.c
deleted file mode 100644
index d6495601715f..000000000000
--- a/drivers/staging/rtl8187se/r8180_sa2400.c
+++ /dev/null
@@ -1,233 +0,0 @@
-/*
- This files contains PHILIPS SA2400 radio frontend programming routines.
-
- 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.
-
- Code at http://che.ojctech.com/~dyoung/rtw/ has been useful to me to
- understand some things.
-
- Code from rtl8181 project has been useful to me to understand some things.
-
- We want to tanks the Authors of such projects and the Ndiswrapper
- project Authors.
-*/
-
-
-#include "r8180.h"
-#include "r8180_hw.h"
-#include "r8180_sa2400.h"
-
-
-//#define DEBUG_SA2400
-
-u32 sa2400_chan[] = {
- 0x0, //dummy channel 0
- 0x00096c, //1
- 0x080970, //2
- 0x100974, //3
- 0x180978, //4
- 0x000980, //5
- 0x080984, //6
- 0x100988, //7
- 0x18098c, //8
- 0x000994, //9
- 0x080998, //10
- 0x10099c, //11
- 0x1809a0, //12
- 0x0009a8, //13
- 0x0009b4, //14
-};
-
-
-void rf_stabilize(struct net_device *dev)
-{
- force_pci_posting(dev);
- mdelay(3); //for now use a great value.. we may optimize in future
-}
-
-
-void write_sa2400(struct net_device *dev,u8 adr, u32 data)
-{
-// struct r8180_priv *priv = ieee80211_priv(dev);
- u32 phy_config;
-
- // philips sa2400 expects 24 bits data
-
- /*if(adr == 4 && priv->digphy){
- phy_config=0x60000000;
- }else{
- phy_config=0xb0000000;
- }*/
-
- phy_config = 0xb0000000; // MAC will bang bits to the sa2400
-
- phy_config |= (((u32)(adr&0xf))<< 24);
- phy_config |= (data & 0xffffff);
- write_nic_dword(dev,PHY_CONFIG,phy_config);
-#ifdef DEBUG_SA2400
- DMESG("Writing sa2400: %x (adr %x)",phy_config,adr);
-#endif
- rf_stabilize(dev);
-}
-
-
-
-void sa2400_write_phy_antenna(struct net_device *dev,short ch)
-{
- struct r8180_priv *priv = ieee80211_priv(dev);
- u8 ant;
-
- ant = SA2400_ANTENNA;
- if(priv->antb) /*default antenna is antenna B */
- ant |= BB_ANTENNA_B;
- if(ch == 14)
- ant |= BB_ANTATTEN_CHAN14;
- write_phy(dev,0x10,ant);
- //DMESG("BB antenna %x ",ant);
-}
-
-
-/* from the rtl8181 embedded driver */
-short sa2400_rf_set_sens(struct net_device *dev, short sens)
-{
- u8 finetune = 0;
- if ((sens > 85) || (sens < 54)) return -1;
-
- write_sa2400(dev,5,0x1dfb | (sens-54) << 15 |(finetune<<20)); // AGC 0xc9dfb
-
- return 0;
-}
-
-
-void sa2400_rf_set_chan(struct net_device *dev, short ch)
-{
- struct r8180_priv *priv = ieee80211_priv(dev);
- u32 txpw = 0xff & priv->chtxpwr[ch];
- u32 chan = sa2400_chan[ch];
-
- write_sa2400(dev,7,txpw);
- //write_phy(dev,0x10,0xd1);
- sa2400_write_phy_antenna(dev,ch);
- write_sa2400(dev,0,chan);
- write_sa2400(dev,1,0xbb50);
- write_sa2400(dev,2,0x80);
- write_sa2400(dev,3,0);
-}
-
-
-void sa2400_rf_close(struct net_device *dev)
-{
- write_sa2400(dev, 4, 0);
-}
-
-
-void sa2400_rf_init(struct net_device *dev)
-{
- struct r8180_priv *priv = ieee80211_priv(dev);
- u32 anaparam;
- u8 firdac;
-
- write_nic_byte(dev,PHY_DELAY,0x6); //this is general
- write_nic_byte(dev,CARRIER_SENSE_COUNTER,0x4c); //this is general
-
- /*these are philips sa2400 specific*/
- anaparam = read_nic_dword(dev,ANAPARAM);
- anaparam = anaparam &~ (1<<ANAPARAM_TXDACOFF_SHIFT);
-
- anaparam = anaparam &~ANAPARAM_PWR1_MASK;
- anaparam = anaparam &~ANAPARAM_PWR0_MASK;
- if(priv->digphy){
- anaparam |= (SA2400_DIG_ANAPARAM_PWR1_ON<<ANAPARAM_PWR1_SHIFT);
- anaparam |= (SA2400_ANAPARAM_PWR0_ON<<ANAPARAM_PWR0_SHIFT);
- }else{
- anaparam |= (SA2400_ANA_ANAPARAM_PWR1_ON<<ANAPARAM_PWR1_SHIFT);
- }
-
- rtl8180_set_anaparam(dev,anaparam);
-
- firdac = (priv->digphy) ? (1<<SA2400_REG4_FIRDAC_SHIFT) : 0;
- write_sa2400(dev,0,sa2400_chan[priv->chan]);
- write_sa2400(dev,1,0xbb50);
- write_sa2400(dev,2,0x80);
- write_sa2400(dev,3,0);
- write_sa2400(dev,4,0x19340 | firdac);
- write_sa2400(dev,5,0xc9dfb); // AGC
- write_sa2400(dev,4,0x19348 | firdac); //calibrates VCO
-
- if(priv->digphy)
- write_sa2400(dev,4,0x1938c); /*???*/
-
- write_sa2400(dev,4,0x19340 | firdac);
-
- write_sa2400(dev,0,sa2400_chan[priv->chan]);
- write_sa2400(dev,1,0xbb50);
- write_sa2400(dev,2,0x80);
- write_sa2400(dev,3,0);
- write_sa2400(dev,4,0x19344 | firdac); //calibrates filter
-
- /* new from rtl8180 embedded driver (rtl8181 project) */
- write_sa2400(dev,6,0x13ff | (1<<23)); // MANRX
- write_sa2400(dev,8,0); //VCO
-
- if(!priv->digphy)
- {
- rtl8180_set_anaparam(dev, anaparam | \
- (1<<ANAPARAM_TXDACOFF_SHIFT));
-
- rtl8180_conttx_enable(dev);
-
- write_sa2400(dev, 4, 0x19341); // calibrates DC
-
- /* a 5us sleep is required here,
- we rely on the 3ms delay introduced in write_sa2400
- */
- write_sa2400(dev, 4, 0x19345);
- /* a 20us sleep is required here,
- we rely on the 3ms delay introduced in write_sa2400
- */
- rtl8180_conttx_disable(dev);
-
- rtl8180_set_anaparam(dev, anaparam);
- }
- /* end new */
-
- write_sa2400(dev,4,0x19341 | firdac ); //RTX MODE
-
- // Set tx power level !?
-
-
- /*baseband configuration*/
- write_phy(dev,0,0x98);
- write_phy(dev,3,0x38);
- write_phy(dev,4,0xe0);
- write_phy(dev,5,0x90);
- write_phy(dev,6,0x1a);
- write_phy(dev,7,0x64);
-
- /*Should be done something more here??*/
-
- sa2400_write_phy_antenna(dev,priv->chan);
-
- write_phy(dev,0x11,0x80);
- if(priv->diversity)
- write_phy(dev,0x12,0xc7);
- else
- write_phy(dev,0x12,0x47);
-
- write_phy(dev,0x13,0x90 | priv->cs_treshold );
-
- write_phy(dev,0x19,0x0);
- write_phy(dev,0x1a,0xa0);
-
- sa2400_rf_set_chan(dev,priv->chan);
-}
diff --git a/drivers/staging/rtl8187se/r8180_sa2400.h b/drivers/staging/rtl8187se/r8180_sa2400.h
deleted file mode 100644
index 683a69b96af4..000000000000
--- a/drivers/staging/rtl8187se/r8180_sa2400.h
+++ /dev/null
@@ -1,26 +0,0 @@
-/*
- This is part of rtl8180 OpenSource driver - v 0.7
- 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.
-*/
-
-#define SA2400_ANTENNA 0x91
-#define SA2400_DIG_ANAPARAM_PWR1_ON 0x8
-#define SA2400_ANA_ANAPARAM_PWR1_ON 0x28
-#define SA2400_ANAPARAM_PWR0_ON 0x3
-
-#define SA2400_RF_MAX_SENS 85
-#define SA2400_RF_DEF_SENS 80
-
-#define SA2400_REG4_FIRDAC_SHIFT 7
-
-void sa2400_rf_init(struct net_device *dev);
-void sa2400_rf_set_chan(struct net_device *dev,short ch);
-short sa2400_rf_set_sens(struct net_device *dev,short sens);
-void sa2400_rf_close(struct net_device *dev);
diff --git a/drivers/staging/rtl8187se/r8180_wx.c b/drivers/staging/rtl8187se/r8180_wx.c
index 979ba0b5f331..58ad6fdb1707 100644
--- a/drivers/staging/rtl8187se/r8180_wx.c
+++ b/drivers/staging/rtl8187se/r8180_wx.c
@@ -20,11 +20,8 @@
#include "r8180.h"
#include "r8180_hw.h"
-#include "r8180_sa2400.h"
-#ifdef ENABLE_DOT11D
-#include "dot11d.h"
-#endif
+#include "ieee80211/dot11d.h"
//#define RATE_COUNT 4
u32 rtl8180_rates[] = {1000000,2000000,5500000,11000000,
@@ -313,11 +310,7 @@ static int rtl8180_wx_get_range(struct net_device *dev,
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;
@@ -1189,20 +1182,12 @@ static int r8180_wx_set_channelplan(struct net_device *dev,
// Clear old channel map
for (i=1;i<=MAX_CHANNEL_NUMBER;i++)
{
-#ifdef ENABLE_DOT11D
GET_DOT11D_INFO(priv->ieee80211)->channel_map[i] = 0;
-#else
- priv->ieee80211->channel_map[i] = 0;
-#endif
}
// Set new channel map
for (i=1;i<=DefaultChannelPlan[*val].Len;i++)
{
-#ifdef ENABLE_DOT11D
GET_DOT11D_INFO(priv->ieee80211)->channel_map[DefaultChannelPlan[*val].Channel[i-1]] = 1;
-#else
- priv->ieee80211->channel_map[DefaultChannelPlan[*val].Channel[i-1]] = 1;
-#endif
}
}
up(&priv->wx_sem);
@@ -1543,7 +1528,6 @@ static iw_handler r8180_private_handler[] = {
r8180_wx_set_forcerate,
};
-#if WIRELESS_EXT >= 17
static inline int is_same_network(struct ieee80211_network *src,
struct ieee80211_network *dst,
struct ieee80211_device *ieee)
@@ -1584,36 +1568,7 @@ static struct iw_statistics *r8180_get_wireless_stats(struct net_device *dev)
wstats->qual.updated = IW_QUAL_ALL_UPDATED | IW_QUAL_DBM;
return wstats;
}
-#if 0
- spin_lock_irqsave(&ieee->lock, flag);
- list_for_each_entry(target, &ieee->network_list, list)
- {
- if (is_same_network(target, &ieee->current_network, ieee))
- {
- printk("it's same network:%s\n", target->ssid);
-#if 0
- if (!tmp_level)
- {
- tmp_level = target->stats.signalstrength;
- tmp_qual = target->stats.signal;
- }
- else
- {
- tmp_level = (15*tmp_level + target->stats.signalstrength)/16;
- tmp_qual = (15*tmp_qual + target->stats.signal)/16;
- }
-#else
- tmp_level = target->stats.signal;
- tmp_qual = target->stats.signalstrength;
- tmp_noise = target->stats.noise;
- printk("level:%d, qual:%d, noise:%d\n", tmp_level, tmp_qual, tmp_noise);
-#endif
- break;
- }
- }
- spin_unlock_irqrestore(&ieee->lock, flag);
-#endif
tmp_level = (&ieee->current_network)->stats.signal;
tmp_qual = (&ieee->current_network)->stats.signalstrength;
tmp_noise = (&ieee->current_network)->stats.noise;
@@ -1626,8 +1581,6 @@ static struct iw_statistics *r8180_get_wireless_stats(struct net_device *dev)
wstats->qual.updated = IW_QUAL_ALL_UPDATED| IW_QUAL_DBM;
return wstats;
}
-#endif
-
struct iw_handler_def r8180_wx_handlers_def={
.standard = r8180_wx_handlers,
@@ -1635,9 +1588,7 @@ struct iw_handler_def r8180_wx_handlers_def={
.private = r8180_private_handler,
.num_private = sizeof(r8180_private_handler) / sizeof(iw_handler),
.num_private_args = sizeof(r8180_private_args) / sizeof(struct iw_priv_args),
-#if WIRELESS_EXT >= 17
.get_wireless_stats = r8180_get_wireless_stats,
-#endif
.private_args = (struct iw_priv_args *)r8180_private_args,
};
diff --git a/drivers/staging/rtl8187se/r8180_wx.h b/drivers/staging/rtl8187se/r8180_wx.h
index b20a67d33411..735d03dceed3 100644
--- a/drivers/staging/rtl8187se/r8180_wx.h
+++ b/drivers/staging/rtl8187se/r8180_wx.h
@@ -15,7 +15,7 @@
#ifndef R8180_WX_H
#define R8180_WX_H
#include <linux/wireless.h>
-#include "ieee80211.h"
+#include "ieee80211/ieee80211.h"
extern struct iw_handler_def r8180_wx_handlers_def;
#endif
diff --git a/drivers/staging/rtl8187se/r8185b_init.c b/drivers/staging/rtl8187se/r8185b_init.c
index 4b885a2319ee..ed5d19c96de1 100644
--- a/drivers/staging/rtl8187se/r8185b_init.c
+++ b/drivers/staging/rtl8187se/r8185b_init.c
@@ -22,28 +22,16 @@ Notes:
#include <linux/spinlock.h>
#include "r8180_hw.h"
#include "r8180.h"
-#include "r8180_sa2400.h" /* PHILIPS Radio frontend */
-#include "r8180_max2820.h" /* MAXIM Radio frontend */
-#include "r8180_gct.h" /* GCT Radio frontend */
#include "r8180_rtl8225.h" /* RTL8225 Radio frontend */
-#include "r8180_rtl8255.h" /* RTL8255 Radio frontend */
#include "r8180_93cx6.h" /* Card EEPROM */
#include "r8180_wx.h"
-#ifdef CONFIG_RTL8180_PM
-#include "r8180_pm.h"
-#endif
-
-#ifdef ENABLE_DOT11D
-#include "dot11d.h"
-#endif
+#include "ieee80211/dot11d.h"
-#ifdef CONFIG_RTL8185B
//#define CONFIG_RTL8180_IO_MAP
#define TC_3W_POLL_MAX_TRY_CNT 5
-#ifdef CONFIG_RTL818X_S
static u8 MAC_REG_TABLE[][2]={
//PAGA 0:
// 0x34(BRSR), 0xBE(RATE_FALLBACK_CTL), 0x1E0(ARFR) would set in HwConfigureRTL8185()
@@ -124,97 +112,6 @@ static u8 OFDM_CONFIG[]={
0xC0, 0xC1, 0x58, 0xF1, 0x00, 0xC4, 0x90, 0x3e,
0xD8, 0x3C, 0x7B, 0x10, 0x10
};
-#else
- static u8 MAC_REG_TABLE[][2]={
- //PAGA 0:
- {0xf0, 0x32}, {0xf1, 0x32}, {0xf2, 0x00}, {0xf3, 0x00}, {0xf4, 0x32},
- {0xf5, 0x43}, {0xf6, 0x00}, {0xf7, 0x00}, {0xf8, 0x46}, {0xf9, 0xa4},
- {0xfa, 0x00}, {0xfb, 0x00}, {0xfc, 0x96}, {0xfd, 0xa4}, {0xfe, 0x00},
- {0xff, 0x00},
-
- //PAGE 1:
- {0x5e, 0x01},
- {0x58, 0x4b}, {0x59, 0x00}, {0x5a, 0x4b}, {0x5b, 0x00}, {0x60, 0x4b},
- {0x61, 0x09}, {0x62, 0x4b}, {0x63, 0x09}, {0xce, 0x0f}, {0xcf, 0x00},
- {0xe0, 0xff}, {0xe1, 0x0f}, {0xe2, 0x00}, {0xf0, 0x4e}, {0xf1, 0x01},
- {0xf2, 0x02}, {0xf3, 0x03}, {0xf4, 0x04}, {0xf5, 0x05}, {0xf6, 0x06},
- {0xf7, 0x07}, {0xf8, 0x08},
-
-
- //PAGE 2:
- {0x5e, 0x02},
- {0x0c, 0x04}, {0x21, 0x61}, {0x22, 0x68}, {0x23, 0x6f}, {0x24, 0x76},
- {0x25, 0x7d}, {0x26, 0x84}, {0x27, 0x8d}, {0x4d, 0x08}, {0x4e, 0x00},
- {0x50, 0x05}, {0x51, 0xf5}, {0x52, 0x04}, {0x53, 0xa0}, {0x54, 0x1f},
- {0x55, 0x23}, {0x56, 0x45}, {0x57, 0x67}, {0x58, 0x08}, {0x59, 0x08},
- {0x5a, 0x08}, {0x5b, 0x08}, {0x60, 0x08}, {0x61, 0x08}, {0x62, 0x08},
- {0x63, 0x08}, {0x64, 0xcf}, {0x72, 0x56}, {0x73, 0x9a},
-
- //PAGA 0:
- {0x5e, 0x00},
- {0x34, 0xff}, {0x35, 0x0f}, {0x5b, 0x40}, {0x84, 0x88}, {0x85, 0x24},
- {0x88, 0x54}, {0x8b, 0xb8}, {0x8c, 0x07}, {0x8d, 0x00}, {0x94, 0x1b},
- {0x95, 0x12}, {0x96, 0x00}, {0x97, 0x06}, {0x9d, 0x1a}, {0x9f, 0x10},
- {0xb4, 0x22}, {0xbe, 0x80}, {0xdb, 0x00}, {0xee, 0x00}, {0x5b, 0x42},
- {0x91, 0x03},
-
- //PAGE 2:
- {0x5e, 0x02},
- {0x4c, 0x03},
-
- //PAGE 0:
- {0x5e, 0x00},
-
- //PAGE 3:
- {0x5e, 0x03},
- {0x9f, 0x00},
-
- //PAGE 0:
- {0x5e, 0x00},
- {0x8c, 0x01}, {0x8d, 0x10},{0x8e, 0x08}, {0x8f, 0x00}
- };
-
-
-static u8 ZEBRA_AGC[]={
- 0,
- 0x5e,0x5e,0x5e,0x5e,0x5d,0x5b,0x59,0x57,0x55,0x53,0x51,0x4f,0x4d,0x4b,0x49,0x47,
- 0x45,0x43,0x41,0x3f,0x3d,0x3b,0x39,0x37,0x35,0x33,0x31,0x2f,0x2d,0x2b,0x29,0x27,
- 0x25,0x23,0x21,0x1f,0x1d,0x1b,0x19,0x17,0x15,0x13,0x11,0x0f,0x0d,0x0b,0x09,0x07,
- 0x05,0x03,0x01,0x01,0x01,0x01,0x01,0x01,0x01,0x01,0x01,0x01,0x01,0x01,0x01,0x01,
- 0x19,0x19,0x19,0x019,0x19,0x19,0x19,0x19,0x19,0x19,0x1e,0x1f,0x20,0x21,0x21,0x22,
- 0x23,0x24,0x24,0x25,0x25,0x26,0x26,0x27,0x27,0x28,0x28,0x28,0x29,0x2a,0x2a,0x2b,
- 0x2b,0x2b,0x2c,0x2c,0x2c,0x2d,0x2d,0x2d,0x2e,0x2e,0x2f,0x30,0x31,0x31,0x31,0x31,
- 0x31,0x31,0x31,0x31,0x31,0x31,0x31,0x31,0x31,0x31,0x31,0x31,0x31,0x31,0x31,0x31
- };
-
-static u32 ZEBRA_RF_RX_GAIN_TABLE[]={
- 0,
- 0x0400,0x0401,0x0402,0x0403,0x0404,0x0405,0x0408,0x0409,
- 0x040a,0x040b,0x0502,0x0503,0x0504,0x0505,0x0540,0x0541,
- 0x0542,0x0543,0x0544,0x0545,0x0580,0x0581,0x0582,0x0583,
- 0x0584,0x0585,0x0588,0x0589,0x058a,0x058b,0x0643,0x0644,
- 0x0645,0x0680,0x0681,0x0682,0x0683,0x0684,0x0685,0x0688,
- 0x0689,0x068a,0x068b,0x068c,0x0742,0x0743,0x0744,0x0745,
- 0x0780,0x0781,0x0782,0x0783,0x0784,0x0785,0x0788,0x0789,
- 0x078a,0x078b,0x078c,0x078d,0x0790,0x0791,0x0792,0x0793,
- 0x0794,0x0795,0x0798,0x0799,0x079a,0x079b,0x079c,0x079d,
- 0x07a0,0x07a1,0x07a2,0x07a3,0x07a4,0x07a5,0x07a8,0x07a9,
- 0x03aa,0x03ab,0x03ac,0x03ad,0x03b0,0x03b1,0x03b2,0x03b3,
- 0x03b4,0x03b5,0x03b8,0x03b9,0x03ba,0x03bb,0x03bb
-};
-
-// 2006.07.13, SD3 szuyitasi:
-// OFDM.0x03=0x0C (original is 0x0F)
-// Use the new SD3 given param, by shien chang, 2006.07.14
-static u8 OFDM_CONFIG[]={
- 0x10, 0x0d, 0x01, 0x0C, 0x14, 0xfb, 0x0f, 0x60, 0x00, 0x60,
- 0x00, 0x00, 0x00, 0x5c, 0x00, 0x00, 0x40, 0x00, 0x40, 0x00,
- 0x00, 0x00, 0xa8, 0x46, 0xb2, 0x33, 0x07, 0xa5, 0x6f, 0x55,
- 0xc8, 0xb3, 0x0a, 0xe1, 0x1c, 0x8a, 0xb6, 0x83, 0x34, 0x0f,
- 0x4f, 0x23, 0x6f, 0xc2, 0x6b, 0x40, 0x80, 0x00, 0xc0, 0xc1,
- 0x58, 0xf1, 0x00, 0xe4, 0x90, 0x3e, 0x6d, 0x3c, 0xff, 0x07
-};
-#endif
/*---------------------------------------------------------------
* Hardware IO
@@ -228,37 +125,9 @@ PlatformIOWrite1Byte(
u8 data
)
{
-#ifndef CONFIG_RTL8180_IO_MAP
write_nic_byte(dev, offset, data);
read_nic_byte(dev, offset); // To make sure write operation is completed, 2005.11.09, by rcnjko.
-#else // Port IO
- u32 Page = (offset >> 8);
-
- switch(Page)
- {
- case 0: // Page 0
- write_nic_byte(dev, offset, data);
- break;
-
- case 1: // Page 1
- case 2: // Page 2
- case 3: // Page 3
- {
- u8 psr = read_nic_byte(dev, PSR);
-
- write_nic_byte(dev, PSR, ((psr & 0xfc) | (u8)Page)); // Switch to page N.
- write_nic_byte(dev, (offset & 0xff), data);
- write_nic_byte(dev, PSR, (psr & 0xfc)); // Switch to page 0.
- }
- break;
-
- default:
- // Illegal page number.
- DMESGE("PlatformIOWrite1Byte(): illegal page number: %d, offset: %#X", Page, offset);
- break;
- }
-#endif
}
void
@@ -268,38 +137,10 @@ PlatformIOWrite2Byte(
u16 data
)
{
-#ifndef CONFIG_RTL8180_IO_MAP
write_nic_word(dev, offset, data);
read_nic_word(dev, offset); // To make sure write operation is completed, 2005.11.09, by rcnjko.
-#else // Port IO
- u32 Page = (offset >> 8);
-
- switch(Page)
- {
- case 0: // Page 0
- write_nic_word(dev, offset, data);
- break;
-
- case 1: // Page 1
- case 2: // Page 2
- case 3: // Page 3
- {
- u8 psr = read_nic_byte(dev, PSR);
-
- write_nic_byte(dev, PSR, ((psr & 0xfc) | (u8)Page)); // Switch to page N.
- write_nic_word(dev, (offset & 0xff), data);
- write_nic_byte(dev, PSR, (psr & 0xfc)); // Switch to page 0.
- }
- break;
-
- default:
- // Illegal page number.
- DMESGE("PlatformIOWrite2Byte(): illegal page number: %d, offset: %#X", Page, offset);
- break;
- }
-#endif
}
u8 PlatformIORead1Byte(struct net_device *dev, u32 offset);
@@ -310,7 +151,6 @@ PlatformIOWrite4Byte(
u32 data
)
{
-#ifndef CONFIG_RTL8180_IO_MAP
//{by amy 080312
if (offset == PhyAddr)
{//For Base Band configuration.
@@ -354,33 +194,6 @@ if (offset == PhyAddr)
write_nic_dword(dev, offset, data);
read_nic_dword(dev, offset); // To make sure write operation is completed, 2005.11.09, by rcnjko.
}
-#else // Port IO
- u32 Page = (offset >> 8);
-
- switch(Page)
- {
- case 0: // Page 0
- write_nic_word(dev, offset, data);
- break;
-
- case 1: // Page 1
- case 2: // Page 2
- case 3: // Page 3
- {
- u8 psr = read_nic_byte(dev, PSR);
-
- write_nic_byte(dev, PSR, ((psr & 0xfc) | (u8)Page)); // Switch to page N.
- write_nic_dword(dev, (offset & 0xff), data);
- write_nic_byte(dev, PSR, (psr & 0xfc)); // Switch to page 0.
- }
- break;
-
- default:
- // Illegal page number.
- DMESGE("PlatformIOWrite4Byte(): illegal page number: %d, offset: %#X", Page, offset);
- break;
- }
-#endif
}
u8
@@ -391,36 +204,8 @@ PlatformIORead1Byte(
{
u8 data = 0;
-#ifndef CONFIG_RTL8180_IO_MAP
data = read_nic_byte(dev, offset);
-#else // Port IO
- u32 Page = (offset >> 8);
-
- switch(Page)
- {
- case 0: // Page 0
- data = read_nic_byte(dev, offset);
- break;
-
- case 1: // Page 1
- case 2: // Page 2
- case 3: // Page 3
- {
- u8 psr = read_nic_byte(dev, PSR);
-
- write_nic_byte(dev, PSR, ((psr & 0xfc) | (u8)Page)); // Switch to page N.
- data = read_nic_byte(dev, (offset & 0xff));
- write_nic_byte(dev, PSR, (psr & 0xfc)); // Switch to page 0.
- }
- break;
-
- default:
- // Illegal page number.
- DMESGE("PlatformIORead1Byte(): illegal page number: %d, offset: %#X", Page, offset);
- break;
- }
-#endif
return data;
}
@@ -433,36 +218,8 @@ PlatformIORead2Byte(
{
u16 data = 0;
-#ifndef CONFIG_RTL8180_IO_MAP
data = read_nic_word(dev, offset);
-#else // Port IO
- u32 Page = (offset >> 8);
-
- switch(Page)
- {
- case 0: // Page 0
- data = read_nic_word(dev, offset);
- break;
-
- case 1: // Page 1
- case 2: // Page 2
- case 3: // Page 3
- {
- u8 psr = read_nic_byte(dev, PSR);
-
- write_nic_byte(dev, PSR, ((psr & 0xfc) | (u8)Page)); // Switch to page N.
- data = read_nic_word(dev, (offset & 0xff));
- write_nic_byte(dev, PSR, (psr & 0xfc)); // Switch to page 0.
- }
- break;
-
- default:
- // Illegal page number.
- DMESGE("PlatformIORead2Byte(): illegal page number: %d, offset: %#X", Page, offset);
- break;
- }
-#endif
return data;
}
@@ -475,36 +232,8 @@ PlatformIORead4Byte(
{
u32 data = 0;
-#ifndef CONFIG_RTL8180_IO_MAP
data = read_nic_dword(dev, offset);
-#else // Port IO
- u32 Page = (offset >> 8);
-
- switch(Page)
- {
- case 0: // Page 0
- data = read_nic_dword(dev, offset);
- break;
-
- case 1: // Page 1
- case 2: // Page 2
- case 3: // Page 3
- {
- u8 psr = read_nic_byte(dev, PSR);
-
- write_nic_byte(dev, PSR, ((psr & 0xfc) | (u8)Page)); // Switch to page N.
- data = read_nic_dword(dev, (offset & 0xff));
- write_nic_byte(dev, PSR, (psr & 0xfc)); // Switch to page 0.
- }
- break;
-
- default:
- // Illegal page number.
- DMESGE("PlatformIORead4Byte(): illegal page number: %d, offset: %#X\n", Page, offset);
- break;
- }
-#endif
return data;
}
@@ -542,12 +271,10 @@ ZEBRA_RFSerialWrite(
u16 UshortBuffer;
u8 u1bTmp;
-#ifdef CONFIG_RTL818X_S
// RTL8187S HSSI Read/Write Function
u1bTmp = read_nic_byte(dev, RF_SW_CONFIG);
u1bTmp |= RF_SW_CFG_SI; //reg08[1]=1 Serial Interface(SI)
write_nic_byte(dev, RF_SW_CONFIG, u1bTmp);
-#endif
UshortBuffer = read_nic_word(dev, RFPinsOutput);
oval = UshortBuffer & 0xfff8; // We shall clear bit0, 1, 2 first, 2005.10.28, by rcnjko.
@@ -918,7 +645,6 @@ RF_WriteReg(
1); // bWrite
}
break;
- #ifdef CONFIG_RTL818X_S
case HW_THREE_WIRE_PI: //Parallel Interface
{ // Pure HW 3-wire.
data2Write = (data << 4) | (u32)(offset & 0x0f);
@@ -952,7 +678,6 @@ RF_WriteReg(
// printk(" exit ZEBRA_RFSerialWrite\n ");
}
break;
- #endif
default:
@@ -985,13 +710,11 @@ ZEBRA_RFSerialRead(
u8 u1bTmp;
ThreeWireReg tdata;
//PHAL_DATA_8187 pHalData = GetHalData8187(pAdapter);
-#ifdef CONFIG_RTL818X_S
{ // RTL8187S HSSI Read/Write Function
u1bTmp = read_nic_byte(dev, RF_SW_CONFIG);
u1bTmp |= RF_SW_CFG_SI; //reg08[1]=1 Serial Interface(SI)
write_nic_byte(dev, RF_SW_CONFIG, u1bTmp);
}
-#endif
wReg80 = oval = read_nic_word(dev, RFPinsOutput);
oval2 = read_nic_word(dev, RFPinsEnable);
@@ -1115,7 +838,6 @@ RF_ReadReg(
case RF_ZEBRA4:
switch(priv->RegThreeWireMode)
{
-#ifdef CONFIG_RTL818X_S
case HW_THREE_WIRE_PI: // For 87S Parallel Interface.
{
data2Write = ((u32)(offset&0x0f));
@@ -1145,7 +867,6 @@ RF_ReadReg(
}
break;
-#endif
// Perform SW 3-wire programming by driver.
default:
{
@@ -1204,7 +925,6 @@ ReadBBPortUchar(
return RegisterContent;
}
//{by amy 080312
-#ifdef CONFIG_RTL818X_S
//
// Description:
// Perform Antenna settings with antenna diversity on 87SE.
@@ -1286,7 +1006,6 @@ SetAntennaConfig87SE(
priv->CurrAntennaIndex = DefaultAnt; // Update default settings.
return bAntennaSwitched;
}
-#endif
//by amy 080312
/*---------------------------------------------------------------
* Hardware Initialization.
@@ -1305,7 +1024,6 @@ ZEBRA_Config_85BASIC_HardCode(
u32 u4bRegOffset, u4bRegValue, u4bRF23, u4bRF24;
u8 u1b24E;
-#ifdef CONFIG_RTL818X_S
//=============================================================================
// 87S_PCIE :: RADIOCFG.TXT
@@ -1470,11 +1188,6 @@ ZEBRA_Config_85BASIC_HardCode(
RF_WriteReg(dev, 0x05, 0x05ab); mdelay(1); // Rx mode//+edward
RF_WriteReg(dev, 0x00, 0x009f); mdelay(1); // Rx mode//+edward
-#if 0//-edward
- RF_WriteReg(dev, 0x00, 0x0197); mdelay(1);
- RF_WriteReg(dev, 0x05, 0x05ab); mdelay(1);
- RF_WriteReg(dev, 0x00, 0x009F); mdelay(1);
-#endif
RF_WriteReg(dev, 0x01, 0x0000); mdelay(1); // Rx mode//+edward
RF_WriteReg(dev, 0x02, 0x0000); mdelay(1); // Rx mode//+edward
//power save parameters.
@@ -1494,14 +1207,7 @@ ZEBRA_Config_85BASIC_HardCode(
CCK reg0x06[3]=1'b1: turn off unused circuits before cca = 1
CCK reg0x06[2]=1'b1: turn off cck's circuit if macrst =0
*/
-#if 0
- write_nic_dword(dev, PHY_ADR, 0x0100c880);
- write_nic_dword(dev, PHY_ADR, 0x01001c86);
- write_nic_dword(dev, PHY_ADR, 0x01007890);
- write_nic_dword(dev, PHY_ADR, 0x0100d0ae);
- write_nic_dword(dev, PHY_ADR, 0x010006af);
- write_nic_dword(dev, PHY_ADR, 0x01004681);
-#endif
+
write_phy_cck(dev,0x00,0xc8);
write_phy_cck(dev,0x06,0x1c);
write_phy_cck(dev,0x10,0x78);
@@ -1513,72 +1219,6 @@ ZEBRA_Config_85BASIC_HardCode(
write_nic_byte(dev, CCK_TXAGC, 0x10);
write_nic_byte(dev, OFDM_TXAGC, 0x1B);
write_nic_byte(dev, ANTSEL, 0x03);
-#else
- //=============================================================================
- // RADIOCFG.TXT
- //=============================================================================
-
- RF_WriteReg(dev, 0x00, 0x00b7); mdelay(1);
- RF_WriteReg(dev, 0x01, 0x0ee0); mdelay(1);
- RF_WriteReg(dev, 0x02, 0x044d); mdelay(1);
- RF_WriteReg(dev, 0x03, 0x0441); mdelay(1);
- RF_WriteReg(dev, 0x04, 0x08c3); mdelay(1);
- RF_WriteReg(dev, 0x05, 0x0c72); mdelay(1);
- RF_WriteReg(dev, 0x06, 0x00e6); mdelay(1);
- RF_WriteReg(dev, 0x07, 0x082a); mdelay(1);
- RF_WriteReg(dev, 0x08, 0x003f); mdelay(1);
- RF_WriteReg(dev, 0x09, 0x0335); mdelay(1);
- RF_WriteReg(dev, 0x0a, 0x09d4); mdelay(1);
- RF_WriteReg(dev, 0x0b, 0x07bb); mdelay(1);
- RF_WriteReg(dev, 0x0c, 0x0850); mdelay(1);
- RF_WriteReg(dev, 0x0d, 0x0cdf); mdelay(1);
- RF_WriteReg(dev, 0x0e, 0x002b); mdelay(1);
- RF_WriteReg(dev, 0x0f, 0x0114); mdelay(1);
-
- RF_WriteReg(dev, 0x00, 0x01b7); mdelay(1);
-
-
- for(i=1;i<=95;i++)
- {
- RF_WriteReg(dev, 0x01, i); mdelay(1);
- RF_WriteReg(dev, 0x02, ZEBRA_RF_RX_GAIN_TABLE[i]); mdelay(1);
- //DbgPrint("RF - 0x%x = 0x%x", i, ZEBRA_RF_RX_GAIN_TABLE[i]);
- }
-
- RF_WriteReg(dev, 0x03, 0x0080); mdelay(1); // write reg 18
- RF_WriteReg(dev, 0x05, 0x0004); mdelay(1); // write reg 20
- RF_WriteReg(dev, 0x00, 0x00b7); mdelay(1); // switch to reg0-reg15
- //0xfd
- //0xfd
- //0xfd
- RF_WriteReg(dev, 0x02, 0x0c4d); mdelay(1);
- mdelay(100); // Deay 100 ms. //0xfe
- mdelay(100); // Deay 100 ms. //0xfe
- RF_WriteReg(dev, 0x02, 0x044d); mdelay(1);
- RF_WriteReg(dev, 0x00, 0x02bf); mdelay(1); //0x002f disable 6us corner change, 06f--> enable
-
- //=============================================================================
-
- //=============================================================================
- // CCKCONF.TXT
- //=============================================================================
-
- //=============================================================================
-
- //=============================================================================
- // Follow WMAC RTL8225_Config()
- //=============================================================================
-
- // power control
- write_nic_byte(dev, CCK_TXAGC, 0x03);
- write_nic_byte(dev, OFDM_TXAGC, 0x07);
- write_nic_byte(dev, ANTSEL, 0x03);
-
- //=============================================================================
-
- // OFDM BBP setup
-// SetOutputEnableOfRfPins(dev);//by amy
-#endif
@@ -1633,69 +1273,9 @@ ZEBRA_Config_85BASIC_HardCode(
//by amy for antenna
//=============================================================================
//{by amy 080312
-#ifdef CONFIG_RTL818X_S
// Config Sw/Hw Combinational Antenna Diversity. Added by Roger, 2008.02.26.
SetAntennaConfig87SE(dev, priv->bDefaultAntenna1, priv->bSwAntennaDiverity);
-#endif
//by amy 080312}
-#if 0
- // Config Sw/Hw Antenna Diversity
- if( priv->bSwAntennaDiverity ) // Use SW+Hw Antenna Diversity
- {
- if( priv->bDefaultAntenna1 == true ) // aux antenna
- {
- // Mac register, aux antenna
- write_nic_byte(dev, ANTSEL, 0x00);
- // Config CCK RX antenna.
- write_phy_cck(dev, 0x11, 0xbb); // Reg11 : bb
- write_phy_cck(dev, 0x0c, 0x09); // Reg0c : 09
- write_phy_cck(dev, 0x01, 0xc7); // Reg01 : c7
- // Config OFDM RX antenna.
- write_phy_ofdm(dev, 0x0d, 0x54); // Reg0d : 54
- write_phy_ofdm(dev, 0x18, 0xb2); // Reg18 : b2
- }
- else // main antenna
- {
- // Mac register, main antenna
- write_nic_byte(dev, ANTSEL, 0x03);
- //base band
- // Config CCK RX antenna.
- write_phy_cck(dev, 0x11, 0x9b); // Reg11 : 9b
- write_phy_cck(dev, 0x0c, 0x09); // Reg0c : 09
- write_phy_cck(dev, 0x01, 0xc7); // Reg01 : c7
- // Config OFDM RX antenna.
- write_phy_ofdm(dev, 0x0d, 0x5c); // Reg0d : 5c
- write_phy_ofdm(dev, 0x18, 0xb2); // Reg18 : b2
- }
- }
- else // Disable Antenna Diversity
- {
- if( priv->bDefaultAntenna1 == true ) // aux Antenna
- {
- // Mac register, aux antenna
- write_nic_byte(dev, ANTSEL, 0x00);
- // Config CCK RX antenna.
- write_phy_cck(dev, 0x11, 0xbb); // Reg11 : bb
- write_phy_cck(dev, 0x0c, 0x09); // Reg0c : 09
- write_phy_cck(dev, 0x01, 0x47); // Reg01 : 47
- // Config OFDM RX antenna.
- write_phy_ofdm(dev, 0x0d, 0x54); // Reg0d : 54
- write_phy_ofdm(dev, 0x18, 0x32); // Reg18 : 32
- }
- else // main Antenna
- {
- // Mac register, main antenna
- write_nic_byte(dev, ANTSEL, 0x03);
- // Config CCK RX antenna.
- write_phy_cck(dev, 0x11, 0x9b); // Reg11 : 9b
- write_phy_cck(dev, 0x0c, 0x09); // Reg0c : 09
- write_phy_cck(dev, 0x01, 0x47); // Reg01 : 47
- // Config OFDM RX antenna.
- write_phy_ofdm(dev, 0x0d, 0x5c); // Reg0d : 5c
- write_phy_ofdm(dev, 0x18, 0x32); // Reg18 : 32
- }
- }
-#endif
//by amy for antenna
}
@@ -1722,69 +1302,6 @@ UpdateInitialGain(
switch(priv->rf_chip)
{
-#if 0
- case RF_ZEBRA2:
- // Dynamic set initial gain, by shien chang, 2006.07.14
- switch(priv->InitialGain)
- {
- case 1: //m861dBm
- DMESG("RTL8185B + 8225 Initial Gain State 1: -82 dBm \n");
- write_nic_dword(dev, PhyAddr, 0x2697); mdelay(1);
- write_nic_dword(dev, PhyAddr, 0x86a4); mdelay(1);
- write_nic_dword(dev, PhyAddr, 0xfa85); mdelay(1);
- break;
-
- case 2: //m862dBm
- DMESG("RTL8185B + 8225 Initial Gain State 2: -82 dBm \n");
- write_nic_dword(dev, PhyAddr, 0x2697); mdelay(1);
- write_nic_dword(dev, PhyAddr, 0x86a4); mdelay(1);
- write_nic_dword(dev, PhyAddr, 0xfb85); mdelay(1);
- break;
-
- case 3: //m863dBm
- DMESG("RTL8185B + 8225 Initial Gain State 3: -82 dBm \n");
- write_nic_dword(dev, PhyAddr, 0x2697); mdelay(1);
- write_nic_dword(dev, PhyAddr, 0x96a4); mdelay(1);
- write_nic_dword(dev, PhyAddr, 0xfb85); mdelay(1);
- break;
-
- case 4: //m864dBm
- DMESG("RTL8185B + 8225 Initial Gain State 4: -78 dBm \n");
- write_nic_dword(dev, PhyAddr, 0x2697); mdelay(1);
- write_nic_dword(dev, PhyAddr, 0xa6a4); mdelay(1);
- write_nic_dword(dev, PhyAddr, 0xfb85); mdelay(1);
- break;
-
- case 5: //m82dBm
- DMESG("RTL8185B + 8225 Initial Gain State 5: -74 dBm \n");
- write_nic_dword(dev, PhyAddr, 0x3697); mdelay(1);
- write_nic_dword(dev, PhyAddr, 0xa6a4); mdelay(1);
- write_nic_dword(dev, PhyAddr, 0xfb85); mdelay(1);
- break;
-
- case 6: //m78dBm
- DMESG("RTL8185B + 8225 Initial Gain State 6: -70 dBm \n");
- write_nic_dword(dev, PhyAddr, 0x4697); mdelay(1);
- write_nic_dword(dev, PhyAddr, 0xa6a4); mdelay(1);
- write_nic_dword(dev, PhyAddr, 0xfb85); mdelay(1);
- break;
-
- case 7: //m74dBm
- DMESG("RTL8185B + 8225 Initial Gain State 7: -66 dBm \n");
- write_nic_dword(dev, PhyAddr, 0x5697); mdelay(1);
- write_nic_dword(dev, PhyAddr, 0xa6a4); mdelay(1);
- write_nic_dword(dev, PhyAddr, 0xfb85); mdelay(1);
- break;
-
- default: //MP
- DMESG("RTL8185B + 8225 Initial Gain State 1: -82 dBm (default)\n");
- write_nic_dword(dev, PhyAddr, 0x2697); mdelay(1);
- write_nic_dword(dev, PhyAddr, 0x86a4); mdelay(1);
- write_nic_dword(dev, PhyAddr, 0xfa85); mdelay(1);
- break;
- }
- break;
-#endif
case RF_ZEBRA4:
// Dynamic set initial gain, follow 87B
switch(priv->InitialGain)
@@ -1861,7 +1378,6 @@ UpdateInitialGain(
break;
}
}
-#ifdef CONFIG_RTL818X_S
//
// Description:
// Tx Power tracking mechanism routine on 87SE.
@@ -1882,7 +1398,6 @@ InitTxPwrTracking87SE(
RF_WriteReg(dev, 0x02, u4bRfReg|PWR_METER_EN); mdelay(1);
}
-#endif
void
PhyConfig8185(
struct net_device *dev
@@ -1900,7 +1415,6 @@ PhyConfig8185(
break;
}
//{by amy 080312
-#ifdef CONFIG_RTL818X_S
// Set default initial gain state to 4, approved by SD3 DZ, by Bruce, 2007-06-06.
if(priv->bDigMechanism)
{
@@ -1917,7 +1431,6 @@ PhyConfig8185(
if(priv->bTxPowerTrack)
InitTxPwrTracking87SE(dev);
-#endif
//by amy 080312}
priv->InitialGainBackUp= priv->InitialGain;
UpdateInitialGain(dev);
@@ -2005,16 +1518,8 @@ HwConfigureRTL8185(
// <RJ_TODO_8185B> We shall set up the ARFR according to user's setting.
//write_nic_word(dev, ARFR, 0x0fff); // set 1M ~ 54M
//by amy
-#if 0
- PlatformIOWrite2Byte(dev, ARFR, 0x0fff); // set 1M ~ 54M
-#endif
-#ifdef CONFIG_RTL818X_S
// Aadded by Roger, 2007.11.15.
PlatformIOWrite2Byte(dev, ARFR, 0x0fff); //set 1M ~ 54Mbps.
-#else
- PlatformIOWrite2Byte(dev, ARFR, 0x0c00); //set 48Mbps, 54Mbps.
- // By SD3 szuyi's request. by Roger, 2007.03.26.
-#endif
//by amy
}
else
@@ -2084,10 +1589,6 @@ MacConfig_85BASIC(
// Asked for by SD3 CM Lin, 2006.06.27, by rcnjko.
//PlatformIOWrite4Byte(dev, RFTiming, 0x00004001);
//by amy
-#if 0
- write_nic_dword(dev, RFTiming, 0x00004001);
-#endif
-#ifdef CONFIG_RTL818X_S
// power save parameter based on "87SE power save parameters 20071127.doc", as follow.
//Enable DA10 TX power saving
@@ -2108,9 +1609,6 @@ MacConfig_85BASIC(
write_nic_word(dev, 0x37C, 0x00EC);
// write_nic_word(dev, 0x37E, 0x00FE);//-edward
write_nic_word(dev, 0x37E, 0x00EC);//+edward
-#else
- write_nic_dword(dev, RFTiming, 0x00004003);
-#endif
write_nic_byte(dev, 0x24E,0x01);
//by amy
@@ -2231,11 +1729,9 @@ ActUpdateChannelAccessSetting(
//lzm reserved 080826
#if 1
-#ifdef THOMAS_TURBO
// For turbo mode setting. port from 87B by Isaiah 2008-08-01
if( ieee->current_network.Turbo_Enable == 1 )
AcParam.f.TXOPLimit = 0x01FF;
-#endif
// For 87SE with Intel 4965 Ad-Hoc mode have poor throughput (19MB)
if (ieee->iw_mode == IW_MODE_ADHOC)
AcParam.f.TXOPLimit = 0x0020;
@@ -2477,16 +1973,6 @@ MgntDisconnectIBSS(
notify_wx_assoc_event(priv->ieee80211);
// Stop SW Beacon.Use hw beacon so do not need to do so.by amy
-#if 0
- if(pMgntInfo->bEnableSwBeaconTimer)
- {
- // SwBeaconTimer will stop if pMgntInfo->mIbss==FALSE, see SwBeaconCallback() for details.
-// comment out by haich, 2007.10.01
-//#if DEV_BUS_TYPE==USB_INTERFACE
- PlatformCancelTimer( Adapter, &pMgntInfo->SwBeaconTimer);
-//#endif
- }
-#endif
// MgntIndicateMediaStatus( Adapter, RT_MEDIA_DISCONNECT, GENERAL_INDICATE );
@@ -2576,10 +2062,8 @@ MgntDisconnect(
// Indication of disassociation event.
//DrvIFIndicateDisassociation(Adapter, asRsn);
-#ifdef ENABLE_DOT11D
if(IS_DOT11D_ENABLE(priv->ieee80211))
Dot11d_Reset(priv->ieee80211);
-#endif
// In adhoc mode, update beacon frame.
if( priv->ieee80211->state == IEEE80211_LINKED )
{
@@ -2844,19 +2328,7 @@ InactivePowerSave(
//
// To solve CAM values miss in RF OFF, rewrite CAM values after RF ON. By Bruce, 2007-09-20.
//
-#if 0
- while( index < 4 )
- {
- if( ( pMgntInfo->SecurityInfo.PairwiseEncAlgorithm == WEP104_Encryption ) ||
- (pMgntInfo->SecurityInfo.PairwiseEncAlgorithm == WEP40_Encryption) )
- {
- if( pMgntInfo->SecurityInfo.KeyLen[index] != 0)
- pAdapter->HalFunc.SetKeyHandler(pAdapter, index, 0, FALSE, pMgntInfo->SecurityInfo.PairwiseEncAlgorithm, TRUE, FALSE);
- }
- index++;
- }
-#endif
priv->bSwRfProcessing = false;
}
@@ -2981,22 +2453,14 @@ void rtl8185b_adapter_start(struct net_device *dev)
write_nic_byte(dev, CR9346, 0xc0); // enable config register write
//by amy
tmpu8 = read_nic_byte(dev, CONFIG3);
-#ifdef CONFIG_RTL818X_S
write_nic_byte(dev, CONFIG3, (tmpu8 |CONFIG3_PARM_En) );
-#else
- write_nic_byte(dev, CONFIG3, (tmpu8 |CONFIG3_PARM_En | CONFIG3_CLKRUN_En) );
-#endif
//by amy
// Turn on Analog power.
// Asked for by William, otherwise, MAC 3-wire can't work, 2006.06.27, by rcnjko.
write_nic_dword(dev, ANAPARAM2, ANAPARM2_ASIC_ON);
write_nic_dword(dev, ANAPARAM, ANAPARM_ASIC_ON);
//by amy
-#ifdef CONFIG_RTL818X_S
write_nic_word(dev, ANAPARAM3, 0x0010);
-#else
- write_nic_byte(dev, ANAPARAM3, 0x00);
-#endif
//by amy
write_nic_byte(dev, CONFIG3, tmpu8);
@@ -3151,58 +2615,6 @@ void rtl8185b_rx_enable(struct net_device *dev)
//u32 rxconf;
/* for now we accept data, management & ctl frame*/
struct r8180_priv *priv = (struct r8180_priv *)ieee80211_priv(dev);
-#if 0
- rxconf=read_nic_dword(dev,RX_CONF);
- rxconf = rxconf &~ MAC_FILTER_MASK;
- rxconf = rxconf | (1<<ACCEPT_MNG_FRAME_SHIFT);
- rxconf = rxconf | (1<<ACCEPT_DATA_FRAME_SHIFT);
- rxconf = rxconf | (1<<ACCEPT_BCAST_FRAME_SHIFT);
- rxconf = rxconf | (1<<ACCEPT_MCAST_FRAME_SHIFT);
-// rxconf = rxconf | (1<<ACCEPT_CRCERR_FRAME_SHIFT);
- if (dev->flags & IFF_PROMISC) DMESG ("NIC in promisc mode");
-
- if(priv->ieee80211->iw_mode == IW_MODE_MONITOR || \
- dev->flags & IFF_PROMISC){
- rxconf = rxconf | (1<<ACCEPT_ALLMAC_FRAME_SHIFT);
- }else{
- rxconf = rxconf | (1<<ACCEPT_NICMAC_FRAME_SHIFT);
- if(priv->card_8185 == 0)
- rxconf = rxconf | (1<<RX_CHECK_BSSID_SHIFT);
- }
-
- /*if(priv->ieee80211->iw_mode == IW_MODE_MASTER){
- rxconf = rxconf | (1<<ACCEPT_ALLMAC_FRAME_SHIFT);
- rxconf = rxconf | (1<<RX_CHECK_BSSID_SHIFT);
- }*/
-
- if(priv->ieee80211->iw_mode == IW_MODE_MONITOR){
- rxconf = rxconf | (1<<ACCEPT_CTL_FRAME_SHIFT);
- rxconf = rxconf | (1<<ACCEPT_ICVERR_FRAME_SHIFT);
- rxconf = rxconf | (1<<ACCEPT_PWR_FRAME_SHIFT);
- }
-
- if( priv->crcmon == 1 && priv->ieee80211->iw_mode == IW_MODE_MONITOR)
- rxconf = rxconf | (1<<ACCEPT_CRCERR_FRAME_SHIFT);
-
- //if(!priv->card_8185){
- rxconf = rxconf &~ RX_FIFO_THRESHOLD_MASK;
- rxconf = rxconf | (RX_FIFO_THRESHOLD_NONE<<RX_FIFO_THRESHOLD_SHIFT);
- //}
-
- rxconf = rxconf | (1<<RX_AUTORESETPHY_SHIFT);
- rxconf = rxconf &~ MAX_RX_DMA_MASK;
- rxconf = rxconf | (MAX_RX_DMA_2048<<MAX_RX_DMA_SHIFT);
-
- //if(!priv->card_8185)
- rxconf = rxconf | RCR_ONLYERLPKT;
-
- rxconf = rxconf &~ RCR_CS_MASK;
- if(!priv->card_8185)
- rxconf |= (priv->rcr_csense<<RCR_CS_SHIFT);
-// rxconf &=~ 0xfff00000;
-// rxconf |= 0x90100000;//9014f76f;
- write_nic_dword(dev, RX_CONF, rxconf);
-#endif
if (dev->flags & IFF_PROMISC) DMESG ("NIC in promisc mode");
@@ -3244,76 +2656,6 @@ void rtl8185b_tx_enable(struct net_device *dev)
//u32 txconf;
struct r8180_priv *priv = (struct r8180_priv *)ieee80211_priv(dev);
-#if 0
- txconf= read_nic_dword(dev,TX_CONF);
- if(priv->card_8185){
-
-
- 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);
-
- tx_agc_ctl = read_nic_byte(dev, TX_AGC_CTL);
- tx_agc_ctl &= ~(1<<TX_AGC_CTL_PERPACKET_GAIN_SHIFT);
- tx_agc_ctl &= ~(1<<TX_AGC_CTL_PERPACKET_ANTSEL_SHIFT);
- tx_agc_ctl |=(1<<TX_AGC_CTL_FEEDBACK_ANT);
- write_nic_byte(dev, TX_AGC_CTL, tx_agc_ctl);
- /*
- write_nic_word(dev, 0x5e, 0x01);
- force_pci_posting(dev);
- mdelay(1);
- write_nic_word(dev, 0xfe, 0x10);
- force_pci_posting(dev);
- mdelay(1);
- write_nic_word(dev, 0x5e, 0x00);
- force_pci_posting(dev);
- mdelay(1);
- */
- write_nic_byte(dev, 0xec, 0x3f); /* Disable early TX */
- }
-
- if(priv->card_8185){
-
- txconf = txconf &~ (1<<TCR_PROBE_NOTIMESTAMP_SHIFT);
-
- }else{
-
- if(hwseqnum)
- txconf= txconf &~ (1<<TX_CONF_HEADER_AUTOICREMENT_SHIFT);
- else
- txconf= txconf | (1<<TX_CONF_HEADER_AUTOICREMENT_SHIFT);
- }
-
- txconf = txconf &~ TX_LOOPBACK_MASK;
- txconf = txconf | (TX_LOOPBACK_NONE <<TX_LOOPBACK_SHIFT);
- txconf = txconf &~ TCR_DPRETRY_MASK;
- txconf = txconf &~ TCR_RTSRETRY_MASK;
- txconf = txconf | (priv->retry_data<<TX_DPRETRY_SHIFT);
- txconf = txconf | (priv->retry_rts<<TX_RTSRETRY_SHIFT);
- txconf = txconf &~ (1<<TX_NOCRC_SHIFT);
-
- if(priv->card_8185){
- if(priv->hw_plcp_len)
- txconf = txconf &~ TCR_PLCP_LEN;
- else
- txconf = txconf | TCR_PLCP_LEN;
- }else{
- txconf = txconf &~ TCR_SAT;
- }
- txconf = txconf &~ TCR_MXDMA_MASK;
- txconf = txconf | (TCR_MXDMA_2048<<TCR_MXDMA_SHIFT);
- txconf = txconf | TCR_CWMIN;
- txconf = txconf | TCR_DISCW;
-
-// if(priv->ieee80211->hw_wep)
-// txconf=txconf &~ (1<<TX_NOICV_SHIFT);
-// else
- txconf=txconf | (1<<TX_NOICV_SHIFT);
-
- write_nic_dword(dev,TX_CONF,txconf);
-#endif
-
write_nic_dword(dev, TCR, priv->TransmitConfig);
byte = read_nic_byte(dev, MSR);
byte |= MSR_LINK_ENEDCA;
@@ -3339,4 +2681,3 @@ void rtl8185b_tx_enable(struct net_device *dev)
}
-#endif
diff --git a/drivers/staging/rtl8192su/Kconfig b/drivers/staging/rtl8192su/Kconfig
index 4b5552c5926e..770f41280f21 100644
--- a/drivers/staging/rtl8192su/Kconfig
+++ b/drivers/staging/rtl8192su/Kconfig
@@ -1,6 +1,6 @@
config RTL8192SU
tristate "RealTek RTL8192SU 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/rtl8192su/Makefile b/drivers/staging/rtl8192su/Makefile
index f010ab502a97..aa9f80664dea 100644
--- a/drivers/staging/rtl8192su/Makefile
+++ b/drivers/staging/rtl8192su/Makefile
@@ -5,30 +5,9 @@ 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 += -DTHOMAS_BEACON
#EXTRA_CFLAGS += -DMUTIPLE_BULK_OUT
-EXTRA_CFLAGS += -DCONFIG_RTL8192_PM
r8192s_usb-objs := \
r8180_93cx6.o \
diff --git a/drivers/staging/rtl8192su/TODO b/drivers/staging/rtl8192su/TODO
new file mode 100644
index 000000000000..0d0ffce545df
--- /dev/null
+++ b/drivers/staging/rtl8192su/TODO
@@ -0,0 +1,23 @@
+TODO:
+- make ieee80211 stack private (may conflict with libipw currently)
+- prepare private ieee80211 stack for merge with rtl8187se's version:
+ - remove JOHN_DUMP[_DESC] ifdefs
+ - remove [IN]_OPENSUSE_SLED definitions
+ - remove superflous container_of definition from ieee80211.h
+ - remove superfluous ieee80211_* definitions from ieee80211.h
+ - remove rtl8192su's specific dead code
+ - cleanup ieee80211.h
+ - move rtl8192su's specific code out from ieee80211.h
+ - abstract rtl819su's specific code
+ - use list_for_each_safe() in ieee80211_crypto_deinit
+- switch to use shared "librtl" instead of private ieee80211 stack
+- switch to use LIB80211
+- switch to use MAC80211
+- switch to use EEPROM_93CX6
+- use kernel coding style
+- checkpatch.pl fixes
+- sparse fixes
+- integrate with drivers/net/wireless/rtl818x
+
+Please send any patches to Greg Kroah-Hartman <greg@kroah.com> and
+Bartlomiej Zolnierkiewicz <bzolnier@gmail.com>.
diff --git a/drivers/staging/rtl8192su/dot11d.h b/drivers/staging/rtl8192su/dot11d.h
deleted file mode 100644
index 15b7a4ba37b6..000000000000
--- a/drivers/staging/rtl8192su/dot11d.h
+++ /dev/null
@@ -1,102 +0,0 @@
-#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
deleted file mode 100644
index 0edb09a536f9..000000000000
--- a/drivers/staging/rtl8192su/ieee80211.h
+++ /dev/null
@@ -1,2901 +0,0 @@
-/*
- * 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
deleted file mode 100644
index 0c417a6234a9..000000000000
--- a/drivers/staging/rtl8192su/ieee80211/EndianFree.h
+++ /dev/null
@@ -1,199 +0,0 @@
-#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
index 295a18f3c9ca..a500bfaeaef2 100644
--- a/drivers/staging/rtl8192su/ieee80211/Makefile
+++ b/drivers/staging/rtl8192su/ieee80211/Makefile
@@ -5,8 +5,7 @@ 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 \
diff --git a/drivers/staging/rtl8192su/ieee80211/aes.c b/drivers/staging/rtl8192su/ieee80211/aes.c
deleted file mode 100644
index 0c176e29a797..000000000000
--- a/drivers/staging/rtl8192su/ieee80211/aes.c
+++ /dev/null
@@ -1,469 +0,0 @@
-/*
- * 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
deleted file mode 100644
index c627d029528b..000000000000
--- a/drivers/staging/rtl8192su/ieee80211/api.c
+++ /dev/null
@@ -1,246 +0,0 @@
-/*
- * 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
deleted file mode 100644
index e408472af305..000000000000
--- a/drivers/staging/rtl8192su/ieee80211/arc4.c
+++ /dev/null
@@ -1,103 +0,0 @@
-/*
- * 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
deleted file mode 100644
index c97756f3b2ea..000000000000
--- a/drivers/staging/rtl8192su/ieee80211/autoload.c
+++ /dev/null
@@ -1,40 +0,0 @@
-/*
- * 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
deleted file mode 100644
index 1968acfe32b1..000000000000
--- a/drivers/staging/rtl8192su/ieee80211/cipher.c
+++ /dev/null
@@ -1,299 +0,0 @@
-/*
- * 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
deleted file mode 100644
index c2df80e2ed9d..000000000000
--- a/drivers/staging/rtl8192su/ieee80211/compress.c
+++ /dev/null
@@ -1,64 +0,0 @@
-/*
- * 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
deleted file mode 100644
index 587e8bb2db6a..000000000000
--- a/drivers/staging/rtl8192su/ieee80211/crypto_compat.h
+++ /dev/null
@@ -1,90 +0,0 @@
-/*
- * 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
deleted file mode 100644
index 1a95f2d37837..000000000000
--- a/drivers/staging/rtl8192su/ieee80211/digest.c
+++ /dev/null
@@ -1,108 +0,0 @@
-/*
- * 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
index e5f2dedc4372..757266a152b8 100644
--- a/drivers/staging/rtl8192su/ieee80211/dot11d.c
+++ b/drivers/staging/rtl8192su/ieee80211/dot11d.c
@@ -1,4 +1,3 @@
-#ifdef ENABLE_DOT11D
//-----------------------------------------------------------------------------
// File:
// Dot11d.c
@@ -35,10 +34,7 @@ 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);
@@ -218,7 +214,7 @@ int ToLegalChannel(
return default_chn;
}
-#if (LINUX_VERSION_CODE > KERNEL_VERSION(2,5,0))
+
EXPORT_SYMBOL(Dot11d_Init);
EXPORT_SYMBOL(Dot11d_Reset);
EXPORT_SYMBOL(Dot11d_UpdateCountryIe);
@@ -226,14 +222,4 @@ 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
index 15b7a4ba37b6..913ac5d97e75 100644
--- a/drivers/staging/rtl8192su/ieee80211/dot11d.h
+++ b/drivers/staging/rtl8192su/ieee80211/dot11d.h
@@ -1,11 +1,8 @@
#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 {
@@ -98,5 +95,4 @@ 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
index 720bfcbfadc1..6732797f849f 100644
--- a/drivers/staging/rtl8192su/ieee80211/ieee80211.h
+++ b/drivers/staging/rtl8192su/ieee80211/ieee80211.h
@@ -27,28 +27,18 @@
#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 <linux/ieee80211.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
@@ -57,25 +47,6 @@ typedef enum{false = 0, true} bool;
#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
@@ -244,55 +215,6 @@ typedef struct cb_desc {
#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
@@ -409,13 +331,11 @@ enum _ReasonCode{
#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;
@@ -446,56 +366,8 @@ typedef struct ieee_param {
} 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
@@ -521,62 +393,19 @@ static inline void msleep(unsigned int msecs)
/* 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
@@ -796,93 +625,12 @@ struct ieee80211_snap_hdr {
#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 RTL_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)
@@ -1173,7 +921,7 @@ enum ieee80211_mfie {
/* 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 {
+struct rtl_ieee80211_hdr {
__le16 frame_ctl;
__le16 duration_id;
u8 payload[0];
@@ -1695,13 +1443,9 @@ struct ieee80211_network {
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.
@@ -1787,21 +1531,6 @@ enum ieee80211_state {
#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;
@@ -1879,11 +1608,7 @@ typedef struct _RT_POWER_SAVE_CONTROL
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
@@ -1945,7 +1670,6 @@ typedef u32 RT_RF_CHANGE_SOURCE;
#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,
@@ -1960,7 +1684,6 @@ typedef enum
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
@@ -2169,12 +1892,8 @@ struct ieee80211_device {
/* 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
@@ -2290,41 +2009,17 @@ struct ieee80211_device {
/* 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;
@@ -2424,36 +2119,10 @@ struct ieee80211_device {
// 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
@@ -2512,11 +2181,7 @@ struct ieee80211_device {
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)
@@ -2588,7 +2253,7 @@ extern inline int ieee80211_get_hdrlen(u16 fc)
return hdrlen;
}
-static inline u8 *ieee80211_get_payload(struct ieee80211_hdr *hdr)
+static inline u8 *ieee80211_get_payload(struct rtl_ieee80211_hdr *hdr)
{
switch (ieee80211_get_hdrlen(le16_to_cpu(hdr->frame_ctl))) {
case IEEE80211_1ADDR_LEN:
@@ -2667,7 +2332,6 @@ extern int ieee80211_wx_set_encode(struct ieee80211_device *ieee,
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);
@@ -2680,7 +2344,6 @@ extern int ieee80211_wx_set_auth(struct ieee80211_device *ieee,
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 */
@@ -2769,12 +2432,7 @@ extern int ieee80211_wx_get_freq(struct ieee80211_device *ieee, struct iw_reques
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,
diff --git a/drivers/staging/rtl8192su/ieee80211/ieee80211_crypt.c b/drivers/staging/rtl8192su/ieee80211/ieee80211_crypt.c
index 199ee1695ad3..14ffd76e0d76 100644
--- a/drivers/staging/rtl8192su/ieee80211/ieee80211_crypt.c
+++ b/drivers/staging/rtl8192su/ieee80211/ieee80211_crypt.c
@@ -55,11 +55,7 @@ void ieee80211_crypt_deinit_entries(struct ieee80211_device *ieee,
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);
}
@@ -251,7 +247,6 @@ static void __exit ieee80211_crypto_deinit(void)
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);
@@ -259,15 +254,6 @@ 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
index a84df4b76489..b58a3bcc0dc0 100644
--- a/drivers/staging/rtl8192su/ieee80211/ieee80211_crypt.h
+++ b/drivers/staging/rtl8192su/ieee80211/ieee80211_crypt.h
@@ -82,12 +82,5 @@ 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
index a86c26eceb34..e9225fef427c 100644
--- a/drivers/staging/rtl8192su/ieee80211/ieee80211_crypt_ccmp.c
+++ b/drivers/staging/rtl8192su/ieee80211/ieee80211_crypt_ccmp.c
@@ -24,18 +24,8 @@
#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>
+#include <linux/scatterlist.h>
MODULE_AUTHOR("Jouni Malinen");
MODULE_DESCRIPTION("Host AP crypt: CCMP");
@@ -75,21 +65,7 @@ struct ieee80211_ccmp_data {
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)
@@ -102,32 +78,20 @@ static void * ieee80211_ccmp_init(int key_idx)
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);
+ 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);
}
@@ -138,12 +102,9 @@ fail:
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);
}
@@ -524,11 +485,7 @@ 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
index b031b6495247..7e497b4927ce 100644
--- a/drivers/staging/rtl8192su/ieee80211/ieee80211_crypt_tkip.c
+++ b/drivers/staging/rtl8192su/ieee80211/ieee80211_crypt_tkip.c
@@ -22,23 +22,9 @@
#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/scatterlist.h>
#include <linux/crc32.h>
MODULE_AUTHOR("Jouni Malinen");
@@ -71,17 +57,12 @@ struct ieee80211_tkip_data {
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];
};
@@ -95,35 +76,7 @@ static void * ieee80211_tkip_init(int key_idx)
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)) {
@@ -159,22 +112,11 @@ static void * ieee80211_tkip_init(int key_idx)
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)
@@ -183,7 +125,6 @@ fail:
crypto_free_hash(priv->rx_tfm_michael);
if (priv->rx_tfm_arc4)
crypto_free_blkcipher(priv->rx_tfm_arc4);
-#endif
kfree(priv);
}
@@ -194,16 +135,7 @@ fail:
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);
@@ -214,7 +146,6 @@ static void ieee80211_tkip_deinit(void *priv)
if (_priv->rx_tfm_arc4)
crypto_free_blkcipher(_priv->rx_tfm_arc4);
}
-#endif
kfree(priv);
}
@@ -384,11 +315,8 @@ static int ieee80211_tkip_encrypt(struct sk_buff *skb, int hdr_len, void *priv)
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};
+ struct blkcipher_desc desc = { .tfm = tkey->tx_tfm_arc4 };
int ret = 0;
- #endif
u8 rc4key[16], *icv;
u32 crc;
struct scatterlist sg;
@@ -399,18 +327,6 @@ static int ieee80211_tkip_encrypt(struct sk_buff *skb, int hdr_len, void *priv)
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) {
@@ -451,33 +367,14 @@ printk("%x\n", ((u32*)tkey->key)[7]);
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
+ sg_init_one(&sg, pos, len + 4);
ret= crypto_blkcipher_encrypt(&desc, &sg, &sg, len + 4);
-#endif
-
}
tkey->tx_iv16++;
@@ -487,11 +384,7 @@ printk("%x\n", ((u32*)tkey->key)[7]);
}
if (!tcb_desc->bHwSec)
-#if((LINUX_VERSION_CODE < KERNEL_VERSION(2,6,21)) && (!OPENSUSE_SLED))
- return 0;
- #else
return ret;
- #endif
else
return 0;
@@ -506,9 +399,7 @@ static int ieee80211_tkip_decrypt(struct sk_buff *skb, int hdr_len, void *priv)
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
+ struct blkcipher_desc desc = { .tfm = tkey->rx_tfm_arc4 };
u8 rc4key[16];
u8 icv[4];
u32 crc;
@@ -567,21 +458,9 @@ static int ieee80211_tkip_decrypt(struct sk_buff *skb, int hdr_len, void *priv)
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
+ sg_init_one(&sg, pos, plen + 4);
+
if (crypto_blkcipher_decrypt(&desc, &sg, &sg, plen + 4)) {
if (net_ratelimit()) {
printk(KERN_DEBUG ": TKIP: failed to decrypt "
@@ -590,13 +469,8 @@ static int ieee80211_tkip_decrypt(struct sk_buff *skb, int hdr_len, void *priv)
}
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;
@@ -643,48 +517,6 @@ if( ((u16*)skb->data)[0] & 0x4000){
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)
{
@@ -695,19 +527,10 @@ static int michael_mic(struct crypto_hash *tfm_michael, u8 * key, u8 * hdr,
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
+
+ sg_init_table(sg, 2);
+ sg_set_buf(&sg[0], hdr, 16);
+ sg_set_buf(&sg[1], data, data_len);
if (crypto_hash_setkey(tfm_michael, key, 8))
return -1;
@@ -716,9 +539,6 @@ static int michael_mic(struct crypto_hash *tfm_michael, u8 * key, u8 * hdr,
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)
{
@@ -775,20 +595,14 @@ static int ieee80211_michael_mic_add(struct sk_buff *skb, int hdr_len, void *pri
}
// }
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
+ skb->data + hdr_len, skb->len - 8 - hdr_len, pos))
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)
@@ -809,29 +623,6 @@ static void ieee80211_michael_mic_failure(struct net_device *dev,
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)
@@ -853,13 +644,8 @@ static int ieee80211_michael_mic_verify(struct sk_buff *skb, int keyidx,
}
// }
-#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
+ skb->data + hdr_len, skb->len - 8 - hdr_len, mic))
return -1;
if (memcmp(mic, skb->data + skb->len - 8, 8) != 0) {
struct ieee80211_hdr_4addr *hdr;
@@ -889,32 +675,18 @@ 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);
@@ -1024,11 +796,7 @@ 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
index 7e394328ec90..df07212bd172 100644
--- a/drivers/staging/rtl8192su/ieee80211/ieee80211_crypt_wep.c
+++ b/drivers/staging/rtl8192su/ieee80211/ieee80211_crypt_wep.c
@@ -20,35 +20,10 @@
#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/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");
@@ -62,12 +37,8 @@ struct prism2_wep_data {
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
+ struct crypto_blkcipher *tx_tfm;
+ struct crypto_blkcipher *rx_tfm;
};
@@ -81,14 +52,6 @@ static void * prism2_wep_init(int keyidx)
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 "
@@ -103,7 +66,6 @@ static void * prism2_wep_init(int keyidx)
priv->rx_tfm = NULL;
goto fail;
}
- #endif
/* start WEP IV from a random value */
get_random_bytes(&priv->iv, 4);
@@ -111,13 +73,6 @@ static void * prism2_wep_init(int keyidx)
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);
@@ -125,7 +80,7 @@ fail:
crypto_free_blkcipher(priv->rx_tfm);
kfree(priv);
}
- #endif
+
return NULL;
}
@@ -133,17 +88,13 @@ fail:
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);
}
@@ -160,9 +111,7 @@ static int prism2_wep_encrypt(struct sk_buff *skb, int hdr_len, void *priv)
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
+ struct blkcipher_desc desc = { .tfm = wep->tx_tfm };
u32 crc;
u8 *icv;
struct scatterlist sg;
@@ -201,35 +150,17 @@ static int prism2_wep_encrypt(struct sk_buff *skb, int hdr_len, void *priv)
{
/* 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;
@@ -250,9 +181,7 @@ static int prism2_wep_decrypt(struct sk_buff *skb, int hdr_len, void *priv)
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
+ struct blkcipher_desc desc = { .tfm = wep->rx_tfm };
u32 crc;
u8 icv[4];
struct scatterlist sg;
@@ -277,29 +206,13 @@ static int prism2_wep_decrypt(struct sk_buff *skb, int hdr_len, void *priv)
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
+ sg_init_one(&sg, pos, plen + 4);
+
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;
@@ -387,11 +300,7 @@ 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
index f408b4583b82..7c18b8a0569a 100644
--- a/drivers/staging/rtl8192su/ieee80211/ieee80211_module.c
+++ b/drivers/staging/rtl8192su/ieee80211/ieee80211_module.c
@@ -113,13 +113,7 @@ struct net_device *alloc_ieee80211(int sizeof_priv)
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;
@@ -167,12 +161,7 @@ struct net_device *alloc_ieee80211(int sizeof_priv)
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");
@@ -181,13 +170,7 @@ struct net_device *alloc_ieee80211(int sizeof_priv)
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]);
@@ -206,22 +189,15 @@ struct net_device *alloc_ieee80211(int sizeof_priv)
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);
@@ -242,11 +218,7 @@ void free_ieee80211(struct net_device *dev)
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;
@@ -254,20 +226,7 @@ void free_ieee80211(struct net_device *dev)
}
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
@@ -333,11 +292,8 @@ 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");
@@ -346,11 +302,7 @@ static int __init ieee80211_init(void)
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;
}
@@ -365,16 +317,11 @@ 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");
@@ -383,12 +330,6 @@ 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
index 2b2ffd34bc92..f63bb49a84e4 100644
--- a/drivers/staging/rtl8192su/ieee80211/ieee80211_rx.c
+++ b/drivers/staging/rtl8192su/ieee80211/ieee80211_rx.c
@@ -44,9 +44,7 @@
#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)
@@ -55,11 +53,7 @@ static inline void ieee80211_monitor_rx(struct ieee80211_device *ieee,
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;
@@ -626,10 +620,6 @@ void RxReorderIndicatePacket( struct ieee80211_device *ieee,
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;
@@ -790,14 +780,7 @@ void RxReorderIndicatePacket( struct ieee80211_device *ieee,
// 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
}
@@ -866,11 +849,6 @@ u8 parse_subframe(struct sk_buff *skb,
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);
@@ -990,7 +968,6 @@ int ieee80211_rx(struct ieee80211_device *ieee, struct sk_buff *skb,
//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 */
@@ -1004,18 +981,16 @@ int ieee80211_rx(struct ieee80211_device *ieee, struct sk_buff *skb,
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)
@@ -1067,17 +1042,6 @@ int ieee80211_rx(struct ieee80211_device *ieee, struct sk_buff *skb,
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(
@@ -1111,20 +1075,6 @@ int ieee80211_rx(struct ieee80211_device *ieee, struct sk_buff *skb,
#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;
@@ -1659,7 +1609,6 @@ static const char *get_info_element_string(u16 id)
}
#endif
-#ifdef ENABLE_DOT11D
static inline void ieee80211_extract_country_ie(
struct ieee80211_device *ieee,
struct ieee80211_info_element *info_element,
@@ -1692,7 +1641,6 @@ static inline void ieee80211_extract_country_ie(
}
}
-#endif
int ieee80211_parse_info_param(struct ieee80211_device *ieee,
struct ieee80211_info_element *info_element,
@@ -1823,12 +1771,8 @@ int ieee80211_parse_info_param(struct ieee80211_device *ieee,
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;
@@ -1891,7 +1835,6 @@ int ieee80211_parse_info_param(struct ieee80211_device *ieee,
break;
}
-#ifdef THOMAS_TURBO
if (info_element->len == 7 &&
info_element->data[0] == 0x00 &&
info_element->data[1] == 0xe0 &&
@@ -1900,7 +1843,6 @@ int ieee80211_parse_info_param(struct ieee80211_device *ieee,
info_element->data[4] == 0x02) {
network->Turbo_Enable = 1;
}
-#endif
//for HTcap and HTinfo parameters
if(tmp_htcap_len == 0){
@@ -1997,16 +1939,6 @@ int ieee80211_parse_info_param(struct ieee80211_device *ieee,
}
}
-#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 &&
@@ -2183,53 +2115,12 @@ int ieee80211_parse_info_param(struct ieee80211_device *ieee,
"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",
@@ -2363,13 +2254,9 @@ static inline int ieee80211_network_init(
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);
@@ -2543,14 +2430,10 @@ static inline void update_network(struct ieee80211_network *dst,
#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;
@@ -2618,7 +2501,6 @@ static inline void ieee80211_process_probe_response(
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.
@@ -2675,7 +2557,6 @@ static inline void ieee80211_process_probe_response(
}
}
}
-#endif
/* The network parsed correctly -- so now we scan our known networks
* to see if we can find it in our list.
@@ -2823,10 +2704,5 @@ void ieee80211_rx_mgt(struct ieee80211_device *ieee,
}
}
-#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
index 6773e84c778e..c724968dba44 100644
--- a/drivers/staging/rtl8192su/ieee80211/ieee80211_softmac.c
+++ b/drivers/staging/rtl8192su/ieee80211/ieee80211_softmac.c
@@ -20,9 +20,7 @@
#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
@@ -129,7 +127,6 @@ void ieee80211_WMM_Info(struct ieee80211_device *ieee, u8 **tag_p) {
*tag_p = tag;
}
-#ifdef THOMAS_TURBO
void ieee80211_TURBO_Info(struct ieee80211_device *ieee, u8 **tag_p) {
u8 *tag = *tag_p;
@@ -146,7 +143,6 @@ void ieee80211_TURBO_Info(struct ieee80211_device *ieee, u8 **tag_p) {
*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)
{
@@ -435,10 +431,8 @@ void ieee80211_send_probe_requests(struct ieee80211_device *ieee)
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);
@@ -449,11 +443,7 @@ void ieee80211_softmac_scan_syncro(struct ieee80211_device *ieee)
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
@@ -477,9 +467,7 @@ void ieee80211_softmac_scan_syncro(struct ieee80211_device *ieee)
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
@@ -503,48 +491,20 @@ out:
}
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);
@@ -554,43 +514,24 @@ void ieee80211_softmac_scan_wq(struct ieee80211_device *ieee)
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;
@@ -598,19 +539,6 @@ out:
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;
@@ -666,11 +594,7 @@ void ieee80211_softmac_stop_scan(struct ieee80211_device *ieee)
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);
@@ -688,7 +612,6 @@ void ieee80211_stop_scan(struct ieee80211_device *ieee)
/* 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))
@@ -696,20 +619,10 @@ void ieee80211_start_scan(struct ieee80211_device *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);
@@ -719,7 +632,6 @@ void ieee80211_start_scan(struct ieee80211_device *ieee)
/* 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))
@@ -727,7 +639,6 @@ void ieee80211_start_scan_syncro(struct ieee80211_device *ieee)
RESET_CIE_WATCHDOG(ieee);
}
}
-#endif
ieee->sync_scan_hurryup = 0;
if (ieee->softmac_features & IEEE_SOFTMAC_SCAN)
ieee80211_softmac_scan_syncro(ieee);
@@ -885,10 +796,7 @@ static struct sk_buff* ieee80211_probe_resp(struct ieee80211_device *ieee, u8 *d
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);
@@ -927,14 +835,7 @@ static struct sk_buff* ieee80211_probe_resp(struct ieee80211_device *ieee, u8 *d
*(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;
@@ -942,14 +843,6 @@ static struct sk_buff* ieee80211_probe_resp(struct ieee80211_device *ieee, u8 *d
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)
@@ -960,28 +853,6 @@ static struct sk_buff* ieee80211_probe_resp(struct ieee80211_device *ieee, u8 *d
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;
}
@@ -1150,9 +1021,7 @@ inline struct sk_buff *ieee80211_association_req(struct ieee80211_network *beaco
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;
@@ -1190,7 +1059,6 @@ inline struct sk_buff *ieee80211_association_req(struct ieee80211_network *beaco
{
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
@@ -1203,19 +1071,6 @@ inline struct sk_buff *ieee80211_association_req(struct ieee80211_network *beaco
+ 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);
@@ -1337,12 +1192,10 @@ inline struct sk_buff *ieee80211_association_req(struct ieee80211_network *beaco
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)
@@ -1390,12 +1243,8 @@ void ieee80211_associate_abort(struct ieee80211_device *ieee)
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);
}
@@ -1457,10 +1306,6 @@ void ieee80211_auth_challenge(struct ieee80211_device *ieee, u8 *challenge, int
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);
@@ -1482,21 +1327,14 @@ void ieee80211_associate_step2(struct ieee80211_device *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) &&
@@ -1548,41 +1386,15 @@ void ieee80211_associate_complete(struct ieee80211_device *ieee)
// 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);
@@ -1682,11 +1494,7 @@ inline void ieee80211_softmac_new_net(struct ieee80211_device *ieee, struct ieee
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)){
@@ -1903,11 +1711,6 @@ ieee80211_rx_assoc_rq(struct ieee80211_device *ieee, struct sk_buff *skb)
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
}
@@ -2090,7 +1893,8 @@ void ieee80211_ps_tx_ack(struct ieee80211_device *ieee, short success)
}
void ieee80211_process_action(struct ieee80211_device* ieee, struct sk_buff* skb)
{
- struct ieee80211_hdr* header = (struct ieee80211_hdr*)skb->data;
+ struct rtl_ieee80211_hdr *header =
+ (struct rtl_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);
@@ -2135,18 +1939,6 @@ ieee80211_rx_frame_softmac(struct ieee80211_device *ieee, struct sk_buff *skb,
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)) {
@@ -2194,11 +1986,7 @@ ieee80211_rx_frame_softmac(struct ieee80211_device *ieee, struct sk_buff *skb,
"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);
}
@@ -2310,11 +2098,7 @@ ieee80211_rx_frame_softmac(struct ieee80211_device *ieee, struct sk_buff *skb,
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:
@@ -2370,11 +2154,7 @@ void ieee80211_softmac_xmit(struct ieee80211_txb *txb, struct ieee80211_device *
#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 */
@@ -2383,11 +2163,7 @@ void ieee80211_softmac_xmit(struct ieee80211_txb *txb, struct ieee80211_device *
* */
//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],
@@ -2551,16 +2327,12 @@ void ieee80211_start_monitor_mode(struct ieee80211_device *ieee)
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.
@@ -2586,11 +2358,9 @@ void ieee80211_start_ibss_wq(struct ieee80211_device *ieee)
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
@@ -2673,18 +2443,13 @@ void ieee80211_start_ibss_wq(struct ieee80211_device *ieee)
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.
@@ -2696,7 +2461,6 @@ void ieee80211_start_bss(struct ieee80211_device *ieee)
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
@@ -2720,15 +2484,11 @@ void ieee80211_start_bss(struct ieee80211_device *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 */
@@ -2742,34 +2502,24 @@ void ieee80211_disassociate(struct ieee80211_device *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);
@@ -2868,11 +2618,9 @@ void ieee80211_stop_protocol(struct ieee80211_device *ieee)
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);
@@ -2901,11 +2649,7 @@ void ieee80211_start_protocol(struct ieee80211_device *ieee)
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;
}
@@ -2953,12 +2697,10 @@ void ieee80211_softmac_init(struct ieee80211_device *ieee)
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;
@@ -2990,11 +2732,6 @@ void ieee80211_softmac_init(struct ieee80211_device *ieee)
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);
@@ -3005,16 +2742,12 @@ void ieee80211_softmac_init(struct ieee80211_device *ieee)
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);
@@ -3023,25 +2756,6 @@ void ieee80211_softmac_init(struct ieee80211_device *ieee)
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);
@@ -3057,19 +2771,15 @@ void ieee80211_softmac_init(struct ieee80211_device *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);
}
@@ -3172,7 +2882,7 @@ static int ieee80211_wpa_set_auth_algs(struct ieee80211_device *ieee, int value)
ieee->auth_mode = 0;
}
else if (value & AUTH_ALG_LEAP){
- sec.auth_mode = WLAN_AUTH_LEAP;
+ sec.auth_mode = RTL_WLAN_AUTH_LEAP;
ieee->open_wep = 1;
ieee->auth_mode = 2;
}
@@ -3347,11 +3057,8 @@ static int ieee80211_wpa_set_encryption(struct ieee80211_device *ieee,
}
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);
@@ -3534,7 +3241,6 @@ void notify_wx_assoc_event(struct ieee80211_device *ieee)
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);
@@ -3555,26 +3261,4 @@ 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
index 1f50c46dcb90..dfb61ef656f0 100644
--- a/drivers/staging/rtl8192su/ieee80211/ieee80211_softmac_wx.c
+++ b/drivers/staging/rtl8192su/ieee80211/ieee80211_softmac_wx.c
@@ -15,9 +15,7 @@
#include "ieee80211.h"
-#ifdef ENABLE_DOT11D
#include "dot11d.h"
-#endif
/* FIXME: add A freqs */
const long ieee80211_wlan_frequencies[] = {
@@ -63,12 +61,10 @@ int ieee80211_wx_set_freq(struct ieee80211_device *ieee, struct iw_request_info
}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);
@@ -234,7 +230,6 @@ int ieee80211_wx_get_rate(struct ieee80211_device *ieee,
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;
@@ -247,10 +242,6 @@ int ieee80211_wx_get_rate(struct ieee80211_device *ieee,
else
tmp_rate = HTMcsToDataRate(ieee, 15);
}
-#else
- tmp_rate = TxCountToDataRate(ieee, ieee->softmac_stats.CurrentShowTxate);
-
-#endif
wrqu->bitrate.value = tmp_rate * 500000;
return 0;
@@ -313,14 +304,9 @@ out:
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;
@@ -336,16 +322,12 @@ void ieee80211_wx_sync_scan_wq(struct ieee80211_device *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;
@@ -367,16 +349,12 @@ void ieee80211_wx_sync_scan_wq(struct ieee80211_device *ieee)
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.
@@ -410,11 +388,7 @@ int ieee80211_wx_set_scan(struct ieee80211_device *ieee, struct iw_request_info
}
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;
}
@@ -460,29 +434,8 @@ int ieee80211_wx_set_essid(struct ieee80211_device *ieee,
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{
@@ -548,21 +501,21 @@ 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");
+ strlcpy(wrqu->name, "802.11", IFNAMSIZ);
if(ieee->modulation & IEEE80211_CCK_MODULATION){
- strcat(wrqu->name, "b");
+ strlcat(wrqu->name, "b", IFNAMSIZ);
if(ieee->modulation & IEEE80211_OFDM_MODULATION)
- strcat(wrqu->name, "/g");
+ strlcat(wrqu->name, "/g", IFNAMSIZ);
}else if(ieee->modulation & IEEE80211_OFDM_MODULATION)
- strcat(wrqu->name, "g");
+ strlcat(wrqu->name, "g", IFNAMSIZ);
if (ieee->mode & (IEEE_N_24G | IEEE_N_5G))
- strcat(wrqu->name, "/n");
+ strlcat(wrqu->name, "/n", IFNAMSIZ);
if((ieee->state == IEEE80211_LINKED) ||
(ieee->state == IEEE80211_LINKED_SCANNING))
- strcat(wrqu->name," linked");
+ strlcat(wrqu->name, " link", IFNAMSIZ);
else if(ieee->state != IEEE80211_NOLINK)
- strcat(wrqu->name," link..");
+ strlcat(wrqu->name, " .....", IFNAMSIZ);
return 0;
@@ -670,7 +623,7 @@ exit:
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);
@@ -689,23 +642,3 @@ 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
index 7294572b990f..2e8149e4772d 100644
--- a/drivers/staging/rtl8192su/ieee80211/ieee80211_tx.c
+++ b/drivers/staging/rtl8192su/ieee80211/ieee80211_tx.c
@@ -193,11 +193,11 @@ int ieee80211_encrypt_fragment(
return -1;
}
#ifdef CONFIG_IEEE80211_CRYPT_TKIP
- struct ieee80211_hdr *header;
+ struct rtl_ieee80211_hdr *header;
if (ieee->tkip_countermeasures &&
crypt && crypt->ops && strcmp(crypt->ops->name, "TKIP") == 0) {
- header = (struct ieee80211_hdr *) frag->data;
+ header = (struct rtl_ieee80211_hdr *)frag->data;
if (net_ratelimit()) {
printk(KERN_DEBUG "%s: TKIP countermeasures: dropped "
"TX packet to " MAC_FMT "\n",
@@ -235,11 +235,6 @@ 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);
}
@@ -287,11 +282,8 @@ ieee80211_classify(struct sk_buff *skb, struct ieee80211_network *network)
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;
@@ -498,11 +490,7 @@ void ieee80211_query_protectionmode(struct ieee80211_device* ieee, cb_desc* tcb_
{
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))
@@ -620,11 +608,7 @@ void ieee80211_query_seqnum(struct ieee80211_device*ieee, struct sk_buff* skb, u
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;
diff --git a/drivers/staging/rtl8192su/ieee80211/ieee80211_wx.c b/drivers/staging/rtl8192su/ieee80211/ieee80211_wx.c
index ae11e2576beb..5c37964552f3 100644
--- a/drivers/staging/rtl8192su/ieee80211/ieee80211_wx.c
+++ b/drivers/staging/rtl8192su/ieee80211/ieee80211_wx.c
@@ -35,11 +35,7 @@
#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;
@@ -53,25 +49,7 @@ struct modes_unit ieee80211_modes[] = {
{"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,
@@ -92,11 +70,8 @@ static inline char *rtl819x_translate_scan(struct ieee80211_device *ieee,
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 */
@@ -105,18 +80,10 @@ static inline char *rtl819x_translate_scan(struct ieee80211_device *ieee,
// 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;
@@ -128,11 +95,7 @@ static inline char *rtl819x_translate_scan(struct ieee80211_device *ieee,
}
*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 &
@@ -141,11 +104,7 @@ static inline char *rtl819x_translate_scan(struct ieee80211_device *ieee,
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 */
@@ -155,11 +114,7 @@ static inline char *rtl819x_translate_scan(struct ieee80211_device *ieee,
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)
@@ -167,11 +122,7 @@ static inline char *rtl819x_translate_scan(struct ieee80211_device *ieee,
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;
@@ -215,33 +166,18 @@ static inline char *rtl819x_translate_scan(struct ieee80211_device *ieee,
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;
@@ -256,60 +192,14 @@ static inline char *rtl819x_translate_scan(struct ieee80211_device *ieee,
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)
{
@@ -317,11 +207,7 @@ static inline char *rtl819x_translate_scan(struct ieee80211_device *ieee,
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)
@@ -330,14 +216,8 @@ static inline char *rtl819x_translate_scan(struct ieee80211_device *ieee,
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. */
@@ -347,11 +227,7 @@ static inline char *rtl819x_translate_scan(struct ieee80211_device *ieee,
" 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;
}
@@ -486,11 +362,7 @@ int ieee80211_wx_set_encode(struct ieee80211_device *ieee,
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) {
@@ -611,15 +483,7 @@ int ieee80211_wx_get_encode(struct ieee80211_device *ieee,
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);
@@ -632,13 +496,12 @@ int ieee80211_wx_get_encode(struct ieee80211_device *ieee,
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;
@@ -702,12 +565,7 @@ int ieee80211_wx_set_encode_ext(struct ieee80211_device *ieee,
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";
@@ -747,12 +605,7 @@ int ieee80211_wx_set_encode_ext(struct ieee80211_device *ieee,
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;
@@ -818,7 +671,7 @@ done:
IEEE80211_DEBUG_WX("%s: reset_port failed\n", dev->name);
return -EINVAL;
}
-#endif
+
return ret;
}
@@ -881,8 +734,8 @@ 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:
@@ -891,7 +744,7 @@ int ieee80211_wx_set_mlme(struct ieee80211_device *ieee,
default:
return -EOPNOTSUPP;
}
-#endif
+
return 0;
}
@@ -899,7 +752,6 @@ 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*/
@@ -957,23 +809,13 @@ int ieee80211_wx_set_auth(struct ieee80211_device *ieee,
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))
@@ -1004,29 +846,17 @@ int ieee80211_wx_set_gen_ie(struct ieee80211_device *ieee, u8 *ie, size_t len)
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
deleted file mode 100644
index ddc22350d006..000000000000
--- a/drivers/staging/rtl8192su/ieee80211/internal.h
+++ /dev/null
@@ -1,115 +0,0 @@
-/*
- * 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
deleted file mode 100644
index de67bb01b5f5..000000000000
--- a/drivers/staging/rtl8192su/ieee80211/kmap_types.h
+++ /dev/null
@@ -1,20 +0,0 @@
-#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
deleted file mode 100644
index df256e487c20..000000000000
--- a/drivers/staging/rtl8192su/ieee80211/michael_mic.c
+++ /dev/null
@@ -1,194 +0,0 @@
-/*
- * 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
deleted file mode 100644
index 4f3f9ed7751a..000000000000
--- a/drivers/staging/rtl8192su/ieee80211/proc.c
+++ /dev/null
@@ -1,116 +0,0 @@
-/*
- * 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/rtl819x_BAProc.c b/drivers/staging/rtl8192su/ieee80211/rtl819x_BAProc.c
index cc5623a94b42..219ed5a4cdc3 100644
--- a/drivers/staging/rtl8192su/ieee80211/rtl819x_BAProc.c
+++ b/drivers/staging/rtl8192su/ieee80211/rtl819x_BAProc.c
@@ -174,49 +174,6 @@ static struct sk_buff* ieee80211_ADDBA(struct ieee80211_device* ieee, u8* Dst, P
//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
diff --git a/drivers/staging/rtl8192su/ieee80211/rtl819x_HT.h b/drivers/staging/rtl8192su/ieee80211/rtl819x_HT.h
index 16a7462d7dfb..a97c901edbf5 100644
--- a/drivers/staging/rtl8192su/ieee80211/rtl819x_HT.h
+++ b/drivers/staging/rtl8192su/ieee80211/rtl819x_HT.h
@@ -324,15 +324,6 @@ typedef struct _RT_HIGH_THROUGHPUT{
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;
diff --git a/drivers/staging/rtl8192su/ieee80211/rtl819x_HTProc.c b/drivers/staging/rtl8192su/ieee80211/rtl819x_HTProc.c
index f357085f6643..8a1090d59254 100644
--- a/drivers/staging/rtl8192su/ieee80211/rtl819x_HTProc.c
+++ b/drivers/staging/rtl8192su/ieee80211/rtl819x_HTProc.c
@@ -102,24 +102,6 @@ void HTUpdateDefaultSetting(struct ieee80211_device* ieee)
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
}
@@ -358,11 +340,7 @@ 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) ||
@@ -441,24 +419,7 @@ void HTIOTPeerDetermine(struct ieee80211_device* ieee)
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;
}
@@ -534,7 +495,6 @@ bool HTIOTActIsDisableMCSTwoSpatialStream(struct ieee80211_device* ieee)
//#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))
{
@@ -544,7 +504,6 @@ bool HTIOTActIsDisableMCSTwoSpatialStream(struct ieee80211_device* ieee)
retValue = true;
}
#endif
-#endif
return retValue;
}
@@ -561,18 +520,6 @@ u8 HTIOTActIsDisableEDCATurbo(struct ieee80211_device* ieee, u8* PeerMacAddr)
// 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
}
/********************************************************************************************************************
@@ -613,7 +560,6 @@ u8 HTIOTActIsForcedRTSCTS(struct ieee80211_device *ieee, struct ieee80211_networ
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)
@@ -624,7 +570,6 @@ u8 HTIOTActIsForcedRTSCTS(struct ieee80211_device *ieee, struct ieee80211_networ
retValue = 1;
}
}
-#endif
return retValue;
}
@@ -639,14 +584,12 @@ HTIOTActIsForcedAMSDU8K(struct ieee80211_device *ieee, struct ieee80211_network
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;
}
@@ -660,7 +603,6 @@ HTIOCActRejcectADDBARequest(struct ieee80211_network *network)
//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!
@@ -670,7 +612,6 @@ HTIOCActRejcectADDBARequest(struct ieee80211_network *network)
// return FALSE;
}
-#endif
return retValue;
@@ -684,7 +625,6 @@ HTIOCActRejcectADDBARequest(struct ieee80211_network *network)
{
u8 retValue = 0;
//if(IS_HARDWARE_TYPE_8192SU(Adapter))
-#ifdef RTL8192SU
PRT_HIGH_THROUGHPUT pHTInfo = ieee->pHTInfo;
{
//#if UNDER_VISTA
@@ -698,7 +638,6 @@ HTIOCActRejcectADDBARequest(struct ieee80211_network *network)
return 1;
}
-#endif
return retValue;
}
@@ -753,7 +692,6 @@ HTIOTActIsDisableTx40MHz(struct ieee80211_device* ieee,struct ieee80211_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) ||
@@ -764,7 +702,6 @@ HTIOTActIsDisableTx40MHz(struct ieee80211_device* ieee,struct ieee80211_network
if((pHTInfo->IOTPeer==HT_IOT_PEER_REALTEK) && (network->bssht.bdSupportHT))
retValue = 1;
}
-#endif
return retValue;
}
@@ -774,7 +711,6 @@ HTIOTActIsTxNoAggregation(struct ieee80211_device* ieee,struct ieee80211_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) ||
@@ -786,7 +722,6 @@ HTIOTActIsTxNoAggregation(struct ieee80211_device* ieee,struct ieee80211_network
pHTInfo->IOTPeer==HT_IOT_PEER_UNKNOWN)
retValue = 1;
}
-#endif
return retValue;
}
@@ -797,7 +732,6 @@ HTIOTActIsDisableTx2SS(struct ieee80211_device* ieee,struct ieee80211_network *n
{
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) ||
@@ -808,7 +742,6 @@ HTIOTActIsDisableTx2SS(struct ieee80211_device* ieee,struct ieee80211_network *n
if((pHTInfo->IOTPeer==HT_IOT_PEER_REALTEK) && (network->bssht.bdSupportHT))
retValue = 1;
}
-#endif
return retValue;
}
@@ -817,14 +750,12 @@ HTIOTActIsDisableTx2SS(struct ieee80211_device* ieee,struct ieee80211_network *n
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;
}
@@ -1239,17 +1170,7 @@ u8 HTFilterMCSRate( struct ieee80211_device* ieee, u8* pSupportMCS, u8* pOperate
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;
@@ -1356,10 +1277,6 @@ void HTOnAssocRsp(struct ieee80211_device *ieee)
{
// 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)
@@ -1539,187 +1456,7 @@ void HTInitializeBssDesc(PBSS_HT pBssHT)
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
@@ -1808,11 +1545,9 @@ void HTResetSelfAndSavePeerSetting(struct ieee80211_device* ieee, struct ieee80
//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)
@@ -1822,7 +1557,6 @@ void HTResetSelfAndSavePeerSetting(struct ieee80211_device* ieee, struct ieee80
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;
@@ -1830,13 +1564,11 @@ void HTResetSelfAndSavePeerSetting(struct ieee80211_device* ieee, struct ieee80
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;
@@ -1848,7 +1580,6 @@ void HTResetSelfAndSavePeerSetting(struct ieee80211_device* ieee, struct ieee80
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)
@@ -2030,8 +1761,4 @@ void HTSetConnectBwModeCallback(struct ieee80211_device* ieee)
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
index f7b882b99d14..7aa9a7790b63 100644
--- a/drivers/staging/rtl8192su/ieee80211/rtl819x_Qos.h
+++ b/drivers/staging/rtl8192su/ieee80211/rtl819x_Qos.h
@@ -70,147 +70,6 @@ typedef enum _ACK_POLICY{
}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
@@ -361,22 +220,6 @@ typedef union _QOS_INFO_FIELD{
}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.
@@ -650,16 +493,7 @@ 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]
diff --git a/drivers/staging/rtl8192su/ieee80211/rtl819x_TSProc.c b/drivers/staging/rtl8192su/ieee80211/rtl819x_TSProc.c
index 6fb7033ed360..3143b252fb1d 100644
--- a/drivers/staging/rtl8192su/ieee80211/rtl819x_TSProc.c
+++ b/drivers/staging/rtl8192su/ieee80211/rtl819x_TSProc.c
@@ -2,13 +2,6 @@
#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
@@ -96,21 +89,7 @@ void RxPktPendingTimeout(unsigned long data)
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);
@@ -379,17 +358,11 @@ bool GetTs(
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))
{
@@ -660,8 +633,5 @@ void TsStartAddBaProcess(struct ieee80211_device* ieee, PTX_TS_RECORD pTxTS)
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
deleted file mode 100644
index ccf6ae763572..000000000000
--- a/drivers/staging/rtl8192su/ieee80211/rtl_crypto.h
+++ /dev/null
@@ -1,399 +0,0 @@
-/*
- * 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
deleted file mode 100644
index 49f401fbce88..000000000000
--- a/drivers/staging/rtl8192su/ieee80211/scatterwalk.c
+++ /dev/null
@@ -1,126 +0,0 @@
-/*
- * 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
deleted file mode 100644
index b16446519017..000000000000
--- a/drivers/staging/rtl8192su/ieee80211/scatterwalk.h
+++ /dev/null
@@ -1,51 +0,0 @@
-/*
- * 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
deleted file mode 100644
index b58a3bcc0dc0..000000000000
--- a/drivers/staging/rtl8192su/ieee80211_crypt.h
+++ /dev/null
@@ -1,86 +0,0 @@
-/*
- * 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.h b/drivers/staging/rtl8192su/r8180_93cx6.h
index ca228d368174..0309800255cf 100644
--- a/drivers/staging/rtl8192su/r8180_93cx6.h
+++ b/drivers/staging/rtl8192su/r8180_93cx6.h
@@ -13,13 +13,8 @@
/*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
diff --git a/drivers/staging/rtl8192su/r8190_rtl8256.c b/drivers/staging/rtl8192su/r8190_rtl8256.c
deleted file mode 100644
index 74ff337b0583..000000000000
--- a/drivers/staging/rtl8192su/r8190_rtl8256.c
+++ /dev/null
@@ -1,312 +0,0 @@
-/*
- 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/r8192S_Efuse.c b/drivers/staging/rtl8192su/r8192S_Efuse.c
index 394ab9674359..f0ce6562c23b 100644
--- a/drivers/staging/rtl8192su/r8192S_Efuse.c
+++ b/drivers/staging/rtl8192su/r8192S_Efuse.c
@@ -35,7 +35,6 @@
//
// In the future, we will always support EFUSE!!
//
-#ifdef RTL8192SU
/*---------------------------Define Local Constant---------------------------*/
#define _POWERON_DELAY_
#define _PRE_EXECUTE_READ_CMD_
@@ -189,10 +188,6 @@ 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!!!
//
@@ -708,12 +703,6 @@ EFUSE_ShadowUpdate(struct net_device* dev)
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;
@@ -729,12 +718,6 @@ EFUSE_ShadowUpdate(struct net_device* dev)
}
// 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)
{
@@ -774,21 +757,6 @@ EFUSE_ShadowUpdate(struct net_device* dev)
// 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.
@@ -1048,49 +1016,6 @@ efuse_ReadAllMap(struct net_device* dev, u8 *Efuse)
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
@@ -1800,43 +1725,6 @@ efuse_CalculateWordCnts(u8 word_en)
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
*
@@ -2428,7 +2316,6 @@ void efuset_test_func_write(struct net_device* dev)
-#endif // #if (HAL_CODE_BASE == RTL8192_S)
diff --git a/drivers/staging/rtl8192su/r8192S_firmware.c b/drivers/staging/rtl8192su/r8192S_firmware.c
index b3d69b33acba..f508c6260643 100644
--- a/drivers/staging/rtl8192su/r8192S_firmware.c
+++ b/drivers/staging/rtl8192su/r8192S_firmware.c
@@ -11,24 +11,15 @@
* 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 )
@@ -53,9 +44,6 @@ bool FirmwareDownloadCode(struct net_device *dev, u8 * code_virtual_address,u32
u8 bLastIniPkt = 0;
u16 ExtraDescOffset = 0;
-#ifdef RTL8192SE
- fw_SetRQPN(dev); // For 92SE only
-#endif
RT_TRACE(COMP_FIRMWARE, "--->FirmwareDownloadCode()\n" );
@@ -120,19 +108,6 @@ cmdsend_downloadcode_fail:
}
-#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)
@@ -144,9 +119,6 @@ FirmwareEnableCPU(struct net_device *dev)
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
@@ -305,10 +277,6 @@ FirmwareCheckReady(struct net_device *dev, u8 LoadFWStatus)
// <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
@@ -323,13 +291,11 @@ FirmwareCheckReady(struct net_device *dev, u8 LoadFWStatus)
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);
@@ -370,11 +336,9 @@ u8 FirmwareHeaderMapRfType(struct net_device *dev)
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);
@@ -406,16 +370,11 @@ bool FirmwareDownload92S(struct net_device *dev)
//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)
{
@@ -474,7 +433,6 @@ bool FirmwareDownload92S(struct net_device *dev)
}
-#endif
break;
case FW_SOURCE_HEADER_FILE:
@@ -585,439 +543,4 @@ bool FirmwareDownload92S(struct net_device *dev)
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
index 047f8ae44740..c525380e6473 100644
--- a/drivers/staging/rtl8192su/r8192S_firmware.h
+++ b/drivers/staging/rtl8192su/r8192S_firmware.h
@@ -30,12 +30,7 @@
#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,
diff --git a/drivers/staging/rtl8192su/r8192S_hw.h b/drivers/staging/rtl8192su/r8192S_hw.h
index 7a3d850de0bf..82ea96b6f4d1 100644
--- a/drivers/staging/rtl8192su/r8192S_hw.h
+++ b/drivers/staging/rtl8192su/r8192S_hw.h
@@ -49,10 +49,8 @@ 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,
@@ -64,16 +62,6 @@ typedef enum _BaseBand_Config_Type{
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
@@ -1205,112 +1193,6 @@ Default: 00b.
// 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.
//----------------------------------------------------------------------------
@@ -1330,25 +1212,6 @@ Default: 00b.
// <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.
@@ -1366,7 +1229,6 @@ Default: 00b.
#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
@@ -1408,7 +1270,6 @@ Default: 00b.
//#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.
@@ -1432,51 +1293,6 @@ Default: 00b.
#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
diff --git a/drivers/staging/rtl8192su/r8192S_phy.c b/drivers/staging/rtl8192su/r8192S_phy.c
index 99a4051a8458..a53e35c954ec 100644
--- a/drivers/staging/rtl8192su/r8192S_phy.c
+++ b/drivers/staging/rtl8192su/r8192S_phy.c
@@ -35,21 +35,13 @@
#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
+#include "ieee80211/dot11d.h"
/*---------------------------Define Local Constant---------------------------*/
/* Channel switch:The size of command tables for switch channel*/
@@ -60,26 +52,6 @@
/*------------------------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);
@@ -111,18 +83,11 @@ phy_SwChnlStepByStep(
);
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.
@@ -390,7 +355,6 @@ void phy_SetUsbRFReg(struct net_device* dev,RF90_RADIO_PATH_E eRFPath,u32 RegAdd
}
-#endif
/*---------------------Define local function prototype-----------------------*/
@@ -420,9 +384,6 @@ 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);
@@ -433,7 +394,6 @@ u32 rtl8192_QueryBBReg(struct net_device* dev, u32 RegAddr, u32 BitMask)
// 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;
@@ -447,7 +407,6 @@ u32 rtl8192_QueryBBReg(struct net_device* dev, u32 RegAddr, u32 BitMask)
OriginalValue = phy_QueryUsbBBReg(dev, RegAddr);
}
else
-#endif
{
OriginalValue = read_nic_dword(dev, RegAddr);
}
@@ -483,9 +442,6 @@ 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);
@@ -496,7 +452,6 @@ void rtl8192_setBBreg(struct net_device* dev, u32 RegAddr, u32 BitMask, u32 Data
// 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)
@@ -515,7 +470,6 @@ void rtl8192_setBBreg(struct net_device* dev, u32 RegAddr, u32 BitMask, u32 Data
phy_SetUsbBBReg(dev, RegAddr, Data);
}
else
-#endif
{
if(BitMask!= bMaskDWord)
{//if not "double word" write
@@ -559,9 +513,6 @@ u32 rtl8192_phy_QueryRFReg(struct net_device* dev, RF90_RADIO_PATH_E eRFPath, u3
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);
@@ -588,19 +539,8 @@ u32 rtl8192_phy_QueryRFReg(struct net_device* dev, RF90_RADIO_PATH_E eRFPath, u3
// 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;
@@ -638,9 +578,6 @@ void rtl8192_phy_SetRFReg(struct net_device* dev, RF90_RADIO_PATH_E eRFPath, u32
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);
@@ -667,7 +604,6 @@ void rtl8192_phy_SetRFReg(struct net_device* dev, RF90_RADIO_PATH_E eRFPath, u32
// 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
@@ -679,37 +615,6 @@ void rtl8192_phy_SetRFReg(struct net_device* dev, RF90_RADIO_PATH_E eRFPath, u32
}
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);
@@ -719,579 +624,6 @@ void rtl8192_phy_SetRFReg(struct net_device* dev, RF90_RADIO_PATH_E eRFPath, u32
}
-#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
*
@@ -1345,13 +677,7 @@ extern bool PHY_MACConfig8192S(struct net_device* dev)
//
// 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;
}
@@ -1559,7 +885,6 @@ phy_BB8192S_Config_ParaFile(struct net_device* dev)
// 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)
{
@@ -1571,26 +896,6 @@ phy_BB8192S_Config_ParaFile(struct net_device* dev)
}
}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!!");
@@ -1602,11 +907,7 @@ phy_BB8192S_Config_ParaFile(struct net_device* dev)
//
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!!");
@@ -1616,12 +917,7 @@ phy_BB8192S_Config_ParaFile(struct net_device* dev)
//
// 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");
@@ -1629,33 +925,6 @@ phy_BB8192S_Config_ParaFile(struct net_device* dev)
}
-#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));
@@ -1934,11 +1203,7 @@ u8 rtl8192_phy_ConfigRFWithHeaderFile(struct net_device* dev, RF90_RADIO_PATH_E
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);
@@ -1962,11 +1227,7 @@ u8 rtl8192_phy_ConfigRFWithHeaderFile(struct net_device* dev, RF90_RADIO_PATH_E
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);
@@ -2641,10 +1902,6 @@ PHY_GetTxPowerLevel8192S(
//
// 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.
@@ -2706,18 +1963,10 @@ PHY_GetTxPowerLevel8192S(
// 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]);
}
}
@@ -2759,10 +2008,6 @@ PHY_GetTxPowerLevel8192S(
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)
@@ -2792,10 +2037,6 @@ PHY_GetTxPowerLevel8192S(
}
}
}
-#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
@@ -2823,7 +2064,6 @@ PHY_GetTxPowerLevel8192S(
// Notify Tx power difference for B/C/D to A!!!
rtl8192_setBBreg(dev, rFPGA0_TxGainStage, (bXBTxAGC|bXCTxAGC|bXDTxAGC), u4RegValue);
-#endif
}
//
@@ -2885,10 +2125,6 @@ PHY_GetTxPowerLevel8192S(
break;
case RF_8256:
-#if 0
- PHY_SetRF8256CCKTxPower(dev, powerlevel);
- PHY_SetRF8256OFDMTxPower(dev, powerlevelOFDM24G);
-#endif
break;
case RF_6052:
@@ -3081,7 +2317,6 @@ PHY_ScanOperationBackup8192S(
-#if(RTL8192S_DISABLE_FW_DM == 0)
if(!Adapter->bDriverStopped)
{
@@ -3110,7 +2345,6 @@ PHY_ScanOperationBackup8192S(
break;
}
}
-#endif
}
#endif
@@ -3121,65 +2355,6 @@ 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
}
/*-----------------------------------------------------------------------------
@@ -3276,12 +2451,6 @@ void PHY_SetBWModeCallback8192S(struct net_device *dev)
//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);
@@ -3298,11 +2467,6 @@ void PHY_SetBWModeCallback8192S(struct net_device *dev)
//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));
@@ -3421,23 +2585,9 @@ void rtl8192_SetBWMode(struct net_device *dev, HT_CHANNEL_WIDTH Bandwidth, HT_EX
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
{
@@ -3552,11 +2702,7 @@ u8 rtl8192_phy_SwChnl(struct net_device* dev, u8 channel)
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)
{
@@ -3691,13 +2837,11 @@ phy_SwChnlStepByStep(
//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"));
@@ -3809,13 +2953,9 @@ phy_SwChnlStepByStep(
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:
@@ -3881,16 +3021,6 @@ u8 rtl8192_phy_CheckIsLegalRFPath(struct net_device* dev, u32 eRFPath)
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 */
@@ -4283,7 +3413,6 @@ extern void PHY_IQCalibrateBcut(struct net_device* dev)
//
//-------------------------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)
@@ -4431,18 +3560,6 @@ void SetBWModeCallback8192SUsb(struct net_device *dev)
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);
@@ -4579,33 +3696,12 @@ void SetBWModeCallback8192SUsbWorkItem(struct net_device *dev)
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));
@@ -4660,7 +3756,6 @@ void SetBWModeCallback8192SUsbWorkItem(struct net_device *dev)
}
//--------------------------Move to oter DIR later-------------------------------*/
-#ifdef RTL8192SU
void InitialGain8192S(struct net_device *dev, u8 Operation)
{
#ifdef TO_DO_LIST
@@ -4668,7 +3763,6 @@ void InitialGain8192S(struct net_device *dev, u8 Operation)
#endif
}
-#endif
void InitialGain819xUsb(struct net_device *dev, u8 Operation)
{
@@ -4678,29 +3772,15 @@ void InitialGain819xUsb(struct net_device *dev, u8 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;
@@ -4768,7 +3848,6 @@ extern void InitialGainOperateWorkItemCallBack(struct net_device *dev)
}
}
-#endif // #if (DEV_BUS_TYPE == USB_INTERFACE)
//-----------------------------------------------------------------------------
// Description:
diff --git a/drivers/staging/rtl8192su/r8192S_phy.h b/drivers/staging/rtl8192su/r8192S_phy.h
index 580a7c6a7609..b752fa35a7ae 100644
--- a/drivers/staging/rtl8192su/r8192S_phy.h
+++ b/drivers/staging/rtl8192su/r8192S_phy.h
@@ -121,11 +121,8 @@ 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 );
diff --git a/drivers/staging/rtl8192su/r8192S_rtl6052.c b/drivers/staging/rtl8192su/r8192S_rtl6052.c
index 71caf81a6e10..69ef6dfc588b 100644
--- a/drivers/staging/rtl8192su/r8192S_rtl6052.c
+++ b/drivers/staging/rtl8192su/r8192S_rtl6052.c
@@ -23,15 +23,9 @@
#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---------------------------*/
@@ -93,51 +87,6 @@ static RF_SHADOW_T RF_Shadow[RF6052_MAX_PATH][RF6052_MAX_REG];// = {{0}};//FIXLZ
*---------------------------------------------------------------------------*/
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 */
@@ -162,7 +111,6 @@ void PHY_RF6052SetBandwidth(struct net_device* dev, HT_CHANNEL_WIDTH Bandwidth)
//if (priv->card_8192 == NIC_8192SE)
-#ifdef RTL8192SU //YJ,test,090113
{
switch(Bandwidth)
{
@@ -184,26 +132,6 @@ void PHY_RF6052SetBandwidth(struct net_device* dev, HT_CHANNEL_WIDTH Bandwidth)
}
}
// 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
}
@@ -306,15 +234,6 @@ extern void PHY_RF6052SetOFDMTxPower(struct net_device* dev, u8 powerlevel)
{
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];
@@ -412,18 +331,6 @@ extern void PHY_RF6052SetOFDMTxPower(struct net_device* dev, u8 powerlevel)
//
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));
@@ -684,21 +591,10 @@ RT_STATUS phy_RF6052_Config_ParaFile(struct net_device* dev)
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;
diff --git a/drivers/staging/rtl8192su/r8192S_rtl6052.h b/drivers/staging/rtl8192su/r8192S_rtl6052.h
index 916603ceaae0..3dcc9bb76394 100644
--- a/drivers/staging/rtl8192su/r8192S_rtl6052.h
+++ b/drivers/staging/rtl8192su/r8192S_rtl6052.h
@@ -81,53 +81,6 @@ 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---------------------*/
diff --git a/drivers/staging/rtl8192su/r8192U.h b/drivers/staging/rtl8192su/r8192U.h
index a2365587b1c7..2a11e0113d3a 100644
--- a/drivers/staging/rtl8192su/r8192U.h
+++ b/drivers/staging/rtl8192su/r8192U.h
@@ -39,16 +39,10 @@
#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 "ieee80211/ieee80211.h"
+
#include "r8192S_firmware.h"
-#else
-#include "r819xU_firmware.h"
-#endif
//#define RTL8192U
#define RTL819xU_MODULE_NAME "rtl819xU"
@@ -93,11 +87,6 @@
// 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...)
@@ -155,7 +144,6 @@ do { if(rt_global_debug_component & component) \
#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
@@ -307,7 +295,6 @@ do { if(rt_global_debug_component & component) \
#define OFDM_Table_Length 19
#define CCK_Table_length 12
-#ifdef RTL8192SU
//
//Tx Descriptor for RLT8192SU(Normal mode)
//
@@ -425,75 +412,9 @@ typedef struct _tx_status_desc_8192s_usb{
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)
//
@@ -558,39 +479,7 @@ typedef struct _tx_h2c_cmd_hdr_8192s_usb{
// 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;
@@ -619,38 +508,6 @@ typedef struct _tx_fwinfo_819x_usb{
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;
@@ -658,7 +515,6 @@ typedef struct rtl8192_rx_info {
u8 out_pipe;
}rtl8192_rx_info ;
-#ifdef RTL8192SU
//typedef struct _RX_DESC_STATUS_8192SU{
typedef struct rx_desc_819x_usb{
//DWORD 0
@@ -695,11 +551,7 @@ typedef struct rx_desc_819x_usb{
//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;
@@ -725,57 +577,8 @@ typedef struct rx_desc_819x_usb{
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
//
@@ -851,41 +654,11 @@ typedef struct rx_drvinfo_819x_usb{
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*/
@@ -895,17 +668,10 @@ typedef struct rx_drvinfo_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
@@ -939,146 +705,6 @@ typedef enum _RTL8192SUSB_LOOPBACK{
}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
@@ -1087,18 +713,6 @@ typedef struct _rt_firmware_info_819xUsb{
#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
@@ -1111,7 +725,6 @@ typedef struct _rt_firmware_info_819xUsb{
#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
@@ -1172,21 +785,6 @@ typedef struct rtl_reg_debug{
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];
@@ -1555,11 +1153,7 @@ typedef struct r8192_priv
// 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;
@@ -1619,11 +1213,9 @@ typedef struct r8192_priv
/* 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
@@ -1653,11 +1245,8 @@ typedef struct r8192_priv
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
@@ -1686,11 +1275,6 @@ typedef struct r8192_priv
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
@@ -1702,7 +1286,6 @@ typedef struct r8192_priv
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;
@@ -1745,11 +1328,7 @@ typedef struct r8192_priv
/*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
@@ -1874,33 +1453,14 @@ typedef struct r8192_priv
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;
@@ -1945,13 +1505,6 @@ typedef struct r8192_priv
//#endif
-#ifdef USB_RX_AGGREGATION_SUPPORT
- bool bCurrentRxAggrEnable;
- bool bForcedUsbRxAggr;
- u32 ForcedUsbRxAggrInfo;
- u32 LastUsbRxAggrInfoSetting;
- u32 RegUsbRxAggrInfo;
-#endif
@@ -1986,70 +1539,6 @@ typedef enum{
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;
@@ -2057,14 +1546,9 @@ struct ssid_thread {
};
#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);
diff --git a/drivers/staging/rtl8192su/r8192U_core.c b/drivers/staging/rtl8192su/r8192U_core.c
index f1423d714496..bafed04408b3 100644
--- a/drivers/staging/rtl8192su/r8192U_core.c
+++ b/drivers/staging/rtl8192su/r8192U_core.c
@@ -58,7 +58,6 @@ double __extendsfdf2(float a) {return a;}
#define CONFIG_RTL8192_IO_MAP
-#ifdef RTL8192SU
#include <asm/uaccess.h>
#include "r8192U.h"
//#include "r8190_rtl8256.h" /* RTL8225 Radio frontend */
@@ -75,50 +74,13 @@ double __extendsfdf2(float a) {return a;}
#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
+#include "ieee80211/dot11d.h"
-#endif
-#ifdef RTL8192SU
u32 rt_global_debug_component = \
// COMP_TRACE |
// COMP_DBG |
@@ -152,29 +114,6 @@ u32 rt_global_debug_component = \
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
@@ -201,77 +140,41 @@ static struct usb_device_id rtl8192_usb_id_tbl[] = {
};
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);
@@ -294,32 +197,7 @@ struct rtl819x_ops rtl8192su_ops = {
.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
{
@@ -395,11 +273,9 @@ static void rtl819x_set_channel_map(u8 channel_plan, struct r8192_priv* priv)
}
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 ||\
@@ -413,14 +289,6 @@ static void rtl819x_set_channel_map(u8 channel_plan, struct r8192_priv* priv)
_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
@@ -505,11 +373,7 @@ void write_nic_byte(struct net_device *dev, int indx, u8 data)
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)
{
@@ -530,11 +394,7 @@ void write_nic_word(struct net_device *dev, int indx, u16 data)
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)
{
@@ -554,11 +414,7 @@ void write_nic_dword(struct net_device *dev, int indx, u32 data)
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)
@@ -579,11 +435,7 @@ u8 read_nic_byte(struct net_device *dev, int indx)
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)
{
@@ -604,11 +456,7 @@ u16 read_nic_word(struct net_device *dev, int indx)
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)
{
@@ -650,11 +498,7 @@ u32 read_nic_dword(struct net_device *dev, int indx)
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);
// }
@@ -686,13 +530,8 @@ 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);
@@ -735,7 +574,6 @@ static int proc_get_stats_ap(char *page, char **start,
return len;
}
-#ifdef RTL8192SU
static int proc_get_registers(char *page, char **start,
off_t offset, int count,
int *eof, void *data)
@@ -1026,166 +864,6 @@ static int proc_get_registers_e(char *page, char **start,
*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,
@@ -1283,35 +961,17 @@ static int proc_get_stats_rx(char *page, char **start,
*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
}
@@ -1357,16 +1017,6 @@ void rtl8192_proc_init_one(struct net_device *dev)
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);
@@ -1385,17 +1035,6 @@ void rtl8192_proc_init_one(struct net_device *dev)
"/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);
@@ -1413,7 +1052,6 @@ void rtl8192_proc_init_one(struct net_device *dev)
"/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) {
@@ -1477,24 +1115,6 @@ void rtl8192_proc_init_one(struct net_device *dev)
"/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-------------------------
@@ -1533,11 +1153,7 @@ 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");
}
@@ -1572,31 +1188,6 @@ void rtl8192_dump_reg(struct net_device *dev)
------------------------------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;
@@ -1644,15 +1235,6 @@ void rtl8192_set_chan(struct net_device *dev,short ch)
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*/
@@ -1672,22 +1254,11 @@ void rtl8192_set_chan(struct net_device *dev,short ch)
#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);
@@ -1704,11 +1275,7 @@ static int rtl8192_rx_initiate(struct net_device*dev)
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;
@@ -1722,11 +1289,7 @@ static int rtl8192_rx_initiate(struct net_device*dev)
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 */
@@ -1735,11 +1298,7 @@ static int rtl8192_rx_initiate(struct net_device*dev)
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;
@@ -1752,11 +1311,7 @@ static int rtl8192_rx_initiate(struct net_device*dev)
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;
@@ -1825,107 +1380,13 @@ void rtl8192_rx_enable(struct net_device *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;
@@ -1959,91 +1420,9 @@ void rtl8192_rtx_disable(struct net_device *dev)
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){
@@ -2083,13 +1462,7 @@ inline u16 rtl8192_rate2rate(short rate)
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;
@@ -2107,20 +1480,8 @@ static void rtl8192_rx_isr(struct 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);
@@ -2146,11 +1507,7 @@ static void rtl8192_rx_isr(struct urb *urb)
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);
}
@@ -2179,44 +1536,15 @@ rtl819xusb_rx_command_packet(
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.
@@ -2288,263 +1616,8 @@ int rtl8192_hard_start_xmit(struct sk_buff *skb,struct net_device *dev)
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;
@@ -2580,29 +1653,11 @@ static void rtl8192_tx_isr(struct 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.
@@ -2627,74 +1682,8 @@ static void rtl8192_tx_isr(struct urb *tx_urb)
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)
@@ -2775,7 +1764,6 @@ void rtl8192_update_cap(struct net_device* dev, u16 cap)
priv->short_preamble = cap & WLAN_CAPABILITY_SHORT_PREAMBLE;
//LZM MOD 090303 HW_VAR_ACK_PREAMBLE
-#ifdef RTL8192SU
if(0)
{
u8 tmp = 0;
@@ -2784,15 +1772,6 @@ void rtl8192_update_cap(struct net_device* dev, u16 cap)
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))
{
@@ -2851,41 +1830,6 @@ void rtl8192_net_update(struct net_device *dev)
#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)
@@ -2976,38 +1920,6 @@ u16 N_DBPSOfRate(u16 DataRate)
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);
}
@@ -3021,7 +1933,6 @@ unsigned int txqueue2outpipe(struct r8192_priv* priv,unsigned int tx_queue) {
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);
@@ -3036,11 +1947,7 @@ short rtl8192SU_tx_cmd(struct net_device *dev, struct sk_buff *skb)
//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;
@@ -3076,12 +1983,7 @@ short rtl8192SU_tx_cmd(struct net_device *dev, struct sk_buff *skb)
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{
@@ -3090,74 +1992,6 @@ short rtl8192SU_tx_cmd(struct net_device *dev, struct sk_buff *skb)
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"
@@ -3212,7 +2046,6 @@ u8 MapHwQueueToFirmwareQueue(u8 QueueID)
return QueueSelect;
}
-#ifdef RTL8192SU
u8 MRateToHwRate8190Pci(u8 rate)
{
u8 ret = DESC92S_RATE1M;
@@ -3277,49 +2110,6 @@ u8 MRateToHwRate8190Pci(u8 rate)
}
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)
{
@@ -3333,17 +2123,12 @@ u8 QueryIsShort(u8 TxHT, u8 TxRate, cb_desc *tcb_desc)
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.
@@ -3372,12 +2157,6 @@ short rtl8192SU_tx(struct net_device *dev, struct sk_buff* skb)
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 */
@@ -3401,11 +2180,7 @@ short rtl8192SU_tx(struct net_device *dev, struct sk_buff* 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;
@@ -3414,22 +2189,7 @@ short rtl8192SU_tx(struct net_device *dev, struct sk_buff* skb)
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));
@@ -3438,10 +2198,6 @@ short rtl8192SU_tx(struct net_device *dev, struct sk_buff* skb)
/* 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;
@@ -3509,12 +2265,6 @@ short rtl8192SU_tx(struct net_device *dev, struct sk_buff* skb)
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 */
@@ -3522,11 +2272,6 @@ short rtl8192SU_tx(struct net_device *dev, struct sk_buff* skb)
//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;
}
@@ -3535,57 +2280,14 @@ short rtl8192SU_tx(struct net_device *dev, struct sk_buff* skb)
//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)
@@ -3626,40 +2328,16 @@ short rtl8192SU_tx(struct net_device *dev, struct sk_buff* skb)
/* 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]);
@@ -3674,11 +2352,7 @@ short rtl8192SU_tx(struct net_device *dev, struct sk_buff* skb)
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;
@@ -3696,11 +2370,7 @@ short rtl8192SU_tx(struct net_device *dev, struct sk_buff* skb)
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;
@@ -3708,11 +2378,7 @@ short rtl8192SU_tx(struct net_device *dev, struct sk_buff* skb)
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;
@@ -3728,347 +2394,7 @@ short rtl8192SU_tx(struct net_device *dev, struct sk_buff* skb)
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)
{
@@ -4088,11 +2414,7 @@ void rtl8192SU_net_update(struct net_device *dev)
//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);
@@ -4221,11 +2543,7 @@ void rtl8192SU_update_ratr_table(struct net_device* dev)
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)) &&
@@ -4287,42 +2605,6 @@ void rtl8192SU_link_change(struct net_device *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 */
@@ -4333,16 +2615,10 @@ static struct ieee80211_qos_parameters def_qos_parameters = {
};
-#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;
@@ -4357,16 +2633,11 @@ void rtl8192_update_beacon(struct net_device *dev)
* 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);
@@ -4377,11 +2648,8 @@ void rtl8192_qos_activate(struct net_device *dev)
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");
@@ -4401,11 +2669,7 @@ void rtl8192_qos_activate(struct net_device *dev)
}
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,
@@ -4432,11 +2696,7 @@ static int rtl8192_qos_handle_probe_response(struct r8192_priv *priv,
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");
}
@@ -4445,11 +2705,7 @@ static int rtl8192_qos_handle_probe_response(struct r8192_priv *priv,
&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;
@@ -4467,16 +2723,8 @@ static int rtl8192_handle_beacon(struct net_device * dev,
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;
}
@@ -4509,10 +2757,6 @@ static int rtl8192_qos_association_resp(struct r8192_priv *priv,
&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 */
@@ -4533,12 +2777,7 @@ static int rtl8192_qos_association_resp(struct r8192_priv *priv,
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;
}
@@ -4614,9 +2853,7 @@ bool GetNmodeSupportBySecCfg8192(struct net_device*dev)
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
@@ -4638,18 +2875,6 @@ bool GetNmodeSupportBySecCfg8192(struct net_device*dev)
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
}
@@ -4661,9 +2886,7 @@ bool GetHalfNmodeSupportByAPs819xUsb(struct net_device* dev)
struct ieee80211_device* ieee = priv->ieee80211;
// Added by Roger, 2008.08.29.
-#ifdef RTL8192SU
return false;
-#endif
if(ieee->bHalfWirelessN24GMode == true)
Reval = true;
@@ -4745,10 +2968,8 @@ void rtl8192_SetWirelessMode(struct net_device* dev, u8 wireless_mode)
#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))
@@ -4779,13 +3000,7 @@ short rtl8192_is_tx_queue_empty(struct net_device *dev)
}
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__);
@@ -4793,7 +3008,7 @@ void rtl8192_hw_sleep_down(struct net_device *dev)
// 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);
@@ -4802,10 +3017,7 @@ void rtl8192_hw_sleep_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,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);
}
@@ -4823,7 +3035,7 @@ void rtl8192_hw_wakeup(struct net_device* dev)
//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);
@@ -4832,12 +3044,8 @@ void rtl8192_hw_wakeup_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,hw_wakeup_wq);
struct net_device *dev = ieee->dev;
-#else
-void rtl8192_hw_wakeup_wq(struct net_device* dev)
-{
-#endif
- rtl8192_hw_wakeup(dev);
+ rtl8192_hw_wakeup(dev);
}
#define MIN_SLEEP_TIME 50
@@ -4881,11 +3089,7 @@ void rtl8192_hw_to_sleep(struct net_device *dev, u32 th, u32 tl)
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
@@ -4902,11 +3106,8 @@ void rtl8192_hw_to_sleep(struct net_device *dev, u32 th, u32 tl)
// 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.
@@ -4977,7 +3178,6 @@ static void rtl8192_init_priv_variable(struct net_device* dev)
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;
@@ -5036,51 +3236,6 @@ static void rtl8192_init_priv_variable(struct net_device* dev)
//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));
@@ -5113,18 +3268,10 @@ static void rtl8192_init_priv_lock(struct r8192_priv* priv)
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
@@ -5133,15 +3280,12 @@ 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);
@@ -5157,36 +3301,6 @@ static void rtl8192_init_priv_task(struct net_device* dev)
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);
@@ -5212,7 +3326,6 @@ static inline u16 endian_swap(u16* data)
return *data;
}
-#ifdef RTL8192SU
u8 rtl8192SU_UsbOptionToEndPointNumber(u8 UsbOption)
{
u8 nEndPoint = 0;
@@ -5342,26 +3455,6 @@ rtl8192SU_ConfigAdapterInfo8192SForAutoLoadFail(struct net_device* dev)
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++)
{
@@ -5411,7 +3504,6 @@ rtl8192SU_ConfigAdapterInfo8192SForAutoLoadFail(struct net_device* dev)
//priv->RfTxPwrLevelOfdm1T[0][i] ,
//priv->RfTxPwrLevelOfdm2T[0][i] );
}
-#endif
//
// Update remained HAL variables.
@@ -5431,747 +3523,6 @@ rtl8192SU_ConfigAdapterInfo8192SForAutoLoadFail(struct net_device* dev)
}
-#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.
@@ -6290,12 +3641,7 @@ rtl8192SU_ReadAdapterInfo8192SUsb(struct net_device* dev)
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)
@@ -6455,11 +3801,7 @@ rtl8192SU_ReadAdapterInfo8192SUsb(struct net_device* dev)
// 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);
@@ -6540,52 +3882,6 @@ rtl8192SU_ReadAdapterInfo8192SUsb(struct net_device* dev)
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)
@@ -6753,7 +4049,6 @@ rtl8192SU_ReadAdapterInfo8192SUsb(struct net_device* dev)
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.
@@ -6863,256 +4158,10 @@ static void rtl8192SU_read_eeprom_info(struct net_device *dev)
//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;
@@ -7120,21 +4169,6 @@ short rtl8192_get_channel_map(struct net_device * dev)
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;
}
@@ -7143,28 +4177,6 @@ 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);
@@ -7278,21 +4290,6 @@ void rtl8192_hwconfig(struct net_device* dev)
}
-#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:
@@ -7450,203 +4447,6 @@ static void rtl8192SU_MacConfigBeforeFwDownloadASIC(struct net_device *dev)
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:
@@ -7709,96 +4509,11 @@ static void rtl8192SU_MacConfigAfterFwDownload(struct net_device *dev)
//
//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)
@@ -7889,11 +4604,7 @@ void rtl8192SU_HwConfigureRTL8192SUsb(struct net_device *dev)
// 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.
@@ -7930,11 +4641,7 @@ void rtl8192SU_HwConfigureRTL8192SUsb(struct net_device *dev)
// 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.
@@ -7987,9 +4694,7 @@ void rtl8192SU_HwConfigureRTL8192SUsb(struct net_device *dev)
//rtl8192SU_SetHwRegAmpduMinSpace(dev, priv->MinSpaceCfg);
}
-#endif
-#ifdef RTL8192SU
// Description: Initial HW relted registers.
//
// Assumption: This function is only invoked at driver intialization once.
@@ -8050,9 +4755,6 @@ start:
//
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;
@@ -8131,17 +4833,6 @@ start:
//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"
@@ -8198,17 +4889,6 @@ start:
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);
@@ -8324,351 +5004,11 @@ start:
// <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---------------------------
***************************************************************************/
@@ -8723,11 +5063,7 @@ TxCheckStuck(struct net_device *dev)
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
@@ -8865,9 +5201,7 @@ rtl819x_ifcheck_resetornot(struct net_device *dev)
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;
@@ -9092,9 +5426,7 @@ RESET_START:
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);
@@ -9131,11 +5463,7 @@ RESET_START:
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
}
@@ -9231,18 +5559,11 @@ void rtl819x_update_rxcounts(
}
}
-
-#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;
@@ -9288,12 +5609,7 @@ extern void rtl819x_watchdog_wqcallback(struct net_device *dev)
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;
@@ -9328,20 +5644,8 @@ 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)
{
@@ -9488,17 +5792,10 @@ 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);
@@ -9537,11 +5834,8 @@ int r8192_set_mac_adr(struct net_device *dev, void *mac)
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;
@@ -9666,7 +5960,6 @@ out:
return ret;
}
-#ifdef RTL8192SU
u8 rtl8192SU_HwRateToMRate(bool bIsHT, u8 rate,bool bFirstAMPDU)
{
@@ -9769,7 +6062,6 @@ u8 rtl8192SU_HwRateToMRate(bool bIsHT, u8 rate,bool bFirstAMPDU)
}
return ret_rate;
}
-#endif
u8 HwRateToMRate90(bool bIsHT, u8 rate)
{
@@ -9903,14 +6195,6 @@ void rtl8192_process_phyinfo(struct r8192_priv * priv,u8* buffer, struct ieee802
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
}
@@ -10220,7 +6504,6 @@ rtl819x_signal_scale_mapping(
return retsig;
}
-#ifdef RTL8192SU
/*-----------------------------------------------------------------------------
* Function: QueryRxPhyStatus8192S()
*
@@ -10286,17 +6569,6 @@ static void rtl8192SU_query_rxphystatus(
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;
@@ -10485,9 +6757,6 @@ static void rtl8192SU_query_rxphystatus(
//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)
{
@@ -10523,256 +6792,6 @@ static void rtl8192SU_query_rxphystatus(
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(
@@ -10785,7 +6804,6 @@ rtl8192_record_rxdesc_forlateruse(
ptarget_stats->Seq_Num = psrc_stats->Seq_Num;
}
-#ifdef RTL8192SU
static void rtl8192SU_query_rxphystatus(
struct r8192_priv * priv,
struct ieee80211_rx_stats * pstats,
@@ -10865,75 +6883,6 @@ void rtl8192SU_TranslateRxSignalStuff(struct sk_buff *skb,
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
@@ -11017,7 +6966,6 @@ UpdateReceivedRateHistogramStatistics8190(
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;
@@ -11031,11 +6979,6 @@ void rtl8192SU_query_rxdesc_status(struct sk_buff *skb, struct ieee80211_rx_stat
//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)
@@ -11160,247 +7103,7 @@ if(stats->bHwError)
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 :
@@ -11441,27 +7144,6 @@ void rtl8192SU_rx_nomal(struct sk_buff* skb)
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)) {
@@ -11471,14 +7153,6 @@ void rtl8192SU_rx_nomal(struct sk_buff* skb)
/* 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 */
@@ -11506,106 +7180,6 @@ void rtl8192SU_rx_nomal(struct sk_buff* skb)
}
//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
{
@@ -11615,178 +7189,6 @@ void rtl8192SU_rx_nomal(struct sk_buff* 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(
@@ -11865,7 +7267,6 @@ void query_rx_cmdpkt_desc_status(struct sk_buff *skb, struct ieee80211_rx_stats
stats->ntotalfrag = 1;
}
-#ifdef RTL8192SU
void rtl8192SU_rx_cmd(struct sk_buff *skb)
{
struct rtl8192_rx_info *info = (struct rtl8192_rx_info *)skb->cb;
@@ -11889,21 +7290,6 @@ void rtl8192SU_rx_cmd(struct sk_buff *skb)
//
// 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;
@@ -11936,70 +7322,6 @@ void rtl8192SU_rx_cmd(struct sk_buff *skb)
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)
{
@@ -12038,7 +7360,6 @@ void rtl8192_irq_rx_tasklet(struct r8192_priv *priv)
/****************************************************************************
---------------------------- 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)
{
@@ -12052,13 +7373,11 @@ static void HalUsbSetQueuePipeMapping8192SUsb(struct usb_interface *intf, struct
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 ++;
@@ -12068,19 +7387,6 @@ static void HalUsbSetQueuePipeMapping8192SUsb(struct usb_interface *intf, struct
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);
@@ -12121,88 +7427,51 @@ static void HalUsbSetQueuePipeMapping8192SUsb(struct usb_interface *intf, struct
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 const struct net_device_ops rtl8192_netdev_ops = {
+ .ndo_open = rtl8192_open,
+ .ndo_stop = rtl8192_close,
+ .ndo_get_stats = rtl8192_stats,
+ .ndo_tx_timeout = tx_timeout,
+ .ndo_do_ioctl = rtl8192_ioctl,
+ .ndo_set_multicast_list = r8192_set_multicast,
+ .ndo_set_mac_address = r8192_set_mac_adr,
+ .ndo_validate_addr = eth_validate_addr,
+ .ndo_change_mtu = eth_change_mtu,
+ .ndo_start_xmit = ieee80211_xmit,
+};
+
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;
+ dev->netdev_ops = &rtl8192_netdev_ops;
//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
@@ -12229,29 +7498,17 @@ static void * __devinit rtl8192_usb_probe(struct usb_device *udev,
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);
@@ -12260,35 +7517,11 @@ void rtl8192_cancel_deferred_work(struct r8192_priv* priv)
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){
@@ -12305,9 +7538,7 @@ static void __devexit rtl8192_usb_disconnect(struct usb_device *udev, void *ptr)
}
// 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);
@@ -12351,14 +7582,6 @@ void rtl8192_try_wake_queue(struct net_device *dev, int pri)
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;
diff --git a/drivers/staging/rtl8192su/r8192U_dm.c b/drivers/staging/rtl8192su/r8192U_dm.c
index 304274b886ea..06f55dcb2e58 100644
--- a/drivers/staging/rtl8192su/r8192U_dm.c
+++ b/drivers/staging/rtl8192su/r8192U_dm.c
@@ -15,7 +15,6 @@ Major Change History:
--*/
-#ifdef RTL8192SU
#include "r8192U.h"
#include "r8192U_dm.h"
//#include "r8190_rtl8256.h"
@@ -23,34 +22,12 @@ Major Change History:
#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};
@@ -58,14 +35,6 @@ typedef enum _HT_IOT_PEER
// 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
@@ -98,12 +67,7 @@ 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);
@@ -118,15 +82,8 @@ extern void dm_force_tx_fw_info(struct net_device *dev,
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);
@@ -211,7 +168,6 @@ static void dm_ctstoself(struct net_device *dev);
//================================================================================
// HW Dynamic mechanism interface.
//================================================================================
-#ifdef RTL8192SU
static void dm_CheckAggrPolicy(struct net_device *dev)
{
struct r8192_priv *priv = ieee80211_priv(dev);
@@ -282,7 +238,6 @@ static void dm_CheckAggrPolicy(struct net_device *dev)
lastTxOkCnt = priv->stats.txbytesunicast;
lastRxOkCnt = priv->stats.rxbytesunicast;
}
-#endif
//
// Description:
// Prepare SW resource for HW dynamic mechanism.
@@ -302,11 +257,7 @@ init_hal_dm(struct net_device *dev)
//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);
@@ -324,101 +275,8 @@ extern void deinit_hal_dm(struct net_device *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)
{
@@ -447,9 +305,6 @@ extern void hal_dm_watchdog(struct net_device *dev)
//if (IS_HARDWARE_TYPE_8192S(dev))
return;
-#ifdef USB_RX_AGGREGATION_SUPPORT
- dm_CheckRxAggregation(dev);
-#endif
#ifdef TO_DO_LIST
if(Adapter->MgntInfo.mActingAsAp)
{
@@ -476,34 +331,6 @@ extern void hal_dm_watchdog(struct net_device *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)
@@ -1081,33 +908,6 @@ static void dm_TXPowerTrackingCallback_ThermalMeter(struct net_device * dev)
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);
@@ -1180,17 +980,11 @@ static void dm_TXPowerTrackingCallback_ThermalMeter(struct net_device * dev)
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);
@@ -1708,37 +1502,15 @@ static void dm_InitializeTXPowerTracking_TSSI(struct net_device *dev)
}
-#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)
+#else
// 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
@@ -1754,15 +1526,7 @@ static void dm_CheckTXPowerTracking_TSSI(struct net_device *dev)
{
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++;
}
@@ -1774,19 +1538,7 @@ 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;
@@ -1804,35 +1556,19 @@ static void dm_CheckTXPowerTracking_ThermalMeter(struct net_device *dev)
//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
}
@@ -2040,14 +1776,6 @@ extern void dm_restore_dynamic_mechanism_state(struct net_device *dev)
//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){
@@ -2150,14 +1878,12 @@ 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;
@@ -2318,29 +2044,6 @@ dm_change_rxpath_selection_setting(
}
}
-#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()
*
@@ -2529,15 +2232,7 @@ static void dm_ctrl_initgain_byrssi_by_fwfalse_alarm(
{
/* 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);
*/
@@ -2681,15 +2376,7 @@ static void dm_ctrl_initgain_byrssi_highpwr(
// 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);
*/
@@ -2856,15 +2543,7 @@ static void dm_pd_th(
{
/* 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);
*/
@@ -3028,7 +2707,6 @@ static void dm_check_edca_turbo(
{
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)
@@ -3071,31 +2749,6 @@ static void dm_check_edca_turbo(
}
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
{
@@ -3235,80 +2888,6 @@ static void dm_ctstoself(struct net_device *dev)
}
}
-
-#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()
*
@@ -3341,19 +2920,9 @@ static void dm_check_rfctrl_gpio(struct net_device * dev)
#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 */
@@ -3394,7 +2963,6 @@ static void dm_check_pbc_gpio(struct net_device *dev)
priv->bpbc_pressed = true;
}
#endif
-#ifdef RTL8192SU
struct r8192_priv *priv = ieee80211_priv(dev);
u8 tmp1byte;
@@ -3420,7 +2988,6 @@ static void dm_check_pbc_gpio(struct net_device *dev)
priv->bpbc_pressed = true;
}
-#endif
}
@@ -3442,17 +3009,11 @@ static void dm_check_pbc_gpio(struct net_device *dev)
* 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;
@@ -3520,17 +3081,11 @@ extern void dm_gpio_change_rf_callback(struct net_device *dev)
* 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;
@@ -3855,15 +3410,8 @@ static void dm_rxpath_sel_byrssi(struct net_device * dev)
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 */
@@ -4018,15 +3566,7 @@ extern void dm_fsync_timer_callback(unsigned long data)
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);
@@ -4215,12 +3755,6 @@ void dm_check_fsync(struct net_device *dev)
#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))
@@ -4265,51 +3799,6 @@ void dm_check_fsync(struct net_device *dev)
}
}
-#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()
*
@@ -4439,16 +3928,6 @@ static void dm_dynamic_txpower(struct net_device *dev)
(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;
@@ -4462,11 +3941,7 @@ static void dm_check_txrateandretrycount(struct net_device * 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);
@@ -4478,24 +3953,6 @@ static void dm_check_txrateandretrycount(struct net_device * dev)
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
diff --git a/drivers/staging/rtl8192su/r8192U_dm.h b/drivers/staging/rtl8192su/r8192U_dm.h
index 1e05d7579882..1b48436ce1ad 100644
--- a/drivers/staging/rtl8192su/r8192U_dm.h
+++ b/drivers/staging/rtl8192su/r8192U_dm.h
@@ -62,50 +62,6 @@
#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-------------------------------*/
@@ -275,11 +231,7 @@ 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,
@@ -287,16 +239,9 @@ extern void dm_change_dynamic_initgain_thresh(struct net_device *dev,
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---------------------*/
diff --git a/drivers/staging/rtl8192su/r8192U_hw.h b/drivers/staging/rtl8192su/r8192U_hw.h
deleted file mode 100644
index f2500e654a79..000000000000
--- a/drivers/staging/rtl8192su/r8192U_hw.h
+++ /dev/null
@@ -1,746 +0,0 @@
-/*
- 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
index 92c95aa36638..60d739b85eb7 100644
--- a/drivers/staging/rtl8192su/r8192U_pm.c
+++ b/drivers/staging/rtl8192su/r8192U_pm.c
@@ -9,7 +9,6 @@
Released under the terms of GPL (General Public Licence)
*/
-#ifdef CONFIG_RTL8192_PM
#include "r8192U.h"
#include "r8192U_pm.h"
@@ -22,11 +21,8 @@ int rtl8192U_save_state (struct pci_dev *dev, u32 state)
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) {
@@ -35,7 +31,9 @@ int rtl8192U_suspend(struct usb_interface *intf, pm_message_t state)
return 0;
}
- dev->stop(dev);
+ if (dev->netdev_ops->ndo_stop)
+ dev->netdev_ops->ndo_stop(dev);
+
mdelay(10);
netif_device_detach(dev);
@@ -46,11 +44,7 @@ int rtl8192U_suspend(struct usb_interface *intf, pm_message_t state)
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.");
@@ -61,7 +55,9 @@ int rtl8192U_resume (struct usb_interface *intf)
}
netif_device_attach(dev);
- dev->open(dev);
+
+ if (dev->netdev_ops->ndo_open)
+ dev->netdev_ops->ndo_open(dev);
}
return 0;
@@ -74,4 +70,3 @@ int rtl8192U_enable_wake (struct pci_dev *dev, u32 state, int enable)
return(-EAGAIN);
}
-#endif //CONFIG_RTL8192_PM
diff --git a/drivers/staging/rtl8192su/r8192U_pm.h b/drivers/staging/rtl8192su/r8192U_pm.h
index ab025d64f5e2..d89e423ea5cd 100644
--- a/drivers/staging/rtl8192su/r8192U_pm.h
+++ b/drivers/staging/rtl8192su/r8192U_pm.h
@@ -10,7 +10,6 @@
*/
-#ifdef CONFIG_RTL8192_PM
#ifndef R8192_PM_H
#define R8192_PM_H
@@ -24,4 +23,3 @@ 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
index f9eafb16dbb7..ad56faec596e 100644
--- a/drivers/staging/rtl8192su/r8192U_wx.c
+++ b/drivers/staging/rtl8192su/r8192U_wx.c
@@ -17,19 +17,11 @@
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
+#include "ieee80211/dot11d.h"
#define RATE_COUNT 12
u32 rtl8180_rates[] = {1000000,2000000,5500000,11000000,
@@ -49,41 +41,6 @@ static int r8192_wx_get_freq(struct net_device *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)
{
@@ -221,10 +178,6 @@ static int r8192_wx_read_bb(struct net_device *dev,
{
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);
@@ -323,14 +276,6 @@ static int r8192_wx_get_ap_status(struct net_device *dev,
#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)
@@ -346,7 +291,6 @@ static int r8192_wx_force_reset(struct net_device *dev,
}
-#ifdef RTL8192SU
static int r8191su_wx_get_firm_version(struct net_device *dev,
struct iw_request_info *info,
struct iw_param *wrqu, char *extra)
@@ -362,7 +306,6 @@ static int r8191su_wx_get_firm_version(struct net_device *dev,
up(&priv->wx_sem);
return 0;
}
-#endif
@@ -529,11 +472,7 @@ static int rtl8180_wx_get_range(struct net_device *dev,
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;
@@ -548,10 +487,8 @@ static int rtl8180_wx_get_range(struct net_device *dev,
}
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;
}
@@ -568,7 +505,7 @@ static int r8192_wx_set_scan(struct net_device *dev, struct iw_request_info *a,
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;
@@ -580,7 +517,6 @@ static int r8192_wx_set_scan(struct net_device *dev, struct iw_request_info *a,
//printk("=====>network ssid:%s\n", ieee->current_network.ssid);
}
}
-#endif
down(&priv->wx_sem);
if(priv->ieee80211->state != IEEE80211_LINKED){
@@ -963,25 +899,12 @@ exit:
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__);
@@ -996,13 +919,6 @@ static int r8192_wx_set_enc_ext(struct net_device *dev,
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
@@ -1065,22 +981,19 @@ static int r8192_wx_set_enc_ext(struct net_device *dev,
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;
}
@@ -1091,23 +1004,19 @@ static int r8192_wx_set_mlme(struct net_device *dev,
//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
@@ -1115,7 +1024,6 @@ static int r8192_wx_set_gen_ie(struct net_device *dev,
#endif
up(&priv->wx_sem);
//printk("<======%s(), ret:%d\n", __FUNCTION__, ret);
-#endif
return ret;
@@ -1152,11 +1060,7 @@ static iw_handler r8192_wx_handlers[] =
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 */
@@ -1185,17 +1089,10 @@ static iw_handler r8192_wx_handlers[] =
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---*/
@@ -1262,14 +1159,12 @@ static const struct iw_priv_args r8192_private_args[] = {
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
};
@@ -1292,12 +1187,9 @@ static iw_handler r8192_private_handler[] = {
#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);
@@ -1311,11 +1203,7 @@ struct iw_statistics *r8192_get_wireless_stats(struct net_device *dev)
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;
}
@@ -1327,15 +1215,9 @@ struct iw_statistics *r8192_get_wireless_stats(struct net_device *dev)
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,
@@ -1343,8 +1225,6 @@ struct iw_handler_def r8192_wx_handlers_def={
.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
index b2f7a571b1c8..61a2c2652536 100644
--- a/drivers/staging/rtl8192su/r8192U_wx.h
+++ b/drivers/staging/rtl8192su/r8192U_wx.h
@@ -15,7 +15,6 @@
#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);
diff --git a/drivers/staging/rtl8192su/r819xU_HTType.h b/drivers/staging/rtl8192su/r819xU_HTType.h
index 2994aa0876ad..3f379e0d9d31 100644
--- a/drivers/staging/rtl8192su/r819xU_HTType.h
+++ b/drivers/staging/rtl8192su/r819xU_HTType.h
@@ -293,15 +293,6 @@ typedef struct _RT_HIGH_THROUGHPUT{
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;
diff --git a/drivers/staging/rtl8192su/r819xU_cmdpkt.c b/drivers/staging/rtl8192su/r819xU_cmdpkt.c
index c1149c6f77bc..e2ba93e30757 100644
--- a/drivers/staging/rtl8192su/r819xU_cmdpkt.c
+++ b/drivers/staging/rtl8192su/r819xU_cmdpkt.c
@@ -108,84 +108,7 @@ SendTxCommandPacket(
{
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 */
/*-----------------------------------------------------------------------------
@@ -319,45 +242,13 @@ cmpk_handle_tx_feedback(
//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
diff --git a/drivers/staging/rtl8192su/r819xU_cmdpkt.h b/drivers/staging/rtl8192su/r819xU_cmdpkt.h
index f67af6cfd201..cced8e0d2788 100644
--- a/drivers/staging/rtl8192su/r819xU_cmdpkt.h
+++ b/drivers/staging/rtl8192su/r819xU_cmdpkt.h
@@ -13,17 +13,6 @@
#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----------------------------*/
@@ -201,15 +190,6 @@ typedef enum tag_command_packet_directories
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);
diff --git a/drivers/staging/rtl8192su/r819xU_firmware.c b/drivers/staging/rtl8192su/r819xU_firmware.c
deleted file mode 100644
index 219f71e8cda7..000000000000
--- a/drivers/staging/rtl8192su/r819xU_firmware.c
+++ /dev/null
@@ -1,707 +0,0 @@
-/**************************************************************************************************
- * 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
deleted file mode 100644
index 10801be014e0..000000000000
--- a/drivers/staging/rtl8192su/r819xU_firmware.h
+++ /dev/null
@@ -1,106 +0,0 @@
-#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_phy.c b/drivers/staging/rtl8192su/r819xU_phy.c
deleted file mode 100644
index 00497d313f9b..000000000000
--- a/drivers/staging/rtl8192su/r819xU_phy.c
+++ /dev/null
@@ -1,1826 +0,0 @@
-#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
deleted file mode 100644
index c165ac1265d9..000000000000
--- a/drivers/staging/rtl8192su/r819xU_phy.h
+++ /dev/null
@@ -1,94 +0,0 @@
-#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
deleted file mode 100644
index b62f1a6fb1eb..000000000000
--- a/drivers/staging/rtl8192su/r819xU_phyreg.h
+++ /dev/null
@@ -1,871 +0,0 @@
-#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_usb2/serqt_usb2.c b/drivers/staging/serqt_usb2/serqt_usb2.c
index 90b29b564631..a9bd4106beb7 100644
--- a/drivers/staging/serqt_usb2/serqt_usb2.c
+++ b/drivers/staging/serqt_usb2/serqt_usb2.c
@@ -866,7 +866,7 @@ static void qt_release(struct usb_serial *serial)
}
-int qt_open(struct tty_struct *tty,
+static int qt_open(struct tty_struct *tty,
struct usb_serial_port *port, struct file *filp)
{
struct usb_serial *serial;
@@ -1041,17 +1041,19 @@ static void qt_block_until_empty(struct tty_struct *tty,
}
}
-static void qt_close(struct tty_struct *tty, struct usb_serial_port *port,
- struct file *filp)
+static void qt_close( struct usb_serial_port *port)
{
struct usb_serial *serial = port->serial;
struct quatech_port *qt_port;
struct quatech_port *port0;
+ struct tty_struct *tty;
int status;
unsigned int index;
status = 0;
dbg("%s - port %d\n", __func__, port->number);
+
+ tty = tty_port_tty_get(&port->port);
index = tty->index - serial->minor;
qt_port = qt_get_port_private(port);
diff --git a/drivers/staging/stlc45xx/stlc45xx.c b/drivers/staging/stlc45xx/stlc45xx.c
index 52744faedbff..12d414deaad6 100644
--- a/drivers/staging/stlc45xx/stlc45xx.c
+++ b/drivers/staging/stlc45xx/stlc45xx.c
@@ -2236,24 +2236,6 @@ static void stlc45xx_op_remove_interface(struct ieee80211_hw *hw,
stlc45xx_debug(DEBUG_FUNC, "%s", __func__);
}
-static int stlc45xx_op_config_interface(struct ieee80211_hw *hw,
- struct ieee80211_vif *vif,
- struct ieee80211_if_conf *conf)
-{
- struct stlc45xx *stlc = hw->priv;
-
- stlc45xx_debug(DEBUG_FUNC, "%s", __func__);
-
- mutex_lock(&stlc->mutex);
-
- memcpy(stlc->bssid, conf->bssid, ETH_ALEN);
- stlc45xx_tx_setup(stlc);
-
- mutex_unlock(&stlc->mutex);
-
- return 0;
-}
-
static int stlc45xx_op_config(struct ieee80211_hw *hw, u32 changed)
{
struct stlc45xx *stlc = hw->priv;
@@ -2296,6 +2278,14 @@ static void stlc45xx_op_bss_info_changed(struct ieee80211_hw *hw,
{
struct stlc45xx *stlc = hw->priv;
+ stlc45xx_debug(DEBUG_FUNC, "%s", __func__);
+ mutex_lock(&stlc->mutex);
+
+ memcpy(stlc->bssid, info->bssid, ETH_ALEN);
+ stlc45xx_tx_setup(stlc);
+
+ mutex_unlock(&stlc->mutex);
+
if (changed & BSS_CHANGED_ASSOC) {
stlc->associated = info->assoc;
if (info->assoc)
@@ -2358,7 +2348,6 @@ static const struct ieee80211_ops stlc45xx_ops = {
.add_interface = stlc45xx_op_add_interface,
.remove_interface = stlc45xx_op_remove_interface,
.config = stlc45xx_op_config,
- .config_interface = stlc45xx_op_config_interface,
.configure_filter = stlc45xx_op_configure_filter,
.tx = stlc45xx_op_tx,
.bss_info_changed = stlc45xx_op_bss_info_changed,
diff --git a/drivers/staging/vt6655/Kconfig b/drivers/staging/vt6655/Kconfig
index a01b1e49fb31..9bec95adcce2 100644
--- a/drivers/staging/vt6655/Kconfig
+++ b/drivers/staging/vt6655/Kconfig
@@ -1,6 +1,6 @@
config VT6655
tristate "VIA Technologies VT6655 support"
- depends on PCI
+ depends on WIRELESS_EXT && PCI
---help---
This is a vendor-written driver for VIA VT6655.
diff --git a/drivers/staging/vt6655/Makefile b/drivers/staging/vt6655/Makefile
index 7d76e7ef3f88..260c81d1eae9 100644
--- a/drivers/staging/vt6655/Makefile
+++ b/drivers/staging/vt6655/Makefile
@@ -1,5 +1,5 @@
# TODO: all of these should be removed
-EXTRA_CFLAGS += -DLINUX -D__KERNEL__ -DMODULE -DEXPORT_SYMTAB -D__NO_VERSION__
+EXTRA_CFLAGS += -DLINUX -D__KERNEL__ -DMODULE -D__NO_VERSION__
EXTRA_CFLAGS += -DHOSTAP
vt6655-y += device_main.o \
diff --git a/drivers/staging/vt6655/Makefile.arm b/drivers/staging/vt6655/Makefile.arm
deleted file mode 100644
index 2d2ccaded6ac..000000000000
--- a/drivers/staging/vt6655/Makefile.arm
+++ /dev/null
@@ -1,181 +0,0 @@
-#
-#
-# 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
deleted file mode 100644
index 69082f09ba73..000000000000
--- a/drivers/staging/vt6655/Makefile.x86
+++ /dev/null
@@ -1,209 +0,0 @@
-#
-# 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/desc.h b/drivers/staging/vt6655/desc.h
index c0fc1d3b0a2e..087a3e0e2671 100644
--- a/drivers/staging/vt6655/desc.h
+++ b/drivers/staging/vt6655/desc.h
@@ -41,12 +41,6 @@
#if !defined(__TETHER_H__)
#include "tether.h"
#endif
-// #ifdef PRIVATE_OBJ
-//#if !defined(__DEVICE_MODULE_H)
-//#include "device_module.h"
-//#endif
-
-
/*--------------------- Export Definitions -------------------------*/
@@ -237,9 +231,6 @@
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;
diff --git a/drivers/staging/vt6655/device.h b/drivers/staging/vt6655/device.h
index 264d1bb2ff79..38cc942deca6 100644
--- a/drivers/staging/vt6655/device.h
+++ b/drivers/staging/vt6655/device.h
@@ -70,16 +70,12 @@
#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
//
@@ -141,11 +137,6 @@
//#define TASK_LET
//PLICE_DEBUG<-
-// #ifdef PRIVATE_OBJ
-//#if !defined(__DEVICE_MODULE_H)
-//#include "device_module.h"
-//#endif
-
/*--------------------- Export Definitions -------------------------*/
@@ -207,93 +198,9 @@
// 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)]))
@@ -456,9 +363,6 @@ typedef struct tagSDeFragControlBlock
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;
@@ -954,9 +858,7 @@ typedef struct __device_info {
UINT uChannel;
BOOL bMACSuspend;
-#ifdef WIRELESS_EXT
struct iw_statistics wstats; // wireless stats
-#endif /* WIRELESS_EXT */
BOOL bCommit;
} DEVICE_INFO, *PSDevice;
diff --git a/drivers/staging/vt6655/device_main.c b/drivers/staging/vt6655/device_main.c
index a10ed27acbc2..cb5fce2702a3 100644
--- a/drivers/staging/vt6655/device_main.c
+++ b/drivers/staging/vt6655/device_main.c
@@ -132,16 +132,8 @@
#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;
@@ -151,11 +143,9 @@ static int msglevel = MSG_LEVEL_INFO;
//
// 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;
@@ -332,7 +322,6 @@ DEVICE_PARAM(bDiversityANTEnable, "ANT diversity mode");
//
-#ifndef PRIVATE_OBJ
static int device_nics =0;
static PSDevice pDevice_Infos =NULL;
static struct net_device *root_device_dev = NULL;
@@ -344,14 +333,12 @@ static CHIP_INFO chip_info_table[]= {
};
static struct pci_device_id device_id_table[] __devinitdata = {
-{ 0x1106, 0x3253, PCI_ANY_ID, PCI_ANY_ID, 0, 0, (int)&chip_info_table[0]},
+{ 0x1106, 0x3253, PCI_ANY_ID, PCI_ANY_ID, 0, 0, (long)&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);
@@ -369,7 +356,7 @@ static int device_ioctl(struct net_device *dev, struct ifreq *rq, int cmd);
#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_suspend(struct pci_dev *pcid, pm_message_t state);
static int viawget_resume(struct pci_dev *pcid);
struct notifier_block device_notifier = {
notifier_call: device_notify_reboot,
@@ -378,7 +365,6 @@ struct notifier_block device_notifier = {
};
#endif
-#endif // #ifndef PRIVATE_OBJ
static void device_init_rd0_ring(PSDevice pDevice);
static void device_init_rd1_ring(PSDevice pDevice);
@@ -386,9 +372,7 @@ 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);
@@ -412,7 +396,6 @@ static int Config_FileGetParameter(UCHAR *string, UCHAR *dest,UCHAR *source);
/*--------------------- Export Functions --------------------------*/
-#ifndef PRIVATE_OBJ
static char* get_chip_name(int chip_id) {
int i;
@@ -432,7 +415,6 @@ static void __devexit device_remove1(struct pci_dev *pcid)
}
-#endif
/*
static void
device_set_int_opt(int *opt, int val, int min, int max, int def,char* name,char* devname) {
@@ -978,7 +960,6 @@ static const struct net_device_ops device_netdev_ops = {
};
-#ifndef PRIVATE_OBJ
static int
device_found1(struct pci_dev *pcid, const struct pci_device_id *ent)
@@ -1146,14 +1127,7 @@ device_found1(struct pci_dev *pcid, const struct pci_device_id *ent)
dev->irq = pcid->irq;
dev->netdev_ops = &device_netdev_ops;
-#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 */
rc = register_netdev(dev);
if (rc)
@@ -1336,7 +1310,6 @@ device_release_WPADEV(pDevice);
pci_set_drvdata(pDevice->pcid,NULL);
}
}
-#endif// ifndef PRIVATE_OBJ
static BOOL device_init_rings(PSDevice pDevice) {
void* vir_pool;
@@ -1683,11 +1656,7 @@ static int device_rx_srv(PSDevice pDevice, UINT uIdx) {
}
}
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;
@@ -1700,15 +1669,6 @@ 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
@@ -1720,7 +1680,6 @@ static BOOL device_alloc_rx_buf(PSDevice pDevice, PSRxDesc pRD) {
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);
@@ -1735,20 +1694,11 @@ static BOOL device_alloc_rx_buf(PSDevice pDevice, PSRxDesc pRD) {
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;
}
@@ -1767,9 +1717,6 @@ static int device_tx_srv(PSDevice pDevice, UINT uIdx) {
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) {
@@ -1789,9 +1736,6 @@ static int device_tx_srv(PSDevice pDevice, UINT uIdx) {
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
@@ -1816,11 +1760,7 @@ static int device_tx_srv(PSDevice pDevice, UINT uIdx) {
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",
@@ -1833,14 +1773,6 @@ static int device_tx_srv(PSDevice pDevice, UINT uIdx) {
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;
skb->mac_header = skb->data;
@@ -1848,7 +1780,6 @@ static int device_tx_srv(PSDevice pDevice, UINT uIdx) {
//skb->protocol = htons(ETH_P_802_2);
memset(skb->cb, 0, sizeof(skb->cb));
netif_rx(skb);
-#endif
}
}
@@ -2005,28 +1936,18 @@ INT MlmeThread(
}
-#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) netdev_priv(dev);
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
i=request_irq(pDevice->pcid->irq, &device_intr, IRQF_SHARED, dev->name, dev);
if (i)
return i;
-#endif
//printk("DEBUG1\n");
#ifdef WPA_SM_Transtatus
extern SWPAResult wpa_Result;
@@ -2092,11 +2013,7 @@ 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);
@@ -2148,17 +2065,8 @@ DEVICE_PRT(MSG_LEVEL_DEBUG, KERN_INFO "call MACvIntEnable\n");
}
-#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) netdev_priv(dev);
-#endif
PSMgmtObject pMgmt = pDevice->pMgmt;
//PLICE_DEBUG->
#ifdef THREAD
@@ -2211,19 +2119,10 @@ device_release_WPADEV(pDevice);
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=netdev_priv(dev);
-#endif
PBYTE pbMPDU;
UINT cbMPDULen = 0;
@@ -2244,14 +2143,8 @@ static int device_dma0_tx_80211(struct sk_buff *skb, struct net_device *dev) {
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);
@@ -2275,9 +2168,6 @@ BOOL device_dma0_xmit(PSDevice pDevice, struct sk_buff *skb, UINT uNodeIndex) {
UINT ii;
SKeyItem STempKey;
// BYTE byKeyIndex = 0;
-#ifdef PRIVATE_OBJ
- ref_sk_buff ref_skb;
-#endif
if (pDevice->bStopTx0Pkt == TRUE) {
@@ -2299,21 +2189,12 @@ BOOL device_dma0_xmit(PSDevice pDevice, struct sk_buff *skb, UINT uNodeIndex) {
}
}
-#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) {
@@ -2424,19 +2305,9 @@ BOOL device_dma0_xmit(PSDevice pDevice, struct sk_buff *skb, UINT uNodeIndex) {
}
//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=netdev_priv(dev);
-#endif
PSMgmtObject pMgmt = pDevice->pMgmt;
PSTxDesc pHeadTD, pLastTD;
UINT uNodeIndex = 0;
@@ -2470,9 +2341,6 @@ static int device_xmit(struct sk_buff *skb, struct net_device *dev) {
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) {
@@ -2480,19 +2348,11 @@ static int device_xmit(struct sk_buff *skb, struct net_device *dev) {
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];
@@ -2500,17 +2360,9 @@ static int device_xmit(struct sk_buff *skb, struct net_device *dev) {
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;
@@ -2545,13 +2397,8 @@ static int device_xmit(struct sk_buff *skb, struct net_device *dev) {
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;
@@ -2770,14 +2617,6 @@ pDevice->byTopCCKBasicRate,pDevice->byTopOFDMBasicRate);
}
-#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)
//{
@@ -2790,7 +2629,6 @@ pDevice->byTopCCKBasicRate,pDevice->byTopOFDMBasicRate);
&uMACfragNum,
&cbHeaderSize
);
-#endif
if (MACbIsRegBitsOn(pDevice->PortOffset, MAC_REG_PSCTL, PSCTL_PS)) {
// Disable PS
@@ -2811,11 +2649,7 @@ pDevice->byTopCCKBasicRate,pDevice->byTopOFDMBasicRate);
// 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
@@ -2869,29 +2703,16 @@ BOOL bTxeapol_key = FALSE;
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) netdev_priv(dev);
-#endif
int max_count=0;
DWORD dwMIBCounter=0;
@@ -3297,18 +3118,9 @@ error2:
}
-#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) netdev_priv(dev);
-#endif
PSMgmtObject pMgmt = pDevice->pMgmt;
u32 mc_filter[2];
@@ -3318,24 +3130,13 @@ static void device_set_multi(struct net_device *dev) {
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);
@@ -3344,13 +3145,8 @@ static void device_set_multi(struct net_device *dev) {
}
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));
}
@@ -3373,38 +3169,19 @@ static void device_set_multi(struct net_device *dev) {
}
-#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) netdev_priv(dev);
-#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)netdev_priv(dev);
-#endif
-#ifdef WIRELESS_EXT
struct iwreq *wrq = (struct iwreq *) rq;
int rc =0;
-#endif
PSMgmtObject pMgmt = pDevice->pMgmt;
PSCmdRequest pReq;
@@ -3416,9 +3193,6 @@ static int device_ioctl(struct net_device *dev, struct ifreq *rq, int cmd) {
switch(cmd) {
-#ifdef WIRELESS_EXT
-//#if WIRELESS_EXT < 13
-
case SIOCGIWNAME:
rc = iwctl_giwname(dev, NULL, (char *)&(wrq->u.name), NULL);
break;
@@ -3593,7 +3367,6 @@ static int device_ioctl(struct net_device *dev, struct ifreq *rq, int cmd) {
}
break;
-#if WIRELESS_EXT > 9
// Get the current Tx-Power
case SIOCGIWTXPOW:
DEVICE_PRT(MSG_LEVEL_DEBUG, KERN_INFO " SIOCGIWTXPOW \n");
@@ -3605,9 +3378,6 @@ static int device_ioctl(struct net_device *dev, struct ifreq *rq, int cmd) {
rc = -EOPNOTSUPP;
break;
-#endif // WIRELESS_EXT > 9
-
-#if WIRELESS_EXT > 10
case SIOCSIWRETRY:
rc = iwctl_siwretry(dev, NULL, &(wrq->u.retry), NULL);
@@ -3618,8 +3388,6 @@ static int device_ioctl(struct net_device *dev, struct ifreq *rq, int cmd) {
rc = iwctl_giwretry(dev, NULL, &(wrq->u.retry), NULL);
break;
-#endif // WIRELESS_EXT > 10
-
// Get range of parameters
case SIOCGIWRANGE:
@@ -3706,7 +3474,6 @@ static int device_ioctl(struct net_device *dev, struct ifreq *rq, int cmd) {
break;
-//#endif // WIRELESS_EXT < 13
//2008-0409-07, <Add> by Einsn Liu
#ifdef WPA_SUPPLICANT_DRIVER_WEXT_SUPPORT
case SIOCSIWAUTH:
@@ -3764,8 +3531,6 @@ static int device_ioctl(struct net_device *dev, struct ifreq *rq, int cmd) {
#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)) {
@@ -3804,20 +3569,12 @@ static int device_ioctl(struct net_device *dev, struct ifreq *rq, int cmd) {
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
+ rc = hostap_ioctl(pDevice, &wrq->u.data);
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
+ rc = wpa_ioctl(pDevice, &wrq->u.data);
break;
case SIOCETHTOOL:
@@ -3883,7 +3640,6 @@ static int ethtool_ioctl(struct net_device *dev, void *useraddr)
}
/*------------------------------------------------------------------*/
-#ifndef PRIVATE_OBJ
MODULE_DEVICE_TABLE(pci, device_id_table);
@@ -3941,7 +3697,7 @@ device_notify_reboot(struct notifier_block *nb, unsigned long event, void *p)
while ((pdev = pci_get_device(PCI_ANY_ID, PCI_ANY_ID, pdev)) != NULL) {
if(pci_dev_driver(pdev) == &device_driver) {
if (pci_get_drvdata(pdev))
- viawget_suspend(pdev, 3);
+ viawget_suspend(pdev, PMSG_HIBERNATE);
}
}
}
@@ -3949,7 +3705,7 @@ device_notify_reboot(struct notifier_block *nb, unsigned long event, void *p)
}
static int
-viawget_suspend(struct pci_dev *pcid, u32 state)
+viawget_suspend(struct pci_dev *pcid, pm_message_t state)
{
int power_status; // to silence the compiler
@@ -3971,7 +3727,7 @@ viawget_suspend(struct pci_dev *pcid, u32 state)
memset(pMgmt->abyCurrBSSID, 0, 6);
pMgmt->eCurrState = WMAC_STATE_IDLE;
pci_disable_device(pcid);
- power_status = pci_set_power_state(pcid, state);
+ power_status = pci_set_power_state(pcid, pci_choose_state(pcid, state));
spin_unlock_irq(&pDevice->lock);
return 0;
}
@@ -4016,59 +3772,6 @@ viawget_resume(struct pci_dev *pcid)
#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
index acc6d82a9544..11611982a990 100644
--- a/drivers/staging/vt6655/dpc.c
+++ b/drivers/staging/vt6655/dpc.c
@@ -143,17 +143,6 @@ static BOOL s_bAPModeRxCtl(
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,
@@ -163,7 +152,6 @@ static BOOL s_bAPModeRxData (
IN INT iSANodeIndex,
IN INT iDANodeIndex
);
-#endif
static BOOL s_bHandleRxEncryption(
@@ -395,11 +383,7 @@ device_receive_frame (
//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;
@@ -435,12 +419,8 @@ device_receive_frame (
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->
@@ -541,11 +521,7 @@ device_receive_frame (
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;
}
}
@@ -639,11 +615,7 @@ device_receive_frame (
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;
}
@@ -705,16 +677,6 @@ device_receive_frame (
// 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);
- skb->mac_header = skb->data;
- *(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);
@@ -723,7 +685,6 @@ device_receive_frame (
skb->protocol = htons(ETH_P_802_2);
memset(skb->cb, 0, sizeof(skb->cb));
netif_rx(skb);
-#endif
return TRUE;
}
}
@@ -846,16 +807,6 @@ device_receive_frame (
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);
- skb->mac_header = skb->data;
- *(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);
@@ -865,7 +816,6 @@ device_receive_frame (
skb->protocol = htons(ETH_P_802_2);
memset(skb->cb, 0, sizeof(skb->cb));
netif_rx(skb);
-#endif
return TRUE;
}
@@ -1081,29 +1031,17 @@ device_receive_frame (
}
-#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) {
@@ -1117,17 +1055,10 @@ device_receive_frame (
}
*/
-#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])) {
@@ -1541,18 +1472,6 @@ static BOOL s_bHostWepRxEncryption (
-#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,
@@ -1562,20 +1481,13 @@ static BOOL s_bAPModeRxData (
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
@@ -1585,28 +1497,16 @@ static BOOL s_bAPModeRxData (
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];
@@ -1623,16 +1523,10 @@ static BOOL s_bAPModeRxData (
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];
diff --git a/drivers/staging/vt6655/hostap.c b/drivers/staging/vt6655/hostap.c
index 91f189ddeef4..3788c9422294 100644
--- a/drivers/staging/vt6655/hostap.c
+++ b/drivers/staging/vt6655/hostap.c
@@ -106,25 +106,6 @@ static int hostap_enable_hostapd(PSDevice pDevice, int rtnl_locked)
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;
@@ -160,7 +141,6 @@ static int hostap_enable_hostapd(PSDevice pDevice, int rtnl_locked)
dev->name, pDevice->apdev->name);
KeyvInitTable(&pDevice->sKey, pDevice->PortOffset);
-#endif
return 0;
}
@@ -308,11 +288,7 @@ static int hostap_add_sta(PSDevice pDevice,
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],
@@ -349,13 +325,8 @@ static int hostap_get_info_sta(PSDevice pDevice,
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 {
diff --git a/drivers/staging/vt6655/hostap.h b/drivers/staging/vt6655/hostap.h
index 1fcb2f0788b3..c5ad3494b6e4 100644
--- a/drivers/staging/vt6655/hostap.h
+++ b/drivers/staging/vt6655/hostap.h
@@ -37,14 +37,6 @@
/*--------------------- 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
diff --git a/drivers/staging/vt6655/iwctl.c b/drivers/staging/vt6655/iwctl.c
index 4d5a1da8edfc..2ff8f243e49f 100644
--- a/drivers/staging/vt6655/iwctl.c
+++ b/drivers/staging/vt6655/iwctl.c
@@ -68,9 +68,7 @@
#endif
#endif
-#if WIRELESS_EXT > 12
#include <net/iw_handler.h>
-#endif
extern WORD TxRate_iwconfig;//2008-5-8 <add> by chester
/*--------------------- Static Definitions -------------------------*/
@@ -82,8 +80,6 @@ extern WORD TxRate_iwconfig;//2008-5-8 <add> by chester
#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,
@@ -92,8 +88,6 @@ static const long frequency_list[] = {
5700, 5745, 5765, 5785, 5805, 5825
};
-#endif
-
/*--------------------- Static Classes ----------------------------*/
@@ -107,10 +101,6 @@ static int msglevel =MSG_LEVEL_INFO;
/*--------------------- Export Variables --------------------------*/
-#ifdef WIRELESS_EXT
-
-#if WIRELESS_EXT > 12
-
struct iw_statistics *iwctl_get_wireless_stats(struct net_device *dev)
{
PSDevice pDevice = netdev_priv(dev);
@@ -156,8 +146,6 @@ struct iw_statistics *iwctl_get_wireless_stats(struct net_device *dev)
return &pDevice->wstats;
}
-#endif
-
/*------------------------------------------------------------------*/
@@ -198,7 +186,6 @@ int iwctl_giwnwid(struct net_device *dev,
//return 0;
return -EOPNOTSUPP;
}
-#if WIRELESS_EXT > 13
/*
* Wireless Handler : set scan
@@ -286,9 +273,7 @@ int iwctl_giwscan(struct net_device *dev,
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");
@@ -397,14 +382,12 @@ int iwctl_giwscan(struct net_device *dev,
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);
current_ev = iwe_stream_add_point(info,current_ev, end_buf, &iwe, buf);
-#if WIRELESS_EXT > 17
if ((pBSS->wWPALen > 0) && (pBSS->wWPALen <= MAX_WPA_IE_LEN)) {
memset(&iwe, 0, sizeof(iwe));
iwe.cmd = IWEVGENIE;
@@ -419,33 +402,6 @@ int iwctl_giwscan(struct net_device *dev,
current_ev = iwe_stream_add_point(info,current_ev, end_buf, &iwe, pBSS->byRSNIE);
}
-#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);
- current_ev = iwe_stream_add_point(info,current_ev, end_buf, &iwe, buf);
- }
-
-
- 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);
- current_ev = iwe_stream_add_point(info,current_ev, end_buf, &iwe, buf);
- }
-#endif
-#endif
}
}// for
@@ -454,8 +410,6 @@ int iwctl_giwscan(struct net_device *dev,
}
-#endif /* WIRELESS_EXT > 13 */
-
/*
* Wireless Handler : set frequence or channel
@@ -708,12 +662,9 @@ int iwctl_giwrange(struct net_device *dev,
// 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;
@@ -727,8 +678,6 @@ int iwctl_giwrange(struct net_device *dev,
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;
@@ -738,15 +687,12 @@ int iwctl_giwrange(struct net_device *dev,
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
}
@@ -1004,13 +950,8 @@ if (pMgmt->eScanState == WMAC_IS_SCANNING) {
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
*/
}
@@ -1049,11 +990,7 @@ int iwctl_giwessid(struct net_device *dev,
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
@@ -2217,8 +2154,6 @@ int iwctl_siwmlme(struct net_device *dev,
*/
-#if WIRELESS_EXT > 12
-
/*
static const iw_handler iwctl_handler[] =
{
@@ -2246,13 +2181,8 @@ static const iw_handler iwctl_handler[] =
(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
@@ -2273,7 +2203,6 @@ static const iw_handler iwctl_handler[] =
(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
@@ -2284,7 +2213,6 @@ static const iw_handler iwctl_handler[] =
(iw_handler) iwctl_giwencodeext, // SIOCGIWENCODEEXT
(iw_handler) NULL, // SIOCSIWPMKSA
(iw_handler) NULL, // -- hole --
-#endif // WIRELESS_EXT > 17
};
*/
@@ -2315,13 +2243,8 @@ static const iw_handler iwctl_handler[] =
(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
@@ -2344,7 +2267,6 @@ static const iw_handler iwctl_handler[] =
(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
@@ -2355,7 +2277,6 @@ static const iw_handler iwctl_handler[] =
(iw_handler) NULL, // SIOCGIWENCODEEXT
(iw_handler) NULL, // SIOCSIWPMKSA
(iw_handler) NULL, // -- hole --
-#endif // WIRELESS_EXT > 17
};
@@ -2375,9 +2296,7 @@ struct iw_priv_args iwctl_private_args[] = {
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),
@@ -2389,9 +2308,3 @@ const struct iw_handler_def iwctl_handler_def =
.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
index 07554e14d5f2..44ee46c2c475 100644
--- a/drivers/staging/vt6655/iwctl.h
+++ b/drivers/staging/vt6655/iwctl.h
@@ -50,87 +50,6 @@ 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);
@@ -310,14 +229,8 @@ int iwctl_siwmlme(struct net_device *dev,
#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" { */
diff --git a/drivers/staging/vt6655/kcompat.h b/drivers/staging/vt6655/kcompat.h
index 652c2c78b0f5..ee22006122ed 100644
--- a/drivers/staging/vt6655/kcompat.h
+++ b/drivers/staging/vt6655/kcompat.h
@@ -66,11 +66,7 @@
#ifndef IRQ_RETVAL
typedef void irqreturn_t;
-#ifdef PRIVATE_OBJ
-#define IRQ_RETVAL(x) (int)x
-#else
#define IRQ_RETVAL(x)
-#endif
#endif
diff --git a/drivers/staging/vt6655/wctl.c b/drivers/staging/vt6655/wctl.c
index b4fecc2ed55c..ac9ec7e0806a 100644
--- a/drivers/staging/vt6655/wctl.c
+++ b/drivers/staging/vt6655/wctl.c
@@ -212,11 +212,7 @@ UINT uHeaderSize;
}
}
// 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;
diff --git a/drivers/staging/vt6656/80211hdr.h b/drivers/staging/vt6656/80211hdr.h
new file mode 100644
index 000000000000..84cb1d020cb7
--- /dev/null
+++ b/drivers/staging/vt6656/80211hdr.h
@@ -0,0 +1,358 @@
+/*
+ * 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: 802.11 MAC headers related pre-defines and macros.
+ *
+ *
+ * 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/vt6656/80211mgr.c b/drivers/staging/vt6656/80211mgr.c
new file mode 100644
index 000000000000..fda7224428c0
--- /dev/null
+++ b/drivers/staging/vt6656/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 managment frame parsing 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:
+ DBG_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:
+ DBG_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;
+ DBG_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:
+ DBG_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:
+ DBG_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) ) {
+
+ //20080701-01,<Remark> by Mike Liu
+ // 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:
+ DBG_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/vt6656/80211mgr.h b/drivers/staging/vt6656/80211mgr.h
new file mode 100644
index 000000000000..d94bfb9e8b1c
--- /dev/null
+++ b/drivers/staging/vt6656/80211mgr.h
@@ -0,0 +1,867 @@
+/*
+ * 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: 802.11 managment frames pre-defines.
+ *
+ *
+ * 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
+
+#ifdef Cisco_ccx
+#define WLAN_EID_CCX 133 //DavidWang
+#define WLAN_EID_CCX_IP 149 //DavidWang
+#define WLAN_EID_CCX_Ver 221 //DavidWang
+#endif
+
+#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;
+
+//DavidWang
+// CCX Identity DavidWang
+#pragma pack(1)
+typedef struct tagWLAN_IE_CCX {
+BYTE byElementID;
+BYTE len;
+BYTE abyCCX[30];
+} WLAN_IE_CCX, *PWLAN_IE_CCX;
+#pragma pack(1)
+typedef struct tagWLAN_IE_CCX_IP {
+BYTE byElementID;
+BYTE len;
+BYTE abyCCXOUI[4];
+BYTE abyCCXIP[4];
+BYTE abyCCXREV[2];
+} WLAN_IE_CCX_IP, *PWLAN_IE_CCX_IP;
+#pragma pack(1)
+typedef struct tagWLAN_IE_CCX_Ver {
+BYTE byElementID;
+BYTE len;
+BYTE abyCCXVer[5];
+} WLAN_IE_CCX_Ver, *PWLAN_IE_CCX_Ver;
+
+//DavidWang
+
+// 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_CCX pCCX;
+ PWLAN_IE_CCX_IP pCCXIP;
+ PWLAN_IE_CCX_Ver pCCXVER;
+ 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_CCX pCCX;
+ PWLAN_IE_CCX_IP pCCXIP;
+ PWLAN_IE_CCX_Ver pCCXVER;
+ 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/vt6656/Kconfig b/drivers/staging/vt6656/Kconfig
new file mode 100644
index 000000000000..3165f2c42079
--- /dev/null
+++ b/drivers/staging/vt6656/Kconfig
@@ -0,0 +1,6 @@
+config VT6656
+ tristate "VIA Technologies VT6656 support"
+ depends on WIRELESS_EXT && USB
+ ---help---
+ This is a vendor-written driver for VIA VT6656.
+
diff --git a/drivers/staging/vt6656/Makefile b/drivers/staging/vt6656/Makefile
new file mode 100644
index 000000000000..4467bb1a608c
--- /dev/null
+++ b/drivers/staging/vt6656/Makefile
@@ -0,0 +1,39 @@
+# TODO: all of these should be removed
+EXTRA_CFLAGS += -DLINUX -D__KERNEL__ -DMODULE -DEXPORT_SYMTAB -D__NO_VERSION__
+EXTRA_CFLAGS += -DHOSTAP
+
+vt6656-y += main_usb.o \
+ card.o \
+ mac.o \
+ baseband.o \
+ wctl.o \
+ 80211mgr.o \
+ wcmd.o\
+ wmgr.o \
+ bssdb.o \
+ wpa2.o \
+ rxtx.o \
+ dpc.o \
+ power.o \
+ datarate.o \
+ mib.o \
+ rc4.o \
+ tether.o \
+ tcrc.o \
+ ioctl.o \
+ hostap.o \
+ wpa.o \
+ key.o \
+ tkip.o \
+ michael.o \
+ rf.o \
+ iwctl.o \
+ wpactl.o \
+ aes_ccmp.o \
+ usbpipe.o \
+ channel.o \
+ control.o \
+ firmware.o \
+ int.o
+
+obj-$(CONFIG_VT6656) += vt6656.o
diff --git a/drivers/staging/vt6656/aes_ccmp.c b/drivers/staging/vt6656/aes_ccmp.c
new file mode 100644
index 000000000000..59cc018d48a2
--- /dev/null
+++ b/drivers/staging/vt6656/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/vt6656/aes_ccmp.h b/drivers/staging/vt6656/aes_ccmp.h
new file mode 100644
index 000000000000..2b1920f28609
--- /dev/null
+++ b/drivers/staging/vt6656/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/vt6656/baseband.c b/drivers/staging/vt6656/baseband.c
new file mode 100644
index 000000000000..7b43ceabecc0
--- /dev/null
+++ b/drivers/staging/vt6656/baseband.c
@@ -0,0 +1,2129 @@
+/*
+ * 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: Jerry Chen
+ *
+ * Date: Jun. 5, 2002
+ *
+ * Functions:
+ * BBuGetFrameTime - Calculate data frame transmitting time
+ * BBvCaculateParameter - Caculate PhyLength, PhyService and Phy Signal parameter for baseband Tx
+ * BBbVT3184Init - VIA VT3184 baseband chip init code
+ * BBvLoopbackOn - Turn on BaseBand Loopback mode
+ * BBvLoopbackOff - Turn off BaseBand Loopback mode
+ *
+ * Revision History:
+ *
+ *
+ */
+
+
+#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(__RF_H__)
+#include "rf.h"
+#endif
+#if !defined(__SROM_H__)
+#include "srom.h"
+#endif
+#if !defined(__CONTROL_H__)
+#include "control.h"
+#endif
+#if !defined(__DATARATE_H__)
+#include "datarate.h"
+#endif
+#if !defined(__RNDIS_H__)
+#include "rndis.h"
+#endif
+#if !defined(__CONTROL_H__)
+#include "control.h"
+#endif
+
+/*--------------------- Static Definitions -------------------------*/
+static int msglevel =MSG_LEVEL_INFO;
+//static int msglevel =MSG_LEVEL_DEBUG;
+
+/*--------------------- Static Classes ----------------------------*/
+
+/*--------------------- Static Variables --------------------------*/
+
+/*--------------------- Static Functions --------------------------*/
+
+/*--------------------- Export Variables --------------------------*/
+
+/*--------------------- Static Definitions -------------------------*/
+
+/*--------------------- Static Classes ----------------------------*/
+
+/*--------------------- Static Variables --------------------------*/
+
+
+BYTE abyVT3184_AGC[] = {
+ 0x00, //0
+ 0x00, //1
+ 0x02, //2
+ 0x02, //3 //RobertYu:20060505, 0x04, //3
+ 0x04, //4
+ 0x04, //5 //RobertYu:20060505, 0x06, //5
+ 0x06, //6
+ 0x06, //7
+ 0x08, //8
+ 0x08, //9
+ 0x0A, //A
+ 0x0A, //B
+ 0x0C, //C
+ 0x0C, //D
+ 0x0E, //E
+ 0x0E, //F
+ 0x10, //10
+ 0x10, //11
+ 0x12, //12
+ 0x12, //13
+ 0x14, //14
+ 0x14, //15
+ 0x16, //16
+ 0x16, //17
+ 0x18, //18
+ 0x18, //19
+ 0x1A, //1A
+ 0x1A, //1B
+ 0x1C, //1C
+ 0x1C, //1D
+ 0x1E, //1E
+ 0x1E, //1F
+ 0x20, //20
+ 0x20, //21
+ 0x22, //22
+ 0x22, //23
+ 0x24, //24
+ 0x24, //25
+ 0x26, //26
+ 0x26, //27
+ 0x28, //28
+ 0x28, //29
+ 0x2A, //2A
+ 0x2A, //2B
+ 0x2C, //2C
+ 0x2C, //2D
+ 0x2E, //2E
+ 0x2E, //2F
+ 0x30, //30
+ 0x30, //31
+ 0x32, //32
+ 0x32, //33
+ 0x34, //34
+ 0x34, //35
+ 0x36, //36
+ 0x36, //37
+ 0x38, //38
+ 0x38, //39
+ 0x3A, //3A
+ 0x3A, //3B
+ 0x3C, //3C
+ 0x3C, //3D
+ 0x3E, //3E
+ 0x3E //3F
+};
+
+
+BYTE abyVT3184_AL2230[] = {
+ 0x31,//00
+ 0x00,
+ 0x00,
+ 0x00,
+ 0x00,
+ 0x80,
+ 0x00,
+ 0x00,
+ 0x70,
+ 0x45,//tx //0x64 for FPGA
+ 0x2A,
+ 0x76,
+ 0x00,
+ 0x00,
+ 0x80,
+ 0x00,
+ 0x00,//10
+ 0x00,
+ 0x00,
+ 0x00,
+ 0x00,
+ 0x00,
+ 0x00,
+ 0x00,
+ 0x00,
+ 0x00,
+ 0x00,
+ 0x8e, //RobertYu:20060522, //0x8d,
+ 0x0a, //RobertYu:20060515, //0x09,
+ 0x00,
+ 0x00,
+ 0x00,
+ 0x00,//20
+ 0x00,
+ 0x00,
+ 0x00,
+ 0x00,
+ 0x4a,
+ 0x00,
+ 0x00,
+ 0x00,
+ 0x00,
+ 0x00,
+ 0x00,
+ 0x00,
+ 0x4a,
+ 0x00,
+ 0x0c, //RobertYu:20060522, //0x10,
+ 0x26,//30
+ 0x5b,
+ 0x00,
+ 0x00,
+ 0x00,
+ 0x00,
+ 0xaa,
+ 0xaa,
+ 0xff,
+ 0xff,
+ 0x79,
+ 0x00,
+ 0x00,
+ 0x0b,
+ 0x48,
+ 0x04,
+ 0x00,//40
+ 0x08,
+ 0x00,
+ 0x08,
+ 0x08,
+ 0x14,
+ 0x05,
+ 0x09,
+ 0x00,
+ 0x00,
+ 0x00,
+ 0x00,
+ 0x09,
+ 0x73,
+ 0x00,
+ 0xc5,
+ 0x00,//50 //RobertYu:20060505, //0x15,//50
+ 0x19,
+ 0x00,
+ 0x00,
+ 0x00,
+ 0x00,
+ 0x00,
+ 0x00,
+ 0x00,
+ 0xd0, //RobertYu:20060505, //0xb0,
+ 0x00,
+ 0x00,
+ 0x00,
+ 0x00,
+ 0x00,
+ 0x00,
+ 0xe4,//60
+ 0x80,
+ 0x00,
+ 0x00,
+ 0x00,
+ 0x00,
+ 0x98,
+ 0x0a,
+ 0x00,
+ 0x00,
+ 0x00,
+ 0x00,
+ 0x00, //0x80 for FPGA
+ 0x03,
+ 0x01,
+ 0x00,
+ 0x00,//70
+ 0x00,
+ 0x00,
+ 0x00,
+ 0x00,
+ 0x00,
+ 0x00,
+ 0x00,
+ 0x00,
+ 0x00,
+ 0x00,
+ 0x00,
+ 0x00,
+ 0x00,
+ 0x00,
+ 0x00,
+ 0x8c,//80
+ 0x01,
+ 0x09,
+ 0x00,
+ 0x00,
+ 0x00,
+ 0x00,
+ 0x00,
+ 0x08,
+ 0x00,
+ 0x1f, //RobertYu:20060516, //0x0f,
+ 0xb7,
+ 0x88,
+ 0x47,
+ 0xaa,
+ 0x00, //RobertYu:20060505, //0x02,
+ 0x20,//90 //RobertYu:20060505, //0x22,//90
+ 0x00,
+ 0x00,
+ 0x00,
+ 0x00,
+ 0x00,
+ 0x00,
+ 0xeb,
+ 0x00,
+ 0x00,
+ 0x00,
+ 0x00,
+ 0x00,
+ 0x00,
+ 0x00,
+ 0x01,
+ 0x00,//a0
+ 0x00,
+ 0x00,
+ 0x00,
+ 0x00,
+ 0x00,
+ 0x10,
+ 0x00,
+ 0x18,
+ 0x00,
+ 0x00,
+ 0x00,
+ 0x00,
+ 0x15, //RobertYu:20060516, //0x00,
+ 0x00,
+ 0x18,
+ 0x38,//b0
+ 0x30,
+ 0x00,
+ 0x00,
+ 0xff,
+ 0x0f,
+ 0xe4,
+ 0xe2,
+ 0x00,
+ 0x00,
+ 0x00,
+ 0x03,
+ 0x01,
+ 0x00,
+ 0x00,
+ 0x00,
+ 0x18,//c0
+ 0x20,
+ 0x07,
+ 0x18,
+ 0xff,
+ 0xff, //RobertYu:20060509, //0x2c,
+ 0x0e, //RobertYu:20060530, //0x0c,
+ 0x0a,
+ 0x0e,
+ 0x00, //RobertYu:20060505, //0x01,
+ 0x82, //RobertYu:20060516, //0x8f,
+ 0xa7,
+ 0x3c,
+ 0x10,
+ 0x30, //RobertYu:20060627, //0x0b,
+ 0x05, //RobertYu:20060516, //0x25,
+ 0x40,//d0
+ 0x12,
+ 0x00,
+ 0x00,
+ 0x10,
+ 0x28,
+ 0x80,
+ 0x2A,
+ 0x00,
+ 0x00,
+ 0x00,
+ 0x00,
+ 0x00,
+ 0x00,
+ 0x00,
+ 0x00,
+ 0x00,//e0
+ 0xf3, //RobertYu:20060516, //0xd3,
+ 0x00,
+ 0x00,
+ 0x00,
+ 0x10,
+ 0x00,
+ 0x12, //RobertYu:20060627, //0x10,
+ 0x00,
+ 0xf4,
+ 0x00,
+ 0xff,
+ 0x79,
+ 0x20,
+ 0x30,
+ 0x05, //RobertYu:20060516, //0x0c,
+ 0x00,//f0
+ 0x3e,
+ 0x00,
+ 0x00,
+ 0x00,
+ 0x00,
+ 0x00,
+ 0x00,
+ 0x00,
+ 0x00,
+ 0x00,
+ 0x00,
+ 0x00,
+ 0x00,
+ 0x00,
+ 0x00
+};
+
+
+
+//{{RobertYu:20060515, new BB setting for VT3226D0
+BYTE abyVT3184_VT3226D0[] = {
+ 0x31,//00
+ 0x00,
+ 0x00,
+ 0x00,
+ 0x00,
+ 0x80,
+ 0x00,
+ 0x00,
+ 0x70,
+ 0x45,//tx //0x64 for FPGA
+ 0x2A,
+ 0x76,
+ 0x00,
+ 0x00,
+ 0x80,
+ 0x00,
+ 0x00,//10
+ 0x00,
+ 0x00,
+ 0x00,
+ 0x00,
+ 0x00,
+ 0x00,
+ 0x00,
+ 0x00,
+ 0x00,
+ 0x00,
+ 0x8e, //RobertYu:20060525, //0x8d,
+ 0x0a, //RobertYu:20060515, //0x09,
+ 0x00,
+ 0x00,
+ 0x00,
+ 0x00,//20
+ 0x00,
+ 0x00,
+ 0x00,
+ 0x00,
+ 0x4a,
+ 0x00,
+ 0x00,
+ 0x00,
+ 0x00,
+ 0x00,
+ 0x00,
+ 0x00,
+ 0x4a,
+ 0x00,
+ 0x0c, //RobertYu:20060525, //0x10,
+ 0x26,//30
+ 0x5b,
+ 0x00,
+ 0x00,
+ 0x00,
+ 0x00,
+ 0xaa,
+ 0xaa,
+ 0xff,
+ 0xff,
+ 0x79,
+ 0x00,
+ 0x00,
+ 0x0b,
+ 0x48,
+ 0x04,
+ 0x00,//40
+ 0x08,
+ 0x00,
+ 0x08,
+ 0x08,
+ 0x14,
+ 0x05,
+ 0x09,
+ 0x00,
+ 0x00,
+ 0x00,
+ 0x00,
+ 0x09,
+ 0x73,
+ 0x00,
+ 0xc5,
+ 0x00,//50 //RobertYu:20060505, //0x15,//50
+ 0x19,
+ 0x00,
+ 0x00,
+ 0x00,
+ 0x00,
+ 0x00,
+ 0x00,
+ 0x00,
+ 0xd0, //RobertYu:20060505, //0xb0,
+ 0x00,
+ 0x00,
+ 0x00,
+ 0x00,
+ 0x00,
+ 0x00,
+ 0xe4,//60
+ 0x80,
+ 0x00,
+ 0x00,
+ 0x00,
+ 0x00,
+ 0x98,
+ 0x0a,
+ 0x00,
+ 0x00,
+ 0x00,
+ 0x00,
+ 0x00, //0x80 for FPGA
+ 0x03,
+ 0x01,
+ 0x00,
+ 0x00,//70
+ 0x00,
+ 0x00,
+ 0x00,
+ 0x00,
+ 0x00,
+ 0x00,
+ 0x00,
+ 0x00,
+ 0x00,
+ 0x00,
+ 0x00,
+ 0x00,
+ 0x00,
+ 0x00,
+ 0x00,
+ 0x8c,//80
+ 0x01,
+ 0x09,
+ 0x00,
+ 0x00,
+ 0x00,
+ 0x00,
+ 0x00,
+ 0x08,
+ 0x00,
+ 0x1f, //RobertYu:20060515, //0x0f,
+ 0xb7,
+ 0x88,
+ 0x47,
+ 0xaa,
+ 0x00, //RobertYu:20060505, //0x02,
+ 0x20,//90 //RobertYu:20060505, //0x22,//90
+ 0x00,
+ 0x00,
+ 0x00,
+ 0x00,
+ 0x00,
+ 0x00,
+ 0xeb,
+ 0x00,
+ 0x00,
+ 0x00,
+ 0x00,
+ 0x00,
+ 0x00,
+ 0x00,
+ 0x01,
+ 0x00,//a0
+ 0x00,
+ 0x00,
+ 0x00,
+ 0x00,
+ 0x00,
+ 0x10,
+ 0x00,
+ 0x18,
+ 0x00,
+ 0x00,
+ 0x00,
+ 0x00,
+ 0x00,
+ 0x00,
+ 0x18,
+ 0x38,//b0
+ 0x30,
+ 0x00,
+ 0x00,
+ 0xff,
+ 0x0f,
+ 0xe4,
+ 0xe2,
+ 0x00,
+ 0x00,
+ 0x00,
+ 0x03,
+ 0x01,
+ 0x00,
+ 0x00,
+ 0x00,
+ 0x18,//c0
+ 0x20,
+ 0x07,
+ 0x18,
+ 0xff,
+ 0xff, //RobertYu:20060509, //0x2c,
+ 0x10, //RobertYu:20060525, //0x0c,
+ 0x0a,
+ 0x0e,
+ 0x00, //RobertYu:20060505, //0x01,
+ 0x84, //RobertYu:20060525, //0x8f,
+ 0xa7,
+ 0x3c,
+ 0x10,
+ 0x24, //RobertYu:20060627, //0x18,
+ 0x05, //RobertYu:20060515, //0x25,
+ 0x40,//d0
+ 0x12,
+ 0x00,
+ 0x00,
+ 0x10,
+ 0x28,
+ 0x80,
+ 0x2A,
+ 0x00,
+ 0x00,
+ 0x00,
+ 0x00,
+ 0x00,
+ 0x00,
+ 0x00,
+ 0x00,
+ 0x00,//e0
+ 0xf3, //RobertYu:20060515, //0xd3,
+ 0x00,
+ 0x00,
+ 0x00,
+ 0x10,
+ 0x00,
+ 0x10, //RobertYu:20060627, //0x0e,
+ 0x00,
+ 0xf4,
+ 0x00,
+ 0xff,
+ 0x79,
+ 0x20,
+ 0x30,
+ 0x08, //RobertYu:20060515, //0x0c,
+ 0x00,//f0
+ 0x3e,
+ 0x00,
+ 0x00,
+ 0x00,
+ 0x00,
+ 0x00,
+ 0x00,
+ 0x00,
+ 0x00,
+ 0x00,
+ 0x00,
+ 0x00,
+ 0x00,
+ 0x00,
+ 0x00,
+};
+
+const WORD awcFrameTime[MAX_RATE] =
+{10, 20, 55, 110, 24, 36, 48, 72, 96, 144, 192, 216};
+
+/*--------------------- Static Functions --------------------------*/
+
+/*
+static
+ULONG
+s_ulGetLowSQ3(PSDevice pDevice);
+
+static
+ULONG
+s_ulGetRatio(PSDevice pDevice);
+
+static
+void
+s_vClearSQ3Value(PSDevice pDevice);
+*/
+
+/*--------------------- 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) {
+ ASSERT(0);
+ 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: Set Antenna mode
+ *
+ * Parameters:
+ * In:
+ * pDevice - Device Structure
+ * byAntennaMode - Antenna Mode
+ * Out:
+ * none
+ *
+ * Return Value: none
+ *
+ */
+VOID
+BBvSetAntennaMode (PSDevice pDevice, BYTE byAntennaMode)
+{
+ //{{ RobertYu: 20041124, ABG Mode, VC1/VC2 define, make the ANT_A, ANT_B inverted
+ /*if ( (pDevice->byRFType == RF_MAXIM2829) ||
+ (pDevice->byRFType == RF_UW2452) ||
+ (pDevice->byRFType == RF_AIROHA7230) ) { // RobertYu: 20041210, 20050104
+
+ switch (byAntennaMode) {
+ case ANT_TXA:
+ byAntennaMode = ANT_TXB;
+ break;
+ case ANT_TXB:
+ byAntennaMode = ANT_TXA;
+ break;
+ case ANT_RXA:
+ byAntennaMode = ANT_RXB;
+ break;
+ case ANT_RXB:
+ byAntennaMode = ANT_RXA;
+ break;
+ }
+ }*/
+
+ switch (byAntennaMode) {
+ case ANT_TXA:
+ break;
+ case ANT_TXB:
+ break;
+ case ANT_RXA:
+ pDevice->byBBRxConf &= 0xFC;
+ break;
+ case ANT_RXB:
+ pDevice->byBBRxConf &= 0xFE;
+ pDevice->byBBRxConf |= 0x02;;
+ break;
+ }
+
+
+ CONTROLnsRequestOut(pDevice,
+ MESSAGE_TYPE_SET_ANTMD,
+ (WORD) byAntennaMode,
+ 0,
+ 0,
+ NULL);
+}
+
+/*
+ * Description: Set Antenna mode
+ *
+ * Parameters:
+ * In:
+ * pDevice - Device Structure
+ * byAntennaMode - Antenna Mode
+ * Out:
+ * none
+ *
+ * Return Value: none
+ *
+ */
+BOOL
+BBbVT3184Init (PSDevice pDevice)
+{
+ NTSTATUS ntStatus;
+ WORD wLength;
+ PBYTE pbyAddr;
+ PBYTE pbyAgc;
+ WORD wLengthAgc;
+ BYTE abyArray[256];
+
+ ntStatus = CONTROLnsRequestIn(pDevice,
+ MESSAGE_TYPE_READ,
+ 0,
+ MESSAGE_REQUEST_EEPROM,
+ EEP_MAX_CONTEXT_SIZE,
+ pDevice->abyEEPROM);
+ if (ntStatus != STATUS_SUCCESS) {
+ return FALSE;
+ }
+
+
+ //20080215-01,<Add> by Mike Liu
+// if ((pDevice->abyEEPROM[EEP_OFS_RADIOCTL]&0x06)==0x04)
+// return FALSE;
+
+//20080804-01,<Add> by Mike Liu
+//zonetype initial
+ pDevice->byOriginalZonetype = pDevice->abyEEPROM[EEP_OFS_ZONETYPE];
+ if(pDevice->config_file.ZoneType >= 0) { //read zonetype file ok!
+ if ((pDevice->config_file.ZoneType == 0)&&
+ (pDevice->abyEEPROM[EEP_OFS_ZONETYPE] !=0x00)){ //for USA
+ pDevice->abyEEPROM[EEP_OFS_ZONETYPE] = 0;
+ pDevice->abyEEPROM[EEP_OFS_MAXCHANNEL] = 0x0B;
+ DBG_PRT(MSG_LEVEL_DEBUG, KERN_INFO"Init Zone Type :USA\n");
+ }
+ else if((pDevice->config_file.ZoneType == 1)&&
+ (pDevice->abyEEPROM[EEP_OFS_ZONETYPE]!=0x01)){ //for Japan
+ pDevice->abyEEPROM[EEP_OFS_ZONETYPE] = 0x01;
+ pDevice->abyEEPROM[EEP_OFS_MAXCHANNEL] = 0x0D;
+ DBG_PRT(MSG_LEVEL_DEBUG, KERN_INFO"Init Zone Type :Japan\n");
+ }
+ else if((pDevice->config_file.ZoneType == 2)&&
+ (pDevice->abyEEPROM[EEP_OFS_ZONETYPE]!=0x02)){ //for Europe
+ pDevice->abyEEPROM[EEP_OFS_ZONETYPE] = 0x02;
+ pDevice->abyEEPROM[EEP_OFS_MAXCHANNEL] = 0x0D;
+ DBG_PRT(MSG_LEVEL_DEBUG, KERN_INFO"Init Zone Type :Europe\n");
+ }
+else {
+ if(pDevice->config_file.ZoneType !=pDevice->abyEEPROM[EEP_OFS_ZONETYPE])
+ printk("zonetype in file[%02x] mismatch with in EEPROM[%02x]\n",pDevice->config_file.ZoneType,pDevice->abyEEPROM[EEP_OFS_ZONETYPE]);
+ else
+ printk("Read Zonetype file sucess,use default zonetype setting[%02x]\n",pDevice->config_file.ZoneType);
+ }
+}
+
+ if ( !pDevice->bZoneRegExist ) {
+ pDevice->byZoneType = pDevice->abyEEPROM[EEP_OFS_ZONETYPE];
+ }
+ pDevice->byRFType = pDevice->abyEEPROM[EEP_OFS_RFTYPE];
+
+ DBG_PRT(MSG_LEVEL_DEBUG, KERN_INFO"Zone Type %x\n", pDevice->byZoneType);
+ DBG_PRT(MSG_LEVEL_DEBUG, KERN_INFO"RF Type %d\n", pDevice->byRFType);
+
+ if ((pDevice->byRFType == RF_AL2230) || (pDevice->byRFType == RF_AL2230S)) {
+ pDevice->byBBRxConf = abyVT3184_AL2230[10];
+ wLength = sizeof(abyVT3184_AL2230);
+ pbyAddr = abyVT3184_AL2230;
+ pbyAgc = abyVT3184_AGC;
+ wLengthAgc = sizeof(abyVT3184_AGC);
+
+ 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 (pDevice->byRFType == RF_AIROHA7230) {
+ pDevice->byBBRxConf = abyVT3184_AL2230[10];
+ wLength = sizeof(abyVT3184_AL2230);
+ pbyAddr = abyVT3184_AL2230;
+ pbyAgc = abyVT3184_AGC;
+ wLengthAgc = sizeof(abyVT3184_AGC);
+
+ // Init ANT B select,TX Config CR09 = 0x61->0x45, 0x45->0x41(VC1/VC2 define, make the ANT_A, ANT_B inverted)
+ //pbyAddr[0x09] = 0x41;
+ // Init ANT B select,RX Config CR10 = 0x28->0x2A, 0x2A->0x28(VC1/VC2 define, make the ANT_A, ANT_B inverted)
+ //pbyAddr[0x0a] = 0x28;
+ // Select VC1/VC2, CR215 = 0x02->0x06
+ pbyAddr[0xd7] = 0x06;
+
+ 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 ( (pDevice->byRFType == RF_VT3226) || (pDevice->byRFType == RF_VT3226D0) ) {
+ pDevice->byBBRxConf = abyVT3184_VT3226D0[10]; //RobertYu:20060515
+ wLength = sizeof(abyVT3184_VT3226D0); //RobertYu:20060515
+ pbyAddr = abyVT3184_VT3226D0; //RobertYu:20060515
+ pbyAgc = abyVT3184_AGC;
+ wLengthAgc = sizeof(abyVT3184_AGC);
+
+ pDevice->abyBBVGA[0] = 0x20; //RobertYu:20060104, reguest by Jack
+ 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
+ MACvRegBitsOn(pDevice, MAC_REG_SOFTPWRCTL2, SOFTPWRCTL_RFLEOPT);
+ //}}
+ //{{RobertYu:20060609
+ } else if ( (pDevice->byRFType == RF_VT3342A0) ) {
+ pDevice->byBBRxConf = abyVT3184_VT3226D0[10];
+ wLength = sizeof(abyVT3184_VT3226D0);
+ pbyAddr = abyVT3184_VT3226D0;
+ pbyAgc = abyVT3184_AGC;
+ wLengthAgc = sizeof(abyVT3184_AGC);
+
+ pDevice->abyBBVGA[0] = 0x20;
+ 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
+ MACvRegBitsOn(pDevice, MAC_REG_SOFTPWRCTL2, SOFTPWRCTL_RFLEOPT);
+ //}}
+ } else {
+ return TRUE;
+ }
+
+ memcpy(abyArray, pbyAddr, wLength);
+ CONTROLnsRequestOut(pDevice,
+ MESSAGE_TYPE_WRITE,
+ 0,
+ MESSAGE_REQUEST_BBREG,
+ wLength,
+ abyArray
+ );
+
+ memcpy(abyArray, pbyAgc, wLengthAgc);
+ CONTROLnsRequestOut(pDevice,
+ MESSAGE_TYPE_WRITE,
+ 0,
+ MESSAGE_REQUEST_BBAGC,
+ wLengthAgc,
+ abyArray
+ );
+
+
+ if ((pDevice->byRFType == RF_VT3226) || //RobertYu:20051116, 20060111 remove VT3226D0
+ (pDevice->byRFType == RF_VT3342A0) //RobertYu:20060609
+ ) {
+ ControlvWriteByte(pDevice,MESSAGE_REQUEST_MACREG,MAC_REG_ITRTMSET,0x23);
+ MACvRegBitsOn(pDevice,MAC_REG_PAPEDELAY,0x01);
+ }
+ else if (pDevice->byRFType == RF_VT3226D0)
+ {
+ ControlvWriteByte(pDevice,MESSAGE_REQUEST_MACREG,MAC_REG_ITRTMSET,0x11);
+ MACvRegBitsOn(pDevice,MAC_REG_PAPEDELAY,0x01);
+ }
+
+
+ ControlvWriteByte(pDevice,MESSAGE_REQUEST_BBREG,0x04,0x7F);
+ ControlvWriteByte(pDevice,MESSAGE_REQUEST_BBREG,0x0D,0x01);
+
+ RFbRFTableDownload(pDevice);
+ return TRUE;//ntStatus;
+}
+
+
+/*
+ * Description: Turn on BaseBand Loopback mode
+ *
+ * Parameters:
+ * In:
+ * pDevice - Device Structure
+ *
+ * Out:
+ * none
+ *
+ * Return Value: none
+ *
+ */
+void BBvLoopbackOn (PSDevice pDevice)
+{
+ BYTE byData;
+
+ //CR C9 = 0x00
+ ControlvReadByte (pDevice, MESSAGE_REQUEST_BBREG, 0xC9, &pDevice->byBBCRc9);//CR201
+ ControlvWriteByte(pDevice, MESSAGE_REQUEST_BBREG, 0xC9, 0);
+ ControlvReadByte (pDevice, MESSAGE_REQUEST_BBREG, 0x4D, &pDevice->byBBCR4d);//CR77
+ ControlvWriteByte(pDevice, MESSAGE_REQUEST_BBREG, 0x4D, 0x90);
+
+ //CR 88 = 0x02(CCK), 0x03(OFDM)
+ ControlvReadByte (pDevice, MESSAGE_REQUEST_BBREG, 0x88, &pDevice->byBBCR88);//CR136
+
+ if (pDevice->wCurrentRate <= RATE_11M) { //CCK
+ // Enable internal digital loopback: CR33 |= 0000 0001
+ ControlvReadByte (pDevice, MESSAGE_REQUEST_BBREG, 0x21, &byData);//CR33
+ ControlvWriteByte(pDevice, MESSAGE_REQUEST_BBREG, 0x21, (BYTE)(byData | 0x01));//CR33
+ // CR154 = 0x00
+ ControlvWriteByte(pDevice, MESSAGE_REQUEST_BBREG, 0x9A, 0); //CR154
+
+ ControlvWriteByte(pDevice, MESSAGE_REQUEST_BBREG, 0x88, 0x02);//CR239
+ }
+ else { //OFDM
+ // Enable internal digital loopback:CR154 |= 0000 0001
+ ControlvReadByte (pDevice, MESSAGE_REQUEST_BBREG, 0x9A, &byData);//CR154
+ ControlvWriteByte(pDevice, MESSAGE_REQUEST_BBREG, 0x9A, (BYTE)(byData | 0x01));//CR154
+ // CR33 = 0x00
+ ControlvWriteByte(pDevice, MESSAGE_REQUEST_BBREG, 0x21, 0); //CR33
+
+ ControlvWriteByte(pDevice, MESSAGE_REQUEST_BBREG, 0x88, 0x03);//CR239
+ }
+
+ //CR14 = 0x00
+ ControlvWriteByte(pDevice, MESSAGE_REQUEST_BBREG, 0x0E, 0);//CR14
+
+ // Disable TX_IQUN
+ ControlvReadByte (pDevice, MESSAGE_REQUEST_BBREG, 0x09, &pDevice->byBBCR09);
+ ControlvWriteByte(pDevice, MESSAGE_REQUEST_BBREG, 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;
+
+ ControlvWriteByte(pDevice, MESSAGE_REQUEST_BBREG, 0xC9, pDevice->byBBCRc9);//CR201
+ ControlvWriteByte(pDevice, MESSAGE_REQUEST_BBREG, 0x88, pDevice->byBBCR88);//CR136
+ ControlvWriteByte(pDevice, MESSAGE_REQUEST_BBREG, 0x09, pDevice->byBBCR09);//CR136
+ ControlvWriteByte(pDevice, MESSAGE_REQUEST_BBREG, 0x4D, pDevice->byBBCR4d);//CR77
+
+ if (pDevice->wCurrentRate <= RATE_11M) { // CCK
+ // Set the CR33 Bit2 to disable internal Loopback.
+ ControlvReadByte (pDevice, MESSAGE_REQUEST_BBREG, 0x21, &byData);//CR33
+ ControlvWriteByte(pDevice, MESSAGE_REQUEST_BBREG, 0x21, (BYTE)(byData & 0xFE));//CR33
+ }
+ else { // OFDM
+ ControlvReadByte (pDevice, MESSAGE_REQUEST_BBREG, 0x9A, &byData);//CR154
+ ControlvWriteByte(pDevice, MESSAGE_REQUEST_BBREG, 0x9A, (BYTE)(byData & 0xFE));//CR154
+ }
+ ControlvReadByte (pDevice, MESSAGE_REQUEST_BBREG, 0x0E, &byData);//CR14
+ ControlvWriteByte(pDevice, MESSAGE_REQUEST_BBREG, 0x0E, (BYTE)(byData | 0x80));//CR14
+
+}
+
+
+/*
+ * Description: Set ShortSlotTime mode
+ *
+ * Parameters:
+ * In:
+ * pDevice - Device Structure
+ * Out:
+ * none
+ *
+ * Return Value: none
+ *
+ */
+VOID
+BBvSetShortSlotTime (PSDevice pDevice)
+{
+ BYTE byBBVGA=0;
+
+ if (pDevice->bShortSlotTime) {
+ pDevice->byBBRxConf &= 0xDF;//1101 1111
+ } else {
+ pDevice->byBBRxConf |= 0x20;//0010 0000
+ }
+
+ ControlvReadByte (pDevice, MESSAGE_REQUEST_BBREG, 0xE7, &byBBVGA);
+ if (byBBVGA == pDevice->abyBBVGA[0]) {
+ pDevice->byBBRxConf |= 0x20;//0010 0000
+ }
+
+ ControlvWriteByte(pDevice, MESSAGE_REQUEST_BBREG, 0x0A, pDevice->byBBRxConf);
+
+}
+
+
+VOID BBvSetVGAGainOffset(PSDevice pDevice, BYTE byData)
+{
+
+ ControlvWriteByte(pDevice, MESSAGE_REQUEST_BBREG, 0xE7, byData);
+
+ // patch for 3253B0 Baseband with Cardbus module
+ if (byData == pDevice->abyBBVGA[0]) {
+ pDevice->byBBRxConf |= 0x20;//0010 0000
+ } else if (pDevice->bShortSlotTime) {
+ pDevice->byBBRxConf &= 0xDF;//1101 1111
+ } else {
+ pDevice->byBBRxConf |= 0x20;//0010 0000
+ }
+ ControlvWriteByte(pDevice, MESSAGE_REQUEST_BBREG, 0x0A, pDevice->byBBRxConf);//CR10
+}
+
+
+/*
+ * Description: Baseband SoftwareReset
+ *
+ * Parameters:
+ * In:
+ * dwIoBase - I/O base address
+ * Out:
+ * none
+ *
+ * Return Value: none
+ *
+ */
+VOID
+BBvSoftwareReset (PSDevice pDevice)
+{
+ ControlvWriteByte(pDevice, MESSAGE_REQUEST_BBREG, 0x50, 0x40);
+ ControlvWriteByte(pDevice, MESSAGE_REQUEST_BBREG, 0x50, 0);
+ ControlvWriteByte(pDevice, MESSAGE_REQUEST_BBREG, 0x9C, 0x01);
+ ControlvWriteByte(pDevice, MESSAGE_REQUEST_BBREG, 0x9C, 0);
+}
+
+/*
+ * Description: BBvSetDeepSleep
+ *
+ * Parameters:
+ * In:
+ * pDevice - Device Structure
+ * Out:
+ * none
+ *
+ * Return Value: none
+ *
+ */
+VOID
+BBvSetDeepSleep (PSDevice pDevice)
+{
+ ControlvWriteByte(pDevice, MESSAGE_REQUEST_BBREG, 0x0c, 0x17);//CR12
+ ControlvWriteByte(pDevice, MESSAGE_REQUEST_BBREG, 0x0D, 0xB9);//CR13
+}
+
+VOID
+BBvExitDeepSleep (PSDevice pDevice)
+{
+ ControlvWriteByte(pDevice, MESSAGE_REQUEST_BBREG, 0x0C, 0x00);//CR12
+ ControlvWriteByte(pDevice, MESSAGE_REQUEST_BBREG, 0x0D, 0x01);//CR13
+}
+
+
+static
+ULONG
+s_ulGetLowSQ3(PSDevice pDevice)
+{
+int ii;
+ULONG ulSQ3 = 0;
+ULONG ulMaxPacket;
+
+ ulMaxPacket = pDevice->aulPktNum[RATE_54M];
+ if ( pDevice->aulPktNum[RATE_54M] != 0 ) {
+ ulSQ3 = pDevice->aulSQ3Val[RATE_54M] / pDevice->aulPktNum[RATE_54M];
+ }
+ for ( ii=RATE_48M;ii>=RATE_6M;ii-- ) {
+ if ( pDevice->aulPktNum[ii] > ulMaxPacket ) {
+ ulMaxPacket = pDevice->aulPktNum[ii];
+ ulSQ3 = pDevice->aulSQ3Val[ii] / pDevice->aulPktNum[ii];
+ }
+ }
+
+ return ulSQ3;
+}
+
+
+
+static
+ULONG
+s_ulGetRatio (PSDevice pDevice)
+{
+int ii,jj;
+ULONG ulRatio = 0;
+ULONG ulMaxPacket;
+ULONG ulPacketNum;
+
+ //This is a thousand-ratio
+ ulMaxPacket = pDevice->aulPktNum[RATE_54M];
+ if ( pDevice->aulPktNum[RATE_54M] != 0 ) {
+ ulPacketNum = pDevice->aulPktNum[RATE_54M];
+ ulRatio = (ulPacketNum * 1000 / pDevice->uDiversityCnt);
+ ulRatio += TOP_RATE_54M;
+ }
+ for ( ii=RATE_48M;ii>=RATE_1M;ii-- ) {
+ if ( pDevice->aulPktNum[ii] > ulMaxPacket ) {
+ ulPacketNum = 0;
+ for ( jj=RATE_54M;jj>=ii;jj--)
+ ulPacketNum += pDevice->aulPktNum[jj];
+ ulRatio = (ulPacketNum * 1000 / pDevice->uDiversityCnt);
+ ulRatio += TOP_RATE_48M;
+ ulMaxPacket = pDevice->aulPktNum[ii];
+ }
+
+ }
+
+ return ulRatio;
+}
+
+
+static
+void
+s_vClearSQ3Value (PSDevice pDevice)
+{
+ int ii;
+ pDevice->uDiversityCnt = 0;
+
+ for ( ii=RATE_1M;ii<MAX_RATE;ii++) {
+ pDevice->aulPktNum[ii] = 0;
+ pDevice->aulSQ3Val[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)
+{
+
+ pDevice->uDiversityCnt++;
+ DBG_PRT(MSG_LEVEL_DEBUG, KERN_INFO"pDevice->uDiversityCnt = %d\n", (int)pDevice->uDiversityCnt);
+
+ if (byRxRate == 2) {
+ pDevice->aulPktNum[RATE_1M]++;
+ }
+ else if (byRxRate==4) {
+ pDevice->aulPktNum[RATE_2M]++;
+ }
+ else if (byRxRate==11) {
+ pDevice->aulPktNum[RATE_5M]++;
+ }
+ else if (byRxRate==22) {
+ pDevice->aulPktNum[RATE_11M]++;
+ }
+ else if(byRxRate==12){
+ pDevice->aulPktNum[RATE_6M]++;
+ pDevice->aulSQ3Val[RATE_6M] += bySQ3;
+ }
+ else if(byRxRate==18){
+ pDevice->aulPktNum[RATE_9M]++;
+ pDevice->aulSQ3Val[RATE_9M] += bySQ3;
+ }
+ else if(byRxRate==24){
+ pDevice->aulPktNum[RATE_12M]++;
+ pDevice->aulSQ3Val[RATE_12M] += bySQ3;
+ }
+ else if(byRxRate==36){
+ pDevice->aulPktNum[RATE_18M]++;
+ pDevice->aulSQ3Val[RATE_18M] += bySQ3;
+ }
+ else if(byRxRate==48){
+ pDevice->aulPktNum[RATE_24M]++;
+ pDevice->aulSQ3Val[RATE_24M] += bySQ3;
+ }
+ else if(byRxRate==72){
+ pDevice->aulPktNum[RATE_36M]++;
+ pDevice->aulSQ3Val[RATE_36M] += bySQ3;
+ }
+ else if(byRxRate==96){
+ pDevice->aulPktNum[RATE_48M]++;
+ pDevice->aulSQ3Val[RATE_48M] += bySQ3;
+ }
+ else if(byRxRate==108){
+ pDevice->aulPktNum[RATE_54M]++;
+ pDevice->aulSQ3Val[RATE_54M] += bySQ3;
+ }
+
+ if (pDevice->byAntennaState == 0) {
+
+ if (pDevice->uDiversityCnt > pDevice->ulDiversityNValue) {
+ DBG_PRT(MSG_LEVEL_DEBUG, KERN_INFO"ulDiversityNValue=[%d],54M-[%d]\n",(int)pDevice->ulDiversityNValue, (int)pDevice->aulPktNum[RATE_54M]);
+
+ pDevice->ulSQ3_State0 = s_ulGetLowSQ3(pDevice);
+ pDevice->ulRatio_State0 = s_ulGetRatio(pDevice);
+ DBG_PRT(MSG_LEVEL_DEBUG, KERN_INFO"SQ3_State0, SQ3= [%08x] rate = [%08x]\n",(int)pDevice->ulSQ3_State0,(int)pDevice->ulRatio_State0);
+
+ if ( ((pDevice->aulPktNum[RATE_54M] < pDevice->ulDiversityNValue/2) &&
+ (pDevice->ulSQ3_State0 > pDevice->ulSQ3TH) ) ||
+ (pDevice->ulSQ3_State0 == 0 ) ) {
+
+ if ( pDevice->byTMax == 0 )
+ return;
+
+ bScheduleCommand((HANDLE) pDevice, WLAN_CMD_CHANGE_ANTENNA, NULL);
+
+ 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);
+ }
+ s_vClearSQ3Value(pDevice);
+
+ }
+ } else { //byAntennaState == 1
+
+ if (pDevice->uDiversityCnt > pDevice->ulDiversityMValue) {
+
+ del_timer(&pDevice->TimerSQ3Tmax1);
+ pDevice->ulSQ3_State1 = s_ulGetLowSQ3(pDevice);
+ pDevice->ulRatio_State1 = s_ulGetRatio(pDevice);
+ DBG_PRT(MSG_LEVEL_DEBUG, KERN_INFO"SQ3_State1, rate0 = %08x,rate1 = %08x\n",(int)pDevice->ulRatio_State0,(int)pDevice->ulRatio_State1);
+
+ if ( ((pDevice->ulSQ3_State1 == 0) && (pDevice->ulSQ3_State0 != 0)) ||
+ ((pDevice->ulSQ3_State1 == 0) && (pDevice->ulSQ3_State0 == 0) && (pDevice->ulRatio_State1 < pDevice->ulRatio_State0)) ||
+ ((pDevice->ulSQ3_State1 != 0) && (pDevice->ulSQ3_State0 != 0) && (pDevice->ulSQ3_State0 < pDevice->ulSQ3_State1))
+ ) {
+
+ bScheduleCommand((HANDLE) pDevice, WLAN_CMD_CHANGE_ANTENNA, NULL);
+
+ 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;
+ s_vClearSQ3Value(pDevice);
+ }
+ } //byAntennaState
+}
+
+
+/*+
+ *
+ * Description:
+ * Timer for SQ3 antenna diversity
+ *
+ * Parameters:
+ * In:
+ * pvSysSpec1
+ * hDeviceContext - Pointer to the adapter
+ * pvSysSpec2
+ * pvSysSpec3
+ * Out:
+ * none
+ *
+ * Return Value: none
+ *
+-*/
+
+VOID
+TimerSQ3CallBack (
+ IN HANDLE hDeviceContext
+ )
+{
+ PSDevice pDevice = (PSDevice)hDeviceContext;
+
+ DBG_PRT(MSG_LEVEL_DEBUG, KERN_INFO"TimerSQ3CallBack...");
+ spin_lock_irq(&pDevice->lock);
+
+ bScheduleCommand((HANDLE) pDevice, WLAN_CMD_CHANGE_ANTENNA, NULL);
+ pDevice->byAntennaState = 0;
+ s_vClearSQ3Value(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
+TimerSQ3Tmax3CallBack (
+ IN HANDLE hDeviceContext
+ )
+{
+ PSDevice pDevice = (PSDevice)hDeviceContext;
+
+ DBG_PRT(MSG_LEVEL_DEBUG, KERN_INFO"TimerSQ3Tmax3CallBack...");
+ spin_lock_irq(&pDevice->lock);
+
+ pDevice->ulRatio_State0 = s_ulGetRatio(pDevice);
+ DBG_PRT(MSG_LEVEL_DEBUG, KERN_INFO"SQ3_State0 = [%08x]\n",(int)pDevice->ulRatio_State0);
+
+ s_vClearSQ3Value(pDevice);
+ if ( pDevice->byTMax == 0 ) {
+ pDevice->TimerSQ3Tmax3.expires = RUN_AT(pDevice->byTMax3 * HZ);
+ add_timer(&pDevice->TimerSQ3Tmax3);
+ spin_unlock_irq(&pDevice->lock);
+ return;
+ }
+
+ bScheduleCommand((HANDLE) pDevice, WLAN_CMD_CHANGE_ANTENNA, NULL);
+ pDevice->byAntennaState = 1;
+ del_timer(&pDevice->TimerSQ3Tmax3);
+ del_timer(&pDevice->TimerSQ3Tmax2);
+ pDevice->TimerSQ3Tmax1.expires = RUN_AT(pDevice->byTMax * HZ);
+ add_timer(&pDevice->TimerSQ3Tmax1);
+
+ spin_unlock_irq(&pDevice->lock);
+ return;
+}
+
+VOID
+BBvUpdatePreEDThreshold(
+ IN PSDevice pDevice,
+ IN BOOL bScanning)
+{
+
+
+ switch(pDevice->byRFType)
+ {
+ case RF_AL2230:
+ case RF_AL2230S:
+ case RF_AIROHA7230:
+ //RobertYu:20060627, update new table
+
+ if( bScanning )
+ { // need Max sensitivity //RSSI -69, -70,....
+ if(pDevice->byBBPreEDIndex == 0) break;
+ pDevice->byBBPreEDIndex = 0;
+ ControlvWriteByte(pDevice, MESSAGE_REQUEST_BBREG, 0xC9, 0x00); //CR201(0xC9)
+ ControlvWriteByte(pDevice, MESSAGE_REQUEST_BBREG, 0xCE, 0x30); //CR206(0xCE)
+ DBG_PRT(MSG_LEVEL_DEBUG, KERN_INFO" pDevice->byBBPreEDRSSI -69, -70, -71,...\n");
+ break;
+ }
+
+ if(pDevice->byBBPreEDRSSI <= 45) { // RSSI 0, -1,-2,....-45
+ if(pDevice->byBBPreEDIndex == 20) break;
+ pDevice->byBBPreEDIndex = 20;
+ ControlvWriteByte(pDevice, MESSAGE_REQUEST_BBREG, 0xC9, 0xFF); //CR201(0xC9)
+ ControlvWriteByte(pDevice, MESSAGE_REQUEST_BBREG, 0xCE, 0x00); //CR206(0xCE)
+ DBG_PRT(MSG_LEVEL_DEBUG, KERN_INFO" pDevice->byBBPreEDRSSI 0, -1,-2,..-45\n");
+ } else if(pDevice->byBBPreEDRSSI <= 46) { //RSSI -46
+ if(pDevice->byBBPreEDIndex == 19) break;
+ pDevice->byBBPreEDIndex = 19;
+ ControlvWriteByte(pDevice, MESSAGE_REQUEST_BBREG, 0xC9, 0x1A); //CR201(0xC9)
+ ControlvWriteByte(pDevice, MESSAGE_REQUEST_BBREG, 0xCE, 0x00); //CR206(0xCE)
+ DBG_PRT(MSG_LEVEL_DEBUG, KERN_INFO" pDevice->byBBPreEDRSSI -46\n");
+ } else if(pDevice->byBBPreEDRSSI <= 47) { //RSSI -47
+ if(pDevice->byBBPreEDIndex == 18) break;
+ pDevice->byBBPreEDIndex = 18;
+ ControlvWriteByte(pDevice, MESSAGE_REQUEST_BBREG, 0xC9, 0x15); //CR201(0xC9)
+ ControlvWriteByte(pDevice, MESSAGE_REQUEST_BBREG, 0xCE, 0x00); //CR206(0xCE)
+ DBG_PRT(MSG_LEVEL_DEBUG, KERN_INFO" pDevice->byBBPreEDRSSI -47\n");
+ } else if(pDevice->byBBPreEDRSSI <= 49) { //RSSI -48, -49
+ if(pDevice->byBBPreEDIndex == 17) break;
+ pDevice->byBBPreEDIndex = 17;
+ ControlvWriteByte(pDevice, MESSAGE_REQUEST_BBREG, 0xC9, 0x0E); //CR201(0xC9)
+ ControlvWriteByte(pDevice, MESSAGE_REQUEST_BBREG, 0xCE, 0x00); //CR206(0xCE)
+ DBG_PRT(MSG_LEVEL_DEBUG, KERN_INFO" pDevice->byBBPreEDRSSI -48,-49\n");
+ } else if(pDevice->byBBPreEDRSSI <= 51) { //RSSI -50, -51
+ if(pDevice->byBBPreEDIndex == 16) break;
+ pDevice->byBBPreEDIndex = 16;
+ ControlvWriteByte(pDevice, MESSAGE_REQUEST_BBREG, 0xC9, 0x09); //CR201(0xC9)
+ ControlvWriteByte(pDevice, MESSAGE_REQUEST_BBREG, 0xCE, 0x00); //CR206(0xCE)
+ DBG_PRT(MSG_LEVEL_DEBUG, KERN_INFO" pDevice->byBBPreEDRSSI -50,-51\n");
+ } else if(pDevice->byBBPreEDRSSI <= 53) { //RSSI -52, -53
+ if(pDevice->byBBPreEDIndex == 15) break;
+ pDevice->byBBPreEDIndex = 15;
+ ControlvWriteByte(pDevice, MESSAGE_REQUEST_BBREG, 0xC9, 0x06); //CR201(0xC9)
+ ControlvWriteByte(pDevice, MESSAGE_REQUEST_BBREG, 0xCE, 0x00); //CR206(0xCE)
+ DBG_PRT(MSG_LEVEL_DEBUG, KERN_INFO" pDevice->byBBPreEDRSSI -52,-53\n");
+ } else if(pDevice->byBBPreEDRSSI <= 55) { //RSSI -54, -55
+ if(pDevice->byBBPreEDIndex == 14) break;
+ pDevice->byBBPreEDIndex = 14;
+ ControlvWriteByte(pDevice, MESSAGE_REQUEST_BBREG, 0xC9, 0x03); //CR201(0xC9)
+ ControlvWriteByte(pDevice, MESSAGE_REQUEST_BBREG, 0xCE, 0x00); //CR206(0xCE)
+ DBG_PRT(MSG_LEVEL_DEBUG, KERN_INFO" pDevice->byBBPreEDRSSI -54,-55\n");
+ } else if(pDevice->byBBPreEDRSSI <= 56) { //RSSI -56
+ if(pDevice->byBBPreEDIndex == 13) break;
+ pDevice->byBBPreEDIndex = 13;
+ ControlvWriteByte(pDevice, MESSAGE_REQUEST_BBREG, 0xC9, 0x02); //CR201(0xC9)
+ ControlvWriteByte(pDevice, MESSAGE_REQUEST_BBREG, 0xCE, 0xA0); //CR206(0xCE)
+ DBG_PRT(MSG_LEVEL_DEBUG, KERN_INFO" pDevice->byBBPreEDRSSI -56\n");
+ } else if(pDevice->byBBPreEDRSSI <= 57) { //RSSI -57
+ if(pDevice->byBBPreEDIndex == 12) break;
+ pDevice->byBBPreEDIndex = 12;
+ ControlvWriteByte(pDevice, MESSAGE_REQUEST_BBREG, 0xC9, 0x02); //CR201(0xC9)
+ ControlvWriteByte(pDevice, MESSAGE_REQUEST_BBREG, 0xCE, 0x20); //CR206(0xCE)
+ DBG_PRT(MSG_LEVEL_DEBUG, KERN_INFO" pDevice->byBBPreEDRSSI -57\n");
+ } else if(pDevice->byBBPreEDRSSI <= 58) { //RSSI -58
+ if(pDevice->byBBPreEDIndex == 11) break;
+ pDevice->byBBPreEDIndex = 11;
+ ControlvWriteByte(pDevice, MESSAGE_REQUEST_BBREG, 0xC9, 0x01); //CR201(0xC9)
+ ControlvWriteByte(pDevice, MESSAGE_REQUEST_BBREG, 0xCE, 0xA0); //CR206(0xCE)
+ DBG_PRT(MSG_LEVEL_DEBUG, KERN_INFO" pDevice->byBBPreEDRSSI -58\n");
+ } else if(pDevice->byBBPreEDRSSI <= 59) { //RSSI -59
+ if(pDevice->byBBPreEDIndex == 10) break;
+ pDevice->byBBPreEDIndex = 10;
+ ControlvWriteByte(pDevice, MESSAGE_REQUEST_BBREG, 0xC9, 0x01); //CR201(0xC9)
+ ControlvWriteByte(pDevice, MESSAGE_REQUEST_BBREG, 0xCE, 0x54); //CR206(0xCE)
+ DBG_PRT(MSG_LEVEL_DEBUG, KERN_INFO" pDevice->byBBPreEDRSSI -59\n");
+ } else if(pDevice->byBBPreEDRSSI <= 60) { //RSSI -60
+ if(pDevice->byBBPreEDIndex == 9) break;
+ pDevice->byBBPreEDIndex = 9;
+ ControlvWriteByte(pDevice, MESSAGE_REQUEST_BBREG, 0xC9, 0x01); //CR201(0xC9)
+ ControlvWriteByte(pDevice, MESSAGE_REQUEST_BBREG, 0xCE, 0x18); //CR206(0xCE)
+ DBG_PRT(MSG_LEVEL_DEBUG, KERN_INFO" pDevice->byBBPreEDRSSI -60\n");
+ } else if(pDevice->byBBPreEDRSSI <= 61) { //RSSI -61
+ if(pDevice->byBBPreEDIndex == 8) break;
+ pDevice->byBBPreEDIndex = 8;
+ ControlvWriteByte(pDevice, MESSAGE_REQUEST_BBREG, 0xC9, 0x00); //CR201(0xC9)
+ ControlvWriteByte(pDevice, MESSAGE_REQUEST_BBREG, 0xCE, 0xE3); //CR206(0xCE)
+ DBG_PRT(MSG_LEVEL_DEBUG, KERN_INFO" pDevice->byBBPreEDRSSI -61\n");
+ } else if(pDevice->byBBPreEDRSSI <= 62) { //RSSI -62
+ if(pDevice->byBBPreEDIndex == 7) break;
+ pDevice->byBBPreEDIndex = 7;
+ ControlvWriteByte(pDevice, MESSAGE_REQUEST_BBREG, 0xC9, 0x00); //CR201(0xC9)
+ ControlvWriteByte(pDevice, MESSAGE_REQUEST_BBREG, 0xCE, 0xB9); //CR206(0xCE)
+ DBG_PRT(MSG_LEVEL_DEBUG, KERN_INFO" pDevice->byBBPreEDRSSI -62\n");
+ } else if(pDevice->byBBPreEDRSSI <= 63) { //RSSI -63
+ if(pDevice->byBBPreEDIndex == 6) break;
+ pDevice->byBBPreEDIndex = 6;
+ ControlvWriteByte(pDevice, MESSAGE_REQUEST_BBREG, 0xC9, 0x00); //CR201(0xC9)
+ ControlvWriteByte(pDevice, MESSAGE_REQUEST_BBREG, 0xCE, 0x93); //CR206(0xCE)
+ DBG_PRT(MSG_LEVEL_DEBUG, KERN_INFO" pDevice->byBBPreEDRSSI -63\n");
+ } else if(pDevice->byBBPreEDRSSI <= 64) { //RSSI -64
+ if(pDevice->byBBPreEDIndex == 5) break;
+ pDevice->byBBPreEDIndex = 5;
+ ControlvWriteByte(pDevice, MESSAGE_REQUEST_BBREG, 0xC9, 0x00); //CR201(0xC9)
+ ControlvWriteByte(pDevice, MESSAGE_REQUEST_BBREG, 0xCE, 0x79); //CR206(0xCE)
+ DBG_PRT(MSG_LEVEL_DEBUG, KERN_INFO" pDevice->byBBPreEDRSSI -64\n");
+ } else if(pDevice->byBBPreEDRSSI <= 65) { //RSSI -65
+ if(pDevice->byBBPreEDIndex == 4) break;
+ pDevice->byBBPreEDIndex = 4;
+ ControlvWriteByte(pDevice, MESSAGE_REQUEST_BBREG, 0xC9, 0x00); //CR201(0xC9)
+ ControlvWriteByte(pDevice, MESSAGE_REQUEST_BBREG, 0xCE, 0x62); //CR206(0xCE)
+ DBG_PRT(MSG_LEVEL_DEBUG, KERN_INFO" pDevice->byBBPreEDRSSI -65\n");
+ } else if(pDevice->byBBPreEDRSSI <= 66) { //RSSI -66
+ if(pDevice->byBBPreEDIndex == 3) break;
+ pDevice->byBBPreEDIndex = 3;
+ ControlvWriteByte(pDevice, MESSAGE_REQUEST_BBREG, 0xC9, 0x00); //CR201(0xC9)
+ ControlvWriteByte(pDevice, MESSAGE_REQUEST_BBREG, 0xCE, 0x51); //CR206(0xCE)
+ DBG_PRT(MSG_LEVEL_DEBUG, KERN_INFO" pDevice->byBBPreEDRSSI -66\n");
+ } else if(pDevice->byBBPreEDRSSI <= 67) { //RSSI -67
+ if(pDevice->byBBPreEDIndex == 2) break;
+ pDevice->byBBPreEDIndex = 2;
+ ControlvWriteByte(pDevice, MESSAGE_REQUEST_BBREG, 0xC9, 0x00); //CR201(0xC9)
+ ControlvWriteByte(pDevice, MESSAGE_REQUEST_BBREG, 0xCE, 0x43); //CR206(0xCE)
+ DBG_PRT(MSG_LEVEL_DEBUG, KERN_INFO" pDevice->byBBPreEDRSSI -67\n");
+ } else if(pDevice->byBBPreEDRSSI <= 68) { //RSSI -68
+ if(pDevice->byBBPreEDIndex == 1) break;
+ pDevice->byBBPreEDIndex = 1;
+ ControlvWriteByte(pDevice, MESSAGE_REQUEST_BBREG, 0xC9, 0x00); //CR201(0xC9)
+ ControlvWriteByte(pDevice, MESSAGE_REQUEST_BBREG, 0xCE, 0x36); //CR206(0xCE)
+ DBG_PRT(MSG_LEVEL_DEBUG, KERN_INFO" pDevice->byBBPreEDRSSI -68\n");
+ } else { //RSSI -69, -70,....
+ if(pDevice->byBBPreEDIndex == 0) break;
+ pDevice->byBBPreEDIndex = 0;
+ ControlvWriteByte(pDevice, MESSAGE_REQUEST_BBREG, 0xC9, 0x00); //CR201(0xC9)
+ ControlvWriteByte(pDevice, MESSAGE_REQUEST_BBREG, 0xCE, 0x30); //CR206(0xCE)
+ DBG_PRT(MSG_LEVEL_DEBUG, KERN_INFO" pDevice->byBBPreEDRSSI -69, -70,...\n");
+ }
+ break;
+
+ case RF_VT3226:
+ case RF_VT3226D0:
+ //RobertYu:20060627, update new table
+
+ if( bScanning )
+ { // need Max sensitivity //RSSI -69, -70, ...
+ if(pDevice->byBBPreEDIndex == 0) break;
+ pDevice->byBBPreEDIndex = 0;
+ ControlvWriteByte(pDevice, MESSAGE_REQUEST_BBREG, 0xC9, 0x00); //CR201(0xC9)
+ ControlvWriteByte(pDevice, MESSAGE_REQUEST_BBREG, 0xCE, 0x24); //CR206(0xCE)
+ DBG_PRT(MSG_LEVEL_DEBUG, KERN_INFO" pDevice->byBBPreEDRSSI -69, -70,..\n");
+ break;
+ }
+
+ if(pDevice->byBBPreEDRSSI <= 41) { // RSSI 0, -1,-2,....-41
+ if(pDevice->byBBPreEDIndex == 22) break;
+ pDevice->byBBPreEDIndex = 22;
+ ControlvWriteByte(pDevice, MESSAGE_REQUEST_BBREG, 0xC9, 0xFF); //CR201(0xC9)
+ ControlvWriteByte(pDevice, MESSAGE_REQUEST_BBREG, 0xCE, 0x00); //CR206(0xCE)
+ DBG_PRT(MSG_LEVEL_DEBUG, KERN_INFO" pDevice->byBBPreEDRSSI 0, -1,-2,..-41\n");
+ } else if(pDevice->byBBPreEDRSSI <= 42) { //RSSI -42
+ if(pDevice->byBBPreEDIndex == 21) break;
+ pDevice->byBBPreEDIndex = 21;
+ ControlvWriteByte(pDevice, MESSAGE_REQUEST_BBREG, 0xC9, 0x36); //CR201(0xC9)
+ ControlvWriteByte(pDevice, MESSAGE_REQUEST_BBREG, 0xCE, 0x00); //CR206(0xCE)
+ DBG_PRT(MSG_LEVEL_DEBUG, KERN_INFO" pDevice->byBBPreEDRSSI -42\n");
+ } else if(pDevice->byBBPreEDRSSI <= 43) { //RSSI -43
+ if(pDevice->byBBPreEDIndex == 20) break;
+ pDevice->byBBPreEDIndex = 20;
+ ControlvWriteByte(pDevice, MESSAGE_REQUEST_BBREG, 0xC9, 0x26); //CR201(0xC9)
+ ControlvWriteByte(pDevice, MESSAGE_REQUEST_BBREG, 0xCE, 0x00); //CR206(0xCE)
+ DBG_PRT(MSG_LEVEL_DEBUG, KERN_INFO" pDevice->byBBPreEDRSSI -43\n");
+ } else if(pDevice->byBBPreEDRSSI <= 45) { //RSSI -44, -45
+ if(pDevice->byBBPreEDIndex == 19) break;
+ pDevice->byBBPreEDIndex = 19;
+ ControlvWriteByte(pDevice, MESSAGE_REQUEST_BBREG, 0xC9, 0x18); //CR201(0xC9)
+ ControlvWriteByte(pDevice, MESSAGE_REQUEST_BBREG, 0xCE, 0x00); //CR206(0xCE)
+ DBG_PRT(MSG_LEVEL_DEBUG, KERN_INFO" pDevice->byBBPreEDRSSI -44,-45\n");
+ } else if(pDevice->byBBPreEDRSSI <= 47) { //RSSI -46, -47
+ if(pDevice->byBBPreEDIndex == 18) break;
+ pDevice->byBBPreEDIndex = 18;
+ ControlvWriteByte(pDevice, MESSAGE_REQUEST_BBREG, 0xC9, 0x11); //CR201(0xC9)
+ ControlvWriteByte(pDevice, MESSAGE_REQUEST_BBREG, 0xCE, 0x00); //CR206(0xCE)
+ DBG_PRT(MSG_LEVEL_DEBUG, KERN_INFO" pDevice->byBBPreEDRSSI -46,-47\n");
+ } else if(pDevice->byBBPreEDRSSI <= 49) { //RSSI -48, -49
+ if(pDevice->byBBPreEDIndex == 17) break;
+ pDevice->byBBPreEDIndex = 17;
+ ControlvWriteByte(pDevice, MESSAGE_REQUEST_BBREG, 0xC9, 0x0a); //CR201(0xC9)
+ ControlvWriteByte(pDevice, MESSAGE_REQUEST_BBREG, 0xCE, 0x00); //CR206(0xCE)
+ DBG_PRT(MSG_LEVEL_DEBUG, KERN_INFO" pDevice->byBBPreEDRSSI -48,-49\n");
+ } else if(pDevice->byBBPreEDRSSI <= 51) { //RSSI -50, -51
+ if(pDevice->byBBPreEDIndex == 16) break;
+ pDevice->byBBPreEDIndex = 16;
+ ControlvWriteByte(pDevice, MESSAGE_REQUEST_BBREG, 0xC9, 0x07); //CR201(0xC9)
+ ControlvWriteByte(pDevice, MESSAGE_REQUEST_BBREG, 0xCE, 0x00); //CR206(0xCE)
+ DBG_PRT(MSG_LEVEL_DEBUG, KERN_INFO" pDevice->byBBPreEDRSSI -50,-51\n");
+ } else if(pDevice->byBBPreEDRSSI <= 53) { //RSSI -52, -53
+ if(pDevice->byBBPreEDIndex == 15) break;
+ pDevice->byBBPreEDIndex = 15;
+ ControlvWriteByte(pDevice, MESSAGE_REQUEST_BBREG, 0xC9, 0x04); //CR201(0xC9)
+ ControlvWriteByte(pDevice, MESSAGE_REQUEST_BBREG, 0xCE, 0x00); //CR206(0xCE)
+ DBG_PRT(MSG_LEVEL_DEBUG, KERN_INFO" pDevice->byBBPreEDRSSI -52,-53\n");
+ } else if(pDevice->byBBPreEDRSSI <= 55) { //RSSI -54, -55
+ if(pDevice->byBBPreEDIndex == 14) break;
+ pDevice->byBBPreEDIndex = 14;
+ ControlvWriteByte(pDevice, MESSAGE_REQUEST_BBREG, 0xC9, 0x02); //CR201(0xC9)
+ ControlvWriteByte(pDevice, MESSAGE_REQUEST_BBREG, 0xCE, 0xC0); //CR206(0xCE)
+ DBG_PRT(MSG_LEVEL_DEBUG, KERN_INFO" pDevice->byBBPreEDRSSI -54,-55\n");
+ } else if(pDevice->byBBPreEDRSSI <= 56) { //RSSI -56
+ if(pDevice->byBBPreEDIndex == 13) break;
+ pDevice->byBBPreEDIndex = 13;
+ ControlvWriteByte(pDevice, MESSAGE_REQUEST_BBREG, 0xC9, 0x02); //CR201(0xC9)
+ ControlvWriteByte(pDevice, MESSAGE_REQUEST_BBREG, 0xCE, 0x30); //CR206(0xCE)
+ DBG_PRT(MSG_LEVEL_DEBUG, KERN_INFO" pDevice->byBBPreEDRSSI -56\n");
+ } else if(pDevice->byBBPreEDRSSI <= 57) { //RSSI -57
+ if(pDevice->byBBPreEDIndex == 12) break;
+ pDevice->byBBPreEDIndex = 12;
+ ControlvWriteByte(pDevice, MESSAGE_REQUEST_BBREG, 0xC9, 0x01); //CR201(0xC9)
+ ControlvWriteByte(pDevice, MESSAGE_REQUEST_BBREG, 0xCE, 0xB0); //CR206(0xCE)
+ DBG_PRT(MSG_LEVEL_DEBUG, KERN_INFO" pDevice->byBBPreEDRSSI -57\n");
+ } else if(pDevice->byBBPreEDRSSI <= 58) { //RSSI -58
+ if(pDevice->byBBPreEDIndex == 11) break;
+ pDevice->byBBPreEDIndex = 11;
+ ControlvWriteByte(pDevice, MESSAGE_REQUEST_BBREG, 0xC9, 0x01); //CR201(0xC9)
+ ControlvWriteByte(pDevice, MESSAGE_REQUEST_BBREG, 0xCE, 0x70); //CR206(0xCE)
+ DBG_PRT(MSG_LEVEL_DEBUG, KERN_INFO" pDevice->byBBPreEDRSSI -58\n");
+ } else if(pDevice->byBBPreEDRSSI <= 59) { //RSSI -59
+ if(pDevice->byBBPreEDIndex == 10) break;
+ pDevice->byBBPreEDIndex = 10;
+ ControlvWriteByte(pDevice, MESSAGE_REQUEST_BBREG, 0xC9, 0x01); //CR201(0xC9)
+ ControlvWriteByte(pDevice, MESSAGE_REQUEST_BBREG, 0xCE, 0x30); //CR206(0xCE)
+ DBG_PRT(MSG_LEVEL_DEBUG, KERN_INFO" pDevice->byBBPreEDRSSI -59\n");
+ } else if(pDevice->byBBPreEDRSSI <= 60) { //RSSI -60
+ if(pDevice->byBBPreEDIndex == 9) break;
+ pDevice->byBBPreEDIndex = 9;
+ ControlvWriteByte(pDevice, MESSAGE_REQUEST_BBREG, 0xC9, 0x00); //CR201(0xC9)
+ ControlvWriteByte(pDevice, MESSAGE_REQUEST_BBREG, 0xCE, 0xEA); //CR206(0xCE)
+ DBG_PRT(MSG_LEVEL_DEBUG, KERN_INFO" pDevice->byBBPreEDRSSI -60\n");
+ } else if(pDevice->byBBPreEDRSSI <= 61) { //RSSI -61
+ if(pDevice->byBBPreEDIndex == 8) break;
+ pDevice->byBBPreEDIndex = 8;
+ ControlvWriteByte(pDevice, MESSAGE_REQUEST_BBREG, 0xC9, 0x00); //CR201(0xC9)
+ ControlvWriteByte(pDevice, MESSAGE_REQUEST_BBREG, 0xCE, 0xC0); //CR206(0xCE)
+ DBG_PRT(MSG_LEVEL_DEBUG, KERN_INFO" pDevice->byBBPreEDRSSI -61\n");
+ } else if(pDevice->byBBPreEDRSSI <= 62) { //RSSI -62
+ if(pDevice->byBBPreEDIndex == 7) break;
+ pDevice->byBBPreEDIndex = 7;
+ ControlvWriteByte(pDevice, MESSAGE_REQUEST_BBREG, 0xC9, 0x00); //CR201(0xC9)
+ ControlvWriteByte(pDevice, MESSAGE_REQUEST_BBREG, 0xCE, 0x9C); //CR206(0xCE)
+ DBG_PRT(MSG_LEVEL_DEBUG, KERN_INFO" pDevice->byBBPreEDRSSI -62\n");
+ } else if(pDevice->byBBPreEDRSSI <= 63) { //RSSI -63
+ if(pDevice->byBBPreEDIndex == 6) break;
+ pDevice->byBBPreEDIndex = 6;
+ ControlvWriteByte(pDevice, MESSAGE_REQUEST_BBREG, 0xC9, 0x00); //CR201(0xC9)
+ ControlvWriteByte(pDevice, MESSAGE_REQUEST_BBREG, 0xCE, 0x80); //CR206(0xCE)
+ DBG_PRT(MSG_LEVEL_DEBUG, KERN_INFO" pDevice->byBBPreEDRSSI -63\n");
+ } else if(pDevice->byBBPreEDRSSI <= 64) { //RSSI -64
+ if(pDevice->byBBPreEDIndex == 5) break;
+ pDevice->byBBPreEDIndex = 5;
+ ControlvWriteByte(pDevice, MESSAGE_REQUEST_BBREG, 0xC9, 0x00); //CR201(0xC9)
+ ControlvWriteByte(pDevice, MESSAGE_REQUEST_BBREG, 0xCE, 0x68); //CR206(0xCE)
+ DBG_PRT(MSG_LEVEL_DEBUG, KERN_INFO" pDevice->byBBPreEDRSSI -64\n");
+ } else if(pDevice->byBBPreEDRSSI <= 65) { //RSSI -65
+ if(pDevice->byBBPreEDIndex == 4) break;
+ pDevice->byBBPreEDIndex = 4;
+ ControlvWriteByte(pDevice, MESSAGE_REQUEST_BBREG, 0xC9, 0x00); //CR201(0xC9)
+ ControlvWriteByte(pDevice, MESSAGE_REQUEST_BBREG, 0xCE, 0x52); //CR206(0xCE)
+ DBG_PRT(MSG_LEVEL_DEBUG, KERN_INFO" pDevice->byBBPreEDRSSI -65\n");
+ } else if(pDevice->byBBPreEDRSSI <= 66) { //RSSI -66
+ if(pDevice->byBBPreEDIndex == 3) break;
+ pDevice->byBBPreEDIndex = 3;
+ ControlvWriteByte(pDevice, MESSAGE_REQUEST_BBREG, 0xC9, 0x00); //CR201(0xC9)
+ ControlvWriteByte(pDevice, MESSAGE_REQUEST_BBREG, 0xCE, 0x43); //CR206(0xCE)
+ DBG_PRT(MSG_LEVEL_DEBUG, KERN_INFO" pDevice->byBBPreEDRSSI -66\n");
+ } else if(pDevice->byBBPreEDRSSI <= 67) { //RSSI -67
+ if(pDevice->byBBPreEDIndex == 2) break;
+ pDevice->byBBPreEDIndex = 2;
+ ControlvWriteByte(pDevice, MESSAGE_REQUEST_BBREG, 0xC9, 0x00); //CR201(0xC9)
+ ControlvWriteByte(pDevice, MESSAGE_REQUEST_BBREG, 0xCE, 0x36); //CR206(0xCE)
+ DBG_PRT(MSG_LEVEL_DEBUG, KERN_INFO" pDevice->byBBPreEDRSSI -67\n");
+ } else if(pDevice->byBBPreEDRSSI <= 68) { //RSSI -68
+ if(pDevice->byBBPreEDIndex == 1) break;
+ pDevice->byBBPreEDIndex = 1;
+ ControlvWriteByte(pDevice, MESSAGE_REQUEST_BBREG, 0xC9, 0x00); //CR201(0xC9)
+ ControlvWriteByte(pDevice, MESSAGE_REQUEST_BBREG, 0xCE, 0x2D); //CR206(0xCE)
+ DBG_PRT(MSG_LEVEL_DEBUG, KERN_INFO" pDevice->byBBPreEDRSSI -68\n");
+ } else { //RSSI -69, -70, ...
+ if(pDevice->byBBPreEDIndex == 0) break;
+ pDevice->byBBPreEDIndex = 0;
+ ControlvWriteByte(pDevice, MESSAGE_REQUEST_BBREG, 0xC9, 0x00); //CR201(0xC9)
+ ControlvWriteByte(pDevice, MESSAGE_REQUEST_BBREG, 0xCE, 0x24); //CR206(0xCE)
+ DBG_PRT(MSG_LEVEL_DEBUG, KERN_INFO" pDevice->byBBPreEDRSSI -69, -70,..\n");
+ }
+ break;
+
+ case RF_VT3342A0: //RobertYu:20060627, testing table
+ if( bScanning )
+ { // need Max sensitivity //RSSI -67, -68, ...
+ if(pDevice->byBBPreEDIndex == 0) break;
+ pDevice->byBBPreEDIndex = 0;
+ ControlvWriteByte(pDevice, MESSAGE_REQUEST_BBREG, 0xC9, 0x00); //CR201(0xC9)
+ ControlvWriteByte(pDevice, MESSAGE_REQUEST_BBREG, 0xCE, 0x38); //CR206(0xCE)
+ DBG_PRT(MSG_LEVEL_DEBUG, KERN_INFO" pDevice->byBBPreEDRSSI -67, -68,..\n");
+ break;
+ }
+
+ if(pDevice->byBBPreEDRSSI <= 41) { // RSSI 0, -1,-2,....-41
+ if(pDevice->byBBPreEDIndex == 20) break;
+ pDevice->byBBPreEDIndex = 20;
+ ControlvWriteByte(pDevice, MESSAGE_REQUEST_BBREG, 0xC9, 0xFF); //CR201(0xC9)
+ ControlvWriteByte(pDevice, MESSAGE_REQUEST_BBREG, 0xCE, 0x00); //CR206(0xCE)
+ DBG_PRT(MSG_LEVEL_DEBUG, KERN_INFO" pDevice->byBBPreEDRSSI 0, -1,-2,..-41\n");
+ } else if(pDevice->byBBPreEDRSSI <= 42) { //RSSI -42
+ if(pDevice->byBBPreEDIndex == 19) break;
+ pDevice->byBBPreEDIndex = 19;
+ ControlvWriteByte(pDevice, MESSAGE_REQUEST_BBREG, 0xC9, 0x36); //CR201(0xC9)
+ ControlvWriteByte(pDevice, MESSAGE_REQUEST_BBREG, 0xCE, 0x00); //CR206(0xCE)
+ DBG_PRT(MSG_LEVEL_DEBUG, KERN_INFO" pDevice->byBBPreEDRSSI -42\n");
+ } else if(pDevice->byBBPreEDRSSI <= 43) { //RSSI -43
+ if(pDevice->byBBPreEDIndex == 18) break;
+ pDevice->byBBPreEDIndex = 18;
+ ControlvWriteByte(pDevice, MESSAGE_REQUEST_BBREG, 0xC9, 0x26); //CR201(0xC9)
+ ControlvWriteByte(pDevice, MESSAGE_REQUEST_BBREG, 0xCE, 0x00); //CR206(0xCE)
+ DBG_PRT(MSG_LEVEL_DEBUG, KERN_INFO" pDevice->byBBPreEDRSSI -43\n");
+ } else if(pDevice->byBBPreEDRSSI <= 45) { //RSSI -44, -45
+ if(pDevice->byBBPreEDIndex == 17) break;
+ pDevice->byBBPreEDIndex = 17;
+ ControlvWriteByte(pDevice, MESSAGE_REQUEST_BBREG, 0xC9, 0x18); //CR201(0xC9)
+ ControlvWriteByte(pDevice, MESSAGE_REQUEST_BBREG, 0xCE, 0x00); //CR206(0xCE)
+ DBG_PRT(MSG_LEVEL_DEBUG, KERN_INFO" pDevice->byBBPreEDRSSI -44,-45\n");
+ } else if(pDevice->byBBPreEDRSSI <= 47) { //RSSI -46, -47
+ if(pDevice->byBBPreEDIndex == 16) break;
+ pDevice->byBBPreEDIndex = 16;
+ ControlvWriteByte(pDevice, MESSAGE_REQUEST_BBREG, 0xC9, 0x11); //CR201(0xC9)
+ ControlvWriteByte(pDevice, MESSAGE_REQUEST_BBREG, 0xCE, 0x00); //CR206(0xCE)
+ DBG_PRT(MSG_LEVEL_DEBUG, KERN_INFO" pDevice->byBBPreEDRSSI -46,-47\n");
+ } else if(pDevice->byBBPreEDRSSI <= 49) { //RSSI -48, -49
+ if(pDevice->byBBPreEDIndex == 15) break;
+ pDevice->byBBPreEDIndex = 15;
+ ControlvWriteByte(pDevice, MESSAGE_REQUEST_BBREG, 0xC9, 0x0a); //CR201(0xC9)
+ ControlvWriteByte(pDevice, MESSAGE_REQUEST_BBREG, 0xCE, 0x00); //CR206(0xCE)
+ DBG_PRT(MSG_LEVEL_DEBUG, KERN_INFO" pDevice->byBBPreEDRSSI -48,-49\n");
+ } else if(pDevice->byBBPreEDRSSI <= 51) { //RSSI -50, -51
+ if(pDevice->byBBPreEDIndex == 14) break;
+ pDevice->byBBPreEDIndex = 14;
+ ControlvWriteByte(pDevice, MESSAGE_REQUEST_BBREG, 0xC9, 0x07); //CR201(0xC9)
+ ControlvWriteByte(pDevice, MESSAGE_REQUEST_BBREG, 0xCE, 0x00); //CR206(0xCE)
+ DBG_PRT(MSG_LEVEL_DEBUG, KERN_INFO" pDevice->byBBPreEDRSSI -50,-51\n");
+ } else if(pDevice->byBBPreEDRSSI <= 53) { //RSSI -52, -53
+ if(pDevice->byBBPreEDIndex == 13) break;
+ pDevice->byBBPreEDIndex = 13;
+ ControlvWriteByte(pDevice, MESSAGE_REQUEST_BBREG, 0xC9, 0x04); //CR201(0xC9)
+ ControlvWriteByte(pDevice, MESSAGE_REQUEST_BBREG, 0xCE, 0x00); //CR206(0xCE)
+ DBG_PRT(MSG_LEVEL_DEBUG, KERN_INFO" pDevice->byBBPreEDRSSI -52,-53\n");
+ } else if(pDevice->byBBPreEDRSSI <= 55) { //RSSI -54, -55
+ if(pDevice->byBBPreEDIndex == 12) break;
+ pDevice->byBBPreEDIndex = 12;
+ ControlvWriteByte(pDevice, MESSAGE_REQUEST_BBREG, 0xC9, 0x02); //CR201(0xC9)
+ ControlvWriteByte(pDevice, MESSAGE_REQUEST_BBREG, 0xCE, 0xC0); //CR206(0xCE)
+ DBG_PRT(MSG_LEVEL_DEBUG, KERN_INFO" pDevice->byBBPreEDRSSI -54,-55\n");
+ } else if(pDevice->byBBPreEDRSSI <= 56) { //RSSI -56
+ if(pDevice->byBBPreEDIndex == 11) break;
+ pDevice->byBBPreEDIndex = 11;
+ ControlvWriteByte(pDevice, MESSAGE_REQUEST_BBREG, 0xC9, 0x02); //CR201(0xC9)
+ ControlvWriteByte(pDevice, MESSAGE_REQUEST_BBREG, 0xCE, 0x30); //CR206(0xCE)
+ DBG_PRT(MSG_LEVEL_DEBUG, KERN_INFO" pDevice->byBBPreEDRSSI -56\n");
+ } else if(pDevice->byBBPreEDRSSI <= 57) { //RSSI -57
+ if(pDevice->byBBPreEDIndex == 10) break;
+ pDevice->byBBPreEDIndex = 10;
+ ControlvWriteByte(pDevice, MESSAGE_REQUEST_BBREG, 0xC9, 0x01); //CR201(0xC9)
+ ControlvWriteByte(pDevice, MESSAGE_REQUEST_BBREG, 0xCE, 0xB0); //CR206(0xCE)
+ DBG_PRT(MSG_LEVEL_DEBUG, KERN_INFO" pDevice->byBBPreEDRSSI -57\n");
+ } else if(pDevice->byBBPreEDRSSI <= 58) { //RSSI -58
+ if(pDevice->byBBPreEDIndex == 9) break;
+ pDevice->byBBPreEDIndex = 9;
+ ControlvWriteByte(pDevice, MESSAGE_REQUEST_BBREG, 0xC9, 0x01); //CR201(0xC9)
+ ControlvWriteByte(pDevice, MESSAGE_REQUEST_BBREG, 0xCE, 0x70); //CR206(0xCE)
+ DBG_PRT(MSG_LEVEL_DEBUG, KERN_INFO" pDevice->byBBPreEDRSSI -58\n");
+ } else if(pDevice->byBBPreEDRSSI <= 59) { //RSSI -59
+ if(pDevice->byBBPreEDIndex == 8) break;
+ pDevice->byBBPreEDIndex = 8;
+ ControlvWriteByte(pDevice, MESSAGE_REQUEST_BBREG, 0xC9, 0x01); //CR201(0xC9)
+ ControlvWriteByte(pDevice, MESSAGE_REQUEST_BBREG, 0xCE, 0x30); //CR206(0xCE)
+ DBG_PRT(MSG_LEVEL_DEBUG, KERN_INFO" pDevice->byBBPreEDRSSI -59\n");
+ } else if(pDevice->byBBPreEDRSSI <= 60) { //RSSI -60
+ if(pDevice->byBBPreEDIndex == 7) break;
+ pDevice->byBBPreEDIndex = 7;
+ ControlvWriteByte(pDevice, MESSAGE_REQUEST_BBREG, 0xC9, 0x00); //CR201(0xC9)
+ ControlvWriteByte(pDevice, MESSAGE_REQUEST_BBREG, 0xCE, 0xEA); //CR206(0xCE)
+ DBG_PRT(MSG_LEVEL_DEBUG, KERN_INFO" pDevice->byBBPreEDRSSI -60\n");
+ } else if(pDevice->byBBPreEDRSSI <= 61) { //RSSI -61
+ if(pDevice->byBBPreEDIndex == 6) break;
+ pDevice->byBBPreEDIndex = 6;
+ ControlvWriteByte(pDevice, MESSAGE_REQUEST_BBREG, 0xC9, 0x00); //CR201(0xC9)
+ ControlvWriteByte(pDevice, MESSAGE_REQUEST_BBREG, 0xCE, 0xC0); //CR206(0xCE)
+ DBG_PRT(MSG_LEVEL_DEBUG, KERN_INFO" pDevice->byBBPreEDRSSI -61\n");
+ } else if(pDevice->byBBPreEDRSSI <= 62) { //RSSI -62
+ if(pDevice->byBBPreEDIndex == 5) break;
+ pDevice->byBBPreEDIndex = 5;
+ ControlvWriteByte(pDevice, MESSAGE_REQUEST_BBREG, 0xC9, 0x00); //CR201(0xC9)
+ ControlvWriteByte(pDevice, MESSAGE_REQUEST_BBREG, 0xCE, 0x9C); //CR206(0xCE)
+ DBG_PRT(MSG_LEVEL_DEBUG, KERN_INFO" pDevice->byBBPreEDRSSI -62\n");
+ } else if(pDevice->byBBPreEDRSSI <= 63) { //RSSI -63
+ if(pDevice->byBBPreEDIndex == 4) break;
+ pDevice->byBBPreEDIndex = 4;
+ ControlvWriteByte(pDevice, MESSAGE_REQUEST_BBREG, 0xC9, 0x00); //CR201(0xC9)
+ ControlvWriteByte(pDevice, MESSAGE_REQUEST_BBREG, 0xCE, 0x80); //CR206(0xCE)
+ DBG_PRT(MSG_LEVEL_DEBUG, KERN_INFO" pDevice->byBBPreEDRSSI -63\n");
+ } else if(pDevice->byBBPreEDRSSI <= 64) { //RSSI -64
+ if(pDevice->byBBPreEDIndex == 3) break;
+ pDevice->byBBPreEDIndex = 3;
+ ControlvWriteByte(pDevice, MESSAGE_REQUEST_BBREG, 0xC9, 0x00); //CR201(0xC9)
+ ControlvWriteByte(pDevice, MESSAGE_REQUEST_BBREG, 0xCE, 0x68); //CR206(0xCE)
+ DBG_PRT(MSG_LEVEL_DEBUG, KERN_INFO" pDevice->byBBPreEDRSSI -64\n");
+ } else if(pDevice->byBBPreEDRSSI <= 65) { //RSSI -65
+ if(pDevice->byBBPreEDIndex == 2) break;
+ pDevice->byBBPreEDIndex = 2;
+ ControlvWriteByte(pDevice, MESSAGE_REQUEST_BBREG, 0xC9, 0x00); //CR201(0xC9)
+ ControlvWriteByte(pDevice, MESSAGE_REQUEST_BBREG, 0xCE, 0x52); //CR206(0xCE)
+ DBG_PRT(MSG_LEVEL_DEBUG, KERN_INFO" pDevice->byBBPreEDRSSI -65\n");
+ } else if(pDevice->byBBPreEDRSSI <= 66) { //RSSI -66
+ if(pDevice->byBBPreEDIndex == 1) break;
+ pDevice->byBBPreEDIndex = 1;
+ ControlvWriteByte(pDevice, MESSAGE_REQUEST_BBREG, 0xC9, 0x00); //CR201(0xC9)
+ ControlvWriteByte(pDevice, MESSAGE_REQUEST_BBREG, 0xCE, 0x43); //CR206(0xCE)
+ DBG_PRT(MSG_LEVEL_DEBUG, KERN_INFO" pDevice->byBBPreEDRSSI -66\n");
+ } else { //RSSI -67, -68, ...
+ if(pDevice->byBBPreEDIndex == 0) break;
+ pDevice->byBBPreEDIndex = 0;
+ ControlvWriteByte(pDevice, MESSAGE_REQUEST_BBREG, 0xC9, 0x00); //CR201(0xC9)
+ ControlvWriteByte(pDevice, MESSAGE_REQUEST_BBREG, 0xCE, 0x38); //CR206(0xCE)
+ DBG_PRT(MSG_LEVEL_DEBUG, KERN_INFO" pDevice->byBBPreEDRSSI -67, -68,..\n");
+ }
+ break;
+
+ }
+
+}
+
diff --git a/drivers/staging/vt6656/baseband.h b/drivers/staging/vt6656/baseband.h
new file mode 100644
index 000000000000..9cad837aa7e7
--- /dev/null
+++ b/drivers/staging/vt6656/baseband.h
@@ -0,0 +1,163 @@
+/*
+ * 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
+ *
+ * Revision History:
+ * 06-10-2003 Bryan YC Fan: Re-write codes to support VT3253 spec.
+ * 08-26-2003 Kyle Hsu : Add defines of packet type and TX rate.
+ */
+
+#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 -------------------------*/
+
+#define PREAMBLE_LONG 0
+#define PREAMBLE_SHORT 1
+
+//
+// Registers in the BASEBAND
+//
+#define BB_MAX_CONTEXT_SIZE 256
+
+#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
+
+//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 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 ------------------------------*/
+
+/*--------------------- Export Classes ----------------------------*/
+
+/*--------------------- Export Variables --------------------------*/
+
+/*--------------------- Export Functions --------------------------*/
+#ifdef __cplusplus
+extern "C" { /* Assume C declarations for C++ */
+#endif /* __cplusplus */
+
+UINT
+BBuGetFrameTime(
+ IN BYTE byPreambleType,
+ IN BYTE byFreqType,
+ 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
+ );
+
+// timer for antenna diversity
+
+VOID
+TimerSQ3CallBack (
+ IN HANDLE hDeviceContext
+ );
+
+VOID
+TimerSQ3Tmax3CallBack (
+ IN HANDLE hDeviceContext
+ );
+
+VOID BBvAntennaDiversity (PSDevice pDevice, BYTE byRxRate, BYTE bySQ3);
+void BBvLoopbackOn (PSDevice pDevice);
+void BBvLoopbackOff (PSDevice pDevice);
+void BBvSoftwareReset (PSDevice pDevice);
+
+void BBvSetShortSlotTime(PSDevice pDevice);
+VOID BBvSetVGAGainOffset(PSDevice pDevice, BYTE byData);
+void BBvSetAntennaMode(PSDevice pDevice, BYTE byAntennaMode);
+BOOL BBbVT3184Init (PSDevice pDevice);
+VOID BBvSetDeepSleep (PSDevice pDevice);
+VOID BBvExitDeepSleep (PSDevice pDevice);
+VOID BBvUpdatePreEDThreshold(
+ IN PSDevice pDevice,
+ IN BOOL bScanning
+ );
+
+#ifdef __cplusplus
+} /* End of extern "C" { */
+#endif /* __cplusplus */
+
+
+#endif // __BASEBAND_H__
diff --git a/drivers/staging/vt6656/bssdb.c b/drivers/staging/vt6656/bssdb.c
new file mode 100644
index 000000000000..58348cf10d06
--- /dev/null
+++ b/drivers/staging/vt6656/bssdb.c
@@ -0,0 +1,1768 @@
+/*
+ * 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
+ * BSSbIsSTAInNodeDB - 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(__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
+#if !defined(__TBIT_H__)
+#include "tbit.h"
+#endif
+#if !defined(__CONTROL_H__)
+#include "control.h"
+#endif
+#if !defined(__RNDIS_H__)
+#include "rndis.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;
+
+
+
+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
+ );
+
+VOID s_vCheckPreEDThreshold(
+ IN HANDLE hDeviceContext
+ );
+
+#ifdef Calcu_LinkQual
+VOID s_uCalculateLinkQual(
+ IN HANDLE hDeviceContext
+ );
+#endif
+/*--------------------- 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->sMgmtObj);
+ 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) {
+ DBG_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)&&(pDevice->bRoaming == FALSE)) {
+ // match BSSID first
+ for (ii = 0; ii <MAX_BSS_NUM; ii++) {
+ pCurrBSS = &(pMgmt->sBSSList[ii]);
+
+ //2008-0718-01<Add>by MikeLiu
+ 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<Mark>by MikeLiu
+ // if ((pCurrBSS->bActive) &&
+ // (pCurrBSS->bSelected == FALSE)) {
+
+ //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
+ DBG_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
+ DBG_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;
+ }
+ }
+*/
+//DavidWang
+ pMgmt->pSameBSS[jj].uChannel = pCurrBSS->uChannel;
+ DBG_PRT(MSG_LEVEL_DEBUG, KERN_INFO"BSSpSearchBSSList pSelect1[%02X %02X %02X-%02X %02X %02X]\n",*pCurrBSS->abyBSSID,*(pCurrBSS->abyBSSID+1),*(pCurrBSS->abyBSSID+2),*(pCurrBSS->abyBSSID+3),*(pCurrBSS->abyBSSID+4),*(pCurrBSS->abyBSSID+5));
+ jj++;
+
+//DavidWang
+ if (pSelect == NULL) {
+ pSelect = pCurrBSS;
+ } else {
+ // compare RSSI, select signal strong one
+ if (pCurrBSS->uRSSI < pSelect->uRSSI) {
+ pSelect = pCurrBSS;
+ }
+ }
+ }
+ }
+//DavidWang
+pDevice->bSameBSSMaxNum = jj;
+//DavidWang
+ 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->sMgmtObj);
+ 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)) {
+ //mike mark: there are two same BSSID in list if that AP is in hidden ssid mode,one 's SSID is null,
+ // but other's is obvious, so if it acssociate with your STA exactly,you must keep two
+ // of them!!!!!!!!!
+ // 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->sMgmtObj);
+ 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->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->sMgmtObj);
+ PSRxMgmtPacket pRxPacket = (PSRxMgmtPacket)pRxPacketContext;
+ PKnownBSS pBSSList = NULL;
+ UINT ii;
+ BOOL bParsingQuiet = FALSE;
+
+
+
+ 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){
+ DBG_PRT(MSG_LEVEL_DEBUG, 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);
+ DBG_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;
+ pBSSList->ldBmAverRange = 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, jj;
+ PSDevice pDevice = (PSDevice)hDeviceContext;
+ PSMgmtObject pMgmt = &(pDevice->sMgmtObj);
+ PSRxMgmtPacket pRxPacket = (PSRxMgmtPacket)pRxPacketContext;
+ LONG ldBm, ldBmSum;
+ BOOL bParsingQuiet = FALSE;
+ // BYTE abyTmpSSID[WLAN_IEHDR_LEN + WLAN_SSID_MAXLEN + 1];
+
+
+ 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;
+// DBG_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;
+ ldBmSum = 0;
+ for(ii=0, jj=0;ii<RSSI_STAT_COUNT;ii++) {
+ if (pBSSList->ldBmAverage[ii] != 0) {
+ pBSSList->ldBmMAX = max(pBSSList->ldBmAverage[ii], ldBm);
+ ldBmSum += pBSSList->ldBmAverage[ii];
+ jj++;
+ }
+ }
+ pBSSList->ldBmAverRange = ldBmSum /jj;
+ }
+
+ pBSSList->uIELength = uIELength;
+ if (pBSSList->uIELength > WLAN_BEACON_FR_MAXLEN)
+ pBSSList->uIELength = WLAN_BEACON_FR_MAXLEN;
+ memcpy(pBSSList->abyIEs, pbyIEs, pBSSList->uIELength);
+
+//mike add: if the AP in this pBSSList is hidden ssid and we can find two of them,
+// you need upgrade the other related pBSSList of which ssid is obvious,
+// for these two AP is the same one!!!!
+/********judge by:BSSID is the same,but ssid is different!*****************/
+#if 0
+ for (ii = 0; ii < MAX_BSS_NUM; ii++) {
+ if (IS_ETH_ADDRESS_EQUAL(pMgmt->sBSSList[ii].abyBSSID, pBSSList->abyBSSID)) { //BSSID is the same!
+ if (memcmp(((PWLAN_IE_SSID)pMgmt->sBSSList[ii].abySSID)->abySSID, //ssid is different??
+ ((PWLAN_IE_SSID)pBSSList->abySSID)->abySSID,
+ ((PWLAN_IE_SSID)pBSSList->abySSID)->len) != 0) {
+ //reserve temp
+ memset(abyTmpSSID,0,sizeof(abyTmpSSID));
+ memcpy(abyTmpSSID,pMgmt->sBSSList[ii].abySSID,sizeof(abyTmpSSID));
+ //upgrade the other one pBSSList
+ memcpy(&(pMgmt->sBSSList[ii]),pBSSList,sizeof(KnownBSS));
+ //recover ssid info
+ memcpy(pMgmt->sBSSList[ii].abySSID,abyTmpSSID,sizeof(abyTmpSSID));
+ }
+ }
+ }
+#endif
+
+ return TRUE;
+}
+
+
+
+
+
+/*+
+ *
+ * Routine Description:
+ * Search Node DB table to find the index of matched DstAddr
+ *
+ * Return Value:
+ * None
+ *
+-*/
+
+BOOL
+BSSbIsSTAInNodeDB(
+ IN HANDLE hDeviceContext,
+ IN PBYTE abyDstAddr,
+ OUT PUINT puNodeIndex
+ )
+{
+ PSDevice pDevice = (PSDevice)hDeviceContext;
+ PSMgmtObject pMgmt = &(pDevice->sMgmtObj);
+ 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->sMgmtObj);
+ 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;
+ DBG_PRT(MSG_LEVEL_DEBUG, 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;
+ DBG_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->sMgmtObj);
+ 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->sMgmtObj);
+ UINT uRateLen = WLAN_RATES_MAXLEN;
+
+ memset(&pMgmt->sNodeDBTable[0], 0, sizeof(KnownNodeDB));
+
+ pMgmt->sNodeDBTable[0].bActive = TRUE;
+ if (pDevice->byBBType == BB_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;
+ // Auto rate fallback function initiation.
+ // RATEbInit(pDevice);
+ DBG_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->sMgmtObj);
+
+ 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;
+ pMgmt->sNodeDBTable[0].uRatePollTimeout = FALLBACK_POLL_SECOND;
+
+};
+
+
+
+
+
+/*+
+ *
+ * Routine Description:
+ *
+ *
+ * Second call back function to update Node DB info & AP link status
+ *
+ *
+ * Return Value:
+ * none.
+ *
+-*/
+
+
+VOID
+BSSvSecondCallBack(
+ IN HANDLE hDeviceContext
+ )
+{
+ PSDevice pDevice = (PSDevice)hDeviceContext;
+ PSMgmtObject pMgmt = &(pDevice->sMgmtObj);
+ UINT ii;
+ PWLAN_IE_SSID pItemSSID, pCurrSSID;
+ UINT uSleepySTACnt = 0;
+ UINT uNonShortSlotSTACnt = 0;
+ UINT uLongPreambleSTACnt = 0;
+ viawget_wpa_header *wpahdr; //DavidWang
+
+ spin_lock_irq(&pDevice->lock);
+
+ pDevice->uAssocCount = 0;
+
+ //Power Saving Mode Tx Burst
+ if ( pDevice->bEnablePSMode == TRUE ) {
+ pDevice->ulPSModeWaitTx++;
+ if ( pDevice->ulPSModeWaitTx >= 2 ) {
+ pDevice->ulPSModeWaitTx = 0;
+ pDevice->bPSModeTxBurst = FALSE;
+ }
+ }
+
+ pDevice->byERPFlag &=
+ ~(WLAN_SET_ERP_BARKER_MODE(1) | WLAN_SET_ERP_NONERP_PRESENT(1));
+
+ if (pDevice->wUseProtectCntDown > 0) {
+ pDevice->wUseProtectCntDown --;
+ }
+ else {
+ // disable protect mode
+ pDevice->byERPFlag &= ~(WLAN_SET_ERP_USE_PROTECTION(1));
+ }
+
+if(pDevice->byReAssocCount > 0) {
+ 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;
+ PRINT_K("wireless_send_event--->SIOCGIWAP(disassociated)\n");
+ wireless_send_event(pDevice->dev, SIOCGIWAP, &wrqu, NULL);
+ }
+ #endif
+ }
+ else if(pDevice->bLinkPass == TRUE)
+ pDevice->byReAssocCount = 0;
+}
+
+#ifdef SndEvt_ToAPI
+if((pMgmt->eCurrState!=WMAC_STATE_ASSOC) &&
+ (pMgmt->eLastState==WMAC_STATE_ASSOC))
+{
+ union iwreq_data wrqu;
+ memset(&wrqu, 0, sizeof(wrqu));
+ wrqu.data.flags = RT_DISCONNECTED_EVENT_FLAG;
+ wireless_send_event(pDevice->dev, IWEVCUSTOM, &wrqu, NULL);
+}
+ pMgmt->eLastState = pMgmt->eCurrState ;
+#endif
+
+#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);
+ DBG_PRT(MSG_LEVEL_DEBUG, 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)
+ RATEvTxRateFallBack((PVOID)pDevice, &(pMgmt->sNodeDBTable[ii]));
+ }
+
+ }
+
+ // check if pending PS queue
+ if (pMgmt->sNodeDBTable[ii].wEnQueueCnt != 0) {
+ DBG_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);
+ DBG_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->byBBType == BB_TYPE_11G)) {
+
+ // on/off protect mode
+ if (WLAN_GET_ERP_USE_PROTECTION(pDevice->byERPFlag)) {
+ if (!pDevice->bProtectMode) {
+ MACvEnableProtectMD(pDevice);
+ pDevice->bProtectMode = TRUE;
+ }
+ }
+ else {
+ if (pDevice->bProtectMode) {
+ MACvDisableProtectMD(pDevice);
+ 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);
+ pDevice->bBarkerPreambleMd = TRUE;
+ }
+ }
+ else {
+ if (pDevice->bBarkerPreambleMd) {
+ MACvDisableBarkerPreambleMd(pDevice);
+ 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;
+
+ if ((pMgmt->eCurrMode == WMAC_MODE_STANDBY) ||
+ (pMgmt->eCurrMode == WMAC_MODE_ESS_STA)) {
+
+ if (pMgmt->sNodeDBTable[0].bActive) { // Assoc with BSS
+ // DBG_PRT(MSG_LEVEL_INFO, KERN_INFO "Callback inactive Count = [%d]\n", pMgmt->sNodeDBTable[0].uInActiveCount);
+
+ 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;
+ ControlvMaskByte(pDevice,MESSAGE_REQUEST_MACREG,MAC_REG_PAPEDELAY,LEDSTS_STS,LEDSTS_SLOW);
+ pDevice->bRoaming = TRUE;
+ pDevice->bIsRoaming = FALSE;
+
+ DBG_PRT(MSG_LEVEL_NOTICE, KERN_INFO "Lost AP beacon [%d] sec, disconnected !\n", pMgmt->sNodeDBTable[0].uInActiveCount);
+ //let wpa supplicant know AP may disconnect.//20080717-01,<Add> by James Li
+ 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;
+ pDevice->skb->mac_header = pDevice->skb->data;
+ 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;
+ PRINT_K("wireless_send_event--->SIOCGIWAP(disassociated)\n");
+ wireless_send_event(pDevice->dev, SIOCGIWAP, &wrqu, NULL);
+ }
+ #endif
+ }
+ }
+ else if (pItemSSID->len != 0) {
+//Davidwang
+ if ((pDevice->bEnableRoaming == TRUE)&&(!(pMgmt->Cisco_cckm))) {
+DBG_PRT(MSG_LEVEL_DEBUG, KERN_INFO "bRoaming %d, !\n", pDevice->bRoaming );
+DBG_PRT(MSG_LEVEL_DEBUG, KERN_INFO "bIsRoaming %d, !\n", pDevice->bIsRoaming );
+ if ((pDevice->bRoaming == TRUE)&&(pDevice->bIsRoaming == TRUE)){
+ DBG_PRT(MSG_LEVEL_DEBUG, KERN_INFO "Fast Roaming ...\n");
+ BSSvClearBSSList((HANDLE)pDevice, pDevice->bLinkPass);
+ bScheduleCommand((HANDLE) pDevice, WLAN_CMD_BSSID_SCAN, pMgmt->abyDesireSSID);
+ bScheduleCommand((HANDLE) pDevice, WLAN_CMD_SSID, pMgmt->abyDesireSSID);
+ pDevice->uAutoReConnectTime = 0;
+ pDevice->uIsroamingTime = 0;
+ pDevice->bRoaming = FALSE;
+
+// if ((pDevice->bWPADEVUp) && (pDevice->skb != NULL)) {
+ wpahdr = (viawget_wpa_header *)pDevice->skb->data;
+ wpahdr->type = VIAWGET_CCKM_ROAM_MSG;
+ wpahdr->resp_ie_len = 0;
+ wpahdr->req_ie_len = 0;
+ skb_put(pDevice->skb, sizeof(viawget_wpa_header));
+ pDevice->skb->dev = pDevice->wpadev;
+ pDevice->skb->mac_header = pDevice->skb->data;
+ 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);
+
+// }
+ }
+ else if ((pDevice->bRoaming == FALSE)&&(pDevice->bIsRoaming == TRUE)) {
+ pDevice->uIsroamingTime++;
+ if (pDevice->uIsroamingTime >= 20)
+ pDevice->bIsRoaming = FALSE;
+ }
+
+ }
+else {
+ 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;
+
+ DBG_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 {
+ DBG_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) {
+ DBG_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;
+ ControlvMaskByte(pDevice,MESSAGE_REQUEST_MACREG,MAC_REG_PAPEDELAY,LEDSTS_STS,LEDSTS_SLOW);
+ }
+ }
+ }
+
+ if (pDevice->bLinkPass == TRUE) {
+ if (netif_queue_stopped(pDevice->dev))
+ netif_wake_queue(pDevice->dev);
+ }
+
+ 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 PSStatCounter pStatistic,
+ IN BYTE byTSR,
+ IN BYTE byPktNO
+ )
+{
+ PSDevice pDevice = (PSDevice)hDeviceContext;
+ PSMgmtObject pMgmt = &(pDevice->sMgmtObj);
+ UINT uNodeIndex = 0;
+ BYTE byTxRetry;
+ WORD wRate;
+ WORD wFallBackRate = RATE_1M;
+ BYTE byFallBack;
+ UINT ii;
+ PBYTE pbyDestAddr;
+ BYTE byPktNum;
+ WORD wFIFOCtl;
+
+
+
+ byPktNum = (byPktNO & 0x0F) >> 4;
+ byTxRetry = (byTSR & 0xF0) >> 4;
+ wRate = (WORD) (byPktNO & 0xF0) >> 4;
+ wFIFOCtl = pStatistic->abyTxPktInfo[byPktNum].wFIFOCtl;
+ pbyDestAddr = (PBYTE) &( pStatistic->abyTxPktInfo[byPktNum].abyDestAddr[0]);
+
+ if (wFIFOCtl & FIFOCTL_AUTO_FB_0) {
+ byFallBack = AUTO_FB_0;
+ } else if (wFIFOCtl & FIFOCTL_AUTO_FB_1) {
+ byFallBack = AUTO_FB_1;
+ } else {
+ byFallBack = AUTO_FB_NONE;
+ }
+
+ // Only Unicast using support rates
+ if (wFIFOCtl & FIFOCTL_NEEDACK) {
+ //DBG_PRN_GRP21(("Device %08X, wRate %04X, byTSR %02X\n", hDeviceContext, wRate, byTSR));
+ if (pMgmt->eCurrMode == WMAC_MODE_ESS_STA) {
+ pMgmt->sNodeDBTable[0].uTxAttempts += 1;
+ if (BITbIsAllBitsOff(byTSR, (TSR_TMO | TSR_RETRYTMO))) {
+ // 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) {
+ 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[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) {
+ for(ii=0;ii<byTxRetry;ii++) {
+ if (ii < 5)
+ wFallBackRate = awHWRetry0[wRate-RATE_18M][ii];
+ else
+ wFallBackRate = awHWRetry0[wRate-RATE_18M][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)) {
+
+ if (BSSbIsSTAInNodeDB((HANDLE)pDevice, pbyDestAddr, &uNodeIndex)){
+ pMgmt->sNodeDBTable[uNodeIndex].uTxAttempts += 1;
+ if (BITbIsAllBitsOff(byTSR, (TSR_TMO | TSR_RETRYTMO))) {
+ // 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->sMgmtObj);
+ 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){
+ DBG_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->sMgmtObj);
+ int ii;
+
+ 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++) {
+ DBG_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;
+ }
+ }
+ }
+ }
+}
+
+#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
+BSSvClearAnyBSSJoinRecord (
+ IN HANDLE hDeviceContext
+ )
+{
+ PSDevice pDevice = (PSDevice)hDeviceContext;
+ PSMgmtObject pMgmt = &(pDevice->sMgmtObj);
+ UINT ii;
+
+ for (ii = 0; ii < MAX_BSS_NUM; ii++) {
+ pMgmt->sBSSList[ii].bSelected = FALSE;
+ }
+ return;
+}
+
+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/vt6656/bssdb.h b/drivers/staging/vt6656/bssdb.h
new file mode 100644
index 000000000000..bcea3ad5e89b
--- /dev/null
+++ b/drivers/staging/vt6656/bssdb.h
@@ -0,0 +1,370 @@
+/*
+ * 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__
+
+
+#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
+#if !defined(__MIB_H__)
+#include "mib.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 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
+
+ CARD_PHY_TYPE eNetworkTypeInUse;
+
+ ERPObject sERP;
+ SRSNCapObject sRSNCapObj;
+ BYTE abyIEs[1024]; // don't move this field !!
+
+}__attribute__ ((__packed__))
+KnownBSS , DEF* PKnownBSS;
+
+
+
+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
+BSSbIsSTAInNodeDB(
+ 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 PSStatCounter pStatistic,
+ IN BYTE byTSR,
+ IN BYTE byPktNO
+ );
+
+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/vt6656/card.c b/drivers/staging/vt6656/card.c
new file mode 100644
index 000000000000..f1f5f35aa8ed
--- /dev/null
+++ b/drivers/staging/vt6656/card.c
@@ -0,0 +1,1147 @@
+/*
+ * 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(__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
+#if !defined(__DATARATE_H__)
+#include "datarate.h"
+#endif
+#if !defined(__RNDIS_H__)
+#include "rndis.h"
+#endif
+#if !defined(__CONTROL_H__)
+#include "control.h"
+#endif
+
+
+
+/*--------------------- Static Definitions -------------------------*/
+
+//static int msglevel =MSG_LEVEL_DEBUG;
+static int msglevel =MSG_LEVEL_INFO;
+
+
+/*--------------------- Static Definitions -------------------------*/
+#define CB_TXPOWER_LEVEL 6
+
+/*--------------------- Static Classes ----------------------------*/
+
+/*--------------------- Static Variables --------------------------*/
+//const WORD cwRXBCNTSFOff[MAX_RATE] =
+//{17, 34, 96, 192, 34, 23, 17, 11, 8, 5, 4, 3};
+
+const WORD cwRXBCNTSFOff[MAX_RATE] =
+{192, 96, 34, 17, 34, 23, 17, 11, 8, 5, 4, 3};
+
+/*--------------------- Static Functions --------------------------*/
+
+/*--------------------- Export Variables --------------------------*/
+
+/*--------------------- Export Functions --------------------------*/
+/*
+ * Description: Set NIC media channel
+ *
+ * Parameters:
+ * In:
+ * pDevice - The adapter to be set
+ * uConnectionChannel - Channel to be set
+ * Out:
+ * none
+ *
+ * Return Value: TRUE if succeeded; FALSE if failed.
+ *
+ */
+BOOL CARDbSetMediaChannel (PVOID pDeviceHandler, UINT uConnectionChannel)
+{
+PSDevice pDevice = (PSDevice) pDeviceHandler;
+BOOL bResult = TRUE;
+
+
+ if (pDevice->byBBType == BB_TYPE_11A) { // 15 ~ 38
+ if ((uConnectionChannel < (CB_MAX_CHANNEL_24G+1)) || (uConnectionChannel > CB_MAX_CHANNEL))
+ uConnectionChannel = (CB_MAX_CHANNEL_24G+1);
+ } else {
+ if ((uConnectionChannel > CB_MAX_CHANNEL_24G) || (uConnectionChannel == 0)) // 1 ~ 14
+ uConnectionChannel = 1;
+ }
+
+ // clear NAV
+ MACvRegBitsOn(pDevice, MAC_REG_MACCR, MACCR_CLRNAV);
+
+ // Set Channel[7] = 0 to tell H/W channel is changing now.
+ MACvRegBitsOff(pDevice, MAC_REG_CHANNEL, 0x80);
+
+ //if (pMgmt->uCurrChannel == uConnectionChannel)
+ // return bResult;
+
+ CONTROLnsRequestOut(pDevice,
+ MESSAGE_TYPE_SELECT_CHANNLE,
+ (WORD) uConnectionChannel,
+ 0,
+ 0,
+ NULL
+ );
+
+ //{{ RobertYu: 20041202
+ //// TX_PE will reserve 3 us for MAX2829 A mode only, it is for better TX throughput
+
+ if (pDevice->byBBType == BB_TYPE_11A) {
+ pDevice->byCurPwr = 0xFF;
+ RFbRawSetPower(pDevice, pDevice->abyOFDMAPwrTbl[uConnectionChannel-15], RATE_54M);
+ } else if (pDevice->byBBType == BB_TYPE_11G) {
+ pDevice->byCurPwr = 0xFF;
+ RFbRawSetPower(pDevice, pDevice->abyOFDMPwrTbl[uConnectionChannel-1], RATE_54M);
+ } else {
+ pDevice->byCurPwr = 0xFF;
+ RFbRawSetPower(pDevice, pDevice->abyCCKPwrTbl[uConnectionChannel-1], RATE_1M);
+ }
+ ControlvWriteByte(pDevice,MESSAGE_REQUEST_MACREG,MAC_REG_CHANNEL,(BYTE)(uConnectionChannel|0x80));
+ return(bResult);
+}
+
+/*
+ * Description: Get CCK mode basic rate
+ *
+ * Parameters:
+ * In:
+ * pDevice - The adapter to be set
+ * wRateIdx - Receiving data rate
+ * Out:
+ * none
+ *
+ * Return Value: response Control frame rate
+ *
+ */
+static
+WORD swGetCCKControlRate(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 OFDM mode basic rate
+ *
+ * Parameters:
+ * In:
+ * pDevice - The adapter to be set
+ * wRateIdx - Receiving data rate
+ * Out:
+ * none
+ *
+ * Return Value: response Control frame rate
+ *
+ */
+static
+WORD swGetOFDMControlRate (PVOID pDeviceHandler, WORD wRateIdx)
+{
+ PSDevice pDevice = (PSDevice) pDeviceHandler;
+ UINT ui = (UINT)wRateIdx;
+
+ DBG_PRT(MSG_LEVEL_DEBUG, KERN_INFO"BASIC RATE: %X\n", pDevice->wBasicRate);
+
+ if (!CARDbIsOFDMinBasicRate(pDevice)) {
+ DBG_PRT(MSG_LEVEL_DEBUG, KERN_INFO"swGetOFDMControlRate:(NO OFDM) %d\n", wRateIdx);
+ if (wRateIdx > RATE_24M)
+ wRateIdx = RATE_24M;
+ return wRateIdx;
+ }
+ while (ui > RATE_11M) {
+ if (pDevice->wBasicRate & ((WORD)1 << ui)) {
+ DBG_PRT(MSG_LEVEL_DEBUG, KERN_INFO"swGetOFDMControlRate : %d\n", ui);
+ return (WORD)ui;
+ }
+ ui --;
+ }
+ DBG_PRT(MSG_LEVEL_DEBUG, KERN_INFO"swGetOFDMControlRate: 6M\n");
+ return (WORD)RATE_24M;
+}
+
+/*
+ * 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
+ *
+ */
+VOID
+CARDvCaculateOFDMRParameter (
+ IN WORD wRate,
+ IN BYTE byBBType,
+ OUT PBYTE pbyTxRate,
+ OUT PBYTE pbyRsvTime
+ )
+{
+ switch (wRate) {
+ case RATE_6M :
+ if (byBBType == BB_TYPE_11A) {//5GHZ
+ *pbyTxRate = 0x9B;
+ *pbyRsvTime = 24;
+ }
+ else {
+ *pbyTxRate = 0x8B;
+ *pbyRsvTime = 30;
+ }
+ break;
+
+ case RATE_9M :
+ if (byBBType == BB_TYPE_11A) {//5GHZ
+ *pbyTxRate = 0x9F;
+ *pbyRsvTime = 16;
+ }
+ else {
+ *pbyTxRate = 0x8F;
+ *pbyRsvTime = 22;
+ }
+ break;
+
+ case RATE_12M :
+ if (byBBType == BB_TYPE_11A) {//5GHZ
+ *pbyTxRate = 0x9A;
+ *pbyRsvTime = 12;
+ }
+ else {
+ *pbyTxRate = 0x8A;
+ *pbyRsvTime = 18;
+ }
+ break;
+
+ case RATE_18M :
+ if (byBBType == BB_TYPE_11A) {//5GHZ
+ *pbyTxRate = 0x9E;
+ *pbyRsvTime = 8;
+ }
+ else {
+ *pbyTxRate = 0x8E;
+ *pbyRsvTime = 14;
+ }
+ break;
+
+ case RATE_36M :
+ if (byBBType == BB_TYPE_11A) {//5GHZ
+ *pbyTxRate = 0x9D;
+ *pbyRsvTime = 4;
+ }
+ else {
+ *pbyTxRate = 0x8D;
+ *pbyRsvTime = 10;
+ }
+ break;
+
+ case RATE_48M :
+ if (byBBType == BB_TYPE_11A) {//5GHZ
+ *pbyTxRate = 0x98;
+ *pbyRsvTime = 4;
+ }
+ else {
+ *pbyTxRate = 0x88;
+ *pbyRsvTime = 10;
+ }
+ break;
+
+ case RATE_54M :
+ if (byBBType == BB_TYPE_11A) {//5GHZ
+ *pbyTxRate = 0x9C;
+ *pbyRsvTime = 4;
+ }
+ else {
+ *pbyTxRate = 0x8C;
+ *pbyRsvTime = 10;
+ }
+ break;
+
+ case RATE_24M :
+ default :
+ if (byBBType == BB_TYPE_11A) {//5GHZ
+ *pbyTxRate = 0x99;
+ *pbyRsvTime = 8;
+ }
+ else {
+ *pbyTxRate = 0x89;
+ *pbyRsvTime = 14;
+ }
+ break;
+ }
+}
+
+/*
+ * Description: Set RSPINF
+ *
+ * Parameters:
+ * In:
+ * pDevice - The adapter to be set
+ * Out:
+ * none
+ *
+ * Return Value: None.
+ *
+ */
+void CARDvSetRSPINF (PVOID pDeviceHandler, BYTE byBBType)
+{
+ PSDevice pDevice = (PSDevice) pDeviceHandler;
+ BYTE abyServ[4] = {0,0,0,0}; // For CCK
+ BYTE abySignal[4] = {0,0,0,0};
+ WORD awLen[4] = {0,0,0,0};
+ BYTE abyTxRate[9] = {0,0,0,0,0,0,0,0,0}; // For OFDM
+ BYTE abyRsvTime[9] = {0,0,0,0,0,0,0,0,0};
+ BYTE abyData[34];
+ int i;
+
+ //RSPINF_b_1
+ BBvCaculateParameter(pDevice,
+ 14,
+ swGetCCKControlRate(pDevice, RATE_1M),
+ PK_TYPE_11B,
+ &awLen[0],
+ &abyServ[0],
+ &abySignal[0]
+ );
+
+ ///RSPINF_b_2
+ BBvCaculateParameter(pDevice,
+ 14,
+ swGetCCKControlRate(pDevice, RATE_2M),
+ PK_TYPE_11B,
+ &awLen[1],
+ &abyServ[1],
+ &abySignal[1]
+ );
+
+ //RSPINF_b_5
+ BBvCaculateParameter(pDevice,
+ 14,
+ swGetCCKControlRate(pDevice, RATE_5M),
+ PK_TYPE_11B,
+ &awLen[2],
+ &abyServ[2],
+ &abySignal[2]
+ );
+
+ //RSPINF_b_11
+ BBvCaculateParameter(pDevice,
+ 14,
+ swGetCCKControlRate(pDevice, RATE_11M),
+ PK_TYPE_11B,
+ &awLen[3],
+ &abyServ[3],
+ &abySignal[3]
+ );
+
+ //RSPINF_a_6
+ CARDvCaculateOFDMRParameter (RATE_6M,
+ byBBType,
+ &abyTxRate[0],
+ &abyRsvTime[0]);
+
+ //RSPINF_a_9
+ CARDvCaculateOFDMRParameter (RATE_9M,
+ byBBType,
+ &abyTxRate[1],
+ &abyRsvTime[1]);
+
+ //RSPINF_a_12
+ CARDvCaculateOFDMRParameter (RATE_12M,
+ byBBType,
+ &abyTxRate[2],
+ &abyRsvTime[2]);
+
+ //RSPINF_a_18
+ CARDvCaculateOFDMRParameter (RATE_18M,
+ byBBType,
+ &abyTxRate[3],
+ &abyRsvTime[3]);
+
+ //RSPINF_a_24
+ CARDvCaculateOFDMRParameter (RATE_24M,
+ byBBType,
+ &abyTxRate[4],
+ &abyRsvTime[4]);
+
+ //RSPINF_a_36
+ CARDvCaculateOFDMRParameter (swGetOFDMControlRate(pDevice, RATE_36M),
+ byBBType,
+ &abyTxRate[5],
+ &abyRsvTime[5]);
+
+ //RSPINF_a_48
+ CARDvCaculateOFDMRParameter (swGetOFDMControlRate(pDevice, RATE_48M),
+ byBBType,
+ &abyTxRate[6],
+ &abyRsvTime[6]);
+
+ //RSPINF_a_54
+ CARDvCaculateOFDMRParameter (swGetOFDMControlRate(pDevice, RATE_54M),
+ byBBType,
+ &abyTxRate[7],
+ &abyRsvTime[7]);
+
+ //RSPINF_a_72
+ CARDvCaculateOFDMRParameter (swGetOFDMControlRate(pDevice, RATE_54M),
+ byBBType,
+ &abyTxRate[8],
+ &abyRsvTime[8]);
+
+ abyData[0] = (BYTE)(awLen[0]&0xFF);
+ abyData[1] = (BYTE)(awLen[0]>>8);
+ abyData[2] = abySignal[0];
+ abyData[3] = abyServ[0];
+
+ abyData[4] = (BYTE)(awLen[1]&0xFF);
+ abyData[5] = (BYTE)(awLen[1]>>8);
+ abyData[6] = abySignal[1];
+ abyData[7] = abyServ[1];
+
+ abyData[8] = (BYTE)(awLen[2]&0xFF);
+ abyData[9] = (BYTE)(awLen[2]>>8);
+ abyData[10] = abySignal[2];
+ abyData[11] = abyServ[2];
+
+ abyData[12] = (BYTE)(awLen[3]&0xFF);
+ abyData[13] = (BYTE)(awLen[3]>>8);
+ abyData[14] = abySignal[3];
+ abyData[15] = abyServ[3];
+
+ for(i=0;i<9;i++) {
+ abyData[16+i*2] = abyTxRate[i];
+ abyData[16+i*2+1] = abyRsvTime[i];
+ }
+
+
+ CONTROLnsRequestOut(pDevice,
+ MESSAGE_TYPE_WRITE,
+ MAC_REG_RSPINF_B_1,
+ MESSAGE_REQUEST_MACREG,
+ 34,
+ &abyData[0]);
+
+}
+
+/*
+ * Description: Update IFS
+ *
+ * Parameters:
+ * In:
+ * pDevice - The adapter to be set
+ * Out:
+ * none
+ *
+ * Return Value: None.
+ *
+ */
+void vUpdateIFS (PVOID pDeviceHandler)
+{
+ PSDevice pDevice = (PSDevice) pDeviceHandler;
+ //Set SIFS, DIFS, EIFS, SlotTime, CwMin
+ BYTE byMaxMin = 0;
+ BYTE byData[4];
+
+ 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
+ BYTE byRate = 0;
+ BOOL bOFDMRate = FALSE;
+ UINT ii = 0;
+ PWLAN_IE_SUPP_RATES pItemRates = NULL;
+
+ 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;
+
+ pItemRates = (PWLAN_IE_SUPP_RATES)pDevice->sMgmtObj.abyCurrSuppRates;
+ for (ii = 0; ii < pItemRates->len; ii++) {
+ byRate = (BYTE)(pItemRates->abyRates[ii]&0x7F);
+ if (RATEwGetRateIdx(byRate) > RATE_11M) {
+ bOFDMRate = TRUE;
+ break;
+ }
+ }
+ if (bOFDMRate == FALSE) {
+ pItemRates = (PWLAN_IE_SUPP_RATES)pDevice->sMgmtObj.abyCurrExtSuppRates;
+ for (ii = 0; ii < pItemRates->len; ii++) {
+ byRate = (BYTE)(pItemRates->abyRates[ii]&0x7F);
+ if (RATEwGetRateIdx(byRate) > RATE_11M) {
+ bOFDMRate = TRUE;
+ break;
+ }
+ }
+ }
+ if (bOFDMRate == TRUE) {
+ pDevice->uCwMin = C_CWMIN_A;
+ byMaxMin = 4;
+ } else {
+ pDevice->uCwMin = C_CWMIN_B;
+ byMaxMin = 5;
+ }
+ }
+
+ pDevice->uCwMax = C_CWMAX;
+ pDevice->uEIFS = C_EIFS;
+
+ byData[0] = (BYTE)pDevice->uSIFS;
+ byData[1] = (BYTE)pDevice->uDIFS;
+ byData[2] = (BYTE)pDevice->uEIFS;
+ byData[3] = (BYTE)pDevice->uSlot;
+ CONTROLnsRequestOut(pDevice,
+ MESSAGE_TYPE_WRITE,
+ MAC_REG_SIFS,
+ MESSAGE_REQUEST_MACREG,
+ 4,
+ &byData[0]);
+
+ byMaxMin |= 0xA0;//1010 1111,C_CWMAX = 1023
+ CONTROLnsRequestOut(pDevice,
+ MESSAGE_TYPE_WRITE,
+ MAC_REG_CWMAXMIN0,
+ MESSAGE_REQUEST_MACREG,
+ 1,
+ &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(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(pDevice)) {
+ return PK_TYPE_11GA;
+ }
+ else {
+ return PK_TYPE_11GB;
+ }
+}
+
+
+/*
+ * 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: Sync. TSF counter to BSS
+ * Get TSF offset and write to HW
+ *
+ * Parameters:
+ * In:
+ * pDevice - The adapter to be sync.
+ * qwBSSTimestamp - Rx BCN's TSF
+ * qwLocalTSF - Local TSF
+ * Out:
+ * none
+ *
+ * Return Value: none
+ *
+ */
+void CARDvAdjustTSF (PVOID pDeviceHandler, BYTE byRxRate, QWORD qwBSSTimestamp, QWORD qwLocalTSF)
+{
+
+ PSDevice pDevice = (PSDevice) pDeviceHandler;
+ QWORD qwTSFOffset;
+ DWORD dwTSFOffset1,dwTSFOffset2;
+ BYTE pbyData[8];
+
+ HIDWORD(qwTSFOffset) = 0;
+ LODWORD(qwTSFOffset) = 0;
+
+ qwTSFOffset = CARDqGetTSFOffset(byRxRate, qwBSSTimestamp, qwLocalTSF);
+ // adjust TSF
+ // HW's TSF add TSF Offset reg
+ dwTSFOffset1 = LODWORD(qwTSFOffset);
+ dwTSFOffset2 = HIDWORD(qwTSFOffset);
+
+
+ pbyData[0] = (BYTE)dwTSFOffset1;
+ pbyData[1] = (BYTE)(dwTSFOffset1>>8);
+ pbyData[2] = (BYTE)(dwTSFOffset1>>16);
+ pbyData[3] = (BYTE)(dwTSFOffset1>>24);
+ pbyData[4] = (BYTE)dwTSFOffset2;
+ pbyData[5] = (BYTE)(dwTSFOffset2>>8);
+ pbyData[6] = (BYTE)(dwTSFOffset2>>16);
+ pbyData[7] = (BYTE)(dwTSFOffset2>>24);
+
+ CONTROLnsRequestOut(pDevice,
+ MESSAGE_TYPE_SET_TSFTBTT,
+ MESSAGE_REQUEST_TSF,
+ 0,
+ 8,
+ pbyData
+ );
+
+}
+/*
+ * 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 (PVOID pDeviceHandler, PQWORD pqwCurrTSF)
+{
+ PSDevice pDevice = (PSDevice) pDeviceHandler;
+
+ LODWORD(*pqwCurrTSF) = LODWORD(pDevice->qwCurrTSF);
+ HIDWORD(*pqwCurrTSF) = HIDWORD(pDevice->qwCurrTSF);
+
+ return(TRUE);
+}
+
+
+/*
+ * Description: Clear NIC TSF counter
+ * Clear local TSF counter
+ *
+ * Parameters:
+ * In:
+ * pDevice - The adapter to be read
+ *
+ * Return Value: TRUE if success; otherwise FALSE
+ *
+ */
+BOOL CARDbClearCurrentTSF(PVOID pDeviceHandler)
+{
+ PSDevice pDevice = (PSDevice) pDeviceHandler;
+
+ MACvRegBitsOn(pDevice,MAC_REG_TFTCTL,TFTCTL_TSFCNTRST);
+
+ LODWORD(pDevice->qwCurrTSF) = 0;
+ HIDWORD(pDevice->qwCurrTSF) = 0;
+
+ 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;
+ uLowRemain = (uLowNextTBTT) % uBeaconInterval;
+ uHighRemain = ((0x80000000 % uBeaconInterval)* 2 * 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 (PVOID pDeviceHandler, WORD wBeaconInterval)
+{
+
+ PSDevice pDevice = (PSDevice) pDeviceHandler;
+ QWORD qwNextTBTT;
+ DWORD dwLoTBTT,dwHiTBTT;
+ BYTE pbyData[8];
+
+ HIDWORD(qwNextTBTT) = 0;
+ LODWORD(qwNextTBTT) = 0;
+ CARDbClearCurrentTSF(pDevice);
+ //CARDbGetCurrentTSF(pDevice, &qwNextTBTT); //Get Local TSF counter
+ qwNextTBTT = CARDqGetNextTBTT(qwNextTBTT, wBeaconInterval);
+ // Set NextTBTT
+
+ dwLoTBTT = LODWORD(qwNextTBTT);
+ dwHiTBTT = HIDWORD(qwNextTBTT);
+
+ pbyData[0] = (BYTE)dwLoTBTT;
+ pbyData[1] = (BYTE)(dwLoTBTT>>8);
+ pbyData[2] = (BYTE)(dwLoTBTT>>16);
+ pbyData[3] = (BYTE)(dwLoTBTT>>24);
+ pbyData[4] = (BYTE)dwHiTBTT;
+ pbyData[5] = (BYTE)(dwHiTBTT>>8);
+ pbyData[6] = (BYTE)(dwHiTBTT>>16);
+ pbyData[7] = (BYTE)(dwHiTBTT>>24);
+
+ CONTROLnsRequestOut(pDevice,
+ MESSAGE_TYPE_SET_TSFTBTT,
+ MESSAGE_REQUEST_TBTT,
+ 0,
+ 8,
+ pbyData
+ );
+
+ 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 (PVOID pDeviceHandler, QWORD qwTSF, WORD wBeaconInterval)
+{
+ PSDevice pDevice = (PSDevice) pDeviceHandler;
+ DWORD dwLoTBTT,dwHiTBTT;
+ BYTE pbyData[8];
+
+ qwTSF = CARDqGetNextTBTT(qwTSF, wBeaconInterval);
+
+ // Set NextTBTT
+ dwLoTBTT = LODWORD(qwTSF);
+ dwHiTBTT = HIDWORD(qwTSF);
+
+ pbyData[0] = (BYTE)dwLoTBTT;
+ pbyData[1] = (BYTE)(dwLoTBTT>>8);
+ pbyData[2] = (BYTE)(dwLoTBTT>>16);
+ pbyData[3] = (BYTE)(dwLoTBTT>>24);
+ pbyData[4] = (BYTE)dwHiTBTT;
+ pbyData[5] = (BYTE)(dwHiTBTT>>8);
+ pbyData[6] = (BYTE)(dwHiTBTT>>16);
+ pbyData[7] = (BYTE)(dwHiTBTT>>24);
+
+ CONTROLnsRequestOut(pDevice,
+ MESSAGE_TYPE_SET_TSFTBTT,
+ MESSAGE_REQUEST_TBTT,
+ 0,
+ 8,
+ pbyData
+ );
+
+
+ DBG_PRT(MSG_LEVEL_DEBUG, KERN_INFO"Card:Update Next TBTT[%8xh:%8xh] \n",(int)HIDWORD(qwTSF), (int)LODWORD(qwTSF));
+
+ return;
+}
+
+/*
+ * 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;
+
+ pDevice->bRadioOff = TRUE;
+
+ switch (pDevice->byRFType) {
+ case RF_AL2230:
+ case RF_AL2230S:
+ case RF_AIROHA7230:
+ case RF_VT3226: //RobertYu:20051111
+ case RF_VT3226D0:
+ case RF_VT3342A0: //RobertYu:20060609
+ MACvRegBitsOff(pDevice, MAC_REG_SOFTPWRCTL, (SOFTPWRCTL_SWPE2 | SOFTPWRCTL_SWPE3));
+ break;
+ }
+
+ MACvRegBitsOff(pDevice, MAC_REG_HOSTCR, HOSTCR_RXON);
+
+ BBvSetDeepSleep(pDevice);
+
+ 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;
+
+
+ if ((pDevice->bHWRadioOff == TRUE) || (pDevice->bRadioControlOff == TRUE)) {
+ return FALSE;
+ }
+
+ //if (pDevice->bRadioOff == FALSE)
+ // return TRUE;
+
+ pDevice->bRadioOff = FALSE;
+
+ BBvExitDeepSleep(pDevice);
+
+ MACvRegBitsOn(pDevice, MAC_REG_HOSTCR, HOSTCR_RXON);
+
+ switch (pDevice->byRFType) {
+ case RF_AL2230:
+ case RF_AL2230S:
+ case RF_AIROHA7230:
+ case RF_VT3226: //RobertYu:20051111
+ case RF_VT3226D0:
+ case RF_VT3342A0: //RobertYu:20060609
+ MACvRegBitsOn(pDevice, MAC_REG_SOFTPWRCTL, (SOFTPWRCTL_SWPE2 | SOFTPWRCTL_SWPE3));
+ break;
+ }
+
+ return bResult;
+}
+
+void CARDvSetBSSMode (PVOID pDeviceHandler)
+{
+ PSDevice pDevice = (PSDevice) pDeviceHandler;
+ // Set BB and packet type at the same time.//{{RobertYu:20050222, AL7230 have two TX PA output, only connet to b/g now
+ // so in 11a mode need to set the MAC Reg0x4C to 11b/g mode to turn on PA
+ if( (pDevice->byRFType == RF_AIROHA7230 ) && (pDevice->byBBType == BB_TYPE_11A) )
+ {
+ MACvSetBBType(pDevice, BB_TYPE_11G);
+ }
+ else
+ {
+ MACvSetBBType(pDevice, pDevice->byBBType);
+ }
+ pDevice->byPacketType = CARDbyGetPktType(pDevice);
+
+ if (pDevice->byBBType == BB_TYPE_11A) {
+ ControlvWriteByte(pDevice, MESSAGE_REQUEST_BBREG, 0x88, 0x03);
+ } else if (pDevice->byBBType == BB_TYPE_11B) {
+ ControlvWriteByte(pDevice, MESSAGE_REQUEST_BBREG, 0x88, 0x02);
+ } else if (pDevice->byBBType == BB_TYPE_11G) {
+ ControlvWriteByte(pDevice, MESSAGE_REQUEST_BBREG, 0x88, 0x08);
+ }
+
+ vUpdateIFS(pDevice);
+ CARDvSetRSPINF(pDevice, (BYTE)pDevice->byBBType);
+
+ if ( pDevice->byBBType == BB_TYPE_11A ) {
+ //request by Jack 2005-04-26
+ if (pDevice->byRFType == RF_AIROHA7230) {
+ pDevice->abyBBVGA[0] = 0x20;
+ ControlvWriteByte(pDevice, MESSAGE_REQUEST_BBREG, 0xE7, pDevice->abyBBVGA[0]);
+ }
+ pDevice->abyBBVGA[2] = 0x10;
+ pDevice->abyBBVGA[3] = 0x10;
+ } else {
+ //request by Jack 2005-04-26
+ if (pDevice->byRFType == RF_AIROHA7230) {
+ pDevice->abyBBVGA[0] = 0x1C;
+ ControlvWriteByte(pDevice, MESSAGE_REQUEST_BBREG, 0xE7, pDevice->abyBBVGA[0]);
+ }
+ pDevice->abyBBVGA[2] = 0x0;
+ pDevice->abyBBVGA[3] = 0x0;
+ }
+}
+
+/*
+ *
+ * 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) {
+ pDevice->sMgmtObj.uCurrChannel = byNewChannel;
+ bResult = CARDbSetMediaChannel(pDevice, byNewChannel);
+
+ return(bResult);
+ }
+ pDevice->byChannelSwitchCount = byCount;
+ pDevice->byNewChannel = byNewChannel;
+ pDevice->bChannelSwitch = TRUE;
+
+ if (byMode == 1) {
+ //bResult=CARDbStopTxPacket(pDevice, PKT_TYPE_802_11_ALL);
+ pDevice->bStopDataPkt = TRUE;
+ }
+ return (bResult);
+}
+
+
+
+
+
+
diff --git a/drivers/staging/vt6656/card.h b/drivers/staging/vt6656/card.h
new file mode 100644
index 000000000000..6d623bedfcd7
--- /dev/null
+++ b/drivers/staging/vt6656/card.h
@@ -0,0 +1,109 @@
+/*
+ * 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(__TTYPE_H__)
+#include "ttype.h"
+#endif
+
+
+/*--------------------- Export Definitions -------------------------*/
+
+
+/*--------------------- Export Classes ----------------------------*/
+
+// Init card type
+
+typedef enum _CARD_PHY_TYPE {
+
+ PHY_TYPE_AUTO=0,
+ PHY_TYPE_11B,
+ PHY_TYPE_11G,
+ PHY_TYPE_11A
+} CARD_PHY_TYPE, DEF* PCARD_PHY_TYPE;
+
+typedef enum _CARD_OP_MODE {
+
+ OP_MODE_INFRASTRUCTURE=0,
+ OP_MODE_ADHOC,
+ OP_MODE_AP,
+ OP_MODE_UNKNOWN
+} CARD_OP_MODE, *PCARD_OP_MODE;
+
+#define CB_MAX_CHANNEL_24G 14
+//#define CB_MAX_CHANNEL_5G 24
+#define CB_MAX_CHANNEL_5G 42 //[20050104] add channel9(5045MHz), 41==>42
+#define CB_MAX_CHANNEL (CB_MAX_CHANNEL_24G+CB_MAX_CHANNEL_5G)
+
+/*--------------------- Export Variables --------------------------*/
+
+/*--------------------- Export Functions --------------------------*/
+#ifdef __cplusplus
+extern "C" { /* Assume C declarations for C++ */
+#endif /* __cplusplus */
+
+
+BOOL CARDbSetMediaChannel(PVOID pDeviceHandler, UINT uConnectionChannel);
+void CARDvSetRSPINF(PVOID pDeviceHandler, BYTE byBBType);
+void vUpdateIFS(PVOID pDeviceHandler);
+void CARDvUpdateBasicTopRate(PVOID pDeviceHandler);
+BOOL CARDbAddBasicRate(PVOID pDeviceHandler, WORD wRateIdx);
+BOOL CARDbIsOFDMinBasicRate(PVOID pDeviceHandler);
+void CARDvAdjustTSF(PVOID pDeviceHandler, BYTE byRxRate, QWORD qwBSSTimestamp, QWORD qwLocalTSF);
+BOOL CARDbGetCurrentTSF (PVOID pDeviceHandler, PQWORD pqwCurrTSF);
+BOOL CARDbClearCurrentTSF(PVOID pDeviceHandler);
+void CARDvSetFirstNextTBTT(PVOID pDeviceHandler, WORD wBeaconInterval);
+void CARDvUpdateNextTBTT(PVOID pDeviceHandler, QWORD qwTSF, WORD wBeaconInterval);
+QWORD CARDqGetNextTBTT(QWORD qwTSF, WORD wBeaconInterval);
+QWORD CARDqGetTSFOffset(BYTE byRxRate, QWORD qwTSF1, QWORD qwTSF2);
+BOOL CARDbRadioPowerOff(PVOID pDeviceHandler);
+BOOL CARDbRadioPowerOn(PVOID pDeviceHandler);
+BYTE CARDbyGetPktType(PVOID pDeviceHandler);
+void CARDvSetBSSMode(PVOID pDeviceHandler);
+
+BOOL
+CARDbChannelSwitch (
+ IN PVOID pDeviceHandler,
+ IN BYTE byMode,
+ IN BYTE byNewChannel,
+ IN BYTE byCount
+ );
+
+
+#ifdef __cplusplus
+} /* End of extern "C" { */
+#endif /* __cplusplus */
+
+
+#endif // __CARD_H__
+
+
+
diff --git a/drivers/staging/vt6656/channel.c b/drivers/staging/vt6656/channel.c
new file mode 100644
index 000000000000..56308b0df5c1
--- /dev/null
+++ b/drivers/staging/vt6656/channel.c
@@ -0,0 +1,535 @@
+/*
+ * 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: channel.c
+ *
+ * Purpose: Channel number maping
+ *
+ * Author: Lucas Lin
+ *
+ * Date: Dec 24, 2004
+ *
+ *
+ *
+ * Revision History:
+ * 01-18-2005 RobertYu: remove the for loop searching in ChannelValid,
+ * change ChannelRuleTab to lookup-type, reorder table items.
+ *
+ *
+ */
+
+#if !defined (_COUNTRY_H_)
+#include "country.h"
+#endif
+#if !defined (_CHANNEL_H_)
+#include "channel.h"
+#endif
+#if !defined(__RF_H__)
+#include "rf.h"
+#endif
+#if !defined(__UMEM_H__)
+#include "umem.h"
+#endif
+
+
+/*--------------------- Static Definitions -------------------------*/
+static int msglevel =MSG_LEVEL_INFO;
+//static int msglevel =MSG_LEVEL_DEBUG;
+
+/*--------------------- Static Classes ----------------------------*/
+
+/*--------------------- Export Definitions -------------------------*/
+
+
+static SChannelTblElement sChannelTbl[CB_MAX_CHANNEL+1] =
+{
+ {0, 0, FALSE},
+ {1, 2412, TRUE},
+ {2, 2417, TRUE},
+ {3, 2422, TRUE},
+ {4, 2427, TRUE},
+ {5, 2432, TRUE},
+ {6, 2437, TRUE},
+ {7, 2442, TRUE},
+ {8, 2447, TRUE},
+ {9, 2452, TRUE},
+ {10, 2457, TRUE},
+ {11, 2462, TRUE},
+ {12, 2467, TRUE},
+ {13, 2472, TRUE},
+ {14, 2484, TRUE},
+ {183, 4915, TRUE}, //15
+ {184, 4920, TRUE}, //16
+ {185, 4925, TRUE}, //17
+ {187, 4935, TRUE}, //18
+ {188, 4940, TRUE}, //19
+ {189, 4945, TRUE}, //20
+ {192, 4960, TRUE}, //21
+ {196, 4980, TRUE}, //22
+ {7, 5035, TRUE}, //23
+ {8, 5040, TRUE}, //24
+ {9, 5045, TRUE}, //25
+ {11, 5055, TRUE}, //26
+ {12, 5060, TRUE}, //27
+ {16, 5080, TRUE}, //28
+ {34, 5170, TRUE}, //29
+ {36, 5180, TRUE}, //30
+ {38, 5190, TRUE}, //31
+ {40, 5200, TRUE}, //32
+ {42, 5210, TRUE}, //33
+ {44, 5220, TRUE}, //34
+ {46, 5230, TRUE}, //35
+ {48, 5240, TRUE}, //36
+ {52, 5260, TRUE}, //37
+ {56, 5280, TRUE}, //38
+ {60, 5300, TRUE}, //39
+ {64, 5320, TRUE}, //40
+ {100, 5500, TRUE}, //41
+ {104, 5520, TRUE}, //42
+ {108, 5540, TRUE}, //43
+ {112, 5560, TRUE}, //44
+ {116, 5580, TRUE}, //45
+ {120, 5600, TRUE}, //46
+ {124, 5620, TRUE}, //47
+ {128, 5640, TRUE}, //48
+ {132, 5660, TRUE}, //49
+ {136, 5680, TRUE}, //50
+ {140, 5700, TRUE}, //51
+ {149, 5745, TRUE}, //52
+ {153, 5765, TRUE}, //53
+ {157, 5785, TRUE}, //54
+ {161, 5805, TRUE}, //55
+ {165, 5825, TRUE} //56
+};
+
+
+
+/************************************************************************
+ * The Radar regulation rules for each country
+ ************************************************************************/
+static struct
+{
+ BYTE byChannelCountryCode; /* The country code */
+ CHAR chCountryCode[2];
+ BYTE bChannelIdxList[CB_MAX_CHANNEL]; /* Available channels Index */
+ BYTE byPower[CB_MAX_CHANNEL];
+} ChannelRuleTab[] =
+{
+/************************************************************************
+ * 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 */
+};
+
+#define NUM_RULES (sizeof(ChannelRuleTab) / sizeof(ChannelRuleTab[0]))
+
+/*--------------------- 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)
+ ************************************************************************/
+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 */
+
+/************************************************************************
+ * CHvChannelGetList
+ * Get Available Channel List for a given country
+ * Input:
+ * CountryCode = The country code defined in country.h
+ * Output:
+ * ChannelBitMask = (QWORD *) correspondent bit mask
+ * of available channels
+ * 0x0000000000000001 means channel 1 is supported
+ * 0x0000000000000003 means channel 1,2 are supported
+ * 0x000000000000000F means channel 1,2,..15 are supported
+ ************************************************************************/
+BOOL
+CHvChannelGetList (
+ IN UINT uCountryCodeIdx,
+ OUT PBYTE pbyChannelTable
+ )
+{
+ if (uCountryCodeIdx >= CCODE_MAX) {
+ return (FALSE);
+ }
+ MEMvCopy(pbyChannelTable, ChannelRuleTab[uCountryCodeIdx].bChannelIdxList, CB_MAX_CHANNEL);
+ return (TRUE);
+}
+
+
+VOID CHvInitChannelTable (PVOID pDeviceHandler)
+{
+ PSDevice pDevice = (PSDevice) pDeviceHandler;
+ BOOL bMultiBand = FALSE;
+ UINT ii;
+
+ for(ii=1;ii<=CB_MAX_CHANNEL;ii++) {
+ sChannelTbl[ii].bValid = FALSE;
+ }
+
+ switch (pDevice->byRFType) {
+ case RF_AL2230:
+ case RF_AL2230S:
+ case RF_VT3226:
+ case RF_VT3226D0:
+ bMultiBand = FALSE;
+ break;
+ case RF_AIROHA7230:
+ case RF_VT3342A0:
+ default :
+ bMultiBand = TRUE;
+ break;
+ }
+
+ if ((pDevice->dwDiagRefCount != 0) ||
+ (pDevice->b11hEable == TRUE)) {
+ if (bMultiBand == TRUE) {
+ for(ii=0;ii<CB_MAX_CHANNEL;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<CB_MAX_CHANNEL_24G;ii++) {
+ //pDevice->abyRegPwr[ii+1] = pDevice->abyCCKDefaultPwr[ii+1];
+ //pDevice->abyLocalPwr[ii+1] = pDevice->abyCCKDefaultPwr[ii+1];
+ }
+ } else {
+ for(ii=0;ii<CB_MAX_CHANNEL_24G;ii++) {
+ 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<CB_MAX_CHANNEL;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<CB_MAX_CHANNEL_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];
+ }
+ }
+ }
+ }
+ DBG_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<CB_MAX_CHANNEL;ii++) {
+ DBG_PRT(MSG_LEVEL_DEBUG, KERN_INFO"Channel[%d] is [%d]\n",sChannelTbl[ii].byChannelNumber,sChannelTbl[ii+1].bValid);
+ /*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];
+ }*/
+ }
+}
+
+BYTE CHbyGetChannelMapping(BYTE byChannelNumber)
+{
+BYTE ii;
+BYTE byCHMapping = 0;
+
+ for (ii=1; ii<=CB_MAX_CHANNEL; ii++ ) {
+ if ( sChannelTbl[ii].byChannelNumber == byChannelNumber ) {
+ byCHMapping = ii;
+ }
+ }
+ return byCHMapping;
+}
diff --git a/drivers/staging/vt6656/channel.h b/drivers/staging/vt6656/channel.h
new file mode 100644
index 000000000000..29b6ec5eaa43
--- /dev/null
+++ b/drivers/staging/vt6656/channel.h
@@ -0,0 +1,58 @@
+/*
+ * 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: channel.h
+ *
+ * Purpose: Country Regulation Rules header file
+ *
+ * Author: Lucas Lin
+ *
+ * Date: Dec 23, 2004
+ *
+ */
+
+#ifndef _CHANNEL_H_
+#define _CHANNEL_H_
+
+#if !defined(__TTYPE_H__)
+#include "ttype.h"
+#endif
+
+/*--------------------- Export Definitions -------------------------*/
+
+/*--------------------- Export Classes ----------------------------*/
+typedef struct tagSChannelTblElement {
+ BYTE byChannelNumber;
+ UINT uFrequency;
+ BOOL bValid;
+}SChannelTblElement, DEF* PSChannelTblElement;
+
+/*--------------------- Export Variables --------------------------*/
+
+/*--------------------- Export Functions --------------------------*/
+BOOL ChannelValid(UINT CountryCode, UINT ChannelNum);
+VOID CHvInitChannelTable (PVOID pDeviceHandler);
+BYTE CHbyGetChannelMapping(BYTE byChannelNumber);
+
+BOOL
+CHvChannelGetList (
+ IN UINT uCountryCodeIdx,
+ OUT PBYTE pbyChannelTable
+ );
+#endif /* _REGULATE_H_ */
diff --git a/drivers/staging/vt6656/control.c b/drivers/staging/vt6656/control.c
new file mode 100644
index 000000000000..ee541256cf9a
--- /dev/null
+++ b/drivers/staging/vt6656/control.c
@@ -0,0 +1,116 @@
+/*
+ * 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: control.c
+ *
+ * Purpose: Handle USB control endpoint
+ *
+ * Author: Jerry Chen
+ *
+ * Date: Apr. 5, 2004
+ *
+ * Functions:
+ * CONTROLnsRequestOut - Write variable length bytes to MEM/BB/MAC/EEPROM
+ * CONTROLnsRequestIn - Read variable length bytes from MEM/BB/MAC/EEPROM
+ * ControlvWriteByte - Write one byte to MEM/BB/MAC/EEPROM
+ * ControlvReadByte - Read one byte from MEM/BB/MAC/EEPROM
+ * ControlvMaskByte - Read one byte from MEM/BB/MAC/EEPROM and clear/set some bits in the same address
+ *
+ * Revision History:
+ * 04-05-2004 Jerry Chen: Initial release
+ * 11-24-2004 Warren Hsu: Add ControlvWriteByte,ControlvReadByte,ControlvMaskByte
+ *
+ */
+
+#if !defined(__CONTROL_H__)
+#include "control.h"
+#endif
+#if !defined(__UMEM_H__)
+#include "umem.h"
+#endif
+#if !defined(__RNDIS_H__)
+#include "rndis.h"
+#endif
+
+/*--------------------- Static Definitions -------------------------*/
+//static int msglevel =MSG_LEVEL_INFO;
+//static int msglevel =MSG_LEVEL_DEBUG;
+/*--------------------- Static Classes ----------------------------*/
+
+/*--------------------- Static Variables --------------------------*/
+
+/*--------------------- Static Functions --------------------------*/
+
+/*--------------------- Export Variables --------------------------*/
+
+/*--------------------- Export Functions --------------------------*/
+
+
+void ControlvWriteByte(PSDevice pDevice, BYTE byRegType, BYTE byRegOfs, BYTE byData)
+{
+BYTE byData1;
+
+ byData1 = byData;
+
+ CONTROLnsRequestOut(pDevice,
+ MESSAGE_TYPE_WRITE,
+ byRegOfs,
+ byRegType,
+ 1,
+ &byData1
+ );
+
+}
+
+
+void ControlvReadByte(PSDevice pDevice, BYTE byRegType, BYTE byRegOfs, PBYTE pbyData)
+{
+NTSTATUS ntStatus;
+BYTE byData1;
+
+
+ ntStatus = CONTROLnsRequestIn(pDevice,
+ MESSAGE_TYPE_READ,
+ byRegOfs,
+ byRegType,
+ 1,
+ &byData1);
+
+ *pbyData = byData1;
+
+}
+
+
+
+void ControlvMaskByte(PSDevice pDevice, BYTE byRegType, BYTE byRegOfs, BYTE byMask, BYTE byData)
+{
+BYTE pbyData[2];
+
+ pbyData[0] = byData;
+ pbyData[1] = byMask;
+
+ CONTROLnsRequestOut(pDevice,
+ MESSAGE_TYPE_WRITE_MASK,
+ byRegOfs,
+ byRegType,
+ 2,
+ pbyData
+ );
+
+}
diff --git a/drivers/staging/vt6656/control.h b/drivers/staging/vt6656/control.h
new file mode 100644
index 000000000000..c208eb508e8a
--- /dev/null
+++ b/drivers/staging/vt6656/control.h
@@ -0,0 +1,103 @@
+/*
+ * 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: control.h
+ *
+ * Purpose:
+ *
+ * Author: Jerry Chen
+ *
+ * Date: Apr. 5, 2004
+ *
+ */
+
+
+#ifndef __CONTROL_H__
+#define __CONTROL_H__
+
+#if !defined(__TTYPE_H__)
+#include "ttype.h"
+#endif
+#if !defined(__DEVICE_H__)
+#include "device.h"
+#endif
+#if !defined(__USBPIPE_H__)
+#include "usbpipe.h"
+#endif
+
+
+
+/*--------------------- Export Definitions -------------------------*/
+
+
+#define CONTROLnsRequestOut( Device,Request,Value,Index,Length,Buffer) \
+ PIPEnsControlOut( Device,Request,Value,Index,Length,Buffer)
+
+#define CONTROLnsRequestOutAsyn( Device,Request,Value,Index,Length,Buffer) \
+ PIPEnsControlOutAsyn( Device,Request,Value,Index,Length,Buffer)
+
+#define CONTROLnsRequestIn( Device,Request,Value,Index,Length,Buffer) \
+ PIPEnsControlIn( Device,Request,Value,Index,Length,Buffer)
+
+
+/*--------------------- Export Classes ----------------------------*/
+
+/*--------------------- Export Variables --------------------------*/
+
+/*--------------------- Export Functions --------------------------*/
+#ifdef __cplusplus
+extern "C" { /* Assume C declarations for C++ */
+#endif /* __cplusplus */
+
+
+void ControlvWriteByte(
+ IN PSDevice pDevice,
+ IN BYTE byRegType,
+ IN BYTE byRegOfs,
+ IN BYTE byData
+ );
+
+
+void ControlvReadByte(
+ IN PSDevice pDevice,
+ IN BYTE byRegType,
+ IN BYTE byRegOfs,
+ IN PBYTE pbyData
+ );
+
+
+void ControlvMaskByte(
+ IN PSDevice pDevice,
+ IN BYTE byRegType,
+ IN BYTE byRegOfs,
+ IN BYTE byMask,
+ IN BYTE byData
+ );
+
+#ifdef __cplusplus
+} /* End of extern "C" { */
+#endif /* __cplusplus */
+
+
+
+
+#endif // __RCV_H__
+
+
+
diff --git a/drivers/staging/vt6656/country.h b/drivers/staging/vt6656/country.h
new file mode 100644
index 000000000000..7bdc8d47aedb
--- /dev/null
+++ b/drivers/staging/vt6656/country.h
@@ -0,0 +1,163 @@
+/*
+ * 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__
+
+/************************************************************************
+ * 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;
+
+
+/************************************************************************
+ * Function prototype
+ ************************************************************************/
+#endif /* __COUNTRY_H__ */
diff --git a/drivers/staging/vt6656/datarate.c b/drivers/staging/vt6656/datarate.c
new file mode 100644
index 000000000000..ad1ed5084226
--- /dev/null
+++ b/drivers/staging/vt6656/datarate.c
@@ -0,0 +1,518 @@
+/*
+ * 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
+#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;
+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
+RATEwGetRateIdx(
+ 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;
+
+ DBG_PRT(MSG_LEVEL_DEBUG, KERN_INFO"ParseMaxRate Len: %d\n", uRateLen);
+ if (pDevice->byBBType != BB_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, RATEwGetRateIdx(byRate));
+ DBG_PRT(MSG_LEVEL_DEBUG, KERN_INFO"ParseMaxRate AddBasicRate: %d\n", RATEwGetRateIdx(byRate));
+ }
+ byRate = (BYTE)(pItemRates->abyRates[ii]&0x7F);
+ if (byHighSuppRate == 0)
+ byHighSuppRate = byRate;
+ if (byRate > byHighSuppRate)
+ byHighSuppRate = byRate;
+ *pwSuppRate |= (1<<RATEwGetRateIdx(byRate));
+ }
+ if ((pItemExtRates != NULL) && (pItemExtRates->byElementID == WLAN_EID_EXTSUPP_RATES) &&
+ (pDevice->byBBType != BB_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, RATEwGetRateIdx(byRate));
+ DBG_PRT(MSG_LEVEL_DEBUG, KERN_INFO"ParseMaxRate AddBasicRate: %d\n", RATEwGetRateIdx(byRate));
+ }
+ byRate = (BYTE)(pItemExtRates->abyRates[ii]&0x7F);
+ if (byHighSuppRate == 0)
+ byHighSuppRate = byRate;
+ if (byRate > byHighSuppRate)
+ byHighSuppRate = byRate;
+ *pwSuppRate |= (1<<RATEwGetRateIdx(byRate));
+ //DBG_PRN_GRP09(("ParseMaxRate : HighSuppRate: %d, %X\n", RATEwGetRateIdx(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 = RATEwGetRateIdx(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->byBBType);
+
+ DBG_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;
+PSMgmtObject pMgmt = &(pDevice->sMgmtObj);
+#if 1 //mike fixed old: use packet lose ratio algorithm to control rate
+WORD wIdxDownRate = 0;
+UINT ii;
+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 (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, (int)psNodeDBTable->uTxOk[ii], (int)psNodeDBTable->uTxFail[ii], (int)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(total) =0 & uTxFail(total) = 0
+ if (psNodeDBTable->uTxFail[MAX_RATE] == 0)
+ psNodeDBTable->wTxDataRate = wIdxUpRate;
+ }
+
+ if (pDevice->byBBType == BB_TYPE_11A) {
+ if (psNodeDBTable->wTxDataRate <= RATE_11M)
+ psNodeDBTable->wTxDataRate = RATE_6M;
+ }
+ DBG_PRT(MSG_LEVEL_DEBUG, KERN_INFO"uTxOk[MAX_RATE] %d, uTxFail[MAX_RATE]:%d\n",(int)psNodeDBTable->uTxOk[MAX_RATE], (int)psNodeDBTable->uTxFail[MAX_RATE]);
+ s_vResetCounter(psNodeDBTable);
+ DBG_PRT(MSG_LEVEL_DEBUG, KERN_INFO"Rate: %d, U:%d, D:%d\n", (int)psNodeDBTable->wTxDataRate, (int)wIdxUpRate, (int)wIdxDownRate);
+ return;
+#else //mike fixed new: use differ-signal strength to control rate
+WORD wIdxUpRate = 0;
+BOOL bAutoRate[MAX_RATE] = {TRUE,TRUE,TRUE,TRUE,FALSE,FALSE,TRUE,TRUE,TRUE,TRUE,TRUE,TRUE};
+UINT ii;
+long ldBm;
+
+ if (pMgmt->eScanState != WMAC_NO_SCANNING) {
+ // Don't do Fallback when scanning Channel
+ return;
+ }
+
+ for(ii=0;ii<MAX_RATE;ii++) {
+ if (psNodeDBTable->wSuppRate & (0x0001<<ii)) {
+ if (bAutoRate[ii] == TRUE) {
+ wIdxUpRate = (WORD) ii;
+ }
+ } else {
+ bAutoRate[ii] = FALSE;
+ }
+ }
+
+ RFvRSSITodBm(pDevice, (BYTE)(pDevice->uCurrRSSI), &ldBm);
+
+ if (ldBm > -55) {
+ if ( psNodeDBTable->wSuppRate & (0x0001<<RATE_54M) ) //11a/g
+ {
+ psNodeDBTable->wTxDataRate = RATE_54M;
+ }
+ else{ //11b
+ psNodeDBTable->wTxDataRate = RATE_11M;
+ }
+ }
+
+if (wIdxUpRate == RATE_54M ) { //11a/g
+ if (ldBm > -56 )
+ psNodeDBTable->wTxDataRate = RATE_54M;
+ else if (ldBm > -61 )
+ psNodeDBTable->wTxDataRate = RATE_48M;
+ else if (ldBm > -66 )
+ psNodeDBTable->wTxDataRate = RATE_36M;
+ else if (ldBm > -72 )
+ psNodeDBTable->wTxDataRate = RATE_24M;
+ else if (ldBm > -80 )
+ psNodeDBTable->wTxDataRate = RATE_5M;
+ else {
+ psNodeDBTable->wTxDataRate = RATE_1M;
+ //increasingVGA = TRUE;
+ }
+ }
+ else { //11b
+ if (ldBm > -65 )
+ psNodeDBTable->wTxDataRate = RATE_11M;
+ else if (ldBm > -75 )
+ psNodeDBTable->wTxDataRate = RATE_5M;
+ else
+ psNodeDBTable->wTxDataRate = RATE_1M;
+ }
+
+ return;
+#endif
+}
+
+/*+
+ *
+ * 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/vt6656/datarate.h b/drivers/staging/vt6656/datarate.h
new file mode 100644
index 000000000000..68f206e2707b
--- /dev/null
+++ b/drivers/staging/vt6656/datarate.h
@@ -0,0 +1,110 @@
+/*
+ * 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
+
+
+#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
+
+/*--------------------- 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
+RATEwGetRateIdx(
+ IN BYTE byRate
+ );
+
+
+BYTE
+DATARATEbyGetRateIdx(
+ IN BYTE byRate
+ );
+
+
+#endif //__DATARATE_H__
diff --git a/drivers/staging/vt6656/desc.h b/drivers/staging/vt6656/desc.h
new file mode 100644
index 000000000000..87e5c8ca9ffe
--- /dev/null
+++ b/drivers/staging/vt6656/desc.h
@@ -0,0 +1,453 @@
+/*
+ * 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
+
+
+
+
+
+/*--------------------- Export Definitions -------------------------*/
+
+// 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 MAX_TOTAL_SIZE_WITH_ALL_HEADERS CB_MAX_BUF_SIZE
+
+#define MAX_INTERRUPT_SIZE 32
+
+
+#define RX_BLOCKS 64 // form 0x60 to 0xA0
+#define TX_BLOCKS 32 // from 0xA0 to 0xC0
+
+#define CB_MAX_RX_DESC 128 // max # of descriptor
+#define CB_MIN_RX_DESC 16 // min # of rx descriptor
+#define CB_MAX_TX_DESC 128 // max # of descriptor
+#define CB_MIN_TX_DESC 16 // min # of tx descriptor
+
+#define CB_RD_NUM 64 // default # of RD
+#define CB_TD_NUM 64 // default # of TD
+
+
+
+//
+// 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 TSR register
+//
+#define TSR_RETRYTMO 0x08 // 0000 1000
+#define TSR_TMO 0x04 // 0000 0100
+#define TSR_ACKDATA 0x02 // 0000 0010
+#define TSR_VALID 0x01 // 0000 0001
+
+
+#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
+
+
+#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
+
+
+//#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 ------------------------------*/
+
+
+//
+// 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;
+ WORD 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/vt6656/device.h b/drivers/staging/vt6656/device.h
new file mode 100644
index 000000000000..c4f9a0321f52
--- /dev/null
+++ b/drivers/staging/vt6656/device.h
@@ -0,0 +1,976 @@
+/*
+ * 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 <linux/if.h>
+#include <linux/rtnetlink.h>//James
+#include <linux/proc_fs.h>
+#include <linux/inetdevice.h>
+#include <linux/reboot.h>
+#include <linux/usb.h>
+#include <linux/signal.h>
+#include <asm/io.h>
+#include <asm/uaccess.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>
+#include <net/iw_handler.h> // New driver API
+
+#ifndef WPA_SUPPLICANT_DRIVER_WEXT_SUPPORT
+#define WPA_SUPPLICANT_DRIVER_WEXT_SUPPORT
+#endif
+
+//2007-0920-01<Add>by MikeLiu
+#ifndef SndEvt_ToAPI
+#define SndEvt_ToAPI
+//please copy below macro to driver_event.c for API
+#define RT_INSMOD_EVENT_FLAG 0x0101
+#define RT_UPDEV_EVENT_FLAG 0x0102
+#define RT_DISCONNECTED_EVENT_FLAG 0x0103
+#define RT_WPACONNECTED_EVENT_FLAG 0x0104
+#define RT_DOWNDEV_EVENT_FLAG 0x0105
+#define RT_RMMOD_EVENT_FLAG 0x0106
+#endif
+
+//
+// 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(__CARD_H__)
+#include "card.h"
+#endif
+
+/*--------------------- Export Definitions -------------------------*/
+#define VNT_USB_VENDOR_ID 0x160A
+#define VNT_USB_PRODUCT_ID 0x3184
+
+#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 ANT_TXA 0
+#define ANT_TXB 1
+#define ANT_RXA 2
+#define ANT_RXB 3
+
+
+#define MAXCHECKHANGCNT 4
+
+//Packet type
+#define TX_PKT_UNI 0x00
+#define TX_PKT_MULTI 0x01
+#define TX_PKT_BROAD 0x02
+
+#define BB_VGA_LEVEL 4
+#define BB_VGA_CHANGE_THRESHOLD 3
+
+
+
+#ifndef RUN_AT
+#define RUN_AT(x) (jiffies+(x))
+#endif
+
+// DMA related
+#define RESERV_AC0DMA 4
+
+#define PRIVATE_Message 0
+
+/*--------------------- Export Types ------------------------------*/
+
+#define DBG_PRT(l, p, args...) {if (l<=msglevel) printk( p ,##args);}
+#define PRINT_K(p, args...) {if (PRIVATE_Message) printk( p ,##args);}
+
+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;
+
+
+//USB
+
+//
+// Enum of context types for SendPacket
+//
+typedef enum _CONTEXT_TYPE {
+ CONTEXT_DATA_PACKET = 1,
+ CONTEXT_MGMT_PACKET
+} CONTEXT_TYPE;
+
+
+
+
+// RCB (Receive Control Block)
+typedef struct _RCB
+{
+ PVOID Next;
+ LONG Ref;
+ PVOID pDevice;
+ struct urb *pUrb;
+ SRxMgmtPacket sMngPacket;
+ struct sk_buff* skb;
+ BOOL bBoolInUse;
+
+} RCB, *PRCB;
+
+
+// used to track bulk out irps
+typedef struct _USB_SEND_CONTEXT {
+ PVOID pDevice;
+ struct sk_buff *pPacket;
+ struct urb *pUrb;
+ UINT uBufLen;
+ CONTEXT_TYPE Type;
+ SEthernetHeader sEthHeader;
+ PVOID Next;
+ BOOL bBoolInUse;
+ UCHAR Data[MAX_TOTAL_SIZE_WITH_ALL_HEADERS];
+} USB_SEND_CONTEXT, *PUSB_SEND_CONTEXT;
+
+
+//structure got from configuration file as user desired default setting.
+typedef struct _DEFAULT_CONFIG{
+ INT ZoneType;
+ INT eConfigMode;
+ INT eAuthenMode; //open/wep/wpa
+ INT bShareKeyAlgorithm; //open-open/open-sharekey/wep-sharekey
+ INT keyidx; //wepkey index
+ INT eEncryptionStatus;
+
+}DEFAULT_CONFIG,*PDEFAULT_CONFIG;
+
+//
+// Structure to keep track of usb interrupt packets
+//
+typedef struct {
+ UINT uDataLen;
+ PBYTE pDataBuf;
+// struct urb *pUrb;
+ BOOL bInUse;
+} INT_BUFFER, *PINT_BUFFER;
+
+
+
+//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;
+
+
+
+
+//++ NDIS related
+
+#define NDIS_STATUS int
+#define NTSTATUS int
+
+typedef enum __DEVICE_NDIS_STATUS {
+ STATUS_SUCCESS=0,
+ STATUS_FAILURE,
+ STATUS_RESOURCES,
+ STATUS_PENDING,
+} DEVICE_NDIS_STATUS, *PDEVICE_NDIS_STATUS;
+
+
+#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;
+
+//--
+
+
+// The receive duplicate detection cache entry
+typedef struct tagSCacheEntry{
+ WORD wFmSequence;
+ BYTE abyAddr2[U_ETHER_ADDR_LEN];
+ WORD wFrameCtl;
+} 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;
+ PBYTE pbyRxBuffer;
+ UINT cbFrameLength;
+ BOOL bInUse;
+} SDeFragControlBlock, DEF* PSDeFragControlBlock;
+
+
+
+//flags for options
+#define DEVICE_FLAGS_UNPLUG 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
+
+//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
+
+
+typedef struct __device_opt {
+ int nRxDescs0; //Number of RX descriptors0
+ int nTxDescs0; //Number of TX descriptors 0, 1, 2, 3
+ int rts_thresh; //rts threshold
+ int frag_thresh;
+ int OpMode;
+ int data_rate;
+ int channel_num;
+ int short_retry;
+ int long_retry;
+ int bbp_type;
+ U32 flags;
+} OPTIONS, *POPTIONS;
+
+
+typedef struct __device_info {
+
+// netdev
+ struct usb_device* usb;
+ struct net_device* dev;
+ struct net_device_stats stats;
+
+ OPTIONS sOpts;
+
+ struct tasklet_struct CmdWorkItem;
+ struct tasklet_struct EventWorkItem;
+ struct tasklet_struct ReadWorkItem;
+ struct tasklet_struct RxMngWorkItem;
+
+ U32 rx_buf_sz;
+ int multicast_limit;
+ BYTE byRxMode;
+
+ spinlock_t lock;
+
+ U32 rx_bytes;
+
+ BYTE byRevId;
+
+ U32 flags;
+ ULONG Flags;
+
+ SCache sDupRxCache;
+
+ SDeFragControlBlock sRxDFCB[CB_MAX_RX_FRAG];
+ UINT cbDFCB;
+ UINT cbFreeDFCB;
+ UINT uCurrentDFCBIdx;
+
+ // +++USB
+
+ struct urb *pControlURB;
+ struct urb *pInterruptURB;
+ struct usb_ctrlrequest sUsbCtlRequest;
+
+ UINT int_interval;
+ //
+ // Variables to track resources for the BULK In Pipe
+ //
+ PRCB pRCBMem;
+ PRCB apRCB[CB_MAX_RX_DESC];
+ UINT cbRD;
+ PRCB FirstRecvFreeList;
+ PRCB LastRecvFreeList;
+ UINT NumRecvFreeList;
+ PRCB FirstRecvMngList;
+ PRCB LastRecvMngList;
+ UINT NumRecvMngList;
+ BOOL bIsRxWorkItemQueued;
+ BOOL bIsRxMngWorkItemQueued;
+ ULONG ulRcvRefCount; // number of packets that have not been returned back
+
+ //
+ // Variables to track resources for the BULK Out Pipe
+ //
+
+ PUSB_SEND_CONTEXT apTD[CB_MAX_TX_DESC];
+ UINT cbTD;
+
+ //
+ // Variables to track resources for the Interript In Pipe
+ //
+ INT_BUFFER intBuf;
+ BOOL fKillEventPollingThread;
+ BOOL bEventAvailable;
+
+
+ //default config from file by user setting
+ DEFAULT_CONFIG config_file;
+
+
+ //
+ // Statistic for USB
+ // protect with spinlock
+ ULONG ulBulkInPosted;
+ ULONG ulBulkInError;
+ ULONG ulBulkInContCRCError;
+ ULONG ulBulkInBytesRead;
+
+ ULONG ulBulkOutPosted;
+ ULONG ulBulkOutError;
+ ULONG ulBulkOutContCRCError;
+ ULONG ulBulkOutBytesWrite;
+
+ ULONG ulIntInPosted;
+ ULONG ulIntInError;
+ ULONG ulIntInContCRCError;
+ ULONG ulIntInBytesRead;
+
+
+ // Version control
+ WORD wFirmwareVersion;
+ BYTE byLocalID;
+ BYTE byRFType;
+ BYTE byBBRxConf;
+
+
+ BYTE byZoneType;
+ BOOL bZoneRegExist;
+
+ BYTE byOriginalZonetype;
+
+ BOOL bLinkPass; // link status: OK or fail
+ BYTE abyCurrentNetAddr[U_ETHER_ADDR_LEN];
+ BYTE abyPermanentNetAddr[U_ETHER_ADDR_LEN];
+ // SW network address
+// BYTE abySoftwareNetAddr[U_ETHER_ADDR_LEN];
+ BOOL bExistSWNetAddr;
+
+ // Adapter statistics
+ SStatCounter scStatistic;
+ // 802.11 counter
+ SDot11Counters s802_11Counter;
+
+ //
+ // Maintain statistical debug info.
+ //
+ ULONG packetsReceived;
+ ULONG packetsReceivedDropped;
+ ULONG packetsReceivedOverflow;
+ ULONG packetsSent;
+ ULONG packetsSentDropped;
+ ULONG SendContextsInUse;
+ ULONG RcvBuffersInUse;
+
+
+ // 802.11 management
+ SMgmtObject sMgmtObj;
+
+ QWORD qwCurrTSF;
+ UINT cbBulkInMax;
+ BOOL bPSRxBeacon;
+
+ // 802.11 MAC specific
+ UINT uCurrRSSI;
+ BYTE byCurrSQ;
+
+
+ //Antenna Diversity
+ BOOL bTxRxAntInv;
+ DWORD dwRxAntennaSel;
+ DWORD dwTxAntennaSel;
+ BYTE byAntennaCount;
+ BYTE byRxAntennaMode;
+ BYTE byTxAntennaMode;
+ BYTE byRadioCtl;
+ BYTE bHWRadioOff;
+
+ //SQ3 functions for antenna diversity
+ struct timer_list TimerSQ3Tmax1;
+ struct timer_list TimerSQ3Tmax2;
+ struct timer_list TimerSQ3Tmax3;
+
+ BOOL bDiversityRegCtlON;
+ BOOL bDiversityEnable;
+ ULONG ulDiversityNValue;
+ ULONG ulDiversityMValue;
+ BYTE byTMax;
+ BYTE byTMax2;
+ BYTE byTMax3;
+ ULONG ulSQ3TH;
+
+ ULONG uDiversityCnt;
+ BYTE byAntennaState;
+ ULONG ulRatio_State0;
+ ULONG ulRatio_State1;
+ ULONG ulSQ3_State0;
+ ULONG ulSQ3_State1;
+
+ ULONG aulSQ3Val[MAX_RATE];
+ ULONG aulPktNum[MAX_RATE];
+
+ // IFS & Cw
+ 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;
+
+ // Rate
+ 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;
+
+
+ DWORD dwAotoRateTxOkCnt;
+ DWORD dwAotoRateTxFailCnt;
+ DWORD dwErrorRateThreshold[13];
+ DWORD dwTPTable[MAX_RATE];
+ BYTE abyEEPROM[EEP_MAX_CONTEXT_SIZE]; //DWORD alignment
+
+ BYTE byMinChannel;
+ BYTE byMaxChannel;
+ UINT uConnectionRate;
+
+ BYTE byPreambleType;
+ BYTE byShortPreamble;
+ // CARD_PHY_TYPE
+ BYTE eConfigPHYMode;
+
+ // For RF Power table
+ BYTE byCCKPwr;
+ BYTE byOFDMPwrG;
+ BYTE byOFDMPwrA;
+ BYTE byCurPwr;
+ BYTE abyCCKPwrTbl[14];
+ BYTE abyOFDMPwrTbl[14];
+ BYTE abyOFDMAPwrTbl[42];
+
+ WORD wCurrentRate;
+ WORD wRTSThreshold;
+ WORD wFragmentationThreshold;
+ BYTE byShortRetryLimit;
+ BYTE byLongRetryLimit;
+ CARD_OP_MODE eOPMode;
+ 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 bSoftwareGenCrcErr;
+ BOOL bShortSlotTime;
+ BOOL bProtectMode;
+ BOOL bNonERPPresent;
+ BOOL bBarkerPreambleMd;
+
+ BYTE byERPFlag;
+ WORD wUseProtectCntDown;
+
+ BOOL bRadioControlOff;
+ BOOL bRadioOff;
+
+ // Power save
+ BOOL bEnablePSMode;
+ WORD wListenInterval;
+ BOOL bPWBitOn;
+ WMAC_POWER_MODE ePSMode;
+ ULONG ulPSModeWaitTx;
+ BOOL bPSModeTxBurst;
+
+ // Beacon releated
+ WORD wSeqCounter;
+ BOOL bBeaconBufReady;
+ BOOL bBeaconSent;
+ BOOL bFixRate;
+ BYTE byCurrentCh;
+ UINT uScanTime;
+
+ CMD_STATE eCommandState;
+
+ CMD_CODE eCommand;
+ BOOL bBeaconTx;
+ BYTE byScanBBType;
+
+ BOOL bStopBeacon;
+ BOOL bStopDataPkt;
+ BOOL bStopTx0Pkt;
+ UINT uAutoReConnectTime;
+ UINT uIsroamingTime;
+
+ // 802.11 counter
+
+ CMD_ITEM eCmdQueue[CMD_Q_SIZE];
+ UINT uCmdDequeueIdx;
+ UINT uCmdEnqueueIdx;
+ UINT cbFreeCmdQueue;
+ BOOL bCmdRunning;
+ BOOL bCmdClear;
+ BOOL bNeedRadioOFF;
+
+ BOOL bEnableRoaming; //DavidWang
+ BOOL bIsRoaming; //DavidWang
+ BOOL bFastRoaming; //DavidWang
+ BYTE bSameBSSMaxNum; //Davidwang
+ BYTE bSameBSSCurNum; //DavidWang
+ BOOL bRoaming;
+ BOOL b11hEable;
+ ULONG ulTxPower;
+
+ // Encryption
+ 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;
+
+
+ RC4Ext SBox;
+ BYTE abyPRNG[WLAN_WEPMAX_KEYLEN+3];
+ BYTE byKeyIndex;
+
+ BOOL bAES;
+ BYTE byCntMeasure;
+
+ UINT uKeyLength;
+ BYTE abyKey[WLAN_WEP232_KEYLEN];
+
+ // for AP mode
+ UINT uAssocCount;
+ BOOL bMoreData;
+
+ // QoS
+ BOOL bGrpAckPolicy;
+
+
+ BYTE byAutoFBCtrl;
+
+ BOOL bTxMICFail;
+ BOOL bRxMICFail;
+
+
+ // 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;
+
+ // BaseBand Loopback Use
+ BYTE byBBCR4d;
+ BYTE byBBCRc9;
+ BYTE byBBCR88;
+ BYTE byBBCR09;
+
+ // command timer
+ struct timer_list sTimerCommand;
+
+//2007-0115-01<Add>by MikeLiu
+#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;
+
+ SEthernetHeader sTxEthHeader;
+ SEthernetHeader sRxEthHeader;
+ BYTE abyBroadcastAddr[U_ETHER_ADDR_LEN];
+ BYTE abySNAP_RFC1042[U_ETHER_ADDR_LEN];
+ BYTE abySNAP_Bridgetunnel[U_ETHER_ADDR_LEN];
+
+ // Pre-Authentication & PMK cache
+ SPMKID gsPMKID;
+ SPMKIDCandidateEvent gsPMKIDCandidate;
+
+
+ // for 802.11h
+ BOOL b11hEnable;
+
+ BOOL bChannelSwitch;
+ BYTE byNewChannel;
+ BYTE byChannelSwitchCount;
+
+ //WPA supplicant daemon
+ struct net_device *wpadev;
+ BOOL bWPADEVUp;
+ struct sk_buff *skb;
+ //--
+
+#ifdef WPA_SUPPLICANT_DRIVER_WEXT_SUPPORT
+ BOOL bwextstep0;
+ BOOL bwextstep1;
+ BOOL bwextstep2;
+ BOOL bwextstep3;
+ 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;
+
+ struct iw_statistics wstats; // wireless stats
+ BOOL bCommit;
+
+} DEVICE_INFO, *PSDevice;
+
+
+
+
+#define EnqueueRCB(_Head, _Tail, _RCB) \
+{ \
+ if (!_Head) { \
+ _Head = _RCB; \
+ } \
+ else { \
+ _Tail->Next = _RCB; \
+ } \
+ _RCB->Next = NULL; \
+ _Tail = _RCB; \
+}
+
+#define DequeueRCB(Head, Tail) \
+{ \
+ PRCB RCB = Head; \
+ if (!RCB->Next) { \
+ Tail = NULL; \
+ } \
+ Head = RCB->Next; \
+}
+
+
+#define ADD_ONE_WITH_WRAP_AROUND(uVar, uModulo) { \
+ if ((uVar) >= ((uModulo) - 1)) \
+ (uVar) = 0; \
+ else \
+ (uVar)++; \
+}
+
+
+#define fMP_RESET_IN_PROGRESS 0x00000001
+#define fMP_DISCONNECTED 0x00000002
+#define fMP_HALT_IN_PROGRESS 0x00000004
+#define fMP_SURPRISE_REMOVED 0x00000008
+#define fMP_RECV_LOOKASIDE 0x00000010
+#define fMP_INIT_IN_PROGRESS 0x00000020
+#define fMP_SEND_SIDE_RESOURCE_ALLOCATED 0x00000040
+#define fMP_RECV_SIDE_RESOURCE_ALLOCATED 0x00000080
+#define fMP_POST_READS 0x00000100
+#define fMP_POST_WRITES 0x00000200
+#define fMP_CONTROL_READS 0x00000400
+#define fMP_CONTROL_WRITES 0x00000800
+
+
+
+#define MP_SET_FLAG(_M, _F) ((_M)->Flags |= (_F))
+#define MP_CLEAR_FLAG(_M, _F) ((_M)->Flags &= ~(_F))
+#define MP_TEST_FLAG(_M, _F) (((_M)->Flags & (_F)) != 0)
+#define MP_TEST_FLAGS(_M, _F) (((_M)->Flags & (_F)) == (_F))
+
+#define MP_IS_READY(_M) (((_M)->Flags & \
+ (fMP_DISCONNECTED | fMP_RESET_IN_PROGRESS | fMP_HALT_IN_PROGRESS | fMP_INIT_IN_PROGRESS | fMP_SURPRISE_REMOVED)) == 0)
+
+/*--------------------- Export Functions --------------------------*/
+
+//BOOL device_dma0_xmit(PSDevice pDevice, struct sk_buff *skb, UINT uNodeIndex);
+BOOL device_alloc_frag_buf(PSDevice pDevice, PSDeFragControlBlock pDeF);
+
+#endif
+
+
diff --git a/drivers/staging/vt6656/device_cfg.h b/drivers/staging/vt6656/device_cfg.h
new file mode 100644
index 000000000000..e8acc9067713
--- /dev/null
+++ b/drivers/staging/vt6656/device_cfg.h
@@ -0,0 +1,142 @@
+/*
+ * 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_cfg.h
+ *
+ * Purpose: Driver configuration header
+ * Author: Lyndon Chen
+ *
+ * Date: Dec 9, 2005
+ *
+ */
+#ifndef __DEVICE_CONFIG_H
+#define __DEVICE_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 "vt6656"
+#define DEVICE_FULL_DRV_NAM "VIA Networking Wireless LAN USB Driver"
+
+#ifndef MAJOR_VERSION
+#define MAJOR_VERSION 1
+#endif
+
+#ifndef MINOR_VERSION
+#define MINOR_VERSION 13
+#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{
+ VT3184=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/vt6656/dpc.c b/drivers/staging/vt6656/dpc.c
new file mode 100644
index 000000000000..a90d0924b85d
--- /dev/null
+++ b/drivers/staging/vt6656/dpc.c
@@ -0,0 +1,1658 @@
+/*
+ * 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(__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
+#if !defined(__DATARATE_H__)
+#include "datarate.h"
+#endif
+#if !defined(__USBPIPE_H__)
+#include "usbpipe.h"
+#endif
+
+
+/*--------------------- 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
+ );
+
+
+
+static BOOL s_bAPModeRxData (
+ IN PSDevice pDevice,
+ IN struct sk_buff* skb,
+ IN UINT FrameSize,
+ IN UINT cbHeaderOffset,
+ IN INT iSANodeIndex,
+ IN INT iDANodeIndex
+ );
+
+
+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;
+}
+
+
+
+
+BOOL
+RXbBulkInProcessData (
+ IN PSDevice pDevice,
+ IN PRCB pRCB,
+ IN ULONG BytesToIndicate
+ )
+{
+
+ struct net_device_stats* pStats=&pDevice->stats;
+ struct sk_buff* skb;
+ PSMgmtObject pMgmt = &(pDevice->sMgmtObj);
+ PSRxMgmtPacket pRxPacket = &(pMgmt->sRxPacket);
+ PS802_11Header p802_11Header;
+ PBYTE pbyRsr;
+ PBYTE pbyNewRsr;
+ PBYTE pbyRSSI;
+ PQWORD pqwTSFTime;
+ PBYTE pbyFrame;
+ BOOL bDeFragRx = FALSE;
+ UINT cbHeaderOffset;
+ UINT FrameSize;
+ WORD wEtherType = 0;
+ INT iSANodeIndex = -1;
+ INT iDANodeIndex = -1;
+ UINT ii;
+ UINT cbIVOffset;
+ PBYTE pbyRxSts;
+ PBYTE pbyRxRate;
+ PBYTE pbySQ;
+#ifdef Calcu_LinkQual
+ PBYTE pby3SQ;
+#endif
+ UINT cbHeaderSize;
+ PSKeyItem pKey = NULL;
+ WORD wRxTSC15_0 = 0;
+ DWORD dwRxTSC47_16 = 0;
+ SKeyItem STempKey;
+ // 802.11h RPI
+ //LONG ldBm = 0;
+ BOOL bIsWEP = FALSE;
+ BOOL bExtIV = FALSE;
+ DWORD dwWbkStatus;
+ PRCB pRCBIndicate = pRCB;
+ PBYTE pbyDAddress;
+ PWORD pwPLCP_Length;
+ BYTE abyVaildRate[MAX_RATE] = {2,4,11,22,12,18,24,36,48,72,96,108};
+ WORD wPLCPwithPadding;
+ PS802_11Header pMACHeader;
+ BOOL bRxeapol_key = FALSE;
+
+
+
+ DBG_PRT(MSG_LEVEL_DEBUG, KERN_INFO"---------- RXbBulkInProcessData---\n");
+
+ skb = pRCB->skb;
+
+ //[31:16]RcvByteCount ( not include 4-byte Status )
+ dwWbkStatus = *( (PDWORD)(skb->data) );
+ FrameSize = (UINT)(dwWbkStatus >> 16);
+ FrameSize += 4;
+
+ if (BytesToIndicate != FrameSize) {
+ DBG_PRT(MSG_LEVEL_DEBUG, KERN_INFO"---------- WRONG Length 1 \n");
+ return FALSE;
+ }
+
+ if ((BytesToIndicate > 2372)||(BytesToIndicate <= 40)) {
+ // Frame Size error drop this packet.
+ DBG_PRT(MSG_LEVEL_DEBUG, KERN_INFO"---------- WRONG Length 2 \n");
+ return FALSE;
+ }
+
+ pbyDAddress = (PBYTE)(skb->data);
+ pbyRxSts = pbyDAddress+4;
+ pbyRxRate = pbyDAddress+5;
+
+ //real Frame Size = USBFrameSize -4WbkStatus - 4RxStatus - 8TSF - 4RSR - 4SQ3 - ?Padding
+ //if SQ3 the range is 24~27, if no SQ3 the range is 20~23
+ //real Frame size in PLCPLength field.
+ pwPLCP_Length = (PWORD) (pbyDAddress + 6);
+ //Fix hardware bug => PLCP_Length error
+ if ( ((BytesToIndicate - (*pwPLCP_Length)) > 27) ||
+ ((BytesToIndicate - (*pwPLCP_Length)) < 24) ||
+ (BytesToIndicate < (*pwPLCP_Length)) ) {
+
+ DBG_PRT(MSG_LEVEL_DEBUG, KERN_INFO"Wrong PLCP Length %x\n", (int) *pwPLCP_Length);
+ ASSERT(0);
+ return FALSE;
+ }
+ for ( ii=RATE_1M;ii<MAX_RATE;ii++) {
+ if ( *pbyRxRate == abyVaildRate[ii] ) {
+ break;
+ }
+ }
+ if ( ii==MAX_RATE ) {
+ DBG_PRT(MSG_LEVEL_DEBUG, KERN_INFO"Wrong RxRate %x\n",(int) *pbyRxRate);
+ return FALSE;
+ }
+
+ wPLCPwithPadding = ( (*pwPLCP_Length / 4) + ( (*pwPLCP_Length % 4) ? 1:0 ) ) *4;
+
+ pqwTSFTime = (PQWORD) (pbyDAddress + 8 + wPLCPwithPadding);
+#ifdef Calcu_LinkQual
+ if(pDevice->byBBType == BB_TYPE_11G) {
+ pby3SQ = pbyDAddress + 8 + wPLCPwithPadding + 12;
+ pbySQ = pby3SQ;
+ }
+ else {
+ pbySQ = pbyDAddress + 8 + wPLCPwithPadding + 8;
+ pby3SQ = pbySQ;
+ }
+#else
+ pbySQ = pbyDAddress + 8 + wPLCPwithPadding + 8;
+#endif
+ pbyNewRsr = pbyDAddress + 8 + wPLCPwithPadding + 9;
+ pbyRSSI = pbyDAddress + 8 + wPLCPwithPadding + 10;
+ pbyRsr = pbyDAddress + 8 + wPLCPwithPadding + 11;
+
+ FrameSize = *pwPLCP_Length;
+
+ pbyFrame = pbyDAddress + 8;
+ // update receive statistic counter
+
+ STAvUpdateRDStatCounter(&pDevice->scStatistic,
+ *pbyRsr,
+ *pbyNewRsr,
+ *pbyRxSts,
+ *pbyRxRate,
+ pbyFrame,
+ FrameSize
+ );
+
+
+ pMACHeader = (PS802_11Header) pbyFrame;
+
+//mike add: to judge if current AP is activated?
+ if ((pMgmt->eCurrMode == WMAC_MODE_STANDBY) ||
+ (pMgmt->eCurrMode == WMAC_MODE_ESS_STA)) {
+ if (pMgmt->sNodeDBTable[0].bActive) {
+ if(IS_ETH_ADDRESS_EQUAL (pMgmt->abyCurrBSSID, pMACHeader->abyAddr2) ) {
+ if (pMgmt->sNodeDBTable[0].uInActiveCount != 0)
+ pMgmt->sNodeDBTable[0].uInActiveCount = 0;
+ }
+ }
+ }
+
+ if (!IS_MULTICAST_ADDRESS(pMACHeader->abyAddr1) && !IS_BROADCAST_ADDRESS(pMACHeader->abyAddr1)) {
+ if ( WCTLbIsDuplicate(&(pDevice->sDupRxCache), (PS802_11Header) pbyFrame) ) {
+ pDevice->s802_11Counter.FrameDuplicateCount++;
+ return FALSE;
+ }
+
+ if ( !IS_ETH_ADDRESS_EQUAL (pDevice->abyCurrentNetAddr, pMACHeader->abyAddr1) ) {
+ return FALSE;
+ }
+ }
+
+
+ // Use for TKIP MIC
+ s_vGetDASA(pbyFrame, &cbHeaderSize, &pDevice->sRxEthHeader);
+
+ 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 (BSSbIsSTAInNodeDB(pDevice, (PBYTE)(p802_11Header->abyAddr2), &iSANodeIndex)) {
+ pMgmt->sNodeDBTable[iSANodeIndex].ulLastRxJiffer = jiffies;
+ 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;
+
+ DBG_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) {
+ DBG_PRT(MSG_LEVEL_DEBUG, KERN_INFO"ICV Fail\n");
+ 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 ((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 {
+ DBG_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((pbyFrame)))
+ ) {
+ // defragment
+ bDeFragRx = WCTLbHandleFragment(pDevice, (PS802_11Header) (pbyFrame), FrameSize, bIsWEP, bExtIV);
+ pDevice->s802_11Counter.ReceivedFragmentCount++;
+ if (bDeFragRx) {
+ // defrag complete
+ // TODO skb, pbyFrame
+ skb = pDevice->sRxDFCB[pDevice->uCurrentDFCBIdx].skb;
+ FrameSize = pDevice->sRxDFCB[pDevice->uCurrentDFCBIdx].cbFrameLength;
+ pbyFrame = skb->data + 8;
+ }
+ else {
+ return FALSE;
+ }
+ }
+
+ //
+ // Management & Control frame Handle
+ //
+ if ((IS_TYPE_DATA((pbyFrame))) == FALSE) {
+ // Handle Control & Manage Frame
+
+ if (IS_TYPE_MGMT((pbyFrame))) {
+ PBYTE pbyData1;
+ PBYTE pbyData2;
+
+ pRxPacket = &(pRCB->sMngPacket);
+ pRxPacket->p80211Header = (PUWLAN_80211HDR)(pbyFrame);
+ 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(pbyFrame);
+ pbyData2 = WLAN_HDR_A3_DATA_PTR(pbyFrame) + 4;
+ for (ii = 0; ii < (FrameSize - 4); ii++) {
+ *pbyData1 = *pbyData2;
+ pbyData1++;
+ pbyData2++;
+ }
+ }
+
+ pRxPacket->byRxRate = s_byGetRateIdx(*pbyRxRate);
+
+ if ( *pbyRxSts == 0 ) {
+ //Discard beacon packet which channel is 0
+ if ( (WLAN_GET_FC_FSTYPE((pRxPacket->p80211Header->sA3.wFrameCtl)) == WLAN_FSTYPE_BEACON) ||
+ (WLAN_GET_FC_FSTYPE((pRxPacket->p80211Header->sA3.wFrameCtl)) == WLAN_FSTYPE_PROBERESP) ) {
+ return TRUE;
+ }
+ }
+ pRxPacket->byRxChannel = (*pbyRxSts) >> 2;
+
+ // hostap Deamon handle 802.11 management
+ if (pDevice->bEnableHostapd) {
+ skb->dev = pDevice->apdev;
+ //skb->data += 4;
+ //skb->tail += 4;
+ skb->data += 8;
+ skb->tail += 8;
+ skb_put(skb, FrameSize);
+ skb->mac_header = skb->data;
+ skb->pkt_type = PACKET_OTHERHOST;
+ skb->protocol = htons(ETH_P_802_2);
+ memset(skb->cb, 0, sizeof(skb->cb));
+ netif_rx(skb);
+ return TRUE;
+ }
+
+ //
+ // Insert the RCB in the Recv Mng list
+ //
+ EnqueueRCB(pDevice->FirstRecvMngList, pDevice->LastRecvMngList, pRCBIndicate);
+ pDevice->NumRecvMngList++;
+ if ( bDeFragRx == FALSE) {
+ pRCB->Ref++;
+ }
+ if (pDevice->bIsRxMngWorkItemQueued == FALSE) {
+ pDevice->bIsRxMngWorkItemQueued = TRUE;
+ tasklet_schedule(&pDevice->RxMngWorkItem);
+ }
+
+ }
+ 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])) {
+ DBG_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])) {
+ DBG_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
+ BYTE Descriptor_type;
+ WORD Key_info;
+ 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;
+ Descriptor_type = skb->data[cbIVOffset + 8 + 24 + 6 + 1 +1+1+1+2];
+ Key_info = (skb->data[cbIVOffset + 8 + 24 + 6 + 1 +1+1+1+2+1]<<8) |skb->data[cbIVOffset + 8 + 24 + 6 + 1 +1+1+1+2+2] ;
+ if(Descriptor_type==2) { //RSN
+ // printk("WPA2_Rx_eapol-key_info<-----:%x\n",Key_info);
+ }
+ else if(Descriptor_type==254) {
+ // printk("WPA_Rx_eapol-key_info<-----:%x\n",Key_info);
+ }
+ }
+ }
+ }
+ //mike add:station mode check eapol-key challenge<---
+ }
+ }
+
+
+// Data frame Handle
+
+
+ if (pDevice->bEnablePSMode) {
+ if (IS_FC_MOREDATA((pbyFrame))) {
+ if (BITbIsBitOn(*pbyRsr, RSR_ADDROK)) {
+ //PSbSendPSPOLL((PSDevice)pDevice);
+ }
+ }
+ else {
+ if (pMgmt->bInTIMWake == TRUE) {
+ 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)) {
+ BBvAntennaDiversity(pDevice, s_byGetRateIdx(*pbyRxRate), 0);
+ }
+
+ // ++++++++ For BaseBand Algorithm +++++++++++++++
+ pDevice->uCurrRSSI = *pbyRSSI;
+ pDevice->byCurrSQ = *pbySQ;
+
+ // todo
+/*
+ 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 + 8 + 24 + 6] << 8) |
+ skb->data[cbIVOffset + 8 + 24 + 6 + 1];
+
+ DBG_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 + 8), 24);
+ memcpy((skb->data + 8 + cbIVOffset), &abyMacHdr[0], 24);
+ }
+
+ skb->data += (cbIVOffset + 8);
+ skb->tail += (cbIVOffset + 8);
+ skb_put(skb, FrameSize);
+ skb->mac_header = skb->data;
+ skb->pkt_type = PACKET_OTHERHOST;
+ skb->protocol = htons(ETH_P_802_2);
+ memset(skb->cb, 0, sizeof(skb->cb));
+ netif_rx(skb);
+ 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 (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 + 8 + WLAN_HDR_ADDR3_LEN + 8),
+ FrameSize - WLAN_HDR_ADDR3_LEN - 8);
+ MIC_vGetMIC(&dwLocalMIC_L, &dwLocalMIC_R);
+ MIC_vUnInit();
+
+ pdwMIC_L = (PDWORD)(skb->data + 8 + FrameSize);
+ pdwMIC_R = (PDWORD)(skb->data + 8 + FrameSize + 4);
+
+
+ if ((cpu_to_le32(*pdwMIC_L) != dwLocalMIC_L) || (cpu_to_le32(*pdwMIC_R) != dwLocalMIC_R) ||
+ (pDevice->bRxMICFail == TRUE)) {
+ DBG_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])) {
+ DBG_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->bWPASuppWextEnabled == 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);
+ PRINT_K("wireless_send_event--->IWEVMICHAELMICFAILURE\n");
+ wireless_send_event(pDevice->dev, IWEVMICHAELMICFAILURE, &wrqu, (char *)&ev);
+
+ }
+ #endif
+
+
+ if ((pDevice->bWPADEVUp) && (pDevice->skb != NULL)) {
+ wpahdr = (viawget_wpa_header *)pDevice->skb->data;
+ if ((pMgmt->eCurrMode == WMAC_MODE_ESS_STA) &&
+ (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;
+ pDevice->skb->mac_header = pDevice->skb->data;
+ 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))) {
+ DBG_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])) {
+ DBG_PRT(MSG_LEVEL_ERR,KERN_ERR "%s: can not alloc more frag bufs\n",
+ pDevice->dev->name);
+ }
+ }
+ return FALSE;
+ }
+ }
+ }
+ } // ----- End of Reply Counter Check --------------------------
+
+
+ s_vProcessRxMACHeader(pDevice, (PBYTE)(skb->data+8), FrameSize, bIsWEP, bExtIV, &cbHeaderOffset);
+ FrameSize -= cbHeaderOffset;
+ cbHeaderOffset += 8; // 8 is Rcv buffer header
+
+ // Null data, framesize = 12
+ if (FrameSize < 12)
+ 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])) {
+ DBG_PRT(MSG_LEVEL_ERR,KERN_ERR "%s: can not alloc more frag bufs\n",
+ pDevice->dev->name);
+ }
+ }
+ return FALSE;
+ }
+
+ }
+
+ skb->data += cbHeaderOffset;
+ skb->tail += cbHeaderOffset;
+ skb_put(skb, FrameSize);
+ skb->protocol=eth_type_trans(skb, skb->dev);
+ skb->ip_summed=CHECKSUM_NONE;
+ pStats->rx_bytes +=skb->len;
+ pStats->rx_packets++;
+ netif_rx(skb);
+ if (bDeFragRx) {
+ if (!device_alloc_frag_buf(pDevice, &pDevice->sRxDFCB[pDevice->uCurrentDFCBIdx])) {
+ DBG_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->sMgmtObj);
+
+
+ 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
+ );
+ DBG_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
+ );
+ DBG_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);
+ DBG_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);
+ DBG_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);
+ DBG_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
+ );
+ DBG_PRT(MSG_LEVEL_DEBUG, KERN_INFO "dpc: send vMgrDeAuthenBeginSta 3\n");
+ DBG_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]
+ );
+ DBG_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]
+ );
+ DBG_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]
+ );
+ DBG_PRT(MSG_LEVEL_DEBUG, KERN_INFO "dpc: wFrameCtl= %x\n", p802_11Header->wFrameCtl );
+ 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->sMgmtObj);
+
+
+ *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;
+ DBG_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) &&
+ (pMgmt->byCSSPK != KEY_CTL_NONE)) {
+ // unicast pkt use pairwise key
+ DBG_PRT(MSG_LEVEL_DEBUG, KERN_INFO"unicast pkt\n");
+ if (KeybGetKey(&(pDevice->sKey), pDevice->abyBSSID, 0xFFFFFFFF, &pKey) == TRUE) {
+ if (pMgmt->byCSSPK == KEY_CTL_TKIP)
+ byDecMode = KEY_CTL_TKIP;
+ else if (pMgmt->byCSSPK == KEY_CTL_CCMP)
+ byDecMode = KEY_CTL_CCMP;
+ }
+ DBG_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 (pMgmt->byCSSGK == KEY_CTL_TKIP)
+ byDecMode = KEY_CTL_TKIP;
+ else if (pMgmt->byCSSGK == KEY_CTL_CCMP)
+ byDecMode = KEY_CTL_CCMP;
+ DBG_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 (pMgmt->byCSSGK == KEY_CTL_TKIP)
+ byDecMode = KEY_CTL_TKIP;
+ else if (pMgmt->byCSSGK == KEY_CTL_CCMP)
+ byDecMode = KEY_CTL_CCMP;
+ }
+ *pKeyOut = pKey;
+
+ DBG_PRT(MSG_LEVEL_DEBUG, KERN_INFO"AES:%d %d %d\n", pMgmt->byCSSPK, pMgmt->byCSSGK, byDecMode);
+
+ if (pKey == NULL) {
+ DBG_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));
+ DBG_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);
+ }
+ DBG_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;
+ DBG_PRT(MSG_LEVEL_DEBUG, KERN_INFO"ICV OK!\n");
+ } else {
+ DBG_PRT(MSG_LEVEL_DEBUG, KERN_INFO"ICV FAIL!!!\n");
+ DBG_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
+ )
+{
+ PSMgmtObject pMgmt = &(pDevice->sMgmtObj);
+ 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;
+ DBG_PRT(MSG_LEVEL_DEBUG, KERN_INFO"\nKeyIdx: %d\n", byKeyIdx);
+
+
+ if (pMgmt->byCSSGK == KEY_CTL_TKIP)
+ byDecMode = KEY_CTL_TKIP;
+ else if (pMgmt->byCSSGK == KEY_CTL_CCMP)
+ byDecMode = KEY_CTL_CCMP;
+
+ DBG_PRT(MSG_LEVEL_DEBUG, KERN_INFO"AES:%d %d %d\n", pMgmt->byCSSPK, 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
+ DBG_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));
+ DBG_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);
+ }
+ DBG_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
+ DBG_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;
+ DBG_PRT(MSG_LEVEL_DEBUG, KERN_INFO"ICV OK!\n");
+ } else {
+ DBG_PRT(MSG_LEVEL_DEBUG, KERN_INFO"ICV FAIL!!!\n");
+ DBG_PRT(MSG_LEVEL_DEBUG, KERN_INFO"PayloadLen = %d\n", PayloadLen);
+ }
+ }
+ }
+
+ if (byDecMode == KEY_CTL_CCMP) {
+ if (bOnFly == FALSE) {
+ // Software CCMP
+ // NotOnFly
+ DBG_PRT(MSG_LEVEL_DEBUG, KERN_INFO"soft KEY_CTL_CCMP\n");
+ if (AESbGenCCMP(pKey->abyKey, pbyFrame, FrameSize)) {
+ *pbyNewRsr |= NEWRSR_DECRYPTOK;
+ DBG_PRT(MSG_LEVEL_DEBUG, KERN_INFO"CCMP MIC compare OK!\n");
+ } else {
+ DBG_PRT(MSG_LEVEL_DEBUG, KERN_INFO"CCMP MIC fail!\n");
+ }
+ }
+ }
+
+ }// end of TKIP/AES
+
+ if ((*(pbyIV+3) & 0x20) != 0)
+ *pbExtIV = TRUE;
+ return TRUE;
+}
+
+
+
+static BOOL s_bAPModeRxData (
+ IN PSDevice pDevice,
+ IN struct sk_buff* skb,
+ IN UINT FrameSize,
+ IN UINT cbHeaderOffset,
+ IN INT iSANodeIndex,
+ IN INT iDANodeIndex
+ )
+
+{
+ PSMgmtObject pMgmt = &(pDevice->sMgmtObj);
+ BOOL bRelayAndForward = FALSE;
+ BOOL bRelayOnly = FALSE;
+ BYTE byMask[8] = {1, 2, 4, 8, 0x10, 0x20, 0x40, 0x80};
+ WORD wAID;
+
+
+ struct sk_buff* skbcpy = NULL;
+
+ if (FrameSize > CB_MAX_BUF_SIZE)
+ return FALSE;
+ // check DA
+ if(IS_MULTICAST_ADDRESS((PBYTE)(skb->data+cbHeaderOffset))) {
+ if (pMgmt->sNodeDBTable[0].bPSEnable) {
+
+ skbcpy = dev_alloc_skb((int)pDevice->rx_buf_sz);
+
+ // if any node in PS mode, buffer packet until DTIM.
+ if (skbcpy == NULL) {
+ DBG_PRT(MSG_LEVEL_NOTICE, KERN_INFO "relay multicast no skb available \n");
+ }
+ else {
+ skbcpy->dev = pDevice->dev;
+ skbcpy->len = FrameSize;
+ memcpy(skbcpy->data, skb->data+cbHeaderOffset, FrameSize);
+ skb_queue_tail(&(pMgmt->sNodeDBTable[0].sTxPSQueue), skbcpy);
+ pMgmt->sNodeDBTable[0].wEnQueueCnt++;
+ // set tx map
+ pMgmt->abyPSTxMap[0] |= byMask[0];
+ }
+ }
+ else {
+ bRelayAndForward = TRUE;
+ }
+ }
+ else {
+ // check if relay
+ if (BSSbIsSTAInNodeDB(pDevice, (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.
+
+ skb->data += cbHeaderOffset;
+ skb->tail += cbHeaderOffset;
+ skb_put(skb, FrameSize);
+ skb_queue_tail(&pMgmt->sNodeDBTable[iDANodeIndex].sTxPSQueue, skb);
+
+ pMgmt->sNodeDBTable[iDANodeIndex].wEnQueueCnt++;
+ wAID = pMgmt->sNodeDBTable[iDANodeIndex].wAID;
+ pMgmt->abyPSTxMap[wAID >> 3] |= byMask[wAID & 7];
+ DBG_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)) {
+ bRelayPacketSend(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;
+}
+
+
+
+
+VOID
+RXvWorkItem(
+ PVOID Context
+ )
+{
+ PSDevice pDevice = (PSDevice) Context;
+ NTSTATUS ntStatus;
+ PRCB pRCB=NULL;
+
+ DBG_PRT(MSG_LEVEL_DEBUG, KERN_INFO"---->Rx Polling Thread\n");
+ spin_lock_irq(&pDevice->lock);
+ while ( MP_TEST_FLAG(pDevice, fMP_POST_READS) &&
+ MP_IS_READY(pDevice) &&
+ (pDevice->NumRecvFreeList != 0) ) {
+ pRCB = pDevice->FirstRecvFreeList;
+ pDevice->NumRecvFreeList--;
+ ASSERT(pRCB);// cannot be NULL
+ DequeueRCB(pDevice->FirstRecvFreeList, pDevice->LastRecvFreeList);
+ ntStatus = PIPEnsBulkInUsbRead(pDevice, pRCB);
+ }
+ pDevice->bIsRxWorkItemQueued = FALSE;
+ spin_unlock_irq(&pDevice->lock);
+
+}
+
+
+VOID
+RXvFreeRCB(
+ IN PRCB pRCB,
+ IN BOOL bReAllocSkb
+ )
+{
+ PSDevice pDevice = (PSDevice)pRCB->pDevice;
+
+
+ DBG_PRT(MSG_LEVEL_DEBUG, KERN_INFO"---->RXvFreeRCB\n");
+
+ ASSERT(!pRCB->Ref); // should be 0
+ ASSERT(pRCB->pDevice); // shouldn't be NULL
+
+ if (bReAllocSkb == TRUE) {
+ pRCB->skb = dev_alloc_skb((int)pDevice->rx_buf_sz);
+ // todo error handling
+ if (pRCB->skb == NULL) {
+ DBG_PRT(MSG_LEVEL_ERR,KERN_ERR" Failed to re-alloc rx skb\n");
+ }else {
+ pRCB->skb->dev = pDevice->dev;
+ }
+ }
+ //
+ // Insert the RCB back in the Recv free list
+ //
+ EnqueueRCB(pDevice->FirstRecvFreeList, pDevice->LastRecvFreeList, pRCB);
+ pDevice->NumRecvFreeList++;
+
+
+ if (MP_TEST_FLAG(pDevice, fMP_POST_READS) && MP_IS_READY(pDevice) &&
+ (pDevice->bIsRxWorkItemQueued == FALSE) ) {
+
+ pDevice->bIsRxWorkItemQueued = TRUE;
+ tasklet_schedule(&pDevice->ReadWorkItem);
+ }
+ DBG_PRT(MSG_LEVEL_DEBUG, KERN_INFO"<----RXFreeRCB %d %d\n",pDevice->NumRecvFreeList, pDevice->NumRecvMngList);
+}
+
+
+VOID
+RXvMngWorkItem(
+ PVOID Context
+ )
+{
+ PSDevice pDevice = (PSDevice) Context;
+ PRCB pRCB=NULL;
+ PSRxMgmtPacket pRxPacket;
+ BOOL bReAllocSkb = FALSE;
+
+ DBG_PRT(MSG_LEVEL_DEBUG, KERN_INFO"---->Rx Mng Thread\n");
+
+ spin_lock_irq(&pDevice->lock);
+ while (pDevice->NumRecvMngList!=0)
+ {
+ pRCB = pDevice->FirstRecvMngList;
+ pDevice->NumRecvMngList--;
+ DequeueRCB(pDevice->FirstRecvMngList, pDevice->LastRecvMngList);
+ if(!pRCB){
+ break;
+ }
+ ASSERT(pRCB);// cannot be NULL
+ pRxPacket = &(pRCB->sMngPacket);
+ vMgrRxManagePacket((HANDLE)pDevice, &(pDevice->sMgmtObj), pRxPacket);
+ pRCB->Ref--;
+ if(pRCB->Ref == 0) {
+ DBG_PRT(MSG_LEVEL_DEBUG, KERN_INFO"RxvFreeMng %d %d\n",pDevice->NumRecvFreeList, pDevice->NumRecvMngList);
+ RXvFreeRCB(pRCB, bReAllocSkb);
+ } else {
+ DBG_PRT(MSG_LEVEL_DEBUG, KERN_INFO"Rx Mng Only we have the right to free RCB\n");
+ }
+ }
+
+ pDevice->bIsRxMngWorkItemQueued = FALSE;
+ spin_unlock_irq(&pDevice->lock);
+
+}
+
+
diff --git a/drivers/staging/vt6656/dpc.h b/drivers/staging/vt6656/dpc.h
new file mode 100644
index 000000000000..eb4677f15fed
--- /dev/null
+++ b/drivers/staging/vt6656/dpc.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: dpc.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 */
+
+
+
+
+VOID
+RXvWorkItem(
+ PVOID Context
+ );
+
+VOID
+RXvMngWorkItem(
+ PVOID Context
+ );
+
+VOID
+RXvFreeRCB(
+ IN PRCB pRCB,
+ IN BOOL bReAllocSkb
+ );
+
+BOOL
+RXbBulkInProcessData(
+ IN PSDevice pDevice,
+ IN PRCB pRCB,
+ IN ULONG BytesToIndicate
+ );
+
+
+#ifdef __cplusplus
+} /* End of extern "C" { */
+#endif /* __cplusplus */
+
+
+
+
+#endif // __RXTX_H__
+
+
+
diff --git a/drivers/staging/vt6656/firmware.c b/drivers/staging/vt6656/firmware.c
new file mode 100644
index 000000000000..e315a4662236
--- /dev/null
+++ b/drivers/staging/vt6656/firmware.c
@@ -0,0 +1,887 @@
+/*
+ * 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: Yiching Chen
+ *
+ * Date: May 20, 2004
+ *
+ * Functions:
+ *
+ * Revision History:
+ *
+ */
+
+
+#if !defined(__UMEM_H__)
+#include "umem.h"
+#endif
+#if !defined(__FIRMWARE_H__)
+#include "firmware.h"
+#endif
+#if !defined(__CONTROL_H__)
+#include "control.h"
+#endif
+#if !defined(__RNDIS_H__)
+#include "rndis.h"
+#endif
+
+
+/*--------------------- Static Definitions -------------------------*/
+
+static int msglevel =MSG_LEVEL_INFO;
+//static int msglevel =MSG_LEVEL_DEBUG;
+/*--------------------- Static Classes ----------------------------*/
+
+/*--------------------- Static Variables --------------------------*/
+
+/*--------------------- Static Functions --------------------------*/
+
+/*--------------------- Export Variables --------------------------*/
+
+/*
+ * This is firmware version 1.51
+ */
+#define FIRMWARE_VERSION 0x133
+
+const BYTE abyFirmware[] = {
+
+0x02, 0x35, 0x62, 0x02, 0x3B, 0xED, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0x02, 0x3E, 0x21, 0xD2, 0x04,
+0x90, 0x06, 0x24, 0x74, 0x08, 0xF0, 0x90, 0x06, 0x21, 0xE0, 0x90, 0x45, 0x39, 0xF0, 0xE0, 0x90,
+0x06, 0x21, 0xF0, 0x90, 0x06, 0x10, 0xE0, 0x54, 0x60, 0x60, 0x03, 0x02, 0x1A, 0xE9, 0xA3, 0xE0,
+0x12, 0x28, 0x7E, 0x18, 0x15, 0x00, 0x18, 0xF6, 0x01, 0x19, 0xD1, 0x03, 0x16, 0x79, 0x05, 0x12,
+0x52, 0x06, 0x17, 0xE5, 0x08, 0x16, 0xAF, 0x09, 0x17, 0x33, 0x0A, 0x17, 0x91, 0x0B, 0x00, 0x00,
+0x1A, 0xE1, 0x90, 0x06, 0x17, 0xE0, 0xFE, 0x90, 0x06, 0x16, 0xE0, 0xFD, 0xEE, 0x90, 0x45, 0x31,
+0xF0, 0xED, 0xA3, 0xF0, 0x90, 0x10, 0x3D, 0x74, 0x05, 0xF0, 0x90, 0x06, 0x24, 0x74, 0x08, 0xF0,
+0x90, 0x06, 0x13, 0xE0, 0x24, 0xFE, 0x60, 0x47, 0x14, 0x70, 0x03, 0x02, 0x14, 0x79, 0x24, 0xFD,
+0x60, 0x25, 0x14, 0x70, 0x03, 0x02, 0x13, 0x9C, 0x24, 0x06, 0x60, 0x03, 0x02, 0x16, 0x54, 0x7B,
+0x01, 0x7A, 0x10, 0x79, 0x8B, 0x90, 0x10, 0x46, 0x12, 0x27, 0xBA, 0x90, 0x10, 0x4C, 0xE4, 0xF0,
+0xA3, 0x74, 0x12, 0xF0, 0x02, 0x16, 0x5C, 0x7B, 0x01, 0x7A, 0x10, 0x79, 0x81, 0x90, 0x10, 0x46,
+0x12, 0x27, 0xBA, 0x90, 0x10, 0x4C, 0xE4, 0xF0, 0xA3, 0x74, 0x0A, 0xF0, 0x02, 0x16, 0x5C, 0x7B,
+0x01, 0x7A, 0x10, 0x79, 0x51, 0x90, 0x10, 0x46, 0x12, 0x27, 0xBA, 0x90, 0x10, 0x52, 0x74, 0x02,
+0xF0, 0x90, 0x10, 0x54, 0xE0, 0xFE, 0x90, 0x10, 0x53, 0xE0, 0xFD, 0xEE, 0x90, 0x10, 0x4C, 0xF0,
+0xED, 0xA3, 0xF0, 0x30, 0x06, 0x5A, 0xE0, 0xFD, 0x24, 0x47, 0xF5, 0x82, 0xE4, 0x34, 0x10, 0xF5,
+0x83, 0xE4, 0xF0, 0x74, 0x48, 0x2D, 0xF5, 0x82, 0xE4, 0x34, 0x10, 0xF5, 0x83, 0x74, 0x02, 0xF0,
+0x74, 0x4E, 0x2D, 0xF5, 0x82, 0xE4, 0x34, 0x10, 0xF5, 0x83, 0xE4, 0xF0, 0x74, 0x4F, 0x2D, 0xF5,
+0x82, 0xE4, 0x34, 0x10, 0xF5, 0x83, 0x74, 0x02, 0xF0, 0x90, 0x10, 0x98, 0xE0, 0xFE, 0x90, 0x10,
+0x97, 0xE0, 0xFB, 0xEE, 0xEB, 0xC3, 0x94, 0x20, 0xEE, 0x94, 0x01, 0x40, 0x03, 0x02, 0x16, 0x5C,
+0x74, 0x50, 0x2D, 0xF5, 0x82, 0xE4, 0x34, 0x10, 0xF5, 0x83, 0x74, 0x01, 0xF0, 0x02, 0x16, 0x5C,
+0x90, 0x10, 0x4D, 0xE0, 0xFD, 0x24, 0x47, 0xF5, 0x82, 0xE4, 0x34, 0x10, 0xF5, 0x83, 0x74, 0x40,
+0xF0, 0x74, 0x48, 0x2D, 0xF5, 0x82, 0xE4, 0x34, 0x10, 0xF5, 0x83, 0xE4, 0xF0, 0x74, 0x4E, 0x2D,
+0xF5, 0x82, 0xE4, 0x34, 0x10, 0xF5, 0x83, 0x74, 0x40, 0xF0, 0x74, 0x4F, 0x2D, 0xF5, 0x82, 0xE4,
+0x34, 0x10, 0xF5, 0x83, 0xE4, 0xF0, 0x90, 0x10, 0x98, 0xE0, 0xFE, 0x90, 0x10, 0x97, 0xE0, 0xFB,
+0xEE, 0xEB, 0xC3, 0x94, 0x20, 0xEE, 0x94, 0x01, 0x40, 0x03, 0x02, 0x16, 0x5C, 0x74, 0x50, 0x2D,
+0xF5, 0x82, 0xE4, 0x34, 0x10, 0xF5, 0x83, 0xE4, 0xF0, 0x02, 0x16, 0x5C, 0x7B, 0x01, 0x7A, 0x10,
+0x79, 0x51, 0x90, 0x10, 0x46, 0x12, 0x27, 0xBA, 0x90, 0x10, 0x52, 0x74, 0x07, 0xF0, 0x90, 0x10,
+0x54, 0xE0, 0xFE, 0x90, 0x10, 0x53, 0xE0, 0xFD, 0xEE, 0x90, 0x10, 0x4C, 0xF0, 0xED, 0xA3, 0xF0,
+0x30, 0x06, 0x59, 0xE0, 0xFD, 0x24, 0x47, 0xF5, 0x82, 0xE4, 0x34, 0x10, 0xF5, 0x83, 0x74, 0x40,
+0xF0, 0x74, 0x48, 0x2D, 0xF5, 0x82, 0xE4, 0x34, 0x10, 0xF5, 0x83, 0xE4, 0xF0, 0x74, 0x4E, 0x2D,
+0xF5, 0x82, 0xE4, 0x34, 0x10, 0xF5, 0x83, 0x74, 0x40, 0xF0, 0x74, 0x4F, 0x2D, 0xF5, 0x82, 0xE4,
+0x34, 0x10, 0xF5, 0x83, 0xE4, 0xF0, 0x90, 0x10, 0x98, 0xE0, 0xFE, 0x90, 0x10, 0x97, 0xE0, 0xFB,
+0xEE, 0xEB, 0xC3, 0x94, 0x20, 0xEE, 0x94, 0x01, 0x40, 0x03, 0x02, 0x16, 0x5C, 0x74, 0x50, 0x2D,
+0xF5, 0x82, 0xE4, 0x34, 0x10, 0xF5, 0x83, 0xE4, 0xF0, 0x02, 0x16, 0x5C, 0x90, 0x10, 0x4D, 0xE0,
+0xFD, 0x24, 0x47, 0xF5, 0x82, 0xE4, 0x34, 0x10, 0xF5, 0x83, 0xE4, 0xF0, 0x74, 0x48, 0x2D, 0xF5,
+0x82, 0xE4, 0x34, 0x10, 0xF5, 0x83, 0x74, 0x02, 0xF0, 0x74, 0x4E, 0x2D, 0xF5, 0x82, 0xE4, 0x34,
+0x10, 0xF5, 0x83, 0xE4, 0xF0, 0x74, 0x4F, 0x2D, 0xF5, 0x82, 0xE4, 0x34, 0x10, 0xF5, 0x83, 0x74,
+0x02, 0xF0, 0x90, 0x10, 0x98, 0xE0, 0xFE, 0x90, 0x10, 0x97, 0xE0, 0xFB, 0xEE, 0xEB, 0xC3, 0x94,
+0x20, 0xEE, 0x94, 0x01, 0x40, 0x03, 0x02, 0x16, 0x5C, 0x74, 0x50, 0x2D, 0xF5, 0x82, 0xE4, 0x34,
+0x10, 0xF5, 0x83, 0x74, 0x01, 0xF0, 0x02, 0x16, 0x5C, 0x90, 0x06, 0x12, 0xE0, 0x14, 0x60, 0x2F,
+0x14, 0x70, 0x03, 0x02, 0x15, 0x34, 0x14, 0x70, 0x03, 0x02, 0x15, 0xD5, 0x24, 0x03, 0x60, 0x03,
+0x02, 0x16, 0x4C, 0x7B, 0x01, 0x7A, 0x43, 0x79, 0x1A, 0x90, 0x10, 0x46, 0x12, 0x27, 0xBA, 0x90,
+0x43, 0x1A, 0xE0, 0xFF, 0x90, 0x10, 0x4C, 0xE4, 0xF0, 0xA3, 0xEF, 0xF0, 0x02, 0x16, 0x5C, 0x90,
+0x10, 0x98, 0xE0, 0xFE, 0x90, 0x10, 0x97, 0xE0, 0xFD, 0xEE, 0xED, 0xC3, 0x94, 0x20, 0xEE, 0x94,
+0x01, 0x50, 0x1C, 0x7B, 0x01, 0x7A, 0x10, 0x79, 0x14, 0x90, 0x10, 0x46, 0x12, 0x27, 0xBA, 0x90,
+0x10, 0x14, 0xE0, 0xFF, 0x90, 0x10, 0x4C, 0xE4, 0xF0, 0xA3, 0xEF, 0xF0, 0x02, 0x16, 0x5C, 0x90,
+0x10, 0x3C, 0xE0, 0xC3, 0x94, 0x01, 0x50, 0x08, 0x90, 0x06, 0x22, 0xE0, 0x44, 0x08, 0xF0, 0x22,
+0x90, 0x10, 0x0D, 0xE0, 0x20, 0xE0, 0x1C, 0x7B, 0x01, 0x7A, 0x10, 0x79, 0x14, 0x90, 0x10, 0x46,
+0x12, 0x27, 0xBA, 0x90, 0x10, 0x14, 0xE0, 0xFF, 0x90, 0x10, 0x4C, 0xE4, 0xF0, 0xA3, 0xEF, 0xF0,
+0x02, 0x16, 0x5C, 0x90, 0x10, 0x2E, 0x12, 0x27, 0x9A, 0x90, 0x10, 0x46, 0x12, 0x27, 0xBA, 0x90,
+0x10, 0x2E, 0x12, 0x27, 0x9A, 0x12, 0x26, 0x36, 0xFF, 0x90, 0x10, 0x4C, 0xE4, 0xF0, 0xA3, 0xEF,
+0xF0, 0x02, 0x16, 0x5C, 0x90, 0x10, 0x98, 0xE0, 0xFE, 0x90, 0x10, 0x97, 0xE0, 0xFD, 0xEE, 0xED,
+0xC3, 0x94, 0x20, 0xEE, 0x94, 0x01, 0x50, 0x33, 0x90, 0x10, 0x99, 0xE0, 0x70, 0x0C, 0xA3, 0xE0,
+0x70, 0x08, 0x90, 0x06, 0x22, 0xE0, 0x44, 0x08, 0xF0, 0x22, 0x90, 0x10, 0x2E, 0x12, 0x27, 0x9A,
+0x90, 0x10, 0x46, 0x12, 0x27, 0xBA, 0x90, 0x10, 0x2E, 0x12, 0x27, 0x9A, 0x12, 0x26, 0x36, 0xFF,
+0x90, 0x10, 0x4C, 0xE4, 0xF0, 0xA3, 0xEF, 0xF0, 0x02, 0x16, 0x5C, 0x90, 0x10, 0x3C, 0xE0, 0xC3,
+0x94, 0x02, 0x50, 0x08, 0x90, 0x06, 0x22, 0xE0, 0x44, 0x08, 0xF0, 0x22, 0x90, 0x10, 0x0D, 0xE0,
+0x20, 0xE0, 0x21, 0x90, 0x10, 0x2E, 0x12, 0x27, 0x9A, 0x90, 0x10, 0x46, 0x12, 0x27, 0xBA, 0x90,
+0x10, 0x2E, 0x12, 0x27, 0x9A, 0x12, 0x26, 0x36, 0xFF, 0x90, 0x10, 0x4C, 0xE4, 0xF0, 0xA3, 0xEF,
+0xF0, 0x02, 0x16, 0x5C, 0x90, 0x10, 0x31, 0x12, 0x27, 0x9A, 0x90, 0x10, 0x46, 0x12, 0x27, 0xBA,
+0x90, 0x10, 0x31, 0x12, 0x27, 0x9A, 0x12, 0x26, 0x36, 0xFF, 0x90, 0x10, 0x4C, 0xE4, 0xF0, 0xA3,
+0xEF, 0xF0, 0x02, 0x16, 0x5C, 0x90, 0x10, 0x98, 0xE0, 0xFE, 0x90, 0x10, 0x97, 0xE0, 0xFD, 0xEE,
+0xED, 0xC3, 0x94, 0x20, 0xEE, 0x94, 0x01, 0x50, 0x32, 0x90, 0x10, 0x99, 0xE0, 0x60, 0x04, 0xA3,
+0xE0, 0x70, 0x08, 0x90, 0x06, 0x22, 0xE0, 0x44, 0x08, 0xF0, 0x22, 0x90, 0x10, 0x31, 0x12, 0x27,
+0x9A, 0x90, 0x10, 0x46, 0x12, 0x27, 0xBA, 0x90, 0x10, 0x31, 0x12, 0x27, 0x9A, 0x12, 0x26, 0x36,
+0xFF, 0x90, 0x10, 0x4C, 0xE4, 0xF0, 0xA3, 0xEF, 0xF0, 0x80, 0x41, 0x90, 0x10, 0x3C, 0xE0, 0xC3,
+0x94, 0x03, 0x50, 0x08, 0x90, 0x06, 0x22, 0xE0, 0x44, 0x08, 0xF0, 0x22, 0x90, 0x10, 0x31, 0x12,
+0x27, 0x9A, 0x90, 0x10, 0x46, 0x12, 0x27, 0xBA, 0x90, 0x10, 0x31, 0x12, 0x27, 0x9A, 0x12, 0x26,
+0x36, 0xFF, 0x90, 0x10, 0x4C, 0xE4, 0xF0, 0xA3, 0xEF, 0xF0, 0x80, 0x10, 0x90, 0x06, 0x22, 0xE0,
+0x44, 0x08, 0xF0, 0x22, 0x90, 0x06, 0x22, 0xE0, 0x44, 0x08, 0xF0, 0x22, 0x90, 0x45, 0x31, 0xE0,
+0xFE, 0xA3, 0xE0, 0xFF, 0xD3, 0x90, 0x10, 0x4D, 0xE0, 0x9F, 0x90, 0x10, 0x4C, 0xE0, 0x9E, 0x40,
+0x05, 0xEE, 0xF0, 0xA3, 0xEF, 0xF0, 0x02, 0x33, 0xF6, 0x90, 0x06, 0x12, 0xE0, 0x90, 0x10, 0x3E,
+0xF0, 0x90, 0x10, 0x3D, 0x74, 0x04, 0xF0, 0x90, 0x06, 0x23, 0x74, 0x80, 0xF0, 0xA3, 0x74, 0x08,
+0xF0, 0xA3, 0xF0, 0x90, 0x10, 0x3E, 0xE0, 0xFF, 0x44, 0x80, 0x90, 0x06, 0x06, 0xF0, 0xEF, 0x70,
+0x07, 0x90, 0x10, 0x38, 0x74, 0x07, 0xF0, 0x22, 0x90, 0x10, 0x38, 0x74, 0x0F, 0xF0, 0x22, 0x90,
+0x06, 0x13, 0xE0, 0xFE, 0x90, 0x06, 0x12, 0xE0, 0xFD, 0xEE, 0x90, 0x45, 0x35, 0xF0, 0xED, 0xA3,
+0xF0, 0x90, 0x45, 0x35, 0xE0, 0xFE, 0xA3, 0xE0, 0xFF, 0x64, 0x01, 0x4E, 0x60, 0x0C, 0xEF, 0x4E,
+0x60, 0x08, 0x90, 0x06, 0x22, 0xE0, 0x44, 0x08, 0xF0, 0x22, 0x90, 0x06, 0x12, 0xE0, 0x90, 0x10,
+0x3A, 0xF0, 0x90, 0x10, 0x3D, 0x74, 0x08, 0xF0, 0x90, 0x06, 0x08, 0x74, 0x02, 0xF0, 0xA3, 0x04,
+0xF0, 0xA3, 0x74, 0x01, 0xF0, 0x90, 0x06, 0x23, 0x74, 0x80, 0xF0, 0xA3, 0x74, 0x08, 0xF0, 0xA3,
+0xF0, 0x90, 0x10, 0x3A, 0xE0, 0x70, 0x0D, 0x90, 0x10, 0x38, 0x74, 0x0F, 0xF0, 0x90, 0x06, 0x07,
+0x74, 0x02, 0xF0, 0x22, 0x90, 0x10, 0x38, 0x74, 0x1F, 0xF0, 0x90, 0x06, 0x07, 0xE0, 0x44, 0x1C,
+0xF0, 0x90, 0x06, 0x0B, 0x74, 0x70, 0xF0, 0xE4, 0x90, 0x10, 0x34, 0xF0, 0xA3, 0xF0, 0xA3, 0xF0,
+0xA3, 0xF0, 0x22, 0x90, 0x10, 0x38, 0xE0, 0x64, 0x1F, 0x70, 0x4E, 0x90, 0x06, 0x15, 0xE0, 0xFE,
+0x90, 0x06, 0x14, 0xE0, 0xFD, 0xEE, 0x90, 0x45, 0x33, 0xF0, 0xED, 0xA3, 0xF0, 0x90, 0x10, 0x55,
+0xE0, 0xFF, 0xC3, 0x90, 0x45, 0x34, 0xE0, 0x9F, 0x90, 0x45, 0x33, 0xE0, 0x94, 0x00, 0x50, 0x21,
+0xE4, 0x90, 0x06, 0x60, 0xF0, 0x90, 0x10, 0x3D, 0x74, 0x09, 0xF0, 0xE4, 0x90, 0x10, 0x4C, 0xF0,
+0xA3, 0xF0, 0xC2, 0x04, 0x90, 0x06, 0x23, 0x74, 0x81, 0xF0, 0xA3, 0x74, 0x08, 0xF0, 0xA3, 0xF0,
+0x22, 0x90, 0x06, 0x22, 0xE0, 0x44, 0x08, 0xF0, 0x22, 0x90, 0x06, 0x22, 0xE0, 0x44, 0x08, 0xF0,
+0x22, 0x90, 0x06, 0x13, 0xE0, 0xFE, 0x90, 0x06, 0x12, 0xE0, 0xFD, 0xEE, 0x90, 0x45, 0x35, 0xF0,
+0xED, 0xA3, 0xF0, 0x90, 0x06, 0x15, 0xE0, 0xFE, 0x90, 0x06, 0x14, 0xE0, 0xFD, 0xEE, 0x90, 0x45,
+0x33, 0xF0, 0xED, 0xA3, 0xF0, 0xA3, 0xE0, 0x70, 0x02, 0xA3, 0xE0, 0x70, 0x13, 0x90, 0x10, 0x55,
+0xE0, 0xFF, 0xC3, 0x90, 0x45, 0x34, 0xE0, 0x9F, 0x90, 0x45, 0x33, 0xE0, 0x94, 0x00, 0x40, 0x08,
+0x90, 0x06, 0x22, 0xE0, 0x44, 0x08, 0xF0, 0x22, 0x90, 0x06, 0x23, 0x74, 0x80, 0xF0, 0xA3, 0x74,
+0x08, 0xF0, 0xA3, 0xF0, 0x22, 0x90, 0x10, 0x38, 0xE0, 0xB4, 0x1F, 0x08, 0x90, 0x06, 0x60, 0x74,
+0x01, 0xF0, 0x80, 0x05, 0xE4, 0x90, 0x06, 0x60, 0xF0, 0x90, 0x10, 0x3D, 0x74, 0x07, 0xF0, 0xE4,
+0x90, 0x10, 0x4C, 0xF0, 0xA3, 0xF0, 0xC2, 0x04, 0x90, 0x06, 0x23, 0x74, 0x81, 0xF0, 0xA3, 0x74,
+0x08, 0xF0, 0xA3, 0xF0, 0x22, 0x90, 0x06, 0x10, 0xE0, 0x24, 0x7F, 0x60, 0x14, 0x14, 0x60, 0x4E,
+0x24, 0x02, 0x60, 0x03, 0x02, 0x18, 0xD2, 0xE4, 0x90, 0x06, 0x60, 0xF0, 0xA3, 0xF0, 0x02, 0x18,
+0xDA, 0x90, 0x06, 0x15, 0xE0, 0xFE, 0x90, 0x06, 0x14, 0xE0, 0xFD, 0xEE, 0x90, 0x45, 0x33, 0xF0,
+0xED, 0xA3, 0xF0, 0x90, 0x10, 0x55, 0xE0, 0xFF, 0xC3, 0x90, 0x45, 0x34, 0xE0, 0x9F, 0x90, 0x45,
+0x33, 0xE0, 0x94, 0x00, 0x50, 0x07, 0x90, 0x10, 0x38, 0xE0, 0xB4, 0x0F, 0x08, 0x90, 0x06, 0x22,
+0xE0, 0x44, 0x08, 0xF0, 0x22, 0xE4, 0x90, 0x06, 0x60, 0xF0, 0xA3, 0xF0, 0x80, 0x6C, 0x90, 0x06,
+0x15, 0xE0, 0xFE, 0x90, 0x06, 0x14, 0xE0, 0xFD, 0xEE, 0x90, 0x45, 0x33, 0xF0, 0xED, 0xA3, 0xF0,
+0x90, 0x45, 0x33, 0xE0, 0xFE, 0xA3, 0xE0, 0xFF, 0x64, 0x81, 0x4E, 0x60, 0x0C, 0xEF, 0x64, 0x82,
+0x4E, 0x60, 0x06, 0xEF, 0x64, 0x03, 0x4E, 0x70, 0x0B, 0x90, 0x10, 0x38, 0xE0, 0xB4, 0x0F, 0x0C,
+0xEF, 0x4E, 0x60, 0x08, 0x90, 0x06, 0x22, 0xE0, 0x44, 0x08, 0xF0, 0x22, 0x7E, 0x00, 0xEF, 0x54,
+0x7F, 0x24, 0x34, 0xF5, 0x82, 0xEE, 0x34, 0x10, 0xF5, 0x83, 0xE0, 0xB4, 0x01, 0x08, 0x90, 0x06,
+0x60, 0x74, 0x01, 0xF0, 0x80, 0x05, 0xE4, 0x90, 0x06, 0x60, 0xF0, 0xE4, 0x90, 0x06, 0x61, 0xF0,
+0x80, 0x08, 0x90, 0x06, 0x22, 0xE0, 0x44, 0x08, 0xF0, 0x22, 0x90, 0x10, 0x3D, 0x74, 0x01, 0xF0,
+0xE4, 0x90, 0x10, 0x4C, 0xF0, 0xA3, 0xF0, 0xC2, 0x04, 0x90, 0x06, 0x23, 0x74, 0x82, 0xF0, 0xA3,
+0x74, 0x08, 0xF0, 0xA3, 0xF0, 0x22, 0x90, 0x06, 0x10, 0xE0, 0x24, 0xFE, 0x60, 0x03, 0x02, 0x19,
+0xBA, 0x90, 0x06, 0x15, 0xE0, 0xFE, 0x90, 0x06, 0x14, 0xE0, 0xFD, 0xEE, 0x90, 0x45, 0x33, 0xF0,
+0xED, 0xA3, 0xF0, 0x90, 0x06, 0x13, 0xE0, 0xFE, 0x90, 0x06, 0x12, 0xE0, 0xFD, 0xEE, 0x90, 0x45,
+0x35, 0xF0, 0xED, 0xA3, 0xF0, 0x90, 0x10, 0x38, 0xE0, 0xF9, 0x64, 0x1F, 0x70, 0x76, 0x90, 0x45,
+0x33, 0xE0, 0xFE, 0xA3, 0xE0, 0xFF, 0x64, 0x81, 0x4E, 0x70, 0x19, 0x90, 0x06, 0x0B, 0xE0, 0x54,
+0xFB, 0xF0, 0x7C, 0x00, 0xEF, 0x54, 0x7F, 0x24, 0x34, 0xF5, 0x82, 0xEC, 0x34, 0x10, 0xF5, 0x83,
+0xE4, 0xF0, 0x80, 0x6E, 0xEF, 0x64, 0x82, 0x4E, 0x70, 0x1C, 0x90, 0x06, 0x0B, 0xE0, 0x54, 0xFE,
+0xF0, 0x7E, 0x00, 0x90, 0x45, 0x34, 0xE0, 0x54, 0x7F, 0x24, 0x34, 0xF5, 0x82, 0xEE, 0x34, 0x10,
+0xF5, 0x83, 0xE4, 0xF0, 0x80, 0x4C, 0x90, 0x45, 0x33, 0xE0, 0xFE, 0xA3, 0xE0, 0xFF, 0x64, 0x03,
+0x4E, 0x70, 0x19, 0x90, 0x06, 0x0B, 0xE0, 0x54, 0xFD, 0xF0, 0x7E, 0x00, 0xEF, 0x54, 0x7F, 0x24,
+0x34, 0xF5, 0x82, 0xEE, 0x34, 0x10, 0xF5, 0x83, 0xE4, 0xF0, 0x80, 0x26, 0x90, 0x06, 0x22, 0xE0,
+0x44, 0x08, 0xF0, 0x22, 0xE9, 0xB4, 0x0F, 0x1A, 0x90, 0x45, 0x33, 0xE0, 0x70, 0x02, 0xA3, 0xE0,
+0x60, 0x10, 0x90, 0x06, 0x22, 0xE0, 0x44, 0x08, 0xF0, 0x22, 0x90, 0x06, 0x22, 0xE0, 0x44, 0x08,
+0xF0, 0x22, 0xC2, 0x04, 0x90, 0x06, 0x23, 0x74, 0x80, 0xF0, 0xA3, 0x74, 0x08, 0xF0, 0xA3, 0xF0,
+0x22, 0x90, 0x06, 0x10, 0xE0, 0x24, 0xFE, 0x60, 0x44, 0x24, 0x02, 0x60, 0x03, 0x02, 0x1A, 0xCA,
+0x90, 0x06, 0x13, 0xE0, 0xFE, 0x90, 0x06, 0x12, 0xE0, 0xFD, 0xEE, 0x90, 0x45, 0x35, 0xF0, 0xED,
+0xA3, 0xF0, 0x90, 0x45, 0x35, 0xE0, 0x70, 0x04, 0xA3, 0xE0, 0x64, 0x02, 0x70, 0x17, 0x90, 0x06,
+0x14, 0xE0, 0x70, 0x11, 0x90, 0x10, 0x3D, 0x74, 0x0F, 0xF0, 0x90, 0x06, 0x15, 0xE0, 0x90, 0x10,
+0x50, 0xF0, 0x02, 0x1A, 0xD2, 0x90, 0x06, 0x22, 0xE0, 0x44, 0x08, 0xF0, 0x22, 0x90, 0x06, 0x15,
+0xE0, 0xFE, 0x90, 0x06, 0x14, 0xE0, 0xFD, 0xEE, 0x90, 0x45, 0x33, 0xF0, 0xED, 0xA3, 0xF0, 0x90,
+0x06, 0x13, 0xE0, 0xFE, 0x90, 0x06, 0x12, 0xE0, 0xFD, 0xEE, 0x90, 0x45, 0x35, 0xF0, 0xED, 0xA3,
+0xF0, 0x90, 0x10, 0x38, 0xE0, 0x64, 0x1F, 0x70, 0x79, 0x90, 0x45, 0x33, 0xE0, 0xFE, 0xA3, 0xE0,
+0xFF, 0x64, 0x81, 0x4E, 0x70, 0x1A, 0x90, 0x06, 0x0B, 0xE0, 0x44, 0x04, 0xF0, 0x7C, 0x00, 0xEF,
+0x54, 0x7F, 0x24, 0x34, 0xF5, 0x82, 0xEC, 0x34, 0x10, 0xF5, 0x83, 0x74, 0x01, 0xF0, 0x80, 0x62,
+0xEF, 0x64, 0x82, 0x4E, 0x70, 0x1D, 0x90, 0x06, 0x0B, 0xE0, 0x44, 0x01, 0xF0, 0x7E, 0x00, 0x90,
+0x45, 0x34, 0xE0, 0x54, 0x7F, 0x24, 0x34, 0xF5, 0x82, 0xEE, 0x34, 0x10, 0xF5, 0x83, 0x74, 0x01,
+0xF0, 0x80, 0x3F, 0x90, 0x45, 0x33, 0xE0, 0xFE, 0xA3, 0xE0, 0xFF, 0x64, 0x03, 0x4E, 0x70, 0x1A,
+0x90, 0x06, 0x0B, 0xE0, 0x44, 0x02, 0xF0, 0x7E, 0x00, 0xEF, 0x54, 0x7F, 0x24, 0x34, 0xF5, 0x82,
+0xEE, 0x34, 0x10, 0xF5, 0x83, 0x74, 0x01, 0xF0, 0x80, 0x18, 0x90, 0x06, 0x22, 0xE0, 0x44, 0x08,
+0xF0, 0x22, 0x90, 0x06, 0x22, 0xE0, 0x44, 0x08, 0xF0, 0x22, 0x90, 0x06, 0x22, 0xE0, 0x44, 0x08,
+0xF0, 0x22, 0xC2, 0x04, 0x90, 0x06, 0x23, 0x74, 0x80, 0xF0, 0xA3, 0x74, 0x08, 0xF0, 0xA3, 0xF0,
+0x22, 0x90, 0x06, 0x22, 0xE0, 0x44, 0x08, 0xF0, 0x22, 0x90, 0x06, 0x10, 0xE0, 0x64, 0x40, 0x60,
+0x03, 0x02, 0x1C, 0xA2, 0xE0, 0x90, 0x43, 0x1E, 0xF0, 0x90, 0x06, 0x11, 0xE0, 0x90, 0x43, 0x1F,
+0xF0, 0x90, 0x06, 0x13, 0xE0, 0xFE, 0x90, 0x06, 0x12, 0xE0, 0xFD, 0xEE, 0x90, 0x43, 0x20, 0xF0,
+0xED, 0xA3, 0xF0, 0x90, 0x06, 0x15, 0xE0, 0xFE, 0x90, 0x06, 0x14, 0xE0, 0xFD, 0xEE, 0x90, 0x43,
+0x22, 0xF0, 0xED, 0xA3, 0xF0, 0x90, 0x06, 0x17, 0xE0, 0xFE, 0x90, 0x06, 0x16, 0xE0, 0xFD, 0xEE,
+0x90, 0x43, 0x24, 0xF0, 0xED, 0xA3, 0xF0, 0xE4, 0x90, 0x10, 0x44, 0xF0, 0xA3, 0xF0, 0x90, 0x43,
+0x24, 0xE0, 0xFF, 0xA3, 0xE0, 0x90, 0x10, 0x42, 0xCF, 0xF0, 0xA3, 0xEF, 0xF0, 0x90, 0x43, 0x1F,
+0xE0, 0x12, 0x28, 0x7E, 0x1B, 0x70, 0x00, 0x1B, 0xE6, 0x01, 0x1B, 0x79, 0x07, 0x1B, 0x8F, 0x0B,
+0x1B, 0xAF, 0x0C, 0x1B, 0xC9, 0x10, 0x1B, 0xD9, 0x12, 0x1B, 0xFE, 0x13, 0x00, 0x00, 0x1C, 0x6A,
+0x90, 0x10, 0x3D, 0x74, 0x0B, 0xF0, 0x02, 0x1C, 0x8E, 0x90, 0x10, 0x3D, 0x74, 0x0B, 0xF0, 0x12,
+0x3D, 0x31, 0x90, 0x06, 0x23, 0x74, 0x80, 0xF0, 0xA3, 0x74, 0x08, 0xF0, 0xA3, 0xF0, 0x22, 0x90,
+0x10, 0x3D, 0x74, 0x0B, 0xF0, 0x90, 0x43, 0x21, 0xE0, 0xFF, 0x90, 0x45, 0x45, 0xE0, 0xFD, 0x12,
+0x39, 0xB4, 0x90, 0x06, 0x23, 0x74, 0x80, 0xF0, 0xA3, 0x74, 0x08, 0xF0, 0xA3, 0xF0, 0x22, 0x90,
+0x45, 0x45, 0xE0, 0xFF, 0x90, 0x06, 0x12, 0xE0, 0xFD, 0x12, 0x39, 0x2D, 0x90, 0x06, 0x23, 0x74,
+0x80, 0xF0, 0xA3, 0x74, 0x08, 0xF0, 0xA3, 0xF0, 0x22, 0x12, 0x3E, 0x03, 0x90, 0x06, 0x23, 0x74,
+0x80, 0xF0, 0xA3, 0x74, 0x08, 0xF0, 0xA3, 0xF0, 0x22, 0x90, 0x06, 0x23, 0x74, 0x80, 0xF0, 0xA3,
+0x74, 0x08, 0xF0, 0xA3, 0xF0, 0x22, 0x90, 0x10, 0x3D, 0x74, 0x10, 0xF0, 0x90, 0x06, 0x23, 0x74,
+0x80, 0xF0, 0xA3, 0x74, 0x08, 0xF0, 0xA3, 0xF0, 0x12, 0x3D, 0xBA, 0x02, 0x1C, 0x8E, 0x90, 0x06,
+0x23, 0x74, 0x80, 0xF0, 0xA3, 0x74, 0x08, 0xF0, 0xA3, 0xF0, 0x90, 0x04, 0x7A, 0xE0, 0x90, 0x45,
+0x39, 0xF0, 0xE0, 0x54, 0x7F, 0xF0, 0x44, 0x80, 0xF0, 0x90, 0x04, 0x7A, 0xF0, 0x7D, 0x17, 0x7F,
+0x0C, 0x12, 0x3D, 0x00, 0x7D, 0xB9, 0x7F, 0x0D, 0x12, 0x3D, 0x00, 0x90, 0x04, 0x54, 0x74, 0x01,
+0xF0, 0xE4, 0x90, 0x04, 0x78, 0xF0, 0xA3, 0xF0, 0x90, 0x06, 0x20, 0x74, 0x20, 0xF0, 0x90, 0x04,
+0x59, 0x74, 0x10, 0xF0, 0xE4, 0x90, 0x06, 0x05, 0xF0, 0x90, 0x06, 0x07, 0x74, 0x03, 0xF0, 0x75,
+0xA8, 0x81, 0x43, 0x87, 0x01, 0x90, 0x06, 0x20, 0x74, 0x21, 0xF0, 0x90, 0x04, 0x58, 0x74, 0x14,
+0xF0, 0xA3, 0x74, 0x50, 0xF0, 0x43, 0xA8, 0x81, 0x80, 0x24, 0x90, 0x10, 0x3D, 0x74, 0x0D, 0xF0,
+0x7B, 0x01, 0x7A, 0x43, 0x79, 0x26, 0x90, 0x10, 0x3F, 0x12, 0x27, 0xBA, 0x90, 0x06, 0x17, 0xE0,
+0xFE, 0x90, 0x06, 0x16, 0xE0, 0xFD, 0xEE, 0x90, 0x10, 0x42, 0xF0, 0xED, 0xA3, 0xF0, 0xE4, 0x90,
+0x06, 0x24, 0xF0, 0x90, 0x06, 0x23, 0x74, 0xC0, 0xF0, 0x90, 0x06, 0x25, 0x74, 0x08, 0xF0, 0xC2,
+0x04, 0x22, 0x90, 0x06, 0x10, 0xE0, 0x64, 0xC0, 0x60, 0x03, 0x02, 0x1E, 0x86, 0xE0, 0x90, 0x43,
+0x1E, 0xF0, 0x90, 0x06, 0x11, 0xE0, 0x90, 0x43, 0x1F, 0xF0, 0x90, 0x06, 0x13, 0xE0, 0xFE, 0x90,
+0x06, 0x12, 0xE0, 0xFD, 0xEE, 0x90, 0x43, 0x20, 0xF0, 0xED, 0xA3, 0xF0, 0x90, 0x06, 0x15, 0xE0,
+0xFE, 0x90, 0x06, 0x14, 0xE0, 0xFD, 0xEE, 0x90, 0x43, 0x22, 0xF0, 0xED, 0xA3, 0xF0, 0x90, 0x06,
+0x17, 0xE0, 0xFE, 0x90, 0x06, 0x16, 0xE0, 0xFD, 0xEE, 0x90, 0x43, 0x24, 0xF0, 0xED, 0xA3, 0xF0,
+0x90, 0x43, 0x24, 0xE0, 0xFF, 0xA3, 0xE0, 0x90, 0x10, 0x4C, 0xCF, 0xF0, 0xA3, 0xEF, 0xF0, 0x90,
+0x43, 0x1F, 0xE0, 0x24, 0xFA, 0x70, 0x03, 0x02, 0x1E, 0x58, 0x24, 0x05, 0x60, 0x03, 0x02, 0x1E,
+0x6F, 0x90, 0x43, 0x22, 0xE0, 0xFE, 0xA3, 0xE0, 0xFF, 0xEE, 0x60, 0x03, 0x02, 0x1E, 0x50, 0xEF,
+0x24, 0xFE, 0x70, 0x03, 0x02, 0x1D, 0xCD, 0x14, 0x60, 0x31, 0x14, 0x60, 0x4E, 0x24, 0xFC, 0x70,
+0x03, 0x02, 0x1E, 0x1A, 0x24, 0x07, 0x60, 0x03, 0x02, 0x1E, 0x50, 0x7B, 0x01, 0x7A, 0x00, 0x79,
+0x00, 0x90, 0x10, 0x46, 0x12, 0x27, 0xBA, 0x90, 0x43, 0x20, 0xE0, 0xFE, 0xA3, 0xE0, 0xFF, 0x90,
+0x10, 0x47, 0xEE, 0x8F, 0xF0, 0x12, 0x26, 0xB0, 0x02, 0x1E, 0x77, 0x7B, 0x01, 0x7A, 0x04, 0x79,
+0x00, 0x90, 0x10, 0x46, 0x12, 0x27, 0xBA, 0x90, 0x43, 0x20, 0xE0, 0xFE, 0xA3, 0xE0, 0xFF, 0x90,
+0x10, 0x47, 0xEE, 0x8F, 0xF0, 0x12, 0x26, 0xB0, 0x02, 0x1E, 0x77, 0x7B, 0x01, 0x7A, 0x43, 0x79,
+0x26, 0x90, 0x10, 0x46, 0x12, 0x27, 0xBA, 0xE4, 0x90, 0x45, 0x37, 0xF0, 0xA3, 0xF0, 0x90, 0x43,
+0x24, 0xE0, 0xFE, 0xA3, 0xE0, 0xFF, 0xC3, 0x90, 0x45, 0x38, 0xE0, 0x9F, 0x90, 0x45, 0x37, 0xE0,
+0x9E, 0x40, 0x03, 0x02, 0x1E, 0x77, 0xA3, 0xE0, 0xFF, 0x90, 0x43, 0x21, 0xE0, 0x2F, 0xFF, 0x12,
+0x3B, 0x25, 0x90, 0x45, 0x38, 0xE0, 0x24, 0x26, 0xF5, 0x82, 0xE4, 0x34, 0x43, 0xF5, 0x83, 0xEF,
+0xF0, 0x90, 0x45, 0x37, 0xE4, 0x75, 0xF0, 0x01, 0x12, 0x26, 0xB0, 0x80, 0xC1, 0x7B, 0x01, 0x7A,
+0x43, 0x79, 0x26, 0x90, 0x10, 0x46, 0x12, 0x27, 0xBA, 0xE4, 0x90, 0x45, 0x37, 0xF0, 0xA3, 0xF0,
+0x90, 0x43, 0x24, 0xE0, 0xFE, 0xA3, 0xE0, 0xFF, 0xC3, 0x90, 0x45, 0x38, 0xE0, 0x9F, 0x90, 0x45,
+0x37, 0xE0, 0x9E, 0x40, 0x03, 0x02, 0x1E, 0x77, 0xA3, 0xE0, 0xFE, 0x90, 0x43, 0x21, 0xE0, 0x2E,
+0xFF, 0x74, 0x26, 0x2E, 0xF9, 0xE4, 0x34, 0x43, 0xFA, 0x7B, 0x01, 0x12, 0x3C, 0xCD, 0x90, 0x45,
+0x37, 0xE4, 0x75, 0xF0, 0x01, 0x12, 0x26, 0xB0, 0x80, 0xC6, 0x7B, 0x01, 0x7A, 0x43, 0x79, 0x26,
+0x90, 0x10, 0x46, 0x12, 0x27, 0xBA, 0xD3, 0x90, 0x43, 0x25, 0xE0, 0x94, 0x02, 0x90, 0x43, 0x24,
+0xE0, 0x94, 0x00, 0x40, 0x0F, 0xE4, 0xF0, 0xA3, 0x74, 0x02, 0xF0, 0x90, 0x10, 0x4C, 0xE4, 0xF0,
+0xA3, 0x74, 0x02, 0xF0, 0x90, 0x43, 0x26, 0x74, 0x33, 0xF0, 0xA3, 0x74, 0x01, 0xF0, 0x80, 0x27,
+0x90, 0x06, 0x22, 0xE0, 0x44, 0x08, 0xF0, 0x22, 0x7B, 0x01, 0x7A, 0x44, 0x79, 0x2E, 0x90, 0x10,
+0x46, 0x12, 0x27, 0xBA, 0x90, 0x10, 0x4C, 0xE4, 0xF0, 0xA3, 0x74, 0x0A, 0xF0, 0x80, 0x08, 0x90,
+0x06, 0x22, 0xE0, 0x44, 0x08, 0xF0, 0x22, 0x90, 0x06, 0x24, 0x74, 0x08, 0xF0, 0x12, 0x33, 0xF6,
+0x90, 0x10, 0x3D, 0x74, 0x0C, 0xF0, 0x22, 0xD2, 0x00, 0x90, 0x43, 0x1F, 0xE0, 0x12, 0x28, 0x7E,
+0x1E, 0xAF, 0x04, 0x1F, 0xB1, 0x05, 0x1F, 0xC4, 0x08, 0x20, 0xE2, 0x09, 0x21, 0x37, 0x0A, 0x21,
+0xE9, 0x0D, 0x22, 0x7F, 0x0E, 0x22, 0xB1, 0x0F, 0x23, 0x3B, 0x11, 0x00, 0x00, 0x23, 0x4F, 0x90,
+0x43, 0x22, 0xE0, 0xFE, 0xA3, 0xE0, 0xFF, 0xEE, 0x60, 0x03, 0x02, 0x23, 0x4F, 0xEF, 0x24, 0xFE,
+0x70, 0x03, 0x02, 0x1F, 0x7D, 0x14, 0x60, 0x4B, 0x14, 0x70, 0x03, 0x02, 0x1F, 0x51, 0x24, 0x03,
+0x60, 0x03, 0x02, 0x23, 0x4F, 0x90, 0x43, 0x21, 0xE0, 0xFF, 0x24, 0x00, 0xF5, 0x82, 0xE4, 0x34,
+0x00, 0xF5, 0x83, 0xC0, 0x83, 0xC0, 0x82, 0xE0, 0xFE, 0x90, 0x43, 0x27, 0xE0, 0xF4, 0xFD, 0xEE,
+0x5D, 0xD0, 0x82, 0xD0, 0x83, 0xF0, 0x74, 0x00, 0x2F, 0xF5, 0x82, 0xE4, 0x34, 0x00, 0xF5, 0x83,
+0xC0, 0x83, 0xC0, 0x82, 0xE0, 0xFF, 0x90, 0x43, 0x26, 0xE0, 0xFE, 0xEF, 0x4E, 0xD0, 0x82, 0xD0,
+0x83, 0xF0, 0x22, 0x90, 0x43, 0x21, 0xE0, 0xFF, 0x24, 0x00, 0xF5, 0x82, 0xE4, 0x34, 0x04, 0xF5,
+0x83, 0xC0, 0x83, 0xC0, 0x82, 0xE0, 0xFE, 0x90, 0x43, 0x27, 0xE0, 0xF4, 0xFD, 0xEE, 0x5D, 0xD0,
+0x82, 0xD0, 0x83, 0xF0, 0x74, 0x00, 0x2F, 0xF5, 0x82, 0xE4, 0x34, 0x04, 0xF5, 0x83, 0xC0, 0x83,
+0xC0, 0x82, 0xE0, 0xFF, 0x90, 0x43, 0x26, 0xE0, 0xFE, 0xEF, 0x4E, 0xD0, 0x82, 0xD0, 0x83, 0xF0,
+0x22, 0x90, 0x43, 0x21, 0xE0, 0xFF, 0x12, 0x3B, 0x25, 0x90, 0x45, 0x37, 0xEF, 0xF0, 0x90, 0x43,
+0x27, 0xE0, 0xF4, 0x5F, 0xFF, 0x90, 0x45, 0x37, 0xF0, 0xFE, 0x90, 0x43, 0x21, 0xE0, 0xFF, 0x90,
+0x43, 0x26, 0xE0, 0x4E, 0xFD, 0x12, 0x3A, 0x33, 0x72, 0x00, 0x92, 0x00, 0x22, 0x90, 0x43, 0x21,
+0xE0, 0xFF, 0x7B, 0x01, 0x7A, 0x45, 0x79, 0x37, 0x12, 0x3C, 0xCD, 0x90, 0x45, 0x37, 0xE0, 0xFF,
+0x90, 0x43, 0x27, 0xE0, 0xF4, 0xFE, 0xEF, 0x5E, 0xFF, 0x90, 0x45, 0x37, 0xF0, 0xFE, 0x90, 0x43,
+0x21, 0xE0, 0xFF, 0x90, 0x43, 0x26, 0xE0, 0x4E, 0xFD, 0x12, 0x3D, 0x00, 0x72, 0x00, 0x92, 0x00,
+0x22, 0x7B, 0x01, 0x7A, 0x44, 0x79, 0x2E, 0x90, 0x45, 0x3B, 0x12, 0x27, 0xBA, 0x7A, 0x43, 0x79,
+0x26, 0x02, 0x2A, 0xF6, 0x90, 0x43, 0x21, 0xE0, 0xFD, 0x90, 0x04, 0xBC, 0xF0, 0x90, 0x43, 0x20,
+0xE0, 0xFA, 0xA3, 0xE0, 0xFB, 0xEA, 0x90, 0x04, 0xBD, 0xF0, 0x90, 0x43, 0x26, 0xE0, 0x90, 0x04,
+0xC0, 0xF0, 0x90, 0x43, 0x27, 0xE0, 0x90, 0x04, 0xC1, 0xF0, 0x90, 0x43, 0x28, 0xE0, 0x90, 0x04,
+0xC2, 0xF0, 0x90, 0x43, 0x29, 0xE0, 0x90, 0x04, 0xC3, 0xF0, 0x90, 0x04, 0xBE, 0x74, 0x01, 0xF0,
+0xED, 0x04, 0x90, 0x04, 0xBC, 0xF0, 0xEB, 0x24, 0x01, 0xE4, 0x3A, 0xA3, 0xF0, 0x90, 0x43, 0x2A,
+0xE0, 0x90, 0x04, 0xC0, 0xF0, 0x90, 0x43, 0x2B, 0xE0, 0x90, 0x04, 0xC1, 0xF0, 0x90, 0x43, 0x2C,
+0xE0, 0x90, 0x04, 0xC2, 0xF0, 0x90, 0x43, 0x2D, 0xE0, 0x90, 0x04, 0xC3, 0xF0, 0x90, 0x04, 0xBE,
+0x74, 0x01, 0xF0, 0xE4, 0x90, 0x45, 0x35, 0xF0, 0xA3, 0xF0, 0x90, 0x45, 0x35, 0xE0, 0xFE, 0xA3,
+0xE0, 0xFF, 0xC3, 0x94, 0x04, 0xEE, 0x64, 0x80, 0x94, 0x80, 0x40, 0x03, 0x02, 0x23, 0x4F, 0x90,
+0x43, 0x21, 0xE0, 0x24, 0x02, 0xFD, 0x90, 0x45, 0x36, 0xE0, 0xF9, 0x2D, 0xFD, 0x90, 0x43, 0x23,
+0xE0, 0x25, 0xE0, 0x25, 0xE0, 0x2D, 0x90, 0x04, 0xBC, 0xF0, 0x90, 0x43, 0x21, 0xE0, 0x24, 0x02,
+0xFD, 0x90, 0x43, 0x20, 0xE0, 0x34, 0x00, 0xCD, 0x2F, 0xCD, 0x3E, 0xFC, 0x90, 0x43, 0x22, 0xE0,
+0xFE, 0xA3, 0xE0, 0x78, 0x02, 0xC3, 0x33, 0xCE, 0x33, 0xCE, 0xD8, 0xF9, 0x2D, 0xEC, 0x3E, 0x90,
+0x04, 0xBD, 0xF0, 0x75, 0xF0, 0x04, 0xE9, 0x90, 0x43, 0x2E, 0x12, 0x27, 0x8E, 0xE0, 0x90, 0x04,
+0xC0, 0xF0, 0x75, 0xF0, 0x04, 0xE9, 0x90, 0x43, 0x2F, 0x12, 0x27, 0x8E, 0xE0, 0x90, 0x04, 0xC1,
+0xF0, 0x75, 0xF0, 0x04, 0xE9, 0x90, 0x43, 0x30, 0x12, 0x27, 0x8E, 0xE0, 0x90, 0x04, 0xC2, 0xF0,
+0x75, 0xF0, 0x04, 0xE9, 0x90, 0x43, 0x31, 0x12, 0x27, 0x8E, 0xE0, 0x90, 0x04, 0xC3, 0xF0, 0x90,
+0x04, 0xBE, 0x74, 0x01, 0xF0, 0x90, 0x45, 0x35, 0xE4, 0x75, 0xF0, 0x01, 0x12, 0x26, 0xB0, 0x02,
+0x20, 0x3A, 0xE4, 0x90, 0x04, 0xBD, 0xF0, 0x90, 0x04, 0xC0, 0xF0, 0xA3, 0xF0, 0xA3, 0xF0, 0xA3,
+0xF0, 0x90, 0x45, 0x35, 0xF0, 0xA3, 0xF0, 0x90, 0x43, 0x24, 0xE0, 0xFE, 0xA3, 0xE0, 0xFF, 0xC3,
+0x90, 0x45, 0x36, 0xE0, 0x9F, 0x90, 0x45, 0x35, 0xE0, 0x9E, 0x40, 0x03, 0x02, 0x23, 0x4F, 0xA3,
+0xE0, 0x24, 0x26, 0xF5, 0x82, 0xE4, 0x34, 0x43, 0xF5, 0x83, 0xE0, 0x75, 0xF0, 0x16, 0xA4, 0x24,
+0x20, 0x90, 0x04, 0xBC, 0xF0, 0x90, 0x04, 0xBE, 0x74, 0x01, 0xF0, 0x90, 0x45, 0x35, 0xE4, 0x75,
+0xF0, 0x01, 0x12, 0x26, 0xB0, 0x80, 0xC0, 0xE4, 0x90, 0x45, 0x35, 0xF0, 0xA3, 0xF0, 0xFD, 0xFC,
+0x90, 0x43, 0x24, 0xE0, 0xFE, 0xA3, 0xE0, 0xFF, 0xC3, 0x90, 0x45, 0x36, 0xE0, 0x9F, 0x90, 0x45,
+0x35, 0xE0, 0x9E, 0x40, 0x03, 0x02, 0x23, 0x4F, 0x90, 0x43, 0x21, 0xE0, 0x2D, 0x90, 0x04, 0xBC,
+0xF0, 0x90, 0x43, 0x21, 0xE0, 0x2D, 0x90, 0x43, 0x20, 0xE0, 0x3C, 0x90, 0x04, 0xBD, 0xF0, 0x90,
+0x45, 0x35, 0xE4, 0x75, 0xF0, 0x01, 0x12, 0x26, 0xC6, 0xFE, 0x74, 0x26, 0x25, 0xF0, 0xF5, 0x82,
+0x74, 0x43, 0x3E, 0xF5, 0x83, 0xE0, 0x90, 0x04, 0xC0, 0xF0, 0x90, 0x45, 0x35, 0xE4, 0x75, 0xF0,
+0x01, 0x12, 0x26, 0xC6, 0xFE, 0x74, 0x26, 0x25, 0xF0, 0xF5, 0x82, 0x74, 0x43, 0x3E, 0xF5, 0x83,
+0xE0, 0x90, 0x04, 0xC1, 0xF0, 0x90, 0x45, 0x35, 0xE4, 0x75, 0xF0, 0x01, 0x12, 0x26, 0xC6, 0xFE,
+0x74, 0x26, 0x25, 0xF0, 0xF5, 0x82, 0x74, 0x43, 0x3E, 0xF5, 0x83, 0xE0, 0x90, 0x04, 0xC2, 0xF0,
+0x90, 0x45, 0x35, 0xE4, 0x75, 0xF0, 0x01, 0x12, 0x26, 0xC6, 0xFE, 0x74, 0x26, 0x25, 0xF0, 0xF5,
+0x82, 0x74, 0x43, 0x3E, 0xF5, 0x83, 0xE0, 0x90, 0x04, 0xC3, 0xF0, 0x90, 0x04, 0xBE, 0x74, 0x01,
+0xF0, 0x0D, 0xBD, 0x00, 0x01, 0x0C, 0x02, 0x21, 0x40, 0x90, 0x43, 0x20, 0xE0, 0xFE, 0xA3, 0xE0,
+0xFF, 0x64, 0x05, 0x4E, 0x70, 0x40, 0x90, 0x45, 0x35, 0xF0, 0xA3, 0xF0, 0x90, 0x45, 0x36, 0xE0,
+0xFD, 0x24, 0x26, 0xF5, 0x82, 0xE4, 0x34, 0x43, 0xF5, 0x83, 0xE0, 0xFC, 0x74, 0x40, 0x2D, 0xF5,
+0x82, 0xE4, 0x34, 0x04, 0xF5, 0x83, 0xEC, 0xF0, 0x90, 0x45, 0x35, 0xE4, 0x75, 0xF0, 0x01, 0x12,
+0x26, 0xB0, 0x90, 0x45, 0x35, 0xE0, 0x70, 0x04, 0xA3, 0xE0, 0x64, 0x08, 0x70, 0xCE, 0x90, 0x04,
+0x48, 0xE0, 0x44, 0x04, 0xF0, 0x22, 0xEF, 0x64, 0x06, 0x4E, 0x60, 0x03, 0x02, 0x23, 0x4F, 0x90,
+0x45, 0x35, 0xF0, 0xA3, 0xF0, 0x90, 0x45, 0x36, 0xE0, 0xFF, 0x24, 0x26, 0xF5, 0x82, 0xE4, 0x34,
+0x43, 0xF5, 0x83, 0xE0, 0xFE, 0x74, 0x38, 0x2F, 0xF5, 0x82, 0xE4, 0x34, 0x04, 0xF5, 0x83, 0xEE,
+0xF0, 0x90, 0x45, 0x35, 0xE4, 0x75, 0xF0, 0x01, 0x12, 0x26, 0xB0, 0x90, 0x45, 0x35, 0xE0, 0x70,
+0x04, 0xA3, 0xE0, 0x64, 0x08, 0x70, 0xCE, 0x90, 0x04, 0x48, 0xE0, 0x44, 0x08, 0xF0, 0x22, 0x90,
+0x43, 0x26, 0xE0, 0x90, 0x04, 0x22, 0xF0, 0x90, 0x43, 0x27, 0xE0, 0x90, 0x04, 0x23, 0xF0, 0x90,
+0x43, 0x28, 0xE0, 0x90, 0x04, 0x24, 0xF0, 0x90, 0x43, 0x29, 0xE0, 0x90, 0x04, 0x25, 0xF0, 0x90,
+0x43, 0x2A, 0xE0, 0x90, 0x04, 0x28, 0xF0, 0x90, 0x43, 0x2B, 0xE0, 0xFD, 0x7F, 0x0A, 0x02, 0x3D,
+0x00, 0x90, 0x43, 0x26, 0xE0, 0x90, 0x04, 0x22, 0xF0, 0x90, 0x43, 0x27, 0xE0, 0x90, 0x04, 0x23,
+0xF0, 0x90, 0x43, 0x28, 0xE0, 0x90, 0x04, 0x24, 0xF0, 0x90, 0x43, 0x29, 0xE0, 0x90, 0x04, 0x25,
+0xF0, 0x90, 0x43, 0x2A, 0xE0, 0x90, 0x04, 0x28, 0xF0, 0x90, 0x43, 0x2B, 0xE0, 0xFD, 0x7F, 0x0A,
+0x12, 0x3D, 0x00, 0x90, 0x43, 0x2C, 0xE0, 0xFD, 0x7F, 0x88, 0x12, 0x3D, 0x00, 0x90, 0x04, 0x4C,
+0xE0, 0x54, 0xFC, 0xF0, 0xE0, 0xFF, 0x90, 0x43, 0x2D, 0xE0, 0xFE, 0xEF, 0x4E, 0x90, 0x04, 0x4C,
+0xF0, 0xE4, 0x90, 0x45, 0x35, 0xF0, 0xA3, 0xF0, 0x90, 0x45, 0x36, 0xE0, 0xFF, 0x24, 0x2E, 0xF5,
+0x82, 0xE4, 0x34, 0x43, 0xF5, 0x83, 0xE0, 0xFE, 0x74, 0xDC, 0x2F, 0xF5, 0x82, 0xE4, 0x34, 0x04,
+0xF5, 0x83, 0xEE, 0xF0, 0x90, 0x45, 0x35, 0xE4, 0x75, 0xF0, 0x01, 0x12, 0x26, 0xB0, 0x90, 0x45,
+0x35, 0xE0, 0x70, 0x04, 0xA3, 0xE0, 0x64, 0x22, 0x70, 0xCE, 0x22, 0x90, 0x43, 0x26, 0xE0, 0xFF,
+0xA3, 0xE0, 0xFD, 0xA3, 0xE0, 0xFB, 0xA3, 0xE0, 0x90, 0x45, 0x44, 0xF0, 0x12, 0x3C, 0x90, 0x22,
+0x90, 0x06, 0x30, 0x74, 0x70, 0xF0, 0x90, 0x06, 0x31, 0x74, 0xA0, 0xF0, 0xE0, 0x90, 0x06, 0x35,
+0xF0, 0x90, 0x06, 0x36, 0x74, 0xC0, 0xF0, 0x90, 0x06, 0x37, 0x74, 0x08, 0xF0, 0xE4, 0x90, 0x45,
+0x46, 0xF0, 0xA3, 0xF0, 0xC2, 0x05, 0x90, 0x06, 0x20, 0x74, 0x21, 0xF0, 0x90, 0x04, 0x58, 0x74,
+0x14, 0xF0, 0xA3, 0x74, 0x50, 0xF0, 0x12, 0x3C, 0x43, 0x75, 0xA8, 0x81, 0x90, 0x06, 0x05, 0x74,
+0x04, 0xF0, 0x90, 0x06, 0x0F, 0xE0, 0x30, 0xE4, 0x04, 0xD2, 0x06, 0x80, 0x02, 0xC2, 0x06, 0xE4,
+0x90, 0x43, 0x19, 0xF0, 0x20, 0x05, 0x03, 0x02, 0x25, 0xFB, 0xC2, 0x05, 0x90, 0x10, 0x39, 0xE0,
+0xFF, 0x20, 0xE5, 0x03, 0x02, 0x24, 0xCD, 0x54, 0xDF, 0xF0, 0x90, 0x06, 0x0E, 0xE0, 0x20, 0xE0,
+0x03, 0x02, 0x24, 0x4D, 0x7D, 0x17, 0x7F, 0x0C, 0x12, 0x3D, 0x00, 0x7D, 0xB9, 0x7F, 0x0D, 0x12,
+0x3D, 0x00, 0x90, 0x04, 0x54, 0x74, 0x01, 0xF0, 0xE4, 0x90, 0x45, 0x2F, 0xF0, 0xA3, 0xF0, 0x90,
+0x04, 0x54, 0xE0, 0x30, 0xE0, 0x16, 0x90, 0x45, 0x2F, 0xE4, 0x75, 0xF0, 0x01, 0x12, 0x26, 0xB0,
+0x90, 0x45, 0x2F, 0xE0, 0xB4, 0x07, 0xE8, 0xA3, 0xE0, 0xB4, 0xFF, 0xE3, 0xE4, 0x90, 0x04, 0x78,
+0xF0, 0xA3, 0x74, 0x11, 0xF0, 0x90, 0x06, 0x0E, 0xE0, 0x54, 0x01, 0xF0, 0x90, 0x06, 0x30, 0x74,
+0x70, 0xF0, 0x90, 0x06, 0x31, 0x74, 0xA0, 0xF0, 0xE0, 0x90, 0x06, 0x35, 0xF0, 0x90, 0x06, 0x36,
+0x74, 0xC0, 0xF0, 0x90, 0x06, 0x37, 0x74, 0x08, 0xF0, 0x90, 0x06, 0x38, 0x74, 0x03, 0xF0, 0x90,
+0x06, 0x01, 0xE0, 0x44, 0x20, 0xF0, 0x90, 0x06, 0x07, 0x74, 0x02, 0xF0, 0x90, 0x10, 0x38, 0x74,
+0x07, 0xF0, 0x90, 0x06, 0x0E, 0xE0, 0x30, 0xE1, 0x04, 0xE0, 0x54, 0x02, 0xF0, 0x90, 0x06, 0x0E,
+0xE0, 0x30, 0xE3, 0x11, 0xE0, 0x54, 0x08, 0xF0, 0x90, 0x06, 0x0F, 0xE0, 0x30, 0xE4, 0x04, 0xD2,
+0x06, 0x80, 0x02, 0xC2, 0x06, 0x90, 0x06, 0x0E, 0xE0, 0x30, 0xE2, 0x0A, 0xE0, 0x54, 0x04, 0xF0,
+0x90, 0x04, 0x79, 0x74, 0x11, 0xF0, 0x90, 0x06, 0x0E, 0xE0, 0x30, 0xE1, 0x50, 0xE0, 0x20, 0xE0,
+0x4C, 0x7D, 0x17, 0x7F, 0x0C, 0x12, 0x3D, 0x00, 0x7D, 0xB9, 0x7F, 0x0D, 0x12, 0x3D, 0x00, 0x90,
+0x04, 0x54, 0x74, 0x01, 0xF0, 0xE4, 0x90, 0x04, 0x78, 0xF0, 0xA3, 0xF0, 0x90, 0x06, 0x0E, 0xE0,
+0x54, 0x02, 0xF0, 0x90, 0x06, 0x20, 0x74, 0x20, 0xF0, 0xE4, 0x90, 0x04, 0x58, 0xF0, 0x90, 0x06,
+0x07, 0x74, 0x03, 0xF0, 0x90, 0x04, 0x7A, 0xE0, 0x90, 0x45, 0x2E, 0xF0, 0xE0, 0x54, 0xF9, 0xF0,
+0x44, 0x02, 0xF0, 0x90, 0x04, 0x7A, 0xF0, 0x43, 0xA8, 0x81, 0x43, 0x87, 0x01, 0x90, 0x10, 0x39,
+0xE0, 0x30, 0xE0, 0x22, 0x90, 0x06, 0x24, 0xE0, 0x30, 0xE4, 0x05, 0x12, 0x12, 0x0E, 0x80, 0x0F,
+0x90, 0x06, 0x24, 0xE0, 0x30, 0xE3, 0x05, 0x12, 0x34, 0xB9, 0x80, 0x03, 0x12, 0x28, 0xF4, 0x90,
+0x10, 0x39, 0xE0, 0x54, 0xFE, 0xF0, 0x90, 0x45, 0x46, 0xE0, 0x54, 0x14, 0x70, 0x09, 0xA3, 0xE0,
+0xFF, 0x20, 0xE6, 0x03, 0x30, 0xE3, 0x4F, 0x7B, 0x01, 0x7A, 0x06, 0x79, 0x40, 0x12, 0x33, 0x2B,
+0x90, 0x45, 0x46, 0xE0, 0xFF, 0x90, 0x06, 0x48, 0xF0, 0x90, 0x45, 0x47, 0xE0, 0x90, 0x06, 0x49,
+0xF0, 0x90, 0x04, 0x2C, 0xE0, 0x90, 0x06, 0x4A, 0xF0, 0x90, 0x04, 0x2D, 0xE0, 0x90, 0x06, 0x4B,
+0xF0, 0x90, 0x04, 0x2E, 0xE0, 0x90, 0x06, 0x4C, 0xF0, 0x90, 0x04, 0x2F, 0xE0, 0x90, 0x06, 0x4D,
+0xF0, 0x90, 0x06, 0x3F, 0x74, 0x01, 0xF0, 0xEF, 0x54, 0xEB, 0x90, 0x45, 0x46, 0xF0, 0xA3, 0xE0,
+0x54, 0xBF, 0xF0, 0x54, 0xF7, 0xF0, 0x90, 0x45, 0x47, 0xE0, 0xFF, 0x20, 0xE4, 0x03, 0x02, 0x25,
+0xE8, 0x90, 0x04, 0x7A, 0xE0, 0x54, 0xDF, 0xF0, 0xE0, 0x90, 0x45, 0x2E, 0xF0, 0xE0, 0x20, 0xE6,
+0x54, 0x90, 0x04, 0x7A, 0xE0, 0x90, 0x45, 0x2E, 0xF0, 0xE0, 0x54, 0x7F, 0xF0, 0x44, 0x80, 0xF0,
+0x90, 0x04, 0x7A, 0xF0, 0xEF, 0x54, 0xEF, 0x90, 0x45, 0x47, 0xF0, 0x7D, 0x17, 0x7F, 0x0C, 0x12,
+0x3D, 0x00, 0x7D, 0xB9, 0x7F, 0x0D, 0x12, 0x3D, 0x00, 0x90, 0x04, 0x54, 0x74, 0x01, 0xF0, 0xE4,
+0x90, 0x04, 0x78, 0xF0, 0xA3, 0xF0, 0x90, 0x06, 0x20, 0x74, 0x20, 0xF0, 0x90, 0x04, 0x59, 0x74,
+0x10, 0xF0, 0xE4, 0x90, 0x06, 0x05, 0xF0, 0x90, 0x06, 0x07, 0x74, 0x03, 0xF0, 0x75, 0xA8, 0x81,
+0x43, 0x87, 0x01, 0x80, 0x23, 0x90, 0x04, 0x7A, 0xE0, 0x90, 0x45, 0x2E, 0xF0, 0xE0, 0x54, 0x7F,
+0xF0, 0x90, 0x04, 0x7A, 0xF0, 0x90, 0x10, 0x38, 0x74, 0x07, 0xF0, 0x90, 0x06, 0x05, 0x74, 0x04,
+0xF0, 0x90, 0x45, 0x47, 0xE0, 0x54, 0xEF, 0xF0, 0x90, 0x06, 0x20, 0x74, 0x21, 0xF0, 0x90, 0x04,
+0x58, 0x74, 0x14, 0xF0, 0xA3, 0x74, 0x50, 0xF0, 0x43, 0xA8, 0x81, 0x90, 0x43, 0x19, 0xE0, 0x64,
+0x01, 0x60, 0x03, 0x02, 0x23, 0xA4, 0xF0, 0x90, 0x06, 0x24, 0xE0, 0x30, 0xE3, 0x03, 0x02, 0x23,
+0xA4, 0x90, 0x06, 0x25, 0xE0, 0x54, 0xF7, 0xF0, 0x30, 0x04, 0x07, 0xE4, 0x90, 0x06, 0x23, 0xF0,
+0x80, 0x06, 0x90, 0x06, 0x23, 0x74, 0x80, 0xF0, 0x90, 0x06, 0x24, 0x74, 0x08, 0xF0, 0x90, 0x06,
+0x25, 0xF0, 0x02, 0x23, 0xA4, 0x22, 0xBB, 0x01, 0x06, 0x89, 0x82, 0x8A, 0x83, 0xE0, 0x22, 0x50,
+0x02, 0xE7, 0x22, 0xBB, 0xFE, 0x02, 0xE3, 0x22, 0x89, 0x82, 0x8A, 0x83, 0xE4, 0x93, 0x22, 0xBB,
+0x01, 0x0C, 0xE5, 0x82, 0x29, 0xF5, 0x82, 0xE5, 0x83, 0x3A, 0xF5, 0x83, 0xE0, 0x22, 0x50, 0x06,
+0xE9, 0x25, 0x82, 0xF8, 0xE6, 0x22, 0xBB, 0xFE, 0x06, 0xE9, 0x25, 0x82, 0xF8, 0xE2, 0x22, 0xE5,
+0x82, 0x29, 0xF5, 0x82, 0xE5, 0x83, 0x3A, 0xF5, 0x83, 0xE4, 0x93, 0x22, 0xBB, 0x01, 0x06, 0x89,
+0x82, 0x8A, 0x83, 0xF0, 0x22, 0x50, 0x02, 0xF7, 0x22, 0xBB, 0xFE, 0x01, 0xF3, 0x22, 0xF8, 0xBB,
+0x01, 0x0D, 0xE5, 0x82, 0x29, 0xF5, 0x82, 0xE5, 0x83, 0x3A, 0xF5, 0x83, 0xE8, 0xF0, 0x22, 0x50,
+0x06, 0xE9, 0x25, 0x82, 0xC8, 0xF6, 0x22, 0xBB, 0xFE, 0x05, 0xE9, 0x25, 0x82, 0xC8, 0xF2, 0x22,
+0xC5, 0xF0, 0xF8, 0xA3, 0xE0, 0x28, 0xF0, 0xC5, 0xF0, 0xF8, 0xE5, 0x82, 0x15, 0x82, 0x70, 0x02,
+0x15, 0x83, 0xE0, 0x38, 0xF0, 0x22, 0xA3, 0xF8, 0xE0, 0xC5, 0xF0, 0x25, 0xF0, 0xF0, 0xE5, 0x82,
+0x15, 0x82, 0x70, 0x02, 0x15, 0x83, 0xE0, 0xC8, 0x38, 0xF0, 0xE8, 0x22, 0xBB, 0x01, 0x10, 0xE5,
+0x82, 0x29, 0xF5, 0x82, 0xE5, 0x83, 0x3A, 0xF5, 0x83, 0xE0, 0xF5, 0xF0, 0xA3, 0xE0, 0x22, 0x50,
+0x09, 0xE9, 0x25, 0x82, 0xF8, 0x86, 0xF0, 0x08, 0xE6, 0x22, 0xBB, 0xFE, 0x0A, 0xE9, 0x25, 0x82,
+0xF8, 0xE2, 0xF5, 0xF0, 0x08, 0xE2, 0x22, 0xE5, 0x83, 0x2A, 0xF5, 0x83, 0xE9, 0x93, 0xF5, 0xF0,
+0xA3, 0xE9, 0x93, 0x22, 0xBB, 0x01, 0x0D, 0xC5, 0x82, 0x29, 0xC5, 0x82, 0xC5, 0x83, 0x3A, 0xC5,
+0x83, 0x02, 0x26, 0xB0, 0x50, 0x11, 0xC5, 0x82, 0x29, 0xF8, 0x08, 0xE5, 0xF0, 0x26, 0xF6, 0x18,
+0xF5, 0xF0, 0xE5, 0x82, 0x36, 0xF6, 0x22, 0xBB, 0xFE, 0x11, 0xC5, 0x82, 0x29, 0xF8, 0x08, 0xE2,
+0x25, 0xF0, 0xF5, 0xF0, 0xF2, 0x18, 0xE2, 0x35, 0x82, 0xF2, 0x22, 0xF8, 0xE5, 0x82, 0x29, 0xF5,
+0x82, 0xE5, 0x83, 0x2A, 0xF5, 0x83, 0x74, 0x01, 0x93, 0x25, 0xF0, 0xF5, 0xF0, 0xE4, 0x93, 0x38,
+0x22, 0xF8, 0xBB, 0x01, 0x11, 0xE5, 0x82, 0x29, 0xF5, 0x82, 0xE5, 0x83, 0x3A, 0xF5, 0x83, 0xE8,
+0xF0, 0xE5, 0xF0, 0xA3, 0xF0, 0x22, 0x50, 0x09, 0xE9, 0x25, 0x82, 0xC8, 0xF6, 0x08, 0xA6, 0xF0,
+0x22, 0xBB, 0xFE, 0x09, 0xE9, 0x25, 0x82, 0xC8, 0xF2, 0xE5, 0xF0, 0x08, 0xF2, 0x22, 0xA4, 0x25,
+0x82, 0xF5, 0x82, 0xE5, 0xF0, 0x35, 0x83, 0xF5, 0x83, 0x22, 0xE0, 0xFB, 0xA3, 0xE0, 0xFA, 0xA3,
+0xE0, 0xF9, 0x22, 0xF8, 0xE0, 0xFB, 0xA3, 0xA3, 0xE0, 0xF9, 0x25, 0xF0, 0xF0, 0xE5, 0x82, 0x15,
+0x82, 0x70, 0x02, 0x15, 0x83, 0xE0, 0xFA, 0x38, 0xF0, 0x22, 0xEB, 0xF0, 0xA3, 0xEA, 0xF0, 0xA3,
+0xE9, 0xF0, 0x22, 0xBB, 0x01, 0x0D, 0xE5, 0x82, 0x29, 0xF5, 0x82, 0xE5, 0x83, 0x3A, 0xF5, 0x83,
+0x02, 0x27, 0x9A, 0x50, 0x07, 0xE9, 0x25, 0x82, 0xF8, 0x02, 0x28, 0xA4, 0xBB, 0xFE, 0x07, 0xE9,
+0x25, 0x82, 0xF8, 0x02, 0x28, 0xC6, 0xE5, 0x82, 0x29, 0xF5, 0x82, 0xE5, 0x83, 0x3A, 0xF5, 0x83,
+0x02, 0x28, 0xE8, 0xBB, 0x01, 0x0D, 0xC5, 0x82, 0x29, 0xC5, 0x82, 0xC5, 0x83, 0x3A, 0xC5, 0x83,
+0x02, 0x27, 0xA3, 0x50, 0x08, 0xF8, 0xE9, 0x25, 0x82, 0xC8, 0x02, 0x28, 0xAD, 0xBB, 0xFE, 0x08,
+0xF8, 0xE9, 0x25, 0x82, 0xC8, 0x02, 0x28, 0xCF, 0xC5, 0x82, 0x29, 0xC5, 0x82, 0xC5, 0x83, 0x3A,
+0xC5, 0x83, 0x02, 0x28, 0xE8, 0xBB, 0x01, 0x20, 0xE5, 0x82, 0x29, 0xF5, 0x82, 0xE5, 0x83, 0x3A,
+0xF5, 0x83, 0xD0, 0xF0, 0xD0, 0xE0, 0xF8, 0xD0, 0xE0, 0xF9, 0xD0, 0xE0, 0xFA, 0xD0, 0xE0, 0xFB,
+0xE8, 0xC0, 0xE0, 0xC0, 0xF0, 0x02, 0x27, 0xBA, 0x50, 0x18, 0xE9, 0x25, 0x82, 0xF8, 0xD0, 0x83,
+0xD0, 0x82, 0xD0, 0xE0, 0xF9, 0xD0, 0xE0, 0xFA, 0xD0, 0xE0, 0xFB, 0xC0, 0x82, 0xC0, 0x83, 0x02,
+0x28, 0xBD, 0xBB, 0xFE, 0x18, 0xE9, 0x25, 0x82, 0xF8, 0xD0, 0x83, 0xD0, 0x82, 0xD0, 0xE0, 0xF9,
+0xD0, 0xE0, 0xFA, 0xD0, 0xE0, 0xFB, 0xC0, 0x82, 0xC0, 0x83, 0x02, 0x28, 0xDF, 0x22, 0xD0, 0x83,
+0xD0, 0x82, 0xF8, 0xE4, 0x93, 0x70, 0x12, 0x74, 0x01, 0x93, 0x70, 0x0D, 0xA3, 0xA3, 0x93, 0xF8,
+0x74, 0x01, 0x93, 0xF5, 0x82, 0x88, 0x83, 0xE4, 0x73, 0x74, 0x02, 0x93, 0x68, 0x60, 0xEF, 0xA3,
+0xA3, 0xA3, 0x80, 0xDF, 0xE6, 0xFB, 0x08, 0xE6, 0xFA, 0x08, 0xE6, 0xF9, 0x22, 0xFA, 0xE6, 0xFB,
+0x08, 0x08, 0xE6, 0xF9, 0x25, 0xF0, 0xF6, 0x18, 0xE6, 0xCA, 0x3A, 0xF6, 0x22, 0xEB, 0xF6, 0x08,
+0xEA, 0xF6, 0x08, 0xE9, 0xF6, 0x22, 0xE2, 0xFB, 0x08, 0xE2, 0xFA, 0x08, 0xE2, 0xF9, 0x22, 0xFA,
+0xE2, 0xFB, 0x08, 0x08, 0xE2, 0xF9, 0x25, 0xF0, 0xF2, 0x18, 0xE2, 0xCA, 0x3A, 0xF2, 0x22, 0xEB,
+0xF2, 0x08, 0xEA, 0xF2, 0x08, 0xE9, 0xF2, 0x22, 0xE4, 0x93, 0xFB, 0x74, 0x01, 0x93, 0xFA, 0x74,
+0x02, 0x93, 0xF9, 0x22, 0x90, 0x06, 0x23, 0xE0, 0x54, 0x7F, 0xFF, 0xC3, 0x74, 0x40, 0x9F, 0x90,
+0x45, 0x31, 0xF0, 0xE4, 0xA3, 0xF0, 0x90, 0x10, 0x3D, 0xE0, 0x64, 0x0B, 0x60, 0x03, 0x02, 0x2A,
+0x60, 0x90, 0x10, 0x44, 0xE0, 0xFE, 0xA3, 0xE0, 0xFF, 0x90, 0x43, 0x21, 0xE0, 0x2F, 0x90, 0x45,
+0x34, 0xF0, 0x90, 0x43, 0x20, 0xE0, 0x3E, 0x90, 0x45, 0x33, 0xF0, 0x90, 0x45, 0x31, 0xE0, 0x70,
+0x03, 0x02, 0x2A, 0xA6, 0x14, 0xF0, 0x90, 0x43, 0x22, 0xE0, 0xFE, 0xA3, 0xE0, 0xFF, 0xEE, 0x60,
+0x03, 0x02, 0x2A, 0x57, 0xEF, 0x12, 0x28, 0x7E, 0x29, 0x6A, 0x01, 0x29, 0x94, 0x02, 0x29, 0xB5,
+0x03, 0x29, 0xDE, 0x04, 0x29, 0xFE, 0x07, 0x2A, 0x31, 0x09, 0x2A, 0x31, 0x0A, 0x2A, 0x31, 0x0B,
+0x2A, 0x31, 0x0C, 0x2A, 0x31, 0x0D, 0x00, 0x00, 0x2A, 0x57, 0x90, 0x45, 0x32, 0xE0, 0x24, 0x60,
+0xF5, 0x82, 0xE4, 0x34, 0x06, 0xF5, 0x83, 0xE0, 0xFF, 0x90, 0x45, 0x33, 0xE4, 0x75, 0xF0, 0x01,
+0x12, 0x26, 0xC6, 0xFC, 0x74, 0x00, 0x25, 0xF0, 0xF5, 0x82, 0x74, 0x00, 0x3C, 0xF5, 0x83, 0xEF,
+0xF0, 0x02, 0x2A, 0x57, 0x90, 0x45, 0x33, 0xE4, 0x75, 0xF0, 0x01, 0x12, 0x26, 0xC6, 0xAF, 0xF0,
+0x90, 0x45, 0x32, 0xE0, 0x24, 0x60, 0xF5, 0x82, 0xE4, 0x34, 0x06, 0xF5, 0x83, 0xE0, 0xFD, 0x12,
+0x3D, 0x00, 0x02, 0x2A, 0x57, 0x90, 0x45, 0x32, 0xE0, 0x24, 0x60, 0xF5, 0x82, 0xE4, 0x34, 0x06,
+0xF5, 0x83, 0xE0, 0xFF, 0x90, 0x45, 0x33, 0xE4, 0x75, 0xF0, 0x01, 0x12, 0x26, 0xC6, 0xFC, 0x74,
+0x00, 0x25, 0xF0, 0xF5, 0x82, 0x74, 0x04, 0x3C, 0xF5, 0x83, 0xEF, 0xF0, 0x80, 0x79, 0x90, 0x45,
+0x33, 0xE4, 0x75, 0xF0, 0x01, 0x12, 0x26, 0xC6, 0xAF, 0xF0, 0x90, 0x45, 0x32, 0xE0, 0x24, 0x60,
+0xF5, 0x82, 0xE4, 0x34, 0x06, 0xF5, 0x83, 0xE0, 0xFD, 0x12, 0x3A, 0x33, 0x80, 0x59, 0x90, 0x45,
+0x32, 0xE0, 0x24, 0x60, 0xF5, 0x82, 0xE4, 0x34, 0x06, 0xF5, 0x83, 0xE0, 0xFD, 0x7F, 0xF1, 0x12,
+0x3D, 0x00, 0x90, 0x45, 0x34, 0xE0, 0x44, 0x80, 0xFD, 0x7F, 0xF0, 0x12, 0x3D, 0x00, 0x90, 0x45,
+0x33, 0xE4, 0x75, 0xF0, 0x01, 0x12, 0x26, 0xC6, 0xAD, 0xF0, 0x7F, 0xF0, 0x12, 0x3D, 0x00, 0x80,
+0x26, 0x90, 0x43, 0x22, 0xE0, 0xFE, 0xA3, 0xE0, 0xFF, 0x90, 0x45, 0x33, 0xE4, 0x75, 0xF0, 0x01,
+0x12, 0x26, 0xC6, 0xAD, 0xF0, 0x90, 0x45, 0x32, 0xE0, 0x24, 0x60, 0xF5, 0x82, 0xE4, 0x34, 0x06,
+0xF5, 0x83, 0xE0, 0xFB, 0x12, 0x3A, 0xAE, 0x90, 0x45, 0x32, 0xE0, 0x04, 0xF0, 0x02, 0x29, 0x2B,
+0x90, 0x10, 0x3D, 0xE0, 0xFF, 0xB4, 0x0D, 0x2D, 0x90, 0x45, 0x31, 0xE0, 0x60, 0x38, 0xA3, 0xE0,
+0xFE, 0x04, 0xF0, 0x74, 0x60, 0x2E, 0xF5, 0x82, 0xE4, 0x34, 0x06, 0xF5, 0x83, 0xE0, 0xFE, 0x90,
+0x10, 0x3F, 0xE4, 0x75, 0xF0, 0x01, 0x12, 0x27, 0xA3, 0xEE, 0x12, 0x26, 0x7C, 0x90, 0x45, 0x31,
+0xE0, 0x14, 0xF0, 0x80, 0xD3, 0xEF, 0xB4, 0x0C, 0x07, 0xC2, 0x8C, 0xE4, 0x90, 0x43, 0x19, 0xF0,
+0xE4, 0x90, 0x10, 0x3D, 0xF0, 0x22, 0x30, 0x04, 0x0A, 0xC2, 0x04, 0x90, 0x06, 0x23, 0x74, 0xC0,
+0xF0, 0x80, 0x08, 0xD2, 0x04, 0x90, 0x06, 0x23, 0x74, 0x40, 0xF0, 0x90, 0x45, 0x32, 0xE0, 0xFF,
+0x90, 0x10, 0x44, 0xE4, 0x8F, 0xF0, 0x12, 0x26, 0xB0, 0x90, 0x10, 0x42, 0xE0, 0xFE, 0xA3, 0xE0,
+0xFF, 0xA3, 0xE0, 0xB5, 0x06, 0x19, 0xA3, 0xE0, 0xB5, 0x07, 0x14, 0x90, 0x10, 0x3D, 0xE0, 0xB4,
+0x0D, 0x03, 0x12, 0x1E, 0x87, 0x90, 0x06, 0x23, 0x74, 0x80, 0xF0, 0xA3, 0x74, 0x08, 0xF0, 0x90,
+0x06, 0x25, 0x74, 0x08, 0xF0, 0x22, 0x90, 0x45, 0x38, 0x12, 0x27, 0xBA, 0x12, 0x26, 0x36, 0x60,
+0x03, 0x02, 0x2B, 0x8F, 0x7F, 0x1C, 0x12, 0x3B, 0x25, 0x90, 0x45, 0x3B, 0x12, 0x27, 0x9A, 0x90,
+0x00, 0x08, 0xEF, 0x12, 0x26, 0x8E, 0x7F, 0x1D, 0x12, 0x3B, 0x25, 0x90, 0x45, 0x3B, 0x12, 0x27,
+0x9A, 0x90, 0x00, 0x09, 0xEF, 0x12, 0x26, 0x8E, 0x7F, 0x1B, 0x12, 0x3B, 0x25, 0x90, 0x45, 0x3B,
+0x12, 0x27, 0x9A, 0x90, 0x00, 0x07, 0xEF, 0x12, 0x26, 0x8E, 0xE9, 0x24, 0x07, 0xF9, 0xE4, 0x3A,
+0xFA, 0x12, 0x26, 0x36, 0x54, 0x7F, 0x12, 0x26, 0x7C, 0x90, 0x45, 0x3B, 0x12, 0x27, 0x9A, 0x90,
+0x00, 0x07, 0x12, 0x26, 0x4F, 0x90, 0x45, 0x45, 0xF0, 0x90, 0x04, 0x2B, 0x74, 0xFF, 0xF0, 0x12,
+0x3C, 0x43, 0x90, 0x45, 0x3B, 0x12, 0x27, 0x9A, 0x90, 0x00, 0x07, 0x12, 0x26, 0x4F, 0xFF, 0x12,
+0x3D, 0x62, 0x90, 0x45, 0x3B, 0x12, 0x27, 0x9A, 0x90, 0x00, 0x08, 0x12, 0x26, 0x4F, 0xFD, 0x90,
+0x40, 0xC0, 0xF0, 0x90, 0x00, 0x07, 0x12, 0x26, 0x4F, 0xFF, 0x12, 0x39, 0x2D, 0x80, 0x1B, 0x12,
+0x3D, 0xE2, 0x90, 0x04, 0x54, 0xE0, 0x54, 0xFB, 0xF0, 0x90, 0x06, 0x38, 0x74, 0x03, 0xF0, 0x12,
+0x3D, 0x31, 0x90, 0x04, 0x48, 0x74, 0x02, 0xF0, 0x14, 0xF0, 0xE4, 0xFF, 0xFE, 0x74, 0xC4, 0x2F,
+0xF5, 0x82, 0xE4, 0x34, 0x04, 0xF5, 0x83, 0xE0, 0xFD, 0x90, 0x45, 0x3B, 0x12, 0x27, 0x9A, 0xE9,
+0x24, 0x01, 0xF9, 0xE4, 0x3A, 0xFA, 0xE9, 0x2F, 0xF9, 0xEA, 0x3E, 0xFA, 0xED, 0x12, 0x26, 0x7C,
+0x0F, 0xBF, 0x00, 0x01, 0x0E, 0xEF, 0x64, 0x06, 0x4E, 0x70, 0xD2, 0x90, 0x45, 0x38, 0x12, 0x27,
+0x9A, 0x90, 0x00, 0x01, 0x12, 0x26, 0x4F, 0x60, 0x31, 0xE4, 0xFE, 0xFF, 0x90, 0x45, 0x38, 0x12,
+0x27, 0x9A, 0xE9, 0x24, 0x02, 0xF9, 0xE4, 0x3A, 0xFA, 0xE9, 0x2F, 0xF9, 0xEA, 0x3E, 0xFA, 0x12,
+0x26, 0x36, 0xFD, 0x74, 0xC4, 0x2F, 0xF5, 0x82, 0xE4, 0x34, 0x04, 0xF5, 0x83, 0xED, 0xF0, 0x0F,
+0xBF, 0x00, 0x01, 0x0E, 0xEF, 0x64, 0x06, 0x4E, 0x70, 0xD2, 0x90, 0x45, 0x38, 0x12, 0x27, 0x9A,
+0x90, 0x00, 0x08, 0x12, 0x26, 0x4F, 0x90, 0x04, 0x21, 0xF0, 0x90, 0x00, 0x09, 0x12, 0x26, 0x4F,
+0x90, 0x04, 0x20, 0xF0, 0x90, 0x04, 0x50, 0xE0, 0x44, 0x82, 0xF0, 0x90, 0x04, 0x54, 0x74, 0x0E,
+0xF0, 0x90, 0x45, 0x3B, 0x12, 0x27, 0x9A, 0xE4, 0x12, 0x26, 0x7C, 0xD3, 0x22, 0xAC, 0x07, 0xAA,
+0x05, 0xD2, 0x03, 0x90, 0x04, 0x78, 0xE0, 0x54, 0xFE, 0xF0, 0xEC, 0xD3, 0x94, 0x0E, 0x40, 0x03,
+0x02, 0x2C, 0xFA, 0xEA, 0x94, 0x0E, 0x50, 0x03, 0x02, 0x2C, 0xFA, 0x90, 0x40, 0xC9, 0xE0, 0xFD,
+0x90, 0x40, 0xC8, 0xE0, 0xFB, 0x90, 0x40, 0xC7, 0x12, 0x3C, 0x89, 0x82, 0x03, 0x92, 0x03, 0x90,
+0x40, 0xCC, 0xE0, 0xFD, 0x90, 0x40, 0xCB, 0xE0, 0xFB, 0x90, 0x40, 0xCA, 0x12, 0x3C, 0x89, 0x82,
+0x03, 0x92, 0x03, 0x90, 0x40, 0xD2, 0xE0, 0xFD, 0x90, 0x40, 0xD1, 0xE0, 0xFB, 0x90, 0x40, 0xD0,
+0x12, 0x3C, 0x89, 0x82, 0x03, 0x92, 0x03, 0x90, 0x40, 0xD8, 0xE0, 0xFD, 0x90, 0x40, 0xD7, 0xE0,
+0xFB, 0x90, 0x40, 0xD6, 0x12, 0x3C, 0x89, 0x82, 0x03, 0x92, 0x03, 0x90, 0x40, 0xE1, 0xE0, 0xFD,
+0x90, 0x40, 0xE0, 0xE0, 0xFB, 0x90, 0x40, 0xDF, 0x12, 0x3C, 0x89, 0x82, 0x03, 0x92, 0x03, 0x90,
+0x40, 0xE7, 0xE0, 0xFD, 0x90, 0x40, 0xE6, 0xE0, 0xFB, 0x90, 0x40, 0xE5, 0x12, 0x3C, 0x89, 0x82,
+0x03, 0x92, 0x03, 0x90, 0x40, 0xF0, 0xE0, 0xFD, 0x90, 0x40, 0xEF, 0xE0, 0xFB, 0x90, 0x40, 0xEE,
+0x12, 0x3C, 0x89, 0x82, 0x03, 0x92, 0x03, 0x02, 0x2D, 0x98, 0xEC, 0xD3, 0x94, 0x0E, 0x50, 0x03,
+0x02, 0x2D, 0x98, 0xEA, 0xD3, 0x94, 0x0E, 0x40, 0x03, 0x02, 0x2D, 0x98, 0x90, 0x42, 0xF1, 0xE0,
+0xFD, 0x90, 0x42, 0xF0, 0xE0, 0xFB, 0x90, 0x42, 0xEF, 0x12, 0x3C, 0x89, 0x82, 0x03, 0x92, 0x03,
+0x90, 0x42, 0xF4, 0xE0, 0xFD, 0x90, 0x42, 0xF3, 0xE0, 0xFB, 0x90, 0x42, 0xF2, 0x12, 0x3C, 0x89,
+0x82, 0x03, 0x92, 0x03, 0x90, 0x42, 0xFA, 0xE0, 0xFD, 0x90, 0x42, 0xF9, 0xE0, 0xFB, 0x90, 0x42,
+0xF8, 0x12, 0x3C, 0x89, 0x82, 0x03, 0x92, 0x03, 0x90, 0x43, 0x00, 0xE0, 0xFD, 0x90, 0x42, 0xFF,
+0xE0, 0xFB, 0x90, 0x42, 0xFE, 0x12, 0x3C, 0x89, 0x82, 0x03, 0x92, 0x03, 0x90, 0x43, 0x09, 0xE0,
+0xFD, 0x90, 0x43, 0x08, 0xE0, 0xFB, 0x90, 0x43, 0x07, 0x12, 0x3C, 0x89, 0x82, 0x03, 0x92, 0x03,
+0x90, 0x43, 0x0F, 0xE0, 0xFD, 0x90, 0x43, 0x0E, 0xE0, 0xFB, 0x90, 0x43, 0x0D, 0x12, 0x3C, 0x89,
+0x82, 0x03, 0x92, 0x03, 0x90, 0x43, 0x18, 0xE0, 0xFD, 0x90, 0x43, 0x17, 0xE0, 0xFB, 0x90, 0x43,
+0x16, 0x12, 0x3C, 0x89, 0x82, 0x03, 0x92, 0x03, 0x90, 0x04, 0x78, 0xE0, 0x44, 0x01, 0xF0, 0xA2,
+0x03, 0x22, 0xAC, 0x07, 0xAA, 0x05, 0xD2, 0x03, 0xEC, 0xD3, 0x94, 0x0E, 0x40, 0x03, 0x02, 0x2E,
+0x43, 0xEA, 0x94, 0x0E, 0x50, 0x03, 0x02, 0x2E, 0x43, 0x90, 0x40, 0xC9, 0xE0, 0xFD, 0x90, 0x40,
+0xC8, 0xE0, 0xFB, 0x90, 0x40, 0xC7, 0xE0, 0x90, 0x45, 0x44, 0xF0, 0x7F, 0xB9, 0x12, 0x3C, 0x90,
+0x82, 0x03, 0x92, 0x03, 0x90, 0x40, 0xD8, 0xE0, 0xFD, 0x90, 0x40, 0xD7, 0xE0, 0xFB, 0x90, 0x40,
+0xD6, 0xE0, 0x90, 0x45, 0x44, 0xF0, 0x7F, 0xB9, 0x12, 0x3C, 0x90, 0x82, 0x03, 0x92, 0x03, 0x90,
+0x40, 0xDE, 0xE0, 0xFD, 0x90, 0x40, 0xDD, 0xE0, 0xFB, 0x90, 0x40, 0xDC, 0xE0, 0x90, 0x45, 0x44,
+0xF0, 0x7F, 0xB9, 0x12, 0x3C, 0x90, 0x82, 0x03, 0x92, 0x03, 0x90, 0x40, 0xE7, 0xE0, 0xFD, 0x90,
+0x40, 0xE6, 0xE0, 0xFB, 0x90, 0x40, 0xE5, 0xE0, 0x90, 0x45, 0x44, 0xF0, 0x7F, 0xB9, 0x12, 0x3C,
+0x90, 0x82, 0x03, 0x92, 0x03, 0x90, 0x40, 0xED, 0xE0, 0xFD, 0x90, 0x40, 0xEC, 0xE0, 0xFB, 0x90,
+0x40, 0xEB, 0xE0, 0x90, 0x45, 0x44, 0xF0, 0x7F, 0xB9, 0x12, 0x3C, 0x90, 0x82, 0x03, 0x92, 0x03,
+0x02, 0x2E, 0xDC, 0xEC, 0xD3, 0x94, 0x0E, 0x50, 0x03, 0x02, 0x2E, 0xDC, 0xEA, 0xD3, 0x94, 0x0E,
+0x40, 0x03, 0x02, 0x2E, 0xDC, 0x90, 0x42, 0xF1, 0xE0, 0xFD, 0x90, 0x42, 0xF0, 0xE0, 0xFB, 0x90,
+0x42, 0xEF, 0xE0, 0x90, 0x45, 0x44, 0xF0, 0x7F, 0xB9, 0x12, 0x3C, 0x90, 0x82, 0x03, 0x92, 0x03,
+0x90, 0x43, 0x00, 0xE0, 0xFD, 0x90, 0x42, 0xFF, 0xE0, 0xFB, 0x90, 0x42, 0xFE, 0xE0, 0x90, 0x45,
+0x44, 0xF0, 0x7F, 0xB9, 0x12, 0x3C, 0x90, 0x82, 0x03, 0x92, 0x03, 0x90, 0x43, 0x06, 0xE0, 0xFD,
+0x90, 0x43, 0x05, 0xE0, 0xFB, 0x90, 0x43, 0x04, 0xE0, 0x90, 0x45, 0x44, 0xF0, 0x7F, 0xB9, 0x12,
+0x3C, 0x90, 0x82, 0x03, 0x92, 0x03, 0x90, 0x43, 0x0F, 0xE0, 0xFD, 0x90, 0x43, 0x0E, 0xE0, 0xFB,
+0x90, 0x43, 0x0D, 0xE0, 0x90, 0x45, 0x44, 0xF0, 0x7F, 0xB9, 0x12, 0x3C, 0x90, 0x82, 0x03, 0x92,
+0x03, 0x90, 0x43, 0x15, 0xE0, 0xFD, 0x90, 0x43, 0x14, 0xE0, 0xFB, 0x90, 0x43, 0x13, 0xE0, 0x90,
+0x45, 0x44, 0xF0, 0x7F, 0xB9, 0x12, 0x3C, 0x90, 0x82, 0x03, 0x92, 0x03, 0xA2, 0x03, 0x22, 0x90,
+0x45, 0x40, 0xEF, 0xF0, 0xD2, 0x02, 0x90, 0x40, 0xC0, 0xE0, 0xFF, 0x90, 0x45, 0x40, 0xE0, 0xFD,
+0x12, 0x2D, 0xA2, 0x82, 0x02, 0x92, 0x02, 0x90, 0x45, 0x40, 0xE0, 0xFC, 0xD3, 0x94, 0x0E, 0x50,
+0x10, 0xE4, 0x90, 0x45, 0x44, 0xF0, 0x7B, 0x8A, 0x7D, 0xF1, 0x7F, 0xB9, 0x12, 0x3C, 0x90, 0x80,
+0x3A, 0xEC, 0xD3, 0x94, 0x28, 0x50, 0x10, 0xE4, 0x90, 0x45, 0x44, 0xF0, 0x7B, 0x8B, 0x7D, 0xF1,
+0x7F, 0xB9, 0x12, 0x3C, 0x90, 0x80, 0x24, 0xEC, 0xD3, 0x94, 0x33, 0x50, 0x10, 0xE4, 0x90, 0x45,
+0x44, 0xF0, 0x7B, 0x8B, 0x7D, 0xB1, 0x7F, 0xB9, 0x12, 0x3C, 0x90, 0x80, 0x0E, 0xE4, 0x90, 0x45,
+0x44, 0xF0, 0x7B, 0x8B, 0x7D, 0x91, 0x7F, 0xB9, 0x12, 0x3C, 0x90, 0x90, 0x45, 0x40, 0xE0, 0xFF,
+0x75, 0xF0, 0x03, 0xA4, 0x24, 0xF0, 0xF5, 0x82, 0xE4, 0x34, 0x40, 0xF5, 0x83, 0xE0, 0xFD, 0xEF,
+0x75, 0xF0, 0x03, 0xA4, 0x24, 0xEF, 0xF5, 0x82, 0xE4, 0x34, 0x40, 0xF5, 0x83, 0xE0, 0xFB, 0xEF,
+0x75, 0xF0, 0x03, 0xA4, 0x24, 0xEE, 0xF5, 0x82, 0xE4, 0x34, 0x40, 0xF5, 0x83, 0xE0, 0x90, 0x45,
+0x44, 0xF0, 0x7F, 0xB9, 0x12, 0x3C, 0x90, 0x82, 0x02, 0x92, 0x02, 0x90, 0x45, 0x40, 0xE0, 0xFF,
+0x75, 0xF0, 0x03, 0xA4, 0x24, 0x98, 0xF5, 0x82, 0xE4, 0x34, 0x41, 0xF5, 0x83, 0xE0, 0xFD, 0xEF,
+0x75, 0xF0, 0x03, 0xA4, 0x24, 0x97, 0xF5, 0x82, 0xE4, 0x34, 0x41, 0xF5, 0x83, 0xE0, 0xFB, 0xEF,
+0x75, 0xF0, 0x03, 0xA4, 0x24, 0x96, 0xF5, 0x82, 0xE4, 0x34, 0x41, 0xF5, 0x83, 0xE0, 0x90, 0x45,
+0x44, 0xF0, 0x7F, 0xB9, 0x12, 0x3C, 0x90, 0x82, 0x02, 0x92, 0x02, 0x90, 0x45, 0x40, 0xE0, 0xFF,
+0x75, 0xF0, 0x03, 0xA4, 0x24, 0x40, 0xF5, 0x82, 0xE4, 0x34, 0x42, 0xF5, 0x83, 0xE0, 0xFD, 0xEF,
+0x75, 0xF0, 0x03, 0xA4, 0x24, 0x3F, 0xF5, 0x82, 0xE4, 0x34, 0x42, 0xF5, 0x83, 0xE0, 0xFB, 0xEF,
+0x75, 0xF0, 0x03, 0xA4, 0x24, 0x3E, 0xF5, 0x82, 0xE4, 0x34, 0x42, 0xF5, 0x83, 0xE0, 0x90, 0x45,
+0x44, 0xF0, 0x7F, 0xB9, 0x12, 0x3C, 0x90, 0x82, 0x02, 0x92, 0x02, 0xE4, 0x90, 0x45, 0x44, 0xF0,
+0xFB, 0xFD, 0x7F, 0xC8, 0x12, 0x3D, 0x90, 0xA2, 0x02, 0x22, 0xD2, 0x01, 0xE4, 0x90, 0x04, 0x78,
+0xF0, 0xA3, 0x74, 0x13, 0xF0, 0x7B, 0x01, 0x7A, 0x45, 0x79, 0x40, 0x7F, 0x0D, 0x12, 0x3C, 0xCD,
+0x90, 0x45, 0x40, 0xE0, 0x54, 0xFE, 0xFF, 0xF0, 0xFD, 0x7F, 0x0D, 0x12, 0x3D, 0x00, 0xE4, 0x90,
+0x45, 0x3E, 0xF0, 0xA3, 0xF0, 0x90, 0x45, 0x3E, 0xE0, 0xFE, 0xA3, 0xE0, 0xFF, 0xC3, 0x94, 0x10,
+0xEE, 0x64, 0x80, 0x94, 0x80, 0x50, 0x57, 0x90, 0x42, 0xEB, 0x75, 0xF0, 0x03, 0xEF, 0x12, 0x27,
+0x8E, 0xEE, 0x75, 0xF0, 0x03, 0xA4, 0x25, 0x83, 0xF5, 0x83, 0xE0, 0xFD, 0x90, 0x42, 0xEA, 0x75,
+0xF0, 0x03, 0xEF, 0x12, 0x27, 0x8E, 0xEE, 0x75, 0xF0, 0x03, 0xA4, 0x25, 0x83, 0xF5, 0x83, 0xE0,
+0xFB, 0x90, 0x42, 0xE9, 0x75, 0xF0, 0x03, 0xEF, 0x12, 0x27, 0x8E, 0xEE, 0x75, 0xF0, 0x03, 0xA4,
+0x25, 0x83, 0xF5, 0x83, 0xE0, 0x90, 0x45, 0x44, 0xF0, 0x7F, 0xB9, 0x12, 0x3C, 0x90, 0x82, 0x01,
+0x92, 0x01, 0x90, 0x45, 0x3E, 0xE4, 0x75, 0xF0, 0x01, 0x12, 0x26, 0xB0, 0x80, 0x97, 0x90, 0x04,
+0x78, 0x74, 0x01, 0xF0, 0xE4, 0x90, 0x45, 0x44, 0xF0, 0xFB, 0xFD, 0x7F, 0x96, 0x12, 0x3D, 0x90,
+0x90, 0x45, 0x44, 0x74, 0x9A, 0xF0, 0x7B, 0xBA, 0x7D, 0x8F, 0x7F, 0xB9, 0x12, 0x3C, 0x90, 0x82,
+0x01, 0x92, 0x01, 0xE4, 0x90, 0x45, 0x44, 0xF0, 0xFB, 0xFD, 0x7F, 0x1E, 0x12, 0x3D, 0x90, 0x90,
+0x45, 0x44, 0x74, 0x3A, 0xF0, 0x7B, 0xBA, 0x7D, 0x8F, 0x7F, 0xB9, 0x12, 0x3C, 0x90, 0x82, 0x01,
+0x92, 0x01, 0xE4, 0x90, 0x45, 0x44, 0xF0, 0xFB, 0xFD, 0x7F, 0x1E, 0x12, 0x3D, 0x90, 0x90, 0x43,
+0x18, 0xE0, 0xFD, 0x90, 0x43, 0x17, 0xE0, 0xFB, 0x90, 0x43, 0x16, 0xE0, 0x90, 0x45, 0x44, 0xF0,
+0x7F, 0xB9, 0x12, 0x3C, 0x90, 0x82, 0x01, 0x92, 0x01, 0x90, 0x04, 0x79, 0x74, 0x13, 0xF0, 0x90,
+0x04, 0x78, 0x74, 0x05, 0xF0, 0x7B, 0x01, 0x7A, 0x45, 0x79, 0x40, 0x7F, 0x0D, 0x12, 0x3C, 0xCD,
+0x90, 0x45, 0x40, 0xE0, 0x44, 0x01, 0xFF, 0xF0, 0xFD, 0x7F, 0x0D, 0x12, 0x3D, 0x00, 0x90, 0x04,
+0x62, 0x74, 0xC0, 0xF0, 0xA2, 0x01, 0x22, 0xD2, 0x01, 0xE4, 0x90, 0x04, 0x78, 0xF0, 0xA3, 0x74,
+0x13, 0xF0, 0xE4, 0x90, 0x45, 0x3E, 0xF0, 0xA3, 0xF0, 0x90, 0x45, 0x3E, 0xE0, 0xFE, 0xA3, 0xE0,
+0xFF, 0xC3, 0x94, 0x0F, 0xEE, 0x64, 0x80, 0x94, 0x80, 0x50, 0x57, 0x90, 0x42, 0xEB, 0x75, 0xF0,
+0x03, 0xEF, 0x12, 0x27, 0x8E, 0xEE, 0x75, 0xF0, 0x03, 0xA4, 0x25, 0x83, 0xF5, 0x83, 0xE0, 0xFD,
+0x90, 0x42, 0xEA, 0x75, 0xF0, 0x03, 0xEF, 0x12, 0x27, 0x8E, 0xEE, 0x75, 0xF0, 0x03, 0xA4, 0x25,
+0x83, 0xF5, 0x83, 0xE0, 0xFB, 0x90, 0x42, 0xE9, 0x75, 0xF0, 0x03, 0xEF, 0x12, 0x27, 0x8E, 0xEE,
+0x75, 0xF0, 0x03, 0xA4, 0x25, 0x83, 0xF5, 0x83, 0xE0, 0x90, 0x45, 0x44, 0xF0, 0x7F, 0xB9, 0x12,
+0x3C, 0x90, 0x82, 0x01, 0x92, 0x01, 0x90, 0x45, 0x3E, 0xE4, 0x75, 0xF0, 0x01, 0x12, 0x26, 0xB0,
+0x80, 0x97, 0x90, 0x04, 0x78, 0x74, 0x01, 0xF0, 0xE4, 0x90, 0x45, 0x44, 0xF0, 0xFB, 0xFD, 0x7F,
+0x96, 0x12, 0x3D, 0x90, 0xE4, 0x90, 0x45, 0x44, 0xF0, 0x7B, 0xD8, 0x7D, 0x0F, 0x7F, 0xB9, 0x12,
+0x3C, 0x90, 0x82, 0x01, 0x92, 0x01, 0xE4, 0x90, 0x45, 0x44, 0xF0, 0xFB, 0xFD, 0x7F, 0x1E, 0x12,
+0x3D, 0x90, 0xE4, 0x90, 0x45, 0x44, 0xF0, 0x7B, 0x78, 0x7D, 0x0F, 0x7F, 0xB9, 0x12, 0x3C, 0x90,
+0x82, 0x01, 0x92, 0x01, 0xE4, 0x90, 0x45, 0x44, 0xF0, 0xFB, 0xFD, 0x7F, 0x1E, 0x12, 0x3D, 0x90,
+0x90, 0x43, 0x15, 0xE0, 0xFD, 0x90, 0x43, 0x14, 0xE0, 0xFB, 0x90, 0x43, 0x13, 0xE0, 0x90, 0x45,
+0x44, 0xF0, 0x7F, 0xB9, 0x12, 0x3C, 0x90, 0x82, 0x01, 0x92, 0x01, 0x90, 0x04, 0x78, 0x74, 0x05,
+0xF0, 0x90, 0x04, 0x62, 0x74, 0xC0, 0xF0, 0xA2, 0x01, 0x22, 0x90, 0x45, 0x40, 0xEF, 0xF0, 0xD2,
+0x02, 0x90, 0x04, 0x78, 0xE0, 0x54, 0xFE, 0xF0, 0x90, 0x45, 0x40, 0xE0, 0xFF, 0x75, 0xF0, 0x03,
+0xA4, 0x24, 0xF0, 0xF5, 0x82, 0xE4, 0x34, 0x40, 0xF5, 0x83, 0xE0, 0xFD, 0xEF, 0x75, 0xF0, 0x03,
+0xA4, 0x24, 0xEF, 0xF5, 0x82, 0xE4, 0x34, 0x40, 0xF5, 0x83, 0xE0, 0xFB, 0xEF, 0x75, 0xF0, 0x03,
+0xA4, 0x24, 0xEE, 0xF5, 0x82, 0xE4, 0x34, 0x40, 0xF5, 0x83, 0xE0, 0x90, 0x45, 0x44, 0xF0, 0x7F,
+0xB9, 0x12, 0x3C, 0x90, 0x82, 0x02, 0x92, 0x02, 0x90, 0x45, 0x40, 0xE0, 0xFF, 0x75, 0xF0, 0x03,
+0xA4, 0x24, 0x98, 0xF5, 0x82, 0xE4, 0x34, 0x41, 0xF5, 0x83, 0xE0, 0xFD, 0xEF, 0x75, 0xF0, 0x03,
+0xA4, 0x24, 0x97, 0xF5, 0x82, 0xE4, 0x34, 0x41, 0xF5, 0x83, 0xE0, 0xFB, 0xEF, 0x75, 0xF0, 0x03,
+0xA4, 0x24, 0x96, 0xF5, 0x82, 0xE4, 0x34, 0x41, 0xF5, 0x83, 0xE0, 0x90, 0x45, 0x44, 0xF0, 0x7F,
+0xB9, 0x12, 0x3C, 0x90, 0x82, 0x02, 0x92, 0x02, 0x90, 0x45, 0x40, 0xE0, 0xFF, 0x75, 0xF0, 0x03,
+0xA4, 0x24, 0x40, 0xF5, 0x82, 0xE4, 0x34, 0x42, 0xF5, 0x83, 0xE0, 0xFD, 0xEF, 0x75, 0xF0, 0x03,
+0xA4, 0x24, 0x3F, 0xF5, 0x82, 0xE4, 0x34, 0x42, 0xF5, 0x83, 0xE0, 0xFB, 0xEF, 0x75, 0xF0, 0x03,
+0xA4, 0x24, 0x3E, 0xF5, 0x82, 0xE4, 0x34, 0x42, 0xF5, 0x83, 0xE0, 0x90, 0x45, 0x44, 0xF0, 0x7F,
+0xB9, 0x12, 0x3C, 0x90, 0x82, 0x02, 0x92, 0x02, 0x90, 0x04, 0x78, 0xE0, 0x44, 0x01, 0xF0, 0xE4,
+0x90, 0x45, 0x44, 0xF0, 0xFB, 0xFD, 0x7F, 0xC8, 0x12, 0x3D, 0x90, 0x90, 0x40, 0xC0, 0xE0, 0xFF,
+0x90, 0x45, 0x40, 0xE0, 0xFD, 0x12, 0x2C, 0x4D, 0xA2, 0x02, 0x22, 0x90, 0x45, 0x31, 0x12, 0x27,
+0xBA, 0xE4, 0xFF, 0x90, 0x04, 0x48, 0xE0, 0x44, 0x10, 0xF0, 0xE4, 0xFD, 0xFC, 0x90, 0x04, 0x48,
+0xE0, 0xFF, 0x30, 0xE4, 0x0B, 0x0D, 0xBD, 0x00, 0x01, 0x0C, 0xBC, 0x07, 0xF0, 0xBD, 0xFF, 0xED,
+0xAE, 0x04, 0xAF, 0x05, 0xBE, 0x07, 0x05, 0xBF, 0xFF, 0x02, 0xC3, 0x22, 0x90, 0x04, 0x30, 0xE0,
+0xFF, 0x90, 0x45, 0x31, 0xE4, 0x75, 0xF0, 0x01, 0x12, 0x27, 0xA3, 0xEF, 0x12, 0x26, 0x7C, 0x90,
+0x04, 0x31, 0xE0, 0xFF, 0x90, 0x45, 0x31, 0xE4, 0x75, 0xF0, 0x01, 0x12, 0x27, 0xA3, 0xEF, 0x12,
+0x26, 0x7C, 0x90, 0x04, 0x32, 0xE0, 0xFF, 0x90, 0x45, 0x31, 0xE4, 0x75, 0xF0, 0x01, 0x12, 0x27,
+0xA3, 0xEF, 0x12, 0x26, 0x7C, 0x90, 0x04, 0x33, 0xE0, 0xFF, 0x90, 0x45, 0x31, 0xE4, 0x75, 0xF0,
+0x01, 0x12, 0x27, 0xA3, 0xEF, 0x12, 0x26, 0x7C, 0x90, 0x04, 0x34, 0xE0, 0xFF, 0x90, 0x45, 0x31,
+0xE4, 0x75, 0xF0, 0x01, 0x12, 0x27, 0xA3, 0xEF, 0x12, 0x26, 0x7C, 0x90, 0x04, 0x35, 0xE0, 0xFF,
+0x90, 0x45, 0x31, 0xE4, 0x75, 0xF0, 0x01, 0x12, 0x27, 0xA3, 0xEF, 0x12, 0x26, 0x7C, 0x90, 0x04,
+0x36, 0xE0, 0xFF, 0x90, 0x45, 0x31, 0xE4, 0x75, 0xF0, 0x01, 0x12, 0x27, 0xA3, 0xEF, 0x12, 0x26,
+0x7C, 0x90, 0x04, 0x37, 0xE0, 0xFF, 0x90, 0x45, 0x31, 0xE4, 0x75, 0xF0, 0x01, 0x12, 0x27, 0xA3,
+0xEF, 0x12, 0x26, 0x7C, 0xD3, 0x22, 0x7B, 0x01, 0x7A, 0x10, 0x79, 0x34, 0x90, 0x45, 0x3A, 0x12,
+0x27, 0xBA, 0x90, 0x45, 0x3A, 0x12, 0x27, 0x9A, 0x90, 0x00, 0x12, 0x12, 0x27, 0xC3, 0xC0, 0x03,
+0xC0, 0x02, 0xC0, 0x01, 0x90, 0x45, 0x3A, 0x12, 0x27, 0x9A, 0x90, 0x00, 0x15, 0x12, 0x28, 0x25,
+0x90, 0x45, 0x3A, 0x12, 0x27, 0x9A, 0x90, 0x00, 0x18, 0x12, 0x26, 0xDC, 0xFF, 0x90, 0x00, 0x1A,
+0xE5, 0xF0, 0x8F, 0xF0, 0x12, 0x27, 0x61, 0xE4, 0xFF, 0xEF, 0xC3, 0x94, 0x40, 0x50, 0x44, 0x90,
+0x45, 0x3A, 0x12, 0x27, 0x9A, 0x90, 0x00, 0x18, 0x12, 0x26, 0xDC, 0xD3, 0x94, 0x00, 0xE5, 0xF0,
+0x94, 0x00, 0x40, 0x2F, 0x90, 0x00, 0x12, 0xE4, 0x75, 0xF0, 0x01, 0x12, 0x27, 0xF3, 0x12, 0x26,
+0x36, 0xFE, 0xAD, 0x07, 0x0F, 0x74, 0x60, 0x2D, 0xF5, 0x82, 0xE4, 0x34, 0x06, 0xF5, 0x83, 0xEE,
+0xF0, 0x90, 0x45, 0x3A, 0x12, 0x27, 0x9A, 0x90, 0x00, 0x18, 0x74, 0xFF, 0xF5, 0xF0, 0x12, 0x27,
+0x14, 0x80, 0xB6, 0xEF, 0x70, 0x17, 0x90, 0x06, 0x23, 0x74, 0x80, 0xF0, 0xE4, 0xA3, 0xF0, 0x90,
+0x10, 0x3D, 0xE0, 0xB4, 0x0C, 0x1C, 0x12, 0x3E, 0x36, 0xD2, 0x8C, 0x80, 0x15, 0x30, 0x04, 0x0B,
+0xC2, 0x04, 0xEF, 0x44, 0x80, 0x90, 0x06, 0x23, 0xF0, 0x80, 0x07, 0xD2, 0x04, 0x90, 0x06, 0x23,
+0xEF, 0xF0, 0x90, 0x06, 0x25, 0x74, 0x08, 0xF0, 0x22, 0x90, 0x06, 0x25, 0xE0, 0x30, 0xE0, 0x2F,
+0x90, 0x10, 0x3D, 0xE0, 0x24, 0xFB, 0x70, 0x1D, 0x90, 0x10, 0x49, 0x12, 0x27, 0x9A, 0x90, 0x10,
+0x46, 0x12, 0x27, 0xBA, 0x90, 0x10, 0x4E, 0xE0, 0xFF, 0xA3, 0xE0, 0x90, 0x10, 0x4C, 0xCF, 0xF0,
+0xA3, 0xEF, 0xF0, 0x80, 0x07, 0xE4, 0x90, 0x10, 0x4C, 0xF0, 0xA3, 0xF0, 0x02, 0x33, 0xF6, 0x90,
+0x10, 0x3D, 0xE0, 0x12, 0x28, 0x7E, 0x35, 0x12, 0x01, 0x35, 0x12, 0x05, 0x35, 0x12, 0x07, 0x35,
+0x12, 0x09, 0x35, 0x15, 0x0B, 0x35, 0x12, 0x0C, 0x35, 0x1B, 0x0D, 0x35, 0x21, 0x0F, 0x00, 0x00,
+0x35, 0x5C, 0x02, 0x33, 0xF6, 0xE4, 0x90, 0x10, 0x3D, 0xF0, 0x22, 0xE4, 0x90, 0x10, 0x3D, 0xF0,
+0x22, 0x90, 0x10, 0x50, 0xE0, 0xFF, 0xB4, 0x01, 0x07, 0x90, 0x06, 0x07, 0x74, 0x20, 0xF0, 0x22,
+0xEF, 0xB4, 0x02, 0x07, 0x90, 0x06, 0x07, 0x74, 0x40, 0xF0, 0x22, 0xEF, 0xB4, 0x03, 0x07, 0x90,
+0x06, 0x07, 0x74, 0x60, 0xF0, 0x22, 0xEF, 0xB4, 0x04, 0x07, 0x90, 0x06, 0x07, 0x74, 0x80, 0xF0,
+0x22, 0xEF, 0xB4, 0x05, 0x0C, 0x90, 0x06, 0x07, 0x74, 0xA0, 0xF0, 0x22, 0xE4, 0x90, 0x10, 0x3D,
+0xF0, 0x22, 0x78, 0x7F, 0xE4, 0xF6, 0xD8, 0xFD, 0x75, 0x81, 0x20, 0x02, 0x35, 0xA9, 0x02, 0x23,
+0x50, 0xE4, 0x93, 0xA3, 0xF8, 0xE4, 0x93, 0xA3, 0x40, 0x03, 0xF6, 0x80, 0x01, 0xF2, 0x08, 0xDF,
+0xF4, 0x80, 0x29, 0xE4, 0x93, 0xA3, 0xF8, 0x54, 0x07, 0x24, 0x0C, 0xC8, 0xC3, 0x33, 0xC4, 0x54,
+0x0F, 0x44, 0x20, 0xC8, 0x83, 0x40, 0x04, 0xF4, 0x56, 0x80, 0x01, 0x46, 0xF6, 0xDF, 0xE4, 0x80,
+0x0B, 0x01, 0x02, 0x04, 0x08, 0x10, 0x20, 0x40, 0x80, 0x90, 0x3E, 0x45, 0xE4, 0x7E, 0x01, 0x93,
+0x60, 0xBC, 0xA3, 0xFF, 0x54, 0x3F, 0x30, 0xE5, 0x09, 0x54, 0x1F, 0xFE, 0xE4, 0x93, 0xA3, 0x60,
+0x01, 0x0E, 0xCF, 0x54, 0xC0, 0x25, 0xE0, 0x60, 0xA8, 0x40, 0xB8, 0xE4, 0x93, 0xA3, 0xFA, 0xE4,
+0x93, 0xA3, 0xF8, 0xE4, 0x93, 0xA3, 0xC8, 0xC5, 0x82, 0xC8, 0xCA, 0xC5, 0x83, 0xCA, 0xF0, 0xA3,
+0xC8, 0xC5, 0x82, 0xC8, 0xCA, 0xC5, 0x83, 0xCA, 0xDF, 0xE9, 0xDE, 0xE7, 0x80, 0xBE, 0xAC, 0x07,
+0xD2, 0x02, 0xEC, 0x75, 0xF0, 0x03, 0xA4, 0x24, 0xF0, 0xF5, 0x82, 0xE4, 0x34, 0x40, 0xF5, 0x83,
+0xE0, 0xFD, 0xEC, 0x75, 0xF0, 0x03, 0xA4, 0x24, 0xEF, 0xF5, 0x82, 0xE4, 0x34, 0x40, 0xF5, 0x83,
+0xE0, 0xFB, 0xEC, 0x75, 0xF0, 0x03, 0xA4, 0x24, 0xEE, 0xF5, 0x82, 0xE4, 0x34, 0x40, 0xF5, 0x83,
+0xE0, 0x90, 0x45, 0x44, 0xF0, 0x7F, 0xB9, 0x12, 0x3C, 0x90, 0x82, 0x02, 0x92, 0x02, 0xEC, 0x75,
+0xF0, 0x03, 0xA4, 0x24, 0x98, 0xF5, 0x82, 0xE4, 0x34, 0x41, 0xF5, 0x83, 0xE0, 0xFD, 0xEC, 0x75,
+0xF0, 0x03, 0xA4, 0x24, 0x97, 0xF5, 0x82, 0xE4, 0x34, 0x41, 0xF5, 0x83, 0xE0, 0xFB, 0xEC, 0x75,
+0xF0, 0x03, 0xA4, 0x24, 0x96, 0xF5, 0x82, 0xE4, 0x34, 0x41, 0xF5, 0x83, 0xE0, 0x90, 0x45, 0x44,
+0xF0, 0x7F, 0xB9, 0x12, 0x3C, 0x90, 0x82, 0x02, 0x92, 0x02, 0xE4, 0x90, 0x45, 0x44, 0xF0, 0xFB,
+0xFD, 0x7F, 0xC8, 0x12, 0x3D, 0x90, 0xA2, 0x02, 0x22, 0xAC, 0x07, 0xD2, 0x02, 0xEC, 0x75, 0xF0,
+0x03, 0xA4, 0x24, 0xF0, 0xF5, 0x82, 0xE4, 0x34, 0x40, 0xF5, 0x83, 0xE0, 0xFD, 0xEC, 0x75, 0xF0,
+0x03, 0xA4, 0x24, 0xEF, 0xF5, 0x82, 0xE4, 0x34, 0x40, 0xF5, 0x83, 0xE0, 0xFB, 0xEC, 0x75, 0xF0,
+0x03, 0xA4, 0x24, 0xEE, 0xF5, 0x82, 0xE4, 0x34, 0x40, 0xF5, 0x83, 0xE0, 0x90, 0x45, 0x44, 0xF0,
+0x7F, 0xB9, 0x12, 0x3C, 0x90, 0x82, 0x02, 0x92, 0x02, 0xEC, 0x75, 0xF0, 0x03, 0xA4, 0x24, 0x98,
+0xF5, 0x82, 0xE4, 0x34, 0x41, 0xF5, 0x83, 0xE0, 0xFD, 0xEC, 0x75, 0xF0, 0x03, 0xA4, 0x24, 0x97,
+0xF5, 0x82, 0xE4, 0x34, 0x41, 0xF5, 0x83, 0xE0, 0xFB, 0xEC, 0x75, 0xF0, 0x03, 0xA4, 0x24, 0x96,
+0xF5, 0x82, 0xE4, 0x34, 0x41, 0xF5, 0x83, 0xE0, 0x90, 0x45, 0x44, 0xF0, 0x7F, 0xB9, 0x12, 0x3C,
+0x90, 0x82, 0x02, 0x92, 0x02, 0xE4, 0x90, 0x45, 0x44, 0xF0, 0xFB, 0xFD, 0x7F, 0xC8, 0x12, 0x3D,
+0x90, 0xA2, 0x02, 0x22, 0xAC, 0x07, 0xD2, 0x02, 0xEC, 0x75, 0xF0, 0x03, 0xA4, 0x24, 0xF0, 0xF5,
+0x82, 0xE4, 0x34, 0x40, 0xF5, 0x83, 0xE0, 0xFD, 0xEC, 0x75, 0xF0, 0x03, 0xA4, 0x24, 0xEF, 0xF5,
+0x82, 0xE4, 0x34, 0x40, 0xF5, 0x83, 0xE0, 0xFB, 0xEC, 0x75, 0xF0, 0x03, 0xA4, 0x24, 0xEE, 0xF5,
+0x82, 0xE4, 0x34, 0x40, 0xF5, 0x83, 0xE0, 0x90, 0x45, 0x44, 0xF0, 0x7F, 0xB9, 0x12, 0x3C, 0x90,
+0x82, 0x02, 0x92, 0x02, 0xEC, 0x75, 0xF0, 0x03, 0xA4, 0x24, 0x98, 0xF5, 0x82, 0xE4, 0x34, 0x41,
+0xF5, 0x83, 0xE0, 0xFD, 0xEC, 0x75, 0xF0, 0x03, 0xA4, 0x24, 0x97, 0xF5, 0x82, 0xE4, 0x34, 0x41,
+0xF5, 0x83, 0xE0, 0xFB, 0xEC, 0x75, 0xF0, 0x03, 0xA4, 0x24, 0x96, 0xF5, 0x82, 0xE4, 0x34, 0x41,
+0xF5, 0x83, 0xE0, 0x90, 0x45, 0x44, 0xF0, 0x7F, 0xB9, 0x12, 0x3C, 0x90, 0x82, 0x02, 0x92, 0x02,
+0xE4, 0x90, 0x45, 0x44, 0xF0, 0xFB, 0xFD, 0x7F, 0xC8, 0x12, 0x3D, 0x90, 0xA2, 0x02, 0x22, 0xD2,
+0x01, 0xE4, 0x90, 0x04, 0x78, 0xF0, 0xA3, 0x74, 0x1B, 0xF0, 0x90, 0x04, 0x78, 0x74, 0x05, 0xF0,
+0xE4, 0x90, 0x45, 0x3E, 0xF0, 0xA3, 0xF0, 0x90, 0x45, 0x3E, 0xE0, 0xFE, 0xA3, 0xE0, 0xFF, 0xC3,
+0x94, 0x0B, 0xEE, 0x64, 0x80, 0x94, 0x80, 0x50, 0x57, 0x90, 0x42, 0xEB, 0x75, 0xF0, 0x03, 0xEF,
+0x12, 0x27, 0x8E, 0xEE, 0x75, 0xF0, 0x03, 0xA4, 0x25, 0x83, 0xF5, 0x83, 0xE0, 0xFD, 0x90, 0x42,
+0xEA, 0x75, 0xF0, 0x03, 0xEF, 0x12, 0x27, 0x8E, 0xEE, 0x75, 0xF0, 0x03, 0xA4, 0x25, 0x83, 0xF5,
+0x83, 0xE0, 0xFB, 0x90, 0x42, 0xE9, 0x75, 0xF0, 0x03, 0xEF, 0x12, 0x27, 0x8E, 0xEE, 0x75, 0xF0,
+0x03, 0xA4, 0x25, 0x83, 0xF5, 0x83, 0xE0, 0x90, 0x45, 0x44, 0xF0, 0x7F, 0xB9, 0x12, 0x3C, 0x90,
+0x82, 0x01, 0x92, 0x01, 0x90, 0x45, 0x3E, 0xE4, 0x75, 0xF0, 0x01, 0x12, 0x26, 0xB0, 0x80, 0x97,
+0x90, 0x04, 0x62, 0x74, 0xC0, 0xF0, 0xA2, 0x01, 0x22, 0xD2, 0x01, 0xE4, 0x90, 0x04, 0x78, 0xF0,
+0xA3, 0x74, 0x1B, 0xF0, 0x90, 0x04, 0x78, 0x74, 0x05, 0xF0, 0xE4, 0x90, 0x45, 0x3E, 0xF0, 0xA3,
+0xF0, 0x90, 0x45, 0x3E, 0xE0, 0xFE, 0xA3, 0xE0, 0xFF, 0xC3, 0x94, 0x0D, 0xEE, 0x64, 0x80, 0x94,
+0x80, 0x50, 0x57, 0x90, 0x42, 0xEB, 0x75, 0xF0, 0x03, 0xEF, 0x12, 0x27, 0x8E, 0xEE, 0x75, 0xF0,
+0x03, 0xA4, 0x25, 0x83, 0xF5, 0x83, 0xE0, 0xFD, 0x90, 0x42, 0xEA, 0x75, 0xF0, 0x03, 0xEF, 0x12,
+0x27, 0x8E, 0xEE, 0x75, 0xF0, 0x03, 0xA4, 0x25, 0x83, 0xF5, 0x83, 0xE0, 0xFB, 0x90, 0x42, 0xE9,
+0x75, 0xF0, 0x03, 0xEF, 0x12, 0x27, 0x8E, 0xEE, 0x75, 0xF0, 0x03, 0xA4, 0x25, 0x83, 0xF5, 0x83,
+0xE0, 0x90, 0x45, 0x44, 0xF0, 0x7F, 0xB9, 0x12, 0x3C, 0x90, 0x82, 0x01, 0x92, 0x01, 0x90, 0x45,
+0x3E, 0xE4, 0x75, 0xF0, 0x01, 0x12, 0x26, 0xB0, 0x80, 0x97, 0x90, 0x04, 0x62, 0x74, 0xC0, 0xF0,
+0xA2, 0x01, 0x22, 0xD2, 0x01, 0xE4, 0x90, 0x04, 0x78, 0xF0, 0xA3, 0x74, 0x1B, 0xF0, 0x90, 0x04,
+0x78, 0x74, 0x05, 0xF0, 0xE4, 0x90, 0x45, 0x3E, 0xF0, 0xA3, 0xF0, 0x90, 0x45, 0x3E, 0xE0, 0xFE,
+0xA3, 0xE0, 0xFF, 0xC3, 0x94, 0x0F, 0xEE, 0x64, 0x80, 0x94, 0x80, 0x50, 0x57, 0x90, 0x42, 0xEB,
+0x75, 0xF0, 0x03, 0xEF, 0x12, 0x27, 0x8E, 0xEE, 0x75, 0xF0, 0x03, 0xA4, 0x25, 0x83, 0xF5, 0x83,
+0xE0, 0xFD, 0x90, 0x42, 0xEA, 0x75, 0xF0, 0x03, 0xEF, 0x12, 0x27, 0x8E, 0xEE, 0x75, 0xF0, 0x03,
+0xA4, 0x25, 0x83, 0xF5, 0x83, 0xE0, 0xFB, 0x90, 0x42, 0xE9, 0x75, 0xF0, 0x03, 0xEF, 0x12, 0x27,
+0x8E, 0xEE, 0x75, 0xF0, 0x03, 0xA4, 0x25, 0x83, 0xF5, 0x83, 0xE0, 0x90, 0x45, 0x44, 0xF0, 0x7F,
+0xB9, 0x12, 0x3C, 0x90, 0x82, 0x01, 0x92, 0x01, 0x90, 0x45, 0x3E, 0xE4, 0x75, 0xF0, 0x01, 0x12,
+0x26, 0xB0, 0x80, 0x97, 0x90, 0x04, 0x62, 0x74, 0xC0, 0xF0, 0xA2, 0x01, 0x22, 0x90, 0x45, 0x3E,
+0xED, 0xF0, 0xD2, 0x01, 0x90, 0x04, 0x57, 0xE0, 0x90, 0x45, 0x3F, 0xF0, 0x90, 0x04, 0x57, 0xE0,
+0x54, 0xFE, 0xF0, 0xEF, 0x12, 0x28, 0x7E, 0x39, 0x60, 0x03, 0x39, 0x78, 0x09, 0x39, 0x6C, 0x0A,
+0x39, 0x78, 0x0C, 0x39, 0x84, 0x0D, 0x39, 0x60, 0x0E, 0x39, 0x90, 0x0F, 0x00, 0x00, 0x39, 0x9C,
+0x90, 0x45, 0x3E, 0xE0, 0xFF, 0x12, 0x35, 0xEE, 0x92, 0x01, 0x80, 0x32, 0x90, 0x45, 0x3E, 0xE0,
+0xFF, 0x12, 0x32, 0x3A, 0x92, 0x01, 0x80, 0x26, 0x90, 0x45, 0x3E, 0xE0, 0xFF, 0x12, 0x36, 0x79,
+0x92, 0x01, 0x80, 0x1A, 0x90, 0x45, 0x3E, 0xE0, 0xFF, 0x12, 0x37, 0x04, 0x92, 0x01, 0x80, 0x0E,
+0x90, 0x45, 0x3E, 0xE0, 0xFF, 0x12, 0x2E, 0xDF, 0x92, 0x01, 0x80, 0x02, 0xC2, 0x01, 0x12, 0x3D,
+0xE2, 0x90, 0x45, 0x3F, 0xE0, 0x90, 0x04, 0x57, 0xF0, 0x90, 0x45, 0x3E, 0xE0, 0x90, 0x40, 0xC0,
+0xF0, 0xA2, 0x01, 0x22, 0xAC, 0x07, 0xE4, 0x90, 0x45, 0x3A, 0xF0, 0xA3, 0xF0, 0xD2, 0x00, 0x7D,
+0x03, 0xEC, 0x70, 0x13, 0x12, 0x3C, 0xC5, 0x90, 0x45, 0x3B, 0xE0, 0x54, 0xF9, 0xFF, 0xF0, 0xFD,
+0x7F, 0x09, 0x12, 0x3D, 0x00, 0x80, 0x59, 0xEC, 0xB4, 0x01, 0x16, 0x12, 0x3C, 0xC5, 0x90, 0x45,
+0x3B, 0xE0, 0x54, 0xFD, 0xF0, 0x44, 0x04, 0xFF, 0xF0, 0xFD, 0x7F, 0x09, 0x12, 0x3D, 0x00, 0x80,
+0x3F, 0xEC, 0xB4, 0x02, 0x1B, 0x7B, 0x01, 0x7A, 0x45, 0x79, 0x3A, 0x7F, 0x0A, 0x12, 0x3C, 0xCD,
+0x90, 0x45, 0x3A, 0xE0, 0x54, 0xFC, 0xFF, 0xF0, 0xFD, 0x7F, 0x0A, 0x12, 0x3D, 0x00, 0x80, 0x20,
+0xEC, 0xB4, 0x03, 0x1C, 0x7B, 0x01, 0x7A, 0x45, 0x79, 0x3A, 0x7F, 0x0A, 0x12, 0x3C, 0xCD, 0x90,
+0x45, 0x3A, 0xE0, 0x54, 0xFE, 0xF0, 0x44, 0x02, 0xFF, 0xF0, 0xFD, 0x7F, 0x0A, 0x12, 0x3D, 0x00,
+0xA2, 0x00, 0x22, 0x90, 0x45, 0x38, 0xEF, 0xF0, 0xA3, 0xED, 0xF0, 0x90, 0x04, 0x0B, 0xE0, 0xF9,
+0x54, 0xFB, 0xF0, 0xE4, 0xFF, 0xFE, 0x90, 0x04, 0x09, 0x74, 0x50, 0xF0, 0x90, 0x45, 0x38, 0xE0,
+0x90, 0x04, 0x0A, 0xF0, 0x90, 0x45, 0x39, 0xE0, 0x90, 0x04, 0x0E, 0xF0, 0x90, 0x04, 0x08, 0x74,
+0x80, 0xF0, 0xE4, 0xFD, 0xFC, 0x90, 0x04, 0x08, 0xE0, 0x90, 0x45, 0x3A, 0xF0, 0xE0, 0x54, 0x03,
+0x70, 0x0B, 0x0D, 0xBD, 0x00, 0x01, 0x0C, 0xBC, 0x07, 0xEB, 0xBD, 0xFF, 0xE8, 0xC3, 0xED, 0x94,
+0xFF, 0xEC, 0x94, 0x07, 0x50, 0x07, 0x90, 0x45, 0x3A, 0xE0, 0x30, 0xE1, 0x0B, 0x0F, 0xBF, 0x00,
+0x01, 0x0E, 0xBE, 0x07, 0xB1, 0xBF, 0xFF, 0xAE, 0xBE, 0x07, 0x0A, 0xBF, 0xFF, 0x07, 0x90, 0x04,
+0x0B, 0xE9, 0xF0, 0xC3, 0x22, 0xAF, 0x01, 0x90, 0x04, 0x0B, 0xE9, 0xF0, 0xD3, 0x22, 0x90, 0x45,
+0x35, 0xED, 0xF0, 0xA3, 0xEB, 0xF0, 0xEE, 0x70, 0x56, 0xEF, 0x24, 0xF6, 0x60, 0x1B, 0x14, 0x60,
+0x26, 0x14, 0x60, 0x31, 0x14, 0x60, 0x3C, 0x24, 0x04, 0x70, 0x44, 0x7B, 0x01, 0x7A, 0x42, 0x79,
+0xE9, 0x90, 0x45, 0x37, 0x12, 0x27, 0xBA, 0x80, 0x36, 0x7B, 0x01, 0x7A, 0x40, 0x79, 0xC1, 0x90,
+0x45, 0x37, 0x12, 0x27, 0xBA, 0x80, 0x28, 0x7B, 0x01, 0x7A, 0x40, 0x79, 0xF1, 0x90, 0x45, 0x37,
+0x12, 0x27, 0xBA, 0x80, 0x1A, 0x7B, 0x01, 0x7A, 0x41, 0x79, 0x99, 0x90, 0x45, 0x37, 0x12, 0x27,
+0xBA, 0x80, 0x0C, 0x7B, 0x01, 0x7A, 0x42, 0x79, 0x41, 0x90, 0x45, 0x37, 0x12, 0x27, 0xBA, 0x90,
+0x45, 0x36, 0xE0, 0xFF, 0xA3, 0x12, 0x27, 0x9A, 0x90, 0x45, 0x35, 0xE0, 0xF5, 0x82, 0x75, 0x83,
+0x00, 0xEF, 0x02, 0x26, 0x8E, 0x90, 0x45, 0x3F, 0xEF, 0xF0, 0xA3, 0x74, 0xFF, 0xF0, 0x90, 0x04,
+0x0B, 0xE0, 0x90, 0x45, 0x41, 0xF0, 0xE4, 0xFF, 0xFE, 0x90, 0x04, 0x09, 0x74, 0x50, 0xF0, 0x90,
+0x45, 0x3F, 0xE0, 0x90, 0x04, 0x0A, 0xF0, 0x90, 0x04, 0x08, 0x74, 0x40, 0xF0, 0xE4, 0xFD, 0xFC,
+0x90, 0x04, 0x08, 0xE0, 0xF9, 0x54, 0x03, 0x70, 0x0B, 0x0D, 0xBD, 0x00, 0x01, 0x0C, 0xBC, 0x07,
+0xEF, 0xBD, 0xFF, 0xEC, 0xC3, 0xED, 0x94, 0xFF, 0xEC, 0x94, 0x07, 0x50, 0x04, 0xE9, 0x30, 0xE1,
+0x0B, 0x0F, 0xBF, 0x00, 0x01, 0x0E, 0xBE, 0x07, 0xC0, 0xBF, 0xFF, 0xBD, 0x90, 0x04, 0x0C, 0xE0,
+0x90, 0x45, 0x40, 0xF0, 0xA3, 0xE0, 0x90, 0x04, 0x0B, 0xF0, 0x90, 0x45, 0x40, 0xE0, 0xFF, 0x22,
+0xE4, 0xFE, 0xEF, 0x30, 0xE5, 0x11, 0xE4, 0xFC, 0xFD, 0x7C, 0x08, 0x90, 0x04, 0xD4, 0xE4, 0xF0,
+0xA3, 0xDC, 0xFC, 0x7C, 0x00, 0x7D, 0x08, 0xEF, 0x54, 0xC0, 0x60, 0x12, 0xE4, 0xFC, 0xFD, 0x7C,
+0x08, 0x90, 0x04, 0xD4, 0x74, 0xFF, 0xF0, 0xA3, 0xDC, 0xFC, 0x7C, 0x00, 0x7D, 0x08, 0xEF, 0x30,
+0xE6, 0x07, 0xEE, 0x44, 0x78, 0xFE, 0x54, 0xFE, 0xFE, 0xEF, 0x54, 0x88, 0x60, 0x04, 0xEE, 0x44,
+0x08, 0xFE, 0xEF, 0x30, 0xE4, 0x04, 0xEE, 0x44, 0x10, 0xFE, 0xEF, 0x30, 0xE1, 0x04, 0xEE, 0x44,
+0x02, 0xFE, 0x90, 0x04, 0x56, 0xE0, 0xFF, 0x6E, 0x60, 0x02, 0xEE, 0xF0, 0x22, 0xC0, 0xE0, 0xC0,
+0x83, 0xC0, 0x82, 0xC0, 0xD0, 0x75, 0xD0, 0x00, 0xC0, 0x07, 0xD2, 0x05, 0x53, 0xA8, 0xFE, 0x90,
+0x06, 0x20, 0xE4, 0xF0, 0x90, 0x04, 0x58, 0xF0, 0xA3, 0xF0, 0x90, 0x06, 0x21, 0xE0, 0xFF, 0x90,
+0x10, 0x39, 0xE0, 0x4F, 0xF0, 0x90, 0x06, 0x21, 0xEF, 0xF0, 0x90, 0x04, 0x5C, 0xE0, 0xFF, 0x90,
+0x45, 0x46, 0xE0, 0x4F, 0xF0, 0x90, 0x04, 0x5C, 0xEF, 0xF0, 0xA3, 0xE0, 0xFF, 0x90, 0x45, 0x47,
+0xE0, 0x4F, 0xF0, 0x90, 0x04, 0x5D, 0xEF, 0xF0, 0xD0, 0x07, 0xD0, 0xD0, 0xD0, 0x82, 0xD0, 0x83,
+0xD0, 0xE0, 0x32, 0x90, 0x04, 0x79, 0x74, 0x11, 0xF0, 0x12, 0x3D, 0x31, 0xE4, 0x90, 0x45, 0x3E,
+0xF0, 0x90, 0x45, 0x3E, 0xE0, 0xFF, 0xC3, 0x94, 0x06, 0x50, 0x1A, 0x12, 0x3B, 0x25, 0x90, 0x45,
+0x3E, 0xE0, 0x24, 0xC4, 0xF5, 0x82, 0xE4, 0x34, 0x04, 0xF5, 0x83, 0xEF, 0xF0, 0x90, 0x45, 0x3E,
+0xE0, 0x04, 0xF0, 0x80, 0xDC, 0x90, 0x04, 0x48, 0x74, 0x02, 0xF0, 0x14, 0xF0, 0x7F, 0x30, 0x12,
+0x3B, 0x90, 0x90, 0x04, 0x54, 0x74, 0x02, 0xF0, 0x22, 0xE0, 0x90, 0x45, 0x44, 0xF0, 0x7F, 0xB9,
+0x90, 0x04, 0x71, 0xED, 0xF0, 0xA3, 0xEB, 0xF0, 0x90, 0x45, 0x44, 0xE0, 0x90, 0x04, 0x73, 0xF0,
+0x90, 0x04, 0x70, 0xEF, 0xF0, 0xE4, 0xFF, 0xFE, 0x90, 0x04, 0x70, 0xE0, 0xFD, 0x20, 0xE2, 0x0B,
+0x0F, 0xBF, 0x00, 0x01, 0x0E, 0xBE, 0x07, 0xF0, 0xBF, 0xFF, 0xED, 0xBE, 0x07, 0x05, 0xBF, 0xFF,
+0x02, 0xC3, 0x22, 0xD3, 0x22, 0x7B, 0x01, 0x7A, 0x45, 0x79, 0x3B, 0x7F, 0x09, 0x90, 0x04, 0x6E,
+0xEF, 0xF0, 0x90, 0x04, 0x6C, 0xE0, 0x44, 0x02, 0xF0, 0xE4, 0xFF, 0xFE, 0x90, 0x04, 0x6C, 0xE0,
+0xFD, 0x20, 0xE2, 0x0B, 0x0F, 0xBF, 0x00, 0x01, 0x0E, 0xBE, 0x07, 0xF0, 0xBF, 0xFF, 0xED, 0x90,
+0x04, 0x6F, 0xE0, 0x12, 0x26, 0x7C, 0xBE, 0x07, 0x05, 0xBF, 0xFF, 0x02, 0xC3, 0x22, 0xD3, 0x22,
+0x90, 0x04, 0x6E, 0xEF, 0xF0, 0x90, 0x04, 0x6F, 0xED, 0xF0, 0x90, 0x04, 0x6C, 0xE0, 0x44, 0x01,
+0xF0, 0xE4, 0xFF, 0xFE, 0x90, 0x04, 0x6C, 0xE0, 0xFD, 0x20, 0xE2, 0x0B, 0x0F, 0xBF, 0x00, 0x01,
+0x0E, 0xBE, 0x07, 0xF0, 0xBF, 0xFF, 0xED, 0xBE, 0x07, 0x05, 0xBF, 0xFF, 0x02, 0xC3, 0x22, 0xD3,
+0x22, 0x90, 0x04, 0x54, 0x74, 0x01, 0xF0, 0xE4, 0xFF, 0xFE, 0x90, 0x04, 0x54, 0xE0, 0xFD, 0x30,
+0xE0, 0x0B, 0x0F, 0xBF, 0x00, 0x01, 0x0E, 0xBE, 0x07, 0xF0, 0xBF, 0xFF, 0xED, 0xBE, 0x07, 0x05,
+0xBF, 0xFF, 0x02, 0xC3, 0x22, 0x90, 0x06, 0x38, 0xE0, 0x44, 0x02, 0xF0, 0xE0, 0x44, 0x01, 0xF0,
+0xD3, 0x22, 0xEF, 0x12, 0x28, 0x7E, 0x3D, 0x7F, 0x03, 0x3D, 0x85, 0x09, 0x3D, 0x82, 0x0A, 0x3D,
+0x85, 0x0C, 0x3D, 0x88, 0x0D, 0x3D, 0x7F, 0x0E, 0x3D, 0x8B, 0x0F, 0x00, 0x00, 0x3D, 0x8E, 0x02,
+0x31, 0x47, 0x02, 0x30, 0x1A, 0x02, 0x37, 0x8F, 0x02, 0x38, 0x19, 0x02, 0x38, 0xA3, 0xC3, 0x22,
+0x90, 0x04, 0x1C, 0xEF, 0xF0, 0xA3, 0xED, 0xF0, 0xA3, 0xEB, 0xF0, 0x90, 0x45, 0x44, 0xE0, 0x90,
+0x04, 0x1F, 0xF0, 0x90, 0x04, 0x18, 0x74, 0x03, 0xF0, 0x90, 0x04, 0x18, 0xE0, 0xFF, 0x60, 0x04,
+0xEF, 0x30, 0xE2, 0xF5, 0xE4, 0x90, 0x04, 0x18, 0xF0, 0x22, 0x7F, 0xFF, 0x90, 0x04, 0x14, 0xE0,
+0xFF, 0x14, 0x60, 0x0E, 0x14, 0x60, 0x0F, 0x14, 0x60, 0x10, 0x24, 0x03, 0x70, 0x10, 0x02, 0x0B,
+0xBE, 0x22, 0x02, 0x0B, 0xB5, 0x22, 0x02, 0x0B, 0xAE, 0x22, 0x02, 0x0B, 0xEF, 0x22, 0x02, 0x00,
+0x00, 0x22, 0xD2, 0x02, 0x7D, 0x40, 0x7F, 0x50, 0x12, 0x3D, 0x00, 0xE4, 0xFD, 0x7F, 0x50, 0x12,
+0x3D, 0x00, 0x7D, 0x01, 0x7F, 0x9C, 0x12, 0x3D, 0x00, 0xE4, 0xFD, 0x7F, 0x9C, 0x12, 0x3D, 0x00,
+0xA2, 0x02, 0x22, 0x90, 0x04, 0x61, 0xE0, 0x54, 0xFE, 0xF0, 0xE4, 0xFF, 0xFE, 0x90, 0x04, 0x61,
+0xE0, 0xFD, 0x20, 0xE5, 0x0B, 0x0F, 0xBF, 0x00, 0x01, 0x0E, 0xBE, 0x07, 0xF0, 0xBF, 0xFF, 0xED,
+0x22, 0xC0, 0xE0, 0xC0, 0x83, 0xC0, 0x82, 0xC2, 0x8C, 0x90, 0x43, 0x19, 0x74, 0x01, 0xF0, 0xD0,
+0x82, 0xD0, 0x83, 0xD0, 0xE0, 0x32, 0xC2, 0x8C, 0x75, 0x89, 0x01, 0x75, 0x8C, 0xF9, 0x75, 0x8A,
+0x7E, 0x43, 0xA8, 0x02, 0x22, 0x44, 0x43, 0x1A, 0x04, 0x03, 0x09, 0x04, 0x00,
+};
+
+/*--------------------- Export Functions --------------------------*/
+
+
+BOOLEAN
+FIRMWAREbDownload(
+ IN PSDevice pDevice
+ )
+{
+ NDIS_STATUS NdisStatus;
+ PBYTE pBuffer = NULL;
+ WORD wLength;
+ int ii;
+
+ DBG_PRT(MSG_LEVEL_DEBUG, KERN_INFO"---->Download firmware\n");
+ spin_unlock_irq(&pDevice->lock);
+ pBuffer = kmalloc(sizeof(abyFirmware), GFP_KERNEL);
+ if (pBuffer != NULL) {
+
+ for (ii=0;ii<sizeof(abyFirmware);ii++)
+ pBuffer[ii] = abyFirmware[ii];
+
+ for (ii=0;ii<sizeof(abyFirmware);ii+=0x400) {
+
+ if ((sizeof(abyFirmware) - ii) < 0x400)
+ wLength = (sizeof(abyFirmware) - ii);
+ else
+ wLength = 0x400;
+
+ NdisStatus = CONTROLnsRequestOutAsyn(pDevice,
+ 0,
+ 0x1200+ii,
+ 0x0000,
+ wLength,
+ &(pBuffer[ii])
+ );
+
+ DBG_PRT(MSG_LEVEL_DEBUG, KERN_INFO"Download firmware...%d %d\n", ii, sizeof(abyFirmware));
+ if (NdisStatus != STATUS_SUCCESS) {
+ if (pBuffer)
+ kfree(pBuffer);
+ spin_lock_irq(&pDevice->lock);
+ return (FALSE);
+ }
+ }
+ }
+
+ if (pBuffer)
+ kfree(pBuffer);
+
+ spin_lock_irq(&pDevice->lock);
+ return (TRUE);
+}
+
+BOOLEAN
+FIRMWAREbBrach2Sram(
+ IN PSDevice pDevice
+ )
+{
+ NDIS_STATUS NdisStatus;
+
+ DBG_PRT(MSG_LEVEL_DEBUG, KERN_INFO"---->Branch to Sram\n");
+
+ NdisStatus = CONTROLnsRequestOut(pDevice,
+ 1,
+ 0x1200,
+ 0x0000,
+ 0,
+ NULL
+ );
+
+ if (NdisStatus != STATUS_SUCCESS) {
+ return (FALSE);
+ } else {
+ return (TRUE);
+ }
+}
+
+
+BOOLEAN
+FIRMWAREbCheckVersion(
+ IN PSDevice pDevice
+ )
+{
+ NTSTATUS ntStatus;
+
+ ntStatus = CONTROLnsRequestIn(pDevice,
+ MESSAGE_TYPE_READ,
+ 0,
+ MESSAGE_REQUEST_VERSION,
+ 2,
+ (PBYTE) &(pDevice->wFirmwareVersion));
+
+ DBG_PRT(MSG_LEVEL_DEBUG, KERN_INFO"Firmware Version [%04x]\n", pDevice->wFirmwareVersion);
+ if (ntStatus != STATUS_SUCCESS) {
+ DBG_PRT(MSG_LEVEL_DEBUG, KERN_INFO"Firmware Invalid.\n");
+ return FALSE;
+ }
+ if (pDevice->wFirmwareVersion == 0xFFFF) {
+ DBG_PRT(MSG_LEVEL_DEBUG, KERN_INFO"In Loader.\n");
+ return FALSE;
+ }
+ DBG_PRT(MSG_LEVEL_DEBUG, KERN_INFO"Firmware Version [%04x]\n", pDevice->wFirmwareVersion);
+ if (pDevice->wFirmwareVersion != FIRMWARE_VERSION) {
+ // branch to loader for download new firmware
+ FIRMWAREbBrach2Sram(pDevice);
+ return FALSE;
+ }
+ return TRUE;
+}
diff --git a/drivers/staging/vt6656/firmware.h b/drivers/staging/vt6656/firmware.h
new file mode 100644
index 000000000000..fdc380af59e7
--- /dev/null
+++ b/drivers/staging/vt6656/firmware.h
@@ -0,0 +1,66 @@
+/*
+ * 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: firmware.h
+ *
+ * Purpose: Version and Release Information
+ *
+ * Author: Yiching Chen
+ *
+ * Date: May 20, 2004
+ *
+ */
+
+
+#ifndef __FIRMWARE_H__
+#define __FIRMWARE_H__
+
+
+#if !defined(__TTYPE_H__)
+#include "ttype.h"
+#endif
+#if !defined(__DEVICE_H__)
+#include "device.h"
+#endif
+
+/*--------------------- Export Definitions -------------------------*/
+
+/*--------------------- Export Classes ----------------------------*/
+
+/*--------------------- Export Variables --------------------------*/
+
+/*--------------------- Export Functions --------------------------*/
+
+BOOL
+FIRMWAREbDownload(
+ IN PSDevice pDevice
+ );
+
+BOOL
+FIRMWAREbBrach2Sram(
+ IN PSDevice pDevice
+ );
+
+BOOL
+FIRMWAREbCheckVersion(
+ IN PSDevice pDevice
+ );
+
+
+#endif // __FIRMWARE_H__
diff --git a/drivers/staging/vt6656/hostap.c b/drivers/staging/vt6656/hostap.c
new file mode 100644
index 000000000000..223604dffaef
--- /dev/null
+++ b/drivers/staging/vt6656/hostap.c
@@ -0,0 +1,888 @@
+/*
+ * 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
+#if !defined(__DATARATE_H__)
+#include "datarate.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)
+{
+ PSDevice apdev_priv;
+ struct net_device *dev = pDevice->dev;
+ int ret;
+
+ DBG_PRT(MSG_LEVEL_DEBUG, KERN_INFO "%s: Enabling hostapd mode\n", dev->name);
+
+ 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));
+
+ apdev_priv = netdev_priv(pDevice->apdev);
+ *apdev_priv = *pDevice;
+ memcpy(pDevice->apdev->dev_addr, dev->dev_addr, ETH_ALEN);
+
+ const struct net_device_ops apdev_netdev_ops = {
+ .ndo_start_xmit = pDevice->tx_80211,
+ };
+ pDevice->apdev->netdev_ops = &apdev_netdev_ops;
+
+ 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) {
+ DBG_PRT(MSG_LEVEL_DEBUG, KERN_INFO "%s: register_netdevice(AP) failed!\n",
+ dev->name);
+ return -1;
+ }
+
+ DBG_PRT(MSG_LEVEL_DEBUG, KERN_INFO "%s: Registered netdevice %s for AP management\n",
+ dev->name, pDevice->apdev->name);
+
+ KeyvInitTable(pDevice,&pDevice->sKey);
+
+ 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)
+{
+
+ DBG_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);
+ DBG_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;
+
+ 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 (BSSbIsSTAInNodeDB(pDevice, 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->sMgmtObj);
+ UINT uNodeIndex;
+
+
+ if (!BSSbIsSTAInNodeDB(pDevice, 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;
+
+ pMgmt->sNodeDBTable[uNodeIndex].ulLastRxJiffer = jiffies;
+
+ DBG_PRT(MSG_LEVEL_DEBUG, KERN_INFO "Add STA AID= %d \n", pMgmt->sNodeDBTable[uNodeIndex].wAID);
+ DBG_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]
+ ) ;
+ DBG_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->sMgmtObj);
+ UINT uNodeIndex;
+
+ if (BSSbIsSTAInNodeDB(pDevice, param->sta_addr, &uNodeIndex)) {
+ param->u.get_info_sta.inactive_sec =
+ (jiffies - pMgmt->sNodeDBTable[uNodeIndex].ulLastRxJiffer) / HZ;
+
+ //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->sMgmtObj);
+ UINT uNodeIndex;
+
+ if (BSSbIsSTAInNodeDB(pDevice, 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->sMgmtObj);
+ UINT uNodeIndex;
+
+ if (BSSbIsSTAInNodeDB(pDevice, 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;
+ DBG_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->sMgmtObj);
+
+
+
+ memcpy( pMgmt->abyWPAIE,
+ param->u.generic_elem.data,
+ param->u.generic_elem.len
+ );
+
+ pMgmt->wWPAIELen = param->u.generic_elem.len;
+
+ DBG_PRT(MSG_LEVEL_DEBUG, KERN_INFO"pMgmt->wWPAIELen = %d\n", pMgmt->wWPAIELen);
+
+ // disable wpa
+ if (pMgmt->wWPAIELen == 0) {
+ pMgmt->eAuthenMode = WMAC_AUTH_OPEN;
+ DBG_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;
+ DBG_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->sMgmtObj);
+ 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;
+ DBG_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 (BSSbIsSTAInNodeDB(pDevice, param->sta_addr, &iNodeIndex) == FALSE) {
+ param->u.crypt.err = HOSTAP_CRYPT_ERR_UNKNOWN_ADDR;
+ DBG_PRT(MSG_LEVEL_DEBUG, KERN_INFO " HOSTAP_CRYPT_ERR_UNKNOWN_ADDR\n");
+ return -EINVAL;
+ }
+ }
+ DBG_PRT(MSG_LEVEL_DEBUG, KERN_INFO " hostap_set_encryption: sta_index %d \n", iNodeIndex);
+ DBG_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,
+ &(pDevice->sKey),
+ param->sta_addr,
+ pMgmt->sNodeDBTable[iNodeIndex].dwKeyIndex
+ ) == FALSE) {
+ DBG_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,
+ &(pDevice->sKey),
+ dwKeyIndex & ~(BIT30 | USE_KEYRSC),
+ param->u.crypt.key_len,
+ NULL,
+ abyKey,
+ KEY_CTL_WEP
+ );
+
+ } else {
+ // 8021x enable, individual key
+ dwKeyIndex |= (1 << 30); // set pairwise key
+ if (KeybSetKey(pDevice,
+ &(pDevice->sKey),
+ &param->sta_addr[0],
+ dwKeyIndex & ~(USE_KEYRSC),
+ param->u.crypt.key_len,
+ (PQWORD) &(KeyRSC),
+ (PBYTE)abyKey,
+ KEY_CTL_WEP
+ ) == 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,
+ &(pDevice->sKey),
+ dwKeyIndex,
+ param->u.crypt.key_len,
+ (PQWORD) &(KeyRSC),
+ abyKey,
+ byKeyDecMode
+ );
+ pMgmt->sNodeDBTable[iNodeIndex].bOnFly = TRUE;
+
+ } else {
+ dwKeyIndex |= (1 << 30); // set pairwise key
+ if (KeybSetKey(pDevice,
+ &(pDevice->sKey),
+ &param->sta_addr[0],
+ dwKeyIndex,
+ param->u.crypt.key_len,
+ (PQWORD) &(KeyRSC),
+ (PBYTE)abyKey,
+ byKeyDecMode
+ ) == TRUE) {
+
+ pMgmt->sNodeDBTable[iNodeIndex].bOnFly = TRUE;
+
+ } else {
+ // Key Table Full
+ pMgmt->sNodeDBTable[iNodeIndex].bOnFly = FALSE;
+ bKeyTableFull = TRUE;
+ DBG_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
+// Todo.. xxxxxx
+ //MACvSetDefaultKeyCtl(pDevice->PortOffset, wKeyCtl, MAX_KEY_TABLE-1, pDevice->byLocalID);
+ }
+
+ DBG_PRT(MSG_LEVEL_DEBUG, KERN_INFO " Set key sta_index= %d \n", iNodeIndex);
+ DBG_PRT(MSG_LEVEL_DEBUG, KERN_INFO " tx_index=%d len=%d \n", param->u.crypt.idx,
+ param->u.crypt.key_len );
+ DBG_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->sMgmtObj);
+ 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 (BSSbIsSTAInNodeDB(pDevice, param->sta_addr, &iNodeIndex) == FALSE) {
+ param->u.crypt.err = HOSTAP_CRYPT_ERR_UNKNOWN_ADDR;
+ DBG_PRT(MSG_LEVEL_DEBUG, KERN_INFO "hostap_get_encryption: HOSTAP_CRYPT_ERR_UNKNOWN_ADDR\n");
+ return -EINVAL;
+ }
+ }
+ DBG_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:
+ DBG_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:
+ DBG_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:
+ DBG_PRT(MSG_LEVEL_DEBUG, KERN_INFO "VIAWGET_HOSTAPD_SET_ASSOC_AP_ADDR \n");
+ return -EOPNOTSUPP;
+ break;
+ case VIAWGET_HOSTAPD_FLUSH:
+ DBG_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:
+ DBG_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:
+ DBG_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:
+ DBG_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:
+ DBG_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:
+ DBG_PRT(MSG_LEVEL_DEBUG, KERN_INFO "VIAWGET_HOSTAPD_SET_FLAGS_STA \n");
+ ret = hostap_set_flags_sta(pDevice, param);
+ break;
+
+ case VIAWGET_HOSTAPD_MLME:
+ DBG_PRT(MSG_LEVEL_DEBUG, KERN_INFO "VIAWGET_HOSTAPD_MLME \n");
+ return -EOPNOTSUPP;
+
+ case VIAWGET_HOSTAPD_SET_GENERIC_ELEMENT:
+ DBG_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:
+ DBG_PRT(MSG_LEVEL_DEBUG, KERN_INFO "VIAWGET_HOSTAPD_SCAN_REQ \n");
+ return -EOPNOTSUPP;
+
+ case VIAWGET_HOSTAPD_STA_CLEAR_STATS:
+ DBG_PRT(MSG_LEVEL_DEBUG, KERN_INFO "VIAWGET_HOSTAPD_STA_CLEAR_STATS \n");
+ return -EOPNOTSUPP;
+
+ default:
+ DBG_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/vt6656/hostap.h b/drivers/staging/vt6656/hostap.h
new file mode 100644
index 000000000000..c5ad3494b6e4
--- /dev/null
+++ b/drivers/staging/vt6656/hostap.h
@@ -0,0 +1,86 @@
+/*
+ * 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 -------------------------*/
+
+#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/vt6656/int.c b/drivers/staging/vt6656/int.c
new file mode 100644
index 000000000000..158a4cc0e903
--- /dev/null
+++ b/drivers/staging/vt6656/int.c
@@ -0,0 +1,214 @@
+/*
+ * 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: int.c
+ *
+ * Purpose: Handle USB interrupt endpoint
+ *
+ * Author: Jerry Chen
+ *
+ * Date: Apr. 2, 2004
+ *
+ * Functions:
+ *
+ * Revision History:
+ * 04-02-2004 Jerry Chen: Initial release
+ *
+ */
+
+
+#if !defined(__INT_H__)
+#include "int.h"
+#endif
+#if !defined(__MIB_H__)
+#include "mib.h"
+#endif
+#if !defined(__TBIT_H__)
+#include "tbit.h"
+#endif
+#if !defined(__TMACRO_H__)
+#include "tmacro.h"
+#endif
+#if !defined(__MAC_H__)
+#include "mac.h"
+#endif
+#if !defined(__POWER_H__)
+#include "power.h"
+#endif
+#if !defined(__BSSDB_H__)
+#include "bssdb.h"
+#endif
+#if !defined(__UMEM_H__)
+#include "umem.h"
+#endif
+#if !defined(__USBPIPE_H__)
+#include "usbpipe.h"
+#endif
+
+/*--------------------- Static Definitions -------------------------*/
+//static int msglevel =MSG_LEVEL_DEBUG;
+static int msglevel =MSG_LEVEL_INFO;
+
+
+/*--------------------- Static Classes ----------------------------*/
+
+/*--------------------- Static Variables --------------------------*/
+
+/*--------------------- Static Functions --------------------------*/
+
+/*--------------------- Export Variables --------------------------*/
+
+
+/*--------------------- Export Functions --------------------------*/
+
+
+/*+
+ *
+ * Function: InterruptPollingThread
+ *
+ * Synopsis: Thread running at IRQL PASSIVE_LEVEL.
+ *
+ * Arguments: Device Extension
+ *
+ * Returns:
+ *
+ * Algorithm: Call USBD for input data;
+ *
+ * History: dd-mm-yyyy Author Comment
+ *
+ *
+ * Notes:
+ *
+ * USB reads are by nature 'Blocking', and when in a read, the device looks like it's
+ * in a 'stall' condition, so we deliberately time out every second if we've gotten no data
+ *
+-*/
+VOID
+INTvWorkItem(
+ PVOID Context
+ )
+{
+ PSDevice pDevice = (PSDevice) Context;
+ NTSTATUS ntStatus;
+
+ DBG_PRT(MSG_LEVEL_DEBUG, KERN_INFO"---->Interrupt Polling Thread\n");
+
+ spin_lock_irq(&pDevice->lock);
+ if (pDevice->fKillEventPollingThread != TRUE) {
+ ntStatus = PIPEnsInterruptRead(pDevice);
+ }
+ spin_unlock_irq(&pDevice->lock);
+
+ }
+
+
+NTSTATUS
+INTnsProcessData(
+ IN PSDevice pDevice
+ )
+{
+ NTSTATUS status = STATUS_SUCCESS;
+ PSINTData pINTData;
+ PSMgmtObject pMgmt = &(pDevice->sMgmtObj);
+ struct net_device_stats* pStats = &pDevice->stats;
+
+
+ DBG_PRT(MSG_LEVEL_DEBUG, KERN_INFO"---->s_nsInterruptProcessData\n");
+
+ pINTData = (PSINTData) pDevice->intBuf.pDataBuf;
+ if (BITbIsBitOn(pINTData->byTSR0, TSR_VALID)) {
+ STAvUpdateTDStatCounter (&(pDevice->scStatistic), (BYTE) (pINTData->byPkt0 & 0x0F), (BYTE) (pINTData->byPkt0>>4), pINTData->byTSR0);
+ BSSvUpdateNodeTxCounter (pDevice, &(pDevice->scStatistic), pINTData->byTSR0, pINTData->byPkt0);
+ //DBG_PRN_GRP01(("TSR0 %02x\n", pINTData->byTSR0));
+ }
+ if (BITbIsBitOn(pINTData->byTSR1, TSR_VALID)) {
+ STAvUpdateTDStatCounter (&(pDevice->scStatistic), (BYTE) (pINTData->byPkt1 & 0x0F), (BYTE) (pINTData->byPkt1>>4), pINTData->byTSR1);
+ BSSvUpdateNodeTxCounter (pDevice, &(pDevice->scStatistic), pINTData->byTSR1, pINTData->byPkt1);
+ //DBG_PRN_GRP01(("TSR1 %02x\n", pINTData->byTSR1));
+ }
+ if (BITbIsBitOn(pINTData->byTSR2, TSR_VALID)) {
+ STAvUpdateTDStatCounter (&(pDevice->scStatistic), (BYTE) (pINTData->byPkt2 & 0x0F), (BYTE) (pINTData->byPkt2>>4), pINTData->byTSR2);
+ BSSvUpdateNodeTxCounter (pDevice, &(pDevice->scStatistic), pINTData->byTSR2, pINTData->byPkt2);
+ //DBG_PRN_GRP01(("TSR2 %02x\n", pINTData->byTSR2));
+ }
+ if (BITbIsBitOn(pINTData->byTSR3, TSR_VALID)) {
+ STAvUpdateTDStatCounter (&(pDevice->scStatistic), (BYTE) (pINTData->byPkt3 & 0x0F), (BYTE) (pINTData->byPkt3>>4), pINTData->byTSR3);
+ BSSvUpdateNodeTxCounter (pDevice, &(pDevice->scStatistic), pINTData->byTSR3, pINTData->byPkt3);
+ //DBG_PRN_GRP01(("TSR3 %02x\n", pINTData->byTSR3));
+ }
+ if ( pINTData->byISR0 != 0 ) {
+ if ( BITbIsBitOn(pINTData->byISR0, ISR_BNTX) ) {
+
+ 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;
+ if (pMgmt->sNodeDBTable[0].bPSEnable) {
+ bScheduleCommand((HANDLE)pDevice, WLAN_CMD_RX_PSPOLL, NULL);
+ }
+ }
+ bScheduleCommand((HANDLE)pDevice, WLAN_CMD_BECON_SEND, NULL);
+ } // if (pDevice->eOPMode == OP_MODE_AP)
+
+ pDevice->bBeaconSent = TRUE;
+ } else {
+ pDevice->bBeaconSent = FALSE;
+ }
+ if ( BITbIsBitOn(pINTData->byISR0, ISR_TBTT) ) {
+ if ( pDevice->bEnablePSMode ) {
+ bScheduleCommand((HANDLE) pDevice, WLAN_CMD_TBTT_WAKEUP, NULL);
+ }
+ if ( pDevice->bChannelSwitch ) {
+ pDevice->byChannelSwitchCount--;
+ if ( pDevice->byChannelSwitchCount == 0 ) {
+ bScheduleCommand((HANDLE) pDevice, WLAN_CMD_11H_CHSW, NULL);
+ }
+ }
+ }
+ LODWORD(pDevice->qwCurrTSF) = pINTData->dwLoTSF;
+ HIDWORD(pDevice->qwCurrTSF) = pINTData->dwHiTSF;
+ //DBG_PRN_GRP01(("ISR0 = %02x ,LoTsf = %08x,HiTsf = %08x\n", pINTData->byISR0, pINTData->dwLoTSF,pINTData->dwHiTSF));
+
+ STAvUpdate802_11Counter(&pDevice->s802_11Counter, &pDevice->scStatistic, pINTData->byRTSSuccess,
+ pINTData->byRTSFail, pINTData->byACKFail, pINTData->byFCSErr );
+ STAvUpdateIsrStatCounter(&pDevice->scStatistic, pINTData->byISR0, pINTData->byISR1);
+
+ }
+
+ if ( pINTData->byISR1 != 0 ) {
+ if ( BITbIsBitOn(pINTData->byISR1, ISR_GPIO3) ) {
+ bScheduleCommand((HANDLE) pDevice, WLAN_CMD_RADIO, NULL);
+ }
+ }
+ pDevice->intBuf.uDataLen = 0;
+ pDevice->intBuf.bInUse = FALSE;
+
+ pStats->tx_packets = pDevice->scStatistic.ullTsrOK;
+ pStats->tx_bytes = pDevice->scStatistic.ullTxDirectedBytes +
+ pDevice->scStatistic.ullTxMulticastBytes +
+ pDevice->scStatistic.ullTxBroadcastBytes;
+ pStats->tx_errors = pDevice->scStatistic.dwTsrErr;
+ pStats->tx_dropped = pDevice->scStatistic.dwTsrErr;
+
+ return status;
+}
diff --git a/drivers/staging/vt6656/int.h b/drivers/staging/vt6656/int.h
new file mode 100644
index 000000000000..bfbf667eac91
--- /dev/null
+++ b/drivers/staging/vt6656/int.h
@@ -0,0 +1,101 @@
+/*
+ * 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: int.h
+ *
+ * Purpose:
+ *
+ * Author: Jerry Chen
+ *
+ * Date: Apr. 2, 2004
+ *
+ */
+
+
+#ifndef __INT_H__
+#define __INT_H__
+
+#if !defined(__TTYPE_H__)
+#include "ttype.h"
+#endif
+#if !defined(__DEVICE_H__)
+#include "device.h"
+#endif
+
+
+
+/*--------------------- Export Definitions -------------------------*/
+#pragma pack(1)
+typedef struct tagSINTData {
+ BYTE byTSR0;
+ BYTE byPkt0;
+ WORD wTime0;
+ BYTE byTSR1;
+ BYTE byPkt1;
+ WORD wTime1;
+ BYTE byTSR2;
+ BYTE byPkt2;
+ WORD wTime2;
+ BYTE byTSR3;
+ BYTE byPkt3;
+ WORD wTime3;
+ DWORD dwLoTSF;
+ DWORD dwHiTSF;
+ BYTE byISR0;
+ BYTE byISR1;
+ BYTE byRTSSuccess;
+ BYTE byRTSFail;
+ BYTE byACKFail;
+ BYTE byFCSErr;
+ BYTE abySW[2];
+}__attribute__ ((__packed__))
+SINTData, DEF* PSINTData;
+
+
+/*--------------------- Export Classes ----------------------------*/
+
+/*--------------------- Export Variables --------------------------*/
+
+/*--------------------- Export Functions --------------------------*/
+#ifdef __cplusplus
+extern "C" { /* Assume C declarations for C++ */
+#endif /* __cplusplus */
+
+VOID
+INTvWorkItem(
+ PVOID Context
+ );
+
+NTSTATUS
+INTnsProcessData(
+ IN PSDevice pDevice
+ );
+
+
+#ifdef __cplusplus
+} /* End of extern "C" { */
+#endif /* __cplusplus */
+
+
+
+
+#endif // __INT_H__
+
+
+
diff --git a/drivers/staging/vt6656/iocmd.h b/drivers/staging/vt6656/iocmd.h
new file mode 100644
index 000000000000..980031c2f055
--- /dev/null
+++ b/drivers/staging/vt6656/iocmd.h
@@ -0,0 +1,478 @@
+/*
+ * 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: 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;
+
+//
+// Zonetype Setting
+//
+
+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];
+ U16 wBeaconInterval;
+ U16 wCapInfo;
+ U8 byNetType;
+ BOOL bWEPOn;
+ U32 uRSSI;
+
+} SBSSIDItem;
+
+
+typedef struct tagSBSSIDList {
+
+ U32 uItem;
+ SBSSIDItem sBSSIDList[0];
+} SBSSIDList, *PSBSSIDList;
+
+
+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 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 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;
+};
+
+
+
+/*--------------------- Export Classes ----------------------------*/
+
+/*--------------------- Export Variables --------------------------*/
+
+
+/*--------------------- Export Types ------------------------------*/
+
+
+/*--------------------- Export Functions --------------------------*/
+
+
+
+#endif //__IOCMD_H__
diff --git a/drivers/staging/vt6656/ioctl.c b/drivers/staging/vt6656/ioctl.c
new file mode 100644
index 000000000000..8e9762b8cf45
--- /dev/null
+++ b/drivers/staging/vt6656/ioctl.c
@@ -0,0 +1,724 @@
+/*
+ * 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(__CONTROL_H__)
+#include "control.h"
+#endif
+#if !defined(__RNDIS_H__)
+#include "rndis.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;
+
+#ifdef WPA_SM_Transtatus
+ SWPAResult wpa_Result;
+#endif
+
+/*--------------------- Static Functions --------------------------*/
+
+/*--------------------- Export Variables --------------------------*/
+
+int private_ioctl(PSDevice pDevice, struct ifreq *rq) {
+
+ PSCmdRequest pReq = (PSCmdRequest)rq;
+ PSMgmtObject pMgmt = &(pDevice->sMgmtObj);
+ 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:
+
+ 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);
+ }
+ spin_lock_irq(&pDevice->lock);
+ if (memcmp(pMgmt->abyCurrBSSID, &abyNullAddr[0], 6) == 0)
+ BSSvClearBSSList((HANDLE)pDevice, FALSE);
+ else
+ BSSvClearBSSList((HANDLE)pDevice, pDevice->bLinkPass);
+ DBG_PRT(MSG_LEVEL_DEBUG, KERN_INFO "WLAN_CMD_BSS_SCAN..begin \n");
+
+ 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 (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;
+ DBG_PRT(MSG_LEVEL_DEBUG, KERN_INFO "ioct set to adhoc mode\n");
+ }
+ else {
+ pMgmt->eConfigMode = WMAC_CONFIG_ESS_STA;
+ DBG_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;
+ DBG_PRT(MSG_LEVEL_DEBUG, KERN_INFO "Power Saving On\n");
+ }
+ else {
+ pDevice->ePSMode = WMAC_POWER_CAM;
+ pMgmt->wListenInterval = 1;
+ DBG_PRT(MSG_LEVEL_DEBUG, KERN_INFO "Power Saving Off \n");
+ }
+
+ if (sJoinCmd.bShareKeyAuth == TRUE){
+ pMgmt->bShareKeyAlgorithm = TRUE;
+ DBG_PRT(MSG_LEVEL_DEBUG, KERN_INFO "Share Key \n");
+ }
+ else {
+ pMgmt->bShareKeyAlgorithm = FALSE;
+ DBG_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:
+ DBG_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) {
+ int uu;
+
+ pDevice->bEncryptionEnable = FALSE;
+ pDevice->eEncryptionStatus = Ndis802_11EncryptionDisabled;
+ spin_lock_irq(&pDevice->lock);
+ for(uu=0;uu<MAX_KEY_TABLE;uu++)
+ MACvDisableKeyEntry(pDevice,uu);
+ spin_unlock_irq(&pDevice->lock);
+ DBG_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-1207-01<Modify>by Einsn Liu
+// dwKeyIndex|= (1 << 31);
+ dwKeyIndex=ii|(1 << 31);
+ else
+ dwKeyIndex = ii;
+ spin_lock_irq(&pDevice->lock);
+ KeybSetDefaultKey( pDevice,
+ &(pDevice->sKey),
+ dwKeyIndex,
+ sWEPCmd.auWepKeyLength[ii],
+ NULL,
+ (PBYTE)&sWEPCmd.abyWepKey[ii][0],
+ KEY_CTL_WEP
+ );
+ spin_unlock_irq(&pDevice->lock);
+
+ }
+ }
+ pDevice->byKeyIndex = sWEPCmd.byKeyIndex;
+ pDevice->bTransmitKey = TRUE;
+ pDevice->bEncryptionEnable = TRUE;
+ pDevice->eEncryptionStatus = Ndis802_11Encryption1Enabled;
+
+ break;
+
+ case WLAN_CMD_GET_LINK:
+ DBG_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;
+ DBG_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;
+ RFvRSSITodBm(pDevice, (BYTE)(pBSS->uRSSI), &ldBm);
+ pList->sBSSIDList[ii].uRSSI = (UINT)ldBm;
+// pList->sBSSIDList[ii].uRSSI = pBSS->uRSSI;
+ 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:
+
+ DBG_PRT(MSG_LEVEL_DEBUG, KERN_INFO "WLAN_CMD_STOP_MAC\n");
+ // Todo xxxxxx
+ netif_stop_queue(pDevice->dev);
+ spin_lock_irq(&pDevice->lock);
+ if (pDevice->bRadioOff == FALSE) {
+ CARDbRadioPowerOff(pDevice);
+ }
+ pDevice->bLinkPass = FALSE;
+ ControlvMaskByte(pDevice,MESSAGE_REQUEST_MACREG,MAC_REG_PAPEDELAY,LEDSTS_STS,LEDSTS_SLOW);
+ memset(pMgmt->abyCurrBSSID, 0, 6);
+ pMgmt->eCurrState = WMAC_STATE_IDLE;
+// del_timer(&pDevice->sTimerCommand);
+// del_timer(&pMgmt->sTimerSecondCallback);
+ pDevice->bCmdRunning = FALSE;
+ spin_unlock_irq(&pDevice->lock);
+
+ break;
+
+ case WLAN_CMD_START_MAC:
+
+ DBG_PRT(MSG_LEVEL_DEBUG, KERN_INFO "WLAN_CMD_START_MAC\n");
+ // Todo xxxxxxx
+ if (pDevice->bRadioOff == TRUE)
+ CARDbRadioPowerOn(pDevice);
+ break;
+
+ case WLAN_CMD_SET_HOSTAPD:
+
+ DBG_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){
+ DBG_PRT(MSG_LEVEL_DEBUG, KERN_INFO "Enable HOSTAP\n");
+ }
+ else {
+ result = -EFAULT;
+ break;
+ }
+ }
+ else {
+ hostap_set_hostapd(pDevice, 0, 1);
+ DBG_PRT(MSG_LEVEL_DEBUG, KERN_INFO "Disable HOSTAP\n");
+ }
+
+ break;
+
+ case WLAN_CMD_SET_HOSTAPD_STA:
+
+ DBG_PRT(MSG_LEVEL_DEBUG, KERN_INFO "WLAN_CMD_SET_HOSTAPD_STA\n");
+
+ break;
+ case WLAN_CMD_SET_802_1X:
+
+ DBG_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;
+ DBG_PRT(MSG_LEVEL_DEBUG, KERN_INFO "Enable 802.1x\n");
+ }
+ else {
+ pDevice->bEnable8021x = FALSE;
+ DBG_PRT(MSG_LEVEL_DEBUG, KERN_INFO "Disable 802.1x\n");
+ }
+
+ break;
+
+
+ case WLAN_CMD_SET_HOST_WEP:
+
+ DBG_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;
+ DBG_PRT(MSG_LEVEL_DEBUG, KERN_INFO "Enable HostWEP\n");
+ }
+ else {
+ pDevice->bEnableHostWEP = FALSE;
+ DBG_PRT(MSG_LEVEL_DEBUG, KERN_INFO "Disable HostWEP\n");
+ }
+
+ break;
+
+ case WLAN_CMD_SET_WPA:
+ DBG_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) {
+ DBG_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 {
+ DBG_PRT(MSG_LEVEL_DEBUG, KERN_INFO "close wpadev\n");
+ pDevice->bWPADEVUp = FALSE;
+ }
+
+ break;
+
+ case WLAN_CMD_AP_START:
+
+ DBG_PRT(MSG_LEVEL_DEBUG, KERN_INFO "WLAN_CMD_AP_START\n");
+ if (pDevice->bRadioOff == TRUE) {
+ CARDbRadioPowerOn(pDevice);
+ 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;
+ DBG_PRT(MSG_LEVEL_DEBUG, KERN_INFO "ioct set to AP mode\n");
+ }
+ else {
+ DBG_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;
+ DBG_PRT(MSG_LEVEL_DEBUG, KERN_INFO "Share Key \n");
+ }
+ else {
+ pMgmt->bShareKeyAlgorithm = FALSE;
+ DBG_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;
+ }
+
+ DBG_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);
+ DBG_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;
+ }
+//DavidWang for some AP maybe good authenticate
+ if(wpa_Result.key_mgmt==0x20)
+ pMgmt->Cisco_cckm =1;
+ else
+ pMgmt->Cisco_cckm =0;
+//DavidWang
+
+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:
+ DBG_PRT(MSG_LEVEL_DEBUG, KERN_INFO "Private command not support..\n");
+ }
+
+ return result;
+}
diff --git a/drivers/staging/vt6656/ioctl.h b/drivers/staging/vt6656/ioctl.h
new file mode 100644
index 000000000000..9c6816eab46c
--- /dev/null
+++ b/drivers/staging/vt6656/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/vt6656/iowpa.h b/drivers/staging/vt6656/iowpa.h
new file mode 100644
index 000000000000..05f391a02fa5
--- /dev/null
+++ b/drivers/staging/vt6656/iowpa.h
@@ -0,0 +1,159 @@
+/*
+ * 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: 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;
+ u8 roam_dbm; //DavidWang
+ } 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;
+};
+
+
+/*--------------------- Export Classes ----------------------------*/
+
+/*--------------------- Export Variables --------------------------*/
+
+
+/*--------------------- Export Types ------------------------------*/
+
+
+/*--------------------- Export Functions --------------------------*/
+
+
+
+#endif //__IOWPA_H__
diff --git a/drivers/staging/vt6656/iwctl.c b/drivers/staging/vt6656/iwctl.c
new file mode 100644
index 000000000000..e4fdb6fc6eab
--- /dev/null
+++ b/drivers/staging/vt6656/iwctl.c
@@ -0,0 +1,2215 @@
+/*
+ * 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
+
+#include <net/iw_handler.h>
+
+
+/*--------------------- 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
+
+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
+ };
+
+
+/*--------------------- Static Classes ----------------------------*/
+
+
+//static int msglevel =MSG_LEVEL_DEBUG;
+static int msglevel =MSG_LEVEL_INFO;
+
+
+/*--------------------- Static Variables --------------------------*/
+/*--------------------- Static Functions --------------------------*/
+
+/*--------------------- Export Variables --------------------------*/
+
+struct iw_statistics *iwctl_get_wireless_stats(struct net_device *dev)
+{
+ PSDevice pDevice = netdev_priv(dev);
+ 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 = pDevice->scStatistic.dwTsrErr;
+ pDevice->wstats.discard.misc = 0;
+ pDevice->wstats.miss.beacon = 0;
+
+ return &pDevice->wstats;
+}
+
+
+
+/*------------------------------------------------------------------*/
+
+
+static int iwctl_commit(struct net_device *dev,
+ struct iw_request_info *info,
+ void *wrq,
+ char *extra)
+{
+//2008-0409-02, <Mark> by Einsn Liu
+/*
+#ifdef Safe_Close
+ PSDevice pDevice = (PSDevice)netdev_priv(dev);
+ if (!(pDevice->flags & DEVICE_FLAGS_OPENED))
+ return -EINVAL;
+#endif
+*/
+ DBG_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;
+}
+/*
+ * 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)netdev_priv(dev);
+ PSMgmtObject pMgmt = &(pDevice->sMgmtObj);
+ struct iw_scan_req *req = (struct iw_scan_req *)extra;
+ BYTE abyScanSSID[WLAN_IEHDR_LEN + WLAN_SSID_MAXLEN + 1];
+ PWLAN_IE_SSID pItemSSID=NULL;
+
+//2008-0920-01<Add>by MikeLiu
+ if (!(pDevice->flags & DEVICE_FLAGS_OPENED))
+ return -EINVAL;
+
+ PRINT_K(" SIOCSIWSCAN \n");
+
+if (pMgmt->eScanState == WMAC_IS_SCANNING) {
+ // In scanning..
+ PRINT_K("SIOCSIWSCAN(overlap??)-->In scanning...\n");
+ return -EAGAIN;
+ }
+
+if(pDevice->byReAssocCount > 0) { //reject scan when re-associating!
+//send scan event to wpa_Supplicant
+ union iwreq_data wrqu;
+ PRINT_K("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);
+
+ #ifdef update_BssList
+ BSSvClearBSSList((HANDLE)pDevice, pDevice->bLinkPass);
+ #endif
+
+//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;
+ PRINT_K("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;
+ //printk("SIOCSIWSCAN:WLAN_CMD_BSSID_SCAN\n");
+ 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)netdev_priv(dev);
+ 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;
+ char buf[MAX_WPA_IE_LEN * 2 + 30];
+
+//2008-0409-02, <Mark> by Einsn Liu
+/*
+#ifdef Safe_Close
+ if (!(pDevice->flags & DEVICE_FLAGS_OPENED))
+ return -EINVAL;
+#endif
+*/
+ DBG_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) {
+ //ADD 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, pBSS->abyBSSID, WLAN_BSSID_LEN);
+ current_ev = iwe_stream_add_event(info,current_ev,end_buf, &iwe, IW_EV_ADDR_LEN);
+ //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;
+ current_ev = iwe_stream_add_point(info,current_ev,end_buf, &iwe, pItemSSID->abySSID);
+ //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;
+ current_ev = iwe_stream_add_event(info,current_ev, end_buf, &iwe, IW_EV_UINT_LEN);
+ //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;
+ current_ev = iwe_stream_add_event(info,current_ev,end_buf, &iwe, IW_EV_FREQ_LEN);
+ //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;
+ }
+ current_ev = iwe_stream_add_event(info,current_ev,end_buf, &iwe, IW_EV_FREQ_LEN);
+ //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;
+
+//2008-0409-01, <Mark> by Einsn Liu
+/*
+//2008-0220-03, <Modify> by Einsn Liu
+ if(pDevice->bLinkPass== TRUE && IS_ETH_ADDRESS_EQUAL(pBSS->abyBSSID, pMgmt->abyCurrBSSID)){
+ #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;
+ iwe.u.qual.qual =(BYTE) pDevice->scStatistic.LinkQuality;
+ #else
+ iwe.u.qual.qual = pDevice->byCurrSQ;
+ #endif
+ }else {
+ iwe.u.qual.qual = 0;
+ }
+*/
+ current_ev = iwe_stream_add_event(info,current_ev, end_buf, &iwe, IW_EV_QUAL_LEN);
+ //ADD encryption
+ 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;
+ }
+ current_ev = iwe_stream_add_point(info,current_ev,end_buf, &iwe, pItemSSID->abySSID);
+
+ 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);
+ current_val = iwe_stream_add_value(info,current_ev, current_val, end_buf, &iwe, IW_EV_PARAM_LEN);
+ }
+ 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);
+ 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;
+
+ memset(&iwe, 0, sizeof(iwe));
+ iwe.cmd = IWEVCUSTOM;
+ sprintf(buf, "bcn_int=%d", pBSS->wBeaconInterval);
+ iwe.u.data.length = strlen(buf);
+ current_ev = iwe_stream_add_point(info,current_ev, end_buf, &iwe, buf);
+
+ if ((pBSS->wWPALen > 0) && (pBSS->wWPALen <= MAX_WPA_IE_LEN)) {
+ memset(&iwe, 0, sizeof(iwe));
+ iwe.cmd = IWEVGENIE;
+ iwe.u.data.length = pBSS->wWPALen;
+ current_ev = iwe_stream_add_point(info,current_ev, end_buf, &iwe, pBSS->byWPAIE);
+ }
+
+ if ((pBSS->wRSNLen > 0) && (pBSS->wRSNLen <= MAX_WPA_IE_LEN)) {
+ memset(&iwe, 0, sizeof(iwe));
+ iwe.cmd = IWEVGENIE;
+ iwe.u.data.length = pBSS->wRSNLen;
+ current_ev = iwe_stream_add_point(info,current_ev, end_buf, &iwe, pBSS->byRSNIE);
+ }
+
+ }
+ }// for
+
+ wrq->length = current_ev - extra;
+ return 0;
+
+}
+
+
+/*
+ * 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)netdev_priv(dev);
+ int rc = 0;
+
+ DBG_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)) {
+ DBG_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 !!!
+ DBG_PRT(MSG_LEVEL_DEBUG, KERN_INFO " Set to channel = %d\n", channel);
+ pDevice->uChannel = channel;
+ }
+ }
+
+ 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)netdev_priv(dev);
+ PSMgmtObject pMgmt = &(pDevice->sMgmtObj);
+
+ DBG_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)netdev_priv(dev);
+ PSMgmtObject pMgmt = &(pDevice->sMgmtObj);
+ int rc = 0;
+
+ DBG_PRT(MSG_LEVEL_DEBUG, KERN_INFO " SIOCSIWMODE \n");
+
+ if (pMgmt->eCurrMode == WMAC_MODE_ESS_AP && pDevice->bEnableHostapd) {
+ DBG_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;
+ }
+ }
+ DBG_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;
+ }
+ }
+ DBG_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;
+ }
+ }
+ DBG_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)netdev_priv(dev);
+ PSMgmtObject pMgmt = &(pDevice->sMgmtObj);
+
+
+ DBG_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};
+//2008-0409-02, <Mark> by Einsn Liu
+/*
+ #ifdef Safe_Close
+ PSDevice pDevice = (PSDevice)netdev_priv(dev);
+ if (!(pDevice->flags & DEVICE_FLAGS_OPENED))
+ return -EINVAL;
+#endif
+ */
+
+ DBG_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;
+
+ range->enc_capa = IW_ENC_CAPA_WPA | IW_ENC_CAPA_WPA2 |
+ IW_ENC_CAPA_CIPHER_TKIP | IW_ENC_CAPA_CIPHER_CCMP;
+
+ 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;
+ 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;
+ // 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;
+ }
+
+
+ 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)netdev_priv(dev);
+ PSMgmtObject pMgmt = &(pDevice->sMgmtObj);
+ int rc = 0;
+ BYTE ZeroBSSID[WLAN_BSSID_LEN]={0x00,0x00,0x00,0x00,0x00,0x00};
+
+ PRINT_K(" SIOCSIWAP \n");
+
+ if (wrq->sa_family != ARPHRD_ETHER)
+ rc = -EINVAL;
+ else {
+ memset(pMgmt->abyDesireBSSID, 0xFF, 6);
+ memcpy(pMgmt->abyDesireBSSID, wrq->sa_data, 6);
+
+ //mike :add
+ if ((IS_BROADCAST_ADDRESS(pMgmt->abyDesireBSSID)) ||
+ (memcmp(pMgmt->abyDesireBSSID, ZeroBSSID, 6) == 0)){
+ PRINT_K("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!!!
+ PRINT_K("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)netdev_priv(dev);
+ PSMgmtObject pMgmt = &(pDevice->sMgmtObj);
+
+
+ DBG_PRT(MSG_LEVEL_DEBUG, KERN_INFO " SIOCGIWAP \n");
+
+ memcpy(wrq->sa_data, pMgmt->abyCurrBSSID, 6);
+
+//20080123-02,<Modify> by Einsn Liu
+ if ((pDevice->bLinkPass == FALSE) && (pMgmt->eCurrMode != WMAC_MODE_ESS_AP))
+ // if ((pDevice->bLinkPass == FALSE) && (pMgmt->eCurrMode == WMAC_MODE_ESS_STA))
+ 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)netdev_priv(dev);
+ PSMgmtObject pMgmt = &(pDevice->sMgmtObj);
+
+
+ DBG_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)netdev_priv(dev);
+ PSMgmtObject pMgmt = &(pDevice->sMgmtObj);
+ PWLAN_IE_SSID pItemSSID;
+
+//2008-0920-01<Add>by MikeLiu
+ if (!(pDevice->flags & DEVICE_FLAGS_OPENED))
+ return -EINVAL;
+
+ DBG_PRT(MSG_LEVEL_DEBUG, KERN_INFO " SIOCSIWESSID :\n");
+
+ pDevice->fWPA_Authened = FALSE;
+ // Check if we asked for `any'
+ if(wrq->flags == 0) {
+ // Just send an empty SSID list
+ memset(pMgmt->abyDesireSSID, 0, WLAN_IEHDR_LEN + WLAN_SSID_MAXLEN + 1);
+ memset(pMgmt->abyDesireBSSID, 0xFF,6);
+ PRINT_K("set essid to 'any' \n");
+ #ifdef WPA_SUPPLICANT_DRIVER_WEXT_SUPPORT
+ //Unknown desired AP,so here need not associate??
+ 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;
+ PRINT_K("set essid to %s \n",pItemSSID->abySSID);
+
+ //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,
+ pDevice->eConfigPHYMode
+ );
+
+ if (pCurr == NULL){
+ PRINT_K("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!!!
+ PRINT_K("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
+
+ DBG_PRT(MSG_LEVEL_DEBUG, KERN_INFO "set essid = %s \n", pItemSSID->abySSID);
+ }
+
+ 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)netdev_priv(dev);
+ PSMgmtObject pMgmt = &(pDevice->sMgmtObj);
+ PWLAN_IE_SSID pItemSSID;
+
+ DBG_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';
+ //2008-0409-03, <Add> by Einsn Liu
+ wrq->length = pItemSSID->len;
+ 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)netdev_priv(dev);
+ int rc = 0;
+ u8 brate = 0;
+ int i;
+ BYTE abySupportedRates[13]= {0x02, 0x04, 0x0B, 0x16, 0x0c, 0x12, 0x18, 0x24, 0x30, 0x48, 0x60, 0x6C, 0x90};
+
+
+ DBG_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
+ pDevice->bFixRate = TRUE;
+ if ((pDevice->byBBType == BB_TYPE_11B)&& (brate > 3)) {
+ pDevice->uConnectionRate = 3;
+ }
+ else {
+ pDevice->uConnectionRate = brate;
+ DBG_PRT(MSG_LEVEL_DEBUG, KERN_INFO "Fixed to Rate %d \n", pDevice->uConnectionRate);
+ }
+
+ }
+ else {
+ pDevice->bFixRate = FALSE;
+ pDevice->uConnectionRate = 13;
+ }
+
+ 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)netdev_priv(dev);
+ PSMgmtObject pMgmt = &(pDevice->sMgmtObj);
+
+ DBG_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;
+ 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;
+ }
+
+ 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)netdev_priv(dev);
+ int rc = 0;
+
+ DBG_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)netdev_priv(dev);
+
+ DBG_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)netdev_priv(dev);
+ int rc = 0;
+ int fthr = wrq->value;
+
+
+ DBG_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)netdev_priv(dev);
+
+ DBG_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)netdev_priv(dev);
+ int rc = 0;
+
+
+ DBG_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)netdev_priv(dev);
+ DBG_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)netdev_priv(dev);
+ PSMgmtObject pMgmt = &(pDevice->sMgmtObj);
+ DWORD dwKeyIndex = (DWORD)(wrq->flags & IW_ENCODE_INDEX);
+ int ii,uu, rc = 0;
+ int index = (wrq->flags & IW_ENCODE_INDEX);
+
+
+ DBG_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) {
+ DBG_PRT(MSG_LEVEL_DEBUG, KERN_INFO "Set 232 bit wep key\n");
+ }
+ else if (wrq->length == WLAN_WEP104_KEYLEN) {
+ DBG_PRT(MSG_LEVEL_DEBUG, KERN_INFO "Set 104 bit wep key\n");
+ }
+ else if (wrq->length == WLAN_WEP40_KEYLEN) {
+ DBG_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);
+
+ DBG_PRT(MSG_LEVEL_DEBUG, KERN_INFO"abyKey: ");
+ for (ii = 0; ii < wrq->length; ii++) {
+ DBG_PRT(MSG_LEVEL_DEBUG, KERN_INFO "%02x ", pDevice->abyKey[ii]);
+ }
+
+ if (pDevice->flags & DEVICE_FLAGS_OPENED) {
+ spin_lock_irq(&pDevice->lock);
+ KeybSetDefaultKey( pDevice,
+ &(pDevice->sKey),
+ dwKeyIndex | (1 << 31),
+ wrq->length,
+ NULL,
+ pDevice->abyKey,
+ KEY_CTL_WEP
+ );
+ 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){
+
+ DBG_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,uu);
+ spin_unlock_irq(&pDevice->lock);
+ }
+ }
+ if(wrq->flags & IW_ENCODE_RESTRICTED) {
+ DBG_PRT(MSG_LEVEL_DEBUG, KERN_INFO "Enable WEP & ShareKey System\n");
+ pMgmt->bShareKeyAlgorithm = TRUE;
+ }
+ if(wrq->flags & IW_ENCODE_OPEN) {
+ DBG_PRT(MSG_LEVEL_DEBUG, KERN_INFO "Enable WEP & Open System\n");
+ pMgmt->bShareKeyAlgorithm = FALSE;
+ }
+
+#ifdef WPA_SUPPLICANT_DRIVER_WEXT_SUPPORT
+ memset(pMgmt->abyDesireBSSID, 0xFF,6);
+#endif
+
+ return rc;
+}
+
+/*
+ * Wireless Handler : get encode mode
+ */
+//2008-0409-06, <Mark> by Einsn Liu
+ /*
+int iwctl_giwencode(struct net_device *dev,
+ struct iw_request_info *info,
+ struct iw_point *wrq,
+ char *extra)
+{
+ PSDevice pDevice = (PSDevice)netdev_priv(dev);
+ PSMgmtObject pMgmt = &(pDevice->sMgmtObj);
+ int rc = 0;
+ char abyKey[WLAN_WEP232_KEYLEN];
+ UINT index = (UINT)(wrq->flags & IW_ENCODE_INDEX);
+ PSKeyItem pKey = NULL;
+
+ DBG_PRT(MSG_LEVEL_DEBUG, KERN_INFO " SIOCGIWENCODE\n");
+
+
+ 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);
+ }
+ else {
+ rc = -EINVAL;
+ return rc;
+ }
+ wrq->flags |= index;
+ // Copy the key to the user buffer
+ memcpy(extra, abyKey, WLAN_WEP232_KEYLEN);
+ 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)netdev_priv(dev);
+ PSMgmtObject pMgmt = &(pDevice->sMgmtObj);
+ char abyKey[WLAN_WEP232_KEYLEN];
+
+ UINT index = (UINT)(wrq->flags & IW_ENCODE_INDEX);
+ PSKeyItem pKey = NULL;
+
+ DBG_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)netdev_priv(dev);
+ PSMgmtObject pMgmt = &(pDevice->sMgmtObj);
+ int rc = 0;
+
+ DBG_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:
+ DBG_PRT(MSG_LEVEL_DEBUG, KERN_INFO " SIOCSIWPOWER: IW_POWER_UNICAST_R \n");
+ rc = -EINVAL;
+ break;
+ case IW_POWER_ALL_R:
+ DBG_PRT(MSG_LEVEL_DEBUG, KERN_INFO " SIOCSIWPOWER: IW_POWER_ALL_R \n");
+ rc = -EINVAL;
+ case IW_POWER_ON:
+ DBG_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)netdev_priv(dev);
+ PSMgmtObject pMgmt = &(pDevice->sMgmtObj);
+ int mode = pDevice->ePSMode;
+
+
+ DBG_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)netdev_priv(dev);
+ long ldBm;
+
+ DBG_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)netdev_priv(dev);
+ 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;
+
+ DBG_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) {
+ PRINT_K("iwctl_siwauth:set WPADEV to disable at 1??????\n");
+ //pDevice->bWPADEVUp = FALSE;
+ }
+ else if(wrq->value == IW_AUTH_WPA_VERSION_WPA) {
+ PRINT_K("iwctl_siwauth:set WPADEV to WPA1******\n");
+ }
+ else {
+ PRINT_K("iwctl_siwauth:set WPADEV to WPA2******\n");
+ }
+ //pDevice->bWPASuppWextEnabled =TRUE;
+ break;
+ case IW_AUTH_CIPHER_PAIRWISE:
+ pairwise = wrq->value;
+ PRINT_K("iwctl_siwauth:set pairwise=%d\n",pairwise);
+ 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:
+ PRINT_K("iwctl_siwauth:set GROUP=%d\n",wrq->value);
+ 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:
+ PRINT_K("iwctl_siwauth(wpa_version=%d):set KEY_MGMT=%d\n",wpa_version,wrq->value);
+ 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:
+ PRINT_K("iwctl_siwauth:set AUTH_ALG=%d\n",wrq->value);
+ 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->bWPADEVUp = !! wrq->value;
+ //if(pDevice->bWPADEVUp==TRUE)
+ // printk("iwctl_siwauth:set WPADEV to enable sucessful*******\n");
+ //else
+ // printk("iwctl_siwauth:set WPADEV to enable fail?????\n");
+ 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 = WMAC_AUTH_OPEN;
+ //pDevice->bWPADEVUp = FALSE;
+ PRINT_K("iwctl_siwauth:set WPADEV to disaable at 2?????\n");
+ }
+
+ break;
+ default:
+ ret = -EOPNOTSUPP;
+ break;
+ }
+/*
+ DBG_PRT(MSG_LEVEL_DEBUG, KERN_INFO "wpa_version = %d\n",wpa_version);
+ DBG_PRT(MSG_LEVEL_DEBUG, KERN_INFO "pairwise = %d\n",pairwise);
+ DBG_PRT(MSG_LEVEL_DEBUG, KERN_INFO "pDevice->eEncryptionStatus = %d\n",pDevice->eEncryptionStatus);
+ DBG_PRT(MSG_LEVEL_DEBUG, KERN_INFO "pMgmt->eAuthenMode = %d\n",pMgmt->eAuthenMode);
+ DBG_PRT(MSG_LEVEL_DEBUG, KERN_INFO "pMgmt->bShareKeyAlgorithm = %s\n",pMgmt->bShareKeyAlgorithm?"TRUE":"FALSE");
+ DBG_PRT(MSG_LEVEL_DEBUG, KERN_INFO "pDevice->bEncryptionEnable = %s\n",pDevice->bEncryptionEnable?"TRUE":"FALSE");
+ DBG_PRT(MSG_LEVEL_DEBUG, KERN_INFO "pDevice->bWPADEVUp = %s\n",pDevice->bWPADEVUp?"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)netdev_priv(dev);
+ 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)netdev_priv(dev);
+ 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)netdev_priv(dev);
+ PSMgmtObject pMgmt = &(pDevice->sMgmtObj);
+ 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=0;
+ u8 seq[IW_ENCODE_SEQ_MAX_SIZE];
+ u8 key[64];
+ size_t seq_len=0,key_len=0;
+//
+ // int ii;
+ u8 *buf;
+ size_t blen;
+ u8 key_array[64];
+ int ret=0;
+
+PRINT_K("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:
+ PRINT_K("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
+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->bwextstep0 = TRUE;
+ }
+ if((pDevice->bwextstep0 = TRUE)&&(param->u.wpa_key.key_index ==1)) {
+ pDevice->bwextstep0 = FALSE;
+ pDevice->bwextstep1 = TRUE;
+ }
+ if((pDevice->bwextstep1 = TRUE)&&(param->u.wpa_key.key_index ==2)) {
+ pDevice->bwextstep1 = FALSE;
+ pDevice->bwextstep2 = TRUE;
+ }
+ if((pDevice->bwextstep2 = TRUE)&&(param->u.wpa_key.key_index ==3)) {
+ pDevice->bwextstep2 = FALSE;
+ pDevice->bwextstep3 = TRUE;
+ }
+ }
+if(pDevice->bwextstep3 == TRUE) {
+ PRINT_K("SIOCSIWENCODEEXT:Enable WPA WEXT SUPPORT!!!!!\n");
+ pDevice->bwextstep0 = FALSE;
+ pDevice->bwextstep1 = FALSE;
+ pDevice->bwextstep2 = FALSE;
+ pDevice->bwextstep3 = FALSE;
+ pDevice->bWPASuppWextEnabled = TRUE;
+ memset(pMgmt->abyDesireBSSID, 0xFF,6);
+ KeyvInitTable(pDevice,&pDevice->sKey);
+ }
+//******
+
+ 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)netdev_priv(dev);
+ 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
+ //printk("iwctl_siwmlme--->send DEAUTH\n");
+ //bScheduleCommand((HANDLE) pDevice, WLAN_CMD_DEAUTH, (PBYTE)&reason);
+ //break;
+ case IW_MLME_DISASSOC:
+ if(pDevice->bLinkPass == TRUE){
+ PRINT_K("iwctl_siwmlme--->send DISASSOCIATE\n");
+ bScheduleCommand((HANDLE)pDevice, WLAN_CMD_DISASSOCIATE, NULL);
+ }
+ break;
+ default:
+ ret = -EOPNOTSUPP;
+ }
+
+ return ret;
+
+}
+
+#endif
+//End Add --//2008-0409-07, <Add> by Einsn Liu
+
+
+
+/*------------------------------------------------------------------*/
+/*
+ * Structures to export the Wireless Handlers
+ */
+
+
+/*
+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
+ (iw_handler) iwctl_siwscan, // SIOCSIWSCAN
+ (iw_handler) iwctl_giwscan, // SIOCGIWSCAN
+ (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
+ (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 --
+
+};
+*/
+
+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
+ (iw_handler) iwctl_siwscan, // SIOCSIWSCAN
+ (iw_handler) iwctl_giwscan, // SIOCGIWSCAN
+ (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
+ (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 --
+};
+
+
+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 =
+{
+ .get_wireless_stats = &iwctl_get_wireless_stats,
+ .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,
+};
diff --git a/drivers/staging/vt6656/iwctl.h b/drivers/staging/vt6656/iwctl.h
new file mode 100644
index 000000000000..962235f2f397
--- /dev/null
+++ b/drivers/staging/vt6656/iwctl.h
@@ -0,0 +1,246 @@
+/*
+ * 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 */
+
+
+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
+//End Add -- //2008-0409-07, <Add> by Einsn Liu
+
+
+extern const struct iw_handler_def iwctl_handler_def;
+extern const struct iw_priv_args iwctl_private_args;
+
+#ifdef __cplusplus
+} /* End of extern "C" { */
+#endif /* __cplusplus */
+
+
+
+
+#endif // __IWCTL_H__
+
+
+
diff --git a/drivers/staging/vt6656/kcompat.h b/drivers/staging/vt6656/kcompat.h
new file mode 100644
index 000000000000..3dc209c9f9e1
--- /dev/null
+++ b/drivers/staging/vt6656/kcompat.h
@@ -0,0 +1,83 @@
+/*
+ * 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: 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;
+
+
+#define IRQ_RETVAL(x)
+
+#endif
+
+#define vntwusb_submit_urb(val) usb_submit_urb(val, GFP_ATOMIC)
+#define vntwusb_alloc_urb(val) usb_alloc_urb(val, GFP_ATOMIC)
+
+#define vntwusb_unlink_urb(val) usb_kill_urb(val)
+
+#ifndef MODULE_LICESEN
+#define MODULE_LICESEN(x)
+#endif
+
+#endif
+
diff --git a/drivers/staging/vt6656/key.c b/drivers/staging/vt6656/key.c
new file mode 100644
index 000000000000..bd0f29c2afbe
--- /dev/null
+++ b/drivers/staging/vt6656/key.c
@@ -0,0 +1,886 @@
+/*
+ * 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
+#if !defined(__RNDIS_H__)
+#include "rndis.h"
+#endif
+#if !defined(__CONTROL_H__)
+#include "control.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 (PVOID pDeviceHandler, PSKeyManagement pTable)
+{
+ PSDevice pDevice = (PSDevice) pDeviceHandler;
+ int i;
+ WORD wLength = 0;
+ BYTE pbyData[MAX_KEY_TABLE];
+
+ 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;
+ pbyData[wLength++] = (BYTE) i;
+ //MACvDisableKeyEntry(pDevice, i);
+ }
+ }
+ if ( wLength != 0 ) {
+ CONTROLnsRequestOut(pDevice,
+ MESSAGE_TYPE_CLRKEYENTRY,
+ 0,
+ 0,
+ wLength,
+ pbyData
+ );
+ }
+
+}
+
+
+/*--------------------- Export Functions --------------------------*/
+
+
+/*
+ * Description: Init Key management table
+ *
+ * Parameters:
+ * In:
+ * pTable - Pointer to Key table
+ * Out:
+ * none
+ *
+ * Return Value: none
+ *
+ */
+VOID KeyvInitTable(PVOID pDeviceHandler, PSKeyManagement pTable)
+{
+ PSDevice pDevice = (PSDevice) pDeviceHandler;
+ int i;
+ int jj;
+ BYTE pbyData[MAX_KEY_TABLE+1];
+
+ spin_lock_irq(&pDevice->lock);
+ 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;
+ pbyData[i] = (BYTE) i;
+ }
+ pbyData[i] = (BYTE) i;
+ CONTROLnsRequestOut(pDevice,
+ MESSAGE_TYPE_CLRKEYENTRY,
+ 0,
+ 0,
+ 11,
+ pbyData
+ );
+
+ spin_unlock_irq(&pDevice->lock);
+
+ return;
+}
+
+
+/*
+ * 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;
+
+ DBG_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 (
+ PVOID pDeviceHandler,
+ PSKeyManagement pTable,
+ PBYTE pbyBSSID,
+ DWORD dwKeyIndex,
+ ULONG uKeyLength,
+ PQWORD pKeyRSC,
+ PBYTE pbyKey,
+ BYTE byKeyDecMode
+ )
+{
+ PSDevice pDevice = (PSDevice) pDeviceHandler;
+ int i,j;
+ UINT ii;
+ PSKeyItem pKey;
+ UINT uKeyIdx;
+
+ DBG_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;
+ DBG_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(pDevice, pTable->KeyTable[i].wKeyCtl, i, uKeyIdx, pbyBSSID, (PDWORD)pKey->abyKey);
+
+ 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;
+
+ DBG_PRT(MSG_LEVEL_DEBUG, KERN_INFO"KeybSetKey(R): \n");
+ DBG_PRT(MSG_LEVEL_DEBUG, KERN_INFO"pKey->bKeyValid: %d\n ", pKey->bKeyValid);
+ //DBG_PRT(MSG_LEVEL_DEBUG, KERN_INFO"pKey->uKeyLength: %d\n ", pKey->uKeyLength);
+ DBG_PRT(MSG_LEVEL_DEBUG, KERN_INFO"pKey->abyKey: ");
+ for (ii = 0; ii < pKey->uKeyLength; ii++) {
+ DBG_PRT(MSG_LEVEL_DEBUG, KERN_INFO "%02x ", pKey->abyKey[ii]);
+ }
+ DBG_PRT(MSG_LEVEL_DEBUG, KERN_INFO"\n");
+
+ DBG_PRT(MSG_LEVEL_DEBUG, KERN_INFO"pKey->dwTSC47_16: %lx\n ", pKey->dwTSC47_16);
+ DBG_PRT(MSG_LEVEL_DEBUG, KERN_INFO"pKey->wTSC15_0: %x\n ", pKey->wTSC15_0);
+ DBG_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;
+ DBG_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(pDevice, pTable->KeyTable[j].wKeyCtl, j, uKeyIdx, pbyBSSID, (PDWORD)pKey->abyKey);
+
+ 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;
+
+ DBG_PRT(MSG_LEVEL_DEBUG, KERN_INFO"KeybSetKey(N): \n");
+ DBG_PRT(MSG_LEVEL_DEBUG, KERN_INFO"pKey->bKeyValid: %d\n ", pKey->bKeyValid);
+ DBG_PRT(MSG_LEVEL_DEBUG, KERN_INFO"pKey->uKeyLength: %d\n ", (int)pKey->uKeyLength);
+ DBG_PRT(MSG_LEVEL_DEBUG, KERN_INFO"pKey->abyKey: ");
+ for (ii = 0; ii < pKey->uKeyLength; ii++) {
+ DBG_PRT(MSG_LEVEL_DEBUG, KERN_INFO "%02x ", pKey->abyKey[ii]);
+ }
+ DBG_PRT(MSG_LEVEL_DEBUG, KERN_INFO"\n");
+
+ DBG_PRT(MSG_LEVEL_DEBUG, KERN_INFO"pKey->dwTSC47_16: %lx\n ", pKey->dwTSC47_16);
+ DBG_PRT(MSG_LEVEL_DEBUG, KERN_INFO"pKey->wTSC15_0: %x\n ", pKey->wTSC15_0);
+ DBG_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 (
+ PVOID pDeviceHandler,
+ PSKeyManagement pTable,
+ PBYTE pbyBSSID,
+ DWORD dwKeyIndex
+ )
+{
+ PSDevice pDevice = (PSDevice) pDeviceHandler;
+ int i;
+ BOOL bReturnValue = FALSE;
+
+ 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;
+ }
+ bReturnValue = 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;
+ }
+ }
+ bReturnValue = TRUE;
+ }
+ else {
+ bReturnValue = FALSE;
+ }
+
+ } else {
+ 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;
+ bReturnValue = TRUE;
+ break;
+ }
+ 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;
+ }
+ bReturnValue = TRUE;
+ break;
+ }
+ else {
+ bReturnValue = FALSE;
+ break;
+ }
+ } //pTable->KeyTable[i].bInUse == TRUE
+ } //for
+ bReturnValue = TRUE;
+ }
+
+ s_vCheckKeyTableValid(pDevice,pTable);
+ return bReturnValue;
+
+
+}
+
+
+/*
+ * 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 (
+ PVOID pDeviceHandler,
+ PSKeyManagement pTable,
+ PBYTE pbyBSSID
+ )
+{
+ PSDevice pDevice = (PSDevice) pDeviceHandler;
+ 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(pDevice, pTable);
+ 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 (
+ PVOID pDeviceHandler,
+ PSKeyManagement pTable,
+ DWORD dwKeyIndex
+ )
+{
+ PSDevice pDevice = (PSDevice) pDeviceHandler;
+
+ 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(pDevice, pTable);
+ }
+ return;
+}
+
+VOID KeyvRemoveAllWEPKey (
+ PVOID pDeviceHandler,
+ PSKeyManagement pTable
+ )
+{
+ PSDevice pDevice = (PSDevice) pDeviceHandler;
+
+ int i;
+
+ for(i=0;i<MAX_GROUP_KEY;i++) {
+ KeyvRemoveWEPKey(pDevice,pTable, i);
+ }
+
+}
+
+/*
+ * 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);
+
+ DBG_PRT(MSG_LEVEL_DEBUG, KERN_INFO"KeybGetTransmitKey:");
+ DBG_PRT(MSG_LEVEL_DEBUG, KERN_INFO"PAIRWISE_KEY: KeyTable.abyBSSID: ");
+ for (ii = 0; ii < 6; ii++) {
+ DBG_PRT(MSG_LEVEL_DEBUG, KERN_INFO"%x ", pTable->KeyTable[i].abyBSSID[ii]);
+ }
+ DBG_PRT(MSG_LEVEL_DEBUG, KERN_INFO"\n");
+
+
+ return (TRUE);
+ }
+ else {
+ DBG_PRT(MSG_LEVEL_DEBUG, KERN_INFO"PairwiseKey.bKeyValid == FALSE\n");
+ return (FALSE);
+ }
+ } // End of Type == PAIRWISE
+ else {
+ if (pTable->KeyTable[i].dwGTKeyIndex == 0) {
+ DBG_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)]);
+
+ DBG_PRT(MSG_LEVEL_DEBUG, KERN_INFO"KeybGetTransmitKey:");
+ DBG_PRT(MSG_LEVEL_DEBUG, KERN_INFO"GROUP_KEY: KeyTable.abyBSSID\n");
+ for (ii = 0; ii < 6; ii++) {
+ DBG_PRT(MSG_LEVEL_DEBUG, KERN_INFO"%x ", pTable->KeyTable[i].abyBSSID[ii]);
+ }
+ DBG_PRT(MSG_LEVEL_DEBUG, KERN_INFO"\n");
+ DBG_PRT(MSG_LEVEL_DEBUG, KERN_INFO"dwGTKeyIndex: %lX\n", pTable->KeyTable[i].dwGTKeyIndex);
+
+ return (TRUE);
+ }
+ else {
+ DBG_PRT(MSG_LEVEL_DEBUG, KERN_INFO"GroupKey.bKeyValid == FALSE\n");
+ return (FALSE);
+ }
+ } // End of Type = GROUP
+ } // BSSID match
+ }
+ DBG_PRT(MSG_LEVEL_DEBUG, KERN_INFO"ERROR: NO Match BSSID !!! ");
+ for (ii = 0; ii < 6; ii++) {
+ DBG_PRT(MSG_LEVEL_DEBUG, KERN_INFO"%02x ", *(pbyBSSID+ii));
+ }
+ DBG_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 (
+ PVOID pDeviceHandler,
+ PSKeyManagement pTable,
+ DWORD dwKeyIndex,
+ ULONG uKeyLength,
+ PQWORD pKeyRSC,
+ PBYTE pbyKey,
+ BYTE byKeyDecMode
+ )
+{
+ PSDevice pDevice = (PSDevice) pDeviceHandler;
+ UINT ii;
+ PSKeyItem pKey;
+ UINT uKeyIdx;
+
+ DBG_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;
+ DBG_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(pDevice, pTable->KeyTable[MAX_KEY_TABLE-1].wKeyCtl, MAX_KEY_TABLE-1, uKeyIdx, pTable->KeyTable[MAX_KEY_TABLE-1].abyBSSID, (PDWORD) pKey->abyKey);
+
+ 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;
+
+
+ DBG_PRT(MSG_LEVEL_DEBUG, KERN_INFO"KeybSetKey(R): \n");
+ DBG_PRT(MSG_LEVEL_DEBUG, KERN_INFO"pKey->bKeyValid: %d\n", pKey->bKeyValid);
+ DBG_PRT(MSG_LEVEL_DEBUG, KERN_INFO"pKey->uKeyLength: %d\n", (int)pKey->uKeyLength);
+ DBG_PRT(MSG_LEVEL_DEBUG, KERN_INFO"pKey->abyKey: \n");
+ for (ii = 0; ii < pKey->uKeyLength; ii++) {
+ DBG_PRT(MSG_LEVEL_DEBUG, KERN_INFO"%x", pKey->abyKey[ii]);
+ }
+ DBG_PRT(MSG_LEVEL_DEBUG, KERN_INFO"\n");
+
+ DBG_PRT(MSG_LEVEL_DEBUG, KERN_INFO"pKey->dwTSC47_16: %lx\n", pKey->dwTSC47_16);
+ DBG_PRT(MSG_LEVEL_DEBUG, KERN_INFO"pKey->wTSC15_0: %x\n", pKey->wTSC15_0);
+ DBG_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 (
+ PVOID pDeviceHandler,
+ PSKeyManagement pTable,
+ DWORD dwKeyIndex,
+ ULONG uKeyLength,
+ PQWORD pKeyRSC,
+ PBYTE pbyKey,
+ BYTE byKeyDecMode
+ )
+{
+ PSDevice pDevice = (PSDevice) pDeviceHandler;
+ int i;
+ UINT ii;
+ PSKeyItem pKey;
+ UINT uKeyIdx;
+
+ DBG_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;
+ DBG_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(pDevice, pTable->KeyTable[i].wKeyCtl, i, uKeyIdx, pTable->KeyTable[i].abyBSSID, (PDWORD) pKey->abyKey);
+
+ 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;
+
+ DBG_PRT(MSG_LEVEL_DEBUG, KERN_INFO"KeybSetKey(R): \n");
+ DBG_PRT(MSG_LEVEL_DEBUG, KERN_INFO"pKey->bKeyValid: %d\n ", pKey->bKeyValid);
+ DBG_PRT(MSG_LEVEL_DEBUG, KERN_INFO"pKey->uKeyLength: %d\n ", (int)pKey->uKeyLength);
+ DBG_PRT(MSG_LEVEL_DEBUG, KERN_INFO"pKey->abyKey: ");
+ for (ii = 0; ii < pKey->uKeyLength; ii++) {
+ DBG_PRT(MSG_LEVEL_DEBUG, KERN_INFO"%02x ", pKey->abyKey[ii]);
+ }
+ DBG_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/vt6656/key.h b/drivers/staging/vt6656/key.h
new file mode 100644
index 000000000000..6777406df02b
--- /dev/null
+++ b/drivers/staging/vt6656/key.h
@@ -0,0 +1,196 @@
+/*
+ * 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;
+ WORD wKeyCtl;
+ BOOL bSoftWEP;
+ BYTE byReserved1[6];
+} SKeyTable, DEF* PSKeyTable; //352
+
+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(PVOID pDeviceHandler, PSKeyManagement pTable);
+
+BOOL KeybGetKey(
+ IN PSKeyManagement pTable,
+ IN PBYTE pbyBSSID,
+ IN DWORD dwKeyIndex,
+ OUT PSKeyItem *pKey
+ );
+
+BOOL KeybSetKey(
+ PVOID pDeviceHandler,
+ PSKeyManagement pTable,
+ PBYTE pbyBSSID,
+ DWORD dwKeyIndex,
+ ULONG uKeyLength,
+ PQWORD pKeyRSC,
+ PBYTE pbyKey,
+ BYTE byKeyDecMode
+ );
+
+BOOL KeybRemoveKey(
+ PVOID pDeviceHandler,
+ PSKeyManagement pTable,
+ PBYTE pbyBSSID,
+ DWORD dwKeyIndex
+ );
+
+BOOL KeybRemoveAllKey (
+ PVOID pDeviceHandler,
+ PSKeyManagement pTable,
+ PBYTE pbyBSSID
+ );
+
+VOID KeyvRemoveWEPKey(
+ PVOID pDeviceHandler,
+ PSKeyManagement pTable,
+ DWORD dwKeyIndex
+ );
+
+VOID KeyvRemoveAllWEPKey(
+ PVOID pDeviceHandler,
+ PSKeyManagement pTable
+ );
+
+BOOL KeybGetTransmitKey(
+ IN PSKeyManagement pTable,
+ IN PBYTE pbyBSSID,
+ IN DWORD dwKeyType,
+ OUT PSKeyItem *pKey
+ );
+
+BOOL KeybCheckPairewiseKey(
+ IN PSKeyManagement pTable,
+ OUT PSKeyItem *pKey
+ );
+
+BOOL KeybSetDefaultKey (
+ PVOID pDeviceHandler,
+ PSKeyManagement pTable,
+ DWORD dwKeyIndex,
+ ULONG uKeyLength,
+ PQWORD pKeyRSC,
+ PBYTE pbyKey,
+ BYTE byKeyDecMode
+ );
+
+BOOL KeybSetAllGroupKey (
+ PVOID pDeviceHandler,
+ PSKeyManagement pTable,
+ DWORD dwKeyIndex,
+ ULONG uKeyLength,
+ PQWORD pKeyRSC,
+ PBYTE pbyKey,
+ BYTE byKeyDecMode
+ );
+
+
+#ifdef __cplusplus
+} /* End of extern "C" { */
+
+#endif /* __cplusplus */
+
+
+#endif // __KEY_H__
+
diff --git a/drivers/staging/vt6656/mac.c b/drivers/staging/vt6656/mac.c
new file mode 100644
index 000000000000..ff83ef4afa90
--- /dev/null
+++ b/drivers/staging/vt6656/mac.c
@@ -0,0 +1,500 @@
+/*
+ * 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:
+ *
+ * Revision History:
+ */
+
+
+
+#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(__DESC_H__)
+#include "desc.h"
+#endif
+#if !defined(__MAC_H__)
+#include "mac.h"
+#endif
+#if !defined(__80211hdr_H__)
+#include "80211hdr.h"
+#endif
+#if !defined(__RNDIS_H__)
+#include "rndis.h"
+#endif
+#if !defined(__CONTROL_H__)
+#include "control.h"
+#endif
+/*--------------------- 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 this hash index into multicast address register bit
+ *
+ * Parameters:
+ * In:
+ * byHashIdx - Hash index to set
+ * Out:
+ * none
+ *
+ * Return Value: none
+ *
+ */
+void MACvSetMultiAddrByHash (PSDevice pDevice, BYTE byHashIdx)
+{
+ UINT uByteIdx;
+ BYTE byBitMask;
+ BYTE pbyData[2];
+
+
+ // calculate byte position
+ uByteIdx = byHashIdx / 8;
+
+ // calculate bit position
+ byBitMask = 1;
+ byBitMask <<= (byHashIdx % 8);
+ // turn on the bit
+
+ pbyData[0] = byBitMask;
+ pbyData[1] = byBitMask;
+
+ CONTROLnsRequestOut(pDevice,
+ MESSAGE_TYPE_WRITE_MASK,
+ (WORD) (MAC_REG_MAR0 + uByteIdx),
+ MESSAGE_REQUEST_MACREG,
+ 2,
+ pbyData);
+}
+
+
+
+/*
+ * Description:
+ * Write MAC Multicast Address Mask
+ *
+ * Parameters:
+ * In:
+ * uByteidx - Index of Mask
+ * byData - Mask Value to write
+ * Out:
+ * none
+ *
+ * Return Value: none
+ *
+ */
+VOID MACvWriteMultiAddr (PSDevice pDevice, UINT uByteIdx, BYTE byData)
+{
+ BYTE byData1;
+
+ byData1 = byData;
+ CONTROLnsRequestOut(pDevice,
+ MESSAGE_TYPE_WRITE,
+ (WORD) (MAC_REG_MAR0 + uByteIdx),
+ MESSAGE_REQUEST_MACREG,
+ 1,
+ &byData1);
+}
+
+
+/*
+ * Description:
+ * Shut Down MAC
+ *
+ * Parameters:
+ * In:
+ * Out:
+ * none
+ *
+ * Return Value: TRUE if success; otherwise FALSE
+ *
+ */
+BOOL MACbShutdown (PSDevice pDevice)
+{
+ CONTROLnsRequestOutAsyn(pDevice,
+ MESSAGE_TYPE_MACSHUTDOWN,
+ 0,
+ 0,
+ 0,
+ NULL
+ );
+ return TRUE;
+}
+
+void MACvSetBBType(PSDevice pDevice,BYTE byType)
+{
+BYTE pbyData[2];
+
+
+ pbyData[0] = byType;
+ pbyData[1] = EnCFG_BBType_MASK;
+
+ CONTROLnsRequestOut(pDevice,
+ MESSAGE_TYPE_WRITE_MASK,
+ MAC_REG_ENCFG0,
+ MESSAGE_REQUEST_MACREG,
+ 2,
+ pbyData
+ );
+}
+
+void MACvSetMISCFifo (PSDevice pDevice, WORD wOffset, DWORD dwData)
+{
+BYTE pbyData[4];
+
+ if (wOffset > 273)
+ return;
+ pbyData[0] = (BYTE)dwData;
+ pbyData[1] = (BYTE)(dwData>>8);
+ pbyData[2] = (BYTE)(dwData>>16);
+ pbyData[3] = (BYTE)(dwData>>24);
+
+ CONTROLnsRequestOut(pDevice,
+ MESSAGE_TYPE_WRITE_MISCFF,
+ wOffset,
+ 0,
+ 4,
+ pbyData
+ );
+}
+
+/*
+ * Description:
+ * Disable the Key Entry by MISCFIFO
+ *
+ * Parameters:
+ * In:
+ * dwIoBase - Base Address for MAC
+ *
+ * Out:
+ * none
+ *
+ * Return Value: none
+ *
+ */
+void MACvDisableKeyEntry (PSDevice pDevice, UINT uEntryIdx)
+{
+WORD wOffset;
+BYTE byData;
+
+
+ byData = (BYTE) uEntryIdx;
+
+ 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);
+
+ //issue write misc fifo command to device
+ CONTROLnsRequestOut(pDevice,
+ MESSAGE_TYPE_CLRKEYENTRY,
+ 0,
+ 0,
+ 1,
+ &byData
+ );
+}
+
+
+/*
+ * Description:
+ * Set the Key by MISCFIFO
+ *
+ * Parameters:
+ * In:
+ * dwIoBase - Base Address for MAC
+ *
+ * Out:
+ * none
+ *
+ * Return Value: none
+ *
+ */
+void MACvSetKeyEntry (PSDevice pDevice, WORD wKeyCtl, UINT uEntryIdx, UINT uKeyIdx, PBYTE pbyAddr, PDWORD pdwKey)
+{
+PBYTE pbyKey;
+WORD wOffset;
+DWORD dwData1,dwData2;
+int ii;
+BYTE pbyData[24];
+
+
+
+
+
+ if ( pDevice->byLocalID <= MAC_REVISION_A1 ) {
+ if ( pDevice->sMgmtObj.byCSSPK == KEY_CTL_CCMP )
+ return;
+ }
+
+ wOffset = MISCFIFO_KEYETRY0;
+ wOffset += (uEntryIdx * MISCFIFO_KEYENTRYSIZE);
+
+ dwData1 = 0;
+ dwData1 |= wKeyCtl;
+ dwData1 <<= 16;
+ dwData1 |= MAKEWORD(*(pbyAddr+4), *(pbyAddr+5));
+
+ DBG_PRT(MSG_LEVEL_DEBUG, KERN_INFO"1. wOffset: %d, Data: %lX, KeyCtl:%X\n", wOffset, dwData1, wKeyCtl);
+
+ //VNSvOutPortW(dwIoBase + MAC_REG_MISCFFNDEX, wOffset);
+ //VNSvOutPortD(dwIoBase + MAC_REG_MISCFFDATA, dwData);
+ //VNSvOutPortW(dwIoBase + MAC_REG_MISCFFCTL, MISCFFCTL_WRITE);
+
+ //wOffset++;
+
+ dwData2 = 0;
+ dwData2 |= *(pbyAddr+3);
+ dwData2 <<= 8;
+ dwData2 |= *(pbyAddr+2);
+ dwData2 <<= 8;
+ dwData2 |= *(pbyAddr+1);
+ dwData2 <<= 8;
+ dwData2 |= *(pbyAddr+0);
+
+ DBG_PRT(MSG_LEVEL_DEBUG, KERN_INFO"2. wOffset: %d, Data: %lX\n", wOffset, dwData2);
+
+ //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
+ DBG_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);
+ }
+*/
+ pbyKey = (PBYTE)pdwKey;
+
+ pbyData[0] = (BYTE)dwData1;
+ pbyData[1] = (BYTE)(dwData1>>8);
+ pbyData[2] = (BYTE)(dwData1>>16);
+ pbyData[3] = (BYTE)(dwData1>>24);
+ pbyData[4] = (BYTE)dwData2;
+ pbyData[5] = (BYTE)(dwData2>>8);
+ pbyData[6] = (BYTE)(dwData2>>16);
+ pbyData[7] = (BYTE)(dwData2>>24);
+ for(ii=8;ii<24;ii++)
+ pbyData[ii] = *pbyKey++;
+
+ CONTROLnsRequestOut(pDevice,
+ MESSAGE_TYPE_SETKEY,
+ wOffset,
+ (WORD)uKeyIdx,
+ 24,
+ pbyData
+ );
+
+
+}
+
+
+void MACvRegBitsOff(PSDevice pDevice, BYTE byRegOfs, BYTE byBits)
+{
+BYTE pbyData[2];
+
+ pbyData[0] = 0;
+ pbyData[1] = byBits;
+
+ CONTROLnsRequestOut(pDevice,
+ MESSAGE_TYPE_WRITE_MASK,
+ byRegOfs,
+ MESSAGE_REQUEST_MACREG,
+ 2,
+ pbyData
+ );
+}
+
+
+void MACvRegBitsOn(PSDevice pDevice, BYTE byRegOfs, BYTE byBits)
+{
+BYTE pbyData[2];
+
+
+ pbyData[0] = byBits;
+ pbyData[1] = byBits;
+
+ CONTROLnsRequestOut(pDevice,
+ MESSAGE_TYPE_WRITE_MASK,
+ byRegOfs,
+ MESSAGE_REQUEST_MACREG,
+ 2,
+ pbyData
+ );
+}
+
+void MACvWriteWord(PSDevice pDevice, BYTE byRegOfs, WORD wData)
+{
+BYTE pbyData[2];
+
+
+ pbyData[0] = (BYTE)(wData & 0xff);
+ pbyData[1] = (BYTE)(wData >> 8);
+
+ CONTROLnsRequestOut(pDevice,
+ MESSAGE_TYPE_WRITE,
+ byRegOfs,
+ MESSAGE_REQUEST_MACREG,
+ 2,
+ pbyData
+ );
+
+}
+
+void MACvWriteBSSIDAddress(PSDevice pDevice, PBYTE pbyEtherAddr)
+{
+BYTE pbyData[6];
+
+
+ pbyData[0] = *((PBYTE)pbyEtherAddr);
+ pbyData[1] = *((PBYTE)pbyEtherAddr+1);
+ pbyData[2] = *((PBYTE)pbyEtherAddr+2);
+ pbyData[3] = *((PBYTE)pbyEtherAddr+3);
+ pbyData[4] = *((PBYTE)pbyEtherAddr+4);
+ pbyData[5] = *((PBYTE)pbyEtherAddr+5);
+
+ CONTROLnsRequestOut(pDevice,
+ MESSAGE_TYPE_WRITE,
+ MAC_REG_BSSID0,
+ MESSAGE_REQUEST_MACREG,
+ 6,
+ pbyData
+ );
+}
+
+void MACvEnableProtectMD(PSDevice pDevice)
+{
+BYTE pbyData[2];
+
+
+ pbyData[0] = EnCFG_ProtectMd;
+ pbyData[1] = EnCFG_ProtectMd;
+
+ CONTROLnsRequestOut(pDevice,
+ MESSAGE_TYPE_WRITE_MASK,
+ MAC_REG_ENCFG0,
+ MESSAGE_REQUEST_MACREG,
+ 2,
+ pbyData
+ );
+}
+
+void MACvDisableProtectMD(PSDevice pDevice)
+{
+BYTE pbyData[2];
+
+
+ pbyData[0] = 0;
+ pbyData[1] = EnCFG_ProtectMd;
+
+ CONTROLnsRequestOut(pDevice,
+ MESSAGE_TYPE_WRITE_MASK,
+ MAC_REG_ENCFG0,
+ MESSAGE_REQUEST_MACREG,
+ 2,
+ pbyData
+ );
+}
+
+void MACvEnableBarkerPreambleMd(PSDevice pDevice)
+{
+BYTE pbyData[2];
+
+
+ pbyData[0] = EnCFG_BarkerPream;
+ pbyData[1] = EnCFG_BarkerPream;
+
+ CONTROLnsRequestOut(pDevice,
+ MESSAGE_TYPE_WRITE_MASK,
+ MAC_REG_ENCFG2,
+ MESSAGE_REQUEST_MACREG,
+ 2,
+ pbyData
+ );
+}
+
+void MACvDisableBarkerPreambleMd(PSDevice pDevice)
+{
+BYTE pbyData[2];
+
+
+ pbyData[0] = 0;
+ pbyData[1] = EnCFG_BarkerPream;
+
+ CONTROLnsRequestOut(pDevice,
+ MESSAGE_TYPE_WRITE_MASK,
+ MAC_REG_ENCFG2,
+ MESSAGE_REQUEST_MACREG,
+ 2,
+ pbyData
+ );
+}
+
+
+void MACvWriteBeaconInterval(PSDevice pDevice, WORD wInterval)
+{
+BYTE pbyData[2];
+
+ pbyData[0] = (BYTE) (wInterval & 0xff);
+ pbyData[1] = (BYTE) (wInterval >> 8);
+
+ CONTROLnsRequestOut(pDevice,
+ MESSAGE_TYPE_WRITE,
+ MAC_REG_BI,
+ MESSAGE_REQUEST_MACREG,
+ 2,
+ pbyData
+ );
+}
diff --git a/drivers/staging/vt6656/mac.h b/drivers/staging/vt6656/mac.h
new file mode 100644
index 000000000000..78ba7fcd9d34
--- /dev/null
+++ b/drivers/staging/vt6656/mac.h
@@ -0,0 +1,458 @@
+/*
+ * 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(__DEVICE_H__)
+#include "device.h"
+#endif
+#if !defined(__TMACRO_H__)
+#include "tmacro.h"
+#endif
+#if !defined(__UMEM_H__)
+#include "umem.h"
+#endif
+
+/*--------------------- Export Definitions -------------------------*/
+
+#define REV_ID_VT3253_A0 0x00
+#define REV_ID_VT3253_A1 0x01
+#define REV_ID_VT3253_B0 0x08
+#define REV_ID_VT3253_B1 0x09
+
+//
+// Registers in the MAC
+//
+#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_USBSUS 0x0F
+
+#define MAC_REG_LOCALID 0x14
+#define MAC_REG_TESTCFG 0x15
+#define MAC_REG_JUMPER0 0x16
+#define MAC_REG_JUMPER1 0x17
+#define MAC_REG_TMCTL 0x18
+#define MAC_REG_TMDATA0 0x1C
+#define MAC_REG_TMDATA1 0x1D
+#define MAC_REG_TMDATA2 0x1E
+#define MAC_REG_TMDATA3 0x1F
+
+// 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_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_ENCFG0 0x4C //
+#define MAC_REG_ENCFG1 0x4D //
+#define MAC_REG_ENCFG2 0x4E //
+
+#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
+#define MAC_REG_ISR1 0x5D
+// 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_SOFTPWRCTL2 0x79 //
+#define MAC_REG_GPIOCTL0 0x7A //
+#define MAC_REG_GPIOCTL1 0x7B //
+
+// MiscFF PIO related
+#define MAC_REG_MISCFFNDEX 0xBC
+#define MAC_REG_MISCFFCTL 0xBE
+#define MAC_REG_MISCFFDATA 0xC0
+
+// MAC Configuration Group
+#define MAC_REG_PAR0 0xC4
+#define MAC_REG_PAR4 0xC8
+#define MAC_REG_BSSID0 0xCC
+#define MAC_REG_BSSID4 0xD0
+#define MAC_REG_MAR0 0xD4
+#define MAC_REG_MAR4 0xD8
+// MAC RSPPKT INFO Group
+#define MAC_REG_RSPINF_B_1 0xDC
+#define MAC_REG_RSPINF_B_2 0xE0
+#define MAC_REG_RSPINF_B_5 0xE4
+#define MAC_REG_RSPINF_B_11 0xE8
+#define MAC_REG_RSPINF_A_6 0xEC
+#define MAC_REG_RSPINF_A_9 0xEE
+#define MAC_REG_RSPINF_A_12 0xF0
+#define MAC_REG_RSPINF_A_18 0xF2
+#define MAC_REG_RSPINF_A_24 0xF4
+#define MAC_REG_RSPINF_A_36 0xF6
+#define MAC_REG_RSPINF_A_48 0xF8
+#define MAC_REG_RSPINF_A_54 0xFA
+#define MAC_REG_RSPINF_A_72 0xFC
+
+
+//
+// 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 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_0 register
+//
+#define EnCFG_BBType_a 0x00
+#define EnCFG_BBType_b 0x01
+#define EnCFG_BBType_g 0x02
+#define EnCFG_BBType_MASK 0x03
+#define EnCFG_ProtectMd 0x20
+
+//
+// Bits in the EnhanceCFG_1 register
+//
+#define EnCFG_BcnSusInd 0x01
+#define EnCFG_BcnSusClr 0x02
+
+//
+// Bits in the EnhanceCFG_2 register
+//
+#define EnCFG_NXTBTTCFPSTR 0x01
+#define EnCFG_BarkerPream 0x02
+#define EnCFG_PktBurstMode 0x04
+
+//
+// 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 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
+
+
+//ISR1
+#define ISR_GPIO3 0x40
+#define ISR_RXNOBUF 0x08
+#define ISR_MIBNEARFULL 0x04
+#define ISR_SOFTINT 0x02
+#define ISR_FETALERR 0x01
+
+#define LEDSTS_STS 0x06
+#define LEDSTS_TMLEN 0x78
+#define LEDSTS_OFF 0x00
+#define LEDSTS_ON 0x02
+#define LEDSTS_SLOW 0x04
+#define LEDSTS_INTER 0x06
+
+//ISR0
+#define ISR_WATCHDOG 0x80
+#define ISR_SOFTTIMER 0x40
+#define ISR_GPIO0 0x20
+#define ISR_TBTT 0x10
+#define ISR_RXDMA0 0x08
+#define ISR_BNTX 0x04
+#define ISR_ACTX 0x01
+
+//
+// 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 0x08 //
+#define SOFTPWRCTL_TXPEINV 0x02 //
+#define SOFTPWRCTL_SWPECTI 0x01 //
+#define SOFTPWRCTL_SWPAPE 0x20 //
+#define SOFTPWRCTL_SWCALEN 0x10 //
+#define SOFTPWRCTL_SWRADIO_PE 0x08 //
+#define SOFTPWRCTL_SWPE2 0x04 //
+#define SOFTPWRCTL_SWPE1 0x02 //
+#define SOFTPWRCTL_SWPE3 0x01 //
+
+//
+// Bits in the GPIOCTL1 register
+//
+#define GPIO3_MD 0x20 //
+#define GPIO3_DATA 0x40 //
+#define GPIO3_INTMD 0x80 //
+
+//
+// Bits in the MISCFFCTL register
+//
+#define MISCFFCTL_WRITE 0x0001 //
+
+
+// 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
+
+// max time out delay time
+#define W_MAX_TIMEOUT 0xFFF0U //
+
+// wait time within loop
+#define CB_DELAY_LOOP_WAIT 10 // 10ms
+
+#define MAC_REVISION_A0 0x00
+#define MAC_REVISION_A1 0x01
+
+
+/*--------------------- Export Types ------------------------------*/
+
+/*--------------------- Export Macros ------------------------------*/
+
+/*--------------------- Export Classes ----------------------------*/
+
+/*--------------------- Export Variables --------------------------*/
+
+/*--------------------- Export Functions --------------------------*/
+#ifdef __cplusplus
+extern "C" { /* Assume C declarations for C++ */
+#endif /* __cplusplus */
+
+void MACvSetMultiAddrByHash (PSDevice pDevice, BYTE byHashIdx);
+VOID MACvWriteMultiAddr (PSDevice pDevice, UINT uByteIdx, BYTE byData);
+BOOL MACbShutdown(PSDevice pDevice);;
+void MACvSetBBType(PSDevice pDevice,BYTE byType);
+void MACvSetMISCFifo (PSDevice pDevice, WORD wOffset, DWORD dwData);
+void MACvDisableKeyEntry(PSDevice pDevice, UINT uEntryIdx);
+void MACvSetKeyEntry(PSDevice pDevice, WORD wKeyCtl, UINT uEntryIdx, UINT uKeyIdx, PBYTE pbyAddr, PDWORD pdwKey);
+
+void MACvRegBitsOff(PSDevice pDevice, BYTE byRegOfs, BYTE byBits);
+void MACvRegBitsOn(PSDevice pDevice, BYTE byRegOfs, BYTE byBits);
+void MACvWriteWord(PSDevice pDevice, BYTE byRegOfs, WORD wData);
+
+void MACvWriteBSSIDAddress(PSDevice pDevice, PBYTE pbyEtherAddr);
+void MACvEnableProtectMD(PSDevice pDevice);
+void MACvDisableProtectMD(PSDevice pDevice);
+void MACvEnableBarkerPreambleMd(PSDevice pDevice);
+void MACvDisableBarkerPreambleMd(PSDevice pDevice);
+void MACvWriteBeaconInterval(PSDevice pDevice, WORD wInterval);
+
+#ifdef __cplusplus
+} /* End of extern "C" { */
+#endif /* __cplusplus */
+
+#endif // __MAC_H__
diff --git a/drivers/staging/vt6656/main_usb.c b/drivers/staging/vt6656/main_usb.c
new file mode 100644
index 000000000000..8a6814d667d4
--- /dev/null
+++ b/drivers/staging/vt6656/main_usb.c
@@ -0,0 +1,2256 @@
+/*
+ * 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: main_usb.c
+ *
+ * Purpose: driver entry for initial, open, close, tx and rx.
+ *
+ * Author: Lyndon Chen
+ *
+ * Date: Dec 8, 2005
+ *
+ * Functions:
+ *
+ * vntwusb_found1 - module initial (insmod) driver entry
+ * device_remove1 - module remove entry
+ * device_open - allocate dma/descripter resource & initial mac/bbp function
+ * device_xmit - asynchrous data tx function
+ * device_set_multi - set mac filter
+ * device_ioctl - ioctl entry
+ * device_close - shutdown mac/bbp & free dma/descripter resource
+ * device_alloc_frag_buf - rx fragement pre-allocated function
+ * device_free_tx_bufs - free tx buffer function
+ * device_dma0_tx_80211- tx 802.11 frame via dma0
+ * device_dma0_xmit- tx PS bufferred frame via dma0
+ * 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_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(__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(__IOCMD_H__)
+#include "iocmd.h"
+#endif
+#if !defined(__DATARATE_H__)
+#include "datarate.h"
+#endif
+#if !defined(__RF_H__)
+#include "rf.h"
+#endif
+#if !defined(__FIRMWARE_H__)
+#include "firmware.h"
+#endif
+
+#if !defined(__MAC_H__)
+#include "mac.h"
+#endif
+
+#if !defined(__RNDIS_H__)
+#include "rndis.h"
+#endif
+#if !defined(__CONTROL_H__)
+#include "control.h"
+#endif
+#if !defined (_CHANNEL_H_)
+#include "channel.h"
+#endif
+#if !defined(__INT_H__)
+#include "int.h"
+#endif
+#if !defined(__IOWPA_H__)
+#include "iowpa.h"
+#endif
+
+/*--------------------- Static Definitions -------------------------*/
+//static int msglevel =MSG_LEVEL_DEBUG;
+static int msglevel =MSG_LEVEL_INFO;
+
+//
+// Define module options
+//
+
+// Version Information
+#define DRIVER_AUTHOR "VIA Networking Technologies, Inc., <lyndonchen@vntek.com.tw>"
+MODULE_AUTHOR(DRIVER_AUTHOR);
+MODULE_LICENSE("GPL");
+MODULE_DESCRIPTION(DEVICE_FULL_DRV_NAM);
+
+#define DEVICE_PARAM(N,D) \
+ static int N[MAX_UINTS]=OPTION_DEFAULT;\
+ module_param_array(N, int, NULL, 0);\
+ MODULE_PARM_DESC(N, D);
+
+#define RX_DESC_MIN0 16
+#define RX_DESC_MAX0 128
+#define RX_DESC_DEF0 64
+DEVICE_PARAM(RxDescriptors0,"Number of receive usb desc buffer");
+
+
+#define TX_DESC_MIN0 16
+#define TX_DESC_MAX0 128
+#define TX_DESC_DEF0 64
+DEVICE_PARAM(TxDescriptors0,"Number of transmit usb desc buffer");
+
+
+#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_MAX 2
+#define OP_MODE_DEF 0
+#define OP_MODE_MIN 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");
+
+
+//
+// Static vars definitions
+//
+
+
+
+static struct usb_device_id vntwusb_table[] = {
+ {USB_DEVICE(VNT_USB_VENDOR_ID, VNT_USB_PRODUCT_ID)},
+ {}
+};
+
+
+
+// Frequency list (map channels to frequencies)
+/*
+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
+ };
+
+
+#ifndef IW_ENCODE_NOKEY
+#define IW_ENCODE_NOKEY 0x0800
+#define IW_ENCODE_MODE (IW_ENCODE_DISABLED | IW_ENCODE_RESTRICTED | IW_ENCODE_OPEN)
+#endif
+
+static const struct iw_handler_def iwctl_handler_def;
+*/
+
+
+
+/*--------------------- Static Functions --------------------------*/
+static int vntwusb_found1(struct usb_interface *intf, const struct usb_device_id *id);
+static void vntwusb_disconnect(struct usb_interface *intf);
+#ifdef CONFIG_PM /* Minimal support for suspend and resume */
+static int vntwusb_suspend(struct usb_interface *intf, pm_message_t message);
+static int vntwusb_resume(struct usb_interface *intf);
+#endif
+static struct net_device_stats *device_get_stats(struct net_device *dev);
+static int device_open(struct net_device *dev);
+static int device_xmit(struct sk_buff *skb, struct net_device *dev);
+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);
+
+static BOOL device_init_registers(PSDevice pDevice, DEVICE_INIT_TYPE InitType);
+static BOOL device_init_defrag_cb(PSDevice pDevice);
+static void device_init_diversity_timer(PSDevice pDevice);
+static int device_dma0_tx_80211(struct sk_buff *skb, struct net_device *dev);
+
+static int ethtool_ioctl(struct net_device *dev, void *useraddr);
+static void device_free_tx_bufs(PSDevice pDevice);
+static void device_free_rx_bufs(PSDevice pDevice);
+static void device_free_int_bufs(PSDevice pDevice);
+static void device_free_frag_bufs(PSDevice pDevice);
+static BOOL device_alloc_bufs(PSDevice pDevice);
+
+static int Read_config_file(PSDevice pDevice);
+static UCHAR *Config_FileOperation(PSDevice pDevice);
+static int Config_FileGetParameter(UCHAR *string, UCHAR *dest,UCHAR *source);
+
+//2008-0714<Add>by Mike Liu
+static BOOL device_release_WPADEV(PSDevice pDevice);
+
+static void usb_device_reset(PSDevice pDevice);
+
+
+
+/*--------------------- Export Variables --------------------------*/
+
+/*--------------------- Export Functions --------------------------*/
+
+
+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->cbTD = TX_DESC_DEF0;
+ pDevice->cbRD = RX_DESC_DEF0;
+ pDevice->uChannel = CHANNEL_DEF;
+ pDevice->wRTSThreshold = RTS_THRESH_DEF;
+ pDevice->wFragmentationThreshold = FRAG_THRESH_DEF;
+ pDevice->byShortRetryLimit = SHORT_RETRY_DEF;
+ pDevice->byLongRetryLimit = LONG_RETRY_DEF;
+ pDevice->wMaxTransmitMSDULifetime = DEFAULT_MSDU_LIFETIME;
+ pDevice->byShortPreamble = PREAMBLE_TYPE_DEF;
+ pDevice->ePSMode = PS_MODE_DEF;
+ pDevice->b11hEnable = X80211h_MODE_DEF;
+ pDevice->eOPMode = OP_MODE_DEF;
+ pDevice->uConnectionRate = DATA_RATE_DEF;
+ if (pDevice->uConnectionRate < RATE_AUTO) pDevice->bFixRate = TRUE;
+ pDevice->byBBType = BBP_TYPE_DEF;
+ pDevice->byPacketType = pDevice->byBBType;
+ pDevice->byAutoFBCtrl = AUTO_FB_0;
+ pDevice->bUpdateBBVGA = TRUE;
+ pDevice->byFOETuning = 0;
+ pDevice->byAutoPwrTunning = 0;
+ pDevice->wCTSDuration = 0;
+ pDevice->byPreambleType = 0;
+ pDevice->bExistSWNetAddr = FALSE;
+// pDevice->bDiversityRegCtlON = TRUE;
+ pDevice->bDiversityRegCtlON = FALSE;
+}
+
+
+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)TimerSQ3Tmax3CallBack;
+ pDevice->TimerSQ3Tmax3.expires = RUN_AT(HZ);
+
+ return;
+}
+
+
+//
+// Initialiation of MAC & BBP registers
+//
+
+static BOOL device_init_registers(PSDevice pDevice, DEVICE_INIT_TYPE InitType)
+{
+ 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};
+ BYTE byAntenna;
+ UINT ii;
+ CMD_CARD_INIT sInitCmd;
+ NTSTATUS ntStatus = STATUS_SUCCESS;
+ RSP_CARD_INIT sInitRsp;
+ PSMgmtObject pMgmt = &(pDevice->sMgmtObj);
+ BYTE byTmp;
+ BYTE byCalibTXIQ = 0;
+ BYTE byCalibTXDC = 0;
+ BYTE byCalibRXIQ = 0;
+
+ DBG_PRT(MSG_LEVEL_DEBUG, KERN_INFO "---->INIbInitAdapter. [%d][%d]\n", InitType, pDevice->byPacketType);
+ spin_lock_irq(&pDevice->lock);
+ if (InitType == DEVICE_INIT_COLD) {
+ 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);
+
+ if ( !FIRMWAREbCheckVersion(pDevice) ) {
+ if (FIRMWAREbDownload(pDevice) == TRUE) {
+ if (FIRMWAREbBrach2Sram(pDevice) == FALSE) {
+ DBG_PRT(MSG_LEVEL_DEBUG, KERN_INFO" FIRMWAREbBrach2Sram fail \n");
+ spin_unlock_irq(&pDevice->lock);
+ return FALSE;
+ }
+ } else {
+
+ DBG_PRT(MSG_LEVEL_DEBUG, KERN_INFO" FIRMWAREbDownload fail \n");
+ spin_unlock_irq(&pDevice->lock);
+ return FALSE;
+ }
+ }
+
+ if ( !BBbVT3184Init(pDevice) ) {
+ DBG_PRT(MSG_LEVEL_DEBUG, KERN_INFO" BBbVT3184Init fail \n");
+ spin_unlock_irq(&pDevice->lock);
+ return FALSE;
+ }
+ }
+
+ sInitCmd.byInitClass = (BYTE)InitType;
+ sInitCmd.bExistSWNetAddr = (BYTE) pDevice->bExistSWNetAddr;
+ for(ii=0;ii<6;ii++)
+ sInitCmd.bySWNetAddr[ii] = pDevice->abyCurrentNetAddr[ii];
+ sInitCmd.byShortRetryLimit = pDevice->byShortRetryLimit;
+ sInitCmd.byLongRetryLimit = pDevice->byLongRetryLimit;
+
+ //issue Card_init command to device
+ ntStatus = CONTROLnsRequestOut(pDevice,
+ MESSAGE_TYPE_CARDINIT,
+ 0,
+ 0,
+ sizeof(CMD_CARD_INIT),
+ (PBYTE) &(sInitCmd));
+
+ if ( ntStatus != STATUS_SUCCESS ) {
+ DBG_PRT(MSG_LEVEL_DEBUG, KERN_INFO" Issue Card init fail \n");
+ spin_unlock_irq(&pDevice->lock);
+ return FALSE;
+ }
+ if (InitType == DEVICE_INIT_COLD) {
+
+ ntStatus = CONTROLnsRequestIn(pDevice,MESSAGE_TYPE_INIT_RSP,0,0,sizeof(RSP_CARD_INIT), (PBYTE) &(sInitRsp));
+
+ if (ntStatus != STATUS_SUCCESS) {
+ DBG_PRT(MSG_LEVEL_DEBUG, KERN_INFO "Cardinit request in status fail!\n");
+ spin_unlock_irq(&pDevice->lock);
+ return FALSE;
+ }
+
+ //Local ID for AES functions
+ ntStatus = CONTROLnsRequestIn(pDevice,
+ MESSAGE_TYPE_READ,
+ MAC_REG_LOCALID,
+ MESSAGE_REQUEST_MACREG,
+ 1,
+ &pDevice->byLocalID);
+
+ if ( ntStatus != STATUS_SUCCESS ) {
+ spin_unlock_irq(&pDevice->lock);
+ return FALSE;
+ }
+
+ // Do MACbSoftwareReset in MACvInitialize
+ // force CCK
+ pDevice->bCCK = TRUE;
+ pDevice->bProtectMode = FALSE; //Only used in 11g type, sync with ERP IE
+ pDevice->bNonERPPresent = FALSE;
+ pDevice->bBarkerPreambleMd = FALSE;
+ if ( pDevice->bFixRate ) {
+ pDevice->wCurrentRate = (WORD) pDevice->uConnectionRate;
+ } else {
+ if ( pDevice->byBBType == BB_TYPE_11B )
+ pDevice->wCurrentRate = RATE_11M;
+ else
+ pDevice->wCurrentRate = RATE_54M;
+ }
+
+ CHvInitChannelTable(pDevice);
+
+ pDevice->byTopOFDMBasicRate = RATE_24M;
+ pDevice->byTopCCKBasicRate = RATE_1M;
+ pDevice->byRevId = 0; //Target to IF pin while programming to RF chip.
+ pDevice->byCurPwr = 0xFF;
+
+ pDevice->byCCKPwr = pDevice->abyEEPROM[EEP_OFS_PWR_CCK];
+ pDevice->byOFDMPwrG = pDevice->abyEEPROM[EEP_OFS_PWR_OFDMG];
+ // Load power Table
+ for (ii=0;ii<14;ii++) {
+ pDevice->abyCCKPwrTbl[ii] = pDevice->abyEEPROM[ii + EEP_OFS_CCK_PWR_TBL];
+ if (pDevice->abyCCKPwrTbl[ii] == 0)
+ pDevice->abyCCKPwrTbl[ii] = pDevice->byCCKPwr;
+ pDevice->abyOFDMPwrTbl[ii] = pDevice->abyEEPROM[ii + EEP_OFS_OFDM_PWR_TBL];
+ if (pDevice->abyOFDMPwrTbl[ii] == 0)
+ pDevice->abyOFDMPwrTbl[ii] = pDevice->byOFDMPwrG;
+ }
+
+ //original zonetype is USA,but customize zonetype is europe,
+ // then need recover 12,13 ,14 channel with 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];
+ }
+ }
+
+ //{{ RobertYu: 20041124
+ pDevice->byOFDMPwrA = 0x34; // same as RFbMA2829SelectChannel
+ // Load OFDM A Power Table
+ for (ii=0;ii<CB_MAX_CHANNEL_5G;ii++) { //RobertYu:20041224, bug using CB_MAX_CHANNEL
+ pDevice->abyOFDMAPwrTbl[ii] = pDevice->abyEEPROM[ii + EEP_OFS_OFDMA_PWR_TBL];
+ if (pDevice->abyOFDMAPwrTbl[ii] == 0)
+ pDevice->abyOFDMAPwrTbl[ii] = pDevice->byOFDMPwrA;
+ }
+ //}} RobertYu
+
+ byAntenna = pDevice->abyEEPROM[EEP_OFS_ANTENNA];
+ if (byAntenna & EEP_ANTINV)
+ pDevice->bTxRxAntInv = TRUE;
+ else
+ pDevice->bTxRxAntInv = FALSE;
+
+ byAntenna &= (EEP_ANTENNA_AUX | EEP_ANTENNA_MAIN);
+
+ if (byAntenna == 0) // if not set default is All
+ byAntenna = (EEP_ANTENNA_AUX | EEP_ANTENNA_MAIN);
+
+ if (byAntenna == (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;
+
+ if (pDevice->bDiversityRegCtlON)
+ pDevice->bDiversityEnable = TRUE;
+ else
+ pDevice->bDiversityEnable = FALSE;
+ } else {
+ pDevice->bDiversityEnable = FALSE;
+ pDevice->byAntennaCount = 1;
+ pDevice->dwTxAntennaSel = 0;
+ pDevice->dwRxAntennaSel = 0;
+ if (byAntenna & 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;
+ }
+ }
+ pDevice->ulDiversityNValue = 100*255;
+ pDevice->ulDiversityMValue = 100*16;
+ pDevice->byTMax = 1;
+ pDevice->byTMax2 = 4;
+ pDevice->ulSQ3TH = 0;
+ pDevice->byTMax3 = 64;
+ // -----------------------------------------------------------------
+
+ //Get Auto Fall Back Type
+ pDevice->byAutoFBCtrl = AUTO_FB_0;
+
+ // Set SCAN Time
+ pDevice->uScanTime = WLAN_SCAN_MINITIME;
+
+ // default Auto Mode
+ //pDevice->NetworkType = Ndis802_11Automode;
+ pDevice->eConfigPHYMode = PHY_TYPE_AUTO;
+ pDevice->byBBType = BB_TYPE_11G;
+
+ // initialize BBP registers
+ pDevice->ulTxPower = 25;
+
+ // Get Channel range
+ pDevice->byMinChannel = 1;
+ pDevice->byMaxChannel = CB_MAX_CHANNEL;
+
+ // Get RFType
+ pDevice->byRFType = sInitRsp.byRFType;
+
+ if ((pDevice->byRFType & RF_EMU) != 0) {
+ // force change RevID for VT3253 emu
+ pDevice->byRevId = 0x80;
+ }
+
+ // Load EEPROM calibrated vt3266 parameters
+ if (pDevice->byRFType == RF_VT3226D0) {
+ if((pDevice->abyEEPROM[EEP_OFS_MAJOR_VER] == 0x1) &&
+ (pDevice->abyEEPROM[EEP_OFS_MINOR_VER] >= 0x4)) {
+ byCalibTXIQ = pDevice->abyEEPROM[EEP_OFS_CALIB_TX_IQ];
+ byCalibTXDC = pDevice->abyEEPROM[EEP_OFS_CALIB_TX_DC];
+ byCalibRXIQ = pDevice->abyEEPROM[EEP_OFS_CALIB_RX_IQ];
+ if( (byCalibTXIQ || byCalibTXDC || byCalibRXIQ) ) {
+ ControlvWriteByte(pDevice, MESSAGE_REQUEST_BBREG, 0xFF, 0x03); // CR255, Set BB to support TX/RX IQ and DC compensation Mode
+ ControlvWriteByte(pDevice, MESSAGE_REQUEST_BBREG, 0xFB, byCalibTXIQ); // CR251, TX I/Q Imbalance Calibration
+ ControlvWriteByte(pDevice, MESSAGE_REQUEST_BBREG, 0xFC, byCalibTXDC); // CR252, TX DC-Offset Calibration
+ ControlvWriteByte(pDevice, MESSAGE_REQUEST_BBREG, 0xFD, byCalibRXIQ); // CR253, RX I/Q Imbalance Calibration
+ } else {
+ // turn off BB Calibration compensation
+ ControlvWriteByte(pDevice, MESSAGE_REQUEST_BBREG, 0xFF, 0x0); // CR255
+ }
+ }
+ }
+ pMgmt->eScanType = WMAC_SCAN_PASSIVE;
+ pMgmt->uCurrChannel = pDevice->uChannel;
+ pMgmt->uIBSSChannel = pDevice->uChannel;
+ CARDbSetMediaChannel(pDevice, pMgmt->uCurrChannel);
+
+ // get Permanent network address
+ MEMvCopy(pDevice->abyPermanentNetAddr,&(sInitRsp.byNetAddr[0]),6)
+ MEMvCopy(pDevice->abyCurrentNetAddr, pDevice->abyPermanentNetAddr, U_ETHER_ADDR_LEN);
+
+ // if exist SW network address, use SW network address.
+
+ DBG_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]);
+ }
+
+
+
+ // Set BB and packet type at the same time.
+ // Set Short Slot Time, xIFS, and RSPINF.
+ if (pDevice->byBBType == BB_TYPE_11A) {
+ CARDbAddBasicRate(pDevice, RATE_6M);
+ pDevice->bShortSlotTime = TRUE;
+ } else {
+ CARDbAddBasicRate(pDevice, RATE_1M);
+ pDevice->bShortSlotTime = FALSE;
+ }
+ BBvSetShortSlotTime(pDevice);
+ CARDvSetBSSMode(pDevice);
+
+ if (pDevice->bUpdateBBVGA) {
+ pDevice->byBBVGACurrent = pDevice->abyBBVGA[0];
+ pDevice->byBBVGANew = pDevice->byBBVGACurrent;
+ BBvSetVGAGainOffset(pDevice, pDevice->abyBBVGA[0]);
+ }
+
+ pDevice->byRadioCtl = pDevice->abyEEPROM[EEP_OFS_RADIOCTL];
+ pDevice->bHWRadioOff = FALSE;
+ if ( (pDevice->byRadioCtl & EEP_RADIOCTL_ENABLE) != 0 ) {
+ ntStatus = CONTROLnsRequestIn(pDevice,
+ MESSAGE_TYPE_READ,
+ MAC_REG_GPIOCTL1,
+ MESSAGE_REQUEST_MACREG,
+ 1,
+ &byTmp);
+
+ if ( ntStatus != STATUS_SUCCESS ) {
+ spin_unlock_irq(&pDevice->lock);
+ return FALSE;
+ }
+ if ( (byTmp & GPIO3_DATA) == 0 ) {
+ pDevice->bHWRadioOff = TRUE;
+ MACvRegBitsOn(pDevice,MAC_REG_GPIOCTL1,GPIO3_INTMD);
+ } else {
+ MACvRegBitsOff(pDevice,MAC_REG_GPIOCTL1,GPIO3_INTMD);
+ pDevice->bHWRadioOff = FALSE;
+ }
+
+ } //EEP_RADIOCTL_ENABLE
+
+ ControlvMaskByte(pDevice,MESSAGE_REQUEST_MACREG,MAC_REG_PAPEDELAY,LEDSTS_TMLEN,0x38);
+ ControlvMaskByte(pDevice,MESSAGE_REQUEST_MACREG,MAC_REG_PAPEDELAY,LEDSTS_STS,LEDSTS_SLOW);
+ MACvRegBitsOn(pDevice,MAC_REG_GPIOCTL0,0x01);
+
+ if ((pDevice->bHWRadioOff == TRUE) || (pDevice->bRadioControlOff == TRUE)) {
+ CARDbRadioPowerOff(pDevice);
+ } else {
+ CARDbRadioPowerOn(pDevice);
+ }
+
+ spin_unlock_irq(&pDevice->lock);
+ DBG_PRT(MSG_LEVEL_DEBUG, KERN_INFO"<----INIbInitAdapter Exit\n");
+ return TRUE;
+}
+
+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;
+ pDevice->skb->mac_header = pDevice->skb->data;
+ 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;
+}
+
+#ifdef CONFIG_PM /* Minimal support for suspend and resume */
+static int vntwusb_suspend(struct usb_interface *intf, pm_message_t message)
+{
+ PSDevice pDevice = usb_get_intfdata(intf);
+ struct net_device *dev = pDevice->dev;
+
+ printk("VNTWUSB Suspend Start======>\n");
+if(dev != NULL) {
+ if(pDevice->flags & DEVICE_FLAGS_OPENED)
+ device_close(dev);
+}
+
+ usb_put_dev(interface_to_usbdev(intf));
+ return 0;
+}
+
+static int vntwusb_resume(struct usb_interface *intf)
+{
+ PSDevice pDevice = usb_get_intfdata(intf);
+ struct net_device *dev = pDevice->dev;
+
+ printk("VNTWUSB Resume Start======>\n");
+ if(dev != NULL) {
+ usb_get_dev(interface_to_usbdev(intf));
+ if(!(pDevice->flags & DEVICE_FLAGS_OPENED)) {
+ if(device_open(dev)!=0)
+ printk("VNTWUSB Resume Start======>open fail\n");
+ }
+ }
+ return 0;
+}
+#endif
+
+
+static const struct net_device_ops device_netdev_ops = {
+ .ndo_open = device_open,
+ .ndo_stop = device_close,
+ .ndo_do_ioctl = device_ioctl,
+ .ndo_get_stats = device_get_stats,
+ .ndo_start_xmit = device_xmit,
+ .ndo_set_multicast_list = device_set_multi,
+};
+
+
+static int
+vntwusb_found1(struct usb_interface *intf, const struct usb_device_id *id)
+{
+ BYTE fake_mac[U_ETHER_ADDR_LEN] = {0x00, 0x00, 0x00, 0x00, 0x00, 0x01};//fake MAC address
+ struct usb_device *udev = interface_to_usbdev(intf);
+ int rc = 0;
+ struct net_device *netdev = NULL;
+ PSDevice pDevice = NULL;
+
+
+ printk(KERN_NOTICE "%s Ver. %s\n",DEVICE_FULL_DRV_NAM, DEVICE_VERSION);
+ printk(KERN_NOTICE "Copyright (c) 2004 VIA Networking Technologies, Inc.\n");
+
+ udev = usb_get_dev(udev);
+
+ netdev = alloc_etherdev(sizeof(DEVICE_INFO));
+
+ if (netdev == NULL) {
+ printk(KERN_ERR DEVICE_NAME ": allocate net device failed \n");
+ kfree(pDevice);
+ goto err_nomem;
+ }
+
+ pDevice = netdev_priv(netdev);
+ memset(pDevice, 0, sizeof(DEVICE_INFO));
+
+ pDevice->dev = netdev;
+ pDevice->usb = udev;
+
+ // Set initial settings
+ device_set_options(pDevice);
+ spin_lock_init(&pDevice->lock);
+
+ pDevice->tx_80211 = device_dma0_tx_80211;
+ pDevice->sMgmtObj.pAdapter = (PVOID)pDevice;
+
+ netdev->netdev_ops = &device_netdev_ops;
+
+ netdev->wireless_handlers = (struct iw_handler_def *)&iwctl_handler_def;
+
+ //2008-0623-01<Remark>by MikeLiu
+ //2007-0821-01<Add>by MikeLiu
+ usb_set_intfdata(intf, pDevice);
+ SET_NETDEV_DEV(netdev, &intf->dev);
+ memcpy(pDevice->dev->dev_addr, fake_mac, U_ETHER_ADDR_LEN); //use fake mac address
+ rc = register_netdev(netdev);
+ if (rc != 0) {
+ printk(KERN_ERR DEVICE_NAME " Failed to register netdev\n");
+ free_netdev(netdev);
+ kfree(pDevice);
+ return -ENODEV;
+ }
+ //2008-0623-02<Remark>by MikeLiu
+ //2007-0821-01<Add>by MikeLiu
+ //#if LINUX_VERSION_CODE < KERNEL_VERSION(2,6,21)
+ //usb_set_intfdata(intf, pDevice);
+ //SET_NETDEV_DEV(netdev, &intf->dev);
+ //#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(netdev);
+ kfree(pDevice);
+ }
+
+ usb_device_reset(pDevice);
+
+#ifdef SndEvt_ToAPI
+{
+ union iwreq_data wrqu;
+ memset(&wrqu, 0, sizeof(wrqu));
+ wrqu.data.flags = RT_INSMOD_EVENT_FLAG;
+ wrqu.data.length =IFNAMSIZ;
+ wireless_send_event(pDevice->dev, IWEVCUSTOM, &wrqu, pDevice->dev->name);
+}
+#endif
+
+ return 0;
+
+
+err_nomem:
+ //2008-0922-01<Add>by MikeLiu, decrease usb counter.
+ usb_put_dev(udev);
+
+ return -ENOMEM;
+}
+
+
+static VOID device_free_tx_bufs(PSDevice pDevice) {
+ PUSB_SEND_CONTEXT pTxContext;
+ int ii;
+
+ for (ii = 0; ii < pDevice->cbTD; ii++) {
+
+ pTxContext = pDevice->apTD[ii];
+ //de-allocate URBs
+ if (pTxContext->pUrb) {
+ vntwusb_unlink_urb(pTxContext->pUrb);
+ usb_free_urb(pTxContext->pUrb);
+ }
+ if (pTxContext)
+ kfree(pTxContext);
+ }
+ return;
+}
+
+
+static VOID device_free_rx_bufs(PSDevice pDevice) {
+ PRCB pRCB;
+ int ii;
+
+ for (ii = 0; ii < pDevice->cbRD; ii++) {
+
+ pRCB = pDevice->apRCB[ii];
+ //de-allocate URBs
+ if (pRCB->pUrb) {
+ vntwusb_unlink_urb(pRCB->pUrb);
+ usb_free_urb(pRCB->pUrb);
+ }
+ //de-allocate skb
+ if (pRCB->skb)
+ dev_kfree_skb(pRCB->skb);
+ }
+ if (pDevice->pRCBMem)
+ kfree(pDevice->pRCBMem);
+
+ return;
+}
+
+//2007-1107-02<Add>by MikeLiu
+static void usb_device_reset(PSDevice pDevice)
+{
+ int status;
+ status = usb_reset_device(pDevice->usb);
+ if (status)
+ printk("usb_device_reset fail status=%d\n",status);
+ return ;
+}
+
+static VOID device_free_int_bufs(PSDevice pDevice) {
+
+ if (pDevice->intBuf.pDataBuf != NULL)
+ kfree(pDevice->intBuf.pDataBuf);
+ return;
+}
+
+
+static BOOL device_alloc_bufs(PSDevice pDevice) {
+
+ PUSB_SEND_CONTEXT pTxContext;
+ PRCB pRCB;
+ int ii;
+
+
+ for (ii = 0; ii < pDevice->cbTD; ii++) {
+
+ pTxContext = kmalloc(sizeof(USB_SEND_CONTEXT), GFP_KERNEL);
+ if (pTxContext == NULL) {
+ DBG_PRT(MSG_LEVEL_ERR,KERN_ERR "%s : allocate tx usb context failed\n", pDevice->dev->name);
+ goto free_tx;
+ }
+ pDevice->apTD[ii] = pTxContext;
+ pTxContext->pDevice = (PVOID) pDevice;
+ //allocate URBs
+ pTxContext->pUrb = vntwusb_alloc_urb(0);;
+ if (pTxContext->pUrb == NULL) {
+ DBG_PRT(MSG_LEVEL_ERR,KERN_ERR "alloc tx urb failed\n");
+ goto free_tx;
+ }
+ pTxContext->bBoolInUse = FALSE;
+ }
+
+ // allocate rcb mem
+ pDevice->pRCBMem = kmalloc((sizeof(RCB) * pDevice->cbRD), GFP_KERNEL);
+ if (pDevice->pRCBMem == NULL) {
+ DBG_PRT(MSG_LEVEL_ERR,KERN_ERR "%s : alloc rx usb context failed\n", pDevice->dev->name);
+ goto free_tx;
+ }
+
+
+ pDevice->FirstRecvFreeList = NULL;
+ pDevice->LastRecvFreeList = NULL;
+ pDevice->FirstRecvMngList = NULL;
+ pDevice->LastRecvMngList = NULL;
+ pDevice->NumRecvFreeList = 0;
+ memset(pDevice->pRCBMem, 0, (sizeof(RCB) * pDevice->cbRD));
+ pRCB = (PRCB) pDevice->pRCBMem;
+
+ for (ii = 0; ii < pDevice->cbRD; ii++) {
+
+ pDevice->apRCB[ii] = pRCB;
+ pRCB->pDevice = (PVOID) pDevice;
+ //allocate URBs
+ pRCB->pUrb = vntwusb_alloc_urb(0);
+
+ if (pRCB->pUrb == NULL) {
+ DBG_PRT(MSG_LEVEL_ERR,KERN_ERR" Failed to alloc rx urb\n");
+ goto free_rx_tx;
+ }
+ pRCB->skb = dev_alloc_skb((int)pDevice->rx_buf_sz);
+ if (pRCB->skb == NULL) {
+ DBG_PRT(MSG_LEVEL_ERR,KERN_ERR" Failed to alloc rx skb\n");
+ goto free_rx_tx;
+ }
+ pRCB->skb->dev = pDevice->dev;
+ pRCB->bBoolInUse = FALSE;
+ EnqueueRCB(pDevice->FirstRecvFreeList, pDevice->LastRecvFreeList, pRCB);
+ pDevice->NumRecvFreeList++;
+ pRCB++;
+ }
+
+
+ pDevice->pControlURB = vntwusb_alloc_urb(0);
+ if (pDevice->pControlURB == NULL) {
+ DBG_PRT(MSG_LEVEL_ERR,KERN_ERR"Failed to alloc control urb\n");
+ goto free_rx_tx;
+ }
+
+ pDevice->pInterruptURB = vntwusb_alloc_urb(0);
+ if (pDevice->pInterruptURB == NULL) {
+ DBG_PRT(MSG_LEVEL_ERR,KERN_ERR"Failed to alloc int urb\n");
+ vntwusb_unlink_urb(pDevice->pControlURB);
+ usb_free_urb(pDevice->pControlURB);
+ goto free_rx_tx;
+ }
+
+ pDevice->intBuf.pDataBuf = kmalloc(MAX_INTERRUPT_SIZE, GFP_KERNEL);
+ if (pDevice->intBuf.pDataBuf == NULL) {
+ DBG_PRT(MSG_LEVEL_ERR,KERN_ERR"Failed to alloc int buf\n");
+ vntwusb_unlink_urb(pDevice->pControlURB);
+ vntwusb_unlink_urb(pDevice->pInterruptURB);
+ usb_free_urb(pDevice->pControlURB);
+ usb_free_urb(pDevice->pInterruptURB);
+ goto free_rx_tx;
+ }
+
+ return TRUE;
+
+free_rx_tx:
+ device_free_rx_bufs(pDevice);
+
+free_tx:
+ device_free_tx_bufs(pDevice);
+
+ return FALSE;
+}
+
+
+
+
+static BOOL 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)) {
+ DBG_PRT(MSG_LEVEL_ERR,KERN_ERR "%s: can not alloc frag bufs\n",
+ pDevice->dev->name);
+ goto free_frag;
+ };
+ }
+ pDevice->cbDFCB = CB_MAX_RX_FRAG;
+ pDevice->cbFreeDFCB = pDevice->cbDFCB;
+ return TRUE;
+
+free_frag:
+ device_free_frag_bufs(pDevice);
+ return FALSE;
+}
+
+
+
+static void device_free_frag_bufs(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);
+ }
+}
+
+
+
+BOOL device_alloc_frag_buf(PSDevice pDevice, PSDeFragControlBlock pDeF) {
+
+ pDeF->skb = dev_alloc_skb((int)pDevice->rx_buf_sz);
+ if (pDeF->skb == NULL)
+ return FALSE;
+ ASSERT(pDeF->skb);
+ pDeF->skb->dev = pDevice->dev;
+
+ return TRUE;
+}
+
+
+/*-----------------------------------------------------------------*/
+
+static int device_open(struct net_device *dev) {
+ PSDevice pDevice=(PSDevice) netdev_priv(dev);
+
+#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
+
+ DBG_PRT(MSG_LEVEL_DEBUG, KERN_INFO " device_open...\n");
+
+
+ pDevice->rx_buf_sz = MAX_TOTAL_SIZE_WITH_ALL_HEADERS;
+
+ if (device_alloc_bufs(pDevice) == FALSE) {
+ DBG_PRT(MSG_LEVEL_DEBUG, KERN_INFO " device_alloc_bufs fail... \n");
+ return -ENOMEM;
+ }
+
+ if (device_init_defrag_cb(pDevice)== FALSE) {
+ DBG_PRT(MSG_LEVEL_DEBUG, KERN_INFO " Initial defragement cb fail \n");
+ goto free_rx_tx;
+ }
+
+ MP_CLEAR_FLAG(pDevice, fMP_DISCONNECTED);
+ MP_CLEAR_FLAG(pDevice, fMP_CONTROL_READS);
+ MP_CLEAR_FLAG(pDevice, fMP_CONTROL_WRITES);
+ MP_SET_FLAG(pDevice, fMP_POST_READS);
+ MP_SET_FLAG(pDevice, fMP_POST_WRITES);
+
+ //read config file
+ Read_config_file(pDevice);
+
+ if (device_init_registers(pDevice, DEVICE_INIT_COLD) == FALSE) {
+ DBG_PRT(MSG_LEVEL_DEBUG, KERN_INFO " init register fail\n");
+ goto free_all;
+ }
+
+ device_set_multi(pDevice->dev);
+ // Init for Key Management
+
+ KeyvInitTable(pDevice,&pDevice->sKey);
+ memcpy(pDevice->sMgmtObj.abyMACAddr, pDevice->abyCurrentNetAddr, U_ETHER_ADDR_LEN);
+ memcpy(pDevice->dev->dev_addr, pDevice->abyCurrentNetAddr, U_ETHER_ADDR_LEN);
+ pDevice->bStopTx0Pkt = FALSE;
+ pDevice->bStopDataPkt = FALSE;
+ pDevice->bRoaming = FALSE; //DavidWang
+ pDevice->bIsRoaming = FALSE;//DavidWang
+ pDevice->bEnableRoaming = FALSE;
+ if (pDevice->bDiversityRegCtlON) {
+ device_init_diversity_timer(pDevice);
+ }
+
+ vMgrObjectInit(pDevice);
+ tasklet_init(&pDevice->RxMngWorkItem, (void *)RXvMngWorkItem, (unsigned long)pDevice);
+ tasklet_init(&pDevice->ReadWorkItem, (void *)RXvWorkItem, (unsigned long)pDevice);
+ tasklet_init(&pDevice->EventWorkItem, (void *)INTvWorkItem, (unsigned long)pDevice);
+ add_timer(&(pDevice->sMgmtObj.sTimerSecondCallback));
+ pDevice->int_interval = 100; //Max 100 microframes.
+ pDevice->eEncryptionStatus = Ndis802_11EncryptionDisabled;
+
+ pDevice->bIsRxWorkItemQueued = TRUE;
+ pDevice->fKillEventPollingThread = FALSE;
+ pDevice->bEventAvailable = FALSE;
+
+ pDevice->bWPADEVUp = FALSE;
+#ifdef WPA_SUPPLICANT_DRIVER_WEXT_SUPPORT
+ pDevice->bwextstep0 = FALSE;
+ pDevice->bwextstep1 = FALSE;
+ pDevice->bwextstep2 = FALSE;
+ pDevice->bwextstep3 = FALSE;
+ pDevice->bWPASuppWextEnabled = FALSE;
+#endif
+ pDevice->byReAssocCount = 0;
+
+ RXvWorkItem(pDevice);
+ INTvWorkItem(pDevice);
+
+ // Patch: if WEP key already set by iwconfig but device not yet open
+ if ((pDevice->bEncryptionEnable == TRUE) && (pDevice->bTransmitKey == TRUE)) {
+ spin_lock_irq(&pDevice->lock);
+ KeybSetDefaultKey( pDevice,
+ &(pDevice->sKey),
+ pDevice->byKeyIndex | (1 << 31),
+ pDevice->uKeyLength,
+ NULL,
+ pDevice->abyKey,
+ KEY_CTL_WEP
+ );
+ spin_unlock_irq(&pDevice->lock);
+ pDevice->eEncryptionStatus = Ndis802_11Encryption1Enabled;
+ }
+
+ if (pDevice->sMgmtObj.eConfigMode == WMAC_CONFIG_AP) {
+ bScheduleCommand((HANDLE)pDevice, WLAN_CMD_RUN_AP, NULL);
+ }
+ else {
+ //mike:mark@2008-11-10
+ bScheduleCommand((HANDLE)pDevice, WLAN_CMD_BSSID_SCAN, NULL);
+ //bScheduleCommand((HANDLE)pDevice, WLAN_CMD_SSID, NULL);
+ }
+
+
+ netif_stop_queue(pDevice->dev);
+ pDevice->flags |= DEVICE_FLAGS_OPENED;
+
+#ifdef SndEvt_ToAPI
+{
+ union iwreq_data wrqu;
+ memset(&wrqu, 0, sizeof(wrqu));
+ wrqu.data.flags = RT_UPDEV_EVENT_FLAG;
+ wireless_send_event(pDevice->dev, IWEVCUSTOM, &wrqu, NULL);
+}
+#endif
+
+ DBG_PRT(MSG_LEVEL_DEBUG, KERN_INFO "device_open success.. \n");
+ return 0;
+
+free_all:
+ device_free_frag_bufs(pDevice);
+free_rx_tx:
+ device_free_rx_bufs(pDevice);
+ device_free_tx_bufs(pDevice);
+ device_free_int_bufs(pDevice);
+ vntwusb_unlink_urb(pDevice->pControlURB);
+ vntwusb_unlink_urb(pDevice->pInterruptURB);
+ usb_free_urb(pDevice->pControlURB);
+ usb_free_urb(pDevice->pInterruptURB);
+
+ DBG_PRT(MSG_LEVEL_DEBUG, KERN_INFO "device_open fail.. \n");
+ return -ENOMEM;
+}
+
+
+
+static int device_close(struct net_device *dev) {
+ PSDevice pDevice=(PSDevice) netdev_priv(dev);
+ PSMgmtObject pMgmt = &(pDevice->sMgmtObj);
+
+ int uu;
+
+ DBG_PRT(MSG_LEVEL_DEBUG, KERN_INFO "device_close1 \n");
+ if (pDevice == NULL)
+ return -ENODEV;
+
+#ifdef SndEvt_ToAPI
+{
+ union iwreq_data wrqu;
+ memset(&wrqu, 0, sizeof(wrqu));
+ wrqu.data.flags = RT_DOWNDEV_EVENT_FLAG;
+ wireless_send_event(pDevice->dev, IWEVCUSTOM, &wrqu, NULL);
+}
+#endif
+
+//2007-1121-02<Add>by EinsnLiu
+ if (pDevice->bLinkPass) {
+ bScheduleCommand((HANDLE)pDevice, WLAN_CMD_DISASSOCIATE, NULL);
+ mdelay(30);
+ }
+//End Add
+
+//2008-0714-01<Add>by MikeLiu
+device_release_WPADEV(pDevice);
+
+ memset(pMgmt->abyDesireSSID, 0, WLAN_IEHDR_LEN + WLAN_SSID_MAXLEN + 1);
+ pMgmt->bShareKeyAlgorithm = FALSE;
+ pDevice->bEncryptionEnable = FALSE;
+ pDevice->eEncryptionStatus = Ndis802_11EncryptionDisabled;
+ spin_lock_irq(&pDevice->lock);
+ for(uu=0;uu<MAX_KEY_TABLE;uu++)
+ MACvDisableKeyEntry(pDevice,uu);
+ spin_unlock_irq(&pDevice->lock);
+
+ if ((pDevice->flags & DEVICE_FLAGS_UNPLUG) == FALSE) {
+ MACbShutdown(pDevice);
+ }
+ netif_stop_queue(pDevice->dev);
+ MP_SET_FLAG(pDevice, fMP_DISCONNECTED);
+ MP_CLEAR_FLAG(pDevice, fMP_POST_WRITES);
+ MP_CLEAR_FLAG(pDevice, fMP_POST_READS);
+ pDevice->fKillEventPollingThread = TRUE;
+ del_timer(&pDevice->sTimerCommand);
+ del_timer(&pMgmt->sTimerSecondCallback);
+
+//2007-0115-02<Add>by MikeLiu
+#ifdef TxInSleep
+ del_timer(&pDevice->sTimerTxData);
+#endif
+
+ if (pDevice->bDiversityRegCtlON) {
+ del_timer(&pDevice->TimerSQ3Tmax1);
+ del_timer(&pDevice->TimerSQ3Tmax2);
+ del_timer(&pDevice->TimerSQ3Tmax3);
+ }
+ tasklet_kill(&pDevice->RxMngWorkItem);
+ tasklet_kill(&pDevice->ReadWorkItem);
+ tasklet_kill(&pDevice->EventWorkItem);
+
+ pDevice->bRoaming = FALSE; //DavidWang
+ pDevice->bIsRoaming = FALSE;//DavidWang
+ pDevice->bEnableRoaming = FALSE;
+ pDevice->bCmdRunning = FALSE;
+ pDevice->bLinkPass = FALSE;
+ memset(pMgmt->abyCurrBSSID, 0, 6);
+ pMgmt->eCurrState = WMAC_STATE_IDLE;
+
+ device_free_tx_bufs(pDevice);
+ device_free_rx_bufs(pDevice);
+ device_free_int_bufs(pDevice);
+ device_free_frag_bufs(pDevice);
+
+ vntwusb_unlink_urb(pDevice->pControlURB);
+ vntwusb_unlink_urb(pDevice->pInterruptURB);
+ usb_free_urb(pDevice->pControlURB);
+ usb_free_urb(pDevice->pInterruptURB);
+
+ BSSvClearNodeDBTable(pDevice, 0);
+ pDevice->flags &=(~DEVICE_FLAGS_OPENED);
+
+ DBG_PRT(MSG_LEVEL_DEBUG, KERN_INFO "device_close2 \n");
+
+ return 0;
+}
+
+
+static void vntwusb_disconnect(struct usb_interface *intf)
+
+{
+
+ PSDevice pDevice = usb_get_intfdata(intf);
+
+ DBG_PRT(MSG_LEVEL_DEBUG, KERN_INFO "device_disconnect1.. \n");
+ if (pDevice == NULL)
+ return;
+
+#ifdef SndEvt_ToAPI
+{
+ union iwreq_data wrqu;
+ memset(&wrqu, 0, sizeof(wrqu));
+ wrqu.data.flags = RT_RMMOD_EVENT_FLAG;
+ wireless_send_event(pDevice->dev, IWEVCUSTOM, &wrqu, NULL);
+}
+#endif
+
+//2008-0714-01<Add>by MikeLiu
+device_release_WPADEV(pDevice);
+
+ usb_set_intfdata(intf, NULL);
+//2008-0922-01<Add>by MikeLiu, decrease usb counter.
+ usb_put_dev(interface_to_usbdev(intf));
+
+ pDevice->flags |= DEVICE_FLAGS_UNPLUG;
+ if (pDevice->dev != NULL) {
+ DBG_PRT(MSG_LEVEL_DEBUG, KERN_INFO "unregister_netdev..\n");
+ unregister_netdev(pDevice->dev);
+
+//2008-07-21-01<Add>by MikeLiu
+//unregister wpadev
+ if(wpa_set_wpadev(pDevice, 0)!=0)
+ printk("unregister wpadev fail?\n");
+
+ free_netdev(pDevice->dev);
+ }
+
+ kfree(pDevice);
+ DBG_PRT(MSG_LEVEL_DEBUG, KERN_INFO "device_disconnect3.. \n");
+}
+
+
+
+
+static int device_dma0_tx_80211(struct sk_buff *skb, struct net_device *dev) {
+ PSDevice pDevice=netdev_priv(dev);
+ PBYTE pbMPDU;
+ UINT cbMPDULen = 0;
+
+
+ DBG_PRT(MSG_LEVEL_DEBUG, KERN_INFO "device_dma0_tx_80211\n");
+ spin_lock_irq(&pDevice->lock);
+
+ if (pDevice->bStopTx0Pkt == TRUE) {
+ dev_kfree_skb_irq(skb);
+ spin_unlock_irq(&pDevice->lock);
+ return 0;
+ };
+
+
+ cbMPDULen = skb->len;
+ pbMPDU = skb->data;
+
+ vDMA0_tx_80211(pDevice, skb);
+
+ spin_unlock_irq(&pDevice->lock);
+
+ return 0;
+
+}
+
+
+static int device_xmit(struct sk_buff *skb, struct net_device *dev) {
+ PSDevice pDevice=netdev_priv(dev);
+ struct net_device_stats* pStats = &pDevice->stats;
+
+
+ spin_lock_irq(&pDevice->lock);
+
+ netif_stop_queue(pDevice->dev);
+
+ if (pDevice->bLinkPass == FALSE) {
+ dev_kfree_skb_irq(skb);
+ spin_unlock_irq(&pDevice->lock);
+ return 0;
+ }
+ if (pDevice->bStopDataPkt == TRUE) {
+ dev_kfree_skb_irq(skb);
+ pStats->tx_dropped++;
+ spin_unlock_irq(&pDevice->lock);
+ return 0;
+ }
+
+ if(nsDMA_tx_packet(pDevice, TYPE_AC0DMA, skb) !=0) { //mike add:xmit fail!
+ if (netif_queue_stopped(pDevice->dev))
+ netif_wake_queue(pDevice->dev);
+ }
+
+ spin_unlock_irq(&pDevice->lock);
+
+ return 0;
+}
+
+
+
+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;
+}
+
+//find out the start position of str2 from str1
+static UCHAR *kstrstr(const UCHAR *str1,const UCHAR *str2) {
+ int str1_len=strlen(str1);
+ int str2_len=strlen(str2);
+
+ while (str1_len >= str2_len) {
+ str1_len--;
+ if(memcmp(str1,str2,str2_len)==0)
+ return (UCHAR *)str1;
+ str1++;
+ }
+ return NULL;
+}
+
+static int Config_FileGetParameter(UCHAR *string, UCHAR *dest,UCHAR *source)
+{
+ UCHAR buf1[100];
+ UCHAR buf2[100];
+ UCHAR *start_p=NULL,*end_p=NULL,*tmp_p=NULL;
+ int ii;
+
+ memset(buf1,0,100);
+ strcat(buf1, string);
+ strcat(buf1, "=");
+ source+=strlen(buf1);
+
+//find target string start point
+ if((start_p = kstrstr(source,buf1))==NULL)
+ return FALSE;
+
+//check if current config line is marked by "#" ??
+for(ii=1;;ii++) {
+ if(memcmp(start_p-ii,"\n",1)==0)
+ break;
+ if(memcmp(start_p-ii,"#",1)==0)
+ return FALSE;
+}
+
+//find target string end point
+ if((end_p = kstrstr(start_p,"\n"))==NULL) { //cann't find "\n",but don't care
+ end_p=start_p+strlen(start_p); //no include "\n"
+ }
+
+ memset(buf2,0,100);
+ memcpy(buf2,start_p,end_p-start_p); //get the tartget line
+ buf2[end_p-start_p]='\0';
+
+ //find value
+ if((start_p = kstrstr(buf2,"="))==NULL)
+ return FALSE;
+ memset(buf1,0,100);
+ strcpy(buf1,start_p+1);
+
+ //except space
+ tmp_p = buf1;
+ while(*tmp_p != 0x00) {
+ if(*tmp_p==' ')
+ tmp_p++;
+ else
+ break;
+ }
+
+ memcpy(dest,tmp_p,strlen(tmp_p));
+ return TRUE;
+}
+
+//if read fail,return NULL,or return data pointer;
+static UCHAR *Config_FileOperation(PSDevice pDevice) {
+ UCHAR *config_path=CONFIG_PATH;
+ UCHAR *buffer=NULL;
+ 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->fsuid;
+ oldfsgid=current->fsgid;
+ current->fsuid = 0;
+ current->fsgid = 0;
+ */
+
+ //open file
+ filp = filp_open(config_path, O_RDWR, 0);
+ if (IS_ERR(filp)) {
+ printk("Config_FileOperation file Not exist\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;
+ }
+
+error1:
+ if(filp_close(filp,NULL))
+ printk("Config_FileOperation:close file fail\n");
+
+error2:
+ set_fs (old_fs);
+
+ /*
+ current->fsuid=oldfsuid;
+ current->fsgid=oldfsgid;
+ */
+
+if(result!=0) {
+ if(buffer)
+ kfree(buffer);
+ buffer=NULL;
+}
+ return buffer;
+}
+
+//return --->-1:fail; >=0:sucessful
+static int Read_config_file(PSDevice pDevice) {
+ int result=0;
+ UCHAR tmpbuffer[100];
+ UCHAR *buffer=NULL;
+
+ //init config setting
+ pDevice->config_file.ZoneType = -1;
+ pDevice->config_file.eAuthenMode = -1;
+ pDevice->config_file.eEncryptionStatus = -1;
+
+ if((buffer=Config_FileOperation(pDevice)) ==NULL) {
+ result =-1;
+ return result;
+ }
+
+//get zonetype
+{
+ memset(tmpbuffer,0,sizeof(tmpbuffer));
+ if(Config_FileGetParameter("ZONETYPE",tmpbuffer,buffer) ==TRUE) {
+ if(memcmp(tmpbuffer,"USA",3)==0) {
+ pDevice->config_file.ZoneType=ZoneType_USA;
+ }
+ else if(memcmp(tmpbuffer,"JAPAN",5)==0) {
+ pDevice->config_file.ZoneType=ZoneType_Japan;
+ }
+ else if(memcmp(tmpbuffer,"EUROPE",6)==0) {
+ pDevice->config_file.ZoneType=ZoneType_Europe;
+ }
+ else {
+ printk("Unknown Zonetype[%s]?\n",tmpbuffer);
+ }
+ }
+}
+
+#if 1
+//get other parameter
+ {
+ memset(tmpbuffer,0,sizeof(tmpbuffer));
+ if(Config_FileGetParameter("AUTHENMODE",tmpbuffer,buffer)==TRUE) {
+ pDevice->config_file.eAuthenMode = (int) simple_strtol(tmpbuffer, NULL, 10);
+ }
+
+ memset(tmpbuffer,0,sizeof(tmpbuffer));
+ if(Config_FileGetParameter("ENCRYPTIONMODE",tmpbuffer,buffer)==TRUE) {
+ pDevice->config_file.eEncryptionStatus= (int) simple_strtol(tmpbuffer, NULL, 10);
+ }
+ }
+#endif
+
+ kfree(buffer);
+ return result;
+}
+
+static void device_set_multi(struct net_device *dev) {
+ PSDevice pDevice = (PSDevice) netdev_priv(dev);
+ PSMgmtObject pMgmt = &(pDevice->sMgmtObj);
+ u32 mc_filter[2];
+ int ii;
+ struct dev_mc_list *mclist;
+ BYTE pbyData[8] = {0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff};
+ BYTE byTmpMode = 0;
+ int rc;
+
+
+ spin_lock_irq(&pDevice->lock);
+ rc = CONTROLnsRequestIn(pDevice,
+ MESSAGE_TYPE_READ,
+ MAC_REG_RCR,
+ MESSAGE_REQUEST_MACREG,
+ 1,
+ &byTmpMode
+ );
+ if (rc == 0) pDevice->byRxMode = byTmpMode;
+
+ DBG_PRT(MSG_LEVEL_DEBUG, KERN_INFO "pDevice->byRxMode in= %x\n", pDevice->byRxMode);
+
+ if (dev->flags & IFF_PROMISC) { // Set promiscuous.
+ DBG_PRT(MSG_LEVEL_ERR,KERN_NOTICE "%s: Promiscuous mode enabled.\n", dev->name);
+ // Unconditionally log net taps.
+ pDevice->byRxMode |= (RCR_MULTICAST|RCR_BROADCAST|RCR_UNICAST);
+ }
+ else if ((dev->mc_count > pDevice->multicast_limit) || (dev->flags & IFF_ALLMULTI)) {
+ CONTROLnsRequestOut(pDevice,
+ MESSAGE_TYPE_WRITE,
+ MAC_REG_MAR0,
+ MESSAGE_REQUEST_MACREG,
+ 8,
+ pbyData
+ );
+ pDevice->byRxMode |= (RCR_MULTICAST|RCR_BROADCAST);
+ }
+ else {
+ memset(mc_filter, 0, sizeof(mc_filter));
+ for (ii = 0, mclist = dev->mc_list; mclist && ii < dev->mc_count;
+ ii++, mclist = mclist->next) {
+ int bit_nr = ether_crc(ETH_ALEN, mclist->dmi_addr) >> 26;
+ mc_filter[bit_nr >> 5] |= cpu_to_le32(1 << (bit_nr & 31));
+ }
+ for (ii = 0; ii < 4; ii++) {
+ MACvWriteMultiAddr(pDevice, ii, *((PBYTE)&mc_filter[0] + ii));
+ MACvWriteMultiAddr(pDevice, ii+ 4, *((PBYTE)&mc_filter[1] + ii));
+ }
+ 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);
+ }
+ ControlvWriteByte(pDevice, MESSAGE_REQUEST_MACREG, MAC_REG_RCR, pDevice->byRxMode);
+ DBG_PRT(MSG_LEVEL_DEBUG, KERN_INFO "pDevice->byRxMode out= %x\n", pDevice->byRxMode);
+ spin_unlock_irq(&pDevice->lock);
+
+}
+
+
+static struct net_device_stats *device_get_stats(struct net_device *dev) {
+ PSDevice pDevice=(PSDevice) netdev_priv(dev);
+
+ return &pDevice->stats;
+}
+
+
+static int device_ioctl(struct net_device *dev, struct ifreq *rq, int cmd) {
+ PSDevice pDevice = (PSDevice)netdev_priv(dev);
+ PSMgmtObject pMgmt = &(pDevice->sMgmtObj);
+ PSCmdRequest pReq;
+ //BOOL bCommit = FALSE;
+ struct iwreq *wrq = (struct iwreq *) rq;
+ int rc =0;
+
+ if (pMgmt == NULL) {
+ rc = -EFAULT;
+ return rc;
+ }
+
+ switch(cmd) {
+
+ case SIOCGIWNAME:
+ rc = iwctl_giwname(dev, NULL, (char *)&(wrq->u.name), NULL);
+ break;
+
+ case SIOCSIWNWID:
+ rc = -EOPNOTSUPP;
+ 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:
+ DBG_PRT(MSG_LEVEL_DEBUG, KERN_INFO " SIOCSIWNICKN \n");
+ rc = -EOPNOTSUPP;
+ break;
+
+ // Get current station name
+ case SIOCGIWNICKN:
+ DBG_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;
+
+ // Get the current Tx-Power
+ case SIOCGIWTXPOW:
+ DBG_PRT(MSG_LEVEL_DEBUG, KERN_INFO " SIOCGIWTXPOW \n");
+ rc = -EOPNOTSUPP;
+ break;
+
+ case SIOCSIWTXPOW:
+ DBG_PRT(MSG_LEVEL_DEBUG, KERN_INFO " SIOCGIWTXPOW \n");
+ rc = -EOPNOTSUPP;
+ break;
+
+ case SIOCSIWRETRY:
+
+ rc = iwctl_siwretry(dev, NULL, &(wrq->u.retry), NULL);
+ break;
+
+ case SIOCGIWRETRY:
+
+ rc = iwctl_giwretry(dev, NULL, &(wrq->u.retry), NULL);
+ break;
+
+ // 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:
+ DBG_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:
+
+ DBG_PRT(MSG_LEVEL_DEBUG, KERN_INFO " SIOCSIWSPY \n");
+ rc = -EOPNOTSUPP;
+ break;
+
+ // Get the spy list
+ case SIOCGIWSPY:
+
+ DBG_PRT(MSG_LEVEL_DEBUG, KERN_INFO " SIOCSIWSPY \n");
+ rc = -EOPNOTSUPP;
+ break;
+
+#endif // WIRELESS_SPY
+
+ case SIOCGIWPRIV:
+ DBG_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;
+
+
+//2008-0409-07, <Add> by Einsn Liu
+#ifdef WPA_SUPPLICANT_DRIVER_WEXT_SUPPORT
+ case SIOCSIWAUTH:
+ DBG_PRT(MSG_LEVEL_DEBUG, KERN_INFO " SIOCSIWAUTH \n");
+ rc = iwctl_siwauth(dev, NULL, &(wrq->u.param), NULL);
+ break;
+
+ case SIOCGIWAUTH:
+ DBG_PRT(MSG_LEVEL_DEBUG, KERN_INFO " SIOCGIWAUTH \n");
+ rc = iwctl_giwauth(dev, NULL, &(wrq->u.param), NULL);
+ break;
+
+ case SIOCSIWGENIE:
+ DBG_PRT(MSG_LEVEL_DEBUG, KERN_INFO " SIOCSIWGENIE \n");
+ rc = iwctl_siwgenie(dev, NULL, &(wrq->u.data), wrq->u.data.pointer);
+ break;
+
+ case SIOCGIWGENIE:
+ DBG_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];
+ DBG_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:
+ DBG_PRT(MSG_LEVEL_DEBUG, KERN_INFO " SIOCGIWENCODEEXT \n");
+ rc = iwctl_giwencodeext(dev, NULL, &(wrq->u.encoding), NULL);
+ break;
+
+ case SIOCSIWMLME:
+ DBG_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
+
+ case IOCTL_CMD_TEST:
+
+ if (!(pDevice->flags & DEVICE_FLAGS_OPENED)) {
+ rc = -EFAULT;
+ break;
+ } else {
+ rc = 0;
+ }
+ pReq = (PSCmdRequest)rq;
+
+ //20080130-01,<Remark> by Mike Liu
+ // if(pDevice->bLinkPass==TRUE)
+ pReq->wResult = MAGIC_CODE; //Linking status:0x3142
+ //20080130-02,<Remark> by Mike Liu
+ // else
+ // pReq->wResult = MAGIC_CODE+1; //disconnect status:0x3143
+ break;
+
+ case IOCTL_CMD_SET:
+ if (!(pDevice->flags & DEVICE_FLAGS_OPENED) &&
+ (((PSCmdRequest)rq)->wCmdCode !=WLAN_CMD_SET_WPA))
+ {
+ 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 (!(pDevice->flags & DEVICE_FLAGS_OPENED)) {
+ rc = -EFAULT;
+ break;
+ } else {
+ rc = 0;
+ }
+
+ rc = hostap_ioctl(pDevice, &wrq->u.data);
+ break;
+
+ case IOCTL_CMD_WPA:
+
+ if (!(pDevice->flags & DEVICE_FLAGS_OPENED)) {
+ rc = -EFAULT;
+ break;
+ } else {
+ rc = 0;
+ }
+
+ rc = wpa_ioctl(pDevice, &wrq->u.data);
+ break;
+
+ case SIOCETHTOOL:
+ return ethtool_ioctl(dev, (void *) rq->ifr_data);
+ // All other calls are currently unsupported
+
+ default:
+ rc = -EOPNOTSUPP;
+ DBG_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 {
+ DBG_PRT(MSG_LEVEL_DEBUG, KERN_INFO "Commit the settings\n");
+ spin_lock_irq(&pDevice->lock);
+//2007-1121-01<Modify>by EinsnLiu
+ if (pDevice->bLinkPass&&
+ memcmp(pMgmt->abyCurrSSID,pMgmt->abyDesireSSID,WLAN_IEHDR_LEN + WLAN_SSID_MAXLEN)) {
+ bScheduleCommand((HANDLE)pDevice, WLAN_CMD_DISASSOCIATE, NULL);
+ } else {
+ pDevice->bLinkPass = FALSE;
+ pMgmt->eCurrState = WMAC_STATE_IDLE;
+ memset(pMgmt->abyCurrBSSID, 0, 6);
+ }
+ ControlvMaskByte(pDevice,MESSAGE_REQUEST_MACREG,MAC_REG_PAPEDELAY,LEDSTS_STS,LEDSTS_SLOW);
+//End Modify
+ 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;
+}
+
+
+/*------------------------------------------------------------------*/
+
+
+MODULE_DEVICE_TABLE(usb, vntwusb_table);
+
+
+static struct usb_driver vntwusb_driver = {
+ .name = DEVICE_NAME,
+ .probe = vntwusb_found1,
+ .disconnect = vntwusb_disconnect,
+ .id_table = vntwusb_table,
+
+//2008-0920-01<Add>by MikeLiu
+//for supporting S3 & S4 function
+#ifdef CONFIG_PM
+ .suspend = vntwusb_suspend,
+ .resume = vntwusb_resume,
+#endif
+};
+
+static int __init vntwusb_init_module(void)
+{
+ printk(KERN_NOTICE DEVICE_FULL_DRV_NAM " " DEVICE_VERSION);
+ return usb_register(&vntwusb_driver);
+}
+
+static void __exit vntwusb_cleanup_module(void)
+{
+ usb_deregister(&vntwusb_driver);
+}
+
+module_init(vntwusb_init_module);
+module_exit(vntwusb_cleanup_module);
+
diff --git a/drivers/staging/vt6656/mib.c b/drivers/staging/vt6656/mib.c
new file mode 100644
index 000000000000..35b6c2be170f
--- /dev/null
+++ b/drivers/staging/vt6656/mib.c
@@ -0,0 +1,592 @@
+/*
+ * 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, BYTE byIsr0, BYTE byIsr1)
+{
+ /**********************/
+ /* ABNORMAL interrupt */
+ /**********************/
+ // not any IMR bit invoke irq
+ if (byIsr0 == 0) {
+ pStatistic->ISRStat.dwIsrUnknown++;
+ return;
+ }
+
+
+ if (BITbIsBitOn(byIsr0, ISR_ACTX)) // ISR, bit0
+ pStatistic->ISRStat.dwIsrTx0OK++; // TXDMA0 successful
+
+ if (BITbIsBitOn(byIsr0, ISR_BNTX)) // ISR, bit2
+ pStatistic->ISRStat.dwIsrBeaconTxOK++; // BeaconTx successful
+
+ if (BITbIsBitOn(byIsr0, ISR_RXDMA0)) // ISR, bit3
+ pStatistic->ISRStat.dwIsrRx0OK++; // Rx0 successful
+
+ if (BITbIsBitOn(byIsr0, ISR_TBTT)) // ISR, bit4
+ pStatistic->ISRStat.dwIsrTBTTInt++; // TBTT successful
+
+ if (BITbIsBitOn(byIsr0, ISR_SOFTTIMER)) // ISR, bit6
+ pStatistic->ISRStat.dwIsrSTIMERInt++;
+
+ if (BITbIsBitOn(byIsr0, ISR_WATCHDOG)) // ISR, bit7
+ pStatistic->ISRStat.dwIsrWatchDog++;
+
+
+ if (BITbIsBitOn(byIsr1, ISR_FETALERR)) // ISR, bit8
+ pStatistic->ISRStat.dwIsrUnrecoverableError++;
+
+ if (BITbIsBitOn(byIsr1, ISR_SOFTINT)) // ISR, bit9
+ pStatistic->ISRStat.dwIsrSoftInterrupt++; // software interrupt
+
+ if (BITbIsBitOn(byIsr1, ISR_MIBNEARFULL)) // ISR, bit10
+ pStatistic->ISRStat.dwIsrMIBNearfull++;
+
+ if (BITbIsBitOn(byIsr1, ISR_RXNOBUF)) // ISR, bit11
+ pStatistic->ISRStat.dwIsrRxNoBuf++; // Rx No Buff
+
+}
+
+
+/*
+ * 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 byRxSts, 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++;
+ }
+ DBG_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++;
+ }
+ DBG_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++;
+ }
+ DBG_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++;
+ }
+ DBG_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++;
+ }
+ DBG_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++;
+ }
+ DBG_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++;
+ }
+ DBG_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++;
+ }
+ DBG_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++;
+ }
+ DBG_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++;
+ }
+ DBG_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++;
+ }
+ DBG_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++;
+ }
+ DBG_PRT(MSG_LEVEL_DEBUG, KERN_INFO"54M: ALL[%d], OK[%d]\n", (INT)pStatistic->CustomStat.ullRsr54M, (INT)pStatistic->CustomStat.ullRsr54MCRCOk);
+ }
+ else {
+ DBG_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)) || BITbIsBitOff(byRSR, RSR_CRCOK))
+ 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 byRxSts,
+ BYTE byRxRate,
+ PBYTE pbyBuffer,
+ UINT cbFrameLength
+ )
+{
+ STAvUpdateRDStatCounter(
+ pStatistic,
+ byRSR,
+ byNewRSR,
+ byRxSts,
+ 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 byPktNum,
+ BYTE byRate,
+ BYTE byTSR
+ )
+{
+ BYTE byRetyCnt;
+ // increase tx packet count
+ pStatistic->dwTsrTxPacket++;
+
+ byRetyCnt = (byTSR & 0xF0) >> 4;
+ if (byRetyCnt != 0) {
+ pStatistic->dwTsrRetry++;
+ pStatistic->dwTsrTotalRetry += byRetyCnt;
+ pStatistic->dwTxFail[byRate]+= byRetyCnt;
+ pStatistic->dwTxFail[MAX_RATE] += byRetyCnt;
+
+ if ( byRetyCnt == 0x1)
+ pStatistic->dwTsrOnceRetry++;
+ else
+ pStatistic->dwTsrMoreThanOnceRetry++;
+
+ if (byRetyCnt <= 8)
+ pStatistic->dwTxRetryCount[byRetyCnt-1]++;
+
+ }
+ if (BITbIsAllBitsOff(byTSR, (TSR_TMO | TSR_RETRYTMO))) {
+
+#ifdef Calcu_LinkQual
+ if (byRetyCnt < 2)
+ pStatistic->TxNoRetryOkCount ++;
+ else
+ pStatistic->TxRetryOkCount ++;
+#endif
+
+ pStatistic->ullTsrOK++;
+ pStatistic->CustomStat.ullTsrAllOK++;
+ // update counters in case that successful transmit
+ pStatistic->dwTxOk[byRate]++;
+ pStatistic->dwTxOk[MAX_RATE]++;
+
+ if ( pStatistic->abyTxPktInfo[byPktNum].byBroadMultiUni == TX_PKT_BROAD ) {
+ pStatistic->ullTxBroadcastFrames++;
+ pStatistic->ullTxBroadcastBytes += pStatistic->abyTxPktInfo[byPktNum].wLength;
+ } else if ( pStatistic->abyTxPktInfo[byPktNum].byBroadMultiUni == TX_PKT_MULTI ) {
+ pStatistic->ullTxMulticastFrames++;
+ pStatistic->ullTxMulticastBytes += pStatistic->abyTxPktInfo[byPktNum].wLength;
+ } else if ( pStatistic->abyTxPktInfo[byPktNum].byBroadMultiUni == TX_PKT_UNI ) {
+ pStatistic->ullTxDirectedFrames++;
+ pStatistic->ullTxDirectedBytes += pStatistic->abyTxPktInfo[byPktNum].wLength;
+ }
+ }
+ else {
+
+#ifdef Calcu_LinkQual
+ pStatistic->TxFailCount ++;
+#endif
+
+ pStatistic->dwTsrErr++;
+ if (BITbIsBitOn(byTSR, TSR_RETRYTMO))
+ pStatistic->dwTsrRetryTimeout++;
+ if (BITbIsBitOn(byTSR, TSR_TMO))
+ pStatistic->dwTsrTransmitTimeout++;
+ }
+
+ if ( pStatistic->abyTxPktInfo[byPktNum].byBroadMultiUni == TX_PKT_BROAD ) {
+ pStatistic->dwTsrBroadcast++;
+ } else if ( pStatistic->abyTxPktInfo[byPktNum].byBroadMultiUni == TX_PKT_MULTI ) {
+ pStatistic->dwTsrMulticast++;
+ } else if ( pStatistic->abyTxPktInfo[byPktNum].byBroadMultiUni == TX_PKT_UNI ) {
+ pStatistic->dwTsrDirected++;
+ }
+}
+
+
+
+/*
+ * 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,
+ BYTE byRTSSuccess,
+ BYTE byRTSFail,
+ BYTE byACKFail,
+ BYTE byFCSErr
+ )
+{
+ //p802_11Counter->TransmittedFragmentCount
+ p802_11Counter->MulticastTransmittedFrameCount = (ULONGLONG) (pStatistic->dwTsrBroadcast +
+ pStatistic->dwTsrMulticast);
+ p802_11Counter->FailedCount = (ULONGLONG) (pStatistic->dwTsrErr);
+ p802_11Counter->RetryCount = (ULONGLONG) (pStatistic->dwTsrRetry);
+ p802_11Counter->MultipleRetryCount = (ULONGLONG) (pStatistic->dwTsrMoreThanOnceRetry);
+ //p802_11Counter->FrameDuplicateCount
+ p802_11Counter->RTSSuccessCount += (ULONGLONG) byRTSSuccess;
+ p802_11Counter->RTSFailureCount += (ULONGLONG) byRTSFail;
+ p802_11Counter->ACKFailureCount += (ULONGLONG) byACKFail;
+ p802_11Counter->FCSErrorCount += (ULONGLONG) byFCSErr;
+ //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));
+}
+
+/*
+ * Description: Clear 802.11 mib counter
+ *
+ * Parameters:
+ * In:
+ * pUsbCounter - Pointer to USB mib counter
+ * ntStatus - URB status
+ * Out:
+ * none
+ *
+ * Return Value: none
+ *
+ */
+
+void
+STAvUpdateUSBCounter(PSUSBCounter pUsbCounter,
+ NTSTATUS ntStatus
+ )
+{
+
+// if ( ntStatus == USBD_STATUS_CRC ) {
+ pUsbCounter->dwCrc++;
+// }
+
+}
+
+
diff --git a/drivers/staging/vt6656/mib.h b/drivers/staging/vt6656/mib.h
new file mode 100644
index 000000000000..6a11012dda19
--- /dev/null
+++ b/drivers/staging/vt6656/mib.h
@@ -0,0 +1,445 @@
+/*
+ * 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 -------------------------*/
+
+
+//
+// USB counter
+//
+typedef struct tagSUSBCounter {
+ DWORD dwCrc;
+
+} SUSBCounter, DEF* PSUSBCounter;
+
+
+
+//
+// 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 //
+
+
+//
+// Tx packet information
+//
+typedef struct tagSTxPktInfo {
+ BYTE byBroadMultiUni;
+ WORD wLength;
+ WORD wFIFOCtl;
+ BYTE abyDestAddr[U_ETHER_ADDR_LEN];
+} STxPktInfo, DEF* PSTxPktInfo;
+
+
+#define MAX_RATE 12
+//
+// statistic counter
+//
+typedef struct tagSStatCounter {
+ //
+ // ISR status count
+ //
+
+ SISRCounters ISRStat;
+
+ // 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; // total collision retry count
+ DWORD dwTsrOnceRetry; // this packet only occur one collision
+ DWORD dwTsrMoreThanOnceRetry; // this packet occur more than one collision
+ DWORD dwTsrRetry; // this packet has ever occur collision,
+ // that is (dwTsrOnceCollision0 + dwTsrMoreThanOnceCollision0)
+ DWORD dwTsrACKData;
+ DWORD dwTsrErr;
+ DWORD dwAllTsrOK;
+ DWORD dwTsrRetryTimeout;
+ DWORD dwTsrTransmitTimeout;
+
+ DWORD dwTsrTxPacket;
+ DWORD dwTsrTxOctet;
+ DWORD dwTsrBroadcast;
+ DWORD dwTsrMulticast;
+ DWORD dwTsrDirected;
+
+ // 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
+
+
+ // 64-bit OID
+ ULONGLONG ullTsrOK;
+
+ // for some optional OIDs (64 bits) and DMI support
+ ULONGLONG ullTxBroadcastFrames;
+ ULONGLONG ullTxMulticastFrames;
+ ULONGLONG ullTxDirectedFrames;
+ ULONGLONG ullTxBroadcastBytes;
+ ULONGLONG ullTxMulticastBytes;
+ ULONGLONG ullTxDirectedBytes;
+
+ // for autorate
+ DWORD dwTxOk[MAX_RATE+1];
+ DWORD dwTxFail[MAX_RATE+1];
+ DWORD dwTxRetryCount[8];
+
+ STxPktInfo abyTxPktInfo[16];
+
+ SUSBCounter USB_EP0Stat;
+ SUSBCounter USB_BulkInStat;
+ SUSBCounter USB_BulkOutStat;
+ SUSBCounter USB_InterruptStat;
+
+ 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;
+
+#define NTSTATUS int
+
+/*--------------------- 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, BYTE byIsr0, BYTE byIsr1);
+
+void STAvUpdateRDStatCounter(PSStatCounter pStatistic,
+ BYTE byRSR, BYTE byNewRSR, BYTE byRxSts, BYTE byRxRate,
+ PBYTE pbyBuffer, UINT cbFrameLength);
+
+void STAvUpdateRDStatCounterEx(PSStatCounter pStatistic,
+ BYTE byRSR, BYTE byNewRSR, BYTE byRxSts, BYTE byRxRate,
+ PBYTE pbyBuffer, UINT cbFrameLength);
+
+
+void
+STAvUpdateTDStatCounter (
+ PSStatCounter pStatistic,
+ BYTE byPktNum,
+ BYTE byRate,
+ BYTE byTSR
+ );
+
+
+void
+STAvUpdate802_11Counter(
+ PSDot11Counters p802_11Counter,
+ PSStatCounter pStatistic,
+ BYTE byRTSSuccess,
+ BYTE byRTSFail,
+ BYTE byACKFail,
+ BYTE byFCSErr
+ );
+
+void STAvClear802_11Counter(PSDot11Counters p802_11Counter);
+
+void
+STAvUpdateUSBCounter(
+ PSUSBCounter pUsbCounter,
+ NTSTATUS ntStatus
+ );
+
+#ifdef __cplusplus
+} /* End of extern "C" { */
+#endif /* __cplusplus */
+
+
+
+
+#endif // __MIB_H__
+
+
+
diff --git a/drivers/staging/vt6656/michael.c b/drivers/staging/vt6656/michael.c
new file mode 100644
index 000000000000..7bda4c19e903
--- /dev/null
+++ b/drivers/staging/vt6656/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/vt6656/michael.h b/drivers/staging/vt6656/michael.h
new file mode 100644
index 000000000000..62a24a6083aa
--- /dev/null
+++ b/drivers/staging/vt6656/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/vt6656/power.c b/drivers/staging/vt6656/power.c
new file mode 100644
index 000000000000..b522b21b7438
--- /dev/null
+++ b/drivers/staging/vt6656/power.c
@@ -0,0 +1,458 @@
+/*
+ * 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
+#if !defined(__CONTROL_H__)
+#include "control.h"
+#endif
+#if !defined(__RNDIS_H__)
+#include "rndis.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->sMgmtObj);
+ WORD wAID = pMgmt->wCurrAID | BIT14 | BIT15;
+
+ // set period of power up before TBTT
+ MACvWriteWord(pDevice, MAC_REG_PWBT, C_PWBT);
+
+ if (pDevice->eOPMode != OP_MODE_ADHOC) {
+ // set AID
+ MACvWriteWord(pDevice, MAC_REG_AIDATIM, wAID);
+ } else {
+ // set ATIM Window
+ //MACvWriteATIMW(pDevice->PortOffset, pMgmt->wCurrATIMWindow);
+ }
+
+ //Warren:06-18-2004,the sequence must follow PSEN->AUTOSLEEP->GO2DOZE
+ // enable power saving hw function
+ MACvRegBitsOn(pDevice, MAC_REG_PSCTL, PSCTL_PSEN);
+ // Set AutoSleep
+ MACvRegBitsOn(pDevice, MAC_REG_PSCFG, PSCFG_AUTOSLEEP);
+
+ //Warren:MUST turn on this once before turn on AUTOSLEEP ,or the AUTOSLEEP doesn't work
+ MACvRegBitsOn(pDevice, MAC_REG_PSCTL, PSCTL_GO2DOZE);
+
+
+ if (wListenInterval >= 2) {
+
+ // clear always listen beacon
+ MACvRegBitsOff(pDevice, MAC_REG_PSCTL, PSCTL_ALBCN);
+ // first time set listen next beacon
+ MACvRegBitsOn(pDevice, MAC_REG_PSCTL, PSCTL_LNBCN);
+
+ pMgmt->wCountToWakeUp = wListenInterval;
+
+ }
+ else {
+
+ // always listen beacon
+ MACvRegBitsOn(pDevice, MAC_REG_PSCTL, PSCTL_ALBCN);
+ pMgmt->wCountToWakeUp = 0;
+
+ }
+
+ 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;
+ DBG_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->sMgmtObj);
+
+
+ // disable power saving hw function
+ CONTROLnsRequestOut(pDevice,
+ MESSAGE_TYPE_DISABLE_PS,
+ 0,
+ 0,
+ 0,
+ NULL
+ );
+
+ //clear AutoSleep
+ MACvRegBitsOff(pDevice, MAC_REG_PSCFG, PSCFG_AUTOSLEEP);
+
+ // set always listen beacon
+ MACvRegBitsOn(pDevice, 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->sMgmtObj);
+ BYTE byData;
+
+
+ // check if already in Doze mode
+ ControlvReadByte(pDevice, MESSAGE_REQUEST_MACREG, MAC_REG_PSCTL, &byData);
+ if ( (byData & PSCTL_PS) != 0 )
+ 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;
+
+ //Tx Burst
+ if ( pDevice->bPSModeTxBurst )
+ return FALSE;
+
+ // Froce PSEN on
+ MACvRegBitsOn(pDevice, MAC_REG_PSCTL, PSCTL_PSEN);
+
+ if (pMgmt->eCurrMode != WMAC_MODE_IBSS_STA) {
+ if (bCheckCountToWakeUp &&
+ (pMgmt->wCountToWakeUp == 0 || pMgmt->wCountToWakeUp == 1)) {
+ return FALSE;
+ }
+ }
+
+ pDevice->bPSRxBeacon = TRUE;
+ // no Tx, no Rx isr, now go to Doze
+ MACvRegBitsOn(pDevice, MAC_REG_PSCTL, PSCTL_GO2DOZE);
+
+ DBG_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->sMgmtObj);
+ 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) {
+ DBG_PRT(MSG_LEVEL_DEBUG, KERN_INFO "Send PS-Poll packet failed..\n");
+ }
+ else {
+// DBG_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->sMgmtObj);
+
+
+
+ if (pDevice->bLinkPass == FALSE) {
+ return FALSE;
+ }
+
+//2007-0115-03<Add>by MikeLiu
+#ifdef TxInSleep
+ if ((pDevice->bEnablePSMode == FALSE) &&
+ (pDevice->fTxDataInSleep == FALSE)){
+ return FALSE;
+ }
+#else
+ if (pDevice->bEnablePSMode == FALSE) {
+ return FALSE;
+ }
+#endif
+ 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) {
+ DBG_PRT(MSG_LEVEL_DEBUG, KERN_INFO "Send Null Packet failed !\n");
+ return FALSE;
+ }
+ else {
+// DBG_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->sMgmtObj);
+ 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, MAC_REG_PSCTL, PSCTL_LNBCN);
+ pDevice->bPSRxBeacon = FALSE;
+ bWakeUp = TRUE;
+
+ } else if ( !pDevice->bPSRxBeacon ) {
+ //Listen until RxBeacon
+ MACvRegBitsOn(pDevice, MAC_REG_PSCTL, PSCTL_LNBCN);
+ }
+
+ }
+
+ return bWakeUp;
+}
+
diff --git a/drivers/staging/vt6656/power.h b/drivers/staging/vt6656/power.h
new file mode 100644
index 000000000000..c33c93a86f5e
--- /dev/null
+++ b/drivers/staging/vt6656/power.h
@@ -0,0 +1,84 @@
+/*
+ * 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/vt6656/rc4.c b/drivers/staging/vt6656/rc4.c
new file mode 100644
index 000000000000..5ad12a3746c0
--- /dev/null
+++ b/drivers/staging/vt6656/rc4.c
@@ -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: rc4.c
+ *
+ * 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/vt6656/rc4.h b/drivers/staging/vt6656/rc4.h
new file mode 100644
index 000000000000..4e3ccc559c8f
--- /dev/null
+++ b/drivers/staging/vt6656/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/vt6656/rf.c b/drivers/staging/vt6656/rf.c
new file mode 100644
index 000000000000..53b854646526
--- /dev/null
+++ b/drivers/staging/vt6656/rf.c
@@ -0,0 +1,1163 @@
+/*
+ * 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(__RF_H__)
+#include "rf.h"
+#endif
+#if !defined(__BASEBAND_H__)
+#include "baseband.h"
+#endif
+#if !defined(__CONTROL_H__)
+#include "control.h"
+#endif
+#if !defined(__RNDIS_H__)
+#include "rndis.h"
+#endif
+#if !defined(__DATARATE_H__)
+#include "datarate.h"
+#endif
+
+static int msglevel =MSG_LEVEL_INFO;
+//static int msglevel =MSG_LEVEL_DEBUG;
+/*--------------------- Static Definitions -------------------------*/
+#define BY_AL2230_REG_LEN 23 //24bit
+#define CB_AL2230_INIT_SEQ 15
+#define AL2230_PWR_IDX_LEN 64
+
+#define BY_AL7230_REG_LEN 23 //24bit
+#define CB_AL7230_INIT_SEQ 16
+#define AL7230_PWR_IDX_LEN 64
+
+//{{RobertYu:20051111
+#define BY_VT3226_REG_LEN 23
+#define CB_VT3226_INIT_SEQ 11
+#define VT3226_PWR_IDX_LEN 64
+//}}
+
+//{{RobertYu:20060609
+#define BY_VT3342_REG_LEN 23
+#define CB_VT3342_INIT_SEQ 13
+#define VT3342_PWR_IDX_LEN 64
+//}}
+
+/*--------------------- Static Classes ----------------------------*/
+
+/*--------------------- Static Variables --------------------------*/
+
+
+
+
+BYTE abyAL2230InitTable[CB_AL2230_INIT_SEQ][3] = {
+ {0x03, 0xF7, 0x90},
+ {0x03, 0x33, 0x31},
+ {0x01, 0xB8, 0x02},
+ {0x00, 0xFF, 0xF3},
+ {0x00, 0x05, 0xA4},
+ {0x0F, 0x4D, 0xC5}, //RobertYu:20060814
+ {0x08, 0x05, 0xB6},
+ {0x01, 0x47, 0xC7},
+ {0x00, 0x06, 0x88},
+ {0x04, 0x03, 0xB9},
+ {0x00, 0xDB, 0xBA},
+ {0x00, 0x09, 0x9B},
+ {0x0B, 0xDF, 0xFC},
+ {0x00, 0x00, 0x0D},
+ {0x00, 0x58, 0x0F}
+ };
+
+BYTE abyAL2230ChannelTable0[CB_MAX_CHANNEL_24G][3] = {
+ {0x03, 0xF7, 0x90}, // channel = 1, Tf = 2412MHz
+ {0x03, 0xF7, 0x90}, // channel = 2, Tf = 2417MHz
+ {0x03, 0xE7, 0x90}, // channel = 3, Tf = 2422MHz
+ {0x03, 0xE7, 0x90}, // channel = 4, Tf = 2427MHz
+ {0x03, 0xF7, 0xA0}, // channel = 5, Tf = 2432MHz
+ {0x03, 0xF7, 0xA0}, // channel = 6, Tf = 2437MHz
+ {0x03, 0xE7, 0xA0}, // channel = 7, Tf = 2442MHz
+ {0x03, 0xE7, 0xA0}, // channel = 8, Tf = 2447MHz
+ {0x03, 0xF7, 0xB0}, // channel = 9, Tf = 2452MHz
+ {0x03, 0xF7, 0xB0}, // channel = 10, Tf = 2457MHz
+ {0x03, 0xE7, 0xB0}, // channel = 11, Tf = 2462MHz
+ {0x03, 0xE7, 0xB0}, // channel = 12, Tf = 2467MHz
+ {0x03, 0xF7, 0xC0}, // channel = 13, Tf = 2472MHz
+ {0x03, 0xE7, 0xC0} // channel = 14, Tf = 2412M
+ };
+
+BYTE abyAL2230ChannelTable1[CB_MAX_CHANNEL_24G][3] = {
+ {0x03, 0x33, 0x31}, // channel = 1, Tf = 2412MHz
+ {0x0B, 0x33, 0x31}, // channel = 2, Tf = 2417MHz
+ {0x03, 0x33, 0x31}, // channel = 3, Tf = 2422MHz
+ {0x0B, 0x33, 0x31}, // channel = 4, Tf = 2427MHz
+ {0x03, 0x33, 0x31}, // channel = 5, Tf = 2432MHz
+ {0x0B, 0x33, 0x31}, // channel = 6, Tf = 2437MHz
+ {0x03, 0x33, 0x31}, // channel = 7, Tf = 2442MHz
+ {0x0B, 0x33, 0x31}, // channel = 8, Tf = 2447MHz
+ {0x03, 0x33, 0x31}, // channel = 9, Tf = 2452MHz
+ {0x0B, 0x33, 0x31}, // channel = 10, Tf = 2457MHz
+ {0x03, 0x33, 0x31}, // channel = 11, Tf = 2462MHz
+ {0x0B, 0x33, 0x31}, // channel = 12, Tf = 2467MHz
+ {0x03, 0x33, 0x31}, // channel = 13, Tf = 2472MHz
+ {0x06, 0x66, 0x61} // channel = 14, Tf = 2412M
+ };
+
+// 40MHz reference frequency
+// Need to Pull PLLON(PE3) low when writing channel registers through 3-wire.
+BYTE abyAL7230InitTable[CB_AL7230_INIT_SEQ][3] = {
+ {0x20, 0x37, 0x90}, // Channel1 // Need modify for 11a
+ {0x13, 0x33, 0x31}, // Channel1 // Need modify for 11a
+ {0x84, 0x1F, 0xF2}, // Need modify for 11a: 451FE2
+ {0x3F, 0xDF, 0xA3}, // Need modify for 11a: 5FDFA3
+ {0x7F, 0xD7, 0x84}, // 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
+ {0x80, 0x2B, 0x55}, // Need modify for 11a: 8D1B55
+ {0x56, 0xAF, 0x36},
+ {0xCE, 0x02, 0x07}, // Need modify for 11a: 860207
+ {0x6E, 0xBC, 0x98},
+ {0x22, 0x1B, 0xB9},
+ {0xE0, 0x00, 0x0A}, // Need modify for 11a: E0600A
+ {0x08, 0x03, 0x1B}, // 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
+ {0x00, 0x0A, 0x3C}, // Need modify for 11a: 00143C
+ {0xFF, 0xFF, 0xFD},
+ {0x00, 0x00, 0x0E},
+ {0x1A, 0xBA, 0x8F} // Need modify for 11a: 12BACF
+ };
+
+BYTE abyAL7230InitTableAMode[CB_AL7230_INIT_SEQ][3] = {
+ {0x2F, 0xF5, 0x20}, // Channel184 // Need modify for 11b/g
+ {0x00, 0x00, 0x01}, // Channel184 // Need modify for 11b/g
+ {0x45, 0x1F, 0xE2}, // Need modify for 11b/g
+ {0x5F, 0xDF, 0xA3}, // Need modify for 11b/g
+ {0x6F, 0xD7, 0x84}, // 11a // Need modify for 11b/g
+ {0x85, 0x3F, 0x55}, // Need modify for 11b/g, RoberYu:20050113
+ {0x56, 0xAF, 0x36},
+ {0xCE, 0x02, 0x07}, // Need modify for 11b/g
+ {0x6E, 0xBC, 0x98},
+ {0x22, 0x1B, 0xB9},
+ {0xE0, 0x60, 0x0A}, // Need modify for 11b/g
+ {0x08, 0x03, 0x1B}, // init 0x080B1B00 => 0x080F1B00 for 3 wire control TxGain(D10)
+ {0x00, 0x14, 0x7C}, // Need modify for 11b/g
+ {0xFF, 0xFF, 0xFD},
+ {0x00, 0x00, 0x0E},
+ {0x12, 0xBA, 0xCF} // Need modify for 11b/g
+ };
+
+BYTE abyAL7230ChannelTable0[CB_MAX_CHANNEL][3] = {
+ {0x20, 0x37, 0x90}, // channel = 1, Tf = 2412MHz
+ {0x20, 0x37, 0x90}, // channel = 2, Tf = 2417MHz
+ {0x20, 0x37, 0x90}, // channel = 3, Tf = 2422MHz
+ {0x20, 0x37, 0x90}, // channel = 4, Tf = 2427MHz
+ {0x20, 0x37, 0xA0}, // channel = 5, Tf = 2432MHz
+ {0x20, 0x37, 0xA0}, // channel = 6, Tf = 2437MHz
+ {0x20, 0x37, 0xA0}, // channel = 7, Tf = 2442MHz
+ {0x20, 0x37, 0xA0}, // channel = 8, Tf = 2447MHz //RobertYu: 20050218, update for APNode 0.49
+ {0x20, 0x37, 0xB0}, // channel = 9, Tf = 2452MHz //RobertYu: 20050218, update for APNode 0.49
+ {0x20, 0x37, 0xB0}, // channel = 10, Tf = 2457MHz //RobertYu: 20050218, update for APNode 0.49
+ {0x20, 0x37, 0xB0}, // channel = 11, Tf = 2462MHz //RobertYu: 20050218, update for APNode 0.49
+ {0x20, 0x37, 0xB0}, // channel = 12, Tf = 2467MHz //RobertYu: 20050218, update for APNode 0.49
+ {0x20, 0x37, 0xC0}, // channel = 13, Tf = 2472MHz //RobertYu: 20050218, update for APNode 0.49
+ {0x20, 0x37, 0xC0}, // channel = 14, Tf = 2484MHz
+
+ // 4.9G => Ch 183, 184, 185, 187, 188, 189, 192, 196 (Value:15 ~ 22)
+ {0x0F, 0xF5, 0x20}, // channel = 183, Tf = 4915MHz (15)
+ {0x2F, 0xF5, 0x20}, // channel = 184, Tf = 4920MHz (16)
+ {0x0F, 0xF5, 0x20}, // channel = 185, Tf = 4925MHz (17)
+ {0x0F, 0xF5, 0x20}, // channel = 187, Tf = 4935MHz (18)
+ {0x2F, 0xF5, 0x20}, // channel = 188, Tf = 4940MHz (19)
+ {0x0F, 0xF5, 0x20}, // channel = 189, Tf = 4945MHz (20)
+ {0x2F, 0xF5, 0x30}, // channel = 192, Tf = 4960MHz (21)
+ {0x2F, 0xF5, 0x30}, // 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)
+
+ {0x0F, 0xF5, 0x40}, // channel = 7, Tf = 5035MHz (23)
+ {0x2F, 0xF5, 0x40}, // channel = 8, Tf = 5040MHz (24)
+ {0x0F, 0xF5, 0x40}, // channel = 9, Tf = 5045MHz (25)
+ {0x0F, 0xF5, 0x40}, // channel = 11, Tf = 5055MHz (26)
+ {0x2F, 0xF5, 0x40}, // channel = 12, Tf = 5060MHz (27)
+ {0x2F, 0xF5, 0x50}, // channel = 16, Tf = 5080MHz (28)
+ {0x2F, 0xF5, 0x60}, // channel = 34, Tf = 5170MHz (29)
+ {0x2F, 0xF5, 0x60}, // channel = 36, Tf = 5180MHz (30)
+ {0x2F, 0xF5, 0x70}, // channel = 38, Tf = 5190MHz (31) //RobertYu: 20050218, update for APNode 0.49
+ {0x2F, 0xF5, 0x70}, // channel = 40, Tf = 5200MHz (32)
+ {0x2F, 0xF5, 0x70}, // channel = 42, Tf = 5210MHz (33)
+ {0x2F, 0xF5, 0x70}, // channel = 44, Tf = 5220MHz (34)
+ {0x2F, 0xF5, 0x70}, // channel = 46, Tf = 5230MHz (35)
+ {0x2F, 0xF5, 0x70}, // channel = 48, Tf = 5240MHz (36)
+ {0x2F, 0xF5, 0x80}, // channel = 52, Tf = 5260MHz (37)
+ {0x2F, 0xF5, 0x80}, // channel = 56, Tf = 5280MHz (38)
+ {0x2F, 0xF5, 0x80}, // channel = 60, Tf = 5300MHz (39)
+ {0x2F, 0xF5, 0x90}, // channel = 64, Tf = 5320MHz (40)
+
+ {0x2F, 0xF5, 0xC0}, // channel = 100, Tf = 5500MHz (41)
+ {0x2F, 0xF5, 0xC0}, // channel = 104, Tf = 5520MHz (42)
+ {0x2F, 0xF5, 0xC0}, // channel = 108, Tf = 5540MHz (43)
+ {0x2F, 0xF5, 0xD0}, // channel = 112, Tf = 5560MHz (44)
+ {0x2F, 0xF5, 0xD0}, // channel = 116, Tf = 5580MHz (45)
+ {0x2F, 0xF5, 0xD0}, // channel = 120, Tf = 5600MHz (46)
+ {0x2F, 0xF5, 0xE0}, // channel = 124, Tf = 5620MHz (47)
+ {0x2F, 0xF5, 0xE0}, // channel = 128, Tf = 5640MHz (48)
+ {0x2F, 0xF5, 0xE0}, // channel = 132, Tf = 5660MHz (49)
+ {0x2F, 0xF5, 0xF0}, // channel = 136, Tf = 5680MHz (50)
+ {0x2F, 0xF5, 0xF0}, // channel = 140, Tf = 5700MHz (51)
+ {0x2F, 0xF6, 0x00}, // channel = 149, Tf = 5745MHz (52)
+ {0x2F, 0xF6, 0x00}, // channel = 153, Tf = 5765MHz (53)
+ {0x2F, 0xF6, 0x00}, // channel = 157, Tf = 5785MHz (54)
+ {0x2F, 0xF6, 0x10}, // channel = 161, Tf = 5805MHz (55)
+ {0x2F, 0xF6, 0x10} // channel = 165, Tf = 5825MHz (56)
+ };
+
+BYTE abyAL7230ChannelTable1[CB_MAX_CHANNEL][3] = {
+ {0x13, 0x33, 0x31}, // channel = 1, Tf = 2412MHz
+ {0x1B, 0x33, 0x31}, // channel = 2, Tf = 2417MHz
+ {0x03, 0x33, 0x31}, // channel = 3, Tf = 2422MHz
+ {0x0B, 0x33, 0x31}, // channel = 4, Tf = 2427MHz
+ {0x13, 0x33, 0x31}, // channel = 5, Tf = 2432MHz
+ {0x1B, 0x33, 0x31}, // channel = 6, Tf = 2437MHz
+ {0x03, 0x33, 0x31}, // channel = 7, Tf = 2442MHz
+ {0x0B, 0x33, 0x31}, // channel = 8, Tf = 2447MHz
+ {0x13, 0x33, 0x31}, // channel = 9, Tf = 2452MHz
+ {0x1B, 0x33, 0x31}, // channel = 10, Tf = 2457MHz
+ {0x03, 0x33, 0x31}, // channel = 11, Tf = 2462MHz
+ {0x0B, 0x33, 0x31}, // channel = 12, Tf = 2467MHz
+ {0x13, 0x33, 0x31}, // channel = 13, Tf = 2472MHz
+ {0x06, 0x66, 0x61}, // channel = 14, Tf = 2484MHz
+
+ // 4.9G => Ch 183, 184, 185, 187, 188, 189, 192, 196 (Value:15 ~ 22)
+ {0x1D, 0x55, 0x51}, // channel = 183, Tf = 4915MHz (15)
+ {0x00, 0x00, 0x01}, // channel = 184, Tf = 4920MHz (16)
+ {0x02, 0xAA, 0xA1}, // channel = 185, Tf = 4925MHz (17)
+ {0x08, 0x00, 0x01}, // channel = 187, Tf = 4935MHz (18)
+ {0x0A, 0xAA, 0xA1}, // channel = 188, Tf = 4940MHz (19)
+ {0x0D, 0x55, 0x51}, // channel = 189, Tf = 4945MHz (20)
+ {0x15, 0x55, 0x51}, // channel = 192, Tf = 4960MHz (21)
+ {0x00, 0x00, 0x01}, // 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)
+ {0x1D, 0x55, 0x51}, // channel = 7, Tf = 5035MHz (23)
+ {0x00, 0x00, 0x01}, // channel = 8, Tf = 5040MHz (24)
+ {0x02, 0xAA, 0xA1}, // channel = 9, Tf = 5045MHz (25)
+ {0x08, 0x00, 0x01}, // channel = 11, Tf = 5055MHz (26)
+ {0x0A, 0xAA, 0xA1}, // channel = 12, Tf = 5060MHz (27)
+ {0x15, 0x55, 0x51}, // channel = 16, Tf = 5080MHz (28)
+ {0x05, 0x55, 0x51}, // channel = 34, Tf = 5170MHz (29)
+ {0x0A, 0xAA, 0xA1}, // channel = 36, Tf = 5180MHz (30)
+ {0x10, 0x00, 0x01}, // channel = 38, Tf = 5190MHz (31)
+ {0x15, 0x55, 0x51}, // channel = 40, Tf = 5200MHz (32)
+ {0x1A, 0xAA, 0xA1}, // channel = 42, Tf = 5210MHz (33)
+ {0x00, 0x00, 0x01}, // channel = 44, Tf = 5220MHz (34)
+ {0x05, 0x55, 0x51}, // channel = 46, Tf = 5230MHz (35)
+ {0x0A, 0xAA, 0xA1}, // channel = 48, Tf = 5240MHz (36)
+ {0x15, 0x55, 0x51}, // channel = 52, Tf = 5260MHz (37)
+ {0x00, 0x00, 0x01}, // channel = 56, Tf = 5280MHz (38)
+ {0x0A, 0xAA, 0xA1}, // channel = 60, Tf = 5300MHz (39)
+ {0x15, 0x55, 0x51}, // channel = 64, Tf = 5320MHz (40)
+ {0x15, 0x55, 0x51}, // channel = 100, Tf = 5500MHz (41)
+ {0x00, 0x00, 0x01}, // channel = 104, Tf = 5520MHz (42)
+ {0x0A, 0xAA, 0xA1}, // channel = 108, Tf = 5540MHz (43)
+ {0x15, 0x55, 0x51}, // channel = 112, Tf = 5560MHz (44)
+ {0x00, 0x00, 0x01}, // channel = 116, Tf = 5580MHz (45)
+ {0x0A, 0xAA, 0xA1}, // channel = 120, Tf = 5600MHz (46)
+ {0x15, 0x55, 0x51}, // channel = 124, Tf = 5620MHz (47)
+ {0x00, 0x00, 0x01}, // channel = 128, Tf = 5640MHz (48)
+ {0x0A, 0xAA, 0xA1}, // channel = 132, Tf = 5660MHz (49)
+ {0x15, 0x55, 0x51}, // channel = 136, Tf = 5680MHz (50)
+ {0x00, 0x00, 0x01}, // channel = 140, Tf = 5700MHz (51)
+ {0x18, 0x00, 0x01}, // channel = 149, Tf = 5745MHz (52)
+ {0x02, 0xAA, 0xA1}, // channel = 153, Tf = 5765MHz (53)
+ {0x0D, 0x55, 0x51}, // channel = 157, Tf = 5785MHz (54)
+ {0x18, 0x00, 0x01}, // channel = 161, Tf = 5805MHz (55)
+ {0x02, 0xAA, 0xB1} // channel = 165, Tf = 5825MHz (56)
+ };
+
+BYTE abyAL7230ChannelTable2[CB_MAX_CHANNEL][3] = {
+ {0x7F, 0xD7, 0x84}, // channel = 1, Tf = 2412MHz
+ {0x7F, 0xD7, 0x84}, // channel = 2, Tf = 2417MHz
+ {0x7F, 0xD7, 0x84}, // channel = 3, Tf = 2422MHz
+ {0x7F, 0xD7, 0x84}, // channel = 4, Tf = 2427MHz
+ {0x7F, 0xD7, 0x84}, // channel = 5, Tf = 2432MHz
+ {0x7F, 0xD7, 0x84}, // channel = 6, Tf = 2437MHz
+ {0x7F, 0xD7, 0x84}, // channel = 7, Tf = 2442MHz
+ {0x7F, 0xD7, 0x84}, // channel = 8, Tf = 2447MHz
+ {0x7F, 0xD7, 0x84}, // channel = 9, Tf = 2452MHz
+ {0x7F, 0xD7, 0x84}, // channel = 10, Tf = 2457MHz
+ {0x7F, 0xD7, 0x84}, // channel = 11, Tf = 2462MHz
+ {0x7F, 0xD7, 0x84}, // channel = 12, Tf = 2467MHz
+ {0x7F, 0xD7, 0x84}, // channel = 13, Tf = 2472MHz
+ {0x7F, 0xD7, 0x84}, // channel = 14, Tf = 2484MHz
+
+ // 4.9G => Ch 183, 184, 185, 187, 188, 189, 192, 196 (Value:15 ~ 22)
+ {0x7F, 0xD7, 0x84}, // channel = 183, Tf = 4915MHz (15)
+ {0x6F, 0xD7, 0x84}, // channel = 184, Tf = 4920MHz (16)
+ {0x7F, 0xD7, 0x84}, // channel = 185, Tf = 4925MHz (17)
+ {0x7F, 0xD7, 0x84}, // channel = 187, Tf = 4935MHz (18)
+ {0x7F, 0xD7, 0x84}, // channel = 188, Tf = 4940MHz (19)
+ {0x7F, 0xD7, 0x84}, // channel = 189, Tf = 4945MHz (20)
+ {0x7F, 0xD7, 0x84}, // channel = 192, Tf = 4960MHz (21)
+ {0x6F, 0xD7, 0x84}, // 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)
+ {0x7F, 0xD7, 0x84}, // channel = 7, Tf = 5035MHz (23)
+ {0x6F, 0xD7, 0x84}, // channel = 8, Tf = 5040MHz (24)
+ {0x7F, 0xD7, 0x84}, // channel = 9, Tf = 5045MHz (25)
+ {0x7F, 0xD7, 0x84}, // channel = 11, Tf = 5055MHz (26)
+ {0x7F, 0xD7, 0x84}, // channel = 12, Tf = 5060MHz (27)
+ {0x7F, 0xD7, 0x84}, // channel = 16, Tf = 5080MHz (28)
+ {0x7F, 0xD7, 0x84}, // channel = 34, Tf = 5170MHz (29)
+ {0x7F, 0xD7, 0x84}, // channel = 36, Tf = 5180MHz (30)
+ {0x7F, 0xD7, 0x84}, // channel = 38, Tf = 5190MHz (31)
+ {0x7F, 0xD7, 0x84}, // channel = 40, Tf = 5200MHz (32)
+ {0x7F, 0xD7, 0x84}, // channel = 42, Tf = 5210MHz (33)
+ {0x6F, 0xD7, 0x84}, // channel = 44, Tf = 5220MHz (34)
+ {0x7F, 0xD7, 0x84}, // channel = 46, Tf = 5230MHz (35)
+ {0x7F, 0xD7, 0x84}, // channel = 48, Tf = 5240MHz (36)
+ {0x7F, 0xD7, 0x84}, // channel = 52, Tf = 5260MHz (37)
+ {0x6F, 0xD7, 0x84}, // channel = 56, Tf = 5280MHz (38)
+ {0x7F, 0xD7, 0x84}, // channel = 60, Tf = 5300MHz (39)
+ {0x7F, 0xD7, 0x84}, // channel = 64, Tf = 5320MHz (40)
+ {0x7F, 0xD7, 0x84}, // channel = 100, Tf = 5500MHz (41)
+ {0x6F, 0xD7, 0x84}, // channel = 104, Tf = 5520MHz (42)
+ {0x7F, 0xD7, 0x84}, // channel = 108, Tf = 5540MHz (43)
+ {0x7F, 0xD7, 0x84}, // channel = 112, Tf = 5560MHz (44)
+ {0x6F, 0xD7, 0x84}, // channel = 116, Tf = 5580MHz (45)
+ {0x7F, 0xD7, 0x84}, // channel = 120, Tf = 5600MHz (46)
+ {0x7F, 0xD7, 0x84}, // channel = 124, Tf = 5620MHz (47)
+ {0x6F, 0xD7, 0x84}, // channel = 128, Tf = 5640MHz (48)
+ {0x7F, 0xD7, 0x84}, // channel = 132, Tf = 5660MHz (49)
+ {0x7F, 0xD7, 0x84}, // channel = 136, Tf = 5680MHz (50)
+ {0x6F, 0xD7, 0x84}, // channel = 140, Tf = 5700MHz (51)
+ {0x7F, 0xD7, 0x84}, // channel = 149, Tf = 5745MHz (52)
+ {0x7F, 0xD7, 0x84}, // channel = 153, Tf = 5765MHz (53)
+ {0x7F, 0xD7, 0x84}, // channel = 157, Tf = 5785MHz (54)
+ {0x7F, 0xD7, 0x84}, // channel = 161, Tf = 5805MHz (55)
+ {0x7F, 0xD7, 0x84} // channel = 165, Tf = 5825MHz (56)
+ };
+
+///{{RobertYu:20051111
+BYTE abyVT3226_InitTable[CB_VT3226_INIT_SEQ][3] = {
+ {0x03, 0xFF, 0x80},
+ {0x02, 0x82, 0xA1},
+ {0x03, 0xC6, 0xA2},
+ {0x01, 0x97, 0x93},
+ {0x03, 0x66, 0x64},
+ {0x00, 0x61, 0xA5},
+ {0x01, 0x7B, 0xD6},
+ {0x00, 0x80, 0x17},
+ {0x03, 0xF8, 0x08},
+ {0x00, 0x02, 0x39}, //RobertYu:20051116
+ {0x02, 0x00, 0x2A}
+ };
+
+BYTE abyVT3226D0_InitTable[CB_VT3226_INIT_SEQ][3] = {
+ {0x03, 0xFF, 0x80},
+ {0x03, 0x02, 0x21}, //RobertYu:20060327
+ {0x03, 0xC6, 0xA2},
+ {0x01, 0x97, 0x93},
+ {0x03, 0x66, 0x64},
+ {0x00, 0x71, 0xA5}, //RobertYu:20060103
+ {0x01, 0x15, 0xC6}, //RobertYu:20060420
+ {0x01, 0x2E, 0x07}, //RobertYu:20060420
+ {0x00, 0x58, 0x08}, //RobertYu:20060111
+ {0x00, 0x02, 0x79}, //RobertYu:20060420
+ {0x02, 0x01, 0xAA} //RobertYu:20060523
+ };
+
+
+BYTE abyVT3226_ChannelTable0[CB_MAX_CHANNEL_24G][3] = {
+ {0x01, 0x97, 0x83}, // channel = 1, Tf = 2412MHz
+ {0x01, 0x97, 0x83}, // channel = 2, Tf = 2417MHz
+ {0x01, 0x97, 0x93}, // channel = 3, Tf = 2422MHz
+ {0x01, 0x97, 0x93}, // channel = 4, Tf = 2427MHz
+ {0x01, 0x97, 0x93}, // channel = 5, Tf = 2432MHz
+ {0x01, 0x97, 0x93}, // channel = 6, Tf = 2437MHz
+ {0x01, 0x97, 0xA3}, // channel = 7, Tf = 2442MHz
+ {0x01, 0x97, 0xA3}, // channel = 8, Tf = 2447MHz
+ {0x01, 0x97, 0xA3}, // channel = 9, Tf = 2452MHz
+ {0x01, 0x97, 0xA3}, // channel = 10, Tf = 2457MHz
+ {0x01, 0x97, 0xB3}, // channel = 11, Tf = 2462MHz
+ {0x01, 0x97, 0xB3}, // channel = 12, Tf = 2467MHz
+ {0x01, 0x97, 0xB3}, // channel = 13, Tf = 2472MHz
+ {0x03, 0x37, 0xC3} // channel = 14, Tf = 2484MHz
+ };
+
+BYTE abyVT3226_ChannelTable1[CB_MAX_CHANNEL_24G][3] = {
+ {0x02, 0x66, 0x64}, // channel = 1, Tf = 2412MHz
+ {0x03, 0x66, 0x64}, // channel = 2, Tf = 2417MHz
+ {0x00, 0x66, 0x64}, // channel = 3, Tf = 2422MHz
+ {0x01, 0x66, 0x64}, // channel = 4, Tf = 2427MHz
+ {0x02, 0x66, 0x64}, // channel = 5, Tf = 2432MHz
+ {0x03, 0x66, 0x64}, // channel = 6, Tf = 2437MHz
+ {0x00, 0x66, 0x64}, // channel = 7, Tf = 2442MHz
+ {0x01, 0x66, 0x64}, // channel = 8, Tf = 2447MHz
+ {0x02, 0x66, 0x64}, // channel = 9, Tf = 2452MHz
+ {0x03, 0x66, 0x64}, // channel = 10, Tf = 2457MHz
+ {0x00, 0x66, 0x64}, // channel = 11, Tf = 2462MHz
+ {0x01, 0x66, 0x64}, // channel = 12, Tf = 2467MHz
+ {0x02, 0x66, 0x64}, // channel = 13, Tf = 2472MHz
+ {0x00, 0xCC, 0xC4} // channel = 14, Tf = 2484MHz
+ };
+///}}RobertYu
+
+
+//{{RobertYu:20060502, TWIF 1.14, LO Current for 11b mode
+DWORD dwVT3226D0LoCurrentTable[CB_MAX_CHANNEL_24G] = {
+ 0x0135C600+(BY_VT3226_REG_LEN<<3)+IFREGCTL_REGW, // channel = 1, Tf = 2412MHz
+ 0x0135C600+(BY_VT3226_REG_LEN<<3)+IFREGCTL_REGW, // channel = 2, Tf = 2417MHz
+ 0x0235C600+(BY_VT3226_REG_LEN<<3)+IFREGCTL_REGW, // channel = 3, Tf = 2422MHz
+ 0x0235C600+(BY_VT3226_REG_LEN<<3)+IFREGCTL_REGW, // channel = 4, Tf = 2427MHz
+ 0x0235C600+(BY_VT3226_REG_LEN<<3)+IFREGCTL_REGW, // channel = 5, Tf = 2432MHz
+ 0x0335C600+(BY_VT3226_REG_LEN<<3)+IFREGCTL_REGW, // channel = 6, Tf = 2437MHz
+ 0x0335C600+(BY_VT3226_REG_LEN<<3)+IFREGCTL_REGW, // channel = 7, Tf = 2442MHz
+ 0x0335C600+(BY_VT3226_REG_LEN<<3)+IFREGCTL_REGW, // channel = 8, Tf = 2447MHz
+ 0x0335C600+(BY_VT3226_REG_LEN<<3)+IFREGCTL_REGW, // channel = 9, Tf = 2452MHz
+ 0x0335C600+(BY_VT3226_REG_LEN<<3)+IFREGCTL_REGW, // channel = 10, Tf = 2457MHz
+ 0x0335C600+(BY_VT3226_REG_LEN<<3)+IFREGCTL_REGW, // channel = 11, Tf = 2462MHz
+ 0x0335C600+(BY_VT3226_REG_LEN<<3)+IFREGCTL_REGW, // channel = 12, Tf = 2467MHz
+ 0x0335C600+(BY_VT3226_REG_LEN<<3)+IFREGCTL_REGW, // channel = 13, Tf = 2472MHz
+ 0x0135C600+(BY_VT3226_REG_LEN<<3)+IFREGCTL_REGW // channel = 14, Tf = 2484MHz
+};
+//}}
+
+
+//{{RobertYu:20060609
+BYTE abyVT3342A0_InitTable[CB_VT3342_INIT_SEQ][3] = { // 11b/g mode
+ {0x03, 0xFF, 0x80}, //update for mode//
+ {0x02, 0x08, 0x81},
+ {0x00, 0xC6, 0x02},
+ {0x03, 0xC5, 0x13}, // channel6
+ {0x00, 0xEE, 0xE4}, // channel6
+ {0x00, 0x71, 0xA5},
+ {0x01, 0x75, 0x46},
+ {0x01, 0x40, 0x27},
+ {0x01, 0x54, 0x08},
+ {0x00, 0x01, 0x69},
+ {0x02, 0x00, 0xAA},
+ {0x00, 0x08, 0xCB},
+ {0x01, 0x70, 0x0C}
+ };
+
+ //11b/g mode: 0x03, 0xFF, 0x80,
+ //11a mode: 0x03, 0xFF, 0xC0,
+
+ // channel44, 5220MHz 0x00C402
+ // channel56, 5280MHz 0x00C402 for disable Frac
+ // other channels 0x00C602
+
+BYTE abyVT3342_ChannelTable0[CB_MAX_CHANNEL][3] = {
+ {0x02, 0x05, 0x03}, // channel = 1, Tf = 2412MHz
+ {0x01, 0x15, 0x03}, // channel = 2, Tf = 2417MHz
+ {0x03, 0xC5, 0x03}, // channel = 3, Tf = 2422MHz
+ {0x02, 0x65, 0x03}, // channel = 4, Tf = 2427MHz
+ {0x01, 0x15, 0x13}, // channel = 5, Tf = 2432MHz
+ {0x03, 0xC5, 0x13}, // channel = 6, Tf = 2437MHz
+ {0x02, 0x05, 0x13}, // channel = 7, Tf = 2442MHz
+ {0x01, 0x15, 0x13}, // channel = 8, Tf = 2447MHz
+ {0x03, 0xC5, 0x13}, // channel = 9, Tf = 2452MHz
+ {0x02, 0x65, 0x13}, // channel = 10, Tf = 2457MHz
+ {0x01, 0x15, 0x23}, // channel = 11, Tf = 2462MHz
+ {0x03, 0xC5, 0x23}, // channel = 12, Tf = 2467MHz
+ {0x02, 0x05, 0x23}, // channel = 13, Tf = 2472MHz
+ {0x00, 0xD5, 0x23}, // channel = 14, Tf = 2484MHz
+
+ // 4.9G => Ch 183, 184, 185, 187, 188, 189, 192, 196 (Value:15 ~ 22)
+ {0x01, 0x15, 0x13}, // channel = 183, Tf = 4915MHz (15), TBD
+ {0x01, 0x15, 0x13}, // channel = 184, Tf = 4920MHz (16), TBD
+ {0x01, 0x15, 0x13}, // channel = 185, Tf = 4925MHz (17), TBD
+ {0x01, 0x15, 0x13}, // channel = 187, Tf = 4935MHz (18), TBD
+ {0x01, 0x15, 0x13}, // channel = 188, Tf = 4940MHz (19), TBD
+ {0x01, 0x15, 0x13}, // channel = 189, Tf = 4945MHz (20), TBD
+ {0x01, 0x15, 0x13}, // channel = 192, Tf = 4960MHz (21), TBD
+ {0x01, 0x15, 0x13}, // channel = 196, Tf = 4980MHz (22), TBD
+
+ // 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)
+ {0x01, 0x15, 0x13}, // channel = 7, Tf = 5035MHz (23), TBD
+ {0x01, 0x15, 0x13}, // channel = 8, Tf = 5040MHz (24), TBD
+ {0x01, 0x15, 0x13}, // channel = 9, Tf = 5045MHz (25), TBD
+ {0x01, 0x15, 0x13}, // channel = 11, Tf = 5055MHz (26), TBD
+ {0x01, 0x15, 0x13}, // channel = 12, Tf = 5060MHz (27), TBD
+ {0x01, 0x15, 0x13}, // channel = 16, Tf = 5080MHz (28), TBD
+ {0x01, 0x15, 0x13}, // channel = 34, Tf = 5170MHz (29), TBD
+ {0x01, 0x55, 0x63}, // channel = 36, Tf = 5180MHz (30)
+ {0x01, 0x55, 0x63}, // channel = 38, Tf = 5190MHz (31), TBD
+ {0x02, 0xA5, 0x63}, // channel = 40, Tf = 5200MHz (32)
+ {0x02, 0xA5, 0x63}, // channel = 42, Tf = 5210MHz (33), TBD
+ {0x00, 0x05, 0x73}, // channel = 44, Tf = 5220MHz (34)
+ {0x00, 0x05, 0x73}, // channel = 46, Tf = 5230MHz (35), TBD
+ {0x01, 0x55, 0x73}, // channel = 48, Tf = 5240MHz (36)
+ {0x02, 0xA5, 0x73}, // channel = 52, Tf = 5260MHz (37)
+ {0x00, 0x05, 0x83}, // channel = 56, Tf = 5280MHz (38)
+ {0x01, 0x55, 0x83}, // channel = 60, Tf = 5300MHz (39)
+ {0x02, 0xA5, 0x83}, // channel = 64, Tf = 5320MHz (40)
+
+ {0x02, 0xA5, 0x83}, // channel = 100, Tf = 5500MHz (41), TBD
+ {0x02, 0xA5, 0x83}, // channel = 104, Tf = 5520MHz (42), TBD
+ {0x02, 0xA5, 0x83}, // channel = 108, Tf = 5540MHz (43), TBD
+ {0x02, 0xA5, 0x83}, // channel = 112, Tf = 5560MHz (44), TBD
+ {0x02, 0xA5, 0x83}, // channel = 116, Tf = 5580MHz (45), TBD
+ {0x02, 0xA5, 0x83}, // channel = 120, Tf = 5600MHz (46), TBD
+ {0x02, 0xA5, 0x83}, // channel = 124, Tf = 5620MHz (47), TBD
+ {0x02, 0xA5, 0x83}, // channel = 128, Tf = 5640MHz (48), TBD
+ {0x02, 0xA5, 0x83}, // channel = 132, Tf = 5660MHz (49), TBD
+ {0x02, 0xA5, 0x83}, // channel = 136, Tf = 5680MHz (50), TBD
+ {0x02, 0xA5, 0x83}, // channel = 140, Tf = 5700MHz (51), TBD
+
+ {0x00, 0x05, 0xF3}, // channel = 149, Tf = 5745MHz (52)
+ {0x01, 0x56, 0x03}, // channel = 153, Tf = 5765MHz (53)
+ {0x02, 0xA6, 0x03}, // channel = 157, Tf = 5785MHz (54)
+ {0x00, 0x06, 0x03}, // channel = 161, Tf = 5805MHz (55)
+ {0x00, 0x06, 0x03} // channel = 165, Tf = 5825MHz (56), TBD
+ };
+
+BYTE abyVT3342_ChannelTable1[CB_MAX_CHANNEL][3] = {
+ {0x01, 0x99, 0x94}, // channel = 1, Tf = 2412MHz
+ {0x02, 0x44, 0x44}, // channel = 2, Tf = 2417MHz
+ {0x02, 0xEE, 0xE4}, // channel = 3, Tf = 2422MHz
+ {0x03, 0x99, 0x94}, // channel = 4, Tf = 2427MHz
+ {0x00, 0x44, 0x44}, // channel = 5, Tf = 2432MHz
+ {0x00, 0xEE, 0xE4}, // channel = 6, Tf = 2437MHz
+ {0x01, 0x99, 0x94}, // channel = 7, Tf = 2442MHz
+ {0x02, 0x44, 0x44}, // channel = 8, Tf = 2447MHz
+ {0x02, 0xEE, 0xE4}, // channel = 9, Tf = 2452MHz
+ {0x03, 0x99, 0x94}, // channel = 10, Tf = 2457MHz
+ {0x00, 0x44, 0x44}, // channel = 11, Tf = 2462MHz
+ {0x00, 0xEE, 0xE4}, // channel = 12, Tf = 2467MHz
+ {0x01, 0x99, 0x94}, // channel = 13, Tf = 2472MHz
+ {0x03, 0x33, 0x34}, // channel = 14, Tf = 2484MHz
+
+ // 4.9G => Ch 183, 184, 185, 187, 188, 189, 192, 196 (Value:15 ~ 22)
+ {0x00, 0x44, 0x44}, // channel = 183, Tf = 4915MHz (15), TBD
+ {0x00, 0x44, 0x44}, // channel = 184, Tf = 4920MHz (16), TBD
+ {0x00, 0x44, 0x44}, // channel = 185, Tf = 4925MHz (17), TBD
+ {0x00, 0x44, 0x44}, // channel = 187, Tf = 4935MHz (18), TBD
+ {0x00, 0x44, 0x44}, // channel = 188, Tf = 4940MHz (19), TBD
+ {0x00, 0x44, 0x44}, // channel = 189, Tf = 4945MHz (20), TBD
+ {0x00, 0x44, 0x44}, // channel = 192, Tf = 4960MHz (21), TBD
+ {0x00, 0x44, 0x44}, // channel = 196, Tf = 4980MHz (22), TBD
+
+ // 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)
+ {0x00, 0x44, 0x44}, // channel = 7, Tf = 5035MHz (23), TBD
+ {0x00, 0x44, 0x44}, // channel = 8, Tf = 5040MHz (24), TBD
+ {0x00, 0x44, 0x44}, // channel = 9, Tf = 5045MHz (25), TBD
+ {0x00, 0x44, 0x44}, // channel = 11, Tf = 5055MHz (26), TBD
+ {0x00, 0x44, 0x44}, // channel = 12, Tf = 5060MHz (27), TBD
+ {0x00, 0x44, 0x44}, // channel = 16, Tf = 5080MHz (28), TBD
+ {0x00, 0x44, 0x44}, // channel = 34, Tf = 5170MHz (29), TBD
+ {0x01, 0x55, 0x54}, // channel = 36, Tf = 5180MHz (30)
+ {0x01, 0x55, 0x54}, // channel = 38, Tf = 5190MHz (31), TBD
+ {0x02, 0xAA, 0xA4}, // channel = 40, Tf = 5200MHz (32)
+ {0x02, 0xAA, 0xA4}, // channel = 42, Tf = 5210MHz (33), TBD
+ {0x00, 0x00, 0x04}, // channel = 44, Tf = 5220MHz (34)
+ {0x00, 0x00, 0x04}, // channel = 46, Tf = 5230MHz (35), TBD
+ {0x01, 0x55, 0x54}, // channel = 48, Tf = 5240MHz (36)
+ {0x02, 0xAA, 0xA4}, // channel = 52, Tf = 5260MHz (37)
+ {0x00, 0x00, 0x04}, // channel = 56, Tf = 5280MHz (38)
+ {0x01, 0x55, 0x54}, // channel = 60, Tf = 5300MHz (39)
+ {0x02, 0xAA, 0xA4}, // channel = 64, Tf = 5320MHz (40)
+ {0x02, 0xAA, 0xA4}, // channel = 100, Tf = 5500MHz (41), TBD
+ {0x02, 0xAA, 0xA4}, // channel = 104, Tf = 5520MHz (42), TBD
+ {0x02, 0xAA, 0xA4}, // channel = 108, Tf = 5540MHz (43), TBD
+ {0x02, 0xAA, 0xA4}, // channel = 112, Tf = 5560MHz (44), TBD
+ {0x02, 0xAA, 0xA4}, // channel = 116, Tf = 5580MHz (45), TBD
+ {0x02, 0xAA, 0xA4}, // channel = 120, Tf = 5600MHz (46), TBD
+ {0x02, 0xAA, 0xA4}, // channel = 124, Tf = 5620MHz (47), TBD
+ {0x02, 0xAA, 0xA4}, // channel = 128, Tf = 5640MHz (48), TBD
+ {0x02, 0xAA, 0xA4}, // channel = 132, Tf = 5660MHz (49), TBD
+ {0x02, 0xAA, 0xA4}, // channel = 136, Tf = 5680MHz (50), TBD
+ {0x02, 0xAA, 0xA4}, // channel = 140, Tf = 5700MHz (51), TBD
+ {0x03, 0x00, 0x04}, // channel = 149, Tf = 5745MHz (52)
+ {0x00, 0x55, 0x54}, // channel = 153, Tf = 5765MHz (53)
+ {0x01, 0xAA, 0xA4}, // channel = 157, Tf = 5785MHz (54)
+ {0x03, 0x00, 0x04}, // channel = 161, Tf = 5805MHz (55)
+ {0x03, 0x00, 0x04} // channel = 165, Tf = 5825MHz (56), TBD
+ };
+
+
+/*+
+ *
+ * Power Table
+ *
+-*/
+
+const 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
+ };
+
+/*--------------------- Static Functions --------------------------*/
+
+/*--------------------- Export Variables --------------------------*/
+
+//{{ RobertYu:20050103, Channel 11a Number To Index
+// 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)
+
+const BYTE RFaby11aChannelIndex[200] = {
+ // 1 2 3 4 5 6 7 8 9 10
+ 00, 00, 00, 00, 00, 00, 23, 24, 25, 00, // 10
+ 26, 27, 00, 00, 00, 28, 00, 00, 00, 00, // 20
+ 00, 00, 00, 00, 00, 00, 00, 00, 00, 00, // 30
+ 00, 00, 00, 29, 00, 30, 00, 31, 00, 32, // 40
+ 00, 33, 00, 34, 00, 35, 00, 36, 00, 00, // 50
+ 00, 37, 00, 00, 00, 38, 00, 00, 00, 39, // 60
+ 00, 00, 00, 40, 00, 00, 00, 00, 00, 00, // 70
+ 00, 00, 00, 00, 00, 00, 00, 00, 00, 00, // 80
+ 00, 00, 00, 00, 00, 00, 00, 00, 00, 00, // 90
+ 00, 00, 00, 00, 00, 00, 00, 00, 00, 41, //100
+
+ 00, 00, 00, 42, 00, 00, 00, 43, 00, 00, //110
+ 00, 44, 00, 00, 00, 45, 00, 00, 00, 46, //120
+ 00, 00, 00, 47, 00, 00, 00, 48, 00, 00, //130
+ 00, 49, 00, 00, 00, 50, 00, 00, 00, 51, //140
+ 00, 00, 00, 00, 00, 00, 00, 00, 52, 00, //150
+ 00, 00, 53, 00, 00, 00, 54, 00, 00, 00, //160
+ 55, 00, 00, 00, 56, 00, 00, 00, 00, 00, //170
+ 00, 00, 00, 00, 00, 00, 00, 00, 00, 00, //180
+ 00, 00, 15, 16, 17, 00, 18, 19, 20, 00, //190
+ 00, 21, 00, 00, 00, 22, 00, 00, 00, 00 //200
+};
+//}} RobertYu
+
+/*--------------------- Export Functions --------------------------*/
+
+/*
+ * Description: Write to IF/RF, by embeded programming
+ *
+ * Parameters:
+ * In:
+ * dwData - data to write
+ * Out:
+ * none
+ *
+ * Return Value: TRUE if succeeded; FALSE if failed.
+ *
+ */
+BOOL IFRFbWriteEmbeded (PSDevice pDevice, DWORD dwData)
+{
+ BYTE pbyData[4];
+
+ pbyData[0] = (BYTE)dwData;
+ pbyData[1] = (BYTE)(dwData>>8);
+ pbyData[2] = (BYTE)(dwData>>16);
+ pbyData[3] = (BYTE)(dwData>>24);
+ CONTROLnsRequestOut(pDevice,
+ MESSAGE_TYPE_WRITE_IFRF,
+ 0,
+ 0,
+ 4,
+ pbyData
+ );
+
+
+ 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 = pDevice->byCCKPwr;
+
+ if (pDevice->dwDiagRefCount != 0) {
+ return TRUE;
+ }
+
+ switch (uRATE) {
+ case RATE_1M:
+ case RATE_2M:
+ case RATE_5M:
+ case RATE_11M:
+ byPwr = pDevice->abyCCKPwrTbl[uCH-1];
+ break;
+ case RATE_6M:
+ case RATE_9M:
+ case RATE_18M:
+ case RATE_24M:
+ case RATE_36M:
+ case RATE_48M:
+ case RATE_54M:
+ if (uCH > CB_MAX_CHANNEL_24G) {
+ byPwr = pDevice->abyOFDMAPwrTbl[uCH-15];
+ } else {
+ byPwr = pDevice->abyOFDMPwrTbl[uCH-1];
+ }
+ break;
+ }
+
+ bResult = RFbRawSetPower(pDevice, byPwr, uRATE);
+
+ 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;
+
+ if (pDevice->byCurPwr == byPwr)
+ return TRUE;
+
+ pDevice->byCurPwr = byPwr;
+
+ switch (pDevice->byRFType) {
+
+ case RF_AL2230 :
+ if (pDevice->byCurPwr >= AL2230_PWR_IDX_LEN)
+ return FALSE;
+ bResult &= IFRFbWriteEmbeded(pDevice, dwAL2230PowerTable[pDevice->byCurPwr]);
+ if (uRATE <= RATE_11M)
+ bResult &= IFRFbWriteEmbeded(pDevice, 0x0001B400+(BY_AL2230_REG_LEN<<3)+IFREGCTL_REGW);
+ else
+ bResult &= IFRFbWriteEmbeded(pDevice, 0x0005A400+(BY_AL2230_REG_LEN<<3)+IFREGCTL_REGW);
+ break;
+
+ case RF_AL2230S :
+ if (pDevice->byCurPwr >= AL2230_PWR_IDX_LEN)
+ return FALSE;
+ bResult &= IFRFbWriteEmbeded(pDevice, dwAL2230PowerTable[pDevice->byCurPwr]);
+ if (uRATE <= RATE_11M) {
+ bResult &= IFRFbWriteEmbeded(pDevice, 0x040C1400+(BY_AL2230_REG_LEN<<3)+IFREGCTL_REGW);
+ bResult &= IFRFbWriteEmbeded(pDevice, 0x00299B00+(BY_AL2230_REG_LEN<<3)+IFREGCTL_REGW);
+ }else {
+ bResult &= IFRFbWriteEmbeded(pDevice, 0x0005A400+(BY_AL2230_REG_LEN<<3)+IFREGCTL_REGW);
+ bResult &= IFRFbWriteEmbeded(pDevice, 0x00099B00+(BY_AL2230_REG_LEN<<3)+IFREGCTL_REGW);
+ }
+ break;
+
+
+ case RF_AIROHA7230:
+ {
+ DWORD dwMax7230Pwr;
+
+ if (uRATE <= RATE_11M) { //RobertYu:20060426, for better 11b mask
+ bResult &= IFRFbWriteEmbeded(pDevice, 0x111BB900+(BY_AL7230_REG_LEN<<3)+IFREGCTL_REGW);
+ }
+ else {
+ bResult &= IFRFbWriteEmbeded(pDevice, 0x221BB900+(BY_AL7230_REG_LEN<<3)+IFREGCTL_REGW);
+ }
+
+ if (pDevice->byCurPwr > AL7230_PWR_IDX_LEN) return FALSE;
+
+ // 0x080F1B00 for 3 wire control TxGain(D10) and 0x31 as TX Gain value
+ dwMax7230Pwr = 0x080C0B00 | ( (pDevice->byCurPwr) << 12 ) |
+ (BY_AL7230_REG_LEN << 3 ) | IFREGCTL_REGW;
+
+ bResult &= IFRFbWriteEmbeded(pDevice, dwMax7230Pwr);
+ break;
+ }
+ break;
+
+ case RF_VT3226: //RobertYu:20051111, VT3226C0 and before
+ {
+ DWORD dwVT3226Pwr;
+
+ if (pDevice->byCurPwr >= VT3226_PWR_IDX_LEN)
+ return FALSE;
+ dwVT3226Pwr = ((0x3F-pDevice->byCurPwr) << 20 ) | ( 0x17 << 8 ) /* Reg7 */ |
+ (BY_VT3226_REG_LEN << 3 ) | IFREGCTL_REGW;
+ bResult &= IFRFbWriteEmbeded(pDevice, dwVT3226Pwr);
+ break;
+ }
+
+ case RF_VT3226D0: //RobertYu:20051228
+ {
+ DWORD dwVT3226Pwr;
+
+ if (pDevice->byCurPwr >= VT3226_PWR_IDX_LEN)
+ return FALSE;
+
+ if (uRATE <= RATE_11M) {
+
+ dwVT3226Pwr = ((0x3F-pDevice->byCurPwr) << 20 ) | ( 0xE07 << 8 ) /* Reg7 */ | //RobertYu:20060420, TWIF 1.10
+ (BY_VT3226_REG_LEN << 3 ) | IFREGCTL_REGW;
+ bResult &= IFRFbWriteEmbeded(pDevice, dwVT3226Pwr);
+
+ bResult &= IFRFbWriteEmbeded(pDevice, 0x03C6A200+(BY_VT3226_REG_LEN<<3)+IFREGCTL_REGW);
+ if (pDevice->sMgmtObj.eScanState != WMAC_NO_SCANNING) {
+ // scanning, the channel number is pDevice->uScanChannel
+ DBG_PRT(MSG_LEVEL_DEBUG, KERN_INFO"@@@@ RFbRawSetPower> 11B mode uCurrChannel[%d]\n", pDevice->sMgmtObj.uScanChannel);
+ bResult &= IFRFbWriteEmbeded(pDevice, dwVT3226D0LoCurrentTable[pDevice->sMgmtObj.uScanChannel-1]); //RobertYu:20060420, sometimes didn't change channel just set power with different rate
+ } else {
+ DBG_PRT(MSG_LEVEL_DEBUG, KERN_INFO"@@@@ RFbRawSetPower> 11B mode uCurrChannel[%d]\n", pDevice->sMgmtObj.uCurrChannel);
+ bResult &= IFRFbWriteEmbeded(pDevice, dwVT3226D0LoCurrentTable[pDevice->sMgmtObj.uCurrChannel-1]); //RobertYu:20060420, sometimes didn't change channel just set power with different rate
+ }
+
+ bResult &= IFRFbWriteEmbeded(pDevice, 0x015C0800+(BY_VT3226_REG_LEN<<3)+IFREGCTL_REGW); //RobertYu:20060420, ok now, new switching power (mini-pci can have bigger power consumption)
+ } else {
+ DBG_PRT(MSG_LEVEL_DEBUG, KERN_INFO"@@@@ RFbRawSetPower> 11G mode\n");
+ dwVT3226Pwr = ((0x3F-pDevice->byCurPwr) << 20 ) | ( 0x7 << 8 ) /* Reg7 */ | //RobertYu:20060420, TWIF 1.10
+ (BY_VT3226_REG_LEN << 3 ) | IFREGCTL_REGW;
+ bResult &= IFRFbWriteEmbeded(pDevice, dwVT3226Pwr);
+ bResult &= IFRFbWriteEmbeded(pDevice, 0x00C6A200+(BY_VT3226_REG_LEN<<3)+IFREGCTL_REGW); //RobertYu:20060327
+ bResult &= IFRFbWriteEmbeded(pDevice, 0x016BC600+(BY_VT3226_REG_LEN<<3)+IFREGCTL_REGW); //RobertYu:20060111
+ bResult &= IFRFbWriteEmbeded(pDevice, 0x00900800+(BY_VT3226_REG_LEN<<3)+IFREGCTL_REGW); //RobertYu:20060111
+ }
+ break;
+ }
+
+ //{{RobertYu:20060609
+ case RF_VT3342A0:
+ {
+ DWORD dwVT3342Pwr;
+
+ if (pDevice->byCurPwr >= VT3342_PWR_IDX_LEN)
+ return FALSE;
+
+ dwVT3342Pwr = ((0x3F-pDevice->byCurPwr) << 20 ) | ( 0x27 << 8 ) /* Reg7 */ |
+ (BY_VT3342_REG_LEN << 3 ) | IFREGCTL_REGW;
+ bResult &= IFRFbWriteEmbeded(pDevice, dwVT3342Pwr);
+ 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_AL2230:
+ case RF_AL2230S:
+ case RF_AIROHA7230:
+ case RF_VT3226: //RobertYu:20051111
+ case RF_VT3226D0:
+ case RF_VT3342A0: //RobertYu:20060609
+ a = abyAIROHARF[byIdx];
+ break;
+ default:
+ break;
+ }
+
+ *pldBm = -1 * (a + b * 2);
+}
+
+
+
+VOID
+RFbRFTableDownload (
+ IN PSDevice pDevice
+ )
+{
+WORD wLength1 = 0,wLength2 = 0 ,wLength3 = 0;
+PBYTE pbyAddr1 = NULL,pbyAddr2 = NULL,pbyAddr3 = NULL;
+WORD wLength,wValue;
+BYTE abyArray[256];
+
+ switch ( pDevice->byRFType ) {
+ case RF_AL2230:
+ case RF_AL2230S:
+ wLength1 = CB_AL2230_INIT_SEQ * 3;
+ wLength2 = CB_MAX_CHANNEL_24G * 3;
+ wLength3 = CB_MAX_CHANNEL_24G * 3;
+ pbyAddr1 = &(abyAL2230InitTable[0][0]);
+ pbyAddr2 = &(abyAL2230ChannelTable0[0][0]);
+ pbyAddr3 = &(abyAL2230ChannelTable1[0][0]);
+ break;
+ case RF_AIROHA7230:
+ wLength1 = CB_AL7230_INIT_SEQ * 3;
+ wLength2 = CB_MAX_CHANNEL * 3;
+ wLength3 = CB_MAX_CHANNEL * 3;
+ pbyAddr1 = &(abyAL7230InitTable[0][0]);
+ pbyAddr2 = &(abyAL7230ChannelTable0[0][0]);
+ pbyAddr3 = &(abyAL7230ChannelTable1[0][0]);
+ break;
+ case RF_VT3226: //RobertYu:20051111
+ wLength1 = CB_VT3226_INIT_SEQ * 3;
+ wLength2 = CB_MAX_CHANNEL_24G * 3;
+ wLength3 = CB_MAX_CHANNEL_24G * 3;
+ pbyAddr1 = &(abyVT3226_InitTable[0][0]);
+ pbyAddr2 = &(abyVT3226_ChannelTable0[0][0]);
+ pbyAddr3 = &(abyVT3226_ChannelTable1[0][0]);
+ break;
+ case RF_VT3226D0: //RobertYu:20051114
+ wLength1 = CB_VT3226_INIT_SEQ * 3;
+ wLength2 = CB_MAX_CHANNEL_24G * 3;
+ wLength3 = CB_MAX_CHANNEL_24G * 3;
+ pbyAddr1 = &(abyVT3226D0_InitTable[0][0]);
+ pbyAddr2 = &(abyVT3226_ChannelTable0[0][0]);
+ pbyAddr3 = &(abyVT3226_ChannelTable1[0][0]);
+ break;
+ case RF_VT3342A0: //RobertYu:20060609
+ wLength1 = CB_VT3342_INIT_SEQ * 3;
+ wLength2 = CB_MAX_CHANNEL * 3;
+ wLength3 = CB_MAX_CHANNEL * 3;
+ pbyAddr1 = &(abyVT3342A0_InitTable[0][0]);
+ pbyAddr2 = &(abyVT3342_ChannelTable0[0][0]);
+ pbyAddr3 = &(abyVT3342_ChannelTable1[0][0]);
+ break;
+
+ }
+ //Init Table
+
+ memcpy(abyArray, pbyAddr1, wLength1);
+ CONTROLnsRequestOut(pDevice,
+ MESSAGE_TYPE_WRITE,
+ 0,
+ MESSAGE_REQUEST_RF_INIT,
+ wLength1,
+ abyArray
+ );
+ //Channle Table 0
+ wValue = 0;
+ while ( wLength2 > 0 ) {
+
+ if ( wLength2 >= 64 ) {
+ wLength = 64;
+ } else {
+ wLength = wLength2;
+ }
+ memcpy(abyArray, pbyAddr2, wLength);
+ CONTROLnsRequestOut(pDevice,
+ MESSAGE_TYPE_WRITE,
+ wValue,
+ MESSAGE_REQUEST_RF_CH0,
+ wLength,
+ abyArray);
+
+ wLength2 -= wLength;
+ wValue += wLength;
+ pbyAddr2 += wLength;
+ }
+ //Channel table 1
+ wValue = 0;
+ while ( wLength3 > 0 ) {
+
+ if ( wLength3 >= 64 ) {
+ wLength = 64;
+ } else {
+ wLength = wLength3;
+ }
+ memcpy(abyArray, pbyAddr3, wLength);
+ CONTROLnsRequestOut(pDevice,
+ MESSAGE_TYPE_WRITE,
+ wValue,
+ MESSAGE_REQUEST_RF_CH1,
+ wLength,
+ abyArray);
+
+ wLength3 -= wLength;
+ wValue += wLength;
+ pbyAddr3 += wLength;
+ }
+
+ //7230 needs 2 InitTable and 3 Channel Table
+ if ( pDevice->byRFType == RF_AIROHA7230 ) {
+ wLength1 = CB_AL7230_INIT_SEQ * 3;
+ wLength2 = CB_MAX_CHANNEL * 3;
+ pbyAddr1 = &(abyAL7230InitTableAMode[0][0]);
+ pbyAddr2 = &(abyAL7230ChannelTable2[0][0]);
+ memcpy(abyArray, pbyAddr1, wLength1);
+ //Init Table 2
+ CONTROLnsRequestOut(pDevice,
+ MESSAGE_TYPE_WRITE,
+ 0,
+ MESSAGE_REQUEST_RF_INIT2,
+ wLength1,
+ abyArray);
+
+ //Channle Table 0
+ wValue = 0;
+ while ( wLength2 > 0 ) {
+
+ if ( wLength2 >= 64 ) {
+ wLength = 64;
+ } else {
+ wLength = wLength2;
+ }
+ memcpy(abyArray, pbyAddr2, wLength);
+ CONTROLnsRequestOut(pDevice,
+ MESSAGE_TYPE_WRITE,
+ wValue,
+ MESSAGE_REQUEST_RF_CH2,
+ wLength,
+ abyArray);
+
+ wLength2 -= wLength;
+ wValue += wLength;
+ pbyAddr2 += wLength;
+ }
+ }
+
+}
+
+// RobertYu:20060412, TWIF1.11 adjust LO Current for 11b mode
+BOOL s_bVT3226D0_11bLoCurrentAdjust(
+ IN PSDevice pDevice,
+ IN BYTE byChannel,
+ IN BOOL b11bMode )
+{
+ BOOL bResult;
+
+ bResult = TRUE;
+ if( b11bMode )
+ bResult &= IFRFbWriteEmbeded(pDevice, dwVT3226D0LoCurrentTable[byChannel-1]);
+ else
+ bResult &= IFRFbWriteEmbeded(pDevice, 0x016BC600+(BY_VT3226_REG_LEN<<3)+IFREGCTL_REGW); //RobertYu:20060412
+
+ return bResult;
+}
+
+
diff --git a/drivers/staging/vt6656/rf.h b/drivers/staging/vt6656/rf.h
new file mode 100644
index 000000000000..c9ebd003ecfb
--- /dev/null
+++ b/drivers/staging/vt6656/rf.h
@@ -0,0 +1,112 @@
+/*
+ * 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_AL2230 0x03
+#define RF_GCT5103 0x04
+#define RF_UW2451 0x05
+#define RF_MAXIMG 0x06
+#define RF_MAXIM2829 0x07
+#define RF_UW2452 0x08
+#define RF_VT3226 0x09
+#define RF_AIROHA7230 0x0a
+#define RF_UW2453 0x0b
+#define RF_VT3226D0 0x0c //RobertYu:20051114
+#define RF_VT3342A0 0x0d //RobertYu:20060609
+#define RF_AL2230S 0x0e
+
+#define RF_EMU 0x80
+#define RF_MASK 0x7F
+
+
+
+/*--------------------- Export Classes ----------------------------*/
+
+/*--------------------- Export Variables --------------------------*/
+extern const BYTE RFaby11aChannelIndex[200];
+/*--------------------- Export Functions --------------------------*/
+#ifdef __cplusplus
+extern "C" { /* Assume C declarations for C++ */
+#endif /* __cplusplus */
+
+BOOL IFRFbWriteEmbeded(PSDevice pDevice, DWORD dwData);
+BOOL RFbSetPower (
+ IN PSDevice pDevice,
+ IN UINT uRATE,
+ IN UINT uCH
+ );
+
+BOOL RFbRawSetPower(
+ IN PSDevice pDevice,
+ IN BYTE byPwr,
+ IN UINT uRATE
+ );
+
+VOID
+RFvRSSITodBm (
+ IN PSDevice pDevice,
+ IN BYTE byCurrRSSI,
+ OUT PLONG pldBm
+ );
+
+VOID
+RFbRFTableDownload (
+ IN PSDevice pDevice
+ );
+
+BOOL s_bVT3226D0_11bLoCurrentAdjust(
+ IN PSDevice pDevice,
+ IN BYTE byChannel,
+ IN BOOL b11bMode
+ );
+
+#ifdef __cplusplus
+} /* End of extern "C" { */
+#endif /* __cplusplus */
+
+
+#endif // __RF_H__
+
+
+
diff --git a/drivers/staging/vt6656/rndis.h b/drivers/staging/vt6656/rndis.h
new file mode 100644
index 000000000000..1d32d81079b6
--- /dev/null
+++ b/drivers/staging/vt6656/rndis.h
@@ -0,0 +1,162 @@
+/*
+ * 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: rndis.h
+ *
+ * Purpose: Interface between firmware and driver
+ *
+ * Author: Warren Hsu
+ *
+ * Date: Nov 24, 2004
+ *
+ */
+
+
+#ifndef __RNDIS_H__
+#define __RNDIS_H__
+
+/*--------------------- Export Definitions -------------------------*/
+#define MESSAGE_TYPE_READ 0x01
+#define MESSAGE_TYPE_WRITE 0x00
+#define MESSAGE_TYPE_LOCK_OR 0x02
+#define MESSAGE_TYPE_LOCK_AND 0x03
+#define MESSAGE_TYPE_WRITE_MASK 0x04
+#define MESSAGE_TYPE_CARDINIT 0x05
+#define MESSAGE_TYPE_INIT_RSP 0x06
+#define MESSAGE_TYPE_MACSHUTDOWN 0x07
+#define MESSAGE_TYPE_SETKEY 0x08
+#define MESSAGE_TYPE_CLRKEYENTRY 0x09
+#define MESSAGE_TYPE_WRITE_MISCFF 0x0A
+#define MESSAGE_TYPE_SET_ANTMD 0x0B
+#define MESSAGE_TYPE_SELECT_CHANNLE 0x0C
+#define MESSAGE_TYPE_SET_TSFTBTT 0x0D
+#define MESSAGE_TYPE_SET_SSTIFS 0x0E
+#define MESSAGE_TYPE_CHANGE_BBTYPE 0x0F
+#define MESSAGE_TYPE_DISABLE_PS 0x10
+#define MESSAGE_TYPE_WRITE_IFRF 0x11
+
+//used for read/write(index)
+#define MESSAGE_REQUEST_MEM 0x01
+#define MESSAGE_REQUEST_BBREG 0x02
+#define MESSAGE_REQUEST_MACREG 0x03
+#define MESSAGE_REQUEST_EEPROM 0x04
+#define MESSAGE_REQUEST_TSF 0x05
+#define MESSAGE_REQUEST_TBTT 0x06
+#define MESSAGE_REQUEST_BBAGC 0x07
+#define MESSAGE_REQUEST_VERSION 0x08
+#define MESSAGE_REQUEST_RF_INIT 0x09
+#define MESSAGE_REQUEST_RF_INIT2 0x0A
+#define MESSAGE_REQUEST_RF_CH0 0x0B
+#define MESSAGE_REQUEST_RF_CH1 0x0C
+#define MESSAGE_REQUEST_RF_CH2 0x0D
+
+
+#define VIAUSB20_PACKET_HEADER 0x04
+
+
+/*--------------------- Export Classes ----------------------------*/
+
+typedef struct _CMD_MESSAGE
+{
+ BYTE byData[256];
+} CMD_MESSAGE, *PCMD_MESSAGE;
+
+typedef struct _CMD_WRITE_MASK
+{
+ BYTE byData;
+ BYTE byMask;
+} CMD_WRITE_MASK, *PCMD_WRITE_MASK;
+
+typedef struct _CMD_CARD_INIT
+{
+ BYTE byInitClass;
+ BYTE bExistSWNetAddr;
+ BYTE bySWNetAddr[6];
+ BYTE byShortRetryLimit;
+ BYTE byLongRetryLimit;
+} CMD_CARD_INIT, *PCMD_CARD_INIT;
+
+typedef struct _RSP_CARD_INIT
+{
+ BYTE byStatus;
+ BYTE byNetAddr[6];
+ BYTE byRFType;
+ BYTE byMinChannel;
+ BYTE byMaxChannel;
+} RSP_CARD_INIT, *PRSP_CARD_INIT;
+
+typedef struct _CMD_SET_KEY
+{
+ WORD wKCTL;
+ BYTE abyMacAddr[6];
+ BYTE abyKey[16];
+} CMD_SET_KEY, *PCMD_SET_KEY;
+
+typedef struct _CMD_CLRKEY_ENTRY
+{
+ BYTE abyKeyEntry[11];
+} CMD_CLRKEY_ENTRY, *PCMD_CLRKEY_ENTRY;
+
+typedef struct _CMD_WRITE_MISCFF
+{
+ DWORD adwMiscFFData[22][4]; //a key entry has only 22 dwords
+} CMD_WRITE_MISCFF, *PCMD_WRITE_MISCFF;
+
+typedef struct _CMD_SET_TSFTBTT
+{
+ BYTE abyTSF_TBTT[8];
+} CMD_SET_TSFTBTT, *PCMD_SET_TSFTBTT;
+
+typedef struct _CMD_SET_SSTIFS
+{
+ BYTE bySIFS;
+ BYTE byDIFS;
+ BYTE byEIFS;
+ BYTE bySlotTime;
+ BYTE byCwMax_Min;
+ BYTE byBBCR10;
+} CMD_SET_SSTIFS, *PCMD_SET_SSTIFS;
+
+typedef struct _CMD_CHANGE_BBTYPE
+{
+ BYTE bySIFS;
+ BYTE byDIFS;
+ BYTE byEIFS;
+ BYTE bySlotTime;
+ BYTE byCwMax_Min;
+ BYTE byBBCR10;
+ BYTE byBB_BBType; //CR88
+ BYTE byMAC_BBType;
+ DWORD dwRSPINF_b_1;
+ DWORD dwRSPINF_b_2;
+ DWORD dwRSPINF_b_55;
+ DWORD dwRSPINF_b_11;
+ WORD wRSPINF_a[9];
+} CMD_CHANGE_BBTYPE, *PCMD_CHANGE_BBTYPE;
+
+/*--------------------- Export Macros -------------------------*/
+
+#define EXCH_WORD(w) ( (WORD)((WORD)(w)<<8) | (WORD)((WORD)(w)>>8) )
+
+/*--------------------- Export Variables --------------------------*/
+
+/*--------------------- Export Functions --------------------------*/
+
+
+#endif // _RNDIS_H_
diff --git a/drivers/staging/vt6656/rxtx.c b/drivers/staging/vt6656/rxtx.c
new file mode 100644
index 000000000000..c5ce6f56aec0
--- /dev/null
+++ b/drivers/staging/vt6656/rxtx.c
@@ -0,0 +1,3280 @@
+/*
+ * 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.
+ * s_vGenerateMACHeader - Translate 802.3 to 802.11 header
+ * csBeacon_xmit - beacon tx function
+ * csMgmt_xmit - management tx function
+ * 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(__TBIT_H__)
+#include "tbit.h"
+#endif
+#if !defined(__HOSTAP_H__)
+#include "hostap.h"
+#endif
+#if !defined(__RF_H__)
+#include "rf.h"
+#endif
+#if !defined(__DATARATE_H__)
+#include "datarate.h"
+#endif
+#if !defined(__USBPIPE_H__)
+#include "usbpipe.h"
+#endif
+
+#ifdef WPA_SM_Transtatus
+#if !defined(__IOCMD_H__)
+#include "iocmd.h"
+#endif
+#endif
+/*--------------------- Static Definitions -------------------------*/
+
+/*--------------------- Static Classes ----------------------------*/
+
+/*--------------------- Static Variables --------------------------*/
+//static int msglevel =MSG_LEVEL_DEBUG;
+static int msglevel =MSG_LEVEL_INFO;
+
+/*--------------------- 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_vSaveTxPktInfo(
+ IN PSDevice pDevice,
+ IN BYTE byPktNum,
+ IN PBYTE pbyDestAddr,
+ IN WORD wPktLength,
+ IN WORD wFIFOCtl
+);
+
+static
+PVOID
+s_vGetFreeContext(
+ PSDevice pDevice
+ );
+
+
+static
+VOID
+s_vGenerateTxParameter(
+ IN PSDevice pDevice,
+ IN BYTE byPktType,
+ IN WORD wCurrentRate,
+ IN PVOID pTxBufHead,
+ IN PVOID pvRrvTime,
+ IN PVOID pvRTS,
+ IN PVOID pvCTS,
+ IN UINT cbFrameSize,
+ IN BOOL bNeedACK,
+ IN UINT uDMAIdx,
+ IN PSEthernetHeader psEthHeader
+ );
+
+
+static
+UINT
+s_uFillDataHead (
+ IN PSDevice pDevice,
+ IN BYTE byPktType,
+ IN WORD wCurrentRate,
+ IN PVOID pTxDataHead,
+ IN UINT cbFrameLength,
+ IN UINT uDMAIdx,
+ IN BOOL bNeedAck,
+ IN UINT uFragIdx,
+ IN UINT cbLastFragmentSize,
+ IN UINT uMACfragNum,
+ IN BYTE byFBOption
+ );
+
+
+
+
+static
+VOID
+s_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
+ );
+
+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_vSWencryption (
+ IN PSDevice pDevice,
+ IN PSKeyItem pTransmitKey,
+ IN PBYTE pbyPayloadHead,
+ IN WORD wPayloadSize
+ );
+
+static
+UINT
+s_uGetTxRsvTime (
+ IN PSDevice pDevice,
+ IN BYTE byPktType,
+ IN UINT cbFrameLength,
+ IN WORD wRate,
+ IN BOOL bNeedAck
+ );
+
+
+static
+UINT
+s_uGetRTSCTSRsvTime (
+ IN PSDevice pDevice,
+ IN BYTE byRTSRsvType,
+ IN BYTE byPktType,
+ IN UINT cbFrameLength,
+ IN WORD wCurrentRate
+ );
+
+static
+VOID
+s_vFillCTSHead (
+ IN PSDevice pDevice,
+ IN UINT uDMAIdx,
+ IN BYTE byPktType,
+ IN PVOID pvCTS,
+ IN UINT cbFrameLength,
+ IN BOOL bNeedAck,
+ IN BOOL bDisCRC,
+ IN WORD wCurrentRate,
+ IN BYTE byFBOption
+ );
+
+static
+VOID
+s_vFillRTSHead(
+ IN PSDevice pDevice,
+ IN BYTE byPktType,
+ IN PVOID pvRTS,
+ IN UINT cbFrameLength,
+ IN BOOL bNeedAck,
+ IN BOOL bDisCRC,
+ IN PSEthernetHeader psEthHeader,
+ IN WORD wCurrentRate,
+ IN BYTE byFBOption
+ );
+
+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
+ );
+
+
+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
+ );
+
+
+/*--------------------- Export Variables --------------------------*/
+
+static
+PVOID
+s_vGetFreeContext(
+ PSDevice pDevice
+ )
+{
+ PUSB_SEND_CONTEXT pContext = NULL;
+ PUSB_SEND_CONTEXT pReturnContext = NULL;
+ UINT ii;
+
+ DBG_PRT(MSG_LEVEL_DEBUG, KERN_INFO"GetFreeContext()\n");
+
+ for (ii = 0; ii < pDevice->cbTD; ii++) {
+ pContext = pDevice->apTD[ii];
+ if (pContext->bBoolInUse == FALSE) {
+ pContext->bBoolInUse = TRUE;
+ pReturnContext = pContext;
+ break;
+ }
+ }
+ if ( ii == pDevice->cbTD ) {
+ DBG_PRT(MSG_LEVEL_DEBUG, KERN_INFO"No Free Tx Context\n");
+ }
+ return ((PVOID) pReturnContext);
+}
+
+
+static
+VOID
+s_vSaveTxPktInfo(PSDevice pDevice, BYTE byPktNum, PBYTE pbyDestAddr, WORD wPktLength, WORD wFIFOCtl)
+{
+ PSStatCounter pStatistic=&(pDevice->scStatistic);
+
+
+ if (IS_BROADCAST_ADDRESS(pbyDestAddr))
+ pStatistic->abyTxPktInfo[byPktNum].byBroadMultiUni = TX_PKT_BROAD;
+ else if (IS_MULTICAST_ADDRESS(pbyDestAddr))
+ pStatistic->abyTxPktInfo[byPktNum].byBroadMultiUni = TX_PKT_MULTI;
+ else
+ pStatistic->abyTxPktInfo[byPktNum].byBroadMultiUni = TX_PKT_UNI;
+
+ pStatistic->abyTxPktInfo[byPktNum].wLength = wPktLength;
+ pStatistic->abyTxPktInfo[byPktNum].wFIFOCtl = wFIFOCtl;
+ MEMvCopy(pStatistic->abyTxPktInfo[byPktNum].abyDestAddr, pbyDestAddr, U_ETHER_ADDR_LEN);
+}
+
+
+
+
+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;
+
+
+
+ //Fill TXKEY
+ if (pTransmitKey == NULL)
+ return;
+
+ dwRevIVCounter = cpu_to_le32(pDevice->dwIVCounter);
+ *pdwIV = pDevice->dwIVCounter;
+ pDevice->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 |= (pDevice->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)(((pDevice->byKeyIndex << 6) & 0xc0) | 0x20); // 0x20 is ExtIV
+ // Append IV&ExtIV after Mac Header
+ *pdwExtIV = cpu_to_le32(pTransmitKey->dwTSC47_16);
+ DBG_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)(((pDevice->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);
+ //=======================================================================
+ }
+}
+
+
+
+
+/*byPktType : 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 byPktType,
+ IN UINT cbFrameLength,
+ IN WORD wRate,
+ IN BOOL bNeedAck
+ )
+{
+ UINT uDataTime, uAckTime;
+
+ uDataTime = BBuGetFrameTime(pDevice->byPreambleType, byPktType, cbFrameLength, wRate);
+ if (byPktType == PK_TYPE_11B) {//llb,CCK mode
+ uAckTime = BBuGetFrameTime(pDevice->byPreambleType, byPktType, 14, (WORD)pDevice->byTopCCKBasicRate);
+ } else {//11g 2.4G OFDM mode & 11a 5G OFDM mode
+ uAckTime = BBuGetFrameTime(pDevice->byPreambleType, byPktType, 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 byPktType,
+ IN UINT cbFrameLength,
+ IN WORD wCurrentRate
+ )
+{
+ UINT uRrvTime , uRTSTime, uCTSTime, uAckTime, uDataTime;
+
+ uRrvTime = uRTSTime = uCTSTime = uAckTime = uDataTime = 0;
+
+
+ uDataTime = BBuGetFrameTime(pDevice->byPreambleType, byPktType, cbFrameLength, wCurrentRate);
+ if (byRTSRsvType == 0) { //RTSTxRrvTime_bb
+ uRTSTime = BBuGetFrameTime(pDevice->byPreambleType, byPktType, 20, pDevice->byTopCCKBasicRate);
+ uCTSTime = uAckTime = BBuGetFrameTime(pDevice->byPreambleType, byPktType, 14, pDevice->byTopCCKBasicRate);
+ }
+ else if (byRTSRsvType == 1){ //RTSTxRrvTime_ba, only in 2.4GHZ
+ uRTSTime = BBuGetFrameTime(pDevice->byPreambleType, byPktType, 20, pDevice->byTopCCKBasicRate);
+ uCTSTime = BBuGetFrameTime(pDevice->byPreambleType, byPktType, 14, pDevice->byTopCCKBasicRate);
+ uAckTime = BBuGetFrameTime(pDevice->byPreambleType, byPktType, 14, pDevice->byTopOFDMBasicRate);
+ }
+ else if (byRTSRsvType == 2) { //RTSTxRrvTime_aa
+ uRTSTime = BBuGetFrameTime(pDevice->byPreambleType, byPktType, 20, pDevice->byTopOFDMBasicRate);
+ uCTSTime = uAckTime = BBuGetFrameTime(pDevice->byPreambleType, byPktType, 14, pDevice->byTopOFDMBasicRate);
+ }
+ else if (byRTSRsvType == 3) { //CTSTxRrvTime_ba, only in 2.4GHZ
+ uCTSTime = BBuGetFrameTime(pDevice->byPreambleType, byPktType, 14, pDevice->byTopCCKBasicRate);
+ uAckTime = BBuGetFrameTime(pDevice->byPreambleType, byPktType, 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 byPktType,
+ IN WORD wCurrentRate,
+ IN PVOID pTxDataHead,
+ IN UINT cbFrameLength,
+ IN UINT uDMAIdx,
+ IN BOOL bNeedAck,
+ IN UINT uFragIdx,
+ IN UINT cbLastFragmentSize,
+ IN UINT uMACfragNum,
+ IN BYTE byFBOption
+ )
+{
+
+ if (pTxDataHead == NULL) {
+ return 0;
+ }
+
+ if (byPktType == PK_TYPE_11GB || byPktType == PK_TYPE_11GA) {
+ if((uDMAIdx==TYPE_ATIMDMA)||(uDMAIdx==TYPE_BEACONDMA)) {
+ PSTxDataHead_ab pBuf = (PSTxDataHead_ab)pTxDataHead;
+ //Get SignalField,ServiceField,Length
+ BBvCaculateParameter(pDevice, cbFrameLength, wCurrentRate, byPktType,
+ (PWORD)&(pBuf->wTransmitLength), (PBYTE)&(pBuf->byServiceField), (PBYTE)&(pBuf->bySignalField)
+ );
+ //Get Duration and TimeStampOff
+ pBuf->wDuration = (WORD)s_uGetDataDuration(pDevice, DATADUR_A, cbFrameLength, byPktType,
+ wCurrentRate, bNeedAck, uFragIdx,
+ cbLastFragmentSize, uMACfragNum,
+ byFBOption); //1: 2.4GHz
+ if(uDMAIdx!=TYPE_ATIMDMA) {
+ pBuf->wTimeStampOff = wTimeStampOff[pDevice->byPreambleType%2][wCurrentRate%MAX_RATE];
+ }
+ return (pBuf->wDuration);
+ }
+ else { // DATA & MANAGE Frame
+ if (byFBOption == AUTO_FB_NONE) {
+ PSTxDataHead_g pBuf = (PSTxDataHead_g)pTxDataHead;
+ //Get SignalField,ServiceField,Length
+ BBvCaculateParameter(pDevice, cbFrameLength, wCurrentRate, byPktType,
+ (PWORD)&(pBuf->wTransmitLength_a), (PBYTE)&(pBuf->byServiceField_a), (PBYTE)&(pBuf->bySignalField_a)
+ );
+ BBvCaculateParameter(pDevice, cbFrameLength, pDevice->byTopCCKBasicRate, PK_TYPE_11B,
+ (PWORD)&(pBuf->wTransmitLength_b), (PBYTE)&(pBuf->byServiceField_b), (PBYTE)&(pBuf->bySignalField_b)
+ );
+ //Get Duration and TimeStamp
+ pBuf->wDuration_a = (WORD)s_uGetDataDuration(pDevice, DATADUR_A, cbFrameLength,
+ byPktType, wCurrentRate, bNeedAck, uFragIdx,
+ cbLastFragmentSize, uMACfragNum,
+ byFBOption); //1: 2.4GHz
+ pBuf->wDuration_b = (WORD)s_uGetDataDuration(pDevice, DATADUR_B, cbFrameLength,
+ PK_TYPE_11B, pDevice->byTopCCKBasicRate,
+ bNeedAck, uFragIdx, cbLastFragmentSize,
+ uMACfragNum, byFBOption); //1: 2.4GHz
+
+ pBuf->wTimeStampOff_a = wTimeStampOff[pDevice->byPreambleType%2][wCurrentRate%MAX_RATE];
+ pBuf->wTimeStampOff_b = 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, byPktType,
+ (PWORD)&(pBuf->wTransmitLength_a), (PBYTE)&(pBuf->byServiceField_a), (PBYTE)&(pBuf->bySignalField_a)
+ );
+ BBvCaculateParameter(pDevice, cbFrameLength, pDevice->byTopCCKBasicRate, PK_TYPE_11B,
+ (PWORD)&(pBuf->wTransmitLength_b), (PBYTE)&(pBuf->byServiceField_b), (PBYTE)&(pBuf->bySignalField_b)
+ );
+ //Get Duration and TimeStamp
+ pBuf->wDuration_a = (WORD)s_uGetDataDuration(pDevice, DATADUR_A, cbFrameLength, byPktType,
+ wCurrentRate, bNeedAck, uFragIdx, cbLastFragmentSize, uMACfragNum, byFBOption); //1: 2.4GHz
+ pBuf->wDuration_b = (WORD)s_uGetDataDuration(pDevice, DATADUR_B, cbFrameLength, PK_TYPE_11B,
+ pDevice->byTopCCKBasicRate, bNeedAck, uFragIdx, cbLastFragmentSize, uMACfragNum, byFBOption); //1: 2.4GHz
+ pBuf->wDuration_a_f0 = (WORD)s_uGetDataDuration(pDevice, DATADUR_A_F0, cbFrameLength, byPktType,
+ wCurrentRate, bNeedAck, uFragIdx, cbLastFragmentSize, uMACfragNum, byFBOption); //1: 2.4GHz
+ pBuf->wDuration_a_f1 = (WORD)s_uGetDataDuration(pDevice, DATADUR_A_F1, cbFrameLength, byPktType,
+ wCurrentRate, bNeedAck, uFragIdx, cbLastFragmentSize, uMACfragNum, byFBOption); //1: 2.4GHz
+ pBuf->wTimeStampOff_a = wTimeStampOff[pDevice->byPreambleType%2][wCurrentRate%MAX_RATE];
+ pBuf->wTimeStampOff_b = wTimeStampOff[pDevice->byPreambleType%2][pDevice->byTopCCKBasicRate%MAX_RATE];
+ return (pBuf->wDuration_a);
+ } //if (byFBOption == AUTO_FB_NONE)
+ }
+ }
+ else if (byPktType == PK_TYPE_11A) {
+ if ((byFBOption != AUTO_FB_NONE) && (uDMAIdx != TYPE_ATIMDMA) && (uDMAIdx != TYPE_BEACONDMA)) {
+ // Auto Fallback
+ PSTxDataHead_a_FB pBuf = (PSTxDataHead_a_FB)pTxDataHead;
+ //Get SignalField,ServiceField,Length
+ BBvCaculateParameter(pDevice, cbFrameLength, wCurrentRate, byPktType,
+ (PWORD)&(pBuf->wTransmitLength), (PBYTE)&(pBuf->byServiceField), (PBYTE)&(pBuf->bySignalField)
+ );
+ //Get Duration and TimeStampOff
+ pBuf->wDuration = (WORD)s_uGetDataDuration(pDevice, DATADUR_A, cbFrameLength, byPktType,
+ wCurrentRate, bNeedAck, uFragIdx, cbLastFragmentSize, uMACfragNum, byFBOption); //0: 5GHz
+ pBuf->wDuration_f0 = (WORD)s_uGetDataDuration(pDevice, DATADUR_A_F0, cbFrameLength, byPktType,
+ wCurrentRate, bNeedAck, uFragIdx, cbLastFragmentSize, uMACfragNum, byFBOption); //0: 5GHz
+ pBuf->wDuration_f1 = (WORD)s_uGetDataDuration(pDevice, DATADUR_A_F1, cbFrameLength, byPktType,
+ wCurrentRate, bNeedAck, uFragIdx, cbLastFragmentSize, uMACfragNum, byFBOption); //0: 5GHz
+ if(uDMAIdx!=TYPE_ATIMDMA) {
+ pBuf->wTimeStampOff = 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, byPktType,
+ (PWORD)&(pBuf->wTransmitLength), (PBYTE)&(pBuf->byServiceField), (PBYTE)&(pBuf->bySignalField)
+ );
+ //Get Duration and TimeStampOff
+ pBuf->wDuration = (WORD)s_uGetDataDuration(pDevice, DATADUR_A, cbFrameLength, byPktType,
+ wCurrentRate, bNeedAck, uFragIdx,
+ cbLastFragmentSize, uMACfragNum,
+ byFBOption);
+
+ if(uDMAIdx!=TYPE_ATIMDMA) {
+ pBuf->wTimeStampOff = wTimeStampOff[pDevice->byPreambleType%2][wCurrentRate%MAX_RATE];
+ }
+ return (pBuf->wDuration);
+ }
+ }
+ else if (byPktType == PK_TYPE_11B) {
+ PSTxDataHead_ab pBuf = (PSTxDataHead_ab)pTxDataHead;
+ //Get SignalField,ServiceField,Length
+ BBvCaculateParameter(pDevice, cbFrameLength, wCurrentRate, byPktType,
+ (PWORD)&(pBuf->wTransmitLength), (PBYTE)&(pBuf->byServiceField), (PBYTE)&(pBuf->bySignalField)
+ );
+ //Get Duration and TimeStampOff
+ pBuf->wDuration = (WORD)s_uGetDataDuration(pDevice, DATADUR_B, cbFrameLength, byPktType,
+ wCurrentRate, bNeedAck, uFragIdx,
+ cbLastFragmentSize, uMACfragNum,
+ byFBOption);
+ if (uDMAIdx != TYPE_ATIMDMA) {
+ pBuf->wTimeStampOff = wTimeStampOff[pDevice->byPreambleType%2][wCurrentRate%MAX_RATE];
+ }
+ return (pBuf->wDuration);
+ }
+ return 0;
+}
+
+
+
+
+static
+VOID
+s_vFillRTSHead (
+ IN PSDevice pDevice,
+ IN BYTE byPktType,
+ 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 (byPktType == PK_TYPE_11GB || byPktType == 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, byPktType,
+ (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, byPktType, 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, byPktType, 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, byPktType,
+ (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, byPktType, 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, byPktType, 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, byPktType, 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, byPktType, 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, byPktType, 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, byPktType, 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 (byPktType == PK_TYPE_11A) {
+ if (byFBOption == AUTO_FB_NONE) {
+ PSRTS_ab pBuf = (PSRTS_ab)pvRTS;
+ //Get SignalField,ServiceField,Length
+ BBvCaculateParameter(pDevice, uRTSFrameLen, pDevice->byTopOFDMBasicRate, byPktType,
+ (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, byPktType, 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, byPktType,
+ (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, byPktType, 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, byPktType, 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, byPktType, 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 (byPktType == 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, byPktType, 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 byPktType,
+ 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 (byPktType == PK_TYPE_11GB || byPktType == 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, byPktType, 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, byPktType, 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, byPktType, 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, byPktType, 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
+ * uDMAIdx - DMA Index
+ * Out:
+ * none
+ *
+ * Return Value: none
+ *
+-*/
+// UINT cbFrameSize,//Hdr+Payload+FCS
+static
+VOID
+s_vGenerateTxParameter (
+ IN PSDevice pDevice,
+ IN BYTE byPktType,
+ IN WORD wCurrentRate,
+ IN PVOID pTxBufHead,
+ IN PVOID pvRrvTime,
+ IN PVOID pvRTS,
+ IN PVOID pvCTS,
+ IN UINT cbFrameSize,
+ IN BOOL bNeedACK,
+ IN UINT uDMAIdx,
+ IN PSEthernetHeader psEthHeader
+ )
+{
+ UINT cbMACHdLen = WLAN_HDR_ADDR3_LEN; //24
+ WORD wFifoCtl;
+ BOOL bDisCRC = FALSE;
+ BYTE byFBOption = AUTO_FB_NONE;
+// WORD wCurrentRate = pDevice->wCurrentRate;
+
+ //DBG_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 (byPktType == PK_TYPE_11GB || byPktType == 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, byPktType, cbFrameSize, wCurrentRate));//2:RTSTxRrvTime_aa, 1:2.4GHz
+ pBuf->wRTSTxRrvTime_ba = cpu_to_le16((WORD)s_uGetRTSCTSRsvTime(pDevice, 1, byPktType, cbFrameSize, wCurrentRate));//1:RTSTxRrvTime_ba, 1:2.4GHz
+ pBuf->wRTSTxRrvTime_bb = cpu_to_le16((WORD)s_uGetRTSCTSRsvTime(pDevice, 0, byPktType, cbFrameSize, wCurrentRate));//0:RTSTxRrvTime_bb, 1:2.4GHz
+ pBuf->wTxRrvTime_a = cpu_to_le16((WORD) s_uGetTxRsvTime(pDevice, byPktType, 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, byPktType, 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, byPktType, 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, byPktType, cbFrameSize, wCurrentRate));//3:CTSTxRrvTime_Ba, 1:2.4GHz
+ }
+ //Fill CTS
+ s_vFillCTSHead(pDevice, uDMAIdx, byPktType, pvCTS, cbFrameSize, bNeedACK, bDisCRC, wCurrentRate, byFBOption);
+ }
+ }
+ else if (byPktType == 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, byPktType, cbFrameSize, wCurrentRate));//2:RTSTxRrvTime_aa, 0:5GHz
+ pBuf->wTxRrvTime = cpu_to_le16((WORD)s_uGetTxRsvTime(pDevice, byPktType, cbFrameSize, wCurrentRate, bNeedACK));//0:OFDM
+ }
+ //Fill RTS
+ s_vFillRTSHead(pDevice, byPktType, 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 (byPktType == 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, byPktType, 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, byPktType, 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
+ }
+ }
+ }
+ //DBG_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
+*/
+
+
+BOOL
+s_bPacketToWirelessUsb(
+ IN PSDevice pDevice,
+ IN BYTE byPktType,
+ IN PBYTE usbPacketBuf,
+ IN BOOL bNeedEncryption,
+ IN UINT uSkbPacketLen,
+ IN UINT uDMAIdx,
+ IN PSEthernetHeader psEthHeader,
+ IN PBYTE pPacket,
+ IN PSKeyItem pTransmitKey,
+ IN UINT uNodeIndex,
+ IN WORD wCurrentRate,
+ OUT UINT *pcbHeaderLen,
+ OUT UINT *pcbTotalLen
+ )
+{
+ PSMgmtObject pMgmt = &(pDevice->sMgmtObj);
+ UINT cbFrameSize,cbFrameBodySize;
+ PTX_BUFFER pTxBufHead;
+ UINT cb802_1_H_len;
+ UINT cbIVlen=0,cbICVlen=0,cbMIClen=0,cbMACHdLen=0,cbFCSlen=4;
+ UINT cbMICHDR = 0;
+ BOOL bNeedACK,bRTS;
+ PBYTE pbyType,pbyMacHdr,pbyIVHead,pbyPayloadHead,pbyTxBufferAddr;
+ BYTE abySNAP_RFC1042[6] = {0xAA, 0xAA, 0x03, 0x00, 0x00, 0x00};
+ BYTE abySNAP_Bridgetunnel[6] = {0xAA, 0xAA, 0x03, 0x00, 0x00, 0xF8};
+ UINT uDuration;
+ UINT cbHeaderLength= 0,uPadding = 0;
+ PVOID pvRrvTime;
+ PSMICHDRHead pMICHDR;
+ PVOID pvRTS;
+ PVOID pvCTS;
+ PVOID pvTxDataHd;
+ BYTE byFBOption = AUTO_FB_NONE,byFragType;
+ WORD wTxBufSize;
+ DWORD dwMICKey0,dwMICKey1,dwMIC_Priority,dwCRC;
+ PDWORD pdwMIC_L,pdwMIC_R;
+ BOOL bSoftWEP = FALSE;
+
+
+
+
+ pvRrvTime = pMICHDR = pvRTS = pvCTS = pvTxDataHd = NULL;
+ if ((bNeedEncryption) && (pTransmitKey != NULL)) {
+ if (((PSKeyTable) (pTransmitKey->pvKeyTable))->bSoftWEP == TRUE) {
+ // WEP 256
+ bSoftWEP = TRUE;
+ }
+ }
+
+ pTxBufHead = (PTX_BUFFER) usbPacketBuf;
+ ZERO_MEMORY(pTxBufHead, sizeof(TX_BUFFER));
+
+ // Get pkt type
+ if (ntohs(psEthHeader->wType) > MAX_DATA_LEN) {
+ if (pDevice->dwDiagRefCount == 0) {
+ cb802_1_H_len = 8;
+ } else {
+ cb802_1_H_len = 2;
+ }
+ } else {
+ cb802_1_H_len = 0;
+ }
+
+ cbFrameBodySize = uSkbPacketLen - U_HEADER_LEN + cb802_1_H_len;
+
+ //Set packet type
+ pTxBufHead->wFIFOCtl |= (WORD)(byPktType<<8);
+
+ if (pDevice->dwDiagRefCount != 0) {
+ bNeedACK = FALSE;
+ pTxBufHead->wFIFOCtl = pTxBufHead->wFIFOCtl & (~FIFOCTL_NEEDACK);
+ } else { //if (pDevice->dwDiagRefCount != 0) {
+ 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;
+ }
+ }
+ else {
+ // MSDUs in Infra mode always need ACK
+ bNeedACK = TRUE;
+ pTxBufHead->wFIFOCtl |= FIFOCTL_NEEDACK;
+ }
+ } //if (pDevice->dwDiagRefCount != 0) {
+
+ pTxBufHead->wTimeStamp = DEFAULT_MSDU_LIFETIME_RES_64us;
+
+ //Set FIFOCTL_LHEAD
+ if (pDevice->bLongHeader)
+ pTxBufHead->wFIFOCtl |= FIFOCTL_LHEAD;
+
+ if (pDevice->bSoftwareGenCrcErr) {
+ pTxBufHead->wFIFOCtl |= FIFOCTL_CRCDIS; // set tx descriptors to NO hardware CRC
+ }
+
+ //Set FRAGCTL_MACHDCNT
+ if (pDevice->bLongHeader) {
+ cbMACHdLen = WLAN_HDR_ADDR3_LEN + 6;
+ } else {
+ cbMACHdLen = WLAN_HDR_ADDR3_LEN;
+ }
+ pTxBufHead->wFragCtl |= (WORD)(cbMACHdLen << 10);
+
+ //Set FIFOCTL_GrpAckPolicy
+ if (pDevice->bGrpAckPolicy == TRUE) {//0000 0100 0000 0000
+ pTxBufHead->wFIFOCtl |= FIFOCTL_GRPACK;
+ }
+
+ //Set Auto Fallback Ctl
+ if (wCurrentRate >= RATE_18M) {
+ if (pDevice->byAutoFBCtrl == AUTO_FB_0) {
+ pTxBufHead->wFIFOCtl |= FIFOCTL_AUTO_FB_0;
+ byFBOption = AUTO_FB_0;
+ } else if (pDevice->byAutoFBCtrl == AUTO_FB_1) {
+ pTxBufHead->wFIFOCtl |= FIFOCTL_AUTO_FB_1;
+ byFBOption = AUTO_FB_1;
+ }
+ }
+
+ if (bSoftWEP != TRUE) {
+ if ((bNeedEncryption) && (pTransmitKey != NULL)) { //WEP enabled
+ if (pTransmitKey->byCipherSuite == KEY_CTL_WEP) { //WEP40 or WEP104
+ pTxBufHead->wFragCtl |= FRAGCTL_LEGACY;
+ }
+ if (pTransmitKey->byCipherSuite == KEY_CTL_TKIP) {
+ DBG_PRT(MSG_LEVEL_DEBUG, KERN_INFO"Tx Set wFragCtl == FRAGCTL_TKIP\n");
+ pTxBufHead->wFragCtl |= FRAGCTL_TKIP;
+ }
+ else if (pTransmitKey->byCipherSuite == KEY_CTL_CCMP) { //CCMP
+ pTxBufHead->wFragCtl |= FRAGCTL_AES;
+ }
+ }
+ }
+
+
+ if ((bNeedEncryption) && (pTransmitKey != NULL)) {
+ 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;
+ }
+ if (pTransmitKey->byCipherSuite == KEY_CTL_CCMP) {
+ cbIVlen = 8;//RSN Header
+ cbICVlen = 8;//MIC
+ cbMICHDR = sizeof(SMICHDRHead);
+ }
+ if (bSoftWEP == FALSE) {
+ //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) ) {
+ bRTS = FALSE;
+ } else {
+ bRTS = TRUE;
+ pTxBufHead->wFIFOCtl |= (FIFOCTL_RTS | FIFOCTL_LRETRY);
+ }
+
+ pbyTxBufferAddr = (PBYTE) &(pTxBufHead->adwTxKey[0]);
+ wTxBufSize = sizeof(STxBufHead);
+ if (byPktType == PK_TYPE_11GB || byPktType == 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 if (bRTS == FALSE) { //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) {//RTS_need
+ 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(SRrvTime_ab) + cbMICHDR + sizeof(SRTS_ab));
+ cbHeaderLength = wTxBufSize + sizeof(PSRrvTime_ab) + cbMICHDR + sizeof(SRTS_ab) + sizeof(STxDataHead_ab);
+ }
+ else if (bRTS == FALSE) { //RTS_needless, no 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(SRrvTime_ab) + cbMICHDR + sizeof(SRTS_a_FB));
+ cbHeaderLength = wTxBufSize + sizeof(PSRrvTime_ab) + cbMICHDR + sizeof(SRTS_a_FB) + sizeof(STxDataHead_a_FB);
+ }
+ else if (bRTS == FALSE) { //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
+ }
+
+ pbyMacHdr = (PBYTE)(pbyTxBufferAddr + cbHeaderLength);
+ pbyIVHead = (PBYTE)(pbyMacHdr + cbMACHdLen + uPadding);
+ pbyPayloadHead = (PBYTE)(pbyMacHdr + cbMACHdLen + uPadding + cbIVlen);
+
+
+ //=========================
+ // No Fragmentation
+ //=========================
+ DBG_PRT(MSG_LEVEL_DEBUG, KERN_INFO"No Fragmentation...\n");
+ byFragType = FRAGCTL_NONFRAG;
+ //uDMAIdx = TYPE_AC0DMA;
+ //pTxBufHead = (PSTxBufHead) &(pTxBufHead->adwTxKey[0]);
+
+
+ //Fill FIFO,RrvTime,RTS,and CTS
+ s_vGenerateTxParameter(pDevice, byPktType, wCurrentRate, (PVOID)pbyTxBufferAddr, pvRrvTime, pvRTS, pvCTS,
+ cbFrameSize, bNeedACK, uDMAIdx, psEthHeader);
+ //Fill DataHead
+ uDuration = s_uFillDataHead(pDevice, byPktType, wCurrentRate, pvTxDataHd, cbFrameSize, uDMAIdx, bNeedACK,
+ 0, 0, 1/*uMACfragNum*/, byFBOption);
+ // Generate TX MAC Header
+ s_vGenerateMACHeader(pDevice, pbyMacHdr, (WORD)uDuration, psEthHeader, bNeedEncryption,
+ byFragType, uDMAIdx, 0);
+
+ if (bNeedEncryption == TRUE) {
+ //Fill TXKEY
+ 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;
+ }
+ }
+
+ // 802.1H
+ if (ntohs(psEthHeader->wType) > MAX_DATA_LEN) {
+ if (pDevice->dwDiagRefCount == 0) {
+ if ( (psEthHeader->wType == TYPE_PKT_IPX) ||
+ (psEthHeader->wType == cpu_to_le16(0xF380))) {
+ MEMvCopy((PBYTE) (pbyPayloadHead), &abySNAP_Bridgetunnel[0], 6);
+ } else {
+ MEMvCopy((PBYTE) (pbyPayloadHead), &abySNAP_RFC1042[0], 6);
+ }
+ pbyType = (PBYTE) (pbyPayloadHead + 6);
+ MEMvCopy(pbyType, &(psEthHeader->wType), sizeof(WORD));
+ } else {
+ MEMvCopy((PBYTE) (pbyPayloadHead), &(psEthHeader->wType), sizeof(WORD));
+
+ }
+
+ }
+
+
+ if (pPacket != NULL) {
+ // Copy the Packet into a tx Buffer
+ MEMvCopy((pbyPayloadHead + cb802_1_H_len),
+ (pPacket + U_HEADER_LEN),
+ uSkbPacketLen - U_HEADER_LEN
+ );
+
+ } else {
+ // while bRelayPacketSend psEthHeader is point to header+payload
+ MEMvCopy((pbyPayloadHead + cb802_1_H_len), ((PBYTE)psEthHeader)+U_HEADER_LEN, uSkbPacketLen - U_HEADER_LEN);
+ }
+
+ ASSERT(uLength == cbNdisBodySize);
+
+ if ((bNeedEncryption == TRUE) && (pTransmitKey != NULL) && (pTransmitKey->byCipherSuite == KEY_CTL_TKIP)) {
+
+ ///////////////////////////////////////////////////////////////////
+
+ if (pDevice->sMgmtObj.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);
+ DBG_PRT(MSG_LEVEL_DEBUG, KERN_INFO"MIC KEY: %lX, %lX\n", dwMICKey0, dwMICKey1);
+
+ ///////////////////////////////////////////////////////////////////
+
+ //DBG_PRN_GRP12(("Length:%d, %d\n", cbFrameBodySize, uFromHDtoPLDLength));
+ //for (ii = 0; ii < cbFrameBodySize; ii++) {
+ // DBG_PRN_GRP12(("%02x ", *((PBYTE)((pbyPayloadHead + cb802_1_H_len) + ii))));
+ //}
+ //DBG_PRN_GRP12(("\n\n\n"));
+
+ MIC_vAppend(pbyPayloadHead, cbFrameBodySize);
+
+ pdwMIC_L = (PDWORD)(pbyPayloadHead + cbFrameBodySize);
+ pdwMIC_R = (PDWORD)(pbyPayloadHead + cbFrameBodySize + 4);
+
+ MIC_vGetMIC(pdwMIC_L, pdwMIC_R);
+ MIC_vUnInit();
+
+ if (pDevice->bTxMICFail == TRUE) {
+ *pdwMIC_L = 0;
+ *pdwMIC_R = 0;
+ pDevice->bTxMICFail = FALSE;
+ }
+ //DBG_PRT(MSG_LEVEL_DEBUG, KERN_INFO"uLength: %d, %d\n", uLength, cbFrameBodySize);
+ //DBG_PRT(MSG_LEVEL_DEBUG, KERN_INFO"cbReqCount:%d, %d, %d, %d\n", cbReqCount, cbHeaderLength, uPadding, cbIVlen);
+ //DBG_PRT(MSG_LEVEL_DEBUG, KERN_INFO"MIC:%lX, %lX\n", *pdwMIC_L, *pdwMIC_R);
+ }
+
+
+ if (bSoftWEP == TRUE) {
+
+ s_vSWencryption(pDevice, pTransmitKey, (pbyPayloadHead), (WORD)(cbFrameBodySize + cbMIClen));
+
+ } else if ( ((pDevice->eEncryptionStatus == Ndis802_11Encryption1Enabled) && (bNeedEncryption == TRUE)) ||
+ ((pDevice->eEncryptionStatus == Ndis802_11Encryption2Enabled) && (bNeedEncryption == TRUE)) ||
+ ((pDevice->eEncryptionStatus == Ndis802_11Encryption3Enabled) && (bNeedEncryption == TRUE)) ) {
+ cbFrameSize -= cbICVlen;
+ }
+
+ if (pDevice->bSoftwareGenCrcErr == TRUE) {
+ UINT cbLen;
+ PDWORD pdwCRC;
+
+ dwCRC = 0xFFFFFFFFL;
+ cbLen = cbFrameSize - cbFCSlen;
+ // calculate CRC, and wrtie CRC value to end of TD
+ dwCRC = CRCdwGetCrc32Ex(pbyMacHdr, cbLen, dwCRC);
+ pdwCRC = (PDWORD)(pbyMacHdr + cbLen);
+ // finally, we must invert dwCRC to get the correct answer
+ *pdwCRC = ~dwCRC;
+ // Force Error
+ *pdwCRC -= 1;
+ } else {
+ cbFrameSize -= cbFCSlen;
+ }
+
+ *pcbHeaderLen = cbHeaderLength;
+ *pcbTotalLen = cbHeaderLength + cbFrameSize ;
+
+
+ //Set FragCtl in TxBufferHead
+ pTxBufHead->wFragCtl |= (WORD)byFragType;
+
+
+ return TRUE;
+
+}
+
+
+/*+
+ *
+ * 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
+s_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;
+ }
+}
+
+
+
+/*+
+ *
+ * Description:
+ * Request instructs a MAC to transmit a 802.11 management packet through
+ * the adapter onto the medium.
+ *
+ * Parameters:
+ * In:
+ * hDeviceContext - Pointer to the adapter
+ * pPacket - A pointer to a descriptor for the packet to transmit
+ * Out:
+ * none
+ *
+ * Return Value: CMD_STATUS_PENDING if MAC Tx resource avaliable; otherwise FALSE
+ *
+-*/
+
+CMD_STATUS csMgmt_xmit(
+ IN PSDevice pDevice,
+ IN PSTxMgmtPacket pPacket
+ )
+{
+ BYTE byPktType;
+ 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->sMgmtObj);
+ WORD wCurrentRate = RATE_1M;
+ PTX_BUFFER pTX_Buffer;
+ PUSB_SEND_CONTEXT pContext;
+
+
+
+ pContext = (PUSB_SEND_CONTEXT)s_vGetFreeContext(pDevice);
+
+ if (NULL == pContext) {
+ DBG_PRT(MSG_LEVEL_DEBUG, KERN_INFO"ManagementSend TX...NO CONTEXT!\n");
+ return CMD_STATUS_RESOURCES;
+ }
+
+ pTX_Buffer = (PTX_BUFFER) (&pContext->Data[0]);
+ pbyTxBufferAddr = (PBYTE)&(pTX_Buffer->adwTxKey[0]);
+ cbFrameBodySize = pPacket->cbPayloadLen;
+ pTxBufHead = (PSTxBufHead) pbyTxBufferAddr;
+ wTxBufSize = sizeof(STxBufHead);
+ memset(pTxBufHead, 0, wTxBufSize);
+
+ if (pDevice->byBBType == BB_TYPE_11A) {
+ wCurrentRate = RATE_6M;
+ byPktType = PK_TYPE_11A;
+ } else {
+ wCurrentRate = RATE_1M;
+ byPktType = 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 (pMgmt->eScanState != WMAC_NO_SCANNING) {
+ RFbSetPower(pDevice, wCurrentRate, pDevice->byCurrentCh);
+ } else {
+ RFbSetPower(pDevice, wCurrentRate, pMgmt->uCurrChannel);
+ }
+ pDevice->wCurrentRate = wCurrentRate;
+
+
+ //Set packet type
+ if (byPktType == PK_TYPE_11A) {//0000 0000 0000 0000
+ pTxBufHead->wFIFOCtl = 0;
+ }
+ else if (byPktType == PK_TYPE_11B) {//0000 0001 0000 0000
+ pTxBufHead->wFIFOCtl |= FIFOCTL_11B;
+ }
+ else if (byPktType == PK_TYPE_11GB) {//0000 0010 0000 0000
+ pTxBufHead->wFIFOCtl |= FIFOCTL_11GB;
+ }
+ else if (byPktType == 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 (byPktType == PK_TYPE_11GB || byPktType == 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, byPktType, wCurrentRate, pbyTxBufferAddr, pvRrvTime, pvRTS, pCTS,
+ cbFrameSize, bNeedACK, TYPE_TXDMA0, &sEthHeader);
+
+ //Fill DataHead
+ uDuration = s_uFillDataHead(pDevice, byPktType, wCurrentRate, pvTxDataHd, cbFrameSize, TYPE_TXDMA0, bNeedACK,
+ 0, 0, 1, AUTO_FB_NONE);
+
+ 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);
+ 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) {
+ DBG_PRT(MSG_LEVEL_DEBUG, KERN_INFO"Get GTK.\n");
+ break;
+ }
+ } else {
+ DBG_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;
+ DBG_PRT(MSG_LEVEL_DEBUG, KERN_INFO"KEY is NULL. OP Mode[%d]\n", pDevice->eOPMode);
+ } else {
+ DBG_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 (byPktType == PK_TYPE_11GB || byPktType == 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);
+ }
+ }
+
+
+ pTX_Buffer->wTxByteCount = cpu_to_le16((WORD)(cbReqCount));
+ pTX_Buffer->byPKTNO = (BYTE) (((wCurrentRate<<4) &0x00F0) | ((pDevice->wSeqCounter - 1) & 0x000F));
+ pTX_Buffer->byType = 0x00;
+
+ pContext->pPacket = NULL;
+ pContext->Type = CONTEXT_MGMT_PACKET;
+ pContext->uBufLen = (WORD)cbReqCount + 4; //USB header
+
+ if (WLAN_GET_FC_TODS(pMACHeader->wFrameCtl) == 0) {
+ s_vSaveTxPktInfo(pDevice, (BYTE) (pTX_Buffer->byPKTNO & 0x0F), &(pMACHeader->abyAddr1[0]),(WORD)cbFrameSize,pTX_Buffer->wFIFOCtl);
+ }
+ else {
+ s_vSaveTxPktInfo(pDevice, (BYTE) (pTX_Buffer->byPKTNO & 0x0F), &(pMACHeader->abyAddr3[0]),(WORD)cbFrameSize,pTX_Buffer->wFIFOCtl);
+ }
+
+ PIPEnsSendBulkOut(pDevice,pContext);
+ return CMD_STATUS_PENDING;
+}
+
+
+CMD_STATUS
+csBeacon_xmit(
+ IN PSDevice pDevice,
+ IN PSTxMgmtPacket pPacket
+ )
+{
+
+ UINT cbFrameSize = pPacket->cbMPDULen + WLAN_FCS_LEN;
+ UINT cbHeaderSize = 0;
+ WORD wTxBufSize = sizeof(STxShortBufHead);
+ PSTxShortBufHead pTxBufHead;
+ PS802_11Header pMACHeader;
+ PSTxDataHead_ab pTxDataHead;
+ WORD wCurrentRate;
+ UINT cbFrameBodySize;
+ UINT cbReqCount;
+ PBEACON_BUFFER pTX_Buffer;
+ PBYTE pbyTxBufferAddr;
+ PUSB_SEND_CONTEXT pContext;
+ CMD_STATUS status;
+
+
+ pContext = (PUSB_SEND_CONTEXT)s_vGetFreeContext(pDevice);
+ if (NULL == pContext) {
+ status = CMD_STATUS_RESOURCES;
+ DBG_PRT(MSG_LEVEL_DEBUG, KERN_INFO"ManagementSend TX...NO CONTEXT!\n");
+ return status ;
+ }
+ pTX_Buffer = (PBEACON_BUFFER) (&pContext->Data[0]);
+ pbyTxBufferAddr = (PBYTE)&(pTX_Buffer->wFIFOCtl);
+
+ cbFrameBodySize = pPacket->cbPayloadLen;
+
+ pTxBufHead = (PSTxShortBufHead) pbyTxBufferAddr;
+ wTxBufSize = sizeof(STxShortBufHead);
+ memset(pTxBufHead, 0, wTxBufSize);
+
+ if (pDevice->byBBType == BB_TYPE_11A) {
+ wCurrentRate = RATE_6M;
+ pTxDataHead = (PSTxDataHead_ab) (pbyTxBufferAddr + wTxBufSize);
+ //Get SignalField,ServiceField,Length
+ BBvCaculateParameter(pDevice, cbFrameSize, wCurrentRate, PK_TYPE_11A,
+ (PWORD)&(pTxDataHead->wTransmitLength), (PBYTE)&(pTxDataHead->byServiceField), (PBYTE)&(pTxDataHead->bySignalField)
+ );
+ //Get Duration and TimeStampOff
+ pTxDataHead->wDuration = cpu_to_le16((WORD)s_uGetDataDuration(pDevice, DATADUR_A, cbFrameSize, PK_TYPE_11A,
+ wCurrentRate, FALSE, 0, 0, 1, AUTO_FB_NONE));
+ pTxDataHead->wTimeStampOff = wTimeStampOff[pDevice->byPreambleType%2][wCurrentRate%MAX_RATE];
+ cbHeaderSize = wTxBufSize + sizeof(STxDataHead_ab);
+ } else {
+ wCurrentRate = RATE_1M;
+ pTxBufHead->wFIFOCtl |= FIFOCTL_11B;
+ pTxDataHead = (PSTxDataHead_ab) (pbyTxBufferAddr + wTxBufSize);
+ //Get SignalField,ServiceField,Length
+ BBvCaculateParameter(pDevice, cbFrameSize, wCurrentRate, PK_TYPE_11B,
+ (PWORD)&(pTxDataHead->wTransmitLength), (PBYTE)&(pTxDataHead->byServiceField), (PBYTE)&(pTxDataHead->bySignalField)
+ );
+ //Get Duration and TimeStampOff
+ pTxDataHead->wDuration = cpu_to_le16((WORD)s_uGetDataDuration(pDevice, DATADUR_B, cbFrameSize, PK_TYPE_11B,
+ wCurrentRate, FALSE, 0, 0, 1, AUTO_FB_NONE));
+ pTxDataHead->wTimeStampOff = wTimeStampOff[pDevice->byPreambleType%2][wCurrentRate%MAX_RATE];
+ cbHeaderSize = wTxBufSize + sizeof(STxDataHead_ab);
+ }
+
+ //Generate Beacon Header
+ pMACHeader = (PS802_11Header)(pbyTxBufferAddr + 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;
+
+ cbReqCount = cbHeaderSize + WLAN_HDR_ADDR3_LEN + cbFrameBodySize;
+
+ pTX_Buffer->wTxByteCount = (WORD)cbReqCount;
+ pTX_Buffer->byPKTNO = (BYTE) (((wCurrentRate<<4) &0x00F0) | ((pDevice->wSeqCounter - 1) & 0x000F));
+ pTX_Buffer->byType = 0x01;
+
+ pContext->pPacket = NULL;
+ pContext->Type = CONTEXT_MGMT_PACKET;
+ pContext->uBufLen = (WORD)cbReqCount + 4; //USB header
+
+ PIPEnsSendBulkOut(pDevice,pContext);
+ return CMD_STATUS_PENDING;
+
+}
+
+
+
+
+
+VOID
+vDMA0_tx_80211(PSDevice pDevice, struct sk_buff *skb) {
+
+ PSMgmtObject pMgmt = &(pDevice->sMgmtObj);
+ BYTE byPktType;
+ 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;
+ 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;
+ PTX_BUFFER pTX_Buffer;
+ PUSB_SEND_CONTEXT pContext;
+// PWLAN_IE pItem;
+
+
+ pvRrvTime = pMICHDR = pvRTS = pvCTS = pvTxDataHd = NULL;
+
+ if(skb->len <= WLAN_HDR_ADDR3_LEN) {
+ cbFrameBodySize = 0;
+ }
+ else {
+ cbFrameBodySize = skb->len - WLAN_HDR_ADDR3_LEN;
+ }
+ p80211Header = (PUWLAN_80211HDR)skb->data;
+
+ pContext = (PUSB_SEND_CONTEXT)s_vGetFreeContext(pDevice);
+
+ if (NULL == pContext) {
+ DBG_PRT(MSG_LEVEL_DEBUG, KERN_INFO"DMA0 TX...NO CONTEXT!\n");
+ dev_kfree_skb_irq(skb);
+ return ;
+ }
+
+ pTX_Buffer = (PTX_BUFFER)(&pContext->Data[0]);
+ pbyTxBufferAddr = (PBYTE)(&pTX_Buffer->adwTxKey[0]);
+ pTxBufHead = (PSTxBufHead) pbyTxBufferAddr;
+ wTxBufSize = sizeof(STxBufHead);
+ memset(pTxBufHead, 0, wTxBufSize);
+
+ if (pDevice->byBBType == BB_TYPE_11A) {
+ wCurrentRate = RATE_6M;
+ byPktType = PK_TYPE_11A;
+ } else {
+ wCurrentRate = RATE_1M;
+ byPktType = 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 (pMgmt->eScanState != WMAC_NO_SCANNING) {
+ RFbSetPower(pDevice, wCurrentRate, pDevice->byCurrentCh);
+ } else {
+ RFbSetPower(pDevice, wCurrentRate, pMgmt->uCurrChannel);
+ }
+
+ DBG_PRT(MSG_LEVEL_DEBUG, KERN_INFO"vDMA0_tx_80211: p80211Header->sA3.wFrameCtl = %x \n", p80211Header->sA3.wFrameCtl);
+
+ //Set packet type
+ if (byPktType == PK_TYPE_11A) {//0000 0000 0000 0000
+ pTxBufHead->wFIFOCtl = 0;
+ }
+ else if (byPktType == PK_TYPE_11B) {//0000 0001 0000 0000
+ pTxBufHead->wFIFOCtl |= FIFOCTL_11B;
+ }
+ else if (byPktType == PK_TYPE_11GB) {//0000 0010 0000 0000
+ pTxBufHead->wFIFOCtl |= FIFOCTL_11GB;
+ }
+ else if (byPktType == 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 (BSSbIsSTAInNodeDB(pDevice, (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 (byPktType == PK_TYPE_11GB || byPktType == 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, byPktType, wCurrentRate, pbyTxBufferAddr, pvRrvTime, pvRTS, pvCTS,
+ cbFrameSize, bNeedACK, TYPE_TXDMA0, &sEthHeader);
+
+ //Fill DataHead
+ uDuration = s_uFillDataHead(pDevice, byPktType, wCurrentRate, pvTxDataHd, cbFrameSize, TYPE_TXDMA0, bNeedACK,
+ 0, 0, 1, AUTO_FB_NONE);
+
+ 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, skb->data, cbMacHdLen);
+
+ // version set to 0, patch for hostapd deamon
+ pMACHeader->wFrameCtl &= cpu_to_le16(0xfffc);
+ memcpy(pbyPayloadHead, (skb->data + 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);
+ DBG_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;
+ }
+
+ DBG_PRT(MSG_LEVEL_DEBUG, KERN_INFO"uLength: %d, %d\n", uLength, cbFrameBodySize);
+ DBG_PRT(MSG_LEVEL_DEBUG, KERN_INFO"cbReqCount:%d, %d, %d, %d\n", cbReqCount, cbHeaderSize, uPadding, cbIVlen);
+ DBG_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 (byPktType == PK_TYPE_11GB || byPktType == 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);
+ }
+ }
+
+ pTX_Buffer->wTxByteCount = cpu_to_le16((WORD)(cbReqCount));
+ pTX_Buffer->byPKTNO = (BYTE) (((wCurrentRate<<4) &0x00F0) | ((pDevice->wSeqCounter - 1) & 0x000F));
+ pTX_Buffer->byType = 0x00;
+
+ pContext->pPacket = skb;
+ pContext->Type = CONTEXT_MGMT_PACKET;
+ pContext->uBufLen = (WORD)cbReqCount + 4; //USB header
+
+ if (WLAN_GET_FC_TODS(pMACHeader->wFrameCtl) == 0) {
+ s_vSaveTxPktInfo(pDevice, (BYTE) (pTX_Buffer->byPKTNO & 0x0F), &(pMACHeader->abyAddr1[0]),(WORD)cbFrameSize,pTX_Buffer->wFIFOCtl);
+ }
+ else {
+ s_vSaveTxPktInfo(pDevice, (BYTE) (pTX_Buffer->byPKTNO & 0x0F), &(pMACHeader->abyAddr3[0]),(WORD)cbFrameSize,pTX_Buffer->wFIFOCtl);
+ }
+ PIPEnsSendBulkOut(pDevice,pContext);
+ return ;
+
+}
+
+
+
+
+//TYPE_AC0DMA data tx
+/*
+ * Description:
+ * Tx packet via AC0DMA(DMA1)
+ *
+ * Parameters:
+ * In:
+ * pDevice - Pointer to the adapter
+ * skb - Pointer to tx skb packet
+ * Out:
+ * void
+ *
+ * Return Value: NULL
+ */
+
+
+
+NTSTATUS
+nsDMA_tx_packet(
+ IN PSDevice pDevice,
+ IN UINT uDMAIdx,
+ IN struct sk_buff *skb
+ )
+{
+ PSMgmtObject pMgmt = &(pDevice->sMgmtObj);
+ UINT BytesToWrite =0,uHeaderLen = 0;
+ UINT uNodeIndex = 0;
+ BYTE byMask[8] = {1, 2, 4, 8, 0x10, 0x20, 0x40, 0x80};
+ WORD wAID;
+ BYTE byPktType;
+ BOOL bNeedEncryption = FALSE;
+ PSKeyItem pTransmitKey = NULL;
+ SKeyItem STempKey;
+ UINT ii;
+ BOOL bTKIP_UseGTK = FALSE;
+ BOOL bNeedDeAuth = FALSE;
+ PBYTE pbyBSSID;
+ BOOL bNodeExist = FALSE;
+ PUSB_SEND_CONTEXT pContext;
+ BOOL fConvertedPacket;
+ PTX_BUFFER pTX_Buffer;
+ UINT status;
+ WORD wKeepRate = pDevice->wCurrentRate;
+ struct net_device_stats* pStats = &pDevice->stats;
+//#ifdef WPA_SM_Transtatus
+ // extern SWPAResult wpa_Result;
+//#endif
+ BOOL bTxeapol_key = FALSE;
+
+
+ if (pMgmt->eCurrMode == WMAC_MODE_ESS_AP) {
+
+ if (pDevice->uAssocCount == 0) {
+ dev_kfree_skb_irq(skb);
+ return 0;
+ }
+
+ if (IS_MULTICAST_ADDRESS((PBYTE)(skb->data))) {
+ uNodeIndex = 0;
+ bNodeExist = TRUE;
+ if (pMgmt->sNodeDBTable[0].bPSEnable) {
+
+ skb_queue_tail(&(pMgmt->sNodeDBTable[0].sTxPSQueue), skb);
+ pMgmt->sNodeDBTable[0].wEnQueueCnt++;
+ // set tx map
+ pMgmt->abyPSTxMap[0] |= byMask[0];
+ return 0;
+ }
+ // muticast/broadcast data rate
+
+ if (pDevice->byBBType != BB_TYPE_11A)
+ pDevice->wCurrentRate = RATE_2M;
+ else
+ pDevice->wCurrentRate = RATE_24M;
+ // long preamble type
+ pDevice->byPreambleType = PREAMBLE_SHORT;
+
+ }else {
+
+ if (BSSbIsSTAInNodeDB(pDevice, (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];
+ DBG_PRT(MSG_LEVEL_DEBUG, KERN_INFO "Set:pMgmt->abyPSTxMap[%d]= %d\n",
+ (wAID >> 3), pMgmt->abyPSTxMap[wAID >> 3]);
+
+ return 0;
+ }
+ // AP rate decided from node
+ pDevice->wCurrentRate = pMgmt->sNodeDBTable[uNodeIndex].wTxDataRate;
+ // tx preamble decided from node
+
+ if (pMgmt->sNodeDBTable[uNodeIndex].bShortPreamble) {
+ pDevice->byPreambleType = pDevice->byShortPreamble;
+
+ }else {
+ pDevice->byPreambleType = PREAMBLE_LONG;
+ }
+ bNodeExist = TRUE;
+ }
+ }
+
+ if (bNodeExist == FALSE) {
+ DBG_PRT(MSG_LEVEL_DEBUG, KERN_DEBUG"Unknown STA not found in node DB \n");
+ dev_kfree_skb_irq(skb);
+ return 0;
+ }
+ }
+
+ pContext = (PUSB_SEND_CONTEXT)s_vGetFreeContext(pDevice);
+
+ if (pContext == NULL) {
+ DBG_PRT(MSG_LEVEL_DEBUG, KERN_DEBUG" pContext == NULL\n");
+ dev_kfree_skb_irq(skb);
+ return STATUS_RESOURCES;
+ }
+
+ memcpy(pDevice->sTxEthHeader.abyDstAddr, (PBYTE)(skb->data), U_HEADER_LEN);
+
+//mike add:station mode check eapol-key challenge--->
+{
+ BYTE Protocol_Version; //802.1x Authentication
+ BYTE Packet_Type; //802.1x Authentication
+ BYTE Descriptor_type;
+ WORD Key_info;
+
+ 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(!(Key_info & BIT3) && //WPA or RSN group-key challenge
+ (Key_info & BIT8) && (Key_info & BIT9)) { //send 2/2 key
+ if(Descriptor_type==254) {
+ pDevice->fWPA_Authened = TRUE;
+ PRINT_K("WPA ");
+ }
+ else {
+ pDevice->fWPA_Authened = TRUE;
+ PRINT_K("WPA2(re-keying) ");
+ }
+ PRINT_K("Authentication completed!!\n");
+ }
+ else if((Key_info & BIT3) && (Descriptor_type==2) && //RSN pairse-key challenge
+ (Key_info & BIT8) && (Key_info & BIT9)) {
+ pDevice->fWPA_Authened = TRUE;
+ PRINT_K("WPA2 Authentication completed!!\n");
+ }
+ }
+ }
+}
+//mike add:station mode check eapol-key challenge<---
+
+ if (pDevice->bEncryptionEnable == TRUE) {
+ bNeedEncryption = TRUE;
+ // get Transmit key
+ do {
+ if ((pMgmt->eCurrMode == WMAC_MODE_ESS_STA) &&
+ (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;
+ DBG_PRT(MSG_LEVEL_DEBUG, KERN_DEBUG"Get GTK.\n");
+ break;
+ }
+ } else {
+ DBG_PRT(MSG_LEVEL_DEBUG, KERN_DEBUG"Get PTK.\n");
+ break;
+ }
+ }else if (pMgmt->eCurrMode == WMAC_MODE_IBSS_STA) {
+
+ pbyBSSID = pDevice->sTxEthHeader.abyDstAddr; //TO_DS = 0 and FROM_DS = 0 --> 802.11 MAC Address1
+ DBG_PRT(MSG_LEVEL_DEBUG, KERN_DEBUG"IBSS Serach Key: \n");
+ for (ii = 0; ii< 6; ii++)
+ DBG_PRT(MSG_LEVEL_DEBUG, KERN_DEBUG"%x \n", *(pbyBSSID+ii));
+ DBG_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 (pMgmt->eCurrMode == WMAC_MODE_IBSS_STA) {
+ DBG_PRT(MSG_LEVEL_DEBUG, KERN_DEBUG"IBSS and KEY is NULL. [%d]\n", pMgmt->eCurrMode);
+ }
+ else
+ DBG_PRT(MSG_LEVEL_DEBUG, KERN_DEBUG"NOT IBSS and KEY is NULL. [%d]\n", pMgmt->eCurrMode);
+ } else {
+ bTKIP_UseGTK = TRUE;
+ DBG_PRT(MSG_LEVEL_DEBUG, KERN_DEBUG"Get GTK.\n");
+ }
+ } while(FALSE);
+ }
+
+ if (pDevice->bEnableHostWEP) {
+ DBG_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
+ );
+ }
+ }
+
+ byPktType = (BYTE)pDevice->byPacketType;
+
+ if (pDevice->bFixRate) {
+ if (pDevice->byBBType == BB_TYPE_11B) {
+ if (pDevice->uConnectionRate >= RATE_11M) {
+ pDevice->wCurrentRate = RATE_11M;
+ } else {
+ pDevice->wCurrentRate = (WORD)pDevice->uConnectionRate;
+ }
+ } else {
+ if ((pDevice->byBBType == BB_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 {
+ if (pDevice->eOPMode == OP_MODE_ADHOC) {
+ // Adhoc Tx rate decided from node DB
+ if (IS_MULTICAST_ADDRESS(&(pDevice->sTxEthHeader.abyDstAddr[0]))) {
+ // Multicast use highest data rate
+ pDevice->wCurrentRate = pMgmt->sNodeDBTable[0].wTxDataRate;
+ // preamble type
+ pDevice->byPreambleType = pDevice->byShortPreamble;
+ }
+ else {
+ if(BSSbIsSTAInNodeDB(pDevice, &(pDevice->sTxEthHeader.abyDstAddr[0]), &uNodeIndex)) {
+ pDevice->wCurrentRate = pMgmt->sNodeDBTable[uNodeIndex].wTxDataRate;
+ if (pMgmt->sNodeDBTable[uNodeIndex].bShortPreamble) {
+ pDevice->byPreambleType = pDevice->byShortPreamble;
+
+ }
+ else {
+ pDevice->byPreambleType = PREAMBLE_LONG;
+ }
+ DBG_PRT(MSG_LEVEL_DEBUG, KERN_INFO"Found Node Index is [%d] Tx Data Rate:[%d]\n",uNodeIndex, pDevice->wCurrentRate);
+ }
+ else {
+ if (pDevice->byBBType != BB_TYPE_11A)
+ pDevice->wCurrentRate = RATE_2M;
+ else
+ pDevice->wCurrentRate = RATE_24M; // refer to vMgrCreateOwnIBSS()'s
+ // abyCurrExtSuppRates[]
+ pDevice->byPreambleType = PREAMBLE_SHORT;
+ DBG_PRT(MSG_LEVEL_DEBUG, KERN_INFO"Not Found Node use highest basic Rate.....\n");
+ }
+ }
+ }
+ if (pDevice->eOPMode == OP_MODE_INFRASTRUCTURE) {
+ // Infra STA rate decided from AP Node, index = 0
+ pDevice->wCurrentRate = pMgmt->sNodeDBTable[0].wTxDataRate;
+ }
+ }
+
+ if (pDevice->sTxEthHeader.wType == TYPE_PKT_802_1x) {
+ if (pDevice->byBBType != BB_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;
+ }
+ }
+
+ DBG_PRT(MSG_LEVEL_DEBUG, KERN_INFO "dma_tx: pDevice->wCurrentRate = %d \n", pDevice->wCurrentRate);
+
+ if (wKeepRate != pDevice->wCurrentRate) {
+ bScheduleCommand((HANDLE)pDevice, WLAN_CMD_SETPOWER, NULL);
+ }
+
+ if (pDevice->wCurrentRate <= RATE_11M) {
+ byPktType = PK_TYPE_11B;
+ }
+
+ if (bNeedEncryption == TRUE) {
+ DBG_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;
+ DBG_PRT(MSG_LEVEL_DEBUG, KERN_INFO"Pkt Type=%04x\n", (pDevice->sTxEthHeader.wType));
+ if ((pMgmt->eCurrMode == WMAC_MODE_ESS_STA) && (pMgmt->eCurrState == WMAC_STATE_ASSOC)) {
+ if (pTransmitKey == NULL) {
+ DBG_PRT(MSG_LEVEL_DEBUG, KERN_INFO"Don't Find TX KEY\n");
+ }
+ else {
+ if (bTKIP_UseGTK == TRUE) {
+ DBG_PRT(MSG_LEVEL_DEBUG, KERN_INFO"error: KEY is GTK!!~~\n");
+ }
+ else {
+ DBG_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)) {
+ DBG_PRT(MSG_LEVEL_DEBUG, KERN_INFO"Find PTK [%lX]\n", pTransmitKey->dwKeyIndex);
+ bNeedEncryption = TRUE;
+ }
+ }
+ }
+ else {
+
+#if 0
+ if((pDevice->fWPA_Authened == FALSE) &&
+ ((pMgmt->eAuthenMode == WMAC_AUTH_WPAPSK)||(pMgmt->eAuthenMode = WMAC_AUTH_WPA2PSK))){
+ dev_kfree_skb_irq(skb);
+ pStats->tx_dropped++;
+ return STATUS_FAILURE;
+ }
+ else if (pTransmitKey == NULL) {
+ DBG_PRT(MSG_LEVEL_DEBUG, KERN_INFO"return no tx key\n");
+ dev_kfree_skb_irq(skb);
+ pStats->tx_dropped++;
+ return STATUS_FAILURE;
+ }
+#else
+ if (pTransmitKey == NULL) {
+ DBG_PRT(MSG_LEVEL_DEBUG, KERN_INFO"return no tx key\n");
+ dev_kfree_skb_irq(skb);
+ pStats->tx_dropped++;
+ return STATUS_FAILURE;
+ }
+#endif
+
+ }
+ }
+
+ fConvertedPacket = s_bPacketToWirelessUsb(pDevice, byPktType,
+ (PBYTE)(&pContext->Data[0]), bNeedEncryption,
+ skb->len, uDMAIdx, &pDevice->sTxEthHeader,
+ (PBYTE)skb->data, pTransmitKey, uNodeIndex,
+ pDevice->wCurrentRate,
+ &uHeaderLen, &BytesToWrite
+ );
+
+ if (fConvertedPacket == FALSE) {
+ pContext->bBoolInUse = FALSE;
+ dev_kfree_skb_irq(skb);
+ return STATUS_FAILURE;
+ }
+
+ if ( pDevice->bEnablePSMode == TRUE ) {
+ if ( !pDevice->bPSModeTxBurst ) {
+ bScheduleCommand((HANDLE) pDevice, WLAN_CMD_MAC_DISPOWERSAVING, NULL);
+ pDevice->bPSModeTxBurst = TRUE;
+ }
+ }
+
+ pTX_Buffer = (PTX_BUFFER)&(pContext->Data[0]);
+ pTX_Buffer->byPKTNO = (BYTE) (((pDevice->wCurrentRate<<4) &0x00F0) | ((pDevice->wSeqCounter - 1) & 0x000F));
+ pTX_Buffer->wTxByteCount = (WORD)BytesToWrite;
+
+ pContext->pPacket = skb;
+ pContext->Type = CONTEXT_DATA_PACKET;
+ pContext->uBufLen = (WORD)BytesToWrite + 4 ; //USB header
+
+ s_vSaveTxPktInfo(pDevice, (BYTE) (pTX_Buffer->byPKTNO & 0x0F), &(pContext->sEthHeader.abyDstAddr[0]),(WORD) (BytesToWrite-uHeaderLen),pTX_Buffer->wFIFOCtl);
+
+ status = PIPEnsSendBulkOut(pDevice,pContext);
+
+ if (bNeedDeAuth == TRUE) {
+ WORD wReason = WLAN_MGMT_REASON_MIC_FAILURE;
+
+ bScheduleCommand((HANDLE) pDevice, WLAN_CMD_DEAUTH, (PBYTE)&wReason);
+ }
+
+ if(status!=STATUS_PENDING) {
+ pContext->bBoolInUse = FALSE;
+ dev_kfree_skb_irq(skb);
+ return STATUS_FAILURE;
+ }
+ else
+ return 0;
+
+}
+
+
+
+/*
+ * Description:
+ * Relay packet send (AC1DMA) from rx dpc.
+ *
+ * Parameters:
+ * In:
+ * pDevice - Pointer to the adapter
+ * pPacket - Pointer to rx packet
+ * cbPacketSize - rx ethernet frame size
+ * Out:
+ * TURE, FALSE
+ *
+ * Return Value: Return TRUE if packet is copy to dma1; otherwise FALSE
+ */
+
+
+BOOL
+bRelayPacketSend (
+ IN PSDevice pDevice,
+ IN PBYTE pbySkbData,
+ IN UINT uDataLen,
+ IN UINT uNodeIndex
+ )
+{
+ PSMgmtObject pMgmt = &(pDevice->sMgmtObj);
+ UINT BytesToWrite =0,uHeaderLen = 0;
+ BYTE byPktType = PK_TYPE_11B;
+ BOOL bNeedEncryption = FALSE;
+ SKeyItem STempKey;
+ PSKeyItem pTransmitKey = NULL;
+ PBYTE pbyBSSID;
+ PUSB_SEND_CONTEXT pContext;
+ BYTE byPktTyp;
+ BOOL fConvertedPacket;
+ PTX_BUFFER pTX_Buffer;
+ UINT status;
+ WORD wKeepRate = pDevice->wCurrentRate;
+
+
+
+ pContext = (PUSB_SEND_CONTEXT)s_vGetFreeContext(pDevice);
+
+ if (NULL == pContext) {
+ return FALSE;
+ }
+
+ memcpy(pDevice->sTxEthHeader.abyDstAddr, (PBYTE)pbySkbData, U_HEADER_LEN);
+
+ if (pDevice->bEncryptionEnable == TRUE) {
+ bNeedEncryption = TRUE;
+ // get group key
+ pbyBSSID = pDevice->abyBroadcastAddr;
+ if(KeybGetTransmitKey(&(pDevice->sKey), pbyBSSID, GROUP_KEY, &pTransmitKey) == FALSE) {
+ pTransmitKey = NULL;
+ DBG_PRT(MSG_LEVEL_DEBUG, KERN_DEBUG"KEY is NULL. [%d]\n", pMgmt->eCurrMode);
+ } else {
+ DBG_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
+ );
+ }
+ }
+
+ if ( bNeedEncryption && (pTransmitKey == NULL) ) {
+ pContext->bBoolInUse = FALSE;
+ return FALSE;
+ }
+
+ byPktTyp = (BYTE)pDevice->byPacketType;
+
+ if (pDevice->bFixRate) {
+ if (pDevice->byBBType == BB_TYPE_11B) {
+ if (pDevice->uConnectionRate >= RATE_11M) {
+ pDevice->wCurrentRate = RATE_11M;
+ } else {
+ pDevice->wCurrentRate = (WORD)pDevice->uConnectionRate;
+ }
+ } else {
+ if ((pDevice->byBBType == BB_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 = pMgmt->sNodeDBTable[uNodeIndex].wTxDataRate;
+ }
+
+
+ if (wKeepRate != pDevice->wCurrentRate) {
+ bScheduleCommand((HANDLE) pDevice, WLAN_CMD_SETPOWER, NULL);
+ }
+
+ if (pDevice->wCurrentRate <= RATE_11M)
+ byPktType = PK_TYPE_11B;
+
+ BytesToWrite = uDataLen + U_CRC_LEN;
+ // Convert the packet to an usb frame and copy into our buffer
+ // and send the irp.
+
+ fConvertedPacket = s_bPacketToWirelessUsb(pDevice, byPktType,
+ (PBYTE)(&pContext->Data[0]), bNeedEncryption,
+ uDataLen, TYPE_AC0DMA, &pDevice->sTxEthHeader,
+ pbySkbData, pTransmitKey, uNodeIndex,
+ pDevice->wCurrentRate,
+ &uHeaderLen, &BytesToWrite
+ );
+
+ if (fConvertedPacket == FALSE) {
+ pContext->bBoolInUse = FALSE;
+ return FALSE;
+ }
+
+ pTX_Buffer = (PTX_BUFFER)&(pContext->Data[0]);
+ pTX_Buffer->byPKTNO = (BYTE) (((pDevice->wCurrentRate<<4) &0x00F0) | ((pDevice->wSeqCounter - 1) & 0x000F));
+ pTX_Buffer->wTxByteCount = (WORD)BytesToWrite;
+
+ pContext->pPacket = NULL;
+ pContext->Type = CONTEXT_DATA_PACKET;
+ pContext->uBufLen = (WORD)BytesToWrite + 4 ; //USB header
+
+ s_vSaveTxPktInfo(pDevice, (BYTE) (pTX_Buffer->byPKTNO & 0x0F), &(pContext->sEthHeader.abyDstAddr[0]),(WORD) (BytesToWrite-uHeaderLen),pTX_Buffer->wFIFOCtl);
+
+ status = PIPEnsSendBulkOut(pDevice,pContext);
+
+ return TRUE;
+}
+
diff --git a/drivers/staging/vt6656/rxtx.h b/drivers/staging/vt6656/rxtx.h
new file mode 100644
index 000000000000..07d9720f5b99
--- /dev/null
+++ b/drivers/staging/vt6656/rxtx.h
@@ -0,0 +1,716 @@
+/*
+ * 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.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 ----------------------------*/
+
+//
+// RTS buffer header
+//
+typedef struct tagSRTSDataF {
+ WORD wFrameControl;
+ WORD wDurationID;
+ BYTE abyRA[U_ETHER_ADDR_LEN];
+ BYTE abyTA[U_ETHER_ADDR_LEN];
+} SRTSDataF, DEF* PSRTSDataF;
+
+//
+// CTS buffer header
+//
+typedef struct tagSCTSDataF {
+ WORD wFrameControl;
+ WORD wDurationID;
+ BYTE abyRA[U_ETHER_ADDR_LEN];
+ WORD wReserved;
+} SCTSDataF, DEF* PSCTSDataF;
+
+//
+// MICHDR data header
+//
+typedef struct tagSMICHDR {
+ DWORD adwHDR0[4];
+ DWORD adwHDR1[4];
+ DWORD adwHDR2[4];
+} SMICHDR, DEF* PSMICHDR;
+
+
+typedef struct tagSTX_NAF_G_RTS
+{
+ //RsvTime
+ WORD wRTSTxRrvTime_ba;
+ WORD wRTSTxRrvTime_aa;
+ WORD wRTSTxRrvTime_bb;
+ WORD wReserved2;
+ WORD wTxRrvTime_b;
+ WORD wTxRrvTime_a;
+
+ //RTS
+ BYTE byRTSSignalField_b;
+ BYTE byRTSServiceField_b;
+ WORD wRTSTransmitLength_b;
+ BYTE byRTSSignalField_a;
+ BYTE byRTSServiceField_a;
+ WORD wRTSTransmitLength_a;
+ WORD wRTSDuration_ba;
+ WORD wRTSDuration_aa;
+ WORD wRTSDuration_bb;
+ WORD wReserved3;
+ SRTSDataF sRTS;
+
+ //Data
+ 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;
+
+} TX_NAF_G_RTS, DEF* PTX_NAF_G_RTS;
+
+typedef struct tagSTX_NAF_G_RTS_MIC
+{
+ //RsvTime
+ WORD wRTSTxRrvTime_ba;
+ WORD wRTSTxRrvTime_aa;
+ WORD wRTSTxRrvTime_bb;
+ WORD wReserved2;
+ WORD wTxRrvTime_b;
+ WORD wTxRrvTime_a;
+
+ SMICHDR sMICHDR;
+
+ //RTS
+ BYTE byRTSSignalField_b;
+ BYTE byRTSServiceField_b;
+ WORD wRTSTransmitLength_b;
+ BYTE byRTSSignalField_a;
+ BYTE byRTSServiceField_a;
+ WORD wRTSTransmitLength_a;
+ WORD wRTSDuration_ba;
+ WORD wRTSDuration_aa;
+ WORD wRTSDuration_bb;
+ WORD wReserved3;
+ SRTSDataF sRTS;
+
+ //Data
+ 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;
+
+} TX_NAF_G_RTS_MIC, DEF* PTX_NAF_G_RTS_MIC;
+
+typedef struct tagSTX_NAF_G_CTS
+{
+ //RsvTime
+ WORD wCTSTxRrvTime_ba;
+ WORD wReserved2;
+ WORD wTxRrvTime_b;
+ WORD wTxRrvTime_a;
+
+ //CTS
+ BYTE byCTSSignalField_b;
+ BYTE byCTSServiceField_b;
+ WORD wCTSTransmitLength_b;
+ WORD wCTSDuration_ba;
+ WORD wReserved3;
+ SCTSDataF sCTS;
+
+ //Data
+ 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;
+
+} TX_NAF_G_CTS, DEF* PTX_NAF_G_CTS;
+
+
+typedef struct tagSTX_NAF_G_CTS_MIC
+{
+ //RsvTime
+ WORD wCTSTxRrvTime_ba;
+ WORD wReserved2;
+ WORD wTxRrvTime_b;
+ WORD wTxRrvTime_a;
+
+
+ SMICHDR sMICHDR;
+
+ //CTS
+ BYTE byCTSSignalField_b;
+ BYTE byCTSServiceField_b;
+ WORD wCTSTransmitLength_b;
+ WORD wCTSDuration_ba;
+ WORD wReserved3;
+ SCTSDataF sCTS;
+
+ //Data
+ 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;
+
+} TX_NAF_G_CTS_MIC, DEF* PTX_NAF_G_CTS_MIC;
+
+
+typedef struct tagSTX_NAF_G_BEACON
+{
+ WORD wFIFOCtl;
+ WORD wTimeStamp;
+
+ //CTS
+ BYTE byCTSSignalField_b;
+ BYTE byCTSServiceField_b;
+ WORD wCTSTransmitLength_b;
+ WORD wCTSDuration_ba;
+ WORD wReserved1;
+ SCTSDataF sCTS;
+
+ //Data
+ BYTE bySignalField_a;
+ BYTE byServiceField_a;
+ WORD wTransmitLength_a;
+ WORD wDuration_a;
+ WORD wTimeStampOff_a;
+
+
+} TX_NAF_G_BEACON, DEF* PTX_NAF_G_BEACON;
+
+
+typedef struct tagSTX_NAF_AB_RTS
+{
+ //RsvTime
+ WORD wRTSTxRrvTime_ab;
+ WORD wTxRrvTime_ab;
+
+ //RTS
+ BYTE byRTSSignalField_ab;
+ BYTE byRTSServiceField_ab;
+ WORD wRTSTransmitLength_ab;
+ WORD wRTSDuration_ab;
+ WORD wReserved2;
+ SRTSDataF sRTS;
+
+ //Data
+ BYTE bySignalField_ab;
+ BYTE byServiceField_ab;
+ WORD wTransmitLength_ab;
+ WORD wDuration_ab;
+ WORD wTimeStampOff_ab;
+
+
+} TX_NAF_AB_RTS, DEF* PTX_NAF_AB_RTS;
+
+
+typedef struct tagSTX_NAF_AB_RTS_MIC
+{
+ //RsvTime
+ WORD wRTSTxRrvTime_ab;
+ WORD wTxRrvTime_ab;
+
+ SMICHDR sMICHDR;
+
+ //RTS
+ BYTE byRTSSignalField_ab;
+ BYTE byRTSServiceField_ab;
+ WORD wRTSTransmitLength_ab;
+ WORD wRTSDuration_ab;
+ WORD wReserved2;
+ SRTSDataF sRTS;
+
+ //Data
+ BYTE bySignalField_ab;
+ BYTE byServiceField_ab;
+ WORD wTransmitLength_ab;
+ WORD wDuration_ab;
+ WORD wTimeStampOff_ab;
+
+
+} TX_NAF_AB_RTS_MIC, DEF* PTX_NAF_AB_RTS_MIC;
+
+
+
+typedef struct tagSTX_NAF_AB_CTS
+{
+ //RsvTime
+ WORD wReserved2;
+ WORD wTxRrvTime_ab;
+
+ //Data
+ BYTE bySignalField_ab;
+ BYTE byServiceField_ab;
+ WORD wTransmitLength_ab;
+ WORD wDuration_ab;
+ WORD wTimeStampOff_ab;
+
+} TX_NAF_AB_CTS, DEF* PTX_NAF_AB_CTS;
+
+typedef struct tagSTX_NAF_AB_CTS_MIC
+{
+ //RsvTime
+ WORD wReserved2;
+ WORD wTxRrvTime_ab;
+
+ SMICHDR sMICHDR;
+
+ //Data
+ BYTE bySignalField_ab;
+ BYTE byServiceField_ab;
+ WORD wTransmitLength_ab;
+ WORD wDuration_ab;
+ WORD wTimeStampOff_ab;
+
+} TX_NAF_AB_CTS_MIC, DEF* PTX_NAF_AB_CTS_MIC;
+
+
+typedef struct tagSTX_NAF_AB_BEACON
+{
+ WORD wFIFOCtl;
+ WORD wTimeStamp;
+
+ //Data
+ BYTE bySignalField_ab;
+ BYTE byServiceField_ab;
+ WORD wTransmitLength_ab;
+ WORD wDuration_ab;
+ WORD wTimeStampOff_ab;
+
+} TX_NAF_AB_BEACON, DEF* PTX_NAF_AB_BEACON;
+
+typedef struct tagSTX_AF_G_RTS
+{
+ //RsvTime
+ WORD wRTSTxRrvTime_ba;
+ WORD wRTSTxRrvTime_aa;
+ WORD wRTSTxRrvTime_bb;
+ WORD wReserved2;
+ WORD wTxRrvTime_b;
+ WORD wTxRrvTime_a;
+
+ //RTS
+ BYTE byRTSSignalField_b;
+ BYTE byRTSServiceField_b;
+ WORD wRTSTransmitLength_b;
+ BYTE byRTSSignalField_a;
+ BYTE byRTSServiceField_a;
+ WORD wRTSTransmitLength_a;
+ WORD wRTSDuration_ba;
+ WORD wRTSDuration_aa;
+ WORD wRTSDuration_bb;
+ WORD wReserved3;
+ WORD wRTSDuration_ba_f0;
+ WORD wRTSDuration_aa_f0;
+ WORD wRTSDuration_ba_f1;
+ WORD wRTSDuration_aa_f1;
+ SRTSDataF sRTS;
+
+ //Data
+ 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;
+
+} TX_AF_G_RTS, DEF* PTX_AF_G_RTS;
+
+
+typedef struct tagSTX_AF_G_RTS_MIC
+{
+ //RsvTime
+ WORD wRTSTxRrvTime_ba;
+ WORD wRTSTxRrvTime_aa;
+ WORD wRTSTxRrvTime_bb;
+ WORD wReserved2;
+ WORD wTxRrvTime_b;
+ WORD wTxRrvTime_a;
+
+ SMICHDR sMICHDR;
+
+ //RTS
+ BYTE byRTSSignalField_b;
+ BYTE byRTSServiceField_b;
+ WORD wRTSTransmitLength_b;
+ BYTE byRTSSignalField_a;
+ BYTE byRTSServiceField_a;
+ WORD wRTSTransmitLength_a;
+ WORD wRTSDuration_ba;
+ WORD wRTSDuration_aa;
+ WORD wRTSDuration_bb;
+ WORD wReserved3;
+ WORD wRTSDuration_ba_f0;
+ WORD wRTSDuration_aa_f0;
+ WORD wRTSDuration_ba_f1;
+ WORD wRTSDuration_aa_f1;
+ SRTSDataF sRTS;
+
+ //Data
+ 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;
+
+} TX_AF_G_RTS_MIC, DEF* PTX_AF_G_RTS_MIC;
+
+
+
+typedef struct tagSTX_AF_G_CTS
+{
+ //RsvTime
+ WORD wCTSTxRrvTime_ba;
+ WORD wReserved2;
+ WORD wTxRrvTime_b;
+ WORD wTxRrvTime_a;
+
+ //CTS
+ BYTE byCTSSignalField_b;
+ BYTE byCTSServiceField_b;
+ WORD wCTSTransmitLength_b;
+ WORD wCTSDuration_ba;
+ WORD wReserved3;
+ WORD wCTSDuration_ba_f0;
+ WORD wCTSDuration_ba_f1;
+ SCTSDataF sCTS;
+
+ //Data
+ 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;
+
+} TX_AF_G_CTS, DEF* PTX_AF_G_CTS;
+
+
+typedef struct tagSTX_AF_G_CTS_MIC
+{
+ //RsvTime
+ WORD wCTSTxRrvTime_ba;
+ WORD wReserved2;
+ WORD wTxRrvTime_b;
+ WORD wTxRrvTime_a;
+
+
+ SMICHDR sMICHDR;
+
+ //CTS
+ BYTE byCTSSignalField_b;
+ BYTE byCTSServiceField_b;
+ WORD wCTSTransmitLength_b;
+ WORD wCTSDuration_ba;
+ WORD wReserved3;
+ WORD wCTSDuration_ba_f0;
+ WORD wCTSDuration_ba_f1;
+ SCTSDataF sCTS;
+
+ //Data
+ 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;
+
+} TX_AF_G_CTS_MIC, DEF* PTX_AF_G_CTS_MIC;
+
+
+
+typedef struct tagSTX_AF_A_RTS
+{
+ //RsvTime
+ WORD wRTSTxRrvTime_a;
+ WORD wTxRrvTime_a;
+
+ //RTS
+ BYTE byRTSSignalField_a;
+ BYTE byRTSServiceField_a;
+ WORD wRTSTransmitLength_a;
+ WORD wRTSDuration_a;
+ WORD wReserved2;
+ WORD wRTSDuration_a_f0;
+ WORD wRTSDuration_a_f1;
+ SRTSDataF sRTS;
+
+ //Data
+ BYTE bySignalField_a;
+ BYTE byServiceField_a;
+ WORD wTransmitLength_a;
+ WORD wDuration_a;
+ WORD wTimeStampOff_a;
+ WORD wDuration_a_f0;
+ WORD wDuration_a_f1;
+
+} TX_AF_A_RTS, DEF* PTX_AF_A_RTS;
+
+
+typedef struct tagSTX_AF_A_RTS_MIC
+{
+ //RsvTime
+ WORD wRTSTxRrvTime_a;
+ WORD wTxRrvTime_a;
+
+ SMICHDR sMICHDR;
+
+ //RTS
+ BYTE byRTSSignalField_a;
+ BYTE byRTSServiceField_a;
+ WORD wRTSTransmitLength_a;
+ WORD wRTSDuration_a;
+ WORD wReserved2;
+ WORD wRTSDuration_a_f0;
+ WORD wRTSDuration_a_f1;
+ SRTSDataF sRTS;
+
+ //Data
+ BYTE bySignalField_a;
+ BYTE byServiceField_a;
+ WORD wTransmitLength_a;
+ WORD wDuration_a;
+ WORD wTimeStampOff_a;
+ WORD wDuration_a_f0;
+ WORD wDuration_a_f1;
+
+} TX_AF_A_RTS_MIC, DEF* PTX_AF_A_RTS_MIC;
+
+
+
+typedef struct tagSTX_AF_A_CTS
+{
+ //RsvTime
+ WORD wReserved2;
+ WORD wTxRrvTime_a;
+
+ //Data
+ BYTE bySignalField_a;
+ BYTE byServiceField_a;
+ WORD wTransmitLength_a;
+ WORD wDuration_a;
+ WORD wTimeStampOff_a;
+ WORD wDuration_a_f0;
+ WORD wDuration_a_f1;
+
+} TX_AF_A_CTS, DEF* PTX_AF_A_CTS;
+
+
+typedef struct tagSTX_AF_A_CTS_MIC
+{
+ //RsvTime
+ WORD wReserved2;
+ WORD wTxRrvTime_a;
+
+ SMICHDR sMICHDR;
+
+ //Data
+ BYTE bySignalField_a;
+ BYTE byServiceField_a;
+ WORD wTransmitLength_a;
+ WORD wDuration_a;
+ WORD wTimeStampOff_a;
+ WORD wDuration_a_f0;
+ WORD wDuration_a_f1;
+
+} TX_AF_A_CTS_MIC, DEF* PTX_AF_A_CTS_MIC;
+
+
+//
+// union with all of the TX Buffer Type
+//
+typedef union tagUTX_BUFFER_CONTAINER
+{
+ TX_NAF_G_RTS RTS_G;
+ TX_NAF_G_RTS_MIC RTS_G_MIC;
+ TX_NAF_G_CTS CTS_G;
+ TX_NAF_G_CTS_MIC CTS_G_MIC;
+ //TX_NAF_G_BEACON Beacon_G;
+ TX_NAF_AB_RTS RTS_AB;
+ TX_NAF_AB_RTS_MIC RTS_AB_MIC;
+ TX_NAF_AB_CTS CTS_AB;
+ TX_NAF_AB_CTS_MIC CTS_AB_MIC;
+ //TX_NAF_AB_BEACON Beacon_AB;
+ TX_AF_G_RTS RTS_G_AutoFB;
+ TX_AF_G_RTS_MIC RTS_G_AutoFB_MIC;
+ TX_AF_G_CTS CTS_G_AutoFB;
+ TX_AF_G_CTS_MIC CTS_G_AutoFB_MIC;
+ TX_AF_A_RTS RTS_A_AutoFB;
+ TX_AF_A_RTS_MIC RTS_A_AutoFB_MIC;
+ TX_AF_A_CTS CTS_A_AutoFB;
+ TX_AF_A_CTS_MIC CTS_A_AutoFB_MIC;
+
+} TX_BUFFER_CONTAINER, DEF* PTX_BUFFER_CONTAINER;
+
+
+//
+// Remote NDIS message format
+//
+typedef struct tagSTX_BUFFER
+{
+ BYTE byType;
+ BYTE byPKTNO;
+ WORD wTxByteCount;
+
+ DWORD adwTxKey[4];
+ WORD wFIFOCtl;
+ WORD wTimeStamp;
+ WORD wFragCtl;
+ WORD wReserved;
+
+
+ // Actual message
+ TX_BUFFER_CONTAINER BufferHeader;
+
+} TX_BUFFER, DEF* PTX_BUFFER;
+
+
+//
+// Remote NDIS message format
+//
+typedef struct tagSBEACON_BUFFER
+{
+ BYTE byType;
+ BYTE byPKTNO;
+ WORD wTxByteCount;
+
+ WORD wFIFOCtl;
+ WORD wTimeStamp;
+
+ // Actual message
+ TX_BUFFER_CONTAINER BufferHeader;
+
+} BEACON_BUFFER, DEF* PBEACON_BUFFER;
+
+
+/*--------------------- Export Variables --------------------------*/
+
+/*--------------------- Export Functions --------------------------*/
+
+
+#ifdef __cplusplus
+extern "C" { /* Assume C declarations for C++ */
+#endif /* __cplusplus */
+
+
+
+BOOL
+bPacketToWirelessUsb(
+ IN PSDevice pDevice,
+ IN BYTE byPktType,
+ IN PBYTE usbPacketBuf,
+ IN BOOL bNeedEncrypt,
+ IN UINT cbPayloadSize,
+ IN UINT uDMAIdx,
+ IN PSEthernetHeader psEthHeader,
+ IN PBYTE pPacket,
+ IN PSKeyItem pTransmitKey,
+ IN UINT uNodeIndex,
+ IN WORD wCurrentRate,
+ OUT UINT *pcbHeaderLen,
+ OUT UINT *pcbTotalLen
+ );
+
+VOID vDMA0_tx_80211(PSDevice pDevice, struct sk_buff *skb);
+NTSTATUS nsDMA_tx_packet(PSDevice pDevice, UINT uDMAIdx, struct sk_buff *skb);
+CMD_STATUS csMgmt_xmit(PSDevice pDevice, PSTxMgmtPacket pPacket);
+CMD_STATUS csBeacon_xmit(PSDevice pDevice, PSTxMgmtPacket pPacket);
+BOOL bRelayPacketSend(PSDevice pDevice, PBYTE pbySkbData, UINT uDataLen, UINT uNodeIndex);
+
+#ifdef __cplusplus
+} /* End of extern "C" { */
+#endif /* __cplusplus */
+
+
+
+
+#endif // __RXTX_H__
+
+
+
diff --git a/drivers/staging/vt6656/srom.h b/drivers/staging/vt6656/srom.h
new file mode 100644
index 000000000000..2accf5f054aa
--- /dev/null
+++ b/drivers/staging/vt6656/srom.h
@@ -0,0 +1,144 @@
+/*
+ * 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 0x17
+#define EEP_OFS_RADIOCTL 0x18
+#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_CALIB_TX_IQ 0x24
+#define EEP_OFS_CALIB_TX_DC 0x25
+#define EEP_OFS_CALIB_RX_IQ 0x26
+
+#define EEP_OFS_MAJOR_VER 0x2E
+#define EEP_OFS_MINOR_VER 0x2F
+
+#define EEP_OFS_CCK_PWR_TBL 0x30
+#define EEP_OFS_OFDM_PWR_TBL 0x40
+#define EEP_OFS_OFDMA_PWR_TBL 0x50
+
+//
+// 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
+
+/*--------------------- 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 */
+
+
+#ifdef __cplusplus
+} /* End of extern "C" { */
+#endif /* __cplusplus */
+
+
+
+
+#endif // __EEPROM_H__
diff --git a/drivers/staging/vt6656/tbit.h b/drivers/staging/vt6656/tbit.h
new file mode 100644
index 000000000000..7c3a82e9b608
--- /dev/null
+++ b/drivers/staging/vt6656/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/vt6656/tcrc.c b/drivers/staging/vt6656/tcrc.c
new file mode 100644
index 000000000000..b70080c267c8
--- /dev/null
+++ b/drivers/staging/vt6656/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/vt6656/tcrc.h b/drivers/staging/vt6656/tcrc.h
new file mode 100644
index 000000000000..ebea22ed2da6
--- /dev/null
+++ b/drivers/staging/vt6656/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/vt6656/tether.c b/drivers/staging/vt6656/tether.c
new file mode 100644
index 000000000000..fd69423fe14b
--- /dev/null
+++ b/drivers/staging/vt6656/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/vt6656/tether.h b/drivers/staging/vt6656/tether.h
new file mode 100644
index 000000000000..920a8bb68356
--- /dev/null
+++ b/drivers/staging/vt6656/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/vt6656/tkip.c b/drivers/staging/vt6656/tkip.c
new file mode 100644
index 000000000000..2ded8420c390
--- /dev/null
+++ b/drivers/staging/vt6656/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/vt6656/tkip.h b/drivers/staging/vt6656/tkip.h
new file mode 100644
index 000000000000..dc8382b67019
--- /dev/null
+++ b/drivers/staging/vt6656/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/vt6656/tmacro.h b/drivers/staging/vt6656/tmacro.h
new file mode 100644
index 000000000000..3d932a258dd1
--- /dev/null
+++ b/drivers/staging/vt6656/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/vt6656/tpci.h b/drivers/staging/vt6656/tpci.h
new file mode 100644
index 000000000000..3a04845cbb51
--- /dev/null
+++ b/drivers/staging/vt6656/tpci.h
@@ -0,0 +1,119 @@
+/*
+ * 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/vt6656/ttype.h b/drivers/staging/vt6656/ttype.h
new file mode 100644
index 000000000000..1e72f1189178
--- /dev/null
+++ b/drivers/staging/vt6656/ttype.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: ttype.h
+ *
+ * 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
+
+//2007-0115-05<Add>by MikeLiu
+#ifndef TxInSleep
+#define TxInSleep
+#endif
+
+//DavidWang
+
+
+//2007-0814-01<Add>by MikeLiu
+#ifndef Safe_Close
+#define Safe_Close
+#endif
+
+//2008-0131-02<Add>by MikeLiu
+#ifndef Adhoc_STA
+#define Adhoc_STA
+#endif
+
+#if! defined(__CPU8051)
+typedef int BOOL;
+typedef int BOOLEAN;
+#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
+
+/****** 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/vt6656/umem.h b/drivers/staging/vt6656/umem.h
new file mode 100644
index 000000000000..2c3eafa038e7
--- /dev/null
+++ b/drivers/staging/vt6656/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/vt6656/upc.h b/drivers/staging/vt6656/upc.h
new file mode 100644
index 000000000000..113fc2c88c11
--- /dev/null
+++ b/drivers/staging/vt6656/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/vt6656/usbpipe.c b/drivers/staging/vt6656/usbpipe.c
new file mode 100644
index 000000000000..97efd87ddddb
--- /dev/null
+++ b/drivers/staging/vt6656/usbpipe.c
@@ -0,0 +1,857 @@
+/*
+ * 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: usbpipe.c
+ *
+ * Purpose: Handle USB control endpoint
+ *
+ * Author: Warren Hsu
+ *
+ * Date: Mar. 29, 2005
+ *
+ * Functions:
+ * CONTROLnsRequestOut - Write variable length bytes to MEM/BB/MAC/EEPROM
+ * CONTROLnsRequestIn - Read variable length bytes from MEM/BB/MAC/EEPROM
+ * ControlvWriteByte - Write one byte to MEM/BB/MAC/EEPROM
+ * ControlvReadByte - Read one byte from MEM/BB/MAC/EEPROM
+ * ControlvMaskByte - Read one byte from MEM/BB/MAC/EEPROM and clear/set some bits in the same address
+ *
+ * Revision History:
+ * 04-05-2004 Jerry Chen: Initial release
+ * 11-24-2004 Warren Hsu: Add ControlvWriteByte,ControlvReadByte,ControlvMaskByte
+ *
+ */
+
+#if !defined(__UMEM_H__)
+#include "umem.h"
+#endif
+#if !defined(__INT_H__)
+#include "int.h"
+#endif
+#if !defined(__RXTX_H__)
+#include "rxtx.h"
+#endif
+#if !defined(__DPC_H__)
+#include "dpc.h"
+#endif
+#if !defined(__CONTROL_H__)
+#include "control.h"
+#endif
+#if !defined(__DESC_H__)
+#include "desc.h"
+#endif
+#if !defined(__DEVICE_H__)
+#include "device.h"
+#endif
+
+
+/*--------------------- Static Definitions -------------------------*/
+//endpoint def
+//endpoint 0: control
+//endpoint 1: interrupt
+//endpoint 2: read bulk
+//endpoint 3: write bulk
+
+//RequestType:
+//#define REQUEST_OUT (USB_DIR_OUT | USB_TYPE_VENDOR | USB_RECIP_DEVICE) // 0x40
+//#define REQUEST_IN (USB_DIR_IN | USB_TYPE_VENDOR | USB_RECIP_DEVICE ) //0xc0
+//static int msglevel =MSG_LEVEL_DEBUG;
+static int msglevel =MSG_LEVEL_INFO;
+
+
+#define USB_CTL_WAIT 500 //ms
+
+#ifndef URB_ASYNC_UNLINK
+#define URB_ASYNC_UNLINK 0
+#endif
+
+/*--------------------- Static Classes ----------------------------*/
+
+/*--------------------- Static Variables --------------------------*/
+
+/*--------------------- Static Functions --------------------------*/
+static
+VOID
+s_nsInterruptUsbIoCompleteRead(
+ IN struct urb *urb
+ );
+
+
+static
+VOID
+s_nsBulkInUsbIoCompleteRead(
+ IN struct urb *urb
+ );
+
+
+static
+VOID
+s_nsBulkOutIoCompleteWrite(
+ IN struct urb *urb
+ );
+
+
+static
+VOID
+s_nsControlInUsbIoCompleteRead(
+ IN struct urb *urb
+ );
+
+static
+VOID
+s_nsControlInUsbIoCompleteWrite(
+ IN struct urb *urb
+ );
+
+/*--------------------- Export Variables --------------------------*/
+
+/*--------------------- Export Functions --------------------------*/
+
+
+
+NTSTATUS
+PIPEnsControlOutAsyn(
+ IN PSDevice pDevice,
+ IN BYTE byRequest,
+ IN WORD wValue,
+ IN WORD wIndex,
+ IN WORD wLength,
+ IN PBYTE pbyBuffer
+ )
+{
+ NTSTATUS ntStatus;
+
+
+ if (MP_TEST_FLAG(pDevice, fMP_DISCONNECTED))
+ return STATUS_FAILURE;
+
+
+ if (MP_TEST_FLAG(pDevice, fMP_CONTROL_WRITES)) {
+ return STATUS_FAILURE;
+ }
+
+ if (in_interrupt()) {
+ DBG_PRT(MSG_LEVEL_DEBUG, KERN_INFO"in_interrupt return ..byRequest %x\n", byRequest);
+ return STATUS_FAILURE;
+ }
+
+ ntStatus = usb_control_msg(
+ pDevice->usb,
+ usb_sndctrlpipe(pDevice->usb , 0),
+ byRequest,
+ 0x40, // RequestType
+ wValue,
+ wIndex,
+ (PVOID) pbyBuffer,
+ wLength,
+ HZ
+ );
+ if (ntStatus >= 0) {
+ DBG_PRT(MSG_LEVEL_DEBUG, KERN_INFO"usb_sndctrlpipe ntStatus= %d\n", ntStatus);
+ ntStatus = 0;
+ } else {
+ DBG_PRT(MSG_LEVEL_DEBUG, KERN_INFO"usb_sndctrlpipe fail, ntStatus= %d\n", ntStatus);
+ }
+
+ return ntStatus;
+}
+
+
+
+
+
+NTSTATUS
+PIPEnsControlOut(
+ IN PSDevice pDevice,
+ IN BYTE byRequest,
+ IN WORD wValue,
+ IN WORD wIndex,
+ IN WORD wLength,
+ IN PBYTE pbyBuffer
+ )
+{
+ NTSTATUS ntStatus = 0;
+ int ii;
+
+
+ if (MP_TEST_FLAG(pDevice, fMP_DISCONNECTED))
+ return STATUS_FAILURE;
+
+ if (MP_TEST_FLAG(pDevice, fMP_CONTROL_WRITES)) {
+ return STATUS_FAILURE;
+ }
+
+ pDevice->sUsbCtlRequest.bRequestType = 0x40;
+ pDevice->sUsbCtlRequest.bRequest = byRequest;
+ pDevice->sUsbCtlRequest.wValue = cpu_to_le16p(&wValue);
+ pDevice->sUsbCtlRequest.wIndex = cpu_to_le16p(&wIndex);
+ pDevice->sUsbCtlRequest.wLength = cpu_to_le16p(&wLength);
+ pDevice->pControlURB->transfer_flags |= URB_ASYNC_UNLINK;
+ pDevice->pControlURB->actual_length = 0;
+ // Notice, pbyBuffer limited point to variable buffer, can't be constant.
+ usb_fill_control_urb(pDevice->pControlURB, pDevice->usb,
+ usb_sndctrlpipe(pDevice->usb , 0), (char *) &pDevice->sUsbCtlRequest,
+ pbyBuffer, wLength, s_nsControlInUsbIoCompleteWrite, pDevice);
+
+ if ((ntStatus = vntwusb_submit_urb(pDevice->pControlURB) != 0)) {
+ DBG_PRT(MSG_LEVEL_DEBUG, KERN_INFO"control send request submission failed: %d\n", ntStatus);
+ return STATUS_FAILURE;
+ }
+ else {
+ MP_SET_FLAG(pDevice, fMP_CONTROL_WRITES);
+ }
+ spin_unlock_irq(&pDevice->lock);
+ for (ii = 0; ii <= USB_CTL_WAIT; ii ++) {
+ if (MP_TEST_FLAG(pDevice, fMP_CONTROL_WRITES))
+ mdelay(1);
+ else
+ break;
+ if (ii >= USB_CTL_WAIT) {
+ DBG_PRT(MSG_LEVEL_DEBUG, KERN_INFO"control send request submission timeout \n");
+ spin_lock_irq(&pDevice->lock);
+ MP_CLEAR_FLAG(pDevice, fMP_CONTROL_WRITES);
+ return STATUS_FAILURE;
+ }
+ }
+ spin_lock_irq(&pDevice->lock);
+
+ return STATUS_SUCCESS;
+}
+
+
+
+
+NTSTATUS
+PIPEnsControlIn(
+ IN PSDevice pDevice,
+ IN BYTE byRequest,
+ IN WORD wValue,
+ IN WORD wIndex,
+ IN WORD wLength,
+ IN OUT PBYTE pbyBuffer
+ )
+{
+ NTSTATUS ntStatus = 0;
+ int ii;
+
+ if (MP_TEST_FLAG(pDevice, fMP_DISCONNECTED))
+ return STATUS_FAILURE;
+
+ if (MP_TEST_FLAG(pDevice, fMP_CONTROL_READS)) {
+ return STATUS_FAILURE;
+ }
+ pDevice->sUsbCtlRequest.bRequestType = 0xC0;
+ pDevice->sUsbCtlRequest.bRequest = byRequest;
+ pDevice->sUsbCtlRequest.wValue = cpu_to_le16p(&wValue);
+ pDevice->sUsbCtlRequest.wIndex = cpu_to_le16p(&wIndex);
+ pDevice->sUsbCtlRequest.wLength = cpu_to_le16p(&wLength);
+ pDevice->pControlURB->transfer_flags |= URB_ASYNC_UNLINK;
+ pDevice->pControlURB->actual_length = 0;
+ usb_fill_control_urb(pDevice->pControlURB, pDevice->usb,
+ usb_rcvctrlpipe(pDevice->usb , 0), (char *) &pDevice->sUsbCtlRequest,
+ pbyBuffer, wLength, s_nsControlInUsbIoCompleteRead, pDevice);
+
+ if ((ntStatus = vntwusb_submit_urb(pDevice->pControlURB) != 0)) {
+ DBG_PRT(MSG_LEVEL_DEBUG, KERN_INFO"control request submission failed: %d\n", ntStatus);
+ }else {
+ MP_SET_FLAG(pDevice, fMP_CONTROL_READS);
+ }
+
+ spin_unlock_irq(&pDevice->lock);
+ for (ii = 0; ii <= USB_CTL_WAIT; ii ++) {
+ if (MP_TEST_FLAG(pDevice, fMP_CONTROL_READS))
+ mdelay(1);
+ else {
+ break;
+ }
+ if (ii >= USB_CTL_WAIT) {
+ DBG_PRT(MSG_LEVEL_DEBUG, KERN_INFO"control rcv request submission timeout \n");
+ spin_lock_irq(&pDevice->lock);
+ MP_CLEAR_FLAG(pDevice, fMP_CONTROL_READS);
+ return STATUS_FAILURE;
+ }
+ }
+ spin_lock_irq(&pDevice->lock);
+
+ return ntStatus;
+}
+
+static
+VOID
+s_nsControlInUsbIoCompleteWrite(
+ IN struct urb *urb
+ )
+{
+ PSDevice pDevice;
+
+ pDevice = urb->context;
+ switch (urb->status) {
+ case 0:
+ break;
+ case -EINPROGRESS:
+ DBG_PRT(MSG_LEVEL_DEBUG, KERN_INFO"ctrl write urb status EINPROGRESS%d\n", urb->status);
+ break;
+ case -ENOENT:
+ DBG_PRT(MSG_LEVEL_DEBUG, KERN_INFO"ctrl write urb status ENOENT %d\n", urb->status);
+ break;
+ default:
+ DBG_PRT(MSG_LEVEL_DEBUG, KERN_INFO"ctrl write urb status %d\n", urb->status);
+ }
+
+ MP_CLEAR_FLAG(pDevice, fMP_CONTROL_WRITES);
+}
+
+
+
+/*
+ * Description:
+ * Complete function of usb Control callback
+ *
+ * Parameters:
+ * In:
+ * pDevice - Pointer to the adapter
+ *
+ * Out:
+ * none
+ *
+ * Return Value: STATUS_INSUFFICIENT_RESOURCES or result of IoCallDriver
+ *
+ */
+static
+VOID
+s_nsControlInUsbIoCompleteRead(
+ IN struct urb *urb
+ )
+{
+ PSDevice pDevice;
+
+ pDevice = urb->context;
+ switch (urb->status) {
+ case 0:
+ break;
+ case -EINPROGRESS:
+ DBG_PRT(MSG_LEVEL_DEBUG, KERN_INFO"ctrl read urb status EINPROGRESS%d\n", urb->status);
+ break;
+ case -ENOENT:
+ DBG_PRT(MSG_LEVEL_DEBUG, KERN_INFO"ctrl read urb status = ENOENT %d\n", urb->status);
+ break;
+ default:
+ DBG_PRT(MSG_LEVEL_DEBUG, KERN_INFO"ctrl read urb status %d\n", urb->status);
+ }
+
+ MP_CLEAR_FLAG(pDevice, fMP_CONTROL_READS);
+}
+
+
+
+
+/*
+ * Description:
+ * Allocates an usb interrupt in irp and calls USBD.
+ *
+ * Parameters:
+ * In:
+ * pDevice - Pointer to the adapter
+ * Out:
+ * none
+ *
+ * Return Value: STATUS_INSUFFICIENT_RESOURCES or result of IoCallDriver
+ *
+ */
+NTSTATUS
+PIPEnsInterruptRead(
+ IN PSDevice pDevice
+ )
+{
+ NTSTATUS ntStatus = STATUS_FAILURE;
+
+
+ DBG_PRT(MSG_LEVEL_DEBUG, KERN_INFO"---->s_nsStartInterruptUsbRead()\n");
+
+ if(pDevice->intBuf.bInUse == TRUE){
+ return (STATUS_FAILURE);
+ }
+ pDevice->intBuf.bInUse = TRUE;
+// pDevice->bEventAvailable = FALSE;
+ pDevice->ulIntInPosted++;
+
+ //
+ // Now that we have created the urb, we will send a
+ // request to the USB device object.
+ //
+#if 0 //reserve int URB submit
+ usb_fill_int_urb(pDevice->pInterruptURB,
+ pDevice->usb,
+ usb_rcvintpipe(pDevice->usb, 1),
+ (PVOID) pDevice->intBuf.pDataBuf,
+ MAX_INTERRUPT_SIZE,
+ s_nsInterruptUsbIoCompleteRead,
+ pDevice,
+ pDevice->int_interval
+ );
+#else //replace int URB submit by bulk transfer
+#ifndef Safe_Close
+ usb_fill_int_urb(pDevice->pInterruptURB,
+ pDevice->usb,
+ usb_rcvintpipe(pDevice->usb, 1),
+ (PVOID) pDevice->intBuf.pDataBuf,
+ MAX_INTERRUPT_SIZE,
+ s_nsInterruptUsbIoCompleteRead,
+ pDevice,
+ pDevice->int_interval
+ );
+#else
+
+ pDevice->pInterruptURB->interval = pDevice->int_interval;
+
+usb_fill_bulk_urb(pDevice->pInterruptURB,
+ pDevice->usb,
+ usb_rcvbulkpipe(pDevice->usb, 1),
+ (PVOID) pDevice->intBuf.pDataBuf,
+ MAX_INTERRUPT_SIZE,
+ s_nsInterruptUsbIoCompleteRead,
+ pDevice);
+#endif
+#endif
+
+ if ((ntStatus = vntwusb_submit_urb(pDevice->pInterruptURB)) != 0) {
+ DBG_PRT(MSG_LEVEL_DEBUG, KERN_INFO"Submit int URB failed %d\n", ntStatus);
+ }
+
+ DBG_PRT(MSG_LEVEL_DEBUG, KERN_INFO"<----s_nsStartInterruptUsbRead Return(%x)\n",ntStatus);
+ return ntStatus;
+}
+
+
+/*
+ * Description:
+ * Complete function of usb interrupt in irp.
+ *
+ * Parameters:
+ * In:
+ * pDevice - Pointer to the adapter
+ *
+ * Out:
+ * none
+ *
+ * Return Value: STATUS_INSUFFICIENT_RESOURCES or result of IoCallDriver
+ *
+ */
+static
+VOID
+s_nsInterruptUsbIoCompleteRead(
+ IN struct urb *urb
+ )
+
+{
+ PSDevice pDevice;
+ NTSTATUS ntStatus;
+
+
+ DBG_PRT(MSG_LEVEL_DEBUG, KERN_INFO"---->s_nsInterruptUsbIoCompleteRead\n");
+ //
+ // The context given to IoSetCompletionRoutine is the receive buffer object
+ //
+ pDevice = (PSDevice)urb->context;
+
+ //
+ // We have a number of cases:
+ // 1) The USB read timed out and we received no data.
+ // 2) The USB read timed out and we received some data.
+ // 3) The USB read was successful and fully filled our irp buffer.
+ // 4) The irp was cancelled.
+ // 5) Some other failure from the USB device object.
+ //
+ ntStatus = urb->status;
+
+ DBG_PRT(MSG_LEVEL_DEBUG, KERN_INFO"s_nsInterruptUsbIoCompleteRead Status %d\n", ntStatus);
+
+ // if we were not successful, we need to free the int buffer for future use right here
+ // otherwise interrupt data handler will free int buffer after it handle it.
+ if (( ntStatus != STATUS_SUCCESS )) {
+ pDevice->ulBulkInError++;
+ pDevice->intBuf.bInUse = FALSE;
+
+// if (ntStatus == USBD_STATUS_CRC) {
+// pDevice->ulIntInContCRCError++;
+// }
+
+// if (ntStatus == STATUS_NOT_CONNECTED )
+// {
+ pDevice->fKillEventPollingThread = TRUE;
+// }
+ DBG_PRT(MSG_LEVEL_DEBUG, KERN_INFO"IntUSBIoCompleteControl STATUS = %d\n", ntStatus );
+ }
+ else {
+ pDevice->ulIntInBytesRead += (ULONG)urb->actual_length;
+ pDevice->ulIntInContCRCError = 0;
+ pDevice->bEventAvailable = TRUE;
+ INTnsProcessData(pDevice);
+ }
+
+ STAvUpdateUSBCounter(&pDevice->scStatistic.USB_InterruptStat, ntStatus);
+
+
+ if (pDevice->fKillEventPollingThread != TRUE) {
+ #if 0 //reserve int URB submit
+ if ((ntStatus = vntwusb_submit_urb(urb)) != 0) {
+ DBG_PRT(MSG_LEVEL_DEBUG, KERN_INFO"Re-Submit int URB failed %d\n", ntStatus);
+ }
+ #else //replace int URB submit by bulk transfer
+ #ifdef Safe_Close
+ usb_fill_bulk_urb(pDevice->pInterruptURB,
+ pDevice->usb,
+ usb_rcvbulkpipe(pDevice->usb, 1),
+ (PVOID) pDevice->intBuf.pDataBuf,
+ MAX_INTERRUPT_SIZE,
+ s_nsInterruptUsbIoCompleteRead,
+ pDevice);
+
+ if ((ntStatus = vntwusb_submit_urb(pDevice->pInterruptURB)) != 0) {
+ DBG_PRT(MSG_LEVEL_DEBUG, KERN_INFO"Submit int URB failed %d\n", ntStatus);
+ }
+
+ #else
+ tasklet_schedule(&pDevice->EventWorkItem);
+ #endif
+#endif
+ }
+ //
+ // We return STATUS_MORE_PROCESSING_REQUIRED so that the completion
+ // routine (IofCompleteRequest) will stop working on the irp.
+ //
+ return ;
+}
+
+/*
+ * Description:
+ * Allocates an usb BulkIn irp and calls USBD.
+ *
+ * Parameters:
+ * In:
+ * pDevice - Pointer to the adapter
+ * Out:
+ * none
+ *
+ * Return Value: STATUS_INSUFFICIENT_RESOURCES or result of IoCallDriver
+ *
+ */
+NTSTATUS
+PIPEnsBulkInUsbRead(
+ IN PSDevice pDevice,
+ IN PRCB pRCB
+ )
+{
+ NTSTATUS ntStatus= 0;
+ struct urb *pUrb;
+
+
+ DBG_PRT(MSG_LEVEL_DEBUG, KERN_INFO"---->s_nsStartBulkInUsbRead\n");
+
+ if (MP_TEST_FLAG(pDevice, fMP_DISCONNECTED))
+ return STATUS_FAILURE;
+
+ pDevice->ulBulkInPosted++;
+
+
+ pUrb = pRCB->pUrb;
+ //
+ // Now that we have created the urb, we will send a
+ // request to the USB device object.
+ //
+ if (pRCB->skb == NULL) {
+ DBG_PRT(MSG_LEVEL_DEBUG, KERN_INFO"pRCB->skb is null \n");
+ return ntStatus;
+ }
+
+ usb_fill_bulk_urb(pUrb,
+ pDevice->usb,
+ usb_rcvbulkpipe(pDevice->usb, 2),
+ (PVOID) (pRCB->skb->data),
+ MAX_TOTAL_SIZE_WITH_ALL_HEADERS,
+ s_nsBulkInUsbIoCompleteRead,
+ pRCB);
+
+ if((ntStatus = vntwusb_submit_urb(pUrb)!=0)){
+ DBG_PRT(MSG_LEVEL_DEBUG, KERN_INFO"Submit Rx URB failed %d\n", ntStatus);
+ return STATUS_FAILURE ;
+ }
+ pRCB->Ref = 1;
+ pRCB->bBoolInUse= TRUE;
+
+ return ntStatus;
+}
+
+
+
+
+/*
+ * Description:
+ * Complete function of usb BulkIn irp.
+ *
+ * Parameters:
+ * In:
+ * pDevice - Pointer to the adapter
+ *
+ * Out:
+ * none
+ *
+ * Return Value: STATUS_INSUFFICIENT_RESOURCES or result of IoCallDriver
+ *
+ */
+static
+VOID
+s_nsBulkInUsbIoCompleteRead(
+ IN struct urb *urb
+ )
+
+{
+ PRCB pRCB = (PRCB)urb->context;
+ PSDevice pDevice = (PSDevice)pRCB->pDevice;
+ ULONG bytesRead;
+ BOOLEAN bIndicateReceive = FALSE;
+ BOOL bReAllocSkb = FALSE;
+ NTSTATUS status;
+
+
+
+ DBG_PRT(MSG_LEVEL_DEBUG, KERN_INFO"---->s_nsBulkInUsbIoCompleteRead\n");
+ status = urb->status;
+ bytesRead = urb->actual_length;
+
+ if (status) {
+ pDevice->ulBulkInError++;
+ DBG_PRT(MSG_LEVEL_DEBUG, KERN_INFO"BULK In failed %d\n", status);
+
+ #ifdef Calcu_LinkQual
+ pDevice->scStatistic.RxFcsErrCnt ++;
+ #endif
+//todo...xxxxxx
+// if (status == USBD_STATUS_CRC) {
+// pDevice->ulBulkInContCRCError++;
+// }
+// if (status == STATUS_DEVICE_NOT_CONNECTED )
+// {
+// MP_SET_FLAG(pDevice, fMP_DISCONNECTED);
+// }
+ } else {
+ bIndicateReceive = TRUE;
+ pDevice->ulBulkInContCRCError = 0;
+ pDevice->ulBulkInBytesRead += bytesRead;
+
+ #ifdef Calcu_LinkQual
+ pDevice->scStatistic.RxOkCnt ++;
+ #endif
+ }
+
+
+ STAvUpdateUSBCounter(&pDevice->scStatistic.USB_BulkInStat, status);
+
+ if (bIndicateReceive) {
+ spin_lock(&pDevice->lock);
+ if (RXbBulkInProcessData(pDevice, pRCB, bytesRead) == TRUE)
+ bReAllocSkb = TRUE;
+ spin_unlock(&pDevice->lock);
+ }
+ pRCB->Ref--;
+ if (pRCB->Ref == 0)
+ {
+ DBG_PRT(MSG_LEVEL_DEBUG, KERN_INFO"RxvFreeNormal %d \n",pDevice->NumRecvFreeList);
+ spin_lock(&pDevice->lock);
+ RXvFreeRCB(pRCB, bReAllocSkb);
+ spin_unlock(&pDevice->lock);
+ }
+
+
+ return;
+}
+
+/*
+ * Description:
+ * Allocates an usb BulkOut irp and calls USBD.
+ *
+ * Parameters:
+ * In:
+ * pDevice - Pointer to the adapter
+ * Out:
+ * none
+ *
+ * Return Value: STATUS_INSUFFICIENT_RESOURCES or result of IoCallDriver
+ *
+ */
+NDIS_STATUS
+PIPEnsSendBulkOut(
+ IN PSDevice pDevice,
+ IN PUSB_SEND_CONTEXT pContext
+ )
+{
+ NTSTATUS status;
+ struct urb *pUrb;
+
+
+
+ pDevice->bPWBitOn = FALSE;
+
+/*
+ if (pDevice->pPendingBulkOutContext != NULL) {
+ pDevice->NumContextsQueued++;
+ EnqueueContext(pDevice->FirstTxContextQueue, pDevice->LastTxContextQueue, pContext);
+ status = STATUS_PENDING;
+ DBG_PRT(MSG_LEVEL_DEBUG, KERN_INFO"Send pending!\n");
+ return status;
+ }
+*/
+
+ DBG_PRT(MSG_LEVEL_DEBUG, KERN_INFO"s_nsSendBulkOut\n");
+
+ if(MP_IS_READY(pDevice) && MP_TEST_FLAG(pDevice, fMP_POST_WRITES)) {
+
+ pUrb = pContext->pUrb;
+ pDevice->ulBulkOutPosted++;
+// pDevice->pPendingBulkOutContext = pContext;
+ usb_fill_bulk_urb(
+ pUrb,
+ pDevice->usb,
+ usb_sndbulkpipe(pDevice->usb, 3),
+ (PVOID) &(pContext->Data[0]),
+ pContext->uBufLen,
+ s_nsBulkOutIoCompleteWrite,
+ pContext);
+
+ if((status = vntwusb_submit_urb(pUrb))!=0)
+ {
+ DBG_PRT(MSG_LEVEL_DEBUG, KERN_INFO"Submit Tx URB failed %d\n", status);
+ return STATUS_FAILURE;
+ }
+ return STATUS_PENDING;
+ }
+ else {
+ pContext->bBoolInUse = FALSE;
+ return STATUS_RESOURCES;
+ }
+}
+
+/*
+ * Description: s_nsBulkOutIoCompleteWrite
+ * 1a) Indicate to the protocol the status of the write.
+ * 1b) Return ownership of the packet to the protocol.
+ *
+ * 2) If any more packets are queue for sending, send another packet
+ * to USBD.
+ * If the attempt to send the packet to the driver fails,
+ * return ownership of the packet to the protocol and
+ * try another packet (until one succeeds).
+ *
+ * Parameters:
+ * In:
+ * pdoUsbDevObj - pointer to the USB device object which
+ * completed the irp
+ * pIrp - the irp which was completed by the
+ * device object
+ * pContext - the context given to IoSetCompletionRoutine
+ * before calling IoCallDriver on the irp
+ * The pContext is a pointer to the USB device object.
+ * Out:
+ * none
+ *
+ * Return Value: STATUS_MORE_PROCESSING_REQUIRED - allows the completion routine
+ * (IofCompleteRequest) to stop working on the irp.
+ *
+ */
+static
+VOID
+s_nsBulkOutIoCompleteWrite(
+ IN struct urb *urb
+ )
+{
+ PSDevice pDevice;
+ NTSTATUS status;
+ CONTEXT_TYPE ContextType;
+ ULONG ulBufLen;
+ PUSB_SEND_CONTEXT pContext;
+
+
+ DBG_PRT(MSG_LEVEL_DEBUG, KERN_INFO"---->s_nsBulkOutIoCompleteWrite\n");
+ //
+ // The context given to IoSetCompletionRoutine is an USB_CONTEXT struct
+ //
+ pContext = (PUSB_SEND_CONTEXT) urb->context;
+ ASSERT( NULL != pContext );
+
+ pDevice = pContext->pDevice;
+ ContextType = pContext->Type;
+ ulBufLen = pContext->uBufLen;
+
+ if (!netif_device_present(pDevice->dev))
+ return;
+
+ //
+ // Perform various IRP, URB, and buffer 'sanity checks'
+ //
+
+ status = urb->status;
+ //we should have failed, succeeded, or cancelled, but NOT be pending
+ STAvUpdateUSBCounter(&pDevice->scStatistic.USB_BulkOutStat, status);
+
+ if(status == STATUS_SUCCESS) {
+ DBG_PRT(MSG_LEVEL_DEBUG, KERN_INFO"Write %d bytes\n",(int)ulBufLen);
+ pDevice->ulBulkOutBytesWrite += ulBufLen;
+ pDevice->ulBulkOutContCRCError = 0;
+ //2007-0115-06<Add>by MikeLiu
+ #ifdef TxInSleep
+ pDevice->nTxDataTimeCout = 0;
+ #endif
+
+ } else {
+ DBG_PRT(MSG_LEVEL_DEBUG, KERN_INFO"BULK Out failed %d\n", status);
+ pDevice->ulBulkOutError++;
+ }
+
+// pDevice->ulCheckForHangCount = 0;
+// pDevice->pPendingBulkOutContext = NULL;
+
+ if ( CONTEXT_DATA_PACKET == ContextType ) {
+ // Indicate to the protocol the status of the sent packet and return
+ // ownership of the packet.
+ if (pContext->pPacket != NULL) {
+ dev_kfree_skb_irq(pContext->pPacket);
+ pContext->pPacket = NULL;
+ DBG_PRT(MSG_LEVEL_DEBUG, KERN_INFO"tx %d bytes\n",(int)ulBufLen);
+ }
+
+ pDevice->dev->trans_start = jiffies;
+
+
+ if (status == STATUS_SUCCESS) {
+ pDevice->packetsSent++;
+ }
+ else {
+ DBG_PRT(MSG_LEVEL_DEBUG, KERN_INFO"Send USB error! [%08xh]\n", status);
+ pDevice->packetsSentDropped++;
+ }
+
+ }
+ if (pDevice->bLinkPass == TRUE) {
+ if (netif_queue_stopped(pDevice->dev))
+ netif_wake_queue(pDevice->dev);
+ }
+ pContext->bBoolInUse = FALSE;
+
+ return;
+}
diff --git a/drivers/staging/vt6656/usbpipe.h b/drivers/staging/vt6656/usbpipe.h
new file mode 100644
index 000000000000..729edadb491e
--- /dev/null
+++ b/drivers/staging/vt6656/usbpipe.h
@@ -0,0 +1,116 @@
+/*
+ * 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: usbpipe.h
+ *
+ * Purpose:
+ *
+ * Author: Warren Hsu
+ *
+ * Date: Mar. 30, 2005
+ *
+ */
+
+
+#ifndef __USBPIPE_H__
+#define __USBPIPE_H__
+
+#if !defined(__TTYPE_H__)
+#include "ttype.h"
+#endif
+#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 */
+
+NTSTATUS
+PIPEnsControlOut(
+ IN PSDevice pDevice,
+ IN BYTE byRequest,
+ IN WORD wValue,
+ IN WORD wIndex,
+ IN WORD wLength,
+ IN PBYTE pbyBuffer
+ );
+
+
+
+NTSTATUS
+PIPEnsControlOutAsyn(
+ IN PSDevice pDevice,
+ IN BYTE byRequest,
+ IN WORD wValue,
+ IN WORD wIndex,
+ IN WORD wLength,
+ IN PBYTE pbyBuffer
+ );
+
+NTSTATUS
+PIPEnsControlIn(
+ IN PSDevice pDevice,
+ IN BYTE byRequest,
+ IN WORD wValue,
+ IN WORD wIndex,
+ IN WORD wLength,
+ IN OUT PBYTE pbyBuffer
+ );
+
+
+
+
+NTSTATUS
+PIPEnsInterruptRead(
+ IN PSDevice pDevice
+ );
+
+NTSTATUS
+PIPEnsBulkInUsbRead(
+ IN PSDevice pDevice,
+ IN PRCB pRCB
+ );
+
+NTSTATUS
+PIPEnsSendBulkOut(
+ IN PSDevice pDevice,
+ IN PUSB_SEND_CONTEXT pContext
+ );
+
+#ifdef __cplusplus
+} /* End of extern "C" { */
+#endif /* __cplusplus */
+
+
+
+
+#endif // __USBPIPE_H__
+
+
+
diff --git a/drivers/staging/vt6656/vntconfiguration.dat b/drivers/staging/vt6656/vntconfiguration.dat
new file mode 100644
index 000000000000..933774c7d27f
--- /dev/null
+++ b/drivers/staging/vt6656/vntconfiguration.dat
@@ -0,0 +1,6 @@
+#VNT Configuration
+[start]
+ZONETYPE=EUROPE
+AUTHENMODE=12
+ENCRYPTIONMODE=34
+[end] \ No newline at end of file
diff --git a/drivers/staging/vt6656/wcmd.c b/drivers/staging/vt6656/wcmd.c
new file mode 100644
index 000000000000..80d7ca73bcd9
--- /dev/null
+++ b/drivers/staging/vt6656/wcmd.c
@@ -0,0 +1,1397 @@
+/*
+ * 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
+ * s_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(__CONTROL_H__)
+#include "control.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
+#if !defined(__RNDIS_H__)
+#include "rndis.h"
+#endif
+#if !defined (_CHANNEL_H_)
+#include "channel.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
+ );
+
+
+static
+BOOL s_bClearBSSID_SCAN (
+ IN HANDLE hDeviceContext
+ );
+
+/*--------------------- 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)
+ {
+ //PMESG(("STOP_BEACON: IBSSChannel = %u, ScanChannel = %u\n",
+ // pMgmt->uIBSSChannel, pMgmt->uScanChannel));
+ MACvRegBitsOff(pDevice, MAC_REG_TCR, TCR_AUTOBCNTX);
+ }
+
+} /* vAdHocBeaconStop */
+
+
+/*
+ * 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))
+ {
+ //PMESG(("RESTART_BEACON\n"));
+ MACvRegBitsOn(pDevice, 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->sMgmtObj);
+ UINT ii;
+
+
+ if (pDevice->byBBType == BB_TYPE_11A) {
+ pbyRate = &abyCurrSuppRatesA[0];
+ } else if (pDevice->byBBType == BB_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 < 1 ; ii++) {
+ if (csMgmt_xmit(pDevice, pTxPacket) != CMD_STATUS_PENDING) {
+ DBG_PRT(MSG_LEVEL_DEBUG, KERN_INFO "Probe request sending fail.. \n");
+ }
+ else {
+ DBG_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->byBBType == BB_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)vRunCommand;
+ // RUN_AT :1 msec ~= (HZ/1024)
+ pDevice->sTimerCommand.expires = (UINT)RUN_AT((MSecond * HZ) >> 10);
+ add_timer(&pDevice->sTimerCommand);
+ return;
+}
+
+
+
+
+VOID
+vRunCommand(
+ IN HANDLE hDeviceContext
+ )
+{
+ PSDevice pDevice = (PSDevice)hDeviceContext;
+ PSMgmtObject pMgmt = &(pDevice->sMgmtObj);
+ 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;
+ BYTE byData;
+
+
+ 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);
+ spin_unlock_irq(&pDevice->lock);
+ return;
+ }
+
+ pItemSSID = (PWLAN_IE_SSID)pMgmt->abyScanSSID;
+
+ if (pMgmt->uScanChannel == 0 ) {
+ pMgmt->uScanChannel = pDevice->byMinChannel;
+ }
+ if (pMgmt->uScanChannel > pDevice->byMaxChannel) {
+ pMgmt->eScanState = WMAC_NO_SCANNING;
+
+ if (pDevice->byBBType != pDevice->byScanBBType) {
+ pDevice->byBBType = pDevice->byScanBBType;
+ CARDvSetBSSMode(pDevice);
+ }
+
+ if (pDevice->bUpdateBBVGA) {
+ BBvSetShortSlotTime(pDevice);
+ BBvSetVGAGainOffset(pDevice, pDevice->byBBVGACurrent);
+ BBvUpdatePreEDThreshold(pDevice, FALSE);
+ }
+ // Set channel back
+ vAdHocBeaconRestart(pDevice);
+ // Set channel back
+ CARDbSetMediaChannel(pDevice, pMgmt->uCurrChannel);
+ // Set Filter
+ if (pMgmt->bCurrBSSIDFilterOn) {
+ MACvRegBitsOn(pDevice, MAC_REG_RCR, RCR_BSSID);
+ pDevice->byRxMode |= RCR_BSSID;
+ }
+ DBG_PRT(MSG_LEVEL_DEBUG, KERN_INFO "Scanning, set back to channel: [%d]\n", pMgmt->uCurrChannel);
+ pDevice->bStopDataPkt = FALSE;
+ s_bCommandComplete(pDevice);
+ spin_unlock_irq(&pDevice->lock);
+ return;
+
+ } else {
+ if (!ChannelValid(pDevice->byZoneType, pMgmt->uScanChannel)) {
+ DBG_PRT(MSG_LEVEL_DEBUG, KERN_INFO "Invalid channel pMgmt->uScanChannel = %d \n",pMgmt->uScanChannel);
+ s_bCommandComplete(pDevice);
+ spin_unlock_irq(&pDevice->lock);
+ return;
+ }
+ if (pMgmt->uScanChannel == pDevice->byMinChannel) {
+ // pMgmt->eScanType = WMAC_SCAN_ACTIVE; //mike mark
+ 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;
+ pDevice->byScanBBType = pDevice->byBBType; //lucas
+ pDevice->bStopDataPkt = TRUE;
+ // Turn off RCR_BSSID filter everytime
+ MACvRegBitsOff(pDevice, MAC_REG_RCR, RCR_BSSID);
+ pDevice->byRxMode &= ~RCR_BSSID;
+
+ }
+ //lucas
+ vAdHocBeaconStop(pDevice);
+ if ((pDevice->byBBType != BB_TYPE_11A) && (pMgmt->uScanChannel > CB_MAX_CHANNEL_24G)) {
+ pDevice->byBBType = BB_TYPE_11A;
+ CARDvSetBSSMode(pDevice);
+ }
+ else if ((pDevice->byBBType == BB_TYPE_11A) && (pMgmt->uScanChannel <= CB_MAX_CHANNEL_24G)) {
+ pDevice->byBBType = BB_TYPE_11G;
+ CARDvSetBSSMode(pDevice);
+ }
+ DBG_PRT(MSG_LEVEL_DEBUG, KERN_INFO "Scanning.... channel: [%d]\n", pMgmt->uScanChannel);
+ // Set channel
+ CARDbSetMediaChannel(pDevice, pMgmt->uScanChannel);
+ // Set Baseband to be more sensitive.
+
+ if (pDevice->bUpdateBBVGA) {
+ BBvSetShortSlotTime(pDevice);
+ BBvSetVGAGainOffset(pDevice, pDevice->abyBBVGA[0]);
+ BBvUpdatePreEDThreshold(pDevice, TRUE);
+ }
+ pMgmt->uScanChannel++;
+
+ while (!ChannelValid(pDevice->byZoneType, pMgmt->uScanChannel) &&
+ pMgmt->uScanChannel <= pDevice->byMaxChannel ){
+ pMgmt->uScanChannel++;
+ }
+
+ if (pMgmt->uScanChannel > pDevice->byMaxChannel) {
+ // Set Baseband to be not sensitive and rescan
+ pDevice->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, 100);
+ 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.
+ if (pDevice->byBBType != pDevice->byScanBBType) {
+ pDevice->byBBType = pDevice->byScanBBType;
+ CARDvSetBSSMode(pDevice);
+ }
+
+ if (pDevice->bUpdateBBVGA) {
+ BBvSetShortSlotTime(pDevice);
+ BBvSetVGAGainOffset(pDevice, pDevice->byBBVGACurrent);
+ BBvUpdatePreEDThreshold(pDevice, FALSE);
+ }
+
+ // Set channel back
+ vAdHocBeaconRestart(pDevice);
+ // Set channel back
+ CARDbSetMediaChannel(pDevice, pMgmt->uCurrChannel);
+ // Set Filter
+ if (pMgmt->bCurrBSSIDFilterOn) {
+ MACvRegBitsOn(pDevice, MAC_REG_RCR, RCR_BSSID);
+ pDevice->byRxMode |= RCR_BSSID;
+ }
+ DBG_PRT(MSG_LEVEL_DEBUG, KERN_INFO "Scanning, set back to channel: [%d]\n", pMgmt->uCurrChannel);
+ pMgmt->eScanState = WMAC_NO_SCANNING;
+ pDevice->bStopDataPkt = FALSE;
+//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;
+ PRINT_K("wireless_send_event--->SIOCGIWSCAN(scan done)\n");
+ 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 {
+
+ #ifdef WPA_SUPPLICANT_DRIVER_WEXT_SUPPORT
+ pDevice->bwextstep0 = FALSE;
+ pDevice->bwextstep1 = FALSE;
+ pDevice->bwextstep2 = FALSE;
+ pDevice->bwextstep3 = FALSE;
+ pDevice->bWPASuppWextEnabled = FALSE;
+ #endif
+ pDevice->fWPA_Authened = FALSE;
+
+ DBG_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;
+ ControlvMaskByte(pDevice,MESSAGE_REQUEST_MACREG,MAC_REG_PAPEDELAY,LEDSTS_STS,LEDSTS_SLOW);
+ // 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);
+ if (pDevice->bNeedRadioOFF == TRUE)
+ 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;
+ }
+
+//20080131-03,<Add> by Mike Liu
+ #ifdef Adhoc_STA
+ memcpy(pMgmt->abyAdHocSSID,pMgmt->abyDesireSSID,
+ ((PWLAN_IE_SSID)pMgmt->abyDesireSSID)->len + WLAN_IEHDR_LEN);
+ #endif
+ pItemSSID = (PWLAN_IE_SSID)pMgmt->abyDesireSSID;
+ pItemSSIDCurr = (PWLAN_IE_SSID)pMgmt->abyCurrSSID;
+ DBG_PRT(MSG_LEVEL_DEBUG, KERN_INFO" cmd: desire ssid = %s\n", pItemSSID->abySSID);
+ DBG_PRT(MSG_LEVEL_DEBUG, KERN_INFO" cmd: curr ssid = %s\n", pItemSSIDCurr->abySSID);
+
+ if (pMgmt->eCurrState == WMAC_STATE_ASSOC) {
+ DBG_PRT(MSG_LEVEL_DEBUG, KERN_INFO" Cmd pMgmt->eCurrState == WMAC_STATE_ASSOC\n");
+ DBG_PRT(MSG_LEVEL_DEBUG, KERN_INFO" pItemSSID->len =%d\n",pItemSSID->len);
+ DBG_PRT(MSG_LEVEL_DEBUG, KERN_INFO" pItemSSIDCurr->len = %d\n",pItemSSIDCurr->len);
+ DBG_PRT(MSG_LEVEL_DEBUG, KERN_INFO" desire ssid = %s\n", pItemSSID->abySSID);
+ DBG_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;
+ ControlvMaskByte(pDevice,MESSAGE_REQUEST_MACREG,MAC_REG_PAPEDELAY,LEDSTS_STS,LEDSTS_SLOW);
+ }
+ // 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);
+ DBG_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;
+ ControlvMaskByte(pDevice,MESSAGE_REQUEST_MACREG,MAC_REG_PAPEDELAY,LEDSTS_STS,LEDSTS_INTER);
+ pMgmt->sNodeDBTable[0].bActive = TRUE;
+ pMgmt->sNodeDBTable[0].uInActiveCount = 0;
+ }
+ else {
+ // start own IBSS
+ DBG_PRT(MSG_LEVEL_DEBUG, KERN_INFO "CreateOwn IBSS by CurrMode = IBSS_STA \n");
+ vMgrCreateOwnIBSS((HANDLE)pDevice, &Status);
+ if (Status != CMD_STATUS_SUCCESS){
+ DBG_PRT(MSG_LEVEL_DEBUG, KERN_INFO " WLAN_CMD_IBSS_CREATE fail ! \n");
+ };
+ BSSvAddMulticastNode(pDevice);
+ }
+ s_bClearBSSID_SCAN(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
+ DBG_PRT(MSG_LEVEL_DEBUG, KERN_INFO "CreateOwn IBSS by CurrMode = STANDBY \n");
+ vMgrCreateOwnIBSS((HANDLE)pDevice, &Status);
+ if (Status != CMD_STATUS_SUCCESS){
+ DBG_PRT(MSG_LEVEL_DEBUG, KERN_INFO" WLAN_CMD_IBSS_CREATE fail ! \n");
+ };
+ BSSvAddMulticastNode(pDevice);
+ s_bClearBSSID_SCAN(pDevice);
+/*
+ pDevice->bLinkPass = TRUE;
+ ControlvMaskByte(pDevice,MESSAGE_REQUEST_MACREG,MAC_REG_PAPEDELAY,LEDSTS_STS,LEDSTS_INTER);
+ if (netif_queue_stopped(pDevice->dev)){
+ netif_wake_queue(pDevice->dev);
+ }
+ s_bClearBSSID_SCAN(pDevice);
+*/
+ }
+ else {
+ DBG_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;
+ PRINT_K("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 :
+ DBG_PRT(MSG_LEVEL_DEBUG, KERN_INFO"eCommandState == WLAN_AUTHENTICATE_WAIT\n");
+ if (pMgmt->eCurrState == WMAC_STATE_AUTH) {
+ pDevice->byLinkWaitCount = 0;
+ // Call mgr to begin the association
+ DBG_PRT(MSG_LEVEL_DEBUG, KERN_INFO"eCurrState == WMAC_STATE_AUTH\n");
+ vMgrAssocBeginSta((HANDLE)pDevice, pMgmt, &Status);
+ if (Status == CMD_STATUS_SUCCESS) {
+ DBG_PRT(MSG_LEVEL_DEBUG, KERN_INFO"eCommandState = WLAN_ASSOCIATE_WAIT\n");
+ pDevice->byLinkWaitCount = 0;
+ 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) {
+ DBG_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, &(pDevice->sKey), pDevice->abyBSSID);
+ }
+*/
+ pDevice->byLinkWaitCount = 0;
+ pDevice->byReAssocCount = 0;
+ pDevice->bLinkPass = TRUE;
+ ControlvMaskByte(pDevice,MESSAGE_REQUEST_MACREG,MAC_REG_PAPEDELAY,LEDSTS_STS,LEDSTS_INTER);
+ s_bClearBSSID_SCAN(pDevice);
+
+ if (netif_queue_stopped(pDevice->dev)){
+ netif_wake_queue(pDevice->dev);
+ }
+
+ //2007-0115-07<Add>by MikeLiu
+ #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 :
+ DBG_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;
+ ControlvMaskByte(pDevice,MESSAGE_REQUEST_MACREG,MAC_REG_PAPEDELAY,LEDSTS_STS,LEDSTS_SLOW);
+ 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){
+ DBG_PRT(MSG_LEVEL_DEBUG, KERN_INFO " vMgrCreateOwnIBSS fail ! \n");
+ };
+ // alway turn off unicast bit
+ MACvRegBitsOff(pDevice, MAC_REG_RCR, RCR_UNICAST);
+ pDevice->byRxMode &= ~RCR_UNICAST;
+ DBG_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;
+ ControlvMaskByte(pDevice,MESSAGE_REQUEST_MACREG,MAC_REG_PAPEDELAY,LEDSTS_STS,LEDSTS_INTER);
+ 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 (nsDMA_tx_packet(pDevice, TYPE_AC0DMA, skb) != 0) {
+ DBG_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) {
+ DBG_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 (nsDMA_tx_packet(pDevice, TYPE_AC0DMA, skb) != 0) {
+ DBG_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];
+ DBG_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:
+
+ DBG_PRT(MSG_LEVEL_DEBUG, KERN_INFO"eCommandState == WLAN_CMD_RADIO_START\n");
+ // if (pDevice->bRadioCmd == TRUE)
+ // CARDbRadioPowerOn(pDevice);
+ // else
+ // CARDbRadioPowerOff(pDevice);
+ //2008-09-09<Add> BY Mike:Hot Key for Radio On/Off
+ {
+ NTSTATUS ntStatus = STATUS_SUCCESS;
+ BYTE byTmp;
+
+ ntStatus = CONTROLnsRequestIn(pDevice,
+ MESSAGE_TYPE_READ,
+ MAC_REG_GPIOCTL1,
+ MESSAGE_REQUEST_MACREG,
+ 1,
+ &byTmp);
+
+ if ( ntStatus != STATUS_SUCCESS ) {
+ s_bCommandComplete(pDevice);
+ spin_unlock_irq(&pDevice->lock);
+ return;
+ }
+ if ( (byTmp & GPIO3_DATA) == 0 ) {
+ DBG_PRT(MSG_LEVEL_DEBUG, KERN_INFO" WLAN_CMD_RADIO_START_OFF........................\n");
+ // Old commands are useless.
+ // empty command Q
+ pDevice->cbFreeCmdQueue = CMD_Q_SIZE;
+ pDevice->uCmdDequeueIdx = 0;
+ pDevice->uCmdEnqueueIdx = 0;
+ //0415pDevice->bCmdRunning = FALSE;
+ pDevice->bCmdClear = TRUE;
+ pDevice->bStopTx0Pkt = FALSE;
+ pDevice->bStopDataPkt = TRUE;
+
+ pDevice->byKeyIndex = 0;
+ pDevice->bTransmitKey = FALSE;
+ spin_unlock_irq(&pDevice->lock);
+ KeyvInitTable(pDevice,&pDevice->sKey);
+ spin_lock_irq(&pDevice->lock);
+ pMgmt->byCSSPK = KEY_CTL_NONE;
+ pMgmt->byCSSGK = KEY_CTL_NONE;
+
+ if (pDevice->bLinkPass == TRUE) {
+ // reason = 8 : disassoc because sta has left
+ vMgrDisassocBeginSta((HANDLE)pDevice, pMgmt, pMgmt->abyCurrBSSID, (8), &Status);
+ pDevice->bLinkPass = FALSE;
+ // unlock command busy
+ pMgmt->eCurrState = WMAC_STATE_IDLE;
+ pMgmt->sNodeDBTable[0].bActive = FALSE;
+ #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;
+ PRINT_K("wireless_send_event--->SIOCGIWAP(disassociated)\n");
+ wireless_send_event(pDevice->dev, SIOCGIWAP, &wrqu, NULL);
+ }
+ #endif
+ }
+ #ifdef WPA_SUPPLICANT_DRIVER_WEXT_SUPPORT
+ pDevice->bwextstep0 = FALSE;
+ pDevice->bwextstep1 = FALSE;
+ pDevice->bwextstep2 = FALSE;
+ pDevice->bwextstep3 = FALSE;
+ pDevice->bWPASuppWextEnabled = FALSE;
+ #endif
+ //clear current SSID
+ pItemSSID = (PWLAN_IE_SSID)pMgmt->abyCurrSSID;
+ pItemSSID->len = 0;
+ memset(pItemSSID->abySSID, 0, WLAN_SSID_MAXLEN);
+ //clear dessire SSID
+ pItemSSID = (PWLAN_IE_SSID)pMgmt->abyDesireSSID;
+ pItemSSID->len = 0;
+ memset(pItemSSID->abySSID, 0, WLAN_SSID_MAXLEN);
+
+ netif_stop_queue(pDevice->dev);
+ CARDbRadioPowerOff(pDevice);
+ MACvRegBitsOn(pDevice,MAC_REG_GPIOCTL1,GPIO3_INTMD);
+ ControlvMaskByte(pDevice,MESSAGE_REQUEST_MACREG,MAC_REG_PAPEDELAY,LEDSTS_STS,LEDSTS_OFF);
+ pDevice->bHWRadioOff = TRUE;
+ } else {
+ DBG_PRT(MSG_LEVEL_DEBUG, KERN_INFO" WLAN_CMD_RADIO_START_ON........................\n");
+ pDevice->bHWRadioOff = FALSE;
+ CARDbRadioPowerOn(pDevice);
+ MACvRegBitsOff(pDevice,MAC_REG_GPIOCTL1,GPIO3_INTMD);
+ ControlvMaskByte(pDevice,MESSAGE_REQUEST_MACREG,MAC_REG_PAPEDELAY,LEDSTS_STS,LEDSTS_ON);
+ }
+ }
+
+ s_bCommandComplete(pDevice);
+ break;
+
+
+ case WLAN_CMD_CHANGE_BBSENSITIVITY_START:
+
+ pDevice->bStopDataPkt = TRUE;
+ pDevice->byBBVGACurrent = pDevice->byBBVGANew;
+ BBvSetVGAGainOffset(pDevice, pDevice->byBBVGACurrent);
+ DBG_PRT(MSG_LEVEL_DEBUG, KERN_INFO"Change sensitivity pDevice->byBBVGACurrent = %x\n", pDevice->byBBVGACurrent);
+ pDevice->bStopDataPkt = FALSE;
+ s_bCommandComplete(pDevice);
+ break;
+
+ case WLAN_CMD_TBTT_WAKEUP_START:
+ PSbIsNextTBTTWakeUp(pDevice);
+ s_bCommandComplete(pDevice);
+ break;
+
+ case WLAN_CMD_BECON_SEND_START:
+ bMgrPrepareBeaconToSend(pDevice, pMgmt);
+ s_bCommandComplete(pDevice);
+ break;
+
+ case WLAN_CMD_SETPOWER_START:
+
+ RFbSetPower(pDevice, pDevice->wCurrentRate, pMgmt->uCurrChannel);
+
+ s_bCommandComplete(pDevice);
+ break;
+
+ case WLAN_CMD_CHANGE_ANTENNA_START:
+ DBG_PRT(MSG_LEVEL_DEBUG, KERN_INFO"Change from Antenna%d to", (int)pDevice->dwRxAntennaSel);
+ if ( pDevice->dwRxAntennaSel == 0) {
+ pDevice->dwRxAntennaSel=1;
+ if (pDevice->bTxRxAntInv == TRUE)
+ BBvSetAntennaMode(pDevice, ANT_RXA);
+ else
+ BBvSetAntennaMode(pDevice, ANT_RXB);
+ } else {
+ pDevice->dwRxAntennaSel=0;
+ if (pDevice->bTxRxAntInv == TRUE)
+ BBvSetAntennaMode(pDevice, ANT_RXB);
+ else
+ BBvSetAntennaMode(pDevice, ANT_RXA);
+ }
+ s_bCommandComplete(pDevice);
+ break;
+
+ case WLAN_CMD_REMOVE_ALLKEY_START:
+ KeybRemoveAllKey(pDevice, &(pDevice->sKey), pDevice->abyBSSID);
+ s_bCommandComplete(pDevice);
+ break;
+
+
+ case WLAN_CMD_MAC_DISPOWERSAVING_START:
+ ControlvReadByte (pDevice, MESSAGE_REQUEST_MACREG, MAC_REG_PSCTL, &byData);
+ if ( (byData & PSCTL_PS) != 0 ) {
+ // disable power saving hw function
+ CONTROLnsRequestOut(pDevice,
+ MESSAGE_TYPE_DISABLE_PS,
+ 0,
+ 0,
+ 0,
+ NULL
+ );
+ }
+ s_bCommandComplete(pDevice);
+ break;
+
+ case WLAN_CMD_11H_CHSW_START:
+ CARDbSetMediaChannel(pDevice, pDevice->byNewChannel);
+ pDevice->bChannelSwitch = FALSE;
+ pMgmt->uCurrChannel = pDevice->byNewChannel;
+ pDevice->bStopDataPkt = FALSE;
+ 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->sMgmtObj);
+
+
+ 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:
+ DBG_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(pMgmt->abyDesireSSID, pSSID, WLAN_IEHDR_LEN + WLAN_SSID_MAXLEN + 1);
+ DBG_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_CHANGE_BBSENSITIVITY_START;
+ break;
+
+ case WLAN_CMD_TBTT_WAKEUP:
+ pDevice->eCommandState = WLAN_CMD_TBTT_WAKEUP_START;
+ break;
+
+ case WLAN_CMD_BECON_SEND:
+ pDevice->eCommandState = WLAN_CMD_BECON_SEND_START;
+ break;
+
+ case WLAN_CMD_SETPOWER:
+ pDevice->eCommandState = WLAN_CMD_SETPOWER_START;
+ break;
+
+ case WLAN_CMD_CHANGE_ANTENNA:
+ pDevice->eCommandState = WLAN_CMD_CHANGE_ANTENNA_START;
+ break;
+
+ case WLAN_CMD_REMOVE_ALLKEY:
+ pDevice->eCommandState = WLAN_CMD_REMOVE_ALLKEY_START;
+ break;
+
+ case WLAN_CMD_MAC_DISPOWERSAVING:
+ pDevice->eCommandState = WLAN_CMD_MAC_DISPOWERSAVING_START;
+ break;
+
+ case WLAN_CMD_11H_CHSW:
+ pDevice->eCommandState = WLAN_CMD_11H_CHSW_START;
+ 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:
+ pDevice->eCmdQueue[pDevice->uCmdEnqueueIdx].bForceSCAN = FALSE;
+ MEMvCopy(pDevice->eCmdQueue[pDevice->uCmdEnqueueIdx].abyCmdDesireSSID,
+ pbyItem0, WLAN_IEHDR_LEN + WLAN_SSID_MAXLEN + 1);
+ 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_RADIO:
+ pDevice->eCmdQueue[pDevice->uCmdEnqueueIdx].bRadioCmd = *((PBOOL)pbyItem0);
+ 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
+ *
+ */
+static
+BOOL s_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)vRunCommand;
+ 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;
+}
+
+//2007-0115-08<Add>by MikeLiu
+#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);
+ //is wap_supplicant running sucessful OR only open && sharekey mode!
+ #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/vt6656/wcmd.h b/drivers/staging/vt6656/wcmd.h
new file mode 100644
index 000000000000..45866270a190
--- /dev/null
+++ b/drivers/staging/vt6656/wcmd.h
@@ -0,0 +1,156 @@
+/*
+ * 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
+
+typedef enum tagCMD_STATUS {
+
+ CMD_STATUS_SUCCESS = 0,
+ 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;
+ BOOL bRadioCmd;
+ BOOL bForceSCAN;
+ WORD wDeAuthenReason;
+} 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_DEAUTHEN_START,
+ WLAN_CMD_SSID_START,
+ WLAN_AUTHENTICATE_WAIT,
+ WLAN_ASSOCIATE_WAIT,
+ WLAN_DISASSOCIATE_WAIT,
+ WLAN_CMD_TX_PSPACKET_START,
+ WLAN_CMD_RADIO_START,
+ WLAN_CMD_CHANGE_BBSENSITIVITY_START,
+ WLAN_CMD_SETPOWER_START,
+ WLAN_CMD_AP_MODE_START,
+ WLAN_CMD_TBTT_WAKEUP_START,
+ WLAN_CMD_BECON_SEND_START,
+ WLAN_CMD_CHANGE_ANTENNA_START,
+ WLAN_CMD_REMOVE_ALLKEY_START,
+ WLAN_CMD_MAC_DISPOWERSAVING_START,
+ WLAN_CMD_11H_CHSW_START,
+ WLAN_CMD_IDLE
+} CMD_STATE, DEF* PCMD_STATE;
+
+
+
+/*--------------------- Export Classes ----------------------------*/
+
+/*--------------------- Export Variables --------------------------*/
+
+
+/*--------------------- Export Types ------------------------------*/
+
+
+/*--------------------- Export Functions --------------------------*/
+VOID
+vResetCommandTimer(
+ IN HANDLE hDeviceContext
+ );
+
+BOOL
+bScheduleCommand(
+ IN HANDLE hDeviceContext,
+ IN CMD_CODE eCommand,
+ IN PBYTE pbyItem0
+ );
+
+VOID
+vRunCommand(
+ IN HANDLE hDeviceContext
+ );
+/*
+VOID
+WCMDvCommandThread(
+ PVOID Context
+ );
+*/
+
+//2007-0115-09<Add>by MikeLiu
+#ifdef TxInSleep
+VOID
+BSSvSecondTxData(
+ IN HANDLE hDeviceContext
+ );
+#endif
+
+#endif //__WCMD_H__
diff --git a/drivers/staging/vt6656/wctl.c b/drivers/staging/vt6656/wctl.c
new file mode 100644
index 000000000000..a318f00441f5
--- /dev/null
+++ b/drivers/staging/vt6656/wctl.c
@@ -0,0 +1,263 @@
+/*
+ * 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
+#if !defined(__TMACRO_H__)
+#include "tmacro.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]))) &&
+ (LOBYTE(pCacheEntry->wFrameCtl) == LOBYTE(pMACHeader->wFrameCtl))
+ ) {
+ /* 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);
+ pCacheEntry->wFrameCtl = pMACHeader->wFrameCtl;
+ 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 8 byte to match MAC RX Buffer
+ pDevice->sRxDFCB[pDevice->uCurrentDFCBIdx].pbyRxBuffer = (PBYTE) (pDevice->sRxDFCB[pDevice->uCurrentDFCBIdx].skb->data + 8);
+// pDevice->sRxDFCB[pDevice->uCurrentDFCBIdx].pbyRxBuffer = (PBYTE) (pDevice->sRxDFCB[pDevice->uCurrentDFCBIdx].skb->data + 4);
+ 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++;
+ //DBG_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++;
+ //DBG_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;
+ //DBG_PRT(MSG_LEVEL_DEBUG, KERN_INFO "Last pDevice->uCurrentDFCBIdx= %d\n", pDevice->uCurrentDFCBIdx);
+ return(TRUE);
+ }
+ return(FALSE);
+ }
+}
+
+
diff --git a/drivers/staging/vt6656/wctl.h b/drivers/staging/vt6656/wctl.h
new file mode 100644
index 000000000000..f75ca59f6c61
--- /dev/null
+++ b/drivers/staging/vt6656/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/vt6656/wmgr.c b/drivers/staging/vt6656/wmgr.c
new file mode 100644
index 000000000000..5879e484b971
--- /dev/null
+++ b/drivers/staging/vt6656/wmgr.c
@@ -0,0 +1,4993 @@
+/*
+ * 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
+#if !defined(__CONTROL_H__)
+#include "control.h"
+#endif
+#if !defined(__RNDIS_H__)
+#include "rndis.h"
+#endif
+/*--------------------- Static Definitions -------------------------*/
+
+
+
+/*--------------------- Static Classes ----------------------------*/
+
+/*--------------------- Static Variables --------------------------*/
+static int msglevel =MSG_LEVEL_INFO;
+//static int msglevel =MSG_LEVEL_DEBUG;
+
+/*--------------------- Static Functions --------------------------*/
+//2008-0730-01<Add>by MikeLiu
+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
+ );
+
+
+
+/*--------------------- 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->sMgmtObj);
+ 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);
+
+ 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)vRunCommand;
+ pDevice->sTimerCommand.expires = RUN_AT(HZ);
+
+//2007-0115-10<Add>by MikeLiu
+ #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;
+ pDevice->eCommandState = WLAN_CMD_IDLE;
+ pDevice->bCmdRunning = FALSE;
+ pDevice->bCmdClear = FALSE;
+
+ 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 (pDevice->bShortSlotTime == TRUE)
+ pMgmt->wCurrCapInfo |= WLAN_SET_CAP_INFO_SHORTSLOTTIME(1);
+
+ } else if (pMgmt->eCurrentPHYMode == PHY_TYPE_11B) {
+ if (pDevice->byPreambleType == 1) {
+ 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 (pDevice->bShortSlotTime == TRUE)
+ pMgmt->wCurrCapInfo |= WLAN_SET_CAP_INFO_SHORTSLOTTIME(1);
+
+ } else if (pMgmt->eCurrentPHYMode == PHY_TYPE_11B) {
+ if (pDevice->byPreambleType == 1) {
+ 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) {
+ DBG_PRT(MSG_LEVEL_DEBUG, KERN_INFO "Mgt:Reassociation tx failed.\n");
+ }
+ else {
+ DBG_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->byBBType == BB_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->byBBType == BB_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;
+ // 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;
+ }
+
+ DBG_PRT(MSG_LEVEL_INFO, KERN_INFO "Associate AID= %d \n", wAssocAID);
+ DBG_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]
+ ) ;
+ DBG_PRT(MSG_LEVEL_INFO, KERN_INFO "Max Support rate = %d \n",
+ pMgmt->sNodeDBTable[uNodeIndex].wMaxSuppRate);
+ }
+
+
+ // 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) {
+ DBG_PRT(MSG_LEVEL_DEBUG, KERN_INFO "Mgt:Assoc response tx failed\n");
+ }
+ else {
+ DBG_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->byBBType == BB_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->byBBType == BB_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;
+ // 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;
+ }
+
+ DBG_PRT(MSG_LEVEL_INFO, KERN_INFO "Rx ReAssociate AID= %d \n", wAssocAID);
+ DBG_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]
+ ) ;
+ DBG_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) {
+ DBG_PRT(MSG_LEVEL_DEBUG, KERN_INFO "Mgt:ReAssoc response tx failed\n");
+ }
+ else {
+ DBG_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) )
+ {
+ DBG_PRT(MSG_LEVEL_DEBUG, KERN_INFO "AID from AP, has two msb clear.\n");
+ };
+ DBG_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;
+ DBG_PRT(MSG_LEVEL_INFO, KERN_INFO "Link with AP(SSID): %s\n", pItemSSID->abySSID);
+ pDevice->bLinkPass = TRUE;
+ ControlvMaskByte(pDevice,MESSAGE_REQUEST_MACREG,MAC_REG_PAPEDELAY,LEDSTS_STS,LEDSTS_INTER);
+ 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;
+ pDevice->skb->mac_header = pDevice->skb->data;
+ 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->bWPASuppWextEnabled == 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;
+ PRINT_K("wireless_send_event--->IWEVASSOCREQIE\n");
+ 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;
+ PRINT_K("wireless_send_event--->IWEVASSOCRESPIE\n");
+ 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;
+ PRINT_K("wireless_send_event--->SIOCGIWAP(associated)\n");
+ 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))));
+ }
+
+ }
+
+#if 1
+#ifdef WPA_SUPPLICANT_DRIVER_WEXT_SUPPORT
+//need clear flags related to Networkmanager
+ pDevice->bwextstep0 = FALSE;
+ pDevice->bwextstep1 = FALSE;
+ pDevice->bwextstep2 = FALSE;
+ pDevice->bwextstep3 = FALSE;
+ pDevice->bWPASuppWextEnabled = FALSE;
+#endif
+#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:
+ DBG_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 (!BSSbIsSTAInNodeDB(pDevice, 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;
+ }
+ DBG_PRT(MSG_LEVEL_DEBUG, KERN_INFO "Mgt:Authreq_reply sequence_1 tx.. \n");
+ if (csMgmt_xmit(pDevice, pTxPacket) != CMD_STATUS_PENDING) {
+ DBG_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 ){
+ DBG_PRT(MSG_LEVEL_INFO, KERN_INFO "802.11 Authen (OPEN) Successful.\n");
+ pMgmt->eCurrState = WMAC_STATE_AUTH;
+ timer_expire(pDevice->sTimerCommand, 0);
+ }
+ else {
+ DBG_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) {
+ DBG_PRT(MSG_LEVEL_DEBUG, KERN_INFO "Mgt:Auth_reply sequence_2 tx failed.\n");
+ }
+ DBG_PRT(MSG_LEVEL_DEBUG, KERN_INFO "Mgt:Auth_reply sequence_2 tx ...\n");
+ }
+ else {
+ DBG_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:
+ DBG_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 (BSSbIsSTAInNodeDB(pDevice, 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;
+ DBG_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) {
+ DBG_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 ){
+ DBG_PRT(MSG_LEVEL_INFO, KERN_INFO "802.11 Authen (SHAREDKEY) Successful.\n");
+ pMgmt->eCurrState = WMAC_STATE_AUTH;
+ timer_expire(pDevice->sTimerCommand, 0);
+ }
+ else{
+ DBG_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 (BSSbIsSTAInNodeDB(pDevice, pRxPacket->p80211Header->sA3.abyAddr2, &uNodeIndex)) {
+ BSSvRemoveOneNode(pDevice, uNodeIndex);
+ }
+ else {
+ DBG_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);
+ DBG_PRT(MSG_LEVEL_NOTICE, KERN_INFO "AP disassociated me, reason=%d.\n", cpu_to_le16(*(sFrame.pwReason)));
+
+ pDevice->fWPA_Authened = 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;
+ pDevice->skb->mac_header = pDevice->skb->data;
+ 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);
+ };
+
+ //TODO: do something let upper layer know or
+ //try to send associate packet again because of inactivity timeout
+ if (pMgmt->eCurrState == WMAC_STATE_ASSOC) {
+ pDevice->bLinkPass = FALSE;
+ pMgmt->sNodeDBTable[0].bActive = FALSE;
+ pDevice->byReAssocCount = 0;
+ pMgmt->eCurrState = WMAC_STATE_AUTH; // jump back to the auth state!
+ pDevice->eCommandState = WLAN_ASSOCIATE_WAIT;
+ vMgrReAssocBeginSta((PSDevice)pDevice, pMgmt, &CmdStatus);
+ if(CmdStatus == CMD_STATUS_PENDING) {
+ pDevice->byReAssocCount ++;
+ return; //mike add: you'll retry for many times, so it cann't be regarded as disconnected!
+ }
+ };
+
+ #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;
+ PRINT_K("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 (BSSbIsSTAInNodeDB(pDevice, pRxPacket->p80211Header->sA3.abyAddr2, &uNodeIndex)) {
+ BSSvRemoveOneNode(pDevice, uNodeIndex);
+ }
+ else {
+ DBG_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);
+ pDevice->fWPA_Authened = FALSE;
+ DBG_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;
+ ControlvMaskByte(pDevice,MESSAGE_REQUEST_MACREG,MAC_REG_PAPEDELAY,LEDSTS_STS,LEDSTS_SLOW);
+ }
+ };
+
+ 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;
+ pDevice->skb->mac_header = pDevice->skb->data;
+ 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;
+ PRINT_K("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-0730-01<Add>by MikeLiu
+/*+
+ *
+ * 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;
+ BYTE byOldPreambleType;
+
+
+
+ if (pMgmt->eCurrMode == WMAC_MODE_ESS_AP)
+ return;
+
+ 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) ) {
+ DBG_PRT(MSG_LEVEL_DEBUG, KERN_INFO "Rx beacon frame error\n");
+ return;
+ };
+
+
+ if( byCurrChannel > CB_MAX_CHANNEL_24G )
+ {
+ if (sFrame.pDSParms != NULL) {
+ if (byCurrChannel == RFaby11aChannelIndex[sFrame.pDSParms->byCurrChannel-1])
+ bChannelHit = TRUE;
+ byCurrChannel = RFaby11aChannelIndex[sFrame.pDSParms->byCurrChannel-1];
+ } else {
+ bChannelHit = TRUE;
+ }
+
+ } else {
+ if (sFrame.pDSParms != NULL) {
+ if (byCurrChannel == sFrame.pDSParms->byCurrChannel)
+ bChannelHit = TRUE;
+ byCurrChannel = sFrame.pDSParms->byCurrChannel;
+ } else {
+ 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) {
+ DBG_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 {
+// DBG_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);
+ }
+ }
+
+ // check if BSSID the same
+ if (memcmp(sFrame.pHdr->sA3.abyAddr3,
+ pMgmt->abyCurrBSSID,
+ WLAN_BSSID_LEN) == 0) {
+
+ bIsBSSIDEqual = TRUE;
+ pDevice->uCurrRSSI = pRxPacket->uRSSI;
+ pDevice->byCurrSQ = pRxPacket->bySQ;
+ if (pMgmt->sNodeDBTable[0].uInActiveCount != 0) {
+ pMgmt->sNodeDBTable[0].uInActiveCount = 0;
+ //DBG_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) {
+
+ // Sync ERP field
+ if ((pBSSList->sERP.bERPExist == TRUE) && (pDevice->byBBType == BB_TYPE_11G)) {
+ if ((pBSSList->sERP.byERP & WLAN_EID_ERP_USE_PROTECTION) != pDevice->bProtectMode) {//0000 0010
+ pDevice->bProtectMode = (pBSSList->sERP.byERP & WLAN_EID_ERP_USE_PROTECTION);
+ if (pDevice->bProtectMode) {
+ MACvEnableProtectMD(pDevice);
+ } else {
+ MACvDisableProtectMD(pDevice);
+ }
+ vUpdateIFS(pDevice);
+ }
+ if ((pBSSList->sERP.byERP & WLAN_EID_ERP_NONERP_PRESENT) != pDevice->bNonERPPresent) {//0000 0001
+ pDevice->bNonERPPresent = (pBSSList->sERP.byERP & WLAN_EID_ERP_USE_PROTECTION);
+ }
+ if ((pBSSList->sERP.byERP & WLAN_EID_ERP_BARKER_MODE) != pDevice->bBarkerPreambleMd) {//0000 0100
+ pDevice->bBarkerPreambleMd = (pBSSList->sERP.byERP & WLAN_EID_ERP_BARKER_MODE);
+ //BarkerPreambleMd has higher priority than shortPreamble bit in Cap
+ if (pDevice->bBarkerPreambleMd) {
+ MACvEnableBarkerPreambleMd(pDevice);
+ } else {
+ MACvDisableBarkerPreambleMd(pDevice);
+ }
+ }
+ }
+ // Sync Short Slot Time
+ if (WLAN_GET_CAP_INFO_SHORTSLOTTIME(pBSSList->wCapInfo) != pDevice->bShortSlotTime) {
+ BOOL bShortSlotTime;
+
+ bShortSlotTime = WLAN_GET_CAP_INFO_SHORTSLOTTIME(pBSSList->wCapInfo);
+ //DBG_PRN_WLAN05(("Set Short Slot Time: %d\n", pDevice->bShortSlotTime));
+ //Kyle check if it is OK to set G.
+ if (pDevice->byBBType == BB_TYPE_11A) {
+ bShortSlotTime = TRUE;
+ }
+ else if (pDevice->byBBType == BB_TYPE_11B) {
+ bShortSlotTime = FALSE;
+ }
+ if (bShortSlotTime != pDevice->bShortSlotTime) {
+ pDevice->bShortSlotTime = bShortSlotTime;
+ BBvSetShortSlotTime(pDevice);
+ vUpdateIFS(pDevice);
+ }
+ }
+
+ //
+ // Preamble may change dynamiclly
+ //
+ byOldPreambleType = pDevice->byPreambleType;
+ if (WLAN_GET_CAP_INFO_SHORTPREAMBLE(pBSSList->wCapInfo)) {
+ pDevice->byPreambleType = pDevice->byShortPreamble;
+ }
+ else {
+ pDevice->byPreambleType = 0;
+ }
+ if (pDevice->byPreambleType != byOldPreambleType)
+ CARDvSetRSPINF(pDevice, (BYTE)pDevice->byBBType);
+ //
+ // 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)
+ );
+
+ }
+ }
+
+// DBG_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
+// DBG_PRT(MSG_LEVEL_DEBUG, KERN_INFO "BCN:In TIM\n");
+ if (pMgmt->bInTIM) {
+ PSvSendPSPOLL((PSDevice)pDevice);
+// DBG_PRT(MSG_LEVEL_DEBUG, KERN_INFO "BCN:PS-POLL sent..\n");
+ };
+
+ }
+ else {
+ pMgmt->bInTIMWake = FALSE;
+ DBG_PRT(MSG_LEVEL_DEBUG, KERN_INFO "BCN: Not In TIM..\n");
+ if (pDevice->bPWBitOn == FALSE) {
+ DBG_PRT(MSG_LEVEL_DEBUG, KERN_INFO "BCN: Send Null Packet\n");
+ if (PSbSendNullPacket(pDevice))
+ pDevice->bPWBitOn = TRUE;
+ }
+ if(PSbConsiderPowerDown(pDevice, FALSE, FALSE)) {
+ DBG_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 (BSSbIsSTAInNodeDB(pDevice, 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;
+/*
+ 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) {
+ DBG_PRT(MSG_LEVEL_DEBUG, KERN_INFO "Current IBSS State: [Started]........to: [Jointed] \n");
+ pMgmt->eCurrState = WMAC_STATE_JOINTED;
+ pDevice->bLinkPass = TRUE;
+ ControlvMaskByte(pDevice,MESSAGE_REQUEST_MACREG,MAC_REG_PAPEDELAY,LEDSTS_STS,LEDSTS_INTER);
+ 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....
+ DBG_PRT(MSG_LEVEL_DEBUG, KERN_INFO "Rejoining to Other Adhoc group with same SSID........\n");
+
+ MACvWriteBeaconInterval(pDevice, pMgmt->wCurrBeaconPeriod);
+ CARDvAdjustTSF(pDevice, pRxPacket->byRxRate, qwTimestamp, pRxPacket->qwLocalTSF);
+ CARDvUpdateNextTBTT(pDevice, qwTimestamp, pMgmt->wCurrBeaconPeriod);
+
+ // Turn off bssid filter to avoid filter others adhoc station which bssid is different.
+ MACvWriteBSSIDAddress(pDevice, pMgmt->abyCurrBSSID);
+
+ byOldPreambleType = pDevice->byPreambleType;
+ if (WLAN_GET_CAP_INFO_SHORTPREAMBLE(*sFrame.pwCapInfo)) {
+ pDevice->byPreambleType = pDevice->byShortPreamble;
+ }
+ else {
+ pDevice->byPreambleType = 0;
+ }
+ if (pDevice->byPreambleType != byOldPreambleType)
+ CARDvSetRSPINF(pDevice, (BYTE)pDevice->byBBType);
+
+
+ // 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, &qwCurrTSF);
+ CARDvAdjustTSF(pDevice, pRxPacket->byRxRate, qwTimestamp , pRxPacket->qwLocalTSF);
+ CARDbGetCurrentTSF(pDevice, &qwCurrTSF);
+ CARDvUpdateNextTBTT(pDevice, 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->sMgmtObj);
+ 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;
+
+
+
+ HIDWORD(qwCurrTSF) = 0;
+ LODWORD(qwCurrTSF) = 0;
+
+ DBG_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);
+
+ pDevice->bBarkerPreambleMd = 0;
+ MACvDisableBarkerPreambleMd(pDevice);
+
+ // Kyle Test 2003.11.04
+
+ // set HW beacon interval
+ if (pMgmt->wIBSSBeaconPeriod == 0)
+ pMgmt->wIBSSBeaconPeriod = DEFAULT_IBSS_BI;
+ MACvWriteBeaconInterval(pDevice, pMgmt->wIBSSBeaconPeriod);
+
+ CARDbGetCurrentTSF(pDevice, &qwCurrTSF);
+ // clear TSF counter
+ CARDbClearCurrentTSF(pDevice);
+
+ // enable TSF counter
+ MACvRegBitsOn(pDevice,MAC_REG_TFTCTL,TFTCTL_TSFCNTREN);
+ // set Next TBTT
+ CARDvSetFirstNextTBTT(pDevice, pMgmt->wIBSSBeaconPeriod);
+
+ pMgmt->uIBSSChannel = pDevice->uChannel;
+
+ if (pMgmt->uIBSSChannel == 0)
+ pMgmt->uIBSSChannel = DEFAULT_IBSS_CHANNEL;
+
+ // set channel and clear NAV
+ CARDbSetMediaChannel(pDevice, pMgmt->uIBSSChannel);
+ pMgmt->uCurrChannel = pMgmt->uIBSSChannel;
+
+ pDevice->byPreambleType = pDevice->byShortPreamble;
+
+ // 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 (pDevice->byBBType == BB_TYPE_11A) {
+ pDevice->bShortSlotTime = TRUE;
+ } else {
+ pDevice->bShortSlotTime = FALSE;
+ }
+ BBvSetShortSlotTime(pDevice);
+ // vUpdateIFS() use pDevice->bShortSlotTime as parameter so it must be called
+ // after setting ShortSlotTime.
+ // CARDvSetBSSMode call vUpdateIFS()
+ CARDvSetBSSMode(pDevice);
+
+ if (pMgmt->eConfigMode == WMAC_CONFIG_AP) {
+ MACvRegBitsOn(pDevice, MAC_REG_HOSTCR, HOSTCR_AP);
+ pMgmt->eCurrMode = WMAC_MODE_ESS_AP;
+ }
+
+ if (pMgmt->eConfigMode == WMAC_CONFIG_IBSS_STA) {
+ MACvRegBitsOn(pDevice, MAC_REG_HOSTCR, HOSTCR_ADHOC);
+ 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;
+ pDevice->uCurrRSSI = 0;
+ pDevice->byCurrSQ = 0;
+
+//20080131-04,<Add> by Mike Liu
+#ifdef Adhoc_STA
+ memcpy(pMgmt->abyDesireSSID,pMgmt->abyAdHocSSID,
+ ((PWLAN_IE_SSID)pMgmt->abyAdHocSSID)->len + WLAN_IEHDR_LEN);
+#endif
+
+ 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);
+ DBG_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;
+
+
+ DBG_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 BSSID filter
+ MACvWriteBSSIDAddress(pDevice, pMgmt->abyCurrBSSID);
+ memcpy(pDevice->abyBSSID, pMgmt->abyCurrBSSID, WLAN_ADDR_LEN);
+
+ MACvRegBitsOn(pDevice, MAC_REG_RCR, RCR_BSSID);
+ pDevice->byRxMode |= RCR_BSSID;
+ pMgmt->bCurrBSSIDFilterOn = TRUE;
+
+ // 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;
+ pDevice->eOPMode = OP_MODE_AP;
+ }
+
+ if (pMgmt->eCurrMode == WMAC_MODE_IBSS_STA) {
+ pMgmt->wCurrCapInfo |= WLAN_SET_CAP_INFO_IBSS(1);
+ pDevice->eOPMode = OP_MODE_ADHOC;
+ }
+
+ 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;
+
+ if (pDevice->byPreambleType == 1) {
+ pMgmt->wCurrCapInfo |= WLAN_SET_CAP_INFO_SHORTPREAMBLE(1);
+ } else {
+ pMgmt->wCurrCapInfo &= (~WLAN_SET_CAP_INFO_SHORTPREAMBLE(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->sMgmtObj);
+ 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;
+ BOOL bShortSlotTime = FALSE;
+
+
+ for (ii = 0; ii < MAX_BSS_NUM; ii++) {
+ if (pMgmt->sBSSList[ii].bActive == TRUE)
+ break;
+ }
+
+ if (ii == MAX_BSS_NUM) {
+ *pStatus = CMD_STATUS_RESOURCES;
+ DBG_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,
+ pDevice->eConfigPHYMode
+ );
+
+ if (pCurr == NULL){
+ *pStatus = CMD_STATUS_RESOURCES;
+ pItemSSID = (PWLAN_IE_SSID)pMgmt->abyDesireSSID;
+ DBG_PRT(MSG_LEVEL_NOTICE, KERN_INFO "Scanning [%s] not found, disconnected !\n", pItemSSID->abySSID);
+ return;
+ };
+
+ DBG_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)) {
+/*
+ if (pDevice->eEncryptionStatus == Ndis802_11Encryption2Enabled) {
+ if (WPA_SearchRSN(0, WPA_TKIP, pCurr) == FALSE) {
+ DBG_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) {
+ DBG_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);
+ vUpdateIFS(pDevice);
+ // 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->eOPMode = 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);
+ DBG_PRT(MSG_LEVEL_DEBUG, KERN_INFO"bAdd_PMKID_Candidate: 1(%d)\n", bResult);
+ if (bResult == FALSE) {
+ vFlush_PMKID_Candidate((HANDLE)pDevice);
+ DBG_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.
+ if (WLAN_GET_CAP_INFO_SHORTPREAMBLE(pCurr->wCapInfo)) {
+ pDevice->byPreambleType = pDevice->byShortPreamble;
+ }
+ else {
+ pDevice->byPreambleType = 0;
+ }
+ // Change PreambleType must set RSPINF again
+ CARDvSetRSPINF(pDevice, (BYTE)pDevice->byBBType);
+
+ DBG_PRT(MSG_LEVEL_DEBUG, KERN_INFO"Join ESS\n");
+
+ if (pCurr->eNetworkTypeInUse == PHY_TYPE_11G) {
+
+ if ((pCurr->sERP.byERP & WLAN_EID_ERP_USE_PROTECTION) != pDevice->bProtectMode) {//0000 0010
+ pDevice->bProtectMode = (pCurr->sERP.byERP & WLAN_EID_ERP_USE_PROTECTION);
+ if (pDevice->bProtectMode) {
+ MACvEnableProtectMD(pDevice);
+ } else {
+ MACvDisableProtectMD(pDevice);
+ }
+ vUpdateIFS(pDevice);
+ }
+ if ((pCurr->sERP.byERP & WLAN_EID_ERP_NONERP_PRESENT) != pDevice->bNonERPPresent) {//0000 0001
+ pDevice->bNonERPPresent = (pCurr->sERP.byERP & WLAN_EID_ERP_USE_PROTECTION);
+ }
+ if ((pCurr->sERP.byERP & WLAN_EID_ERP_BARKER_MODE) != pDevice->bBarkerPreambleMd) {//0000 0100
+ pDevice->bBarkerPreambleMd = (pCurr->sERP.byERP & WLAN_EID_ERP_BARKER_MODE);
+ //BarkerPreambleMd has higher priority than shortPreamble bit in Cap
+ if (pDevice->bBarkerPreambleMd) {
+ MACvEnableBarkerPreambleMd(pDevice);
+ } else {
+ MACvDisableBarkerPreambleMd(pDevice);
+ }
+ }
+ }
+ //DBG_PRN_WLAN05(("wCapInfo: %X\n", pCurr->wCapInfo));
+ if (WLAN_GET_CAP_INFO_SHORTSLOTTIME(pCurr->wCapInfo) != pDevice->bShortSlotTime) {
+ if (pDevice->byBBType == BB_TYPE_11A) {
+ bShortSlotTime = TRUE;
+ }
+ else if (pDevice->byBBType == BB_TYPE_11B) {
+ bShortSlotTime = FALSE;
+ }
+ else {
+ bShortSlotTime = WLAN_GET_CAP_INFO_SHORTSLOTTIME(pCurr->wCapInfo);
+ }
+ //DBG_PRN_WLAN05(("Set Short Slot Time: %d\n", pDevice->bShortSlotTime));
+ if (bShortSlotTime != pDevice->bShortSlotTime) {
+ pDevice->bShortSlotTime = bShortSlotTime;
+ BBvSetShortSlotTime(pDevice);
+ vUpdateIFS(pDevice);
+ }
+ }
+
+ DBG_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);
+ vUpdateIFS(pDevice);
+ 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;
+ pMgmt->eCurrMode = WMAC_MODE_IBSS_STA;
+ pMgmt->eCurrState = WMAC_STATE_STARTED;
+ // Adopt BSS state in Adapter Device Object
+ pDevice->eOPMode = OP_MODE_ADHOC;
+ pDevice->bLinkPass = TRUE;
+ ControlvMaskByte(pDevice,MESSAGE_REQUEST_MACREG,MAC_REG_PAPEDELAY,LEDSTS_STS,LEDSTS_INTER);
+ memcpy(pDevice->abyBSSID, pCurr->abyBSSID, WLAN_BSSID_LEN);
+
+ DBG_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.
+
+ if (WLAN_GET_CAP_INFO_SHORTPREAMBLE(pCurr->wCapInfo)) {
+ pDevice->byPreambleType = pDevice->byShortPreamble;
+ }
+ else {
+ pDevice->byPreambleType = 0;
+ }
+ // Change PreambleType must set RSPINF again
+ CARDvSetRSPINF(pDevice, (BYTE)pDevice->byBBType);
+
+ // 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
+ )
+{
+ PSMgmtObject pMgmt = &(pDevice->sMgmtObj);
+ //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) {
+ DBG_PRT(MSG_LEVEL_NOTICE, KERN_INFO "s_bCipherMatch Fail .......\n");
+ return;
+ }
+
+ pMgmt->pCurrBSS = pCurr;
+
+ // if previous mode is IBSS.
+ if(pMgmt->eCurrMode == WMAC_MODE_IBSS_STA) {
+ MACvRegBitsOff(pDevice, MAC_REG_TCR, TCR_AUTOBCNTX);
+ }
+
+ // Init the BSS informations
+ pDevice->bCCK = TRUE;
+ pDevice->bProtectMode = FALSE;
+ MACvDisableProtectMD(pDevice);
+ pDevice->bBarkerPreambleMd = FALSE;
+ MACvDisableBarkerPreambleMd(pDevice);
+ 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
+ CARDvAdjustTSF(pDevice, pCurr->byRxRate, pCurr->qwBSSTimestamp, pCurr->qwLocalTSF);
+
+ // set HW beacon interval
+ MACvWriteBeaconInterval(pDevice, pCurr->wBeaconInterval);
+
+ // set Next TBTT
+ // Next TBTT = ((local_current_TSF / beacon_interval) + 1 ) * beacon_interval
+ CARDvSetFirstNextTBTT(pDevice, pCurr->wBeaconInterval);
+
+ // set BSSID
+ MACvWriteBSSIDAddress(pDevice, pCurr->abyBSSID);
+
+ MEMvCopy(pMgmt->abyCurrBSSID, pCurr->abyBSSID, 6);
+
+ DBG_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 ((pDevice->eConfigPHYMode == PHY_TYPE_11A) ||
+ (pDevice->eConfigPHYMode == PHY_TYPE_AUTO)) {
+ pDevice->byBBType = BB_TYPE_11A;
+ pMgmt->eCurrentPHYMode = PHY_TYPE_11A;
+ pDevice->bShortSlotTime = TRUE;
+ BBvSetShortSlotTime(pDevice);
+ CARDvSetBSSMode(pDevice);
+ } else {
+ return;
+ }
+ } else if (pCurr->eNetworkTypeInUse == PHY_TYPE_11B) {
+ if ((pDevice->eConfigPHYMode == PHY_TYPE_11B) ||
+ (pDevice->eConfigPHYMode == PHY_TYPE_11G) ||
+ (pDevice->eConfigPHYMode == PHY_TYPE_AUTO)) {
+ pDevice->byBBType = BB_TYPE_11B;
+ pMgmt->eCurrentPHYMode = PHY_TYPE_11B;
+ pDevice->bShortSlotTime = FALSE;
+ BBvSetShortSlotTime(pDevice);
+ CARDvSetBSSMode(pDevice);
+ } else {
+ return;
+ }
+ } else {
+ if ((pDevice->eConfigPHYMode == PHY_TYPE_11G) ||
+ (pDevice->eConfigPHYMode == PHY_TYPE_AUTO)) {
+ pDevice->byBBType = BB_TYPE_11G;
+ pMgmt->eCurrentPHYMode = PHY_TYPE_11G;
+ pDevice->bShortSlotTime = TRUE;
+ BBvSetShortSlotTime(pDevice);
+ CARDvSetBSSMode(pDevice);
+ } else if (pDevice->eConfigPHYMode == PHY_TYPE_11B) {
+ pDevice->byBBType = BB_TYPE_11B;
+ pDevice->bShortSlotTime = FALSE;
+ BBvSetShortSlotTime(pDevice);
+ CARDvSetBSSMode(pDevice);
+ } else {
+ return;
+ }
+ }
+
+ if (uBSSMode == WMAC_MODE_ESS_STA) {
+ MACvRegBitsOff(pDevice, MAC_REG_HOSTCR, HOSTCR_ADHOC);
+ MACvRegBitsOn(pDevice, MAC_REG_RCR, RCR_BSSID);
+ pDevice->byRxMode |= RCR_BSSID;
+ pMgmt->bCurrBSSIDFilterOn = TRUE;
+ }
+
+ // set channel and clear NAV
+ CARDbSetMediaChannel(pDevice, pCurr->uChannel);
+ pMgmt->uCurrChannel = pCurr->uChannel;
+ DBG_PRT(MSG_LEVEL_DEBUG, KERN_INFO "<----s_bSynchBSS Set Channel [%d]\n", pCurr->uChannel);
+
+ if ((pDevice->bUpdateBBVGA) &&
+ (pDevice->byBBVGACurrent != pDevice->abyBBVGA[0])) {
+ pDevice->byBBVGACurrent = pDevice->abyBBVGA[0];
+ BBvSetVGAGainOffset(pDevice, pDevice->byBBVGACurrent);
+ BBvSetShortSlotTime(pDevice);
+ }
+ //
+ // Notes:
+ // 1. In Ad-hoc mode : check if received others beacon as jointed indication,
+ // otherwise we will start own IBSS.
+ // 2. In Infra mode : Supposed we already synchronized with AP right now.
+
+ if (uBSSMode == WMAC_MODE_IBSS_STA) {
+ MACvRegBitsOn(pDevice, MAC_REG_HOSTCR, HOSTCR_ADHOC);
+ MACvRegBitsOn(pDevice, MAC_REG_RCR, RCR_BSSID);
+ pDevice->byRxMode |= RCR_BSSID;
+ pMgmt->bCurrBSSIDFilterOn = TRUE;
+ };
+
+ if (pDevice->byBBType == BB_TYPE_11A) {
+ MEMvCopy(pMgmt->abyCurrSuppRates, &abyCurrSuppRatesA[0], sizeof(abyCurrSuppRatesA));
+ pMgmt->abyCurrExtSuppRates[1] = 0;
+ } else if (pDevice->byBBType == BB_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));
+ }
+ pMgmt->byERPContext = pCurr->sERP.byERP;
+
+ *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
+ PRINT_K("Encyption_Rebuild--->ssid reset config to [WPAPSK-TKIP]\n");
+ }
+ else if(pCurr->abyPKType[0] == WPA_AESCCMP) {
+ pDevice->eEncryptionStatus = Ndis802_11Encryption3Enabled; //AES
+ PRINT_K("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
+ PRINT_K("Encyption_Rebuild--->ssid reset config to [WPA2PSK-TKIP]\n");
+ }
+ else if(pCurr->abyCSSPK[0] == WLAN_11i_CSS_CCMP) {
+ pDevice->eEncryptionStatus = Ndis802_11Encryption3Enabled; //AES
+ PRINT_K("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 = (WORD)ii;
+ }
+ wEndIndex = (WORD)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};
+
+
+ // 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->byBBType != BB_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->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;
+
+
+
+ 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->byBBType != BB_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->byBBType == BB_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 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->byBBType == BB_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->byBBType == BB_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 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;
+ 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)) {
+ DBG_PRT(MSG_LEVEL_DEBUG, KERN_INFO "Probe resp:Fail addr:[%p] \n", pRxPacket->p80211Header);
+ DBG_PORT80(0xCC);
+ return;
+ };
+
+ if(sFrame.pSSID->len == 0)
+ DBG_PRT(MSG_LEVEL_DEBUG, KERN_INFO "Rx Probe resp: SSID len = 0 \n");
+
+
+ //{{ RobertYu:20050201, 11a byCurrChannel != sFrame.pDSParms->byCurrChannel mapping
+ if( byCurrChannel > CB_MAX_CHANNEL_24G )
+ {
+ if (sFrame.pDSParms != 0) {
+ if (byCurrChannel == RFaby11aChannelIndex[sFrame.pDSParms->byCurrChannel-1])
+ bChannelHit = TRUE;
+ byCurrChannel = RFaby11aChannelIndex[sFrame.pDSParms->byCurrChannel-1];
+ } else {
+ bChannelHit = TRUE;
+ }
+
+ } else {
+ if (sFrame.pDSParms != 0) {
+ if (byCurrChannel == sFrame.pDSParms->byCurrChannel)
+ bChannelHit = TRUE;
+ byCurrChannel = sFrame.pDSParms->byCurrChannel;
+ } else {
+ bChannelHit = TRUE;
+ }
+ }
+ //RobertYu:20050201
+
+//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 {
+ DBG_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);
+/*
+ DBG_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) {
+ DBG_PRT(MSG_LEVEL_DEBUG, KERN_INFO "Mgt:Probe response tx failed\n");
+ }
+ else {
+// DBG_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 (BSSbIsSTAInNodeDB(pDevice, 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
+ DBG_PRT(MSG_LEVEL_DEBUG, KERN_INFO "rx assocreq\n");
+ if ((pMgmt->eCurrMode == WMAC_MODE_ESS_AP) &&
+ (eNodeState < NODE_AUTH)) {
+ // send deauth notification
+ // reason = (6) class 2 received from nonauth sta
+ vMgrDeAuthenBeginSta(pDevice,
+ pMgmt,
+ pRxPacket->p80211Header->sA3.abyAddr2,
+ (6),
+ &Status
+ );
+ DBG_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
+ DBG_PRT(MSG_LEVEL_DEBUG, KERN_INFO "rx assocresp1\n");
+ s_vMgrRxAssocResponse(pDevice, pMgmt, pRxPacket, FALSE);
+ DBG_PRT(MSG_LEVEL_DEBUG, KERN_INFO "rx assocresp2\n");
+ break;
+
+ case WLAN_FSTYPE_REASSOCREQ:
+ // Frame Clase = 2
+ DBG_PRT(MSG_LEVEL_DEBUG, KERN_INFO "rx reassocreq\n");
+ // Todo: reassoc
+ if ((pMgmt->eCurrMode == WMAC_MODE_ESS_AP) &&
+ (eNodeState < NODE_AUTH)) {
+ // send deauth notification
+ // reason = (6) class 2 received from nonauth sta
+ vMgrDeAuthenBeginSta(pDevice,
+ pMgmt,
+ pRxPacket->p80211Header->sA3.abyAddr2,
+ (6),
+ &Status
+ );
+ DBG_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
+ DBG_PRT(MSG_LEVEL_DEBUG, KERN_INFO "rx reassocresp\n");
+ s_vMgrRxAssocResponse(pDevice, pMgmt, pRxPacket, TRUE);
+ break;
+
+ case WLAN_FSTYPE_PROBEREQ:
+ // Frame Clase = 0
+ //DBG_PRT(MSG_LEVEL_DEBUG, KERN_INFO "rx probereq\n");
+ s_vMgrRxProbeRequest(pDevice, pMgmt, pRxPacket);
+ break;
+
+ case WLAN_FSTYPE_PROBERESP:
+ // Frame Clase = 0
+ DBG_PRT(MSG_LEVEL_DEBUG, KERN_INFO "rx proberesp\n");
+
+ s_vMgrRxProbeResponse(pDevice, pMgmt, pRxPacket);
+ break;
+
+ case WLAN_FSTYPE_BEACON:
+ // Frame Clase = 0
+ //DBG_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
+ DBG_PRT(MSG_LEVEL_DEBUG, KERN_INFO "rx atim\n");
+ break;
+
+ case WLAN_FSTYPE_DISASSOC:
+ // Frame Clase = 2
+ DBG_PRT(MSG_LEVEL_DEBUG, KERN_INFO "rx disassoc\n");
+ if ((pMgmt->eCurrMode == WMAC_MODE_ESS_AP) &&
+ (eNodeState < NODE_AUTH)) {
+ // send deauth notification
+ // reason = (6) class 2 received from nonauth sta
+ vMgrDeAuthenBeginSta(pDevice,
+ pMgmt,
+ pRxPacket->p80211Header->sA3.abyAddr2,
+ (6),
+ &Status
+ );
+ DBG_PRT(MSG_LEVEL_DEBUG, KERN_INFO "wmgr: send vMgrDeAuthenBeginSta 3\n");
+ }
+ s_vMgrRxDisassociation(pDevice, pMgmt, pRxPacket);
+ break;
+
+ case WLAN_FSTYPE_AUTHEN:
+ // Frame Clase = 1
+ DBG_PRT(MSG_LEVEL_DEBUG, KERN_INFO "rx authen\n");
+ s_vMgrRxAuthentication(pDevice, pMgmt, pRxPacket);
+ break;
+
+ case WLAN_FSTYPE_DEAUTHEN:
+ // Frame Clase = 1
+ DBG_PRT(MSG_LEVEL_DEBUG, KERN_INFO "rx deauthen\n");
+ s_vMgrRxDeauthentication(pDevice, pMgmt, pRxPacket);
+ break;
+
+ default:
+ DBG_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);
+ MACvRegBitsOn(pDevice, MAC_REG_TCR, TCR_AUTOBCNTX);
+
+ 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:
+ DBG_PRT(MSG_LEVEL_NOTICE, KERN_INFO "Status code == Unspecified error.\n");
+ break;
+ case WLAN_MGMT_STATUS_CAPS_UNSUPPORTED:
+ DBG_PRT(MSG_LEVEL_NOTICE, KERN_INFO "Status code == Can't support all requested capabilities.\n");
+ break;
+ case WLAN_MGMT_STATUS_REASSOC_NO_ASSOC:
+ DBG_PRT(MSG_LEVEL_NOTICE, KERN_INFO "Status code == Reassoc denied, can't confirm original Association.\n");
+ break;
+ case WLAN_MGMT_STATUS_ASSOC_DENIED_UNSPEC:
+ DBG_PRT(MSG_LEVEL_NOTICE, KERN_INFO "Status code == Assoc denied, undefine in spec\n");
+ break;
+ case WLAN_MGMT_STATUS_UNSUPPORTED_AUTHALG:
+ DBG_PRT(MSG_LEVEL_NOTICE, KERN_INFO "Status code == Peer doesn't support authen algorithm.\n");
+ break;
+ case WLAN_MGMT_STATUS_RX_AUTH_NOSEQ:
+ DBG_PRT(MSG_LEVEL_NOTICE, KERN_INFO "Status code == Authen frame received out of sequence.\n");
+ break;
+ case WLAN_MGMT_STATUS_CHALLENGE_FAIL:
+ DBG_PRT(MSG_LEVEL_NOTICE, KERN_INFO "Status code == Authen rejected, challenge failure.\n");
+ break;
+ case WLAN_MGMT_STATUS_AUTH_TIMEOUT:
+ DBG_PRT(MSG_LEVEL_NOTICE, KERN_INFO "Status code == Authen rejected, timeout waiting for next frame.\n");
+ break;
+ case WLAN_MGMT_STATUS_ASSOC_DENIED_BUSY:
+ DBG_PRT(MSG_LEVEL_NOTICE, KERN_INFO "Status code == Assoc denied, AP too busy.\n");
+ break;
+ case WLAN_MGMT_STATUS_ASSOC_DENIED_RATES:
+ DBG_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:
+ DBG_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:
+ DBG_PRT(MSG_LEVEL_NOTICE, KERN_INFO "Status code == Assoc denied, we do not support PBCC.\n");
+ break;
+ case WLAN_MGMT_STATUS_ASSOC_DENIED_AGILITY:
+ DBG_PRT(MSG_LEVEL_NOTICE, KERN_INFO "Status code == Assoc denied, we do not support channel agility.\n");
+ break;
+ default:
+ DBG_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;
+
+ DBG_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++;
+ DBG_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) &&
+ //20080123-01,<Add> by Einsn Liu
+ ((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_11Encryption2Enabled) || (EncStatus == Ndis802_11Encryption3Enabled))) {
+ //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;
+ }
+ }
+ }
+
+ DBG_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)) {
+ 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/vt6656/wmgr.h b/drivers/staging/vt6656/wmgr.h
new file mode 100644
index 000000000000..fcf19e4ad62d
--- /dev/null
+++ b/drivers/staging/vt6656/wmgr.h
@@ -0,0 +1,519 @@
+/*
+ * 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(__WPA2_H__)
+#include "wpa2.h"
+#endif
+#if !defined(__CARD_H__)
+#include "card.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 20 //(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 ------------------------------*/
+//mike define: make timer to expire after desired times
+#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;
+
+
+ // Operation state variables
+ WMAC_CURRENT_MODE eCurrMode; // MAC current connection mode
+ WMAC_BSS_STATE eCurrState; // MAC current BSS state
+ #ifdef SndEvt_ToAPI
+ WMAC_BSS_STATE eLastState; // MAC last BSS state
+ #endif
+
+ PKnownBSS pCurrBSS;
+ BYTE byCSSGK;
+ BYTE byCSSPK;
+
+// BYTE abyNewSuppRates[WLAN_IEHDR_LEN + WLAN_RATES_MAXLEN];
+// BYTE abyNewExtSuppRates[WLAN_IEHDR_LEN + WLAN_RATES_MAXLEN];
+ BOOL bCurrBSSIDFilterOn;
+
+ // 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;
+ UINT uRSSITrigger;
+ 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];
+
+//restore BSS info for Ad-Hoc mode
+//20080131-05,<Add> by Mike Liu
+#ifdef Adhoc_STA
+ BYTE abyAdHocSSID[WLAN_IEHDR_LEN + WLAN_SSID_MAXLEN + 1];
+#endif
+
+ // Adhoc or AP configuration vars
+ 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;
+ 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];
+ //link list of same bss's //DavidWang
+ KnownBSS pSameBSS[6] ;
+ BOOL Cisco_cckm ;
+ BYTE Roam_dbm;
+
+ // 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
+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/vt6656/wpa.c b/drivers/staging/vt6656/wpa.c
new file mode 100644
index 000000000000..754b9989ec03
--- /dev/null
+++ b/drivers/staging/vt6656/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);
+
+ DBG_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)) {
+
+ DBG_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;
+
+ DBG_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;
+ DBG_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;
+ DBG_PRT(MSG_LEVEL_DEBUG, KERN_INFO"wPKCount: %d\n", pBSSList->wPKCount);
+ }
+
+ m = pRSN->wPKCount;
+ DBG_PRT(MSG_LEVEL_DEBUG, KERN_INFO"m: %d\n", m);
+ DBG_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;
+ DBG_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;
+ DBG_PRT(MSG_LEVEL_DEBUG, KERN_INFO"wAuthCount: %d\n", pBSSList->wAuthCount);
+ }
+
+ if (pIE_RSN_Auth != NULL) {
+
+ n = pIE_RSN_Auth->wAuthCount;
+
+ DBG_PRT(MSG_LEVEL_DEBUG, KERN_INFO"n: %d\n", n);
+ DBG_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/vt6656/wpa.h b/drivers/staging/vt6656/wpa.h
new file mode 100644
index 000000000000..8000a37c6fc3
--- /dev/null
+++ b/drivers/staging/vt6656/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/vt6656/wpa2.c b/drivers/staging/vt6656/wpa2.c
new file mode 100644
index 000000000000..82c972dbfbfe
--- /dev/null
+++ b/drivers/staging/vt6656/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;
+
+ DBG_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)) {
+
+ DBG_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;
+
+ DBG_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;
+ DBG_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;
+ DBG_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;
+ DBG_PRT(MSG_LEVEL_DEBUG, KERN_INFO"abyAKMSSAuthType[%d]: %X\n", j-1, pBSSNode->abyAKMSSAuthType[j-1]);
+ } else
+ break;
+ }
+ pBSSNode->wAKMSSAuthCount = (WORD)j;
+ DBG_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/vt6656/wpa2.h b/drivers/staging/vt6656/wpa2.h
new file mode 100644
index 000000000000..cd1ea14b586e
--- /dev/null
+++ b/drivers/staging/vt6656/wpa2.h
@@ -0,0 +1,99 @@
+/*
+ * 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
+
+
+
+
+/*--------------------- Export Definitions -------------------------*/
+#define MAX_PMKID_CACHE 16
+
+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/vt6656/wpactl.c b/drivers/staging/vt6656/wpactl.c
new file mode 100644
index 000000000000..37c2900d6d1a
--- /dev/null
+++ b/drivers/staging/vt6656/wpactl.c
@@ -0,0 +1,1030 @@
+/*
+ * 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: July 28, 2006
+ *
+ * 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
+#if !defined(__CONTROL_H__)
+#include "control.h"
+#endif
+#if !defined(__RNDIS_H__)
+#include "rndis.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)
+{
+ PSDevice wpadev_priv;
+ struct net_device *dev = pDevice->dev;
+ int ret=0;
+
+ pDevice->wpadev = alloc_netdev(sizeof(PSDevice), "vntwpa", wpadev_setup);
+ if (pDevice->wpadev == NULL)
+ return -ENOMEM;
+
+ wpadev_priv = netdev_priv(pDevice->wpadev);
+ *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) {
+ DBG_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;
+ }
+
+ DBG_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) {
+ DBG_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->sMgmtObj);
+ 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;
+
+ DBG_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;
+ for (uu=0; uu<MAX_KEY_TABLE; uu++) {
+ MACvDisableKeyEntry(pDevice, 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 {
+ 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,
+ &(pDevice->sKey),
+ dwKeyIndex & ~(BIT30 | USE_KEYRSC),
+ param->u.wpa_key.key_len,
+ NULL,
+ abyKey,
+ KEY_CTL_WEP
+ );
+
+ }
+ 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 {
+ 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) {
+ DBG_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"));
+ DBG_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_PRT(MSG_LEVEL_DEBUG, KERN_INFO "return - AES Key must be 128 bits\n");
+ return -EINVAL;
+ }
+
+
+ if (IS_BROADCAST_ADDRESS(&param->addr[0]) || (param->addr == NULL)) {
+ // If IS_BROADCAST_ADDRESS, set the key as every key entry's group key.
+ DBG_PRT(MSG_LEVEL_DEBUG, KERN_INFO "Groupe Key Assign.\n");
+
+ if ((KeybSetAllGroupKey(pDevice,
+ &(pDevice->sKey),
+ dwKeyIndex,
+ param->u.wpa_key.key_len,
+ (PQWORD) &(KeyRSC),
+ (PBYTE)abyKey,
+ byKeyDecMode
+ ) == TRUE) &&
+ (KeybSetDefaultKey(pDevice,
+ &(pDevice->sKey),
+ dwKeyIndex,
+ param->u.wpa_key.key_len,
+ (PQWORD) &(KeyRSC),
+ (PBYTE)abyKey,
+ byKeyDecMode
+ ) == TRUE) ) {
+ DBG_PRT(MSG_LEVEL_DEBUG, KERN_INFO "GROUP Key Assign.\n");
+
+ } else {
+ //DBG_PRN_WLAN03(("return NDIS_STATUS_INVALID_DATA -KeybSetDefaultKey Fail.0\n"));
+ return -EINVAL;
+ }
+
+ } else {
+ DBG_PRT(MSG_LEVEL_DEBUG, KERN_INFO "Pairwise Key Assign.\n");
+ // BSSID not 0xffffffffffff
+ // Pairwise Key can't be WEP
+ if (byKeyDecMode == KEY_CTL_WEP) {
+ DBG_PRT(MSG_LEVEL_DEBUG, KERN_INFO "Pairwise Key can't be WEP\n");
+ 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"));
+ return -EINVAL;
+ }
+ if (KeybSetKey(pDevice,
+ &(pDevice->sKey),
+ &param->addr[0],
+ dwKeyIndex,
+ param->u.wpa_key.key_len,
+ (PQWORD) &(KeyRSC),
+ (PBYTE)abyKey,
+ byKeyDecMode
+ ) == TRUE) {
+ DBG_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"));
+ return -EINVAL;
+
+ } else {
+ // Save Key and configure just before associate/reassociate to BSSID
+ // we do not implement now
+ 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;
+
+/*
+ DBG_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->sMgmtObj);
+ 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->sMgmtObj);
+ 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;
+
+//2007-0919-01<Add>by MikeLiu
+/**set ap_scan=1&&scan_ssid=1 under hidden ssid mode**/
+ PSMgmtObject pMgmt = &(pDevice->sMgmtObj);
+ PWLAN_IE_SSID pItemSSID;
+printk("wpa_set_scan-->desired [ssid=%s,ssid_len=%d]\n",
+ param->u.scan_req.ssid,param->u.scan_req.ssid_len);
+// 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, param->u.scan_req.ssid, param->u.scan_req.ssid_len);
+pItemSSID->len = param->u.scan_req.ssid_len;
+
+ spin_lock_irq(&pDevice->lock);
+ BSSvClearBSSList((HANDLE)pDevice, pDevice->bLinkPass);
+ // bScheduleCommand((HANDLE) pDevice, WLAN_CMD_BSSID_SCAN, NULL);
+ bScheduleCommand((HANDLE) pDevice, WLAN_CMD_BSSID_SCAN, pMgmt->abyDesireSSID);
+ 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->sMgmtObj);
+ 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->sMgmtObj);
+ 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->sMgmtObj);
+ PWLAN_IE_SSID pItemSSID;
+ PKnownBSS pBSS;
+ PBYTE pBuf;
+ int ret = 0;
+ u16 count = 0;
+ u16 ii, jj;
+ long ldBm;//James //add
+
+//******mike:bubble sort by stronger RSSI*****//
+
+ 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");
+
+ 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; //DavidWang for sharemode
+//20080717-05,<Add> by James Li
+ RFvRSSITodBm(pDevice, (BYTE)(pBSS->uRSSI), &ldBm);
+ if(-ldBm<50){
+ scan_buf->qual = 100;
+ }else if(-ldBm > 90) {
+ scan_buf->qual = 0;
+ }else {
+ scan_buf->qual=(40-(-ldBm-50))*100/40;
+ }
+
+ //James
+ //scan_buf->caps = pBSS->wCapInfo;
+ //scan_buf->qual =
+ scan_buf->noise = 0;
+ scan_buf->level = ldBm;
+ //20080717-05,<Add> by James Li--End
+ //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;
+ DBG_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->sMgmtObj);
+ 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
+ DBG_PRT(MSG_LEVEL_DEBUG, KERN_INFO "pairwise_suite = %d\n", param->u.wpa_associate.pairwise_suite);
+ DBG_PRT(MSG_LEVEL_DEBUG, KERN_INFO "group_suite = %d\n", param->u.wpa_associate.group_suite);
+ DBG_PRT(MSG_LEVEL_DEBUG, KERN_INFO "key_mgmt_suite = %d\n", param->u.wpa_associate.key_mgmt_suite);
+ DBG_PRT(MSG_LEVEL_DEBUG, KERN_INFO "auth_alg = %d\n", param->u.wpa_associate.auth_alg);
+ DBG_PRT(MSG_LEVEL_DEBUG, KERN_INFO "mode = %d\n", param->u.wpa_associate.mode);
+ DBG_PRT(MSG_LEVEL_DEBUG, KERN_INFO "wpa_ie_len = %d\n", param->u.wpa_associate.wpa_ie_len);
+ DBG_PRT(MSG_LEVEL_DEBUG, KERN_INFO "Roaming dBm = %d\n", param->u.wpa_associate.roam_dbm); //Davidwang
+
+ 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 bssid
+ if (memcmp(param->u.wpa_associate.bssid, &abyNullAddr[0], 6) != 0)
+ memcpy(pMgmt->abyDesireBSSID, param->u.wpa_associate.bssid, 6);
+ // 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);
+
+ 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;
+ // printk("****************wpa_set_associate:set CIPHER_WEP40_104\n");
+ 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;
+ };
+
+ pMgmt->Roam_dbm = param->u.wpa_associate.roam_dbm;
+ // if ((pMgmt->Roam_dbm > 40)&&(pMgmt->Roam_dbm<80))
+ // pDevice->bEnableRoaming = TRUE;
+
+ if (pMgmt->eAuthenMode == WMAC_AUTH_SHAREKEY) { //@wep-sharekey
+ pDevice->eEncryptionStatus = Ndis802_11Encryption1Enabled;
+ pMgmt->bShareKeyAlgorithm = TRUE;
+ }
+ else if (pMgmt->eAuthenMode == WMAC_AUTH_OPEN) {
+ if(bwepEnabled==TRUE) { //@open-wep
+ pDevice->eEncryptionStatus = Ndis802_11Encryption1Enabled;
+ }
+ else { //@only open
+ pDevice->eEncryptionStatus = Ndis802_11EncryptionDisabled;
+ }
+ }
+//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))) {
+ //mike re-comment:open-wep && sharekey-wep needn't do initial key!!
+
+ }
+ else
+ KeyvInitTable(pDevice,&pDevice->sKey);
+
+ spin_lock_irq(&pDevice->lock);
+ pDevice->bLinkPass = FALSE;
+ ControlvMaskByte(pDevice,MESSAGE_REQUEST_MACREG,MAC_REG_PAPEDELAY,LEDSTS_STS,LEDSTS_SLOW);
+ 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,
+ pDevice->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);
+ DBG_PRT(MSG_LEVEL_DEBUG, KERN_INFO "VIAWGET_SET_WPA \n");
+ break;
+
+ case VIAWGET_SET_KEY:
+ DBG_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:
+ DBG_PRT(MSG_LEVEL_DEBUG, KERN_INFO "VIAWGET_SET_SCAN \n");
+ ret = wpa_set_scan(pDevice, param);
+ break;
+
+ case VIAWGET_GET_SCAN:
+ DBG_PRT(MSG_LEVEL_DEBUG, KERN_INFO "VIAWGET_GET_SCAN\n");
+ ret = wpa_get_scan(pDevice, param);
+ wpa_ioctl = 1;
+ break;
+
+ case VIAWGET_GET_SSID:
+ DBG_PRT(MSG_LEVEL_DEBUG, KERN_INFO "VIAWGET_GET_SSID \n");
+ ret = wpa_get_ssid(pDevice, param);
+ wpa_ioctl = 1;
+ break;
+
+ case VIAWGET_GET_BSSID:
+ DBG_PRT(MSG_LEVEL_DEBUG, KERN_INFO "VIAWGET_GET_BSSID \n");
+ ret = wpa_get_bssid(pDevice, param);
+ wpa_ioctl = 1;
+ break;
+
+ case VIAWGET_SET_ASSOCIATE:
+ DBG_PRT(MSG_LEVEL_DEBUG, KERN_INFO "VIAWGET_SET_ASSOCIATE \n");
+ ret = wpa_set_associate(pDevice, param);
+ break;
+
+ case VIAWGET_SET_DISASSOCIATE:
+ DBG_PRT(MSG_LEVEL_DEBUG, KERN_INFO "VIAWGET_SET_DISASSOCIATE \n");
+ ret = wpa_set_disassociate(pDevice, param);
+ break;
+
+ case VIAWGET_SET_DROP_UNENCRYPT:
+ DBG_PRT(MSG_LEVEL_DEBUG, KERN_INFO "VIAWGET_SET_DROP_UNENCRYPT \n");
+ break;
+
+ case VIAWGET_SET_DEAUTHENTICATE:
+ DBG_PRT(MSG_LEVEL_DEBUG, KERN_INFO "VIAWGET_SET_DEAUTHENTICATE \n");
+ break;
+
+ default:
+ DBG_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/vt6656/wpactl.h b/drivers/staging/vt6656/wpactl.h
new file mode 100644
index 000000000000..2db748bc8f64
--- /dev/null
+++ b/drivers/staging/vt6656/wpactl.h
@@ -0,0 +1,90 @@
+/*
+ * 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_PSK, KEY_MGMT_NONE,
+ KEY_MGMT_802_1X_NO_WPA, KEY_MGMT_WPA_NONE, KEY_MGMT_CCKM } wpa_key_mgmt;//20080717-02,<Modify> by James Li
+
+#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/wlan-ng/hfa384x_usb.c b/drivers/staging/wlan-ng/hfa384x_usb.c
index 51d9e520d52a..925678babd9e 100644
--- a/drivers/staging/wlan-ng/hfa384x_usb.c
+++ b/drivers/staging/wlan-ng/hfa384x_usb.c
@@ -128,9 +128,6 @@
#define SUBMIT_URB(u,f) usb_submit_urb(u,f)
-/*================================================================*/
-/* Project Includes */
-
#include "p80211types.h"
#include "p80211hdr.h"
#include "p80211mgmt.h"
@@ -160,13 +157,13 @@ static void dbprint_urb(struct urb *urb);
#endif
static void
-hfa384x_int_rxmonitor(wlandevice_t * wlandev, hfa384x_usb_rxfrm_t * rxfrm);
+hfa384x_int_rxmonitor(wlandevice_t *wlandev, hfa384x_usb_rxfrm_t *rxfrm);
static void hfa384x_usb_defer(struct work_struct *data);
-static int submit_rx_urb(hfa384x_t * hw, gfp_t flags);
+static int submit_rx_urb(hfa384x_t *hw, gfp_t flags);
-static int submit_tx_urb(hfa384x_t * hw, struct urb *tx_urb, gfp_t flags);
+static int submit_tx_urb(hfa384x_t *hw, struct urb *tx_urb, gfp_t flags);
/*---------------------------------------------------*/
/* Callbacks */
@@ -175,22 +172,22 @@ static void hfa384x_ctlxout_callback(struct urb *urb);
static void hfa384x_usbin_callback(struct urb *urb);
static void
-hfa384x_usbin_txcompl(wlandevice_t * wlandev, hfa384x_usbin_t * usbin);
+hfa384x_usbin_txcompl(wlandevice_t *wlandev, hfa384x_usbin_t * usbin);
-static void hfa384x_usbin_rx(wlandevice_t * wlandev, struct sk_buff *skb);
+static void hfa384x_usbin_rx(wlandevice_t *wlandev, struct sk_buff *skb);
-static void hfa384x_usbin_info(wlandevice_t * wlandev, hfa384x_usbin_t * usbin);
+static void hfa384x_usbin_info(wlandevice_t *wlandev, hfa384x_usbin_t * usbin);
static void
-hfa384x_usbout_tx(wlandevice_t * wlandev, hfa384x_usbout_t * usbout);
+hfa384x_usbout_tx(wlandevice_t *wlandev, hfa384x_usbout_t *usbout);
-static void hfa384x_usbin_ctlx(hfa384x_t * hw, hfa384x_usbin_t * usbin,
+static void hfa384x_usbin_ctlx(hfa384x_t *hw, hfa384x_usbin_t *usbin,
int urb_status);
/*---------------------------------------------------*/
/* Functions to support the prism2 usb command queue */
-static void hfa384x_usbctlxq_run(hfa384x_t * hw);
+static void hfa384x_usbctlxq_run(hfa384x_t *hw);
static void hfa384x_usbctlx_reqtimerfn(unsigned long data);
@@ -202,9 +199,9 @@ static void hfa384x_usbctlx_completion_task(unsigned long data);
static void hfa384x_usbctlx_reaper_task(unsigned long data);
-static int hfa384x_usbctlx_submit(hfa384x_t * hw, hfa384x_usbctlx_t * ctlx);
+static int hfa384x_usbctlx_submit(hfa384x_t *hw, hfa384x_usbctlx_t *ctlx);
-static void unlocked_usbctlx_complete(hfa384x_t * hw, hfa384x_usbctlx_t * ctlx);
+static void unlocked_usbctlx_complete(hfa384x_t *hw, hfa384x_usbctlx_t *ctlx);
struct usbctlx_completor {
int (*complete) (struct usbctlx_completor *);
@@ -212,35 +209,35 @@ struct usbctlx_completor {
typedef struct usbctlx_completor usbctlx_completor_t;
static int
-hfa384x_usbctlx_complete_sync(hfa384x_t * hw,
- hfa384x_usbctlx_t * ctlx,
- usbctlx_completor_t * completor);
+hfa384x_usbctlx_complete_sync(hfa384x_t *hw,
+ hfa384x_usbctlx_t *ctlx,
+ usbctlx_completor_t *completor);
static int
-unlocked_usbctlx_cancel_async(hfa384x_t * hw, hfa384x_usbctlx_t * ctlx);
+unlocked_usbctlx_cancel_async(hfa384x_t *hw, hfa384x_usbctlx_t *ctlx);
-static void hfa384x_cb_status(hfa384x_t * hw, const hfa384x_usbctlx_t * ctlx);
+static void hfa384x_cb_status(hfa384x_t *hw, const hfa384x_usbctlx_t *ctlx);
-static void hfa384x_cb_rrid(hfa384x_t * hw, const hfa384x_usbctlx_t * ctlx);
+static void hfa384x_cb_rrid(hfa384x_t *hw, const hfa384x_usbctlx_t *ctlx);
static int
-usbctlx_get_status(const hfa384x_usb_cmdresp_t * cmdresp,
- hfa384x_cmdresult_t * result);
+usbctlx_get_status(const hfa384x_usb_cmdresp_t *cmdresp,
+ hfa384x_cmdresult_t *result);
static void
-usbctlx_get_rridresult(const hfa384x_usb_rridresp_t * rridresp,
- hfa384x_rridresult_t * result);
+usbctlx_get_rridresult(const hfa384x_usb_rridresp_t *rridresp,
+ hfa384x_rridresult_t *result);
/*---------------------------------------------------*/
/* Low level req/resp CTLX formatters and submitters */
static int
-hfa384x_docmd(hfa384x_t * hw,
+hfa384x_docmd(hfa384x_t *hw,
CMD_MODE mode,
- hfa384x_metacmd_t * cmd,
+ hfa384x_metacmd_t *cmd,
ctlx_cmdcb_t cmdcb, ctlx_usercb_t usercb, void *usercb_data);
static int
-hfa384x_dorrid(hfa384x_t * hw,
+hfa384x_dorrid(hfa384x_t *hw,
CMD_MODE mode,
u16 rid,
void *riddata,
@@ -248,7 +245,7 @@ hfa384x_dorrid(hfa384x_t * hw,
ctlx_cmdcb_t cmdcb, ctlx_usercb_t usercb, void *usercb_data);
static int
-hfa384x_dowrid(hfa384x_t * hw,
+hfa384x_dowrid(hfa384x_t *hw,
CMD_MODE mode,
u16 rid,
void *riddata,
@@ -256,7 +253,7 @@ hfa384x_dowrid(hfa384x_t * hw,
ctlx_cmdcb_t cmdcb, ctlx_usercb_t usercb, void *usercb_data);
static int
-hfa384x_dormem(hfa384x_t * hw,
+hfa384x_dormem(hfa384x_t *hw,
CMD_MODE mode,
u16 page,
u16 offset,
@@ -265,7 +262,7 @@ hfa384x_dormem(hfa384x_t * hw,
ctlx_cmdcb_t cmdcb, ctlx_usercb_t usercb, void *usercb_data);
static int
-hfa384x_dowmem(hfa384x_t * hw,
+hfa384x_dowmem(hfa384x_t *hw,
CMD_MODE mode,
u16 page,
u16 offset,
@@ -334,7 +331,7 @@ void dbprint_urb(struct urb *urb)
* Call context:
* Any
----------------------------------------------------------------*/
-static int submit_rx_urb(hfa384x_t * hw, gfp_t memflags)
+static int submit_rx_urb(hfa384x_t *hw, gfp_t memflags)
{
struct sk_buff *skb;
int result;
@@ -395,7 +392,7 @@ done:
* Call context:
* Any
----------------------------------------------------------------*/
-static int submit_tx_urb(hfa384x_t * hw, struct urb *tx_urb, gfp_t memflags)
+static int submit_tx_urb(hfa384x_t *hw, struct urb *tx_urb, gfp_t memflags)
{
struct net_device *netdev = hw->wlandev->netdev;
int result;
@@ -532,7 +529,7 @@ static void hfa384x_usb_defer(struct work_struct *data)
* Call context:
* process
----------------------------------------------------------------*/
-void hfa384x_create(hfa384x_t * hw, struct usb_device *usb)
+void hfa384x_create(hfa384x_t *hw, struct usb_device *usb)
{
memset(hw, 0, sizeof(hfa384x_t));
hw->usb = usb;
@@ -608,7 +605,7 @@ void hfa384x_create(hfa384x_t * hw, struct usb_device *usb)
* Call context:
* process
----------------------------------------------------------------*/
-void hfa384x_destroy(hfa384x_t * hw)
+void hfa384x_destroy(hfa384x_t *hw)
{
struct sk_buff *skb;
@@ -640,8 +637,8 @@ static hfa384x_usbctlx_t *usbctlx_alloc(void)
}
static int
-usbctlx_get_status(const hfa384x_usb_cmdresp_t * cmdresp,
- hfa384x_cmdresult_t * result)
+usbctlx_get_status(const hfa384x_usb_cmdresp_t *cmdresp,
+ hfa384x_cmdresult_t *result)
{
result->status = le16_to_cpu(cmdresp->status);
result->resp0 = le16_to_cpu(cmdresp->resp0);
@@ -656,8 +653,8 @@ usbctlx_get_status(const hfa384x_usb_cmdresp_t * cmdresp,
}
static void
-usbctlx_get_rridresult(const hfa384x_usb_rridresp_t * rridresp,
- hfa384x_rridresult_t * result)
+usbctlx_get_rridresult(const hfa384x_usb_rridresp_t *rridresp,
+ hfa384x_rridresult_t *result)
{
result->rid = le16_to_cpu(rridresp->rid);
result->riddata = rridresp->data;
@@ -712,7 +709,7 @@ struct usbctlx_rrid_completor {
};
typedef struct usbctlx_rrid_completor usbctlx_rrid_completor_t;
-static int usbctlx_rrid_completor_fn(usbctlx_completor_t * head)
+static int usbctlx_rrid_completor_fn(usbctlx_completor_t *head)
{
usbctlx_rrid_completor_t *complete = (usbctlx_rrid_completor_t *) head;
hfa384x_rridresult_t rridresult;
@@ -733,7 +730,7 @@ static int usbctlx_rrid_completor_fn(usbctlx_completor_t * head)
}
static inline usbctlx_completor_t *init_rrid_completor(usbctlx_rrid_completor_t
- * completor,
+ *completor,
const
hfa384x_usb_rridresp_t *
rridresp, void *riddata,
@@ -773,7 +770,7 @@ struct usbctlx_rmem_completor {
};
typedef struct usbctlx_rmem_completor usbctlx_rmem_completor_t;
-static int usbctlx_rmem_completor_fn(usbctlx_completor_t * head)
+static int usbctlx_rmem_completor_fn(usbctlx_completor_t *head)
{
usbctlx_rmem_completor_t *complete = (usbctlx_rmem_completor_t *) head;
@@ -783,9 +780,9 @@ static int usbctlx_rmem_completor_fn(usbctlx_completor_t * head)
}
static inline usbctlx_completor_t *init_rmem_completor(usbctlx_rmem_completor_t
- * completor,
+ *completor,
hfa384x_usb_rmemresp_t
- * rmemresp, void *data,
+ *rmemresp, void *data,
unsigned int len)
{
completor->head.complete = usbctlx_rmem_completor_fn;
@@ -816,7 +813,7 @@ static inline usbctlx_completor_t *init_rmem_completor(usbctlx_rmem_completor_t
* Call context:
* interrupt
----------------------------------------------------------------*/
-static void hfa384x_cb_status(hfa384x_t * hw, const hfa384x_usbctlx_t * ctlx)
+static void hfa384x_cb_status(hfa384x_t *hw, const hfa384x_usbctlx_t *ctlx)
{
if (ctlx->usercb != NULL) {
hfa384x_cmdresult_t cmdresult;
@@ -853,7 +850,7 @@ static void hfa384x_cb_status(hfa384x_t * hw, const hfa384x_usbctlx_t * ctlx)
* Call context:
* interrupt
----------------------------------------------------------------*/
-static void hfa384x_cb_rrid(hfa384x_t * hw, const hfa384x_usbctlx_t * ctlx)
+static void hfa384x_cb_rrid(hfa384x_t *hw, const hfa384x_usbctlx_t *ctlx)
{
if (ctlx->usercb != NULL) {
hfa384x_rridresult_t rridresult;
@@ -870,21 +867,21 @@ static void hfa384x_cb_rrid(hfa384x_t * hw, const hfa384x_usbctlx_t * ctlx)
}
}
-static inline int hfa384x_docmd_wait(hfa384x_t * hw, hfa384x_metacmd_t * cmd)
+static inline int hfa384x_docmd_wait(hfa384x_t *hw, hfa384x_metacmd_t *cmd)
{
return hfa384x_docmd(hw, DOWAIT, cmd, NULL, NULL, NULL);
}
static inline int
-hfa384x_docmd_async(hfa384x_t * hw,
- hfa384x_metacmd_t * cmd,
+hfa384x_docmd_async(hfa384x_t *hw,
+ hfa384x_metacmd_t *cmd,
ctlx_cmdcb_t cmdcb, ctlx_usercb_t usercb, void *usercb_data)
{
return hfa384x_docmd(hw, DOASYNC, cmd, cmdcb, usercb, usercb_data);
}
static inline int
-hfa384x_dorrid_wait(hfa384x_t * hw, u16 rid, void *riddata,
+hfa384x_dorrid_wait(hfa384x_t *hw, u16 rid, void *riddata,
unsigned int riddatalen)
{
return hfa384x_dorrid(hw, DOWAIT,
@@ -892,7 +889,7 @@ hfa384x_dorrid_wait(hfa384x_t * hw, u16 rid, void *riddata,
}
static inline int
-hfa384x_dorrid_async(hfa384x_t * hw,
+hfa384x_dorrid_async(hfa384x_t *hw,
u16 rid, void *riddata, unsigned int riddatalen,
ctlx_cmdcb_t cmdcb,
ctlx_usercb_t usercb, void *usercb_data)
@@ -903,7 +900,7 @@ hfa384x_dorrid_async(hfa384x_t * hw,
}
static inline int
-hfa384x_dowrid_wait(hfa384x_t * hw, u16 rid, void *riddata,
+hfa384x_dowrid_wait(hfa384x_t *hw, u16 rid, void *riddata,
unsigned int riddatalen)
{
return hfa384x_dowrid(hw, DOWAIT,
@@ -911,7 +908,7 @@ hfa384x_dowrid_wait(hfa384x_t * hw, u16 rid, void *riddata,
}
static inline int
-hfa384x_dowrid_async(hfa384x_t * hw,
+hfa384x_dowrid_async(hfa384x_t *hw,
u16 rid, void *riddata, unsigned int riddatalen,
ctlx_cmdcb_t cmdcb,
ctlx_usercb_t usercb, void *usercb_data)
@@ -922,7 +919,7 @@ hfa384x_dowrid_async(hfa384x_t * hw,
}
static inline int
-hfa384x_dormem_wait(hfa384x_t * hw,
+hfa384x_dormem_wait(hfa384x_t *hw,
u16 page, u16 offset, void *data, unsigned int len)
{
return hfa384x_dormem(hw, DOWAIT,
@@ -930,7 +927,7 @@ hfa384x_dormem_wait(hfa384x_t * hw,
}
static inline int
-hfa384x_dormem_async(hfa384x_t * hw,
+hfa384x_dormem_async(hfa384x_t *hw,
u16 page, u16 offset, void *data, unsigned int len,
ctlx_cmdcb_t cmdcb,
ctlx_usercb_t usercb, void *usercb_data)
@@ -941,7 +938,7 @@ hfa384x_dormem_async(hfa384x_t * hw,
}
static inline int
-hfa384x_dowmem_wait(hfa384x_t * hw,
+hfa384x_dowmem_wait(hfa384x_t *hw,
u16 page, u16 offset, void *data, unsigned int len)
{
return hfa384x_dowmem(hw, DOWAIT,
@@ -949,7 +946,7 @@ hfa384x_dowmem_wait(hfa384x_t * hw,
}
static inline int
-hfa384x_dowmem_async(hfa384x_t * hw,
+hfa384x_dowmem_async(hfa384x_t *hw,
u16 page,
u16 offset,
void *data,
@@ -981,7 +978,7 @@ hfa384x_dowmem_async(hfa384x_t * hw,
* Call context:
* process
----------------------------------------------------------------*/
-int hfa384x_cmd_initialize(hfa384x_t * hw)
+int hfa384x_cmd_initialize(hfa384x_t *hw)
{
int result = 0;
int i;
@@ -1029,7 +1026,7 @@ int hfa384x_cmd_initialize(hfa384x_t * hw)
* Call context:
* process
----------------------------------------------------------------*/
-int hfa384x_cmd_disable(hfa384x_t * hw, u16 macport)
+int hfa384x_cmd_disable(hfa384x_t *hw, u16 macport)
{
int result = 0;
hfa384x_metacmd_t cmd;
@@ -1065,7 +1062,7 @@ int hfa384x_cmd_disable(hfa384x_t * hw, u16 macport)
* Call context:
* process
----------------------------------------------------------------*/
-int hfa384x_cmd_enable(hfa384x_t * hw, u16 macport)
+int hfa384x_cmd_enable(hfa384x_t *hw, u16 macport)
{
int result = 0;
hfa384x_metacmd_t cmd;
@@ -1110,7 +1107,7 @@ int hfa384x_cmd_enable(hfa384x_t * hw, u16 macport)
* Call context:
* process
----------------------------------------------------------------*/
-int hfa384x_cmd_monitor(hfa384x_t * hw, u16 enable)
+int hfa384x_cmd_monitor(hfa384x_t *hw, u16 enable)
{
int result = 0;
hfa384x_metacmd_t cmd;
@@ -1164,7 +1161,7 @@ int hfa384x_cmd_monitor(hfa384x_t * hw, u16 enable)
* Call context:
* process
----------------------------------------------------------------*/
-int hfa384x_cmd_download(hfa384x_t * hw, u16 mode, u16 lowaddr,
+int hfa384x_cmd_download(hfa384x_t *hw, u16 mode, u16 lowaddr,
u16 highaddr, u16 codelen)
{
int result = 0;
@@ -1208,7 +1205,7 @@ int hfa384x_cmd_download(hfa384x_t * hw, u16 mode, u16 lowaddr,
* Call context:
* process
----------------------------------------------------------------*/
-int hfa384x_corereset(hfa384x_t * hw, int holdtime, int settletime, int genesis)
+int hfa384x_corereset(hfa384x_t *hw, int holdtime, int settletime, int genesis)
{
int result = 0;
@@ -1245,9 +1242,9 @@ int hfa384x_corereset(hfa384x_t * hw, int holdtime, int settletime, int genesis)
* Call context:
* process
----------------------------------------------------------------*/
-static int hfa384x_usbctlx_complete_sync(hfa384x_t * hw,
- hfa384x_usbctlx_t * ctlx,
- usbctlx_completor_t * completor)
+static int hfa384x_usbctlx_complete_sync(hfa384x_t *hw,
+ hfa384x_usbctlx_t *ctlx,
+ usbctlx_completor_t *completor)
{
unsigned long flags;
int result;
@@ -1361,9 +1358,9 @@ cleanup:
* process
----------------------------------------------------------------*/
static int
-hfa384x_docmd(hfa384x_t * hw,
+hfa384x_docmd(hfa384x_t *hw,
CMD_MODE mode,
- hfa384x_metacmd_t * cmd,
+ hfa384x_metacmd_t *cmd,
ctlx_cmdcb_t cmdcb, ctlx_usercb_t usercb, void *usercb_data)
{
int result;
@@ -1450,7 +1447,7 @@ done:
* process (DOWAIT or DOASYNC)
----------------------------------------------------------------*/
static int
-hfa384x_dorrid(hfa384x_t * hw,
+hfa384x_dorrid(hfa384x_t *hw,
CMD_MODE mode,
u16 rid,
void *riddata,
@@ -1531,7 +1528,7 @@ done:
* process (DOWAIT or DOASYNC)
----------------------------------------------------------------*/
static int
-hfa384x_dowrid(hfa384x_t * hw,
+hfa384x_dowrid(hfa384x_t *hw,
CMD_MODE mode,
u16 rid,
void *riddata,
@@ -1618,7 +1615,7 @@ done:
* process (DOWAIT or DOASYNC)
----------------------------------------------------------------*/
static int
-hfa384x_dormem(hfa384x_t * hw,
+hfa384x_dormem(hfa384x_t *hw,
CMD_MODE mode,
u16 page,
u16 offset,
@@ -1709,7 +1706,7 @@ done:
* process (DOWAIT or DOASYNC)
----------------------------------------------------------------*/
static int
-hfa384x_dowmem(hfa384x_t * hw,
+hfa384x_dowmem(hfa384x_t *hw,
CMD_MODE mode,
u16 page,
u16 offset,
@@ -1783,7 +1780,7 @@ done:
* Call context:
* process
----------------------------------------------------------------*/
-int hfa384x_drvr_commtallies(hfa384x_t * hw)
+int hfa384x_drvr_commtallies(hfa384x_t *hw)
{
hfa384x_metacmd_t cmd;
@@ -1819,7 +1816,7 @@ int hfa384x_drvr_commtallies(hfa384x_t * hw)
* Call context:
* process
----------------------------------------------------------------*/
-int hfa384x_drvr_disable(hfa384x_t * hw, u16 macport)
+int hfa384x_drvr_disable(hfa384x_t *hw, u16 macport)
{
int result = 0;
@@ -1857,7 +1854,7 @@ int hfa384x_drvr_disable(hfa384x_t * hw, u16 macport)
* Call context:
* process
----------------------------------------------------------------*/
-int hfa384x_drvr_enable(hfa384x_t * hw, u16 macport)
+int hfa384x_drvr_enable(hfa384x_t *hw, u16 macport)
{
int result = 0;
@@ -1894,7 +1891,7 @@ int hfa384x_drvr_enable(hfa384x_t * hw, u16 macport)
* Call context:
* process
----------------------------------------------------------------*/
-int hfa384x_drvr_flashdl_enable(hfa384x_t * hw)
+int hfa384x_drvr_flashdl_enable(hfa384x_t *hw)
{
int result = 0;
int i;
@@ -1952,7 +1949,7 @@ int hfa384x_drvr_flashdl_enable(hfa384x_t * hw)
* Call context:
* process
----------------------------------------------------------------*/
-int hfa384x_drvr_flashdl_disable(hfa384x_t * hw)
+int hfa384x_drvr_flashdl_disable(hfa384x_t *hw)
{
/* Check that we're already in the download state */
if (hw->dlstate != HFA384x_DLSTATE_FLASHENABLED)
@@ -1997,7 +1994,7 @@ int hfa384x_drvr_flashdl_disable(hfa384x_t * hw)
* Call context:
* process
----------------------------------------------------------------*/
-int hfa384x_drvr_flashdl_write(hfa384x_t * hw, u32 daddr, void *buf, u32 len)
+int hfa384x_drvr_flashdl_write(hfa384x_t *hw, u32 daddr, void *buf, u32 len)
{
int result = 0;
u32 dlbufaddr;
@@ -2143,7 +2140,7 @@ exit_proc:
* Call context:
* process
----------------------------------------------------------------*/
-int hfa384x_drvr_getconfig(hfa384x_t * hw, u16 rid, void *buf, u16 len)
+int hfa384x_drvr_getconfig(hfa384x_t *hw, u16 rid, void *buf, u16 len)
{
int result;
@@ -2180,7 +2177,7 @@ int hfa384x_drvr_getconfig(hfa384x_t * hw, u16 rid, void *buf, u16 len)
* Any
----------------------------------------------------------------*/
int
-hfa384x_drvr_getconfig_async(hfa384x_t * hw,
+hfa384x_drvr_getconfig_async(hfa384x_t *hw,
u16 rid, ctlx_usercb_t usercb, void *usercb_data)
{
return hfa384x_dorrid_async(hw, rid, NULL, 0,
@@ -2211,7 +2208,7 @@ hfa384x_drvr_getconfig_async(hfa384x_t * hw,
* process
----------------------------------------------------------------*/
int
-hfa384x_drvr_setconfig_async(hfa384x_t * hw,
+hfa384x_drvr_setconfig_async(hfa384x_t *hw,
u16 rid,
void *buf,
u16 len, ctlx_usercb_t usercb, void *usercb_data)
@@ -2238,7 +2235,7 @@ hfa384x_drvr_setconfig_async(hfa384x_t * hw,
* Call context:
* process
----------------------------------------------------------------*/
-int hfa384x_drvr_ramdl_disable(hfa384x_t * hw)
+int hfa384x_drvr_ramdl_disable(hfa384x_t *hw)
{
/* Check that we're already in the download state */
if (hw->dlstate != HFA384x_DLSTATE_RAMENABLED)
@@ -2278,7 +2275,7 @@ int hfa384x_drvr_ramdl_disable(hfa384x_t * hw)
* Call context:
* process
----------------------------------------------------------------*/
-int hfa384x_drvr_ramdl_enable(hfa384x_t * hw, u32 exeaddr)
+int hfa384x_drvr_ramdl_enable(hfa384x_t *hw, u32 exeaddr)
{
int result = 0;
u16 lowaddr;
@@ -2346,7 +2343,7 @@ int hfa384x_drvr_ramdl_enable(hfa384x_t * hw, u32 exeaddr)
* Call context:
* process
----------------------------------------------------------------*/
-int hfa384x_drvr_ramdl_write(hfa384x_t * hw, u32 daddr, void *buf, u32 len)
+int hfa384x_drvr_ramdl_write(hfa384x_t *hw, u32 daddr, void *buf, u32 len)
{
int result = 0;
int nwrites;
@@ -2425,7 +2422,7 @@ int hfa384x_drvr_ramdl_write(hfa384x_t * hw, u32 daddr, void *buf, u32 len)
* Call context:
* process or non-card interrupt.
----------------------------------------------------------------*/
-int hfa384x_drvr_readpda(hfa384x_t * hw, void *buf, unsigned int len)
+int hfa384x_drvr_readpda(hfa384x_t *hw, void *buf, unsigned int len)
{
int result = 0;
u16 *pda = buf;
@@ -2531,7 +2528,7 @@ int hfa384x_drvr_readpda(hfa384x_t * hw, void *buf, unsigned int len)
* Call context:
* process
----------------------------------------------------------------*/
-int hfa384x_drvr_setconfig(hfa384x_t * hw, u16 rid, void *buf, u16 len)
+int hfa384x_drvr_setconfig(hfa384x_t *hw, u16 rid, void *buf, u16 len)
{
return hfa384x_dowrid_wait(hw, rid, buf, len);
}
@@ -2556,7 +2553,7 @@ int hfa384x_drvr_setconfig(hfa384x_t * hw, u16 rid, void *buf, u16 len)
* process
----------------------------------------------------------------*/
-int hfa384x_drvr_start(hfa384x_t * hw)
+int hfa384x_drvr_start(hfa384x_t *hw)
{
int result, result1, result2;
u16 status;
@@ -2657,7 +2654,7 @@ done:
* Call context:
* process
----------------------------------------------------------------*/
-int hfa384x_drvr_stop(hfa384x_t * hw)
+int hfa384x_drvr_stop(hfa384x_t *hw)
{
int result = 0;
int i;
@@ -2708,9 +2705,9 @@ int hfa384x_drvr_stop(hfa384x_t * hw)
* Call context:
* interrupt
----------------------------------------------------------------*/
-int hfa384x_drvr_txframe(hfa384x_t * hw, struct sk_buff *skb,
- p80211_hdr_t * p80211_hdr,
- p80211_metawep_t * p80211_wep)
+int hfa384x_drvr_txframe(hfa384x_t *hw, struct sk_buff *skb,
+ p80211_hdr_t *p80211_hdr,
+ p80211_metawep_t *p80211_wep)
{
int usbpktlen = sizeof(hfa384x_tx_frame_t);
int result;
@@ -2801,7 +2798,7 @@ exit:
return result;
}
-void hfa384x_tx_timeout(wlandevice_t * wlandev)
+void hfa384x_tx_timeout(wlandevice_t *wlandev)
{
hfa384x_t *hw = wlandev->priv;
unsigned long flags;
@@ -2950,8 +2947,8 @@ static void hfa384x_usbctlx_completion_task(unsigned long data)
* Call context:
* Either process or interrupt, but presumably interrupt
----------------------------------------------------------------*/
-static int unlocked_usbctlx_cancel_async(hfa384x_t * hw,
- hfa384x_usbctlx_t * ctlx)
+static int unlocked_usbctlx_cancel_async(hfa384x_t *hw,
+ hfa384x_usbctlx_t *ctlx)
{
int ret;
@@ -3000,7 +2997,7 @@ static int unlocked_usbctlx_cancel_async(hfa384x_t * hw,
* Call context:
* Either, assume interrupt
----------------------------------------------------------------*/
-static void unlocked_usbctlx_complete(hfa384x_t * hw, hfa384x_usbctlx_t * ctlx)
+static void unlocked_usbctlx_complete(hfa384x_t *hw, hfa384x_usbctlx_t *ctlx)
{
/* Timers have been stopped, and ctlx should be in
* a terminal state. Retire it from the "active"
@@ -3038,7 +3035,7 @@ static void unlocked_usbctlx_complete(hfa384x_t * hw, hfa384x_usbctlx_t * ctlx)
* Call context:
* any
----------------------------------------------------------------*/
-static void hfa384x_usbctlxq_run(hfa384x_t * hw)
+static void hfa384x_usbctlxq_run(hfa384x_t *hw)
{
unsigned long flags;
@@ -3318,7 +3315,7 @@ exit:
* Call context:
* interrupt
----------------------------------------------------------------*/
-static void hfa384x_usbin_ctlx(hfa384x_t * hw, hfa384x_usbin_t * usbin,
+static void hfa384x_usbin_ctlx(hfa384x_t *hw, hfa384x_usbin_t *usbin,
int urb_status)
{
hfa384x_usbctlx_t *ctlx;
@@ -3439,8 +3436,8 @@ unlock:
* Call context:
* interrupt
----------------------------------------------------------------*/
-static void hfa384x_usbin_txcompl(wlandevice_t * wlandev,
- hfa384x_usbin_t * usbin)
+static void hfa384x_usbin_txcompl(wlandevice_t *wlandev,
+ hfa384x_usbin_t *usbin)
{
u16 status;
@@ -3470,7 +3467,7 @@ static void hfa384x_usbin_txcompl(wlandevice_t * wlandev,
* Call context:
* interrupt
----------------------------------------------------------------*/
-static void hfa384x_usbin_rx(wlandevice_t * wlandev, struct sk_buff *skb)
+static void hfa384x_usbin_rx(wlandevice_t *wlandev, struct sk_buff *skb)
{
hfa384x_usbin_t *usbin = (hfa384x_usbin_t *) skb->data;
hfa384x_t *hw = wlandev->priv;
@@ -3573,8 +3570,8 @@ done:
* Call context:
* interrupt
----------------------------------------------------------------*/
-static void hfa384x_int_rxmonitor(wlandevice_t * wlandev,
- hfa384x_usb_rxfrm_t * rxfrm)
+static void hfa384x_int_rxmonitor(wlandevice_t *wlandev,
+ hfa384x_usb_rxfrm_t *rxfrm)
{
hfa384x_rx_frame_t *rxdesc = &(rxfrm->desc);
unsigned int hdrlen = 0;
@@ -3677,7 +3674,7 @@ static void hfa384x_int_rxmonitor(wlandevice_t * wlandev,
* Call context:
* interrupt
----------------------------------------------------------------*/
-static void hfa384x_usbin_info(wlandevice_t * wlandev, hfa384x_usbin_t * usbin)
+static void hfa384x_usbin_info(wlandevice_t *wlandev, hfa384x_usbin_t *usbin)
{
usbin->infofrm.info.framelen =
le16_to_cpu(usbin->infofrm.info.framelen);
@@ -4055,7 +4052,7 @@ static void hfa384x_usb_throttlefn(unsigned long data)
* Call context:
* process or interrupt
----------------------------------------------------------------*/
-static int hfa384x_usbctlx_submit(hfa384x_t * hw, hfa384x_usbctlx_t * ctlx)
+static int hfa384x_usbctlx_submit(hfa384x_t *hw, hfa384x_usbctlx_t *ctlx)
{
unsigned long flags;
int ret;
@@ -4096,7 +4093,7 @@ static int hfa384x_usbctlx_submit(hfa384x_t * hw, hfa384x_usbctlx_t * ctlx)
* Call context:
* interrupt
----------------------------------------------------------------*/
-static void hfa384x_usbout_tx(wlandevice_t * wlandev, hfa384x_usbout_t * usbout)
+static void hfa384x_usbout_tx(wlandevice_t *wlandev, hfa384x_usbout_t *usbout)
{
prism2sta_ev_alloc(wlandev);
}
diff --git a/drivers/staging/wlan-ng/p80211conv.c b/drivers/staging/wlan-ng/p80211conv.c
index 8b4f3960d9bc..5952c671073f 100644
--- a/drivers/staging/wlan-ng/p80211conv.c
+++ b/drivers/staging/wlan-ng/p80211conv.c
@@ -102,9 +102,9 @@ static u8 oui_8021h[] = { 0x00, 0x00, 0xf8 };
* Call context:
* May be called in interrupt or non-interrupt context
----------------------------------------------------------------*/
-int skb_ether_to_p80211(wlandevice_t * wlandev, u32 ethconv,
- struct sk_buff *skb, p80211_hdr_t * p80211_hdr,
- p80211_metawep_t * p80211_wep)
+int skb_ether_to_p80211(wlandevice_t *wlandev, u32 ethconv,
+ struct sk_buff *skb, p80211_hdr_t *p80211_hdr,
+ p80211_metawep_t *p80211_wep)
{
u16 fc;
@@ -230,8 +230,8 @@ int skb_ether_to_p80211(wlandevice_t * wlandev, u32 ethconv,
}
/* jkriegl: from orinoco, modified */
-static void orinoco_spy_gather(wlandevice_t * wlandev, char *mac,
- p80211_rxmeta_t * rxmeta)
+static void orinoco_spy_gather(wlandevice_t *wlandev, char *mac,
+ p80211_rxmeta_t *rxmeta)
{
int i;
@@ -272,7 +272,7 @@ static void orinoco_spy_gather(wlandevice_t * wlandev, char *mac,
* Call context:
* May be called in interrupt or non-interrupt context
----------------------------------------------------------------*/
-int skb_p80211_to_ether(wlandevice_t * wlandev, u32 ethconv,
+int skb_p80211_to_ether(wlandevice_t *wlandev, u32 ethconv,
struct sk_buff *skb)
{
netdevice_t *netdev = wlandev->netdev;
diff --git a/drivers/staging/wlan-ng/p80211hdr.h b/drivers/staging/wlan-ng/p80211hdr.h
index 1703c9239476..419de4dee560 100644
--- a/drivers/staging/wlan-ng/p80211hdr.h
+++ b/drivers/staging/wlan-ng/p80211hdr.h
@@ -60,17 +60,8 @@
#ifndef _P80211HDR_H
#define _P80211HDR_H
-/*================================================================*/
-/* System Includes */
-
#include <linux/if_ether.h>
-/*================================================================*/
-/* Project Includes */
-
-/*================================================================*/
-/* Constants */
-
/*--- Sizes -----------------------------------------------*/
#define WLAN_CRC_LEN 4
#define WLAN_BSSID_LEN 6
@@ -121,9 +112,6 @@
#define WLAN_FSTYPE_CFPOLL 0x06
#define WLAN_FSTYPE_CFACK_CFPOLL 0x07
-/*================================================================*/
-/* Macros */
-
/*--- FC Macros ----------------------------------------------*/
/* Macros to get/set the bitfields of the Frame Control Field */
/* GET_FC_??? - takes the host byte-order value of an FC */
@@ -157,9 +145,6 @@
#define DOT11_RATE5_ISBASIC_GET(r) (((u8)(r)) & BIT(7))
-/*================================================================*/
-/* Types */
-
/* Generic 802.11 Header types */
typedef struct p80211_hdr_a3 {
diff --git a/drivers/staging/wlan-ng/p80211meta.h b/drivers/staging/wlan-ng/p80211meta.h
index c1a677be8dea..b9badcff681f 100644
--- a/drivers/staging/wlan-ng/p80211meta.h
+++ b/drivers/staging/wlan-ng/p80211meta.h
@@ -57,12 +57,6 @@
#ifndef _P80211META_H
#define _P80211META_H
-/*================================================================*/
-/* Project Includes */
-
-/*================================================================*/
-/* Types */
-
/*----------------------------------------------------------------*/
/* The following structure types are used for the metadata */
/* representation of category list metadata, group list metadata, */
diff --git a/drivers/staging/wlan-ng/p80211mgmt.h b/drivers/staging/wlan-ng/p80211mgmt.h
index c925a45b1885..14cdc86d1676 100644
--- a/drivers/staging/wlan-ng/p80211mgmt.h
+++ b/drivers/staging/wlan-ng/p80211mgmt.h
@@ -100,16 +100,10 @@
#ifndef _P80211MGMT_H
#define _P80211MGMT_H
-/*================================================================*/
-/* Project Includes */
-
#ifndef _P80211HDR_H
#include "p80211hdr.h"
#endif
-/*================================================================*/
-/* Constants */
-
/*-- Information Element IDs --------------------*/
#define WLAN_EID_SSID 0
#define WLAN_EID_SUPP_RATES 1
diff --git a/drivers/staging/wlan-ng/p80211msg.h b/drivers/staging/wlan-ng/p80211msg.h
index 4ac77274eefd..c691d3eeb9d0 100644
--- a/drivers/staging/wlan-ng/p80211msg.h
+++ b/drivers/staging/wlan-ng/p80211msg.h
@@ -48,14 +48,8 @@
#ifndef _P80211MSG_H
#define _P80211MSG_H
-/*================================================================*/
-/* Project Includes */
-
#define WLAN_DEVNAMELEN_MAX 16
-/*--------------------------------------------------------------------*/
-/* Prototype msg type */
-
typedef struct p80211msg {
u32 msgcode;
u32 msglen;
diff --git a/drivers/staging/wlan-ng/p80211netdev.c b/drivers/staging/wlan-ng/p80211netdev.c
index c273c034a830..22424c8903ee 100644
--- a/drivers/staging/wlan-ng/p80211netdev.c
+++ b/drivers/staging/wlan-ng/p80211netdev.c
@@ -76,9 +76,6 @@
#include <net/iw_handler.h>
#include <net/net_namespace.h>
-/*================================================================*/
-/* Project Includes */
-
#include "p80211types.h"
#include "p80211hdr.h"
#include "p80211conv.h"
@@ -94,18 +91,18 @@
static void p80211netdev_rx_bh(unsigned long arg);
/* netdevice method functions */
-static int p80211knetdev_init(netdevice_t * netdev);
-static struct net_device_stats *p80211knetdev_get_stats(netdevice_t * netdev);
-static int p80211knetdev_open(netdevice_t * netdev);
-static int p80211knetdev_stop(netdevice_t * netdev);
+static int p80211knetdev_init(netdevice_t *netdev);
+static struct net_device_stats *p80211knetdev_get_stats(netdevice_t *netdev);
+static int p80211knetdev_open(netdevice_t *netdev);
+static int p80211knetdev_stop(netdevice_t *netdev);
static int p80211knetdev_hard_start_xmit(struct sk_buff *skb,
- netdevice_t * netdev);
-static void p80211knetdev_set_multicast_list(netdevice_t * dev);
-static int p80211knetdev_do_ioctl(netdevice_t * dev, struct ifreq *ifr,
+ netdevice_t *netdev);
+static void p80211knetdev_set_multicast_list(netdevice_t *dev);
+static int p80211knetdev_do_ioctl(netdevice_t *dev, struct ifreq *ifr,
int cmd);
-static int p80211knetdev_set_mac_address(netdevice_t * dev, void *addr);
-static void p80211knetdev_tx_timeout(netdevice_t * netdev);
-static int p80211_rx_typedrop(wlandevice_t * wlandev, u16 fc);
+static int p80211knetdev_set_mac_address(netdevice_t *dev, void *addr);
+static void p80211knetdev_tx_timeout(netdevice_t *netdev);
+static int p80211_rx_typedrop(wlandevice_t *wlandev, u16 fc);
int wlan_watchdog = 5000;
module_param(wlan_watchdog, int, 0644);
@@ -127,7 +124,7 @@ MODULE_PARM_DESC(wlan_wext_write, "enable write wireless extensions");
* Returns:
* nothing
----------------------------------------------------------------*/
-static int p80211knetdev_init(netdevice_t * netdev)
+static int p80211knetdev_init(netdevice_t *netdev)
{
/* Called in response to register_netdev */
/* This is usually the probe function, but the probe has */
@@ -174,7 +171,7 @@ static struct net_device_stats *p80211knetdev_get_stats(netdevice_t * netdev)
* Returns:
* zero on success, non-zero otherwise
----------------------------------------------------------------*/
-static int p80211knetdev_open(netdevice_t * netdev)
+static int p80211knetdev_open(netdevice_t *netdev)
{
int result = 0; /* success */
wlandevice_t *wlandev = netdev->ml_priv;
@@ -209,7 +206,7 @@ static int p80211knetdev_open(netdevice_t * netdev)
* Returns:
* zero on success, non-zero otherwise
----------------------------------------------------------------*/
-static int p80211knetdev_stop(netdevice_t * netdev)
+static int p80211knetdev_stop(netdevice_t *netdev)
{
int result = 0;
wlandevice_t *wlandev = netdev->ml_priv;
@@ -236,7 +233,7 @@ static int p80211knetdev_stop(netdevice_t * netdev)
* Side effects:
*
----------------------------------------------------------------*/
-void p80211netdev_rx(wlandevice_t * wlandev, struct sk_buff *skb)
+void p80211netdev_rx(wlandevice_t *wlandev, struct sk_buff *skb)
{
/* Enqueue for post-irq processing */
skb_queue_tail(&wlandev->nsd_rxq, skb);
@@ -345,7 +342,7 @@ static void p80211netdev_rx_bh(unsigned long arg)
* zero on success, non-zero on failure.
----------------------------------------------------------------*/
static int p80211knetdev_hard_start_xmit(struct sk_buff *skb,
- netdevice_t * netdev)
+ netdevice_t *netdev)
{
int result = 0;
int txresult = -1;
@@ -451,7 +448,7 @@ static int p80211knetdev_hard_start_xmit(struct sk_buff *skb,
failed:
/* Free up the WEP buffer if it's not the same as the skb */
if ((p80211_wep.data) && (p80211_wep.data != skb->data))
- kfree(p80211_wep.data);
+ kzfree(p80211_wep.data);
/* we always free the skb here, never in a lower level. */
if (!result)
@@ -472,7 +469,7 @@ failed:
* Returns:
* nothing
----------------------------------------------------------------*/
-static void p80211knetdev_set_multicast_list(netdevice_t * dev)
+static void p80211knetdev_set_multicast_list(netdevice_t *dev)
{
wlandevice_t *wlandev = dev->ml_priv;
@@ -485,7 +482,7 @@ static void p80211knetdev_set_multicast_list(netdevice_t * dev)
#ifdef SIOCETHTOOL
-static int p80211netdev_ethtool(wlandevice_t * wlandev, void __user * useraddr)
+static int p80211netdev_ethtool(wlandevice_t *wlandev, void __user *useraddr)
{
u32 ethcmd;
struct ethtool_drvinfo info;
@@ -557,7 +554,7 @@ static int p80211netdev_ethtool(wlandevice_t * wlandev, void __user * useraddr)
* Process thread (ioctl caller). TODO: SMP support may require
* locks.
----------------------------------------------------------------*/
-static int p80211knetdev_do_ioctl(netdevice_t * dev, struct ifreq *ifr, int cmd)
+static int p80211knetdev_do_ioctl(netdevice_t *dev, struct ifreq *ifr, int cmd)
{
int result = 0;
p80211ioctl_req_t *req = (p80211ioctl_req_t *) ifr;
@@ -634,7 +631,7 @@ bail:
*
* by: Collin R. Mulliner <collin@mulliner.org>
----------------------------------------------------------------*/
-static int p80211knetdev_set_mac_address(netdevice_t * dev, void *addr)
+static int p80211knetdev_set_mac_address(netdevice_t *dev, void *addr)
{
struct sockaddr *new_addr = addr;
p80211msg_dot11req_mibset_t dot11req;
@@ -694,7 +691,7 @@ static int p80211knetdev_set_mac_address(netdevice_t * dev, void *addr)
return result;
}
-static int wlan_change_mtu(netdevice_t * dev, int new_mtu)
+static int wlan_change_mtu(netdevice_t *dev, int new_mtu)
{
/* 2312 is max 802.11 payload, 20 is overhead, (ether + llc +snap)
and another 8 for wep. */
@@ -742,7 +739,7 @@ static const struct net_device_ops p80211_netdev_ops = {
* compiled drivers, this function will be called in the
* context of the kernel startup code.
----------------------------------------------------------------*/
-int wlan_setup(wlandevice_t * wlandev)
+int wlan_setup(wlandevice_t *wlandev)
{
int result = 0;
netdevice_t *dev;
@@ -767,9 +764,6 @@ int wlan_setup(wlandevice_t * wlandev)
dev->ml_priv = wlandev;
dev->netdev_ops = &p80211_netdev_ops;
-#if (WIRELESS_EXT < 21)
- dev->get_wireless_stats = p80211wext_get_wireless_stats;
-#endif
dev->wireless_handlers = &p80211wext_handler_def;
netif_stop_queue(dev);
@@ -800,7 +794,7 @@ int wlan_setup(wlandevice_t * wlandev)
* compiled drivers, this function will be called in the
* context of the kernel startup code.
----------------------------------------------------------------*/
-int wlan_unsetup(wlandevice_t * wlandev)
+int wlan_unsetup(wlandevice_t *wlandev)
{
int result = 0;
@@ -836,7 +830,7 @@ int wlan_unsetup(wlandevice_t * wlandev)
* Call Context:
* Can be either interrupt or not.
----------------------------------------------------------------*/
-int register_wlandev(wlandevice_t * wlandev)
+int register_wlandev(wlandevice_t *wlandev)
{
int i = 0;
@@ -864,7 +858,7 @@ int register_wlandev(wlandevice_t * wlandev)
* Call Context:
* Can be either interrupt or not.
----------------------------------------------------------------*/
-int unregister_wlandev(wlandevice_t * wlandev)
+int unregister_wlandev(wlandevice_t *wlandev)
{
struct sk_buff *skb;
@@ -907,7 +901,7 @@ int unregister_wlandev(wlandevice_t * wlandev)
* Call context:
* Usually interrupt.
----------------------------------------------------------------*/
-void p80211netdev_hwremoved(wlandevice_t * wlandev)
+void p80211netdev_hwremoved(wlandevice_t *wlandev)
{
wlandev->hwremoved = 1;
if (wlandev->state == WLAN_DEVICE_OPEN)
@@ -937,7 +931,7 @@ void p80211netdev_hwremoved(wlandevice_t * wlandev)
* Call context:
* interrupt
----------------------------------------------------------------*/
-static int p80211_rx_typedrop(wlandevice_t * wlandev, u16 fc)
+static int p80211_rx_typedrop(wlandevice_t *wlandev, u16 fc)
{
u16 ftype;
u16 fstype;
@@ -1095,7 +1089,7 @@ static int p80211_rx_typedrop(wlandevice_t * wlandev, u16 fc)
return drop;
}
-static void p80211knetdev_tx_timeout(netdevice_t * netdev)
+static void p80211knetdev_tx_timeout(netdevice_t *netdev)
{
wlandevice_t *wlandev = netdev->ml_priv;
diff --git a/drivers/staging/wlan-ng/p80211netdev.h b/drivers/staging/wlan-ng/p80211netdev.h
index f4fcd2b11c47..8bd9dfb3b9b4 100644
--- a/drivers/staging/wlan-ng/p80211netdev.h
+++ b/drivers/staging/wlan-ng/p80211netdev.h
@@ -57,9 +57,6 @@
#include <linux/wireless.h>
#include <linux/netdevice.h>
-/*================================================================*/
-/* Constants */
-
#undef netdevice_t
typedef struct net_device netdevice_t;
diff --git a/drivers/staging/wlan-ng/p80211req.c b/drivers/staging/wlan-ng/p80211req.c
index 584c4193ad84..c88156cdf681 100644
--- a/drivers/staging/wlan-ng/p80211req.c
+++ b/drivers/staging/wlan-ng/p80211req.c
@@ -73,9 +73,9 @@
#include "p80211metastruct.h"
#include "p80211req.h"
-static void p80211req_handlemsg(wlandevice_t * wlandev, p80211msg_t * msg);
-static int p80211req_mibset_mibget(wlandevice_t * wlandev,
- p80211msg_dot11req_mibget_t * mib_msg,
+static void p80211req_handlemsg(wlandevice_t *wlandev, p80211msg_t *msg);
+static int p80211req_mibset_mibget(wlandevice_t *wlandev,
+ p80211msg_dot11req_mibget_t *mib_msg,
int isget);
/*----------------------------------------------------------------
@@ -150,7 +150,7 @@ int p80211req_dorequest(wlandevice_t * wlandev, u8 * msgbuf)
* Call context:
* Process thread
----------------------------------------------------------------*/
-static void p80211req_handlemsg(wlandevice_t * wlandev, p80211msg_t * msg)
+static void p80211req_handlemsg(wlandevice_t *wlandev, p80211msg_t *msg)
{
switch (msg->msgcode) {
@@ -180,8 +180,8 @@ static void p80211req_handlemsg(wlandevice_t * wlandev, p80211msg_t * msg)
return;
}
-static int p80211req_mibset_mibget(wlandevice_t * wlandev,
- p80211msg_dot11req_mibget_t * mib_msg,
+static int p80211req_mibset_mibget(wlandevice_t *wlandev,
+ p80211msg_dot11req_mibget_t *mib_msg,
int isget)
{
p80211itemd_t *mibitem = (p80211itemd_t *) mib_msg->mibattribute.data;
diff --git a/drivers/staging/wlan-ng/p80211types.h b/drivers/staging/wlan-ng/p80211types.h
index 043da1e5607f..2b83ab0c711b 100644
--- a/drivers/staging/wlan-ng/p80211types.h
+++ b/drivers/staging/wlan-ng/p80211types.h
@@ -57,10 +57,6 @@
#ifndef _P80211TYPES_H
#define _P80211TYPES_H
-/*================================================================*/
-/* Project Includes */
-/*================================================================*/
-
/*----------------------------------------------------------------*/
/* The following constants are indexes into the Mib Category List */
/* and the Message Category List */
diff --git a/drivers/staging/wlan-ng/p80211wep.c b/drivers/staging/wlan-ng/p80211wep.c
index f0b4275ab228..ecbb15b297ae 100644
--- a/drivers/staging/wlan-ng/p80211wep.c
+++ b/drivers/staging/wlan-ng/p80211wep.c
@@ -54,10 +54,7 @@
#include <linux/random.h>
#include <linux/kernel.h>
-// #define WEP_DEBUG
-
-/*================================================================*/
-/* Project Includes */
+/* #define WEP_DEBUG */
#include "p80211hdr.h"
#include "p80211types.h"
@@ -65,14 +62,8 @@
#include "p80211conv.h"
#include "p80211netdev.h"
-/*================================================================*/
-/* Local Constants */
-
#define WEP_KEY(x) (((x) & 0xC0) >> 6)
-/*================================================================*/
-/* Local Static Definitions */
-
static const u32 wep_crc32_table[256] = {
0x00000000L, 0x77073096L, 0xee0e612cL, 0x990951baL, 0x076dc419L,
0x706af48fL, 0xe963a535L, 0x9e6495a3L, 0x0edb8832L, 0x79dcb8a4L,
@@ -128,15 +119,9 @@ static const u32 wep_crc32_table[256] = {
0x2d02ef8dL
};
-/*================================================================*/
-/* Local Function Declarations */
-
-/*================================================================*/
-/* Function Definitions */
-
/* keylen in bytes! */
-int wep_change_key(wlandevice_t * wlandev, int keynum, u8 * key, int keylen)
+int wep_change_key(wlandevice_t *wlandev, int keynum, u8 *key, int keylen)
{
if (keylen < 0)
return -1;
@@ -166,8 +151,8 @@ int wep_change_key(wlandevice_t * wlandev, int keynum, u8 * key, int keylen)
4-byte IV at start of buffer, 4-byte ICV at end of buffer.
if successful, buf start is payload begin, length -= 8;
*/
-int wep_decrypt(wlandevice_t * wlandev, u8 * buf, u32 len, int key_override,
- u8 * iv, u8 * icv)
+int wep_decrypt(wlandevice_t *wlandev, u8 *buf, u32 len, int key_override,
+ u8 *iv, u8 *icv)
{
u32 i, j, k, crc, keylen;
u8 s[256], key[64], c_crc[4];
@@ -245,8 +230,8 @@ int wep_decrypt(wlandevice_t * wlandev, u8 * buf, u32 len, int key_override,
}
/* encrypts in-place. */
-int wep_encrypt(wlandevice_t * wlandev, u8 * buf, u8 * dst, u32 len, int keynum,
- u8 * iv, u8 * icv)
+int wep_encrypt(wlandevice_t *wlandev, u8 *buf, u8 *dst, u32 len, int keynum,
+ u8 *iv, u8 *icv)
{
u32 i, j, k, crc, keylen;
u8 s[256], key[64];
diff --git a/drivers/staging/wlan-ng/p80211wext.c b/drivers/staging/wlan-ng/p80211wext.c
index 984e45d9f700..74d8022adb24 100644
--- a/drivers/staging/wlan-ng/p80211wext.c
+++ b/drivers/staging/wlan-ng/p80211wext.c
@@ -52,9 +52,6 @@
#include <linux/if_ether.h>
#include <linux/bitops.h>
-/*================================================================*/
-/* Project Includes */
-
#include "p80211types.h"
#include "p80211hdr.h"
#include "p80211conv.h"
@@ -66,10 +63,10 @@
#include "p80211ioctl.h"
#include "p80211req.h"
-static int p80211wext_giwrate(netdevice_t * dev,
+static int p80211wext_giwrate(netdevice_t *dev,
struct iw_request_info *info,
struct iw_param *rrq, char *extra);
-static int p80211wext_giwessid(netdevice_t * dev,
+static int p80211wext_giwessid(netdevice_t *dev,
struct iw_request_info *info,
struct iw_point *data, char *essid);
@@ -130,7 +127,7 @@ static int qual_as_percent(int snr)
return 100;
}
-static int p80211wext_dorequest(wlandevice_t * wlandev, u32 did, u32 data)
+static int p80211wext_dorequest(wlandevice_t *wlandev, u32 did, u32 data)
{
p80211msg_dot11req_mibset_t msg;
p80211item_uint32_t mibitem;
@@ -145,7 +142,7 @@ static int p80211wext_dorequest(wlandevice_t * wlandev, u32 did, u32 data)
return result;
}
-static int p80211wext_autojoin(wlandevice_t * wlandev)
+static int p80211wext_autojoin(wlandevice_t *wlandev)
{
p80211msg_lnxreq_autojoin_t msg;
struct iw_point data;
@@ -191,7 +188,7 @@ exit:
}
/* called by /proc/net/wireless */
-struct iw_statistics *p80211wext_get_wireless_stats(netdevice_t * dev)
+struct iw_statistics *p80211wext_get_wireless_stats(netdevice_t *dev)
{
p80211msg_lnxreq_commsquality_t quality;
wlandevice_t *wlandev = dev->ml_priv;
@@ -232,7 +229,7 @@ struct iw_statistics *p80211wext_get_wireless_stats(netdevice_t * dev)
return wstats;
}
-static int p80211wext_giwname(netdevice_t * dev,
+static int p80211wext_giwname(netdevice_t *dev,
struct iw_request_info *info,
char *name, char *extra)
{
@@ -261,7 +258,7 @@ exit:
return err;
}
-static int p80211wext_giwfreq(netdevice_t * dev,
+static int p80211wext_giwfreq(netdevice_t *dev,
struct iw_request_info *info,
struct iw_freq *freq, char *extra)
{
@@ -296,7 +293,7 @@ exit:
return err;
}
-static int p80211wext_siwfreq(netdevice_t * dev,
+static int p80211wext_siwfreq(netdevice_t *dev,
struct iw_request_info *info,
struct iw_freq *freq, char *extra)
{
@@ -332,9 +329,9 @@ exit:
return err;
}
-static int p80211wext_giwmode(netdevice_t * dev,
+static int p80211wext_giwmode(netdevice_t *dev,
struct iw_request_info *info,
- __u32 * mode, char *extra)
+ __u32 *mode, char *extra)
{
wlandevice_t *wlandev = dev->ml_priv;
@@ -356,9 +353,9 @@ static int p80211wext_giwmode(netdevice_t * dev,
return 0;
}
-static int p80211wext_siwmode(netdevice_t * dev,
+static int p80211wext_siwmode(netdevice_t *dev,
struct iw_request_info *info,
- __u32 * mode, char *extra)
+ __u32 *mode, char *extra)
{
wlandevice_t *wlandev = dev->ml_priv;
p80211item_uint32_t mibitem;
@@ -411,7 +408,7 @@ exit:
return err;
}
-static int p80211wext_giwrange(netdevice_t * dev,
+static int p80211wext_giwrange(netdevice_t *dev,
struct iw_request_info *info,
struct iw_point *data, char *extra)
{
@@ -480,7 +477,7 @@ static int p80211wext_giwrange(netdevice_t * dev,
return 0;
}
-static int p80211wext_giwap(netdevice_t * dev,
+static int p80211wext_giwap(netdevice_t *dev,
struct iw_request_info *info,
struct sockaddr *ap_addr, char *extra)
{
@@ -493,7 +490,7 @@ static int p80211wext_giwap(netdevice_t * dev,
return 0;
}
-static int p80211wext_giwencode(netdevice_t * dev,
+static int p80211wext_giwencode(netdevice_t *dev,
struct iw_request_info *info,
struct iw_point *erq, char *key)
{
@@ -534,7 +531,7 @@ exit:
return err;
}
-static int p80211wext_siwencode(netdevice_t * dev,
+static int p80211wext_siwencode(netdevice_t *dev,
struct iw_request_info *info,
struct iw_point *erq, char *key)
{
@@ -681,7 +678,7 @@ exit:
return err;
}
-static int p80211wext_giwessid(netdevice_t * dev,
+static int p80211wext_giwessid(netdevice_t *dev,
struct iw_request_info *info,
struct iw_point *data, char *essid)
{
@@ -692,9 +689,6 @@ static int p80211wext_giwessid(netdevice_t * dev,
data->flags = 1;
memcpy(essid, wlandev->ssid.data, data->length);
essid[data->length] = 0;
-#if (WIRELESS_EXT < 21)
- data->length++;
-#endif
} else {
memset(essid, 0, sizeof(wlandev->ssid.data));
data->length = 0;
@@ -704,7 +698,7 @@ static int p80211wext_giwessid(netdevice_t * dev,
return 0;
}
-static int p80211wext_siwessid(netdevice_t * dev,
+static int p80211wext_siwessid(netdevice_t *dev,
struct iw_request_info *info,
struct iw_point *data, char *essid)
{
@@ -727,11 +721,6 @@ static int p80211wext_siwessid(netdevice_t * dev,
msg.msgcode = DIDmsg_lnxreq_autojoin;
-#if (WIRELESS_EXT < 21)
- if (length)
- length--;
-#endif
-
/* Trim the last '\0' to fit the SSID format */
if (length && essid[length - 1] == '\0')
length--;
@@ -752,7 +741,7 @@ exit:
return err;
}
-static int p80211wext_siwcommit(netdevice_t * dev,
+static int p80211wext_siwcommit(netdevice_t *dev,
struct iw_request_info *info,
struct iw_point *data, char *essid)
{
@@ -771,7 +760,7 @@ exit:
return err;
}
-static int p80211wext_giwrate(netdevice_t * dev,
+static int p80211wext_giwrate(netdevice_t *dev,
struct iw_request_info *info,
struct iw_param *rrq, char *extra)
{
@@ -822,7 +811,7 @@ exit:
return err;
}
-static int p80211wext_giwrts(netdevice_t * dev,
+static int p80211wext_giwrts(netdevice_t *dev,
struct iw_request_info *info,
struct iw_param *rts, char *extra)
{
@@ -852,7 +841,7 @@ exit:
return err;
}
-static int p80211wext_siwrts(netdevice_t * dev,
+static int p80211wext_siwrts(netdevice_t *dev,
struct iw_request_info *info,
struct iw_param *rts, char *extra)
{
@@ -886,7 +875,7 @@ exit:
return err;
}
-static int p80211wext_giwfrag(netdevice_t * dev,
+static int p80211wext_giwfrag(netdevice_t *dev,
struct iw_request_info *info,
struct iw_param *frag, char *extra)
{
@@ -917,7 +906,7 @@ exit:
return err;
}
-static int p80211wext_siwfrag(netdevice_t * dev,
+static int p80211wext_siwfrag(netdevice_t *dev,
struct iw_request_info *info,
struct iw_param *frag, char *extra)
{
@@ -961,7 +950,7 @@ exit:
#define IW_RETRY_SHORT IW_RETRY_MIN
#endif
-static int p80211wext_giwretry(netdevice_t * dev,
+static int p80211wext_giwretry(netdevice_t *dev,
struct iw_request_info *info,
struct iw_param *rrq, char *extra)
{
@@ -1038,7 +1027,7 @@ exit:
}
-static int p80211wext_siwretry(netdevice_t * dev,
+static int p80211wext_siwretry(netdevice_t *dev,
struct iw_request_info *info,
struct iw_param *rrq, char *extra)
{
@@ -1109,7 +1098,7 @@ exit:
}
-static int p80211wext_siwtxpow(netdevice_t * dev,
+static int p80211wext_siwtxpow(netdevice_t *dev,
struct iw_request_info *info,
struct iw_param *rrq, char *extra)
{
@@ -1143,7 +1132,7 @@ exit:
return err;
}
-static int p80211wext_giwtxpow(netdevice_t * dev,
+static int p80211wext_giwtxpow(netdevice_t *dev,
struct iw_request_info *info,
struct iw_param *rrq, char *extra)
{
@@ -1178,7 +1167,7 @@ exit:
return err;
}
-static int p80211wext_siwspy(netdevice_t * dev,
+static int p80211wext_siwspy(netdevice_t *dev,
struct iw_request_info *info,
struct iw_point *srq, char *extra)
{
@@ -1213,7 +1202,7 @@ static int p80211wext_siwspy(netdevice_t * dev,
}
/* jkriegl: from orinoco, modified */
-static int p80211wext_giwspy(netdevice_t * dev,
+static int p80211wext_giwspy(netdevice_t *dev,
struct iw_request_info *info,
struct iw_point *srq, char *extra)
{
@@ -1273,7 +1262,7 @@ static int prism2_result2err(int prism2_result)
return err;
}
-static int p80211wext_siwscan(netdevice_t * dev,
+static int p80211wext_siwscan(netdevice_t *dev,
struct iw_request_info *info,
struct iw_point *srq, char *extra)
{
@@ -1320,7 +1309,7 @@ exit:
*/
static char *wext_translate_bss(struct iw_request_info *info, char *current_ev,
char *end_buf,
- p80211msg_dot11req_scan_results_t * bss)
+ p80211msg_dot11req_scan_results_t *bss)
{
struct iw_event iwe; /* Temporary buffer */
@@ -1404,7 +1393,7 @@ static char *wext_translate_bss(struct iw_request_info *info, char *current_ev,
return current_ev;
}
-static int p80211wext_giwscan(netdevice_t * dev,
+static int p80211wext_giwscan(netdevice_t *dev,
struct iw_request_info *info,
struct iw_point *srq, char *extra)
{
diff --git a/drivers/staging/wlan-ng/prism2fw.c b/drivers/staging/wlan-ng/prism2fw.c
index 608b234b6a44..c62b4759b3da 100644
--- a/drivers/staging/wlan-ng/prism2fw.c
+++ b/drivers/staging/wlan-ng/prism2fw.c
@@ -177,19 +177,19 @@ typedef struct imgchunk {
/* s-record image processing */
/* Data records */
-unsigned int ns3data = 0;
+unsigned int ns3data;
s3datarec_t s3data[S3DATA_MAX];
/* Plug records */
-unsigned int ns3plug = 0;
+unsigned int ns3plug;
s3plugrec_t s3plug[S3PLUG_MAX];
/* CRC records */
-unsigned int ns3crc = 0;
+unsigned int ns3crc;
s3crcrec_t s3crc[S3CRC_MAX];
/* Info records */
-unsigned int ns3info = 0;
+unsigned int ns3info;
s3inforec_t s3info[S3INFO_MAX];
/* S7 record (there _better_ be only one) */
@@ -216,17 +216,17 @@ hfa384x_caplevel_t priid;
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 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,
+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_chunks(imgchunk_t *fchunk, unsigned int *nfchunks);
void free_srecs(void);
int validate_identity(void);
@@ -247,7 +247,7 @@ int validate_identity(void);
* 0 - success
* ~0 - failure
----------------------------------------------------------------*/
-int prism2_fwtry(struct usb_device *udev, wlandevice_t * wlandev)
+int prism2_fwtry(struct usb_device *udev, wlandevice_t *wlandev)
{
const struct firmware *fw_entry = NULL;
@@ -283,7 +283,7 @@ int prism2_fwtry(struct usb_device *udev, wlandevice_t * wlandev)
* 0 - success
* ~0 - failure
----------------------------------------------------------------*/
-int prism2_fwapply(char *rfptr, int rfsize, wlandevice_t * wlandev)
+int prism2_fwapply(char *rfptr, int rfsize, wlandevice_t *wlandev)
{
signed int result = 0;
p80211msg_dot11req_mibget_t getmsg;
@@ -425,7 +425,7 @@ int prism2_fwapply(char *rfptr, int rfsize, wlandevice_t * wlandev)
* 0 success
* ~0 failure
----------------------------------------------------------------*/
-int crcimage(imgchunk_t * fchunk, unsigned int nfchunks, s3crcrec_t * s3crc,
+int crcimage(imgchunk_t *fchunk, unsigned int nfchunks, s3crcrec_t *s3crc,
unsigned int ns3crc)
{
int result = 0;
@@ -490,7 +490,7 @@ int crcimage(imgchunk_t * fchunk, unsigned int nfchunks, s3crcrec_t * s3crc,
* Returns:
* nothing
----------------------------------------------------------------*/
-void free_chunks(imgchunk_t * fchunk, unsigned int *nfchunks)
+void free_chunks(imgchunk_t *fchunk, unsigned int *nfchunks)
{
int i;
for (i = 0; i < *nfchunks; i++) {
@@ -545,7 +545,7 @@ void free_srecs(void)
* 0 - success
* ~0 - failure (probably an errno)
----------------------------------------------------------------*/
-int mkimage(imgchunk_t * clist, unsigned int *ccnt)
+int mkimage(imgchunk_t *clist, unsigned int *ccnt)
{
int result = 0;
int i;
@@ -644,7 +644,7 @@ int mkimage(imgchunk_t * clist, unsigned int *ccnt)
* 0 - success
* ~0 - failure (probably an errno)
----------------------------------------------------------------*/
-int mkpdrlist(pda_t * pda)
+int mkpdrlist(pda_t *pda)
{
int result = 0;
u16 *pda16 = (u16 *) pda->buf;
@@ -717,8 +717,8 @@ int mkpdrlist(pda_t * pda)
* 0 success
* ~0 failure
----------------------------------------------------------------*/
-int plugimage(imgchunk_t * fchunk, unsigned int nfchunks,
- s3plugrec_t * s3plug, unsigned int ns3plug, pda_t * pda)
+int plugimage(imgchunk_t *fchunk, unsigned int nfchunks,
+ s3plugrec_t *s3plug, unsigned int ns3plug, pda_t * pda)
{
int result = 0;
int i; /* plug index */
@@ -825,7 +825,7 @@ int plugimage(imgchunk_t * fchunk, unsigned int nfchunks,
* 0 - success
* ~0 - failure (probably an errno)
----------------------------------------------------------------*/
-int read_cardpda(pda_t * pda, wlandevice_t * wlandev)
+int read_cardpda(pda_t *pda, wlandevice_t *wlandev)
{
int result = 0;
p80211msg_p2req_readpda_t msg;
@@ -1175,7 +1175,7 @@ int s3datarec_compare(const void *p1, const void *p2)
* 0 success
* ~0 failure
----------------------------------------------------------------*/
-int writeimage(wlandevice_t * wlandev, imgchunk_t * fchunk,
+int writeimage(wlandevice_t *wlandev, imgchunk_t *fchunk,
unsigned int nfchunks)
{
int result = 0;
diff --git a/drivers/staging/wlan-ng/prism2mgmt.c b/drivers/staging/wlan-ng/prism2mgmt.c
index 465457653eb3..9f7d96cae8e3 100644
--- a/drivers/staging/wlan-ng/prism2mgmt.c
+++ b/drivers/staging/wlan-ng/prism2mgmt.c
@@ -73,9 +73,6 @@
#include <linux/usb.h>
#include <linux/bitops.h>
-/*================================================================*/
-/* Project Includes */
-
#include "p80211types.h"
#include "p80211hdr.h"
#include "p80211mgmt.h"
@@ -117,7 +114,7 @@
* process thread (usually)
* interrupt
----------------------------------------------------------------*/
-int prism2mgmt_scan(wlandevice_t * wlandev, void *msgp)
+int prism2mgmt_scan(wlandevice_t *wlandev, void *msgp)
{
int result = 0;
hfa384x_t *hw = wlandev->priv;
@@ -362,7 +359,7 @@ exit:
* process thread (usually)
* interrupt
----------------------------------------------------------------*/
-int prism2mgmt_scan_results(wlandevice_t * wlandev, void *msgp)
+int prism2mgmt_scan_results(wlandevice_t *wlandev, void *msgp)
{
int result = 0;
p80211msg_dot11req_scan_results_t *req;
@@ -511,7 +508,7 @@ exit:
* process thread (usually)
* interrupt
----------------------------------------------------------------*/
-int prism2mgmt_start(wlandevice_t * wlandev, void *msgp)
+int prism2mgmt_start(wlandevice_t *wlandev, void *msgp)
{
int result = 0;
hfa384x_t *hw = wlandev->priv;
@@ -688,7 +685,7 @@ done:
* Call context:
* process thread (usually)
----------------------------------------------------------------*/
-int prism2mgmt_readpda(wlandevice_t * wlandev, void *msgp)
+int prism2mgmt_readpda(wlandevice_t *wlandev, void *msgp)
{
hfa384x_t *hw = wlandev->priv;
p80211msg_p2req_readpda_t *msg = msgp;
@@ -754,7 +751,7 @@ int prism2mgmt_readpda(wlandevice_t * wlandev, void *msgp)
* Call context:
* process thread (usually)
----------------------------------------------------------------*/
-int prism2mgmt_ramdl_state(wlandevice_t * wlandev, void *msgp)
+int prism2mgmt_ramdl_state(wlandevice_t *wlandev, void *msgp)
{
hfa384x_t *hw = wlandev->priv;
p80211msg_p2req_ramdl_state_t *msg = msgp;
@@ -810,7 +807,7 @@ int prism2mgmt_ramdl_state(wlandevice_t * wlandev, void *msgp)
* Call context:
* process thread (usually)
----------------------------------------------------------------*/
-int prism2mgmt_ramdl_write(wlandevice_t * wlandev, void *msgp)
+int prism2mgmt_ramdl_write(wlandevice_t *wlandev, void *msgp)
{
hfa384x_t *hw = wlandev->priv;
p80211msg_p2req_ramdl_write_t *msg = msgp;
@@ -872,7 +869,7 @@ int prism2mgmt_ramdl_write(wlandevice_t * wlandev, void *msgp)
* Call context:
* process thread (usually)
----------------------------------------------------------------*/
-int prism2mgmt_flashdl_state(wlandevice_t * wlandev, void *msgp)
+int prism2mgmt_flashdl_state(wlandevice_t *wlandev, void *msgp)
{
int result = 0;
hfa384x_t *hw = wlandev->priv;
@@ -943,7 +940,7 @@ int prism2mgmt_flashdl_state(wlandevice_t * wlandev, void *msgp)
* Call context:
* process thread (usually)
----------------------------------------------------------------*/
-int prism2mgmt_flashdl_write(wlandevice_t * wlandev, void *msgp)
+int prism2mgmt_flashdl_write(wlandevice_t *wlandev, void *msgp)
{
hfa384x_t *hw = wlandev->priv;
p80211msg_p2req_flashdl_write_t *msg = msgp;
@@ -1004,7 +1001,7 @@ int prism2mgmt_flashdl_write(wlandevice_t * wlandev, void *msgp)
* process thread (usually)
* interrupt
----------------------------------------------------------------*/
-int prism2mgmt_autojoin(wlandevice_t * wlandev, void *msgp)
+int prism2mgmt_autojoin(wlandevice_t *wlandev, void *msgp)
{
hfa384x_t *hw = wlandev->priv;
int result = 0;
@@ -1075,7 +1072,7 @@ int prism2mgmt_autojoin(wlandevice_t * wlandev, void *msgp)
* process thread (usually)
* interrupt
----------------------------------------------------------------*/
-int prism2mgmt_wlansniff(wlandevice_t * wlandev, void *msgp)
+int prism2mgmt_wlansniff(wlandevice_t *wlandev, void *msgp)
{
int result = 0;
p80211msg_lnxreq_wlansniff_t *msg = msgp;
diff --git a/drivers/staging/wlan-ng/prism2mib.c b/drivers/staging/wlan-ng/prism2mib.c
index f930254e1b34..2fff0a110bcb 100644
--- a/drivers/staging/wlan-ng/prism2mib.c
+++ b/drivers/staging/wlan-ng/prism2mib.c
@@ -86,65 +86,65 @@ typedef struct mibrec {
u16 parm1;
u16 parm2;
u16 parm3;
- int (*func) (struct mibrec * mib,
+ int (*func) (struct mibrec *mib,
int isget,
- wlandevice_t * wlandev,
- hfa384x_t * hw,
- p80211msg_dot11req_mibset_t * msg, void *data);
+ wlandevice_t *wlandev,
+ hfa384x_t *hw,
+ p80211msg_dot11req_mibset_t *msg, void *data);
} mibrec_t;
-static int prism2mib_bytearea2pstr(mibrec_t * mib,
+static int prism2mib_bytearea2pstr(mibrec_t *mib,
int isget,
- wlandevice_t * wlandev,
- hfa384x_t * hw,
- p80211msg_dot11req_mibset_t * msg,
+ wlandevice_t *wlandev,
+ hfa384x_t *hw,
+ p80211msg_dot11req_mibset_t *msg,
void *data);
-static int prism2mib_uint32(mibrec_t * mib,
+static int prism2mib_uint32(mibrec_t *mib,
int isget,
- wlandevice_t * wlandev,
- hfa384x_t * hw,
- p80211msg_dot11req_mibset_t * msg, void *data);
+ wlandevice_t *wlandev,
+ hfa384x_t *hw,
+ p80211msg_dot11req_mibset_t *msg, void *data);
-static int prism2mib_flag(mibrec_t * mib,
+static int prism2mib_flag(mibrec_t *mib,
int isget,
- wlandevice_t * wlandev,
- hfa384x_t * hw,
- p80211msg_dot11req_mibset_t * msg, void *data);
+ wlandevice_t *wlandev,
+ hfa384x_t *hw,
+ p80211msg_dot11req_mibset_t *msg, void *data);
-static int prism2mib_wepdefaultkey(mibrec_t * mib,
+static int prism2mib_wepdefaultkey(mibrec_t *mib,
int isget,
wlandevice_t * wlandev,
- hfa384x_t * hw,
- p80211msg_dot11req_mibset_t * msg,
+ hfa384x_t *hw,
+ p80211msg_dot11req_mibset_t *msg,
void *data);
-static int prism2mib_privacyinvoked(mibrec_t * mib,
+static int prism2mib_privacyinvoked(mibrec_t *mib,
int isget,
- wlandevice_t * wlandev,
- hfa384x_t * hw,
- p80211msg_dot11req_mibset_t * msg,
+ wlandevice_t *wlandev,
+ hfa384x_t *hw,
+ p80211msg_dot11req_mibset_t *msg,
void *data);
-static int prism2mib_excludeunencrypted(mibrec_t * mib,
+static int prism2mib_excludeunencrypted(mibrec_t *mib,
int isget,
- wlandevice_t * wlandev,
- hfa384x_t * hw,
- p80211msg_dot11req_mibset_t * msg,
+ wlandevice_t *wlandev,
+ hfa384x_t *hw,
+ p80211msg_dot11req_mibset_t *msg,
void *data);
-static int prism2mib_fragmentationthreshold(mibrec_t * mib,
+static int prism2mib_fragmentationthreshold(mibrec_t *mib,
int isget,
- wlandevice_t * wlandev,
- hfa384x_t * hw,
- p80211msg_dot11req_mibset_t * msg,
+ wlandevice_t *wlandev,
+ hfa384x_t *hw,
+ p80211msg_dot11req_mibset_t *msg,
void *data);
-static int prism2mib_priv(mibrec_t * mib,
+static int prism2mib_priv(mibrec_t *mib,
int isget,
- wlandevice_t * wlandev,
- hfa384x_t * hw,
- p80211msg_dot11req_mibset_t * msg, void *data);
+ wlandevice_t *wlandev,
+ hfa384x_t *hw,
+ p80211msg_dot11req_mibset_t *msg, void *data);
static mibrec_t mibtab[] = {
@@ -258,7 +258,7 @@ static mibrec_t mibtab[] = {
* interrupt
----------------------------------------------------------------*/
-int prism2mgmt_mibset_mibget(wlandevice_t * wlandev, void *msgp)
+int prism2mgmt_mibset_mibget(wlandevice_t *wlandev, void *msgp)
{
hfa384x_t *hw = wlandev->priv;
int result, isget;
@@ -372,11 +372,11 @@ done:
*
----------------------------------------------------------------*/
-static int prism2mib_bytearea2pstr(mibrec_t * mib,
+static int prism2mib_bytearea2pstr(mibrec_t *mib,
int isget,
- wlandevice_t * wlandev,
- hfa384x_t * hw,
- p80211msg_dot11req_mibset_t * msg,
+ wlandevice_t *wlandev,
+ hfa384x_t *hw,
+ p80211msg_dot11req_mibset_t *msg,
void *data)
{
int result;
@@ -422,11 +422,11 @@ static int prism2mib_bytearea2pstr(mibrec_t * mib,
*
----------------------------------------------------------------*/
-static int prism2mib_uint32(mibrec_t * mib,
+static int prism2mib_uint32(mibrec_t *mib,
int isget,
- wlandevice_t * wlandev,
- hfa384x_t * hw,
- p80211msg_dot11req_mibset_t * msg, void *data)
+ wlandevice_t *wlandev,
+ hfa384x_t *hw,
+ p80211msg_dot11req_mibset_t *msg, void *data)
{
int result;
u32 *uint32 = (u32 *) data;
@@ -469,11 +469,11 @@ static int prism2mib_uint32(mibrec_t * mib,
*
----------------------------------------------------------------*/
-static int prism2mib_flag(mibrec_t * mib,
+static int prism2mib_flag(mibrec_t *mib,
int isget,
- wlandevice_t * wlandev,
- hfa384x_t * hw,
- p80211msg_dot11req_mibset_t * msg, void *data)
+ wlandevice_t *wlandev,
+ hfa384x_t *hw,
+ p80211msg_dot11req_mibset_t *msg, void *data)
{
int result;
u32 *uint32 = (u32 *) data;
@@ -526,11 +526,11 @@ static int prism2mib_flag(mibrec_t * mib,
*
----------------------------------------------------------------*/
-static int prism2mib_wepdefaultkey(mibrec_t * mib,
+static int prism2mib_wepdefaultkey(mibrec_t *mib,
int isget,
- wlandevice_t * wlandev,
- hfa384x_t * hw,
- p80211msg_dot11req_mibset_t * msg,
+ wlandevice_t *wlandev,
+ hfa384x_t *hw,
+ p80211msg_dot11req_mibset_t *msg,
void *data)
{
int result;
@@ -576,11 +576,11 @@ static int prism2mib_wepdefaultkey(mibrec_t * mib,
*
----------------------------------------------------------------*/
-static int prism2mib_privacyinvoked(mibrec_t * mib,
+static int prism2mib_privacyinvoked(mibrec_t *mib,
int isget,
- wlandevice_t * wlandev,
- hfa384x_t * hw,
- p80211msg_dot11req_mibset_t * msg,
+ wlandevice_t *wlandev,
+ hfa384x_t *hw,
+ p80211msg_dot11req_mibset_t *msg,
void *data)
{
int result;
@@ -622,11 +622,11 @@ static int prism2mib_privacyinvoked(mibrec_t * mib,
*
----------------------------------------------------------------*/
-static int prism2mib_excludeunencrypted(mibrec_t * mib,
+static int prism2mib_excludeunencrypted(mibrec_t *mib,
int isget,
- wlandevice_t * wlandev,
- hfa384x_t * hw,
- p80211msg_dot11req_mibset_t * msg,
+ wlandevice_t *wlandev,
+ hfa384x_t *hw,
+ p80211msg_dot11req_mibset_t *msg,
void *data)
{
int result;
@@ -661,11 +661,11 @@ static int prism2mib_excludeunencrypted(mibrec_t * mib,
*
----------------------------------------------------------------*/
-static int prism2mib_fragmentationthreshold(mibrec_t * mib,
+static int prism2mib_fragmentationthreshold(mibrec_t *mib,
int isget,
- wlandevice_t * wlandev,
- hfa384x_t * hw,
- p80211msg_dot11req_mibset_t * msg,
+ wlandevice_t *wlandev,
+ hfa384x_t *hw,
+ p80211msg_dot11req_mibset_t *msg,
void *data)
{
int result;
@@ -710,11 +710,11 @@ static int prism2mib_fragmentationthreshold(mibrec_t * mib,
*
----------------------------------------------------------------*/
-static int prism2mib_priv(mibrec_t * mib,
+static int prism2mib_priv(mibrec_t *mib,
int isget,
- wlandevice_t * wlandev,
- hfa384x_t * hw,
- p80211msg_dot11req_mibset_t * msg, void *data)
+ wlandevice_t *wlandev,
+ hfa384x_t *hw,
+ p80211msg_dot11req_mibset_t *msg, void *data)
{
p80211pstrd_t *pstr = (p80211pstrd_t *) data;
@@ -764,7 +764,7 @@ static int prism2mib_priv(mibrec_t * mib,
*
----------------------------------------------------------------*/
-void prism2mgmt_pstr2bytestr(hfa384x_bytestr_t * bytestr, p80211pstrd_t * pstr)
+void prism2mgmt_pstr2bytestr(hfa384x_bytestr_t *bytestr, p80211pstrd_t *pstr)
{
bytestr->len = cpu_to_le16((u16) (pstr->len));
memcpy(bytestr->data, pstr->data, pstr->len);
@@ -785,7 +785,7 @@ void prism2mgmt_pstr2bytestr(hfa384x_bytestr_t * bytestr, p80211pstrd_t * pstr)
*
----------------------------------------------------------------*/
-void prism2mgmt_pstr2bytearea(u8 * bytearea, p80211pstrd_t * pstr)
+void prism2mgmt_pstr2bytearea(u8 *bytearea, p80211pstrd_t *pstr)
{
memcpy(bytearea, pstr->data, pstr->len);
}
@@ -805,7 +805,7 @@ void prism2mgmt_pstr2bytearea(u8 * bytearea, p80211pstrd_t * pstr)
*
----------------------------------------------------------------*/
-void prism2mgmt_bytestr2pstr(hfa384x_bytestr_t * bytestr, p80211pstrd_t * pstr)
+void prism2mgmt_bytestr2pstr(hfa384x_bytestr_t *bytestr, p80211pstrd_t *pstr)
{
pstr->len = (u8) (le16_to_cpu((u16) (bytestr->len)));
memcpy(pstr->data, bytestr->data, pstr->len);
@@ -826,7 +826,7 @@ void prism2mgmt_bytestr2pstr(hfa384x_bytestr_t * bytestr, p80211pstrd_t * pstr)
*
----------------------------------------------------------------*/
-void prism2mgmt_bytearea2pstr(u8 * bytearea, p80211pstrd_t * pstr, int len)
+void prism2mgmt_bytearea2pstr(u8 *bytearea, p80211pstrd_t *pstr, int len)
{
pstr->len = (u8) len;
memcpy(pstr->data, bytearea, len);
diff --git a/drivers/staging/wlan-ng/prism2sta.c b/drivers/staging/wlan-ng/prism2sta.c
index f493cf430db8..50f301d65212 100644
--- a/drivers/staging/wlan-ng/prism2sta.c
+++ b/drivers/staging/wlan-ng/prism2sta.c
@@ -71,9 +71,6 @@
#include <linux/if_ether.h>
#include <linux/bitops.h>
-/*================================================================*/
-/* Project Includes */
-
#include "p80211types.h"
#include "p80211hdr.h"
#include "p80211mgmt.h"
@@ -115,7 +112,7 @@ static wlandevice_t *create_wlan(void);
int prism2_reset_holdtime = 30; /* Reset hold time in ms */
int prism2_reset_settletime = 100; /* Reset settle time in ms */
-static int prism2_doreset = 0; /* Do a reset at init? */
+static int prism2_doreset; /* Do a reset at init? */
module_param(prism2_doreset, int, 0644);
MODULE_PARM_DESC(prism2_doreset, "Issue a reset on initialization");
@@ -127,37 +124,37 @@ MODULE_PARM_DESC(prism2_reset_settletime, "reset settle time in ms");
MODULE_LICENSE("Dual MPL/GPL");
-static int prism2sta_open(wlandevice_t * wlandev);
-static int prism2sta_close(wlandevice_t * wlandev);
-static void prism2sta_reset(wlandevice_t * wlandev);
-static int prism2sta_txframe(wlandevice_t * wlandev, struct sk_buff *skb,
- p80211_hdr_t * p80211_hdr,
- p80211_metawep_t * p80211_wep);
-static int prism2sta_mlmerequest(wlandevice_t * wlandev, p80211msg_t * msg);
-static int prism2sta_getcardinfo(wlandevice_t * wlandev);
-static int prism2sta_globalsetup(wlandevice_t * wlandev);
-static int prism2sta_setmulticast(wlandevice_t * wlandev, netdevice_t * dev);
-
-static void prism2sta_inf_handover(wlandevice_t * wlandev,
- hfa384x_InfFrame_t * inf);
-static void prism2sta_inf_tallies(wlandevice_t * wlandev,
- hfa384x_InfFrame_t * inf);
-static void prism2sta_inf_hostscanresults(wlandevice_t * wlandev,
- hfa384x_InfFrame_t * inf);
-static void prism2sta_inf_scanresults(wlandevice_t * wlandev,
- hfa384x_InfFrame_t * inf);
-static void prism2sta_inf_chinforesults(wlandevice_t * wlandev,
- hfa384x_InfFrame_t * inf);
-static void prism2sta_inf_linkstatus(wlandevice_t * wlandev,
- hfa384x_InfFrame_t * inf);
-static void prism2sta_inf_assocstatus(wlandevice_t * wlandev,
- hfa384x_InfFrame_t * inf);
-static void prism2sta_inf_authreq(wlandevice_t * wlandev,
- hfa384x_InfFrame_t * inf);
-static void prism2sta_inf_authreq_defer(wlandevice_t * wlandev,
- hfa384x_InfFrame_t * inf);
-static void prism2sta_inf_psusercnt(wlandevice_t * wlandev,
- hfa384x_InfFrame_t * inf);
+static int prism2sta_open(wlandevice_t *wlandev);
+static int prism2sta_close(wlandevice_t *wlandev);
+static void prism2sta_reset(wlandevice_t *wlandev);
+static int prism2sta_txframe(wlandevice_t *wlandev, struct sk_buff *skb,
+ p80211_hdr_t *p80211_hdr,
+ p80211_metawep_t *p80211_wep);
+static int prism2sta_mlmerequest(wlandevice_t *wlandev, p80211msg_t *msg);
+static int prism2sta_getcardinfo(wlandevice_t *wlandev);
+static int prism2sta_globalsetup(wlandevice_t *wlandev);
+static int prism2sta_setmulticast(wlandevice_t *wlandev, netdevice_t *dev);
+
+static void prism2sta_inf_handover(wlandevice_t *wlandev,
+ hfa384x_InfFrame_t *inf);
+static void prism2sta_inf_tallies(wlandevice_t *wlandev,
+ hfa384x_InfFrame_t *inf);
+static void prism2sta_inf_hostscanresults(wlandevice_t *wlandev,
+ hfa384x_InfFrame_t *inf);
+static void prism2sta_inf_scanresults(wlandevice_t *wlandev,
+ hfa384x_InfFrame_t *inf);
+static void prism2sta_inf_chinforesults(wlandevice_t *wlandev,
+ hfa384x_InfFrame_t *inf);
+static void prism2sta_inf_linkstatus(wlandevice_t *wlandev,
+ hfa384x_InfFrame_t *inf);
+static void prism2sta_inf_assocstatus(wlandevice_t *wlandev,
+ hfa384x_InfFrame_t *inf);
+static void prism2sta_inf_authreq(wlandevice_t *wlandev,
+ hfa384x_InfFrame_t *inf);
+static void prism2sta_inf_authreq_defer(wlandevice_t *wlandev,
+ hfa384x_InfFrame_t *inf);
+static void prism2sta_inf_psusercnt(wlandevice_t *wlandev,
+ hfa384x_InfFrame_t *inf);
/*----------------------------------------------------------------
* prism2sta_open
@@ -180,7 +177,7 @@ static void prism2sta_inf_psusercnt(wlandevice_t * wlandev,
* Call context:
* process thread
----------------------------------------------------------------*/
-static int prism2sta_open(wlandevice_t * wlandev)
+static int prism2sta_open(wlandevice_t *wlandev)
{
/* We don't currently have to do anything else.
* The setup of the MAC should be subsequently completed via
@@ -214,7 +211,7 @@ static int prism2sta_open(wlandevice_t * wlandev)
* Call context:
* process thread
----------------------------------------------------------------*/
-static int prism2sta_close(wlandevice_t * wlandev)
+static int prism2sta_close(wlandevice_t *wlandev)
{
/* We don't currently have to do anything else.
* Higher layers know we're not ready from dev->start==0 and
@@ -242,7 +239,7 @@ static int prism2sta_close(wlandevice_t * wlandev)
* Call context:
* process thread
----------------------------------------------------------------*/
-static void prism2sta_reset(wlandevice_t * wlandev)
+static void prism2sta_reset(wlandevice_t *wlandev)
{
return;
}
@@ -268,9 +265,9 @@ static void prism2sta_reset(wlandevice_t * wlandev)
* Call context:
* process thread
----------------------------------------------------------------*/
-static int prism2sta_txframe(wlandevice_t * wlandev, struct sk_buff *skb,
- p80211_hdr_t * p80211_hdr,
- p80211_metawep_t * p80211_wep)
+static int prism2sta_txframe(wlandevice_t *wlandev, struct sk_buff *skb,
+ p80211_hdr_t *p80211_hdr,
+ p80211_metawep_t *p80211_wep)
{
hfa384x_t *hw = (hfa384x_t *) wlandev->priv;
int result;
@@ -310,7 +307,7 @@ static int prism2sta_txframe(wlandevice_t * wlandev, struct sk_buff *skb,
* Call context:
* process thread
----------------------------------------------------------------*/
-static int prism2sta_mlmerequest(wlandevice_t * wlandev, p80211msg_t * msg)
+static int prism2sta_mlmerequest(wlandevice_t *wlandev, p80211msg_t *msg)
{
hfa384x_t *hw = (hfa384x_t *) wlandev->priv;
@@ -437,7 +434,7 @@ static int prism2sta_mlmerequest(wlandevice_t * wlandev, p80211msg_t * msg)
* process thread (usually)
* interrupt
----------------------------------------------------------------*/
-u32 prism2sta_ifstate(wlandevice_t * wlandev, u32 ifstate)
+u32 prism2sta_ifstate(wlandevice_t *wlandev, u32 ifstate)
{
hfa384x_t *hw = (hfa384x_t *) wlandev->priv;
u32 result;
@@ -455,7 +452,8 @@ u32 prism2sta_ifstate(wlandevice_t * wlandev, u32 ifstate)
* Initialize the device+driver sufficiently
* for firmware loading.
*/
- if ((result = hfa384x_drvr_start(hw))) {
+ result = hfa384x_drvr_start(hw);
+ if (result) {
printk(KERN_ERR
"hfa384x_drvr_start() failed,"
"result=%d\n", (int)result);
@@ -499,7 +497,8 @@ u32 prism2sta_ifstate(wlandevice_t * wlandev, u32 ifstate)
* can't make any assumptions about the state
* of the hardware or a previous firmware load.
*/
- if ((result = hfa384x_drvr_start(hw))) {
+ result = hfa384x_drvr_start(hw);
+ if (result) {
printk(KERN_ERR
"hfa384x_drvr_start() failed,"
"result=%d\n", (int)result);
@@ -509,7 +508,8 @@ u32 prism2sta_ifstate(wlandevice_t * wlandev, u32 ifstate)
break;
}
- if ((result = prism2sta_getcardinfo(wlandev))) {
+ result = prism2sta_getcardinfo(wlandev);
+ if (result) {
printk(KERN_ERR
"prism2sta_getcardinfo() failed,"
"result=%d\n", (int)result);
@@ -519,7 +519,8 @@ u32 prism2sta_ifstate(wlandevice_t * wlandev, u32 ifstate)
wlandev->msdstate = WLAN_MSD_HWPRESENT;
break;
}
- if ((result = prism2sta_globalsetup(wlandev))) {
+ result = prism2sta_globalsetup(wlandev);
+ if (result) {
printk(KERN_ERR
"prism2sta_globalsetup() failed,"
"result=%d\n", (int)result);
@@ -607,7 +608,7 @@ u32 prism2sta_ifstate(wlandevice_t * wlandev, u32 ifstate)
* Call context:
* Either.
----------------------------------------------------------------*/
-static int prism2sta_getcardinfo(wlandevice_t * wlandev)
+static int prism2sta_getcardinfo(wlandevice_t *wlandev)
{
int result = 0;
hfa384x_t *hw = (hfa384x_t *) wlandev->priv;
@@ -931,7 +932,7 @@ done:
* Call context:
* process thread
----------------------------------------------------------------*/
-static int prism2sta_globalsetup(wlandevice_t * wlandev)
+static int prism2sta_globalsetup(wlandevice_t *wlandev)
{
hfa384x_t *hw = (hfa384x_t *) wlandev->priv;
@@ -940,7 +941,7 @@ static int prism2sta_globalsetup(wlandevice_t * wlandev)
WLAN_DATA_MAXLEN);
}
-static int prism2sta_setmulticast(wlandevice_t * wlandev, netdevice_t * dev)
+static int prism2sta_setmulticast(wlandevice_t *wlandev, netdevice_t *dev)
{
int result = 0;
hfa384x_t *hw = (hfa384x_t *) wlandev->priv;
@@ -981,8 +982,8 @@ exit:
* Call context:
* interrupt
----------------------------------------------------------------*/
-static void prism2sta_inf_handover(wlandevice_t * wlandev,
- hfa384x_InfFrame_t * inf)
+static void prism2sta_inf_handover(wlandevice_t *wlandev,
+ hfa384x_InfFrame_t *inf)
{
pr_debug("received infoframe:HANDOVER (unhandled)\n");
return;
@@ -1005,8 +1006,8 @@ static void prism2sta_inf_handover(wlandevice_t * wlandev,
* Call context:
* interrupt
----------------------------------------------------------------*/
-static void prism2sta_inf_tallies(wlandevice_t * wlandev,
- hfa384x_InfFrame_t * inf)
+static void prism2sta_inf_tallies(wlandevice_t *wlandev,
+ hfa384x_InfFrame_t *inf)
{
hfa384x_t *hw = (hfa384x_t *) wlandev->priv;
u16 *src16;
@@ -1053,8 +1054,8 @@ static void prism2sta_inf_tallies(wlandevice_t * wlandev,
* Call context:
* interrupt
----------------------------------------------------------------*/
-static void prism2sta_inf_scanresults(wlandevice_t * wlandev,
- hfa384x_InfFrame_t * inf)
+static void prism2sta_inf_scanresults(wlandevice_t *wlandev,
+ hfa384x_InfFrame_t *inf)
{
hfa384x_t *hw = (hfa384x_t *) wlandev->priv;
@@ -1111,8 +1112,8 @@ static void prism2sta_inf_scanresults(wlandevice_t * wlandev,
* Call context:
* interrupt
----------------------------------------------------------------*/
-static void prism2sta_inf_hostscanresults(wlandevice_t * wlandev,
- hfa384x_InfFrame_t * inf)
+static void prism2sta_inf_hostscanresults(wlandevice_t *wlandev,
+ hfa384x_InfFrame_t *inf)
{
hfa384x_t *hw = (hfa384x_t *) wlandev->priv;
int nbss;
@@ -1153,8 +1154,8 @@ static void prism2sta_inf_hostscanresults(wlandevice_t * wlandev,
* Call context:
* interrupt
----------------------------------------------------------------*/
-static void prism2sta_inf_chinforesults(wlandevice_t * wlandev,
- hfa384x_InfFrame_t * inf)
+static void prism2sta_inf_chinforesults(wlandevice_t *wlandev,
+ hfa384x_InfFrame_t *inf)
{
hfa384x_t *hw = (hfa384x_t *) wlandev->priv;
unsigned int i, n;
@@ -1443,9 +1444,7 @@ void prism2sta_processing_defer(struct work_struct *data)
}
wlandev->linkstatus = (hw->link_status == HFA384x_LINK_CONNECTED);
-#ifdef WIRELESS_EXT
p80211wext_event_associated(wlandev, wlandev->linkstatus);
-#endif
failed:
return;
@@ -1468,8 +1467,8 @@ failed:
* Call context:
* interrupt
----------------------------------------------------------------*/
-static void prism2sta_inf_linkstatus(wlandevice_t * wlandev,
- hfa384x_InfFrame_t * inf)
+static void prism2sta_inf_linkstatus(wlandevice_t *wlandev,
+ hfa384x_InfFrame_t *inf)
{
hfa384x_t *hw = (hfa384x_t *) wlandev->priv;
@@ -1498,8 +1497,8 @@ static void prism2sta_inf_linkstatus(wlandevice_t * wlandev,
* Call context:
* interrupt
----------------------------------------------------------------*/
-static void prism2sta_inf_assocstatus(wlandevice_t * wlandev,
- hfa384x_InfFrame_t * inf)
+static void prism2sta_inf_assocstatus(wlandevice_t *wlandev,
+ hfa384x_InfFrame_t *inf)
{
hfa384x_t *hw = (hfa384x_t *) wlandev->priv;
hfa384x_AssocStatus_t rec;
@@ -1560,8 +1559,8 @@ static void prism2sta_inf_assocstatus(wlandevice_t * wlandev,
* interrupt
*
----------------------------------------------------------------*/
-static void prism2sta_inf_authreq(wlandevice_t * wlandev,
- hfa384x_InfFrame_t * inf)
+static void prism2sta_inf_authreq(wlandevice_t *wlandev,
+ hfa384x_InfFrame_t *inf)
{
hfa384x_t *hw = (hfa384x_t *) wlandev->priv;
struct sk_buff *skb;
@@ -1575,8 +1574,8 @@ static void prism2sta_inf_authreq(wlandevice_t * wlandev,
}
}
-static void prism2sta_inf_authreq_defer(wlandevice_t * wlandev,
- hfa384x_InfFrame_t * inf)
+static void prism2sta_inf_authreq_defer(wlandevice_t *wlandev,
+ hfa384x_InfFrame_t *inf)
{
hfa384x_t *hw = (hfa384x_t *) wlandev->priv;
hfa384x_authenticateStation_data_t rec;
@@ -1749,8 +1748,8 @@ static void prism2sta_inf_authreq_defer(wlandevice_t * wlandev,
* Call context:
* interrupt
----------------------------------------------------------------*/
-static void prism2sta_inf_psusercnt(wlandevice_t * wlandev,
- hfa384x_InfFrame_t * inf)
+static void prism2sta_inf_psusercnt(wlandevice_t *wlandev,
+ hfa384x_InfFrame_t *inf)
{
hfa384x_t *hw = (hfa384x_t *) wlandev->priv;
@@ -1776,7 +1775,7 @@ static void prism2sta_inf_psusercnt(wlandevice_t * wlandev,
* Call context:
* interrupt
----------------------------------------------------------------*/
-void prism2sta_ev_info(wlandevice_t * wlandev, hfa384x_InfFrame_t * inf)
+void prism2sta_ev_info(wlandevice_t *wlandev, hfa384x_InfFrame_t *inf)
{
inf->infotype = le16_to_cpu(inf->infotype);
/* Dispatch */
@@ -1844,7 +1843,7 @@ void prism2sta_ev_info(wlandevice_t * wlandev, hfa384x_InfFrame_t * inf)
* Call context:
* interrupt
----------------------------------------------------------------*/
-void prism2sta_ev_txexc(wlandevice_t * wlandev, u16 status)
+void prism2sta_ev_txexc(wlandevice_t *wlandev, u16 status)
{
pr_debug("TxExc status=0x%x.\n", status);
@@ -1867,7 +1866,7 @@ void prism2sta_ev_txexc(wlandevice_t * wlandev, u16 status)
* Call context:
* interrupt
----------------------------------------------------------------*/
-void prism2sta_ev_tx(wlandevice_t * wlandev, u16 status)
+void prism2sta_ev_tx(wlandevice_t *wlandev, u16 status)
{
pr_debug("Tx Complete, status=0x%04x\n", status);
/* update linux network stats */
@@ -1891,7 +1890,7 @@ void prism2sta_ev_tx(wlandevice_t * wlandev, u16 status)
* Call context:
* interrupt
----------------------------------------------------------------*/
-void prism2sta_ev_rx(wlandevice_t * wlandev, struct sk_buff *skb)
+void prism2sta_ev_rx(wlandevice_t *wlandev, struct sk_buff *skb)
{
p80211netdev_rx(wlandev, skb);
return;
@@ -1913,7 +1912,7 @@ void prism2sta_ev_rx(wlandevice_t * wlandev, struct sk_buff *skb)
* Call context:
* interrupt
----------------------------------------------------------------*/
-void prism2sta_ev_alloc(wlandevice_t * wlandev)
+void prism2sta_ev_alloc(wlandevice_t *wlandev)
{
netif_wake_queue(wlandev->netdev);
return;
diff --git a/drivers/staging/wlan-ng/prism2usb.c b/drivers/staging/wlan-ng/prism2usb.c
index 7aa703ce9dd4..9dde68be8d74 100644
--- a/drivers/staging/wlan-ng/prism2usb.c
+++ b/drivers/staging/wlan-ng/prism2usb.c
@@ -4,9 +4,9 @@
#include "prism2sta.c"
#include "prism2fw.c"
-#define PRISM_USB_DEVICE(vid, pid, name) \
- USB_DEVICE(vid, pid), \
- .driver_info = (unsigned long) name
+#define PRISM_USB_DEVICE(vid, pid, name) \
+ USB_DEVICE(vid, pid), \
+ .driver_info = (unsigned long) name
static struct usb_device_id usb_prism_tbl[] = {
{PRISM_USB_DEVICE(0x04bb, 0x0922, "IOData AirPort WN-B11/USBS")},
@@ -111,8 +111,8 @@ static int prism2sta_probe_usb(struct usb_interface *interface,
int result = 0;
dev = interface_to_usbdev(interface);
-
- if ((wlandev = create_wlan()) == NULL) {
+ wlandev = create_wlan();
+ if (wlandev == NULL) {
printk(KERN_ERR "%s: Memory allocation failure.\n", dev_info);
result = -EIO;
goto failed;