Bug Summary

File:dev/ic/rtw.c
Warning:line 2143, column 2
Value stored to 'txpower' is never read

Annotated Source Code

Press '?' to see keyboard shortcuts

clang -cc1 -cc1 -triple amd64-unknown-openbsd7.4 -analyze -disable-free -clear-ast-before-backend -disable-llvm-verifier -discard-value-names -main-file-name rtw.c -analyzer-checker=core -analyzer-checker=apiModeling -analyzer-checker=unix -analyzer-checker=deadcode -analyzer-checker=security.insecureAPI.UncheckedReturn -analyzer-checker=security.insecureAPI.getpw -analyzer-checker=security.insecureAPI.gets -analyzer-checker=security.insecureAPI.mktemp -analyzer-checker=security.insecureAPI.mkstemp -analyzer-checker=security.insecureAPI.vfork -analyzer-checker=nullability.NullPassedToNonnull -analyzer-checker=nullability.NullReturnedFromNonnull -analyzer-output plist -w -setup-static-analyzer -mrelocation-model static -mframe-pointer=all -relaxed-aliasing -ffp-contract=on -fno-rounding-math -mconstructor-aliases -ffreestanding -mcmodel=kernel -target-cpu x86-64 -target-feature +retpoline-indirect-calls -target-feature +retpoline-indirect-branches -target-feature -sse2 -target-feature -sse -target-feature -3dnow -target-feature -mmx -target-feature +save-args -target-feature +retpoline-external-thunk -disable-red-zone -no-implicit-float -tune-cpu generic -debugger-tuning=gdb -fcoverage-compilation-dir=/usr/src/sys/arch/amd64/compile/GENERIC.MP/obj -nostdsysteminc -nobuiltininc -resource-dir /usr/local/llvm16/lib/clang/16 -I /usr/src/sys -I /usr/src/sys/arch/amd64/compile/GENERIC.MP/obj -I /usr/src/sys/arch -I /usr/src/sys/dev/pci/drm/include -I /usr/src/sys/dev/pci/drm/include/uapi -I /usr/src/sys/dev/pci/drm/amd/include/asic_reg -I /usr/src/sys/dev/pci/drm/amd/include -I /usr/src/sys/dev/pci/drm/amd/amdgpu -I /usr/src/sys/dev/pci/drm/amd/display -I /usr/src/sys/dev/pci/drm/amd/display/include -I /usr/src/sys/dev/pci/drm/amd/display/dc -I /usr/src/sys/dev/pci/drm/amd/display/amdgpu_dm -I /usr/src/sys/dev/pci/drm/amd/pm/inc -I /usr/src/sys/dev/pci/drm/amd/pm/legacy-dpm -I /usr/src/sys/dev/pci/drm/amd/pm/swsmu -I /usr/src/sys/dev/pci/drm/amd/pm/swsmu/inc -I /usr/src/sys/dev/pci/drm/amd/pm/swsmu/smu11 -I /usr/src/sys/dev/pci/drm/amd/pm/swsmu/smu12 -I /usr/src/sys/dev/pci/drm/amd/pm/swsmu/smu13 -I /usr/src/sys/dev/pci/drm/amd/pm/powerplay/inc -I /usr/src/sys/dev/pci/drm/amd/pm/powerplay/hwmgr -I /usr/src/sys/dev/pci/drm/amd/pm/powerplay/smumgr -I /usr/src/sys/dev/pci/drm/amd/pm/swsmu/inc -I /usr/src/sys/dev/pci/drm/amd/pm/swsmu/inc/pmfw_if -I /usr/src/sys/dev/pci/drm/amd/display/dc/inc -I /usr/src/sys/dev/pci/drm/amd/display/dc/inc/hw -I /usr/src/sys/dev/pci/drm/amd/display/dc/clk_mgr -I /usr/src/sys/dev/pci/drm/amd/display/modules/inc -I /usr/src/sys/dev/pci/drm/amd/display/modules/hdcp -I /usr/src/sys/dev/pci/drm/amd/display/dmub/inc -I /usr/src/sys/dev/pci/drm/i915 -D DDB -D DIAGNOSTIC -D KTRACE -D ACCOUNTING -D KMEMSTATS -D PTRACE -D POOL_DEBUG -D CRYPTO -D SYSVMSG -D SYSVSEM -D SYSVSHM -D UVM_SWAP_ENCRYPT -D FFS -D FFS2 -D FFS_SOFTUPDATES -D UFS_DIRHASH -D QUOTA -D EXT2FS -D MFS -D NFSCLIENT -D NFSSERVER -D CD9660 -D UDF -D MSDOSFS -D FIFO -D FUSE -D SOCKET_SPLICE -D TCP_ECN -D TCP_SIGNATURE -D INET6 -D IPSEC -D PPP_BSDCOMP -D PPP_DEFLATE -D PIPEX -D MROUTING -D MPLS -D BOOT_CONFIG -D USER_PCICONF -D APERTURE -D MTRR -D NTFS -D SUSPEND -D HIBERNATE -D PCIVERBOSE -D USBVERBOSE -D WSDISPLAY_COMPAT_USL -D WSDISPLAY_COMPAT_RAWKBD -D WSDISPLAY_DEFAULTSCREENS=6 -D X86EMU -D ONEWIREVERBOSE -D MULTIPROCESSOR -D MAXUSERS=80 -D _KERNEL -O2 -Wno-pointer-sign -Wno-address-of-packed-member -Wno-constant-conversion -Wno-unused-but-set-variable -Wno-gnu-folding-constant -fdebug-compilation-dir=/usr/src/sys/arch/amd64/compile/GENERIC.MP/obj -ferror-limit 19 -fwrapv -D_RET_PROTECTOR -ret-protector -fcf-protection=branch -fgnuc-version=4.2.1 -vectorize-loops -vectorize-slp -fno-builtin-malloc -fno-builtin-calloc -fno-builtin-realloc -fno-builtin-valloc -fno-builtin-free -fno-builtin-strdup -fno-builtin-strndup -analyzer-output=html -faddrsig -o /home/ben/Projects/scan/2024-01-11-110808-61670-1 -x c /usr/src/sys/dev/ic/rtw.c
1/* $OpenBSD: rtw.c,v 1.103 2022/04/21 21:03:02 stsp Exp $ */
2/* $NetBSD: rtw.c,v 1.29 2004/12/27 19:49:16 dyoung Exp $ */
3
4/*-
5 * Copyright (c) 2004, 2005 David Young. All rights reserved.
6 *
7 * Programmed for NetBSD by David Young.
8 *
9 * Redistribution and use in source and binary forms, with or without
10 * modification, are permitted provided that the following conditions
11 * are met:
12 * 1. Redistributions of source code must retain the above copyright
13 * notice, this list of conditions and the following disclaimer.
14 * 2. Redistributions in binary form must reproduce the above copyright
15 * notice, this list of conditions and the following disclaimer in the
16 * documentation and/or other materials provided with the distribution.
17 * 3. The name of David Young may not be used to endorse or promote
18 * products derived from this software without specific prior
19 * written permission.
20 *
21 * THIS SOFTWARE IS PROVIDED BY David Young ``AS IS'' AND ANY
22 * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
23 * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A
24 * PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL David
25 * Young BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
26 * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED
27 * TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
28 * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
29 * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
30 * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
31 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY
32 * OF SUCH DAMAGE.
33 */
34/*
35 * Device driver for the Realtek RTL8180 802.11 MAC/BBP.
36 */
37
38#include "bpfilter.h"
39
40#include <sys/param.h>
41#include <sys/systm.h>
42#include <sys/mbuf.h>
43#include <sys/malloc.h>
44#include <sys/kernel.h>
45#include <sys/ioctl.h>
46#include <sys/socket.h>
47#include <sys/time.h>
48#include <sys/endian.h>
49
50#include <machine/bus.h>
51#include <machine/intr.h> /* splnet */
52
53#include <net/if.h>
54#include <net/if_media.h>
55
56#if NBPFILTER1 > 0
57#include <net/bpf.h>
58#endif
59
60#include <netinet/in.h>
61#include <netinet/if_ether.h>
62
63#include <net80211/ieee80211_var.h>
64#include <net80211/ieee80211_radiotap.h>
65
66#include <dev/ic/rtwreg.h>
67#include <dev/ic/rtwvar.h>
68#include <dev/ic/max2820reg.h>
69#include <dev/ic/sa2400reg.h>
70#include <dev/ic/si4136reg.h>
71#include <dev/ic/rtl8225reg.h>
72#include <dev/ic/smc93cx6var.h>
73
74int rtw_rfprog_fallback = 0;
75int rtw_do_chip_reset = 0;
76int rtw_dwelltime = 200; /* milliseconds per channel */
77int rtw_macbangbits_timeout = 100;
78
79#ifdef RTW_DEBUG
80int rtw_debug = 0;
81int rtw_rxbufs_limit = RTW_RXQLEN64;
82#endif /* RTW_DEBUG */
83
84void rtw_start(struct ifnet *);
85void rtw_txdesc_blk_init_all(struct rtw_txdesc_blk *);
86void rtw_txsoft_blk_init_all(struct rtw_txsoft_blk *);
87void rtw_txdesc_blk_init(struct rtw_txdesc_blk *);
88void rtw_txdescs_sync(struct rtw_txdesc_blk *, u_int, u_int, int);
89void rtw_txring_fixup(struct rtw_softc *);
90void rtw_rxbufs_release(bus_dma_tag_t, struct rtw_rxsoft *);
91void rtw_rxdesc_init(struct rtw_rxdesc_blk *, struct rtw_rxsoft *, int, int);
92void rtw_rxring_fixup(struct rtw_softc *);
93void rtw_io_enable(struct rtw_regs *, u_int8_t, int);
94void rtw_intr_rx(struct rtw_softc *, u_int16_t);
95#ifndef IEEE80211_STA_ONLY
96void rtw_intr_beacon(struct rtw_softc *, u_int16_t);
97void rtw_intr_atim(struct rtw_softc *);
98#endif
99void rtw_transmit_config(struct rtw_softc *);
100void rtw_pktfilt_load(struct rtw_softc *);
101void rtw_start(struct ifnet *);
102void rtw_watchdog(struct ifnet *);
103void rtw_next_scan(void *);
104#ifndef IEEE80211_STA_ONLY
105void rtw_recv_mgmt(struct ieee80211com *, struct mbuf *,
106 struct ieee80211_node *, struct ieee80211_rxinfo *, int);
107#endif
108struct ieee80211_node *rtw_node_alloc(struct ieee80211com *);
109void rtw_node_free(struct ieee80211com *, struct ieee80211_node *);
110void rtw_media_status(struct ifnet *, struct ifmediareq *);
111void rtw_txsoft_blk_cleanup_all(struct rtw_softc *);
112void rtw_txdesc_blk_setup(struct rtw_txdesc_blk *, struct rtw_txdesc *,
113 u_int, bus_addr_t, bus_addr_t);
114void rtw_txdesc_blk_setup_all(struct rtw_softc *);
115void rtw_intr_tx(struct rtw_softc *, u_int16_t);
116void rtw_intr_ioerror(struct rtw_softc *, u_int16_t);
117void rtw_intr_timeout(struct rtw_softc *);
118void rtw_stop(struct ifnet *, int);
119void rtw_maxim_pwrstate(struct rtw_regs *, enum rtw_pwrstate, int, int);
120void rtw_philips_pwrstate(struct rtw_regs *, enum rtw_pwrstate, int, int);
121void rtw_rtl_pwrstate(struct rtw_regs *, enum rtw_pwrstate, int, int);
122void rtw_pwrstate0(struct rtw_softc *, enum rtw_pwrstate, int, int);
123void rtw_join_bss(struct rtw_softc *, u_int8_t *, u_int16_t);
124void rtw_set_access1(struct rtw_regs *, enum rtw_access);
125int rtw_srom_parse(struct rtw_softc *);
126int rtw_srom_read(struct rtw_regs *, u_int32_t, struct rtw_srom *,
127 const char *);
128void rtw_set_rfprog(struct rtw_regs *, int, const char *);
129u_int8_t rtw_chan2txpower(struct rtw_srom *, struct ieee80211com *,
130 struct ieee80211_channel *);
131int rtw_txsoft_blk_init(struct rtw_txsoft_blk *);
132int rtw_rxsoft_init_all(bus_dma_tag_t, struct rtw_rxsoft *,
133 int *, const char *);
134void rtw_txsoft_release(bus_dma_tag_t, struct ieee80211com *,
135 struct rtw_txsoft *);
136void rtw_txsofts_release(bus_dma_tag_t, struct ieee80211com *,
137 struct rtw_txsoft_blk *);
138void rtw_hwring_setup(struct rtw_softc *);
139int rtw_swring_setup(struct rtw_softc *);
140void rtw_txdescs_reset(struct rtw_softc *);
141void rtw_rfmd_pwrstate(struct rtw_regs *, enum rtw_pwrstate, int, int);
142int rtw_pwrstate(struct rtw_softc *, enum rtw_pwrstate);
143int rtw_tune(struct rtw_softc *);
144void rtw_set_nettype(struct rtw_softc *, enum ieee80211_opmode);
145int rtw_compute_duration1(int, int, uint32_t, int, struct rtw_duration *);
146int rtw_compute_duration(struct ieee80211_frame *, int, uint32_t, int,
147 int, struct rtw_duration *, struct rtw_duration *, int *, int);
148int rtw_init(struct ifnet *);
149int rtw_ioctl(struct ifnet *, u_long, caddr_t);
150int rtw_seg_too_short(bus_dmamap_t);
151struct mbuf *rtw_dmamap_load_txbuf(bus_dma_tag_t, bus_dmamap_t, struct mbuf *,
152 u_int, short *, const char *);
153int rtw_newstate(struct ieee80211com *, enum ieee80211_state, int);
154int rtw_media_change(struct ifnet *);
155int rtw_txsoft_blk_setup_all(struct rtw_softc *);
156int rtw_rf_attach(struct rtw_softc *, int);
157u_int8_t rtw_check_phydelay(struct rtw_regs *, u_int32_t);
158int rtw_chip_reset1(struct rtw_regs *, const char *);
159int rtw_chip_reset(struct rtw_regs *, const char *);
160int rtw_recall_eeprom(struct rtw_regs *, const char *);
161int rtw_reset(struct rtw_softc *);
162void rtw_reset_oactive(struct rtw_softc *);
163int rtw_txdesc_dmamaps_create(bus_dma_tag_t, struct rtw_txsoft *, u_int);
164int rtw_rxdesc_dmamaps_create(bus_dma_tag_t, struct rtw_rxsoft *, u_int);
165void rtw_rxdesc_dmamaps_destroy(bus_dma_tag_t, struct rtw_rxsoft *, u_int);
166void rtw_txdesc_dmamaps_destroy(bus_dma_tag_t, struct rtw_txsoft *, u_int);
167void rtw_identify_country(struct rtw_regs *, enum rtw_locale *);
168int rtw_identify_sta(struct rtw_regs *, u_int8_t (*)[], const char *);
169void rtw_rxdescs_sync(struct rtw_rxdesc_blk *, int, int, int);
170int rtw_rxsoft_alloc(bus_dma_tag_t, struct rtw_rxsoft *);
171void rtw_collect_txpkt(struct rtw_softc *, struct rtw_txdesc_blk *,
172 struct rtw_txsoft *, int);
173void rtw_collect_txring(struct rtw_softc *, struct rtw_txsoft_blk *,
174 struct rtw_txdesc_blk *, int);
175void rtw_suspend_ticks(struct rtw_softc *);
176void rtw_resume_ticks(struct rtw_softc *);
177void rtw_enable_interrupts(struct rtw_softc *);
178int rtw_dequeue(struct ifnet *, struct rtw_txsoft_blk **,
179 struct rtw_txdesc_blk **, struct mbuf **,
180 struct ieee80211_node **);
181int rtw_txsoft_blk_setup(struct rtw_txsoft_blk *, u_int);
182void rtw_rxdesc_init_all(struct rtw_rxdesc_blk *, struct rtw_rxsoft *,
183 int);
184int rtw_txring_choose(struct rtw_softc *, struct rtw_txsoft_blk **,
185 struct rtw_txdesc_blk **, int);
186u_int rtw_txring_next(struct rtw_regs *, struct rtw_txdesc_blk *);
187struct mbuf *rtw_80211_dequeue(struct rtw_softc *, struct mbuf_queue *, int,
188 struct rtw_txsoft_blk **, struct rtw_txdesc_blk **,
189 struct ieee80211_node **);
190uint64_t rtw_tsf_extend(struct rtw_regs *, u_int32_t);
191#ifndef IEEE80211_STA_ONLY
192void rtw_ibss_merge(struct rtw_softc *, struct ieee80211_node *,
193 u_int32_t);
194#endif
195void rtw_idle(struct rtw_regs *);
196void rtw_led_attach(struct rtw_led_state *, void *);
197void rtw_led_init(struct rtw_regs *);
198void rtw_led_slowblink(void *);
199void rtw_led_fastblink(void *);
200void rtw_led_set(struct rtw_led_state *, struct rtw_regs *, u_int);
201void rtw_led_newstate(struct rtw_softc *, enum ieee80211_state);
202
203int rtw_phy_init(struct rtw_softc *);
204int rtw_bbp_preinit(struct rtw_regs *, u_int, int, u_int);
205int rtw_bbp_init(struct rtw_regs *, struct rtw_bbpset *, int,
206 int, u_int8_t, u_int);
207void rtw_verify_syna(u_int, u_int32_t);
208int rtw_sa2400_pwrstate(struct rtw_softc *, enum rtw_pwrstate);
209int rtw_sa2400_txpower(struct rtw_softc *, u_int8_t);
210int rtw_sa2400_tune(struct rtw_softc *, u_int);
211int rtw_sa2400_vcocal_start(struct rtw_softc *, int);
212int rtw_sa2400_vco_calibration(struct rtw_softc *);
213int rtw_sa2400_filter_calibration(struct rtw_softc *);
214int rtw_sa2400_dc_calibration(struct rtw_softc *);
215int rtw_sa2400_calibrate(struct rtw_softc *, u_int);
216int rtw_sa2400_init(struct rtw_softc *, u_int, u_int8_t,
217 enum rtw_pwrstate);
218int rtw_max2820_pwrstate(struct rtw_softc *, enum rtw_pwrstate);
219int rtw_max2820_init(struct rtw_softc *, u_int, u_int8_t,
220 enum rtw_pwrstate);
221int rtw_max2820_txpower(struct rtw_softc *, u_int8_t);
222int rtw_max2820_tune(struct rtw_softc *, u_int);
223int rtw_rtl8225_pwrstate(struct rtw_softc *, enum rtw_pwrstate);
224int rtw_rtl8225_init(struct rtw_softc *, u_int, u_int8_t,
225 enum rtw_pwrstate);
226int rtw_rtl8225_txpower(struct rtw_softc *, u_int8_t);
227int rtw_rtl8225_tune(struct rtw_softc *, u_int);
228int rtw_rtl8255_pwrstate(struct rtw_softc *, enum rtw_pwrstate);
229int rtw_rtl8255_init(struct rtw_softc *, u_int, u_int8_t,
230 enum rtw_pwrstate);
231int rtw_rtl8255_txpower(struct rtw_softc *, u_int8_t);
232int rtw_rtl8255_tune(struct rtw_softc *, u_int);
233int rtw_grf5101_pwrstate(struct rtw_softc *, enum rtw_pwrstate);
234int rtw_grf5101_init(struct rtw_softc *, u_int, u_int8_t,
235 enum rtw_pwrstate);
236int rtw_grf5101_txpower(struct rtw_softc *, u_int8_t);
237int rtw_grf5101_tune(struct rtw_softc *, u_int);
238int rtw_rf_hostwrite(struct rtw_softc *, u_int, u_int32_t);
239int rtw_rf_macwrite(struct rtw_softc *, u_int, u_int32_t);
240int rtw_bbp_write(struct rtw_regs *, u_int, u_int);
241u_int32_t rtw_grf5101_host_crypt(u_int, u_int32_t);
242u_int32_t rtw_maxim_swizzle(u_int, uint32_t);
243u_int32_t rtw_grf5101_mac_crypt(u_int, u_int32_t);
244void rtw_rf_hostbangbits(struct rtw_regs *, u_int32_t, int, u_int);
245void rtw_rf_rtl8225_hostbangbits(struct rtw_regs *, u_int32_t, int, u_int);
246int rtw_rf_macbangbits(struct rtw_regs *, u_int32_t);
247
248u_int8_t rtw_read8(void *, u_int32_t);
249u_int16_t rtw_read16(void *, u_int32_t);
250u_int32_t rtw_read32(void *, u_int32_t);
251void rtw_write8(void *, u_int32_t, u_int8_t);
252void rtw_write16(void *, u_int32_t, u_int16_t);
253void rtw_write32(void *, u_int32_t, u_int32_t);
254void rtw_barrier(void *, u_int32_t, u_int32_t, int);
255
256#ifdef RTW_DEBUG
257void rtw_print_txdesc(struct rtw_softc *, const char *,
258 struct rtw_txsoft *, struct rtw_txdesc_blk *, int);
259const char *rtw_access_string(enum rtw_access);
260void rtw_dump_rings(struct rtw_softc *);
261void rtw_print_txdesc(struct rtw_softc *, const char *,
262 struct rtw_txsoft *, struct rtw_txdesc_blk *, int);
263#endif
264
265struct cfdriver rtw_cd = {
266 NULL((void *)0), "rtw", DV_IFNET
267};
268
269void
270rtw_continuous_tx_enable(struct rtw_softc *sc, int enable)
271{
272 struct rtw_regs *regs = &sc->sc_regs;
273
274 u_int32_t tcr;
275 tcr = RTW_READ(regs, RTW_TCR)((*(regs)->r_read32)(regs, 0x40));
276 tcr &= ~RTW_TCR_LBK_MASK0x60000;
277 if (enable)
278 tcr |= RTW_TCR_LBK_CONT((3) << ((((u_long)((((((0x60000)) - 1) & ((0x60000
))) ^ ((0x60000)))) >> (16)) != 0) ? 16 + ((((u_long)((
(((((0x60000) >> 16)) - 1) & (((0x60000) >> 16
))) ^ (((0x60000) >> 16)))) >> (8)) != 0) ? 8 + (
(((u_long)((((((((0x60000) >> 16) >> 8)) - 1) &
((((0x60000) >> 16) >> 8))) ^ ((((0x60000) >>
16) >> 8)))) >> (4)) != 0) ? 4 + ((((u_long)((((
(((((0x60000) >> 16) >> 8) >> 4)) - 1) &
(((((0x60000) >> 16) >> 8) >> 4))) ^ (((((
0x60000) >> 16) >> 8) >> 4)))) >> (2)
) != 0) ? 2 + ((((u_long)((((((((((0x60000) >> 16) >>
8) >> 4) >> 2)) - 1) & ((((((0x60000) >>
16) >> 8) >> 4) >> 2))) ^ ((((((0x60000) >>
16) >> 8) >> 4) >> 2)))) >> (1)) != 0
) ? 1 : 0) : ((((u_long)((((((((((0x60000) >> 16) >>
8) >> 4))) - 1) & ((((((0x60000) >> 16) >>
8) >> 4)))) ^ ((((((0x60000) >> 16) >> 8) >>
4))))) >> (1)) != 0) ? 1 : 0)) : ((((u_long)(((((((((0x60000
) >> 16) >> 8))) - 1) & (((((0x60000) >>
16) >> 8)))) ^ (((((0x60000) >> 16) >> 8))
))) >> (2)) != 0) ? 2 + ((((u_long)((((((((((0x60000) >>
16) >> 8)) >> 2)) - 1) & ((((((0x60000) >>
16) >> 8)) >> 2))) ^ ((((((0x60000) >> 16)
>> 8)) >> 2)))) >> (1)) != 0) ? 1 : 0) : (
(((u_long)((((((((((0x60000) >> 16) >> 8)))) - 1)
& ((((((0x60000) >> 16) >> 8))))) ^ ((((((0x60000
) >> 16) >> 8)))))) >> (1)) != 0) ? 1 : 0))
) : ((((u_long)((((((((0x60000) >> 16))) - 1) & (((
(0x60000) >> 16)))) ^ ((((0x60000) >> 16))))) >>
(4)) != 0) ? 4 + ((((u_long)(((((((((0x60000) >> 16)) >>
4)) - 1) & (((((0x60000) >> 16)) >> 4))) ^ (
((((0x60000) >> 16)) >> 4)))) >> (2)) != 0)
? 2 + ((((u_long)((((((((((0x60000) >> 16)) >> 4
) >> 2)) - 1) & ((((((0x60000) >> 16)) >>
4) >> 2))) ^ ((((((0x60000) >> 16)) >> 4) >>
2)))) >> (1)) != 0) ? 1 : 0) : ((((u_long)((((((((((0x60000
) >> 16)) >> 4))) - 1) & ((((((0x60000) >>
16)) >> 4)))) ^ ((((((0x60000) >> 16)) >> 4
))))) >> (1)) != 0) ? 1 : 0)) : ((((u_long)(((((((((0x60000
) >> 16)))) - 1) & (((((0x60000) >> 16))))) ^
(((((0x60000) >> 16)))))) >> (2)) != 0) ? 2 + ((
((u_long)((((((((((0x60000) >> 16))) >> 2)) - 1) &
((((((0x60000) >> 16))) >> 2))) ^ ((((((0x60000)
>> 16))) >> 2)))) >> (1)) != 0) ? 1 : 0) :
((((u_long)((((((((((0x60000) >> 16))))) - 1) & ((
((((0x60000) >> 16)))))) ^ ((((((0x60000) >> 16))
))))) >> (1)) != 0) ? 1 : 0)))) : ((((u_long)(((((((0x60000
))) - 1) & (((0x60000)))) ^ (((0x60000))))) >> (8))
!= 0) ? 8 + ((((u_long)((((((((0x60000)) >> 8)) - 1) &
((((0x60000)) >> 8))) ^ ((((0x60000)) >> 8)))) >>
(4)) != 0) ? 4 + ((((u_long)(((((((((0x60000)) >> 8) >>
4)) - 1) & (((((0x60000)) >> 8) >> 4))) ^ ((
(((0x60000)) >> 8) >> 4)))) >> (2)) != 0) ?
2 + ((((u_long)((((((((((0x60000)) >> 8) >> 4) >>
2)) - 1) & ((((((0x60000)) >> 8) >> 4) >>
2))) ^ ((((((0x60000)) >> 8) >> 4) >> 2)))
) >> (1)) != 0) ? 1 : 0) : ((((u_long)((((((((((0x60000
)) >> 8) >> 4))) - 1) & ((((((0x60000)) >>
8) >> 4)))) ^ ((((((0x60000)) >> 8) >> 4))
))) >> (1)) != 0) ? 1 : 0)) : ((((u_long)(((((((((0x60000
)) >> 8))) - 1) & (((((0x60000)) >> 8)))) ^ (
((((0x60000)) >> 8))))) >> (2)) != 0) ? 2 + ((((u_long
)((((((((((0x60000)) >> 8)) >> 2)) - 1) & (((
(((0x60000)) >> 8)) >> 2))) ^ ((((((0x60000)) >>
8)) >> 2)))) >> (1)) != 0) ? 1 : 0) : ((((u_long
)((((((((((0x60000)) >> 8)))) - 1) & ((((((0x60000)
) >> 8))))) ^ ((((((0x60000)) >> 8)))))) >>
(1)) != 0) ? 1 : 0))) : ((((u_long)((((((((0x60000)))) - 1) &
((((0x60000))))) ^ ((((0x60000)))))) >> (4)) != 0) ? 4
+ ((((u_long)(((((((((0x60000))) >> 4)) - 1) & (((
((0x60000))) >> 4))) ^ (((((0x60000))) >> 4)))) >>
(2)) != 0) ? 2 + ((((u_long)((((((((((0x60000))) >> 4)
>> 2)) - 1) & ((((((0x60000))) >> 4) >>
2))) ^ ((((((0x60000))) >> 4) >> 2)))) >> (
1)) != 0) ? 1 : 0) : ((((u_long)((((((((((0x60000))) >>
4))) - 1) & ((((((0x60000))) >> 4)))) ^ ((((((0x60000
))) >> 4))))) >> (1)) != 0) ? 1 : 0)) : ((((u_long
)(((((((((0x60000))))) - 1) & (((((0x60000)))))) ^ (((((0x60000
))))))) >> (2)) != 0) ? 2 + ((((u_long)((((((((((0x60000
)))) >> 2)) - 1) & ((((((0x60000)))) >> 2))) ^
((((((0x60000)))) >> 2)))) >> (1)) != 0) ? 1 : 0
) : ((((u_long)((((((((((0x60000)))))) - 1) & ((((((0x60000
))))))) ^ ((((((0x60000)))))))) >> (1)) != 0) ? 1 : 0))
))))
;
279 else
280 tcr |= RTW_TCR_LBK_NORMAL((0) << ((((u_long)((((((0x60000)) - 1) & ((0x60000
))) ^ ((0x60000)))) >> (16)) != 0) ? 16 + ((((u_long)((
(((((0x60000) >> 16)) - 1) & (((0x60000) >> 16
))) ^ (((0x60000) >> 16)))) >> (8)) != 0) ? 8 + (
(((u_long)((((((((0x60000) >> 16) >> 8)) - 1) &
((((0x60000) >> 16) >> 8))) ^ ((((0x60000) >>
16) >> 8)))) >> (4)) != 0) ? 4 + ((((u_long)((((
(((((0x60000) >> 16) >> 8) >> 4)) - 1) &
(((((0x60000) >> 16) >> 8) >> 4))) ^ (((((
0x60000) >> 16) >> 8) >> 4)))) >> (2)
) != 0) ? 2 + ((((u_long)((((((((((0x60000) >> 16) >>
8) >> 4) >> 2)) - 1) & ((((((0x60000) >>
16) >> 8) >> 4) >> 2))) ^ ((((((0x60000) >>
16) >> 8) >> 4) >> 2)))) >> (1)) != 0
) ? 1 : 0) : ((((u_long)((((((((((0x60000) >> 16) >>
8) >> 4))) - 1) & ((((((0x60000) >> 16) >>
8) >> 4)))) ^ ((((((0x60000) >> 16) >> 8) >>
4))))) >> (1)) != 0) ? 1 : 0)) : ((((u_long)(((((((((0x60000
) >> 16) >> 8))) - 1) & (((((0x60000) >>
16) >> 8)))) ^ (((((0x60000) >> 16) >> 8))
))) >> (2)) != 0) ? 2 + ((((u_long)((((((((((0x60000) >>
16) >> 8)) >> 2)) - 1) & ((((((0x60000) >>
16) >> 8)) >> 2))) ^ ((((((0x60000) >> 16)
>> 8)) >> 2)))) >> (1)) != 0) ? 1 : 0) : (
(((u_long)((((((((((0x60000) >> 16) >> 8)))) - 1)
& ((((((0x60000) >> 16) >> 8))))) ^ ((((((0x60000
) >> 16) >> 8)))))) >> (1)) != 0) ? 1 : 0))
) : ((((u_long)((((((((0x60000) >> 16))) - 1) & (((
(0x60000) >> 16)))) ^ ((((0x60000) >> 16))))) >>
(4)) != 0) ? 4 + ((((u_long)(((((((((0x60000) >> 16)) >>
4)) - 1) & (((((0x60000) >> 16)) >> 4))) ^ (
((((0x60000) >> 16)) >> 4)))) >> (2)) != 0)
? 2 + ((((u_long)((((((((((0x60000) >> 16)) >> 4
) >> 2)) - 1) & ((((((0x60000) >> 16)) >>
4) >> 2))) ^ ((((((0x60000) >> 16)) >> 4) >>
2)))) >> (1)) != 0) ? 1 : 0) : ((((u_long)((((((((((0x60000
) >> 16)) >> 4))) - 1) & ((((((0x60000) >>
16)) >> 4)))) ^ ((((((0x60000) >> 16)) >> 4
))))) >> (1)) != 0) ? 1 : 0)) : ((((u_long)(((((((((0x60000
) >> 16)))) - 1) & (((((0x60000) >> 16))))) ^
(((((0x60000) >> 16)))))) >> (2)) != 0) ? 2 + ((
((u_long)((((((((((0x60000) >> 16))) >> 2)) - 1) &
((((((0x60000) >> 16))) >> 2))) ^ ((((((0x60000)
>> 16))) >> 2)))) >> (1)) != 0) ? 1 : 0) :
((((u_long)((((((((((0x60000) >> 16))))) - 1) & ((
((((0x60000) >> 16)))))) ^ ((((((0x60000) >> 16))
))))) >> (1)) != 0) ? 1 : 0)))) : ((((u_long)(((((((0x60000
))) - 1) & (((0x60000)))) ^ (((0x60000))))) >> (8))
!= 0) ? 8 + ((((u_long)((((((((0x60000)) >> 8)) - 1) &
((((0x60000)) >> 8))) ^ ((((0x60000)) >> 8)))) >>
(4)) != 0) ? 4 + ((((u_long)(((((((((0x60000)) >> 8) >>
4)) - 1) & (((((0x60000)) >> 8) >> 4))) ^ ((
(((0x60000)) >> 8) >> 4)))) >> (2)) != 0) ?
2 + ((((u_long)((((((((((0x60000)) >> 8) >> 4) >>
2)) - 1) & ((((((0x60000)) >> 8) >> 4) >>
2))) ^ ((((((0x60000)) >> 8) >> 4) >> 2)))
) >> (1)) != 0) ? 1 : 0) : ((((u_long)((((((((((0x60000
)) >> 8) >> 4))) - 1) & ((((((0x60000)) >>
8) >> 4)))) ^ ((((((0x60000)) >> 8) >> 4))
))) >> (1)) != 0) ? 1 : 0)) : ((((u_long)(((((((((0x60000
)) >> 8))) - 1) & (((((0x60000)) >> 8)))) ^ (
((((0x60000)) >> 8))))) >> (2)) != 0) ? 2 + ((((u_long
)((((((((((0x60000)) >> 8)) >> 2)) - 1) & (((
(((0x60000)) >> 8)) >> 2))) ^ ((((((0x60000)) >>
8)) >> 2)))) >> (1)) != 0) ? 1 : 0) : ((((u_long
)((((((((((0x60000)) >> 8)))) - 1) & ((((((0x60000)
) >> 8))))) ^ ((((((0x60000)) >> 8)))))) >>
(1)) != 0) ? 1 : 0))) : ((((u_long)((((((((0x60000)))) - 1) &
((((0x60000))))) ^ ((((0x60000)))))) >> (4)) != 0) ? 4
+ ((((u_long)(((((((((0x60000))) >> 4)) - 1) & (((
((0x60000))) >> 4))) ^ (((((0x60000))) >> 4)))) >>
(2)) != 0) ? 2 + ((((u_long)((((((((((0x60000))) >> 4)
>> 2)) - 1) & ((((((0x60000))) >> 4) >>
2))) ^ ((((((0x60000))) >> 4) >> 2)))) >> (
1)) != 0) ? 1 : 0) : ((((u_long)((((((((((0x60000))) >>
4))) - 1) & ((((((0x60000))) >> 4)))) ^ ((((((0x60000
))) >> 4))))) >> (1)) != 0) ? 1 : 0)) : ((((u_long
)(((((((((0x60000))))) - 1) & (((((0x60000)))))) ^ (((((0x60000
))))))) >> (2)) != 0) ? 2 + ((((u_long)((((((((((0x60000
)))) >> 2)) - 1) & ((((((0x60000)))) >> 2))) ^
((((((0x60000)))) >> 2)))) >> (1)) != 0) ? 1 : 0
) : ((((u_long)((((((((((0x60000)))))) - 1) & ((((((0x60000
))))))) ^ ((((((0x60000)))))))) >> (1)) != 0) ? 1 : 0))
))))
;
281 RTW_WRITE(regs, RTW_TCR, tcr)((*(regs)->r_write32)(regs, 0x40, tcr));
282 RTW_SYNC(regs, RTW_TCR, RTW_TCR)((*(regs)->r_barrier)(regs, 0x40, 0x40, (0x01|0x02)));
283 rtw_set_access(regs, RTW_ACCESS_ANAPARM);
284 rtw_txdac_enable(sc, !enable);
285 rtw_set_access(regs, RTW_ACCESS_ANAPARM);/* XXX Voodoo from Linux. */
286 rtw_set_access(regs, RTW_ACCESS_NONE);
287}
288
289#ifdef RTW_DEBUG
290const char *
291rtw_access_string(enum rtw_access access)
292{
293 switch (access) {
294 case RTW_ACCESS_NONE:
295 return "none";
296 case RTW_ACCESS_CONFIG:
297 return "config";
298 case RTW_ACCESS_ANAPARM:
299 return "anaparm";
300 default:
301 return "unknown";
302 }
303}
304#endif
305
306void
307rtw_set_access1(struct rtw_regs *regs, enum rtw_access naccess)
308{
309 KASSERT(naccess >= RTW_ACCESS_NONE && naccess <= RTW_ACCESS_ANAPARM)((naccess >= RTW_ACCESS_NONE && naccess <= RTW_ACCESS_ANAPARM
) ? (void)0 : __assert("diagnostic ", "/usr/src/sys/dev/ic/rtw.c"
, 309, "naccess >= RTW_ACCESS_NONE && naccess <= RTW_ACCESS_ANAPARM"
))
;
310 KASSERT(regs->r_access >= RTW_ACCESS_NONE &&((regs->r_access >= RTW_ACCESS_NONE && regs->
r_access <= RTW_ACCESS_ANAPARM) ? (void)0 : __assert("diagnostic "
, "/usr/src/sys/dev/ic/rtw.c", 311, "regs->r_access >= RTW_ACCESS_NONE && regs->r_access <= RTW_ACCESS_ANAPARM"
))
311 regs->r_access <= RTW_ACCESS_ANAPARM)((regs->r_access >= RTW_ACCESS_NONE && regs->
r_access <= RTW_ACCESS_ANAPARM) ? (void)0 : __assert("diagnostic "
, "/usr/src/sys/dev/ic/rtw.c", 311, "regs->r_access >= RTW_ACCESS_NONE && regs->r_access <= RTW_ACCESS_ANAPARM"
))
;
312
313 if (naccess == regs->r_access)
314 return;
315
316 switch (naccess) {
317 case RTW_ACCESS_NONE:
318 switch (regs->r_access) {
319 case RTW_ACCESS_ANAPARM:
320 rtw_anaparm_enable(regs, 0);
321 /*FALLTHROUGH*/
322 case RTW_ACCESS_CONFIG:
323 rtw_config0123_enable(regs, 0);
324 /*FALLTHROUGH*/
325 case RTW_ACCESS_NONE:
326 break;
327 }
328 break;
329 case RTW_ACCESS_CONFIG:
330 switch (regs->r_access) {
331 case RTW_ACCESS_NONE:
332 rtw_config0123_enable(regs, 1);
333 /*FALLTHROUGH*/
334 case RTW_ACCESS_CONFIG:
335 break;
336 case RTW_ACCESS_ANAPARM:
337 rtw_anaparm_enable(regs, 0);
338 break;
339 }
340 break;
341 case RTW_ACCESS_ANAPARM:
342 switch (regs->r_access) {
343 case RTW_ACCESS_NONE:
344 rtw_config0123_enable(regs, 1);
345 /*FALLTHROUGH*/
346 case RTW_ACCESS_CONFIG:
347 rtw_anaparm_enable(regs, 1);
348 /*FALLTHROUGH*/
349 case RTW_ACCESS_ANAPARM:
350 break;
351 }
352 break;
353 }
354}
355
356void
357rtw_set_access(struct rtw_regs *regs, enum rtw_access access)
358{
359 rtw_set_access1(regs, access);
360 RTW_DPRINTF(RTW_DEBUG_ACCESS,
361 ("%s: access %s -> %s\n",__func__,
362 rtw_access_string(regs->r_access),
363 rtw_access_string(access)));
364 regs->r_access = access;
365}
366
367/*
368 * Enable registers, switch register banks.
369 */
370void
371rtw_config0123_enable(struct rtw_regs *regs, int enable)
372{
373 u_int8_t ecr;
374 ecr = RTW_READ8(regs, RTW_9346CR)((*(regs)->r_read8)(regs, 0x50));
375 ecr &= ~(RTW_9346CR_EEM_MASK0xc0 | RTW_9346CR_EECS(1<<3) | RTW_9346CR_EESK(1<<2));
376 if (enable)
377 ecr |= RTW_9346CR_EEM_CONFIG((3) << ((((u_long)((((((0xc0)) - 1) & ((0xc0))) ^ (
(0xc0)))) >> (16)) != 0) ? 16 + ((((u_long)(((((((0xc0)
>> 16)) - 1) & (((0xc0) >> 16))) ^ (((0xc0) >>
16)))) >> (8)) != 0) ? 8 + ((((u_long)((((((((0xc0) >>
16) >> 8)) - 1) & ((((0xc0) >> 16) >> 8
))) ^ ((((0xc0) >> 16) >> 8)))) >> (4)) != 0
) ? 4 + ((((u_long)(((((((((0xc0) >> 16) >> 8) >>
4)) - 1) & (((((0xc0) >> 16) >> 8) >> 4
))) ^ (((((0xc0) >> 16) >> 8) >> 4)))) >>
(2)) != 0) ? 2 + ((((u_long)((((((((((0xc0) >> 16) >>
8) >> 4) >> 2)) - 1) & ((((((0xc0) >> 16
) >> 8) >> 4) >> 2))) ^ ((((((0xc0) >>
16) >> 8) >> 4) >> 2)))) >> (1)) != 0
) ? 1 : 0) : ((((u_long)((((((((((0xc0) >> 16) >>
8) >> 4))) - 1) & ((((((0xc0) >> 16) >>
8) >> 4)))) ^ ((((((0xc0) >> 16) >> 8) >>
4))))) >> (1)) != 0) ? 1 : 0)) : ((((u_long)(((((((((0xc0
) >> 16) >> 8))) - 1) & (((((0xc0) >> 16
) >> 8)))) ^ (((((0xc0) >> 16) >> 8))))) >>
(2)) != 0) ? 2 + ((((u_long)((((((((((0xc0) >> 16) >>
8)) >> 2)) - 1) & ((((((0xc0) >> 16) >>
8)) >> 2))) ^ ((((((0xc0) >> 16) >> 8)) >>
2)))) >> (1)) != 0) ? 1 : 0) : ((((u_long)((((((((((0xc0
) >> 16) >> 8)))) - 1) & ((((((0xc0) >>
16) >> 8))))) ^ ((((((0xc0) >> 16) >> 8)))
))) >> (1)) != 0) ? 1 : 0))) : ((((u_long)((((((((0xc0)
>> 16))) - 1) & ((((0xc0) >> 16)))) ^ ((((0xc0
) >> 16))))) >> (4)) != 0) ? 4 + ((((u_long)(((((
((((0xc0) >> 16)) >> 4)) - 1) & (((((0xc0) >>
16)) >> 4))) ^ (((((0xc0) >> 16)) >> 4))))
>> (2)) != 0) ? 2 + ((((u_long)((((((((((0xc0) >>
16)) >> 4) >> 2)) - 1) & ((((((0xc0) >>
16)) >> 4) >> 2))) ^ ((((((0xc0) >> 16)) >>
4) >> 2)))) >> (1)) != 0) ? 1 : 0) : ((((u_long)
((((((((((0xc0) >> 16)) >> 4))) - 1) & ((((((
0xc0) >> 16)) >> 4)))) ^ ((((((0xc0) >> 16)
) >> 4))))) >> (1)) != 0) ? 1 : 0)) : ((((u_long)
(((((((((0xc0) >> 16)))) - 1) & (((((0xc0) >>
16))))) ^ (((((0xc0) >> 16)))))) >> (2)) != 0) ?
2 + ((((u_long)((((((((((0xc0) >> 16))) >> 2)) -
1) & ((((((0xc0) >> 16))) >> 2))) ^ ((((((0xc0
) >> 16))) >> 2)))) >> (1)) != 0) ? 1 : 0) :
((((u_long)((((((((((0xc0) >> 16))))) - 1) & (((((
(0xc0) >> 16)))))) ^ ((((((0xc0) >> 16))))))) >>
(1)) != 0) ? 1 : 0)))) : ((((u_long)(((((((0xc0))) - 1) &
(((0xc0)))) ^ (((0xc0))))) >> (8)) != 0) ? 8 + ((((u_long
)((((((((0xc0)) >> 8)) - 1) & ((((0xc0)) >> 8
))) ^ ((((0xc0)) >> 8)))) >> (4)) != 0) ? 4 + (((
(u_long)(((((((((0xc0)) >> 8) >> 4)) - 1) & (
((((0xc0)) >> 8) >> 4))) ^ (((((0xc0)) >> 8
) >> 4)))) >> (2)) != 0) ? 2 + ((((u_long)(((((((
(((0xc0)) >> 8) >> 4) >> 2)) - 1) & (((
(((0xc0)) >> 8) >> 4) >> 2))) ^ ((((((0xc0)
) >> 8) >> 4) >> 2)))) >> (1)) != 0) ?
1 : 0) : ((((u_long)((((((((((0xc0)) >> 8) >> 4)
)) - 1) & ((((((0xc0)) >> 8) >> 4)))) ^ (((((
(0xc0)) >> 8) >> 4))))) >> (1)) != 0) ? 1 :
0)) : ((((u_long)(((((((((0xc0)) >> 8))) - 1) & ((
(((0xc0)) >> 8)))) ^ (((((0xc0)) >> 8))))) >>
(2)) != 0) ? 2 + ((((u_long)((((((((((0xc0)) >> 8)) >>
2)) - 1) & ((((((0xc0)) >> 8)) >> 2))) ^ (((
(((0xc0)) >> 8)) >> 2)))) >> (1)) != 0) ? 1
: 0) : ((((u_long)((((((((((0xc0)) >> 8)))) - 1) &
((((((0xc0)) >> 8))))) ^ ((((((0xc0)) >> 8))))))
>> (1)) != 0) ? 1 : 0))) : ((((u_long)((((((((0xc0))))
- 1) & ((((0xc0))))) ^ ((((0xc0)))))) >> (4)) != 0
) ? 4 + ((((u_long)(((((((((0xc0))) >> 4)) - 1) & (
((((0xc0))) >> 4))) ^ (((((0xc0))) >> 4)))) >>
(2)) != 0) ? 2 + ((((u_long)((((((((((0xc0))) >> 4) >>
2)) - 1) & ((((((0xc0))) >> 4) >> 2))) ^ (((
(((0xc0))) >> 4) >> 2)))) >> (1)) != 0) ? 1
: 0) : ((((u_long)((((((((((0xc0))) >> 4))) - 1) &
((((((0xc0))) >> 4)))) ^ ((((((0xc0))) >> 4)))))
>> (1)) != 0) ? 1 : 0)) : ((((u_long)(((((((((0xc0))))
) - 1) & (((((0xc0)))))) ^ (((((0xc0))))))) >> (2))
!= 0) ? 2 + ((((u_long)((((((((((0xc0)))) >> 2)) - 1) &
((((((0xc0)))) >> 2))) ^ ((((((0xc0)))) >> 2))))
>> (1)) != 0) ? 1 : 0) : ((((u_long)((((((((((0xc0))))
)) - 1) & ((((((0xc0))))))) ^ ((((((0xc0)))))))) >>
(1)) != 0) ? 1 : 0))))))
;
378 else {
379 RTW_WBW(regs, RTW_9346CR, MAX(RTW_CONFIG0, RTW_CONFIG3))((*(regs)->r_barrier)(regs, 0x50, (((0x51)>(0x59))?(0x51
):(0x59)), 0x02))
;
380 ecr |= RTW_9346CR_EEM_NORMAL((0) << ((((u_long)((((((0xc0)) - 1) & ((0xc0))) ^ (
(0xc0)))) >> (16)) != 0) ? 16 + ((((u_long)(((((((0xc0)
>> 16)) - 1) & (((0xc0) >> 16))) ^ (((0xc0) >>
16)))) >> (8)) != 0) ? 8 + ((((u_long)((((((((0xc0) >>
16) >> 8)) - 1) & ((((0xc0) >> 16) >> 8
))) ^ ((((0xc0) >> 16) >> 8)))) >> (4)) != 0
) ? 4 + ((((u_long)(((((((((0xc0) >> 16) >> 8) >>
4)) - 1) & (((((0xc0) >> 16) >> 8) >> 4
))) ^ (((((0xc0) >> 16) >> 8) >> 4)))) >>
(2)) != 0) ? 2 + ((((u_long)((((((((((0xc0) >> 16) >>
8) >> 4) >> 2)) - 1) & ((((((0xc0) >> 16
) >> 8) >> 4) >> 2))) ^ ((((((0xc0) >>
16) >> 8) >> 4) >> 2)))) >> (1)) != 0
) ? 1 : 0) : ((((u_long)((((((((((0xc0) >> 16) >>
8) >> 4))) - 1) & ((((((0xc0) >> 16) >>
8) >> 4)))) ^ ((((((0xc0) >> 16) >> 8) >>
4))))) >> (1)) != 0) ? 1 : 0)) : ((((u_long)(((((((((0xc0
) >> 16) >> 8))) - 1) & (((((0xc0) >> 16
) >> 8)))) ^ (((((0xc0) >> 16) >> 8))))) >>
(2)) != 0) ? 2 + ((((u_long)((((((((((0xc0) >> 16) >>
8)) >> 2)) - 1) & ((((((0xc0) >> 16) >>
8)) >> 2))) ^ ((((((0xc0) >> 16) >> 8)) >>
2)))) >> (1)) != 0) ? 1 : 0) : ((((u_long)((((((((((0xc0
) >> 16) >> 8)))) - 1) & ((((((0xc0) >>
16) >> 8))))) ^ ((((((0xc0) >> 16) >> 8)))
))) >> (1)) != 0) ? 1 : 0))) : ((((u_long)((((((((0xc0)
>> 16))) - 1) & ((((0xc0) >> 16)))) ^ ((((0xc0
) >> 16))))) >> (4)) != 0) ? 4 + ((((u_long)(((((
((((0xc0) >> 16)) >> 4)) - 1) & (((((0xc0) >>
16)) >> 4))) ^ (((((0xc0) >> 16)) >> 4))))
>> (2)) != 0) ? 2 + ((((u_long)((((((((((0xc0) >>
16)) >> 4) >> 2)) - 1) & ((((((0xc0) >>
16)) >> 4) >> 2))) ^ ((((((0xc0) >> 16)) >>
4) >> 2)))) >> (1)) != 0) ? 1 : 0) : ((((u_long)
((((((((((0xc0) >> 16)) >> 4))) - 1) & ((((((
0xc0) >> 16)) >> 4)))) ^ ((((((0xc0) >> 16)
) >> 4))))) >> (1)) != 0) ? 1 : 0)) : ((((u_long)
(((((((((0xc0) >> 16)))) - 1) & (((((0xc0) >>
16))))) ^ (((((0xc0) >> 16)))))) >> (2)) != 0) ?
2 + ((((u_long)((((((((((0xc0) >> 16))) >> 2)) -
1) & ((((((0xc0) >> 16))) >> 2))) ^ ((((((0xc0
) >> 16))) >> 2)))) >> (1)) != 0) ? 1 : 0) :
((((u_long)((((((((((0xc0) >> 16))))) - 1) & (((((
(0xc0) >> 16)))))) ^ ((((((0xc0) >> 16))))))) >>
(1)) != 0) ? 1 : 0)))) : ((((u_long)(((((((0xc0))) - 1) &
(((0xc0)))) ^ (((0xc0))))) >> (8)) != 0) ? 8 + ((((u_long
)((((((((0xc0)) >> 8)) - 1) & ((((0xc0)) >> 8
))) ^ ((((0xc0)) >> 8)))) >> (4)) != 0) ? 4 + (((
(u_long)(((((((((0xc0)) >> 8) >> 4)) - 1) & (
((((0xc0)) >> 8) >> 4))) ^ (((((0xc0)) >> 8
) >> 4)))) >> (2)) != 0) ? 2 + ((((u_long)(((((((
(((0xc0)) >> 8) >> 4) >> 2)) - 1) & (((
(((0xc0)) >> 8) >> 4) >> 2))) ^ ((((((0xc0)
) >> 8) >> 4) >> 2)))) >> (1)) != 0) ?
1 : 0) : ((((u_long)((((((((((0xc0)) >> 8) >> 4)
)) - 1) & ((((((0xc0)) >> 8) >> 4)))) ^ (((((
(0xc0)) >> 8) >> 4))))) >> (1)) != 0) ? 1 :
0)) : ((((u_long)(((((((((0xc0)) >> 8))) - 1) & ((
(((0xc0)) >> 8)))) ^ (((((0xc0)) >> 8))))) >>
(2)) != 0) ? 2 + ((((u_long)((((((((((0xc0)) >> 8)) >>
2)) - 1) & ((((((0xc0)) >> 8)) >> 2))) ^ (((
(((0xc0)) >> 8)) >> 2)))) >> (1)) != 0) ? 1
: 0) : ((((u_long)((((((((((0xc0)) >> 8)))) - 1) &
((((((0xc0)) >> 8))))) ^ ((((((0xc0)) >> 8))))))
>> (1)) != 0) ? 1 : 0))) : ((((u_long)((((((((0xc0))))
- 1) & ((((0xc0))))) ^ ((((0xc0)))))) >> (4)) != 0
) ? 4 + ((((u_long)(((((((((0xc0))) >> 4)) - 1) & (
((((0xc0))) >> 4))) ^ (((((0xc0))) >> 4)))) >>
(2)) != 0) ? 2 + ((((u_long)((((((((((0xc0))) >> 4) >>
2)) - 1) & ((((((0xc0))) >> 4) >> 2))) ^ (((
(((0xc0))) >> 4) >> 2)))) >> (1)) != 0) ? 1
: 0) : ((((u_long)((((((((((0xc0))) >> 4))) - 1) &
((((((0xc0))) >> 4)))) ^ ((((((0xc0))) >> 4)))))
>> (1)) != 0) ? 1 : 0)) : ((((u_long)(((((((((0xc0))))
) - 1) & (((((0xc0)))))) ^ (((((0xc0))))))) >> (2))
!= 0) ? 2 + ((((u_long)((((((((((0xc0)))) >> 2)) - 1) &
((((((0xc0)))) >> 2))) ^ ((((((0xc0)))) >> 2))))
>> (1)) != 0) ? 1 : 0) : ((((u_long)((((((((((0xc0))))
)) - 1) & ((((((0xc0))))))) ^ ((((((0xc0)))))))) >>
(1)) != 0) ? 1 : 0))))))
;
381 }
382 RTW_WRITE8(regs, RTW_9346CR, ecr)((*(regs)->r_write8)(regs, 0x50, ecr));
383 RTW_SYNC(regs, RTW_9346CR, RTW_9346CR)((*(regs)->r_barrier)(regs, 0x50, 0x50, (0x01|0x02)));
384}
385
386/* requires rtw_config0123_enable(, 1) */
387void
388rtw_anaparm_enable(struct rtw_regs *regs, int enable)
389{
390 u_int8_t cfg3;
391
392 cfg3 = RTW_READ8(regs, RTW_CONFIG3)((*(regs)->r_read8)(regs, 0x59));
393 cfg3 |= RTW_CONFIG3_CLKRUNEN(1<<2);
394 if (enable)
395 cfg3 |= RTW_CONFIG3_PARMEN(1<<6);
396 else
397 cfg3 &= ~RTW_CONFIG3_PARMEN(1<<6);
398 RTW_WRITE8(regs, RTW_CONFIG3, cfg3)((*(regs)->r_write8)(regs, 0x59, cfg3));
399 RTW_SYNC(regs, RTW_CONFIG3, RTW_CONFIG3)((*(regs)->r_barrier)(regs, 0x59, 0x59, (0x01|0x02)));
400}
401
402/* requires rtw_anaparm_enable(, 1) */
403void
404rtw_txdac_enable(struct rtw_softc *sc, int enable)
405{
406 u_int32_t anaparm;
407 struct rtw_regs *regs = &sc->sc_regs;
408
409 anaparm = RTW_READ(regs, RTW_ANAPARM_0)((*(regs)->r_read32)(regs, 0x54));
410 if (enable)
411 anaparm &= ~RTW_ANAPARM_TXDACOFF(1<<27);
412 else
413 anaparm |= RTW_ANAPARM_TXDACOFF(1<<27);
414 RTW_WRITE(regs, RTW_ANAPARM_0, anaparm)((*(regs)->r_write32)(regs, 0x54, anaparm));
415 RTW_SYNC(regs, RTW_ANAPARM_0, RTW_ANAPARM_0)((*(regs)->r_barrier)(regs, 0x54, 0x54, (0x01|0x02)));
416}
417
418int
419rtw_chip_reset1(struct rtw_regs *regs, const char *dvname)
420{
421 u_int8_t cr;
422 int i;
423
424 RTW_WRITE8(regs, RTW_CR, RTW_CR_RST)((*(regs)->r_write8)(regs, 0x37, (1<<4)));
425
426 RTW_WBR(regs, RTW_CR, RTW_CR)((*(regs)->r_barrier)(regs, 0x37, 0x37, 0x02));
427
428 for (i = 0; i < 1000; i++) {
429 if ((cr = RTW_READ8(regs, RTW_CR)((*(regs)->r_read8)(regs, 0x37)) & RTW_CR_RST(1<<4)) == 0) {
430 RTW_DPRINTF(RTW_DEBUG_RESET,
431 ("%s: reset in %dus\n", dvname, i));
432 return 0;
433 }
434 RTW_RBR(regs, RTW_CR, RTW_CR)((*(regs)->r_barrier)(regs, 0x37, 0x37, 0x01));
435 DELAY(10)(*delay_func)(10); /* 10us */
436 }
437
438 printf("\n%s: reset failed\n", dvname);
439 return ETIMEDOUT60;
440}
441
442int
443rtw_chip_reset(struct rtw_regs *regs, const char *dvname)
444{
445 uint32_t tcr;
446
447 /* from Linux driver */
448 tcr = RTW_TCR_CWMIN(1<<31) | RTW_TCR_MXDMA_2048((7) << ((((u_long)((((((0xe00000)) - 1) & ((0xe00000
))) ^ ((0xe00000)))) >> (16)) != 0) ? 16 + ((((u_long)(
((((((0xe00000) >> 16)) - 1) & (((0xe00000) >>
16))) ^ (((0xe00000) >> 16)))) >> (8)) != 0) ? 8
+ ((((u_long)((((((((0xe00000) >> 16) >> 8)) - 1
) & ((((0xe00000) >> 16) >> 8))) ^ ((((0xe00000
) >> 16) >> 8)))) >> (4)) != 0) ? 4 + ((((u_long
)(((((((((0xe00000) >> 16) >> 8) >> 4)) - 1
) & (((((0xe00000) >> 16) >> 8) >> 4)))
^ (((((0xe00000) >> 16) >> 8) >> 4)))) >>
(2)) != 0) ? 2 + ((((u_long)((((((((((0xe00000) >> 16)
>> 8) >> 4) >> 2)) - 1) & ((((((0xe00000
) >> 16) >> 8) >> 4) >> 2))) ^ ((((((
0xe00000) >> 16) >> 8) >> 4) >> 2))))
>> (1)) != 0) ? 1 : 0) : ((((u_long)((((((((((0xe00000
) >> 16) >> 8) >> 4))) - 1) & ((((((0xe00000
) >> 16) >> 8) >> 4)))) ^ ((((((0xe00000) >>
16) >> 8) >> 4))))) >> (1)) != 0) ? 1 : 0)
) : ((((u_long)(((((((((0xe00000) >> 16) >> 8))) -
1) & (((((0xe00000) >> 16) >> 8)))) ^ (((((0xe00000
) >> 16) >> 8))))) >> (2)) != 0) ? 2 + ((((
u_long)((((((((((0xe00000) >> 16) >> 8)) >>
2)) - 1) & ((((((0xe00000) >> 16) >> 8)) >>
2))) ^ ((((((0xe00000) >> 16) >> 8)) >> 2)
))) >> (1)) != 0) ? 1 : 0) : ((((u_long)((((((((((0xe00000
) >> 16) >> 8)))) - 1) & ((((((0xe00000) >>
16) >> 8))))) ^ ((((((0xe00000) >> 16) >> 8
)))))) >> (1)) != 0) ? 1 : 0))) : ((((u_long)((((((((0xe00000
) >> 16))) - 1) & ((((0xe00000) >> 16)))) ^ (
(((0xe00000) >> 16))))) >> (4)) != 0) ? 4 + ((((u_long
)(((((((((0xe00000) >> 16)) >> 4)) - 1) & (((
((0xe00000) >> 16)) >> 4))) ^ (((((0xe00000) >>
16)) >> 4)))) >> (2)) != 0) ? 2 + ((((u_long)(((
(((((((0xe00000) >> 16)) >> 4) >> 2)) - 1) &
((((((0xe00000) >> 16)) >> 4) >> 2))) ^ ((
((((0xe00000) >> 16)) >> 4) >> 2)))) >>
(1)) != 0) ? 1 : 0) : ((((u_long)((((((((((0xe00000) >>
16)) >> 4))) - 1) & ((((((0xe00000) >> 16)) >>
4)))) ^ ((((((0xe00000) >> 16)) >> 4))))) >>
(1)) != 0) ? 1 : 0)) : ((((u_long)(((((((((0xe00000) >>
16)))) - 1) & (((((0xe00000) >> 16))))) ^ (((((0xe00000
) >> 16)))))) >> (2)) != 0) ? 2 + ((((u_long)((((
((((((0xe00000) >> 16))) >> 2)) - 1) & ((((((
0xe00000) >> 16))) >> 2))) ^ ((((((0xe00000) >>
16))) >> 2)))) >> (1)) != 0) ? 1 : 0) : ((((u_long
)((((((((((0xe00000) >> 16))))) - 1) & ((((((0xe00000
) >> 16)))))) ^ ((((((0xe00000) >> 16))))))) >>
(1)) != 0) ? 1 : 0)))) : ((((u_long)(((((((0xe00000))) - 1) &
(((0xe00000)))) ^ (((0xe00000))))) >> (8)) != 0) ? 8 +
((((u_long)((((((((0xe00000)) >> 8)) - 1) & ((((0xe00000
)) >> 8))) ^ ((((0xe00000)) >> 8)))) >> (4)
) != 0) ? 4 + ((((u_long)(((((((((0xe00000)) >> 8) >>
4)) - 1) & (((((0xe00000)) >> 8) >> 4))) ^ (
((((0xe00000)) >> 8) >> 4)))) >> (2)) != 0)
? 2 + ((((u_long)((((((((((0xe00000)) >> 8) >> 4
) >> 2)) - 1) & ((((((0xe00000)) >> 8) >>
4) >> 2))) ^ ((((((0xe00000)) >> 8) >> 4) >>
2)))) >> (1)) != 0) ? 1 : 0) : ((((u_long)((((((((((0xe00000
)) >> 8) >> 4))) - 1) & ((((((0xe00000)) >>
8) >> 4)))) ^ ((((((0xe00000)) >> 8) >> 4)
)))) >> (1)) != 0) ? 1 : 0)) : ((((u_long)(((((((((0xe00000
)) >> 8))) - 1) & (((((0xe00000)) >> 8)))) ^ (
((((0xe00000)) >> 8))))) >> (2)) != 0) ? 2 + ((((
u_long)((((((((((0xe00000)) >> 8)) >> 2)) - 1) &
((((((0xe00000)) >> 8)) >> 2))) ^ ((((((0xe00000
)) >> 8)) >> 2)))) >> (1)) != 0) ? 1 : 0) :
((((u_long)((((((((((0xe00000)) >> 8)))) - 1) & ((
((((0xe00000)) >> 8))))) ^ ((((((0xe00000)) >> 8)
))))) >> (1)) != 0) ? 1 : 0))) : ((((u_long)((((((((0xe00000
)))) - 1) & ((((0xe00000))))) ^ ((((0xe00000)))))) >>
(4)) != 0) ? 4 + ((((u_long)(((((((((0xe00000))) >> 4)
) - 1) & (((((0xe00000))) >> 4))) ^ (((((0xe00000))
) >> 4)))) >> (2)) != 0) ? 2 + ((((u_long)(((((((
(((0xe00000))) >> 4) >> 2)) - 1) & ((((((0xe00000
))) >> 4) >> 2))) ^ ((((((0xe00000))) >> 4)
>> 2)))) >> (1)) != 0) ? 1 : 0) : ((((u_long)(((
(((((((0xe00000))) >> 4))) - 1) & ((((((0xe00000)))
>> 4)))) ^ ((((((0xe00000))) >> 4))))) >> (
1)) != 0) ? 1 : 0)) : ((((u_long)(((((((((0xe00000))))) - 1) &
(((((0xe00000)))))) ^ (((((0xe00000))))))) >> (2)) != 0
) ? 2 + ((((u_long)((((((((((0xe00000)))) >> 2)) - 1) &
((((((0xe00000)))) >> 2))) ^ ((((((0xe00000)))) >>
2)))) >> (1)) != 0) ? 1 : 0) : ((((u_long)((((((((((0xe00000
)))))) - 1) & ((((((0xe00000))))))) ^ ((((((0xe00000)))))
))) >> (1)) != 0) ? 1 : 0))))))
|
449 LSHIFT(7, RTW_TCR_SRL_MASK)((7) << ((((u_long)((((((0xff00)) - 1) & ((0xff00))
) ^ ((0xff00)))) >> (16)) != 0) ? 16 + ((((u_long)(((((
((0xff00) >> 16)) - 1) & (((0xff00) >> 16))) ^
(((0xff00) >> 16)))) >> (8)) != 0) ? 8 + ((((u_long
)((((((((0xff00) >> 16) >> 8)) - 1) & ((((0xff00
) >> 16) >> 8))) ^ ((((0xff00) >> 16) >>
8)))) >> (4)) != 0) ? 4 + ((((u_long)(((((((((0xff00) >>
16) >> 8) >> 4)) - 1) & (((((0xff00) >>
16) >> 8) >> 4))) ^ (((((0xff00) >> 16) >>
8) >> 4)))) >> (2)) != 0) ? 2 + ((((u_long)(((((
(((((0xff00) >> 16) >> 8) >> 4) >> 2)
) - 1) & ((((((0xff00) >> 16) >> 8) >> 4
) >> 2))) ^ ((((((0xff00) >> 16) >> 8) >>
4) >> 2)))) >> (1)) != 0) ? 1 : 0) : ((((u_long)
((((((((((0xff00) >> 16) >> 8) >> 4))) - 1)
& ((((((0xff00) >> 16) >> 8) >> 4)))) ^
((((((0xff00) >> 16) >> 8) >> 4))))) >>
(1)) != 0) ? 1 : 0)) : ((((u_long)(((((((((0xff00) >> 16
) >> 8))) - 1) & (((((0xff00) >> 16) >>
8)))) ^ (((((0xff00) >> 16) >> 8))))) >> (
2)) != 0) ? 2 + ((((u_long)((((((((((0xff00) >> 16) >>
8)) >> 2)) - 1) & ((((((0xff00) >> 16) >>
8)) >> 2))) ^ ((((((0xff00) >> 16) >> 8)) >>
2)))) >> (1)) != 0) ? 1 : 0) : ((((u_long)((((((((((0xff00
) >> 16) >> 8)))) - 1) & ((((((0xff00) >>
16) >> 8))))) ^ ((((((0xff00) >> 16) >> 8)
))))) >> (1)) != 0) ? 1 : 0))) : ((((u_long)((((((((0xff00
) >> 16))) - 1) & ((((0xff00) >> 16)))) ^ (((
(0xff00) >> 16))))) >> (4)) != 0) ? 4 + ((((u_long
)(((((((((0xff00) >> 16)) >> 4)) - 1) & (((((
0xff00) >> 16)) >> 4))) ^ (((((0xff00) >> 16
)) >> 4)))) >> (2)) != 0) ? 2 + ((((u_long)((((((
((((0xff00) >> 16)) >> 4) >> 2)) - 1) &
((((((0xff00) >> 16)) >> 4) >> 2))) ^ ((((
((0xff00) >> 16)) >> 4) >> 2)))) >> (
1)) != 0) ? 1 : 0) : ((((u_long)((((((((((0xff00) >> 16
)) >> 4))) - 1) & ((((((0xff00) >> 16)) >>
4)))) ^ ((((((0xff00) >> 16)) >> 4))))) >>
(1)) != 0) ? 1 : 0)) : ((((u_long)(((((((((0xff00) >> 16
)))) - 1) & (((((0xff00) >> 16))))) ^ (((((0xff00) >>
16)))))) >> (2)) != 0) ? 2 + ((((u_long)((((((((((0xff00
) >> 16))) >> 2)) - 1) & ((((((0xff00) >>
16))) >> 2))) ^ ((((((0xff00) >> 16))) >> 2
)))) >> (1)) != 0) ? 1 : 0) : ((((u_long)((((((((((0xff00
) >> 16))))) - 1) & ((((((0xff00) >> 16))))))
^ ((((((0xff00) >> 16))))))) >> (1)) != 0) ? 1 :
0)))) : ((((u_long)(((((((0xff00))) - 1) & (((0xff00))))
^ (((0xff00))))) >> (8)) != 0) ? 8 + ((((u_long)((((((
((0xff00)) >> 8)) - 1) & ((((0xff00)) >> 8)))
^ ((((0xff00)) >> 8)))) >> (4)) != 0) ? 4 + ((((
u_long)(((((((((0xff00)) >> 8) >> 4)) - 1) & (
((((0xff00)) >> 8) >> 4))) ^ (((((0xff00)) >>
8) >> 4)))) >> (2)) != 0) ? 2 + ((((u_long)(((((
(((((0xff00)) >> 8) >> 4) >> 2)) - 1) &
((((((0xff00)) >> 8) >> 4) >> 2))) ^ (((((
(0xff00)) >> 8) >> 4) >> 2)))) >> (1)
) != 0) ? 1 : 0) : ((((u_long)((((((((((0xff00)) >> 8) >>
4))) - 1) & ((((((0xff00)) >> 8) >> 4)))) ^ (
(((((0xff00)) >> 8) >> 4))))) >> (1)) != 0)
? 1 : 0)) : ((((u_long)(((((((((0xff00)) >> 8))) - 1) &
(((((0xff00)) >> 8)))) ^ (((((0xff00)) >> 8)))))
>> (2)) != 0) ? 2 + ((((u_long)((((((((((0xff00)) >>
8)) >> 2)) - 1) & ((((((0xff00)) >> 8)) >>
2))) ^ ((((((0xff00)) >> 8)) >> 2)))) >> (
1)) != 0) ? 1 : 0) : ((((u_long)((((((((((0xff00)) >> 8
)))) - 1) & ((((((0xff00)) >> 8))))) ^ ((((((0xff00
)) >> 8)))))) >> (1)) != 0) ? 1 : 0))) : ((((u_long
)((((((((0xff00)))) - 1) & ((((0xff00))))) ^ ((((0xff00))
)))) >> (4)) != 0) ? 4 + ((((u_long)(((((((((0xff00))) >>
4)) - 1) & (((((0xff00))) >> 4))) ^ (((((0xff00)))
>> 4)))) >> (2)) != 0) ? 2 + ((((u_long)((((((((
((0xff00))) >> 4) >> 2)) - 1) & ((((((0xff00)
)) >> 4) >> 2))) ^ ((((((0xff00))) >> 4) >>
2)))) >> (1)) != 0) ? 1 : 0) : ((((u_long)((((((((((0xff00
))) >> 4))) - 1) & ((((((0xff00))) >> 4)))) ^
((((((0xff00))) >> 4))))) >> (1)) != 0) ? 1 : 0)
) : ((((u_long)(((((((((0xff00))))) - 1) & (((((0xff00)))
))) ^ (((((0xff00))))))) >> (2)) != 0) ? 2 + ((((u_long
)((((((((((0xff00)))) >> 2)) - 1) & ((((((0xff00)))
) >> 2))) ^ ((((((0xff00)))) >> 2)))) >> (1
)) != 0) ? 1 : 0) : ((((u_long)((((((((((0xff00)))))) - 1) &
((((((0xff00))))))) ^ ((((((0xff00)))))))) >> (1)) != 0
) ? 1 : 0))))))
| LSHIFT(7, RTW_TCR_LRL_MASK)((7) << ((((u_long)((((((0xff)) - 1) & ((0xff))) ^ (
(0xff)))) >> (16)) != 0) ? 16 + ((((u_long)(((((((0xff)
>> 16)) - 1) & (((0xff) >> 16))) ^ (((0xff) >>
16)))) >> (8)) != 0) ? 8 + ((((u_long)((((((((0xff) >>
16) >> 8)) - 1) & ((((0xff) >> 16) >> 8
))) ^ ((((0xff) >> 16) >> 8)))) >> (4)) != 0
) ? 4 + ((((u_long)(((((((((0xff) >> 16) >> 8) >>
4)) - 1) & (((((0xff) >> 16) >> 8) >> 4
))) ^ (((((0xff) >> 16) >> 8) >> 4)))) >>
(2)) != 0) ? 2 + ((((u_long)((((((((((0xff) >> 16) >>
8) >> 4) >> 2)) - 1) & ((((((0xff) >> 16
) >> 8) >> 4) >> 2))) ^ ((((((0xff) >>
16) >> 8) >> 4) >> 2)))) >> (1)) != 0
) ? 1 : 0) : ((((u_long)((((((((((0xff) >> 16) >>
8) >> 4))) - 1) & ((((((0xff) >> 16) >>
8) >> 4)))) ^ ((((((0xff) >> 16) >> 8) >>
4))))) >> (1)) != 0) ? 1 : 0)) : ((((u_long)(((((((((0xff
) >> 16) >> 8))) - 1) & (((((0xff) >> 16
) >> 8)))) ^ (((((0xff) >> 16) >> 8))))) >>
(2)) != 0) ? 2 + ((((u_long)((((((((((0xff) >> 16) >>
8)) >> 2)) - 1) & ((((((0xff) >> 16) >>
8)) >> 2))) ^ ((((((0xff) >> 16) >> 8)) >>
2)))) >> (1)) != 0) ? 1 : 0) : ((((u_long)((((((((((0xff
) >> 16) >> 8)))) - 1) & ((((((0xff) >>
16) >> 8))))) ^ ((((((0xff) >> 16) >> 8)))
))) >> (1)) != 0) ? 1 : 0))) : ((((u_long)((((((((0xff)
>> 16))) - 1) & ((((0xff) >> 16)))) ^ ((((0xff
) >> 16))))) >> (4)) != 0) ? 4 + ((((u_long)(((((
((((0xff) >> 16)) >> 4)) - 1) & (((((0xff) >>
16)) >> 4))) ^ (((((0xff) >> 16)) >> 4))))
>> (2)) != 0) ? 2 + ((((u_long)((((((((((0xff) >>
16)) >> 4) >> 2)) - 1) & ((((((0xff) >>
16)) >> 4) >> 2))) ^ ((((((0xff) >> 16)) >>
4) >> 2)))) >> (1)) != 0) ? 1 : 0) : ((((u_long)
((((((((((0xff) >> 16)) >> 4))) - 1) & ((((((
0xff) >> 16)) >> 4)))) ^ ((((((0xff) >> 16)
) >> 4))))) >> (1)) != 0) ? 1 : 0)) : ((((u_long)
(((((((((0xff) >> 16)))) - 1) & (((((0xff) >>
16))))) ^ (((((0xff) >> 16)))))) >> (2)) != 0) ?
2 + ((((u_long)((((((((((0xff) >> 16))) >> 2)) -
1) & ((((((0xff) >> 16))) >> 2))) ^ ((((((0xff
) >> 16))) >> 2)))) >> (1)) != 0) ? 1 : 0) :
((((u_long)((((((((((0xff) >> 16))))) - 1) & (((((
(0xff) >> 16)))))) ^ ((((((0xff) >> 16))))))) >>
(1)) != 0) ? 1 : 0)))) : ((((u_long)(((((((0xff))) - 1) &
(((0xff)))) ^ (((0xff))))) >> (8)) != 0) ? 8 + ((((u_long
)((((((((0xff)) >> 8)) - 1) & ((((0xff)) >> 8
))) ^ ((((0xff)) >> 8)))) >> (4)) != 0) ? 4 + (((
(u_long)(((((((((0xff)) >> 8) >> 4)) - 1) & (
((((0xff)) >> 8) >> 4))) ^ (((((0xff)) >> 8
) >> 4)))) >> (2)) != 0) ? 2 + ((((u_long)(((((((
(((0xff)) >> 8) >> 4) >> 2)) - 1) & (((
(((0xff)) >> 8) >> 4) >> 2))) ^ ((((((0xff)
) >> 8) >> 4) >> 2)))) >> (1)) != 0) ?
1 : 0) : ((((u_long)((((((((((0xff)) >> 8) >> 4)
)) - 1) & ((((((0xff)) >> 8) >> 4)))) ^ (((((
(0xff)) >> 8) >> 4))))) >> (1)) != 0) ? 1 :
0)) : ((((u_long)(((((((((0xff)) >> 8))) - 1) & ((
(((0xff)) >> 8)))) ^ (((((0xff)) >> 8))))) >>
(2)) != 0) ? 2 + ((((u_long)((((((((((0xff)) >> 8)) >>
2)) - 1) & ((((((0xff)) >> 8)) >> 2))) ^ (((
(((0xff)) >> 8)) >> 2)))) >> (1)) != 0) ? 1
: 0) : ((((u_long)((((((((((0xff)) >> 8)))) - 1) &
((((((0xff)) >> 8))))) ^ ((((((0xff)) >> 8))))))
>> (1)) != 0) ? 1 : 0))) : ((((u_long)((((((((0xff))))
- 1) & ((((0xff))))) ^ ((((0xff)))))) >> (4)) != 0
) ? 4 + ((((u_long)(((((((((0xff))) >> 4)) - 1) & (
((((0xff))) >> 4))) ^ (((((0xff))) >> 4)))) >>
(2)) != 0) ? 2 + ((((u_long)((((((((((0xff))) >> 4) >>
2)) - 1) & ((((((0xff))) >> 4) >> 2))) ^ (((
(((0xff))) >> 4) >> 2)))) >> (1)) != 0) ? 1
: 0) : ((((u_long)((((((((((0xff))) >> 4))) - 1) &
((((((0xff))) >> 4)))) ^ ((((((0xff))) >> 4)))))
>> (1)) != 0) ? 1 : 0)) : ((((u_long)(((((((((0xff))))
) - 1) & (((((0xff)))))) ^ (((((0xff))))))) >> (2))
!= 0) ? 2 + ((((u_long)((((((((((0xff)))) >> 2)) - 1) &
((((((0xff)))) >> 2))) ^ ((((((0xff)))) >> 2))))
>> (1)) != 0) ? 1 : 0) : ((((u_long)((((((((((0xff))))
)) - 1) & ((((((0xff))))))) ^ ((((((0xff)))))))) >>
(1)) != 0) ? 1 : 0))))))
;
450
451 RTW_WRITE(regs, RTW_TCR, tcr)((*(regs)->r_write32)(regs, 0x40, tcr));
452
453 RTW_WBW(regs, RTW_CR, RTW_TCR)((*(regs)->r_barrier)(regs, 0x37, 0x40, 0x02));
454
455 return rtw_chip_reset1(regs, dvname);
456}
457
458int
459rtw_recall_eeprom(struct rtw_regs *regs, const char *dvname)
460{
461 int i;
462 u_int8_t ecr;
463
464 ecr = RTW_READ8(regs, RTW_9346CR)((*(regs)->r_read8)(regs, 0x50));
465 ecr = (ecr & ~RTW_9346CR_EEM_MASK0xc0) | RTW_9346CR_EEM_AUTOLOAD((1) << ((((u_long)((((((0xc0)) - 1) & ((0xc0))) ^ (
(0xc0)))) >> (16)) != 0) ? 16 + ((((u_long)(((((((0xc0)
>> 16)) - 1) & (((0xc0) >> 16))) ^ (((0xc0) >>
16)))) >> (8)) != 0) ? 8 + ((((u_long)((((((((0xc0) >>
16) >> 8)) - 1) & ((((0xc0) >> 16) >> 8
))) ^ ((((0xc0) >> 16) >> 8)))) >> (4)) != 0
) ? 4 + ((((u_long)(((((((((0xc0) >> 16) >> 8) >>
4)) - 1) & (((((0xc0) >> 16) >> 8) >> 4
))) ^ (((((0xc0) >> 16) >> 8) >> 4)))) >>
(2)) != 0) ? 2 + ((((u_long)((((((((((0xc0) >> 16) >>
8) >> 4) >> 2)) - 1) & ((((((0xc0) >> 16
) >> 8) >> 4) >> 2))) ^ ((((((0xc0) >>
16) >> 8) >> 4) >> 2)))) >> (1)) != 0
) ? 1 : 0) : ((((u_long)((((((((((0xc0) >> 16) >>
8) >> 4))) - 1) & ((((((0xc0) >> 16) >>
8) >> 4)))) ^ ((((((0xc0) >> 16) >> 8) >>
4))))) >> (1)) != 0) ? 1 : 0)) : ((((u_long)(((((((((0xc0
) >> 16) >> 8))) - 1) & (((((0xc0) >> 16
) >> 8)))) ^ (((((0xc0) >> 16) >> 8))))) >>
(2)) != 0) ? 2 + ((((u_long)((((((((((0xc0) >> 16) >>
8)) >> 2)) - 1) & ((((((0xc0) >> 16) >>
8)) >> 2))) ^ ((((((0xc0) >> 16) >> 8)) >>
2)))) >> (1)) != 0) ? 1 : 0) : ((((u_long)((((((((((0xc0
) >> 16) >> 8)))) - 1) & ((((((0xc0) >>
16) >> 8))))) ^ ((((((0xc0) >> 16) >> 8)))
))) >> (1)) != 0) ? 1 : 0))) : ((((u_long)((((((((0xc0)
>> 16))) - 1) & ((((0xc0) >> 16)))) ^ ((((0xc0
) >> 16))))) >> (4)) != 0) ? 4 + ((((u_long)(((((
((((0xc0) >> 16)) >> 4)) - 1) & (((((0xc0) >>
16)) >> 4))) ^ (((((0xc0) >> 16)) >> 4))))
>> (2)) != 0) ? 2 + ((((u_long)((((((((((0xc0) >>
16)) >> 4) >> 2)) - 1) & ((((((0xc0) >>
16)) >> 4) >> 2))) ^ ((((((0xc0) >> 16)) >>
4) >> 2)))) >> (1)) != 0) ? 1 : 0) : ((((u_long)
((((((((((0xc0) >> 16)) >> 4))) - 1) & ((((((
0xc0) >> 16)) >> 4)))) ^ ((((((0xc0) >> 16)
) >> 4))))) >> (1)) != 0) ? 1 : 0)) : ((((u_long)
(((((((((0xc0) >> 16)))) - 1) & (((((0xc0) >>
16))))) ^ (((((0xc0) >> 16)))))) >> (2)) != 0) ?
2 + ((((u_long)((((((((((0xc0) >> 16))) >> 2)) -
1) & ((((((0xc0) >> 16))) >> 2))) ^ ((((((0xc0
) >> 16))) >> 2)))) >> (1)) != 0) ? 1 : 0) :
((((u_long)((((((((((0xc0) >> 16))))) - 1) & (((((
(0xc0) >> 16)))))) ^ ((((((0xc0) >> 16))))))) >>
(1)) != 0) ? 1 : 0)))) : ((((u_long)(((((((0xc0))) - 1) &
(((0xc0)))) ^ (((0xc0))))) >> (8)) != 0) ? 8 + ((((u_long
)((((((((0xc0)) >> 8)) - 1) & ((((0xc0)) >> 8
))) ^ ((((0xc0)) >> 8)))) >> (4)) != 0) ? 4 + (((
(u_long)(((((((((0xc0)) >> 8) >> 4)) - 1) & (
((((0xc0)) >> 8) >> 4))) ^ (((((0xc0)) >> 8
) >> 4)))) >> (2)) != 0) ? 2 + ((((u_long)(((((((
(((0xc0)) >> 8) >> 4) >> 2)) - 1) & (((
(((0xc0)) >> 8) >> 4) >> 2))) ^ ((((((0xc0)
) >> 8) >> 4) >> 2)))) >> (1)) != 0) ?
1 : 0) : ((((u_long)((((((((((0xc0)) >> 8) >> 4)
)) - 1) & ((((((0xc0)) >> 8) >> 4)))) ^ (((((
(0xc0)) >> 8) >> 4))))) >> (1)) != 0) ? 1 :
0)) : ((((u_long)(((((((((0xc0)) >> 8))) - 1) & ((
(((0xc0)) >> 8)))) ^ (((((0xc0)) >> 8))))) >>
(2)) != 0) ? 2 + ((((u_long)((((((((((0xc0)) >> 8)) >>
2)) - 1) & ((((((0xc0)) >> 8)) >> 2))) ^ (((
(((0xc0)) >> 8)) >> 2)))) >> (1)) != 0) ? 1
: 0) : ((((u_long)((((((((((0xc0)) >> 8)))) - 1) &
((((((0xc0)) >> 8))))) ^ ((((((0xc0)) >> 8))))))
>> (1)) != 0) ? 1 : 0))) : ((((u_long)((((((((0xc0))))
- 1) & ((((0xc0))))) ^ ((((0xc0)))))) >> (4)) != 0
) ? 4 + ((((u_long)(((((((((0xc0))) >> 4)) - 1) & (
((((0xc0))) >> 4))) ^ (((((0xc0))) >> 4)))) >>
(2)) != 0) ? 2 + ((((u_long)((((((((((0xc0))) >> 4) >>
2)) - 1) & ((((((0xc0))) >> 4) >> 2))) ^ (((
(((0xc0))) >> 4) >> 2)))) >> (1)) != 0) ? 1
: 0) : ((((u_long)((((((((((0xc0))) >> 4))) - 1) &
((((((0xc0))) >> 4)))) ^ ((((((0xc0))) >> 4)))))
>> (1)) != 0) ? 1 : 0)) : ((((u_long)(((((((((0xc0))))
) - 1) & (((((0xc0)))))) ^ (((((0xc0))))))) >> (2))
!= 0) ? 2 + ((((u_long)((((((((((0xc0)))) >> 2)) - 1) &
((((((0xc0)))) >> 2))) ^ ((((((0xc0)))) >> 2))))
>> (1)) != 0) ? 1 : 0) : ((((u_long)((((((((((0xc0))))
)) - 1) & ((((((0xc0))))))) ^ ((((((0xc0)))))))) >>
(1)) != 0) ? 1 : 0))))))
;
466 RTW_WRITE8(regs, RTW_9346CR, ecr)((*(regs)->r_write8)(regs, 0x50, ecr));
467
468 RTW_WBR(regs, RTW_9346CR, RTW_9346CR)((*(regs)->r_barrier)(regs, 0x50, 0x50, 0x02));
469
470 /* wait 10ms for completion */
471 for (i = 0; i < 50; i++) {
472 ecr = RTW_READ8(regs, RTW_9346CR)((*(regs)->r_read8)(regs, 0x50));
473 if ((ecr & RTW_9346CR_EEM_MASK0xc0) == RTW_9346CR_EEM_NORMAL((0) << ((((u_long)((((((0xc0)) - 1) & ((0xc0))) ^ (
(0xc0)))) >> (16)) != 0) ? 16 + ((((u_long)(((((((0xc0)
>> 16)) - 1) & (((0xc0) >> 16))) ^ (((0xc0) >>
16)))) >> (8)) != 0) ? 8 + ((((u_long)((((((((0xc0) >>
16) >> 8)) - 1) & ((((0xc0) >> 16) >> 8
))) ^ ((((0xc0) >> 16) >> 8)))) >> (4)) != 0
) ? 4 + ((((u_long)(((((((((0xc0) >> 16) >> 8) >>
4)) - 1) & (((((0xc0) >> 16) >> 8) >> 4
))) ^ (((((0xc0) >> 16) >> 8) >> 4)))) >>
(2)) != 0) ? 2 + ((((u_long)((((((((((0xc0) >> 16) >>
8) >> 4) >> 2)) - 1) & ((((((0xc0) >> 16
) >> 8) >> 4) >> 2))) ^ ((((((0xc0) >>
16) >> 8) >> 4) >> 2)))) >> (1)) != 0
) ? 1 : 0) : ((((u_long)((((((((((0xc0) >> 16) >>
8) >> 4))) - 1) & ((((((0xc0) >> 16) >>
8) >> 4)))) ^ ((((((0xc0) >> 16) >> 8) >>
4))))) >> (1)) != 0) ? 1 : 0)) : ((((u_long)(((((((((0xc0
) >> 16) >> 8))) - 1) & (((((0xc0) >> 16
) >> 8)))) ^ (((((0xc0) >> 16) >> 8))))) >>
(2)) != 0) ? 2 + ((((u_long)((((((((((0xc0) >> 16) >>
8)) >> 2)) - 1) & ((((((0xc0) >> 16) >>
8)) >> 2))) ^ ((((((0xc0) >> 16) >> 8)) >>
2)))) >> (1)) != 0) ? 1 : 0) : ((((u_long)((((((((((0xc0
) >> 16) >> 8)))) - 1) & ((((((0xc0) >>
16) >> 8))))) ^ ((((((0xc0) >> 16) >> 8)))
))) >> (1)) != 0) ? 1 : 0))) : ((((u_long)((((((((0xc0)
>> 16))) - 1) & ((((0xc0) >> 16)))) ^ ((((0xc0
) >> 16))))) >> (4)) != 0) ? 4 + ((((u_long)(((((
((((0xc0) >> 16)) >> 4)) - 1) & (((((0xc0) >>
16)) >> 4))) ^ (((((0xc0) >> 16)) >> 4))))
>> (2)) != 0) ? 2 + ((((u_long)((((((((((0xc0) >>
16)) >> 4) >> 2)) - 1) & ((((((0xc0) >>
16)) >> 4) >> 2))) ^ ((((((0xc0) >> 16)) >>
4) >> 2)))) >> (1)) != 0) ? 1 : 0) : ((((u_long)
((((((((((0xc0) >> 16)) >> 4))) - 1) & ((((((
0xc0) >> 16)) >> 4)))) ^ ((((((0xc0) >> 16)
) >> 4))))) >> (1)) != 0) ? 1 : 0)) : ((((u_long)
(((((((((0xc0) >> 16)))) - 1) & (((((0xc0) >>
16))))) ^ (((((0xc0) >> 16)))))) >> (2)) != 0) ?
2 + ((((u_long)((((((((((0xc0) >> 16))) >> 2)) -
1) & ((((((0xc0) >> 16))) >> 2))) ^ ((((((0xc0
) >> 16))) >> 2)))) >> (1)) != 0) ? 1 : 0) :
((((u_long)((((((((((0xc0) >> 16))))) - 1) & (((((
(0xc0) >> 16)))))) ^ ((((((0xc0) >> 16))))))) >>
(1)) != 0) ? 1 : 0)))) : ((((u_long)(((((((0xc0))) - 1) &
(((0xc0)))) ^ (((0xc0))))) >> (8)) != 0) ? 8 + ((((u_long
)((((((((0xc0)) >> 8)) - 1) & ((((0xc0)) >> 8
))) ^ ((((0xc0)) >> 8)))) >> (4)) != 0) ? 4 + (((
(u_long)(((((((((0xc0)) >> 8) >> 4)) - 1) & (
((((0xc0)) >> 8) >> 4))) ^ (((((0xc0)) >> 8
) >> 4)))) >> (2)) != 0) ? 2 + ((((u_long)(((((((
(((0xc0)) >> 8) >> 4) >> 2)) - 1) & (((
(((0xc0)) >> 8) >> 4) >> 2))) ^ ((((((0xc0)
) >> 8) >> 4) >> 2)))) >> (1)) != 0) ?
1 : 0) : ((((u_long)((((((((((0xc0)) >> 8) >> 4)
)) - 1) & ((((((0xc0)) >> 8) >> 4)))) ^ (((((
(0xc0)) >> 8) >> 4))))) >> (1)) != 0) ? 1 :
0)) : ((((u_long)(((((((((0xc0)) >> 8))) - 1) & ((
(((0xc0)) >> 8)))) ^ (((((0xc0)) >> 8))))) >>
(2)) != 0) ? 2 + ((((u_long)((((((((((0xc0)) >> 8)) >>
2)) - 1) & ((((((0xc0)) >> 8)) >> 2))) ^ (((
(((0xc0)) >> 8)) >> 2)))) >> (1)) != 0) ? 1
: 0) : ((((u_long)((((((((((0xc0)) >> 8)))) - 1) &
((((((0xc0)) >> 8))))) ^ ((((((0xc0)) >> 8))))))
>> (1)) != 0) ? 1 : 0))) : ((((u_long)((((((((0xc0))))
- 1) & ((((0xc0))))) ^ ((((0xc0)))))) >> (4)) != 0
) ? 4 + ((((u_long)(((((((((0xc0))) >> 4)) - 1) & (
((((0xc0))) >> 4))) ^ (((((0xc0))) >> 4)))) >>
(2)) != 0) ? 2 + ((((u_long)((((((((((0xc0))) >> 4) >>
2)) - 1) & ((((((0xc0))) >> 4) >> 2))) ^ (((
(((0xc0))) >> 4) >> 2)))) >> (1)) != 0) ? 1
: 0) : ((((u_long)((((((((((0xc0))) >> 4))) - 1) &
((((((0xc0))) >> 4)))) ^ ((((((0xc0))) >> 4)))))
>> (1)) != 0) ? 1 : 0)) : ((((u_long)(((((((((0xc0))))
) - 1) & (((((0xc0)))))) ^ (((((0xc0))))))) >> (2))
!= 0) ? 2 + ((((u_long)((((((((((0xc0)))) >> 2)) - 1) &
((((((0xc0)))) >> 2))) ^ ((((((0xc0)))) >> 2))))
>> (1)) != 0) ? 1 : 0) : ((((u_long)((((((((((0xc0))))
)) - 1) & ((((((0xc0))))))) ^ ((((((0xc0)))))))) >>
(1)) != 0) ? 1 : 0))))))
) {
474 RTW_DPRINTF(RTW_DEBUG_RESET,
475 ("%s: recall EEPROM in %dus\n", dvname, i * 200));
476 return (0);
477 }
478 RTW_RBR(regs, RTW_9346CR, RTW_9346CR)((*(regs)->r_barrier)(regs, 0x50, 0x50, 0x01));
479 DELAY(200)(*delay_func)(200);
480 }
481
482 printf("\n%s: could not recall EEPROM in %dus\n", dvname, i * 200);
483
484 return (ETIMEDOUT60);
485}
486
487int
488rtw_reset(struct rtw_softc *sc)
489{
490 int rc;
491 uint8_t config1;
492
493 if ((rc = rtw_chip_reset(&sc->sc_regs, sc->sc_dev.dv_xname)) != 0)
494 return rc;
495
496 if ((rc = rtw_recall_eeprom(&sc->sc_regs, sc->sc_dev.dv_xname)) != 0)
497 ;
498
499 config1 = RTW_READ8(&sc->sc_regs, RTW_CONFIG1)((*(&sc->sc_regs)->r_read8)(&sc->sc_regs, 0x52
))
;
500 RTW_WRITE8(&sc->sc_regs, RTW_CONFIG1, config1 & ~RTW_CONFIG1_PMEN)((*(&sc->sc_regs)->r_write8)(&sc->sc_regs, 0x52
, config1 & ~(1<<0)))
;
501 /* TBD turn off maximum power saving? */
502
503 return 0;
504}
505
506int
507rtw_txdesc_dmamaps_create(bus_dma_tag_t dmat, struct rtw_txsoft *descs,
508 u_int ndescs)
509{
510 int i, rc = 0;
511 for (i = 0; i < ndescs; i++) {
512 rc = bus_dmamap_create(dmat, MCLBYTES, RTW_MAXPKTSEGS, MCLBYTES,(*(dmat)->_dmamap_create)((dmat), ((1 << 11)), (64),
((1 << 11)), (0), (0), (&descs[i].ts_dmamap))
513 0, 0, &descs[i].ts_dmamap)(*(dmat)->_dmamap_create)((dmat), ((1 << 11)), (64),
((1 << 11)), (0), (0), (&descs[i].ts_dmamap))
;
514 if (rc != 0)
515 break;
516 }
517 return rc;
518}
519
520int
521rtw_rxdesc_dmamaps_create(bus_dma_tag_t dmat, struct rtw_rxsoft *descs,
522 u_int ndescs)
523{
524 int i, rc = 0;
525 for (i = 0; i < ndescs; i++) {
526 rc = bus_dmamap_create(dmat, MCLBYTES, 1, MCLBYTES, 0, 0,(*(dmat)->_dmamap_create)((dmat), ((1 << 11)), (1), (
(1 << 11)), (0), (0), (&descs[i].rs_dmamap))
527 &descs[i].rs_dmamap)(*(dmat)->_dmamap_create)((dmat), ((1 << 11)), (1), (
(1 << 11)), (0), (0), (&descs[i].rs_dmamap))
;
528 if (rc != 0)
529 break;
530 }
531 return rc;
532}
533
534void
535rtw_rxdesc_dmamaps_destroy(bus_dma_tag_t dmat, struct rtw_rxsoft *descs,
536 u_int ndescs)
537{
538 int i;
539 for (i = 0; i < ndescs; i++) {
540 if (descs[i].rs_dmamap != NULL((void *)0))
541 bus_dmamap_destroy(dmat, descs[i].rs_dmamap)(*(dmat)->_dmamap_destroy)((dmat), (descs[i].rs_dmamap));
542 }
543}
544
545void
546rtw_txdesc_dmamaps_destroy(bus_dma_tag_t dmat, struct rtw_txsoft *descs,
547 u_int ndescs)
548{
549 int i;
550 for (i = 0; i < ndescs; i++) {
551 if (descs[i].ts_dmamap != NULL((void *)0))
552 bus_dmamap_destroy(dmat, descs[i].ts_dmamap)(*(dmat)->_dmamap_destroy)((dmat), (descs[i].ts_dmamap));
553 }
554}
555
556int
557rtw_srom_parse(struct rtw_softc *sc)
558{
559 int i;
560 struct rtw_srom *sr = &sc->sc_srom;
561 u_int32_t *flags = &sc->sc_flags;
562 u_int8_t *cs_threshold = &sc->sc_csthr;
563 int *rfchipid = &sc->sc_rfchipid;
564 u_int32_t *rcr = &sc->sc_rcr;
565 enum rtw_locale *locale = &sc->sc_locale;
566 u_int16_t version;
567 u_int8_t mac[IEEE80211_ADDR_LEN6];
568
569 *flags &= ~(RTW_F_DIGPHY0x00000002|RTW_F_DFLANTB0x00000004|RTW_F_ANTDIV0x00000010);
570 *rcr &= ~(RTW_RCR_ENCS1(1<<29) | RTW_RCR_ENCS2(1<<30));
571
572 version = RTW_SR_GET16(sr, RTW_SR_VERSION)(((((sr))->sr_content[((0x3c))/2] >> ((((0x3c)) % 2 ==
0) ? 0 : 8)) & 0xff) | (((((sr))->sr_content[((0x3c) +
1)/2] >> ((((0x3c) + 1) % 2 == 0) ? 0 : 8)) & 0xff
) << 8))
;
573 RTW_DPRINTF(RTW_DEBUG_ATTACH,
574 ("%s: SROM %d.%d\n", sc->sc_dev.dv_xname, version >> 8,
575 version & 0xff));
576
577 if (version <= 0x0101) {
578 printf(" is not understood, limping along with defaults ");
579 *flags |= (RTW_F_DIGPHY0x00000002|RTW_F_ANTDIV0x00000010);
580 *cs_threshold = RTW_SR_ENERGYDETTHR_DEFAULT0x0c;
581 *rcr |= RTW_RCR_ENCS1(1<<29);
582 *rfchipid = RTW_RFCHIPID_PHILIPS0x03;
583 return 0;
584 }
585
586 for (i = 0; i < IEEE80211_ADDR_LEN6; i++)
587 mac[i] = RTW_SR_GET(sr, RTW_SR_MAC + i)(((sr)->sr_content[(0x0e + i)/2] >> (((0x0e + i) % 2
== 0) ? 0 : 8)) & 0xff)
;
588
589 RTW_DPRINTF(RTW_DEBUG_ATTACH,
590 ("%s: EEPROM MAC %s\n", sc->sc_dev.dv_xname, ether_sprintf(mac)));
591
592 *cs_threshold = RTW_SR_GET(sr, RTW_SR_ENERGYDETTHR)(((sr)->sr_content[(0x2f)/2] >> (((0x2f) % 2 == 0) ?
0 : 8)) & 0xff)
;
593
594 if ((RTW_SR_GET(sr, RTW_SR_CONFIG2)(((sr)->sr_content[(0x18)/2] >> (((0x18) % 2 == 0) ?
0 : 8)) & 0xff)
& RTW8180_CONFIG2_ANT(1<<6)) != 0)
595 *flags |= RTW_F_ANTDIV0x00000010;
596
597 /* Note well: the sense of the RTW_SR_RFPARM_DIGPHY bit seems
598 * to be reversed.
599 */
600 if ((RTW_SR_GET(sr, RTW_SR_RFPARM)(((sr)->sr_content[(0x32)/2] >> (((0x32) % 2 == 0) ?
0 : 8)) & 0xff)
& RTW_SR_RFPARM_DIGPHY(1<<0)) == 0)
601 *flags |= RTW_F_DIGPHY0x00000002;
602 if ((RTW_SR_GET(sr, RTW_SR_RFPARM)(((sr)->sr_content[(0x32)/2] >> (((0x32) % 2 == 0) ?
0 : 8)) & 0xff)
& RTW_SR_RFPARM_DFLANTB(1<<1)) != 0)
603 *flags |= RTW_F_DFLANTB0x00000004;
604
605 *rcr |= LSHIFT(MASK_AND_RSHIFT(RTW_SR_GET(sr, RTW_SR_RFPARM),((((((((sr)->sr_content[(0x32)/2] >> (((0x32) % 2 ==
0) ? 0 : 8)) & 0xff)) & (0xc)) >> ((((u_long)(
(((((0xc)) - 1) & ((0xc))) ^ ((0xc)))) >> (16)) != 0
) ? 16 + ((((u_long)(((((((0xc) >> 16)) - 1) & (((0xc
) >> 16))) ^ (((0xc) >> 16)))) >> (8)) != 0
) ? 8 + ((((u_long)((((((((0xc) >> 16) >> 8)) - 1
) & ((((0xc) >> 16) >> 8))) ^ ((((0xc) >>
16) >> 8)))) >> (4)) != 0) ? 4 + ((((u_long)((((
(((((0xc) >> 16) >> 8) >> 4)) - 1) & ((
(((0xc) >> 16) >> 8) >> 4))) ^ (((((0xc) >>
16) >> 8) >> 4)))) >> (2)) != 0) ? 2 + (((
(u_long)((((((((((0xc) >> 16) >> 8) >> 4) >>
2)) - 1) & ((((((0xc) >> 16) >> 8) >> 4
) >> 2))) ^ ((((((0xc) >> 16) >> 8) >>
4) >> 2)))) >> (1)) != 0) ? 1 : 0) : ((((u_long)
((((((((((0xc) >> 16) >> 8) >> 4))) - 1) &
((((((0xc) >> 16) >> 8) >> 4)))) ^ ((((((0xc
) >> 16) >> 8) >> 4))))) >> (1)) != 0
) ? 1 : 0)) : ((((u_long)(((((((((0xc) >> 16) >> 8
))) - 1) & (((((0xc) >> 16) >> 8)))) ^ (((((0xc
) >> 16) >> 8))))) >> (2)) != 0) ? 2 + ((((
u_long)((((((((((0xc) >> 16) >> 8)) >> 2)) -
1) & ((((((0xc) >> 16) >> 8)) >> 2))) ^
((((((0xc) >> 16) >> 8)) >> 2)))) >>
(1)) != 0) ? 1 : 0) : ((((u_long)((((((((((0xc) >> 16)
>> 8)))) - 1) & ((((((0xc) >> 16) >> 8
))))) ^ ((((((0xc) >> 16) >> 8)))))) >> (1)
) != 0) ? 1 : 0))) : ((((u_long)((((((((0xc) >> 16))) -
1) & ((((0xc) >> 16)))) ^ ((((0xc) >> 16))))
) >> (4)) != 0) ? 4 + ((((u_long)(((((((((0xc) >>
16)) >> 4)) - 1) & (((((0xc) >> 16)) >>
4))) ^ (((((0xc) >> 16)) >> 4)))) >> (2)) !=
0) ? 2 + ((((u_long)((((((((((0xc) >> 16)) >> 4)
>> 2)) - 1) & ((((((0xc) >> 16)) >> 4)
>> 2))) ^ ((((((0xc) >> 16)) >> 4) >>
2)))) >> (1)) != 0) ? 1 : 0) : ((((u_long)((((((((((0xc
) >> 16)) >> 4))) - 1) & ((((((0xc) >> 16
)) >> 4)))) ^ ((((((0xc) >> 16)) >> 4))))) >>
(1)) != 0) ? 1 : 0)) : ((((u_long)(((((((((0xc) >> 16)
))) - 1) & (((((0xc) >> 16))))) ^ (((((0xc) >>
16)))))) >> (2)) != 0) ? 2 + ((((u_long)((((((((((0xc)
>> 16))) >> 2)) - 1) & ((((((0xc) >> 16
))) >> 2))) ^ ((((((0xc) >> 16))) >> 2)))) >>
(1)) != 0) ? 1 : 0) : ((((u_long)((((((((((0xc) >> 16)
)))) - 1) & ((((((0xc) >> 16)))))) ^ ((((((0xc) >>
16))))))) >> (1)) != 0) ? 1 : 0)))) : ((((u_long)(((((
((0xc))) - 1) & (((0xc)))) ^ (((0xc))))) >> (8)) !=
0) ? 8 + ((((u_long)((((((((0xc)) >> 8)) - 1) & ((
((0xc)) >> 8))) ^ ((((0xc)) >> 8)))) >> (4)
) != 0) ? 4 + ((((u_long)(((((((((0xc)) >> 8) >> 4
)) - 1) & (((((0xc)) >> 8) >> 4))) ^ (((((0xc
)) >> 8) >> 4)))) >> (2)) != 0) ? 2 + ((((u_long
)((((((((((0xc)) >> 8) >> 4) >> 2)) - 1) &
((((((0xc)) >> 8) >> 4) >> 2))) ^ ((((((0xc
)) >> 8) >> 4) >> 2)))) >> (1)) != 0)
? 1 : 0) : ((((u_long)((((((((((0xc)) >> 8) >> 4
))) - 1) & ((((((0xc)) >> 8) >> 4)))) ^ (((((
(0xc)) >> 8) >> 4))))) >> (1)) != 0) ? 1 : 0
)) : ((((u_long)(((((((((0xc)) >> 8))) - 1) & (((((
0xc)) >> 8)))) ^ (((((0xc)) >> 8))))) >> (2
)) != 0) ? 2 + ((((u_long)((((((((((0xc)) >> 8)) >>
2)) - 1) & ((((((0xc)) >> 8)) >> 2))) ^ ((((
((0xc)) >> 8)) >> 2)))) >> (1)) != 0) ? 1 :
0) : ((((u_long)((((((((((0xc)) >> 8)))) - 1) & ((
((((0xc)) >> 8))))) ^ ((((((0xc)) >> 8)))))) >>
(1)) != 0) ? 1 : 0))) : ((((u_long)((((((((0xc)))) - 1) &
((((0xc))))) ^ ((((0xc)))))) >> (4)) != 0) ? 4 + ((((u_long
)(((((((((0xc))) >> 4)) - 1) & (((((0xc))) >>
4))) ^ (((((0xc))) >> 4)))) >> (2)) != 0) ? 2 + (
(((u_long)((((((((((0xc))) >> 4) >> 2)) - 1) &
((((((0xc))) >> 4) >> 2))) ^ ((((((0xc))) >>
4) >> 2)))) >> (1)) != 0) ? 1 : 0) : ((((u_long)
((((((((((0xc))) >> 4))) - 1) & ((((((0xc))) >>
4)))) ^ ((((((0xc))) >> 4))))) >> (1)) != 0) ? 1
: 0)) : ((((u_long)(((((((((0xc))))) - 1) & (((((0xc))))
)) ^ (((((0xc))))))) >> (2)) != 0) ? 2 + ((((u_long)(((
(((((((0xc)))) >> 2)) - 1) & ((((((0xc)))) >>
2))) ^ ((((((0xc)))) >> 2)))) >> (1)) != 0) ? 1 :
0) : ((((u_long)((((((((((0xc)))))) - 1) & ((((((0xc))))
))) ^ ((((((0xc)))))))) >> (1)) != 0) ? 1 : 0))))))) <<
((((u_long)(((((((1<<29))) - 1) & (((1<<29))
)) ^ (((1<<29))))) >> (16)) != 0) ? 16 + ((((u_long
)((((((((1<<29)) >> 16)) - 1) & ((((1<<
29)) >> 16))) ^ ((((1<<29)) >> 16)))) >>
(8)) != 0) ? 8 + ((((u_long)(((((((((1<<29)) >> 16
) >> 8)) - 1) & (((((1<<29)) >> 16) >>
8))) ^ (((((1<<29)) >> 16) >> 8)))) >>
(4)) != 0) ? 4 + ((((u_long)((((((((((1<<29)) >>
16) >> 8) >> 4)) - 1) & ((((((1<<29)) >>
16) >> 8) >> 4))) ^ ((((((1<<29)) >>
16) >> 8) >> 4)))) >> (2)) != 0) ? 2 + (((
(u_long)(((((((((((1<<29)) >> 16) >> 8) >>
4) >> 2)) - 1) & (((((((1<<29)) >> 16)
>> 8) >> 4) >> 2))) ^ (((((((1<<29))
>> 16) >> 8) >> 4) >> 2)))) >>
(1)) != 0) ? 1 : 0) : ((((u_long)(((((((((((1<<29)) >>
16) >> 8) >> 4))) - 1) & (((((((1<<29)
) >> 16) >> 8) >> 4)))) ^ (((((((1<<29
)) >> 16) >> 8) >> 4))))) >> (1)) != 0
) ? 1 : 0)) : ((((u_long)((((((((((1<<29)) >> 16)
>> 8))) - 1) & ((((((1<<29)) >> 16) >>
8)))) ^ ((((((1<<29)) >> 16) >> 8))))) >>
(2)) != 0) ? 2 + ((((u_long)(((((((((((1<<29)) >>
16) >> 8)) >> 2)) - 1) & (((((((1<<29)
) >> 16) >> 8)) >> 2))) ^ (((((((1<<29
)) >> 16) >> 8)) >> 2)))) >> (1)) != 0
) ? 1 : 0) : ((((u_long)(((((((((((1<<29)) >> 16)
>> 8)))) - 1) & (((((((1<<29)) >> 16) >>
8))))) ^ (((((((1<<29)) >> 16) >> 8)))))) >>
(1)) != 0) ? 1 : 0))) : ((((u_long)(((((((((1<<29)) >>
16))) - 1) & (((((1<<29)) >> 16)))) ^ (((((1
<<29)) >> 16))))) >> (4)) != 0) ? 4 + ((((u_long
)((((((((((1<<29)) >> 16)) >> 4)) - 1) &
((((((1<<29)) >> 16)) >> 4))) ^ ((((((1<<
29)) >> 16)) >> 4)))) >> (2)) != 0) ? 2 + (
(((u_long)(((((((((((1<<29)) >> 16)) >> 4) >>
2)) - 1) & (((((((1<<29)) >> 16)) >> 4
) >> 2))) ^ (((((((1<<29)) >> 16)) >>
4) >> 2)))) >> (1)) != 0) ? 1 : 0) : ((((u_long)
(((((((((((1<<29)) >> 16)) >> 4))) - 1) &
(((((((1<<29)) >> 16)) >> 4)))) ^ (((((((1
<<29)) >> 16)) >> 4))))) >> (1)) != 0
) ? 1 : 0)) : ((((u_long)((((((((((1<<29)) >> 16)
))) - 1) & ((((((1<<29)) >> 16))))) ^ ((((((1
<<29)) >> 16)))))) >> (2)) != 0) ? 2 + ((((
u_long)(((((((((((1<<29)) >> 16))) >> 2)) -
1) & (((((((1<<29)) >> 16))) >> 2))) ^
(((((((1<<29)) >> 16))) >> 2)))) >> (
1)) != 0) ? 1 : 0) : ((((u_long)(((((((((((1<<29)) >>
16))))) - 1) & (((((((1<<29)) >> 16)))))) ^ (
((((((1<<29)) >> 16))))))) >> (1)) != 0) ? 1
: 0)))) : ((((u_long)((((((((1<<29)))) - 1) & ((((
1<<29))))) ^ ((((1<<29)))))) >> (8)) != 0) ?
8 + ((((u_long)(((((((((1<<29))) >> 8)) - 1) &
(((((1<<29))) >> 8))) ^ (((((1<<29))) >>
8)))) >> (4)) != 0) ? 4 + ((((u_long)((((((((((1<<
29))) >> 8) >> 4)) - 1) & ((((((1<<29))
) >> 8) >> 4))) ^ ((((((1<<29))) >> 8
) >> 4)))) >> (2)) != 0) ? 2 + ((((u_long)(((((((
((((1<<29))) >> 8) >> 4) >> 2)) - 1) &
(((((((1<<29))) >> 8) >> 4) >> 2))) ^
(((((((1<<29))) >> 8) >> 4) >> 2))))
>> (1)) != 0) ? 1 : 0) : ((((u_long)(((((((((((1<<
29))) >> 8) >> 4))) - 1) & (((((((1<<29
))) >> 8) >> 4)))) ^ (((((((1<<29))) >>
8) >> 4))))) >> (1)) != 0) ? 1 : 0)) : ((((u_long
)((((((((((1<<29))) >> 8))) - 1) & ((((((1<<
29))) >> 8)))) ^ ((((((1<<29))) >> 8))))) >>
(2)) != 0) ? 2 + ((((u_long)(((((((((((1<<29))) >>
8)) >> 2)) - 1) & (((((((1<<29))) >> 8
)) >> 2))) ^ (((((((1<<29))) >> 8)) >>
2)))) >> (1)) != 0) ? 1 : 0) : ((((u_long)(((((((((((1
<<29))) >> 8)))) - 1) & (((((((1<<29)))
>> 8))))) ^ (((((((1<<29))) >> 8)))))) >>
(1)) != 0) ? 1 : 0))) : ((((u_long)(((((((((1<<29)))))
- 1) & (((((1<<29)))))) ^ (((((1<<29))))))) >>
(4)) != 0) ? 4 + ((((u_long)((((((((((1<<29)))) >>
4)) - 1) & ((((((1<<29)))) >> 4))) ^ ((((((1
<<29)))) >> 4)))) >> (2)) != 0) ? 2 + ((((u_long
)(((((((((((1<<29)))) >> 4) >> 2)) - 1) &
(((((((1<<29)))) >> 4) >> 2))) ^ (((((((1<<
29)))) >> 4) >> 2)))) >> (1)) != 0) ? 1 : 0
) : ((((u_long)(((((((((((1<<29)))) >> 4))) - 1) &
(((((((1<<29)))) >> 4)))) ^ (((((((1<<29))
)) >> 4))))) >> (1)) != 0) ? 1 : 0)) : ((((u_long
)((((((((((1<<29)))))) - 1) & ((((((1<<29))))
))) ^ ((((((1<<29)))))))) >> (2)) != 0) ? 2 + (((
(u_long)(((((((((((1<<29))))) >> 2)) - 1) & (
((((((1<<29))))) >> 2))) ^ (((((((1<<29))))
) >> 2)))) >> (1)) != 0) ? 1 : 0) : ((((u_long)((
(((((((((1<<29))))))) - 1) & (((((((1<<29))))
)))) ^ (((((((1<<29))))))))) >> (1)) != 0) ? 1 : 0
))))))
606 RTW_SR_RFPARM_CS_MASK), RTW_RCR_ENCS1)((((((((sr)->sr_content[(0x32)/2] >> (((0x32) % 2 ==
0) ? 0 : 8)) & 0xff)) & (0xc)) >> ((((u_long)(
(((((0xc)) - 1) & ((0xc))) ^ ((0xc)))) >> (16)) != 0
) ? 16 + ((((u_long)(((((((0xc) >> 16)) - 1) & (((0xc
) >> 16))) ^ (((0xc) >> 16)))) >> (8)) != 0
) ? 8 + ((((u_long)((((((((0xc) >> 16) >> 8)) - 1
) & ((((0xc) >> 16) >> 8))) ^ ((((0xc) >>
16) >> 8)))) >> (4)) != 0) ? 4 + ((((u_long)((((
(((((0xc) >> 16) >> 8) >> 4)) - 1) & ((
(((0xc) >> 16) >> 8) >> 4))) ^ (((((0xc) >>
16) >> 8) >> 4)))) >> (2)) != 0) ? 2 + (((
(u_long)((((((((((0xc) >> 16) >> 8) >> 4) >>
2)) - 1) & ((((((0xc) >> 16) >> 8) >> 4
) >> 2))) ^ ((((((0xc) >> 16) >> 8) >>
4) >> 2)))) >> (1)) != 0) ? 1 : 0) : ((((u_long)
((((((((((0xc) >> 16) >> 8) >> 4))) - 1) &
((((((0xc) >> 16) >> 8) >> 4)))) ^ ((((((0xc
) >> 16) >> 8) >> 4))))) >> (1)) != 0
) ? 1 : 0)) : ((((u_long)(((((((((0xc) >> 16) >> 8
))) - 1) & (((((0xc) >> 16) >> 8)))) ^ (((((0xc
) >> 16) >> 8))))) >> (2)) != 0) ? 2 + ((((
u_long)((((((((((0xc) >> 16) >> 8)) >> 2)) -
1) & ((((((0xc) >> 16) >> 8)) >> 2))) ^
((((((0xc) >> 16) >> 8)) >> 2)))) >>
(1)) != 0) ? 1 : 0) : ((((u_long)((((((((((0xc) >> 16)
>> 8)))) - 1) & ((((((0xc) >> 16) >> 8
))))) ^ ((((((0xc) >> 16) >> 8)))))) >> (1)
) != 0) ? 1 : 0))) : ((((u_long)((((((((0xc) >> 16))) -
1) & ((((0xc) >> 16)))) ^ ((((0xc) >> 16))))
) >> (4)) != 0) ? 4 + ((((u_long)(((((((((0xc) >>
16)) >> 4)) - 1) & (((((0xc) >> 16)) >>
4))) ^ (((((0xc) >> 16)) >> 4)))) >> (2)) !=
0) ? 2 + ((((u_long)((((((((((0xc) >> 16)) >> 4)
>> 2)) - 1) & ((((((0xc) >> 16)) >> 4)
>> 2))) ^ ((((((0xc) >> 16)) >> 4) >>
2)))) >> (1)) != 0) ? 1 : 0) : ((((u_long)((((((((((0xc
) >> 16)) >> 4))) - 1) & ((((((0xc) >> 16
)) >> 4)))) ^ ((((((0xc) >> 16)) >> 4))))) >>
(1)) != 0) ? 1 : 0)) : ((((u_long)(((((((((0xc) >> 16)
))) - 1) & (((((0xc) >> 16))))) ^ (((((0xc) >>
16)))))) >> (2)) != 0) ? 2 + ((((u_long)((((((((((0xc)
>> 16))) >> 2)) - 1) & ((((((0xc) >> 16
))) >> 2))) ^ ((((((0xc) >> 16))) >> 2)))) >>
(1)) != 0) ? 1 : 0) : ((((u_long)((((((((((0xc) >> 16)
)))) - 1) & ((((((0xc) >> 16)))))) ^ ((((((0xc) >>
16))))))) >> (1)) != 0) ? 1 : 0)))) : ((((u_long)(((((
((0xc))) - 1) & (((0xc)))) ^ (((0xc))))) >> (8)) !=
0) ? 8 + ((((u_long)((((((((0xc)) >> 8)) - 1) & ((
((0xc)) >> 8))) ^ ((((0xc)) >> 8)))) >> (4)
) != 0) ? 4 + ((((u_long)(((((((((0xc)) >> 8) >> 4
)) - 1) & (((((0xc)) >> 8) >> 4))) ^ (((((0xc
)) >> 8) >> 4)))) >> (2)) != 0) ? 2 + ((((u_long
)((((((((((0xc)) >> 8) >> 4) >> 2)) - 1) &
((((((0xc)) >> 8) >> 4) >> 2))) ^ ((((((0xc
)) >> 8) >> 4) >> 2)))) >> (1)) != 0)
? 1 : 0) : ((((u_long)((((((((((0xc)) >> 8) >> 4
))) - 1) & ((((((0xc)) >> 8) >> 4)))) ^ (((((
(0xc)) >> 8) >> 4))))) >> (1)) != 0) ? 1 : 0
)) : ((((u_long)(((((((((0xc)) >> 8))) - 1) & (((((
0xc)) >> 8)))) ^ (((((0xc)) >> 8))))) >> (2
)) != 0) ? 2 + ((((u_long)((((((((((0xc)) >> 8)) >>
2)) - 1) & ((((((0xc)) >> 8)) >> 2))) ^ ((((
((0xc)) >> 8)) >> 2)))) >> (1)) != 0) ? 1 :
0) : ((((u_long)((((((((((0xc)) >> 8)))) - 1) & ((
((((0xc)) >> 8))))) ^ ((((((0xc)) >> 8)))))) >>
(1)) != 0) ? 1 : 0))) : ((((u_long)((((((((0xc)))) - 1) &
((((0xc))))) ^ ((((0xc)))))) >> (4)) != 0) ? 4 + ((((u_long
)(((((((((0xc))) >> 4)) - 1) & (((((0xc))) >>
4))) ^ (((((0xc))) >> 4)))) >> (2)) != 0) ? 2 + (
(((u_long)((((((((((0xc))) >> 4) >> 2)) - 1) &
((((((0xc))) >> 4) >> 2))) ^ ((((((0xc))) >>
4) >> 2)))) >> (1)) != 0) ? 1 : 0) : ((((u_long)
((((((((((0xc))) >> 4))) - 1) & ((((((0xc))) >>
4)))) ^ ((((((0xc))) >> 4))))) >> (1)) != 0) ? 1
: 0)) : ((((u_long)(((((((((0xc))))) - 1) & (((((0xc))))
)) ^ (((((0xc))))))) >> (2)) != 0) ? 2 + ((((u_long)(((
(((((((0xc)))) >> 2)) - 1) & ((((((0xc)))) >>
2))) ^ ((((((0xc)))) >> 2)))) >> (1)) != 0) ? 1 :
0) : ((((u_long)((((((((((0xc)))))) - 1) & ((((((0xc))))
))) ^ ((((((0xc)))))))) >> (1)) != 0) ? 1 : 0))))))) <<
((((u_long)(((((((1<<29))) - 1) & (((1<<29))
)) ^ (((1<<29))))) >> (16)) != 0) ? 16 + ((((u_long
)((((((((1<<29)) >> 16)) - 1) & ((((1<<
29)) >> 16))) ^ ((((1<<29)) >> 16)))) >>
(8)) != 0) ? 8 + ((((u_long)(((((((((1<<29)) >> 16
) >> 8)) - 1) & (((((1<<29)) >> 16) >>
8))) ^ (((((1<<29)) >> 16) >> 8)))) >>
(4)) != 0) ? 4 + ((((u_long)((((((((((1<<29)) >>
16) >> 8) >> 4)) - 1) & ((((((1<<29)) >>
16) >> 8) >> 4))) ^ ((((((1<<29)) >>
16) >> 8) >> 4)))) >> (2)) != 0) ? 2 + (((
(u_long)(((((((((((1<<29)) >> 16) >> 8) >>
4) >> 2)) - 1) & (((((((1<<29)) >> 16)
>> 8) >> 4) >> 2))) ^ (((((((1<<29))
>> 16) >> 8) >> 4) >> 2)))) >>
(1)) != 0) ? 1 : 0) : ((((u_long)(((((((((((1<<29)) >>
16) >> 8) >> 4))) - 1) & (((((((1<<29)
) >> 16) >> 8) >> 4)))) ^ (((((((1<<29
)) >> 16) >> 8) >> 4))))) >> (1)) != 0
) ? 1 : 0)) : ((((u_long)((((((((((1<<29)) >> 16)
>> 8))) - 1) & ((((((1<<29)) >> 16) >>
8)))) ^ ((((((1<<29)) >> 16) >> 8))))) >>
(2)) != 0) ? 2 + ((((u_long)(((((((((((1<<29)) >>
16) >> 8)) >> 2)) - 1) & (((((((1<<29)
) >> 16) >> 8)) >> 2))) ^ (((((((1<<29
)) >> 16) >> 8)) >> 2)))) >> (1)) != 0
) ? 1 : 0) : ((((u_long)(((((((((((1<<29)) >> 16)
>> 8)))) - 1) & (((((((1<<29)) >> 16) >>
8))))) ^ (((((((1<<29)) >> 16) >> 8)))))) >>
(1)) != 0) ? 1 : 0))) : ((((u_long)(((((((((1<<29)) >>
16))) - 1) & (((((1<<29)) >> 16)))) ^ (((((1
<<29)) >> 16))))) >> (4)) != 0) ? 4 + ((((u_long
)((((((((((1<<29)) >> 16)) >> 4)) - 1) &
((((((1<<29)) >> 16)) >> 4))) ^ ((((((1<<
29)) >> 16)) >> 4)))) >> (2)) != 0) ? 2 + (
(((u_long)(((((((((((1<<29)) >> 16)) >> 4) >>
2)) - 1) & (((((((1<<29)) >> 16)) >> 4
) >> 2))) ^ (((((((1<<29)) >> 16)) >>
4) >> 2)))) >> (1)) != 0) ? 1 : 0) : ((((u_long)
(((((((((((1<<29)) >> 16)) >> 4))) - 1) &
(((((((1<<29)) >> 16)) >> 4)))) ^ (((((((1
<<29)) >> 16)) >> 4))))) >> (1)) != 0
) ? 1 : 0)) : ((((u_long)((((((((((1<<29)) >> 16)
))) - 1) & ((((((1<<29)) >> 16))))) ^ ((((((1
<<29)) >> 16)))))) >> (2)) != 0) ? 2 + ((((
u_long)(((((((((((1<<29)) >> 16))) >> 2)) -
1) & (((((((1<<29)) >> 16))) >> 2))) ^
(((((((1<<29)) >> 16))) >> 2)))) >> (
1)) != 0) ? 1 : 0) : ((((u_long)(((((((((((1<<29)) >>
16))))) - 1) & (((((((1<<29)) >> 16)))))) ^ (
((((((1<<29)) >> 16))))))) >> (1)) != 0) ? 1
: 0)))) : ((((u_long)((((((((1<<29)))) - 1) & ((((
1<<29))))) ^ ((((1<<29)))))) >> (8)) != 0) ?
8 + ((((u_long)(((((((((1<<29))) >> 8)) - 1) &
(((((1<<29))) >> 8))) ^ (((((1<<29))) >>
8)))) >> (4)) != 0) ? 4 + ((((u_long)((((((((((1<<
29))) >> 8) >> 4)) - 1) & ((((((1<<29))
) >> 8) >> 4))) ^ ((((((1<<29))) >> 8
) >> 4)))) >> (2)) != 0) ? 2 + ((((u_long)(((((((
((((1<<29))) >> 8) >> 4) >> 2)) - 1) &
(((((((1<<29))) >> 8) >> 4) >> 2))) ^
(((((((1<<29))) >> 8) >> 4) >> 2))))
>> (1)) != 0) ? 1 : 0) : ((((u_long)(((((((((((1<<
29))) >> 8) >> 4))) - 1) & (((((((1<<29
))) >> 8) >> 4)))) ^ (((((((1<<29))) >>
8) >> 4))))) >> (1)) != 0) ? 1 : 0)) : ((((u_long
)((((((((((1<<29))) >> 8))) - 1) & ((((((1<<
29))) >> 8)))) ^ ((((((1<<29))) >> 8))))) >>
(2)) != 0) ? 2 + ((((u_long)(((((((((((1<<29))) >>
8)) >> 2)) - 1) & (((((((1<<29))) >> 8
)) >> 2))) ^ (((((((1<<29))) >> 8)) >>
2)))) >> (1)) != 0) ? 1 : 0) : ((((u_long)(((((((((((1
<<29))) >> 8)))) - 1) & (((((((1<<29)))
>> 8))))) ^ (((((((1<<29))) >> 8)))))) >>
(1)) != 0) ? 1 : 0))) : ((((u_long)(((((((((1<<29)))))
- 1) & (((((1<<29)))))) ^ (((((1<<29))))))) >>
(4)) != 0) ? 4 + ((((u_long)((((((((((1<<29)))) >>
4)) - 1) & ((((((1<<29)))) >> 4))) ^ ((((((1
<<29)))) >> 4)))) >> (2)) != 0) ? 2 + ((((u_long
)(((((((((((1<<29)))) >> 4) >> 2)) - 1) &
(((((((1<<29)))) >> 4) >> 2))) ^ (((((((1<<
29)))) >> 4) >> 2)))) >> (1)) != 0) ? 1 : 0
) : ((((u_long)(((((((((((1<<29)))) >> 4))) - 1) &
(((((((1<<29)))) >> 4)))) ^ (((((((1<<29))
)) >> 4))))) >> (1)) != 0) ? 1 : 0)) : ((((u_long
)((((((((((1<<29)))))) - 1) & ((((((1<<29))))
))) ^ ((((((1<<29)))))))) >> (2)) != 0) ? 2 + (((
(u_long)(((((((((((1<<29))))) >> 2)) - 1) & (
((((((1<<29))))) >> 2))) ^ (((((((1<<29))))
) >> 2)))) >> (1)) != 0) ? 1 : 0) : ((((u_long)((
(((((((((1<<29))))))) - 1) & (((((((1<<29))))
)))) ^ (((((((1<<29))))))))) >> (1)) != 0) ? 1 : 0
))))))
;
607
608 *rfchipid = RTW_SR_GET(sr, RTW_SR_RFCHIPID)(((sr)->sr_content[(0x0c)/2] >> (((0x0c) % 2 == 0) ?
0 : 8)) & 0xff)
;
609
610 if (sc->sc_flags & RTW_F_RTL81850x00000008) {
611 *locale = RTW_LOCALE_UNKNOWN;
612 return (0);
613 }
614
615 switch (RTW_SR_GET(sr, RTW_SR_CONFIG0)(((sr)->sr_content[(0x14)/2] >> (((0x14) % 2 == 0) ?
0 : 8)) & 0xff)
& RTW8180_CONFIG0_GL_MASK0x3) {
616 case RTW8180_CONFIG0_GL_USA((3) << ((((u_long)((((((0x3)) - 1) & ((0x3))) ^ ((
0x3)))) >> (16)) != 0) ? 16 + ((((u_long)(((((((0x3) >>
16)) - 1) & (((0x3) >> 16))) ^ (((0x3) >> 16
)))) >> (8)) != 0) ? 8 + ((((u_long)((((((((0x3) >>
16) >> 8)) - 1) & ((((0x3) >> 16) >> 8
))) ^ ((((0x3) >> 16) >> 8)))) >> (4)) != 0
) ? 4 + ((((u_long)(((((((((0x3) >> 16) >> 8) >>
4)) - 1) & (((((0x3) >> 16) >> 8) >> 4
))) ^ (((((0x3) >> 16) >> 8) >> 4)))) >>
(2)) != 0) ? 2 + ((((u_long)((((((((((0x3) >> 16) >>
8) >> 4) >> 2)) - 1) & ((((((0x3) >> 16
) >> 8) >> 4) >> 2))) ^ ((((((0x3) >>
16) >> 8) >> 4) >> 2)))) >> (1)) != 0
) ? 1 : 0) : ((((u_long)((((((((((0x3) >> 16) >> 8
) >> 4))) - 1) & ((((((0x3) >> 16) >> 8
) >> 4)))) ^ ((((((0x3) >> 16) >> 8) >>
4))))) >> (1)) != 0) ? 1 : 0)) : ((((u_long)(((((((((0x3
) >> 16) >> 8))) - 1) & (((((0x3) >> 16
) >> 8)))) ^ (((((0x3) >> 16) >> 8))))) >>
(2)) != 0) ? 2 + ((((u_long)((((((((((0x3) >> 16) >>
8)) >> 2)) - 1) & ((((((0x3) >> 16) >>
8)) >> 2))) ^ ((((((0x3) >> 16) >> 8)) >>
2)))) >> (1)) != 0) ? 1 : 0) : ((((u_long)((((((((((0x3
) >> 16) >> 8)))) - 1) & ((((((0x3) >> 16
) >> 8))))) ^ ((((((0x3) >> 16) >> 8)))))) >>
(1)) != 0) ? 1 : 0))) : ((((u_long)((((((((0x3) >> 16)
)) - 1) & ((((0x3) >> 16)))) ^ ((((0x3) >> 16
))))) >> (4)) != 0) ? 4 + ((((u_long)(((((((((0x3) >>
16)) >> 4)) - 1) & (((((0x3) >> 16)) >>
4))) ^ (((((0x3) >> 16)) >> 4)))) >> (2)) !=
0) ? 2 + ((((u_long)((((((((((0x3) >> 16)) >> 4)
>> 2)) - 1) & ((((((0x3) >> 16)) >> 4)
>> 2))) ^ ((((((0x3) >> 16)) >> 4) >>
2)))) >> (1)) != 0) ? 1 : 0) : ((((u_long)((((((((((0x3
) >> 16)) >> 4))) - 1) & ((((((0x3) >> 16
)) >> 4)))) ^ ((((((0x3) >> 16)) >> 4))))) >>
(1)) != 0) ? 1 : 0)) : ((((u_long)(((((((((0x3) >> 16)
))) - 1) & (((((0x3) >> 16))))) ^ (((((0x3) >>
16)))))) >> (2)) != 0) ? 2 + ((((u_long)((((((((((0x3)
>> 16))) >> 2)) - 1) & ((((((0x3) >> 16
))) >> 2))) ^ ((((((0x3) >> 16))) >> 2)))) >>
(1)) != 0) ? 1 : 0) : ((((u_long)((((((((((0x3) >> 16)
)))) - 1) & ((((((0x3) >> 16)))))) ^ ((((((0x3) >>
16))))))) >> (1)) != 0) ? 1 : 0)))) : ((((u_long)(((((
((0x3))) - 1) & (((0x3)))) ^ (((0x3))))) >> (8)) !=
0) ? 8 + ((((u_long)((((((((0x3)) >> 8)) - 1) & ((
((0x3)) >> 8))) ^ ((((0x3)) >> 8)))) >> (4)
) != 0) ? 4 + ((((u_long)(((((((((0x3)) >> 8) >> 4
)) - 1) & (((((0x3)) >> 8) >> 4))) ^ (((((0x3
)) >> 8) >> 4)))) >> (2)) != 0) ? 2 + ((((u_long
)((((((((((0x3)) >> 8) >> 4) >> 2)) - 1) &
((((((0x3)) >> 8) >> 4) >> 2))) ^ ((((((0x3
)) >> 8) >> 4) >> 2)))) >> (1)) != 0)
? 1 : 0) : ((((u_long)((((((((((0x3)) >> 8) >> 4
))) - 1) & ((((((0x3)) >> 8) >> 4)))) ^ (((((
(0x3)) >> 8) >> 4))))) >> (1)) != 0) ? 1 : 0
)) : ((((u_long)(((((((((0x3)) >> 8))) - 1) & (((((
0x3)) >> 8)))) ^ (((((0x3)) >> 8))))) >> (2
)) != 0) ? 2 + ((((u_long)((((((((((0x3)) >> 8)) >>
2)) - 1) & ((((((0x3)) >> 8)) >> 2))) ^ ((((
((0x3)) >> 8)) >> 2)))) >> (1)) != 0) ? 1 :
0) : ((((u_long)((((((((((0x3)) >> 8)))) - 1) & ((
((((0x3)) >> 8))))) ^ ((((((0x3)) >> 8)))))) >>
(1)) != 0) ? 1 : 0))) : ((((u_long)((((((((0x3)))) - 1) &
((((0x3))))) ^ ((((0x3)))))) >> (4)) != 0) ? 4 + ((((u_long
)(((((((((0x3))) >> 4)) - 1) & (((((0x3))) >>
4))) ^ (((((0x3))) >> 4)))) >> (2)) != 0) ? 2 + (
(((u_long)((((((((((0x3))) >> 4) >> 2)) - 1) &
((((((0x3))) >> 4) >> 2))) ^ ((((((0x3))) >>
4) >> 2)))) >> (1)) != 0) ? 1 : 0) : ((((u_long)
((((((((((0x3))) >> 4))) - 1) & ((((((0x3))) >>
4)))) ^ ((((((0x3))) >> 4))))) >> (1)) != 0) ? 1
: 0)) : ((((u_long)(((((((((0x3))))) - 1) & (((((0x3))))
)) ^ (((((0x3))))))) >> (2)) != 0) ? 2 + ((((u_long)(((
(((((((0x3)))) >> 2)) - 1) & ((((((0x3)))) >>
2))) ^ ((((((0x3)))) >> 2)))) >> (1)) != 0) ? 1 :
0) : ((((u_long)((((((((((0x3)))))) - 1) & ((((((0x3))))
))) ^ ((((((0x3)))))))) >> (1)) != 0) ? 1 : 0))))))
:
617 *locale = RTW_LOCALE_USA;
618 break;
619 case RTW8180_CONFIG0_GL_EUROPE((2) << ((((u_long)((((((0x3)) - 1) & ((0x3))) ^ ((
0x3)))) >> (16)) != 0) ? 16 + ((((u_long)(((((((0x3) >>
16)) - 1) & (((0x3) >> 16))) ^ (((0x3) >> 16
)))) >> (8)) != 0) ? 8 + ((((u_long)((((((((0x3) >>
16) >> 8)) - 1) & ((((0x3) >> 16) >> 8
))) ^ ((((0x3) >> 16) >> 8)))) >> (4)) != 0
) ? 4 + ((((u_long)(((((((((0x3) >> 16) >> 8) >>
4)) - 1) & (((((0x3) >> 16) >> 8) >> 4
))) ^ (((((0x3) >> 16) >> 8) >> 4)))) >>
(2)) != 0) ? 2 + ((((u_long)((((((((((0x3) >> 16) >>
8) >> 4) >> 2)) - 1) & ((((((0x3) >> 16
) >> 8) >> 4) >> 2))) ^ ((((((0x3) >>
16) >> 8) >> 4) >> 2)))) >> (1)) != 0
) ? 1 : 0) : ((((u_long)((((((((((0x3) >> 16) >> 8
) >> 4))) - 1) & ((((((0x3) >> 16) >> 8
) >> 4)))) ^ ((((((0x3) >> 16) >> 8) >>
4))))) >> (1)) != 0) ? 1 : 0)) : ((((u_long)(((((((((0x3
) >> 16) >> 8))) - 1) & (((((0x3) >> 16
) >> 8)))) ^ (((((0x3) >> 16) >> 8))))) >>
(2)) != 0) ? 2 + ((((u_long)((((((((((0x3) >> 16) >>
8)) >> 2)) - 1) & ((((((0x3) >> 16) >>
8)) >> 2))) ^ ((((((0x3) >> 16) >> 8)) >>
2)))) >> (1)) != 0) ? 1 : 0) : ((((u_long)((((((((((0x3
) >> 16) >> 8)))) - 1) & ((((((0x3) >> 16
) >> 8))))) ^ ((((((0x3) >> 16) >> 8)))))) >>
(1)) != 0) ? 1 : 0))) : ((((u_long)((((((((0x3) >> 16)
)) - 1) & ((((0x3) >> 16)))) ^ ((((0x3) >> 16
))))) >> (4)) != 0) ? 4 + ((((u_long)(((((((((0x3) >>
16)) >> 4)) - 1) & (((((0x3) >> 16)) >>
4))) ^ (((((0x3) >> 16)) >> 4)))) >> (2)) !=
0) ? 2 + ((((u_long)((((((((((0x3) >> 16)) >> 4)
>> 2)) - 1) & ((((((0x3) >> 16)) >> 4)
>> 2))) ^ ((((((0x3) >> 16)) >> 4) >>
2)))) >> (1)) != 0) ? 1 : 0) : ((((u_long)((((((((((0x3
) >> 16)) >> 4))) - 1) & ((((((0x3) >> 16
)) >> 4)))) ^ ((((((0x3) >> 16)) >> 4))))) >>
(1)) != 0) ? 1 : 0)) : ((((u_long)(((((((((0x3) >> 16)
))) - 1) & (((((0x3) >> 16))))) ^ (((((0x3) >>
16)))))) >> (2)) != 0) ? 2 + ((((u_long)((((((((((0x3)
>> 16))) >> 2)) - 1) & ((((((0x3) >> 16
))) >> 2))) ^ ((((((0x3) >> 16))) >> 2)))) >>
(1)) != 0) ? 1 : 0) : ((((u_long)((((((((((0x3) >> 16)
)))) - 1) & ((((((0x3) >> 16)))))) ^ ((((((0x3) >>
16))))))) >> (1)) != 0) ? 1 : 0)))) : ((((u_long)(((((
((0x3))) - 1) & (((0x3)))) ^ (((0x3))))) >> (8)) !=
0) ? 8 + ((((u_long)((((((((0x3)) >> 8)) - 1) & ((
((0x3)) >> 8))) ^ ((((0x3)) >> 8)))) >> (4)
) != 0) ? 4 + ((((u_long)(((((((((0x3)) >> 8) >> 4
)) - 1) & (((((0x3)) >> 8) >> 4))) ^ (((((0x3
)) >> 8) >> 4)))) >> (2)) != 0) ? 2 + ((((u_long
)((((((((((0x3)) >> 8) >> 4) >> 2)) - 1) &
((((((0x3)) >> 8) >> 4) >> 2))) ^ ((((((0x3
)) >> 8) >> 4) >> 2)))) >> (1)) != 0)
? 1 : 0) : ((((u_long)((((((((((0x3)) >> 8) >> 4
))) - 1) & ((((((0x3)) >> 8) >> 4)))) ^ (((((
(0x3)) >> 8) >> 4))))) >> (1)) != 0) ? 1 : 0
)) : ((((u_long)(((((((((0x3)) >> 8))) - 1) & (((((
0x3)) >> 8)))) ^ (((((0x3)) >> 8))))) >> (2
)) != 0) ? 2 + ((((u_long)((((((((((0x3)) >> 8)) >>
2)) - 1) & ((((((0x3)) >> 8)) >> 2))) ^ ((((
((0x3)) >> 8)) >> 2)))) >> (1)) != 0) ? 1 :
0) : ((((u_long)((((((((((0x3)) >> 8)))) - 1) & ((
((((0x3)) >> 8))))) ^ ((((((0x3)) >> 8)))))) >>
(1)) != 0) ? 1 : 0))) : ((((u_long)((((((((0x3)))) - 1) &
((((0x3))))) ^ ((((0x3)))))) >> (4)) != 0) ? 4 + ((((u_long
)(((((((((0x3))) >> 4)) - 1) & (((((0x3))) >>
4))) ^ (((((0x3))) >> 4)))) >> (2)) != 0) ? 2 + (
(((u_long)((((((((((0x3))) >> 4) >> 2)) - 1) &
((((((0x3))) >> 4) >> 2))) ^ ((((((0x3))) >>
4) >> 2)))) >> (1)) != 0) ? 1 : 0) : ((((u_long)
((((((((((0x3))) >> 4))) - 1) & ((((((0x3))) >>
4)))) ^ ((((((0x3))) >> 4))))) >> (1)) != 0) ? 1
: 0)) : ((((u_long)(((((((((0x3))))) - 1) & (((((0x3))))
)) ^ (((((0x3))))))) >> (2)) != 0) ? 2 + ((((u_long)(((
(((((((0x3)))) >> 2)) - 1) & ((((((0x3)))) >>
2))) ^ ((((((0x3)))) >> 2)))) >> (1)) != 0) ? 1 :
0) : ((((u_long)((((((((((0x3)))))) - 1) & ((((((0x3))))
))) ^ ((((((0x3)))))))) >> (1)) != 0) ? 1 : 0))))))
:
620 *locale = RTW_LOCALE_EUROPE;
621 break;
622 case RTW8180_CONFIG0_GL_JAPAN((1) << ((((u_long)((((((0x3)) - 1) & ((0x3))) ^ ((
0x3)))) >> (16)) != 0) ? 16 + ((((u_long)(((((((0x3) >>
16)) - 1) & (((0x3) >> 16))) ^ (((0x3) >> 16
)))) >> (8)) != 0) ? 8 + ((((u_long)((((((((0x3) >>
16) >> 8)) - 1) & ((((0x3) >> 16) >> 8
))) ^ ((((0x3) >> 16) >> 8)))) >> (4)) != 0
) ? 4 + ((((u_long)(((((((((0x3) >> 16) >> 8) >>
4)) - 1) & (((((0x3) >> 16) >> 8) >> 4
))) ^ (((((0x3) >> 16) >> 8) >> 4)))) >>
(2)) != 0) ? 2 + ((((u_long)((((((((((0x3) >> 16) >>
8) >> 4) >> 2)) - 1) & ((((((0x3) >> 16
) >> 8) >> 4) >> 2))) ^ ((((((0x3) >>
16) >> 8) >> 4) >> 2)))) >> (1)) != 0
) ? 1 : 0) : ((((u_long)((((((((((0x3) >> 16) >> 8
) >> 4))) - 1) & ((((((0x3) >> 16) >> 8
) >> 4)))) ^ ((((((0x3) >> 16) >> 8) >>
4))))) >> (1)) != 0) ? 1 : 0)) : ((((u_long)(((((((((0x3
) >> 16) >> 8))) - 1) & (((((0x3) >> 16
) >> 8)))) ^ (((((0x3) >> 16) >> 8))))) >>
(2)) != 0) ? 2 + ((((u_long)((((((((((0x3) >> 16) >>
8)) >> 2)) - 1) & ((((((0x3) >> 16) >>
8)) >> 2))) ^ ((((((0x3) >> 16) >> 8)) >>
2)))) >> (1)) != 0) ? 1 : 0) : ((((u_long)((((((((((0x3
) >> 16) >> 8)))) - 1) & ((((((0x3) >> 16
) >> 8))))) ^ ((((((0x3) >> 16) >> 8)))))) >>
(1)) != 0) ? 1 : 0))) : ((((u_long)((((((((0x3) >> 16)
)) - 1) & ((((0x3) >> 16)))) ^ ((((0x3) >> 16
))))) >> (4)) != 0) ? 4 + ((((u_long)(((((((((0x3) >>
16)) >> 4)) - 1) & (((((0x3) >> 16)) >>
4))) ^ (((((0x3) >> 16)) >> 4)))) >> (2)) !=
0) ? 2 + ((((u_long)((((((((((0x3) >> 16)) >> 4)
>> 2)) - 1) & ((((((0x3) >> 16)) >> 4)
>> 2))) ^ ((((((0x3) >> 16)) >> 4) >>
2)))) >> (1)) != 0) ? 1 : 0) : ((((u_long)((((((((((0x3
) >> 16)) >> 4))) - 1) & ((((((0x3) >> 16
)) >> 4)))) ^ ((((((0x3) >> 16)) >> 4))))) >>
(1)) != 0) ? 1 : 0)) : ((((u_long)(((((((((0x3) >> 16)
))) - 1) & (((((0x3) >> 16))))) ^ (((((0x3) >>
16)))))) >> (2)) != 0) ? 2 + ((((u_long)((((((((((0x3)
>> 16))) >> 2)) - 1) & ((((((0x3) >> 16
))) >> 2))) ^ ((((((0x3) >> 16))) >> 2)))) >>
(1)) != 0) ? 1 : 0) : ((((u_long)((((((((((0x3) >> 16)
)))) - 1) & ((((((0x3) >> 16)))))) ^ ((((((0x3) >>
16))))))) >> (1)) != 0) ? 1 : 0)))) : ((((u_long)(((((
((0x3))) - 1) & (((0x3)))) ^ (((0x3))))) >> (8)) !=
0) ? 8 + ((((u_long)((((((((0x3)) >> 8)) - 1) & ((
((0x3)) >> 8))) ^ ((((0x3)) >> 8)))) >> (4)
) != 0) ? 4 + ((((u_long)(((((((((0x3)) >> 8) >> 4
)) - 1) & (((((0x3)) >> 8) >> 4))) ^ (((((0x3
)) >> 8) >> 4)))) >> (2)) != 0) ? 2 + ((((u_long
)((((((((((0x3)) >> 8) >> 4) >> 2)) - 1) &
((((((0x3)) >> 8) >> 4) >> 2))) ^ ((((((0x3
)) >> 8) >> 4) >> 2)))) >> (1)) != 0)
? 1 : 0) : ((((u_long)((((((((((0x3)) >> 8) >> 4
))) - 1) & ((((((0x3)) >> 8) >> 4)))) ^ (((((
(0x3)) >> 8) >> 4))))) >> (1)) != 0) ? 1 : 0
)) : ((((u_long)(((((((((0x3)) >> 8))) - 1) & (((((
0x3)) >> 8)))) ^ (((((0x3)) >> 8))))) >> (2
)) != 0) ? 2 + ((((u_long)((((((((((0x3)) >> 8)) >>
2)) - 1) & ((((((0x3)) >> 8)) >> 2))) ^ ((((
((0x3)) >> 8)) >> 2)))) >> (1)) != 0) ? 1 :
0) : ((((u_long)((((((((((0x3)) >> 8)))) - 1) & ((
((((0x3)) >> 8))))) ^ ((((((0x3)) >> 8)))))) >>
(1)) != 0) ? 1 : 0))) : ((((u_long)((((((((0x3)))) - 1) &
((((0x3))))) ^ ((((0x3)))))) >> (4)) != 0) ? 4 + ((((u_long
)(((((((((0x3))) >> 4)) - 1) & (((((0x3))) >>
4))) ^ (((((0x3))) >> 4)))) >> (2)) != 0) ? 2 + (
(((u_long)((((((((((0x3))) >> 4) >> 2)) - 1) &
((((((0x3))) >> 4) >> 2))) ^ ((((((0x3))) >>
4) >> 2)))) >> (1)) != 0) ? 1 : 0) : ((((u_long)
((((((((((0x3))) >> 4))) - 1) & ((((((0x3))) >>
4)))) ^ ((((((0x3))) >> 4))))) >> (1)) != 0) ? 1
: 0)) : ((((u_long)(((((((((0x3))))) - 1) & (((((0x3))))
)) ^ (((((0x3))))))) >> (2)) != 0) ? 2 + ((((u_long)(((
(((((((0x3)))) >> 2)) - 1) & ((((((0x3)))) >>
2))) ^ ((((((0x3)))) >> 2)))) >> (1)) != 0) ? 1 :
0) : ((((u_long)((((((((((0x3)))))) - 1) & ((((((0x3))))
))) ^ ((((((0x3)))))))) >> (1)) != 0) ? 1 : 0))))))
:
623 case RTW8180_CONFIG0_GL_JAPAN2((0) << ((((u_long)((((((0x3)) - 1) & ((0x3))) ^ ((
0x3)))) >> (16)) != 0) ? 16 + ((((u_long)(((((((0x3) >>
16)) - 1) & (((0x3) >> 16))) ^ (((0x3) >> 16
)))) >> (8)) != 0) ? 8 + ((((u_long)((((((((0x3) >>
16) >> 8)) - 1) & ((((0x3) >> 16) >> 8
))) ^ ((((0x3) >> 16) >> 8)))) >> (4)) != 0
) ? 4 + ((((u_long)(((((((((0x3) >> 16) >> 8) >>
4)) - 1) & (((((0x3) >> 16) >> 8) >> 4
))) ^ (((((0x3) >> 16) >> 8) >> 4)))) >>
(2)) != 0) ? 2 + ((((u_long)((((((((((0x3) >> 16) >>
8) >> 4) >> 2)) - 1) & ((((((0x3) >> 16
) >> 8) >> 4) >> 2))) ^ ((((((0x3) >>
16) >> 8) >> 4) >> 2)))) >> (1)) != 0
) ? 1 : 0) : ((((u_long)((((((((((0x3) >> 16) >> 8
) >> 4))) - 1) & ((((((0x3) >> 16) >> 8
) >> 4)))) ^ ((((((0x3) >> 16) >> 8) >>
4))))) >> (1)) != 0) ? 1 : 0)) : ((((u_long)(((((((((0x3
) >> 16) >> 8))) - 1) & (((((0x3) >> 16
) >> 8)))) ^ (((((0x3) >> 16) >> 8))))) >>
(2)) != 0) ? 2 + ((((u_long)((((((((((0x3) >> 16) >>
8)) >> 2)) - 1) & ((((((0x3) >> 16) >>
8)) >> 2))) ^ ((((((0x3) >> 16) >> 8)) >>
2)))) >> (1)) != 0) ? 1 : 0) : ((((u_long)((((((((((0x3
) >> 16) >> 8)))) - 1) & ((((((0x3) >> 16
) >> 8))))) ^ ((((((0x3) >> 16) >> 8)))))) >>
(1)) != 0) ? 1 : 0))) : ((((u_long)((((((((0x3) >> 16)
)) - 1) & ((((0x3) >> 16)))) ^ ((((0x3) >> 16
))))) >> (4)) != 0) ? 4 + ((((u_long)(((((((((0x3) >>
16)) >> 4)) - 1) & (((((0x3) >> 16)) >>
4))) ^ (((((0x3) >> 16)) >> 4)))) >> (2)) !=
0) ? 2 + ((((u_long)((((((((((0x3) >> 16)) >> 4)
>> 2)) - 1) & ((((((0x3) >> 16)) >> 4)
>> 2))) ^ ((((((0x3) >> 16)) >> 4) >>
2)))) >> (1)) != 0) ? 1 : 0) : ((((u_long)((((((((((0x3
) >> 16)) >> 4))) - 1) & ((((((0x3) >> 16
)) >> 4)))) ^ ((((((0x3) >> 16)) >> 4))))) >>
(1)) != 0) ? 1 : 0)) : ((((u_long)(((((((((0x3) >> 16)
))) - 1) & (((((0x3) >> 16))))) ^ (((((0x3) >>
16)))))) >> (2)) != 0) ? 2 + ((((u_long)((((((((((0x3)
>> 16))) >> 2)) - 1) & ((((((0x3) >> 16
))) >> 2))) ^ ((((((0x3) >> 16))) >> 2)))) >>
(1)) != 0) ? 1 : 0) : ((((u_long)((((((((((0x3) >> 16)
)))) - 1) & ((((((0x3) >> 16)))))) ^ ((((((0x3) >>
16))))))) >> (1)) != 0) ? 1 : 0)))) : ((((u_long)(((((
((0x3))) - 1) & (((0x3)))) ^ (((0x3))))) >> (8)) !=
0) ? 8 + ((((u_long)((((((((0x3)) >> 8)) - 1) & ((
((0x3)) >> 8))) ^ ((((0x3)) >> 8)))) >> (4)
) != 0) ? 4 + ((((u_long)(((((((((0x3)) >> 8) >> 4
)) - 1) & (((((0x3)) >> 8) >> 4))) ^ (((((0x3
)) >> 8) >> 4)))) >> (2)) != 0) ? 2 + ((((u_long
)((((((((((0x3)) >> 8) >> 4) >> 2)) - 1) &
((((((0x3)) >> 8) >> 4) >> 2))) ^ ((((((0x3
)) >> 8) >> 4) >> 2)))) >> (1)) != 0)
? 1 : 0) : ((((u_long)((((((((((0x3)) >> 8) >> 4
))) - 1) & ((((((0x3)) >> 8) >> 4)))) ^ (((((
(0x3)) >> 8) >> 4))))) >> (1)) != 0) ? 1 : 0
)) : ((((u_long)(((((((((0x3)) >> 8))) - 1) & (((((
0x3)) >> 8)))) ^ (((((0x3)) >> 8))))) >> (2
)) != 0) ? 2 + ((((u_long)((((((((((0x3)) >> 8)) >>
2)) - 1) & ((((((0x3)) >> 8)) >> 2))) ^ ((((
((0x3)) >> 8)) >> 2)))) >> (1)) != 0) ? 1 :
0) : ((((u_long)((((((((((0x3)) >> 8)))) - 1) & ((
((((0x3)) >> 8))))) ^ ((((((0x3)) >> 8)))))) >>
(1)) != 0) ? 1 : 0))) : ((((u_long)((((((((0x3)))) - 1) &
((((0x3))))) ^ ((((0x3)))))) >> (4)) != 0) ? 4 + ((((u_long
)(((((((((0x3))) >> 4)) - 1) & (((((0x3))) >>
4))) ^ (((((0x3))) >> 4)))) >> (2)) != 0) ? 2 + (
(((u_long)((((((((((0x3))) >> 4) >> 2)) - 1) &
((((((0x3))) >> 4) >> 2))) ^ ((((((0x3))) >>
4) >> 2)))) >> (1)) != 0) ? 1 : 0) : ((((u_long)
((((((((((0x3))) >> 4))) - 1) & ((((((0x3))) >>
4)))) ^ ((((((0x3))) >> 4))))) >> (1)) != 0) ? 1
: 0)) : ((((u_long)(((((((((0x3))))) - 1) & (((((0x3))))
)) ^ (((((0x3))))))) >> (2)) != 0) ? 2 + ((((u_long)(((
(((((((0x3)))) >> 2)) - 1) & ((((((0x3)))) >>
2))) ^ ((((((0x3)))) >> 2)))) >> (1)) != 0) ? 1 :
0) : ((((u_long)((((((((((0x3)))))) - 1) & ((((((0x3))))
))) ^ ((((((0x3)))))))) >> (1)) != 0) ? 1 : 0))))))
:
624 *locale = RTW_LOCALE_JAPAN;
625 break;
626 default:
627 *locale = RTW_LOCALE_UNKNOWN;
628 break;
629 }
630 return 0;
631}
632
633/* Returns -1 on failure. */
634int
635rtw_srom_read(struct rtw_regs *regs, u_int32_t flags, struct rtw_srom *sr,
636 const char *dvname)
637{
638 int rc;
639 struct seeprom_descriptor sd;
640 u_int8_t ecr;
641
642 bzero(&sd, sizeof(sd))__builtin_bzero((&sd), (sizeof(sd)));
643
644 ecr = RTW_READ8(regs, RTW_9346CR)((*(regs)->r_read8)(regs, 0x50));
645
646 if ((flags & RTW_F_9356SROM0x00000020) != 0) {
647 RTW_DPRINTF(RTW_DEBUG_ATTACH, ("%s: 93c56 SROM\n", dvname));
648 sr->sr_size = 256;
649 sd.sd_chip = C56_66;
650 } else {
651 RTW_DPRINTF(RTW_DEBUG_ATTACH, ("%s: 93c46 SROM\n", dvname));
652 sr->sr_size = 128;
653 sd.sd_chip = C46;
654 }
655
656 ecr &= ~(RTW_9346CR_EEDI(1<<1) | RTW_9346CR_EEDO(1<<0) | RTW_9346CR_EESK(1<<2) |
657 RTW_9346CR_EEM_MASK0xc0 | RTW_9346CR_EECS(1<<3));
658 ecr |= RTW_9346CR_EEM_PROGRAM((2) << ((((u_long)((((((0xc0)) - 1) & ((0xc0))) ^ (
(0xc0)))) >> (16)) != 0) ? 16 + ((((u_long)(((((((0xc0)
>> 16)) - 1) & (((0xc0) >> 16))) ^ (((0xc0) >>
16)))) >> (8)) != 0) ? 8 + ((((u_long)((((((((0xc0) >>
16) >> 8)) - 1) & ((((0xc0) >> 16) >> 8
))) ^ ((((0xc0) >> 16) >> 8)))) >> (4)) != 0
) ? 4 + ((((u_long)(((((((((0xc0) >> 16) >> 8) >>
4)) - 1) & (((((0xc0) >> 16) >> 8) >> 4
))) ^ (((((0xc0) >> 16) >> 8) >> 4)))) >>
(2)) != 0) ? 2 + ((((u_long)((((((((((0xc0) >> 16) >>
8) >> 4) >> 2)) - 1) & ((((((0xc0) >> 16
) >> 8) >> 4) >> 2))) ^ ((((((0xc0) >>
16) >> 8) >> 4) >> 2)))) >> (1)) != 0
) ? 1 : 0) : ((((u_long)((((((((((0xc0) >> 16) >>
8) >> 4))) - 1) & ((((((0xc0) >> 16) >>
8) >> 4)))) ^ ((((((0xc0) >> 16) >> 8) >>
4))))) >> (1)) != 0) ? 1 : 0)) : ((((u_long)(((((((((0xc0
) >> 16) >> 8))) - 1) & (((((0xc0) >> 16
) >> 8)))) ^ (((((0xc0) >> 16) >> 8))))) >>
(2)) != 0) ? 2 + ((((u_long)((((((((((0xc0) >> 16) >>
8)) >> 2)) - 1) & ((((((0xc0) >> 16) >>
8)) >> 2))) ^ ((((((0xc0) >> 16) >> 8)) >>
2)))) >> (1)) != 0) ? 1 : 0) : ((((u_long)((((((((((0xc0
) >> 16) >> 8)))) - 1) & ((((((0xc0) >>
16) >> 8))))) ^ ((((((0xc0) >> 16) >> 8)))
))) >> (1)) != 0) ? 1 : 0))) : ((((u_long)((((((((0xc0)
>> 16))) - 1) & ((((0xc0) >> 16)))) ^ ((((0xc0
) >> 16))))) >> (4)) != 0) ? 4 + ((((u_long)(((((
((((0xc0) >> 16)) >> 4)) - 1) & (((((0xc0) >>
16)) >> 4))) ^ (((((0xc0) >> 16)) >> 4))))
>> (2)) != 0) ? 2 + ((((u_long)((((((((((0xc0) >>
16)) >> 4) >> 2)) - 1) & ((((((0xc0) >>
16)) >> 4) >> 2))) ^ ((((((0xc0) >> 16)) >>
4) >> 2)))) >> (1)) != 0) ? 1 : 0) : ((((u_long)
((((((((((0xc0) >> 16)) >> 4))) - 1) & ((((((
0xc0) >> 16)) >> 4)))) ^ ((((((0xc0) >> 16)
) >> 4))))) >> (1)) != 0) ? 1 : 0)) : ((((u_long)
(((((((((0xc0) >> 16)))) - 1) & (((((0xc0) >>
16))))) ^ (((((0xc0) >> 16)))))) >> (2)) != 0) ?
2 + ((((u_long)((((((((((0xc0) >> 16))) >> 2)) -
1) & ((((((0xc0) >> 16))) >> 2))) ^ ((((((0xc0
) >> 16))) >> 2)))) >> (1)) != 0) ? 1 : 0) :
((((u_long)((((((((((0xc0) >> 16))))) - 1) & (((((
(0xc0) >> 16)))))) ^ ((((((0xc0) >> 16))))))) >>
(1)) != 0) ? 1 : 0)))) : ((((u_long)(((((((0xc0))) - 1) &
(((0xc0)))) ^ (((0xc0))))) >> (8)) != 0) ? 8 + ((((u_long
)((((((((0xc0)) >> 8)) - 1) & ((((0xc0)) >> 8
))) ^ ((((0xc0)) >> 8)))) >> (4)) != 0) ? 4 + (((
(u_long)(((((((((0xc0)) >> 8) >> 4)) - 1) & (
((((0xc0)) >> 8) >> 4))) ^ (((((0xc0)) >> 8
) >> 4)))) >> (2)) != 0) ? 2 + ((((u_long)(((((((
(((0xc0)) >> 8) >> 4) >> 2)) - 1) & (((
(((0xc0)) >> 8) >> 4) >> 2))) ^ ((((((0xc0)
) >> 8) >> 4) >> 2)))) >> (1)) != 0) ?
1 : 0) : ((((u_long)((((((((((0xc0)) >> 8) >> 4)
)) - 1) & ((((((0xc0)) >> 8) >> 4)))) ^ (((((
(0xc0)) >> 8) >> 4))))) >> (1)) != 0) ? 1 :
0)) : ((((u_long)(((((((((0xc0)) >> 8))) - 1) & ((
(((0xc0)) >> 8)))) ^ (((((0xc0)) >> 8))))) >>
(2)) != 0) ? 2 + ((((u_long)((((((((((0xc0)) >> 8)) >>
2)) - 1) & ((((((0xc0)) >> 8)) >> 2))) ^ (((
(((0xc0)) >> 8)) >> 2)))) >> (1)) != 0) ? 1
: 0) : ((((u_long)((((((((((0xc0)) >> 8)))) - 1) &
((((((0xc0)) >> 8))))) ^ ((((((0xc0)) >> 8))))))
>> (1)) != 0) ? 1 : 0))) : ((((u_long)((((((((0xc0))))
- 1) & ((((0xc0))))) ^ ((((0xc0)))))) >> (4)) != 0
) ? 4 + ((((u_long)(((((((((0xc0))) >> 4)) - 1) & (
((((0xc0))) >> 4))) ^ (((((0xc0))) >> 4)))) >>
(2)) != 0) ? 2 + ((((u_long)((((((((((0xc0))) >> 4) >>
2)) - 1) & ((((((0xc0))) >> 4) >> 2))) ^ (((
(((0xc0))) >> 4) >> 2)))) >> (1)) != 0) ? 1
: 0) : ((((u_long)((((((((((0xc0))) >> 4))) - 1) &
((((((0xc0))) >> 4)))) ^ ((((((0xc0))) >> 4)))))
>> (1)) != 0) ? 1 : 0)) : ((((u_long)(((((((((0xc0))))
) - 1) & (((((0xc0)))))) ^ (((((0xc0))))))) >> (2))
!= 0) ? 2 + ((((u_long)((((((((((0xc0)))) >> 2)) - 1) &
((((((0xc0)))) >> 2))) ^ ((((((0xc0)))) >> 2))))
>> (1)) != 0) ? 1 : 0) : ((((u_long)((((((((((0xc0))))
)) - 1) & ((((((0xc0))))))) ^ ((((((0xc0)))))))) >>
(1)) != 0) ? 1 : 0))))))
;
659
660 RTW_WRITE8(regs, RTW_9346CR, ecr)((*(regs)->r_write8)(regs, 0x50, ecr));
661
662 sr->sr_content = malloc(sr->sr_size, M_DEVBUF2, M_NOWAIT0x0002 | M_ZERO0x0008);
663
664 if (sr->sr_content == NULL((void *)0)) {
665 printf("%s: unable to allocate SROM buffer\n", dvname);
666 return ENOMEM12;
667 }
668
669 /* RTL8180 has a single 8-bit register for controlling the
670 * 93cx6 SROM. There is no "ready" bit. The RTL8180
671 * input/output sense is the reverse of read_seeprom's.
672 */
673 sd.sd_tag = regs->r_bt;
674 sd.sd_bsh = regs->r_bh;
675 sd.sd_regsize = 1;
676 sd.sd_control_offset = RTW_9346CR0x50;
677 sd.sd_status_offset = RTW_9346CR0x50;
678 sd.sd_dataout_offset = RTW_9346CR0x50;
679 sd.sd_CK = RTW_9346CR_EESK(1<<2);
680 sd.sd_CS = RTW_9346CR_EECS(1<<3);
681 sd.sd_DI = RTW_9346CR_EEDO(1<<0);
682 sd.sd_DO = RTW_9346CR_EEDI(1<<1);
683 /* make read_seeprom enter EEPROM read/write mode */
684 sd.sd_MS = ecr;
685 sd.sd_RDY = 0;
686
687 /* TBD bus barriers */
688 if (!read_seeprom(&sd, sr->sr_content, 0, sr->sr_size/2)) {
689 printf("\n%s: could not read SROM\n", dvname);
690 free(sr->sr_content, M_DEVBUF2, 0);
691 sr->sr_content = NULL((void *)0);
692 return -1; /* XXX */
693 }
694
695 /* end EEPROM read/write mode */
696 RTW_WRITE8(regs, RTW_9346CR,((*(regs)->r_write8)(regs, 0x50, (ecr & ~0xc0) | ((0) <<
((((u_long)((((((0xc0)) - 1) & ((0xc0))) ^ ((0xc0)))) >>
(16)) != 0) ? 16 + ((((u_long)(((((((0xc0) >> 16)) - 1
) & (((0xc0) >> 16))) ^ (((0xc0) >> 16)))) >>
(8)) != 0) ? 8 + ((((u_long)((((((((0xc0) >> 16) >>
8)) - 1) & ((((0xc0) >> 16) >> 8))) ^ ((((0xc0
) >> 16) >> 8)))) >> (4)) != 0) ? 4 + ((((u_long
)(((((((((0xc0) >> 16) >> 8) >> 4)) - 1) &
(((((0xc0) >> 16) >> 8) >> 4))) ^ (((((0xc0
) >> 16) >> 8) >> 4)))) >> (2)) != 0)
? 2 + ((((u_long)((((((((((0xc0) >> 16) >> 8) >>
4) >> 2)) - 1) & ((((((0xc0) >> 16) >>
8) >> 4) >> 2))) ^ ((((((0xc0) >> 16) >>
8) >> 4) >> 2)))) >> (1)) != 0) ? 1 : 0) :
((((u_long)((((((((((0xc0) >> 16) >> 8) >>
4))) - 1) & ((((((0xc0) >> 16) >> 8) >>
4)))) ^ ((((((0xc0) >> 16) >> 8) >> 4)))))
>> (1)) != 0) ? 1 : 0)) : ((((u_long)(((((((((0xc0) >>
16) >> 8))) - 1) & (((((0xc0) >> 16) >>
8)))) ^ (((((0xc0) >> 16) >> 8))))) >> (2)
) != 0) ? 2 + ((((u_long)((((((((((0xc0) >> 16) >>
8)) >> 2)) - 1) & ((((((0xc0) >> 16) >>
8)) >> 2))) ^ ((((((0xc0) >> 16) >> 8)) >>
2)))) >> (1)) != 0) ? 1 : 0) : ((((u_long)((((((((((0xc0
) >> 16) >> 8)))) - 1) & ((((((0xc0) >>
16) >> 8))))) ^ ((((((0xc0) >> 16) >> 8)))
))) >> (1)) != 0) ? 1 : 0))) : ((((u_long)((((((((0xc0)
>> 16))) - 1) & ((((0xc0) >> 16)))) ^ ((((0xc0
) >> 16))))) >> (4)) != 0) ? 4 + ((((u_long)(((((
((((0xc0) >> 16)) >> 4)) - 1) & (((((0xc0) >>
16)) >> 4))) ^ (((((0xc0) >> 16)) >> 4))))
>> (2)) != 0) ? 2 + ((((u_long)((((((((((0xc0) >>
16)) >> 4) >> 2)) - 1) & ((((((0xc0) >>
16)) >> 4) >> 2))) ^ ((((((0xc0) >> 16)) >>
4) >> 2)))) >> (1)) != 0) ? 1 : 0) : ((((u_long)
((((((((((0xc0) >> 16)) >> 4))) - 1) & ((((((
0xc0) >> 16)) >> 4)))) ^ ((((((0xc0) >> 16)
) >> 4))))) >> (1)) != 0) ? 1 : 0)) : ((((u_long)
(((((((((0xc0) >> 16)))) - 1) & (((((0xc0) >>
16))))) ^ (((((0xc0) >> 16)))))) >> (2)) != 0) ?
2 + ((((u_long)((((((((((0xc0) >> 16))) >> 2)) -
1) & ((((((0xc0) >> 16))) >> 2))) ^ ((((((0xc0
) >> 16))) >> 2)))) >> (1)) != 0) ? 1 : 0) :
((((u_long)((((((((((0xc0) >> 16))))) - 1) & (((((
(0xc0) >> 16)))))) ^ ((((((0xc0) >> 16))))))) >>
(1)) != 0) ? 1 : 0)))) : ((((u_long)(((((((0xc0))) - 1) &
(((0xc0)))) ^ (((0xc0))))) >> (8)) != 0) ? 8 + ((((u_long
)((((((((0xc0)) >> 8)) - 1) & ((((0xc0)) >> 8
))) ^ ((((0xc0)) >> 8)))) >> (4)) != 0) ? 4 + (((
(u_long)(((((((((0xc0)) >> 8) >> 4)) - 1) & (
((((0xc0)) >> 8) >> 4))) ^ (((((0xc0)) >> 8
) >> 4)))) >> (2)) != 0) ? 2 + ((((u_long)(((((((
(((0xc0)) >> 8) >> 4) >> 2)) - 1) & (((
(((0xc0)) >> 8) >> 4) >> 2))) ^ ((((((0xc0)
) >> 8) >> 4) >> 2)))) >> (1)) != 0) ?
1 : 0) : ((((u_long)((((((((((0xc0)) >> 8) >> 4)
)) - 1) & ((((((0xc0)) >> 8) >> 4)))) ^ (((((
(0xc0)) >> 8) >> 4))))) >> (1)) != 0) ? 1 :
0)) : ((((u_long)(((((((((0xc0)) >> 8))) - 1) & ((
(((0xc0)) >> 8)))) ^ (((((0xc0)) >> 8))))) >>
(2)) != 0) ? 2 + ((((u_long)((((((((((0xc0)) >> 8)) >>
2)) - 1) & ((((((0xc0)) >> 8)) >> 2))) ^ (((
(((0xc0)) >> 8)) >> 2)))) >> (1)) != 0) ? 1
: 0) : ((((u_long)((((((((((0xc0)) >> 8)))) - 1) &
((((((0xc0)) >> 8))))) ^ ((((((0xc0)) >> 8))))))
>> (1)) != 0) ? 1 : 0))) : ((((u_long)((((((((0xc0))))
- 1) & ((((0xc0))))) ^ ((((0xc0)))))) >> (4)) != 0
) ? 4 + ((((u_long)(((((((((0xc0))) >> 4)) - 1) & (
((((0xc0))) >> 4))) ^ (((((0xc0))) >> 4)))) >>
(2)) != 0) ? 2 + ((((u_long)((((((((((0xc0))) >> 4) >>
2)) - 1) & ((((((0xc0))) >> 4) >> 2))) ^ (((
(((0xc0))) >> 4) >> 2)))) >> (1)) != 0) ? 1
: 0) : ((((u_long)((((((((((0xc0))) >> 4))) - 1) &
((((((0xc0))) >> 4)))) ^ ((((((0xc0))) >> 4)))))
>> (1)) != 0) ? 1 : 0)) : ((((u_long)(((((((((0xc0))))
) - 1) & (((((0xc0)))))) ^ (((((0xc0))))))) >> (2))
!= 0) ? 2 + ((((u_long)((((((((((0xc0)))) >> 2)) - 1) &
((((((0xc0)))) >> 2))) ^ ((((((0xc0)))) >> 2))))
>> (1)) != 0) ? 1 : 0) : ((((u_long)((((((((((0xc0))))
)) - 1) & ((((((0xc0))))))) ^ ((((((0xc0)))))))) >>
(1)) != 0) ? 1 : 0))))))))
697 (ecr & ~RTW_9346CR_EEM_MASK) | RTW_9346CR_EEM_NORMAL)((*(regs)->r_write8)(regs, 0x50, (ecr & ~0xc0) | ((0) <<
((((u_long)((((((0xc0)) - 1) & ((0xc0))) ^ ((0xc0)))) >>
(16)) != 0) ? 16 + ((((u_long)(((((((0xc0) >> 16)) - 1
) & (((0xc0) >> 16))) ^ (((0xc0) >> 16)))) >>
(8)) != 0) ? 8 + ((((u_long)((((((((0xc0) >> 16) >>
8)) - 1) & ((((0xc0) >> 16) >> 8))) ^ ((((0xc0
) >> 16) >> 8)))) >> (4)) != 0) ? 4 + ((((u_long
)(((((((((0xc0) >> 16) >> 8) >> 4)) - 1) &
(((((0xc0) >> 16) >> 8) >> 4))) ^ (((((0xc0
) >> 16) >> 8) >> 4)))) >> (2)) != 0)
? 2 + ((((u_long)((((((((((0xc0) >> 16) >> 8) >>
4) >> 2)) - 1) & ((((((0xc0) >> 16) >>
8) >> 4) >> 2))) ^ ((((((0xc0) >> 16) >>
8) >> 4) >> 2)))) >> (1)) != 0) ? 1 : 0) :
((((u_long)((((((((((0xc0) >> 16) >> 8) >>
4))) - 1) & ((((((0xc0) >> 16) >> 8) >>
4)))) ^ ((((((0xc0) >> 16) >> 8) >> 4)))))
>> (1)) != 0) ? 1 : 0)) : ((((u_long)(((((((((0xc0) >>
16) >> 8))) - 1) & (((((0xc0) >> 16) >>
8)))) ^ (((((0xc0) >> 16) >> 8))))) >> (2)
) != 0) ? 2 + ((((u_long)((((((((((0xc0) >> 16) >>
8)) >> 2)) - 1) & ((((((0xc0) >> 16) >>
8)) >> 2))) ^ ((((((0xc0) >> 16) >> 8)) >>
2)))) >> (1)) != 0) ? 1 : 0) : ((((u_long)((((((((((0xc0
) >> 16) >> 8)))) - 1) & ((((((0xc0) >>
16) >> 8))))) ^ ((((((0xc0) >> 16) >> 8)))
))) >> (1)) != 0) ? 1 : 0))) : ((((u_long)((((((((0xc0)
>> 16))) - 1) & ((((0xc0) >> 16)))) ^ ((((0xc0
) >> 16))))) >> (4)) != 0) ? 4 + ((((u_long)(((((
((((0xc0) >> 16)) >> 4)) - 1) & (((((0xc0) >>
16)) >> 4))) ^ (((((0xc0) >> 16)) >> 4))))
>> (2)) != 0) ? 2 + ((((u_long)((((((((((0xc0) >>
16)) >> 4) >> 2)) - 1) & ((((((0xc0) >>
16)) >> 4) >> 2))) ^ ((((((0xc0) >> 16)) >>
4) >> 2)))) >> (1)) != 0) ? 1 : 0) : ((((u_long)
((((((((((0xc0) >> 16)) >> 4))) - 1) & ((((((
0xc0) >> 16)) >> 4)))) ^ ((((((0xc0) >> 16)
) >> 4))))) >> (1)) != 0) ? 1 : 0)) : ((((u_long)
(((((((((0xc0) >> 16)))) - 1) & (((((0xc0) >>
16))))) ^ (((((0xc0) >> 16)))))) >> (2)) != 0) ?
2 + ((((u_long)((((((((((0xc0) >> 16))) >> 2)) -
1) & ((((((0xc0) >> 16))) >> 2))) ^ ((((((0xc0
) >> 16))) >> 2)))) >> (1)) != 0) ? 1 : 0) :
((((u_long)((((((((((0xc0) >> 16))))) - 1) & (((((
(0xc0) >> 16)))))) ^ ((((((0xc0) >> 16))))))) >>
(1)) != 0) ? 1 : 0)))) : ((((u_long)(((((((0xc0))) - 1) &
(((0xc0)))) ^ (((0xc0))))) >> (8)) != 0) ? 8 + ((((u_long
)((((((((0xc0)) >> 8)) - 1) & ((((0xc0)) >> 8
))) ^ ((((0xc0)) >> 8)))) >> (4)) != 0) ? 4 + (((
(u_long)(((((((((0xc0)) >> 8) >> 4)) - 1) & (
((((0xc0)) >> 8) >> 4))) ^ (((((0xc0)) >> 8
) >> 4)))) >> (2)) != 0) ? 2 + ((((u_long)(((((((
(((0xc0)) >> 8) >> 4) >> 2)) - 1) & (((
(((0xc0)) >> 8) >> 4) >> 2))) ^ ((((((0xc0)
) >> 8) >> 4) >> 2)))) >> (1)) != 0) ?
1 : 0) : ((((u_long)((((((((((0xc0)) >> 8) >> 4)
)) - 1) & ((((((0xc0)) >> 8) >> 4)))) ^ (((((
(0xc0)) >> 8) >> 4))))) >> (1)) != 0) ? 1 :
0)) : ((((u_long)(((((((((0xc0)) >> 8))) - 1) & ((
(((0xc0)) >> 8)))) ^ (((((0xc0)) >> 8))))) >>
(2)) != 0) ? 2 + ((((u_long)((((((((((0xc0)) >> 8)) >>
2)) - 1) & ((((((0xc0)) >> 8)) >> 2))) ^ (((
(((0xc0)) >> 8)) >> 2)))) >> (1)) != 0) ? 1
: 0) : ((((u_long)((((((((((0xc0)) >> 8)))) - 1) &
((((((0xc0)) >> 8))))) ^ ((((((0xc0)) >> 8))))))
>> (1)) != 0) ? 1 : 0))) : ((((u_long)((((((((0xc0))))
- 1) & ((((0xc0))))) ^ ((((0xc0)))))) >> (4)) != 0
) ? 4 + ((((u_long)(((((((((0xc0))) >> 4)) - 1) & (
((((0xc0))) >> 4))) ^ (((((0xc0))) >> 4)))) >>
(2)) != 0) ? 2 + ((((u_long)((((((((((0xc0))) >> 4) >>
2)) - 1) & ((((((0xc0))) >> 4) >> 2))) ^ (((
(((0xc0))) >> 4) >> 2)))) >> (1)) != 0) ? 1
: 0) : ((((u_long)((((((((((0xc0))) >> 4))) - 1) &
((((((0xc0))) >> 4)))) ^ ((((((0xc0))) >> 4)))))
>> (1)) != 0) ? 1 : 0)) : ((((u_long)(((((((((0xc0))))
) - 1) & (((((0xc0)))))) ^ (((((0xc0))))))) >> (2))
!= 0) ? 2 + ((((u_long)((((((((((0xc0)))) >> 2)) - 1) &
((((((0xc0)))) >> 2))) ^ ((((((0xc0)))) >> 2))))
>> (1)) != 0) ? 1 : 0) : ((((u_long)((((((((((0xc0))))
)) - 1) & ((((((0xc0))))))) ^ ((((((0xc0)))))))) >>
(1)) != 0) ? 1 : 0))))))))
;
698 RTW_WBRW(regs, RTW_9346CR, RTW_9346CR)((*(regs)->r_barrier)(regs, 0x50, 0x50, 0x02 | 0x02));
699
700 if ((rc = rtw_recall_eeprom(regs, dvname)) != 0)
701 return rc;
702
703#ifdef RTW_DEBUG
704 {
705 int i;
706 RTW_DPRINTF(RTW_DEBUG_ATTACH,
707 ("\n%s: serial ROM:\n\t", dvname));
708 for (i = 0; i < sr->sr_size/2; i++) {
709 if (((i % 8) == 0) && (i != 0))
710 RTW_DPRINTF(RTW_DEBUG_ATTACH, ("\n\t"));
711 RTW_DPRINTF(RTW_DEBUG_ATTACH,
712 (" %04x", sr->sr_content[i]));
713 }
714 RTW_DPRINTF(RTW_DEBUG_ATTACH, ("\n"));
715 }
716#endif /* RTW_DEBUG */
717 return 0;
718}
719
720void
721rtw_set_rfprog(struct rtw_regs *regs, int rfchipid,
722 const char *dvname)
723{
724 u_int8_t cfg4;
725 const char *method;
726
727 cfg4 = RTW_READ8(regs, RTW_CONFIG4)((*(regs)->r_read8)(regs, 0x5A)) & ~RTW_CONFIG4_RFTYPE_MASK0x3;
728
729 switch (rfchipid) {
730 default:
731 cfg4 |= LSHIFT(rtw_rfprog_fallback, RTW_CONFIG4_RFTYPE_MASK)((rtw_rfprog_fallback) << ((((u_long)((((((0x3)) - 1) &
((0x3))) ^ ((0x3)))) >> (16)) != 0) ? 16 + ((((u_long)
(((((((0x3) >> 16)) - 1) & (((0x3) >> 16))) ^
(((0x3) >> 16)))) >> (8)) != 0) ? 8 + ((((u_long
)((((((((0x3) >> 16) >> 8)) - 1) & ((((0x3) >>
16) >> 8))) ^ ((((0x3) >> 16) >> 8)))) >>
(4)) != 0) ? 4 + ((((u_long)(((((((((0x3) >> 16) >>
8) >> 4)) - 1) & (((((0x3) >> 16) >> 8
) >> 4))) ^ (((((0x3) >> 16) >> 8) >>
4)))) >> (2)) != 0) ? 2 + ((((u_long)((((((((((0x3) >>
16) >> 8) >> 4) >> 2)) - 1) & ((((((0x3
) >> 16) >> 8) >> 4) >> 2))) ^ ((((((
0x3) >> 16) >> 8) >> 4) >> 2)))) >>
(1)) != 0) ? 1 : 0) : ((((u_long)((((((((((0x3) >> 16)
>> 8) >> 4))) - 1) & ((((((0x3) >> 16)
>> 8) >> 4)))) ^ ((((((0x3) >> 16) >>
8) >> 4))))) >> (1)) != 0) ? 1 : 0)) : ((((u_long
)(((((((((0x3) >> 16) >> 8))) - 1) & (((((0x3
) >> 16) >> 8)))) ^ (((((0x3) >> 16) >>
8))))) >> (2)) != 0) ? 2 + ((((u_long)((((((((((0x3) >>
16) >> 8)) >> 2)) - 1) & ((((((0x3) >>
16) >> 8)) >> 2))) ^ ((((((0x3) >> 16) >>
8)) >> 2)))) >> (1)) != 0) ? 1 : 0) : ((((u_long
)((((((((((0x3) >> 16) >> 8)))) - 1) & ((((((
0x3) >> 16) >> 8))))) ^ ((((((0x3) >> 16) >>
8)))))) >> (1)) != 0) ? 1 : 0))) : ((((u_long)((((((((
0x3) >> 16))) - 1) & ((((0x3) >> 16)))) ^ (((
(0x3) >> 16))))) >> (4)) != 0) ? 4 + ((((u_long)(
((((((((0x3) >> 16)) >> 4)) - 1) & (((((0x3) >>
16)) >> 4))) ^ (((((0x3) >> 16)) >> 4)))) >>
(2)) != 0) ? 2 + ((((u_long)((((((((((0x3) >> 16)) >>
4) >> 2)) - 1) & ((((((0x3) >> 16)) >>
4) >> 2))) ^ ((((((0x3) >> 16)) >> 4) >>
2)))) >> (1)) != 0) ? 1 : 0) : ((((u_long)((((((((((0x3
) >> 16)) >> 4))) - 1) & ((((((0x3) >> 16
)) >> 4)))) ^ ((((((0x3) >> 16)) >> 4))))) >>
(1)) != 0) ? 1 : 0)) : ((((u_long)(((((((((0x3) >> 16)
))) - 1) & (((((0x3) >> 16))))) ^ (((((0x3) >>
16)))))) >> (2)) != 0) ? 2 + ((((u_long)((((((((((0x3)
>> 16))) >> 2)) - 1) & ((((((0x3) >> 16
))) >> 2))) ^ ((((((0x3) >> 16))) >> 2)))) >>
(1)) != 0) ? 1 : 0) : ((((u_long)((((((((((0x3) >> 16)
)))) - 1) & ((((((0x3) >> 16)))))) ^ ((((((0x3) >>
16))))))) >> (1)) != 0) ? 1 : 0)))) : ((((u_long)(((((
((0x3))) - 1) & (((0x3)))) ^ (((0x3))))) >> (8)) !=
0) ? 8 + ((((u_long)((((((((0x3)) >> 8)) - 1) & ((
((0x3)) >> 8))) ^ ((((0x3)) >> 8)))) >> (4)
) != 0) ? 4 + ((((u_long)(((((((((0x3)) >> 8) >> 4
)) - 1) & (((((0x3)) >> 8) >> 4))) ^ (((((0x3
)) >> 8) >> 4)))) >> (2)) != 0) ? 2 + ((((u_long
)((((((((((0x3)) >> 8) >> 4) >> 2)) - 1) &
((((((0x3)) >> 8) >> 4) >> 2))) ^ ((((((0x3
)) >> 8) >> 4) >> 2)))) >> (1)) != 0)
? 1 : 0) : ((((u_long)((((((((((0x3)) >> 8) >> 4
))) - 1) & ((((((0x3)) >> 8) >> 4)))) ^ (((((
(0x3)) >> 8) >> 4))))) >> (1)) != 0) ? 1 : 0
)) : ((((u_long)(((((((((0x3)) >> 8))) - 1) & (((((
0x3)) >> 8)))) ^ (((((0x3)) >> 8))))) >> (2
)) != 0) ? 2 + ((((u_long)((((((((((0x3)) >> 8)) >>
2)) - 1) & ((((((0x3)) >> 8)) >> 2))) ^ ((((
((0x3)) >> 8)) >> 2)))) >> (1)) != 0) ? 1 :
0) : ((((u_long)((((((((((0x3)) >> 8)))) - 1) & ((
((((0x3)) >> 8))))) ^ ((((((0x3)) >> 8)))))) >>
(1)) != 0) ? 1 : 0))) : ((((u_long)((((((((0x3)))) - 1) &
((((0x3))))) ^ ((((0x3)))))) >> (4)) != 0) ? 4 + ((((u_long
)(((((((((0x3))) >> 4)) - 1) & (((((0x3))) >>
4))) ^ (((((0x3))) >> 4)))) >> (2)) != 0) ? 2 + (
(((u_long)((((((((((0x3))) >> 4) >> 2)) - 1) &
((((((0x3))) >> 4) >> 2))) ^ ((((((0x3))) >>
4) >> 2)))) >> (1)) != 0) ? 1 : 0) : ((((u_long)
((((((((((0x3))) >> 4))) - 1) & ((((((0x3))) >>
4)))) ^ ((((((0x3))) >> 4))))) >> (1)) != 0) ? 1
: 0)) : ((((u_long)(((((((((0x3))))) - 1) & (((((0x3))))
)) ^ (((((0x3))))))) >> (2)) != 0) ? 2 + ((((u_long)(((
(((((((0x3)))) >> 2)) - 1) & ((((((0x3)))) >>
2))) ^ ((((((0x3)))) >> 2)))) >> (1)) != 0) ? 1 :
0) : ((((u_long)((((((((((0x3)))))) - 1) & ((((((0x3))))
))) ^ ((((((0x3)))))))) >> (1)) != 0) ? 1 : 0))))))
;
732 method = "fallback";
733 break;
734 case RTW_RFCHIPID_INTERSIL0x01:
735 cfg4 |= RTW_CONFIG4_RFTYPE_INTERSIL((1) << ((((u_long)((((((0x3)) - 1) & ((0x3))) ^ ((
0x3)))) >> (16)) != 0) ? 16 + ((((u_long)(((((((0x3) >>
16)) - 1) & (((0x3) >> 16))) ^ (((0x3) >> 16
)))) >> (8)) != 0) ? 8 + ((((u_long)((((((((0x3) >>
16) >> 8)) - 1) & ((((0x3) >> 16) >> 8
))) ^ ((((0x3) >> 16) >> 8)))) >> (4)) != 0
) ? 4 + ((((u_long)(((((((((0x3) >> 16) >> 8) >>
4)) - 1) & (((((0x3) >> 16) >> 8) >> 4
))) ^ (((((0x3) >> 16) >> 8) >> 4)))) >>
(2)) != 0) ? 2 + ((((u_long)((((((((((0x3) >> 16) >>
8) >> 4) >> 2)) - 1) & ((((((0x3) >> 16
) >> 8) >> 4) >> 2))) ^ ((((((0x3) >>
16) >> 8) >> 4) >> 2)))) >> (1)) != 0
) ? 1 : 0) : ((((u_long)((((((((((0x3) >> 16) >> 8
) >> 4))) - 1) & ((((((0x3) >> 16) >> 8
) >> 4)))) ^ ((((((0x3) >> 16) >> 8) >>
4))))) >> (1)) != 0) ? 1 : 0)) : ((((u_long)(((((((((0x3
) >> 16) >> 8))) - 1) & (((((0x3) >> 16
) >> 8)))) ^ (((((0x3) >> 16) >> 8))))) >>
(2)) != 0) ? 2 + ((((u_long)((((((((((0x3) >> 16) >>
8)) >> 2)) - 1) & ((((((0x3) >> 16) >>
8)) >> 2))) ^ ((((((0x3) >> 16) >> 8)) >>
2)))) >> (1)) != 0) ? 1 : 0) : ((((u_long)((((((((((0x3
) >> 16) >> 8)))) - 1) & ((((((0x3) >> 16
) >> 8))))) ^ ((((((0x3) >> 16) >> 8)))))) >>
(1)) != 0) ? 1 : 0))) : ((((u_long)((((((((0x3) >> 16)
)) - 1) & ((((0x3) >> 16)))) ^ ((((0x3) >> 16
))))) >> (4)) != 0) ? 4 + ((((u_long)(((((((((0x3) >>
16)) >> 4)) - 1) & (((((0x3) >> 16)) >>
4))) ^ (((((0x3) >> 16)) >> 4)))) >> (2)) !=
0) ? 2 + ((((u_long)((((((((((0x3) >> 16)) >> 4)
>> 2)) - 1) & ((((((0x3) >> 16)) >> 4)
>> 2))) ^ ((((((0x3) >> 16)) >> 4) >>
2)))) >> (1)) != 0) ? 1 : 0) : ((((u_long)((((((((((0x3
) >> 16)) >> 4))) - 1) & ((((((0x3) >> 16
)) >> 4)))) ^ ((((((0x3) >> 16)) >> 4))))) >>
(1)) != 0) ? 1 : 0)) : ((((u_long)(((((((((0x3) >> 16)
))) - 1) & (((((0x3) >> 16))))) ^ (((((0x3) >>
16)))))) >> (2)) != 0) ? 2 + ((((u_long)((((((((((0x3)
>> 16))) >> 2)) - 1) & ((((((0x3) >> 16
))) >> 2))) ^ ((((((0x3) >> 16))) >> 2)))) >>
(1)) != 0) ? 1 : 0) : ((((u_long)((((((((((0x3) >> 16)
)))) - 1) & ((((((0x3) >> 16)))))) ^ ((((((0x3) >>
16))))))) >> (1)) != 0) ? 1 : 0)))) : ((((u_long)(((((
((0x3))) - 1) & (((0x3)))) ^ (((0x3))))) >> (8)) !=
0) ? 8 + ((((u_long)((((((((0x3)) >> 8)) - 1) & ((
((0x3)) >> 8))) ^ ((((0x3)) >> 8)))) >> (4)
) != 0) ? 4 + ((((u_long)(((((((((0x3)) >> 8) >> 4
)) - 1) & (((((0x3)) >> 8) >> 4))) ^ (((((0x3
)) >> 8) >> 4)))) >> (2)) != 0) ? 2 + ((((u_long
)((((((((((0x3)) >> 8) >> 4) >> 2)) - 1) &
((((((0x3)) >> 8) >> 4) >> 2))) ^ ((((((0x3
)) >> 8) >> 4) >> 2)))) >> (1)) != 0)
? 1 : 0) : ((((u_long)((((((((((0x3)) >> 8) >> 4
))) - 1) & ((((((0x3)) >> 8) >> 4)))) ^ (((((
(0x3)) >> 8) >> 4))))) >> (1)) != 0) ? 1 : 0
)) : ((((u_long)(((((((((0x3)) >> 8))) - 1) & (((((
0x3)) >> 8)))) ^ (((((0x3)) >> 8))))) >> (2
)) != 0) ? 2 + ((((u_long)((((((((((0x3)) >> 8)) >>
2)) - 1) & ((((((0x3)) >> 8)) >> 2))) ^ ((((
((0x3)) >> 8)) >> 2)))) >> (1)) != 0) ? 1 :
0) : ((((u_long)((((((((((0x3)) >> 8)))) - 1) & ((
((((0x3)) >> 8))))) ^ ((((((0x3)) >> 8)))))) >>
(1)) != 0) ? 1 : 0))) : ((((u_long)((((((((0x3)))) - 1) &
((((0x3))))) ^ ((((0x3)))))) >> (4)) != 0) ? 4 + ((((u_long
)(((((((((0x3))) >> 4)) - 1) & (((((0x3))) >>
4))) ^ (((((0x3))) >> 4)))) >> (2)) != 0) ? 2 + (
(((u_long)((((((((((0x3))) >> 4) >> 2)) - 1) &
((((((0x3))) >> 4) >> 2))) ^ ((((((0x3))) >>
4) >> 2)))) >> (1)) != 0) ? 1 : 0) : ((((u_long)
((((((((((0x3))) >> 4))) - 1) & ((((((0x3))) >>
4)))) ^ ((((((0x3))) >> 4))))) >> (1)) != 0) ? 1
: 0)) : ((((u_long)(((((((((0x3))))) - 1) & (((((0x3))))
)) ^ (((((0x3))))))) >> (2)) != 0) ? 2 + ((((u_long)(((
(((((((0x3)))) >> 2)) - 1) & ((((((0x3)))) >>
2))) ^ ((((((0x3)))) >> 2)))) >> (1)) != 0) ? 1 :
0) : ((((u_long)((((((((((0x3)))))) - 1) & ((((((0x3))))
))) ^ ((((((0x3)))))))) >> (1)) != 0) ? 1 : 0))))))
;
736 method = "Intersil";
737 break;
738 case RTW_RFCHIPID_PHILIPS0x03:
739 cfg4 |= RTW_CONFIG4_RFTYPE_PHILIPS((3) << ((((u_long)((((((0x3)) - 1) & ((0x3))) ^ ((
0x3)))) >> (16)) != 0) ? 16 + ((((u_long)(((((((0x3) >>
16)) - 1) & (((0x3) >> 16))) ^ (((0x3) >> 16
)))) >> (8)) != 0) ? 8 + ((((u_long)((((((((0x3) >>
16) >> 8)) - 1) & ((((0x3) >> 16) >> 8
))) ^ ((((0x3) >> 16) >> 8)))) >> (4)) != 0
) ? 4 + ((((u_long)(((((((((0x3) >> 16) >> 8) >>
4)) - 1) & (((((0x3) >> 16) >> 8) >> 4
))) ^ (((((0x3) >> 16) >> 8) >> 4)))) >>
(2)) != 0) ? 2 + ((((u_long)((((((((((0x3) >> 16) >>
8) >> 4) >> 2)) - 1) & ((((((0x3) >> 16
) >> 8) >> 4) >> 2))) ^ ((((((0x3) >>
16) >> 8) >> 4) >> 2)))) >> (1)) != 0
) ? 1 : 0) : ((((u_long)((((((((((0x3) >> 16) >> 8
) >> 4))) - 1) & ((((((0x3) >> 16) >> 8
) >> 4)))) ^ ((((((0x3) >> 16) >> 8) >>
4))))) >> (1)) != 0) ? 1 : 0)) : ((((u_long)(((((((((0x3
) >> 16) >> 8))) - 1) & (((((0x3) >> 16
) >> 8)))) ^ (((((0x3) >> 16) >> 8))))) >>
(2)) != 0) ? 2 + ((((u_long)((((((((((0x3) >> 16) >>
8)) >> 2)) - 1) & ((((((0x3) >> 16) >>
8)) >> 2))) ^ ((((((0x3) >> 16) >> 8)) >>
2)))) >> (1)) != 0) ? 1 : 0) : ((((u_long)((((((((((0x3
) >> 16) >> 8)))) - 1) & ((((((0x3) >> 16
) >> 8))))) ^ ((((((0x3) >> 16) >> 8)))))) >>
(1)) != 0) ? 1 : 0))) : ((((u_long)((((((((0x3) >> 16)
)) - 1) & ((((0x3) >> 16)))) ^ ((((0x3) >> 16
))))) >> (4)) != 0) ? 4 + ((((u_long)(((((((((0x3) >>
16)) >> 4)) - 1) & (((((0x3) >> 16)) >>
4))) ^ (((((0x3) >> 16)) >> 4)))) >> (2)) !=
0) ? 2 + ((((u_long)((((((((((0x3) >> 16)) >> 4)
>> 2)) - 1) & ((((((0x3) >> 16)) >> 4)
>> 2))) ^ ((((((0x3) >> 16)) >> 4) >>
2)))) >> (1)) != 0) ? 1 : 0) : ((((u_long)((((((((((0x3
) >> 16)) >> 4))) - 1) & ((((((0x3) >> 16
)) >> 4)))) ^ ((((((0x3) >> 16)) >> 4))))) >>
(1)) != 0) ? 1 : 0)) : ((((u_long)(((((((((0x3) >> 16)
))) - 1) & (((((0x3) >> 16))))) ^ (((((0x3) >>
16)))))) >> (2)) != 0) ? 2 + ((((u_long)((((((((((0x3)
>> 16))) >> 2)) - 1) & ((((((0x3) >> 16
))) >> 2))) ^ ((((((0x3) >> 16))) >> 2)))) >>
(1)) != 0) ? 1 : 0) : ((((u_long)((((((((((0x3) >> 16)
)))) - 1) & ((((((0x3) >> 16)))))) ^ ((((((0x3) >>
16))))))) >> (1)) != 0) ? 1 : 0)))) : ((((u_long)(((((
((0x3))) - 1) & (((0x3)))) ^ (((0x3))))) >> (8)) !=
0) ? 8 + ((((u_long)((((((((0x3)) >> 8)) - 1) & ((
((0x3)) >> 8))) ^ ((((0x3)) >> 8)))) >> (4)
) != 0) ? 4 + ((((u_long)(((((((((0x3)) >> 8) >> 4
)) - 1) & (((((0x3)) >> 8) >> 4))) ^ (((((0x3
)) >> 8) >> 4)))) >> (2)) != 0) ? 2 + ((((u_long
)((((((((((0x3)) >> 8) >> 4) >> 2)) - 1) &
((((((0x3)) >> 8) >> 4) >> 2))) ^ ((((((0x3
)) >> 8) >> 4) >> 2)))) >> (1)) != 0)
? 1 : 0) : ((((u_long)((((((((((0x3)) >> 8) >> 4
))) - 1) & ((((((0x3)) >> 8) >> 4)))) ^ (((((
(0x3)) >> 8) >> 4))))) >> (1)) != 0) ? 1 : 0
)) : ((((u_long)(((((((((0x3)) >> 8))) - 1) & (((((
0x3)) >> 8)))) ^ (((((0x3)) >> 8))))) >> (2
)) != 0) ? 2 + ((((u_long)((((((((((0x3)) >> 8)) >>
2)) - 1) & ((((((0x3)) >> 8)) >> 2))) ^ ((((
((0x3)) >> 8)) >> 2)))) >> (1)) != 0) ? 1 :
0) : ((((u_long)((((((((((0x3)) >> 8)))) - 1) & ((
((((0x3)) >> 8))))) ^ ((((((0x3)) >> 8)))))) >>
(1)) != 0) ? 1 : 0))) : ((((u_long)((((((((0x3)))) - 1) &
((((0x3))))) ^ ((((0x3)))))) >> (4)) != 0) ? 4 + ((((u_long
)(((((((((0x3))) >> 4)) - 1) & (((((0x3))) >>
4))) ^ (((((0x3))) >> 4)))) >> (2)) != 0) ? 2 + (
(((u_long)((((((((((0x3))) >> 4) >> 2)) - 1) &
((((((0x3))) >> 4) >> 2))) ^ ((((((0x3))) >>
4) >> 2)))) >> (1)) != 0) ? 1 : 0) : ((((u_long)
((((((((((0x3))) >> 4))) - 1) & ((((((0x3))) >>
4)))) ^ ((((((0x3))) >> 4))))) >> (1)) != 0) ? 1
: 0)) : ((((u_long)(((((((((0x3))))) - 1) & (((((0x3))))
)) ^ (((((0x3))))))) >> (2)) != 0) ? 2 + ((((u_long)(((
(((((((0x3)))) >> 2)) - 1) & ((((((0x3)))) >>
2))) ^ ((((((0x3)))) >> 2)))) >> (1)) != 0) ? 1 :
0) : ((((u_long)((((((((((0x3)))))) - 1) & ((((((0x3))))
))) ^ ((((((0x3)))))))) >> (1)) != 0) ? 1 : 0))))))
;
740 method = "Philips";
741 break;
742 case RTW_RFCHIPID_RFMD29480x02:
743 cfg4 |= RTW_CONFIG4_RFTYPE_RFMD((2) << ((((u_long)((((((0x3)) - 1) & ((0x3))) ^ ((
0x3)))) >> (16)) != 0) ? 16 + ((((u_long)(((((((0x3) >>
16)) - 1) & (((0x3) >> 16))) ^ (((0x3) >> 16
)))) >> (8)) != 0) ? 8 + ((((u_long)((((((((0x3) >>
16) >> 8)) - 1) & ((((0x3) >> 16) >> 8
))) ^ ((((0x3) >> 16) >> 8)))) >> (4)) != 0
) ? 4 + ((((u_long)(((((((((0x3) >> 16) >> 8) >>
4)) - 1) & (((((0x3) >> 16) >> 8) >> 4
))) ^ (((((0x3) >> 16) >> 8) >> 4)))) >>
(2)) != 0) ? 2 + ((((u_long)((((((((((0x3) >> 16) >>
8) >> 4) >> 2)) - 1) & ((((((0x3) >> 16
) >> 8) >> 4) >> 2))) ^ ((((((0x3) >>
16) >> 8) >> 4) >> 2)))) >> (1)) != 0
) ? 1 : 0) : ((((u_long)((((((((((0x3) >> 16) >> 8
) >> 4))) - 1) & ((((((0x3) >> 16) >> 8
) >> 4)))) ^ ((((((0x3) >> 16) >> 8) >>
4))))) >> (1)) != 0) ? 1 : 0)) : ((((u_long)(((((((((0x3
) >> 16) >> 8))) - 1) & (((((0x3) >> 16
) >> 8)))) ^ (((((0x3) >> 16) >> 8))))) >>
(2)) != 0) ? 2 + ((((u_long)((((((((((0x3) >> 16) >>
8)) >> 2)) - 1) & ((((((0x3) >> 16) >>
8)) >> 2))) ^ ((((((0x3) >> 16) >> 8)) >>
2)))) >> (1)) != 0) ? 1 : 0) : ((((u_long)((((((((((0x3
) >> 16) >> 8)))) - 1) & ((((((0x3) >> 16
) >> 8))))) ^ ((((((0x3) >> 16) >> 8)))))) >>
(1)) != 0) ? 1 : 0))) : ((((u_long)((((((((0x3) >> 16)
)) - 1) & ((((0x3) >> 16)))) ^ ((((0x3) >> 16
))))) >> (4)) != 0) ? 4 + ((((u_long)(((((((((0x3) >>
16)) >> 4)) - 1) & (((((0x3) >> 16)) >>
4))) ^ (((((0x3) >> 16)) >> 4)))) >> (2)) !=
0) ? 2 + ((((u_long)((((((((((0x3) >> 16)) >> 4)
>> 2)) - 1) & ((((((0x3) >> 16)) >> 4)
>> 2))) ^ ((((((0x3) >> 16)) >> 4) >>
2)))) >> (1)) != 0) ? 1 : 0) : ((((u_long)((((((((((0x3
) >> 16)) >> 4))) - 1) & ((((((0x3) >> 16
)) >> 4)))) ^ ((((((0x3) >> 16)) >> 4))))) >>
(1)) != 0) ? 1 : 0)) : ((((u_long)(((((((((0x3) >> 16)
))) - 1) & (((((0x3) >> 16))))) ^ (((((0x3) >>
16)))))) >> (2)) != 0) ? 2 + ((((u_long)((((((((((0x3)
>> 16))) >> 2)) - 1) & ((((((0x3) >> 16
))) >> 2))) ^ ((((((0x3) >> 16))) >> 2)))) >>
(1)) != 0) ? 1 : 0) : ((((u_long)((((((((((0x3) >> 16)
)))) - 1) & ((((((0x3) >> 16)))))) ^ ((((((0x3) >>
16))))))) >> (1)) != 0) ? 1 : 0)))) : ((((u_long)(((((
((0x3))) - 1) & (((0x3)))) ^ (((0x3))))) >> (8)) !=
0) ? 8 + ((((u_long)((((((((0x3)) >> 8)) - 1) & ((
((0x3)) >> 8))) ^ ((((0x3)) >> 8)))) >> (4)
) != 0) ? 4 + ((((u_long)(((((((((0x3)) >> 8) >> 4
)) - 1) & (((((0x3)) >> 8) >> 4))) ^ (((((0x3
)) >> 8) >> 4)))) >> (2)) != 0) ? 2 + ((((u_long
)((((((((((0x3)) >> 8) >> 4) >> 2)) - 1) &
((((((0x3)) >> 8) >> 4) >> 2))) ^ ((((((0x3
)) >> 8) >> 4) >> 2)))) >> (1)) != 0)
? 1 : 0) : ((((u_long)((((((((((0x3)) >> 8) >> 4
))) - 1) & ((((((0x3)) >> 8) >> 4)))) ^ (((((
(0x3)) >> 8) >> 4))))) >> (1)) != 0) ? 1 : 0
)) : ((((u_long)(((((((((0x3)) >> 8))) - 1) & (((((
0x3)) >> 8)))) ^ (((((0x3)) >> 8))))) >> (2
)) != 0) ? 2 + ((((u_long)((((((((((0x3)) >> 8)) >>
2)) - 1) & ((((((0x3)) >> 8)) >> 2))) ^ ((((
((0x3)) >> 8)) >> 2)))) >> (1)) != 0) ? 1 :
0) : ((((u_long)((((((((((0x3)) >> 8)))) - 1) & ((
((((0x3)) >> 8))))) ^ ((((((0x3)) >> 8)))))) >>
(1)) != 0) ? 1 : 0))) : ((((u_long)((((((((0x3)))) - 1) &
((((0x3))))) ^ ((((0x3)))))) >> (4)) != 0) ? 4 + ((((u_long
)(((((((((0x3))) >> 4)) - 1) & (((((0x3))) >>
4))) ^ (((((0x3))) >> 4)))) >> (2)) != 0) ? 2 + (
(((u_long)((((((((((0x3))) >> 4) >> 2)) - 1) &
((((((0x3))) >> 4) >> 2))) ^ ((((((0x3))) >>
4) >> 2)))) >> (1)) != 0) ? 1 : 0) : ((((u_long)
((((((((((0x3))) >> 4))) - 1) & ((((((0x3))) >>
4)))) ^ ((((((0x3))) >> 4))))) >> (1)) != 0) ? 1
: 0)) : ((((u_long)(((((((((0x3))))) - 1) & (((((0x3))))
)) ^ (((((0x3))))))) >> (2)) != 0) ? 2 + ((((u_long)(((
(((((((0x3)))) >> 2)) - 1) & ((((((0x3)))) >>
2))) ^ ((((((0x3)))) >> 2)))) >> (1)) != 0) ? 1 :
0) : ((((u_long)((((((((((0x3)))))) - 1) & ((((((0x3))))
))) ^ ((((((0x3)))))))) >> (1)) != 0) ? 1 : 0))))))
;
744 method = "RFMD";
745 break;
746 }
747
748 RTW_WRITE8(regs, RTW_CONFIG4, cfg4)((*(regs)->r_write8)(regs, 0x5A, cfg4));
749
750 RTW_WBR(regs, RTW_CONFIG4, RTW_CONFIG4)((*(regs)->r_barrier)(regs, 0x5A, 0x5A, 0x02));
751
752 RTW_DPRINTF(RTW_DEBUG_INIT,
753 ("%s: %s RF programming method, %#02x\n", dvname, method,
754 RTW_READ8(regs, RTW_CONFIG4)));
755}
756
757void
758rtw_identify_country(struct rtw_regs *regs, enum rtw_locale *locale)
759{
760 u_int8_t cfg0 = RTW_READ8(regs, RTW_CONFIG0)((*(regs)->r_read8)(regs, 0x51));
761
762 switch (cfg0 & RTW8180_CONFIG0_GL_MASK0x3) {
763 case RTW8180_CONFIG0_GL_USA((3) << ((((u_long)((((((0x3)) - 1) & ((0x3))) ^ ((
0x3)))) >> (16)) != 0) ? 16 + ((((u_long)(((((((0x3) >>
16)) - 1) & (((0x3) >> 16))) ^ (((0x3) >> 16
)))) >> (8)) != 0) ? 8 + ((((u_long)((((((((0x3) >>
16) >> 8)) - 1) & ((((0x3) >> 16) >> 8
))) ^ ((((0x3) >> 16) >> 8)))) >> (4)) != 0
) ? 4 + ((((u_long)(((((((((0x3) >> 16) >> 8) >>
4)) - 1) & (((((0x3) >> 16) >> 8) >> 4
))) ^ (((((0x3) >> 16) >> 8) >> 4)))) >>
(2)) != 0) ? 2 + ((((u_long)((((((((((0x3) >> 16) >>
8) >> 4) >> 2)) - 1) & ((((((0x3) >> 16
) >> 8) >> 4) >> 2))) ^ ((((((0x3) >>
16) >> 8) >> 4) >> 2)))) >> (1)) != 0
) ? 1 : 0) : ((((u_long)((((((((((0x3) >> 16) >> 8
) >> 4))) - 1) & ((((((0x3) >> 16) >> 8
) >> 4)))) ^ ((((((0x3) >> 16) >> 8) >>
4))))) >> (1)) != 0) ? 1 : 0)) : ((((u_long)(((((((((0x3
) >> 16) >> 8))) - 1) & (((((0x3) >> 16
) >> 8)))) ^ (((((0x3) >> 16) >> 8))))) >>
(2)) != 0) ? 2 + ((((u_long)((((((((((0x3) >> 16) >>
8)) >> 2)) - 1) & ((((((0x3) >> 16) >>
8)) >> 2))) ^ ((((((0x3) >> 16) >> 8)) >>
2)))) >> (1)) != 0) ? 1 : 0) : ((((u_long)((((((((((0x3
) >> 16) >> 8)))) - 1) & ((((((0x3) >> 16
) >> 8))))) ^ ((((((0x3) >> 16) >> 8)))))) >>
(1)) != 0) ? 1 : 0))) : ((((u_long)((((((((0x3) >> 16)
)) - 1) & ((((0x3) >> 16)))) ^ ((((0x3) >> 16
))))) >> (4)) != 0) ? 4 + ((((u_long)(((((((((0x3) >>
16)) >> 4)) - 1) & (((((0x3) >> 16)) >>
4))) ^ (((((0x3) >> 16)) >> 4)))) >> (2)) !=
0) ? 2 + ((((u_long)((((((((((0x3) >> 16)) >> 4)
>> 2)) - 1) & ((((((0x3) >> 16)) >> 4)
>> 2))) ^ ((((((0x3) >> 16)) >> 4) >>
2)))) >> (1)) != 0) ? 1 : 0) : ((((u_long)((((((((((0x3
) >> 16)) >> 4))) - 1) & ((((((0x3) >> 16
)) >> 4)))) ^ ((((((0x3) >> 16)) >> 4))))) >>
(1)) != 0) ? 1 : 0)) : ((((u_long)(((((((((0x3) >> 16)
))) - 1) & (((((0x3) >> 16))))) ^ (((((0x3) >>
16)))))) >> (2)) != 0) ? 2 + ((((u_long)((((((((((0x3)
>> 16))) >> 2)) - 1) & ((((((0x3) >> 16
))) >> 2))) ^ ((((((0x3) >> 16))) >> 2)))) >>
(1)) != 0) ? 1 : 0) : ((((u_long)((((((((((0x3) >> 16)
)))) - 1) & ((((((0x3) >> 16)))))) ^ ((((((0x3) >>
16))))))) >> (1)) != 0) ? 1 : 0)))) : ((((u_long)(((((
((0x3))) - 1) & (((0x3)))) ^ (((0x3))))) >> (8)) !=
0) ? 8 + ((((u_long)((((((((0x3)) >> 8)) - 1) & ((
((0x3)) >> 8))) ^ ((((0x3)) >> 8)))) >> (4)
) != 0) ? 4 + ((((u_long)(((((((((0x3)) >> 8) >> 4
)) - 1) & (((((0x3)) >> 8) >> 4))) ^ (((((0x3
)) >> 8) >> 4)))) >> (2)) != 0) ? 2 + ((((u_long
)((((((((((0x3)) >> 8) >> 4) >> 2)) - 1) &
((((((0x3)) >> 8) >> 4) >> 2))) ^ ((((((0x3
)) >> 8) >> 4) >> 2)))) >> (1)) != 0)
? 1 : 0) : ((((u_long)((((((((((0x3)) >> 8) >> 4
))) - 1) & ((((((0x3)) >> 8) >> 4)))) ^ (((((
(0x3)) >> 8) >> 4))))) >> (1)) != 0) ? 1 : 0
)) : ((((u_long)(((((((((0x3)) >> 8))) - 1) & (((((
0x3)) >> 8)))) ^ (((((0x3)) >> 8))))) >> (2
)) != 0) ? 2 + ((((u_long)((((((((((0x3)) >> 8)) >>
2)) - 1) & ((((((0x3)) >> 8)) >> 2))) ^ ((((
((0x3)) >> 8)) >> 2)))) >> (1)) != 0) ? 1 :
0) : ((((u_long)((((((((((0x3)) >> 8)))) - 1) & ((
((((0x3)) >> 8))))) ^ ((((((0x3)) >> 8)))))) >>
(1)) != 0) ? 1 : 0))) : ((((u_long)((((((((0x3)))) - 1) &
((((0x3))))) ^ ((((0x3)))))) >> (4)) != 0) ? 4 + ((((u_long
)(((((((((0x3))) >> 4)) - 1) & (((((0x3))) >>
4))) ^ (((((0x3))) >> 4)))) >> (2)) != 0) ? 2 + (
(((u_long)((((((((((0x3))) >> 4) >> 2)) - 1) &
((((((0x3))) >> 4) >> 2))) ^ ((((((0x3))) >>
4) >> 2)))) >> (1)) != 0) ? 1 : 0) : ((((u_long)
((((((((((0x3))) >> 4))) - 1) & ((((((0x3))) >>
4)))) ^ ((((((0x3))) >> 4))))) >> (1)) != 0) ? 1
: 0)) : ((((u_long)(((((((((0x3))))) - 1) & (((((0x3))))
)) ^ (((((0x3))))))) >> (2)) != 0) ? 2 + ((((u_long)(((
(((((((0x3)))) >> 2)) - 1) & ((((((0x3)))) >>
2))) ^ ((((((0x3)))) >> 2)))) >> (1)) != 0) ? 1 :
0) : ((((u_long)((((((((((0x3)))))) - 1) & ((((((0x3))))
))) ^ ((((((0x3)))))))) >> (1)) != 0) ? 1 : 0))))))
:
764 *locale = RTW_LOCALE_USA;
765 break;
766 case RTW8180_CONFIG0_GL_JAPAN((1) << ((((u_long)((((((0x3)) - 1) & ((0x3))) ^ ((
0x3)))) >> (16)) != 0) ? 16 + ((((u_long)(((((((0x3) >>
16)) - 1) & (((0x3) >> 16))) ^ (((0x3) >> 16
)))) >> (8)) != 0) ? 8 + ((((u_long)((((((((0x3) >>
16) >> 8)) - 1) & ((((0x3) >> 16) >> 8
))) ^ ((((0x3) >> 16) >> 8)))) >> (4)) != 0
) ? 4 + ((((u_long)(((((((((0x3) >> 16) >> 8) >>
4)) - 1) & (((((0x3) >> 16) >> 8) >> 4
))) ^ (((((0x3) >> 16) >> 8) >> 4)))) >>
(2)) != 0) ? 2 + ((((u_long)((((((((((0x3) >> 16) >>
8) >> 4) >> 2)) - 1) & ((((((0x3) >> 16
) >> 8) >> 4) >> 2))) ^ ((((((0x3) >>
16) >> 8) >> 4) >> 2)))) >> (1)) != 0
) ? 1 : 0) : ((((u_long)((((((((((0x3) >> 16) >> 8
) >> 4))) - 1) & ((((((0x3) >> 16) >> 8
) >> 4)))) ^ ((((((0x3) >> 16) >> 8) >>
4))))) >> (1)) != 0) ? 1 : 0)) : ((((u_long)(((((((((0x3
) >> 16) >> 8))) - 1) & (((((0x3) >> 16
) >> 8)))) ^ (((((0x3) >> 16) >> 8))))) >>
(2)) != 0) ? 2 + ((((u_long)((((((((((0x3) >> 16) >>
8)) >> 2)) - 1) & ((((((0x3) >> 16) >>
8)) >> 2))) ^ ((((((0x3) >> 16) >> 8)) >>
2)))) >> (1)) != 0) ? 1 : 0) : ((((u_long)((((((((((0x3
) >> 16) >> 8)))) - 1) & ((((((0x3) >> 16
) >> 8))))) ^ ((((((0x3) >> 16) >> 8)))))) >>
(1)) != 0) ? 1 : 0))) : ((((u_long)((((((((0x3) >> 16)
)) - 1) & ((((0x3) >> 16)))) ^ ((((0x3) >> 16
))))) >> (4)) != 0) ? 4 + ((((u_long)(((((((((0x3) >>
16)) >> 4)) - 1) & (((((0x3) >> 16)) >>
4))) ^ (((((0x3) >> 16)) >> 4)))) >> (2)) !=
0) ? 2 + ((((u_long)((((((((((0x3) >> 16)) >> 4)
>> 2)) - 1) & ((((((0x3) >> 16)) >> 4)
>> 2))) ^ ((((((0x3) >> 16)) >> 4) >>
2)))) >> (1)) != 0) ? 1 : 0) : ((((u_long)((((((((((0x3
) >> 16)) >> 4))) - 1) & ((((((0x3) >> 16
)) >> 4)))) ^ ((((((0x3) >> 16)) >> 4))))) >>
(1)) != 0) ? 1 : 0)) : ((((u_long)(((((((((0x3) >> 16)
))) - 1) & (((((0x3) >> 16))))) ^ (((((0x3) >>
16)))))) >> (2)) != 0) ? 2 + ((((u_long)((((((((((0x3)
>> 16))) >> 2)) - 1) & ((((((0x3) >> 16
))) >> 2))) ^ ((((((0x3) >> 16))) >> 2)))) >>
(1)) != 0) ? 1 : 0) : ((((u_long)((((((((((0x3) >> 16)
)))) - 1) & ((((((0x3) >> 16)))))) ^ ((((((0x3) >>
16))))))) >> (1)) != 0) ? 1 : 0)))) : ((((u_long)(((((
((0x3))) - 1) & (((0x3)))) ^ (((0x3))))) >> (8)) !=
0) ? 8 + ((((u_long)((((((((0x3)) >> 8)) - 1) & ((
((0x3)) >> 8))) ^ ((((0x3)) >> 8)))) >> (4)
) != 0) ? 4 + ((((u_long)(((((((((0x3)) >> 8) >> 4
)) - 1) & (((((0x3)) >> 8) >> 4))) ^ (((((0x3
)) >> 8) >> 4)))) >> (2)) != 0) ? 2 + ((((u_long
)((((((((((0x3)) >> 8) >> 4) >> 2)) - 1) &
((((((0x3)) >> 8) >> 4) >> 2))) ^ ((((((0x3
)) >> 8) >> 4) >> 2)))) >> (1)) != 0)
? 1 : 0) : ((((u_long)((((((((((0x3)) >> 8) >> 4
))) - 1) & ((((((0x3)) >> 8) >> 4)))) ^ (((((
(0x3)) >> 8) >> 4))))) >> (1)) != 0) ? 1 : 0
)) : ((((u_long)(((((((((0x3)) >> 8))) - 1) & (((((
0x3)) >> 8)))) ^ (((((0x3)) >> 8))))) >> (2
)) != 0) ? 2 + ((((u_long)((((((((((0x3)) >> 8)) >>
2)) - 1) & ((((((0x3)) >> 8)) >> 2))) ^ ((((
((0x3)) >> 8)) >> 2)))) >> (1)) != 0) ? 1 :
0) : ((((u_long)((((((((((0x3)) >> 8)))) - 1) & ((
((((0x3)) >> 8))))) ^ ((((((0x3)) >> 8)))))) >>
(1)) != 0) ? 1 : 0))) : ((((u_long)((((((((0x3)))) - 1) &
((((0x3))))) ^ ((((0x3)))))) >> (4)) != 0) ? 4 + ((((u_long
)(((((((((0x3))) >> 4)) - 1) & (((((0x3))) >>
4))) ^ (((((0x3))) >> 4)))) >> (2)) != 0) ? 2 + (
(((u_long)((((((((((0x3))) >> 4) >> 2)) - 1) &
((((((0x3))) >> 4) >> 2))) ^ ((((((0x3))) >>
4) >> 2)))) >> (1)) != 0) ? 1 : 0) : ((((u_long)
((((((((((0x3))) >> 4))) - 1) & ((((((0x3))) >>
4)))) ^ ((((((0x3))) >> 4))))) >> (1)) != 0) ? 1
: 0)) : ((((u_long)(((((((((0x3))))) - 1) & (((((0x3))))
)) ^ (((((0x3))))))) >> (2)) != 0) ? 2 + ((((u_long)(((
(((((((0x3)))) >> 2)) - 1) & ((((((0x3)))) >>
2))) ^ ((((((0x3)))) >> 2)))) >> (1)) != 0) ? 1 :
0) : ((((u_long)((((((((((0x3)))))) - 1) & ((((((0x3))))
))) ^ ((((((0x3)))))))) >> (1)) != 0) ? 1 : 0))))))
:
767 case RTW8180_CONFIG0_GL_JAPAN2((0) << ((((u_long)((((((0x3)) - 1) & ((0x3))) ^ ((
0x3)))) >> (16)) != 0) ? 16 + ((((u_long)(((((((0x3) >>
16)) - 1) & (((0x3) >> 16))) ^ (((0x3) >> 16
)))) >> (8)) != 0) ? 8 + ((((u_long)((((((((0x3) >>
16) >> 8)) - 1) & ((((0x3) >> 16) >> 8
))) ^ ((((0x3) >> 16) >> 8)))) >> (4)) != 0
) ? 4 + ((((u_long)(((((((((0x3) >> 16) >> 8) >>
4)) - 1) & (((((0x3) >> 16) >> 8) >> 4
))) ^ (((((0x3) >> 16) >> 8) >> 4)))) >>
(2)) != 0) ? 2 + ((((u_long)((((((((((0x3) >> 16) >>
8) >> 4) >> 2)) - 1) & ((((((0x3) >> 16
) >> 8) >> 4) >> 2))) ^ ((((((0x3) >>
16) >> 8) >> 4) >> 2)))) >> (1)) != 0
) ? 1 : 0) : ((((u_long)((((((((((0x3) >> 16) >> 8
) >> 4))) - 1) & ((((((0x3) >> 16) >> 8
) >> 4)))) ^ ((((((0x3) >> 16) >> 8) >>
4))))) >> (1)) != 0) ? 1 : 0)) : ((((u_long)(((((((((0x3
) >> 16) >> 8))) - 1) & (((((0x3) >> 16
) >> 8)))) ^ (((((0x3) >> 16) >> 8))))) >>
(2)) != 0) ? 2 + ((((u_long)((((((((((0x3) >> 16) >>
8)) >> 2)) - 1) & ((((((0x3) >> 16) >>
8)) >> 2))) ^ ((((((0x3) >> 16) >> 8)) >>
2)))) >> (1)) != 0) ? 1 : 0) : ((((u_long)((((((((((0x3
) >> 16) >> 8)))) - 1) & ((((((0x3) >> 16
) >> 8))))) ^ ((((((0x3) >> 16) >> 8)))))) >>
(1)) != 0) ? 1 : 0))) : ((((u_long)((((((((0x3) >> 16)
)) - 1) & ((((0x3) >> 16)))) ^ ((((0x3) >> 16
))))) >> (4)) != 0) ? 4 + ((((u_long)(((((((((0x3) >>
16)) >> 4)) - 1) & (((((0x3) >> 16)) >>
4))) ^ (((((0x3) >> 16)) >> 4)))) >> (2)) !=
0) ? 2 + ((((u_long)((((((((((0x3) >> 16)) >> 4)
>> 2)) - 1) & ((((((0x3) >> 16)) >> 4)
>> 2))) ^ ((((((0x3) >> 16)) >> 4) >>
2)))) >> (1)) != 0) ? 1 : 0) : ((((u_long)((((((((((0x3
) >> 16)) >> 4))) - 1) & ((((((0x3) >> 16
)) >> 4)))) ^ ((((((0x3) >> 16)) >> 4))))) >>
(1)) != 0) ? 1 : 0)) : ((((u_long)(((((((((0x3) >> 16)
))) - 1) & (((((0x3) >> 16))))) ^ (((((0x3) >>
16)))))) >> (2)) != 0) ? 2 + ((((u_long)((((((((((0x3)
>> 16))) >> 2)) - 1) & ((((((0x3) >> 16
))) >> 2))) ^ ((((((0x3) >> 16))) >> 2)))) >>
(1)) != 0) ? 1 : 0) : ((((u_long)((((((((((0x3) >> 16)
)))) - 1) & ((((((0x3) >> 16)))))) ^ ((((((0x3) >>
16))))))) >> (1)) != 0) ? 1 : 0)))) : ((((u_long)(((((
((0x3))) - 1) & (((0x3)))) ^ (((0x3))))) >> (8)) !=
0) ? 8 + ((((u_long)((((((((0x3)) >> 8)) - 1) & ((
((0x3)) >> 8))) ^ ((((0x3)) >> 8)))) >> (4)
) != 0) ? 4 + ((((u_long)(((((((((0x3)) >> 8) >> 4
)) - 1) & (((((0x3)) >> 8) >> 4))) ^ (((((0x3
)) >> 8) >> 4)))) >> (2)) != 0) ? 2 + ((((u_long
)((((((((((0x3)) >> 8) >> 4) >> 2)) - 1) &
((((((0x3)) >> 8) >> 4) >> 2))) ^ ((((((0x3
)) >> 8) >> 4) >> 2)))) >> (1)) != 0)
? 1 : 0) : ((((u_long)((((((((((0x3)) >> 8) >> 4
))) - 1) & ((((((0x3)) >> 8) >> 4)))) ^ (((((
(0x3)) >> 8) >> 4))))) >> (1)) != 0) ? 1 : 0
)) : ((((u_long)(((((((((0x3)) >> 8))) - 1) & (((((
0x3)) >> 8)))) ^ (((((0x3)) >> 8))))) >> (2
)) != 0) ? 2 + ((((u_long)((((((((((0x3)) >> 8)) >>
2)) - 1) & ((((((0x3)) >> 8)) >> 2))) ^ ((((
((0x3)) >> 8)) >> 2)))) >> (1)) != 0) ? 1 :
0) : ((((u_long)((((((((((0x3)) >> 8)))) - 1) & ((
((((0x3)) >> 8))))) ^ ((((((0x3)) >> 8)))))) >>
(1)) != 0) ? 1 : 0))) : ((((u_long)((((((((0x3)))) - 1) &
((((0x3))))) ^ ((((0x3)))))) >> (4)) != 0) ? 4 + ((((u_long
)(((((((((0x3))) >> 4)) - 1) & (((((0x3))) >>
4))) ^ (((((0x3))) >> 4)))) >> (2)) != 0) ? 2 + (
(((u_long)((((((((((0x3))) >> 4) >> 2)) - 1) &
((((((0x3))) >> 4) >> 2))) ^ ((((((0x3))) >>
4) >> 2)))) >> (1)) != 0) ? 1 : 0) : ((((u_long)
((((((((((0x3))) >> 4))) - 1) & ((((((0x3))) >>
4)))) ^ ((((((0x3))) >> 4))))) >> (1)) != 0) ? 1
: 0)) : ((((u_long)(((((((((0x3))))) - 1) & (((((0x3))))
)) ^ (((((0x3))))))) >> (2)) != 0) ? 2 + ((((u_long)(((
(((((((0x3)))) >> 2)) - 1) & ((((((0x3)))) >>
2))) ^ ((((((0x3)))) >> 2)))) >> (1)) != 0) ? 1 :
0) : ((((u_long)((((((((((0x3)))))) - 1) & ((((((0x3))))
))) ^ ((((((0x3)))))))) >> (1)) != 0) ? 1 : 0))))))
:
768 *locale = RTW_LOCALE_JAPAN;
769 break;
770 case RTW8180_CONFIG0_GL_EUROPE((2) << ((((u_long)((((((0x3)) - 1) & ((0x3))) ^ ((
0x3)))) >> (16)) != 0) ? 16 + ((((u_long)(((((((0x3) >>
16)) - 1) & (((0x3) >> 16))) ^ (((0x3) >> 16
)))) >> (8)) != 0) ? 8 + ((((u_long)((((((((0x3) >>
16) >> 8)) - 1) & ((((0x3) >> 16) >> 8
))) ^ ((((0x3) >> 16) >> 8)))) >> (4)) != 0
) ? 4 + ((((u_long)(((((((((0x3) >> 16) >> 8) >>
4)) - 1) & (((((0x3) >> 16) >> 8) >> 4
))) ^ (((((0x3) >> 16) >> 8) >> 4)))) >>
(2)) != 0) ? 2 + ((((u_long)((((((((((0x3) >> 16) >>
8) >> 4) >> 2)) - 1) & ((((((0x3) >> 16
) >> 8) >> 4) >> 2))) ^ ((((((0x3) >>
16) >> 8) >> 4) >> 2)))) >> (1)) != 0
) ? 1 : 0) : ((((u_long)((((((((((0x3) >> 16) >> 8
) >> 4))) - 1) & ((((((0x3) >> 16) >> 8
) >> 4)))) ^ ((((((0x3) >> 16) >> 8) >>
4))))) >> (1)) != 0) ? 1 : 0)) : ((((u_long)(((((((((0x3
) >> 16) >> 8))) - 1) & (((((0x3) >> 16
) >> 8)))) ^ (((((0x3) >> 16) >> 8))))) >>
(2)) != 0) ? 2 + ((((u_long)((((((((((0x3) >> 16) >>
8)) >> 2)) - 1) & ((((((0x3) >> 16) >>
8)) >> 2))) ^ ((((((0x3) >> 16) >> 8)) >>
2)))) >> (1)) != 0) ? 1 : 0) : ((((u_long)((((((((((0x3
) >> 16) >> 8)))) - 1) & ((((((0x3) >> 16
) >> 8))))) ^ ((((((0x3) >> 16) >> 8)))))) >>
(1)) != 0) ? 1 : 0))) : ((((u_long)((((((((0x3) >> 16)
)) - 1) & ((((0x3) >> 16)))) ^ ((((0x3) >> 16
))))) >> (4)) != 0) ? 4 + ((((u_long)(((((((((0x3) >>
16)) >> 4)) - 1) & (((((0x3) >> 16)) >>
4))) ^ (((((0x3) >> 16)) >> 4)))) >> (2)) !=
0) ? 2 + ((((u_long)((((((((((0x3) >> 16)) >> 4)
>> 2)) - 1) & ((((((0x3) >> 16)) >> 4)
>> 2))) ^ ((((((0x3) >> 16)) >> 4) >>
2)))) >> (1)) != 0) ? 1 : 0) : ((((u_long)((((((((((0x3
) >> 16)) >> 4))) - 1) & ((((((0x3) >> 16
)) >> 4)))) ^ ((((((0x3) >> 16)) >> 4))))) >>
(1)) != 0) ? 1 : 0)) : ((((u_long)(((((((((0x3) >> 16)
))) - 1) & (((((0x3) >> 16))))) ^ (((((0x3) >>
16)))))) >> (2)) != 0) ? 2 + ((((u_long)((((((((((0x3)
>> 16))) >> 2)) - 1) & ((((((0x3) >> 16
))) >> 2))) ^ ((((((0x3) >> 16))) >> 2)))) >>
(1)) != 0) ? 1 : 0) : ((((u_long)((((((((((0x3) >> 16)
)))) - 1) & ((((((0x3) >> 16)))))) ^ ((((((0x3) >>
16))))))) >> (1)) != 0) ? 1 : 0)))) : ((((u_long)(((((
((0x3))) - 1) & (((0x3)))) ^ (((0x3))))) >> (8)) !=
0) ? 8 + ((((u_long)((((((((0x3)) >> 8)) - 1) & ((
((0x3)) >> 8))) ^ ((((0x3)) >> 8)))) >> (4)
) != 0) ? 4 + ((((u_long)(((((((((0x3)) >> 8) >> 4
)) - 1) & (((((0x3)) >> 8) >> 4))) ^ (((((0x3
)) >> 8) >> 4)))) >> (2)) != 0) ? 2 + ((((u_long
)((((((((((0x3)) >> 8) >> 4) >> 2)) - 1) &
((((((0x3)) >> 8) >> 4) >> 2))) ^ ((((((0x3
)) >> 8) >> 4) >> 2)))) >> (1)) != 0)
? 1 : 0) : ((((u_long)((((((((((0x3)) >> 8) >> 4
))) - 1) & ((((((0x3)) >> 8) >> 4)))) ^ (((((
(0x3)) >> 8) >> 4))))) >> (1)) != 0) ? 1 : 0
)) : ((((u_long)(((((((((0x3)) >> 8))) - 1) & (((((
0x3)) >> 8)))) ^ (((((0x3)) >> 8))))) >> (2
)) != 0) ? 2 + ((((u_long)((((((((((0x3)) >> 8)) >>
2)) - 1) & ((((((0x3)) >> 8)) >> 2))) ^ ((((
((0x3)) >> 8)) >> 2)))) >> (1)) != 0) ? 1 :
0) : ((((u_long)((((((((((0x3)) >> 8)))) - 1) & ((
((((0x3)) >> 8))))) ^ ((((((0x3)) >> 8)))))) >>
(1)) != 0) ? 1 : 0))) : ((((u_long)((((((((0x3)))) - 1) &
((((0x3))))) ^ ((((0x3)))))) >> (4)) != 0) ? 4 + ((((u_long
)(((((((((0x3))) >> 4)) - 1) & (((((0x3))) >>
4))) ^ (((((0x3))) >> 4)))) >> (2)) != 0) ? 2 + (
(((u_long)((((((((((0x3))) >> 4) >> 2)) - 1) &
((((((0x3))) >> 4) >> 2))) ^ ((((((0x3))) >>
4) >> 2)))) >> (1)) != 0) ? 1 : 0) : ((((u_long)
((((((((((0x3))) >> 4))) - 1) & ((((((0x3))) >>
4)))) ^ ((((((0x3))) >> 4))))) >> (1)) != 0) ? 1
: 0)) : ((((u_long)(((((((((0x3))))) - 1) & (((((0x3))))
)) ^ (((((0x3))))))) >> (2)) != 0) ? 2 + ((((u_long)(((
(((((((0x3)))) >> 2)) - 1) & ((((((0x3)))) >>
2))) ^ ((((((0x3)))) >> 2)))) >> (1)) != 0) ? 1 :
0) : ((((u_long)((((((((((0x3)))))) - 1) & ((((((0x3))))
))) ^ ((((((0x3)))))))) >> (1)) != 0) ? 1 : 0))))))
:
771 *locale = RTW_LOCALE_EUROPE;
772 break;
773 default:
774 *locale = RTW_LOCALE_UNKNOWN;
775 break;
776 }
777}
778
779int
780rtw_identify_sta(struct rtw_regs *regs, u_int8_t (*addr)[IEEE80211_ADDR_LEN6],
781 const char *dvname)
782{
783 static const u_int8_t empty_macaddr[IEEE80211_ADDR_LEN6] = {
784 0x00, 0x00, 0x00, 0x00, 0x00, 0x00
785 };
786 u_int32_t idr0 = RTW_READ(regs, RTW_IDR0)((*(regs)->r_read32)(regs, 0x00)),
787 idr1 = RTW_READ(regs, RTW_IDR1)((*(regs)->r_read32)(regs, 0x04));
788
789 (*addr)[0] = MASK_AND_RSHIFT(idr0, 0xff)(((idr0) & (0xff)) >> ((((u_long)((((((0xff)) - 1) &
((0xff))) ^ ((0xff)))) >> (16)) != 0) ? 16 + ((((u_long
)(((((((0xff) >> 16)) - 1) & (((0xff) >> 16))
) ^ (((0xff) >> 16)))) >> (8)) != 0) ? 8 + ((((u_long
)((((((((0xff) >> 16) >> 8)) - 1) & ((((0xff)
>> 16) >> 8))) ^ ((((0xff) >> 16) >>
8)))) >> (4)) != 0) ? 4 + ((((u_long)(((((((((0xff) >>
16) >> 8) >> 4)) - 1) & (((((0xff) >> 16
) >> 8) >> 4))) ^ (((((0xff) >> 16) >>
8) >> 4)))) >> (2)) != 0) ? 2 + ((((u_long)(((((
(((((0xff) >> 16) >> 8) >> 4) >> 2)) -
1) & ((((((0xff) >> 16) >> 8) >> 4) >>
2))) ^ ((((((0xff) >> 16) >> 8) >> 4) >>
2)))) >> (1)) != 0) ? 1 : 0) : ((((u_long)((((((((((0xff
) >> 16) >> 8) >> 4))) - 1) & ((((((0xff
) >> 16) >> 8) >> 4)))) ^ ((((((0xff) >>
16) >> 8) >> 4))))) >> (1)) != 0) ? 1 : 0)
) : ((((u_long)(((((((((0xff) >> 16) >> 8))) - 1)
& (((((0xff) >> 16) >> 8)))) ^ (((((0xff) >>
16) >> 8))))) >> (2)) != 0) ? 2 + ((((u_long)(((
(((((((0xff) >> 16) >> 8)) >> 2)) - 1) &
((((((0xff) >> 16) >> 8)) >> 2))) ^ ((((((
0xff) >> 16) >> 8)) >> 2)))) >> (1)) !=
0) ? 1 : 0) : ((((u_long)((((((((((0xff) >> 16) >>
8)))) - 1) & ((((((0xff) >> 16) >> 8))))) ^ (
(((((0xff) >> 16) >> 8)))))) >> (1)) != 0) ?
1 : 0))) : ((((u_long)((((((((0xff) >> 16))) - 1) &
((((0xff) >> 16)))) ^ ((((0xff) >> 16))))) >>
(4)) != 0) ? 4 + ((((u_long)(((((((((0xff) >> 16)) >>
4)) - 1) & (((((0xff) >> 16)) >> 4))) ^ ((((
(0xff) >> 16)) >> 4)))) >> (2)) != 0) ? 2 +
((((u_long)((((((((((0xff) >> 16)) >> 4) >>
2)) - 1) & ((((((0xff) >> 16)) >> 4) >>
2))) ^ ((((((0xff) >> 16)) >> 4) >> 2)))) >>
(1)) != 0) ? 1 : 0) : ((((u_long)((((((((((0xff) >> 16
)) >> 4))) - 1) & ((((((0xff) >> 16)) >>
4)))) ^ ((((((0xff) >> 16)) >> 4))))) >> (
1)) != 0) ? 1 : 0)) : ((((u_long)(((((((((0xff) >> 16))
)) - 1) & (((((0xff) >> 16))))) ^ (((((0xff) >>
16)))))) >> (2)) != 0) ? 2 + ((((u_long)((((((((((0xff
) >> 16))) >> 2)) - 1) & ((((((0xff) >>
16))) >> 2))) ^ ((((((0xff) >> 16))) >> 2)
))) >> (1)) != 0) ? 1 : 0) : ((((u_long)((((((((((0xff)
>> 16))))) - 1) & ((((((0xff) >> 16)))))) ^ (
(((((0xff) >> 16))))))) >> (1)) != 0) ? 1 : 0))))
: ((((u_long)(((((((0xff))) - 1) & (((0xff)))) ^ (((0xff
))))) >> (8)) != 0) ? 8 + ((((u_long)((((((((0xff)) >>
8)) - 1) & ((((0xff)) >> 8))) ^ ((((0xff)) >>
8)))) >> (4)) != 0) ? 4 + ((((u_long)(((((((((0xff)) >>
8) >> 4)) - 1) & (((((0xff)) >> 8) >> 4
))) ^ (((((0xff)) >> 8) >> 4)))) >> (2)) !=
0) ? 2 + ((((u_long)((((((((((0xff)) >> 8) >> 4)
>> 2)) - 1) & ((((((0xff)) >> 8) >> 4)
>> 2))) ^ ((((((0xff)) >> 8) >> 4) >>
2)))) >> (1)) != 0) ? 1 : 0) : ((((u_long)((((((((((0xff
)) >> 8) >> 4))) - 1) & ((((((0xff)) >>
8) >> 4)))) ^ ((((((0xff)) >> 8) >> 4)))))
>> (1)) != 0) ? 1 : 0)) : ((((u_long)(((((((((0xff)) >>
8))) - 1) & (((((0xff)) >> 8)))) ^ (((((0xff)) >>
8))))) >> (2)) != 0) ? 2 + ((((u_long)((((((((((0xff))
>> 8)) >> 2)) - 1) & ((((((0xff)) >> 8
)) >> 2))) ^ ((((((0xff)) >> 8)) >> 2)))) >>
(1)) != 0) ? 1 : 0) : ((((u_long)((((((((((0xff)) >> 8
)))) - 1) & ((((((0xff)) >> 8))))) ^ ((((((0xff)) >>
8)))))) >> (1)) != 0) ? 1 : 0))) : ((((u_long)((((((((
0xff)))) - 1) & ((((0xff))))) ^ ((((0xff)))))) >> (
4)) != 0) ? 4 + ((((u_long)(((((((((0xff))) >> 4)) - 1)
& (((((0xff))) >> 4))) ^ (((((0xff))) >> 4))
)) >> (2)) != 0) ? 2 + ((((u_long)((((((((((0xff))) >>
4) >> 2)) - 1) & ((((((0xff))) >> 4) >>
2))) ^ ((((((0xff))) >> 4) >> 2)))) >> (1)
) != 0) ? 1 : 0) : ((((u_long)((((((((((0xff))) >> 4)))
- 1) & ((((((0xff))) >> 4)))) ^ ((((((0xff))) >>
4))))) >> (1)) != 0) ? 1 : 0)) : ((((u_long)(((((((((0xff
))))) - 1) & (((((0xff)))))) ^ (((((0xff))))))) >> (
2)) != 0) ? 2 + ((((u_long)((((((((((0xff)))) >> 2)) - 1
) & ((((((0xff)))) >> 2))) ^ ((((((0xff)))) >>
2)))) >> (1)) != 0) ? 1 : 0) : ((((u_long)((((((((((0xff
)))))) - 1) & ((((((0xff))))))) ^ ((((((0xff)))))))) >>
(1)) != 0) ? 1 : 0))))))
;
790 (*addr)[1] = MASK_AND_RSHIFT(idr0, 0xff00)(((idr0) & (0xff00)) >> ((((u_long)((((((0xff00)) -
1) & ((0xff00))) ^ ((0xff00)))) >> (16)) != 0) ? 16
+ ((((u_long)(((((((0xff00) >> 16)) - 1) & (((0xff00
) >> 16))) ^ (((0xff00) >> 16)))) >> (8)) !=
0) ? 8 + ((((u_long)((((((((0xff00) >> 16) >> 8)
) - 1) & ((((0xff00) >> 16) >> 8))) ^ ((((0xff00
) >> 16) >> 8)))) >> (4)) != 0) ? 4 + ((((u_long
)(((((((((0xff00) >> 16) >> 8) >> 4)) - 1) &
(((((0xff00) >> 16) >> 8) >> 4))) ^ (((((0xff00
) >> 16) >> 8) >> 4)))) >> (2)) != 0)
? 2 + ((((u_long)((((((((((0xff00) >> 16) >> 8) >>
4) >> 2)) - 1) & ((((((0xff00) >> 16) >>
8) >> 4) >> 2))) ^ ((((((0xff00) >> 16) >>
8) >> 4) >> 2)))) >> (1)) != 0) ? 1 : 0) :
((((u_long)((((((((((0xff00) >> 16) >> 8) >>
4))) - 1) & ((((((0xff00) >> 16) >> 8) >>
4)))) ^ ((((((0xff00) >> 16) >> 8) >> 4)))
)) >> (1)) != 0) ? 1 : 0)) : ((((u_long)(((((((((0xff00
) >> 16) >> 8))) - 1) & (((((0xff00) >>
16) >> 8)))) ^ (((((0xff00) >> 16) >> 8)))
)) >> (2)) != 0) ? 2 + ((((u_long)((((((((((0xff00) >>
16) >> 8)) >> 2)) - 1) & ((((((0xff00) >>
16) >> 8)) >> 2))) ^ ((((((0xff00) >> 16) >>
8)) >> 2)))) >> (1)) != 0) ? 1 : 0) : ((((u_long
)((((((((((0xff00) >> 16) >> 8)))) - 1) & (((
(((0xff00) >> 16) >> 8))))) ^ ((((((0xff00) >>
16) >> 8)))))) >> (1)) != 0) ? 1 : 0))) : ((((u_long
)((((((((0xff00) >> 16))) - 1) & ((((0xff00) >>
16)))) ^ ((((0xff00) >> 16))))) >> (4)) != 0) ? 4
+ ((((u_long)(((((((((0xff00) >> 16)) >> 4)) - 1
) & (((((0xff00) >> 16)) >> 4))) ^ (((((0xff00
) >> 16)) >> 4)))) >> (2)) != 0) ? 2 + ((((
u_long)((((((((((0xff00) >> 16)) >> 4) >> 2
)) - 1) & ((((((0xff00) >> 16)) >> 4) >>
2))) ^ ((((((0xff00) >> 16)) >> 4) >> 2)))
) >> (1)) != 0) ? 1 : 0) : ((((u_long)((((((((((0xff00)
>> 16)) >> 4))) - 1) & ((((((0xff00) >>
16)) >> 4)))) ^ ((((((0xff00) >> 16)) >> 4
))))) >> (1)) != 0) ? 1 : 0)) : ((((u_long)(((((((((0xff00
) >> 16)))) - 1) & (((((0xff00) >> 16))))) ^ (
((((0xff00) >> 16)))))) >> (2)) != 0) ? 2 + ((((u_long
)((((((((((0xff00) >> 16))) >> 2)) - 1) & (((
(((0xff00) >> 16))) >> 2))) ^ ((((((0xff00) >>
16))) >> 2)))) >> (1)) != 0) ? 1 : 0) : ((((u_long
)((((((((((0xff00) >> 16))))) - 1) & ((((((0xff00) >>
16)))))) ^ ((((((0xff00) >> 16))))))) >> (1)) !=
0) ? 1 : 0)))) : ((((u_long)(((((((0xff00))) - 1) & (((0xff00
)))) ^ (((0xff00))))) >> (8)) != 0) ? 8 + ((((u_long)((
((((((0xff00)) >> 8)) - 1) & ((((0xff00)) >> 8
))) ^ ((((0xff00)) >> 8)))) >> (4)) != 0) ? 4 + (
(((u_long)(((((((((0xff00)) >> 8) >> 4)) - 1) &
(((((0xff00)) >> 8) >> 4))) ^ (((((0xff00)) >>
8) >> 4)))) >> (2)) != 0) ? 2 + ((((u_long)(((((
(((((0xff00)) >> 8) >> 4) >> 2)) - 1) &
((((((0xff00)) >> 8) >> 4) >> 2))) ^ (((((
(0xff00)) >> 8) >> 4) >> 2)))) >> (1)
) != 0) ? 1 : 0) : ((((u_long)((((((((((0xff00)) >> 8) >>
4))) - 1) & ((((((0xff00)) >> 8) >> 4)))) ^ (
(((((0xff00)) >> 8) >> 4))))) >> (1)) != 0)
? 1 : 0)) : ((((u_long)(((((((((0xff00)) >> 8))) - 1) &
(((((0xff00)) >> 8)))) ^ (((((0xff00)) >> 8)))))
>> (2)) != 0) ? 2 + ((((u_long)((((((((((0xff00)) >>
8)) >> 2)) - 1) & ((((((0xff00)) >> 8)) >>
2))) ^ ((((((0xff00)) >> 8)) >> 2)))) >> (
1)) != 0) ? 1 : 0) : ((((u_long)((((((((((0xff00)) >> 8
)))) - 1) & ((((((0xff00)) >> 8))))) ^ ((((((0xff00
)) >> 8)))))) >> (1)) != 0) ? 1 : 0))) : ((((u_long
)((((((((0xff00)))) - 1) & ((((0xff00))))) ^ ((((0xff00))
)))) >> (4)) != 0) ? 4 + ((((u_long)(((((((((0xff00))) >>
4)) - 1) & (((((0xff00))) >> 4))) ^ (((((0xff00)))
>> 4)))) >> (2)) != 0) ? 2 + ((((u_long)((((((((
((0xff00))) >> 4) >> 2)) - 1) & ((((((0xff00)
)) >> 4) >> 2))) ^ ((((((0xff00))) >> 4) >>
2)))) >> (1)) != 0) ? 1 : 0) : ((((u_long)((((((((((0xff00
))) >> 4))) - 1) & ((((((0xff00))) >> 4)))) ^
((((((0xff00))) >> 4))))) >> (1)) != 0) ? 1 : 0)
) : ((((u_long)(((((((((0xff00))))) - 1) & (((((0xff00)))
))) ^ (((((0xff00))))))) >> (2)) != 0) ? 2 + ((((u_long
)((((((((((0xff00)))) >> 2)) - 1) & ((((((0xff00)))
) >> 2))) ^ ((((((0xff00)))) >> 2)))) >> (1
)) != 0) ? 1 : 0) : ((((u_long)((((((((((0xff00)))))) - 1) &
((((((0xff00))))))) ^ ((((((0xff00)))))))) >> (1)) != 0
) ? 1 : 0))))))
;
791 (*addr)[2] = MASK_AND_RSHIFT(idr0, 0xff0000)(((idr0) & (0xff0000)) >> ((((u_long)((((((0xff0000
)) - 1) & ((0xff0000))) ^ ((0xff0000)))) >> (16)) !=
0) ? 16 + ((((u_long)(((((((0xff0000) >> 16)) - 1) &
(((0xff0000) >> 16))) ^ (((0xff0000) >> 16)))) >>
(8)) != 0) ? 8 + ((((u_long)((((((((0xff0000) >> 16) >>
8)) - 1) & ((((0xff0000) >> 16) >> 8))) ^ ((
((0xff0000) >> 16) >> 8)))) >> (4)) != 0) ?
4 + ((((u_long)(((((((((0xff0000) >> 16) >> 8) >>
4)) - 1) & (((((0xff0000) >> 16) >> 8) >>
4))) ^ (((((0xff0000) >> 16) >> 8) >> 4)))
) >> (2)) != 0) ? 2 + ((((u_long)((((((((((0xff0000) >>
16) >> 8) >> 4) >> 2)) - 1) & ((((((0xff0000
) >> 16) >> 8) >> 4) >> 2))) ^ ((((((
0xff0000) >> 16) >> 8) >> 4) >> 2))))
>> (1)) != 0) ? 1 : 0) : ((((u_long)((((((((((0xff0000
) >> 16) >> 8) >> 4))) - 1) & ((((((0xff0000
) >> 16) >> 8) >> 4)))) ^ ((((((0xff0000) >>
16) >> 8) >> 4))))) >> (1)) != 0) ? 1 : 0)
) : ((((u_long)(((((((((0xff0000) >> 16) >> 8))) -
1) & (((((0xff0000) >> 16) >> 8)))) ^ (((((0xff0000
) >> 16) >> 8))))) >> (2)) != 0) ? 2 + ((((
u_long)((((((((((0xff0000) >> 16) >> 8)) >>
2)) - 1) & ((((((0xff0000) >> 16) >> 8)) >>
2))) ^ ((((((0xff0000) >> 16) >> 8)) >> 2)
))) >> (1)) != 0) ? 1 : 0) : ((((u_long)((((((((((0xff0000
) >> 16) >> 8)))) - 1) & ((((((0xff0000) >>
16) >> 8))))) ^ ((((((0xff0000) >> 16) >> 8
)))))) >> (1)) != 0) ? 1 : 0))) : ((((u_long)((((((((0xff0000
) >> 16))) - 1) & ((((0xff0000) >> 16)))) ^ (
(((0xff0000) >> 16))))) >> (4)) != 0) ? 4 + ((((u_long
)(((((((((0xff0000) >> 16)) >> 4)) - 1) & (((
((0xff0000) >> 16)) >> 4))) ^ (((((0xff0000) >>
16)) >> 4)))) >> (2)) != 0) ? 2 + ((((u_long)(((
(((((((0xff0000) >> 16)) >> 4) >> 2)) - 1) &
((((((0xff0000) >> 16)) >> 4) >> 2))) ^ ((
((((0xff0000) >> 16)) >> 4) >> 2)))) >>
(1)) != 0) ? 1 : 0) : ((((u_long)((((((((((0xff0000) >>
16)) >> 4))) - 1) & ((((((0xff0000) >> 16)) >>
4)))) ^ ((((((0xff0000) >> 16)) >> 4))))) >>
(1)) != 0) ? 1 : 0)) : ((((u_long)(((((((((0xff0000) >>
16)))) - 1) & (((((0xff0000) >> 16))))) ^ (((((0xff0000
) >> 16)))))) >> (2)) != 0) ? 2 + ((((u_long)((((
((((((0xff0000) >> 16))) >> 2)) - 1) & ((((((
0xff0000) >> 16))) >> 2))) ^ ((((((0xff0000) >>
16))) >> 2)))) >> (1)) != 0) ? 1 : 0) : ((((u_long
)((((((((((0xff0000) >> 16))))) - 1) & ((((((0xff0000
) >> 16)))))) ^ ((((((0xff0000) >> 16))))))) >>
(1)) != 0) ? 1 : 0)))) : ((((u_long)(((((((0xff0000))) - 1) &
(((0xff0000)))) ^ (((0xff0000))))) >> (8)) != 0) ? 8 +
((((u_long)((((((((0xff0000)) >> 8)) - 1) & ((((0xff0000
)) >> 8))) ^ ((((0xff0000)) >> 8)))) >> (4)
) != 0) ? 4 + ((((u_long)(((((((((0xff0000)) >> 8) >>
4)) - 1) & (((((0xff0000)) >> 8) >> 4))) ^ (
((((0xff0000)) >> 8) >> 4)))) >> (2)) != 0)
? 2 + ((((u_long)((((((((((0xff0000)) >> 8) >> 4
) >> 2)) - 1) & ((((((0xff0000)) >> 8) >>
4) >> 2))) ^ ((((((0xff0000)) >> 8) >> 4) >>
2)))) >> (1)) != 0) ? 1 : 0) : ((((u_long)((((((((((0xff0000
)) >> 8) >> 4))) - 1) & ((((((0xff0000)) >>
8) >> 4)))) ^ ((((((0xff0000)) >> 8) >> 4)
)))) >> (1)) != 0) ? 1 : 0)) : ((((u_long)(((((((((0xff0000
)) >> 8))) - 1) & (((((0xff0000)) >> 8)))) ^ (
((((0xff0000)) >> 8))))) >> (2)) != 0) ? 2 + ((((
u_long)((((((((((0xff0000)) >> 8)) >> 2)) - 1) &
((((((0xff0000)) >> 8)) >> 2))) ^ ((((((0xff0000
)) >> 8)) >> 2)))) >> (1)) != 0) ? 1 : 0) :
((((u_long)((((((((((0xff0000)) >> 8)))) - 1) & ((
((((0xff0000)) >> 8))))) ^ ((((((0xff0000)) >> 8)
))))) >> (1)) != 0) ? 1 : 0))) : ((((u_long)((((((((0xff0000
)))) - 1) & ((((0xff0000))))) ^ ((((0xff0000)))))) >>
(4)) != 0) ? 4 + ((((u_long)(((((((((0xff0000))) >> 4)
) - 1) & (((((0xff0000))) >> 4))) ^ (((((0xff0000))
) >> 4)))) >> (2)) != 0) ? 2 + ((((u_long)(((((((
(((0xff0000))) >> 4) >> 2)) - 1) & ((((((0xff0000
))) >> 4) >> 2))) ^ ((((((0xff0000))) >> 4)
>> 2)))) >> (1)) != 0) ? 1 : 0) : ((((u_long)(((
(((((((0xff0000))) >> 4))) - 1) & ((((((0xff0000)))
>> 4)))) ^ ((((((0xff0000))) >> 4))))) >> (
1)) != 0) ? 1 : 0)) : ((((u_long)(((((((((0xff0000))))) - 1) &
(((((0xff0000)))))) ^ (((((0xff0000))))))) >> (2)) != 0
) ? 2 + ((((u_long)((((((((((0xff0000)))) >> 2)) - 1) &
((((((0xff0000)))) >> 2))) ^ ((((((0xff0000)))) >>
2)))) >> (1)) != 0) ? 1 : 0) : ((((u_long)((((((((((0xff0000
)))))) - 1) & ((((((0xff0000))))))) ^ ((((((0xff0000)))))
))) >> (1)) != 0) ? 1 : 0))))))
;
792 (*addr)[3] = MASK_AND_RSHIFT(idr0, 0xff000000)(((idr0) & (0xff000000)) >> ((((u_long)((((((0xff000000
)) - 1) & ((0xff000000))) ^ ((0xff000000)))) >> (16
)) != 0) ? 16 + ((((u_long)(((((((0xff000000) >> 16)) -
1) & (((0xff000000) >> 16))) ^ (((0xff000000) >>
16)))) >> (8)) != 0) ? 8 + ((((u_long)((((((((0xff000000
) >> 16) >> 8)) - 1) & ((((0xff000000) >>
16) >> 8))) ^ ((((0xff000000) >> 16) >> 8)
))) >> (4)) != 0) ? 4 + ((((u_long)(((((((((0xff000000)
>> 16) >> 8) >> 4)) - 1) & (((((0xff000000
) >> 16) >> 8) >> 4))) ^ (((((0xff000000) >>
16) >> 8) >> 4)))) >> (2)) != 0) ? 2 + (((
(u_long)((((((((((0xff000000) >> 16) >> 8) >>
4) >> 2)) - 1) & ((((((0xff000000) >> 16) >>
8) >> 4) >> 2))) ^ ((((((0xff000000) >> 16
) >> 8) >> 4) >> 2)))) >> (1)) != 0) ?
1 : 0) : ((((u_long)((((((((((0xff000000) >> 16) >>
8) >> 4))) - 1) & ((((((0xff000000) >> 16) >>
8) >> 4)))) ^ ((((((0xff000000) >> 16) >> 8
) >> 4))))) >> (1)) != 0) ? 1 : 0)) : ((((u_long)
(((((((((0xff000000) >> 16) >> 8))) - 1) & ((
(((0xff000000) >> 16) >> 8)))) ^ (((((0xff000000)
>> 16) >> 8))))) >> (2)) != 0) ? 2 + ((((u_long
)((((((((((0xff000000) >> 16) >> 8)) >> 2))
- 1) & ((((((0xff000000) >> 16) >> 8)) >>
2))) ^ ((((((0xff000000) >> 16) >> 8)) >> 2
)))) >> (1)) != 0) ? 1 : 0) : ((((u_long)((((((((((0xff000000
) >> 16) >> 8)))) - 1) & ((((((0xff000000) >>
16) >> 8))))) ^ ((((((0xff000000) >> 16) >>
8)))))) >> (1)) != 0) ? 1 : 0))) : ((((u_long)((((((((
0xff000000) >> 16))) - 1) & ((((0xff000000) >>
16)))) ^ ((((0xff000000) >> 16))))) >> (4)) != 0
) ? 4 + ((((u_long)(((((((((0xff000000) >> 16)) >>
4)) - 1) & (((((0xff000000) >> 16)) >> 4))) ^
(((((0xff000000) >> 16)) >> 4)))) >> (2)) !=
0) ? 2 + ((((u_long)((((((((((0xff000000) >> 16)) >>
4) >> 2)) - 1) & ((((((0xff000000) >> 16)) >>
4) >> 2))) ^ ((((((0xff000000) >> 16)) >> 4
) >> 2)))) >> (1)) != 0) ? 1 : 0) : ((((u_long)((
((((((((0xff000000) >> 16)) >> 4))) - 1) & ((
((((0xff000000) >> 16)) >> 4)))) ^ ((((((0xff000000
) >> 16)) >> 4))))) >> (1)) != 0) ? 1 : 0))
: ((((u_long)(((((((((0xff000000) >> 16)))) - 1) &
(((((0xff000000) >> 16))))) ^ (((((0xff000000) >>
16)))))) >> (2)) != 0) ? 2 + ((((u_long)((((((((((0xff000000
) >> 16))) >> 2)) - 1) & ((((((0xff000000) >>
16))) >> 2))) ^ ((((((0xff000000) >> 16))) >>
2)))) >> (1)) != 0) ? 1 : 0) : ((((u_long)((((((((((0xff000000
) >> 16))))) - 1) & ((((((0xff000000) >> 16))
)))) ^ ((((((0xff000000) >> 16))))))) >> (1)) != 0
) ? 1 : 0)))) : ((((u_long)(((((((0xff000000))) - 1) & ((
(0xff000000)))) ^ (((0xff000000))))) >> (8)) != 0) ? 8 +
((((u_long)((((((((0xff000000)) >> 8)) - 1) & ((((
0xff000000)) >> 8))) ^ ((((0xff000000)) >> 8)))) >>
(4)) != 0) ? 4 + ((((u_long)(((((((((0xff000000)) >> 8
) >> 4)) - 1) & (((((0xff000000)) >> 8) >>
4))) ^ (((((0xff000000)) >> 8) >> 4)))) >>
(2)) != 0) ? 2 + ((((u_long)((((((((((0xff000000)) >> 8
) >> 4) >> 2)) - 1) & ((((((0xff000000)) >>
8) >> 4) >> 2))) ^ ((((((0xff000000)) >> 8
) >> 4) >> 2)))) >> (1)) != 0) ? 1 : 0) : (
(((u_long)((((((((((0xff000000)) >> 8) >> 4))) - 1
) & ((((((0xff000000)) >> 8) >> 4)))) ^ (((((
(0xff000000)) >> 8) >> 4))))) >> (1)) != 0)
? 1 : 0)) : ((((u_long)(((((((((0xff000000)) >> 8))) -
1) & (((((0xff000000)) >> 8)))) ^ (((((0xff000000)
) >> 8))))) >> (2)) != 0) ? 2 + ((((u_long)((((((
((((0xff000000)) >> 8)) >> 2)) - 1) & ((((((0xff000000
)) >> 8)) >> 2))) ^ ((((((0xff000000)) >> 8
)) >> 2)))) >> (1)) != 0) ? 1 : 0) : ((((u_long)(
(((((((((0xff000000)) >> 8)))) - 1) & ((((((0xff000000
)) >> 8))))) ^ ((((((0xff000000)) >> 8)))))) >>
(1)) != 0) ? 1 : 0))) : ((((u_long)((((((((0xff000000)))) - 1
) & ((((0xff000000))))) ^ ((((0xff000000)))))) >> (
4)) != 0) ? 4 + ((((u_long)(((((((((0xff000000))) >> 4)
) - 1) & (((((0xff000000))) >> 4))) ^ (((((0xff000000
))) >> 4)))) >> (2)) != 0) ? 2 + ((((u_long)(((((
(((((0xff000000))) >> 4) >> 2)) - 1) & ((((((
0xff000000))) >> 4) >> 2))) ^ ((((((0xff000000)))
>> 4) >> 2)))) >> (1)) != 0) ? 1 : 0) : ((
((u_long)((((((((((0xff000000))) >> 4))) - 1) & (((
(((0xff000000))) >> 4)))) ^ ((((((0xff000000))) >>
4))))) >> (1)) != 0) ? 1 : 0)) : ((((u_long)(((((((((0xff000000
))))) - 1) & (((((0xff000000)))))) ^ (((((0xff000000)))))
)) >> (2)) != 0) ? 2 + ((((u_long)((((((((((0xff000000)
))) >> 2)) - 1) & ((((((0xff000000)))) >> 2))
) ^ ((((((0xff000000)))) >> 2)))) >> (1)) != 0) ?
1 : 0) : ((((u_long)((((((((((0xff000000)))))) - 1) & ((
((((0xff000000))))))) ^ ((((((0xff000000)))))))) >> (1)
) != 0) ? 1 : 0))))))
;
793
794 (*addr)[4] = MASK_AND_RSHIFT(idr1, 0xff)(((idr1) & (0xff)) >> ((((u_long)((((((0xff)) - 1) &
((0xff))) ^ ((0xff)))) >> (16)) != 0) ? 16 + ((((u_long
)(((((((0xff) >> 16)) - 1) & (((0xff) >> 16))
) ^ (((0xff) >> 16)))) >> (8)) != 0) ? 8 + ((((u_long
)((((((((0xff) >> 16) >> 8)) - 1) & ((((0xff)
>> 16) >> 8))) ^ ((((0xff) >> 16) >>
8)))) >> (4)) != 0) ? 4 + ((((u_long)(((((((((0xff) >>
16) >> 8) >> 4)) - 1) & (((((0xff) >> 16
) >> 8) >> 4))) ^ (((((0xff) >> 16) >>
8) >> 4)))) >> (2)) != 0) ? 2 + ((((u_long)(((((
(((((0xff) >> 16) >> 8) >> 4) >> 2)) -
1) & ((((((0xff) >> 16) >> 8) >> 4) >>
2))) ^ ((((((0xff) >> 16) >> 8) >> 4) >>
2)))) >> (1)) != 0) ? 1 : 0) : ((((u_long)((((((((((0xff
) >> 16) >> 8) >> 4))) - 1) & ((((((0xff
) >> 16) >> 8) >> 4)))) ^ ((((((0xff) >>
16) >> 8) >> 4))))) >> (1)) != 0) ? 1 : 0)
) : ((((u_long)(((((((((0xff) >> 16) >> 8))) - 1)
& (((((0xff) >> 16) >> 8)))) ^ (((((0xff) >>
16) >> 8))))) >> (2)) != 0) ? 2 + ((((u_long)(((
(((((((0xff) >> 16) >> 8)) >> 2)) - 1) &
((((((0xff) >> 16) >> 8)) >> 2))) ^ ((((((
0xff) >> 16) >> 8)) >> 2)))) >> (1)) !=
0) ? 1 : 0) : ((((u_long)((((((((((0xff) >> 16) >>
8)))) - 1) & ((((((0xff) >> 16) >> 8))))) ^ (
(((((0xff) >> 16) >> 8)))))) >> (1)) != 0) ?
1 : 0))) : ((((u_long)((((((((0xff) >> 16))) - 1) &
((((0xff) >> 16)))) ^ ((((0xff) >> 16))))) >>
(4)) != 0) ? 4 + ((((u_long)(((((((((0xff) >> 16)) >>
4)) - 1) & (((((0xff) >> 16)) >> 4))) ^ ((((
(0xff) >> 16)) >> 4)))) >> (2)) != 0) ? 2 +
((((u_long)((((((((((0xff) >> 16)) >> 4) >>
2)) - 1) & ((((((0xff) >> 16)) >> 4) >>
2))) ^ ((((((0xff) >> 16)) >> 4) >> 2)))) >>
(1)) != 0) ? 1 : 0) : ((((u_long)((((((((((0xff) >> 16
)) >> 4))) - 1) & ((((((0xff) >> 16)) >>
4)))) ^ ((((((0xff) >> 16)) >> 4))))) >> (
1)) != 0) ? 1 : 0)) : ((((u_long)(((((((((0xff) >> 16))
)) - 1) & (((((0xff) >> 16))))) ^ (((((0xff) >>
16)))))) >> (2)) != 0) ? 2 + ((((u_long)((((((((((0xff
) >> 16))) >> 2)) - 1) & ((((((0xff) >>
16))) >> 2))) ^ ((((((0xff) >> 16))) >> 2)
))) >> (1)) != 0) ? 1 : 0) : ((((u_long)((((((((((0xff)
>> 16))))) - 1) & ((((((0xff) >> 16)))))) ^ (
(((((0xff) >> 16))))))) >> (1)) != 0) ? 1 : 0))))
: ((((u_long)(((((((0xff))) - 1) & (((0xff)))) ^ (((0xff
))))) >> (8)) != 0) ? 8 + ((((u_long)((((((((0xff)) >>
8)) - 1) & ((((0xff)) >> 8))) ^ ((((0xff)) >>
8)))) >> (4)) != 0) ? 4 + ((((u_long)(((((((((0xff)) >>
8) >> 4)) - 1) & (((((0xff)) >> 8) >> 4
))) ^ (((((0xff)) >> 8) >> 4)))) >> (2)) !=
0) ? 2 + ((((u_long)((((((((((0xff)) >> 8) >> 4)
>> 2)) - 1) & ((((((0xff)) >> 8) >> 4)
>> 2))) ^ ((((((0xff)) >> 8) >> 4) >>
2)))) >> (1)) != 0) ? 1 : 0) : ((((u_long)((((((((((0xff
)) >> 8) >> 4))) - 1) & ((((((0xff)) >>
8) >> 4)))) ^ ((((((0xff)) >> 8) >> 4)))))
>> (1)) != 0) ? 1 : 0)) : ((((u_long)(((((((((0xff)) >>
8))) - 1) & (((((0xff)) >> 8)))) ^ (((((0xff)) >>
8))))) >> (2)) != 0) ? 2 + ((((u_long)((((((((((0xff))
>> 8)) >> 2)) - 1) & ((((((0xff)) >> 8
)) >> 2))) ^ ((((((0xff)) >> 8)) >> 2)))) >>
(1)) != 0) ? 1 : 0) : ((((u_long)((((((((((0xff)) >> 8
)))) - 1) & ((((((0xff)) >> 8))))) ^ ((((((0xff)) >>
8)))))) >> (1)) != 0) ? 1 : 0))) : ((((u_long)((((((((
0xff)))) - 1) & ((((0xff))))) ^ ((((0xff)))))) >> (
4)) != 0) ? 4 + ((((u_long)(((((((((0xff))) >> 4)) - 1)
& (((((0xff))) >> 4))) ^ (((((0xff))) >> 4))
)) >> (2)) != 0) ? 2 + ((((u_long)((((((((((0xff))) >>
4) >> 2)) - 1) & ((((((0xff))) >> 4) >>
2))) ^ ((((((0xff))) >> 4) >> 2)))) >> (1)
) != 0) ? 1 : 0) : ((((u_long)((((((((((0xff))) >> 4)))
- 1) & ((((((0xff))) >> 4)))) ^ ((((((0xff))) >>
4))))) >> (1)) != 0) ? 1 : 0)) : ((((u_long)(((((((((0xff
))))) - 1) & (((((0xff)))))) ^ (((((0xff))))))) >> (
2)) != 0) ? 2 + ((((u_long)((((((((((0xff)))) >> 2)) - 1
) & ((((((0xff)))) >> 2))) ^ ((((((0xff)))) >>
2)))) >> (1)) != 0) ? 1 : 0) : ((((u_long)((((((((((0xff
)))))) - 1) & ((((((0xff))))))) ^ ((((((0xff)))))))) >>
(1)) != 0) ? 1 : 0))))))
;
795 (*addr)[5] = MASK_AND_RSHIFT(idr1, 0xff00)(((idr1) & (0xff00)) >> ((((u_long)((((((0xff00)) -
1) & ((0xff00))) ^ ((0xff00)))) >> (16)) != 0) ? 16
+ ((((u_long)(((((((0xff00) >> 16)) - 1) & (((0xff00
) >> 16))) ^ (((0xff00) >> 16)))) >> (8)) !=
0) ? 8 + ((((u_long)((((((((0xff00) >> 16) >> 8)
) - 1) & ((((0xff00) >> 16) >> 8))) ^ ((((0xff00
) >> 16) >> 8)))) >> (4)) != 0) ? 4 + ((((u_long
)(((((((((0xff00) >> 16) >> 8) >> 4)) - 1) &
(((((0xff00) >> 16) >> 8) >> 4))) ^ (((((0xff00
) >> 16) >> 8) >> 4)))) >> (2)) != 0)
? 2 + ((((u_long)((((((((((0xff00) >> 16) >> 8) >>
4) >> 2)) - 1) & ((((((0xff00) >> 16) >>
8) >> 4) >> 2))) ^ ((((((0xff00) >> 16) >>
8) >> 4) >> 2)))) >> (1)) != 0) ? 1 : 0) :
((((u_long)((((((((((0xff00) >> 16) >> 8) >>
4))) - 1) & ((((((0xff00) >> 16) >> 8) >>
4)))) ^ ((((((0xff00) >> 16) >> 8) >> 4)))
)) >> (1)) != 0) ? 1 : 0)) : ((((u_long)(((((((((0xff00
) >> 16) >> 8))) - 1) & (((((0xff00) >>
16) >> 8)))) ^ (((((0xff00) >> 16) >> 8)))
)) >> (2)) != 0) ? 2 + ((((u_long)((((((((((0xff00) >>
16) >> 8)) >> 2)) - 1) & ((((((0xff00) >>
16) >> 8)) >> 2))) ^ ((((((0xff00) >> 16) >>
8)) >> 2)))) >> (1)) != 0) ? 1 : 0) : ((((u_long
)((((((((((0xff00) >> 16) >> 8)))) - 1) & (((
(((0xff00) >> 16) >> 8))))) ^ ((((((0xff00) >>
16) >> 8)))))) >> (1)) != 0) ? 1 : 0))) : ((((u_long
)((((((((0xff00) >> 16))) - 1) & ((((0xff00) >>
16)))) ^ ((((0xff00) >> 16))))) >> (4)) != 0) ? 4
+ ((((u_long)(((((((((0xff00) >> 16)) >> 4)) - 1
) & (((((0xff00) >> 16)) >> 4))) ^ (((((0xff00
) >> 16)) >> 4)))) >> (2)) != 0) ? 2 + ((((
u_long)((((((((((0xff00) >> 16)) >> 4) >> 2
)) - 1) & ((((((0xff00) >> 16)) >> 4) >>
2))) ^ ((((((0xff00) >> 16)) >> 4) >> 2)))
) >> (1)) != 0) ? 1 : 0) : ((((u_long)((((((((((0xff00)
>> 16)) >> 4))) - 1) & ((((((0xff00) >>
16)) >> 4)))) ^ ((((((0xff00) >> 16)) >> 4
))))) >> (1)) != 0) ? 1 : 0)) : ((((u_long)(((((((((0xff00
) >> 16)))) - 1) & (((((0xff00) >> 16))))) ^ (
((((0xff00) >> 16)))))) >> (2)) != 0) ? 2 + ((((u_long
)((((((((((0xff00) >> 16))) >> 2)) - 1) & (((
(((0xff00) >> 16))) >> 2))) ^ ((((((0xff00) >>
16))) >> 2)))) >> (1)) != 0) ? 1 : 0) : ((((u_long
)((((((((((0xff00) >> 16))))) - 1) & ((((((0xff00) >>
16)))))) ^ ((((((0xff00) >> 16))))))) >> (1)) !=
0) ? 1 : 0)))) : ((((u_long)(((((((0xff00))) - 1) & (((0xff00
)))) ^ (((0xff00))))) >> (8)) != 0) ? 8 + ((((u_long)((
((((((0xff00)) >> 8)) - 1) & ((((0xff00)) >> 8
))) ^ ((((0xff00)) >> 8)))) >> (4)) != 0) ? 4 + (
(((u_long)(((((((((0xff00)) >> 8) >> 4)) - 1) &
(((((0xff00)) >> 8) >> 4))) ^ (((((0xff00)) >>
8) >> 4)))) >> (2)) != 0) ? 2 + ((((u_long)(((((
(((((0xff00)) >> 8) >> 4) >> 2)) - 1) &
((((((0xff00)) >> 8) >> 4) >> 2))) ^ (((((
(0xff00)) >> 8) >> 4) >> 2)))) >> (1)
) != 0) ? 1 : 0) : ((((u_long)((((((((((0xff00)) >> 8) >>
4))) - 1) & ((((((0xff00)) >> 8) >> 4)))) ^ (
(((((0xff00)) >> 8) >> 4))))) >> (1)) != 0)
? 1 : 0)) : ((((u_long)(((((((((0xff00)) >> 8))) - 1) &
(((((0xff00)) >> 8)))) ^ (((((0xff00)) >> 8)))))
>> (2)) != 0) ? 2 + ((((u_long)((((((((((0xff00)) >>
8)) >> 2)) - 1) & ((((((0xff00)) >> 8)) >>
2))) ^ ((((((0xff00)) >> 8)) >> 2)))) >> (
1)) != 0) ? 1 : 0) : ((((u_long)((((((((((0xff00)) >> 8
)))) - 1) & ((((((0xff00)) >> 8))))) ^ ((((((0xff00
)) >> 8)))))) >> (1)) != 0) ? 1 : 0))) : ((((u_long
)((((((((0xff00)))) - 1) & ((((0xff00))))) ^ ((((0xff00))
)))) >> (4)) != 0) ? 4 + ((((u_long)(((((((((0xff00))) >>
4)) - 1) & (((((0xff00))) >> 4))) ^ (((((0xff00)))
>> 4)))) >> (2)) != 0) ? 2 + ((((u_long)((((((((
((0xff00))) >> 4) >> 2)) - 1) & ((((((0xff00)
)) >> 4) >> 2))) ^ ((((((0xff00))) >> 4) >>
2)))) >> (1)) != 0) ? 1 : 0) : ((((u_long)((((((((((0xff00
))) >> 4))) - 1) & ((((((0xff00))) >> 4)))) ^
((((((0xff00))) >> 4))))) >> (1)) != 0) ? 1 : 0)
) : ((((u_long)(((((((((0xff00))))) - 1) & (((((0xff00)))
))) ^ (((((0xff00))))))) >> (2)) != 0) ? 2 + ((((u_long
)((((((((((0xff00)))) >> 2)) - 1) & ((((((0xff00)))
) >> 2))) ^ ((((((0xff00)))) >> 2)))) >> (1
)) != 0) ? 1 : 0) : ((((u_long)((((((((((0xff00)))))) - 1) &
((((((0xff00))))))) ^ ((((((0xff00)))))))) >> (1)) != 0
) ? 1 : 0))))))
;
796
797 if (IEEE80211_ADDR_EQ(addr, empty_macaddr)(__builtin_memcmp((addr), (empty_macaddr), (6)) == 0)) {
798 printf("\n%s: could not get mac address, attach failed\n",
799 dvname);
800 return ENXIO6;
801 }
802
803 printf("address %s\n", ether_sprintf(*addr));
804
805 return 0;
806}
807
808u_int8_t
809rtw_chan2txpower(struct rtw_srom *sr, struct ieee80211com *ic,
810 struct ieee80211_channel *chan)
811{
812 u_int idx = RTW_SR_TXPOWER10x20 + ieee80211_chan2ieee(ic, chan) - 1;
813 KASSERT2(idx >= RTW_SR_TXPOWER1 && idx <= RTW_SR_TXPOWER14,do { if (!(idx >= 0x20 && idx <= 0x2d)) panic (
"%s: channel %d out of range", __func__, idx - 0x20 + 1) ; } while
(0)
814 ("%s: channel %d out of range", __func__,do { if (!(idx >= 0x20 && idx <= 0x2d)) panic (
"%s: channel %d out of range", __func__, idx - 0x20 + 1) ; } while
(0)
815 idx - RTW_SR_TXPOWER1 + 1))do { if (!(idx >= 0x20 && idx <= 0x2d)) panic (
"%s: channel %d out of range", __func__, idx - 0x20 + 1) ; } while
(0)
;
816 return RTW_SR_GET(sr, idx)(((sr)->sr_content[(idx)/2] >> (((idx) % 2 == 0) ? 0
: 8)) & 0xff)
;
817}
818
819void
820rtw_txdesc_blk_init_all(struct rtw_txdesc_blk *tdb)
821{
822 int pri;
823 /* nfree: the number of free descriptors in each ring.
824 * The beacon ring is a special case: I do not let the
825 * driver use all of the descriptors on the beacon ring.
826 * The reasons are two-fold:
827 *
828 * (1) A BEACON descriptor's OWN bit is (apparently) not
829 * updated, so the driver cannot easily know if the descriptor
830 * belongs to it, or if it is racing the NIC. If the NIC
831 * does not OWN every descriptor, then the driver can safely
832 * update the descriptors when RTW_TBDA points at tdb_next.
833 *
834 * (2) I hope that the NIC will process more than one BEACON
835 * descriptor in a single beacon interval, since that will
836 * enable multiple-BSS support. Since the NIC does not
837 * clear the OWN bit, there is no natural place for it to
838 * stop processing BEACON descriptors. Maybe it will *not*
839 * stop processing them! I do not want to chance the NIC
840 * looping around and around a saturated beacon ring, so
841 * I will leave one descriptor unOWNed at all times.
842 */
843 u_int nfree[RTW_NTXPRI4] =
844 {RTW_NTXDESCLO64, RTW_NTXDESCMD64, RTW_NTXDESCHI64,
845 RTW_NTXDESCBCN8 - 1};
846
847 for (pri = 0; pri < RTW_NTXPRI4; pri++) {
848 tdb[pri].tdb_nfree = nfree[pri];
849 tdb[pri].tdb_next = 0;
850 }
851}
852
853int
854rtw_txsoft_blk_init(struct rtw_txsoft_blk *tsb)
855{
856 int i;
857 struct rtw_txsoft *ts;
858
859 SIMPLEQ_INIT(&tsb->tsb_dirtyq)do { (&tsb->tsb_dirtyq)->sqh_first = ((void *)0); (
&tsb->tsb_dirtyq)->sqh_last = &(&tsb->tsb_dirtyq
)->sqh_first; } while (0)
;
860 SIMPLEQ_INIT(&tsb->tsb_freeq)do { (&tsb->tsb_freeq)->sqh_first = ((void *)0); (&
tsb->tsb_freeq)->sqh_last = &(&tsb->tsb_freeq
)->sqh_first; } while (0)
;
861 for (i = 0; i < tsb->tsb_ndesc; i++) {
862 ts = &tsb->tsb_desc[i];
863 ts->ts_mbuf = NULL((void *)0);
864 SIMPLEQ_INSERT_TAIL(&tsb->tsb_freeq, ts, ts_q)do { (ts)->ts_q.sqe_next = ((void *)0); *(&tsb->tsb_freeq
)->sqh_last = (ts); (&tsb->tsb_freeq)->sqh_last =
&(ts)->ts_q.sqe_next; } while (0)
;
865 }
866 tsb->tsb_tx_timer = 0;
867 return 0;
868}
869
870void
871rtw_txsoft_blk_init_all(struct rtw_txsoft_blk *tsb)
872{
873 int pri;
874 for (pri = 0; pri < RTW_NTXPRI4; pri++)
875 rtw_txsoft_blk_init(&tsb[pri]);
876}
877
878void
879rtw_rxdescs_sync(struct rtw_rxdesc_blk *rdb, int desc0, int nsync, int ops)
880{
881 KASSERT(nsync <= rdb->rdb_ndesc)((nsync <= rdb->rdb_ndesc) ? (void)0 : __assert("diagnostic "
, "/usr/src/sys/dev/ic/rtw.c", 881, "nsync <= rdb->rdb_ndesc"
))
;
882 /* sync to end of ring */
883 if (desc0 + nsync > rdb->rdb_ndesc) {
884 bus_dmamap_sync(rdb->rdb_dmat, rdb->rdb_dmamap,(*(rdb->rdb_dmat)->_dmamap_sync)((rdb->rdb_dmat), (rdb
->rdb_dmamap), (__builtin_offsetof(struct rtw_descs, hd_rx
[desc0])), (sizeof(struct rtw_rxdesc) * (rdb->rdb_ndesc - desc0
)), (ops))
885 offsetof(struct rtw_descs, hd_rx[desc0]),(*(rdb->rdb_dmat)->_dmamap_sync)((rdb->rdb_dmat), (rdb
->rdb_dmamap), (__builtin_offsetof(struct rtw_descs, hd_rx
[desc0])), (sizeof(struct rtw_rxdesc) * (rdb->rdb_ndesc - desc0
)), (ops))
886 sizeof(struct rtw_rxdesc) * (rdb->rdb_ndesc - desc0), ops)(*(rdb->rdb_dmat)->_dmamap_sync)((rdb->rdb_dmat), (rdb
->rdb_dmamap), (__builtin_offsetof(struct rtw_descs, hd_rx
[desc0])), (sizeof(struct rtw_rxdesc) * (rdb->rdb_ndesc - desc0
)), (ops))
;
887 nsync -= (rdb->rdb_ndesc - desc0);
888 desc0 = 0;
889 }
890
891 KASSERT(desc0 < rdb->rdb_ndesc)((desc0 < rdb->rdb_ndesc) ? (void)0 : __assert("diagnostic "
, "/usr/src/sys/dev/ic/rtw.c", 891, "desc0 < rdb->rdb_ndesc"
))
;
892 KASSERT(nsync <= rdb->rdb_ndesc)((nsync <= rdb->rdb_ndesc) ? (void)0 : __assert("diagnostic "
, "/usr/src/sys/dev/ic/rtw.c", 892, "nsync <= rdb->rdb_ndesc"
))
;
893 KASSERT(desc0 + nsync <= rdb->rdb_ndesc)((desc0 + nsync <= rdb->rdb_ndesc) ? (void)0 : __assert
("diagnostic ", "/usr/src/sys/dev/ic/rtw.c", 893, "desc0 + nsync <= rdb->rdb_ndesc"
))
;
894
895 /* sync what remains */
896 bus_dmamap_sync(rdb->rdb_dmat, rdb->rdb_dmamap,(*(rdb->rdb_dmat)->_dmamap_sync)((rdb->rdb_dmat), (rdb
->rdb_dmamap), (__builtin_offsetof(struct rtw_descs, hd_rx
[desc0])), (sizeof(struct rtw_rxdesc) * nsync), (ops))
897 offsetof(struct rtw_descs, hd_rx[desc0]),(*(rdb->rdb_dmat)->_dmamap_sync)((rdb->rdb_dmat), (rdb
->rdb_dmamap), (__builtin_offsetof(struct rtw_descs, hd_rx
[desc0])), (sizeof(struct rtw_rxdesc) * nsync), (ops))
898 sizeof(struct rtw_rxdesc) * nsync, ops)(*(rdb->rdb_dmat)->_dmamap_sync)((rdb->rdb_dmat), (rdb
->rdb_dmamap), (__builtin_offsetof(struct rtw_descs, hd_rx
[desc0])), (sizeof(struct rtw_rxdesc) * nsync), (ops))
;
899}
900
901void
902rtw_txdescs_sync(struct rtw_txdesc_blk *tdb, u_int desc0, u_int nsync, int ops)
903{
904 /* sync to end of ring */
905 if (desc0 + nsync > tdb->tdb_ndesc) {
906 bus_dmamap_sync(tdb->tdb_dmat, tdb->tdb_dmamap,(*(tdb->tdb_dmat)->_dmamap_sync)((tdb->tdb_dmat), (tdb
->tdb_dmamap), (tdb->tdb_ofs + sizeof(struct rtw_txdesc
) * desc0), (sizeof(struct rtw_txdesc) * (tdb->tdb_ndesc -
desc0)), (ops))
907 tdb->tdb_ofs + sizeof(struct rtw_txdesc) * desc0,(*(tdb->tdb_dmat)->_dmamap_sync)((tdb->tdb_dmat), (tdb
->tdb_dmamap), (tdb->tdb_ofs + sizeof(struct rtw_txdesc
) * desc0), (sizeof(struct rtw_txdesc) * (tdb->tdb_ndesc -
desc0)), (ops))
908 sizeof(struct rtw_txdesc) * (tdb->tdb_ndesc - desc0),(*(tdb->tdb_dmat)->_dmamap_sync)((tdb->tdb_dmat), (tdb
->tdb_dmamap), (tdb->tdb_ofs + sizeof(struct rtw_txdesc
) * desc0), (sizeof(struct rtw_txdesc) * (tdb->tdb_ndesc -
desc0)), (ops))
909 ops)(*(tdb->tdb_dmat)->_dmamap_sync)((tdb->tdb_dmat), (tdb
->tdb_dmamap), (tdb->tdb_ofs + sizeof(struct rtw_txdesc
) * desc0), (sizeof(struct rtw_txdesc) * (tdb->tdb_ndesc -
desc0)), (ops))
;
910 nsync -= (tdb->tdb_ndesc - desc0);
911 desc0 = 0;
912 }
913
914 /* sync what remains */
915 bus_dmamap_sync(tdb->tdb_dmat, tdb->tdb_dmamap,(*(tdb->tdb_dmat)->_dmamap_sync)((tdb->tdb_dmat), (tdb
->tdb_dmamap), (tdb->tdb_ofs + sizeof(struct rtw_txdesc
) * desc0), (sizeof(struct rtw_txdesc) * nsync), (ops))
916 tdb->tdb_ofs + sizeof(struct rtw_txdesc) * desc0,(*(tdb->tdb_dmat)->_dmamap_sync)((tdb->tdb_dmat), (tdb
->tdb_dmamap), (tdb->tdb_ofs + sizeof(struct rtw_txdesc
) * desc0), (sizeof(struct rtw_txdesc) * nsync), (ops))
917 sizeof(struct rtw_txdesc) * nsync, ops)(*(tdb->tdb_dmat)->_dmamap_sync)((tdb->tdb_dmat), (tdb
->tdb_dmamap), (tdb->tdb_ofs + sizeof(struct rtw_txdesc
) * desc0), (sizeof(struct rtw_txdesc) * nsync), (ops))
;
918}
919
920void
921rtw_rxbufs_release(bus_dma_tag_t dmat, struct rtw_rxsoft *desc)
922{
923 int i;
924 struct rtw_rxsoft *rs;
925
926 for (i = 0; i < RTW_RXQLEN64; i++) {
927 rs = &desc[i];
928 if (rs->rs_mbuf == NULL((void *)0))
929 continue;
930 bus_dmamap_sync(dmat, rs->rs_dmamap, 0,(*(dmat)->_dmamap_sync)((dmat), (rs->rs_dmamap), (0), (
rs->rs_dmamap->dm_mapsize), (0x02))
931 rs->rs_dmamap->dm_mapsize, BUS_DMASYNC_POSTREAD)(*(dmat)->_dmamap_sync)((dmat), (rs->rs_dmamap), (0), (
rs->rs_dmamap->dm_mapsize), (0x02))
;
932 bus_dmamap_unload(dmat, rs->rs_dmamap)(*(dmat)->_dmamap_unload)((dmat), (rs->rs_dmamap));
933 m_freem(rs->rs_mbuf);
934 rs->rs_mbuf = NULL((void *)0);
935 }
936}
937
938int
939rtw_rxsoft_alloc(bus_dma_tag_t dmat, struct rtw_rxsoft *rs)
940{
941 int rc;
942 struct mbuf *m;
943
944 MGETHDR(m, M_DONTWAIT, MT_DATA)m = m_gethdr((0x0002), (1));
945 if (m == NULL((void *)0))
946 return ENOBUFS55;
947
948 MCLGET(m, M_DONTWAIT)(void) m_clget((m), (0x0002), (1 << 11));
949 if ((m->m_flagsm_hdr.mh_flags & M_EXT0x0001) == 0) {
950 m_freem(m);
951 return ENOBUFS55;
952 }
953
954 m->m_pkthdrM_dat.MH.MH_pkthdr.len = m->m_lenm_hdr.mh_len = m->m_extM_dat.MH.MH_dat.MH_ext.ext_size;
955
956 if (rs->rs_mbuf != NULL((void *)0))
957 bus_dmamap_unload(dmat, rs->rs_dmamap)(*(dmat)->_dmamap_unload)((dmat), (rs->rs_dmamap));
958
959 rs->rs_mbuf = NULL((void *)0);
960
961 rc = bus_dmamap_load_mbuf(dmat, rs->rs_dmamap, m, BUS_DMA_NOWAIT)(*(dmat)->_dmamap_load_mbuf)((dmat), (rs->rs_dmamap), (
m), (0x0001))
;
962 if (rc != 0) {
963 m_freem(m);
964 return -1;
965 }
966
967 rs->rs_mbuf = m;
968
969 return 0;
970}
971
972int
973rtw_rxsoft_init_all(bus_dma_tag_t dmat, struct rtw_rxsoft *desc,
974 int *ndesc, const char *dvname)
975{
976 int i, rc = 0;
977 struct rtw_rxsoft *rs;
978
979 for (i = 0; i < RTW_RXQLEN64; i++) {
980 rs = &desc[i];
981 /* we're in rtw_init, so there should be no mbufs allocated */
982 KASSERT(rs->rs_mbuf == NULL)((rs->rs_mbuf == ((void *)0)) ? (void)0 : __assert("diagnostic "
, "/usr/src/sys/dev/ic/rtw.c", 982, "rs->rs_mbuf == NULL")
)
;
983#ifdef RTW_DEBUG
984 if (i == rtw_rxbufs_limit) {
985 printf("%s: TEST hit %d-buffer limit\n", dvname, i);
986 rc = ENOBUFS55;
987 break;
988 }
989#endif /* RTW_DEBUG */
990 if ((rc = rtw_rxsoft_alloc(dmat, rs)) != 0) {
991 printf("%s: rtw_rxsoft_alloc failed, %d buffers, "
992 "rc %d\n", dvname, i, rc);
993 break;
994 }
995 }
996 *ndesc = i;
997 return rc;
998}
999
1000void
1001rtw_rxdesc_init(struct rtw_rxdesc_blk *rdb, struct rtw_rxsoft *rs,
1002 int idx, int kick)
1003{
1004 int is_last = (idx == rdb->rdb_ndesc - 1);
1005 uint32_t ctl, octl, obuf;
1006 struct rtw_rxdesc *rd = &rdb->rdb_desc[idx];
1007
1008 obuf = rd->rd_buf;
1009 rd->rd_buf = htole32(rs->rs_dmamap->dm_segs[0].ds_addr)((__uint32_t)(rs->rs_dmamap->dm_segs[0].ds_addr));
1010
1011 ctl = LSHIFT(rs->rs_mbuf->m_len, RTW_RXCTL_LENGTH_MASK)((rs->rs_mbuf->m_hdr.mh_len) << ((((u_long)((((((
0xfff)) - 1) & ((0xfff))) ^ ((0xfff)))) >> (16)) !=
0) ? 16 + ((((u_long)(((((((0xfff) >> 16)) - 1) & (
((0xfff) >> 16))) ^ (((0xfff) >> 16)))) >> (
8)) != 0) ? 8 + ((((u_long)((((((((0xfff) >> 16) >>
8)) - 1) & ((((0xfff) >> 16) >> 8))) ^ ((((0xfff
) >> 16) >> 8)))) >> (4)) != 0) ? 4 + ((((u_long
)(((((((((0xfff) >> 16) >> 8) >> 4)) - 1) &
(((((0xfff) >> 16) >> 8) >> 4))) ^ (((((0xfff
) >> 16) >> 8) >> 4)))) >> (2)) != 0)
? 2 + ((((u_long)((((((((((0xfff) >> 16) >> 8) >>
4) >> 2)) - 1) & ((((((0xfff) >> 16) >>
8) >> 4) >> 2))) ^ ((((((0xfff) >> 16) >>
8) >> 4) >> 2)))) >> (1)) != 0) ? 1 : 0) :
((((u_long)((((((((((0xfff) >> 16) >> 8) >>
4))) - 1) & ((((((0xfff) >> 16) >> 8) >>
4)))) ^ ((((((0xfff) >> 16) >> 8) >> 4))))
) >> (1)) != 0) ? 1 : 0)) : ((((u_long)(((((((((0xfff) >>
16) >> 8))) - 1) & (((((0xfff) >> 16) >>
8)))) ^ (((((0xfff) >> 16) >> 8))))) >> (2
)) != 0) ? 2 + ((((u_long)((((((((((0xfff) >> 16) >>
8)) >> 2)) - 1) & ((((((0xfff) >> 16) >>
8)) >> 2))) ^ ((((((0xfff) >> 16) >> 8)) >>
2)))) >> (1)) != 0) ? 1 : 0) : ((((u_long)((((((((((0xfff
) >> 16) >> 8)))) - 1) & ((((((0xfff) >>
16) >> 8))))) ^ ((((((0xfff) >> 16) >> 8))
)))) >> (1)) != 0) ? 1 : 0))) : ((((u_long)((((((((0xfff
) >> 16))) - 1) & ((((0xfff) >> 16)))) ^ ((((
0xfff) >> 16))))) >> (4)) != 0) ? 4 + ((((u_long)
(((((((((0xfff) >> 16)) >> 4)) - 1) & (((((0xfff
) >> 16)) >> 4))) ^ (((((0xfff) >> 16)) >>
4)))) >> (2)) != 0) ? 2 + ((((u_long)((((((((((0xfff) >>
16)) >> 4) >> 2)) - 1) & ((((((0xfff) >>
16)) >> 4) >> 2))) ^ ((((((0xfff) >> 16)) >>
4) >> 2)))) >> (1)) != 0) ? 1 : 0) : ((((u_long)
((((((((((0xfff) >> 16)) >> 4))) - 1) & (((((
(0xfff) >> 16)) >> 4)))) ^ ((((((0xfff) >> 16
)) >> 4))))) >> (1)) != 0) ? 1 : 0)) : ((((u_long
)(((((((((0xfff) >> 16)))) - 1) & (((((0xfff) >>
16))))) ^ (((((0xfff) >> 16)))))) >> (2)) != 0) ?
2 + ((((u_long)((((((((((0xfff) >> 16))) >> 2)) -
1) & ((((((0xfff) >> 16))) >> 2))) ^ ((((((0xfff
) >> 16))) >> 2)))) >> (1)) != 0) ? 1 : 0) :
((((u_long)((((((((((0xfff) >> 16))))) - 1) & ((((
((0xfff) >> 16)))))) ^ ((((((0xfff) >> 16))))))) >>
(1)) != 0) ? 1 : 0)))) : ((((u_long)(((((((0xfff))) - 1) &
(((0xfff)))) ^ (((0xfff))))) >> (8)) != 0) ? 8 + ((((u_long
)((((((((0xfff)) >> 8)) - 1) & ((((0xfff)) >>
8))) ^ ((((0xfff)) >> 8)))) >> (4)) != 0) ? 4 + (
(((u_long)(((((((((0xfff)) >> 8) >> 4)) - 1) &
(((((0xfff)) >> 8) >> 4))) ^ (((((0xfff)) >>
8) >> 4)))) >> (2)) != 0) ? 2 + ((((u_long)(((((
(((((0xfff)) >> 8) >> 4) >> 2)) - 1) & (
(((((0xfff)) >> 8) >> 4) >> 2))) ^ ((((((0xfff
)) >> 8) >> 4) >> 2)))) >> (1)) != 0)
? 1 : 0) : ((((u_long)((((((((((0xfff)) >> 8) >>
4))) - 1) & ((((((0xfff)) >> 8) >> 4)))) ^ (
(((((0xfff)) >> 8) >> 4))))) >> (1)) != 0) ?
1 : 0)) : ((((u_long)(((((((((0xfff)) >> 8))) - 1) &
(((((0xfff)) >> 8)))) ^ (((((0xfff)) >> 8))))) >>
(2)) != 0) ? 2 + ((((u_long)((((((((((0xfff)) >> 8)) >>
2)) - 1) & ((((((0xfff)) >> 8)) >> 2))) ^ ((
((((0xfff)) >> 8)) >> 2)))) >> (1)) != 0) ?
1 : 0) : ((((u_long)((((((((((0xfff)) >> 8)))) - 1) &
((((((0xfff)) >> 8))))) ^ ((((((0xfff)) >> 8))))
)) >> (1)) != 0) ? 1 : 0))) : ((((u_long)((((((((0xfff)
))) - 1) & ((((0xfff))))) ^ ((((0xfff)))))) >> (4))
!= 0) ? 4 + ((((u_long)(((((((((0xfff))) >> 4)) - 1) &
(((((0xfff))) >> 4))) ^ (((((0xfff))) >> 4)))) >>
(2)) != 0) ? 2 + ((((u_long)((((((((((0xfff))) >> 4) >>
2)) - 1) & ((((((0xfff))) >> 4) >> 2))) ^ ((
((((0xfff))) >> 4) >> 2)))) >> (1)) != 0) ?
1 : 0) : ((((u_long)((((((((((0xfff))) >> 4))) - 1) &
((((((0xfff))) >> 4)))) ^ ((((((0xfff))) >> 4)))
)) >> (1)) != 0) ? 1 : 0)) : ((((u_long)(((((((((0xfff)
)))) - 1) & (((((0xfff)))))) ^ (((((0xfff))))))) >>
(2)) != 0) ? 2 + ((((u_long)((((((((((0xfff)))) >> 2))
- 1) & ((((((0xfff)))) >> 2))) ^ ((((((0xfff)))) >>
2)))) >> (1)) != 0) ? 1 : 0) : ((((u_long)((((((((((0xfff
)))))) - 1) & ((((((0xfff))))))) ^ ((((((0xfff)))))))) >>
(1)) != 0) ? 1 : 0))))))
|
1012 RTW_RXCTL_OWN(1<<31) | RTW_RXCTL_FS(1<<29) | RTW_RXCTL_LS(1<<28);
1013
1014 if (is_last)
1015 ctl |= RTW_RXCTL_EOR(1<<30);
1016
1017 octl = rd->rd_ctl;
1018 rd->rd_ctl = htole32(ctl)((__uint32_t)(ctl));
1019
1020 RTW_DPRINTF(kick ? (RTW_DEBUG_RECV_DESC | RTW_DEBUG_IO_KICK)
1021 : RTW_DEBUG_RECV_DESC,
1022 ("%s: rd %p buf %08x -> %08x ctl %08x -> %08x\n", __func__, rd,
1023 letoh32(obuf), letoh32(rd->rd_buf), letoh32(octl),
1024 letoh32(rd->rd_ctl)));
1025
1026 /* sync the mbuf */
1027 bus_dmamap_sync(rdb->rdb_dmat, rs->rs_dmamap, 0,(*(rdb->rdb_dmat)->_dmamap_sync)((rdb->rdb_dmat), (rs
->rs_dmamap), (0), (rs->rs_dmamap->dm_mapsize), (0x01
))
1028 rs->rs_dmamap->dm_mapsize, BUS_DMASYNC_PREREAD)(*(rdb->rdb_dmat)->_dmamap_sync)((rdb->rdb_dmat), (rs
->rs_dmamap), (0), (rs->rs_dmamap->dm_mapsize), (0x01
))
;
1029
1030 /* sync the descriptor */
1031 bus_dmamap_sync(rdb->rdb_dmat, rdb->rdb_dmamap,(*(rdb->rdb_dmat)->_dmamap_sync)((rdb->rdb_dmat), (rdb
->rdb_dmamap), (__builtin_offsetof(struct rtw_descs, hd_rx
[idx])), (sizeof(struct rtw_rxdesc)), (0x01|0x04))
1032 RTW_DESC_OFFSET(hd_rx, idx), sizeof(struct rtw_rxdesc),(*(rdb->rdb_dmat)->_dmamap_sync)((rdb->rdb_dmat), (rdb
->rdb_dmamap), (__builtin_offsetof(struct rtw_descs, hd_rx
[idx])), (sizeof(struct rtw_rxdesc)), (0x01|0x04))
1033 BUS_DMASYNC_PREREAD|BUS_DMASYNC_PREWRITE)(*(rdb->rdb_dmat)->_dmamap_sync)((rdb->rdb_dmat), (rdb
->rdb_dmamap), (__builtin_offsetof(struct rtw_descs, hd_rx
[idx])), (sizeof(struct rtw_rxdesc)), (0x01|0x04))
;
1034}
1035
1036void
1037rtw_rxdesc_init_all(struct rtw_rxdesc_blk *rdb, struct rtw_rxsoft *ctl,
1038 int kick)
1039{
1040 int i;
1041 struct rtw_rxsoft *rs;
1042
1043 for (i = 0; i < rdb->rdb_ndesc; i++) {
1044 rs = &ctl[i];
1045 rtw_rxdesc_init(rdb, rs, i, kick);
1046 }
1047}
1048
1049void
1050rtw_io_enable(struct rtw_regs *regs, u_int8_t flags, int enable)
1051{
1052 u_int8_t cr;
1053
1054 RTW_DPRINTF(RTW_DEBUG_IOSTATE, ("%s: %s 0x%02x\n", __func__,
1055 enable ? "enable" : "disable", flags));
1056
1057 cr = RTW_READ8(regs, RTW_CR)((*(regs)->r_read8)(regs, 0x37));
1058
1059 /* XXX reference source does not enable MULRW */
1060#if 0
1061 /* enable PCI Read/Write Multiple */
1062 cr |= RTW_CR_MULRW(1<<0);
1063#endif
1064
1065 RTW_RBW(regs, RTW_CR, RTW_CR)((*(regs)->r_barrier)(regs, 0x37, 0x37, 0x01)); /* XXX paranoia? */
1066 if (enable)
1067 cr |= flags;
1068 else
1069 cr &= ~flags;
1070 RTW_WRITE8(regs, RTW_CR, cr)((*(regs)->r_write8)(regs, 0x37, cr));
1071 RTW_SYNC(regs, RTW_CR, RTW_CR)((*(regs)->r_barrier)(regs, 0x37, 0x37, (0x01|0x02)));
1072}
1073
1074void
1075rtw_intr_rx(struct rtw_softc *sc, u_int16_t isr)
1076{
1077#define IS_BEACON(__fc0) \
1078 ((__fc0 & (IEEE80211_FC0_TYPE_MASK0x0c | IEEE80211_FC0_SUBTYPE_MASK0xf0)) ==\
1079 (IEEE80211_FC0_TYPE_MGT0x00 | IEEE80211_FC0_SUBTYPE_BEACON0x80))
1080
1081 static const int ratetbl[4] = {2, 4, 11, 22}; /* convert rates:
1082 * hardware -> net80211
1083 */
1084 struct mbuf_list ml = MBUF_LIST_INITIALIZER(){ ((void *)0), ((void *)0), 0 };
1085 u_int next, nproc = 0;
1086 int hwrate, len, rate, rssi, sq;
1087 u_int32_t hrssi, hstat, htsfth, htsftl;
1088 struct rtw_rxdesc *rd;
1089 struct rtw_rxsoft *rs;
1090 struct rtw_rxdesc_blk *rdb;
1091 struct mbuf *m;
1092 struct ieee80211_rxinfo rxi;
1093 struct ieee80211_node *ni;
1094 struct ieee80211_frame *wh;
1095
1096 rdb = &sc->sc_rxdesc_blk;
1097
1098 KASSERT(rdb->rdb_next < rdb->rdb_ndesc)((rdb->rdb_next < rdb->rdb_ndesc) ? (void)0 : __assert
("diagnostic ", "/usr/src/sys/dev/ic/rtw.c", 1098, "rdb->rdb_next < rdb->rdb_ndesc"
))
;
1099
1100 for (next = rdb->rdb_next; ; next = (next + 1) % rdb->rdb_ndesc) {
1101 rtw_rxdescs_sync(rdb, next, 1,
1102 BUS_DMASYNC_POSTREAD0x02|BUS_DMASYNC_POSTWRITE0x08);
1103 rd = &rdb->rdb_desc[next];
1104 rs = &sc->sc_rxsoft[next];
1105
1106 hstat = letoh32(rd->rd_stat)((__uint32_t)(rd->rd_ctl));
1107 hrssi = letoh32(rd->rd_rssi)((__uint32_t)(rd->rd_rsvd0));
1108 htsfth = letoh32(rd->rd_tsfth)((__uint32_t)(rd->rd_rsvd1));
1109 htsftl = letoh32(rd->rd_tsftl)((__uint32_t)(rd->rd_buf));
1110
1111 RTW_DPRINTF(RTW_DEBUG_RECV_DESC,
1112 ("%s: rxdesc[%d] hstat %08x hrssi %08x htsft %08x%08x\n",
1113 __func__, next, hstat, hrssi, htsfth, htsftl));
1114
1115 ++nproc;
1116
1117 /* still belongs to NIC */
1118 if ((hstat & RTW_RXSTAT_OWN(1<<31)) != 0) {
1119 if (nproc > 1)
1120 break;
1121
1122 /* sometimes the NIC skips to the 0th descriptor */
1123 rtw_rxdescs_sync(rdb, 0, 1,
1124 BUS_DMASYNC_POSTREAD0x02|BUS_DMASYNC_POSTWRITE0x08);
1125 rd = &rdb->rdb_desc[0];
1126 if ((rd->rd_statrd_ctl & htole32(RTW_RXSTAT_OWN)((__uint32_t)((1<<31)))) != 0)
1127 break;
1128 RTW_DPRINTF(RTW_DEBUG_BUGS,
1129 ("%s: NIC skipped from rxdesc[%u] to rxdesc[0]\n",
1130 sc->sc_dev.dv_xname, next));
1131 next = rdb->rdb_ndesc - 1;
1132 continue;
1133 }
1134
1135#ifdef RTW_DEBUG
1136#define PRINTSTAT(flag) do { \
1137 if ((hstat & flag) != 0) { \
1138 printf("%s" #flag, delim); \
1139 delim = ","; \
1140 } \
1141} while (0)
1142 if ((rtw_debug & RTW_DEBUG_RECV_DESC) != 0) {
1143 const char *delim = "<";
1144 printf("%s: ", sc->sc_dev.dv_xname);
1145 if ((hstat & RTW_RXSTAT_DEBUG((1<<25)|(1<<18)| (1<<17)|(1<<16)| (1
<<14)|(1<<13)| (1<<12))
) != 0) {
1146 printf("status %08x", hstat);
1147 PRINTSTAT(RTW_RXSTAT_SPLCP(1<<25));
1148 PRINTSTAT(RTW_RXSTAT_MAR(1<<18));
1149 PRINTSTAT(RTW_RXSTAT_PAR(1<<17));
1150 PRINTSTAT(RTW_RXSTAT_BAR(1<<16));
1151 PRINTSTAT(RTW_RXSTAT_PWRMGT(1<<14));
1152 PRINTSTAT(RTW_RXSTAT_CRC32(1<<13));
1153 PRINTSTAT(RTW_RXSTAT_ICV(1<<12));
1154 printf(">, ");
1155 }
1156 }
1157#undef PRINTSTAT
1158#endif /* RTW_DEBUG */
1159
1160 if ((hstat & RTW_RXSTAT_IOERROR((1<<27)|(1<<26))) != 0) {
1161 printf("%s: DMA error/FIFO overflow %08x, "
1162 "rx descriptor %d\n", sc->sc_dev.dv_xname,
1163 hstat & RTW_RXSTAT_IOERROR((1<<27)|(1<<26)), next);
1164 sc->sc_ifsc_ic.ic_ac.ac_if.if_ierrorsif_data.ifi_ierrors++;
1165 goto next;
1166 }
1167
1168 len = MASK_AND_RSHIFT(hstat, RTW_RXSTAT_LENGTH_MASK)(((hstat) & (0xfff)) >> ((((u_long)((((((0xfff)) - 1
) & ((0xfff))) ^ ((0xfff)))) >> (16)) != 0) ? 16 + (
(((u_long)(((((((0xfff) >> 16)) - 1) & (((0xfff) >>
16))) ^ (((0xfff) >> 16)))) >> (8)) != 0) ? 8 + (
(((u_long)((((((((0xfff) >> 16) >> 8)) - 1) &
((((0xfff) >> 16) >> 8))) ^ ((((0xfff) >> 16
) >> 8)))) >> (4)) != 0) ? 4 + ((((u_long)(((((((
((0xfff) >> 16) >> 8) >> 4)) - 1) & (((
((0xfff) >> 16) >> 8) >> 4))) ^ (((((0xfff)
>> 16) >> 8) >> 4)))) >> (2)) != 0) ?
2 + ((((u_long)((((((((((0xfff) >> 16) >> 8) >>
4) >> 2)) - 1) & ((((((0xfff) >> 16) >>
8) >> 4) >> 2))) ^ ((((((0xfff) >> 16) >>
8) >> 4) >> 2)))) >> (1)) != 0) ? 1 : 0) :
((((u_long)((((((((((0xfff) >> 16) >> 8) >>
4))) - 1) & ((((((0xfff) >> 16) >> 8) >>
4)))) ^ ((((((0xfff) >> 16) >> 8) >> 4))))
) >> (1)) != 0) ? 1 : 0)) : ((((u_long)(((((((((0xfff) >>
16) >> 8))) - 1) & (((((0xfff) >> 16) >>
8)))) ^ (((((0xfff) >> 16) >> 8))))) >> (2
)) != 0) ? 2 + ((((u_long)((((((((((0xfff) >> 16) >>
8)) >> 2)) - 1) & ((((((0xfff) >> 16) >>
8)) >> 2))) ^ ((((((0xfff) >> 16) >> 8)) >>
2)))) >> (1)) != 0) ? 1 : 0) : ((((u_long)((((((((((0xfff
) >> 16) >> 8)))) - 1) & ((((((0xfff) >>
16) >> 8))))) ^ ((((((0xfff) >> 16) >> 8))
)))) >> (1)) != 0) ? 1 : 0))) : ((((u_long)((((((((0xfff
) >> 16))) - 1) & ((((0xfff) >> 16)))) ^ ((((
0xfff) >> 16))))) >> (4)) != 0) ? 4 + ((((u_long)
(((((((((0xfff) >> 16)) >> 4)) - 1) & (((((0xfff
) >> 16)) >> 4))) ^ (((((0xfff) >> 16)) >>
4)))) >> (2)) != 0) ? 2 + ((((u_long)((((((((((0xfff) >>
16)) >> 4) >> 2)) - 1) & ((((((0xfff) >>
16)) >> 4) >> 2))) ^ ((((((0xfff) >> 16)) >>
4) >> 2)))) >> (1)) != 0) ? 1 : 0) : ((((u_long)
((((((((((0xfff) >> 16)) >> 4))) - 1) & (((((
(0xfff) >> 16)) >> 4)))) ^ ((((((0xfff) >> 16
)) >> 4))))) >> (1)) != 0) ? 1 : 0)) : ((((u_long
)(((((((((0xfff) >> 16)))) - 1) & (((((0xfff) >>
16))))) ^ (((((0xfff) >> 16)))))) >> (2)) != 0) ?
2 + ((((u_long)((((((((((0xfff) >> 16))) >> 2)) -
1) & ((((((0xfff) >> 16))) >> 2))) ^ ((((((0xfff
) >> 16))) >> 2)))) >> (1)) != 0) ? 1 : 0) :
((((u_long)((((((((((0xfff) >> 16))))) - 1) & ((((
((0xfff) >> 16)))))) ^ ((((((0xfff) >> 16))))))) >>
(1)) != 0) ? 1 : 0)))) : ((((u_long)(((((((0xfff))) - 1) &
(((0xfff)))) ^ (((0xfff))))) >> (8)) != 0) ? 8 + ((((u_long
)((((((((0xfff)) >> 8)) - 1) & ((((0xfff)) >>
8))) ^ ((((0xfff)) >> 8)))) >> (4)) != 0) ? 4 + (
(((u_long)(((((((((0xfff)) >> 8) >> 4)) - 1) &
(((((0xfff)) >> 8) >> 4))) ^ (((((0xfff)) >>
8) >> 4)))) >> (2)) != 0) ? 2 + ((((u_long)(((((
(((((0xfff)) >> 8) >> 4) >> 2)) - 1) & (
(((((0xfff)) >> 8) >> 4) >> 2))) ^ ((((((0xfff
)) >> 8) >> 4) >> 2)))) >> (1)) != 0)
? 1 : 0) : ((((u_long)((((((((((0xfff)) >> 8) >>
4))) - 1) & ((((((0xfff)) >> 8) >> 4)))) ^ (
(((((0xfff)) >> 8) >> 4))))) >> (1)) != 0) ?
1 : 0)) : ((((u_long)(((((((((0xfff)) >> 8))) - 1) &
(((((0xfff)) >> 8)))) ^ (((((0xfff)) >> 8))))) >>
(2)) != 0) ? 2 + ((((u_long)((((((((((0xfff)) >> 8)) >>
2)) - 1) & ((((((0xfff)) >> 8)) >> 2))) ^ ((
((((0xfff)) >> 8)) >> 2)))) >> (1)) != 0) ?
1 : 0) : ((((u_long)((((((((((0xfff)) >> 8)))) - 1) &
((((((0xfff)) >> 8))))) ^ ((((((0xfff)) >> 8))))
)) >> (1)) != 0) ? 1 : 0))) : ((((u_long)((((((((0xfff)
))) - 1) & ((((0xfff))))) ^ ((((0xfff)))))) >> (4))
!= 0) ? 4 + ((((u_long)(((((((((0xfff))) >> 4)) - 1) &
(((((0xfff))) >> 4))) ^ (((((0xfff))) >> 4)))) >>
(2)) != 0) ? 2 + ((((u_long)((((((((((0xfff))) >> 4) >>
2)) - 1) & ((((((0xfff))) >> 4) >> 2))) ^ ((
((((0xfff))) >> 4) >> 2)))) >> (1)) != 0) ?
1 : 0) : ((((u_long)((((((((((0xfff))) >> 4))) - 1) &
((((((0xfff))) >> 4)))) ^ ((((((0xfff))) >> 4)))
)) >> (1)) != 0) ? 1 : 0)) : ((((u_long)(((((((((0xfff)
)))) - 1) & (((((0xfff)))))) ^ (((((0xfff))))))) >>
(2)) != 0) ? 2 + ((((u_long)((((((((((0xfff)))) >> 2))
- 1) & ((((((0xfff)))) >> 2))) ^ ((((((0xfff)))) >>
2)))) >> (1)) != 0) ? 1 : 0) : ((((u_long)((((((((((0xfff
)))))) - 1) & ((((((0xfff))))))) ^ ((((((0xfff)))))))) >>
(1)) != 0) ? 1 : 0))))))
;
1169 if (len < IEEE80211_MIN_LEN(sizeof(struct ieee80211_frame_min) + 4)) {
1170 sc->sc_ic.ic_stats.is_rx_tooshort++;
1171 goto next;
1172 }
1173
1174 /* CRC is included with the packet; trim it off. */
1175 len -= IEEE80211_CRC_LEN4;
1176
1177 hwrate = MASK_AND_RSHIFT(hstat, RTW_RXSTAT_RATE_MASK)(((hstat) & (0xf00000)) >> ((((u_long)((((((0xf00000
)) - 1) & ((0xf00000))) ^ ((0xf00000)))) >> (16)) !=
0) ? 16 + ((((u_long)(((((((0xf00000) >> 16)) - 1) &
(((0xf00000) >> 16))) ^ (((0xf00000) >> 16)))) >>
(8)) != 0) ? 8 + ((((u_long)((((((((0xf00000) >> 16) >>
8)) - 1) & ((((0xf00000) >> 16) >> 8))) ^ ((
((0xf00000) >> 16) >> 8)))) >> (4)) != 0) ?
4 + ((((u_long)(((((((((0xf00000) >> 16) >> 8) >>
4)) - 1) & (((((0xf00000) >> 16) >> 8) >>
4))) ^ (((((0xf00000) >> 16) >> 8) >> 4)))
) >> (2)) != 0) ? 2 + ((((u_long)((((((((((0xf00000) >>
16) >> 8) >> 4) >> 2)) - 1) & ((((((0xf00000
) >> 16) >> 8) >> 4) >> 2))) ^ ((((((
0xf00000) >> 16) >> 8) >> 4) >> 2))))
>> (1)) != 0) ? 1 : 0) : ((((u_long)((((((((((0xf00000
) >> 16) >> 8) >> 4))) - 1) & ((((((0xf00000
) >> 16) >> 8) >> 4)))) ^ ((((((0xf00000) >>
16) >> 8) >> 4))))) >> (1)) != 0) ? 1 : 0)
) : ((((u_long)(((((((((0xf00000) >> 16) >> 8))) -
1) & (((((0xf00000) >> 16) >> 8)))) ^ (((((0xf00000
) >> 16) >> 8))))) >> (2)) != 0) ? 2 + ((((
u_long)((((((((((0xf00000) >> 16) >> 8)) >>
2)) - 1) & ((((((0xf00000) >> 16) >> 8)) >>
2))) ^ ((((((0xf00000) >> 16) >> 8)) >> 2)
))) >> (1)) != 0) ? 1 : 0) : ((((u_long)((((((((((0xf00000
) >> 16) >> 8)))) - 1) & ((((((0xf00000) >>
16) >> 8))))) ^ ((((((0xf00000) >> 16) >> 8
)))))) >> (1)) != 0) ? 1 : 0))) : ((((u_long)((((((((0xf00000
) >> 16))) - 1) & ((((0xf00000) >> 16)))) ^ (
(((0xf00000) >> 16))))) >> (4)) != 0) ? 4 + ((((u_long
)(((((((((0xf00000) >> 16)) >> 4)) - 1) & (((
((0xf00000) >> 16)) >> 4))) ^ (((((0xf00000) >>
16)) >> 4)))) >> (2)) != 0) ? 2 + ((((u_long)(((
(((((((0xf00000) >> 16)) >> 4) >> 2)) - 1) &
((((((0xf00000) >> 16)) >> 4) >> 2))) ^ ((
((((0xf00000) >> 16)) >> 4) >> 2)))) >>
(1)) != 0) ? 1 : 0) : ((((u_long)((((((((((0xf00000) >>
16)) >> 4))) - 1) & ((((((0xf00000) >> 16)) >>
4)))) ^ ((((((0xf00000) >> 16)) >> 4))))) >>
(1)) != 0) ? 1 : 0)) : ((((u_long)(((((((((0xf00000) >>
16)))) - 1) & (((((0xf00000) >> 16))))) ^ (((((0xf00000
) >> 16)))))) >> (2)) != 0) ? 2 + ((((u_long)((((
((((((0xf00000) >> 16))) >> 2)) - 1) & ((((((
0xf00000) >> 16))) >> 2))) ^ ((((((0xf00000) >>
16))) >> 2)))) >> (1)) != 0) ? 1 : 0) : ((((u_long
)((((((((((0xf00000) >> 16))))) - 1) & ((((((0xf00000
) >> 16)))))) ^ ((((((0xf00000) >> 16))))))) >>
(1)) != 0) ? 1 : 0)))) : ((((u_long)(((((((0xf00000))) - 1) &
(((0xf00000)))) ^ (((0xf00000))))) >> (8)) != 0) ? 8 +
((((u_long)((((((((0xf00000)) >> 8)) - 1) & ((((0xf00000
)) >> 8))) ^ ((((0xf00000)) >> 8)))) >> (4)
) != 0) ? 4 + ((((u_long)(((((((((0xf00000)) >> 8) >>
4)) - 1) & (((((0xf00000)) >> 8) >> 4))) ^ (
((((0xf00000)) >> 8) >> 4)))) >> (2)) != 0)
? 2 + ((((u_long)((((((((((0xf00000)) >> 8) >> 4
) >> 2)) - 1) & ((((((0xf00000)) >> 8) >>
4) >> 2))) ^ ((((((0xf00000)) >> 8) >> 4) >>
2)))) >> (1)) != 0) ? 1 : 0) : ((((u_long)((((((((((0xf00000
)) >> 8) >> 4))) - 1) & ((((((0xf00000)) >>
8) >> 4)))) ^ ((((((0xf00000)) >> 8) >> 4)
)))) >> (1)) != 0) ? 1 : 0)) : ((((u_long)(((((((((0xf00000
)) >> 8))) - 1) & (((((0xf00000)) >> 8)))) ^ (
((((0xf00000)) >> 8))))) >> (2)) != 0) ? 2 + ((((
u_long)((((((((((0xf00000)) >> 8)) >> 2)) - 1) &
((((((0xf00000)) >> 8)) >> 2))) ^ ((((((0xf00000
)) >> 8)) >> 2)))) >> (1)) != 0) ? 1 : 0) :
((((u_long)((((((((((0xf00000)) >> 8)))) - 1) & ((
((((0xf00000)) >> 8))))) ^ ((((((0xf00000)) >> 8)
))))) >> (1)) != 0) ? 1 : 0))) : ((((u_long)((((((((0xf00000
)))) - 1) & ((((0xf00000))))) ^ ((((0xf00000)))))) >>
(4)) != 0) ? 4 + ((((u_long)(((((((((0xf00000))) >> 4)
) - 1) & (((((0xf00000))) >> 4))) ^ (((((0xf00000))
) >> 4)))) >> (2)) != 0) ? 2 + ((((u_long)(((((((
(((0xf00000))) >> 4) >> 2)) - 1) & ((((((0xf00000
))) >> 4) >> 2))) ^ ((((((0xf00000))) >> 4)
>> 2)))) >> (1)) != 0) ? 1 : 0) : ((((u_long)(((
(((((((0xf00000))) >> 4))) - 1) & ((((((0xf00000)))
>> 4)))) ^ ((((((0xf00000))) >> 4))))) >> (
1)) != 0) ? 1 : 0)) : ((((u_long)(((((((((0xf00000))))) - 1) &
(((((0xf00000)))))) ^ (((((0xf00000))))))) >> (2)) != 0
) ? 2 + ((((u_long)((((((((((0xf00000)))) >> 2)) - 1) &
((((((0xf00000)))) >> 2))) ^ ((((((0xf00000)))) >>
2)))) >> (1)) != 0) ? 1 : 0) : ((((u_long)((((((((((0xf00000
)))))) - 1) & ((((((0xf00000))))))) ^ ((((((0xf00000)))))
))) >> (1)) != 0) ? 1 : 0))))))
;
1178 if (hwrate >= sizeof(ratetbl) / sizeof(ratetbl[0])) {
1179 printf("%s: unknown rate #%d\n", sc->sc_dev.dv_xname,
1180 MASK_AND_RSHIFT(hstat, RTW_RXSTAT_RATE_MASK)(((hstat) & (0xf00000)) >> ((((u_long)((((((0xf00000
)) - 1) & ((0xf00000))) ^ ((0xf00000)))) >> (16)) !=
0) ? 16 + ((((u_long)(((((((0xf00000) >> 16)) - 1) &
(((0xf00000) >> 16))) ^ (((0xf00000) >> 16)))) >>
(8)) != 0) ? 8 + ((((u_long)((((((((0xf00000) >> 16) >>
8)) - 1) & ((((0xf00000) >> 16) >> 8))) ^ ((
((0xf00000) >> 16) >> 8)))) >> (4)) != 0) ?
4 + ((((u_long)(((((((((0xf00000) >> 16) >> 8) >>
4)) - 1) & (((((0xf00000) >> 16) >> 8) >>
4))) ^ (((((0xf00000) >> 16) >> 8) >> 4)))
) >> (2)) != 0) ? 2 + ((((u_long)((((((((((0xf00000) >>
16) >> 8) >> 4) >> 2)) - 1) & ((((((0xf00000
) >> 16) >> 8) >> 4) >> 2))) ^ ((((((
0xf00000) >> 16) >> 8) >> 4) >> 2))))
>> (1)) != 0) ? 1 : 0) : ((((u_long)((((((((((0xf00000
) >> 16) >> 8) >> 4))) - 1) & ((((((0xf00000
) >> 16) >> 8) >> 4)))) ^ ((((((0xf00000) >>
16) >> 8) >> 4))))) >> (1)) != 0) ? 1 : 0)
) : ((((u_long)(((((((((0xf00000) >> 16) >> 8))) -
1) & (((((0xf00000) >> 16) >> 8)))) ^ (((((0xf00000
) >> 16) >> 8))))) >> (2)) != 0) ? 2 + ((((
u_long)((((((((((0xf00000) >> 16) >> 8)) >>
2)) - 1) & ((((((0xf00000) >> 16) >> 8)) >>
2))) ^ ((((((0xf00000) >> 16) >> 8)) >> 2)
))) >> (1)) != 0) ? 1 : 0) : ((((u_long)((((((((((0xf00000
) >> 16) >> 8)))) - 1) & ((((((0xf00000) >>
16) >> 8))))) ^ ((((((0xf00000) >> 16) >> 8
)))))) >> (1)) != 0) ? 1 : 0))) : ((((u_long)((((((((0xf00000
) >> 16))) - 1) & ((((0xf00000) >> 16)))) ^ (
(((0xf00000) >> 16))))) >> (4)) != 0) ? 4 + ((((u_long
)(((((((((0xf00000) >> 16)) >> 4)) - 1) & (((
((0xf00000) >> 16)) >> 4))) ^ (((((0xf00000) >>
16)) >> 4)))) >> (2)) != 0) ? 2 + ((((u_long)(((
(((((((0xf00000) >> 16)) >> 4) >> 2)) - 1) &
((((((0xf00000) >> 16)) >> 4) >> 2))) ^ ((
((((0xf00000) >> 16)) >> 4) >> 2)))) >>
(1)) != 0) ? 1 : 0) : ((((u_long)((((((((((0xf00000) >>
16)) >> 4))) - 1) & ((((((0xf00000) >> 16)) >>
4)))) ^ ((((((0xf00000) >> 16)) >> 4))))) >>
(1)) != 0) ? 1 : 0)) : ((((u_long)(((((((((0xf00000) >>
16)))) - 1) & (((((0xf00000) >> 16))))) ^ (((((0xf00000
) >> 16)))))) >> (2)) != 0) ? 2 + ((((u_long)((((
((((((0xf00000) >> 16))) >> 2)) - 1) & ((((((
0xf00000) >> 16))) >> 2))) ^ ((((((0xf00000) >>
16))) >> 2)))) >> (1)) != 0) ? 1 : 0) : ((((u_long
)((((((((((0xf00000) >> 16))))) - 1) & ((((((0xf00000
) >> 16)))))) ^ ((((((0xf00000) >> 16))))))) >>
(1)) != 0) ? 1 : 0)))) : ((((u_long)(((((((0xf00000))) - 1) &
(((0xf00000)))) ^ (((0xf00000))))) >> (8)) != 0) ? 8 +
((((u_long)((((((((0xf00000)) >> 8)) - 1) & ((((0xf00000
)) >> 8))) ^ ((((0xf00000)) >> 8)))) >> (4)
) != 0) ? 4 + ((((u_long)(((((((((0xf00000)) >> 8) >>
4)) - 1) & (((((0xf00000)) >> 8) >> 4))) ^ (
((((0xf00000)) >> 8) >> 4)))) >> (2)) != 0)
? 2 + ((((u_long)((((((((((0xf00000)) >> 8) >> 4
) >> 2)) - 1) & ((((((0xf00000)) >> 8) >>
4) >> 2))) ^ ((((((0xf00000)) >> 8) >> 4) >>
2)))) >> (1)) != 0) ? 1 : 0) : ((((u_long)((((((((((0xf00000
)) >> 8) >> 4))) - 1) & ((((((0xf00000)) >>
8) >> 4)))) ^ ((((((0xf00000)) >> 8) >> 4)
)))) >> (1)) != 0) ? 1 : 0)) : ((((u_long)(((((((((0xf00000
)) >> 8))) - 1) & (((((0xf00000)) >> 8)))) ^ (
((((0xf00000)) >> 8))))) >> (2)) != 0) ? 2 + ((((
u_long)((((((((((0xf00000)) >> 8)) >> 2)) - 1) &
((((((0xf00000)) >> 8)) >> 2))) ^ ((((((0xf00000
)) >> 8)) >> 2)))) >> (1)) != 0) ? 1 : 0) :
((((u_long)((((((((((0xf00000)) >> 8)))) - 1) & ((
((((0xf00000)) >> 8))))) ^ ((((((0xf00000)) >> 8)
))))) >> (1)) != 0) ? 1 : 0))) : ((((u_long)((((((((0xf00000
)))) - 1) & ((((0xf00000))))) ^ ((((0xf00000)))))) >>
(4)) != 0) ? 4 + ((((u_long)(((((((((0xf00000))) >> 4)
) - 1) & (((((0xf00000))) >> 4))) ^ (((((0xf00000))
) >> 4)))) >> (2)) != 0) ? 2 + ((((u_long)(((((((
(((0xf00000))) >> 4) >> 2)) - 1) & ((((((0xf00000
))) >> 4) >> 2))) ^ ((((((0xf00000))) >> 4)
>> 2)))) >> (1)) != 0) ? 1 : 0) : ((((u_long)(((
(((((((0xf00000))) >> 4))) - 1) & ((((((0xf00000)))
>> 4)))) ^ ((((((0xf00000))) >> 4))))) >> (
1)) != 0) ? 1 : 0)) : ((((u_long)(((((((((0xf00000))))) - 1) &
(((((0xf00000)))))) ^ (((((0xf00000))))))) >> (2)) != 0
) ? 2 + ((((u_long)((((((((((0xf00000)))) >> 2)) - 1) &
((((((0xf00000)))) >> 2))) ^ ((((((0xf00000)))) >>
2)))) >> (1)) != 0) ? 1 : 0) : ((((u_long)((((((((((0xf00000
)))))) - 1) & ((((((0xf00000))))))) ^ ((((((0xf00000)))))
))) >> (1)) != 0) ? 1 : 0))))))
);
1181 sc->sc_ifsc_ic.ic_ac.ac_if.if_ierrorsif_data.ifi_ierrors++;
1182 goto next;
1183 }
1184 rate = ratetbl[hwrate];
1185
1186#ifdef RTW_DEBUG
1187 RTW_DPRINTF(RTW_DEBUG_RECV_DESC,
1188 ("rate %d.%d Mb/s, time %08x%08x\n", (rate * 5) / 10,
1189 (rate * 5) % 10, htsfth, htsftl));
1190#endif /* RTW_DEBUG */
1191
1192 if ((hstat & RTW_RXSTAT_RES(1<<15)) != 0 &&
1193 sc->sc_ic.ic_opmode != IEEE80211_M_MONITOR)
1194 goto next;
1195
1196 /* if bad flags, skip descriptor */
1197 if ((hstat & RTW_RXSTAT_ONESEG((1<<29)|(1<<28))) != RTW_RXSTAT_ONESEG((1<<29)|(1<<28))) {
1198 printf("%s: too many rx segments\n",
1199 sc->sc_dev.dv_xname);
1200 goto next;
1201 }
1202
1203 bus_dmamap_sync(sc->sc_dmat, rs->rs_dmamap, 0,(*(sc->sc_dmat)->_dmamap_sync)((sc->sc_dmat), (rs->
rs_dmamap), (0), (rs->rs_dmamap->dm_mapsize), (0x02))
1204 rs->rs_dmamap->dm_mapsize, BUS_DMASYNC_POSTREAD)(*(sc->sc_dmat)->_dmamap_sync)((sc->sc_dmat), (rs->
rs_dmamap), (0), (rs->rs_dmamap->dm_mapsize), (0x02))
;
1205
1206 m = rs->rs_mbuf;
1207
1208 /* if temporarily out of memory, re-use mbuf */
1209 switch (rtw_rxsoft_alloc(sc->sc_dmat, rs)) {
1210 case 0:
1211 break;
1212 case ENOBUFS55:
1213 printf("%s: rtw_rxsoft_alloc(, %d) failed, "
1214 "dropping this packet\n", sc->sc_dev.dv_xname,
1215 next);
1216 goto next;
1217 default:
1218 /* XXX shorten rx ring, instead? */
1219 panic("%s: could not load DMA map",
1220 sc->sc_dev.dv_xname);
1221 }
1222
1223 if (sc->sc_rfchipid == RTW_RFCHIPID_PHILIPS0x03)
1224 rssi = MASK_AND_RSHIFT(hrssi, RTW_RXRSSI_RSSI)(((hrssi) & (0xff00)) >> ((((u_long)((((((0xff00)) -
1) & ((0xff00))) ^ ((0xff00)))) >> (16)) != 0) ? 16
+ ((((u_long)(((((((0xff00) >> 16)) - 1) & (((0xff00
) >> 16))) ^ (((0xff00) >> 16)))) >> (8)) !=
0) ? 8 + ((((u_long)((((((((0xff00) >> 16) >> 8)
) - 1) & ((((0xff00) >> 16) >> 8))) ^ ((((0xff00
) >> 16) >> 8)))) >> (4)) != 0) ? 4 + ((((u_long
)(((((((((0xff00) >> 16) >> 8) >> 4)) - 1) &
(((((0xff00) >> 16) >> 8) >> 4))) ^ (((((0xff00
) >> 16) >> 8) >> 4)))) >> (2)) != 0)
? 2 + ((((u_long)((((((((((0xff00) >> 16) >> 8) >>
4) >> 2)) - 1) & ((((((0xff00) >> 16) >>
8) >> 4) >> 2))) ^ ((((((0xff00) >> 16) >>
8) >> 4) >> 2)))) >> (1)) != 0) ? 1 : 0) :
((((u_long)((((((((((0xff00) >> 16) >> 8) >>
4))) - 1) & ((((((0xff00) >> 16) >> 8) >>
4)))) ^ ((((((0xff00) >> 16) >> 8) >> 4)))
)) >> (1)) != 0) ? 1 : 0)) : ((((u_long)(((((((((0xff00
) >> 16) >> 8))) - 1) & (((((0xff00) >>
16) >> 8)))) ^ (((((0xff00) >> 16) >> 8)))
)) >> (2)) != 0) ? 2 + ((((u_long)((((((((((0xff00) >>
16) >> 8)) >> 2)) - 1) & ((((((0xff00) >>
16) >> 8)) >> 2))) ^ ((((((0xff00) >> 16) >>
8)) >> 2)))) >> (1)) != 0) ? 1 : 0) : ((((u_long
)((((((((((0xff00) >> 16) >> 8)))) - 1) & (((
(((0xff00) >> 16) >> 8))))) ^ ((((((0xff00) >>
16) >> 8)))))) >> (1)) != 0) ? 1 : 0))) : ((((u_long
)((((((((0xff00) >> 16))) - 1) & ((((0xff00) >>
16)))) ^ ((((0xff00) >> 16))))) >> (4)) != 0) ? 4
+ ((((u_long)(((((((((0xff00) >> 16)) >> 4)) - 1
) & (((((0xff00) >> 16)) >> 4))) ^ (((((0xff00
) >> 16)) >> 4)))) >> (2)) != 0) ? 2 + ((((
u_long)((((((((((0xff00) >> 16)) >> 4) >> 2
)) - 1) & ((((((0xff00) >> 16)) >> 4) >>
2))) ^ ((((((0xff00) >> 16)) >> 4) >> 2)))
) >> (1)) != 0) ? 1 : 0) : ((((u_long)((((((((((0xff00)
>> 16)) >> 4))) - 1) & ((((((0xff00) >>
16)) >> 4)))) ^ ((((((0xff00) >> 16)) >> 4
))))) >> (1)) != 0) ? 1 : 0)) : ((((u_long)(((((((((0xff00
) >> 16)))) - 1) & (((((0xff00) >> 16))))) ^ (
((((0xff00) >> 16)))))) >> (2)) != 0) ? 2 + ((((u_long
)((((((((((0xff00) >> 16))) >> 2)) - 1) & (((
(((0xff00) >> 16))) >> 2))) ^ ((((((0xff00) >>
16))) >> 2)))) >> (1)) != 0) ? 1 : 0) : ((((u_long
)((((((((((0xff00) >> 16))))) - 1) & ((((((0xff00) >>
16)))))) ^ ((((((0xff00) >> 16))))))) >> (1)) !=
0) ? 1 : 0)))) : ((((u_long)(((((((0xff00))) - 1) & (((0xff00
)))) ^ (((0xff00))))) >> (8)) != 0) ? 8 + ((((u_long)((
((((((0xff00)) >> 8)) - 1) & ((((0xff00)) >> 8
))) ^ ((((0xff00)) >> 8)))) >> (4)) != 0) ? 4 + (
(((u_long)(((((((((0xff00)) >> 8) >> 4)) - 1) &
(((((0xff00)) >> 8) >> 4))) ^ (((((0xff00)) >>
8) >> 4)))) >> (2)) != 0) ? 2 + ((((u_long)(((((
(((((0xff00)) >> 8) >> 4) >> 2)) - 1) &
((((((0xff00)) >> 8) >> 4) >> 2))) ^ (((((
(0xff00)) >> 8) >> 4) >> 2)))) >> (1)
) != 0) ? 1 : 0) : ((((u_long)((((((((((0xff00)) >> 8) >>
4))) - 1) & ((((((0xff00)) >> 8) >> 4)))) ^ (
(((((0xff00)) >> 8) >> 4))))) >> (1)) != 0)
? 1 : 0)) : ((((u_long)(((((((((0xff00)) >> 8))) - 1) &
(((((0xff00)) >> 8)))) ^ (((((0xff00)) >> 8)))))
>> (2)) != 0) ? 2 + ((((u_long)((((((((((0xff00)) >>
8)) >> 2)) - 1) & ((((((0xff00)) >> 8)) >>
2))) ^ ((((((0xff00)) >> 8)) >> 2)))) >> (
1)) != 0) ? 1 : 0) : ((((u_long)((((((((((0xff00)) >> 8
)))) - 1) & ((((((0xff00)) >> 8))))) ^ ((((((0xff00
)) >> 8)))))) >> (1)) != 0) ? 1 : 0))) : ((((u_long
)((((((((0xff00)))) - 1) & ((((0xff00))))) ^ ((((0xff00))
)))) >> (4)) != 0) ? 4 + ((((u_long)(((((((((0xff00))) >>
4)) - 1) & (((((0xff00))) >> 4))) ^ (((((0xff00)))
>> 4)))) >> (2)) != 0) ? 2 + ((((u_long)((((((((
((0xff00))) >> 4) >> 2)) - 1) & ((((((0xff00)
)) >> 4) >> 2))) ^ ((((((0xff00))) >> 4) >>
2)))) >> (1)) != 0) ? 1 : 0) : ((((u_long)((((((((((0xff00
))) >> 4))) - 1) & ((((((0xff00))) >> 4)))) ^
((((((0xff00))) >> 4))))) >> (1)) != 0) ? 1 : 0)
) : ((((u_long)(((((((((0xff00))))) - 1) & (((((0xff00)))
))) ^ (((((0xff00))))))) >> (2)) != 0) ? 2 + ((((u_long
)((((((((((0xff00)))) >> 2)) - 1) & ((((((0xff00)))
) >> 2))) ^ ((((((0xff00)))) >> 2)))) >> (1
)) != 0) ? 1 : 0) : ((((u_long)((((((((((0xff00)))))) - 1) &
((((((0xff00))))))) ^ ((((((0xff00)))))))) >> (1)) != 0
) ? 1 : 0))))))
;
1225 else {
1226 rssi = MASK_AND_RSHIFT(hrssi, RTW_RXRSSI_IMR_RSSI)(((hrssi) & (0xfe00)) >> ((((u_long)((((((0xfe00)) -
1) & ((0xfe00))) ^ ((0xfe00)))) >> (16)) != 0) ? 16
+ ((((u_long)(((((((0xfe00) >> 16)) - 1) & (((0xfe00
) >> 16))) ^ (((0xfe00) >> 16)))) >> (8)) !=
0) ? 8 + ((((u_long)((((((((0xfe00) >> 16) >> 8)
) - 1) & ((((0xfe00) >> 16) >> 8))) ^ ((((0xfe00
) >> 16) >> 8)))) >> (4)) != 0) ? 4 + ((((u_long
)(((((((((0xfe00) >> 16) >> 8) >> 4)) - 1) &
(((((0xfe00) >> 16) >> 8) >> 4))) ^ (((((0xfe00
) >> 16) >> 8) >> 4)))) >> (2)) != 0)
? 2 + ((((u_long)((((((((((0xfe00) >> 16) >> 8) >>
4) >> 2)) - 1) & ((((((0xfe00) >> 16) >>
8) >> 4) >> 2))) ^ ((((((0xfe00) >> 16) >>
8) >> 4) >> 2)))) >> (1)) != 0) ? 1 : 0) :
((((u_long)((((((((((0xfe00) >> 16) >> 8) >>
4))) - 1) & ((((((0xfe00) >> 16) >> 8) >>
4)))) ^ ((((((0xfe00) >> 16) >> 8) >> 4)))
)) >> (1)) != 0) ? 1 : 0)) : ((((u_long)(((((((((0xfe00
) >> 16) >> 8))) - 1) & (((((0xfe00) >>
16) >> 8)))) ^ (((((0xfe00) >> 16) >> 8)))
)) >> (2)) != 0) ? 2 + ((((u_long)((((((((((0xfe00) >>
16) >> 8)) >> 2)) - 1) & ((((((0xfe00) >>
16) >> 8)) >> 2))) ^ ((((((0xfe00) >> 16) >>
8)) >> 2)))) >> (1)) != 0) ? 1 : 0) : ((((u_long
)((((((((((0xfe00) >> 16) >> 8)))) - 1) & (((
(((0xfe00) >> 16) >> 8))))) ^ ((((((0xfe00) >>
16) >> 8)))))) >> (1)) != 0) ? 1 : 0))) : ((((u_long
)((((((((0xfe00) >> 16))) - 1) & ((((0xfe00) >>
16)))) ^ ((((0xfe00) >> 16))))) >> (4)) != 0) ? 4
+ ((((u_long)(((((((((0xfe00) >> 16)) >> 4)) - 1
) & (((((0xfe00) >> 16)) >> 4))) ^ (((((0xfe00
) >> 16)) >> 4)))) >> (2)) != 0) ? 2 + ((((
u_long)((((((((((0xfe00) >> 16)) >> 4) >> 2
)) - 1) & ((((((0xfe00) >> 16)) >> 4) >>
2))) ^ ((((((0xfe00) >> 16)) >> 4) >> 2)))
) >> (1)) != 0) ? 1 : 0) : ((((u_long)((((((((((0xfe00)
>> 16)) >> 4))) - 1) & ((((((0xfe00) >>
16)) >> 4)))) ^ ((((((0xfe00) >> 16)) >> 4
))))) >> (1)) != 0) ? 1 : 0)) : ((((u_long)(((((((((0xfe00
) >> 16)))) - 1) & (((((0xfe00) >> 16))))) ^ (
((((0xfe00) >> 16)))))) >> (2)) != 0) ? 2 + ((((u_long
)((((((((((0xfe00) >> 16))) >> 2)) - 1) & (((
(((0xfe00) >> 16))) >> 2))) ^ ((((((0xfe00) >>
16))) >> 2)))) >> (1)) != 0) ? 1 : 0) : ((((u_long
)((((((((((0xfe00) >> 16))))) - 1) & ((((((0xfe00) >>
16)))))) ^ ((((((0xfe00) >> 16))))))) >> (1)) !=
0) ? 1 : 0)))) : ((((u_long)(((((((0xfe00))) - 1) & (((0xfe00
)))) ^ (((0xfe00))))) >> (8)) != 0) ? 8 + ((((u_long)((
((((((0xfe00)) >> 8)) - 1) & ((((0xfe00)) >> 8
))) ^ ((((0xfe00)) >> 8)))) >> (4)) != 0) ? 4 + (
(((u_long)(((((((((0xfe00)) >> 8) >> 4)) - 1) &
(((((0xfe00)) >> 8) >> 4))) ^ (((((0xfe00)) >>
8) >> 4)))) >> (2)) != 0) ? 2 + ((((u_long)(((((
(((((0xfe00)) >> 8) >> 4) >> 2)) - 1) &
((((((0xfe00)) >> 8) >> 4) >> 2))) ^ (((((
(0xfe00)) >> 8) >> 4) >> 2)))) >> (1)
) != 0) ? 1 : 0) : ((((u_long)((((((((((0xfe00)) >> 8) >>
4))) - 1) & ((((((0xfe00)) >> 8) >> 4)))) ^ (
(((((0xfe00)) >> 8) >> 4))))) >> (1)) != 0)
? 1 : 0)) : ((((u_long)(((((((((0xfe00)) >> 8))) - 1) &
(((((0xfe00)) >> 8)))) ^ (((((0xfe00)) >> 8)))))
>> (2)) != 0) ? 2 + ((((u_long)((((((((((0xfe00)) >>
8)) >> 2)) - 1) & ((((((0xfe00)) >> 8)) >>
2))) ^ ((((((0xfe00)) >> 8)) >> 2)))) >> (
1)) != 0) ? 1 : 0) : ((((u_long)((((((((((0xfe00)) >> 8
)))) - 1) & ((((((0xfe00)) >> 8))))) ^ ((((((0xfe00
)) >> 8)))))) >> (1)) != 0) ? 1 : 0))) : ((((u_long
)((((((((0xfe00)))) - 1) & ((((0xfe00))))) ^ ((((0xfe00))
)))) >> (4)) != 0) ? 4 + ((((u_long)(((((((((0xfe00))) >>
4)) - 1) & (((((0xfe00))) >> 4))) ^ (((((0xfe00)))
>> 4)))) >> (2)) != 0) ? 2 + ((((u_long)((((((((
((0xfe00))) >> 4) >> 2)) - 1) & ((((((0xfe00)
)) >> 4) >> 2))) ^ ((((((0xfe00))) >> 4) >>
2)))) >> (1)) != 0) ? 1 : 0) : ((((u_long)((((((((((0xfe00
))) >> 4))) - 1) & ((((((0xfe00))) >> 4)))) ^
((((((0xfe00))) >> 4))))) >> (1)) != 0) ? 1 : 0)
) : ((((u_long)(((((((((0xfe00))))) - 1) & (((((0xfe00)))
))) ^ (((((0xfe00))))))) >> (2)) != 0) ? 2 + ((((u_long
)((((((((((0xfe00)))) >> 2)) - 1) & ((((((0xfe00)))
) >> 2))) ^ ((((((0xfe00)))) >> 2)))) >> (1
)) != 0) ? 1 : 0) : ((((u_long)((((((((((0xfe00)))))) - 1) &
((((((0xfe00))))))) ^ ((((((0xfe00)))))))) >> (1)) != 0
) ? 1 : 0))))))
;
1227 /* TBD find out each front-end's LNA gain in the
1228 * front-end's units
1229 */
1230 if ((hrssi & RTW_RXRSSI_IMR_LNA(1<<8)) == 0)
1231 rssi |= 0x80;
1232 }
1233
1234 sq = MASK_AND_RSHIFT(hrssi, RTW_RXRSSI_SQ)(((hrssi) & (0xff)) >> ((((u_long)((((((0xff)) - 1)
& ((0xff))) ^ ((0xff)))) >> (16)) != 0) ? 16 + (((
(u_long)(((((((0xff) >> 16)) - 1) & (((0xff) >>
16))) ^ (((0xff) >> 16)))) >> (8)) != 0) ? 8 + (
(((u_long)((((((((0xff) >> 16) >> 8)) - 1) & (
(((0xff) >> 16) >> 8))) ^ ((((0xff) >> 16) >>
8)))) >> (4)) != 0) ? 4 + ((((u_long)(((((((((0xff) >>
16) >> 8) >> 4)) - 1) & (((((0xff) >> 16
) >> 8) >> 4))) ^ (((((0xff) >> 16) >>
8) >> 4)))) >> (2)) != 0) ? 2 + ((((u_long)(((((
(((((0xff) >> 16) >> 8) >> 4) >> 2)) -
1) & ((((((0xff) >> 16) >> 8) >> 4) >>
2))) ^ ((((((0xff) >> 16) >> 8) >> 4) >>
2)))) >> (1)) != 0) ? 1 : 0) : ((((u_long)((((((((((0xff
) >> 16) >> 8) >> 4))) - 1) & ((((((0xff
) >> 16) >> 8) >> 4)))) ^ ((((((0xff) >>
16) >> 8) >> 4))))) >> (1)) != 0) ? 1 : 0)
) : ((((u_long)(((((((((0xff) >> 16) >> 8))) - 1)
& (((((0xff) >> 16) >> 8)))) ^ (((((0xff) >>
16) >> 8))))) >> (2)) != 0) ? 2 + ((((u_long)(((
(((((((0xff) >> 16) >> 8)) >> 2)) - 1) &
((((((0xff) >> 16) >> 8)) >> 2))) ^ ((((((
0xff) >> 16) >> 8)) >> 2)))) >> (1)) !=
0) ? 1 : 0) : ((((u_long)((((((((((0xff) >> 16) >>
8)))) - 1) & ((((((0xff) >> 16) >> 8))))) ^ (
(((((0xff) >> 16) >> 8)))))) >> (1)) != 0) ?
1 : 0))) : ((((u_long)((((((((0xff) >> 16))) - 1) &
((((0xff) >> 16)))) ^ ((((0xff) >> 16))))) >>
(4)) != 0) ? 4 + ((((u_long)(((((((((0xff) >> 16)) >>
4)) - 1) & (((((0xff) >> 16)) >> 4))) ^ ((((
(0xff) >> 16)) >> 4)))) >> (2)) != 0) ? 2 +
((((u_long)((((((((((0xff) >> 16)) >> 4) >>
2)) - 1) & ((((((0xff) >> 16)) >> 4) >>
2))) ^ ((((((0xff) >> 16)) >> 4) >> 2)))) >>
(1)) != 0) ? 1 : 0) : ((((u_long)((((((((((0xff) >> 16
)) >> 4))) - 1) & ((((((0xff) >> 16)) >>
4)))) ^ ((((((0xff) >> 16)) >> 4))))) >> (
1)) != 0) ? 1 : 0)) : ((((u_long)(((((((((0xff) >> 16))
)) - 1) & (((((0xff) >> 16))))) ^ (((((0xff) >>
16)))))) >> (2)) != 0) ? 2 + ((((u_long)((((((((((0xff
) >> 16))) >> 2)) - 1) & ((((((0xff) >>
16))) >> 2))) ^ ((((((0xff) >> 16))) >> 2)
))) >> (1)) != 0) ? 1 : 0) : ((((u_long)((((((((((0xff)
>> 16))))) - 1) & ((((((0xff) >> 16)))))) ^ (
(((((0xff) >> 16))))))) >> (1)) != 0) ? 1 : 0))))
: ((((u_long)(((((((0xff))) - 1) & (((0xff)))) ^ (((0xff
))))) >> (8)) != 0) ? 8 + ((((u_long)((((((((0xff)) >>
8)) - 1) & ((((0xff)) >> 8))) ^ ((((0xff)) >>
8)))) >> (4)) != 0) ? 4 + ((((u_long)(((((((((0xff)) >>
8) >> 4)) - 1) & (((((0xff)) >> 8) >> 4
))) ^ (((((0xff)) >> 8) >> 4)))) >> (2)) !=
0) ? 2 + ((((u_long)((((((((((0xff)) >> 8) >> 4)
>> 2)) - 1) & ((((((0xff)) >> 8) >> 4)
>> 2))) ^ ((((((0xff)) >> 8) >> 4) >>
2)))) >> (1)) != 0) ? 1 : 0) : ((((u_long)((((((((((0xff
)) >> 8) >> 4))) - 1) & ((((((0xff)) >>
8) >> 4)))) ^ ((((((0xff)) >> 8) >> 4)))))
>> (1)) != 0) ? 1 : 0)) : ((((u_long)(((((((((0xff)) >>
8))) - 1) & (((((0xff)) >> 8)))) ^ (((((0xff)) >>
8))))) >> (2)) != 0) ? 2 + ((((u_long)((((((((((0xff))
>> 8)) >> 2)) - 1) & ((((((0xff)) >> 8
)) >> 2))) ^ ((((((0xff)) >> 8)) >> 2)))) >>
(1)) != 0) ? 1 : 0) : ((((u_long)((((((((((0xff)) >> 8
)))) - 1) & ((((((0xff)) >> 8))))) ^ ((((((0xff)) >>
8)))))) >> (1)) != 0) ? 1 : 0))) : ((((u_long)((((((((
0xff)))) - 1) & ((((0xff))))) ^ ((((0xff)))))) >> (
4)) != 0) ? 4 + ((((u_long)(((((((((0xff))) >> 4)) - 1)
& (((((0xff))) >> 4))) ^ (((((0xff))) >> 4))
)) >> (2)) != 0) ? 2 + ((((u_long)((((((((((0xff))) >>
4) >> 2)) - 1) & ((((((0xff))) >> 4) >>
2))) ^ ((((((0xff))) >> 4) >> 2)))) >> (1)
) != 0) ? 1 : 0) : ((((u_long)((((((((((0xff))) >> 4)))
- 1) & ((((((0xff))) >> 4)))) ^ ((((((0xff))) >>
4))))) >> (1)) != 0) ? 1 : 0)) : ((((u_long)(((((((((0xff
))))) - 1) & (((((0xff)))))) ^ (((((0xff))))))) >> (
2)) != 0) ? 2 + ((((u_long)((((((((((0xff)))) >> 2)) - 1
) & ((((((0xff)))) >> 2))) ^ ((((((0xff)))) >>
2)))) >> (1)) != 0) ? 1 : 0) : ((((u_long)((((((((((0xff
)))))) - 1) & ((((((0xff))))))) ^ ((((((0xff)))))))) >>
(1)) != 0) ? 1 : 0))))))
;
1235
1236 /*
1237 * Note well: now we cannot recycle the rs_mbuf unless
1238 * we restore its original length.
1239 */
1240 m->m_pkthdrM_dat.MH.MH_pkthdr.len = m->m_lenm_hdr.mh_len = len;
1241
1242 wh = mtod(m, struct ieee80211_frame *)((struct ieee80211_frame *)((m)->m_hdr.mh_data));
1243
1244 if (!IS_BEACON(wh->i_fc[0]))
1245 sc->sc_led_state.ls_event |= RTW_LED_S_RX0x1;
1246 /* TBD use _MAR, _BAR, _PAR flags as hints to _find_rxnode? */
1247 ni = ieee80211_find_rxnode(&sc->sc_ic, wh);
1248
1249 sc->sc_tsfth = htsfth;
1250
1251#ifdef RTW_DEBUG
1252 if ((sc->sc_ifsc_ic.ic_ac.ac_if.if_flags & (IFF_DEBUG0x4|IFF_LINK20x4000)) ==
1253 (IFF_DEBUG0x4|IFF_LINK20x4000)) {
1254 ieee80211_dump_pkt(mtod(m, uint8_t *)((uint8_t *)((m)->m_hdr.mh_data)), m->m_pkthdrM_dat.MH.MH_pkthdr.len,
1255 rate, rssi);
1256 }
1257#endif /* RTW_DEBUG */
1258
1259#if NBPFILTER1 > 0
1260 if (sc->sc_radiobpf != NULL((void *)0)) {
1261 struct mbuf mb;
1262 struct ieee80211com *ic = &sc->sc_ic;
1263 struct rtw_rx_radiotap_header *rr = &sc->sc_rxtapsc_rxtapu.tap;
1264
1265 rr->rr_tsft =
1266 htole64(((uint64_t)htsfth << 32) | htsftl)((__uint64_t)(((uint64_t)htsfth << 32) | htsftl));
1267
1268 rr->rr_flags = 0;
1269 if ((hstat & RTW_RXSTAT_SPLCP(1<<25)) != 0)
1270 rr->rr_flags |= IEEE80211_RADIOTAP_F_SHORTPRE0x02;
1271
1272 rr->rr_rate = rate;
1273 rr->rr_chan_freq =
1274 htole16(ic->ic_bss->ni_chan->ic_freq)((__uint16_t)(ic->ic_bss->ni_chan->ic_freq));
1275 rr->rr_chan_flags =
1276 htole16(ic->ic_bss->ni_chan->ic_flags)((__uint16_t)(ic->ic_bss->ni_chan->ic_flags));
1277 rr->rr_antsignal = rssi;
1278 rr->rr_barker_lock = htole16(sq)((__uint16_t)(sq));
1279
1280 mb.m_datam_hdr.mh_data = (caddr_t)rr;
1281 mb.m_lenm_hdr.mh_len = sizeof(sc->sc_rxtapu);
1282 mb.m_nextm_hdr.mh_next = m;
1283 mb.m_nextpktm_hdr.mh_nextpkt = NULL((void *)0);
1284 mb.m_typem_hdr.mh_type = 0;
1285 mb.m_flagsm_hdr.mh_flags = 0;
1286 bpf_mtap(sc->sc_radiobpf, &mb, BPF_DIRECTION_IN(1 << 0));
1287 }
1288#endif /* NBPFILTER > 0 */
1289
1290 memset(&rxi, 0, sizeof(rxi))__builtin_memset((&rxi), (0), (sizeof(rxi)));
1291 rxi.rxi_rssi = rssi;
1292 rxi.rxi_tstamp = htsftl;
1293 ieee80211_inputm(&sc->sc_ifsc_ic.ic_ac.ac_if, m, ni, &rxi, &ml);
1294 ieee80211_release_node(&sc->sc_ic, ni);
1295next:
1296 rtw_rxdesc_init(rdb, rs, next, 0);
1297 }
1298 if_input(&sc->sc_ifsc_ic.ic_ac.ac_if, &ml);
1299 rdb->rdb_next = next;
1300
1301 KASSERT(rdb->rdb_next < rdb->rdb_ndesc)((rdb->rdb_next < rdb->rdb_ndesc) ? (void)0 : __assert
("diagnostic ", "/usr/src/sys/dev/ic/rtw.c", 1301, "rdb->rdb_next < rdb->rdb_ndesc"
))
;
1302
1303 return;
1304#undef IS_BEACON
1305}
1306
1307void
1308rtw_txsoft_release(bus_dma_tag_t dmat, struct ieee80211com *ic,
1309 struct rtw_txsoft *ts)
1310{
1311 struct mbuf *m;
1312 struct ieee80211_node *ni;
1313
1314 m = ts->ts_mbuf;
1315 ni = ts->ts_ni;
1316 KASSERT(m != NULL)((m != ((void *)0)) ? (void)0 : __assert("diagnostic ", "/usr/src/sys/dev/ic/rtw.c"
, 1316, "m != NULL"))
;
1317 KASSERT(ni != NULL)((ni != ((void *)0)) ? (void)0 : __assert("diagnostic ", "/usr/src/sys/dev/ic/rtw.c"
, 1317, "ni != NULL"))
;
1318 ts->ts_mbuf = NULL((void *)0);
1319 ts->ts_ni = NULL((void *)0);
1320
1321 bus_dmamap_sync(dmat, ts->ts_dmamap, 0, ts->ts_dmamap->dm_mapsize,(*(dmat)->_dmamap_sync)((dmat), (ts->ts_dmamap), (0), (
ts->ts_dmamap->dm_mapsize), (0x08))
1322 BUS_DMASYNC_POSTWRITE)(*(dmat)->_dmamap_sync)((dmat), (ts->ts_dmamap), (0), (
ts->ts_dmamap->dm_mapsize), (0x08))
;
1323 bus_dmamap_unload(dmat, ts->ts_dmamap)(*(dmat)->_dmamap_unload)((dmat), (ts->ts_dmamap));
1324 m_freem(m);
1325 ieee80211_release_node(ic, ni);
1326}
1327
1328void
1329rtw_txsofts_release(bus_dma_tag_t dmat, struct ieee80211com *ic,
1330 struct rtw_txsoft_blk *tsb)
1331{
1332 struct rtw_txsoft *ts;
1333
1334 while ((ts = SIMPLEQ_FIRST(&tsb->tsb_dirtyq)((&tsb->tsb_dirtyq)->sqh_first)) != NULL((void *)0)) {
1335 rtw_txsoft_release(dmat, ic, ts);
1336 SIMPLEQ_REMOVE_HEAD(&tsb->tsb_dirtyq, ts_q)do { if (((&tsb->tsb_dirtyq)->sqh_first = (&tsb
->tsb_dirtyq)->sqh_first->ts_q.sqe_next) == ((void *
)0)) (&tsb->tsb_dirtyq)->sqh_last = &(&tsb->
tsb_dirtyq)->sqh_first; } while (0)
;
1337 SIMPLEQ_INSERT_TAIL(&tsb->tsb_freeq, ts, ts_q)do { (ts)->ts_q.sqe_next = ((void *)0); *(&tsb->tsb_freeq
)->sqh_last = (ts); (&tsb->tsb_freeq)->sqh_last =
&(ts)->ts_q.sqe_next; } while (0)
;
1338 }
1339 tsb->tsb_tx_timer = 0;
1340}
1341
1342void
1343rtw_collect_txpkt(struct rtw_softc *sc, struct rtw_txdesc_blk *tdb,
1344 struct rtw_txsoft *ts, int ndesc)
1345{
1346 uint32_t hstat;
1347 int data_retry, rts_retry;
1348 struct rtw_txdesc *tdn;
1349 const char *condstring;
1350
1351 rtw_txsoft_release(sc->sc_dmat, &sc->sc_ic, ts);
1352
1353 tdb->tdb_nfree += ndesc;
1354
1355 tdn = &tdb->tdb_desc[ts->ts_last];
1356
1357 hstat = letoh32(tdn->td_stat)((__uint32_t)(tdn->td_ctl0));
1358 rts_retry = MASK_AND_RSHIFT(hstat, RTW_TXSTAT_RTSRETRY_MASK)(((hstat) & (0x7f00)) >> ((((u_long)((((((0x7f00)) -
1) & ((0x7f00))) ^ ((0x7f00)))) >> (16)) != 0) ? 16
+ ((((u_long)(((((((0x7f00) >> 16)) - 1) & (((0x7f00
) >> 16))) ^ (((0x7f00) >> 16)))) >> (8)) !=
0) ? 8 + ((((u_long)((((((((0x7f00) >> 16) >> 8)
) - 1) & ((((0x7f00) >> 16) >> 8))) ^ ((((0x7f00
) >> 16) >> 8)))) >> (4)) != 0) ? 4 + ((((u_long
)(((((((((0x7f00) >> 16) >> 8) >> 4)) - 1) &
(((((0x7f00) >> 16) >> 8) >> 4))) ^ (((((0x7f00
) >> 16) >> 8) >> 4)))) >> (2)) != 0)
? 2 + ((((u_long)((((((((((0x7f00) >> 16) >> 8) >>
4) >> 2)) - 1) & ((((((0x7f00) >> 16) >>
8) >> 4) >> 2))) ^ ((((((0x7f00) >> 16) >>
8) >> 4) >> 2)))) >> (1)) != 0) ? 1 : 0) :
((((u_long)((((((((((0x7f00) >> 16) >> 8) >>
4))) - 1) & ((((((0x7f00) >> 16) >> 8) >>
4)))) ^ ((((((0x7f00) >> 16) >> 8) >> 4)))
)) >> (1)) != 0) ? 1 : 0)) : ((((u_long)(((((((((0x7f00
) >> 16) >> 8))) - 1) & (((((0x7f00) >>
16) >> 8)))) ^ (((((0x7f00) >> 16) >> 8)))
)) >> (2)) != 0) ? 2 + ((((u_long)((((((((((0x7f00) >>
16) >> 8)) >> 2)) - 1) & ((((((0x7f00) >>
16) >> 8)) >> 2))) ^ ((((((0x7f00) >> 16) >>
8)) >> 2)))) >> (1)) != 0) ? 1 : 0) : ((((u_long
)((((((((((0x7f00) >> 16) >> 8)))) - 1) & (((
(((0x7f00) >> 16) >> 8))))) ^ ((((((0x7f00) >>
16) >> 8)))))) >> (1)) != 0) ? 1 : 0))) : ((((u_long
)((((((((0x7f00) >> 16))) - 1) & ((((0x7f00) >>
16)))) ^ ((((0x7f00) >> 16))))) >> (4)) != 0) ? 4
+ ((((u_long)(((((((((0x7f00) >> 16)) >> 4)) - 1
) & (((((0x7f00) >> 16)) >> 4))) ^ (((((0x7f00
) >> 16)) >> 4)))) >> (2)) != 0) ? 2 + ((((
u_long)((((((((((0x7f00) >> 16)) >> 4) >> 2
)) - 1) & ((((((0x7f00) >> 16)) >> 4) >>
2))) ^ ((((((0x7f00) >> 16)) >> 4) >> 2)))
) >> (1)) != 0) ? 1 : 0) : ((((u_long)((((((((((0x7f00)
>> 16)) >> 4))) - 1) & ((((((0x7f00) >>
16)) >> 4)))) ^ ((((((0x7f00) >> 16)) >> 4
))))) >> (1)) != 0) ? 1 : 0)) : ((((u_long)(((((((((0x7f00
) >> 16)))) - 1) & (((((0x7f00) >> 16))))) ^ (
((((0x7f00) >> 16)))))) >> (2)) != 0) ? 2 + ((((u_long
)((((((((((0x7f00) >> 16))) >> 2)) - 1) & (((
(((0x7f00) >> 16))) >> 2))) ^ ((((((0x7f00) >>
16))) >> 2)))) >> (1)) != 0) ? 1 : 0) : ((((u_long
)((((((((((0x7f00) >> 16))))) - 1) & ((((((0x7f00) >>
16)))))) ^ ((((((0x7f00) >> 16))))))) >> (1)) !=
0) ? 1 : 0)))) : ((((u_long)(((((((0x7f00))) - 1) & (((0x7f00
)))) ^ (((0x7f00))))) >> (8)) != 0) ? 8 + ((((u_long)((
((((((0x7f00)) >> 8)) - 1) & ((((0x7f00)) >> 8
))) ^ ((((0x7f00)) >> 8)))) >> (4)) != 0) ? 4 + (
(((u_long)(((((((((0x7f00)) >> 8) >> 4)) - 1) &
(((((0x7f00)) >> 8) >> 4))) ^ (((((0x7f00)) >>
8) >> 4)))) >> (2)) != 0) ? 2 + ((((u_long)(((((
(((((0x7f00)) >> 8) >> 4) >> 2)) - 1) &
((((((0x7f00)) >> 8) >> 4) >> 2))) ^ (((((
(0x7f00)) >> 8) >> 4) >> 2)))) >> (1)
) != 0) ? 1 : 0) : ((((u_long)((((((((((0x7f00)) >> 8) >>
4))) - 1) & ((((((0x7f00)) >> 8) >> 4)))) ^ (
(((((0x7f00)) >> 8) >> 4))))) >> (1)) != 0)
? 1 : 0)) : ((((u_long)(((((((((0x7f00)) >> 8))) - 1) &
(((((0x7f00)) >> 8)))) ^ (((((0x7f00)) >> 8)))))
>> (2)) != 0) ? 2 + ((((u_long)((((((((((0x7f00)) >>
8)) >> 2)) - 1) & ((((((0x7f00)) >> 8)) >>
2))) ^ ((((((0x7f00)) >> 8)) >> 2)))) >> (
1)) != 0) ? 1 : 0) : ((((u_long)((((((((((0x7f00)) >> 8
)))) - 1) & ((((((0x7f00)) >> 8))))) ^ ((((((0x7f00
)) >> 8)))))) >> (1)) != 0) ? 1 : 0))) : ((((u_long
)((((((((0x7f00)))) - 1) & ((((0x7f00))))) ^ ((((0x7f00))
)))) >> (4)) != 0) ? 4 + ((((u_long)(((((((((0x7f00))) >>
4)) - 1) & (((((0x7f00))) >> 4))) ^ (((((0x7f00)))
>> 4)))) >> (2)) != 0) ? 2 + ((((u_long)((((((((
((0x7f00))) >> 4) >> 2)) - 1) & ((((((0x7f00)
)) >> 4) >> 2))) ^ ((((((0x7f00))) >> 4) >>
2)))) >> (1)) != 0) ? 1 : 0) : ((((u_long)((((((((((0x7f00
))) >> 4))) - 1) & ((((((0x7f00))) >> 4)))) ^
((((((0x7f00))) >> 4))))) >> (1)) != 0) ? 1 : 0)
) : ((((u_long)(((((((((0x7f00))))) - 1) & (((((0x7f00)))
))) ^ (((((0x7f00))))))) >> (2)) != 0) ? 2 + ((((u_long
)((((((((((0x7f00)))) >> 2)) - 1) & ((((((0x7f00)))
) >> 2))) ^ ((((((0x7f00)))) >> 2)))) >> (1
)) != 0) ? 1 : 0) : ((((u_long)((((((((((0x7f00)))))) - 1) &
((((((0x7f00))))))) ^ ((((((0x7f00)))))))) >> (1)) != 0
) ? 1 : 0))))))
;
1359 data_retry = MASK_AND_RSHIFT(hstat, RTW_TXSTAT_DRC_MASK)(((hstat) & (0xff)) >> ((((u_long)((((((0xff)) - 1)
& ((0xff))) ^ ((0xff)))) >> (16)) != 0) ? 16 + (((
(u_long)(((((((0xff) >> 16)) - 1) & (((0xff) >>
16))) ^ (((0xff) >> 16)))) >> (8)) != 0) ? 8 + (
(((u_long)((((((((0xff) >> 16) >> 8)) - 1) & (
(((0xff) >> 16) >> 8))) ^ ((((0xff) >> 16) >>
8)))) >> (4)) != 0) ? 4 + ((((u_long)(((((((((0xff) >>
16) >> 8) >> 4)) - 1) & (((((0xff) >> 16
) >> 8) >> 4))) ^ (((((0xff) >> 16) >>
8) >> 4)))) >> (2)) != 0) ? 2 + ((((u_long)(((((
(((((0xff) >> 16) >> 8) >> 4) >> 2)) -
1) & ((((((0xff) >> 16) >> 8) >> 4) >>
2))) ^ ((((((0xff) >> 16) >> 8) >> 4) >>
2)))) >> (1)) != 0) ? 1 : 0) : ((((u_long)((((((((((0xff
) >> 16) >> 8) >> 4))) - 1) & ((((((0xff
) >> 16) >> 8) >> 4)))) ^ ((((((0xff) >>
16) >> 8) >> 4))))) >> (1)) != 0) ? 1 : 0)
) : ((((u_long)(((((((((0xff) >> 16) >> 8))) - 1)
& (((((0xff) >> 16) >> 8)))) ^ (((((0xff) >>
16) >> 8))))) >> (2)) != 0) ? 2 + ((((u_long)(((
(((((((0xff) >> 16) >> 8)) >> 2)) - 1) &
((((((0xff) >> 16) >> 8)) >> 2))) ^ ((((((
0xff) >> 16) >> 8)) >> 2)))) >> (1)) !=
0) ? 1 : 0) : ((((u_long)((((((((((0xff) >> 16) >>
8)))) - 1) & ((((((0xff) >> 16) >> 8))))) ^ (
(((((0xff) >> 16) >> 8)))))) >> (1)) != 0) ?
1 : 0))) : ((((u_long)((((((((0xff) >> 16))) - 1) &
((((0xff) >> 16)))) ^ ((((0xff) >> 16))))) >>
(4)) != 0) ? 4 + ((((u_long)(((((((((0xff) >> 16)) >>
4)) - 1) & (((((0xff) >> 16)) >> 4))) ^ ((((
(0xff) >> 16)) >> 4)))) >> (2)) != 0) ? 2 +
((((u_long)((((((((((0xff) >> 16)) >> 4) >>
2)) - 1) & ((((((0xff) >> 16)) >> 4) >>
2))) ^ ((((((0xff) >> 16)) >> 4) >> 2)))) >>
(1)) != 0) ? 1 : 0) : ((((u_long)((((((((((0xff) >> 16
)) >> 4))) - 1) & ((((((0xff) >> 16)) >>
4)))) ^ ((((((0xff) >> 16)) >> 4))))) >> (
1)) != 0) ? 1 : 0)) : ((((u_long)(((((((((0xff) >> 16))
)) - 1) & (((((0xff) >> 16))))) ^ (((((0xff) >>
16)))))) >> (2)) != 0) ? 2 + ((((u_long)((((((((((0xff
) >> 16))) >> 2)) - 1) & ((((((0xff) >>
16))) >> 2))) ^ ((((((0xff) >> 16))) >> 2)
))) >> (1)) != 0) ? 1 : 0) : ((((u_long)((((((((((0xff)
>> 16))))) - 1) & ((((((0xff) >> 16)))))) ^ (
(((((0xff) >> 16))))))) >> (1)) != 0) ? 1 : 0))))
: ((((u_long)(((((((0xff))) - 1) & (((0xff)))) ^ (((0xff
))))) >> (8)) != 0) ? 8 + ((((u_long)((((((((0xff)) >>
8)) - 1) & ((((0xff)) >> 8))) ^ ((((0xff)) >>
8)))) >> (4)) != 0) ? 4 + ((((u_long)(((((((((0xff)) >>
8) >> 4)) - 1) & (((((0xff)) >> 8) >> 4
))) ^ (((((0xff)) >> 8) >> 4)))) >> (2)) !=
0) ? 2 + ((((u_long)((((((((((0xff)) >> 8) >> 4)
>> 2)) - 1) & ((((((0xff)) >> 8) >> 4)
>> 2))) ^ ((((((0xff)) >> 8) >> 4) >>
2)))) >> (1)) != 0) ? 1 : 0) : ((((u_long)((((((((((0xff
)) >> 8) >> 4))) - 1) & ((((((0xff)) >>
8) >> 4)))) ^ ((((((0xff)) >> 8) >> 4)))))
>> (1)) != 0) ? 1 : 0)) : ((((u_long)(((((((((0xff)) >>
8))) - 1) & (((((0xff)) >> 8)))) ^ (((((0xff)) >>
8))))) >> (2)) != 0) ? 2 + ((((u_long)((((((((((0xff))
>> 8)) >> 2)) - 1) & ((((((0xff)) >> 8
)) >> 2))) ^ ((((((0xff)) >> 8)) >> 2)))) >>
(1)) != 0) ? 1 : 0) : ((((u_long)((((((((((0xff)) >> 8
)))) - 1) & ((((((0xff)) >> 8))))) ^ ((((((0xff)) >>
8)))))) >> (1)) != 0) ? 1 : 0))) : ((((u_long)((((((((
0xff)))) - 1) & ((((0xff))))) ^ ((((0xff)))))) >> (
4)) != 0) ? 4 + ((((u_long)(((((((((0xff))) >> 4)) - 1)
& (((((0xff))) >> 4))) ^ (((((0xff))) >> 4))
)) >> (2)) != 0) ? 2 + ((((u_long)((((((((((0xff))) >>
4) >> 2)) - 1) & ((((((0xff))) >> 4) >>
2))) ^ ((((((0xff))) >> 4) >> 2)))) >> (1)
) != 0) ? 1 : 0) : ((((u_long)((((((((((0xff))) >> 4)))
- 1) & ((((((0xff))) >> 4)))) ^ ((((((0xff))) >>
4))))) >> (1)) != 0) ? 1 : 0)) : ((((u_long)(((((((((0xff
))))) - 1) & (((((0xff)))))) ^ (((((0xff))))))) >> (
2)) != 0) ? 2 + ((((u_long)((((((((((0xff)))) >> 2)) - 1
) & ((((((0xff)))) >> 2))) ^ ((((((0xff)))) >>
2)))) >> (1)) != 0) ? 1 : 0) : ((((u_long)((((((((((0xff
)))))) - 1) & ((((((0xff))))))) ^ ((((((0xff)))))))) >>
(1)) != 0) ? 1 : 0))))))
;
1360
1361 sc->sc_ifsc_ic.ic_ac.ac_if.if_collisionsif_data.ifi_collisions += rts_retry + data_retry;
1362
1363 if ((hstat & RTW_TXSTAT_TOK(1<<15)) != 0)
1364 condstring = "ok";
1365 else {
1366 sc->sc_ifsc_ic.ic_ac.ac_if.if_oerrorsif_data.ifi_oerrors++;
1367 condstring = "error";
1368 }
1369
1370 DPRINTF(sc, RTW_DEBUG_XMIT_DESC,
1371 ("%s: ts %p txdesc[%d, %d] %s tries rts %u data %u\n",
1372 sc->sc_dev.dv_xname, ts, ts->ts_first, ts->ts_last,
1373 condstring, rts_retry, data_retry));
1374}
1375
1376void
1377rtw_reset_oactive(struct rtw_softc *sc)
1378{
1379 int oactive;
1380 int pri;
1381 struct rtw_txsoft_blk *tsb;
1382 struct rtw_txdesc_blk *tdb;
1383 oactive = ifq_is_oactive(&sc->sc_ifsc_ic.ic_ac.ac_if.if_snd);
1384 for (pri = 0; pri < RTW_NTXPRI4; pri++) {
1385 tsb = &sc->sc_txsoft_blk[pri];
1386 tdb = &sc->sc_txdesc_blk[pri];
1387 if (!SIMPLEQ_EMPTY(&tsb->tsb_freeq)(((&tsb->tsb_freeq)->sqh_first) == ((void *)0)) && tdb->tdb_nfree > 0)
1388 ifq_set_oactive(&sc->sc_ifsc_ic.ic_ac.ac_if.if_snd);
1389 }
1390 if (oactive != ifq_is_oactive(&sc->sc_ifsc_ic.ic_ac.ac_if.if_snd)) {
1391 DPRINTF(sc, RTW_DEBUG_OACTIVE,
1392 ("%s: reset OACTIVE\n", __func__));
1393 }
1394}
1395
1396/* Collect transmitted packets. */
1397void
1398rtw_collect_txring(struct rtw_softc *sc, struct rtw_txsoft_blk *tsb,
1399 struct rtw_txdesc_blk *tdb, int force)
1400{
1401 int ndesc;
1402 struct rtw_txsoft *ts;
1403
1404 while ((ts = SIMPLEQ_FIRST(&tsb->tsb_dirtyq)((&tsb->tsb_dirtyq)->sqh_first)) != NULL((void *)0)) {
1405 ndesc = 1 + ts->ts_last - ts->ts_first;
1406 if (ts->ts_last < ts->ts_first)
1407 ndesc += tdb->tdb_ndesc;
1408
1409 KASSERT(ndesc > 0)((ndesc > 0) ? (void)0 : __assert("diagnostic ", "/usr/src/sys/dev/ic/rtw.c"
, 1409, "ndesc > 0"))
;
1410
1411 rtw_txdescs_sync(tdb, ts->ts_first, ndesc,
1412 BUS_DMASYNC_POSTREAD0x02|BUS_DMASYNC_POSTWRITE0x08);
1413
1414 if (force) {
1415 int i;
1416 for (i = ts->ts_first; ; i = RTW_NEXT_IDX(tdb, i)(((i) + 1) % (tdb)->tdb_ndesc)) {
1417 tdb->tdb_desc[i].td_stattd_ctl0 &=
1418 ~htole32(RTW_TXSTAT_OWN)((__uint32_t)((1<<31)));
1419 if (i == ts->ts_last)
1420 break;
1421 }
1422 rtw_txdescs_sync(tdb, ts->ts_first, ndesc,
1423 BUS_DMASYNC_PREREAD0x01|BUS_DMASYNC_PREWRITE0x04);
1424 } else if ((tdb->tdb_desc[ts->ts_last].td_stattd_ctl0 &
1425 htole32(RTW_TXSTAT_OWN)((__uint32_t)((1<<31)))) != 0)
1426 break;
1427
1428 rtw_collect_txpkt(sc, tdb, ts, ndesc);
1429 SIMPLEQ_REMOVE_HEAD(&tsb->tsb_dirtyq, ts_q)do { if (((&tsb->tsb_dirtyq)->sqh_first = (&tsb
->tsb_dirtyq)->sqh_first->ts_q.sqe_next) == ((void *
)0)) (&tsb->tsb_dirtyq)->sqh_last = &(&tsb->
tsb_dirtyq)->sqh_first; } while (0)
;
1430 SIMPLEQ_INSERT_TAIL(&tsb->tsb_freeq, ts, ts_q)do { (ts)->ts_q.sqe_next = ((void *)0); *(&tsb->tsb_freeq
)->sqh_last = (ts); (&tsb->tsb_freeq)->sqh_last =
&(ts)->ts_q.sqe_next; } while (0)
;
1431 }
1432 /* no more pending transmissions, cancel watchdog */
1433 if (ts == NULL((void *)0))
1434 tsb->tsb_tx_timer = 0;
1435 rtw_reset_oactive(sc);
1436}
1437
1438void
1439rtw_intr_tx(struct rtw_softc *sc, u_int16_t isr)
1440{
1441 int pri;
1442 struct rtw_txsoft_blk *tsb;
1443 struct rtw_txdesc_blk *tdb;
1444
1445 for (pri = 0; pri < RTW_NTXPRI4; pri++) {
1446 tsb = &sc->sc_txsoft_blk[pri];
1447 tdb = &sc->sc_txdesc_blk[pri];
1448
1449 rtw_collect_txring(sc, tsb, tdb, 0);
1450
1451 }
1452
1453 if ((isr & RTW_INTR_TX((1<<3)|(1<<2)|(1<<9)| (1<<8)|(1<<
7)|(1<<6)| (1<<11)|(1<<10))
) != 0)
1454 rtw_start(&sc->sc_ifsc_ic.ic_ac.ac_if);
1455}
1456
1457#ifndef IEEE80211_STA_ONLY
1458void
1459rtw_intr_beacon(struct rtw_softc *sc, u_int16_t isr)
1460{
1461 u_int next;
1462 uint32_t tsfth, tsftl;
1463 struct ieee80211com *ic;
1464 struct rtw_txdesc_blk *tdb = &sc->sc_txdesc_blk[RTW_TXPRIBCN3];
1465 struct rtw_txsoft_blk *tsb = &sc->sc_txsoft_blk[RTW_TXPRIBCN3];
1466 struct mbuf *m;
1467
1468 tsfth = RTW_READ(&sc->sc_regs, RTW_TSFTRH)((*(&sc->sc_regs)->r_read32)(&sc->sc_regs, 0x1c
))
;
1469 tsftl = RTW_READ(&sc->sc_regs, RTW_TSFTRL)((*(&sc->sc_regs)->r_read32)(&sc->sc_regs, 0x18
))
;
1470
1471 if ((isr & (RTW_INTR_TBDOK(1<<10)|RTW_INTR_TBDER(1<<11))) != 0) {
1472 next = rtw_txring_next(&sc->sc_regs, tdb);
1473 RTW_DPRINTF(RTW_DEBUG_BEACON,
1474 ("%s: beacon ring %sprocessed, isr = %#04hx"
1475 ", next %u expected %u, %llu\n", __func__,
1476 (next == tdb->tdb_next) ? "" : "un", isr, next,
1477 tdb->tdb_next, (uint64_t)tsfth << 32 | tsftl));
1478 if ((RTW_READ8(&sc->sc_regs, RTW_TPPOLL)((*(&sc->sc_regs)->r_read8)(&sc->sc_regs, 0xd9
))
& RTW_TPPOLL_BQ(1<<7)) == 0){
1479 rtw_collect_txring(sc, tsb, tdb, 1);
1480 tdb->tdb_next = 0;
1481 }
1482 }
1483 /* Start beacon transmission. */
1484
1485 if ((isr & RTW_INTR_BCNINT(1<<13)) != 0 &&
1486 sc->sc_ic.ic_state == IEEE80211_S_RUN &&
1487 SIMPLEQ_EMPTY(&tsb->tsb_dirtyq)(((&tsb->tsb_dirtyq)->sqh_first) == ((void *)0))) {
1488 RTW_DPRINTF(RTW_DEBUG_BEACON,
1489 ("%s: beacon prep. time, isr = %#04hx"
1490 ", %16llu\n", __func__, isr,
1491 (uint64_t)tsfth << 32 | tsftl));
1492 ic = &sc->sc_ic;
1493 if ((m = ieee80211_beacon_alloc(ic, ic->ic_bss)) != NULL((void *)0)) {
1494 RTW_DPRINTF(RTW_DEBUG_BEACON,
1495 ("%s: m %p len %u\n", __func__, m, m->m_len));
1496 }
1497
1498 if (m == NULL((void *)0)) {
1499 printf("%s: could not allocate beacon\n",
1500 sc->sc_dev.dv_xname);
1501 return;
1502 }
1503 m->m_pkthdrM_dat.MH.MH_pkthdr.ph_cookie = ieee80211_ref_node(ic->ic_bss);
1504 mq_enqueue(&sc->sc_beaconq, m);
1505 rtw_start(&sc->sc_ifsc_ic.ic_ac.ac_if);
1506 }
1507}
1508
1509void
1510rtw_intr_atim(struct rtw_softc *sc)
1511{
1512 /* TBD */
1513 return;
1514}
1515#endif /* IEEE80211_STA_ONLY */
1516
1517#ifdef RTW_DEBUG
1518void
1519rtw_dump_rings(struct rtw_softc *sc)
1520{
1521 struct rtw_txdesc_blk *tdb;
1522 struct rtw_rxdesc *rd;
1523 struct rtw_rxdesc_blk *rdb;
1524 int desc, pri;
1525
1526 if ((rtw_debug & RTW_DEBUG_IO_KICK) == 0)
1527 return;
1528
1529 for (pri = 0; pri < RTW_NTXPRI4; pri++) {
1530 tdb = &sc->sc_txdesc_blk[pri];
1531 printf("%s: txpri %d ndesc %d nfree %d\n", __func__, pri,
1532 tdb->tdb_ndesc, tdb->tdb_nfree);
1533 for (desc = 0; desc < tdb->tdb_ndesc; desc++)
1534 rtw_print_txdesc(sc, ".", NULL((void *)0), tdb, desc);
1535 }
1536
1537 rdb = &sc->sc_rxdesc_blk;
1538
1539 for (desc = 0; desc < RTW_RXQLEN64; desc++) {
1540 rd = &rdb->rdb_desc[desc];
1541 printf("%s: %sctl %08x rsvd0/rssi %08x buf/tsftl %08x "
1542 "rsvd1/tsfth %08x\n", __func__,
1543 (desc >= rdb->rdb_ndesc) ? "UNUSED " : "",
1544 letoh32(rd->rd_ctl)((__uint32_t)(rd->rd_ctl)), letoh32(rd->rd_rssi)((__uint32_t)(rd->rd_rsvd0)),
1545 letoh32(rd->rd_buf)((__uint32_t)(rd->rd_buf)), letoh32(rd->rd_tsfth)((__uint32_t)(rd->rd_rsvd1)));
1546 }
1547}
1548#endif /* RTW_DEBUG */
1549
1550void
1551rtw_hwring_setup(struct rtw_softc *sc)
1552{
1553 int pri;
1554 struct rtw_regs *regs = &sc->sc_regs;
1555 struct rtw_txdesc_blk *tdb;
1556
1557 sc->sc_txdesc_blk[RTW_TXPRILO0].tdb_basereg = RTW_TLPDA0x20;
1558 sc->sc_txdesc_blk[RTW_TXPRILO0].tdb_base = RTW_RING_BASE(sc, hd_txlo)((sc)->sc_desc_dmamap->dm_segs[0].ds_addr + __builtin_offsetof
(struct rtw_descs, hd_txlo[0]))
;
1559 sc->sc_txdesc_blk[RTW_TXPRIMD1].tdb_basereg = RTW_TNPDA0x24;
1560 sc->sc_txdesc_blk[RTW_TXPRIMD1].tdb_base = RTW_RING_BASE(sc, hd_txmd)((sc)->sc_desc_dmamap->dm_segs[0].ds_addr + __builtin_offsetof
(struct rtw_descs, hd_txmd[0]))
;
1561 sc->sc_txdesc_blk[RTW_TXPRIHI2].tdb_basereg = RTW_THPDA0x28;
1562 sc->sc_txdesc_blk[RTW_TXPRIHI2].tdb_base = RTW_RING_BASE(sc, hd_txhi)((sc)->sc_desc_dmamap->dm_segs[0].ds_addr + __builtin_offsetof
(struct rtw_descs, hd_txhi[0]))
;
1563 sc->sc_txdesc_blk[RTW_TXPRIBCN3].tdb_basereg = RTW_TBDA0x4c;
1564 sc->sc_txdesc_blk[RTW_TXPRIBCN3].tdb_base = RTW_RING_BASE(sc, hd_bcn)((sc)->sc_desc_dmamap->dm_segs[0].ds_addr + __builtin_offsetof
(struct rtw_descs, hd_bcn[0]))
;
1565
1566 for (pri = 0; pri < RTW_NTXPRI4; pri++) {
1567 tdb = &sc->sc_txdesc_blk[pri];
1568 RTW_WRITE(regs, tdb->tdb_basereg, tdb->tdb_base)((*(regs)->r_write32)(regs, tdb->tdb_basereg, tdb->tdb_base
))
;
1569 RTW_DPRINTF(RTW_DEBUG_XMIT_DESC,
1570 ("%s: reg[tdb->tdb_basereg] <- %lx\n", __func__,
1571 (u_int *)tdb->tdb_base));
1572 }
1573
1574 RTW_WRITE(regs, RTW_RDSAR, RTW_RING_BASE(sc, hd_rx))((*(regs)->r_write32)(regs, 0xe4, ((sc)->sc_desc_dmamap
->dm_segs[0].ds_addr + __builtin_offsetof(struct rtw_descs
, hd_rx[0]))))
;
1575
1576 RTW_DPRINTF(RTW_DEBUG_RECV_DESC,
1577 ("%s: reg[RDSAR] <- %lx\n", __func__,
1578 (u_int *)RTW_RING_BASE(sc, hd_rx)));
1579
1580 RTW_SYNC(regs, RTW_TLPDA, RTW_RDSAR)((*(regs)->r_barrier)(regs, 0x20, 0xe4, (0x01|0x02)));
1581}
1582
1583int
1584rtw_swring_setup(struct rtw_softc *sc)
1585{
1586 int rc, pri;
1587 struct rtw_rxdesc_blk *rdb;
1588 struct rtw_txdesc_blk *tdb;
1589
1590 rtw_txdesc_blk_init_all(&sc->sc_txdesc_blk[0]);
1591
1592 rtw_txsoft_blk_init_all(&sc->sc_txsoft_blk[0]);
1593
1594 rdb = &sc->sc_rxdesc_blk;
1595 if ((rc = rtw_rxsoft_init_all(sc->sc_dmat, sc->sc_rxsoft,
1596 &rdb->rdb_ndesc, sc->sc_dev.dv_xname)) != 0 &&
1597 rdb->rdb_ndesc == 0) {
1598 printf("%s: could not allocate rx buffers\n",
1599 sc->sc_dev.dv_xname);
1600 return rc;
1601 }
1602
1603 rdb = &sc->sc_rxdesc_blk;
1604 rtw_rxdescs_sync(rdb, 0, rdb->rdb_ndesc,
1605 BUS_DMASYNC_POSTREAD0x02|BUS_DMASYNC_POSTWRITE0x08);
1606 rtw_rxdesc_init_all(rdb, sc->sc_rxsoft, 1);
1607 rdb->rdb_next = 0;
1608
1609 tdb = &sc->sc_txdesc_blk[0];
1610 for (pri = 0; pri < RTW_NTXPRI4; pri++) {
1611 rtw_txdescs_sync(&tdb[pri], 0, tdb[pri].tdb_ndesc,
1612 BUS_DMASYNC_PREREAD0x01|BUS_DMASYNC_PREWRITE0x04);
1613 }
1614 return 0;
1615}
1616
1617void
1618rtw_txdesc_blk_init(struct rtw_txdesc_blk *tdb)
1619{
1620 int i;
1621
1622 bzero(tdb->tdb_desc, sizeof(tdb->tdb_desc[0]) * tdb->tdb_ndesc)__builtin_bzero((tdb->tdb_desc), (sizeof(tdb->tdb_desc[
0]) * tdb->tdb_ndesc))
;
1623 for (i = 0; i < tdb->tdb_ndesc; i++)
1624 tdb->tdb_desc[i].td_next = htole32(RTW_NEXT_DESC(tdb, i))((__uint32_t)(((tdb)->tdb_physbase + sizeof(struct rtw_txdesc
) * ((((i)) + 1) % ((tdb))->tdb_ndesc))))
;
1625}
1626
1627u_int
1628rtw_txring_next(struct rtw_regs *regs, struct rtw_txdesc_blk *tdb)
1629{
1630 return (letoh32(RTW_READ(regs, tdb->tdb_basereg))((__uint32_t)(((*(regs)->r_read32)(regs, tdb->tdb_basereg
))))
- tdb->tdb_base) /
1631 sizeof(struct rtw_txdesc);
1632}
1633
1634void
1635rtw_txring_fixup(struct rtw_softc *sc)
1636{
1637 int pri;
1638 u_int next;
1639 struct rtw_txdesc_blk *tdb;
1640 struct rtw_regs *regs = &sc->sc_regs;
1641
1642 for (pri = 0; pri < RTW_NTXPRI4; pri++) {
1643 tdb = &sc->sc_txdesc_blk[pri];
1644 next = rtw_txring_next(regs, tdb);
1645 if (tdb->tdb_next == next)
1646 continue;
1647 RTW_DPRINTF(RTW_DEBUG_BUGS,
1648 ("%s: tx-ring %d expected next %u, read %u\n", __func__,
1649 pri, tdb->tdb_next, next));
1650 tdb->tdb_next = MIN(next, tdb->tdb_ndesc - 1)(((next)<(tdb->tdb_ndesc - 1))?(next):(tdb->tdb_ndesc
- 1))
;
1651 }
1652}
1653
1654void
1655rtw_rxring_fixup(struct rtw_softc *sc)
1656{
1657 u_int next;
1658 uint32_t rdsar;
1659 struct rtw_rxdesc_blk *rdb;
1660
1661 rdsar = letoh32(RTW_READ(&sc->sc_regs, RTW_RDSAR))((__uint32_t)(((*(&sc->sc_regs)->r_read32)(&sc->
sc_regs, 0xe4))))
;
1662 next = (rdsar - RTW_RING_BASE(sc, hd_rx)((sc)->sc_desc_dmamap->dm_segs[0].ds_addr + __builtin_offsetof
(struct rtw_descs, hd_rx[0]))
) / sizeof(struct rtw_rxdesc);
1663
1664 rdb = &sc->sc_rxdesc_blk;
1665 if (rdb->rdb_next != next) {
1666 RTW_DPRINTF(RTW_DEBUG_BUGS,
1667 ("%s: rx-ring expected next %u, read %u\n", __func__,
1668 rdb->rdb_next, next));
1669 rdb->rdb_next = MIN(next, rdb->rdb_ndesc - 1)(((next)<(rdb->rdb_ndesc - 1))?(next):(rdb->rdb_ndesc
- 1))
;
1670 }
1671}
1672
1673void
1674rtw_txdescs_reset(struct rtw_softc *sc)
1675{
1676 int pri;
1677
1678 for (pri = 0; pri < RTW_NTXPRI4; pri++) {
1679 rtw_collect_txring(sc, &sc->sc_txsoft_blk[pri],
1680 &sc->sc_txdesc_blk[pri], 1);
1681 }
1682}
1683
1684void
1685rtw_intr_ioerror(struct rtw_softc *sc, u_int16_t isr)
1686{
1687 uint8_t cr = 0;
1688 int xmtr = 0, rcvr = 0;
1689 struct rtw_regs *regs = &sc->sc_regs;
1690
1691 if ((isr & RTW_INTR_TXFOVW(1<<15)) != 0) {
1692 RTW_DPRINTF(RTW_DEBUG_BUGS,
1693 ("%s: tx fifo underflow\n", sc->sc_dev.dv_xname));
1694 rcvr = xmtr = 1;
1695 cr |= RTW_CR_TE(1<<2) | RTW_CR_RE(1<<3);
1696 }
1697
1698 if ((isr & (RTW_INTR_RDU(1<<4)|RTW_INTR_RXFOVW(1<<5))) != 0) {
1699 cr |= RTW_CR_RE(1<<3);
1700 rcvr = 1;
1701 }
1702
1703 RTW_DPRINTF(RTW_DEBUG_BUGS, ("%s: restarting xmit/recv, isr %hx"
1704 "\n", sc->sc_dev.dv_xname, isr));
1705
1706#ifdef RTW_DEBUG
1707 rtw_dump_rings(sc);
1708#endif /* RTW_DEBUG */
1709
1710 rtw_io_enable(regs, cr, 0);
1711
1712 /* Collect rx'd packets. Refresh rx buffers. */
1713 if (rcvr)
1714 rtw_intr_rx(sc, 0);
1715 /* Collect tx'd packets. XXX let's hope this stops the transmit
1716 * timeouts.
1717 */
1718 if (xmtr)
1719 rtw_txdescs_reset(sc);
1720
1721 RTW_WRITE16(regs, RTW_IMR, 0)((*(regs)->r_write16)(regs, 0x3c, 0));
1722 RTW_SYNC(regs, RTW_IMR, RTW_IMR)((*(regs)->r_barrier)(regs, 0x3c, 0x3c, (0x01|0x02)));
1723
1724 if (rtw_do_chip_reset) {
1725 rtw_chip_reset1(regs, sc->sc_dev.dv_xname);
1726 }
1727
1728 rtw_rxdesc_init_all(&sc->sc_rxdesc_blk, &sc->sc_rxsoft[0], 1);
1729
1730#ifdef RTW_DEBUG
1731 rtw_dump_rings(sc);
1732#endif /* RTW_DEBUG */
1733
1734 RTW_WRITE16(regs, RTW_IMR, sc->sc_inten)((*(regs)->r_write16)(regs, 0x3c, sc->sc_inten));
1735 RTW_SYNC(regs, RTW_IMR, RTW_IMR)((*(regs)->r_barrier)(regs, 0x3c, 0x3c, (0x01|0x02)));
1736 if (rcvr)
1737 rtw_rxring_fixup(sc);
1738 rtw_io_enable(regs, cr, 1);
1739 if (xmtr)
1740 rtw_txring_fixup(sc);
1741}
1742
1743void
1744rtw_suspend_ticks(struct rtw_softc *sc)
1745{
1746 RTW_DPRINTF(RTW_DEBUG_TIMEOUT,
1747 ("%s: suspending ticks\n", sc->sc_dev.dv_xname));
1748 sc->sc_do_tick = 0;
1749}
1750
1751void
1752rtw_resume_ticks(struct rtw_softc *sc)
1753{
1754 u_int32_t tsftrl0, tsftrl1, next_tick;
1755
1756 tsftrl0 = RTW_READ(&sc->sc_regs, RTW_TSFTRL)((*(&sc->sc_regs)->r_read32)(&sc->sc_regs, 0x18
))
;
1757
1758 tsftrl1 = RTW_READ(&sc->sc_regs, RTW_TSFTRL)((*(&sc->sc_regs)->r_read32)(&sc->sc_regs, 0x18
))
;
1759 next_tick = tsftrl1 + 1000000;
1760 RTW_WRITE(&sc->sc_regs, RTW_TINT, next_tick)((*(&sc->sc_regs)->r_write32)(&sc->sc_regs, 0x48
, next_tick))
;
1761
1762 sc->sc_do_tick = 1;
1763
1764 RTW_DPRINTF(RTW_DEBUG_TIMEOUT,
1765 ("%s: resume ticks delta %#08x now %#08x next %#08x\n",
1766 sc->sc_dev.dv_xname, tsftrl1 - tsftrl0, tsftrl1, next_tick));
1767}
1768
1769void
1770rtw_intr_timeout(struct rtw_softc *sc)
1771{
1772 RTW_DPRINTF(RTW_DEBUG_TIMEOUT, ("%s: timeout\n", sc->sc_dev.dv_xname));
1773 if (sc->sc_do_tick)
1774 rtw_resume_ticks(sc);
1775 return;
1776}
1777
1778int
1779rtw_intr(void *arg)
1780{
1781 int i;
1782 struct rtw_softc *sc = arg;
1783 struct rtw_regs *regs = &sc->sc_regs;
1784 u_int16_t isr;
1785
1786 /*
1787 * If the interface isn't running, the interrupt couldn't
1788 * possibly have come from us.
1789 */
1790 if ((sc->sc_flags & RTW_F_ENABLED0x00000001) == 0 ||
1791 (sc->sc_ifsc_ic.ic_ac.ac_if.if_flags & IFF_RUNNING0x40) == 0 ||
1792 (sc->sc_dev.dv_flags & DVF_ACTIVE0x0001) == 0) {
1793 RTW_DPRINTF(RTW_DEBUG_INTR, ("%s: stray interrupt\n",
1794 sc->sc_dev.dv_xname));
1795 return (0);
1796 }
1797
1798 for (i = 0; i < 10; i++) {
1799 isr = RTW_READ16(regs, RTW_ISR)((*(regs)->r_read16)(regs, 0x3e));
1800
1801 RTW_WRITE16(regs, RTW_ISR, isr)((*(regs)->r_write16)(regs, 0x3e, isr));
1802 RTW_WBR(regs, RTW_ISR, RTW_ISR)((*(regs)->r_barrier)(regs, 0x3e, 0x3e, 0x02));
1803
1804 if (sc->sc_intr_ack != NULL((void *)0))
1805 (*sc->sc_intr_ack)(regs);
1806
1807 if (isr == 0)
1808 break;
1809
1810#ifdef RTW_DEBUG
1811#define PRINTINTR(flag) do { \
1812 if ((isr & flag) != 0) { \
1813 printf("%s" #flag, delim); \
1814 delim = ","; \
1815 } \
1816} while (0)
1817
1818 if ((rtw_debug & RTW_DEBUG_INTR) != 0 && isr != 0) {
1819 const char *delim = "<";
1820
1821 printf("%s: reg[ISR] = %x", sc->sc_dev.dv_xname, isr);
1822
1823 PRINTINTR(RTW_INTR_TXFOVW(1<<15));
1824 PRINTINTR(RTW_INTR_TIMEOUT(1<<14));
1825 PRINTINTR(RTW_INTR_BCNINT(1<<13));
1826 PRINTINTR(RTW_INTR_ATIMINT(1<<12));
1827 PRINTINTR(RTW_INTR_TBDER(1<<11));
1828 PRINTINTR(RTW_INTR_TBDOK(1<<10));
1829 PRINTINTR(RTW_INTR_THPDER(1<<9));
1830 PRINTINTR(RTW_INTR_THPDOK(1<<8));
1831 PRINTINTR(RTW_INTR_TNPDER(1<<7));
1832 PRINTINTR(RTW_INTR_TNPDOK(1<<6));
1833 PRINTINTR(RTW_INTR_RXFOVW(1<<5));
1834 PRINTINTR(RTW_INTR_RDU(1<<4));
1835 PRINTINTR(RTW_INTR_TLPDER(1<<3));
1836 PRINTINTR(RTW_INTR_TLPDOK(1<<2));
1837 PRINTINTR(RTW_INTR_RER(1<<1));
1838 PRINTINTR(RTW_INTR_ROK(1<<0));
1839
1840 printf(">\n");
1841 }
1842#undef PRINTINTR
1843#endif /* RTW_DEBUG */
1844
1845 if ((isr & RTW_INTR_RX((1<<1)|(1<<0))) != 0)
1846 rtw_intr_rx(sc, isr & RTW_INTR_RX((1<<1)|(1<<0)));
1847 if ((isr & RTW_INTR_TX((1<<3)|(1<<2)|(1<<9)| (1<<8)|(1<<
7)|(1<<6)| (1<<11)|(1<<10))
) != 0)
1848 rtw_intr_tx(sc, isr & RTW_INTR_TX((1<<3)|(1<<2)|(1<<9)| (1<<8)|(1<<
7)|(1<<6)| (1<<11)|(1<<10))
);
1849#ifndef IEEE80211_STA_ONLY
1850 if ((isr & RTW_INTR_BEACON((1<<13)|(1<<11)|(1<<10))) != 0)
1851 rtw_intr_beacon(sc, isr & RTW_INTR_BEACON((1<<13)|(1<<11)|(1<<10)));
1852 if ((isr & RTW_INTR_ATIMINT(1<<12)) != 0)
1853 rtw_intr_atim(sc);
1854#endif
1855 if ((isr & RTW_INTR_IOERROR((1<<15)|(1<<5)|(1<<4))) != 0)
1856 rtw_intr_ioerror(sc, isr & RTW_INTR_IOERROR((1<<15)|(1<<5)|(1<<4)));
1857 if ((isr & RTW_INTR_TIMEOUT(1<<14)) != 0)
1858 rtw_intr_timeout(sc);
1859 }
1860
1861 return 1;
1862}
1863
1864/* Must be called at splnet. */
1865void
1866rtw_stop(struct ifnet *ifp, int disable)
1867{
1868 int pri;
1869 struct rtw_softc *sc = (struct rtw_softc *)ifp->if_softc;
1870 struct ieee80211com *ic = &sc->sc_ic;
1871 struct rtw_regs *regs = &sc->sc_regs;
1872
1873 if ((sc->sc_flags & RTW_F_ENABLED0x00000001) == 0)
1874 return;
1875
1876 rtw_suspend_ticks(sc);
1877
1878 ieee80211_new_state(ic, IEEE80211_S_INIT, -1)(((ic)->ic_newstate)((ic), (IEEE80211_S_INIT), (-1)));
1879
1880 if ((sc->sc_flags & RTW_F_INVALID0x00000080) == 0) {
1881 /* Disable interrupts. */
1882 RTW_WRITE16(regs, RTW_IMR, 0)((*(regs)->r_write16)(regs, 0x3c, 0));
1883
1884 RTW_WBW(regs, RTW_TPPOLL, RTW_IMR)((*(regs)->r_barrier)(regs, 0xd9, 0x3c, 0x02));
1885
1886 /* Stop the transmit and receive processes. First stop DMA,
1887 * then disable receiver and transmitter.
1888 */
1889 RTW_WRITE8(regs, RTW_TPPOLL, RTW_TPPOLL_SALL)((*(regs)->r_write8)(regs, 0xd9, ((1<<3) | (1<<
2) | (1<<1) | (1<<0))))
;
1890
1891 RTW_SYNC(regs, RTW_TPPOLL, RTW_IMR)((*(regs)->r_barrier)(regs, 0xd9, 0x3c, (0x01|0x02)));
1892
1893 rtw_io_enable(&sc->sc_regs, RTW_CR_RE(1<<3)|RTW_CR_TE(1<<2), 0);
1894 }
1895
1896 for (pri = 0; pri < RTW_NTXPRI4; pri++) {
1897 rtw_txsofts_release(sc->sc_dmat, &sc->sc_ic,
1898 &sc->sc_txsoft_blk[pri]);
1899 }
1900
1901 rtw_rxbufs_release(sc->sc_dmat, &sc->sc_rxsoft[0]);
1902
1903 if (disable)
1904 rtw_disable(sc);
1905
1906 /* Mark the interface as not running. Cancel the watchdog timer. */
1907 ifp->if_flags &= ~IFF_RUNNING0x40;
1908 ifq_clr_oactive(&ifp->if_snd);
1909 ifp->if_timer = 0;
1910
1911 return;
1912}
1913
1914#ifdef RTW_DEBUG
1915const char *
1916rtw_pwrstate_string(enum rtw_pwrstate power)
1917{
1918 switch (power) {
1919 case RTW_ON:
1920 return "on";
1921 case RTW_SLEEP:
1922 return "sleep";
1923 case RTW_OFF:
1924 return "off";
1925 default:
1926 return "unknown";
1927 }
1928}
1929#endif
1930
1931/* XXX For Maxim, I am using the RFMD settings gleaned from the
1932 * reference driver, plus a magic Maxim "ON" value that comes from
1933 * the Realtek document "Windows PG for Rtl8180."
1934 */
1935void
1936rtw_maxim_pwrstate(struct rtw_regs *regs, enum rtw_pwrstate power,
1937 int before_rf, int digphy)
1938{
1939 u_int32_t anaparm;
1940
1941 anaparm = RTW_READ(regs, RTW_ANAPARM_0)((*(regs)->r_read32)(regs, 0x54));
1942 anaparm &= ~(RTW_ANAPARM_RFPOW_MASK(0x70000000|0x7f00000) | RTW_ANAPARM_TXDACOFF(1<<27));
1943
1944 switch (power) {
1945 case RTW_OFF:
1946 if (before_rf)
1947 return;
1948 anaparm |= RTW_ANAPARM_RFPOW_MAXIM_OFF((0x379) << ((((u_long)((((((0x7f00000)) - 1) & ((0x7f00000
))) ^ ((0x7f00000)))) >> (16)) != 0) ? 16 + ((((u_long)
(((((((0x7f00000) >> 16)) - 1) & (((0x7f00000) >>
16))) ^ (((0x7f00000) >> 16)))) >> (8)) != 0) ? 8
+ ((((u_long)((((((((0x7f00000) >> 16) >> 8)) - 1
) & ((((0x7f00000) >> 16) >> 8))) ^ ((((0x7f00000
) >> 16) >> 8)))) >> (4)) != 0) ? 4 + ((((u_long
)(((((((((0x7f00000) >> 16) >> 8) >> 4)) - 1
) & (((((0x7f00000) >> 16) >> 8) >> 4))
) ^ (((((0x7f00000) >> 16) >> 8) >> 4)))) >>
(2)) != 0) ? 2 + ((((u_long)((((((((((0x7f00000) >> 16
) >> 8) >> 4) >> 2)) - 1) & ((((((0x7f00000
) >> 16) >> 8) >> 4) >> 2))) ^ ((((((
0x7f00000) >> 16) >> 8) >> 4) >> 2)))
) >> (1)) != 0) ? 1 : 0) : ((((u_long)((((((((((0x7f00000
) >> 16) >> 8) >> 4))) - 1) & ((((((0x7f00000
) >> 16) >> 8) >> 4)))) ^ ((((((0x7f00000) >>
16) >> 8) >> 4))))) >> (1)) != 0) ? 1 : 0)
) : ((((u_long)(((((((((0x7f00000) >> 16) >> 8)))
- 1) & (((((0x7f00000) >> 16) >> 8)))) ^ (((
((0x7f00000) >> 16) >> 8))))) >> (2)) != 0)
? 2 + ((((u_long)((((((((((0x7f00000) >> 16) >> 8
)) >> 2)) - 1) & ((((((0x7f00000) >> 16) >>
8)) >> 2))) ^ ((((((0x7f00000) >> 16) >> 8
)) >> 2)))) >> (1)) != 0) ? 1 : 0) : ((((u_long)(
(((((((((0x7f00000) >> 16) >> 8)))) - 1) & ((
((((0x7f00000) >> 16) >> 8))))) ^ ((((((0x7f00000
) >> 16) >> 8)))))) >> (1)) != 0) ? 1 : 0))
) : ((((u_long)((((((((0x7f00000) >> 16))) - 1) & (
(((0x7f00000) >> 16)))) ^ ((((0x7f00000) >> 16)))
)) >> (4)) != 0) ? 4 + ((((u_long)(((((((((0x7f00000) >>
16)) >> 4)) - 1) & (((((0x7f00000) >> 16)) >>
4))) ^ (((((0x7f00000) >> 16)) >> 4)))) >>
(2)) != 0) ? 2 + ((((u_long)((((((((((0x7f00000) >> 16
)) >> 4) >> 2)) - 1) & ((((((0x7f00000) >>
16)) >> 4) >> 2))) ^ ((((((0x7f00000) >> 16
)) >> 4) >> 2)))) >> (1)) != 0) ? 1 : 0) : (
(((u_long)((((((((((0x7f00000) >> 16)) >> 4))) - 1
) & ((((((0x7f00000) >> 16)) >> 4)))) ^ (((((
(0x7f00000) >> 16)) >> 4))))) >> (1)) != 0)
? 1 : 0)) : ((((u_long)(((((((((0x7f00000) >> 16)))) -
1) & (((((0x7f00000) >> 16))))) ^ (((((0x7f00000) >>
16)))))) >> (2)) != 0) ? 2 + ((((u_long)((((((((((0x7f00000
) >> 16))) >> 2)) - 1) & ((((((0x7f00000) >>
16))) >> 2))) ^ ((((((0x7f00000) >> 16))) >>
2)))) >> (1)) != 0) ? 1 : 0) : ((((u_long)((((((((((0x7f00000
) >> 16))))) - 1) & ((((((0x7f00000) >> 16)))
))) ^ ((((((0x7f00000) >> 16))))))) >> (1)) != 0)
? 1 : 0)))) : ((((u_long)(((((((0x7f00000))) - 1) & (((0x7f00000
)))) ^ (((0x7f00000))))) >> (8)) != 0) ? 8 + ((((u_long
)((((((((0x7f00000)) >> 8)) - 1) & ((((0x7f00000)) >>
8))) ^ ((((0x7f00000)) >> 8)))) >> (4)) != 0) ? 4
+ ((((u_long)(((((((((0x7f00000)) >> 8) >> 4)) -
1) & (((((0x7f00000)) >> 8) >> 4))) ^ (((((0x7f00000
)) >> 8) >> 4)))) >> (2)) != 0) ? 2 + ((((u_long
)((((((((((0x7f00000)) >> 8) >> 4) >> 2)) -
1) & ((((((0x7f00000)) >> 8) >> 4) >> 2
))) ^ ((((((0x7f00000)) >> 8) >> 4) >> 2)))
) >> (1)) != 0) ? 1 : 0) : ((((u_long)((((((((((0x7f00000
)) >> 8) >> 4))) - 1) & ((((((0x7f00000)) >>
8) >> 4)))) ^ ((((((0x7f00000)) >> 8) >> 4
))))) >> (1)) != 0) ? 1 : 0)) : ((((u_long)(((((((((0x7f00000
)) >> 8))) - 1) & (((((0x7f00000)) >> 8)))) ^
(((((0x7f00000)) >> 8))))) >> (2)) != 0) ? 2 + (
(((u_long)((((((((((0x7f00000)) >> 8)) >> 2)) - 1
) & ((((((0x7f00000)) >> 8)) >> 2))) ^ ((((((
0x7f00000)) >> 8)) >> 2)))) >> (1)) != 0) ?
1 : 0) : ((((u_long)((((((((((0x7f00000)) >> 8)))) - 1
) & ((((((0x7f00000)) >> 8))))) ^ ((((((0x7f00000))
>> 8)))))) >> (1)) != 0) ? 1 : 0))) : ((((u_long
)((((((((0x7f00000)))) - 1) & ((((0x7f00000))))) ^ ((((0x7f00000
)))))) >> (4)) != 0) ? 4 + ((((u_long)(((((((((0x7f00000
))) >> 4)) - 1) & (((((0x7f00000))) >> 4))) ^
(((((0x7f00000))) >> 4)))) >> (2)) != 0) ? 2 + (
(((u_long)((((((((((0x7f00000))) >> 4) >> 2)) - 1
) & ((((((0x7f00000))) >> 4) >> 2))) ^ ((((((
0x7f00000))) >> 4) >> 2)))) >> (1)) != 0) ?
1 : 0) : ((((u_long)((((((((((0x7f00000))) >> 4))) - 1
) & ((((((0x7f00000))) >> 4)))) ^ ((((((0x7f00000))
) >> 4))))) >> (1)) != 0) ? 1 : 0)) : ((((u_long)
(((((((((0x7f00000))))) - 1) & (((((0x7f00000)))))) ^ (((
((0x7f00000))))))) >> (2)) != 0) ? 2 + ((((u_long)(((((
(((((0x7f00000)))) >> 2)) - 1) & ((((((0x7f00000)))
) >> 2))) ^ ((((((0x7f00000)))) >> 2)))) >>
(1)) != 0) ? 1 : 0) : ((((u_long)((((((((((0x7f00000)))))) -
1) & ((((((0x7f00000))))))) ^ ((((((0x7f00000)))))))) >>
(1)) != 0) ? 1 : 0))))))
;
1949 anaparm |= RTW_ANAPARM_TXDACOFF(1<<27);
1950 break;
1951 case RTW_SLEEP:
1952 if (!before_rf)
1953 return;
1954 anaparm |= RTW_ANAPARM_RFPOW_MAXIM_SLEEP((0x378) << ((((u_long)((((((0x7f00000)) - 1) & ((0x7f00000
))) ^ ((0x7f00000)))) >> (16)) != 0) ? 16 + ((((u_long)
(((((((0x7f00000) >> 16)) - 1) & (((0x7f00000) >>
16))) ^ (((0x7f00000) >> 16)))) >> (8)) != 0) ? 8
+ ((((u_long)((((((((0x7f00000) >> 16) >> 8)) - 1
) & ((((0x7f00000) >> 16) >> 8))) ^ ((((0x7f00000
) >> 16) >> 8)))) >> (4)) != 0) ? 4 + ((((u_long
)(((((((((0x7f00000) >> 16) >> 8) >> 4)) - 1
) & (((((0x7f00000) >> 16) >> 8) >> 4))
) ^ (((((0x7f00000) >> 16) >> 8) >> 4)))) >>
(2)) != 0) ? 2 + ((((u_long)((((((((((0x7f00000) >> 16
) >> 8) >> 4) >> 2)) - 1) & ((((((0x7f00000
) >> 16) >> 8) >> 4) >> 2))) ^ ((((((
0x7f00000) >> 16) >> 8) >> 4) >> 2)))
) >> (1)) != 0) ? 1 : 0) : ((((u_long)((((((((((0x7f00000
) >> 16) >> 8) >> 4))) - 1) & ((((((0x7f00000
) >> 16) >> 8) >> 4)))) ^ ((((((0x7f00000) >>
16) >> 8) >> 4))))) >> (1)) != 0) ? 1 : 0)
) : ((((u_long)(((((((((0x7f00000) >> 16) >> 8)))
- 1) & (((((0x7f00000) >> 16) >> 8)))) ^ (((
((0x7f00000) >> 16) >> 8))))) >> (2)) != 0)
? 2 + ((((u_long)((((((((((0x7f00000) >> 16) >> 8
)) >> 2)) - 1) & ((((((0x7f00000) >> 16) >>
8)) >> 2))) ^ ((((((0x7f00000) >> 16) >> 8
)) >> 2)))) >> (1)) != 0) ? 1 : 0) : ((((u_long)(
(((((((((0x7f00000) >> 16) >> 8)))) - 1) & ((
((((0x7f00000) >> 16) >> 8))))) ^ ((((((0x7f00000
) >> 16) >> 8)))))) >> (1)) != 0) ? 1 : 0))
) : ((((u_long)((((((((0x7f00000) >> 16))) - 1) & (
(((0x7f00000) >> 16)))) ^ ((((0x7f00000) >> 16)))
)) >> (4)) != 0) ? 4 + ((((u_long)(((((((((0x7f00000) >>
16)) >> 4)) - 1) & (((((0x7f00000) >> 16)) >>
4))) ^ (((((0x7f00000) >> 16)) >> 4)))) >>
(2)) != 0) ? 2 + ((((u_long)((((((((((0x7f00000) >> 16
)) >> 4) >> 2)) - 1) & ((((((0x7f00000) >>
16)) >> 4) >> 2))) ^ ((((((0x7f00000) >> 16
)) >> 4) >> 2)))) >> (1)) != 0) ? 1 : 0) : (
(((u_long)((((((((((0x7f00000) >> 16)) >> 4))) - 1
) & ((((((0x7f00000) >> 16)) >> 4)))) ^ (((((
(0x7f00000) >> 16)) >> 4))))) >> (1)) != 0)
? 1 : 0)) : ((((u_long)(((((((((0x7f00000) >> 16)))) -
1) & (((((0x7f00000) >> 16))))) ^ (((((0x7f00000) >>
16)))))) >> (2)) != 0) ? 2 + ((((u_long)((((((((((0x7f00000
) >> 16))) >> 2)) - 1) & ((((((0x7f00000) >>
16))) >> 2))) ^ ((((((0x7f00000) >> 16))) >>
2)))) >> (1)) != 0) ? 1 : 0) : ((((u_long)((((((((((0x7f00000
) >> 16))))) - 1) & ((((((0x7f00000) >> 16)))
))) ^ ((((((0x7f00000) >> 16))))))) >> (1)) != 0)
? 1 : 0)))) : ((((u_long)(((((((0x7f00000))) - 1) & (((0x7f00000
)))) ^ (((0x7f00000))))) >> (8)) != 0) ? 8 + ((((u_long
)((((((((0x7f00000)) >> 8)) - 1) & ((((0x7f00000)) >>
8))) ^ ((((0x7f00000)) >> 8)))) >> (4)) != 0) ? 4
+ ((((u_long)(((((((((0x7f00000)) >> 8) >> 4)) -
1) & (((((0x7f00000)) >> 8) >> 4))) ^ (((((0x7f00000
)) >> 8) >> 4)))) >> (2)) != 0) ? 2 + ((((u_long
)((((((((((0x7f00000)) >> 8) >> 4) >> 2)) -
1) & ((((((0x7f00000)) >> 8) >> 4) >> 2
))) ^ ((((((0x7f00000)) >> 8) >> 4) >> 2)))
) >> (1)) != 0) ? 1 : 0) : ((((u_long)((((((((((0x7f00000
)) >> 8) >> 4))) - 1) & ((((((0x7f00000)) >>
8) >> 4)))) ^ ((((((0x7f00000)) >> 8) >> 4
))))) >> (1)) != 0) ? 1 : 0)) : ((((u_long)(((((((((0x7f00000
)) >> 8))) - 1) & (((((0x7f00000)) >> 8)))) ^
(((((0x7f00000)) >> 8))))) >> (2)) != 0) ? 2 + (
(((u_long)((((((((((0x7f00000)) >> 8)) >> 2)) - 1
) & ((((((0x7f00000)) >> 8)) >> 2))) ^ ((((((
0x7f00000)) >> 8)) >> 2)))) >> (1)) != 0) ?
1 : 0) : ((((u_long)((((((((((0x7f00000)) >> 8)))) - 1
) & ((((((0x7f00000)) >> 8))))) ^ ((((((0x7f00000))
>> 8)))))) >> (1)) != 0) ? 1 : 0))) : ((((u_long
)((((((((0x7f00000)))) - 1) & ((((0x7f00000))))) ^ ((((0x7f00000
)))))) >> (4)) != 0) ? 4 + ((((u_long)(((((((((0x7f00000
))) >> 4)) - 1) & (((((0x7f00000))) >> 4))) ^
(((((0x7f00000))) >> 4)))) >> (2)) != 0) ? 2 + (
(((u_long)((((((((((0x7f00000))) >> 4) >> 2)) - 1
) & ((((((0x7f00000))) >> 4) >> 2))) ^ ((((((
0x7f00000))) >> 4) >> 2)))) >> (1)) != 0) ?
1 : 0) : ((((u_long)((((((((((0x7f00000))) >> 4))) - 1
) & ((((((0x7f00000))) >> 4)))) ^ ((((((0x7f00000))
) >> 4))))) >> (1)) != 0) ? 1 : 0)) : ((((u_long)
(((((((((0x7f00000))))) - 1) & (((((0x7f00000)))))) ^ (((
((0x7f00000))))))) >> (2)) != 0) ? 2 + ((((u_long)(((((
(((((0x7f00000)))) >> 2)) - 1) & ((((((0x7f00000)))
) >> 2))) ^ ((((((0x7f00000)))) >> 2)))) >>
(1)) != 0) ? 1 : 0) : ((((u_long)((((((((((0x7f00000)))))) -
1) & ((((((0x7f00000))))))) ^ ((((((0x7f00000)))))))) >>
(1)) != 0) ? 1 : 0))))))
;
1955 anaparm |= RTW_ANAPARM_TXDACOFF(1<<27);
1956 break;
1957 case RTW_ON:
1958 if (!before_rf)
1959 return;
1960 anaparm |= RTW_ANAPARM_RFPOW_MAXIM_ON((0x8) << ((((u_long)((((((0x7f00000)) - 1) & ((0x7f00000
))) ^ ((0x7f00000)))) >> (16)) != 0) ? 16 + ((((u_long)
(((((((0x7f00000) >> 16)) - 1) & (((0x7f00000) >>
16))) ^ (((0x7f00000) >> 16)))) >> (8)) != 0) ? 8
+ ((((u_long)((((((((0x7f00000) >> 16) >> 8)) - 1
) & ((((0x7f00000) >> 16) >> 8))) ^ ((((0x7f00000
) >> 16) >> 8)))) >> (4)) != 0) ? 4 + ((((u_long
)(((((((((0x7f00000) >> 16) >> 8) >> 4)) - 1
) & (((((0x7f00000) >> 16) >> 8) >> 4))
) ^ (((((0x7f00000) >> 16) >> 8) >> 4)))) >>
(2)) != 0) ? 2 + ((((u_long)((((((((((0x7f00000) >> 16
) >> 8) >> 4) >> 2)) - 1) & ((((((0x7f00000
) >> 16) >> 8) >> 4) >> 2))) ^ ((((((
0x7f00000) >> 16) >> 8) >> 4) >> 2)))
) >> (1)) != 0) ? 1 : 0) : ((((u_long)((((((((((0x7f00000
) >> 16) >> 8) >> 4))) - 1) & ((((((0x7f00000
) >> 16) >> 8) >> 4)))) ^ ((((((0x7f00000) >>
16) >> 8) >> 4))))) >> (1)) != 0) ? 1 : 0)
) : ((((u_long)(((((((((0x7f00000) >> 16) >> 8)))
- 1) & (((((0x7f00000) >> 16) >> 8)))) ^ (((
((0x7f00000) >> 16) >> 8))))) >> (2)) != 0)
? 2 + ((((u_long)((((((((((0x7f00000) >> 16) >> 8
)) >> 2)) - 1) & ((((((0x7f00000) >> 16) >>
8)) >> 2))) ^ ((((((0x7f00000) >> 16) >> 8
)) >> 2)))) >> (1)) != 0) ? 1 : 0) : ((((u_long)(
(((((((((0x7f00000) >> 16) >> 8)))) - 1) & ((
((((0x7f00000) >> 16) >> 8))))) ^ ((((((0x7f00000
) >> 16) >> 8)))))) >> (1)) != 0) ? 1 : 0))
) : ((((u_long)((((((((0x7f00000) >> 16))) - 1) & (
(((0x7f00000) >> 16)))) ^ ((((0x7f00000) >> 16)))
)) >> (4)) != 0) ? 4 + ((((u_long)(((((((((0x7f00000) >>
16)) >> 4)) - 1) & (((((0x7f00000) >> 16)) >>
4))) ^ (((((0x7f00000) >> 16)) >> 4)))) >>
(2)) != 0) ? 2 + ((((u_long)((((((((((0x7f00000) >> 16
)) >> 4) >> 2)) - 1) & ((((((0x7f00000) >>
16)) >> 4) >> 2))) ^ ((((((0x7f00000) >> 16
)) >> 4) >> 2)))) >> (1)) != 0) ? 1 : 0) : (
(((u_long)((((((((((0x7f00000) >> 16)) >> 4))) - 1
) & ((((((0x7f00000) >> 16)) >> 4)))) ^ (((((
(0x7f00000) >> 16)) >> 4))))) >> (1)) != 0)
? 1 : 0)) : ((((u_long)(((((((((0x7f00000) >> 16)))) -
1) & (((((0x7f00000) >> 16))))) ^ (((((0x7f00000) >>
16)))))) >> (2)) != 0) ? 2 + ((((u_long)((((((((((0x7f00000
) >> 16))) >> 2)) - 1) & ((((((0x7f00000) >>
16))) >> 2))) ^ ((((((0x7f00000) >> 16))) >>
2)))) >> (1)) != 0) ? 1 : 0) : ((((u_long)((((((((((0x7f00000
) >> 16))))) - 1) & ((((((0x7f00000) >> 16)))
))) ^ ((((((0x7f00000) >> 16))))))) >> (1)) != 0)
? 1 : 0)))) : ((((u_long)(((((((0x7f00000))) - 1) & (((0x7f00000
)))) ^ (((0x7f00000))))) >> (8)) != 0) ? 8 + ((((u_long
)((((((((0x7f00000)) >> 8)) - 1) & ((((0x7f00000)) >>
8))) ^ ((((0x7f00000)) >> 8)))) >> (4)) != 0) ? 4
+ ((((u_long)(((((((((0x7f00000)) >> 8) >> 4)) -
1) & (((((0x7f00000)) >> 8) >> 4))) ^ (((((0x7f00000
)) >> 8) >> 4)))) >> (2)) != 0) ? 2 + ((((u_long
)((((((((((0x7f00000)) >> 8) >> 4) >> 2)) -
1) & ((((((0x7f00000)) >> 8) >> 4) >> 2
))) ^ ((((((0x7f00000)) >> 8) >> 4) >> 2)))
) >> (1)) != 0) ? 1 : 0) : ((((u_long)((((((((((0x7f00000
)) >> 8) >> 4))) - 1) & ((((((0x7f00000)) >>
8) >> 4)))) ^ ((((((0x7f00000)) >> 8) >> 4
))))) >> (1)) != 0) ? 1 : 0)) : ((((u_long)(((((((((0x7f00000
)) >> 8))) - 1) & (((((0x7f00000)) >> 8)))) ^
(((((0x7f00000)) >> 8))))) >> (2)) != 0) ? 2 + (
(((u_long)((((((((((0x7f00000)) >> 8)) >> 2)) - 1
) & ((((((0x7f00000)) >> 8)) >> 2))) ^ ((((((
0x7f00000)) >> 8)) >> 2)))) >> (1)) != 0) ?
1 : 0) : ((((u_long)((((((((((0x7f00000)) >> 8)))) - 1
) & ((((((0x7f00000)) >> 8))))) ^ ((((((0x7f00000))
>> 8)))))) >> (1)) != 0) ? 1 : 0))) : ((((u_long
)((((((((0x7f00000)))) - 1) & ((((0x7f00000))))) ^ ((((0x7f00000
)))))) >> (4)) != 0) ? 4 + ((((u_long)(((((((((0x7f00000
))) >> 4)) - 1) & (((((0x7f00000))) >> 4))) ^
(((((0x7f00000))) >> 4)))) >> (2)) != 0) ? 2 + (
(((u_long)((((((((((0x7f00000))) >> 4) >> 2)) - 1
) & ((((((0x7f00000))) >> 4) >> 2))) ^ ((((((
0x7f00000))) >> 4) >> 2)))) >> (1)) != 0) ?
1 : 0) : ((((u_long)((((((((((0x7f00000))) >> 4))) - 1
) & ((((((0x7f00000))) >> 4)))) ^ ((((((0x7f00000))
) >> 4))))) >> (1)) != 0) ? 1 : 0)) : ((((u_long)
(((((((((0x7f00000))))) - 1) & (((((0x7f00000)))))) ^ (((
((0x7f00000))))))) >> (2)) != 0) ? 2 + ((((u_long)(((((
(((((0x7f00000)))) >> 2)) - 1) & ((((((0x7f00000)))
) >> 2))) ^ ((((((0x7f00000)))) >> 2)))) >>
(1)) != 0) ? 1 : 0) : ((((u_long)((((((((((0x7f00000)))))) -
1) & ((((((0x7f00000))))))) ^ ((((((0x7f00000)))))))) >>
(1)) != 0) ? 1 : 0))))))
;
1961 break;
1962 }
1963 RTW_DPRINTF(RTW_DEBUG_PWR,
1964 ("%s: power state %s, %s RF, reg[ANAPARM] <- %08x\n",
1965 __func__, rtw_pwrstate_string(power),
1966 (before_rf) ? "before" : "after", anaparm));
1967
1968 RTW_WRITE(regs, RTW_ANAPARM_0, anaparm)((*(regs)->r_write32)(regs, 0x54, anaparm));
1969 RTW_SYNC(regs, RTW_ANAPARM_0, RTW_ANAPARM_0)((*(regs)->r_barrier)(regs, 0x54, 0x54, (0x01|0x02)));
1970}
1971
1972/* XXX I am using the RFMD settings gleaned from the reference
1973 * driver. They agree
1974 */
1975void
1976rtw_rfmd_pwrstate(struct rtw_regs *regs, enum rtw_pwrstate power,
1977 int before_rf, int digphy)
1978{
1979 u_int32_t anaparm;
1980
1981 anaparm = RTW_READ(regs, RTW_ANAPARM_0)((*(regs)->r_read32)(regs, 0x54));
1982 anaparm &= ~(RTW_ANAPARM_RFPOW_MASK(0x70000000|0x7f00000) | RTW_ANAPARM_TXDACOFF(1<<27));
1983
1984 switch (power) {
1985 case RTW_OFF:
1986 if (before_rf)
1987 return;
1988 anaparm |= RTW_ANAPARM_RFPOW_RFMD_OFF((0x379) << ((((u_long)((((((0x7f00000)) - 1) & ((0x7f00000
))) ^ ((0x7f00000)))) >> (16)) != 0) ? 16 + ((((u_long)
(((((((0x7f00000) >> 16)) - 1) & (((0x7f00000) >>
16))) ^ (((0x7f00000) >> 16)))) >> (8)) != 0) ? 8
+ ((((u_long)((((((((0x7f00000) >> 16) >> 8)) - 1
) & ((((0x7f00000) >> 16) >> 8))) ^ ((((0x7f00000
) >> 16) >> 8)))) >> (4)) != 0) ? 4 + ((((u_long
)(((((((((0x7f00000) >> 16) >> 8) >> 4)) - 1
) & (((((0x7f00000) >> 16) >> 8) >> 4))
) ^ (((((0x7f00000) >> 16) >> 8) >> 4)))) >>
(2)) != 0) ? 2 + ((((u_long)((((((((((0x7f00000) >> 16
) >> 8) >> 4) >> 2)) - 1) & ((((((0x7f00000
) >> 16) >> 8) >> 4) >> 2))) ^ ((((((
0x7f00000) >> 16) >> 8) >> 4) >> 2)))
) >> (1)) != 0) ? 1 : 0) : ((((u_long)((((((((((0x7f00000
) >> 16) >> 8) >> 4))) - 1) & ((((((0x7f00000
) >> 16) >> 8) >> 4)))) ^ ((((((0x7f00000) >>
16) >> 8) >> 4))))) >> (1)) != 0) ? 1 : 0)
) : ((((u_long)(((((((((0x7f00000) >> 16) >> 8)))
- 1) & (((((0x7f00000) >> 16) >> 8)))) ^ (((
((0x7f00000) >> 16) >> 8))))) >> (2)) != 0)
? 2 + ((((u_long)((((((((((0x7f00000) >> 16) >> 8
)) >> 2)) - 1) & ((((((0x7f00000) >> 16) >>
8)) >> 2))) ^ ((((((0x7f00000) >> 16) >> 8
)) >> 2)))) >> (1)) != 0) ? 1 : 0) : ((((u_long)(
(((((((((0x7f00000) >> 16) >> 8)))) - 1) & ((
((((0x7f00000) >> 16) >> 8))))) ^ ((((((0x7f00000
) >> 16) >> 8)))))) >> (1)) != 0) ? 1 : 0))
) : ((((u_long)((((((((0x7f00000) >> 16))) - 1) & (
(((0x7f00000) >> 16)))) ^ ((((0x7f00000) >> 16)))
)) >> (4)) != 0) ? 4 + ((((u_long)(((((((((0x7f00000) >>
16)) >> 4)) - 1) & (((((0x7f00000) >> 16)) >>
4))) ^ (((((0x7f00000) >> 16)) >> 4)))) >>
(2)) != 0) ? 2 + ((((u_long)((((((((((0x7f00000) >> 16
)) >> 4) >> 2)) - 1) & ((((((0x7f00000) >>
16)) >> 4) >> 2))) ^ ((((((0x7f00000) >> 16
)) >> 4) >> 2)))) >> (1)) != 0) ? 1 : 0) : (
(((u_long)((((((((((0x7f00000) >> 16)) >> 4))) - 1
) & ((((((0x7f00000) >> 16)) >> 4)))) ^ (((((
(0x7f00000) >> 16)) >> 4))))) >> (1)) != 0)
? 1 : 0)) : ((((u_long)(((((((((0x7f00000) >> 16)))) -
1) & (((((0x7f00000) >> 16))))) ^ (((((0x7f00000) >>
16)))))) >> (2)) != 0) ? 2 + ((((u_long)((((((((((0x7f00000
) >> 16))) >> 2)) - 1) & ((((((0x7f00000) >>
16))) >> 2))) ^ ((((((0x7f00000) >> 16))) >>
2)))) >> (1)) != 0) ? 1 : 0) : ((((u_long)((((((((((0x7f00000
) >> 16))))) - 1) & ((((((0x7f00000) >> 16)))
))) ^ ((((((0x7f00000) >> 16))))))) >> (1)) != 0)
? 1 : 0)))) : ((((u_long)(((((((0x7f00000))) - 1) & (((0x7f00000
)))) ^ (((0x7f00000))))) >> (8)) != 0) ? 8 + ((((u_long
)((((((((0x7f00000)) >> 8)) - 1) & ((((0x7f00000)) >>
8))) ^ ((((0x7f00000)) >> 8)))) >> (4)) != 0) ? 4
+ ((((u_long)(((((((((0x7f00000)) >> 8) >> 4)) -
1) & (((((0x7f00000)) >> 8) >> 4))) ^ (((((0x7f00000
)) >> 8) >> 4)))) >> (2)) != 0) ? 2 + ((((u_long
)((((((((((0x7f00000)) >> 8) >> 4) >> 2)) -
1) & ((((((0x7f00000)) >> 8) >> 4) >> 2
))) ^ ((((((0x7f00000)) >> 8) >> 4) >> 2)))
) >> (1)) != 0) ? 1 : 0) : ((((u_long)((((((((((0x7f00000
)) >> 8) >> 4))) - 1) & ((((((0x7f00000)) >>
8) >> 4)))) ^ ((((((0x7f00000)) >> 8) >> 4
))))) >> (1)) != 0) ? 1 : 0)) : ((((u_long)(((((((((0x7f00000
)) >> 8))) - 1) & (((((0x7f00000)) >> 8)))) ^
(((((0x7f00000)) >> 8))))) >> (2)) != 0) ? 2 + (
(((u_long)((((((((((0x7f00000)) >> 8)) >> 2)) - 1
) & ((((((0x7f00000)) >> 8)) >> 2))) ^ ((((((
0x7f00000)) >> 8)) >> 2)))) >> (1)) != 0) ?
1 : 0) : ((((u_long)((((((((((0x7f00000)) >> 8)))) - 1
) & ((((((0x7f00000)) >> 8))))) ^ ((((((0x7f00000))
>> 8)))))) >> (1)) != 0) ? 1 : 0))) : ((((u_long
)((((((((0x7f00000)))) - 1) & ((((0x7f00000))))) ^ ((((0x7f00000
)))))) >> (4)) != 0) ? 4 + ((((u_long)(((((((((0x7f00000
))) >> 4)) - 1) & (((((0x7f00000))) >> 4))) ^
(((((0x7f00000))) >> 4)))) >> (2)) != 0) ? 2 + (
(((u_long)((((((((((0x7f00000))) >> 4) >> 2)) - 1
) & ((((((0x7f00000))) >> 4) >> 2))) ^ ((((((
0x7f00000))) >> 4) >> 2)))) >> (1)) != 0) ?
1 : 0) : ((((u_long)((((((((((0x7f00000))) >> 4))) - 1
) & ((((((0x7f00000))) >> 4)))) ^ ((((((0x7f00000))
) >> 4))))) >> (1)) != 0) ? 1 : 0)) : ((((u_long)
(((((((((0x7f00000))))) - 1) & (((((0x7f00000)))))) ^ (((
((0x7f00000))))))) >> (2)) != 0) ? 2 + ((((u_long)(((((
(((((0x7f00000)))) >> 2)) - 1) & ((((((0x7f00000)))
) >> 2))) ^ ((((((0x7f00000)))) >> 2)))) >>
(1)) != 0) ? 1 : 0) : ((((u_long)((((((((((0x7f00000)))))) -
1) & ((((((0x7f00000))))))) ^ ((((((0x7f00000)))))))) >>
(1)) != 0) ? 1 : 0))))))
;
1989 anaparm |= RTW_ANAPARM_TXDACOFF(1<<27);
1990 break;
1991 case RTW_SLEEP:
1992 if (!before_rf)
1993 return;
1994 anaparm |= RTW_ANAPARM_RFPOW_RFMD_SLEEP((0x378) << ((((u_long)((((((0x7f00000)) - 1) & ((0x7f00000
))) ^ ((0x7f00000)))) >> (16)) != 0) ? 16 + ((((u_long)
(((((((0x7f00000) >> 16)) - 1) & (((0x7f00000) >>
16))) ^ (((0x7f00000) >> 16)))) >> (8)) != 0) ? 8
+ ((((u_long)((((((((0x7f00000) >> 16) >> 8)) - 1
) & ((((0x7f00000) >> 16) >> 8))) ^ ((((0x7f00000
) >> 16) >> 8)))) >> (4)) != 0) ? 4 + ((((u_long
)(((((((((0x7f00000) >> 16) >> 8) >> 4)) - 1
) & (((((0x7f00000) >> 16) >> 8) >> 4))
) ^ (((((0x7f00000) >> 16) >> 8) >> 4)))) >>
(2)) != 0) ? 2 + ((((u_long)((((((((((0x7f00000) >> 16
) >> 8) >> 4) >> 2)) - 1) & ((((((0x7f00000
) >> 16) >> 8) >> 4) >> 2))) ^ ((((((
0x7f00000) >> 16) >> 8) >> 4) >> 2)))
) >> (1)) != 0) ? 1 : 0) : ((((u_long)((((((((((0x7f00000
) >> 16) >> 8) >> 4))) - 1) & ((((((0x7f00000
) >> 16) >> 8) >> 4)))) ^ ((((((0x7f00000) >>
16) >> 8) >> 4))))) >> (1)) != 0) ? 1 : 0)
) : ((((u_long)(((((((((0x7f00000) >> 16) >> 8)))
- 1) & (((((0x7f00000) >> 16) >> 8)))) ^ (((
((0x7f00000) >> 16) >> 8))))) >> (2)) != 0)
? 2 + ((((u_long)((((((((((0x7f00000) >> 16) >> 8
)) >> 2)) - 1) & ((((((0x7f00000) >> 16) >>
8)) >> 2))) ^ ((((((0x7f00000) >> 16) >> 8
)) >> 2)))) >> (1)) != 0) ? 1 : 0) : ((((u_long)(
(((((((((0x7f00000) >> 16) >> 8)))) - 1) & ((
((((0x7f00000) >> 16) >> 8))))) ^ ((((((0x7f00000
) >> 16) >> 8)))))) >> (1)) != 0) ? 1 : 0))
) : ((((u_long)((((((((0x7f00000) >> 16))) - 1) & (
(((0x7f00000) >> 16)))) ^ ((((0x7f00000) >> 16)))
)) >> (4)) != 0) ? 4 + ((((u_long)(((((((((0x7f00000) >>
16)) >> 4)) - 1) & (((((0x7f00000) >> 16)) >>
4))) ^ (((((0x7f00000) >> 16)) >> 4)))) >>
(2)) != 0) ? 2 + ((((u_long)((((((((((0x7f00000) >> 16
)) >> 4) >> 2)) - 1) & ((((((0x7f00000) >>
16)) >> 4) >> 2))) ^ ((((((0x7f00000) >> 16
)) >> 4) >> 2)))) >> (1)) != 0) ? 1 : 0) : (
(((u_long)((((((((((0x7f00000) >> 16)) >> 4))) - 1
) & ((((((0x7f00000) >> 16)) >> 4)))) ^ (((((
(0x7f00000) >> 16)) >> 4))))) >> (1)) != 0)
? 1 : 0)) : ((((u_long)(((((((((0x7f00000) >> 16)))) -
1) & (((((0x7f00000) >> 16))))) ^ (((((0x7f00000) >>
16)))))) >> (2)) != 0) ? 2 + ((((u_long)((((((((((0x7f00000
) >> 16))) >> 2)) - 1) & ((((((0x7f00000) >>
16))) >> 2))) ^ ((((((0x7f00000) >> 16))) >>
2)))) >> (1)) != 0) ? 1 : 0) : ((((u_long)((((((((((0x7f00000
) >> 16))))) - 1) & ((((((0x7f00000) >> 16)))
))) ^ ((((((0x7f00000) >> 16))))))) >> (1)) != 0)
? 1 : 0)))) : ((((u_long)(((((((0x7f00000))) - 1) & (((0x7f00000
)))) ^ (((0x7f00000))))) >> (8)) != 0) ? 8 + ((((u_long
)((((((((0x7f00000)) >> 8)) - 1) & ((((0x7f00000)) >>
8))) ^ ((((0x7f00000)) >> 8)))) >> (4)) != 0) ? 4
+ ((((u_long)(((((((((0x7f00000)) >> 8) >> 4)) -
1) & (((((0x7f00000)) >> 8) >> 4))) ^ (((((0x7f00000
)) >> 8) >> 4)))) >> (2)) != 0) ? 2 + ((((u_long
)((((((((((0x7f00000)) >> 8) >> 4) >> 2)) -
1) & ((((((0x7f00000)) >> 8) >> 4) >> 2
))) ^ ((((((0x7f00000)) >> 8) >> 4) >> 2)))
) >> (1)) != 0) ? 1 : 0) : ((((u_long)((((((((((0x7f00000
)) >> 8) >> 4))) - 1) & ((((((0x7f00000)) >>
8) >> 4)))) ^ ((((((0x7f00000)) >> 8) >> 4
))))) >> (1)) != 0) ? 1 : 0)) : ((((u_long)(((((((((0x7f00000
)) >> 8))) - 1) & (((((0x7f00000)) >> 8)))) ^
(((((0x7f00000)) >> 8))))) >> (2)) != 0) ? 2 + (
(((u_long)((((((((((0x7f00000)) >> 8)) >> 2)) - 1
) & ((((((0x7f00000)) >> 8)) >> 2))) ^ ((((((
0x7f00000)) >> 8)) >> 2)))) >> (1)) != 0) ?
1 : 0) : ((((u_long)((((((((((0x7f00000)) >> 8)))) - 1
) & ((((((0x7f00000)) >> 8))))) ^ ((((((0x7f00000))
>> 8)))))) >> (1)) != 0) ? 1 : 0))) : ((((u_long
)((((((((0x7f00000)))) - 1) & ((((0x7f00000))))) ^ ((((0x7f00000
)))))) >> (4)) != 0) ? 4 + ((((u_long)(((((((((0x7f00000
))) >> 4)) - 1) & (((((0x7f00000))) >> 4))) ^
(((((0x7f00000))) >> 4)))) >> (2)) != 0) ? 2 + (
(((u_long)((((((((((0x7f00000))) >> 4) >> 2)) - 1
) & ((((((0x7f00000))) >> 4) >> 2))) ^ ((((((
0x7f00000))) >> 4) >> 2)))) >> (1)) != 0) ?
1 : 0) : ((((u_long)((((((((((0x7f00000))) >> 4))) - 1
) & ((((((0x7f00000))) >> 4)))) ^ ((((((0x7f00000))
) >> 4))))) >> (1)) != 0) ? 1 : 0)) : ((((u_long)
(((((((((0x7f00000))))) - 1) & (((((0x7f00000)))))) ^ (((
((0x7f00000))))))) >> (2)) != 0) ? 2 + ((((u_long)(((((
(((((0x7f00000)))) >> 2)) - 1) & ((((((0x7f00000)))
) >> 2))) ^ ((((((0x7f00000)))) >> 2)))) >>
(1)) != 0) ? 1 : 0) : ((((u_long)((((((((((0x7f00000)))))) -
1) & ((((((0x7f00000))))))) ^ ((((((0x7f00000)))))))) >>
(1)) != 0) ? 1 : 0))))))
;
1995 anaparm |= RTW_ANAPARM_TXDACOFF(1<<27);
1996 break;
1997 case RTW_ON:
1998 if (!before_rf)
1999 return;
2000 anaparm |= RTW_ANAPARM_RFPOW_RFMD_ON((0x408) << ((((u_long)((((((0x7f00000)) - 1) & ((0x7f00000
))) ^ ((0x7f00000)))) >> (16)) != 0) ? 16 + ((((u_long)
(((((((0x7f00000) >> 16)) - 1) & (((0x7f00000) >>
16))) ^ (((0x7f00000) >> 16)))) >> (8)) != 0) ? 8
+ ((((u_long)((((((((0x7f00000) >> 16) >> 8)) - 1
) & ((((0x7f00000) >> 16) >> 8))) ^ ((((0x7f00000
) >> 16) >> 8)))) >> (4)) != 0) ? 4 + ((((u_long
)(((((((((0x7f00000) >> 16) >> 8) >> 4)) - 1
) & (((((0x7f00000) >> 16) >> 8) >> 4))
) ^ (((((0x7f00000) >> 16) >> 8) >> 4)))) >>
(2)) != 0) ? 2 + ((((u_long)((((((((((0x7f00000) >> 16
) >> 8) >> 4) >> 2)) - 1) & ((((((0x7f00000
) >> 16) >> 8) >> 4) >> 2))) ^ ((((((
0x7f00000) >> 16) >> 8) >> 4) >> 2)))
) >> (1)) != 0) ? 1 : 0) : ((((u_long)((((((((((0x7f00000
) >> 16) >> 8) >> 4))) - 1) & ((((((0x7f00000
) >> 16) >> 8) >> 4)))) ^ ((((((0x7f00000) >>
16) >> 8) >> 4))))) >> (1)) != 0) ? 1 : 0)
) : ((((u_long)(((((((((0x7f00000) >> 16) >> 8)))
- 1) & (((((0x7f00000) >> 16) >> 8)))) ^ (((
((0x7f00000) >> 16) >> 8))))) >> (2)) != 0)
? 2 + ((((u_long)((((((((((0x7f00000) >> 16) >> 8
)) >> 2)) - 1) & ((((((0x7f00000) >> 16) >>
8)) >> 2))) ^ ((((((0x7f00000) >> 16) >> 8
)) >> 2)))) >> (1)) != 0) ? 1 : 0) : ((((u_long)(
(((((((((0x7f00000) >> 16) >> 8)))) - 1) & ((
((((0x7f00000) >> 16) >> 8))))) ^ ((((((0x7f00000
) >> 16) >> 8)))))) >> (1)) != 0) ? 1 : 0))
) : ((((u_long)((((((((0x7f00000) >> 16))) - 1) & (
(((0x7f00000) >> 16)))) ^ ((((0x7f00000) >> 16)))
)) >> (4)) != 0) ? 4 + ((((u_long)(((((((((0x7f00000) >>
16)) >> 4)) - 1) & (((((0x7f00000) >> 16)) >>
4))) ^ (((((0x7f00000) >> 16)) >> 4)))) >>
(2)) != 0) ? 2 + ((((u_long)((((((((((0x7f00000) >> 16
)) >> 4) >> 2)) - 1) & ((((((0x7f00000) >>
16)) >> 4) >> 2))) ^ ((((((0x7f00000) >> 16
)) >> 4) >> 2)))) >> (1)) != 0) ? 1 : 0) : (
(((u_long)((((((((((0x7f00000) >> 16)) >> 4))) - 1
) & ((((((0x7f00000) >> 16)) >> 4)))) ^ (((((
(0x7f00000) >> 16)) >> 4))))) >> (1)) != 0)
? 1 : 0)) : ((((u_long)(((((((((0x7f00000) >> 16)))) -
1) & (((((0x7f00000) >> 16))))) ^ (((((0x7f00000) >>
16)))))) >> (2)) != 0) ? 2 + ((((u_long)((((((((((0x7f00000
) >> 16))) >> 2)) - 1) & ((((((0x7f00000) >>
16))) >> 2))) ^ ((((((0x7f00000) >> 16))) >>
2)))) >> (1)) != 0) ? 1 : 0) : ((((u_long)((((((((((0x7f00000
) >> 16))))) - 1) & ((((((0x7f00000) >> 16)))
))) ^ ((((((0x7f00000) >> 16))))))) >> (1)) != 0)
? 1 : 0)))) : ((((u_long)(((((((0x7f00000))) - 1) & (((0x7f00000
)))) ^ (((0x7f00000))))) >> (8)) != 0) ? 8 + ((((u_long
)((((((((0x7f00000)) >> 8)) - 1) & ((((0x7f00000)) >>
8))) ^ ((((0x7f00000)) >> 8)))) >> (4)) != 0) ? 4
+ ((((u_long)(((((((((0x7f00000)) >> 8) >> 4)) -
1) & (((((0x7f00000)) >> 8) >> 4))) ^ (((((0x7f00000
)) >> 8) >> 4)))) >> (2)) != 0) ? 2 + ((((u_long
)((((((((((0x7f00000)) >> 8) >> 4) >> 2)) -
1) & ((((((0x7f00000)) >> 8) >> 4) >> 2
))) ^ ((((((0x7f00000)) >> 8) >> 4) >> 2)))
) >> (1)) != 0) ? 1 : 0) : ((((u_long)((((((((((0x7f00000
)) >> 8) >> 4))) - 1) & ((((((0x7f00000)) >>
8) >> 4)))) ^ ((((((0x7f00000)) >> 8) >> 4
))))) >> (1)) != 0) ? 1 : 0)) : ((((u_long)(((((((((0x7f00000
)) >> 8))) - 1) & (((((0x7f00000)) >> 8)))) ^
(((((0x7f00000)) >> 8))))) >> (2)) != 0) ? 2 + (
(((u_long)((((((((((0x7f00000)) >> 8)) >> 2)) - 1
) & ((((((0x7f00000)) >> 8)) >> 2))) ^ ((((((
0x7f00000)) >> 8)) >> 2)))) >> (1)) != 0) ?
1 : 0) : ((((u_long)((((((((((0x7f00000)) >> 8)))) - 1
) & ((((((0x7f00000)) >> 8))))) ^ ((((((0x7f00000))
>> 8)))))) >> (1)) != 0) ? 1 : 0))) : ((((u_long
)((((((((0x7f00000)))) - 1) & ((((0x7f00000))))) ^ ((((0x7f00000
)))))) >> (4)) != 0) ? 4 + ((((u_long)(((((((((0x7f00000
))) >> 4)) - 1) & (((((0x7f00000))) >> 4))) ^
(((((0x7f00000))) >> 4)))) >> (2)) != 0) ? 2 + (
(((u_long)((((((((((0x7f00000))) >> 4) >> 2)) - 1
) & ((((((0x7f00000))) >> 4) >> 2))) ^ ((((((
0x7f00000))) >> 4) >> 2)))) >> (1)) != 0) ?
1 : 0) : ((((u_long)((((((((((0x7f00000))) >> 4))) - 1
) & ((((((0x7f00000))) >> 4)))) ^ ((((((0x7f00000))
) >> 4))))) >> (1)) != 0) ? 1 : 0)) : ((((u_long)
(((((((((0x7f00000))))) - 1) & (((((0x7f00000)))))) ^ (((
((0x7f00000))))))) >> (2)) != 0) ? 2 + ((((u_long)(((((
(((((0x7f00000)))) >> 2)) - 1) & ((((((0x7f00000)))
) >> 2))) ^ ((((((0x7f00000)))) >> 2)))) >>
(1)) != 0) ? 1 : 0) : ((((u_long)((((((((((0x7f00000)))))) -
1) & ((((((0x7f00000))))))) ^ ((((((0x7f00000)))))))) >>
(1)) != 0) ? 1 : 0))))))
;
2001 break;
2002 }
2003 RTW_DPRINTF(RTW_DEBUG_PWR,
2004 ("%s: power state %s, %s RF, reg[ANAPARM] <- %08x\n",
2005 __func__, rtw_pwrstate_string(power),
2006 (before_rf) ? "before" : "after", anaparm));
2007
2008 RTW_WRITE(regs, RTW_ANAPARM_0, anaparm)((*(regs)->r_write32)(regs, 0x54, anaparm));
2009 RTW_SYNC(regs, RTW_ANAPARM_0, RTW_ANAPARM_0)((*(regs)->r_barrier)(regs, 0x54, 0x54, (0x01|0x02)));
2010}
2011
2012void
2013rtw_philips_pwrstate(struct rtw_regs *regs, enum rtw_pwrstate power,
2014 int before_rf, int digphy)
2015{
2016 u_int32_t anaparm;
2017
2018 anaparm = RTW_READ(regs, RTW_ANAPARM_0)((*(regs)->r_read32)(regs, 0x54));
2019 anaparm &= ~(RTW_ANAPARM_RFPOW_MASK(0x70000000|0x7f00000) | RTW_ANAPARM_TXDACOFF(1<<27));
2020
2021 switch (power) {
2022 case RTW_OFF:
2023 if (before_rf)
2024 return;
2025 anaparm |= RTW_ANAPARM_RFPOW_PHILIPS_OFF((0x379) << ((((u_long)((((((0x7f00000)) - 1) & ((0x7f00000
))) ^ ((0x7f00000)))) >> (16)) != 0) ? 16 + ((((u_long)
(((((((0x7f00000) >> 16)) - 1) & (((0x7f00000) >>
16))) ^ (((0x7f00000) >> 16)))) >> (8)) != 0) ? 8
+ ((((u_long)((((((((0x7f00000) >> 16) >> 8)) - 1
) & ((((0x7f00000) >> 16) >> 8))) ^ ((((0x7f00000
) >> 16) >> 8)))) >> (4)) != 0) ? 4 + ((((u_long
)(((((((((0x7f00000) >> 16) >> 8) >> 4)) - 1
) & (((((0x7f00000) >> 16) >> 8) >> 4))
) ^ (((((0x7f00000) >> 16) >> 8) >> 4)))) >>
(2)) != 0) ? 2 + ((((u_long)((((((((((0x7f00000) >> 16
) >> 8) >> 4) >> 2)) - 1) & ((((((0x7f00000
) >> 16) >> 8) >> 4) >> 2))) ^ ((((((
0x7f00000) >> 16) >> 8) >> 4) >> 2)))
) >> (1)) != 0) ? 1 : 0) : ((((u_long)((((((((((0x7f00000
) >> 16) >> 8) >> 4))) - 1) & ((((((0x7f00000
) >> 16) >> 8) >> 4)))) ^ ((((((0x7f00000) >>
16) >> 8) >> 4))))) >> (1)) != 0) ? 1 : 0)
) : ((((u_long)(((((((((0x7f00000) >> 16) >> 8)))
- 1) & (((((0x7f00000) >> 16) >> 8)))) ^ (((
((0x7f00000) >> 16) >> 8))))) >> (2)) != 0)
? 2 + ((((u_long)((((((((((0x7f00000) >> 16) >> 8
)) >> 2)) - 1) & ((((((0x7f00000) >> 16) >>
8)) >> 2))) ^ ((((((0x7f00000) >> 16) >> 8
)) >> 2)))) >> (1)) != 0) ? 1 : 0) : ((((u_long)(
(((((((((0x7f00000) >> 16) >> 8)))) - 1) & ((
((((0x7f00000) >> 16) >> 8))))) ^ ((((((0x7f00000
) >> 16) >> 8)))))) >> (1)) != 0) ? 1 : 0))
) : ((((u_long)((((((((0x7f00000) >> 16))) - 1) & (
(((0x7f00000) >> 16)))) ^ ((((0x7f00000) >> 16)))
)) >> (4)) != 0) ? 4 + ((((u_long)(((((((((0x7f00000) >>
16)) >> 4)) - 1) & (((((0x7f00000) >> 16)) >>
4))) ^ (((((0x7f00000) >> 16)) >> 4)))) >>
(2)) != 0) ? 2 + ((((u_long)((((((((((0x7f00000) >> 16
)) >> 4) >> 2)) - 1) & ((((((0x7f00000) >>
16)) >> 4) >> 2))) ^ ((((((0x7f00000) >> 16
)) >> 4) >> 2)))) >> (1)) != 0) ? 1 : 0) : (
(((u_long)((((((((((0x7f00000) >> 16)) >> 4))) - 1
) & ((((((0x7f00000) >> 16)) >> 4)))) ^ (((((
(0x7f00000) >> 16)) >> 4))))) >> (1)) != 0)
? 1 : 0)) : ((((u_long)(((((((((0x7f00000) >> 16)))) -
1) & (((((0x7f00000) >> 16))))) ^ (((((0x7f00000) >>
16)))))) >> (2)) != 0) ? 2 + ((((u_long)((((((((((0x7f00000
) >> 16))) >> 2)) - 1) & ((((((0x7f00000) >>
16))) >> 2))) ^ ((((((0x7f00000) >> 16))) >>
2)))) >> (1)) != 0) ? 1 : 0) : ((((u_long)((((((((((0x7f00000
) >> 16))))) - 1) & ((((((0x7f00000) >> 16)))
))) ^ ((((((0x7f00000) >> 16))))))) >> (1)) != 0)
? 1 : 0)))) : ((((u_long)(((((((0x7f00000))) - 1) & (((0x7f00000
)))) ^ (((0x7f00000))))) >> (8)) != 0) ? 8 + ((((u_long
)((((((((0x7f00000)) >> 8)) - 1) & ((((0x7f00000)) >>
8))) ^ ((((0x7f00000)) >> 8)))) >> (4)) != 0) ? 4
+ ((((u_long)(((((((((0x7f00000)) >> 8) >> 4)) -
1) & (((((0x7f00000)) >> 8) >> 4))) ^ (((((0x7f00000
)) >> 8) >> 4)))) >> (2)) != 0) ? 2 + ((((u_long
)((((((((((0x7f00000)) >> 8) >> 4) >> 2)) -
1) & ((((((0x7f00000)) >> 8) >> 4) >> 2
))) ^ ((((((0x7f00000)) >> 8) >> 4) >> 2)))
) >> (1)) != 0) ? 1 : 0) : ((((u_long)((((((((((0x7f00000
)) >> 8) >> 4))) - 1) & ((((((0x7f00000)) >>
8) >> 4)))) ^ ((((((0x7f00000)) >> 8) >> 4
))))) >> (1)) != 0) ? 1 : 0)) : ((((u_long)(((((((((0x7f00000
)) >> 8))) - 1) & (((((0x7f00000)) >> 8)))) ^
(((((0x7f00000)) >> 8))))) >> (2)) != 0) ? 2 + (
(((u_long)((((((((((0x7f00000)) >> 8)) >> 2)) - 1
) & ((((((0x7f00000)) >> 8)) >> 2))) ^ ((((((
0x7f00000)) >> 8)) >> 2)))) >> (1)) != 0) ?
1 : 0) : ((((u_long)((((((((((0x7f00000)) >> 8)))) - 1
) & ((((((0x7f00000)) >> 8))))) ^ ((((((0x7f00000))
>> 8)))))) >> (1)) != 0) ? 1 : 0))) : ((((u_long
)((((((((0x7f00000)))) - 1) & ((((0x7f00000))))) ^ ((((0x7f00000
)))))) >> (4)) != 0) ? 4 + ((((u_long)(((((((((0x7f00000
))) >> 4)) - 1) & (((((0x7f00000))) >> 4))) ^
(((((0x7f00000))) >> 4)))) >> (2)) != 0) ? 2 + (
(((u_long)((((((((((0x7f00000))) >> 4) >> 2)) - 1
) & ((((((0x7f00000))) >> 4) >> 2))) ^ ((((((
0x7f00000))) >> 4) >> 2)))) >> (1)) != 0) ?
1 : 0) : ((((u_long)((((((((((0x7f00000))) >> 4))) - 1
) & ((((((0x7f00000))) >> 4)))) ^ ((((((0x7f00000))
) >> 4))))) >> (1)) != 0) ? 1 : 0)) : ((((u_long)
(((((((((0x7f00000))))) - 1) & (((((0x7f00000)))))) ^ (((
((0x7f00000))))))) >> (2)) != 0) ? 2 + ((((u_long)(((((
(((((0x7f00000)))) >> 2)) - 1) & ((((((0x7f00000)))
) >> 2))) ^ ((((((0x7f00000)))) >> 2)))) >>
(1)) != 0) ? 1 : 0) : ((((u_long)((((((((((0x7f00000)))))) -
1) & ((((((0x7f00000))))))) ^ ((((((0x7f00000)))))))) >>
(1)) != 0) ? 1 : 0))))))
;
2026 anaparm |= RTW_ANAPARM_TXDACOFF(1<<27);
2027 break;
2028 case RTW_SLEEP:
2029 if (!before_rf)
2030 return;
2031 anaparm |= RTW_ANAPARM_RFPOW_PHILIPS_SLEEP((0x378) << ((((u_long)((((((0x7f00000)) - 1) & ((0x7f00000
))) ^ ((0x7f00000)))) >> (16)) != 0) ? 16 + ((((u_long)
(((((((0x7f00000) >> 16)) - 1) & (((0x7f00000) >>
16))) ^ (((0x7f00000) >> 16)))) >> (8)) != 0) ? 8
+ ((((u_long)((((((((0x7f00000) >> 16) >> 8)) - 1
) & ((((0x7f00000) >> 16) >> 8))) ^ ((((0x7f00000
) >> 16) >> 8)))) >> (4)) != 0) ? 4 + ((((u_long
)(((((((((0x7f00000) >> 16) >> 8) >> 4)) - 1
) & (((((0x7f00000) >> 16) >> 8) >> 4))
) ^ (((((0x7f00000) >> 16) >> 8) >> 4)))) >>
(2)) != 0) ? 2 + ((((u_long)((((((((((0x7f00000) >> 16
) >> 8) >> 4) >> 2)) - 1) & ((((((0x7f00000
) >> 16) >> 8) >> 4) >> 2))) ^ ((((((
0x7f00000) >> 16) >> 8) >> 4) >> 2)))
) >> (1)) != 0) ? 1 : 0) : ((((u_long)((((((((((0x7f00000
) >> 16) >> 8) >> 4))) - 1) & ((((((0x7f00000
) >> 16) >> 8) >> 4)))) ^ ((((((0x7f00000) >>
16) >> 8) >> 4))))) >> (1)) != 0) ? 1 : 0)
) : ((((u_long)(((((((((0x7f00000) >> 16) >> 8)))
- 1) & (((((0x7f00000) >> 16) >> 8)))) ^ (((
((0x7f00000) >> 16) >> 8))))) >> (2)) != 0)
? 2 + ((((u_long)((((((((((0x7f00000) >> 16) >> 8
)) >> 2)) - 1) & ((((((0x7f00000) >> 16) >>
8)) >> 2))) ^ ((((((0x7f00000) >> 16) >> 8
)) >> 2)))) >> (1)) != 0) ? 1 : 0) : ((((u_long)(
(((((((((0x7f00000) >> 16) >> 8)))) - 1) & ((
((((0x7f00000) >> 16) >> 8))))) ^ ((((((0x7f00000
) >> 16) >> 8)))))) >> (1)) != 0) ? 1 : 0))
) : ((((u_long)((((((((0x7f00000) >> 16))) - 1) & (
(((0x7f00000) >> 16)))) ^ ((((0x7f00000) >> 16)))
)) >> (4)) != 0) ? 4 + ((((u_long)(((((((((0x7f00000) >>
16)) >> 4)) - 1) & (((((0x7f00000) >> 16)) >>
4))) ^ (((((0x7f00000) >> 16)) >> 4)))) >>
(2)) != 0) ? 2 + ((((u_long)((((((((((0x7f00000) >> 16
)) >> 4) >> 2)) - 1) & ((((((0x7f00000) >>
16)) >> 4) >> 2))) ^ ((((((0x7f00000) >> 16
)) >> 4) >> 2)))) >> (1)) != 0) ? 1 : 0) : (
(((u_long)((((((((((0x7f00000) >> 16)) >> 4))) - 1
) & ((((((0x7f00000) >> 16)) >> 4)))) ^ (((((
(0x7f00000) >> 16)) >> 4))))) >> (1)) != 0)
? 1 : 0)) : ((((u_long)(((((((((0x7f00000) >> 16)))) -
1) & (((((0x7f00000) >> 16))))) ^ (((((0x7f00000) >>
16)))))) >> (2)) != 0) ? 2 + ((((u_long)((((((((((0x7f00000
) >> 16))) >> 2)) - 1) & ((((((0x7f00000) >>
16))) >> 2))) ^ ((((((0x7f00000) >> 16))) >>
2)))) >> (1)) != 0) ? 1 : 0) : ((((u_long)((((((((((0x7f00000
) >> 16))))) - 1) & ((((((0x7f00000) >> 16)))
))) ^ ((((((0x7f00000) >> 16))))))) >> (1)) != 0)
? 1 : 0)))) : ((((u_long)(((((((0x7f00000))) - 1) & (((0x7f00000
)))) ^ (((0x7f00000))))) >> (8)) != 0) ? 8 + ((((u_long
)((((((((0x7f00000)) >> 8)) - 1) & ((((0x7f00000)) >>
8))) ^ ((((0x7f00000)) >> 8)))) >> (4)) != 0) ? 4
+ ((((u_long)(((((((((0x7f00000)) >> 8) >> 4)) -
1) & (((((0x7f00000)) >> 8) >> 4))) ^ (((((0x7f00000
)) >> 8) >> 4)))) >> (2)) != 0) ? 2 + ((((u_long
)((((((((((0x7f00000)) >> 8) >> 4) >> 2)) -
1) & ((((((0x7f00000)) >> 8) >> 4) >> 2
))) ^ ((((((0x7f00000)) >> 8) >> 4) >> 2)))
) >> (1)) != 0) ? 1 : 0) : ((((u_long)((((((((((0x7f00000
)) >> 8) >> 4))) - 1) & ((((((0x7f00000)) >>
8) >> 4)))) ^ ((((((0x7f00000)) >> 8) >> 4
))))) >> (1)) != 0) ? 1 : 0)) : ((((u_long)(((((((((0x7f00000
)) >> 8))) - 1) & (((((0x7f00000)) >> 8)))) ^
(((((0x7f00000)) >> 8))))) >> (2)) != 0) ? 2 + (
(((u_long)((((((((((0x7f00000)) >> 8)) >> 2)) - 1
) & ((((((0x7f00000)) >> 8)) >> 2))) ^ ((((((
0x7f00000)) >> 8)) >> 2)))) >> (1)) != 0) ?
1 : 0) : ((((u_long)((((((((((0x7f00000)) >> 8)))) - 1
) & ((((((0x7f00000)) >> 8))))) ^ ((((((0x7f00000))
>> 8)))))) >> (1)) != 0) ? 1 : 0))) : ((((u_long
)((((((((0x7f00000)))) - 1) & ((((0x7f00000))))) ^ ((((0x7f00000
)))))) >> (4)) != 0) ? 4 + ((((u_long)(((((((((0x7f00000
))) >> 4)) - 1) & (((((0x7f00000))) >> 4))) ^
(((((0x7f00000))) >> 4)))) >> (2)) != 0) ? 2 + (
(((u_long)((((((((((0x7f00000))) >> 4) >> 2)) - 1
) & ((((((0x7f00000))) >> 4) >> 2))) ^ ((((((
0x7f00000))) >> 4) >> 2)))) >> (1)) != 0) ?
1 : 0) : ((((u_long)((((((((((0x7f00000))) >> 4))) - 1
) & ((((((0x7f00000))) >> 4)))) ^ ((((((0x7f00000))
) >> 4))))) >> (1)) != 0) ? 1 : 0)) : ((((u_long)
(((((((((0x7f00000))))) - 1) & (((((0x7f00000)))))) ^ (((
((0x7f00000))))))) >> (2)) != 0) ? 2 + ((((u_long)(((((
(((((0x7f00000)))) >> 2)) - 1) & ((((((0x7f00000)))
) >> 2))) ^ ((((((0x7f00000)))) >> 2)))) >>
(1)) != 0) ? 1 : 0) : ((((u_long)((((((((((0x7f00000)))))) -
1) & ((((((0x7f00000))))))) ^ ((((((0x7f00000)))))))) >>
(1)) != 0) ? 1 : 0))))))
;
2032 anaparm |= RTW_ANAPARM_TXDACOFF(1<<27);
2033 break;
2034 case RTW_ON:
2035 if (!before_rf)
2036 return;
2037 if (digphy) {
2038 anaparm |= RTW_ANAPARM_RFPOW_DIG_PHILIPS_ON((0x008) << ((((u_long)((((((0x7f00000)) - 1) & ((0x7f00000
))) ^ ((0x7f00000)))) >> (16)) != 0) ? 16 + ((((u_long)
(((((((0x7f00000) >> 16)) - 1) & (((0x7f00000) >>
16))) ^ (((0x7f00000) >> 16)))) >> (8)) != 0) ? 8
+ ((((u_long)((((((((0x7f00000) >> 16) >> 8)) - 1
) & ((((0x7f00000) >> 16) >> 8))) ^ ((((0x7f00000
) >> 16) >> 8)))) >> (4)) != 0) ? 4 + ((((u_long
)(((((((((0x7f00000) >> 16) >> 8) >> 4)) - 1
) & (((((0x7f00000) >> 16) >> 8) >> 4))
) ^ (((((0x7f00000) >> 16) >> 8) >> 4)))) >>
(2)) != 0) ? 2 + ((((u_long)((((((((((0x7f00000) >> 16
) >> 8) >> 4) >> 2)) - 1) & ((((((0x7f00000
) >> 16) >> 8) >> 4) >> 2))) ^ ((((((
0x7f00000) >> 16) >> 8) >> 4) >> 2)))
) >> (1)) != 0) ? 1 : 0) : ((((u_long)((((((((((0x7f00000
) >> 16) >> 8) >> 4))) - 1) & ((((((0x7f00000
) >> 16) >> 8) >> 4)))) ^ ((((((0x7f00000) >>
16) >> 8) >> 4))))) >> (1)) != 0) ? 1 : 0)
) : ((((u_long)(((((((((0x7f00000) >> 16) >> 8)))
- 1) & (((((0x7f00000) >> 16) >> 8)))) ^ (((
((0x7f00000) >> 16) >> 8))))) >> (2)) != 0)
? 2 + ((((u_long)((((((((((0x7f00000) >> 16) >> 8
)) >> 2)) - 1) & ((((((0x7f00000) >> 16) >>
8)) >> 2))) ^ ((((((0x7f00000) >> 16) >> 8
)) >> 2)))) >> (1)) != 0) ? 1 : 0) : ((((u_long)(
(((((((((0x7f00000) >> 16) >> 8)))) - 1) & ((
((((0x7f00000) >> 16) >> 8))))) ^ ((((((0x7f00000
) >> 16) >> 8)))))) >> (1)) != 0) ? 1 : 0))
) : ((((u_long)((((((((0x7f00000) >> 16))) - 1) & (
(((0x7f00000) >> 16)))) ^ ((((0x7f00000) >> 16)))
)) >> (4)) != 0) ? 4 + ((((u_long)(((((((((0x7f00000) >>
16)) >> 4)) - 1) & (((((0x7f00000) >> 16)) >>
4))) ^ (((((0x7f00000) >> 16)) >> 4)))) >>
(2)) != 0) ? 2 + ((((u_long)((((((((((0x7f00000) >> 16
)) >> 4) >> 2)) - 1) & ((((((0x7f00000) >>
16)) >> 4) >> 2))) ^ ((((((0x7f00000) >> 16
)) >> 4) >> 2)))) >> (1)) != 0) ? 1 : 0) : (
(((u_long)((((((((((0x7f00000) >> 16)) >> 4))) - 1
) & ((((((0x7f00000) >> 16)) >> 4)))) ^ (((((
(0x7f00000) >> 16)) >> 4))))) >> (1)) != 0)
? 1 : 0)) : ((((u_long)(((((((((0x7f00000) >> 16)))) -
1) & (((((0x7f00000) >> 16))))) ^ (((((0x7f00000) >>
16)))))) >> (2)) != 0) ? 2 + ((((u_long)((((((((((0x7f00000
) >> 16))) >> 2)) - 1) & ((((((0x7f00000) >>
16))) >> 2))) ^ ((((((0x7f00000) >> 16))) >>
2)))) >> (1)) != 0) ? 1 : 0) : ((((u_long)((((((((((0x7f00000
) >> 16))))) - 1) & ((((((0x7f00000) >> 16)))
))) ^ ((((((0x7f00000) >> 16))))))) >> (1)) != 0)
? 1 : 0)))) : ((((u_long)(((((((0x7f00000))) - 1) & (((0x7f00000
)))) ^ (((0x7f00000))))) >> (8)) != 0) ? 8 + ((((u_long
)((((((((0x7f00000)) >> 8)) - 1) & ((((0x7f00000)) >>
8))) ^ ((((0x7f00000)) >> 8)))) >> (4)) != 0) ? 4
+ ((((u_long)(((((((((0x7f00000)) >> 8) >> 4)) -
1) & (((((0x7f00000)) >> 8) >> 4))) ^ (((((0x7f00000
)) >> 8) >> 4)))) >> (2)) != 0) ? 2 + ((((u_long
)((((((((((0x7f00000)) >> 8) >> 4) >> 2)) -
1) & ((((((0x7f00000)) >> 8) >> 4) >> 2
))) ^ ((((((0x7f00000)) >> 8) >> 4) >> 2)))
) >> (1)) != 0) ? 1 : 0) : ((((u_long)((((((((((0x7f00000
)) >> 8) >> 4))) - 1) & ((((((0x7f00000)) >>
8) >> 4)))) ^ ((((((0x7f00000)) >> 8) >> 4
))))) >> (1)) != 0) ? 1 : 0)) : ((((u_long)(((((((((0x7f00000
)) >> 8))) - 1) & (((((0x7f00000)) >> 8)))) ^
(((((0x7f00000)) >> 8))))) >> (2)) != 0) ? 2 + (
(((u_long)((((((((((0x7f00000)) >> 8)) >> 2)) - 1
) & ((((((0x7f00000)) >> 8)) >> 2))) ^ ((((((
0x7f00000)) >> 8)) >> 2)))) >> (1)) != 0) ?
1 : 0) : ((((u_long)((((((((((0x7f00000)) >> 8)))) - 1
) & ((((((0x7f00000)) >> 8))))) ^ ((((((0x7f00000))
>> 8)))))) >> (1)) != 0) ? 1 : 0))) : ((((u_long
)((((((((0x7f00000)))) - 1) & ((((0x7f00000))))) ^ ((((0x7f00000
)))))) >> (4)) != 0) ? 4 + ((((u_long)(((((((((0x7f00000
))) >> 4)) - 1) & (((((0x7f00000))) >> 4))) ^
(((((0x7f00000))) >> 4)))) >> (2)) != 0) ? 2 + (
(((u_long)((((((((((0x7f00000))) >> 4) >> 2)) - 1
) & ((((((0x7f00000))) >> 4) >> 2))) ^ ((((((
0x7f00000))) >> 4) >> 2)))) >> (1)) != 0) ?
1 : 0) : ((((u_long)((((((((((0x7f00000))) >> 4))) - 1
) & ((((((0x7f00000))) >> 4)))) ^ ((((((0x7f00000))
) >> 4))))) >> (1)) != 0) ? 1 : 0)) : ((((u_long)
(((((((((0x7f00000))))) - 1) & (((((0x7f00000)))))) ^ (((
((0x7f00000))))))) >> (2)) != 0) ? 2 + ((((u_long)(((((
(((((0x7f00000)))) >> 2)) - 1) & ((((((0x7f00000)))
) >> 2))) ^ ((((((0x7f00000)))) >> 2)))) >>
(1)) != 0) ? 1 : 0) : ((((u_long)((((((((((0x7f00000)))))) -
1) & ((((((0x7f00000))))))) ^ ((((((0x7f00000)))))))) >>
(1)) != 0) ? 1 : 0))))))
;
2039 /* XXX guess */
2040 anaparm |= RTW_ANAPARM_TXDACOFF(1<<27);
2041 } else
2042 anaparm |= RTW_ANAPARM_RFPOW_ANA_PHILIPS_ON((0x328) << ((((u_long)((((((0x7f00000)) - 1) & ((0x7f00000
))) ^ ((0x7f00000)))) >> (16)) != 0) ? 16 + ((((u_long)
(((((((0x7f00000) >> 16)) - 1) & (((0x7f00000) >>
16))) ^ (((0x7f00000) >> 16)))) >> (8)) != 0) ? 8
+ ((((u_long)((((((((0x7f00000) >> 16) >> 8)) - 1
) & ((((0x7f00000) >> 16) >> 8))) ^ ((((0x7f00000
) >> 16) >> 8)))) >> (4)) != 0) ? 4 + ((((u_long
)(((((((((0x7f00000) >> 16) >> 8) >> 4)) - 1
) & (((((0x7f00000) >> 16) >> 8) >> 4))
) ^ (((((0x7f00000) >> 16) >> 8) >> 4)))) >>
(2)) != 0) ? 2 + ((((u_long)((((((((((0x7f00000) >> 16
) >> 8) >> 4) >> 2)) - 1) & ((((((0x7f00000
) >> 16) >> 8) >> 4) >> 2))) ^ ((((((
0x7f00000) >> 16) >> 8) >> 4) >> 2)))
) >> (1)) != 0) ? 1 : 0) : ((((u_long)((((((((((0x7f00000
) >> 16) >> 8) >> 4))) - 1) & ((((((0x7f00000
) >> 16) >> 8) >> 4)))) ^ ((((((0x7f00000) >>
16) >> 8) >> 4))))) >> (1)) != 0) ? 1 : 0)
) : ((((u_long)(((((((((0x7f00000) >> 16) >> 8)))
- 1) & (((((0x7f00000) >> 16) >> 8)))) ^ (((
((0x7f00000) >> 16) >> 8))))) >> (2)) != 0)
? 2 + ((((u_long)((((((((((0x7f00000) >> 16) >> 8
)) >> 2)) - 1) & ((((((0x7f00000) >> 16) >>
8)) >> 2))) ^ ((((((0x7f00000) >> 16) >> 8
)) >> 2)))) >> (1)) != 0) ? 1 : 0) : ((((u_long)(
(((((((((0x7f00000) >> 16) >> 8)))) - 1) & ((
((((0x7f00000) >> 16) >> 8))))) ^ ((((((0x7f00000
) >> 16) >> 8)))))) >> (1)) != 0) ? 1 : 0))
) : ((((u_long)((((((((0x7f00000) >> 16))) - 1) & (
(((0x7f00000) >> 16)))) ^ ((((0x7f00000) >> 16)))
)) >> (4)) != 0) ? 4 + ((((u_long)(((((((((0x7f00000) >>
16)) >> 4)) - 1) & (((((0x7f00000) >> 16)) >>
4))) ^ (((((0x7f00000) >> 16)) >> 4)))) >>
(2)) != 0) ? 2 + ((((u_long)((((((((((0x7f00000) >> 16
)) >> 4) >> 2)) - 1) & ((((((0x7f00000) >>
16)) >> 4) >> 2))) ^ ((((((0x7f00000) >> 16
)) >> 4) >> 2)))) >> (1)) != 0) ? 1 : 0) : (
(((u_long)((((((((((0x7f00000) >> 16)) >> 4))) - 1
) & ((((((0x7f00000) >> 16)) >> 4)))) ^ (((((
(0x7f00000) >> 16)) >> 4))))) >> (1)) != 0)
? 1 : 0)) : ((((u_long)(((((((((0x7f00000) >> 16)))) -
1) & (((((0x7f00000) >> 16))))) ^ (((((0x7f00000) >>
16)))))) >> (2)) != 0) ? 2 + ((((u_long)((((((((((0x7f00000
) >> 16))) >> 2)) - 1) & ((((((0x7f00000) >>
16))) >> 2))) ^ ((((((0x7f00000) >> 16))) >>
2)))) >> (1)) != 0) ? 1 : 0) : ((((u_long)((((((((((0x7f00000
) >> 16))))) - 1) & ((((((0x7f00000) >> 16)))
))) ^ ((((((0x7f00000) >> 16))))))) >> (1)) != 0)
? 1 : 0)))) : ((((u_long)(((((((0x7f00000))) - 1) & (((0x7f00000
)))) ^ (((0x7f00000))))) >> (8)) != 0) ? 8 + ((((u_long
)((((((((0x7f00000)) >> 8)) - 1) & ((((0x7f00000)) >>
8))) ^ ((((0x7f00000)) >> 8)))) >> (4)) != 0) ? 4
+ ((((u_long)(((((((((0x7f00000)) >> 8) >> 4)) -
1) & (((((0x7f00000)) >> 8) >> 4))) ^ (((((0x7f00000
)) >> 8) >> 4)))) >> (2)) != 0) ? 2 + ((((u_long
)((((((((((0x7f00000)) >> 8) >> 4) >> 2)) -
1) & ((((((0x7f00000)) >> 8) >> 4) >> 2
))) ^ ((((((0x7f00000)) >> 8) >> 4) >> 2)))
) >> (1)) != 0) ? 1 : 0) : ((((u_long)((((((((((0x7f00000
)) >> 8) >> 4))) - 1) & ((((((0x7f00000)) >>
8) >> 4)))) ^ ((((((0x7f00000)) >> 8) >> 4
))))) >> (1)) != 0) ? 1 : 0)) : ((((u_long)(((((((((0x7f00000
)) >> 8))) - 1) & (((((0x7f00000)) >> 8)))) ^
(((((0x7f00000)) >> 8))))) >> (2)) != 0) ? 2 + (
(((u_long)((((((((((0x7f00000)) >> 8)) >> 2)) - 1
) & ((((((0x7f00000)) >> 8)) >> 2))) ^ ((((((
0x7f00000)) >> 8)) >> 2)))) >> (1)) != 0) ?
1 : 0) : ((((u_long)((((((((((0x7f00000)) >> 8)))) - 1
) & ((((((0x7f00000)) >> 8))))) ^ ((((((0x7f00000))
>> 8)))))) >> (1)) != 0) ? 1 : 0))) : ((((u_long
)((((((((0x7f00000)))) - 1) & ((((0x7f00000))))) ^ ((((0x7f00000
)))))) >> (4)) != 0) ? 4 + ((((u_long)(((((((((0x7f00000
))) >> 4)) - 1) & (((((0x7f00000))) >> 4))) ^
(((((0x7f00000))) >> 4)))) >> (2)) != 0) ? 2 + (
(((u_long)((((((((((0x7f00000))) >> 4) >> 2)) - 1
) & ((((((0x7f00000))) >> 4) >> 2))) ^ ((((((
0x7f00000))) >> 4) >> 2)))) >> (1)) != 0) ?
1 : 0) : ((((u_long)((((((((((0x7f00000))) >> 4))) - 1
) & ((((((0x7f00000))) >> 4)))) ^ ((((((0x7f00000))
) >> 4))))) >> (1)) != 0) ? 1 : 0)) : ((((u_long)
(((((((((0x7f00000))))) - 1) & (((((0x7f00000)))))) ^ (((
((0x7f00000))))))) >> (2)) != 0) ? 2 + ((((u_long)(((((
(((((0x7f00000)))) >> 2)) - 1) & ((((((0x7f00000)))
) >> 2))) ^ ((((((0x7f00000)))) >> 2)))) >>
(1)) != 0) ? 1 : 0) : ((((u_long)((((((((((0x7f00000)))))) -
1) & ((((((0x7f00000))))))) ^ ((((((0x7f00000)))))))) >>
(1)) != 0) ? 1 : 0))))))
;
2043 break;
2044 }
2045 RTW_DPRINTF(RTW_DEBUG_PWR,
2046 ("%s: power state %s, %s RF, reg[ANAPARM] <- %08x\n",
2047 __func__, rtw_pwrstate_string(power),
2048 (before_rf) ? "before" : "after", anaparm));
2049
2050 RTW_WRITE(regs, RTW_ANAPARM_0, anaparm)((*(regs)->r_write32)(regs, 0x54, anaparm));
2051 RTW_SYNC(regs, RTW_ANAPARM_0, RTW_ANAPARM_0)((*(regs)->r_barrier)(regs, 0x54, 0x54, (0x01|0x02)));
2052}
2053
2054void
2055rtw_rtl_pwrstate(struct rtw_regs *regs, enum rtw_pwrstate power,
2056 int before_rf, int digphy)
2057{
2058 /* empty */
2059}
2060
2061void
2062rtw_pwrstate0(struct rtw_softc *sc, enum rtw_pwrstate power, int before_rf,
2063 int digphy)
2064{
2065 struct rtw_regs *regs = &sc->sc_regs;
2066
2067 rtw_set_access(regs, RTW_ACCESS_ANAPARM);
2068
2069 (*sc->sc_pwrstate_cb)(regs, power, before_rf, digphy);
2070
2071 rtw_set_access(regs, RTW_ACCESS_NONE);
2072
2073 return;
2074}
2075
2076int
2077rtw_pwrstate(struct rtw_softc *sc, enum rtw_pwrstate power)
2078{
2079 int rc;
2080
2081 RTW_DPRINTF(RTW_DEBUG_PWR,
2082 ("%s: %s->%s\n", __func__,
2083 rtw_pwrstate_string(sc->sc_pwrstate), rtw_pwrstate_string(power)));
2084
2085 if (sc->sc_pwrstate == power)
2086 return 0;
2087
2088 rtw_pwrstate0(sc, power, 1, sc->sc_flags & RTW_F_DIGPHY0x00000002);
2089 rc = (*sc->sc_rf_pwrstate)(sc, power);
2090 rtw_pwrstate0(sc, power, 0, sc->sc_flags & RTW_F_DIGPHY0x00000002);
2091
2092 switch (power) {
2093 case RTW_ON:
2094 /* TBD set LEDs */
2095 break;
2096 case RTW_SLEEP:
2097 /* TBD */
2098 break;
2099 case RTW_OFF:
2100 /* TBD */
2101 break;
2102 }
2103 if (rc == 0)
2104 sc->sc_pwrstate = power;
2105 else
2106 sc->sc_pwrstate = RTW_OFF;
2107 return rc;
2108}
2109
2110int
2111rtw_tune(struct rtw_softc *sc)
2112{
2113 struct ieee80211com *ic = &sc->sc_ic;
2114 u_int chan, idx;
2115 u_int8_t txpower;
2116 int rc;
2117
2118 KASSERT(ic->ic_bss->ni_chan != NULL)((ic->ic_bss->ni_chan != ((void *)0)) ? (void)0 : __assert
("diagnostic ", "/usr/src/sys/dev/ic/rtw.c", 2118, "ic->ic_bss->ni_chan != NULL"
))
;
2119
2120 chan = ieee80211_chan2ieee(ic, ic->ic_bss->ni_chan);
2121 if (chan == 0 || chan == IEEE80211_CHAN_ANY0xffff)
2122 return 0;
2123
2124 if (chan == sc->sc_cur_chan) {
2125 RTW_DPRINTF(RTW_DEBUG_TUNE,
2126 ("%s: already tuned chan #%d\n", __func__, chan));
2127 return 0;
2128 }
2129
2130 rtw_suspend_ticks(sc);
2131
2132 rtw_io_enable(&sc->sc_regs, RTW_CR_RE(1<<3) | RTW_CR_TE(1<<2), 0);
2133
2134 /* TBD wait for Tx to complete */
2135
2136 KASSERT((sc->sc_flags & RTW_F_ENABLED) != 0)(((sc->sc_flags & 0x00000001) != 0) ? (void)0 : __assert
("diagnostic ", "/usr/src/sys/dev/ic/rtw.c", 2136, "(sc->sc_flags & RTW_F_ENABLED) != 0"
))
;
2137
2138 idx = RTW_SR_TXPOWER10x20 +
2139 ieee80211_chan2ieee(ic, ic->ic_bss->ni_chan) - 1;
2140 KASSERT2(idx >= RTW_SR_TXPOWER1 && idx <= RTW_SR_TXPOWER14,do { if (!(idx >= 0x20 && idx <= 0x2d)) panic (
"%s: channel %d out of range", __func__, idx - 0x20 + 1) ; } while
(0)
2141 ("%s: channel %d out of range", __func__,do { if (!(idx >= 0x20 && idx <= 0x2d)) panic (
"%s: channel %d out of range", __func__, idx - 0x20 + 1) ; } while
(0)
2142 idx - RTW_SR_TXPOWER1 + 1))do { if (!(idx >= 0x20 && idx <= 0x2d)) panic (
"%s: channel %d out of range", __func__, idx - 0x20 + 1) ; } while
(0)
;
2143 txpower = RTW_SR_GET(&sc->sc_srom, idx)(((&sc->sc_srom)->sr_content[(idx)/2] >> (((idx
) % 2 == 0) ? 0 : 8)) & 0xff)
;
Value stored to 'txpower' is never read
2144
2145 if ((rc = rtw_phy_init(sc)) != 0) {
2146 /* XXX condition on powersaving */
2147 printf("%s: phy init failed\n", sc->sc_dev.dv_xname);
2148 }
2149
2150 sc->sc_cur_chan = chan;
2151
2152 rtw_io_enable(&sc->sc_regs, RTW_CR_RE(1<<3) | RTW_CR_TE(1<<2), 1);
2153
2154 rtw_resume_ticks(sc);
2155
2156 return rc;
2157}
2158
2159void
2160rtw_disable(struct rtw_softc *sc)
2161{
2162 int rc;
2163
2164 if ((sc->sc_flags & RTW_F_ENABLED0x00000001) == 0)
2165 return;
2166
2167 /* turn off PHY */
2168 if ((sc->sc_flags & RTW_F_INVALID0x00000080) == 0 &&
2169 (rc = rtw_pwrstate(sc, RTW_OFF)) != 0) {
2170 printf("%s: failed to turn off PHY (%d)\n",
2171 sc->sc_dev.dv_xname, rc);
2172 }
2173
2174 if (sc->sc_disable != NULL((void *)0))
2175 (*sc->sc_disable)(sc);
2176
2177 sc->sc_flags &= ~RTW_F_ENABLED0x00000001;
2178}
2179
2180int
2181rtw_enable(struct rtw_softc *sc)
2182{
2183 if ((sc->sc_flags & RTW_F_ENABLED0x00000001) == 0) {
2184 if (sc->sc_enable != NULL((void *)0) && (*sc->sc_enable)(sc) != 0) {
2185 printf("%s: device enable failed\n",
2186 sc->sc_dev.dv_xname);
2187 return (EIO5);
2188 }
2189 sc->sc_flags |= RTW_F_ENABLED0x00000001;
2190 }
2191 return (0);
2192}
2193
2194void
2195rtw_transmit_config(struct rtw_softc *sc)
2196{
2197 struct rtw_regs *regs = &sc->sc_regs;
2198 u_int32_t tcr;
2199
2200 tcr = RTW_READ(regs, RTW_TCR)((*(regs)->r_read32)(regs, 0x40));
2201
2202 tcr |= RTW_TCR_CWMIN(1<<31);
2203 tcr &= ~RTW_TCR_MXDMA_MASK0xe00000;
2204 tcr |= RTW_TCR_MXDMA_256((4) << ((((u_long)((((((0xe00000)) - 1) & ((0xe00000
))) ^ ((0xe00000)))) >> (16)) != 0) ? 16 + ((((u_long)(
((((((0xe00000) >> 16)) - 1) & (((0xe00000) >>
16))) ^ (((0xe00000) >> 16)))) >> (8)) != 0) ? 8
+ ((((u_long)((((((((0xe00000) >> 16) >> 8)) - 1
) & ((((0xe00000) >> 16) >> 8))) ^ ((((0xe00000
) >> 16) >> 8)))) >> (4)) != 0) ? 4 + ((((u_long
)(((((((((0xe00000) >> 16) >> 8) >> 4)) - 1
) & (((((0xe00000) >> 16) >> 8) >> 4)))
^ (((((0xe00000) >> 16) >> 8) >> 4)))) >>
(2)) != 0) ? 2 + ((((u_long)((((((((((0xe00000) >> 16)
>> 8) >> 4) >> 2)) - 1) & ((((((0xe00000
) >> 16) >> 8) >> 4) >> 2))) ^ ((((((
0xe00000) >> 16) >> 8) >> 4) >> 2))))
>> (1)) != 0) ? 1 : 0) : ((((u_long)((((((((((0xe00000
) >> 16) >> 8) >> 4))) - 1) & ((((((0xe00000
) >> 16) >> 8) >> 4)))) ^ ((((((0xe00000) >>
16) >> 8) >> 4))))) >> (1)) != 0) ? 1 : 0)
) : ((((u_long)(((((((((0xe00000) >> 16) >> 8))) -
1) & (((((0xe00000) >> 16) >> 8)))) ^ (((((0xe00000
) >> 16) >> 8))))) >> (2)) != 0) ? 2 + ((((
u_long)((((((((((0xe00000) >> 16) >> 8)) >>
2)) - 1) & ((((((0xe00000) >> 16) >> 8)) >>
2))) ^ ((((((0xe00000) >> 16) >> 8)) >> 2)
))) >> (1)) != 0) ? 1 : 0) : ((((u_long)((((((((((0xe00000
) >> 16) >> 8)))) - 1) & ((((((0xe00000) >>
16) >> 8))))) ^ ((((((0xe00000) >> 16) >> 8
)))))) >> (1)) != 0) ? 1 : 0))) : ((((u_long)((((((((0xe00000
) >> 16))) - 1) & ((((0xe00000) >> 16)))) ^ (
(((0xe00000) >> 16))))) >> (4)) != 0) ? 4 + ((((u_long
)(((((((((0xe00000) >> 16)) >> 4)) - 1) & (((
((0xe00000) >> 16)) >> 4))) ^ (((((0xe00000) >>
16)) >> 4)))) >> (2)) != 0) ? 2 + ((((u_long)(((
(((((((0xe00000) >> 16)) >> 4) >> 2)) - 1) &
((((((0xe00000) >> 16)) >> 4) >> 2))) ^ ((
((((0xe00000) >> 16)) >> 4) >> 2)))) >>
(1)) != 0) ? 1 : 0) : ((((u_long)((((((((((0xe00000) >>
16)) >> 4))) - 1) & ((((((0xe00000) >> 16)) >>
4)))) ^ ((((((0xe00000) >> 16)) >> 4))))) >>
(1)) != 0) ? 1 : 0)) : ((((u_long)(((((((((0xe00000) >>
16)))) - 1) & (((((0xe00000) >> 16))))) ^ (((((0xe00000
) >> 16)))))) >> (2)) != 0) ? 2 + ((((u_long)((((
((((((0xe00000) >> 16))) >> 2)) - 1) & ((((((
0xe00000) >> 16))) >> 2))) ^ ((((((0xe00000) >>
16))) >> 2)))) >> (1)) != 0) ? 1 : 0) : ((((u_long
)((((((((((0xe00000) >> 16))))) - 1) & ((((((0xe00000
) >> 16)))))) ^ ((((((0xe00000) >> 16))))))) >>
(1)) != 0) ? 1 : 0)))) : ((((u_long)(((((((0xe00000))) - 1) &
(((0xe00000)))) ^ (((0xe00000))))) >> (8)) != 0) ? 8 +
((((u_long)((((((((0xe00000)) >> 8)) - 1) & ((((0xe00000
)) >> 8))) ^ ((((0xe00000)) >> 8)))) >> (4)
) != 0) ? 4 + ((((u_long)(((((((((0xe00000)) >> 8) >>
4)) - 1) & (((((0xe00000)) >> 8) >> 4))) ^ (
((((0xe00000)) >> 8) >> 4)))) >> (2)) != 0)
? 2 + ((((u_long)((((((((((0xe00000)) >> 8) >> 4
) >> 2)) - 1) & ((((((0xe00000)) >> 8) >>
4) >> 2))) ^ ((((((0xe00000)) >> 8) >> 4) >>
2)))) >> (1)) != 0) ? 1 : 0) : ((((u_long)((((((((((0xe00000
)) >> 8) >> 4))) - 1) & ((((((0xe00000)) >>
8) >> 4)))) ^ ((((((0xe00000)) >> 8) >> 4)
)))) >> (1)) != 0) ? 1 : 0)) : ((((u_long)(((((((((0xe00000
)) >> 8))) - 1) & (((((0xe00000)) >> 8)))) ^ (
((((0xe00000)) >> 8))))) >> (2)) != 0) ? 2 + ((((
u_long)((((((((((0xe00000)) >> 8)) >> 2)) - 1) &
((((((0xe00000)) >> 8)) >> 2))) ^ ((((((0xe00000
)) >> 8)) >> 2)))) >> (1)) != 0) ? 1 : 0) :
((((u_long)((((((((((0xe00000)) >> 8)))) - 1) & ((
((((0xe00000)) >> 8))))) ^ ((((((0xe00000)) >> 8)
))))) >> (1)) != 0) ? 1 : 0))) : ((((u_long)((((((((0xe00000
)))) - 1) & ((((0xe00000))))) ^ ((((0xe00000)))))) >>
(4)) != 0) ? 4 + ((((u_long)(((((((((0xe00000))) >> 4)
) - 1) & (((((0xe00000))) >> 4))) ^ (((((0xe00000))
) >> 4)))) >> (2)) != 0) ? 2 + ((((u_long)(((((((
(((0xe00000))) >> 4) >> 2)) - 1) & ((((((0xe00000
))) >> 4) >> 2))) ^ ((((((0xe00000))) >> 4)
>> 2)))) >> (1)) != 0) ? 1 : 0) : ((((u_long)(((
(((((((0xe00000))) >> 4))) - 1) & ((((((0xe00000)))
>> 4)))) ^ ((((((0xe00000))) >> 4))))) >> (
1)) != 0) ? 1 : 0)) : ((((u_long)(((((((((0xe00000))))) - 1) &
(((((0xe00000)))))) ^ (((((0xe00000))))))) >> (2)) != 0
) ? 2 + ((((u_long)((((((((((0xe00000)))) >> 2)) - 1) &
((((((0xe00000)))) >> 2))) ^ ((((((0xe00000)))) >>
2)))) >> (1)) != 0) ? 1 : 0) : ((((u_long)((((((((((0xe00000
)))))) - 1) & ((((((0xe00000))))))) ^ ((((((0xe00000)))))
))) >> (1)) != 0) ? 1 : 0))))))
;
2205 if ((sc->sc_flags & RTW_F_RTL81850x00000008) == 0)
2206 tcr |= RTW8180_TCR_SAT(1<<24); /* send ACK as fast as possible */
2207 tcr &= ~RTW_TCR_LBK_MASK0x60000;
2208 tcr |= RTW_TCR_LBK_NORMAL((0) << ((((u_long)((((((0x60000)) - 1) & ((0x60000
))) ^ ((0x60000)))) >> (16)) != 0) ? 16 + ((((u_long)((
(((((0x60000) >> 16)) - 1) & (((0x60000) >> 16
))) ^ (((0x60000) >> 16)))) >> (8)) != 0) ? 8 + (
(((u_long)((((((((0x60000) >> 16) >> 8)) - 1) &
((((0x60000) >> 16) >> 8))) ^ ((((0x60000) >>
16) >> 8)))) >> (4)) != 0) ? 4 + ((((u_long)((((
(((((0x60000) >> 16) >> 8) >> 4)) - 1) &
(((((0x60000) >> 16) >> 8) >> 4))) ^ (((((
0x60000) >> 16) >> 8) >> 4)))) >> (2)
) != 0) ? 2 + ((((u_long)((((((((((0x60000) >> 16) >>
8) >> 4) >> 2)) - 1) & ((((((0x60000) >>
16) >> 8) >> 4) >> 2))) ^ ((((((0x60000) >>
16) >> 8) >> 4) >> 2)))) >> (1)) != 0
) ? 1 : 0) : ((((u_long)((((((((((0x60000) >> 16) >>
8) >> 4))) - 1) & ((((((0x60000) >> 16) >>
8) >> 4)))) ^ ((((((0x60000) >> 16) >> 8) >>
4))))) >> (1)) != 0) ? 1 : 0)) : ((((u_long)(((((((((0x60000
) >> 16) >> 8))) - 1) & (((((0x60000) >>
16) >> 8)))) ^ (((((0x60000) >> 16) >> 8))
))) >> (2)) != 0) ? 2 + ((((u_long)((((((((((0x60000) >>
16) >> 8)) >> 2)) - 1) & ((((((0x60000) >>
16) >> 8)) >> 2))) ^ ((((((0x60000) >> 16)
>> 8)) >> 2)))) >> (1)) != 0) ? 1 : 0) : (
(((u_long)((((((((((0x60000) >> 16) >> 8)))) - 1)
& ((((((0x60000) >> 16) >> 8))))) ^ ((((((0x60000
) >> 16) >> 8)))))) >> (1)) != 0) ? 1 : 0))
) : ((((u_long)((((((((0x60000) >> 16))) - 1) & (((
(0x60000) >> 16)))) ^ ((((0x60000) >> 16))))) >>
(4)) != 0) ? 4 + ((((u_long)(((((((((0x60000) >> 16)) >>
4)) - 1) & (((((0x60000) >> 16)) >> 4))) ^ (
((((0x60000) >> 16)) >> 4)))) >> (2)) != 0)
? 2 + ((((u_long)((((((((((0x60000) >> 16)) >> 4
) >> 2)) - 1) & ((((((0x60000) >> 16)) >>
4) >> 2))) ^ ((((((0x60000) >> 16)) >> 4) >>
2)))) >> (1)) != 0) ? 1 : 0) : ((((u_long)((((((((((0x60000
) >> 16)) >> 4))) - 1) & ((((((0x60000) >>
16)) >> 4)))) ^ ((((((0x60000) >> 16)) >> 4
))))) >> (1)) != 0) ? 1 : 0)) : ((((u_long)(((((((((0x60000
) >> 16)))) - 1) & (((((0x60000) >> 16))))) ^
(((((0x60000) >> 16)))))) >> (2)) != 0) ? 2 + ((
((u_long)((((((((((0x60000) >> 16))) >> 2)) - 1) &
((((((0x60000) >> 16))) >> 2))) ^ ((((((0x60000)
>> 16))) >> 2)))) >> (1)) != 0) ? 1 : 0) :
((((u_long)((((((((((0x60000) >> 16))))) - 1) & ((
((((0x60000) >> 16)))))) ^ ((((((0x60000) >> 16))
))))) >> (1)) != 0) ? 1 : 0)))) : ((((u_long)(((((((0x60000
))) - 1) & (((0x60000)))) ^ (((0x60000))))) >> (8))
!= 0) ? 8 + ((((u_long)((((((((0x60000)) >> 8)) - 1) &
((((0x60000)) >> 8))) ^ ((((0x60000)) >> 8)))) >>
(4)) != 0) ? 4 + ((((u_long)(((((((((0x60000)) >> 8) >>
4)) - 1) & (((((0x60000)) >> 8) >> 4))) ^ ((
(((0x60000)) >> 8) >> 4)))) >> (2)) != 0) ?
2 + ((((u_long)((((((((((0x60000)) >> 8) >> 4) >>
2)) - 1) & ((((((0x60000)) >> 8) >> 4) >>
2))) ^ ((((((0x60000)) >> 8) >> 4) >> 2)))
) >> (1)) != 0) ? 1 : 0) : ((((u_long)((((((((((0x60000
)) >> 8) >> 4))) - 1) & ((((((0x60000)) >>
8) >> 4)))) ^ ((((((0x60000)) >> 8) >> 4))
))) >> (1)) != 0) ? 1 : 0)) : ((((u_long)(((((((((0x60000
)) >> 8))) - 1) & (((((0x60000)) >> 8)))) ^ (
((((0x60000)) >> 8))))) >> (2)) != 0) ? 2 + ((((u_long
)((((((((((0x60000)) >> 8)) >> 2)) - 1) & (((
(((0x60000)) >> 8)) >> 2))) ^ ((((((0x60000)) >>
8)) >> 2)))) >> (1)) != 0) ? 1 : 0) : ((((u_long
)((((((((((0x60000)) >> 8)))) - 1) & ((((((0x60000)
) >> 8))))) ^ ((((((0x60000)) >> 8)))))) >>
(1)) != 0) ? 1 : 0))) : ((((u_long)((((((((0x60000)))) - 1) &
((((0x60000))))) ^ ((((0x60000)))))) >> (4)) != 0) ? 4
+ ((((u_long)(((((((((0x60000))) >> 4)) - 1) & (((
((0x60000))) >> 4))) ^ (((((0x60000))) >> 4)))) >>
(2)) != 0) ? 2 + ((((u_long)((((((((((0x60000))) >> 4)
>> 2)) - 1) & ((((((0x60000))) >> 4) >>
2))) ^ ((((((0x60000))) >> 4) >> 2)))) >> (
1)) != 0) ? 1 : 0) : ((((u_long)((((((((((0x60000))) >>
4))) - 1) & ((((((0x60000))) >> 4)))) ^ ((((((0x60000
))) >> 4))))) >> (1)) != 0) ? 1 : 0)) : ((((u_long
)(((((((((0x60000))))) - 1) & (((((0x60000)))))) ^ (((((0x60000
))))))) >> (2)) != 0) ? 2 + ((((u_long)((((((((((0x60000
)))) >> 2)) - 1) & ((((((0x60000)))) >> 2))) ^
((((((0x60000)))) >> 2)))) >> (1)) != 0) ? 1 : 0
) : ((((u_long)((((((((((0x60000)))))) - 1) & ((((((0x60000
))))))) ^ ((((((0x60000)))))))) >> (1)) != 0) ? 1 : 0))
))))
; /* normal operating mode */
2209
2210 /* set short/long retry limits */
2211 tcr &= ~(RTW_TCR_SRL_MASK0xff00|RTW_TCR_LRL_MASK0xff);
2212 tcr |= LSHIFT(4, RTW_TCR_SRL_MASK)((4) << ((((u_long)((((((0xff00)) - 1) & ((0xff00))
) ^ ((0xff00)))) >> (16)) != 0) ? 16 + ((((u_long)(((((
((0xff00) >> 16)) - 1) & (((0xff00) >> 16))) ^
(((0xff00) >> 16)))) >> (8)) != 0) ? 8 + ((((u_long
)((((((((0xff00) >> 16) >> 8)) - 1) & ((((0xff00
) >> 16) >> 8))) ^ ((((0xff00) >> 16) >>
8)))) >> (4)) != 0) ? 4 + ((((u_long)(((((((((0xff00) >>
16) >> 8) >> 4)) - 1) & (((((0xff00) >>
16) >> 8) >> 4))) ^ (((((0xff00) >> 16) >>
8) >> 4)))) >> (2)) != 0) ? 2 + ((((u_long)(((((
(((((0xff00) >> 16) >> 8) >> 4) >> 2)
) - 1) & ((((((0xff00) >> 16) >> 8) >> 4
) >> 2))) ^ ((((((0xff00) >> 16) >> 8) >>
4) >> 2)))) >> (1)) != 0) ? 1 : 0) : ((((u_long)
((((((((((0xff00) >> 16) >> 8) >> 4))) - 1)
& ((((((0xff00) >> 16) >> 8) >> 4)))) ^
((((((0xff00) >> 16) >> 8) >> 4))))) >>
(1)) != 0) ? 1 : 0)) : ((((u_long)(((((((((0xff00) >> 16
) >> 8))) - 1) & (((((0xff00) >> 16) >>
8)))) ^ (((((0xff00) >> 16) >> 8))))) >> (
2)) != 0) ? 2 + ((((u_long)((((((((((0xff00) >> 16) >>
8)) >> 2)) - 1) & ((((((0xff00) >> 16) >>
8)) >> 2))) ^ ((((((0xff00) >> 16) >> 8)) >>
2)))) >> (1)) != 0) ? 1 : 0) : ((((u_long)((((((((((0xff00
) >> 16) >> 8)))) - 1) & ((((((0xff00) >>
16) >> 8))))) ^ ((((((0xff00) >> 16) >> 8)
))))) >> (1)) != 0) ? 1 : 0))) : ((((u_long)((((((((0xff00
) >> 16))) - 1) & ((((0xff00) >> 16)))) ^ (((
(0xff00) >> 16))))) >> (4)) != 0) ? 4 + ((((u_long
)(((((((((0xff00) >> 16)) >> 4)) - 1) & (((((
0xff00) >> 16)) >> 4))) ^ (((((0xff00) >> 16
)) >> 4)))) >> (2)) != 0) ? 2 + ((((u_long)((((((
((((0xff00) >> 16)) >> 4) >> 2)) - 1) &
((((((0xff00) >> 16)) >> 4) >> 2))) ^ ((((
((0xff00) >> 16)) >> 4) >> 2)))) >> (
1)) != 0) ? 1 : 0) : ((((u_long)((((((((((0xff00) >> 16
)) >> 4))) - 1) & ((((((0xff00) >> 16)) >>
4)))) ^ ((((((0xff00) >> 16)) >> 4))))) >>
(1)) != 0) ? 1 : 0)) : ((((u_long)(((((((((0xff00) >> 16
)))) - 1) & (((((0xff00) >> 16))))) ^ (((((0xff00) >>
16)))))) >> (2)) != 0) ? 2 + ((((u_long)((((((((((0xff00
) >> 16))) >> 2)) - 1) & ((((((0xff00) >>
16))) >> 2))) ^ ((((((0xff00) >> 16))) >> 2
)))) >> (1)) != 0) ? 1 : 0) : ((((u_long)((((((((((0xff00
) >> 16))))) - 1) & ((((((0xff00) >> 16))))))
^ ((((((0xff00) >> 16))))))) >> (1)) != 0) ? 1 :
0)))) : ((((u_long)(((((((0xff00))) - 1) & (((0xff00))))
^ (((0xff00))))) >> (8)) != 0) ? 8 + ((((u_long)((((((
((0xff00)) >> 8)) - 1) & ((((0xff00)) >> 8)))
^ ((((0xff00)) >> 8)))) >> (4)) != 0) ? 4 + ((((
u_long)(((((((((0xff00)) >> 8) >> 4)) - 1) & (
((((0xff00)) >> 8) >> 4))) ^ (((((0xff00)) >>
8) >> 4)))) >> (2)) != 0) ? 2 + ((((u_long)(((((
(((((0xff00)) >> 8) >> 4) >> 2)) - 1) &
((((((0xff00)) >> 8) >> 4) >> 2))) ^ (((((
(0xff00)) >> 8) >> 4) >> 2)))) >> (1)
) != 0) ? 1 : 0) : ((((u_long)((((((((((0xff00)) >> 8) >>
4))) - 1) & ((((((0xff00)) >> 8) >> 4)))) ^ (
(((((0xff00)) >> 8) >> 4))))) >> (1)) != 0)
? 1 : 0)) : ((((u_long)(((((((((0xff00)) >> 8))) - 1) &
(((((0xff00)) >> 8)))) ^ (((((0xff00)) >> 8)))))
>> (2)) != 0) ? 2 + ((((u_long)((((((((((0xff00)) >>
8)) >> 2)) - 1) & ((((((0xff00)) >> 8)) >>
2))) ^ ((((((0xff00)) >> 8)) >> 2)))) >> (
1)) != 0) ? 1 : 0) : ((((u_long)((((((((((0xff00)) >> 8
)))) - 1) & ((((((0xff00)) >> 8))))) ^ ((((((0xff00
)) >> 8)))))) >> (1)) != 0) ? 1 : 0))) : ((((u_long
)((((((((0xff00)))) - 1) & ((((0xff00))))) ^ ((((0xff00))
)))) >> (4)) != 0) ? 4 + ((((u_long)(((((((((0xff00))) >>
4)) - 1) & (((((0xff00))) >> 4))) ^ (((((0xff00)))
>> 4)))) >> (2)) != 0) ? 2 + ((((u_long)((((((((
((0xff00))) >> 4) >> 2)) - 1) & ((((((0xff00)
)) >> 4) >> 2))) ^ ((((((0xff00))) >> 4) >>
2)))) >> (1)) != 0) ? 1 : 0) : ((((u_long)((((((((((0xff00
))) >> 4))) - 1) & ((((((0xff00))) >> 4)))) ^
((((((0xff00))) >> 4))))) >> (1)) != 0) ? 1 : 0)
) : ((((u_long)(((((((((0xff00))))) - 1) & (((((0xff00)))
))) ^ (((((0xff00))))))) >> (2)) != 0) ? 2 + ((((u_long
)((((((((((0xff00)))) >> 2)) - 1) & ((((((0xff00)))
) >> 2))) ^ ((((((0xff00)))) >> 2)))) >> (1
)) != 0) ? 1 : 0) : ((((u_long)((((((((((0xff00)))))) - 1) &
((((((0xff00))))))) ^ ((((((0xff00)))))))) >> (1)) != 0
) ? 1 : 0))))))
| LSHIFT(4, RTW_TCR_LRL_MASK)((4) << ((((u_long)((((((0xff)) - 1) & ((0xff))) ^ (
(0xff)))) >> (16)) != 0) ? 16 + ((((u_long)(((((((0xff)
>> 16)) - 1) & (((0xff) >> 16))) ^ (((0xff) >>
16)))) >> (8)) != 0) ? 8 + ((((u_long)((((((((0xff) >>
16) >> 8)) - 1) & ((((0xff) >> 16) >> 8
))) ^ ((((0xff) >> 16) >> 8)))) >> (4)) != 0
) ? 4 + ((((u_long)(((((((((0xff) >> 16) >> 8) >>
4)) - 1) & (((((0xff) >> 16) >> 8) >> 4
))) ^ (((((0xff) >> 16) >> 8) >> 4)))) >>
(2)) != 0) ? 2 + ((((u_long)((((((((((0xff) >> 16) >>
8) >> 4) >> 2)) - 1) & ((((((0xff) >> 16
) >> 8) >> 4) >> 2))) ^ ((((((0xff) >>
16) >> 8) >> 4) >> 2)))) >> (1)) != 0
) ? 1 : 0) : ((((u_long)((((((((((0xff) >> 16) >>
8) >> 4))) - 1) & ((((((0xff) >> 16) >>
8) >> 4)))) ^ ((((((0xff) >> 16) >> 8) >>
4))))) >> (1)) != 0) ? 1 : 0)) : ((((u_long)(((((((((0xff
) >> 16) >> 8))) - 1) & (((((0xff) >> 16
) >> 8)))) ^ (((((0xff) >> 16) >> 8))))) >>
(2)) != 0) ? 2 + ((((u_long)((((((((((0xff) >> 16) >>
8)) >> 2)) - 1) & ((((((0xff) >> 16) >>
8)) >> 2))) ^ ((((((0xff) >> 16) >> 8)) >>
2)))) >> (1)) != 0) ? 1 : 0) : ((((u_long)((((((((((0xff
) >> 16) >> 8)))) - 1) & ((((((0xff) >>
16) >> 8))))) ^ ((((((0xff) >> 16) >> 8)))
))) >> (1)) != 0) ? 1 : 0))) : ((((u_long)((((((((0xff)
>> 16))) - 1) & ((((0xff) >> 16)))) ^ ((((0xff
) >> 16))))) >> (4)) != 0) ? 4 + ((((u_long)(((((
((((0xff) >> 16)) >> 4)) - 1) & (((((0xff) >>
16)) >> 4))) ^ (((((0xff) >> 16)) >> 4))))
>> (2)) != 0) ? 2 + ((((u_long)((((((((((0xff) >>
16)) >> 4) >> 2)) - 1) & ((((((0xff) >>
16)) >> 4) >> 2))) ^ ((((((0xff) >> 16)) >>
4) >> 2)))) >> (1)) != 0) ? 1 : 0) : ((((u_long)
((((((((((0xff) >> 16)) >> 4))) - 1) & ((((((
0xff) >> 16)) >> 4)))) ^ ((((((0xff) >> 16)
) >> 4))))) >> (1)) != 0) ? 1 : 0)) : ((((u_long)
(((((((((0xff) >> 16)))) - 1) & (((((0xff) >>
16))))) ^ (((((0xff) >> 16)))))) >> (2)) != 0) ?
2 + ((((u_long)((((((((((0xff) >> 16))) >> 2)) -
1) & ((((((0xff) >> 16))) >> 2))) ^ ((((((0xff
) >> 16))) >> 2)))) >> (1)) != 0) ? 1 : 0) :
((((u_long)((((((((((0xff) >> 16))))) - 1) & (((((
(0xff) >> 16)))))) ^ ((((((0xff) >> 16))))))) >>
(1)) != 0) ? 1 : 0)))) : ((((u_long)(((((((0xff))) - 1) &
(((0xff)))) ^ (((0xff))))) >> (8)) != 0) ? 8 + ((((u_long
)((((((((0xff)) >> 8)) - 1) & ((((0xff)) >> 8
))) ^ ((((0xff)) >> 8)))) >> (4)) != 0) ? 4 + (((
(u_long)(((((((((0xff)) >> 8) >> 4)) - 1) & (
((((0xff)) >> 8) >> 4))) ^ (((((0xff)) >> 8
) >> 4)))) >> (2)) != 0) ? 2 + ((((u_long)(((((((
(((0xff)) >> 8) >> 4) >> 2)) - 1) & (((
(((0xff)) >> 8) >> 4) >> 2))) ^ ((((((0xff)
) >> 8) >> 4) >> 2)))) >> (1)) != 0) ?
1 : 0) : ((((u_long)((((((((((0xff)) >> 8) >> 4)
)) - 1) & ((((((0xff)) >> 8) >> 4)))) ^ (((((
(0xff)) >> 8) >> 4))))) >> (1)) != 0) ? 1 :
0)) : ((((u_long)(((((((((0xff)) >> 8))) - 1) & ((
(((0xff)) >> 8)))) ^ (((((0xff)) >> 8))))) >>
(2)) != 0) ? 2 + ((((u_long)((((((((((0xff)) >> 8)) >>
2)) - 1) & ((((((0xff)) >> 8)) >> 2))) ^ (((
(((0xff)) >> 8)) >> 2)))) >> (1)) != 0) ? 1
: 0) : ((((u_long)((((((((((0xff)) >> 8)))) - 1) &
((((((0xff)) >> 8))))) ^ ((((((0xff)) >> 8))))))
>> (1)) != 0) ? 1 : 0))) : ((((u_long)((((((((0xff))))
- 1) & ((((0xff))))) ^ ((((0xff)))))) >> (4)) != 0
) ? 4 + ((((u_long)(((((((((0xff))) >> 4)) - 1) & (
((((0xff))) >> 4))) ^ (((((0xff))) >> 4)))) >>
(2)) != 0) ? 2 + ((((u_long)((((((((((0xff))) >> 4) >>
2)) - 1) & ((((((0xff))) >> 4) >> 2))) ^ (((
(((0xff))) >> 4) >> 2)))) >> (1)) != 0) ? 1
: 0) : ((((u_long)((((((((((0xff))) >> 4))) - 1) &
((((((0xff))) >> 4)))) ^ ((((((0xff))) >> 4)))))
>> (1)) != 0) ? 1 : 0)) : ((((u_long)(((((((((0xff))))
) - 1) & (((((0xff)))))) ^ (((((0xff))))))) >> (2))
!= 0) ? 2 + ((((u_long)((((((((((0xff)))) >> 2)) - 1) &
((((((0xff)))) >> 2))) ^ ((((((0xff)))) >> 2))))
>> (1)) != 0) ? 1 : 0) : ((((u_long)((((((((((0xff))))
)) - 1) & ((((((0xff))))))) ^ ((((((0xff)))))))) >>
(1)) != 0) ? 1 : 0))))))
;
2213
2214 tcr &= ~RTW_TCR_CRC(1<<16); /* NIC appends CRC32 */
2215
2216 RTW_WRITE(regs, RTW_TCR, tcr)((*(regs)->r_write32)(regs, 0x40, tcr));
2217 RTW_SYNC(regs, RTW_TCR, RTW_TCR)((*(regs)->r_barrier)(regs, 0x40, 0x40, (0x01|0x02)));
2218}
2219
2220void
2221rtw_enable_interrupts(struct rtw_softc *sc)
2222{
2223 struct rtw_regs *regs = &sc->sc_regs;
2224
2225 sc->sc_inten = RTW_INTR_RX((1<<1)|(1<<0))|RTW_INTR_TX((1<<3)|(1<<2)|(1<<9)| (1<<8)|(1<<
7)|(1<<6)| (1<<11)|(1<<10))
|RTW_INTR_BEACON((1<<13)|(1<<11)|(1<<10))|RTW_INTR_ATIMINT(1<<12);
2226 sc->sc_inten |= RTW_INTR_IOERROR((1<<15)|(1<<5)|(1<<4))|RTW_INTR_TIMEOUT(1<<14);
2227
2228 RTW_WRITE16(regs, RTW_IMR, sc->sc_inten)((*(regs)->r_write16)(regs, 0x3c, sc->sc_inten));
2229 RTW_WBW(regs, RTW_IMR, RTW_ISR)((*(regs)->r_barrier)(regs, 0x3c, 0x3e, 0x02));
2230 RTW_WRITE16(regs, RTW_ISR, 0xffff)((*(regs)->r_write16)(regs, 0x3e, 0xffff));
2231 RTW_SYNC(regs, RTW_IMR, RTW_ISR)((*(regs)->r_barrier)(regs, 0x3c, 0x3e, (0x01|0x02)));
2232
2233 /* XXX necessary? */
2234 if (sc->sc_intr_ack != NULL((void *)0))
2235 (*sc->sc_intr_ack)(regs);
2236}
2237
2238void
2239rtw_set_nettype(struct rtw_softc *sc, enum ieee80211_opmode opmode)
2240{
2241 uint8_t msr;
2242
2243 /* I'm guessing that MSR is protected as CONFIG[0123] are. */
2244 rtw_set_access(&sc->sc_regs, RTW_ACCESS_CONFIG);
2245
2246 msr = RTW_READ8(&sc->sc_regs, RTW_MSR)((*(&sc->sc_regs)->r_read8)(&sc->sc_regs, 0x58
))
& ~RTW_MSR_NETYPE_MASK0xc;
2247
2248 switch (opmode) {
2249#ifndef IEEE80211_STA_ONLY
2250 case IEEE80211_M_AHDEMO:
2251 case IEEE80211_M_IBSS:
2252 msr |= RTW_MSR_NETYPE_ADHOC_OK((1) << ((((u_long)((((((0xc)) - 1) & ((0xc))) ^ ((
0xc)))) >> (16)) != 0) ? 16 + ((((u_long)(((((((0xc) >>
16)) - 1) & (((0xc) >> 16))) ^ (((0xc) >> 16
)))) >> (8)) != 0) ? 8 + ((((u_long)((((((((0xc) >>
16) >> 8)) - 1) & ((((0xc) >> 16) >> 8
))) ^ ((((0xc) >> 16) >> 8)))) >> (4)) != 0
) ? 4 + ((((u_long)(((((((((0xc) >> 16) >> 8) >>
4)) - 1) & (((((0xc) >> 16) >> 8) >> 4
))) ^ (((((0xc) >> 16) >> 8) >> 4)))) >>
(2)) != 0) ? 2 + ((((u_long)((((((((((0xc) >> 16) >>
8) >> 4) >> 2)) - 1) & ((((((0xc) >> 16
) >> 8) >> 4) >> 2))) ^ ((((((0xc) >>
16) >> 8) >> 4) >> 2)))) >> (1)) != 0
) ? 1 : 0) : ((((u_long)((((((((((0xc) >> 16) >> 8
) >> 4))) - 1) & ((((((0xc) >> 16) >> 8
) >> 4)))) ^ ((((((0xc) >> 16) >> 8) >>
4))))) >> (1)) != 0) ? 1 : 0)) : ((((u_long)(((((((((0xc
) >> 16) >> 8))) - 1) & (((((0xc) >> 16
) >> 8)))) ^ (((((0xc) >> 16) >> 8))))) >>
(2)) != 0) ? 2 + ((((u_long)((((((((((0xc) >> 16) >>
8)) >> 2)) - 1) & ((((((0xc) >> 16) >>
8)) >> 2))) ^ ((((((0xc) >> 16) >> 8)) >>
2)))) >> (1)) != 0) ? 1 : 0) : ((((u_long)((((((((((0xc
) >> 16) >> 8)))) - 1) & ((((((0xc) >> 16
) >> 8))))) ^ ((((((0xc) >> 16) >> 8)))))) >>
(1)) != 0) ? 1 : 0))) : ((((u_long)((((((((0xc) >> 16)
)) - 1) & ((((0xc) >> 16)))) ^ ((((0xc) >> 16
))))) >> (4)) != 0) ? 4 + ((((u_long)(((((((((0xc) >>
16)) >> 4)) - 1) & (((((0xc) >> 16)) >>
4))) ^ (((((0xc) >> 16)) >> 4)))) >> (2)) !=
0) ? 2 + ((((u_long)((((((((((0xc) >> 16)) >> 4)
>> 2)) - 1) & ((((((0xc) >> 16)) >> 4)
>> 2))) ^ ((((((0xc) >> 16)) >> 4) >>
2)))) >> (1)) != 0) ? 1 : 0) : ((((u_long)((((((((((0xc
) >> 16)) >> 4))) - 1) & ((((((0xc) >> 16
)) >> 4)))) ^ ((((((0xc) >> 16)) >> 4))))) >>
(1)) != 0) ? 1 : 0)) : ((((u_long)(((((((((0xc) >> 16)
))) - 1) & (((((0xc) >> 16))))) ^ (((((0xc) >>
16)))))) >> (2)) != 0) ? 2 + ((((u_long)((((((((((0xc)
>> 16))) >> 2)) - 1) & ((((((0xc) >> 16
))) >> 2))) ^ ((((((0xc) >> 16))) >> 2)))) >>
(1)) != 0) ? 1 : 0) : ((((u_long)((((((((((0xc) >> 16)
)))) - 1) & ((((((0xc) >> 16)))))) ^ ((((((0xc) >>
16))))))) >> (1)) != 0) ? 1 : 0)))) : ((((u_long)(((((
((0xc))) - 1) & (((0xc)))) ^ (((0xc))))) >> (8)) !=
0) ? 8 + ((((u_long)((((((((0xc)) >> 8)) - 1) & ((
((0xc)) >> 8))) ^ ((((0xc)) >> 8)))) >> (4)
) != 0) ? 4 + ((((u_long)(((((((((0xc)) >> 8) >> 4
)) - 1) & (((((0xc)) >> 8) >> 4))) ^ (((((0xc
)) >> 8) >> 4)))) >> (2)) != 0) ? 2 + ((((u_long
)((((((((((0xc)) >> 8) >> 4) >> 2)) - 1) &
((((((0xc)) >> 8) >> 4) >> 2))) ^ ((((((0xc
)) >> 8) >> 4) >> 2)))) >> (1)) != 0)
? 1 : 0) : ((((u_long)((((((((((0xc)) >> 8) >> 4
))) - 1) & ((((((0xc)) >> 8) >> 4)))) ^ (((((
(0xc)) >> 8) >> 4))))) >> (1)) != 0) ? 1 : 0
)) : ((((u_long)(((((((((0xc)) >> 8))) - 1) & (((((
0xc)) >> 8)))) ^ (((((0xc)) >> 8))))) >> (2
)) != 0) ? 2 + ((((u_long)((((((((((0xc)) >> 8)) >>
2)) - 1) & ((((((0xc)) >> 8)) >> 2))) ^ ((((
((0xc)) >> 8)) >> 2)))) >> (1)) != 0) ? 1 :
0) : ((((u_long)((((((((((0xc)) >> 8)))) - 1) & ((
((((0xc)) >> 8))))) ^ ((((((0xc)) >> 8)))))) >>
(1)) != 0) ? 1 : 0))) : ((((u_long)((((((((0xc)))) - 1) &
((((0xc))))) ^ ((((0xc)))))) >> (4)) != 0) ? 4 + ((((u_long
)(((((((((0xc))) >> 4)) - 1) & (((((0xc))) >>
4))) ^ (((((0xc))) >> 4)))) >> (2)) != 0) ? 2 + (
(((u_long)((((((((((0xc))) >> 4) >> 2)) - 1) &
((((((0xc))) >> 4) >> 2))) ^ ((((((0xc))) >>
4) >> 2)))) >> (1)) != 0) ? 1 : 0) : ((((u_long)
((((((((((0xc))) >> 4))) - 1) & ((((((0xc))) >>
4)))) ^ ((((((0xc))) >> 4))))) >> (1)) != 0) ? 1
: 0)) : ((((u_long)(((((((((0xc))))) - 1) & (((((0xc))))
)) ^ (((((0xc))))))) >> (2)) != 0) ? 2 + ((((u_long)(((
(((((((0xc)))) >> 2)) - 1) & ((((((0xc)))) >>
2))) ^ ((((((0xc)))) >> 2)))) >> (1)) != 0) ? 1 :
0) : ((((u_long)((((((((((0xc)))))) - 1) & ((((((0xc))))
))) ^ ((((((0xc)))))))) >> (1)) != 0) ? 1 : 0))))))
;
2253 break;
2254 case IEEE80211_M_HOSTAP:
2255 msr |= RTW_MSR_NETYPE_AP_OK((3) << ((((u_long)((((((0xc)) - 1) & ((0xc))) ^ ((
0xc)))) >> (16)) != 0) ? 16 + ((((u_long)(((((((0xc) >>
16)) - 1) & (((0xc) >> 16))) ^ (((0xc) >> 16
)))) >> (8)) != 0) ? 8 + ((((u_long)((((((((0xc) >>
16) >> 8)) - 1) & ((((0xc) >> 16) >> 8
))) ^ ((((0xc) >> 16) >> 8)))) >> (4)) != 0
) ? 4 + ((((u_long)(((((((((0xc) >> 16) >> 8) >>
4)) - 1) & (((((0xc) >> 16) >> 8) >> 4
))) ^ (((((0xc) >> 16) >> 8) >> 4)))) >>
(2)) != 0) ? 2 + ((((u_long)((((((((((0xc) >> 16) >>
8) >> 4) >> 2)) - 1) & ((((((0xc) >> 16
) >> 8) >> 4) >> 2))) ^ ((((((0xc) >>
16) >> 8) >> 4) >> 2)))) >> (1)) != 0
) ? 1 : 0) : ((((u_long)((((((((((0xc) >> 16) >> 8
) >> 4))) - 1) & ((((((0xc) >> 16) >> 8
) >> 4)))) ^ ((((((0xc) >> 16) >> 8) >>
4))))) >> (1)) != 0) ? 1 : 0)) : ((((u_long)(((((((((0xc
) >> 16) >> 8))) - 1) & (((((0xc) >> 16
) >> 8)))) ^ (((((0xc) >> 16) >> 8))))) >>
(2)) != 0) ? 2 + ((((u_long)((((((((((0xc) >> 16) >>
8)) >> 2)) - 1) & ((((((0xc) >> 16) >>
8)) >> 2))) ^ ((((((0xc) >> 16) >> 8)) >>
2)))) >> (1)) != 0) ? 1 : 0) : ((((u_long)((((((((((0xc
) >> 16) >> 8)))) - 1) & ((((((0xc) >> 16
) >> 8))))) ^ ((((((0xc) >> 16) >> 8)))))) >>
(1)) != 0) ? 1 : 0))) : ((((u_long)((((((((0xc) >> 16)
)) - 1) & ((((0xc) >> 16)))) ^ ((((0xc) >> 16
))))) >> (4)) != 0) ? 4 + ((((u_long)(((((((((0xc) >>
16)) >> 4)) - 1) & (((((0xc) >> 16)) >>
4))) ^ (((((0xc) >> 16)) >> 4)))) >> (2)) !=
0) ? 2 + ((((u_long)((((((((((0xc) >> 16)) >> 4)
>> 2)) - 1) & ((((((0xc) >> 16)) >> 4)
>> 2))) ^ ((((((0xc) >> 16)) >> 4) >>
2)))) >> (1)) != 0) ? 1 : 0) : ((((u_long)((((((((((0xc
) >> 16)) >> 4))) - 1) & ((((((0xc) >> 16
)) >> 4)))) ^ ((((((0xc) >> 16)) >> 4))))) >>
(1)) != 0) ? 1 : 0)) : ((((u_long)(((((((((0xc) >> 16)
))) - 1) & (((((0xc) >> 16))))) ^ (((((0xc) >>
16)))))) >> (2)) != 0) ? 2 + ((((u_long)((((((((((0xc)
>> 16))) >> 2)) - 1) & ((((((0xc) >> 16
))) >> 2))) ^ ((((((0xc) >> 16))) >> 2)))) >>
(1)) != 0) ? 1 : 0) : ((((u_long)((((((((((0xc) >> 16)
)))) - 1) & ((((((0xc) >> 16)))))) ^ ((((((0xc) >>
16))))))) >> (1)) != 0) ? 1 : 0)))) : ((((u_long)(((((
((0xc))) - 1) & (((0xc)))) ^ (((0xc))))) >> (8)) !=
0) ? 8 + ((((u_long)((((((((0xc)) >> 8)) - 1) & ((
((0xc)) >> 8))) ^ ((((0xc)) >> 8)))) >> (4)
) != 0) ? 4 + ((((u_long)(((((((((0xc)) >> 8) >> 4
)) - 1) & (((((0xc)) >> 8) >> 4))) ^ (((((0xc
)) >> 8) >> 4)))) >> (2)) != 0) ? 2 + ((((u_long
)((((((((((0xc)) >> 8) >> 4) >> 2)) - 1) &
((((((0xc)) >> 8) >> 4) >> 2))) ^ ((((((0xc
)) >> 8) >> 4) >> 2)))) >> (1)) != 0)
? 1 : 0) : ((((u_long)((((((((((0xc)) >> 8) >> 4
))) - 1) & ((((((0xc)) >> 8) >> 4)))) ^ (((((
(0xc)) >> 8) >> 4))))) >> (1)) != 0) ? 1 : 0
)) : ((((u_long)(((((((((0xc)) >> 8))) - 1) & (((((
0xc)) >> 8)))) ^ (((((0xc)) >> 8))))) >> (2
)) != 0) ? 2 + ((((u_long)((((((((((0xc)) >> 8)) >>
2)) - 1) & ((((((0xc)) >> 8)) >> 2))) ^ ((((
((0xc)) >> 8)) >> 2)))) >> (1)) != 0) ? 1 :
0) : ((((u_long)((((((((((0xc)) >> 8)))) - 1) & ((
((((0xc)) >> 8))))) ^ ((((((0xc)) >> 8)))))) >>
(1)) != 0) ? 1 : 0))) : ((((u_long)((((((((0xc)))) - 1) &
((((0xc))))) ^ ((((0xc)))))) >> (4)) != 0) ? 4 + ((((u_long
)(((((((((0xc))) >> 4)) - 1) & (((((0xc))) >>
4))) ^ (((((0xc))) >> 4)))) >> (2)) != 0) ? 2 + (
(((u_long)((((((((((0xc))) >> 4) >> 2)) - 1) &
((((((0xc))) >> 4) >> 2))) ^ ((((((0xc))) >>
4) >> 2)))) >> (1)) != 0) ? 1 : 0) : ((((u_long)
((((((((((0xc))) >> 4))) - 1) & ((((((0xc))) >>
4)))) ^ ((((((0xc))) >> 4))))) >> (1)) != 0) ? 1
: 0)) : ((((u_long)(((((((((0xc))))) - 1) & (((((0xc))))
)) ^ (((((0xc))))))) >> (2)) != 0) ? 2 + ((((u_long)(((
(((((((0xc)))) >> 2)) - 1) & ((((((0xc)))) >>
2))) ^ ((((((0xc)))) >> 2)))) >> (1)) != 0) ? 1 :
0) : ((((u_long)((((((((((0xc)))))) - 1) & ((((((0xc))))
))) ^ ((((((0xc)))))))) >> (1)) != 0) ? 1 : 0))))))
;
2256 break;
2257#endif
2258 case IEEE80211_M_MONITOR:
2259 /* XXX */
2260 msr |= RTW_MSR_NETYPE_NOLINK((0) << ((((u_long)((((((0xc)) - 1) & ((0xc))) ^ ((
0xc)))) >> (16)) != 0) ? 16 + ((((u_long)(((((((0xc) >>
16)) - 1) & (((0xc) >> 16))) ^ (((0xc) >> 16
)))) >> (8)) != 0) ? 8 + ((((u_long)((((((((0xc) >>
16) >> 8)) - 1) & ((((0xc) >> 16) >> 8
))) ^ ((((0xc) >> 16) >> 8)))) >> (4)) != 0
) ? 4 + ((((u_long)(((((((((0xc) >> 16) >> 8) >>
4)) - 1) & (((((0xc) >> 16) >> 8) >> 4
))) ^ (((((0xc) >> 16) >> 8) >> 4)))) >>
(2)) != 0) ? 2 + ((((u_long)((((((((((0xc) >> 16) >>
8) >> 4) >> 2)) - 1) & ((((((0xc) >> 16
) >> 8) >> 4) >> 2))) ^ ((((((0xc) >>
16) >> 8) >> 4) >> 2)))) >> (1)) != 0
) ? 1 : 0) : ((((u_long)((((((((((0xc) >> 16) >> 8
) >> 4))) - 1) & ((((((0xc) >> 16) >> 8
) >> 4)))) ^ ((((((0xc) >> 16) >> 8) >>
4))))) >> (1)) != 0) ? 1 : 0)) : ((((u_long)(((((((((0xc
) >> 16) >> 8))) - 1) & (((((0xc) >> 16
) >> 8)))) ^ (((((0xc) >> 16) >> 8))))) >>
(2)) != 0) ? 2 + ((((u_long)((((((((((0xc) >> 16) >>
8)) >> 2)) - 1) & ((((((0xc) >> 16) >>
8)) >> 2))) ^ ((((((0xc) >> 16) >> 8)) >>
2)))) >> (1)) != 0) ? 1 : 0) : ((((u_long)((((((((((0xc
) >> 16) >> 8)))) - 1) & ((((((0xc) >> 16
) >> 8))))) ^ ((((((0xc) >> 16) >> 8)))))) >>
(1)) != 0) ? 1 : 0))) : ((((u_long)((((((((0xc) >> 16)
)) - 1) & ((((0xc) >> 16)))) ^ ((((0xc) >> 16
))))) >> (4)) != 0) ? 4 + ((((u_long)(((((((((0xc) >>
16)) >> 4)) - 1) & (((((0xc) >> 16)) >>
4))) ^ (((((0xc) >> 16)) >> 4)))) >> (2)) !=
0) ? 2 + ((((u_long)((((((((((0xc) >> 16)) >> 4)
>> 2)) - 1) & ((((((0xc) >> 16)) >> 4)
>> 2))) ^ ((((((0xc) >> 16)) >> 4) >>
2)))) >> (1)) != 0) ? 1 : 0) : ((((u_long)((((((((((0xc
) >> 16)) >> 4))) - 1) & ((((((0xc) >> 16
)) >> 4)))) ^ ((((((0xc) >> 16)) >> 4))))) >>
(1)) != 0) ? 1 : 0)) : ((((u_long)(((((((((0xc) >> 16)
))) - 1) & (((((0xc) >> 16))))) ^ (((((0xc) >>
16)))))) >> (2)) != 0) ? 2 + ((((u_long)((((((((((0xc)
>> 16))) >> 2)) - 1) & ((((((0xc) >> 16
))) >> 2))) ^ ((((((0xc) >> 16))) >> 2)))) >>
(1)) != 0) ? 1 : 0) : ((((u_long)((((((((((0xc) >> 16)
)))) - 1) & ((((((0xc) >> 16)))))) ^ ((((((0xc) >>
16))))))) >> (1)) != 0) ? 1 : 0)))) : ((((u_long)(((((
((0xc))) - 1) & (((0xc)))) ^ (((0xc))))) >> (8)) !=
0) ? 8 + ((((u_long)((((((((0xc)) >> 8)) - 1) & ((
((0xc)) >> 8))) ^ ((((0xc)) >> 8)))) >> (4)
) != 0) ? 4 + ((((u_long)(((((((((0xc)) >> 8) >> 4
)) - 1) & (((((0xc)) >> 8) >> 4))) ^ (((((0xc
)) >> 8) >> 4)))) >> (2)) != 0) ? 2 + ((((u_long
)((((((((((0xc)) >> 8) >> 4) >> 2)) - 1) &
((((((0xc)) >> 8) >> 4) >> 2))) ^ ((((((0xc
)) >> 8) >> 4) >> 2)))) >> (1)) != 0)
? 1 : 0) : ((((u_long)((((((((((0xc)) >> 8) >> 4
))) - 1) & ((((((0xc)) >> 8) >> 4)))) ^ (((((
(0xc)) >> 8) >> 4))))) >> (1)) != 0) ? 1 : 0
)) : ((((u_long)(((((((((0xc)) >> 8))) - 1) & (((((
0xc)) >> 8)))) ^ (((((0xc)) >> 8))))) >> (2
)) != 0) ? 2 + ((((u_long)((((((((((0xc)) >> 8)) >>
2)) - 1) & ((((((0xc)) >> 8)) >> 2))) ^ ((((
((0xc)) >> 8)) >> 2)))) >> (1)) != 0) ? 1 :
0) : ((((u_long)((((((((((0xc)) >> 8)))) - 1) & ((
((((0xc)) >> 8))))) ^ ((((((0xc)) >> 8)))))) >>
(1)) != 0) ? 1 : 0))) : ((((u_long)((((((((0xc)))) - 1) &
((((0xc))))) ^ ((((0xc)))))) >> (4)) != 0) ? 4 + ((((u_long
)(((((((((0xc))) >> 4)) - 1) & (((((0xc))) >>
4))) ^ (((((0xc))) >> 4)))) >> (2)) != 0) ? 2 + (
(((u_long)((((((((((0xc))) >> 4) >> 2)) - 1) &
((((((0xc))) >> 4) >> 2))) ^ ((((((0xc))) >>
4) >> 2)))) >> (1)) != 0) ? 1 : 0) : ((((u_long)
((((((((((0xc))) >> 4))) - 1) & ((((((0xc))) >>
4)))) ^ ((((((0xc))) >> 4))))) >> (1)) != 0) ? 1
: 0)) : ((((u_long)(((((((((0xc))))) - 1) & (((((0xc))))
)) ^ (((((0xc))))))) >> (2)) != 0) ? 2 + ((((u_long)(((
(((((((0xc)))) >> 2)) - 1) & ((((((0xc)))) >>
2))) ^ ((((((0xc)))) >> 2)))) >> (1)) != 0) ? 1 :
0) : ((((u_long)((((((((((0xc)))))) - 1) & ((((((0xc))))
))) ^ ((((((0xc)))))))) >> (1)) != 0) ? 1 : 0))))))
;
2261 break;
2262 case IEEE80211_M_STA:
2263 msr |= RTW_MSR_NETYPE_INFRA_OK((2) << ((((u_long)((((((0xc)) - 1) & ((0xc))) ^ ((
0xc)))) >> (16)) != 0) ? 16 + ((((u_long)(((((((0xc) >>
16)) - 1) & (((0xc) >> 16))) ^ (((0xc) >> 16
)))) >> (8)) != 0) ? 8 + ((((u_long)((((((((0xc) >>
16) >> 8)) - 1) & ((((0xc) >> 16) >> 8
))) ^ ((((0xc) >> 16) >> 8)))) >> (4)) != 0
) ? 4 + ((((u_long)(((((((((0xc) >> 16) >> 8) >>
4)) - 1) & (((((0xc) >> 16) >> 8) >> 4
))) ^ (((((0xc) >> 16) >> 8) >> 4)))) >>
(2)) != 0) ? 2 + ((((u_long)((((((((((0xc) >> 16) >>
8) >> 4) >> 2)) - 1) & ((((((0xc) >> 16
) >> 8) >> 4) >> 2))) ^ ((((((0xc) >>
16) >> 8) >> 4) >> 2)))) >> (1)) != 0
) ? 1 : 0) : ((((u_long)((((((((((0xc) >> 16) >> 8
) >> 4))) - 1) & ((((((0xc) >> 16) >> 8
) >> 4)))) ^ ((((((0xc) >> 16) >> 8) >>
4))))) >> (1)) != 0) ? 1 : 0)) : ((((u_long)(((((((((0xc
) >> 16) >> 8))) - 1) & (((((0xc) >> 16
) >> 8)))) ^ (((((0xc) >> 16) >> 8))))) >>
(2)) != 0) ? 2 + ((((u_long)((((((((((0xc) >> 16) >>
8)) >> 2)) - 1) & ((((((0xc) >> 16) >>
8)) >> 2))) ^ ((((((0xc) >> 16) >> 8)) >>
2)))) >> (1)) != 0) ? 1 : 0) : ((((u_long)((((((((((0xc
) >> 16) >> 8)))) - 1) & ((((((0xc) >> 16
) >> 8))))) ^ ((((((0xc) >> 16) >> 8)))))) >>
(1)) != 0) ? 1 : 0))) : ((((u_long)((((((((0xc) >> 16)
)) - 1) & ((((0xc) >> 16)))) ^ ((((0xc) >> 16
))))) >> (4)) != 0) ? 4 + ((((u_long)(((((((((0xc) >>
16)) >> 4)) - 1) & (((((0xc) >> 16)) >>
4))) ^ (((((0xc) >> 16)) >> 4)))) >> (2)) !=
0) ? 2 + ((((u_long)((((((((((0xc) >> 16)) >> 4)
>> 2)) - 1) & ((((((0xc) >> 16)) >> 4)
>> 2))) ^ ((((((0xc) >> 16)) >> 4) >>
2)))) >> (1)) != 0) ? 1 : 0) : ((((u_long)((((((((((0xc
) >> 16)) >> 4))) - 1) & ((((((0xc) >> 16
)) >> 4)))) ^ ((((((0xc) >> 16)) >> 4))))) >>
(1)) != 0) ? 1 : 0)) : ((((u_long)(((((((((0xc) >> 16)
))) - 1) & (((((0xc) >> 16))))) ^ (((((0xc) >>
16)))))) >> (2)) != 0) ? 2 + ((((u_long)((((((((((0xc)
>> 16))) >> 2)) - 1) & ((((((0xc) >> 16
))) >> 2))) ^ ((((((0xc) >> 16))) >> 2)))) >>
(1)) != 0) ? 1 : 0) : ((((u_long)((((((((((0xc) >> 16)
)))) - 1) & ((((((0xc) >> 16)))))) ^ ((((((0xc) >>
16))))))) >> (1)) != 0) ? 1 : 0)))) : ((((u_long)(((((
((0xc))) - 1) & (((0xc)))) ^ (((0xc))))) >> (8)) !=
0) ? 8 + ((((u_long)((((((((0xc)) >> 8)) - 1) & ((
((0xc)) >> 8))) ^ ((((0xc)) >> 8)))) >> (4)
) != 0) ? 4 + ((((u_long)(((((((((0xc)) >> 8) >> 4
)) - 1) & (((((0xc)) >> 8) >> 4))) ^ (((((0xc
)) >> 8) >> 4)))) >> (2)) != 0) ? 2 + ((((u_long
)((((((((((0xc)) >> 8) >> 4) >> 2)) - 1) &
((((((0xc)) >> 8) >> 4) >> 2))) ^ ((((((0xc
)) >> 8) >> 4) >> 2)))) >> (1)) != 0)
? 1 : 0) : ((((u_long)((((((((((0xc)) >> 8) >> 4
))) - 1) & ((((((0xc)) >> 8) >> 4)))) ^ (((((
(0xc)) >> 8) >> 4))))) >> (1)) != 0) ? 1 : 0
)) : ((((u_long)(((((((((0xc)) >> 8))) - 1) & (((((
0xc)) >> 8)))) ^ (((((0xc)) >> 8))))) >> (2
)) != 0) ? 2 + ((((u_long)((((((((((0xc)) >> 8)) >>
2)) - 1) & ((((((0xc)) >> 8)) >> 2))) ^ ((((
((0xc)) >> 8)) >> 2)))) >> (1)) != 0) ? 1 :
0) : ((((u_long)((((((((((0xc)) >> 8)))) - 1) & ((
((((0xc)) >> 8))))) ^ ((((((0xc)) >> 8)))))) >>
(1)) != 0) ? 1 : 0))) : ((((u_long)((((((((0xc)))) - 1) &
((((0xc))))) ^ ((((0xc)))))) >> (4)) != 0) ? 4 + ((((u_long
)(((((((((0xc))) >> 4)) - 1) & (((((0xc))) >>
4))) ^ (((((0xc))) >> 4)))) >> (2)) != 0) ? 2 + (
(((u_long)((((((((((0xc))) >> 4) >> 2)) - 1) &
((((((0xc))) >> 4) >> 2))) ^ ((((((0xc))) >>
4) >> 2)))) >> (1)) != 0) ? 1 : 0) : ((((u_long)
((((((((((0xc))) >> 4))) - 1) & ((((((0xc))) >>
4)))) ^ ((((((0xc))) >> 4))))) >> (1)) != 0) ? 1
: 0)) : ((((u_long)(((((((((0xc))))) - 1) & (((((0xc))))
)) ^ (((((0xc))))))) >> (2)) != 0) ? 2 + ((((u_long)(((
(((((((0xc)))) >> 2)) - 1) & ((((((0xc)))) >>
2))) ^ ((((((0xc)))) >> 2)))) >> (1)) != 0) ? 1 :
0) : ((((u_long)((((((((((0xc)))))) - 1) & ((((((0xc))))
))) ^ ((((((0xc)))))))) >> (1)) != 0) ? 1 : 0))))))
;
2264 break;
2265 default:
2266 break;
2267 }
2268 RTW_WRITE8(&sc->sc_regs, RTW_MSR, msr)((*(&sc->sc_regs)->r_write8)(&sc->sc_regs, 0x58
, msr))
;
2269
2270 rtw_set_access(&sc->sc_regs, RTW_ACCESS_NONE);
2271}
2272
2273void
2274rtw_pktfilt_load(struct rtw_softc *sc)
2275{
2276 struct rtw_regs *regs = &sc->sc_regs;
2277 struct ieee80211com *ic = &sc->sc_ic;
2278 struct arpcom *ac = &ic->ic_ac;
2279 struct ifnet *ifp = &sc->sc_ic.ic_ific_ac.ac_if;
2280 int hash;
2281 u_int32_t hashes[2] = { 0, 0 };
2282 struct ether_multi *enm;
2283 struct ether_multistep step;
2284
2285 /* XXX might be necessary to stop Rx/Tx engines while setting filters */
2286
2287 sc->sc_rcr &= ~RTW_RCR_PKTFILTER_MASK( (1<<0) | (1<<3) | (1<<19) | (1<<5) |
(1<<21) | (1<<18) | (1<<12) | (1<<2)
| (1<<20) | (1<<1) | (1<<22) | 0)
;
2288 sc->sc_rcr &= ~(RTW_RCR_MXDMA_MASK0x700 | RTW8180_RCR_RXFTH_MASK0xe000);
2289
2290 sc->sc_rcr |= RTW_RCR_PKTFILTER_DEFAULT( (1<<18) | (1<<20) | (1<<1) | (1<<22
) | 0)
;
2291 /* MAC auto-reset PHY (huh?) */
2292 sc->sc_rcr |= RTW_RCR_ENMARP(1<<28);
2293 /* DMA whole Rx packets, only. Set Tx DMA burst size to 1024 bytes. */
2294 sc->sc_rcr |= RTW_RCR_MXDMA_1024((6) << ((((u_long)((((((0x700)) - 1) & ((0x700))) ^
((0x700)))) >> (16)) != 0) ? 16 + ((((u_long)(((((((0x700
) >> 16)) - 1) & (((0x700) >> 16))) ^ (((0x700
) >> 16)))) >> (8)) != 0) ? 8 + ((((u_long)((((((
((0x700) >> 16) >> 8)) - 1) & ((((0x700) >>
16) >> 8))) ^ ((((0x700) >> 16) >> 8)))) >>
(4)) != 0) ? 4 + ((((u_long)(((((((((0x700) >> 16) >>
8) >> 4)) - 1) & (((((0x700) >> 16) >>
8) >> 4))) ^ (((((0x700) >> 16) >> 8) >>
4)))) >> (2)) != 0) ? 2 + ((((u_long)((((((((((0x700) >>
16) >> 8) >> 4) >> 2)) - 1) & ((((((0x700
) >> 16) >> 8) >> 4) >> 2))) ^ ((((((
0x700) >> 16) >> 8) >> 4) >> 2)))) >>
(1)) != 0) ? 1 : 0) : ((((u_long)((((((((((0x700) >> 16
) >> 8) >> 4))) - 1) & ((((((0x700) >> 16
) >> 8) >> 4)))) ^ ((((((0x700) >> 16) >>
8) >> 4))))) >> (1)) != 0) ? 1 : 0)) : ((((u_long
)(((((((((0x700) >> 16) >> 8))) - 1) & (((((0x700
) >> 16) >> 8)))) ^ (((((0x700) >> 16) >>
8))))) >> (2)) != 0) ? 2 + ((((u_long)((((((((((0x700)
>> 16) >> 8)) >> 2)) - 1) & ((((((0x700
) >> 16) >> 8)) >> 2))) ^ ((((((0x700) >>
16) >> 8)) >> 2)))) >> (1)) != 0) ? 1 : 0)
: ((((u_long)((((((((((0x700) >> 16) >> 8)))) - 1
) & ((((((0x700) >> 16) >> 8))))) ^ ((((((0x700
) >> 16) >> 8)))))) >> (1)) != 0) ? 1 : 0))
) : ((((u_long)((((((((0x700) >> 16))) - 1) & ((((0x700
) >> 16)))) ^ ((((0x700) >> 16))))) >> (4))
!= 0) ? 4 + ((((u_long)(((((((((0x700) >> 16)) >>
4)) - 1) & (((((0x700) >> 16)) >> 4))) ^ (((
((0x700) >> 16)) >> 4)))) >> (2)) != 0) ? 2
+ ((((u_long)((((((((((0x700) >> 16)) >> 4) >>
2)) - 1) & ((((((0x700) >> 16)) >> 4) >>
2))) ^ ((((((0x700) >> 16)) >> 4) >> 2))))
>> (1)) != 0) ? 1 : 0) : ((((u_long)((((((((((0x700) >>
16)) >> 4))) - 1) & ((((((0x700) >> 16)) >>
4)))) ^ ((((((0x700) >> 16)) >> 4))))) >> (
1)) != 0) ? 1 : 0)) : ((((u_long)(((((((((0x700) >> 16)
))) - 1) & (((((0x700) >> 16))))) ^ (((((0x700) >>
16)))))) >> (2)) != 0) ? 2 + ((((u_long)((((((((((0x700
) >> 16))) >> 2)) - 1) & ((((((0x700) >>
16))) >> 2))) ^ ((((((0x700) >> 16))) >> 2
)))) >> (1)) != 0) ? 1 : 0) : ((((u_long)((((((((((0x700
) >> 16))))) - 1) & ((((((0x700) >> 16)))))) ^
((((((0x700) >> 16))))))) >> (1)) != 0) ? 1 : 0)
))) : ((((u_long)(((((((0x700))) - 1) & (((0x700)))) ^ ((
(0x700))))) >> (8)) != 0) ? 8 + ((((u_long)((((((((0x700
)) >> 8)) - 1) & ((((0x700)) >> 8))) ^ ((((0x700
)) >> 8)))) >> (4)) != 0) ? 4 + ((((u_long)((((((
(((0x700)) >> 8) >> 4)) - 1) & (((((0x700)) >>
8) >> 4))) ^ (((((0x700)) >> 8) >> 4)))) >>
(2)) != 0) ? 2 + ((((u_long)((((((((((0x700)) >> 8) >>
4) >> 2)) - 1) & ((((((0x700)) >> 8) >>
4) >> 2))) ^ ((((((0x700)) >> 8) >> 4) >>
2)))) >> (1)) != 0) ? 1 : 0) : ((((u_long)((((((((((0x700
)) >> 8) >> 4))) - 1) & ((((((0x700)) >>
8) >> 4)))) ^ ((((((0x700)) >> 8) >> 4))))
) >> (1)) != 0) ? 1 : 0)) : ((((u_long)(((((((((0x700))
>> 8))) - 1) & (((((0x700)) >> 8)))) ^ (((((
0x700)) >> 8))))) >> (2)) != 0) ? 2 + ((((u_long)
((((((((((0x700)) >> 8)) >> 2)) - 1) & ((((((
0x700)) >> 8)) >> 2))) ^ ((((((0x700)) >> 8
)) >> 2)))) >> (1)) != 0) ? 1 : 0) : ((((u_long)(
(((((((((0x700)) >> 8)))) - 1) & ((((((0x700)) >>
8))))) ^ ((((((0x700)) >> 8)))))) >> (1)) != 0) ?
1 : 0))) : ((((u_long)((((((((0x700)))) - 1) & ((((0x700
))))) ^ ((((0x700)))))) >> (4)) != 0) ? 4 + ((((u_long)
(((((((((0x700))) >> 4)) - 1) & (((((0x700))) >>
4))) ^ (((((0x700))) >> 4)))) >> (2)) != 0) ? 2 +
((((u_long)((((((((((0x700))) >> 4) >> 2)) - 1) &
((((((0x700))) >> 4) >> 2))) ^ ((((((0x700))) >>
4) >> 2)))) >> (1)) != 0) ? 1 : 0) : ((((u_long)
((((((((((0x700))) >> 4))) - 1) & ((((((0x700))) >>
4)))) ^ ((((((0x700))) >> 4))))) >> (1)) != 0) ?
1 : 0)) : ((((u_long)(((((((((0x700))))) - 1) & (((((0x700
)))))) ^ (((((0x700))))))) >> (2)) != 0) ? 2 + ((((u_long
)((((((((((0x700)))) >> 2)) - 1) & ((((((0x700)))) >>
2))) ^ ((((((0x700)))) >> 2)))) >> (1)) != 0) ? 1
: 0) : ((((u_long)((((((((((0x700)))))) - 1) & ((((((0x700
))))))) ^ ((((((0x700)))))))) >> (1)) != 0) ? 1 : 0))))
))
| RTW8180_RCR_RXFTH_WHOLE((7) << ((((u_long)((((((0xe000)) - 1) & ((0xe000))
) ^ ((0xe000)))) >> (16)) != 0) ? 16 + ((((u_long)(((((
((0xe000) >> 16)) - 1) & (((0xe000) >> 16))) ^
(((0xe000) >> 16)))) >> (8)) != 0) ? 8 + ((((u_long
)((((((((0xe000) >> 16) >> 8)) - 1) & ((((0xe000
) >> 16) >> 8))) ^ ((((0xe000) >> 16) >>
8)))) >> (4)) != 0) ? 4 + ((((u_long)(((((((((0xe000) >>
16) >> 8) >> 4)) - 1) & (((((0xe000) >>
16) >> 8) >> 4))) ^ (((((0xe000) >> 16) >>
8) >> 4)))) >> (2)) != 0) ? 2 + ((((u_long)(((((
(((((0xe000) >> 16) >> 8) >> 4) >> 2)
) - 1) & ((((((0xe000) >> 16) >> 8) >> 4
) >> 2))) ^ ((((((0xe000) >> 16) >> 8) >>
4) >> 2)))) >> (1)) != 0) ? 1 : 0) : ((((u_long)
((((((((((0xe000) >> 16) >> 8) >> 4))) - 1)
& ((((((0xe000) >> 16) >> 8) >> 4)))) ^
((((((0xe000) >> 16) >> 8) >> 4))))) >>
(1)) != 0) ? 1 : 0)) : ((((u_long)(((((((((0xe000) >> 16
) >> 8))) - 1) & (((((0xe000) >> 16) >>
8)))) ^ (((((0xe000) >> 16) >> 8))))) >> (
2)) != 0) ? 2 + ((((u_long)((((((((((0xe000) >> 16) >>
8)) >> 2)) - 1) & ((((((0xe000) >> 16) >>
8)) >> 2))) ^ ((((((0xe000) >> 16) >> 8)) >>
2)))) >> (1)) != 0) ? 1 : 0) : ((((u_long)((((((((((0xe000
) >> 16) >> 8)))) - 1) & ((((((0xe000) >>
16) >> 8))))) ^ ((((((0xe000) >> 16) >> 8)
))))) >> (1)) != 0) ? 1 : 0))) : ((((u_long)((((((((0xe000
) >> 16))) - 1) & ((((0xe000) >> 16)))) ^ (((
(0xe000) >> 16))))) >> (4)) != 0) ? 4 + ((((u_long
)(((((((((0xe000) >> 16)) >> 4)) - 1) & (((((
0xe000) >> 16)) >> 4))) ^ (((((0xe000) >> 16
)) >> 4)))) >> (2)) != 0) ? 2 + ((((u_long)((((((
((((0xe000) >> 16)) >> 4) >> 2)) - 1) &
((((((0xe000) >> 16)) >> 4) >> 2))) ^ ((((
((0xe000) >> 16)) >> 4) >> 2)))) >> (
1)) != 0) ? 1 : 0) : ((((u_long)((((((((((0xe000) >> 16
)) >> 4))) - 1) & ((((((0xe000) >> 16)) >>
4)))) ^ ((((((0xe000) >> 16)) >> 4))))) >>
(1)) != 0) ? 1 : 0)) : ((((u_long)(((((((((0xe000) >> 16
)))) - 1) & (((((0xe000) >> 16))))) ^ (((((0xe000) >>
16)))))) >> (2)) != 0) ? 2 + ((((u_long)((((((((((0xe000
) >> 16))) >> 2)) - 1) & ((((((0xe000) >>
16))) >> 2))) ^ ((((((0xe000) >> 16))) >> 2
)))) >> (1)) != 0) ? 1 : 0) : ((((u_long)((((((((((0xe000
) >> 16))))) - 1) & ((((((0xe000) >> 16))))))
^ ((((((0xe000) >> 16))))))) >> (1)) != 0) ? 1 :
0)))) : ((((u_long)(((((((0xe000))) - 1) & (((0xe000))))
^ (((0xe000))))) >> (8)) != 0) ? 8 + ((((u_long)((((((
((0xe000)) >> 8)) - 1) & ((((0xe000)) >> 8)))
^ ((((0xe000)) >> 8)))) >> (4)) != 0) ? 4 + ((((
u_long)(((((((((0xe000)) >> 8) >> 4)) - 1) & (
((((0xe000)) >> 8) >> 4))) ^ (((((0xe000)) >>
8) >> 4)))) >> (2)) != 0) ? 2 + ((((u_long)(((((
(((((0xe000)) >> 8) >> 4) >> 2)) - 1) &
((((((0xe000)) >> 8) >> 4) >> 2))) ^ (((((
(0xe000)) >> 8) >> 4) >> 2)))) >> (1)
) != 0) ? 1 : 0) : ((((u_long)((((((((((0xe000)) >> 8) >>
4))) - 1) & ((((((0xe000)) >> 8) >> 4)))) ^ (
(((((0xe000)) >> 8) >> 4))))) >> (1)) != 0)
? 1 : 0)) : ((((u_long)(((((((((0xe000)) >> 8))) - 1) &
(((((0xe000)) >> 8)))) ^ (((((0xe000)) >> 8)))))
>> (2)) != 0) ? 2 + ((((u_long)((((((((((0xe000)) >>
8)) >> 2)) - 1) & ((((((0xe000)) >> 8)) >>
2))) ^ ((((((0xe000)) >> 8)) >> 2)))) >> (
1)) != 0) ? 1 : 0) : ((((u_long)((((((((((0xe000)) >> 8
)))) - 1) & ((((((0xe000)) >> 8))))) ^ ((((((0xe000
)) >> 8)))))) >> (1)) != 0) ? 1 : 0))) : ((((u_long
)((((((((0xe000)))) - 1) & ((((0xe000))))) ^ ((((0xe000))
)))) >> (4)) != 0) ? 4 + ((((u_long)(((((((((0xe000))) >>
4)) - 1) & (((((0xe000))) >> 4))) ^ (((((0xe000)))
>> 4)))) >> (2)) != 0) ? 2 + ((((u_long)((((((((
((0xe000))) >> 4) >> 2)) - 1) & ((((((0xe000)
)) >> 4) >> 2))) ^ ((((((0xe000))) >> 4) >>
2)))) >> (1)) != 0) ? 1 : 0) : ((((u_long)((((((((((0xe000
))) >> 4))) - 1) & ((((((0xe000))) >> 4)))) ^
((((((0xe000))) >> 4))))) >> (1)) != 0) ? 1 : 0)
) : ((((u_long)(((((((((0xe000))))) - 1) & (((((0xe000)))
))) ^ (((((0xe000))))))) >> (2)) != 0) ? 2 + ((((u_long
)((((((((((0xe000)))) >> 2)) - 1) & ((((((0xe000)))
) >> 2))) ^ ((((((0xe000)))) >> 2)))) >> (1
)) != 0) ? 1 : 0) : ((((u_long)((((((((((0xe000)))))) - 1) &
((((((0xe000))))))) ^ ((((((0xe000)))))))) >> (1)) != 0
) ? 1 : 0))))))
;
2295
2296 switch (ic->ic_opmode) {
2297 case IEEE80211_M_MONITOR:
2298 sc->sc_rcr |= RTW_RCR_MONITOR( (1<<0) | (1<<19) | (1<<5) | (1<<12)
| 0)
;
2299 break;
2300#ifndef IEEE80211_STA_ONLY
2301 case IEEE80211_M_AHDEMO:
2302 case IEEE80211_M_IBSS:
2303 /* receive broadcasts in our BSS */
2304 sc->sc_rcr |= RTW_RCR_ADD3(1<<21);
2305 break;
2306#endif
2307 default:
2308 break;
2309 }
2310
2311 ifp->if_flags &= ~IFF_ALLMULTI0x200;
2312
2313 /* XXX accept all broadcast if scanning */
2314 if ((ifp->if_flags & IFF_BROADCAST0x2) != 0)
2315 sc->sc_rcr |= RTW_RCR_AB(1<<3); /* accept all broadcast */
2316
2317 if (ifp->if_flags & IFF_PROMISC0x100 || ac->ac_multirangecnt > 0) {
2318 if (ifp->if_flags & IFF_PROMISC0x100)
2319 sc->sc_rcr |= RTW_RCR_AB(1<<3); /* accept all broadcast */
2320allmulti:
2321 ifp->if_flags |= IFF_ALLMULTI0x200;
2322 goto setit;
2323 }
2324
2325 /*
2326 * Program the 64-bit multicast hash filter.
2327 */
2328 ETHER_FIRST_MULTI(step, ac, enm)do { (step).e_enm = ((&(ac)->ac_multiaddrs)->lh_first
); do { if ((((enm)) = ((step)).e_enm) != ((void *)0)) ((step
)).e_enm = ((((enm)))->enm_list.le_next); } while ( 0); } while
( 0)
;
2329 while (enm != NULL((void *)0)) {
2330 hash = ether_crc32_be((enm->enm_addrlo),
2331 IEEE80211_ADDR_LEN6) >> 26;
2332 hashes[hash >> 5] |= (1 << (hash & 0x1f));
2333 sc->sc_rcr |= RTW_RCR_AM(1<<2);
2334 ETHER_NEXT_MULTI(step, enm)do { if (((enm) = (step).e_enm) != ((void *)0)) (step).e_enm =
(((enm))->enm_list.le_next); } while ( 0)
;
2335 }
2336
2337 /* all bits set => hash is useless */
2338 if (~(hashes[0] & hashes[1]) == 0)
2339 goto allmulti;
2340
2341 setit:
2342 if (ifp->if_flags & IFF_ALLMULTI0x200) {
2343 sc->sc_rcr |= RTW_RCR_AM(1<<2); /* accept all multicast */
2344 hashes[0] = hashes[1] = 0xffffffff;
2345 }
2346
2347 RTW_WRITE(regs, RTW_MAR0, hashes[0])((*(regs)->r_write32)(regs, 0x08, hashes[0]));
2348 RTW_WRITE(regs, RTW_MAR1, hashes[1])((*(regs)->r_write32)(regs, 0x0c, hashes[1]));
2349 RTW_WRITE(regs, RTW_RCR, sc->sc_rcr)((*(regs)->r_write32)(regs, 0x44, sc->sc_rcr));
2350 RTW_SYNC(regs, RTW_MAR0, RTW_RCR)((*(regs)->r_barrier)(regs, 0x08, 0x44, (0x01|0x02))); /* RTW_MAR0 < RTW_MAR1 < RTW_RCR */
2351
2352 DPRINTF(sc, RTW_DEBUG_PKTFILT,
2353 ("%s: RTW_MAR0 %08x RTW_MAR1 %08x RTW_RCR %08x\n",
2354 sc->sc_dev.dv_xname, RTW_READ(regs, RTW_MAR0),
2355 RTW_READ(regs, RTW_MAR1), RTW_READ(regs, RTW_RCR)));
2356
2357 return;
2358}
2359
2360/* Must be called at splnet. */
2361int
2362rtw_init(struct ifnet *ifp)
2363{
2364 struct rtw_softc *sc = (struct rtw_softc *)ifp->if_softc;
2365 struct ieee80211com *ic = &sc->sc_ic;
2366 struct rtw_regs *regs = &sc->sc_regs;
2367 int rc = 0;
2368
2369 if ((rc = rtw_enable(sc)) != 0)
2370 goto out;
2371
2372 /* Cancel pending I/O and reset. */
2373 rtw_stop(ifp, 0);
2374
2375 ic->ic_bss->ni_chan = ic->ic_ibss_chan;
2376 DPRINTF(sc, RTW_DEBUG_TUNE, ("%s: channel %d freq %d flags 0x%04x\n",
2377 __func__, ieee80211_chan2ieee(ic, ic->ic_bss->ni_chan),
2378 ic->ic_bss->ni_chan->ic_freq, ic->ic_bss->ni_chan->ic_flags));
2379
2380 if ((rc = rtw_pwrstate(sc, RTW_OFF)) != 0)
2381 goto out;
2382
2383 if ((rc = rtw_swring_setup(sc)) != 0)
2384 goto out;
2385
2386 rtw_transmit_config(sc);
2387
2388 rtw_set_access(regs, RTW_ACCESS_CONFIG);
2389
2390 RTW_WRITE8(regs, RTW_MSR, 0x0)((*(regs)->r_write8)(regs, 0x58, 0x0)); /* no link */
2391 RTW_WBW(regs, RTW_MSR, RTW_BRSR)((*(regs)->r_barrier)(regs, 0x58, 0x2c, 0x02));
2392
2393 /* long PLCP header, 1Mb/2Mb basic rate */
2394 if (sc->sc_flags & RTW_F_RTL81850x00000008)
2395 RTW_WRITE16(regs, RTW_BRSR, RTW8185_BRSR_MBR_2MBPS)((*(regs)->r_write16)(regs, 0x2c, (1<<1)));
2396 else
2397 RTW_WRITE16(regs, RTW_BRSR, RTW8180_BRSR_MBR_2MBPS)((*(regs)->r_write16)(regs, 0x2c, ((1) << ((((u_long
)((((((0x3)) - 1) & ((0x3))) ^ ((0x3)))) >> (16)) !=
0) ? 16 + ((((u_long)(((((((0x3) >> 16)) - 1) & ((
(0x3) >> 16))) ^ (((0x3) >> 16)))) >> (8)) !=
0) ? 8 + ((((u_long)((((((((0x3) >> 16) >> 8)) -
1) & ((((0x3) >> 16) >> 8))) ^ ((((0x3) >>
16) >> 8)))) >> (4)) != 0) ? 4 + ((((u_long)((((
(((((0x3) >> 16) >> 8) >> 4)) - 1) & ((
(((0x3) >> 16) >> 8) >> 4))) ^ (((((0x3) >>
16) >> 8) >> 4)))) >> (2)) != 0) ? 2 + (((
(u_long)((((((((((0x3) >> 16) >> 8) >> 4) >>
2)) - 1) & ((((((0x3) >> 16) >> 8) >> 4
) >> 2))) ^ ((((((0x3) >> 16) >> 8) >>
4) >> 2)))) >> (1)) != 0) ? 1 : 0) : ((((u_long)
((((((((((0x3) >> 16) >> 8) >> 4))) - 1) &
((((((0x3) >> 16) >> 8) >> 4)))) ^ ((((((0x3
) >> 16) >> 8) >> 4))))) >> (1)) != 0
) ? 1 : 0)) : ((((u_long)(((((((((0x3) >> 16) >> 8
))) - 1) & (((((0x3) >> 16) >> 8)))) ^ (((((0x3
) >> 16) >> 8))))) >> (2)) != 0) ? 2 + ((((
u_long)((((((((((0x3) >> 16) >> 8)) >> 2)) -
1) & ((((((0x3) >> 16) >> 8)) >> 2))) ^
((((((0x3) >> 16) >> 8)) >> 2)))) >>
(1)) != 0) ? 1 : 0) : ((((u_long)((((((((((0x3) >> 16)
>> 8)))) - 1) & ((((((0x3) >> 16) >> 8
))))) ^ ((((((0x3) >> 16) >> 8)))))) >> (1)
) != 0) ? 1 : 0))) : ((((u_long)((((((((0x3) >> 16))) -
1) & ((((0x3) >> 16)))) ^ ((((0x3) >> 16))))
) >> (4)) != 0) ? 4 + ((((u_long)(((((((((0x3) >>
16)) >> 4)) - 1) & (((((0x3) >> 16)) >>
4))) ^ (((((0x3) >> 16)) >> 4)))) >> (2)) !=
0) ? 2 + ((((u_long)((((((((((0x3) >> 16)) >> 4)
>> 2)) - 1) & ((((((0x3) >> 16)) >> 4)
>> 2))) ^ ((((((0x3) >> 16)) >> 4) >>
2)))) >> (1)) != 0) ? 1 : 0) : ((((u_long)((((((((((0x3
) >> 16)) >> 4))) - 1) & ((((((0x3) >> 16
)) >> 4)))) ^ ((((((0x3) >> 16)) >> 4))))) >>
(1)) != 0) ? 1 : 0)) : ((((u_long)(((((((((0x3) >> 16)
))) - 1) & (((((0x3) >> 16))))) ^ (((((0x3) >>
16)))))) >> (2)) != 0) ? 2 + ((((u_long)((((((((((0x3)
>> 16))) >> 2)) - 1) & ((((((0x3) >> 16
))) >> 2))) ^ ((((((0x3) >> 16))) >> 2)))) >>
(1)) != 0) ? 1 : 0) : ((((u_long)((((((((((0x3) >> 16)
)))) - 1) & ((((((0x3) >> 16)))))) ^ ((((((0x3) >>
16))))))) >> (1)) != 0) ? 1 : 0)))) : ((((u_long)(((((
((0x3))) - 1) & (((0x3)))) ^ (((0x3))))) >> (8)) !=
0) ? 8 + ((((u_long)((((((((0x3)) >> 8)) - 1) & ((
((0x3)) >> 8))) ^ ((((0x3)) >> 8)))) >> (4)
) != 0) ? 4 + ((((u_long)(((((((((0x3)) >> 8) >> 4
)) - 1) & (((((0x3)) >> 8) >> 4))) ^ (((((0x3
)) >> 8) >> 4)))) >> (2)) != 0) ? 2 + ((((u_long
)((((((((((0x3)) >> 8) >> 4) >> 2)) - 1) &
((((((0x3)) >> 8) >> 4) >> 2))) ^ ((((((0x3
)) >> 8) >> 4) >> 2)))) >> (1)) != 0)
? 1 : 0) : ((((u_long)((((((((((0x3)) >> 8) >> 4
))) - 1) & ((((((0x3)) >> 8) >> 4)))) ^ (((((
(0x3)) >> 8) >> 4))))) >> (1)) != 0) ? 1 : 0
)) : ((((u_long)(((((((((0x3)) >> 8))) - 1) & (((((
0x3)) >> 8)))) ^ (((((0x3)) >> 8))))) >> (2
)) != 0) ? 2 + ((((u_long)((((((((((0x3)) >> 8)) >>
2)) - 1) & ((((((0x3)) >> 8)) >> 2))) ^ ((((
((0x3)) >> 8)) >> 2)))) >> (1)) != 0) ? 1 :
0) : ((((u_long)((((((((((0x3)) >> 8)))) - 1) & ((
((((0x3)) >> 8))))) ^ ((((((0x3)) >> 8)))))) >>
(1)) != 0) ? 1 : 0))) : ((((u_long)((((((((0x3)))) - 1) &
((((0x3))))) ^ ((((0x3)))))) >> (4)) != 0) ? 4 + ((((u_long
)(((((((((0x3))) >> 4)) - 1) & (((((0x3))) >>
4))) ^ (((((0x3))) >> 4)))) >> (2)) != 0) ? 2 + (
(((u_long)((((((((((0x3))) >> 4) >> 2)) - 1) &
((((((0x3))) >> 4) >> 2))) ^ ((((((0x3))) >>
4) >> 2)))) >> (1)) != 0) ? 1 : 0) : ((((u_long)
((((((((((0x3))) >> 4))) - 1) & ((((((0x3))) >>
4)))) ^ ((((((0x3))) >> 4))))) >> (1)) != 0) ? 1
: 0)) : ((((u_long)(((((((((0x3))))) - 1) & (((((0x3))))
)) ^ (((((0x3))))))) >> (2)) != 0) ? 2 + ((((u_long)(((
(((((((0x3)))) >> 2)) - 1) & ((((((0x3)))) >>
2))) ^ ((((((0x3)))) >> 2)))) >> (1)) != 0) ? 1 :
0) : ((((u_long)((((((((((0x3)))))) - 1) & ((((((0x3))))
))) ^ ((((((0x3)))))))) >> (1)) != 0) ? 1 : 0))))))))
;
2398 RTW_SYNC(regs, RTW_BRSR, RTW_BRSR)((*(regs)->r_barrier)(regs, 0x2c, 0x2c, (0x01|0x02)));
2399
2400 rtw_set_access(regs, RTW_ACCESS_ANAPARM);
2401 rtw_set_access(regs, RTW_ACCESS_NONE);
2402
2403 /* XXX from reference sources */
2404 RTW_WRITE(regs, RTW_FEMR, 0xffff)((*(regs)->r_write32)(regs, 0xf4, 0xffff));
2405 RTW_SYNC(regs, RTW_FEMR, RTW_FEMR)((*(regs)->r_barrier)(regs, 0xf4, 0xf4, (0x01|0x02)));
2406
2407 rtw_set_rfprog(regs, sc->sc_rfchipid, sc->sc_dev.dv_xname);
2408
2409 RTW_WRITE8(regs, RTW_PHYDELAY, sc->sc_phydelay)((*(regs)->r_write8)(regs, 0x78, sc->sc_phydelay));
2410 /* from Linux driver */
2411 RTW_WRITE8(regs, RTW_CRCOUNT, RTW_CRCOUNT_MAGIC)((*(regs)->r_write8)(regs, 0x79, 0x4c));
2412
2413 RTW_SYNC(regs, RTW_PHYDELAY, RTW_CRCOUNT)((*(regs)->r_barrier)(regs, 0x78, 0x79, (0x01|0x02)));
2414
2415 rtw_enable_interrupts(sc);
2416
2417 rtw_pktfilt_load(sc);
2418
2419 rtw_hwring_setup(sc);
2420
2421 rtw_io_enable(regs, RTW_CR_RE(1<<3)|RTW_CR_TE(1<<2), 1);
2422
2423 ifp->if_flags |= IFF_RUNNING0x40;
2424 ic->ic_state = IEEE80211_S_INIT;
2425
2426 RTW_WRITE16(regs, RTW_BSSID16, 0x0)((*(regs)->r_write16)(regs, 0x2e, 0x0));
2427 RTW_WRITE(regs, RTW_BSSID32, 0x0)((*(regs)->r_write32)(regs, (0x2e + 4), 0x0));
2428
2429 rtw_resume_ticks(sc);
2430
2431 rtw_set_nettype(sc, IEEE80211_M_MONITOR);
2432
2433 if (ic->ic_opmode == IEEE80211_M_MONITOR)
2434 return ieee80211_new_state(ic, IEEE80211_S_RUN, -1)(((ic)->ic_newstate)((ic), (IEEE80211_S_RUN), (-1)));
2435 else
2436 return ieee80211_new_state(ic, IEEE80211_S_SCAN, -1)(((ic)->ic_newstate)((ic), (IEEE80211_S_SCAN), (-1)));
2437
2438out:
2439 printf("%s: interface not running\n", sc->sc_dev.dv_xname);
2440 return rc;
2441}
2442
2443void
2444rtw_led_init(struct rtw_regs *regs)
2445{
2446 u_int8_t cfg0, cfg1;
2447
2448 rtw_set_access(regs, RTW_ACCESS_CONFIG);
2449
2450 cfg0 = RTW_READ8(regs, RTW_CONFIG0)((*(regs)->r_read8)(regs, 0x51));
2451 cfg0 |= RTW8180_CONFIG0_LEDGPOEN(1<<4);
2452 RTW_WRITE8(regs, RTW_CONFIG0, cfg0)((*(regs)->r_write8)(regs, 0x51, cfg0));
2453
2454 cfg1 = RTW_READ8(regs, RTW_CONFIG1)((*(regs)->r_read8)(regs, 0x52));
2455 RTW_DPRINTF(RTW_DEBUG_LED,
2456 ("%s: read % from reg[CONFIG1]\n", __func__, cfg1));
2457
2458 cfg1 &= ~RTW_CONFIG1_LEDS_MASK0xc0;
2459 cfg1 |= RTW_CONFIG1_LEDS_TX_RX((2) << ((((u_long)((((((0xc0)) - 1) & ((0xc0))) ^ (
(0xc0)))) >> (16)) != 0) ? 16 + ((((u_long)(((((((0xc0)
>> 16)) - 1) & (((0xc0) >> 16))) ^ (((0xc0) >>
16)))) >> (8)) != 0) ? 8 + ((((u_long)((((((((0xc0) >>
16) >> 8)) - 1) & ((((0xc0) >> 16) >> 8
))) ^ ((((0xc0) >> 16) >> 8)))) >> (4)) != 0
) ? 4 + ((((u_long)(((((((((0xc0) >> 16) >> 8) >>
4)) - 1) & (((((0xc0) >> 16) >> 8) >> 4
))) ^ (((((0xc0) >> 16) >> 8) >> 4)))) >>
(2)) != 0) ? 2 + ((((u_long)((((((((((0xc0) >> 16) >>
8) >> 4) >> 2)) - 1) & ((((((0xc0) >> 16
) >> 8) >> 4) >> 2))) ^ ((((((0xc0) >>
16) >> 8) >> 4) >> 2)))) >> (1)) != 0
) ? 1 : 0) : ((((u_long)((((((((((0xc0) >> 16) >>
8) >> 4))) - 1) & ((((((0xc0) >> 16) >>
8) >> 4)))) ^ ((((((0xc0) >> 16) >> 8) >>
4))))) >> (1)) != 0) ? 1 : 0)) : ((((u_long)(((((((((0xc0
) >> 16) >> 8))) - 1) & (((((0xc0) >> 16
) >> 8)))) ^ (((((0xc0) >> 16) >> 8))))) >>
(2)) != 0) ? 2 + ((((u_long)((((((((((0xc0) >> 16) >>
8)) >> 2)) - 1) & ((((((0xc0) >> 16) >>
8)) >> 2))) ^ ((((((0xc0) >> 16) >> 8)) >>
2)))) >> (1)) != 0) ? 1 : 0) : ((((u_long)((((((((((0xc0
) >> 16) >> 8)))) - 1) & ((((((0xc0) >>
16) >> 8))))) ^ ((((((0xc0) >> 16) >> 8)))
))) >> (1)) != 0) ? 1 : 0))) : ((((u_long)((((((((0xc0)
>> 16))) - 1) & ((((0xc0) >> 16)))) ^ ((((0xc0
) >> 16))))) >> (4)) != 0) ? 4 + ((((u_long)(((((
((((0xc0) >> 16)) >> 4)) - 1) & (((((0xc0) >>
16)) >> 4))) ^ (((((0xc0) >> 16)) >> 4))))
>> (2)) != 0) ? 2 + ((((u_long)((((((((((0xc0) >>
16)) >> 4) >> 2)) - 1) & ((((((0xc0) >>
16)) >> 4) >> 2))) ^ ((((((0xc0) >> 16)) >>
4) >> 2)))) >> (1)) != 0) ? 1 : 0) : ((((u_long)
((((((((((0xc0) >> 16)) >> 4))) - 1) & ((((((
0xc0) >> 16)) >> 4)))) ^ ((((((0xc0) >> 16)
) >> 4))))) >> (1)) != 0) ? 1 : 0)) : ((((u_long)
(((((((((0xc0) >> 16)))) - 1) & (((((0xc0) >>
16))))) ^ (((((0xc0) >> 16)))))) >> (2)) != 0) ?
2 + ((((u_long)((((((((((0xc0) >> 16))) >> 2)) -
1) & ((((((0xc0) >> 16))) >> 2))) ^ ((((((0xc0
) >> 16))) >> 2)))) >> (1)) != 0) ? 1 : 0) :
((((u_long)((((((((((0xc0) >> 16))))) - 1) & (((((
(0xc0) >> 16)))))) ^ ((((((0xc0) >> 16))))))) >>
(1)) != 0) ? 1 : 0)))) : ((((u_long)(((((((0xc0))) - 1) &
(((0xc0)))) ^ (((0xc0))))) >> (8)) != 0) ? 8 + ((((u_long
)((((((((0xc0)) >> 8)) - 1) & ((((0xc0)) >> 8
))) ^ ((((0xc0)) >> 8)))) >> (4)) != 0) ? 4 + (((
(u_long)(((((((((0xc0)) >> 8) >> 4)) - 1) & (
((((0xc0)) >> 8) >> 4))) ^ (((((0xc0)) >> 8
) >> 4)))) >> (2)) != 0) ? 2 + ((((u_long)(((((((
(((0xc0)) >> 8) >> 4) >> 2)) - 1) & (((
(((0xc0)) >> 8) >> 4) >> 2))) ^ ((((((0xc0)
) >> 8) >> 4) >> 2)))) >> (1)) != 0) ?
1 : 0) : ((((u_long)((((((((((0xc0)) >> 8) >> 4)
)) - 1) & ((((((0xc0)) >> 8) >> 4)))) ^ (((((
(0xc0)) >> 8) >> 4))))) >> (1)) != 0) ? 1 :
0)) : ((((u_long)(((((((((0xc0)) >> 8))) - 1) & ((
(((0xc0)) >> 8)))) ^ (((((0xc0)) >> 8))))) >>
(2)) != 0) ? 2 + ((((u_long)((((((((((0xc0)) >> 8)) >>
2)) - 1) & ((((((0xc0)) >> 8)) >> 2))) ^ (((
(((0xc0)) >> 8)) >> 2)))) >> (1)) != 0) ? 1
: 0) : ((((u_long)((((((((((0xc0)) >> 8)))) - 1) &
((((((0xc0)) >> 8))))) ^ ((((((0xc0)) >> 8))))))
>> (1)) != 0) ? 1 : 0))) : ((((u_long)((((((((0xc0))))
- 1) & ((((0xc0))))) ^ ((((0xc0)))))) >> (4)) != 0
) ? 4 + ((((u_long)(((((((((0xc0))) >> 4)) - 1) & (
((((0xc0))) >> 4))) ^ (((((0xc0))) >> 4)))) >>
(2)) != 0) ? 2 + ((((u_long)((((((((((0xc0))) >> 4) >>
2)) - 1) & ((((((0xc0))) >> 4) >> 2))) ^ (((
(((0xc0))) >> 4) >> 2)))) >> (1)) != 0) ? 1
: 0) : ((((u_long)((((((((((0xc0))) >> 4))) - 1) &
((((((0xc0))) >> 4)))) ^ ((((((0xc0))) >> 4)))))
>> (1)) != 0) ? 1 : 0)) : ((((u_long)(((((((((0xc0))))
) - 1) & (((((0xc0)))))) ^ (((((0xc0))))))) >> (2))
!= 0) ? 2 + ((((u_long)((((((((((0xc0)))) >> 2)) - 1) &
((((((0xc0)))) >> 2))) ^ ((((((0xc0)))) >> 2))))
>> (1)) != 0) ? 1 : 0) : ((((u_long)((((((((((0xc0))))
)) - 1) & ((((((0xc0))))))) ^ ((((((0xc0)))))))) >>
(1)) != 0) ? 1 : 0))))))
;
2460 RTW_WRITE8(regs, RTW_CONFIG1, cfg1)((*(regs)->r_write8)(regs, 0x52, cfg1));
2461
2462 rtw_set_access(regs, RTW_ACCESS_NONE);
2463}
2464
2465/*
2466 * IEEE80211_S_INIT: LED1 off
2467 *
2468 * IEEE80211_S_AUTH,
2469 * IEEE80211_S_ASSOC,
2470 * IEEE80211_S_SCAN: LED1 blinks @ 1 Hz, blinks at 5Hz for tx/rx
2471 *
2472 * IEEE80211_S_RUN: LED1 on, blinks @ 5Hz for tx/rx
2473 */
2474void
2475rtw_led_newstate(struct rtw_softc *sc, enum ieee80211_state nstate)
2476{
2477 struct rtw_led_state *ls;
2478
2479 ls = &sc->sc_led_state;
2480
2481 switch (nstate) {
2482 case IEEE80211_S_INIT:
2483 rtw_led_init(&sc->sc_regs);
2484 timeout_del(&ls->ls_slow_ch);
2485 timeout_del(&ls->ls_fast_ch);
2486 ls->ls_slowblink = 0;
2487 ls->ls_actblink = 0;
2488 ls->ls_default = 0;
2489 break;
2490 case IEEE80211_S_SCAN:
2491 timeout_add_msec(&ls->ls_slow_ch, RTW_LED_SLOW_MSEC500);
2492 timeout_add_msec(&ls->ls_fast_ch, RTW_LED_FAST_MSEC100);
2493 /*FALLTHROUGH*/
2494 case IEEE80211_S_AUTH:
2495 case IEEE80211_S_ASSOC:
2496 ls->ls_default = RTW_LED10x2;
2497 ls->ls_actblink = RTW_LED10x2;
2498 ls->ls_slowblink = RTW_LED10x2;
2499 break;
2500 case IEEE80211_S_RUN:
2501 ls->ls_slowblink = 0;
2502 break;
2503 }
2504 rtw_led_set(ls, &sc->sc_regs, sc->sc_hwverid);
2505}
2506
2507void
2508rtw_led_set(struct rtw_led_state *ls, struct rtw_regs *regs, u_int hwverid)
2509{
2510 u_int8_t led_condition;
2511 bus_size_t ofs;
2512 u_int8_t mask, newval, val;
2513
2514 led_condition = ls->ls_default;
2515
2516 if (ls->ls_state & RTW_LED_S_SLOW0x4)
2517 led_condition ^= ls->ls_slowblink;
2518 if (ls->ls_state & (RTW_LED_S_RX0x1|RTW_LED_S_TX0x2))
2519 led_condition ^= ls->ls_actblink;
2520
2521 RTW_DPRINTF(RTW_DEBUG_LED,
2522 ("%s: LED condition %\n", __func__, led_condition));
2523
2524 switch (hwverid) {
2525 default:
2526 case RTW_TCR_HWVERID_RTL8180F0x6000000:
2527 ofs = RTW_PSR0x5e;
2528 newval = mask = RTW_PSR_LEDGPO0(1<<4) | RTW_PSR_LEDGPO1(1<<5);
2529 if (led_condition & RTW_LED00x1)
2530 newval &= ~RTW_PSR_LEDGPO0(1<<4);
2531 if (led_condition & RTW_LED10x2)
2532 newval &= ~RTW_PSR_LEDGPO1(1<<5);
2533 break;
2534 case RTW_TCR_HWVERID_RTL8180D(1<<26):
2535 ofs = RTW_9346CR0x50;
2536 mask = RTW_9346CR_EEM_MASK0xc0 | RTW_9346CR_EEDI(1<<1) | RTW_9346CR_EECS(1<<3);
2537 newval = RTW_9346CR_EEM_PROGRAM((2) << ((((u_long)((((((0xc0)) - 1) & ((0xc0))) ^ (
(0xc0)))) >> (16)) != 0) ? 16 + ((((u_long)(((((((0xc0)
>> 16)) - 1) & (((0xc0) >> 16))) ^ (((0xc0) >>
16)))) >> (8)) != 0) ? 8 + ((((u_long)((((((((0xc0) >>
16) >> 8)) - 1) & ((((0xc0) >> 16) >> 8
))) ^ ((((0xc0) >> 16) >> 8)))) >> (4)) != 0
) ? 4 + ((((u_long)(((((((((0xc0) >> 16) >> 8) >>
4)) - 1) & (((((0xc0) >> 16) >> 8) >> 4
))) ^ (((((0xc0) >> 16) >> 8) >> 4)))) >>
(2)) != 0) ? 2 + ((((u_long)((((((((((0xc0) >> 16) >>
8) >> 4) >> 2)) - 1) & ((((((0xc0) >> 16
) >> 8) >> 4) >> 2))) ^ ((((((0xc0) >>
16) >> 8) >> 4) >> 2)))) >> (1)) != 0
) ? 1 : 0) : ((((u_long)((((((((((0xc0) >> 16) >>
8) >> 4))) - 1) & ((((((0xc0) >> 16) >>
8) >> 4)))) ^ ((((((0xc0) >> 16) >> 8) >>
4))))) >> (1)) != 0) ? 1 : 0)) : ((((u_long)(((((((((0xc0
) >> 16) >> 8))) - 1) & (((((0xc0) >> 16
) >> 8)))) ^ (((((0xc0) >> 16) >> 8))))) >>
(2)) != 0) ? 2 + ((((u_long)((((((((((0xc0) >> 16) >>
8)) >> 2)) - 1) & ((((((0xc0) >> 16) >>
8)) >> 2))) ^ ((((((0xc0) >> 16) >> 8)) >>
2)))) >> (1)) != 0) ? 1 : 0) : ((((u_long)((((((((((0xc0
) >> 16) >> 8)))) - 1) & ((((((0xc0) >>
16) >> 8))))) ^ ((((((0xc0) >> 16) >> 8)))
))) >> (1)) != 0) ? 1 : 0))) : ((((u_long)((((((((0xc0)
>> 16))) - 1) & ((((0xc0) >> 16)))) ^ ((((0xc0
) >> 16))))) >> (4)) != 0) ? 4 + ((((u_long)(((((
((((0xc0) >> 16)) >> 4)) - 1) & (((((0xc0) >>
16)) >> 4))) ^ (((((0xc0) >> 16)) >> 4))))
>> (2)) != 0) ? 2 + ((((u_long)((((((((((0xc0) >>
16)) >> 4) >> 2)) - 1) & ((((((0xc0) >>
16)) >> 4) >> 2))) ^ ((((((0xc0) >> 16)) >>
4) >> 2)))) >> (1)) != 0) ? 1 : 0) : ((((u_long)
((((((((((0xc0) >> 16)) >> 4))) - 1) & ((((((
0xc0) >> 16)) >> 4)))) ^ ((((((0xc0) >> 16)
) >> 4))))) >> (1)) != 0) ? 1 : 0)) : ((((u_long)
(((((((((0xc0) >> 16)))) - 1) & (((((0xc0) >>
16))))) ^ (((((0xc0) >> 16)))))) >> (2)) != 0) ?
2 + ((((u_long)((((((((((0xc0) >> 16))) >> 2)) -
1) & ((((((0xc0) >> 16))) >> 2))) ^ ((((((0xc0
) >> 16))) >> 2)))) >> (1)) != 0) ? 1 : 0) :
((((u_long)((((((((((0xc0) >> 16))))) - 1) & (((((
(0xc0) >> 16)))))) ^ ((((((0xc0) >> 16))))))) >>
(1)) != 0) ? 1 : 0)))) : ((((u_long)(((((((0xc0))) - 1) &
(((0xc0)))) ^ (((0xc0))))) >> (8)) != 0) ? 8 + ((((u_long
)((((((((0xc0)) >> 8)) - 1) & ((((0xc0)) >> 8
))) ^ ((((0xc0)) >> 8)))) >> (4)) != 0) ? 4 + (((
(u_long)(((((((((0xc0)) >> 8) >> 4)) - 1) & (
((((0xc0)) >> 8) >> 4))) ^ (((((0xc0)) >> 8
) >> 4)))) >> (2)) != 0) ? 2 + ((((u_long)(((((((
(((0xc0)) >> 8) >> 4) >> 2)) - 1) & (((
(((0xc0)) >> 8) >> 4) >> 2))) ^ ((((((0xc0)
) >> 8) >> 4) >> 2)))) >> (1)) != 0) ?
1 : 0) : ((((u_long)((((((((((0xc0)) >> 8) >> 4)
)) - 1) & ((((((0xc0)) >> 8) >> 4)))) ^ (((((
(0xc0)) >> 8) >> 4))))) >> (1)) != 0) ? 1 :
0)) : ((((u_long)(((((((((0xc0)) >> 8))) - 1) & ((
(((0xc0)) >> 8)))) ^ (((((0xc0)) >> 8))))) >>
(2)) != 0) ? 2 + ((((u_long)((((((((((0xc0)) >> 8)) >>
2)) - 1) & ((((((0xc0)) >> 8)) >> 2))) ^ (((
(((0xc0)) >> 8)) >> 2)))) >> (1)) != 0) ? 1
: 0) : ((((u_long)((((((((((0xc0)) >> 8)))) - 1) &
((((((0xc0)) >> 8))))) ^ ((((((0xc0)) >> 8))))))
>> (1)) != 0) ? 1 : 0))) : ((((u_long)((((((((0xc0))))
- 1) & ((((0xc0))))) ^ ((((0xc0)))))) >> (4)) != 0
) ? 4 + ((((u_long)(((((((((0xc0))) >> 4)) - 1) & (
((((0xc0))) >> 4))) ^ (((((0xc0))) >> 4)))) >>
(2)) != 0) ? 2 + ((((u_long)((((((((((0xc0))) >> 4) >>
2)) - 1) & ((((((0xc0))) >> 4) >> 2))) ^ (((
(((0xc0))) >> 4) >> 2)))) >> (1)) != 0) ? 1
: 0) : ((((u_long)((((((((((0xc0))) >> 4))) - 1) &
((((((0xc0))) >> 4)))) ^ ((((((0xc0))) >> 4)))))
>> (1)) != 0) ? 1 : 0)) : ((((u_long)(((((((((0xc0))))
) - 1) & (((((0xc0)))))) ^ (((((0xc0))))))) >> (2))
!= 0) ? 2 + ((((u_long)((((((((((0xc0)))) >> 2)) - 1) &
((((((0xc0)))) >> 2))) ^ ((((((0xc0)))) >> 2))))
>> (1)) != 0) ? 1 : 0) : ((((u_long)((((((((((0xc0))))
)) - 1) & ((((((0xc0))))))) ^ ((((((0xc0)))))))) >>
(1)) != 0) ? 1 : 0))))))
;
2538 if (led_condition & RTW_LED00x1)
2539 newval |= RTW_9346CR_EEDI(1<<1);
2540 if (led_condition & RTW_LED10x2)
2541 newval |= RTW_9346CR_EECS(1<<3);
2542 break;
2543 }
2544 val = RTW_READ8(regs, ofs)((*(regs)->r_read8)(regs, ofs));
2545 RTW_DPRINTF(RTW_DEBUG_LED,
2546 ("%s: read % from reg[%#02]\n", __func__, val,
2547 (u_int *)ofs));
2548 val &= ~mask;
2549 val |= newval;
2550 RTW_WRITE8(regs, ofs, val)((*(regs)->r_write8)(regs, ofs, val));
2551 RTW_DPRINTF(RTW_DEBUG_LED,
2552 ("%s: wrote % to reg[%#02]\n", __func__, val,
2553 (u_int *)ofs));
2554 RTW_SYNC(regs, ofs, ofs)((*(regs)->r_barrier)(regs, ofs, ofs, (0x01|0x02)));
2555}
2556
2557void
2558rtw_led_fastblink(void *arg)
2559{
2560 int ostate, s;
2561 struct rtw_softc *sc = (struct rtw_softc *)arg;
2562 struct rtw_led_state *ls = &sc->sc_led_state;
2563
2564 s = splnet()splraise(0x4);
2565 ostate = ls->ls_state;
2566 ls->ls_state ^= ls->ls_event;
2567
2568 if ((ls->ls_event & RTW_LED_S_TX0x2) == 0)
2569 ls->ls_state &= ~RTW_LED_S_TX0x2;
2570
2571 if ((ls->ls_event & RTW_LED_S_RX0x1) == 0)
2572 ls->ls_state &= ~RTW_LED_S_RX0x1;
2573
2574 ls->ls_event = 0;
2575
2576 if (ostate != ls->ls_state)
2577 rtw_led_set(ls, &sc->sc_regs, sc->sc_hwverid);
2578 splx(s)spllower(s);
2579
2580 timeout_add_msec(&ls->ls_fast_ch, RTW_LED_FAST_MSEC100);
2581}
2582
2583void
2584rtw_led_slowblink(void *arg)
2585{
2586 int s;
2587 struct rtw_softc *sc = (struct rtw_softc *)arg;
2588 struct rtw_led_state *ls = &sc->sc_led_state;
2589
2590 s = splnet()splraise(0x4);
2591 ls->ls_state ^= RTW_LED_S_SLOW0x4;
2592 rtw_led_set(ls, &sc->sc_regs, sc->sc_hwverid);
2593 splx(s)spllower(s);
2594 timeout_add_msec(&ls->ls_slow_ch, RTW_LED_SLOW_MSEC500);
2595}
2596
2597void
2598rtw_led_attach(struct rtw_led_state *ls, void *arg)
2599{
2600 timeout_set(&ls->ls_fast_ch, rtw_led_fastblink, arg);
2601 timeout_set(&ls->ls_slow_ch, rtw_led_slowblink, arg);
2602}
2603
2604int
2605rtw_ioctl(struct ifnet *ifp, u_long cmd, caddr_t data)
2606{
2607 struct rtw_softc *sc = ifp->if_softc;
2608 struct ifreq *ifr = (struct ifreq *)data;
2609 int rc = 0, s;
2610
2611 s = splnet()splraise(0x4);
2612
2613 switch (cmd) {
2614 case SIOCSIFADDR((unsigned long)0x80000000 | ((sizeof(struct ifreq) & 0x1fff
) << 16) | ((('i')) << 8) | ((12)))
:
2615 ifp->if_flags |= IFF_UP0x1;
2616 /* FALLTHROUGH */
2617
2618 case SIOCSIFFLAGS((unsigned long)0x80000000 | ((sizeof(struct ifreq) & 0x1fff
) << 16) | ((('i')) << 8) | ((16)))
:
2619 if ((ifp->if_flags & IFF_UP0x1) != 0) {
2620 if ((sc->sc_flags & RTW_F_ENABLED0x00000001) != 0) {
2621 rtw_pktfilt_load(sc);
2622 } else
2623 rc = rtw_init(ifp);
2624 } else if ((sc->sc_flags & RTW_F_ENABLED0x00000001) != 0)
2625 rtw_stop(ifp, 1);
2626 break;
2627
2628 case SIOCADDMULTI((unsigned long)0x80000000 | ((sizeof(struct ifreq) & 0x1fff
) << 16) | ((('i')) << 8) | ((49)))
:
2629 case SIOCDELMULTI((unsigned long)0x80000000 | ((sizeof(struct ifreq) & 0x1fff
) << 16) | ((('i')) << 8) | ((50)))
:
2630 if (cmd == SIOCADDMULTI((unsigned long)0x80000000 | ((sizeof(struct ifreq) & 0x1fff
) << 16) | ((('i')) << 8) | ((49)))
)
2631 rc = ether_addmulti(ifr, &sc->sc_ic.ic_ac);
2632 else
2633 rc = ether_delmulti(ifr, &sc->sc_ic.ic_ac);
2634 if (rc != ENETRESET52)
2635 break;
2636 if (ifp->if_flags & IFF_RUNNING0x40)
2637 rtw_pktfilt_load(sc);
2638 rc = 0;
2639 break;
2640
2641 default:
2642 if ((rc = ieee80211_ioctl(ifp, cmd, data)) == ENETRESET52) {
2643 if ((sc->sc_flags & RTW_F_ENABLED0x00000001) != 0)
2644 rc = rtw_init(ifp);
2645 else
2646 rc = 0;
2647 }
2648 break;
2649 }
2650
2651 splx(s)spllower(s);
2652 return rc;
2653}
2654
2655/* Select a transmit ring with at least one h/w and s/w descriptor free.
2656 * Return 0 on success, -1 on failure.
2657 */
2658int
2659rtw_txring_choose(struct rtw_softc *sc, struct rtw_txsoft_blk **tsbp,
2660 struct rtw_txdesc_blk **tdbp, int pri)
2661{
2662 struct rtw_txsoft_blk *tsb;
2663 struct rtw_txdesc_blk *tdb;
2664
2665 KASSERT(pri >= 0 && pri < RTW_NTXPRI)((pri >= 0 && pri < 4) ? (void)0 : __assert("diagnostic "
, "/usr/src/sys/dev/ic/rtw.c", 2665, "pri >= 0 && pri < RTW_NTXPRI"
))
;
2666
2667 tsb = &sc->sc_txsoft_blk[pri];
2668 tdb = &sc->sc_txdesc_blk[pri];
2669
2670 if (SIMPLEQ_EMPTY(&tsb->tsb_freeq)(((&tsb->tsb_freeq)->sqh_first) == ((void *)0)) || tdb->tdb_nfree == 0) {
2671 if (tsb->tsb_tx_timer == 0)
2672 tsb->tsb_tx_timer = 5;
2673 *tsbp = NULL((void *)0);
2674 *tdbp = NULL((void *)0);
2675 return -1;
2676 }
2677 *tsbp = tsb;
2678 *tdbp = tdb;
2679 return 0;
2680}
2681
2682struct mbuf *
2683rtw_80211_dequeue(struct rtw_softc *sc, struct mbuf_queue *ifq, int pri,
2684 struct rtw_txsoft_blk **tsbp, struct rtw_txdesc_blk **tdbp,
2685 struct ieee80211_node **nip)
2686{
2687 struct mbuf *m;
2688
2689 if (mq_empty(ifq)(({ typeof((ifq)->mq_list.ml_len) __tmp = *(volatile typeof
((ifq)->mq_list.ml_len) *)&((ifq)->mq_list.ml_len);
membar_datadep_consumer(); __tmp; }) == 0)
)
2690 return NULL((void *)0);
2691 if (rtw_txring_choose(sc, tsbp, tdbp, pri) == -1) {
2692 DPRINTF(sc, RTW_DEBUG_XMIT_RSRC, ("%s: no ring %d descriptor\n",
2693 __func__, pri));
2694 ifq_set_oactive(&sc->sc_ifsc_ic.ic_ac.ac_if.if_snd);
2695 sc->sc_ifsc_ic.ic_ac.ac_if.if_timer = 1;
2696 return NULL((void *)0);
2697 }
2698 m = mq_dequeue(ifq);
2699 *nip = m->m_pkthdrM_dat.MH.MH_pkthdr.ph_cookie;
2700 return m;
2701}
2702
2703/* Point *mp at the next 802.11 frame to transmit. Point *tsbp
2704 * at the driver's selection of transmit control block for the packet.
2705 */
2706int
2707rtw_dequeue(struct ifnet *ifp, struct rtw_txsoft_blk **tsbp,
2708 struct rtw_txdesc_blk **tdbp, struct mbuf **mp,
2709 struct ieee80211_node **nip)
2710{
2711 struct ieee80211com *ic;
2712 struct ieee80211_frame *wh;
2713 struct ieee80211_key *k;
2714 struct mbuf *m0;
2715 struct rtw_softc *sc;
2716
2717 sc = (struct rtw_softc *)ifp->if_softc;
2718 ic = &sc->sc_ic;
2719
2720 DPRINTF(sc, RTW_DEBUG_XMIT,
2721 ("%s: enter %s\n", sc->sc_dev.dv_xname, __func__));
2722
2723 if (ic->ic_state == IEEE80211_S_RUN &&
2724 (*mp = rtw_80211_dequeue(sc, &sc->sc_beaconq, RTW_TXPRIBCN3, tsbp,
2725 tdbp, nip)) != NULL((void *)0)) {
2726 DPRINTF(sc, RTW_DEBUG_XMIT, ("%s: dequeue beacon frame\n",
2727 __func__));
2728 return 0;
2729 }
2730
2731 if ((*mp = rtw_80211_dequeue(sc, &ic->ic_mgtq, RTW_TXPRIMD1, tsbp,
2732 tdbp, nip)) != NULL((void *)0)) {
2733 DPRINTF(sc, RTW_DEBUG_XMIT, ("%s: dequeue mgt frame\n",
2734 __func__));
2735 return 0;
2736 }
2737
2738 if (sc->sc_ic.ic_state != IEEE80211_S_RUN) {
2739 DPRINTF(sc, RTW_DEBUG_XMIT, ("%s: not running\n", __func__));
2740 return 0;
2741 }
2742
2743 if ((*mp = rtw_80211_dequeue(sc, &ic->ic_pwrsaveq, RTW_TXPRIHI2,
2744 tsbp, tdbp, nip)) != NULL((void *)0)) {
2745 DPRINTF(sc, RTW_DEBUG_XMIT, ("%s: dequeue pwrsave frame\n",
2746 __func__));
2747 return 0;
2748 }
2749
2750 if (ic->ic_state != IEEE80211_S_RUN) {
2751 DPRINTF(sc, RTW_DEBUG_XMIT, ("%s: not running\n", __func__));
2752 return 0;
2753 }
2754
2755 *mp = NULL((void *)0);
2756
2757 m0 = ifq_deq_begin(&ifp->if_snd);
2758 if (m0 == NULL((void *)0)) {
2759 DPRINTF(sc, RTW_DEBUG_XMIT, ("%s: no frame ready\n",
2760 __func__));
2761 return 0;
2762 }
2763
2764 if (rtw_txring_choose(sc, tsbp, tdbp, RTW_TXPRIMD1) == -1) {
2765 DPRINTF(sc, RTW_DEBUG_XMIT, ("%s: no descriptor\n", __func__));
2766 ifq_deq_rollback(&ifp->if_snd, m0);
2767 ifq_set_oactive(&ifp->if_snd);
2768 sc->sc_ifsc_ic.ic_ac.ac_if.if_timer = 1;
2769 return 0;
2770 }
2771
2772 ifq_deq_commit(&ifp->if_snd, m0);
2773 if (m0 == NULL((void *)0)) {
2774 DPRINTF(sc, RTW_DEBUG_XMIT, ("%s: no frame/ring ready\n",
2775 __func__));
2776 return 0;
2777 }
2778 DPRINTF(sc, RTW_DEBUG_XMIT, ("%s: dequeue data frame\n", __func__));
2779#if NBPFILTER1 > 0
2780 if (ifp->if_bpf)
2781 bpf_mtap(ifp->if_bpf, m0, BPF_DIRECTION_OUT(1 << 1));
2782#endif
2783 if ((m0 = ieee80211_encap(ifp, m0, nip)) == NULL((void *)0)) {
2784 DPRINTF(sc, RTW_DEBUG_XMIT,
2785 ("%s: encap error\n", __func__));
2786 ifp->if_oerrorsif_data.ifi_oerrors++;
2787 return -1;
2788 }
2789
2790 /* XXX should do WEP in hardware */
2791 if (ic->ic_flags & IEEE80211_F_WEPON0x00000100) {
2792 wh = mtod(m0, struct ieee80211_frame *)((struct ieee80211_frame *)((m0)->m_hdr.mh_data));
2793 k = ieee80211_get_txkey(ic, wh, *nip);
2794 if ((m0 = ieee80211_encrypt(ic, m0, k)) == NULL((void *)0))
2795 return -1;
2796 }
2797
2798 DPRINTF(sc, RTW_DEBUG_XMIT, ("%s: leave\n", __func__));
2799 *mp = m0;
2800 return 0;
2801}
2802
2803int
2804rtw_seg_too_short(bus_dmamap_t dmamap)
2805{
2806 int i;
2807 for (i = 0; i < dmamap->dm_nsegs; i++) {
2808 if (dmamap->dm_segs[i].ds_len < 4) {
2809 printf("%s: segment too short\n", __func__);
2810 return 1;
2811 }
2812 }
2813 return 0;
2814}
2815
2816/* TBD factor with atw_start */
2817struct mbuf *
2818rtw_dmamap_load_txbuf(bus_dma_tag_t dmat, bus_dmamap_t dmam, struct mbuf *chain,
2819 u_int ndescfree, short *ifflagsp, const char *dvname)
2820{
2821 int first, rc;
2822 struct mbuf *m, *m0;
2823
2824 m0 = chain;
2825
2826 /*
2827 * Load the DMA map. Copy and try (once) again if the packet
2828 * didn't fit in the allotted number of segments.
2829 */
2830 for (first = 1;
2831 ((rc = bus_dmamap_load_mbuf(dmat, dmam, m0,(*(dmat)->_dmamap_load_mbuf)((dmat), (dmam), (m0), (0x0400
|0x0001))
2832 BUS_DMA_WRITE|BUS_DMA_NOWAIT)(*(dmat)->_dmamap_load_mbuf)((dmat), (dmam), (m0), (0x0400
|0x0001))
) != 0 ||
2833 dmam->dm_nsegs > ndescfree || rtw_seg_too_short(dmam)) && first;
2834 first = 0) {
2835 if (rc == 0)
2836 bus_dmamap_unload(dmat, dmam)(*(dmat)->_dmamap_unload)((dmat), (dmam));
2837 MGETHDR(m, M_DONTWAIT, MT_DATA)m = m_gethdr((0x0002), (1));
2838 if (m == NULL((void *)0)) {
2839 printf("%s: unable to allocate Tx mbuf\n",
2840 dvname);
2841 break;
2842 }
2843 if (m0->m_pkthdrM_dat.MH.MH_pkthdr.len > MHLEN((256 - sizeof(struct m_hdr)) - sizeof(struct pkthdr))) {
2844 MCLGET(m, M_DONTWAIT)(void) m_clget((m), (0x0002), (1 << 11));
2845 if ((m->m_flagsm_hdr.mh_flags & M_EXT0x0001) == 0) {
2846 printf("%s: cannot allocate Tx cluster\n",
2847 dvname);
2848 m_freem(m);
2849 break;
2850 }
2851 }
2852 m_copydata(m0, 0, m0->m_pkthdrM_dat.MH.MH_pkthdr.len, mtod(m, caddr_t)((caddr_t)((m)->m_hdr.mh_data)));
2853 m->m_pkthdrM_dat.MH.MH_pkthdr.len = m->m_lenm_hdr.mh_len = m0->m_pkthdrM_dat.MH.MH_pkthdr.len;
2854 m_freem(m0);
2855 m0 = m;
2856 m = NULL((void *)0);
2857 }
2858 if (rc != 0) {
2859 printf("%s: cannot load Tx buffer, rc = %d\n", dvname, rc);
2860 m_freem(m0);
2861 return NULL((void *)0);
2862 } else if (rtw_seg_too_short(dmam)) {
2863 printf("%s: cannot load Tx buffer, segment too short\n",
2864 dvname);
2865 bus_dmamap_unload(dmat, dmam)(*(dmat)->_dmamap_unload)((dmat), (dmam));
2866 m_freem(m0);
2867 return NULL((void *)0);
2868 } else if (dmam->dm_nsegs > ndescfree) {
2869 printf("%s: too many tx segments\n", dvname);
2870 bus_dmamap_unload(dmat, dmam)(*(dmat)->_dmamap_unload)((dmat), (dmam));
2871 m_freem(m0);
2872 return NULL((void *)0);
2873 }
2874 return m0;
2875}
2876
2877
2878/*
2879 * Arguments in:
2880 *
2881 * paylen: payload length (no FCS, no WEP header)
2882 *
2883 * hdrlen: header length
2884 *
2885 * rate: MSDU speed, units 500kb/s
2886 *
2887 * flags: IEEE80211_F_SHPREAMBLE (use short preamble),
2888 * IEEE80211_F_SHSLOT (use short slot length)
2889 *
2890 * Arguments out:
2891 *
2892 * d: 802.11 Duration field for RTS,
2893 * 802.11 Duration field for data frame,
2894 * PLCP Length for data frame,
2895 * residual octets at end of data slot
2896 */
2897int
2898rtw_compute_duration1(int len, int use_ack, uint32_t flags, int rate,
2899 struct rtw_duration *d)
2900{
2901 int pre, ctsrate;
2902 int ack, bitlen, data_dur, remainder;
2903
2904 /* RTS reserves medium for SIFS | CTS | SIFS | (DATA) | SIFS | ACK
2905 * DATA reserves medium for SIFS | ACK
2906 *
2907 * XXXMYC: no ACK on multicast/broadcast or control packets
2908 */
2909
2910 bitlen = len * 8;
2911
2912 pre = IEEE80211_DUR_DS_SIFS10;
2913 if ((flags & IEEE80211_F_SHPREAMBLE0x00040000) != 0)
2914 pre += IEEE80211_DUR_DS_SHORT_PREAMBLE72 +
2915 IEEE80211_DUR_DS_FAST_PLCPHDR24;
2916 else
2917 pre += IEEE80211_DUR_DS_LONG_PREAMBLE144 +
2918 IEEE80211_DUR_DS_SLOW_PLCPHDR48;
2919
2920 d->d_residue = 0;
2921 data_dur = (bitlen * 2) / rate;
2922 remainder = (bitlen * 2) % rate;
2923 if (remainder != 0) {
2924 d->d_residue = (rate - remainder) / 16;
2925 data_dur++;
2926 }
2927
2928 switch (rate) {
2929 case 2: /* 1 Mb/s */
2930 case 4: /* 2 Mb/s */
2931 /* 1 - 2 Mb/s WLAN: send ACK/CTS at 1 Mb/s */
2932 ctsrate = 2;
2933 break;
2934 case 11: /* 5.5 Mb/s */
2935 case 22: /* 11 Mb/s */
2936 case 44: /* 22 Mb/s */
2937 /* 5.5 - 11 Mb/s WLAN: send ACK/CTS at 2 Mb/s */
2938 ctsrate = 4;
2939 break;
2940 default:
2941 /* TBD */
2942 return -1;
2943 }
2944
2945 d->d_plcp_len = data_dur;
2946
2947 ack = (use_ack) ? pre + (IEEE80211_DUR_DS_SLOW_ACK112 * 2) / ctsrate : 0;
2948
2949 d->d_rts_dur =
2950 pre + (IEEE80211_DUR_DS_SLOW_CTS112 * 2) / ctsrate +
2951 pre + data_dur +
2952 ack;
2953
2954 d->d_data_dur = ack;
2955
2956 return 0;
2957}
2958
2959/*
2960 * Arguments in:
2961 *
2962 * wh: 802.11 header
2963 *
2964 * len: packet length
2965 *
2966 * rate: MSDU speed, units 500kb/s
2967 *
2968 * fraglen: fragment length, set to maximum (or higher) for no
2969 * fragmentation
2970 *
2971 * flags: IEEE80211_F_WEPON (hardware adds WEP),
2972 * IEEE80211_F_SHPREAMBLE (use short preamble),
2973 * IEEE80211_F_SHSLOT (use short slot length)
2974 *
2975 * Arguments out:
2976 *
2977 * d0: 802.11 Duration fields (RTS/Data), PLCP Length, Service fields
2978 * of first/only fragment
2979 *
2980 * dn: 802.11 Duration fields (RTS/Data), PLCP Length, Service fields
2981 * of first/only fragment
2982 */
2983int
2984rtw_compute_duration(struct ieee80211_frame *wh, int len, uint32_t flags,
2985 int fraglen, int rate, struct rtw_duration *d0, struct rtw_duration *dn,
2986 int *npktp, int debug)
2987{
2988 int ack, rc;
2989 int firstlen, hdrlen, lastlen, lastlen0, npkt, overlen, paylen;
2990
2991 if (ieee80211_has_addr4(wh))
2992 hdrlen = sizeof(struct ieee80211_frame_addr4);
2993 else
2994 hdrlen = sizeof(struct ieee80211_frame);
2995
2996 paylen = len - hdrlen;
2997
2998 if ((flags & IEEE80211_F_WEPON0x00000100) != 0)
2999 overlen = IEEE80211_WEP_TOTLEN(3 + 1 + 4) + IEEE80211_CRC_LEN4;
3000 else
3001 overlen = IEEE80211_CRC_LEN4;
3002
3003 npkt = paylen / fraglen;
3004 lastlen0 = paylen % fraglen;
3005
3006 if (npkt == 0) /* no fragments */
3007 lastlen = paylen + overlen;
3008 else if (lastlen0 != 0) { /* a short "tail" fragment */
3009 lastlen = lastlen0 + overlen;
3010 npkt++;
3011 } else /* full-length "tail" fragment */
3012 lastlen = fraglen + overlen;
3013
3014 if (npktp != NULL((void *)0))
3015 *npktp = npkt;
3016
3017 if (npkt > 1)
3018 firstlen = fraglen + overlen;
3019 else
3020 firstlen = paylen + overlen;
3021
3022 if (debug) {
3023 printf("%s: npkt %d firstlen %d lastlen0 %d lastlen %d "
3024 "fraglen %d overlen %d len %d rate %d flags %08x\n",
3025 __func__, npkt, firstlen, lastlen0, lastlen, fraglen,
3026 overlen, len, rate, flags);
3027 }
3028
3029 ack = !IEEE80211_IS_MULTICAST(wh->i_addr1)(*(wh->i_addr1) & 0x01) &&
3030 (wh->i_fc[1] & IEEE80211_FC0_TYPE_MASK0x0c) != IEEE80211_FC0_TYPE_CTL0x04;
3031
3032 rc = rtw_compute_duration1(firstlen + hdrlen, ack, flags, rate, d0);
3033 if (rc == -1)
3034 return rc;
3035
3036 if (npkt <= 1) {
3037 *dn = *d0;
3038 return 0;
3039 }
3040 return rtw_compute_duration1(lastlen + hdrlen, ack, flags, rate, dn);
3041}
3042
3043#ifdef RTW_DEBUG
3044void
3045rtw_print_txdesc(struct rtw_softc *sc, const char *action,
3046 struct rtw_txsoft *ts, struct rtw_txdesc_blk *tdb, int desc)
3047{
3048 struct rtw_txdesc *td = &tdb->tdb_desc[desc];
3049 DPRINTF(sc, RTW_DEBUG_XMIT_DESC, ("%s: %p %s txdesc[%d] next %#08x "
3050 "buf %#08x ctl0 %#08x ctl1 %#08x len %#08x\n",
3051 sc->sc_dev.dv_xname, ts, action, desc,
3052 letoh32(td->td_buf), letoh32(td->td_next),
3053 letoh32(td->td_ctl0), letoh32(td->td_ctl1),
3054 letoh32(td->td_len)));
3055}
3056#endif /* RTW_DEBUG */
3057
3058void
3059rtw_start(struct ifnet *ifp)
3060{
3061 uint8_t tppoll;
3062 int desc, i, lastdesc, npkt, rate;
3063 uint32_t proto_ctl0, ctl0, ctl1;
3064 bus_dmamap_t dmamap;
3065 struct ieee80211com *ic;
3066 struct ieee80211_frame *wh;
3067 struct ieee80211_node *ni;
3068 struct mbuf *m0;
3069 struct rtw_softc *sc;
3070 struct rtw_duration *d0;
3071 struct rtw_txsoft_blk *tsb;
3072 struct rtw_txdesc_blk *tdb;
3073 struct rtw_txsoft *ts;
3074 struct rtw_txdesc *td;
3075
3076 sc = (struct rtw_softc *)ifp->if_softc;
3077 ic = &sc->sc_ic;
3078
3079 DPRINTF(sc, RTW_DEBUG_XMIT,
3080 ("%s: enter %s\n", sc->sc_dev.dv_xname, __func__));
3081
3082 if (!(ifp->if_flags & IFF_RUNNING0x40) || ifq_is_oactive(&ifp->if_snd))
3083 goto out;
3084
3085 /* XXX do real rate control */
3086 proto_ctl0 = RTW_TXCTL0_RTSRATE_1MBPS((0) << ((((u_long)((((((0x780000)) - 1) & ((0x780000
))) ^ ((0x780000)))) >> (16)) != 0) ? 16 + ((((u_long)(
((((((0x780000) >> 16)) - 1) & (((0x780000) >>
16))) ^ (((0x780000) >> 16)))) >> (8)) != 0) ? 8
+ ((((u_long)((((((((0x780000) >> 16) >> 8)) - 1
) & ((((0x780000) >> 16) >> 8))) ^ ((((0x780000
) >> 16) >> 8)))) >> (4)) != 0) ? 4 + ((((u_long
)(((((((((0x780000) >> 16) >> 8) >> 4)) - 1
) & (((((0x780000) >> 16) >> 8) >> 4)))
^ (((((0x780000) >> 16) >> 8) >> 4)))) >>
(2)) != 0) ? 2 + ((((u_long)((((((((((0x780000) >> 16)
>> 8) >> 4) >> 2)) - 1) & ((((((0x780000
) >> 16) >> 8) >> 4) >> 2))) ^ ((((((
0x780000) >> 16) >> 8) >> 4) >> 2))))
>> (1)) != 0) ? 1 : 0) : ((((u_long)((((((((((0x780000
) >> 16) >> 8) >> 4))) - 1) & ((((((0x780000
) >> 16) >> 8) >> 4)))) ^ ((((((0x780000) >>
16) >> 8) >> 4))))) >> (1)) != 0) ? 1 : 0)
) : ((((u_long)(((((((((0x780000) >> 16) >> 8))) -
1) & (((((0x780000) >> 16) >> 8)))) ^ (((((0x780000
) >> 16) >> 8))))) >> (2)) != 0) ? 2 + ((((
u_long)((((((((((0x780000) >> 16) >> 8)) >>
2)) - 1) & ((((((0x780000) >> 16) >> 8)) >>
2))) ^ ((((((0x780000) >> 16) >> 8)) >> 2)
))) >> (1)) != 0) ? 1 : 0) : ((((u_long)((((((((((0x780000
) >> 16) >> 8)))) - 1) & ((((((0x780000) >>
16) >> 8))))) ^ ((((((0x780000) >> 16) >> 8
)))))) >> (1)) != 0) ? 1 : 0))) : ((((u_long)((((((((0x780000
) >> 16))) - 1) & ((((0x780000) >> 16)))) ^ (
(((0x780000) >> 16))))) >> (4)) != 0) ? 4 + ((((u_long
)(((((((((0x780000) >> 16)) >> 4)) - 1) & (((
((0x780000) >> 16)) >> 4))) ^ (((((0x780000) >>
16)) >> 4)))) >> (2)) != 0) ? 2 + ((((u_long)(((
(((((((0x780000) >> 16)) >> 4) >> 2)) - 1) &
((((((0x780000) >> 16)) >> 4) >> 2))) ^ ((
((((0x780000) >> 16)) >> 4) >> 2)))) >>
(1)) != 0) ? 1 : 0) : ((((u_long)((((((((((0x780000) >>
16)) >> 4))) - 1) & ((((((0x780000) >> 16)) >>
4)))) ^ ((((((0x780000) >> 16)) >> 4))))) >>
(1)) != 0) ? 1 : 0)) : ((((u_long)(((((((((0x780000) >>
16)))) - 1) & (((((0x780000) >> 16))))) ^ (((((0x780000
) >> 16)))))) >> (2)) != 0) ? 2 + ((((u_long)((((
((((((0x780000) >> 16))) >> 2)) - 1) & ((((((
0x780000) >> 16))) >> 2))) ^ ((((((0x780000) >>
16))) >> 2)))) >> (1)) != 0) ? 1 : 0) : ((((u_long
)((((((((((0x780000) >> 16))))) - 1) & ((((((0x780000
) >> 16)))))) ^ ((((((0x780000) >> 16))))))) >>
(1)) != 0) ? 1 : 0)))) : ((((u_long)(((((((0x780000))) - 1) &
(((0x780000)))) ^ (((0x780000))))) >> (8)) != 0) ? 8 +
((((u_long)((((((((0x780000)) >> 8)) - 1) & ((((0x780000
)) >> 8))) ^ ((((0x780000)) >> 8)))) >> (4)
) != 0) ? 4 + ((((u_long)(((((((((0x780000)) >> 8) >>
4)) - 1) & (((((0x780000)) >> 8) >> 4))) ^ (
((((0x780000)) >> 8) >> 4)))) >> (2)) != 0)
? 2 + ((((u_long)((((((((((0x780000)) >> 8) >> 4
) >> 2)) - 1) & ((((((0x780000)) >> 8) >>
4) >> 2))) ^ ((((((0x780000)) >> 8) >> 4) >>
2)))) >> (1)) != 0) ? 1 : 0) : ((((u_long)((((((((((0x780000
)) >> 8) >> 4))) - 1) & ((((((0x780000)) >>
8) >> 4)))) ^ ((((((0x780000)) >> 8) >> 4)
)))) >> (1)) != 0) ? 1 : 0)) : ((((u_long)(((((((((0x780000
)) >> 8))) - 1) & (((((0x780000)) >> 8)))) ^ (
((((0x780000)) >> 8))))) >> (2)) != 0) ? 2 + ((((
u_long)((((((((((0x780000)) >> 8)) >> 2)) - 1) &
((((((0x780000)) >> 8)) >> 2))) ^ ((((((0x780000
)) >> 8)) >> 2)))) >> (1)) != 0) ? 1 : 0) :
((((u_long)((((((((((0x780000)) >> 8)))) - 1) & ((
((((0x780000)) >> 8))))) ^ ((((((0x780000)) >> 8)
))))) >> (1)) != 0) ? 1 : 0))) : ((((u_long)((((((((0x780000
)))) - 1) & ((((0x780000))))) ^ ((((0x780000)))))) >>
(4)) != 0) ? 4 + ((((u_long)(((((((((0x780000))) >> 4)
) - 1) & (((((0x780000))) >> 4))) ^ (((((0x780000))
) >> 4)))) >> (2)) != 0) ? 2 + ((((u_long)(((((((
(((0x780000))) >> 4) >> 2)) - 1) & ((((((0x780000
))) >> 4) >> 2))) ^ ((((((0x780000))) >> 4)
>> 2)))) >> (1)) != 0) ? 1 : 0) : ((((u_long)(((
(((((((0x780000))) >> 4))) - 1) & ((((((0x780000)))
>> 4)))) ^ ((((((0x780000))) >> 4))))) >> (
1)) != 0) ? 1 : 0)) : ((((u_long)(((((((((0x780000))))) - 1) &
(((((0x780000)))))) ^ (((((0x780000))))))) >> (2)) != 0
) ? 2 + ((((u_long)((((((((((0x780000)))) >> 2)) - 1) &
((((((0x780000)))) >> 2))) ^ ((((((0x780000)))) >>
2)))) >> (1)) != 0) ? 1 : 0) : ((((u_long)((((((((((0x780000
)))))) - 1) & ((((((0x780000))))))) ^ ((((((0x780000)))))
))) >> (1)) != 0) ? 1 : 0))))))
;
3087
3088 if ((ic->ic_flags & IEEE80211_F_SHPREAMBLE0x00040000) != 0)
3089 proto_ctl0 |= RTW_TXCTL0_SPLCP(1<<16);
3090
3091 for (;;) {
3092 if (rtw_dequeue(ifp, &tsb, &tdb, &m0, &ni) == -1)
3093 continue;
3094 if (m0 == NULL((void *)0))
3095 break;
3096 ts = SIMPLEQ_FIRST(&tsb->tsb_freeq)((&tsb->tsb_freeq)->sqh_first);
3097
3098 dmamap = ts->ts_dmamap;
3099
3100 m0 = rtw_dmamap_load_txbuf(sc->sc_dmat, dmamap, m0,
3101 tdb->tdb_nfree, &ifp->if_flags, sc->sc_dev.dv_xname);
3102
3103 if (m0 == NULL((void *)0) || dmamap->dm_nsegs == 0) {
3104 DPRINTF(sc, RTW_DEBUG_XMIT,
3105 ("%s: fail dmamap load\n", __func__));
3106 goto post_dequeue_err;
3107 }
3108
3109 wh = mtod(m0, struct ieee80211_frame *)((struct ieee80211_frame *)((m0)->m_hdr.mh_data));
3110
3111 /* XXX do real rate control */
3112 if ((wh->i_fc[0] & IEEE80211_FC0_TYPE_MASK0x0c) ==
3113 IEEE80211_FC0_TYPE_MGT0x00)
3114 rate = 2;
3115 else
3116 rate = MAX(2, ieee80211_get_rate(ic))(((2)>(ieee80211_get_rate(ic)))?(2):(ieee80211_get_rate(ic
)))
;
3117
3118#ifdef RTW_DEBUG
3119 if ((sc->sc_ifsc_ic.ic_ac.ac_if.if_flags & (IFF_DEBUG0x4|IFF_LINK20x4000)) ==
3120 (IFF_DEBUG0x4|IFF_LINK20x4000)) {
3121 ieee80211_dump_pkt(mtod(m0, uint8_t *)((uint8_t *)((m0)->m_hdr.mh_data)),
3122 (dmamap->dm_nsegs == 1) ? m0->m_pkthdrM_dat.MH.MH_pkthdr.len
3123 : sizeof(wh), rate, 0);
3124 }
3125#endif /* RTW_DEBUG */
3126 ctl0 = proto_ctl0 |
3127 LSHIFT(m0->m_pkthdr.len, RTW_TXCTL0_TPKTSIZE_MASK)((m0->M_dat.MH.MH_pkthdr.len) << ((((u_long)((((((0xfff
)) - 1) & ((0xfff))) ^ ((0xfff)))) >> (16)) != 0) ?
16 + ((((u_long)(((((((0xfff) >> 16)) - 1) & (((0xfff
) >> 16))) ^ (((0xfff) >> 16)))) >> (8)) !=
0) ? 8 + ((((u_long)((((((((0xfff) >> 16) >> 8))
- 1) & ((((0xfff) >> 16) >> 8))) ^ ((((0xfff
) >> 16) >> 8)))) >> (4)) != 0) ? 4 + ((((u_long
)(((((((((0xfff) >> 16) >> 8) >> 4)) - 1) &
(((((0xfff) >> 16) >> 8) >> 4))) ^ (((((0xfff
) >> 16) >> 8) >> 4)))) >> (2)) != 0)
? 2 + ((((u_long)((((((((((0xfff) >> 16) >> 8) >>
4) >> 2)) - 1) & ((((((0xfff) >> 16) >>
8) >> 4) >> 2))) ^ ((((((0xfff) >> 16) >>
8) >> 4) >> 2)))) >> (1)) != 0) ? 1 : 0) :
((((u_long)((((((((((0xfff) >> 16) >> 8) >>
4))) - 1) & ((((((0xfff) >> 16) >> 8) >>
4)))) ^ ((((((0xfff) >> 16) >> 8) >> 4))))
) >> (1)) != 0) ? 1 : 0)) : ((((u_long)(((((((((0xfff) >>
16) >> 8))) - 1) & (((((0xfff) >> 16) >>
8)))) ^ (((((0xfff) >> 16) >> 8))))) >> (2
)) != 0) ? 2 + ((((u_long)((((((((((0xfff) >> 16) >>
8)) >> 2)) - 1) & ((((((0xfff) >> 16) >>
8)) >> 2))) ^ ((((((0xfff) >> 16) >> 8)) >>
2)))) >> (1)) != 0) ? 1 : 0) : ((((u_long)((((((((((0xfff
) >> 16) >> 8)))) - 1) & ((((((0xfff) >>
16) >> 8))))) ^ ((((((0xfff) >> 16) >> 8))
)))) >> (1)) != 0) ? 1 : 0))) : ((((u_long)((((((((0xfff
) >> 16))) - 1) & ((((0xfff) >> 16)))) ^ ((((
0xfff) >> 16))))) >> (4)) != 0) ? 4 + ((((u_long)
(((((((((0xfff) >> 16)) >> 4)) - 1) & (((((0xfff
) >> 16)) >> 4))) ^ (((((0xfff) >> 16)) >>
4)))) >> (2)) != 0) ? 2 + ((((u_long)((((((((((0xfff) >>
16)) >> 4) >> 2)) - 1) & ((((((0xfff) >>
16)) >> 4) >> 2))) ^ ((((((0xfff) >> 16)) >>
4) >> 2)))) >> (1)) != 0) ? 1 : 0) : ((((u_long)
((((((((((0xfff) >> 16)) >> 4))) - 1) & (((((
(0xfff) >> 16)) >> 4)))) ^ ((((((0xfff) >> 16
)) >> 4))))) >> (1)) != 0) ? 1 : 0)) : ((((u_long
)(((((((((0xfff) >> 16)))) - 1) & (((((0xfff) >>
16))))) ^ (((((0xfff) >> 16)))))) >> (2)) != 0) ?
2 + ((((u_long)((((((((((0xfff) >> 16))) >> 2)) -
1) & ((((((0xfff) >> 16))) >> 2))) ^ ((((((0xfff
) >> 16))) >> 2)))) >> (1)) != 0) ? 1 : 0) :
((((u_long)((((((((((0xfff) >> 16))))) - 1) & ((((
((0xfff) >> 16)))))) ^ ((((((0xfff) >> 16))))))) >>
(1)) != 0) ? 1 : 0)))) : ((((u_long)(((((((0xfff))) - 1) &
(((0xfff)))) ^ (((0xfff))))) >> (8)) != 0) ? 8 + ((((u_long
)((((((((0xfff)) >> 8)) - 1) & ((((0xfff)) >>
8))) ^ ((((0xfff)) >> 8)))) >> (4)) != 0) ? 4 + (
(((u_long)(((((((((0xfff)) >> 8) >> 4)) - 1) &
(((((0xfff)) >> 8) >> 4))) ^ (((((0xfff)) >>
8) >> 4)))) >> (2)) != 0) ? 2 + ((((u_long)(((((
(((((0xfff)) >> 8) >> 4) >> 2)) - 1) & (
(((((0xfff)) >> 8) >> 4) >> 2))) ^ ((((((0xfff
)) >> 8) >> 4) >> 2)))) >> (1)) != 0)
? 1 : 0) : ((((u_long)((((((((((0xfff)) >> 8) >>
4))) - 1) & ((((((0xfff)) >> 8) >> 4)))) ^ (
(((((0xfff)) >> 8) >> 4))))) >> (1)) != 0) ?
1 : 0)) : ((((u_long)(((((((((0xfff)) >> 8))) - 1) &
(((((0xfff)) >> 8)))) ^ (((((0xfff)) >> 8))))) >>
(2)) != 0) ? 2 + ((((u_long)((((((((((0xfff)) >> 8)) >>
2)) - 1) & ((((((0xfff)) >> 8)) >> 2))) ^ ((
((((0xfff)) >> 8)) >> 2)))) >> (1)) != 0) ?
1 : 0) : ((((u_long)((((((((((0xfff)) >> 8)))) - 1) &
((((((0xfff)) >> 8))))) ^ ((((((0xfff)) >> 8))))
)) >> (1)) != 0) ? 1 : 0))) : ((((u_long)((((((((0xfff)
))) - 1) & ((((0xfff))))) ^ ((((0xfff)))))) >> (4))
!= 0) ? 4 + ((((u_long)(((((((((0xfff))) >> 4)) - 1) &
(((((0xfff))) >> 4))) ^ (((((0xfff))) >> 4)))) >>
(2)) != 0) ? 2 + ((((u_long)((((((((((0xfff))) >> 4) >>
2)) - 1) & ((((((0xfff))) >> 4) >> 2))) ^ ((
((((0xfff))) >> 4) >> 2)))) >> (1)) != 0) ?
1 : 0) : ((((u_long)((((((((((0xfff))) >> 4))) - 1) &
((((((0xfff))) >> 4)))) ^ ((((((0xfff))) >> 4)))
)) >> (1)) != 0) ? 1 : 0)) : ((((u_long)(((((((((0xfff)
)))) - 1) & (((((0xfff)))))) ^ (((((0xfff))))))) >>
(2)) != 0) ? 2 + ((((u_long)((((((((((0xfff)))) >> 2))
- 1) & ((((((0xfff)))) >> 2))) ^ ((((((0xfff)))) >>
2)))) >> (1)) != 0) ? 1 : 0) : ((((u_long)((((((((((0xfff
)))))) - 1) & ((((((0xfff))))))) ^ ((((((0xfff)))))))) >>
(1)) != 0) ? 1 : 0))))))
;
3128
3129 switch (rate) {
3130 default:
3131 case 2:
3132 ctl0 |= RTW_TXCTL0_RATE_1MBPS((0) << ((((u_long)((((((0xf000000)) - 1) & ((0xf000000
))) ^ ((0xf000000)))) >> (16)) != 0) ? 16 + ((((u_long)
(((((((0xf000000) >> 16)) - 1) & (((0xf000000) >>
16))) ^ (((0xf000000) >> 16)))) >> (8)) != 0) ? 8
+ ((((u_long)((((((((0xf000000) >> 16) >> 8)) - 1
) & ((((0xf000000) >> 16) >> 8))) ^ ((((0xf000000
) >> 16) >> 8)))) >> (4)) != 0) ? 4 + ((((u_long
)(((((((((0xf000000) >> 16) >> 8) >> 4)) - 1
) & (((((0xf000000) >> 16) >> 8) >> 4))
) ^ (((((0xf000000) >> 16) >> 8) >> 4)))) >>
(2)) != 0) ? 2 + ((((u_long)((((((((((0xf000000) >> 16
) >> 8) >> 4) >> 2)) - 1) & ((((((0xf000000
) >> 16) >> 8) >> 4) >> 2))) ^ ((((((
0xf000000) >> 16) >> 8) >> 4) >> 2)))
) >> (1)) != 0) ? 1 : 0) : ((((u_long)((((((((((0xf000000
) >> 16) >> 8) >> 4))) - 1) & ((((((0xf000000
) >> 16) >> 8) >> 4)))) ^ ((((((0xf000000) >>
16) >> 8) >> 4))))) >> (1)) != 0) ? 1 : 0)
) : ((((u_long)(((((((((0xf000000) >> 16) >> 8)))
- 1) & (((((0xf000000) >> 16) >> 8)))) ^ (((
((0xf000000) >> 16) >> 8))))) >> (2)) != 0)
? 2 + ((((u_long)((((((((((0xf000000) >> 16) >> 8
)) >> 2)) - 1) & ((((((0xf000000) >> 16) >>
8)) >> 2))) ^ ((((((0xf000000) >> 16) >> 8
)) >> 2)))) >> (1)) != 0) ? 1 : 0) : ((((u_long)(
(((((((((0xf000000) >> 16) >> 8)))) - 1) & ((
((((0xf000000) >> 16) >> 8))))) ^ ((((((0xf000000
) >> 16) >> 8)))))) >> (1)) != 0) ? 1 : 0))
) : ((((u_long)((((((((0xf000000) >> 16))) - 1) & (
(((0xf000000) >> 16)))) ^ ((((0xf000000) >> 16)))
)) >> (4)) != 0) ? 4 + ((((u_long)(((((((((0xf000000) >>
16)) >> 4)) - 1) & (((((0xf000000) >> 16)) >>
4))) ^ (((((0xf000000) >> 16)) >> 4)))) >>
(2)) != 0) ? 2 + ((((u_long)((((((((((0xf000000) >> 16
)) >> 4) >> 2)) - 1) & ((((((0xf000000) >>
16)) >> 4) >> 2))) ^ ((((((0xf000000) >> 16
)) >> 4) >> 2)))) >> (1)) != 0) ? 1 : 0) : (
(((u_long)((((((((((0xf000000) >> 16)) >> 4))) - 1
) & ((((((0xf000000) >> 16)) >> 4)))) ^ (((((
(0xf000000) >> 16)) >> 4))))) >> (1)) != 0)
? 1 : 0)) : ((((u_long)(((((((((0xf000000) >> 16)))) -
1) & (((((0xf000000) >> 16))))) ^ (((((0xf000000) >>
16)))))) >> (2)) != 0) ? 2 + ((((u_long)((((((((((0xf000000
) >> 16))) >> 2)) - 1) & ((((((0xf000000) >>
16))) >> 2))) ^ ((((((0xf000000) >> 16))) >>
2)))) >> (1)) != 0) ? 1 : 0) : ((((u_long)((((((((((0xf000000
) >> 16))))) - 1) & ((((((0xf000000) >> 16)))
))) ^ ((((((0xf000000) >> 16))))))) >> (1)) != 0)
? 1 : 0)))) : ((((u_long)(((((((0xf000000))) - 1) & (((0xf000000
)))) ^ (((0xf000000))))) >> (8)) != 0) ? 8 + ((((u_long
)((((((((0xf000000)) >> 8)) - 1) & ((((0xf000000)) >>
8))) ^ ((((0xf000000)) >> 8)))) >> (4)) != 0) ? 4
+ ((((u_long)(((((((((0xf000000)) >> 8) >> 4)) -
1) & (((((0xf000000)) >> 8) >> 4))) ^ (((((0xf000000
)) >> 8) >> 4)))) >> (2)) != 0) ? 2 + ((((u_long
)((((((((((0xf000000)) >> 8) >> 4) >> 2)) -
1) & ((((((0xf000000)) >> 8) >> 4) >> 2
))) ^ ((((((0xf000000)) >> 8) >> 4) >> 2)))
) >> (1)) != 0) ? 1 : 0) : ((((u_long)((((((((((0xf000000
)) >> 8) >> 4))) - 1) & ((((((0xf000000)) >>
8) >> 4)))) ^ ((((((0xf000000)) >> 8) >> 4
))))) >> (1)) != 0) ? 1 : 0)) : ((((u_long)(((((((((0xf000000
)) >> 8))) - 1) & (((((0xf000000)) >> 8)))) ^
(((((0xf000000)) >> 8))))) >> (2)) != 0) ? 2 + (
(((u_long)((((((((((0xf000000)) >> 8)) >> 2)) - 1
) & ((((((0xf000000)) >> 8)) >> 2))) ^ ((((((
0xf000000)) >> 8)) >> 2)))) >> (1)) != 0) ?
1 : 0) : ((((u_long)((((((((((0xf000000)) >> 8)))) - 1
) & ((((((0xf000000)) >> 8))))) ^ ((((((0xf000000))
>> 8)))))) >> (1)) != 0) ? 1 : 0))) : ((((u_long
)((((((((0xf000000)))) - 1) & ((((0xf000000))))) ^ ((((0xf000000
)))))) >> (4)) != 0) ? 4 + ((((u_long)(((((((((0xf000000
))) >> 4)) - 1) & (((((0xf000000))) >> 4))) ^
(((((0xf000000))) >> 4)))) >> (2)) != 0) ? 2 + (
(((u_long)((((((((((0xf000000))) >> 4) >> 2)) - 1
) & ((((((0xf000000))) >> 4) >> 2))) ^ ((((((
0xf000000))) >> 4) >> 2)))) >> (1)) != 0) ?
1 : 0) : ((((u_long)((((((((((0xf000000))) >> 4))) - 1
) & ((((((0xf000000))) >> 4)))) ^ ((((((0xf000000))
) >> 4))))) >> (1)) != 0) ? 1 : 0)) : ((((u_long)
(((((((((0xf000000))))) - 1) & (((((0xf000000)))))) ^ (((
((0xf000000))))))) >> (2)) != 0) ? 2 + ((((u_long)(((((
(((((0xf000000)))) >> 2)) - 1) & ((((((0xf000000)))
) >> 2))) ^ ((((((0xf000000)))) >> 2)))) >>
(1)) != 0) ? 1 : 0) : ((((u_long)((((((((((0xf000000)))))) -
1) & ((((((0xf000000))))))) ^ ((((((0xf000000)))))))) >>
(1)) != 0) ? 1 : 0))))))
;
3133 break;
3134 case 4:
3135 ctl0 |= RTW_TXCTL0_RATE_2MBPS((1) << ((((u_long)((((((0xf000000)) - 1) & ((0xf000000
))) ^ ((0xf000000)))) >> (16)) != 0) ? 16 + ((((u_long)
(((((((0xf000000) >> 16)) - 1) & (((0xf000000) >>
16))) ^ (((0xf000000) >> 16)))) >> (8)) != 0) ? 8
+ ((((u_long)((((((((0xf000000) >> 16) >> 8)) - 1
) & ((((0xf000000) >> 16) >> 8))) ^ ((((0xf000000
) >> 16) >> 8)))) >> (4)) != 0) ? 4 + ((((u_long
)(((((((((0xf000000) >> 16) >> 8) >> 4)) - 1
) & (((((0xf000000) >> 16) >> 8) >> 4))
) ^ (((((0xf000000) >> 16) >> 8) >> 4)))) >>
(2)) != 0) ? 2 + ((((u_long)((((((((((0xf000000) >> 16
) >> 8) >> 4) >> 2)) - 1) & ((((((0xf000000
) >> 16) >> 8) >> 4) >> 2))) ^ ((((((
0xf000000) >> 16) >> 8) >> 4) >> 2)))
) >> (1)) != 0) ? 1 : 0) : ((((u_long)((((((((((0xf000000
) >> 16) >> 8) >> 4))) - 1) & ((((((0xf000000
) >> 16) >> 8) >> 4)))) ^ ((((((0xf000000) >>
16) >> 8) >> 4))))) >> (1)) != 0) ? 1 : 0)
) : ((((u_long)(((((((((0xf000000) >> 16) >> 8)))
- 1) & (((((0xf000000) >> 16) >> 8)))) ^ (((
((0xf000000) >> 16) >> 8))))) >> (2)) != 0)
? 2 + ((((u_long)((((((((((0xf000000) >> 16) >> 8
)) >> 2)) - 1) & ((((((0xf000000) >> 16) >>
8)) >> 2))) ^ ((((((0xf000000) >> 16) >> 8
)) >> 2)))) >> (1)) != 0) ? 1 : 0) : ((((u_long)(
(((((((((0xf000000) >> 16) >> 8)))) - 1) & ((
((((0xf000000) >> 16) >> 8))))) ^ ((((((0xf000000
) >> 16) >> 8)))))) >> (1)) != 0) ? 1 : 0))
) : ((((u_long)((((((((0xf000000) >> 16))) - 1) & (
(((0xf000000) >> 16)))) ^ ((((0xf000000) >> 16)))
)) >> (4)) != 0) ? 4 + ((((u_long)(((((((((0xf000000) >>
16)) >> 4)) - 1) & (((((0xf000000) >> 16)) >>
4))) ^ (((((0xf000000) >> 16)) >> 4)))) >>
(2)) != 0) ? 2 + ((((u_long)((((((((((0xf000000) >> 16
)) >> 4) >> 2)) - 1) & ((((((0xf000000) >>
16)) >> 4) >> 2))) ^ ((((((0xf000000) >> 16
)) >> 4) >> 2)))) >> (1)) != 0) ? 1 : 0) : (
(((u_long)((((((((((0xf000000) >> 16)) >> 4))) - 1
) & ((((((0xf000000) >> 16)) >> 4)))) ^ (((((
(0xf000000) >> 16)) >> 4))))) >> (1)) != 0)
? 1 : 0)) : ((((u_long)(((((((((0xf000000) >> 16)))) -
1) & (((((0xf000000) >> 16))))) ^ (((((0xf000000) >>
16)))))) >> (2)) != 0) ? 2 + ((((u_long)((((((((((0xf000000
) >> 16))) >> 2)) - 1) & ((((((0xf000000) >>
16))) >> 2))) ^ ((((((0xf000000) >> 16))) >>
2)))) >> (1)) != 0) ? 1 : 0) : ((((u_long)((((((((((0xf000000
) >> 16))))) - 1) & ((((((0xf000000) >> 16)))
))) ^ ((((((0xf000000) >> 16))))))) >> (1)) != 0)
? 1 : 0)))) : ((((u_long)(((((((0xf000000))) - 1) & (((0xf000000
)))) ^ (((0xf000000))))) >> (8)) != 0) ? 8 + ((((u_long
)((((((((0xf000000)) >> 8)) - 1) & ((((0xf000000)) >>
8))) ^ ((((0xf000000)) >> 8)))) >> (4)) != 0) ? 4
+ ((((u_long)(((((((((0xf000000)) >> 8) >> 4)) -
1) & (((((0xf000000)) >> 8) >> 4))) ^ (((((0xf000000
)) >> 8) >> 4)))) >> (2)) != 0) ? 2 + ((((u_long
)((((((((((0xf000000)) >> 8) >> 4) >> 2)) -
1) & ((((((0xf000000)) >> 8) >> 4) >> 2
))) ^ ((((((0xf000000)) >> 8) >> 4) >> 2)))
) >> (1)) != 0) ? 1 : 0) : ((((u_long)((((((((((0xf000000
)) >> 8) >> 4))) - 1) & ((((((0xf000000)) >>
8) >> 4)))) ^ ((((((0xf000000)) >> 8) >> 4
))))) >> (1)) != 0) ? 1 : 0)) : ((((u_long)(((((((((0xf000000
)) >> 8))) - 1) & (((((0xf000000)) >> 8)))) ^
(((((0xf000000)) >> 8))))) >> (2)) != 0) ? 2 + (
(((u_long)((((((((((0xf000000)) >> 8)) >> 2)) - 1
) & ((((((0xf000000)) >> 8)) >> 2))) ^ ((((((
0xf000000)) >> 8)) >> 2)))) >> (1)) != 0) ?
1 : 0) : ((((u_long)((((((((((0xf000000)) >> 8)))) - 1
) & ((((((0xf000000)) >> 8))))) ^ ((((((0xf000000))
>> 8)))))) >> (1)) != 0) ? 1 : 0))) : ((((u_long
)((((((((0xf000000)))) - 1) & ((((0xf000000))))) ^ ((((0xf000000
)))))) >> (4)) != 0) ? 4 + ((((u_long)(((((((((0xf000000
))) >> 4)) - 1) & (((((0xf000000))) >> 4))) ^
(((((0xf000000))) >> 4)))) >> (2)) != 0) ? 2 + (
(((u_long)((((((((((0xf000000))) >> 4) >> 2)) - 1
) & ((((((0xf000000))) >> 4) >> 2))) ^ ((((((
0xf000000))) >> 4) >> 2)))) >> (1)) != 0) ?
1 : 0) : ((((u_long)((((((((((0xf000000))) >> 4))) - 1
) & ((((((0xf000000))) >> 4)))) ^ ((((((0xf000000))
) >> 4))))) >> (1)) != 0) ? 1 : 0)) : ((((u_long)
(((((((((0xf000000))))) - 1) & (((((0xf000000)))))) ^ (((
((0xf000000))))))) >> (2)) != 0) ? 2 + ((((u_long)(((((
(((((0xf000000)))) >> 2)) - 1) & ((((((0xf000000)))
) >> 2))) ^ ((((((0xf000000)))) >> 2)))) >>
(1)) != 0) ? 1 : 0) : ((((u_long)((((((((((0xf000000)))))) -
1) & ((((((0xf000000))))))) ^ ((((((0xf000000)))))))) >>
(1)) != 0) ? 1 : 0))))))
;
3136 break;
3137 case 11:
3138 ctl0 |= RTW_TXCTL0_RATE_5MBPS((2) << ((((u_long)((((((0xf000000)) - 1) & ((0xf000000
))) ^ ((0xf000000)))) >> (16)) != 0) ? 16 + ((((u_long)
(((((((0xf000000) >> 16)) - 1) & (((0xf000000) >>
16))) ^ (((0xf000000) >> 16)))) >> (8)) != 0) ? 8
+ ((((u_long)((((((((0xf000000) >> 16) >> 8)) - 1
) & ((((0xf000000) >> 16) >> 8))) ^ ((((0xf000000
) >> 16) >> 8)))) >> (4)) != 0) ? 4 + ((((u_long
)(((((((((0xf000000) >> 16) >> 8) >> 4)) - 1
) & (((((0xf000000) >> 16) >> 8) >> 4))
) ^ (((((0xf000000) >> 16) >> 8) >> 4)))) >>
(2)) != 0) ? 2 + ((((u_long)((((((((((0xf000000) >> 16
) >> 8) >> 4) >> 2)) - 1) & ((((((0xf000000
) >> 16) >> 8) >> 4) >> 2))) ^ ((((((
0xf000000) >> 16) >> 8) >> 4) >> 2)))
) >> (1)) != 0) ? 1 : 0) : ((((u_long)((((((((((0xf000000
) >> 16) >> 8) >> 4))) - 1) & ((((((0xf000000
) >> 16) >> 8) >> 4)))) ^ ((((((0xf000000) >>
16) >> 8) >> 4))))) >> (1)) != 0) ? 1 : 0)
) : ((((u_long)(((((((((0xf000000) >> 16) >> 8)))
- 1) & (((((0xf000000) >> 16) >> 8)))) ^ (((
((0xf000000) >> 16) >> 8))))) >> (2)) != 0)
? 2 + ((((u_long)((((((((((0xf000000) >> 16) >> 8
)) >> 2)) - 1) & ((((((0xf000000) >> 16) >>
8)) >> 2))) ^ ((((((0xf000000) >> 16) >> 8
)) >> 2)))) >> (1)) != 0) ? 1 : 0) : ((((u_long)(
(((((((((0xf000000) >> 16) >> 8)))) - 1) & ((
((((0xf000000) >> 16) >> 8))))) ^ ((((((0xf000000
) >> 16) >> 8)))))) >> (1)) != 0) ? 1 : 0))
) : ((((u_long)((((((((0xf000000) >> 16))) - 1) & (
(((0xf000000) >> 16)))) ^ ((((0xf000000) >> 16)))
)) >> (4)) != 0) ? 4 + ((((u_long)(((((((((0xf000000) >>
16)) >> 4)) - 1) & (((((0xf000000) >> 16)) >>
4))) ^ (((((0xf000000) >> 16)) >> 4)))) >>
(2)) != 0) ? 2 + ((((u_long)((((((((((0xf000000) >> 16
)) >> 4) >> 2)) - 1) & ((((((0xf000000) >>
16)) >> 4) >> 2))) ^ ((((((0xf000000) >> 16
)) >> 4) >> 2)))) >> (1)) != 0) ? 1 : 0) : (
(((u_long)((((((((((0xf000000) >> 16)) >> 4))) - 1
) & ((((((0xf000000) >> 16)) >> 4)))) ^ (((((
(0xf000000) >> 16)) >> 4))))) >> (1)) != 0)
? 1 : 0)) : ((((u_long)(((((((((0xf000000) >> 16)))) -
1) & (((((0xf000000) >> 16))))) ^ (((((0xf000000) >>
16)))))) >> (2)) != 0) ? 2 + ((((u_long)((((((((((0xf000000
) >> 16))) >> 2)) - 1) & ((((((0xf000000) >>
16))) >> 2))) ^ ((((((0xf000000) >> 16))) >>
2)))) >> (1)) != 0) ? 1 : 0) : ((((u_long)((((((((((0xf000000
) >> 16))))) - 1) & ((((((0xf000000) >> 16)))
))) ^ ((((((0xf000000) >> 16))))))) >> (1)) != 0)
? 1 : 0)))) : ((((u_long)(((((((0xf000000))) - 1) & (((0xf000000
)))) ^ (((0xf000000))))) >> (8)) != 0) ? 8 + ((((u_long
)((((((((0xf000000)) >> 8)) - 1) & ((((0xf000000)) >>
8))) ^ ((((0xf000000)) >> 8)))) >> (4)) != 0) ? 4
+ ((((u_long)(((((((((0xf000000)) >> 8) >> 4)) -
1) & (((((0xf000000)) >> 8) >> 4))) ^ (((((0xf000000
)) >> 8) >> 4)))) >> (2)) != 0) ? 2 + ((((u_long
)((((((((((0xf000000)) >> 8) >> 4) >> 2)) -
1) & ((((((0xf000000)) >> 8) >> 4) >> 2
))) ^ ((((((0xf000000)) >> 8) >> 4) >> 2)))
) >> (1)) != 0) ? 1 : 0) : ((((u_long)((((((((((0xf000000
)) >> 8) >> 4))) - 1) & ((((((0xf000000)) >>
8) >> 4)))) ^ ((((((0xf000000)) >> 8) >> 4
))))) >> (1)) != 0) ? 1 : 0)) : ((((u_long)(((((((((0xf000000
)) >> 8))) - 1) & (((((0xf000000)) >> 8)))) ^
(((((0xf000000)) >> 8))))) >> (2)) != 0) ? 2 + (
(((u_long)((((((((((0xf000000)) >> 8)) >> 2)) - 1
) & ((((((0xf000000)) >> 8)) >> 2))) ^ ((((((
0xf000000)) >> 8)) >> 2)))) >> (1)) != 0) ?
1 : 0) : ((((u_long)((((((((((0xf000000)) >> 8)))) - 1
) & ((((((0xf000000)) >> 8))))) ^ ((((((0xf000000))
>> 8)))))) >> (1)) != 0) ? 1 : 0))) : ((((u_long
)((((((((0xf000000)))) - 1) & ((((0xf000000))))) ^ ((((0xf000000
)))))) >> (4)) != 0) ? 4 + ((((u_long)(((((((((0xf000000
))) >> 4)) - 1) & (((((0xf000000))) >> 4))) ^
(((((0xf000000))) >> 4)))) >> (2)) != 0) ? 2 + (
(((u_long)((((((((((0xf000000))) >> 4) >> 2)) - 1
) & ((((((0xf000000))) >> 4) >> 2))) ^ ((((((
0xf000000))) >> 4) >> 2)))) >> (1)) != 0) ?
1 : 0) : ((((u_long)((((((((((0xf000000))) >> 4))) - 1
) & ((((((0xf000000))) >> 4)))) ^ ((((((0xf000000))
) >> 4))))) >> (1)) != 0) ? 1 : 0)) : ((((u_long)
(((((((((0xf000000))))) - 1) & (((((0xf000000)))))) ^ (((
((0xf000000))))))) >> (2)) != 0) ? 2 + ((((u_long)(((((
(((((0xf000000)))) >> 2)) - 1) & ((((((0xf000000)))
) >> 2))) ^ ((((((0xf000000)))) >> 2)))) >>
(1)) != 0) ? 1 : 0) : ((((u_long)((((((((((0xf000000)))))) -
1) & ((((((0xf000000))))))) ^ ((((((0xf000000)))))))) >>
(1)) != 0) ? 1 : 0))))))
;
3139 break;
3140 case 22:
3141 ctl0 |= RTW_TXCTL0_RATE_11MBPS((3) << ((((u_long)((((((0xf000000)) - 1) & ((0xf000000
))) ^ ((0xf000000)))) >> (16)) != 0) ? 16 + ((((u_long)
(((((((0xf000000) >> 16)) - 1) & (((0xf000000) >>
16))) ^ (((0xf000000) >> 16)))) >> (8)) != 0) ? 8
+ ((((u_long)((((((((0xf000000) >> 16) >> 8)) - 1
) & ((((0xf000000) >> 16) >> 8))) ^ ((((0xf000000
) >> 16) >> 8)))) >> (4)) != 0) ? 4 + ((((u_long
)(((((((((0xf000000) >> 16) >> 8) >> 4)) - 1
) & (((((0xf000000) >> 16) >> 8) >> 4))
) ^ (((((0xf000000) >> 16) >> 8) >> 4)))) >>
(2)) != 0) ? 2 + ((((u_long)((((((((((0xf000000) >> 16
) >> 8) >> 4) >> 2)) - 1) & ((((((0xf000000
) >> 16) >> 8) >> 4) >> 2))) ^ ((((((
0xf000000) >> 16) >> 8) >> 4) >> 2)))
) >> (1)) != 0) ? 1 : 0) : ((((u_long)((((((((((0xf000000
) >> 16) >> 8) >> 4))) - 1) & ((((((0xf000000
) >> 16) >> 8) >> 4)))) ^ ((((((0xf000000) >>
16) >> 8) >> 4))))) >> (1)) != 0) ? 1 : 0)
) : ((((u_long)(((((((((0xf000000) >> 16) >> 8)))
- 1) & (((((0xf000000) >> 16) >> 8)))) ^ (((
((0xf000000) >> 16) >> 8))))) >> (2)) != 0)
? 2 + ((((u_long)((((((((((0xf000000) >> 16) >> 8
)) >> 2)) - 1) & ((((((0xf000000) >> 16) >>
8)) >> 2))) ^ ((((((0xf000000) >> 16) >> 8
)) >> 2)))) >> (1)) != 0) ? 1 : 0) : ((((u_long)(
(((((((((0xf000000) >> 16) >> 8)))) - 1) & ((
((((0xf000000) >> 16) >> 8))))) ^ ((((((0xf000000
) >> 16) >> 8)))))) >> (1)) != 0) ? 1 : 0))
) : ((((u_long)((((((((0xf000000) >> 16))) - 1) & (
(((0xf000000) >> 16)))) ^ ((((0xf000000) >> 16)))
)) >> (4)) != 0) ? 4 + ((((u_long)(((((((((0xf000000) >>
16)) >> 4)) - 1) & (((((0xf000000) >> 16)) >>
4))) ^ (((((0xf000000) >> 16)) >> 4)))) >>
(2)) != 0) ? 2 + ((((u_long)((((((((((0xf000000) >> 16
)) >> 4) >> 2)) - 1) & ((((((0xf000000) >>
16)) >> 4) >> 2))) ^ ((((((0xf000000) >> 16
)) >> 4) >> 2)))) >> (1)) != 0) ? 1 : 0) : (
(((u_long)((((((((((0xf000000) >> 16)) >> 4))) - 1
) & ((((((0xf000000) >> 16)) >> 4)))) ^ (((((
(0xf000000) >> 16)) >> 4))))) >> (1)) != 0)
? 1 : 0)) : ((((u_long)(((((((((0xf000000) >> 16)))) -
1) & (((((0xf000000) >> 16))))) ^ (((((0xf000000) >>
16)))))) >> (2)) != 0) ? 2 + ((((u_long)((((((((((0xf000000
) >> 16))) >> 2)) - 1) & ((((((0xf000000) >>
16))) >> 2))) ^ ((((((0xf000000) >> 16))) >>
2)))) >> (1)) != 0) ? 1 : 0) : ((((u_long)((((((((((0xf000000
) >> 16))))) - 1) & ((((((0xf000000) >> 16)))
))) ^ ((((((0xf000000) >> 16))))))) >> (1)) != 0)
? 1 : 0)))) : ((((u_long)(((((((0xf000000))) - 1) & (((0xf000000
)))) ^ (((0xf000000))))) >> (8)) != 0) ? 8 + ((((u_long
)((((((((0xf000000)) >> 8)) - 1) & ((((0xf000000)) >>
8))) ^ ((((0xf000000)) >> 8)))) >> (4)) != 0) ? 4
+ ((((u_long)(((((((((0xf000000)) >> 8) >> 4)) -
1) & (((((0xf000000)) >> 8) >> 4))) ^ (((((0xf000000
)) >> 8) >> 4)))) >> (2)) != 0) ? 2 + ((((u_long
)((((((((((0xf000000)) >> 8) >> 4) >> 2)) -
1) & ((((((0xf000000)) >> 8) >> 4) >> 2
))) ^ ((((((0xf000000)) >> 8) >> 4) >> 2)))
) >> (1)) != 0) ? 1 : 0) : ((((u_long)((((((((((0xf000000
)) >> 8) >> 4))) - 1) & ((((((0xf000000)) >>
8) >> 4)))) ^ ((((((0xf000000)) >> 8) >> 4
))))) >> (1)) != 0) ? 1 : 0)) : ((((u_long)(((((((((0xf000000
)) >> 8))) - 1) & (((((0xf000000)) >> 8)))) ^
(((((0xf000000)) >> 8))))) >> (2)) != 0) ? 2 + (
(((u_long)((((((((((0xf000000)) >> 8)) >> 2)) - 1
) & ((((((0xf000000)) >> 8)) >> 2))) ^ ((((((
0xf000000)) >> 8)) >> 2)))) >> (1)) != 0) ?
1 : 0) : ((((u_long)((((((((((0xf000000)) >> 8)))) - 1
) & ((((((0xf000000)) >> 8))))) ^ ((((((0xf000000))
>> 8)))))) >> (1)) != 0) ? 1 : 0))) : ((((u_long
)((((((((0xf000000)))) - 1) & ((((0xf000000))))) ^ ((((0xf000000
)))))) >> (4)) != 0) ? 4 + ((((u_long)(((((((((0xf000000
))) >> 4)) - 1) & (((((0xf000000))) >> 4))) ^
(((((0xf000000))) >> 4)))) >> (2)) != 0) ? 2 + (
(((u_long)((((((((((0xf000000))) >> 4) >> 2)) - 1
) & ((((((0xf000000))) >> 4) >> 2))) ^ ((((((
0xf000000))) >> 4) >> 2)))) >> (1)) != 0) ?
1 : 0) : ((((u_long)((((((((((0xf000000))) >> 4))) - 1
) & ((((((0xf000000))) >> 4)))) ^ ((((((0xf000000))
) >> 4))))) >> (1)) != 0) ? 1 : 0)) : ((((u_long)
(((((((((0xf000000))))) - 1) & (((((0xf000000)))))) ^ (((
((0xf000000))))))) >> (2)) != 0) ? 2 + ((((u_long)(((((
(((((0xf000000)))) >> 2)) - 1) & ((((((0xf000000)))
) >> 2))) ^ ((((((0xf000000)))) >> 2)))) >>
(1)) != 0) ? 1 : 0) : ((((u_long)((((((((((0xf000000)))))) -
1) & ((((((0xf000000))))))) ^ ((((((0xf000000)))))))) >>
(1)) != 0) ? 1 : 0))))))
;
3142 break;
3143 }
3144
3145 /* XXX >= ? Compare after fragmentation? */
3146 if (m0->m_pkthdrM_dat.MH.MH_pkthdr.len > ic->ic_rtsthreshold)
3147 ctl0 |= RTW_TXCTL0_RTSEN(1<<23);
3148
3149 if ((wh->i_fc[0] & IEEE80211_FC0_TYPE_MASK0x0c) ==
3150 IEEE80211_FC0_TYPE_MGT0x00) {
3151 ctl0 &= ~(RTW_TXCTL0_SPLCP(1<<16) | RTW_TXCTL0_RTSEN(1<<23));
3152 if ((wh->i_fc[0] & IEEE80211_FC0_SUBTYPE_MASK0xf0) ==
3153 IEEE80211_FC0_SUBTYPE_BEACON0x80)
3154 ctl0 |= RTW_TXCTL0_BEACON(1<<18);
3155 }
3156
3157 if (rtw_compute_duration(wh, m0->m_pkthdrM_dat.MH.MH_pkthdr.len,
3158 ic->ic_flags & ~IEEE80211_F_WEPON0x00000100, ic->ic_fragthreshold,
3159 rate, &ts->ts_d0, &ts->ts_dn, &npkt,
3160 (sc->sc_ifsc_ic.ic_ac.ac_if.if_flags & (IFF_DEBUG0x4|IFF_LINK20x4000)) ==
3161 (IFF_DEBUG0x4|IFF_LINK20x4000)) == -1) {
3162 DPRINTF(sc, RTW_DEBUG_XMIT,
3163 ("%s: fail compute duration\n", __func__));
3164 goto post_load_err;
3165 }
3166
3167 d0 = &ts->ts_d0;
3168
3169 *(uint16_t*)wh->i_dur = htole16(d0->d_data_dur)((__uint16_t)(d0->d_data_dur));
3170
3171 ctl1 = LSHIFT(d0->d_plcp_len, RTW_TXCTL1_LENGTH_MASK)((d0->d_plcp_len) << ((((u_long)((((((0x7fff0000)) -
1) & ((0x7fff0000))) ^ ((0x7fff0000)))) >> (16)) !=
0) ? 16 + ((((u_long)(((((((0x7fff0000) >> 16)) - 1) &
(((0x7fff0000) >> 16))) ^ (((0x7fff0000) >> 16))
)) >> (8)) != 0) ? 8 + ((((u_long)((((((((0x7fff0000) >>
16) >> 8)) - 1) & ((((0x7fff0000) >> 16) >>
8))) ^ ((((0x7fff0000) >> 16) >> 8)))) >> (
4)) != 0) ? 4 + ((((u_long)(((((((((0x7fff0000) >> 16) >>
8) >> 4)) - 1) & (((((0x7fff0000) >> 16) >>
8) >> 4))) ^ (((((0x7fff0000) >> 16) >> 8)
>> 4)))) >> (2)) != 0) ? 2 + ((((u_long)((((((((
((0x7fff0000) >> 16) >> 8) >> 4) >> 2
)) - 1) & ((((((0x7fff0000) >> 16) >> 8) >>
4) >> 2))) ^ ((((((0x7fff0000) >> 16) >> 8
) >> 4) >> 2)))) >> (1)) != 0) ? 1 : 0) : (
(((u_long)((((((((((0x7fff0000) >> 16) >> 8) >>
4))) - 1) & ((((((0x7fff0000) >> 16) >> 8) >>
4)))) ^ ((((((0x7fff0000) >> 16) >> 8) >> 4
))))) >> (1)) != 0) ? 1 : 0)) : ((((u_long)(((((((((0x7fff0000
) >> 16) >> 8))) - 1) & (((((0x7fff0000) >>
16) >> 8)))) ^ (((((0x7fff0000) >> 16) >> 8
))))) >> (2)) != 0) ? 2 + ((((u_long)((((((((((0x7fff0000
) >> 16) >> 8)) >> 2)) - 1) & ((((((0x7fff0000
) >> 16) >> 8)) >> 2))) ^ ((((((0x7fff0000)
>> 16) >> 8)) >> 2)))) >> (1)) != 0)
? 1 : 0) : ((((u_long)((((((((((0x7fff0000) >> 16) >>
8)))) - 1) & ((((((0x7fff0000) >> 16) >> 8))
))) ^ ((((((0x7fff0000) >> 16) >> 8)))))) >>
(1)) != 0) ? 1 : 0))) : ((((u_long)((((((((0x7fff0000) >>
16))) - 1) & ((((0x7fff0000) >> 16)))) ^ ((((0x7fff0000
) >> 16))))) >> (4)) != 0) ? 4 + ((((u_long)(((((
((((0x7fff0000) >> 16)) >> 4)) - 1) & (((((0x7fff0000
) >> 16)) >> 4))) ^ (((((0x7fff0000) >> 16)
) >> 4)))) >> (2)) != 0) ? 2 + ((((u_long)(((((((
(((0x7fff0000) >> 16)) >> 4) >> 2)) - 1) &
((((((0x7fff0000) >> 16)) >> 4) >> 2))) ^ (
(((((0x7fff0000) >> 16)) >> 4) >> 2)))) >>
(1)) != 0) ? 1 : 0) : ((((u_long)((((((((((0x7fff0000) >>
16)) >> 4))) - 1) & ((((((0x7fff0000) >> 16)
) >> 4)))) ^ ((((((0x7fff0000) >> 16)) >> 4
))))) >> (1)) != 0) ? 1 : 0)) : ((((u_long)(((((((((0x7fff0000
) >> 16)))) - 1) & (((((0x7fff0000) >> 16))))
) ^ (((((0x7fff0000) >> 16)))))) >> (2)) != 0) ? 2
+ ((((u_long)((((((((((0x7fff0000) >> 16))) >> 2
)) - 1) & ((((((0x7fff0000) >> 16))) >> 2))) ^
((((((0x7fff0000) >> 16))) >> 2)))) >> (1)
) != 0) ? 1 : 0) : ((((u_long)((((((((((0x7fff0000) >> 16
))))) - 1) & ((((((0x7fff0000) >> 16)))))) ^ ((((((
0x7fff0000) >> 16))))))) >> (1)) != 0) ? 1 : 0)))
) : ((((u_long)(((((((0x7fff0000))) - 1) & (((0x7fff0000)
))) ^ (((0x7fff0000))))) >> (8)) != 0) ? 8 + ((((u_long
)((((((((0x7fff0000)) >> 8)) - 1) & ((((0x7fff0000)
) >> 8))) ^ ((((0x7fff0000)) >> 8)))) >> (4
)) != 0) ? 4 + ((((u_long)(((((((((0x7fff0000)) >> 8) >>
4)) - 1) & (((((0x7fff0000)) >> 8) >> 4))) ^
(((((0x7fff0000)) >> 8) >> 4)))) >> (2)) !=
0) ? 2 + ((((u_long)((((((((((0x7fff0000)) >> 8) >>
4) >> 2)) - 1) & ((((((0x7fff0000)) >> 8) >>
4) >> 2))) ^ ((((((0x7fff0000)) >> 8) >> 4
) >> 2)))) >> (1)) != 0) ? 1 : 0) : ((((u_long)((
((((((((0x7fff0000)) >> 8) >> 4))) - 1) & (((
(((0x7fff0000)) >> 8) >> 4)))) ^ ((((((0x7fff0000
)) >> 8) >> 4))))) >> (1)) != 0) ? 1 : 0)) :
((((u_long)(((((((((0x7fff0000)) >> 8))) - 1) & ((
(((0x7fff0000)) >> 8)))) ^ (((((0x7fff0000)) >> 8
))))) >> (2)) != 0) ? 2 + ((((u_long)((((((((((0x7fff0000
)) >> 8)) >> 2)) - 1) & ((((((0x7fff0000)) >>
8)) >> 2))) ^ ((((((0x7fff0000)) >> 8)) >>
2)))) >> (1)) != 0) ? 1 : 0) : ((((u_long)((((((((((0x7fff0000
)) >> 8)))) - 1) & ((((((0x7fff0000)) >> 8)))
)) ^ ((((((0x7fff0000)) >> 8)))))) >> (1)) != 0) ?
1 : 0))) : ((((u_long)((((((((0x7fff0000)))) - 1) & ((((
0x7fff0000))))) ^ ((((0x7fff0000)))))) >> (4)) != 0) ? 4
+ ((((u_long)(((((((((0x7fff0000))) >> 4)) - 1) & (
((((0x7fff0000))) >> 4))) ^ (((((0x7fff0000))) >>
4)))) >> (2)) != 0) ? 2 + ((((u_long)((((((((((0x7fff0000
))) >> 4) >> 2)) - 1) & ((((((0x7fff0000))) >>
4) >> 2))) ^ ((((((0x7fff0000))) >> 4) >> 2
)))) >> (1)) != 0) ? 1 : 0) : ((((u_long)((((((((((0x7fff0000
))) >> 4))) - 1) & ((((((0x7fff0000))) >> 4))
)) ^ ((((((0x7fff0000))) >> 4))))) >> (1)) != 0) ?
1 : 0)) : ((((u_long)(((((((((0x7fff0000))))) - 1) & (((
((0x7fff0000)))))) ^ (((((0x7fff0000))))))) >> (2)) != 0
) ? 2 + ((((u_long)((((((((((0x7fff0000)))) >> 2)) - 1)
& ((((((0x7fff0000)))) >> 2))) ^ ((((((0x7fff0000)
))) >> 2)))) >> (1)) != 0) ? 1 : 0) : ((((u_long)
((((((((((0x7fff0000)))))) - 1) & ((((((0x7fff0000)))))))
^ ((((((0x7fff0000)))))))) >> (1)) != 0) ? 1 : 0))))))
|
3172 LSHIFT(d0->d_rts_dur, RTW_TXCTL1_RTSDUR_MASK)((d0->d_rts_dur) << ((((u_long)((((((0xffff)) - 1) &
((0xffff))) ^ ((0xffff)))) >> (16)) != 0) ? 16 + ((((u_long
)(((((((0xffff) >> 16)) - 1) & (((0xffff) >> 16
))) ^ (((0xffff) >> 16)))) >> (8)) != 0) ? 8 + ((
((u_long)((((((((0xffff) >> 16) >> 8)) - 1) &
((((0xffff) >> 16) >> 8))) ^ ((((0xffff) >>
16) >> 8)))) >> (4)) != 0) ? 4 + ((((u_long)((((
(((((0xffff) >> 16) >> 8) >> 4)) - 1) &
(((((0xffff) >> 16) >> 8) >> 4))) ^ (((((0xffff
) >> 16) >> 8) >> 4)))) >> (2)) != 0)
? 2 + ((((u_long)((((((((((0xffff) >> 16) >> 8) >>
4) >> 2)) - 1) & ((((((0xffff) >> 16) >>
8) >> 4) >> 2))) ^ ((((((0xffff) >> 16) >>
8) >> 4) >> 2)))) >> (1)) != 0) ? 1 : 0) :
((((u_long)((((((((((0xffff) >> 16) >> 8) >>
4))) - 1) & ((((((0xffff) >> 16) >> 8) >>
4)))) ^ ((((((0xffff) >> 16) >> 8) >> 4)))
)) >> (1)) != 0) ? 1 : 0)) : ((((u_long)(((((((((0xffff
) >> 16) >> 8))) - 1) & (((((0xffff) >>
16) >> 8)))) ^ (((((0xffff) >> 16) >> 8)))
)) >> (2)) != 0) ? 2 + ((((u_long)((((((((((0xffff) >>
16) >> 8)) >> 2)) - 1) & ((((((0xffff) >>
16) >> 8)) >> 2))) ^ ((((((0xffff) >> 16) >>
8)) >> 2)))) >> (1)) != 0) ? 1 : 0) : ((((u_long
)((((((((((0xffff) >> 16) >> 8)))) - 1) & (((
(((0xffff) >> 16) >> 8))))) ^ ((((((0xffff) >>
16) >> 8)))))) >> (1)) != 0) ? 1 : 0))) : ((((u_long
)((((((((0xffff) >> 16))) - 1) & ((((0xffff) >>
16)))) ^ ((((0xffff) >> 16))))) >> (4)) != 0) ? 4
+ ((((u_long)(((((((((0xffff) >> 16)) >> 4)) - 1
) & (((((0xffff) >> 16)) >> 4))) ^ (((((0xffff
) >> 16)) >> 4)))) >> (2)) != 0) ? 2 + ((((
u_long)((((((((((0xffff) >> 16)) >> 4) >> 2
)) - 1) & ((((((0xffff) >> 16)) >> 4) >>
2))) ^ ((((((0xffff) >> 16)) >> 4) >> 2)))
) >> (1)) != 0) ? 1 : 0) : ((((u_long)((((((((((0xffff)
>> 16)) >> 4))) - 1) & ((((((0xffff) >>
16)) >> 4)))) ^ ((((((0xffff) >> 16)) >> 4
))))) >> (1)) != 0) ? 1 : 0)) : ((((u_long)(((((((((0xffff
) >> 16)))) - 1) & (((((0xffff) >> 16))))) ^ (
((((0xffff) >> 16)))))) >> (2)) != 0) ? 2 + ((((u_long
)((((((((((0xffff) >> 16))) >> 2)) - 1) & (((
(((0xffff) >> 16))) >> 2))) ^ ((((((0xffff) >>
16))) >> 2)))) >> (1)) != 0) ? 1 : 0) : ((((u_long
)((((((((((0xffff) >> 16))))) - 1) & ((((((0xffff) >>
16)))))) ^ ((((((0xffff) >> 16))))))) >> (1)) !=
0) ? 1 : 0)))) : ((((u_long)(((((((0xffff))) - 1) & (((0xffff
)))) ^ (((0xffff))))) >> (8)) != 0) ? 8 + ((((u_long)((
((((((0xffff)) >> 8)) - 1) & ((((0xffff)) >> 8
))) ^ ((((0xffff)) >> 8)))) >> (4)) != 0) ? 4 + (
(((u_long)(((((((((0xffff)) >> 8) >> 4)) - 1) &
(((((0xffff)) >> 8) >> 4))) ^ (((((0xffff)) >>
8) >> 4)))) >> (2)) != 0) ? 2 + ((((u_long)(((((
(((((0xffff)) >> 8) >> 4) >> 2)) - 1) &
((((((0xffff)) >> 8) >> 4) >> 2))) ^ (((((
(0xffff)) >> 8) >> 4) >> 2)))) >> (1)
) != 0) ? 1 : 0) : ((((u_long)((((((((((0xffff)) >> 8) >>
4))) - 1) & ((((((0xffff)) >> 8) >> 4)))) ^ (
(((((0xffff)) >> 8) >> 4))))) >> (1)) != 0)
? 1 : 0)) : ((((u_long)(((((((((0xffff)) >> 8))) - 1) &
(((((0xffff)) >> 8)))) ^ (((((0xffff)) >> 8)))))
>> (2)) != 0) ? 2 + ((((u_long)((((((((((0xffff)) >>
8)) >> 2)) - 1) & ((((((0xffff)) >> 8)) >>
2))) ^ ((((((0xffff)) >> 8)) >> 2)))) >> (
1)) != 0) ? 1 : 0) : ((((u_long)((((((((((0xffff)) >> 8
)))) - 1) & ((((((0xffff)) >> 8))))) ^ ((((((0xffff
)) >> 8)))))) >> (1)) != 0) ? 1 : 0))) : ((((u_long
)((((((((0xffff)))) - 1) & ((((0xffff))))) ^ ((((0xffff))
)))) >> (4)) != 0) ? 4 + ((((u_long)(((((((((0xffff))) >>
4)) - 1) & (((((0xffff))) >> 4))) ^ (((((0xffff)))
>> 4)))) >> (2)) != 0) ? 2 + ((((u_long)((((((((
((0xffff))) >> 4) >> 2)) - 1) & ((((((0xffff)
)) >> 4) >> 2))) ^ ((((((0xffff))) >> 4) >>
2)))) >> (1)) != 0) ? 1 : 0) : ((((u_long)((((((((((0xffff
))) >> 4))) - 1) & ((((((0xffff))) >> 4)))) ^
((((((0xffff))) >> 4))))) >> (1)) != 0) ? 1 : 0)
) : ((((u_long)(((((((((0xffff))))) - 1) & (((((0xffff)))
))) ^ (((((0xffff))))))) >> (2)) != 0) ? 2 + ((((u_long
)((((((((((0xffff)))) >> 2)) - 1) & ((((((0xffff)))
) >> 2))) ^ ((((((0xffff)))) >> 2)))) >> (1
)) != 0) ? 1 : 0) : ((((u_long)((((((((((0xffff)))))) - 1) &
((((((0xffff))))))) ^ ((((((0xffff)))))))) >> (1)) != 0
) ? 1 : 0))))))
;
3173
3174 if (d0->d_residue)
3175 ctl1 |= RTW_TXCTL1_LENGEXT(1<<31);
3176
3177 /* TBD fragmentation */
3178
3179 ts->ts_first = tdb->tdb_next;
3180
3181 rtw_txdescs_sync(tdb, ts->ts_first, dmamap->dm_nsegs,
3182 BUS_DMASYNC_PREWRITE0x04);
3183
3184 KASSERT(ts->ts_first < tdb->tdb_ndesc)((ts->ts_first < tdb->tdb_ndesc) ? (void)0 : __assert
("diagnostic ", "/usr/src/sys/dev/ic/rtw.c", 3184, "ts->ts_first < tdb->tdb_ndesc"
))
;
3185
3186#if NBPFILTER1 > 0
3187 if (ic->ic_rawbpf != NULL((void *)0))
3188 bpf_mtap((caddr_t)ic->ic_rawbpf, m0,
3189 BPF_DIRECTION_OUT(1 << 1));
3190
3191 if (sc->sc_radiobpf != NULL((void *)0)) {
3192 struct mbuf mb;
3193 struct rtw_tx_radiotap_header *rt = &sc->sc_txtapsc_txtapu.tap;
3194
3195 rt->rt_flags = 0;
3196 rt->rt_rate = rate;
3197 rt->rt_chan_freq =
3198 htole16(ic->ic_bss->ni_chan->ic_freq)((__uint16_t)(ic->ic_bss->ni_chan->ic_freq));
3199 rt->rt_chan_flags =
3200 htole16(ic->ic_bss->ni_chan->ic_flags)((__uint16_t)(ic->ic_bss->ni_chan->ic_flags));
3201
3202 mb.m_datam_hdr.mh_data = (caddr_t)rt;
3203 mb.m_lenm_hdr.mh_len = sizeof(sc->sc_txtapu);
3204 mb.m_nextm_hdr.mh_next = m0;
3205 mb.m_nextpktm_hdr.mh_nextpkt = NULL((void *)0);
3206 mb.m_typem_hdr.mh_type = 0;
3207 mb.m_flagsm_hdr.mh_flags = 0;
3208 bpf_mtap(sc->sc_radiobpf, &mb, BPF_DIRECTION_OUT(1 << 1));
3209
3210 }
3211#endif /* NBPFILTER > 0 */
3212
3213 for (i = 0, lastdesc = desc = ts->ts_first;
3214 i < dmamap->dm_nsegs;
3215 i++, desc = RTW_NEXT_IDX(tdb, desc)(((desc) + 1) % (tdb)->tdb_ndesc)) {
3216 if (dmamap->dm_segs[i].ds_len > RTW_TXLEN_LENGTH_MASK0xfff) {
3217 DPRINTF(sc, RTW_DEBUG_XMIT_DESC,
3218 ("%s: seg too long\n", __func__));
3219 goto post_load_err;
3220 }
3221 td = &tdb->tdb_desc[desc];
3222 td->td_ctl0 = htole32(ctl0)((__uint32_t)(ctl0));
3223 if (i != 0)
3224 td->td_ctl0 |= htole32(RTW_TXCTL0_OWN)((__uint32_t)((1<<31)));
3225 td->td_ctl1 = htole32(ctl1)((__uint32_t)(ctl1));
3226 td->td_buf = htole32(dmamap->dm_segs[i].ds_addr)((__uint32_t)(dmamap->dm_segs[i].ds_addr));
3227 td->td_len = htole32(dmamap->dm_segs[i].ds_len)((__uint32_t)(dmamap->dm_segs[i].ds_len));
3228 lastdesc = desc;
3229#ifdef RTW_DEBUG
3230 rtw_print_txdesc(sc, "load", ts, tdb, desc);
3231#endif /* RTW_DEBUG */
3232 }
3233
3234 KASSERT(desc < tdb->tdb_ndesc)((desc < tdb->tdb_ndesc) ? (void)0 : __assert("diagnostic "
, "/usr/src/sys/dev/ic/rtw.c", 3234, "desc < tdb->tdb_ndesc"
))
;
3235
3236 ts->ts_ni = ni;
3237 ts->ts_mbuf = m0;
3238 ts->ts_last = lastdesc;
3239 tdb->tdb_desc[ts->ts_last].td_ctl0 |= htole32(RTW_TXCTL0_LS)((__uint32_t)((1<<28)));
3240 tdb->tdb_desc[ts->ts_first].td_ctl0 |=
3241 htole32(RTW_TXCTL0_FS)((__uint32_t)((1<<29)));
3242
3243#ifdef RTW_DEBUG
3244 rtw_print_txdesc(sc, "FS on", ts, tdb, ts->ts_first);
3245 rtw_print_txdesc(sc, "LS on", ts, tdb, ts->ts_last);
3246#endif /* RTW_DEBUG */
3247
3248 tdb->tdb_nfree -= dmamap->dm_nsegs;
3249 tdb->tdb_next = desc;
3250
3251 rtw_txdescs_sync(tdb, ts->ts_first, dmamap->dm_nsegs,
3252 BUS_DMASYNC_PREREAD0x01|BUS_DMASYNC_PREWRITE0x04);
3253
3254 tdb->tdb_desc[ts->ts_first].td_ctl0 |=
3255 htole32(RTW_TXCTL0_OWN)((__uint32_t)((1<<31)));
3256
3257#ifdef RTW_DEBUG
3258 rtw_print_txdesc(sc, "OWN on", ts, tdb, ts->ts_first);
3259#endif /* RTW_DEBUG */
3260
3261 rtw_txdescs_sync(tdb, ts->ts_first, 1,
3262 BUS_DMASYNC_PREREAD0x01|BUS_DMASYNC_PREWRITE0x04);
3263
3264 SIMPLEQ_REMOVE_HEAD(&tsb->tsb_freeq, ts_q)do { if (((&tsb->tsb_freeq)->sqh_first = (&tsb->
tsb_freeq)->sqh_first->ts_q.sqe_next) == ((void *)0)) (
&tsb->tsb_freeq)->sqh_last = &(&tsb->tsb_freeq
)->sqh_first; } while (0)
;
3265 SIMPLEQ_INSERT_TAIL(&tsb->tsb_dirtyq, ts, ts_q)do { (ts)->ts_q.sqe_next = ((void *)0); *(&tsb->tsb_dirtyq
)->sqh_last = (ts); (&tsb->tsb_dirtyq)->sqh_last
= &(ts)->ts_q.sqe_next; } while (0)
;
3266
3267 if (tsb != &sc->sc_txsoft_blk[RTW_TXPRIBCN3])
3268 sc->sc_led_state.ls_event |= RTW_LED_S_TX0x2;
3269 tsb->tsb_tx_timer = 5;
3270 ifp->if_timer = 1;
3271 tppoll = RTW_READ8(&sc->sc_regs, RTW_TPPOLL)((*(&sc->sc_regs)->r_read8)(&sc->sc_regs, 0xd9
))
;
3272 tppoll &= ~RTW_TPPOLL_SALL((1<<3) | (1<<2) | (1<<1) | (1<<0));
3273 tppoll |= tsb->tsb_poll & RTW_TPPOLL_ALL((1<<7) | (1<<6) | (1<<5) | (1<<4));
3274 RTW_WRITE8(&sc->sc_regs, RTW_TPPOLL, tppoll)((*(&sc->sc_regs)->r_write8)(&sc->sc_regs, 0xd9
, tppoll))
;
3275 RTW_SYNC(&sc->sc_regs, RTW_TPPOLL, RTW_TPPOLL)((*(&sc->sc_regs)->r_barrier)(&sc->sc_regs, 0xd9
, 0xd9, (0x01|0x02)))
;
3276 }
3277out:
3278 DPRINTF(sc, RTW_DEBUG_XMIT, ("%s: leave\n", __func__));
3279 return;
3280post_load_err:
3281 bus_dmamap_unload(sc->sc_dmat, dmamap)(*(sc->sc_dmat)->_dmamap_unload)((sc->sc_dmat), (dmamap
))
;
3282 m_freem(m0);
3283post_dequeue_err:
3284 ieee80211_release_node(&sc->sc_ic, ni);
3285 return;
3286}
3287
3288void
3289rtw_idle(struct rtw_regs *regs)
3290{
3291 int active;
3292
3293 /* request stop DMA; wait for packets to stop transmitting. */
3294
3295 RTW_WRITE8(regs, RTW_TPPOLL, RTW_TPPOLL_SALL)((*(regs)->r_write8)(regs, 0xd9, ((1<<3) | (1<<
2) | (1<<1) | (1<<0))))
;
3296 RTW_WBR(regs, RTW_TPPOLL, RTW_TPPOLL)((*(regs)->r_barrier)(regs, 0xd9, 0xd9, 0x02));
3297
3298 for (active = 0; active < 300 &&
3299 (RTW_READ8(regs, RTW_TPPOLL)((*(regs)->r_read8)(regs, 0xd9)) & RTW_TPPOLL_ACTIVE((1<<7) | (1<<6) | (1<<5) | (1<<4))) != 0; active++)
3300 DELAY(10)(*delay_func)(10);
3301 RTW_DPRINTF(RTW_DEBUG_BUGS,
3302 ("%s: transmit DMA idle in %dus\n", __func__, active * 10));
3303}
3304
3305void
3306rtw_watchdog(struct ifnet *ifp)
3307{
3308 int pri, tx_timeouts = 0;
3309 struct rtw_softc *sc;
3310 struct rtw_txsoft_blk *tsb;
3311
3312 sc = ifp->if_softc;
3313
3314 ifp->if_timer = 0;
3315
3316 if ((sc->sc_flags & RTW_F_ENABLED0x00000001) == 0)
3317 return;
3318
3319 for (pri = 0; pri < RTW_NTXPRI4; pri++) {
3320 tsb = &sc->sc_txsoft_blk[pri];
3321
3322 if (tsb->tsb_tx_timer == 0)
3323 continue;
3324 else if (--tsb->tsb_tx_timer == 0) {
3325 if (SIMPLEQ_EMPTY(&tsb->tsb_dirtyq)(((&tsb->tsb_dirtyq)->sqh_first) == ((void *)0)))
3326 continue;
3327 RTW_DPRINTF(RTW_DEBUG_BUGS,
3328 ("%s: transmit timeout, priority %d\n",
3329 ifp->if_xname, pri));
3330 ifp->if_oerrorsif_data.ifi_oerrors++;
3331 tx_timeouts++;
3332 } else
3333 ifp->if_timer = 1;
3334 }
3335
3336 if (tx_timeouts > 0) {
3337 /* Stop Tx DMA, disable xmtr, flush Tx rings, enable xmtr,
3338 * reset s/w tx-ring pointers, and start transmission.
3339 *
3340 * TBD Stop/restart just the broken rings?
3341 */
3342 rtw_idle(&sc->sc_regs);
3343 rtw_io_enable(&sc->sc_regs, RTW_CR_TE(1<<2), 0);
3344 rtw_txdescs_reset(sc);
3345 rtw_io_enable(&sc->sc_regs, RTW_CR_TE(1<<2), 1);
3346 rtw_txring_fixup(sc);
3347 rtw_start(ifp);
3348 }
3349 ieee80211_watchdog(ifp);
3350}
3351
3352void
3353rtw_next_scan(void *arg)
3354{
3355 struct rtw_softc *sc = arg;
3356 struct ieee80211com *ic = &sc->sc_ic;
3357 struct ifnet *ifp = &ic->ic_ific_ac.ac_if;
3358 int s;
3359
3360 /* don't call rtw_start w/o network interrupts blocked */
3361 s = splnet()splraise(0x4);
3362 if (ic->ic_state == IEEE80211_S_SCAN)
3363 ieee80211_next_scan(ifp);
3364 splx(s)spllower(s);
3365}
3366
3367void
3368rtw_join_bss(struct rtw_softc *sc, u_int8_t *bssid, u_int16_t intval0)
3369{
3370 uint16_t bcnitv, bintritv, intval;
3371 int i;
3372 struct rtw_regs *regs = &sc->sc_regs;
3373
3374 for (i = 0; i < IEEE80211_ADDR_LEN6; i++)
3375 RTW_WRITE8(regs, RTW_BSSID + i, bssid[i])((*(regs)->r_write8)(regs, 0x2e + i, bssid[i]));
3376
3377 RTW_SYNC(regs, RTW_BSSID16, RTW_BSSID32)((*(regs)->r_barrier)(regs, 0x2e, (0x2e + 4), (0x01|0x02))
)
;
3378
3379 rtw_set_access(regs, RTW_ACCESS_CONFIG);
3380
3381 intval = MIN(intval0, PRESHIFT(RTW_BCNITV_BCNITV_MASK))(((intval0)<(((((0x3ff)) & ((0x3ff))) >> ((((u_long
)(((((((0x3ff))) - 1) & (((0x3ff)))) ^ (((0x3ff))))) >>
(16)) != 0) ? 16 + ((((u_long)((((((((0x3ff)) >> 16)) -
1) & ((((0x3ff)) >> 16))) ^ ((((0x3ff)) >> 16
)))) >> (8)) != 0) ? 8 + ((((u_long)(((((((((0x3ff)) >>
16) >> 8)) - 1) & (((((0x3ff)) >> 16) >>
8))) ^ (((((0x3ff)) >> 16) >> 8)))) >> (4)
) != 0) ? 4 + ((((u_long)((((((((((0x3ff)) >> 16) >>
8) >> 4)) - 1) & ((((((0x3ff)) >> 16) >>
8) >> 4))) ^ ((((((0x3ff)) >> 16) >> 8) >>
4)))) >> (2)) != 0) ? 2 + ((((u_long)(((((((((((0x3ff)
) >> 16) >> 8) >> 4) >> 2)) - 1) &
(((((((0x3ff)) >> 16) >> 8) >> 4) >>
2))) ^ (((((((0x3ff)) >> 16) >> 8) >> 4) >>
2)))) >> (1)) != 0) ? 1 : 0) : ((((u_long)(((((((((((0x3ff
)) >> 16) >> 8) >> 4))) - 1) & (((((((0x3ff
)) >> 16) >> 8) >> 4)))) ^ (((((((0x3ff)) >>
16) >> 8) >> 4))))) >> (1)) != 0) ? 1 : 0)
) : ((((u_long)((((((((((0x3ff)) >> 16) >> 8))) -
1) & ((((((0x3ff)) >> 16) >> 8)))) ^ ((((((0x3ff
)) >> 16) >> 8))))) >> (2)) != 0) ? 2 + (((
(u_long)(((((((((((0x3ff)) >> 16) >> 8)) >>
2)) - 1) & (((((((0x3ff)) >> 16) >> 8)) >>
2))) ^ (((((((0x3ff)) >> 16) >> 8)) >> 2))
)) >> (1)) != 0) ? 1 : 0) : ((((u_long)(((((((((((0x3ff
)) >> 16) >> 8)))) - 1) & (((((((0x3ff)) >>
16) >> 8))))) ^ (((((((0x3ff)) >> 16) >> 8
)))))) >> (1)) != 0) ? 1 : 0))) : ((((u_long)(((((((((0x3ff
)) >> 16))) - 1) & (((((0x3ff)) >> 16)))) ^ (
((((0x3ff)) >> 16))))) >> (4)) != 0) ? 4 + ((((u_long
)((((((((((0x3ff)) >> 16)) >> 4)) - 1) & ((((
((0x3ff)) >> 16)) >> 4))) ^ ((((((0x3ff)) >>
16)) >> 4)))) >> (2)) != 0) ? 2 + ((((u_long)(((
((((((((0x3ff)) >> 16)) >> 4) >> 2)) - 1) &
(((((((0x3ff)) >> 16)) >> 4) >> 2))) ^ (((
((((0x3ff)) >> 16)) >> 4) >> 2)))) >>
(1)) != 0) ? 1 : 0) : ((((u_long)(((((((((((0x3ff)) >>
16)) >> 4))) - 1) & (((((((0x3ff)) >> 16)) >>
4)))) ^ (((((((0x3ff)) >> 16)) >> 4))))) >>
(1)) != 0) ? 1 : 0)) : ((((u_long)((((((((((0x3ff)) >>
16)))) - 1) & ((((((0x3ff)) >> 16))))) ^ ((((((0x3ff
)) >> 16)))))) >> (2)) != 0) ? 2 + ((((u_long)(((
((((((((0x3ff)) >> 16))) >> 2)) - 1) & ((((((
(0x3ff)) >> 16))) >> 2))) ^ (((((((0x3ff)) >>
16))) >> 2)))) >> (1)) != 0) ? 1 : 0) : ((((u_long
)(((((((((((0x3ff)) >> 16))))) - 1) & (((((((0x3ff)
) >> 16)))))) ^ (((((((0x3ff)) >> 16))))))) >>
(1)) != 0) ? 1 : 0)))) : ((((u_long)((((((((0x3ff)))) - 1) &
((((0x3ff))))) ^ ((((0x3ff)))))) >> (8)) != 0) ? 8 + (
(((u_long)(((((((((0x3ff))) >> 8)) - 1) & (((((0x3ff
))) >> 8))) ^ (((((0x3ff))) >> 8)))) >> (4)
) != 0) ? 4 + ((((u_long)((((((((((0x3ff))) >> 8) >>
4)) - 1) & ((((((0x3ff))) >> 8) >> 4))) ^ ((
((((0x3ff))) >> 8) >> 4)))) >> (2)) != 0) ?
2 + ((((u_long)(((((((((((0x3ff))) >> 8) >> 4) >>
2)) - 1) & (((((((0x3ff))) >> 8) >> 4) >>
2))) ^ (((((((0x3ff))) >> 8) >> 4) >> 2)))
) >> (1)) != 0) ? 1 : 0) : ((((u_long)(((((((((((0x3ff)
)) >> 8) >> 4))) - 1) & (((((((0x3ff))) >>
8) >> 4)))) ^ (((((((0x3ff))) >> 8) >> 4))
))) >> (1)) != 0) ? 1 : 0)) : ((((u_long)((((((((((0x3ff
))) >> 8))) - 1) & ((((((0x3ff))) >> 8)))) ^ (
(((((0x3ff))) >> 8))))) >> (2)) != 0) ? 2 + ((((u_long
)(((((((((((0x3ff))) >> 8)) >> 2)) - 1) & (((
((((0x3ff))) >> 8)) >> 2))) ^ (((((((0x3ff))) >>
8)) >> 2)))) >> (1)) != 0) ? 1 : 0) : ((((u_long
)(((((((((((0x3ff))) >> 8)))) - 1) & (((((((0x3ff))
) >> 8))))) ^ (((((((0x3ff))) >> 8)))))) >>
(1)) != 0) ? 1 : 0))) : ((((u_long)(((((((((0x3ff))))) - 1) &
(((((0x3ff)))))) ^ (((((0x3ff))))))) >> (4)) != 0) ? 4
+ ((((u_long)((((((((((0x3ff)))) >> 4)) - 1) & (((
(((0x3ff)))) >> 4))) ^ ((((((0x3ff)))) >> 4)))) >>
(2)) != 0) ? 2 + ((((u_long)(((((((((((0x3ff)))) >> 4)
>> 2)) - 1) & (((((((0x3ff)))) >> 4) >>
2))) ^ (((((((0x3ff)))) >> 4) >> 2)))) >> (
1)) != 0) ? 1 : 0) : ((((u_long)(((((((((((0x3ff)))) >>
4))) - 1) & (((((((0x3ff)))) >> 4)))) ^ (((((((0x3ff
)))) >> 4))))) >> (1)) != 0) ? 1 : 0)) : ((((u_long
)((((((((((0x3ff)))))) - 1) & ((((((0x3ff))))))) ^ ((((((
0x3ff)))))))) >> (2)) != 0) ? 2 + ((((u_long)((((((((((
(0x3ff))))) >> 2)) - 1) & (((((((0x3ff))))) >>
2))) ^ (((((((0x3ff))))) >> 2)))) >> (1)) != 0) ?
1 : 0) : ((((u_long)(((((((((((0x3ff))))))) - 1) & (((((
((0x3ff)))))))) ^ (((((((0x3ff))))))))) >> (1)) != 0) ?
1 : 0))))))))?(intval0):(((((0x3ff)) & ((0x3ff))) >>
((((u_long)(((((((0x3ff))) - 1) & (((0x3ff)))) ^ (((0x3ff
))))) >> (16)) != 0) ? 16 + ((((u_long)((((((((0x3ff)) >>
16)) - 1) & ((((0x3ff)) >> 16))) ^ ((((0x3ff)) >>
16)))) >> (8)) != 0) ? 8 + ((((u_long)(((((((((0x3ff))
>> 16) >> 8)) - 1) & (((((0x3ff)) >> 16
) >> 8))) ^ (((((0x3ff)) >> 16) >> 8)))) >>
(4)) != 0) ? 4 + ((((u_long)((((((((((0x3ff)) >> 16) >>
8) >> 4)) - 1) & ((((((0x3ff)) >> 16) >>
8) >> 4))) ^ ((((((0x3ff)) >> 16) >> 8) >>
4)))) >> (2)) != 0) ? 2 + ((((u_long)(((((((((((0x3ff)
) >> 16) >> 8) >> 4) >> 2)) - 1) &
(((((((0x3ff)) >> 16) >> 8) >> 4) >>
2))) ^ (((((((0x3ff)) >> 16) >> 8) >> 4) >>
2)))) >> (1)) != 0) ? 1 : 0) : ((((u_long)(((((((((((0x3ff
)) >> 16) >> 8) >> 4))) - 1) & (((((((0x3ff
)) >> 16) >> 8) >> 4)))) ^ (((((((0x3ff)) >>
16) >> 8) >> 4))))) >> (1)) != 0) ? 1 : 0)
) : ((((u_long)((((((((((0x3ff)) >> 16) >> 8))) -
1) & ((((((0x3ff)) >> 16) >> 8)))) ^ ((((((0x3ff
)) >> 16) >> 8))))) >> (2)) != 0) ? 2 + (((
(u_long)(((((((((((0x3ff)) >> 16) >> 8)) >>
2)) - 1) & (((((((0x3ff)) >> 16) >> 8)) >>
2))) ^ (((((((0x3ff)) >> 16) >> 8)) >> 2))
)) >> (1)) != 0) ? 1 : 0) : ((((u_long)(((((((((((0x3ff
)) >> 16) >> 8)))) - 1) & (((((((0x3ff)) >>
16) >> 8))))) ^ (((((((0x3ff)) >> 16) >> 8
)))))) >> (1)) != 0) ? 1 : 0))) : ((((u_long)(((((((((0x3ff
)) >> 16))) - 1) & (((((0x3ff)) >> 16)))) ^ (
((((0x3ff)) >> 16))))) >> (4)) != 0) ? 4 + ((((u_long
)((((((((((0x3ff)) >> 16)) >> 4)) - 1) & ((((
((0x3ff)) >> 16)) >> 4))) ^ ((((((0x3ff)) >>
16)) >> 4)))) >> (2)) != 0) ? 2 + ((((u_long)(((
((((((((0x3ff)) >> 16)) >> 4) >> 2)) - 1) &
(((((((0x3ff)) >> 16)) >> 4) >> 2))) ^ (((
((((0x3ff)) >> 16)) >> 4) >> 2)))) >>
(1)) != 0) ? 1 : 0) : ((((u_long)(((((((((((0x3ff)) >>
16)) >> 4))) - 1) & (((((((0x3ff)) >> 16)) >>
4)))) ^ (((((((0x3ff)) >> 16)) >> 4))))) >>
(1)) != 0) ? 1 : 0)) : ((((u_long)((((((((((0x3ff)) >>
16)))) - 1) & ((((((0x3ff)) >> 16))))) ^ ((((((0x3ff
)) >> 16)))))) >> (2)) != 0) ? 2 + ((((u_long)(((
((((((((0x3ff)) >> 16))) >> 2)) - 1) & ((((((
(0x3ff)) >> 16))) >> 2))) ^ (((((((0x3ff)) >>
16))) >> 2)))) >> (1)) != 0) ? 1 : 0) : ((((u_long
)(((((((((((0x3ff)) >> 16))))) - 1) & (((((((0x3ff)
) >> 16)))))) ^ (((((((0x3ff)) >> 16))))))) >>
(1)) != 0) ? 1 : 0)))) : ((((u_long)((((((((0x3ff)))) - 1) &
((((0x3ff))))) ^ ((((0x3ff)))))) >> (8)) != 0) ? 8 + (
(((u_long)(((((((((0x3ff))) >> 8)) - 1) & (((((0x3ff
))) >> 8))) ^ (((((0x3ff))) >> 8)))) >> (4)
) != 0) ? 4 + ((((u_long)((((((((((0x3ff))) >> 8) >>
4)) - 1) & ((((((0x3ff))) >> 8) >> 4))) ^ ((
((((0x3ff))) >> 8) >> 4)))) >> (2)) != 0) ?
2 + ((((u_long)(((((((((((0x3ff))) >> 8) >> 4) >>
2)) - 1) & (((((((0x3ff))) >> 8) >> 4) >>
2))) ^ (((((((0x3ff))) >> 8) >> 4) >> 2)))
) >> (1)) != 0) ? 1 : 0) : ((((u_long)(((((((((((0x3ff)
)) >> 8) >> 4))) - 1) & (((((((0x3ff))) >>
8) >> 4)))) ^ (((((((0x3ff))) >> 8) >> 4))
))) >> (1)) != 0) ? 1 : 0)) : ((((u_long)((((((((((0x3ff
))) >> 8))) - 1) & ((((((0x3ff))) >> 8)))) ^ (
(((((0x3ff))) >> 8))))) >> (2)) != 0) ? 2 + ((((u_long
)(((((((((((0x3ff))) >> 8)) >> 2)) - 1) & (((
((((0x3ff))) >> 8)) >> 2))) ^ (((((((0x3ff))) >>
8)) >> 2)))) >> (1)) != 0) ? 1 : 0) : ((((u_long
)(((((((((((0x3ff))) >> 8)))) - 1) & (((((((0x3ff))
) >> 8))))) ^ (((((((0x3ff))) >> 8)))))) >>
(1)) != 0) ? 1 : 0))) : ((((u_long)(((((((((0x3ff))))) - 1) &
(((((0x3ff)))))) ^ (((((0x3ff))))))) >> (4)) != 0) ? 4
+ ((((u_long)((((((((((0x3ff)))) >> 4)) - 1) & (((
(((0x3ff)))) >> 4))) ^ ((((((0x3ff)))) >> 4)))) >>
(2)) != 0) ? 2 + ((((u_long)(((((((((((0x3ff)))) >> 4)
>> 2)) - 1) & (((((((0x3ff)))) >> 4) >>
2))) ^ (((((((0x3ff)))) >> 4) >> 2)))) >> (
1)) != 0) ? 1 : 0) : ((((u_long)(((((((((((0x3ff)))) >>
4))) - 1) & (((((((0x3ff)))) >> 4)))) ^ (((((((0x3ff
)))) >> 4))))) >> (1)) != 0) ? 1 : 0)) : ((((u_long
)((((((((((0x3ff)))))) - 1) & ((((((0x3ff))))))) ^ ((((((
0x3ff)))))))) >> (2)) != 0) ? 2 + ((((u_long)((((((((((
(0x3ff))))) >> 2)) - 1) & (((((((0x3ff))))) >>
2))) ^ (((((((0x3ff))))) >> 2)))) >> (1)) != 0) ?
1 : 0) : ((((u_long)(((((((((((0x3ff))))))) - 1) & (((((
((0x3ff)))))))) ^ (((((((0x3ff))))))))) >> (1)) != 0) ?
1 : 0))))))))
;
3382
3383 bcnitv = RTW_READ16(regs, RTW_BCNITV)((*(regs)->r_read16)(regs, 0x70)) & ~RTW_BCNITV_BCNITV_MASK0x3ff;
3384 bcnitv |= LSHIFT(intval, RTW_BCNITV_BCNITV_MASK)((intval) << ((((u_long)((((((0x3ff)) - 1) & ((0x3ff
))) ^ ((0x3ff)))) >> (16)) != 0) ? 16 + ((((u_long)((((
(((0x3ff) >> 16)) - 1) & (((0x3ff) >> 16))) ^
(((0x3ff) >> 16)))) >> (8)) != 0) ? 8 + ((((u_long
)((((((((0x3ff) >> 16) >> 8)) - 1) & ((((0x3ff
) >> 16) >> 8))) ^ ((((0x3ff) >> 16) >>
8)))) >> (4)) != 0) ? 4 + ((((u_long)(((((((((0x3ff) >>
16) >> 8) >> 4)) - 1) & (((((0x3ff) >>
16) >> 8) >> 4))) ^ (((((0x3ff) >> 16) >>
8) >> 4)))) >> (2)) != 0) ? 2 + ((((u_long)(((((
(((((0x3ff) >> 16) >> 8) >> 4) >> 2))
- 1) & ((((((0x3ff) >> 16) >> 8) >> 4)
>> 2))) ^ ((((((0x3ff) >> 16) >> 8) >>
4) >> 2)))) >> (1)) != 0) ? 1 : 0) : ((((u_long)
((((((((((0x3ff) >> 16) >> 8) >> 4))) - 1) &
((((((0x3ff) >> 16) >> 8) >> 4)))) ^ (((((
(0x3ff) >> 16) >> 8) >> 4))))) >> (1)
) != 0) ? 1 : 0)) : ((((u_long)(((((((((0x3ff) >> 16) >>
8))) - 1) & (((((0x3ff) >> 16) >> 8)))) ^ ((
(((0x3ff) >> 16) >> 8))))) >> (2)) != 0) ? 2
+ ((((u_long)((((((((((0x3ff) >> 16) >> 8)) >>
2)) - 1) & ((((((0x3ff) >> 16) >> 8)) >>
2))) ^ ((((((0x3ff) >> 16) >> 8)) >> 2))))
>> (1)) != 0) ? 1 : 0) : ((((u_long)((((((((((0x3ff) >>
16) >> 8)))) - 1) & ((((((0x3ff) >> 16) >>
8))))) ^ ((((((0x3ff) >> 16) >> 8)))))) >>
(1)) != 0) ? 1 : 0))) : ((((u_long)((((((((0x3ff) >> 16
))) - 1) & ((((0x3ff) >> 16)))) ^ ((((0x3ff) >>
16))))) >> (4)) != 0) ? 4 + ((((u_long)(((((((((0x3ff)
>> 16)) >> 4)) - 1) & (((((0x3ff) >> 16
)) >> 4))) ^ (((((0x3ff) >> 16)) >> 4)))) >>
(2)) != 0) ? 2 + ((((u_long)((((((((((0x3ff) >> 16)) >>
4) >> 2)) - 1) & ((((((0x3ff) >> 16)) >>
4) >> 2))) ^ ((((((0x3ff) >> 16)) >> 4) >>
2)))) >> (1)) != 0) ? 1 : 0) : ((((u_long)((((((((((0x3ff
) >> 16)) >> 4))) - 1) & ((((((0x3ff) >>
16)) >> 4)))) ^ ((((((0x3ff) >> 16)) >> 4)
)))) >> (1)) != 0) ? 1 : 0)) : ((((u_long)(((((((((0x3ff
) >> 16)))) - 1) & (((((0x3ff) >> 16))))) ^ (
((((0x3ff) >> 16)))))) >> (2)) != 0) ? 2 + ((((u_long
)((((((((((0x3ff) >> 16))) >> 2)) - 1) & ((((
((0x3ff) >> 16))) >> 2))) ^ ((((((0x3ff) >>
16))) >> 2)))) >> (1)) != 0) ? 1 : 0) : ((((u_long
)((((((((((0x3ff) >> 16))))) - 1) & ((((((0x3ff) >>
16)))))) ^ ((((((0x3ff) >> 16))))))) >> (1)) != 0
) ? 1 : 0)))) : ((((u_long)(((((((0x3ff))) - 1) & (((0x3ff
)))) ^ (((0x3ff))))) >> (8)) != 0) ? 8 + ((((u_long)(((
(((((0x3ff)) >> 8)) - 1) & ((((0x3ff)) >> 8))
) ^ ((((0x3ff)) >> 8)))) >> (4)) != 0) ? 4 + ((((
u_long)(((((((((0x3ff)) >> 8) >> 4)) - 1) & (
((((0x3ff)) >> 8) >> 4))) ^ (((((0x3ff)) >>
8) >> 4)))) >> (2)) != 0) ? 2 + ((((u_long)(((((
(((((0x3ff)) >> 8) >> 4) >> 2)) - 1) & (
(((((0x3ff)) >> 8) >> 4) >> 2))) ^ ((((((0x3ff
)) >> 8) >> 4) >> 2)))) >> (1)) != 0)
? 1 : 0) : ((((u_long)((((((((((0x3ff)) >> 8) >>
4))) - 1) & ((((((0x3ff)) >> 8) >> 4)))) ^ (
(((((0x3ff)) >> 8) >> 4))))) >> (1)) != 0) ?
1 : 0)) : ((((u_long)(((((((((0x3ff)) >> 8))) - 1) &
(((((0x3ff)) >> 8)))) ^ (((((0x3ff)) >> 8))))) >>
(2)) != 0) ? 2 + ((((u_long)((((((((((0x3ff)) >> 8)) >>
2)) - 1) & ((((((0x3ff)) >> 8)) >> 2))) ^ ((
((((0x3ff)) >> 8)) >> 2)))) >> (1)) != 0) ?
1 : 0) : ((((u_long)((((((((((0x3ff)) >> 8)))) - 1) &
((((((0x3ff)) >> 8))))) ^ ((((((0x3ff)) >> 8))))
)) >> (1)) != 0) ? 1 : 0))) : ((((u_long)((((((((0x3ff)
))) - 1) & ((((0x3ff))))) ^ ((((0x3ff)))))) >> (4))
!= 0) ? 4 + ((((u_long)(((((((((0x3ff))) >> 4)) - 1) &
(((((0x3ff))) >> 4))) ^ (((((0x3ff))) >> 4)))) >>
(2)) != 0) ? 2 + ((((u_long)((((((((((0x3ff))) >> 4) >>
2)) - 1) & ((((((0x3ff))) >> 4) >> 2))) ^ ((
((((0x3ff))) >> 4) >> 2)))) >> (1)) != 0) ?
1 : 0) : ((((u_long)((((((((((0x3ff))) >> 4))) - 1) &
((((((0x3ff))) >> 4)))) ^ ((((((0x3ff))) >> 4)))
)) >> (1)) != 0) ? 1 : 0)) : ((((u_long)(((((((((0x3ff)
)))) - 1) & (((((0x3ff)))))) ^ (((((0x3ff))))))) >>
(2)) != 0) ? 2 + ((((u_long)((((((((((0x3ff)))) >> 2))
- 1) & ((((((0x3ff)))) >> 2))) ^ ((((((0x3ff)))) >>
2)))) >> (1)) != 0) ? 1 : 0) : ((((u_long)((((((((((0x3ff
)))))) - 1) & ((((((0x3ff))))))) ^ ((((((0x3ff)))))))) >>
(1)) != 0) ? 1 : 0))))))
;
3385 RTW_WRITE16(regs, RTW_BCNITV, bcnitv)((*(regs)->r_write16)(regs, 0x70, bcnitv));
3386 /* interrupt host 1ms before the TBTT */
3387 bintritv = RTW_READ16(regs, RTW_BINTRITV)((*(regs)->r_read16)(regs, 0x74)) & ~RTW_BINTRITV_BINTRITV0x3ff;
3388 bintritv |= LSHIFT(1000, RTW_BINTRITV_BINTRITV)((1000) << ((((u_long)((((((0x3ff)) - 1) & ((0x3ff)
)) ^ ((0x3ff)))) >> (16)) != 0) ? 16 + ((((u_long)(((((
((0x3ff) >> 16)) - 1) & (((0x3ff) >> 16))) ^ (
((0x3ff) >> 16)))) >> (8)) != 0) ? 8 + ((((u_long
)((((((((0x3ff) >> 16) >> 8)) - 1) & ((((0x3ff
) >> 16) >> 8))) ^ ((((0x3ff) >> 16) >>
8)))) >> (4)) != 0) ? 4 + ((((u_long)(((((((((0x3ff) >>
16) >> 8) >> 4)) - 1) & (((((0x3ff) >>
16) >> 8) >> 4))) ^ (((((0x3ff) >> 16) >>
8) >> 4)))) >> (2)) != 0) ? 2 + ((((u_long)(((((
(((((0x3ff) >> 16) >> 8) >> 4) >> 2))
- 1) & ((((((0x3ff) >> 16) >> 8) >> 4)
>> 2))) ^ ((((((0x3ff) >> 16) >> 8) >>
4) >> 2)))) >> (1)) != 0) ? 1 : 0) : ((((u_long)
((((((((((0x3ff) >> 16) >> 8) >> 4))) - 1) &
((((((0x3ff) >> 16) >> 8) >> 4)))) ^ (((((
(0x3ff) >> 16) >> 8) >> 4))))) >> (1)
) != 0) ? 1 : 0)) : ((((u_long)(((((((((0x3ff) >> 16) >>
8))) - 1) & (((((0x3ff) >> 16) >> 8)))) ^ ((
(((0x3ff) >> 16) >> 8))))) >> (2)) != 0) ? 2
+ ((((u_long)((((((((((0x3ff) >> 16) >> 8)) >>
2)) - 1) & ((((((0x3ff) >> 16) >> 8)) >>
2))) ^ ((((((0x3ff) >> 16) >> 8)) >> 2))))
>> (1)) != 0) ? 1 : 0) : ((((u_long)((((((((((0x3ff) >>
16) >> 8)))) - 1) & ((((((0x3ff) >> 16) >>
8))))) ^ ((((((0x3ff) >> 16) >> 8)))))) >>
(1)) != 0) ? 1 : 0))) : ((((u_long)((((((((0x3ff) >> 16
))) - 1) & ((((0x3ff) >> 16)))) ^ ((((0x3ff) >>
16))))) >> (4)) != 0) ? 4 + ((((u_long)(((((((((0x3ff)
>> 16)) >> 4)) - 1) & (((((0x3ff) >> 16
)) >> 4))) ^ (((((0x3ff) >> 16)) >> 4)))) >>
(2)) != 0) ? 2 + ((((u_long)((((((((((0x3ff) >> 16)) >>
4) >> 2)) - 1) & ((((((0x3ff) >> 16)) >>
4) >> 2))) ^ ((((((0x3ff) >> 16)) >> 4) >>
2)))) >> (1)) != 0) ? 1 : 0) : ((((u_long)((((((((((0x3ff
) >> 16)) >> 4))) - 1) & ((((((0x3ff) >>
16)) >> 4)))) ^ ((((((0x3ff) >> 16)) >> 4)
)))) >> (1)) != 0) ? 1 : 0)) : ((((u_long)(((((((((0x3ff
) >> 16)))) - 1) & (((((0x3ff) >> 16))))) ^ (
((((0x3ff) >> 16)))))) >> (2)) != 0) ? 2 + ((((u_long
)((((((((((0x3ff) >> 16))) >> 2)) - 1) & ((((
((0x3ff) >> 16))) >> 2))) ^ ((((((0x3ff) >>
16))) >> 2)))) >> (1)) != 0) ? 1 : 0) : ((((u_long
)((((((((((0x3ff) >> 16))))) - 1) & ((((((0x3ff) >>
16)))))) ^ ((((((0x3ff) >> 16))))))) >> (1)) != 0
) ? 1 : 0)))) : ((((u_long)(((((((0x3ff))) - 1) & (((0x3ff
)))) ^ (((0x3ff))))) >> (8)) != 0) ? 8 + ((((u_long)(((
(((((0x3ff)) >> 8)) - 1) & ((((0x3ff)) >> 8))
) ^ ((((0x3ff)) >> 8)))) >> (4)) != 0) ? 4 + ((((
u_long)(((((((((0x3ff)) >> 8) >> 4)) - 1) & (
((((0x3ff)) >> 8) >> 4))) ^ (((((0x3ff)) >>
8) >> 4)))) >> (2)) != 0) ? 2 + ((((u_long)(((((
(((((0x3ff)) >> 8) >> 4) >> 2)) - 1) & (
(((((0x3ff)) >> 8) >> 4) >> 2))) ^ ((((((0x3ff
)) >> 8) >> 4) >> 2)))) >> (1)) != 0)
? 1 : 0) : ((((u_long)((((((((((0x3ff)) >> 8) >>
4))) - 1) & ((((((0x3ff)) >> 8) >> 4)))) ^ (
(((((0x3ff)) >> 8) >> 4))))) >> (1)) != 0) ?
1 : 0)) : ((((u_long)(((((((((0x3ff)) >> 8))) - 1) &
(((((0x3ff)) >> 8)))) ^ (((((0x3ff)) >> 8))))) >>
(2)) != 0) ? 2 + ((((u_long)((((((((((0x3ff)) >> 8)) >>
2)) - 1) & ((((((0x3ff)) >> 8)) >> 2))) ^ ((
((((0x3ff)) >> 8)) >> 2)))) >> (1)) != 0) ?
1 : 0) : ((((u_long)((((((((((0x3ff)) >> 8)))) - 1) &
((((((0x3ff)) >> 8))))) ^ ((((((0x3ff)) >> 8))))
)) >> (1)) != 0) ? 1 : 0))) : ((((u_long)((((((((0x3ff)
))) - 1) & ((((0x3ff))))) ^ ((((0x3ff)))))) >> (4))
!= 0) ? 4 + ((((u_long)(((((((((0x3ff))) >> 4)) - 1) &
(((((0x3ff))) >> 4))) ^ (((((0x3ff))) >> 4)))) >>
(2)) != 0) ? 2 + ((((u_long)((((((((((0x3ff))) >> 4) >>
2)) - 1) & ((((((0x3ff))) >> 4) >> 2))) ^ ((
((((0x3ff))) >> 4) >> 2)))) >> (1)) != 0) ?
1 : 0) : ((((u_long)((((((((((0x3ff))) >> 4))) - 1) &
((((((0x3ff))) >> 4)))) ^ ((((((0x3ff))) >> 4)))
)) >> (1)) != 0) ? 1 : 0)) : ((((u_long)(((((((((0x3ff)
)))) - 1) & (((((0x3ff)))))) ^ (((((0x3ff))))))) >>
(2)) != 0) ? 2 + ((((u_long)((((((((((0x3ff)))) >> 2))
- 1) & ((((((0x3ff)))) >> 2))) ^ ((((((0x3ff)))) >>
2)))) >> (1)) != 0) ? 1 : 0) : ((((u_long)((((((((((0x3ff
)))))) - 1) & ((((((0x3ff))))))) ^ ((((((0x3ff)))))))) >>
(1)) != 0) ? 1 : 0))))))
;
3389 RTW_WRITE16(regs, RTW_BINTRITV, bintritv)((*(regs)->r_write16)(regs, 0x74, bintritv));
3390 /* magic from Linux */
3391 RTW_WRITE16(regs, RTW_ATIMWND, LSHIFT(1, RTW_ATIMWND_ATIMWND))((*(regs)->r_write16)(regs, 0x72, ((1) << ((((u_long
)((((((0x3ff)) - 1) & ((0x3ff))) ^ ((0x3ff)))) >> (
16)) != 0) ? 16 + ((((u_long)(((((((0x3ff) >> 16)) - 1)
& (((0x3ff) >> 16))) ^ (((0x3ff) >> 16)))) >>
(8)) != 0) ? 8 + ((((u_long)((((((((0x3ff) >> 16) >>
8)) - 1) & ((((0x3ff) >> 16) >> 8))) ^ ((((0x3ff
) >> 16) >> 8)))) >> (4)) != 0) ? 4 + ((((u_long
)(((((((((0x3ff) >> 16) >> 8) >> 4)) - 1) &
(((((0x3ff) >> 16) >> 8) >> 4))) ^ (((((0x3ff
) >> 16) >> 8) >> 4)))) >> (2)) != 0)
? 2 + ((((u_long)((((((((((0x3ff) >> 16) >> 8) >>
4) >> 2)) - 1) & ((((((0x3ff) >> 16) >>
8) >> 4) >> 2))) ^ ((((((0x3ff) >> 16) >>
8) >> 4) >> 2)))) >> (1)) != 0) ? 1 : 0) :
((((u_long)((((((((((0x3ff) >> 16) >> 8) >>
4))) - 1) & ((((((0x3ff) >> 16) >> 8) >>
4)))) ^ ((((((0x3ff) >> 16) >> 8) >> 4))))
) >> (1)) != 0) ? 1 : 0)) : ((((u_long)(((((((((0x3ff) >>
16) >> 8))) - 1) & (((((0x3ff) >> 16) >>
8)))) ^ (((((0x3ff) >> 16) >> 8))))) >> (2
)) != 0) ? 2 + ((((u_long)((((((((((0x3ff) >> 16) >>
8)) >> 2)) - 1) & ((((((0x3ff) >> 16) >>
8)) >> 2))) ^ ((((((0x3ff) >> 16) >> 8)) >>
2)))) >> (1)) != 0) ? 1 : 0) : ((((u_long)((((((((((0x3ff
) >> 16) >> 8)))) - 1) & ((((((0x3ff) >>
16) >> 8))))) ^ ((((((0x3ff) >> 16) >> 8))
)))) >> (1)) != 0) ? 1 : 0))) : ((((u_long)((((((((0x3ff
) >> 16))) - 1) & ((((0x3ff) >> 16)))) ^ ((((
0x3ff) >> 16))))) >> (4)) != 0) ? 4 + ((((u_long)
(((((((((0x3ff) >> 16)) >> 4)) - 1) & (((((0x3ff
) >> 16)) >> 4))) ^ (((((0x3ff) >> 16)) >>
4)))) >> (2)) != 0) ? 2 + ((((u_long)((((((((((0x3ff) >>
16)) >> 4) >> 2)) - 1) & ((((((0x3ff) >>
16)) >> 4) >> 2))) ^ ((((((0x3ff) >> 16)) >>
4) >> 2)))) >> (1)) != 0) ? 1 : 0) : ((((u_long)
((((((((((0x3ff) >> 16)) >> 4))) - 1) & (((((
(0x3ff) >> 16)) >> 4)))) ^ ((((((0x3ff) >> 16
)) >> 4))))) >> (1)) != 0) ? 1 : 0)) : ((((u_long
)(((((((((0x3ff) >> 16)))) - 1) & (((((0x3ff) >>
16))))) ^ (((((0x3ff) >> 16)))))) >> (2)) != 0) ?
2 + ((((u_long)((((((((((0x3ff) >> 16))) >> 2)) -
1) & ((((((0x3ff) >> 16))) >> 2))) ^ ((((((0x3ff
) >> 16))) >> 2)))) >> (1)) != 0) ? 1 : 0) :
((((u_long)((((((((((0x3ff) >> 16))))) - 1) & ((((
((0x3ff) >> 16)))))) ^ ((((((0x3ff) >> 16))))))) >>
(1)) != 0) ? 1 : 0)))) : ((((u_long)(((((((0x3ff))) - 1) &
(((0x3ff)))) ^ (((0x3ff))))) >> (8)) != 0) ? 8 + ((((u_long
)((((((((0x3ff)) >> 8)) - 1) & ((((0x3ff)) >>
8))) ^ ((((0x3ff)) >> 8)))) >> (4)) != 0) ? 4 + (
(((u_long)(((((((((0x3ff)) >> 8) >> 4)) - 1) &
(((((0x3ff)) >> 8) >> 4))) ^ (((((0x3ff)) >>
8) >> 4)))) >> (2)) != 0) ? 2 + ((((u_long)(((((
(((((0x3ff)) >> 8) >> 4) >> 2)) - 1) & (
(((((0x3ff)) >> 8) >> 4) >> 2))) ^ ((((((0x3ff
)) >> 8) >> 4) >> 2)))) >> (1)) != 0)
? 1 : 0) : ((((u_long)((((((((((0x3ff)) >> 8) >>
4))) - 1) & ((((((0x3ff)) >> 8) >> 4)))) ^ (
(((((0x3ff)) >> 8) >> 4))))) >> (1)) != 0) ?
1 : 0)) : ((((u_long)(((((((((0x3ff)) >> 8))) - 1) &
(((((0x3ff)) >> 8)))) ^ (((((0x3ff)) >> 8))))) >>
(2)) != 0) ? 2 + ((((u_long)((((((((((0x3ff)) >> 8)) >>
2)) - 1) & ((((((0x3ff)) >> 8)) >> 2))) ^ ((
((((0x3ff)) >> 8)) >> 2)))) >> (1)) != 0) ?
1 : 0) : ((((u_long)((((((((((0x3ff)) >> 8)))) - 1) &
((((((0x3ff)) >> 8))))) ^ ((((((0x3ff)) >> 8))))
)) >> (1)) != 0) ? 1 : 0))) : ((((u_long)((((((((0x3ff)
))) - 1) & ((((0x3ff))))) ^ ((((0x3ff)))))) >> (4))
!= 0) ? 4 + ((((u_long)(((((((((0x3ff))) >> 4)) - 1) &
(((((0x3ff))) >> 4))) ^ (((((0x3ff))) >> 4)))) >>
(2)) != 0) ? 2 + ((((u_long)((((((((((0x3ff))) >> 4) >>
2)) - 1) & ((((((0x3ff))) >> 4) >> 2))) ^ ((
((((0x3ff))) >> 4) >> 2)))) >> (1)) != 0) ?
1 : 0) : ((((u_long)((((((((((0x3ff))) >> 4))) - 1) &
((((((0x3ff))) >> 4)))) ^ ((((((0x3ff))) >> 4)))
)) >> (1)) != 0) ? 1 : 0)) : ((((u_long)(((((((((0x3ff)
)))) - 1) & (((((0x3ff)))))) ^ (((((0x3ff))))))) >>
(2)) != 0) ? 2 + ((((u_long)((((((((((0x3ff)))) >> 2))
- 1) & ((((((0x3ff)))) >> 2))) ^ ((((((0x3ff)))) >>
2)))) >> (1)) != 0) ? 1 : 0) : ((((u_long)((((((((((0x3ff
)))))) - 1) & ((((((0x3ff))))))) ^ ((((((0x3ff)))))))) >>
(1)) != 0) ? 1 : 0))))))))
;
3392 RTW_WRITE16(regs, RTW_ATIMTRITV, LSHIFT(2, RTW_ATIMTRITV_ATIMTRITV))((*(regs)->r_write16)(regs, 0x76, ((2) << ((((u_long
)((((((0x3ff)) - 1) & ((0x3ff))) ^ ((0x3ff)))) >> (
16)) != 0) ? 16 + ((((u_long)(((((((0x3ff) >> 16)) - 1)
& (((0x3ff) >> 16))) ^ (((0x3ff) >> 16)))) >>
(8)) != 0) ? 8 + ((((u_long)((((((((0x3ff) >> 16) >>
8)) - 1) & ((((0x3ff) >> 16) >> 8))) ^ ((((0x3ff
) >> 16) >> 8)))) >> (4)) != 0) ? 4 + ((((u_long
)(((((((((0x3ff) >> 16) &