0001
0002 #ifndef B43legacy_H_
0003 #define B43legacy_H_
0004
0005 #include <linux/hw_random.h>
0006 #include <linux/kernel.h>
0007 #include <linux/spinlock.h>
0008 #include <linux/interrupt.h>
0009 #include <linux/stringify.h>
0010 #include <linux/netdevice.h>
0011 #include <linux/pci.h>
0012 #include <linux/atomic.h>
0013 #include <linux/io.h>
0014
0015 #include <linux/ssb/ssb.h>
0016 #include <linux/ssb/ssb_driver_chipcommon.h>
0017 #include <linux/completion.h>
0018
0019 #include <net/mac80211.h>
0020
0021 #include "debugfs.h"
0022 #include "leds.h"
0023 #include "rfkill.h"
0024 #include "phy.h"
0025
0026
0027 #define B43legacy_IRQWAIT_MAX_RETRIES 20
0028
0029
0030 #define B43legacy_MMIO_DMA0_REASON 0x20
0031 #define B43legacy_MMIO_DMA0_IRQ_MASK 0x24
0032 #define B43legacy_MMIO_DMA1_REASON 0x28
0033 #define B43legacy_MMIO_DMA1_IRQ_MASK 0x2C
0034 #define B43legacy_MMIO_DMA2_REASON 0x30
0035 #define B43legacy_MMIO_DMA2_IRQ_MASK 0x34
0036 #define B43legacy_MMIO_DMA3_REASON 0x38
0037 #define B43legacy_MMIO_DMA3_IRQ_MASK 0x3C
0038 #define B43legacy_MMIO_DMA4_REASON 0x40
0039 #define B43legacy_MMIO_DMA4_IRQ_MASK 0x44
0040 #define B43legacy_MMIO_DMA5_REASON 0x48
0041 #define B43legacy_MMIO_DMA5_IRQ_MASK 0x4C
0042 #define B43legacy_MMIO_MACCTL 0x120
0043 #define B43legacy_MMIO_MACCMD 0x124
0044 #define B43legacy_MMIO_GEN_IRQ_REASON 0x128
0045 #define B43legacy_MMIO_GEN_IRQ_MASK 0x12C
0046 #define B43legacy_MMIO_RAM_CONTROL 0x130
0047 #define B43legacy_MMIO_RAM_DATA 0x134
0048 #define B43legacy_MMIO_PS_STATUS 0x140
0049 #define B43legacy_MMIO_RADIO_HWENABLED_HI 0x158
0050 #define B43legacy_MMIO_SHM_CONTROL 0x160
0051 #define B43legacy_MMIO_SHM_DATA 0x164
0052 #define B43legacy_MMIO_SHM_DATA_UNALIGNED 0x166
0053 #define B43legacy_MMIO_XMITSTAT_0 0x170
0054 #define B43legacy_MMIO_XMITSTAT_1 0x174
0055 #define B43legacy_MMIO_REV3PLUS_TSF_LOW 0x180
0056 #define B43legacy_MMIO_REV3PLUS_TSF_HIGH 0x184
0057 #define B43legacy_MMIO_TSF_CFP_REP 0x188
0058 #define B43legacy_MMIO_TSF_CFP_START 0x18C
0059
0060 #define B43legacy_MMIO_DMA32_BASE0 0x200
0061 #define B43legacy_MMIO_DMA32_BASE1 0x220
0062 #define B43legacy_MMIO_DMA32_BASE2 0x240
0063 #define B43legacy_MMIO_DMA32_BASE3 0x260
0064 #define B43legacy_MMIO_DMA32_BASE4 0x280
0065 #define B43legacy_MMIO_DMA32_BASE5 0x2A0
0066
0067 #define B43legacy_MMIO_DMA64_BASE0 0x200
0068 #define B43legacy_MMIO_DMA64_BASE1 0x240
0069 #define B43legacy_MMIO_DMA64_BASE2 0x280
0070 #define B43legacy_MMIO_DMA64_BASE3 0x2C0
0071 #define B43legacy_MMIO_DMA64_BASE4 0x300
0072 #define B43legacy_MMIO_DMA64_BASE5 0x340
0073
0074 #define B43legacy_MMIO_PIO1_BASE 0x300
0075 #define B43legacy_MMIO_PIO2_BASE 0x310
0076 #define B43legacy_MMIO_PIO3_BASE 0x320
0077 #define B43legacy_MMIO_PIO4_BASE 0x330
0078
0079 #define B43legacy_MMIO_PHY_VER 0x3E0
0080 #define B43legacy_MMIO_PHY_RADIO 0x3E2
0081 #define B43legacy_MMIO_PHY0 0x3E6
0082 #define B43legacy_MMIO_ANTENNA 0x3E8
0083 #define B43legacy_MMIO_CHANNEL 0x3F0
0084 #define B43legacy_MMIO_CHANNEL_EXT 0x3F4
0085 #define B43legacy_MMIO_RADIO_CONTROL 0x3F6
0086 #define B43legacy_MMIO_RADIO_DATA_HIGH 0x3F8
0087 #define B43legacy_MMIO_RADIO_DATA_LOW 0x3FA
0088 #define B43legacy_MMIO_PHY_CONTROL 0x3FC
0089 #define B43legacy_MMIO_PHY_DATA 0x3FE
0090 #define B43legacy_MMIO_MACFILTER_CONTROL 0x420
0091 #define B43legacy_MMIO_MACFILTER_DATA 0x422
0092 #define B43legacy_MMIO_RCMTA_COUNT 0x43C
0093 #define B43legacy_MMIO_RADIO_HWENABLED_LO 0x49A
0094 #define B43legacy_MMIO_GPIO_CONTROL 0x49C
0095 #define B43legacy_MMIO_GPIO_MASK 0x49E
0096 #define B43legacy_MMIO_TSF_CFP_PRETBTT 0x612
0097 #define B43legacy_MMIO_TSF_0 0x632
0098 #define B43legacy_MMIO_TSF_1 0x634
0099 #define B43legacy_MMIO_TSF_2 0x636
0100 #define B43legacy_MMIO_TSF_3 0x638
0101 #define B43legacy_MMIO_RNG 0x65A
0102 #define B43legacy_MMIO_POWERUP_DELAY 0x6A8
0103
0104
0105 #define B43legacy_BFL_PACTRL 0x0002
0106 #define B43legacy_BFL_RSSI 0x0008
0107 #define B43legacy_BFL_EXTLNA 0x1000
0108
0109
0110 #define B43legacy_GPIO_CONTROL 0x6c
0111
0112
0113 #define B43legacy_SHM_SHARED 0x0001
0114 #define B43legacy_SHM_WIRELESS 0x0002
0115 #define B43legacy_SHM_HW 0x0004
0116 #define B43legacy_SHM_UCODE 0x0300
0117
0118
0119 #define B43legacy_SHM_AUTOINC_R 0x0200
0120 #define B43legacy_SHM_AUTOINC_W 0x0100
0121 #define B43legacy_SHM_AUTOINC_RW (B43legacy_SHM_AUTOINC_R | \
0122 B43legacy_SHM_AUTOINC_W)
0123
0124
0125 #define B43legacy_SHM_SH_WLCOREREV 0x0016
0126 #define B43legacy_SHM_SH_HOSTFLO 0x005E
0127 #define B43legacy_SHM_SH_HOSTFHI 0x0060
0128
0129 #define B43legacy_SHM_SH_KEYIDXBLOCK 0x05D4
0130
0131 #define B43legacy_SHM_SH_DTIMP 0x0012
0132 #define B43legacy_SHM_SH_BTL0 0x0018
0133 #define B43legacy_SHM_SH_BTL1 0x001A
0134 #define B43legacy_SHM_SH_BTSFOFF 0x001C
0135 #define B43legacy_SHM_SH_TIMPOS 0x001E
0136 #define B43legacy_SHM_SH_BEACPHYCTL 0x0054
0137
0138 #define B43legacy_SHM_SH_ACKCTSPHYCTL 0x0022
0139
0140 #define B43legacy_SHM_SH_PRTLEN 0x004A
0141 #define B43legacy_SHM_SH_PRMAXTIME 0x0074
0142 #define B43legacy_SHM_SH_PRPHYCTL 0x0188
0143
0144 #define B43legacy_SHM_SH_OFDMDIRECT 0x0480
0145 #define B43legacy_SHM_SH_OFDMBASIC 0x04A0
0146 #define B43legacy_SHM_SH_CCKDIRECT 0x04C0
0147 #define B43legacy_SHM_SH_CCKBASIC 0x04E0
0148
0149 #define B43legacy_SHM_SH_UCODEREV 0x0000
0150 #define B43legacy_SHM_SH_UCODEPATCH 0x0002
0151 #define B43legacy_SHM_SH_UCODEDATE 0x0004
0152 #define B43legacy_SHM_SH_UCODETIME 0x0006
0153 #define B43legacy_SHM_SH_SPUWKUP 0x0094
0154 #define B43legacy_SHM_SH_PRETBTT 0x0096
0155
0156 #define B43legacy_UCODEFLAGS_OFFSET 0x005E
0157
0158
0159 #define B43legacy_MMIO_RADIO_HWENABLED_HI_MASK (1 << 16)
0160 #define B43legacy_MMIO_RADIO_HWENABLED_LO_MASK (1 << 4)
0161
0162
0163 #define B43legacy_HF_SYMW 0x00000002
0164 #define B43legacy_HF_GDCW 0x00000020
0165 #define B43legacy_HF_OFDMPABOOST 0x00000040
0166 #define B43legacy_HF_EDCF 0x00000100
0167
0168
0169 #define B43legacy_MACFILTER_SELF 0x0000
0170 #define B43legacy_MACFILTER_BSSID 0x0003
0171 #define B43legacy_MACFILTER_MAC 0x0010
0172
0173
0174 #define B43legacy_PHYTYPE_B 0x01
0175 #define B43legacy_PHYTYPE_G 0x02
0176
0177
0178 #define B43legacy_PHY_G_LO_CONTROL 0x0810
0179 #define B43legacy_PHY_ILT_G_CTRL 0x0472
0180 #define B43legacy_PHY_ILT_G_DATA1 0x0473
0181 #define B43legacy_PHY_ILT_G_DATA2 0x0474
0182 #define B43legacy_PHY_G_PCTL 0x0029
0183 #define B43legacy_PHY_RADIO_BITFIELD 0x0401
0184 #define B43legacy_PHY_G_CRS 0x0429
0185 #define B43legacy_PHY_NRSSILT_CTRL 0x0803
0186 #define B43legacy_PHY_NRSSILT_DATA 0x0804
0187
0188
0189 #define B43legacy_RADIOCTL_ID 0x01
0190
0191
0192 #define B43legacy_MACCTL_ENABLED 0x00000001
0193 #define B43legacy_MACCTL_PSM_RUN 0x00000002
0194 #define B43legacy_MACCTL_PSM_JMP0 0x00000004
0195 #define B43legacy_MACCTL_SHM_ENABLED 0x00000100
0196 #define B43legacy_MACCTL_IHR_ENABLED 0x00000400
0197 #define B43legacy_MACCTL_BE 0x00010000
0198 #define B43legacy_MACCTL_INFRA 0x00020000
0199 #define B43legacy_MACCTL_AP 0x00040000
0200 #define B43legacy_MACCTL_RADIOLOCK 0x00080000
0201 #define B43legacy_MACCTL_BEACPROMISC 0x00100000
0202 #define B43legacy_MACCTL_KEEP_BADPLCP 0x00200000
0203 #define B43legacy_MACCTL_KEEP_CTL 0x00400000
0204 #define B43legacy_MACCTL_KEEP_BAD 0x00800000
0205 #define B43legacy_MACCTL_PROMISC 0x01000000
0206 #define B43legacy_MACCTL_HWPS 0x02000000
0207 #define B43legacy_MACCTL_AWAKE 0x04000000
0208 #define B43legacy_MACCTL_TBTTHOLD 0x10000000
0209 #define B43legacy_MACCTL_GMODE 0x80000000
0210
0211
0212 #define B43legacy_MACCMD_BEACON0_VALID 0x00000001
0213 #define B43legacy_MACCMD_BEACON1_VALID 0x00000002
0214 #define B43legacy_MACCMD_DFQ_VALID 0x00000004
0215 #define B43legacy_MACCMD_CCA 0x00000008
0216 #define B43legacy_MACCMD_BGNOISE 0x00000010
0217
0218
0219 #define B43legacy_TMSLOW_GMODE 0x20000000
0220 #define B43legacy_TMSLOW_PLLREFSEL 0x00200000
0221 #define B43legacy_TMSLOW_MACPHYCLKEN 0x00100000
0222 #define B43legacy_TMSLOW_PHYRESET 0x00080000
0223 #define B43legacy_TMSLOW_PHYCLKEN 0x00040000
0224
0225
0226 #define B43legacy_TMSHIGH_FCLOCK 0x00040000
0227 #define B43legacy_TMSHIGH_GPHY 0x00010000
0228
0229 #define B43legacy_UCODEFLAG_AUTODIV 0x0001
0230
0231
0232 #define B43legacy_IRQ_MAC_SUSPENDED 0x00000001
0233 #define B43legacy_IRQ_BEACON 0x00000002
0234 #define B43legacy_IRQ_TBTT_INDI 0x00000004
0235 #define B43legacy_IRQ_BEACON_TX_OK 0x00000008
0236 #define B43legacy_IRQ_BEACON_CANCEL 0x00000010
0237 #define B43legacy_IRQ_ATIM_END 0x00000020
0238 #define B43legacy_IRQ_PMQ 0x00000040
0239 #define B43legacy_IRQ_PIO_WORKAROUND 0x00000100
0240 #define B43legacy_IRQ_MAC_TXERR 0x00000200
0241 #define B43legacy_IRQ_PHY_TXERR 0x00000800
0242 #define B43legacy_IRQ_PMEVENT 0x00001000
0243 #define B43legacy_IRQ_TIMER0 0x00002000
0244 #define B43legacy_IRQ_TIMER1 0x00004000
0245 #define B43legacy_IRQ_DMA 0x00008000
0246 #define B43legacy_IRQ_TXFIFO_FLUSH_OK 0x00010000
0247 #define B43legacy_IRQ_CCA_MEASURE_OK 0x00020000
0248 #define B43legacy_IRQ_NOISESAMPLE_OK 0x00040000
0249 #define B43legacy_IRQ_UCODE_DEBUG 0x08000000
0250 #define B43legacy_IRQ_RFKILL 0x10000000
0251 #define B43legacy_IRQ_TX_OK 0x20000000
0252 #define B43legacy_IRQ_PHY_G_CHANGED 0x40000000
0253 #define B43legacy_IRQ_TIMEOUT 0x80000000
0254
0255 #define B43legacy_IRQ_ALL 0xFFFFFFFF
0256 #define B43legacy_IRQ_MASKTEMPLATE (B43legacy_IRQ_MAC_SUSPENDED | \
0257 B43legacy_IRQ_TBTT_INDI | \
0258 B43legacy_IRQ_ATIM_END | \
0259 B43legacy_IRQ_PMQ | \
0260 B43legacy_IRQ_MAC_TXERR | \
0261 B43legacy_IRQ_PHY_TXERR | \
0262 B43legacy_IRQ_DMA | \
0263 B43legacy_IRQ_TXFIFO_FLUSH_OK | \
0264 B43legacy_IRQ_NOISESAMPLE_OK | \
0265 B43legacy_IRQ_UCODE_DEBUG | \
0266 B43legacy_IRQ_RFKILL | \
0267 B43legacy_IRQ_TX_OK)
0268
0269
0270
0271
0272 #define B43legacy_CCK_RATE_1MB 2
0273 #define B43legacy_CCK_RATE_2MB 4
0274 #define B43legacy_CCK_RATE_5MB 11
0275 #define B43legacy_CCK_RATE_11MB 22
0276 #define B43legacy_OFDM_RATE_6MB 12
0277 #define B43legacy_OFDM_RATE_9MB 18
0278 #define B43legacy_OFDM_RATE_12MB 24
0279 #define B43legacy_OFDM_RATE_18MB 36
0280 #define B43legacy_OFDM_RATE_24MB 48
0281 #define B43legacy_OFDM_RATE_36MB 72
0282 #define B43legacy_OFDM_RATE_48MB 96
0283 #define B43legacy_OFDM_RATE_54MB 108
0284
0285 #define B43legacy_RATE_TO_100KBPS(rate) (((rate) * 10) / 2)
0286
0287
0288 #define B43legacy_DEFAULT_SHORT_RETRY_LIMIT 7
0289 #define B43legacy_DEFAULT_LONG_RETRY_LIMIT 4
0290
0291 #define B43legacy_PHY_TX_BADNESS_LIMIT 1000
0292
0293
0294 #define B43legacy_SEC_KEYSIZE 16
0295
0296 enum {
0297 B43legacy_SEC_ALGO_NONE = 0,
0298 B43legacy_SEC_ALGO_WEP40,
0299 B43legacy_SEC_ALGO_TKIP,
0300 B43legacy_SEC_ALGO_AES,
0301 B43legacy_SEC_ALGO_WEP104,
0302 B43legacy_SEC_ALGO_AES_LEGACY,
0303 };
0304
0305
0306 #define B43legacy_CIR_BASE 0xf00
0307 #define B43legacy_CIR_SBTPSFLAG (B43legacy_CIR_BASE + 0x18)
0308 #define B43legacy_CIR_SBIMSTATE (B43legacy_CIR_BASE + 0x90)
0309 #define B43legacy_CIR_SBINTVEC (B43legacy_CIR_BASE + 0x94)
0310 #define B43legacy_CIR_SBTMSTATELOW (B43legacy_CIR_BASE + 0x98)
0311 #define B43legacy_CIR_SBTMSTATEHIGH (B43legacy_CIR_BASE + 0x9c)
0312 #define B43legacy_CIR_SBIMCONFIGLOW (B43legacy_CIR_BASE + 0xa8)
0313 #define B43legacy_CIR_SB_ID_HI (B43legacy_CIR_BASE + 0xfc)
0314
0315
0316 #define B43legacy_SBTMSTATEHIGH_SERROR 0x00000001
0317 #define B43legacy_SBTMSTATEHIGH_BUSY 0x00000004
0318 #define B43legacy_SBTMSTATEHIGH_TIMEOUT 0x00000020
0319 #define B43legacy_SBTMSTATEHIGH_G_PHY_AVAIL 0x00010000
0320 #define B43legacy_SBTMSTATEHIGH_COREFLAGS 0x1FFF0000
0321 #define B43legacy_SBTMSTATEHIGH_DMA64BIT 0x10000000
0322 #define B43legacy_SBTMSTATEHIGH_GATEDCLK 0x20000000
0323 #define B43legacy_SBTMSTATEHIGH_BISTFAILED 0x40000000
0324 #define B43legacy_SBTMSTATEHIGH_BISTCOMPLETE 0x80000000
0325
0326
0327 #define B43legacy_SBIMSTATE_IB_ERROR 0x20000
0328 #define B43legacy_SBIMSTATE_TIMEOUT 0x40000
0329
0330 #define PFX KBUILD_MODNAME ": "
0331 #ifdef assert
0332 # undef assert
0333 #endif
0334 #ifdef CONFIG_B43LEGACY_DEBUG
0335 # define B43legacy_WARN_ON(x) WARN_ON(x)
0336 # define B43legacy_BUG_ON(expr) \
0337 do { \
0338 if (unlikely((expr))) { \
0339 printk(KERN_INFO PFX "Test (%s) failed\n", \
0340 #expr); \
0341 BUG_ON(expr); \
0342 } \
0343 } while (0)
0344 # define B43legacy_DEBUG 1
0345 #else
0346
0347 static inline bool __b43legacy_warn_on_dummy(bool x) { return x; }
0348 # define B43legacy_WARN_ON(x) __b43legacy_warn_on_dummy(unlikely(!!(x)))
0349 # define B43legacy_BUG_ON(x) do { } while (0)
0350 # define B43legacy_DEBUG 0
0351 #endif
0352
0353
0354 struct net_device;
0355 struct pci_dev;
0356 struct b43legacy_dmaring;
0357 struct b43legacy_pioqueue;
0358
0359
0360 #define B43legacy_FW_TYPE_UCODE 'u'
0361 #define B43legacy_FW_TYPE_PCM 'p'
0362 #define B43legacy_FW_TYPE_IV 'i'
0363 struct b43legacy_fw_header {
0364
0365 u8 type;
0366
0367 u8 ver;
0368 u8 __padding[2];
0369
0370
0371 __be32 size;
0372 } __packed;
0373
0374
0375 #define B43legacy_IV_OFFSET_MASK 0x7FFF
0376 #define B43legacy_IV_32BIT 0x8000
0377 struct b43legacy_iv {
0378 __be16 offset_size;
0379 union {
0380 __be16 d16;
0381 __be32 d32;
0382 } data __packed;
0383 } __packed;
0384
0385 #define B43legacy_PHYMODE(phytype) (1 << (phytype))
0386 #define B43legacy_PHYMODE_B B43legacy_PHYMODE \
0387 ((B43legacy_PHYTYPE_B))
0388 #define B43legacy_PHYMODE_G B43legacy_PHYMODE \
0389 ((B43legacy_PHYTYPE_G))
0390
0391
0392 struct b43legacy_lopair {
0393 s8 low;
0394 s8 high;
0395 u8 used:1;
0396 };
0397 #define B43legacy_LO_COUNT (14*4)
0398
0399 struct b43legacy_phy {
0400
0401 u8 possible_phymodes;
0402
0403 bool gmode;
0404
0405
0406 u8 analog;
0407
0408 u8 type;
0409
0410 u8 rev;
0411
0412 u16 antenna_diversity;
0413 u16 savedpctlreg;
0414
0415 u16 radio_manuf;
0416 u16 radio_ver;
0417 u8 calibrated:1;
0418 u8 radio_rev;
0419
0420 bool dyn_tssi_tbl;
0421
0422
0423 bool aci_enable;
0424 bool aci_wlan_automatic;
0425 bool aci_hw_rssi;
0426
0427
0428 bool radio_on;
0429 struct {
0430
0431
0432 bool valid;
0433 u16 rfover;
0434 u16 rfoverval;
0435 } radio_off_context;
0436
0437 u16 minlowsig[2];
0438 u16 minlowsigpos[2];
0439
0440
0441
0442
0443 struct b43legacy_lopair *_lo_pairs;
0444
0445 const s8 *tssi2dbm;
0446
0447 s8 idle_tssi;
0448
0449 int tgt_idle_tssi;
0450
0451 int cur_idle_tssi;
0452
0453
0454 struct b43legacy_txpower_lo_control *lo_control;
0455
0456 s16 max_lb_gain;
0457 s16 trsw_rx_gain;
0458 s16 lna_lod_gain;
0459 s16 lna_gain;
0460 s16 pga_gain;
0461
0462
0463
0464 u8 power_level;
0465
0466
0467 u16 loopback_gain[2];
0468
0469
0470
0471 struct {
0472
0473 u16 rfatt;
0474
0475 u16 bbatt;
0476
0477 u16 txctl1;
0478 u16 txctl2;
0479 };
0480
0481 struct {
0482 u16 txpwr_offset;
0483 };
0484
0485
0486 int interfmode;
0487
0488
0489
0490
0491
0492
0493
0494 #define B43legacy_INTERFSTACK_SIZE 26
0495 u32 interfstack[B43legacy_INTERFSTACK_SIZE];
0496
0497
0498 s16 nrssi[2];
0499 s32 nrssislope;
0500
0501 s8 nrssi_lt[64];
0502
0503
0504 u8 channel;
0505
0506 u16 lofcal;
0507
0508 u16 initval;
0509
0510
0511 atomic_t txerr_cnt;
0512
0513 #if B43legacy_DEBUG
0514
0515 bool manual_txpower_control;
0516
0517 bool phy_locked;
0518 #endif
0519 };
0520
0521
0522 struct b43legacy_dma {
0523 struct b43legacy_dmaring *tx_ring0;
0524 struct b43legacy_dmaring *tx_ring1;
0525 struct b43legacy_dmaring *tx_ring2;
0526 struct b43legacy_dmaring *tx_ring3;
0527 struct b43legacy_dmaring *tx_ring4;
0528 struct b43legacy_dmaring *tx_ring5;
0529
0530 struct b43legacy_dmaring *rx_ring0;
0531 struct b43legacy_dmaring *rx_ring3;
0532
0533 u32 translation;
0534 };
0535
0536
0537 struct b43legacy_pio {
0538 struct b43legacy_pioqueue *queue0;
0539 struct b43legacy_pioqueue *queue1;
0540 struct b43legacy_pioqueue *queue2;
0541 struct b43legacy_pioqueue *queue3;
0542 };
0543
0544
0545 struct b43legacy_noise_calculation {
0546 u8 channel_at_start;
0547 bool calculation_running;
0548 u8 nr_samples;
0549 s8 samples[8][4];
0550 };
0551
0552 struct b43legacy_stats {
0553 u8 link_noise;
0554
0555 unsigned long last_tx;
0556 unsigned long last_rx;
0557 };
0558
0559 struct b43legacy_key {
0560 void *keyconf;
0561 bool enabled;
0562 u8 algorithm;
0563 };
0564
0565 #define B43legacy_QOS_QUEUE_NUM 4
0566
0567 struct b43legacy_wldev;
0568
0569
0570 struct b43legacy_qos_params {
0571
0572 struct ieee80211_tx_queue_params p;
0573 };
0574
0575
0576 struct b43legacy_wl {
0577
0578 struct b43legacy_wldev *current_dev;
0579
0580 struct ieee80211_hw *hw;
0581
0582 spinlock_t irq_lock;
0583 struct mutex mutex;
0584 spinlock_t leds_lock;
0585
0586
0587 struct work_struct firmware_load;
0588
0589
0590
0591
0592
0593 struct ieee80211_vif *vif;
0594
0595 u8 mac_addr[ETH_ALEN];
0596
0597 u8 bssid[ETH_ALEN];
0598
0599 int if_type;
0600
0601 bool operating;
0602
0603 unsigned int filter_flags;
0604
0605 struct ieee80211_low_level_stats ieee_stats;
0606
0607 #ifdef CONFIG_B43LEGACY_HWRNG
0608 struct hwrng rng;
0609 u8 rng_initialized;
0610 char rng_name[30 + 1];
0611 #endif
0612
0613
0614 struct list_head devlist;
0615 u8 nr_devs;
0616
0617 bool radiotap_enabled;
0618 bool radio_enabled;
0619
0620
0621
0622 struct sk_buff *current_beacon;
0623 bool beacon0_uploaded;
0624 bool beacon1_uploaded;
0625 bool beacon_templates_virgin;
0626 struct work_struct beacon_update_trigger;
0627
0628 struct b43legacy_qos_params qos_params[B43legacy_QOS_QUEUE_NUM];
0629
0630
0631 struct work_struct tx_work;
0632
0633
0634 struct sk_buff_head tx_queue[B43legacy_QOS_QUEUE_NUM];
0635
0636
0637 bool tx_queue_stopped[B43legacy_QOS_QUEUE_NUM];
0638
0639 };
0640
0641
0642 struct b43legacy_firmware {
0643
0644 const struct firmware *ucode;
0645
0646 const struct firmware *pcm;
0647
0648 const struct firmware *initvals;
0649
0650 const struct firmware *initvals_band;
0651
0652 u16 rev;
0653
0654 u16 patch;
0655 };
0656
0657
0658 enum {
0659 B43legacy_STAT_UNINIT = 0,
0660 B43legacy_STAT_INITIALIZED = 1,
0661 B43legacy_STAT_STARTED = 2,
0662 };
0663 #define b43legacy_status(wldev) atomic_read(&(wldev)->__init_status)
0664 #define b43legacy_set_status(wldev, stat) do { \
0665 atomic_set(&(wldev)->__init_status, (stat)); \
0666 smp_wmb(); \
0667 } while (0)
0668
0669
0670
0671
0672
0673
0674
0675
0676
0677
0678 struct b43legacy_wldev {
0679 struct ssb_device *dev;
0680 struct b43legacy_wl *wl;
0681
0682
0683
0684 atomic_t __init_status;
0685
0686 int suspend_init_status;
0687
0688 bool __using_pio;
0689 bool bad_frames_preempt;
0690 bool dfq_valid;
0691 bool short_preamble;
0692 bool radio_hw_enable;
0693
0694
0695 struct b43legacy_phy phy;
0696 union {
0697
0698 struct b43legacy_dma dma;
0699
0700 struct b43legacy_pio pio;
0701 };
0702
0703
0704 struct b43legacy_stats stats;
0705
0706
0707 struct b43legacy_led led_tx;
0708 struct b43legacy_led led_rx;
0709 struct b43legacy_led led_assoc;
0710 struct b43legacy_led led_radio;
0711
0712
0713 u32 irq_reason;
0714 u32 dma_reason[6];
0715
0716 u32 irq_mask;
0717
0718 struct b43legacy_noise_calculation noisecalc;
0719
0720 int mac_suspended;
0721
0722
0723 struct tasklet_struct isr_tasklet;
0724
0725
0726 struct delayed_work periodic_work;
0727 unsigned int periodic_state;
0728
0729 struct work_struct restart_work;
0730
0731
0732 u16 ktp;
0733 u8 max_nr_keys;
0734 struct b43legacy_key key[58];
0735
0736
0737 struct b43legacy_firmware fw;
0738 const struct firmware *fwp;
0739
0740
0741 struct completion fw_load_complete;
0742
0743
0744 struct list_head list;
0745
0746
0747 #ifdef CONFIG_B43LEGACY_DEBUG
0748 struct b43legacy_dfsentry *dfsentry;
0749 #endif
0750 };
0751
0752
0753 static inline
0754 struct b43legacy_wl *hw_to_b43legacy_wl(struct ieee80211_hw *hw)
0755 {
0756 return hw->priv;
0757 }
0758
0759
0760
0761
0762 #if defined(CONFIG_B43LEGACY_DMA) && defined(CONFIG_B43LEGACY_PIO)
0763 static inline
0764 int b43legacy_using_pio(struct b43legacy_wldev *dev)
0765 {
0766 return dev->__using_pio;
0767 }
0768 #elif defined(CONFIG_B43LEGACY_DMA)
0769 static inline
0770 int b43legacy_using_pio(struct b43legacy_wldev *dev)
0771 {
0772 return 0;
0773 }
0774 #elif defined(CONFIG_B43LEGACY_PIO)
0775 static inline
0776 int b43legacy_using_pio(struct b43legacy_wldev *dev)
0777 {
0778 return 1;
0779 }
0780 #else
0781 # error "Using neither DMA nor PIO? Confused..."
0782 #endif
0783
0784
0785 static inline
0786 struct b43legacy_wldev *dev_to_b43legacy_wldev(struct device *dev)
0787 {
0788 struct ssb_device *ssb_dev = dev_to_ssb_dev(dev);
0789 return ssb_get_drvdata(ssb_dev);
0790 }
0791
0792
0793 static inline
0794 int b43legacy_is_mode(struct b43legacy_wl *wl, int type)
0795 {
0796 return (wl->operating &&
0797 wl->if_type == type);
0798 }
0799
0800 static inline
0801 bool is_bcm_board_vendor(struct b43legacy_wldev *dev)
0802 {
0803 return (dev->dev->bus->boardinfo.vendor == PCI_VENDOR_ID_BROADCOM);
0804 }
0805
0806 static inline
0807 u16 b43legacy_read16(struct b43legacy_wldev *dev, u16 offset)
0808 {
0809 return ssb_read16(dev->dev, offset);
0810 }
0811
0812 static inline
0813 void b43legacy_write16(struct b43legacy_wldev *dev, u16 offset, u16 value)
0814 {
0815 ssb_write16(dev->dev, offset, value);
0816 }
0817
0818 static inline
0819 u32 b43legacy_read32(struct b43legacy_wldev *dev, u16 offset)
0820 {
0821 return ssb_read32(dev->dev, offset);
0822 }
0823
0824 static inline
0825 void b43legacy_write32(struct b43legacy_wldev *dev, u16 offset, u32 value)
0826 {
0827 ssb_write32(dev->dev, offset, value);
0828 }
0829
0830 static inline
0831 struct b43legacy_lopair *b43legacy_get_lopair(struct b43legacy_phy *phy,
0832 u16 radio_attenuation,
0833 u16 baseband_attenuation)
0834 {
0835 return phy->_lo_pairs + (radio_attenuation
0836 + 14 * (baseband_attenuation / 2));
0837 }
0838
0839
0840
0841
0842 __printf(2, 3)
0843 void b43legacyinfo(struct b43legacy_wl *wl, const char *fmt, ...);
0844 __printf(2, 3)
0845 void b43legacyerr(struct b43legacy_wl *wl, const char *fmt, ...);
0846 __printf(2, 3)
0847 void b43legacywarn(struct b43legacy_wl *wl, const char *fmt, ...);
0848 #if B43legacy_DEBUG
0849 __printf(2, 3)
0850 void b43legacydbg(struct b43legacy_wl *wl, const char *fmt, ...);
0851 #else
0852 # define b43legacydbg(wl, fmt...) do { } while (0)
0853 #endif
0854
0855
0856 #define Q52_FMT "%u.%u"
0857 #define Q52_ARG(q52) ((q52) / 4), (((q52) & 3) * 100 / 4)
0858
0859 #endif