00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023
00024
00025
00026
00027
00028
00029
00030
00031
00032
00033
00034
00035
00036
00037
00038
00039
00040
00041
00042
00043
00044
00045
00046
00047
00048
00049 #ifndef _DEV_ATH_ATHVAR_H
00050 #define _DEV_ATH_ATHVAR_H
00051
00052 #include "if_ieee80211.h"
00053 #include "ah.h"
00054 #include "if_ath_ioctl.h"
00055
00056
00057
00058
00059
00060
00061 #include <linux/interrupt.h>
00062 #ifdef DECLARE_TASKLET
00063 #define tq_struct tasklet_struct
00064 #define ATH_INIT_TQUEUE(a,b,c) tasklet_init((a),(b),(unsigned long)(c))
00065 #define ATH_SCHEDULE_TQUEUE(a,b) tasklet_schedule((a))
00066 typedef unsigned long TQUEUE_ARG;
00067 #define mark_bh(a)
00068 #else
00069 #define ATH_INIT_TQUEUE(a,b,c) INIT_TQUEUE(a,b,c)
00070 #define ATH_SCHEDULE_TQUEUE(a,b) do { \
00071 *(b) |= queue_task((a), &tq_immediate); \
00072 } while(0)
00073 typedef void *TQUEUE_ARG;
00074 #define tasklet_disable(t) do { (void) t; local_bh_disable(); } while (0)
00075 #define tasklet_enable(t) do { (void) t; local_bh_enable(); } while (0)
00076 #endif
00077
00078
00079
00080
00081 #if !defined(IRQ_NONE)
00082 typedef void irqreturn_t;
00083 #define IRQ_NONE
00084 #define IRQ_HANDLED
00085 #endif
00086
00087 #ifndef SET_MODULE_OWNER
00088 #define SET_MODULE_OWNER(dev) do { \
00089 dev->owner = THIS_MODULE; \
00090 } while (0)
00091 #endif
00092
00093 #ifndef SET_NETDEV_DEV
00094 #define SET_NETDEV_DEV(ndev, pdev)
00095 #endif
00096
00097
00098
00099
00100 #if LINUX_VERSION_CODE < KERNEL_VERSION(2,6,8)
00101 #define ATH_SYSCTL_DECL(f, ctl, write, filp, buffer, lenp, ppos) \
00102 f(ctl_table *ctl, int write, struct file *filp, void *buffer, \
00103 size_t *lenp)
00104 #define ATH_SYSCTL_PROC_DOINTVEC(ctl, write, filp, buffer, lenp, ppos) \
00105 proc_dointvec(ctl, write, filp, buffer, lenp)
00106 #else
00107 #define ATH_SYSCTL_DECL(f, ctl, write, filp, buffer, lenp, ppos) \
00108 f(ctl_table *ctl, int write, struct file *filp, void *buffer,\
00109 size_t *lenp, loff_t *ppos)
00110 #define ATH_SYSCTL_PROC_DOINTVEC(ctl, write, filp, buffer, lenp, ppos) \
00111 proc_dointvec(ctl, write, filp, buffer, lenp, ppos)
00112 #endif
00113
00114 #define ATH_TIMEOUT 1000
00115
00116
00117
00118
00119
00120
00121
00122 #define ATH_MAX_MTU 5000
00123 #define ATH_MIN_MTU 32
00124
00125 #define ATH_TPC_MAX 63
00126
00127 #define ATH_RXBUF 40
00128 #define ATH_TXBUF 1
00129 #define ATH_TXDESC 1
00130 #define ATH_TXMAXTRY 16
00131
00132
00133 struct ath_buf {
00134 STAILQ_ENTRY(ath_buf) bf_list;
00135 struct ath_desc *bf_desc;
00136 dma_addr_t bf_daddr;
00137 struct sk_buff *bf_skb;
00138 dma_addr_t bf_skbaddr;
00139 struct ieee80211_node *bf_node;
00140 };
00141
00142 struct ath_hal;
00143 struct ath_desc;
00144 struct proc_dir_entry;
00145
00146
00147
00148
00149
00150
00151
00152
00153
00154
00155
00156 struct ath_txq {
00157 u_int axq_qnum;
00158 u_int axq_depth;
00159 u_int axq_intrcnt;
00160 u_int32_t *axq_link;
00161 STAILQ_HEAD(, ath_buf) axq_q;
00162 spinlock_t axq_lock;
00163 };
00164
00165 #define ATH_TXQ_LOCK_INIT(_tq) spin_lock_init(&(_tq)->axq_lock)
00166 #define ATH_TXQ_LOCK_DESTROY(_tq)
00167 #define ATH_TXQ_LOCK(_tq) spin_lock(&(_tq)->axq_lock)
00168 #define ATH_TXQ_UNLOCK(_tq) spin_unlock(&(_tq)->axq_lock)
00169 #define ATH_TXQ_LOCK_BH(_tq) spin_lock_bh(&(_tq)->axq_lock)
00170 #define ATH_TXQ_UNLOCK_BH(_tq) spin_unlock_bh(&(_tq)->axq_lock)
00171 #define ATH_TXQ_LOCK_ASSERT(_tq) \
00172 KASSERT(spin_is_locked(&(_tq)->axq_lock), ("txq not locked!"))
00173
00174 #define ATH_TXQ_INSERT_TAIL(_tq, _elm, _field) do { \
00175 STAILQ_INSERT_TAIL(&(_tq)->axq_q, (_elm), _field); \
00176 (_tq)->axq_depth++; \
00177 } while (0)
00178 #define ATH_TXQ_REMOVE_HEAD(_tq, _field) do { \
00179 STAILQ_REMOVE_HEAD(&(_tq)->axq_q, _field); \
00180 (_tq)->axq_depth--; \
00181 } while (0)
00182
00183 struct ath_softc {
00184
00185 struct net_device dev;
00186 struct semaphore sc_lock;
00187 struct ath_hal *sc_ah;
00188
00189 unsigned int sc_invalid : 1,
00190 sc_mrretry : 1,
00191 sc_softled : 1,
00192 sc_hasdiversity : 1,
00193 sc_diversity : 1;
00194 u_int16_t sc_ledstate;
00195 u_int16_t sc_ledpin;
00196
00197 const HAL_RATE_TABLE *sc_rates[IEEE80211_MODE_MAX];
00198 const HAL_RATE_TABLE *sc_currates;
00199 enum ieee80211_phymode ic_curmode;
00200 u_int8_t sc_rixmap[256];
00201 u_int8_t sc_hwmap[32];
00202 HAL_INT sc_imask;
00203
00204 void *sc_bdev;
00205
00206
00207 struct ath_desc *sc_desc;
00208 size_t sc_desc_len;
00209 u_int16_t sc_cachelsz;
00210 dma_addr_t sc_desc_daddr;
00211
00212 struct tq_struct sc_fataltq;
00213
00214 int sc_rxbufsize;
00215 STAILQ_HEAD(, ath_buf) sc_rxbuf;
00216 u_int32_t *sc_rxlink;
00217 struct tq_struct sc_rxtq;
00218 struct tq_struct sc_rxorntq;
00219
00220 int sc_AC2qNum[4];
00221 u_int32_t *sc_txlink[HAL_NUM_TX_QUEUES];
00222 STAILQ_HEAD(, ath_buf) sc_txbuf;
00223 spinlock_t sc_txbuflock;
00224 u_int sc_txqsetup;
00225
00226 struct ath_txq sc_txq[HAL_NUM_TX_QUEUES];
00227 struct ath_txq *sc_ac2q[5];
00228 struct tq_struct sc_txtq;
00229
00230
00231 struct ath_buf *sc_bcbuf;
00232 struct ath_buf *sc_bufptr;
00233 struct tq_struct sc_bmisstq;
00234
00235 struct timer_list sc_rate_ctl;
00236 struct timer_list sc_cal_ch;
00237 struct timer_list sc_scan_ch;
00238 struct ath_stats sc_stats;
00239 u_int8_t sc_defant;
00240 u_int8_t sc_rxotherant;
00241
00242 u_int sc_keymax;
00243
00244
00245 int ic_fixed_rate;
00246
00247 int ic_rts_threshold;
00248 enum ieee80211_phytype ic_phytype;
00249 enum ieee80211_opmode ic_opmode;
00250
00251 int ic_esslen;
00252 u_int8_t ic_essid[IEEE80211_NWID_LEN];
00253 int ic_nicknamelen;
00254 u_int8_t ic_nickname[IEEE80211_NWID_LEN];
00255
00256 u_int16_t ic_lintval;
00257 u_int16_t ni_fhdwell;
00258 u_int8_t ni_fhindex;
00259
00260 u_int32_t ic_flags;
00261 u_int32_t ic_caps;
00262 u_int16_t ic_modecaps;
00263 struct ieee80211channel ic_channels[IEEE80211_CHAN_MAX+1];
00264 struct ieee80211channel *current_channel;
00265 u_char ic_chan_avail[roundup(IEEE80211_CHAN_MAX/NBBY,NBBY)];
00266
00267 int subsequent_kicks;
00268
00269 int dev_type;
00270
00271 u_int8_t bssid[IEEE80211_ADDR_LEN];
00272 struct net_device_stats ic_stats;
00273 struct ieee80211_wepkey ic_nw_keys[IEEE80211_WEP_NKID];
00274 #ifdef CONFIG_NET_WIRELESS
00275 struct iw_statistics ic_iwstats;
00276 #endif
00277 u_int16_t txseq;
00278
00279 u_int8_t sc_txantenna;
00280 int sc_debug;
00281
00282 #ifdef CONFIG_SYSCTL
00283 struct ctl_table_header *sc_sysctl_header;
00284 struct ctl_table *sc_sysctls;
00285 #endif
00286
00287 };
00288
00289
00290 #define ATH_TXQ_SETUP(sc, i) ((sc)->sc_txqsetup & (1<<i))
00291
00292 #define ATH_TXBUF_LOCK_INIT(_sc) spin_lock_init(&(_sc)->sc_txbuflock)
00293 #define ATH_TXBUF_LOCK_DESTROY(_sc)
00294 #define ATH_TXBUF_LOCK(_sc) spin_lock(&(_sc)->sc_txbuflock)
00295 #define ATH_TXBUF_UNLOCK(_sc) spin_unlock(&(_sc)->sc_txbuflock)
00296 #define ATH_TXBUF_LOCK_BH(_sc) spin_lock_bh(&(_sc)->sc_txbuflock)
00297 #define ATH_TXBUF_UNLOCK_BH(_sc) spin_unlock_bh(&(_sc)->sc_txbuflock)
00298 #define ATH_TXBUF_LOCK_ASSERT(_sc) \
00299 KASSERT(spin_is_locked(&(_sc)->sc_txbuflock), ("txbuf not locked!"))
00300
00301 #define ATH_LOCK_INIT(_sc) init_MUTEX(&(_sc)->sc_lock)
00302 #define ATH_LOCK_DESTROY(_sc)
00303 #define ATH_LOCK(_sc) down(&(_sc)->sc_lock)
00304 #define ATH_UNLOCK(_sc) up(&(_sc)->sc_lock)
00305
00306 extern int ath_debug;
00307
00308
00309 int ath_attach(u_int16_t, struct net_device *);
00310 int ath_detach(struct net_device *);
00311 void ath_resume(struct net_device *);
00312 void ath_suspend(struct net_device *);
00313 void ath_shutdown(struct net_device *);
00314 irqreturn_t ath_intr(int irq, void *dev_id, struct pt_regs *regs);
00315 #ifdef CONFIG_SYSCTL
00316 void ath_sysctl_register(void);
00317 void ath_sysctl_unregister(void);
00318 #endif
00319
00320
00321
00322
00323 #define ath_hal_reset(_ah, _opmode, _chan, _outdoor, _pstatus) \
00324 ((*(_ah)->ah_reset)((_ah), (_opmode), (_chan), (_outdoor), (_pstatus)))
00325 #define ath_hal_getratetable(_ah, _mode) \
00326 ((*(_ah)->ah_getRateTable)((_ah), (_mode)))
00327 #define ath_hal_getmac(_ah, _mac) \
00328 ((*(_ah)->ah_getMacAddress)((_ah), (_mac)))
00329 #define ath_hal_setmac(_ah, _mac) \
00330 ((*(_ah)->ah_setMacAddress)((_ah), (_mac)))
00331 #define ath_hal_intrset(_ah, _mask) \
00332 ((*(_ah)->ah_setInterrupts)((_ah), (_mask)))
00333 #define ath_hal_intrget(_ah) \
00334 ((*(_ah)->ah_getInterrupts)((_ah)))
00335 #define ath_hal_intrpend(_ah) \
00336 ((*(_ah)->ah_isInterruptPending)((_ah)))
00337 #define ath_hal_getisr(_ah, _pmask) \
00338 ((*(_ah)->ah_getPendingInterrupts)((_ah), (_pmask)))
00339 #define ath_hal_updatetxtriglevel(_ah, _inc) \
00340 ((*(_ah)->ah_updateTxTrigLevel)((_ah), (_inc)))
00341 #define ath_hal_setpower(_ah, _mode, _sleepduration) \
00342 ((*(_ah)->ah_setPowerMode)((_ah), (_mode), AH_TRUE, (_sleepduration)))
00343 #define ath_hal_keycachesize(_ah) \
00344 ((*(_ah)->ah_getKeyCacheSize)((_ah)))
00345 #define ath_hal_keyreset(_ah, _ix) \
00346 ((*(_ah)->ah_resetKeyCacheEntry)((_ah), (_ix)))
00347 #define ath_hal_keyset(_ah, _ix, _pk, _mac) \
00348 ((*(_ah)->ah_setKeyCacheEntry)((_ah), (_ix), (_pk), (_mac), AH_FALSE))
00349 #define ath_hal_keyisvalid(_ah, _ix) \
00350 (((*(_ah)->ah_isKeyCacheEntryValid)((_ah), (_ix))))
00351 #define ath_hal_keysetmac(_ah, _ix, _mac) \
00352 ((*(_ah)->ah_setKeyCacheEntryMac)((_ah), (_ix), (_mac)))
00353 #define ath_hal_getrxfilter(_ah) \
00354 ((*(_ah)->ah_getRxFilter)((_ah)))
00355 #define ath_hal_setrxfilter(_ah, _filter) \
00356 ((*(_ah)->ah_setRxFilter)((_ah), (_filter)))
00357 #define ath_hal_setmcastfilter(_ah, _mfilt0, _mfilt1) \
00358 ((*(_ah)->ah_setMulticastFilter)((_ah), (_mfilt0), (_mfilt1)))
00359 #define ath_hal_waitforbeacon(_ah, _bf) \
00360 ((*(_ah)->ah_waitForBeaconDone)((_ah), (_bf)->bf_daddr))
00361 #define ath_hal_putrxbuf(_ah, _bufaddr) \
00362 ((*(_ah)->ah_setRxDP)((_ah), (_bufaddr)))
00363 #define ath_hal_gettsf32(_ah) \
00364 ((*(_ah)->ah_getTsf32)((_ah)))
00365 #define ath_hal_gettsf64(_ah) \
00366 ((*(_ah)->ah_getTsf64)((_ah)))
00367 #define ath_hal_resettsf(_ah) \
00368 ((*(_ah)->ah_resetTsf)((_ah)))
00369 #define ath_hal_rxena(_ah) \
00370 ((*(_ah)->ah_enableReceive)((_ah)))
00371 #define ath_hal_puttxbuf(_ah, _q, _bufaddr) \
00372 ((*(_ah)->ah_setTxDP)((_ah), (_q), (_bufaddr)))
00373 #define ath_hal_gettxbuf(_ah, _q) \
00374 ((*(_ah)->ah_getTxDP)((_ah), (_q)))
00375 #define ath_hal_getrxbuf(_ah) \
00376 ((*(_ah)->ah_getRxDP)((_ah)))
00377 #define ath_hal_txstart(_ah, _q) \
00378 ((*(_ah)->ah_startTxDma)((_ah), (_q)))
00379 #define ath_hal_setchannel(_ah, _chan) \
00380 ((*(_ah)->ah_setChannel)((_ah), (_chan)))
00381 #define ath_hal_calibrate(_ah, _chan) \
00382 ((*(_ah)->ah_perCalibration)((_ah), (_chan)))
00383 #define ath_hal_setledstate(_ah, _state) \
00384 ((*(_ah)->ah_setLedState)((_ah), (_state)))
00385 #define ath_hal_beaconinit(_ah, _nextb, _bperiod) \
00386 ((*(_ah)->ah_beaconInit)((_ah), (_nextb), (_bperiod)))
00387 #define ath_hal_beaconreset(_ah) \
00388 ((*(_ah)->ah_resetStationBeaconTimers)((_ah)))
00389 #define ath_hal_beacontimers(_ah, _bs) \
00390 ((*(_ah)->ah_setStationBeaconTimers)((_ah), (_bs)))
00391 #define ath_hal_setassocid(_ah, _bss, _associd) \
00392 ((*(_ah)->ah_writeAssocid)((_ah), (_bss), (_associd)))
00393 #define ath_hal_phydisable(_ah) \
00394 ((*(_ah)->ah_phyDisable)((_ah)))
00395 #define ath_hal_setopmode(_ah) \
00396 ((*(_ah)->ah_setPCUConfig)((_ah)))
00397 #define ath_hal_stoptxdma(_ah, _qnum) \
00398 ((*(_ah)->ah_stopTxDma)((_ah), (_qnum)))
00399 #define ath_hal_stoppcurecv(_ah) \
00400 ((*(_ah)->ah_stopPcuReceive)((_ah)))
00401 #define ath_hal_startpcurecv(_ah) \
00402 ((*(_ah)->ah_startPcuReceive)((_ah)))
00403 #define ath_hal_stopdmarecv(_ah) \
00404 ((*(_ah)->ah_stopDmaReceive)((_ah)))
00405 #define ath_hal_getdiagstate(_ah, _id, _indata, _insize, _outdata, _outsize) \
00406 ((*(_ah)->ah_getDiagState)((_ah), (_id), \
00407 (_indata), (_insize), (_outdata), (_outsize)))
00408 #define ath_hal_setuptxqueue(_ah, _type, _irq) \
00409 ((*(_ah)->ah_setupTxQueue)((_ah), (_type), (_irq)))
00410 #define ath_hal_resettxqueue(_ah, _q) \
00411 ((*(_ah)->ah_resetTxQueue)((_ah), (_q)))
00412 #define ath_hal_releasetxqueue(_ah, _q) \
00413 ((*(_ah)->ah_releaseTxQueue)((_ah), (_q)))
00414 #define ath_hal_hasveol(_ah) \
00415 ((*(_ah)->ah_hasVEOL)((_ah)))
00416 #define ath_hal_getrfgain(_ah) \
00417 ((*(_ah)->ah_getRfGain)((_ah)))
00418 #define ath_hal_getdefantenna(_ah) \
00419 ((*(_ah)->ah_getDefAntenna)((_ah)))
00420 #define ath_hal_setdefantenna(_ah, _ant) \
00421 ((*(_ah)->ah_setDefAntenna)((_ah), (_ant)))
00422 #define ath_hal_rxmonitor(_ah, _arg) \
00423 ((*(_ah)->ah_rxMonitor)((_ah), (_arg)))
00424 #define ath_hal_mibevent(_ah, _stats) \
00425 ((*(_ah)->ah_procMibEvent)((_ah), (_stats)))
00426 #define ath_hal_setslottime(_ah, _us) \
00427 ((*(_ah)->ah_setSlotTime)((_ah), (_us)))
00428 #define ath_hal_getslottime(_ah) \
00429 ((*(_ah)->ah_getSlotTime)((_ah)))
00430 #define ath_hal_setacktimeout(_ah, _us) \
00431 ((*(_ah)->ah_setAckTimeout)((_ah), (_us)))
00432 #define ath_hal_getacktimeout(_ah) \
00433 ((*(_ah)->ah_getAckTimeout)((_ah)))
00434 #define ath_hal_setctstimeout(_ah, _us) \
00435 ((*(_ah)->ah_setCTSTimeout)((_ah), (_us)))
00436 #define ath_hal_getctstimeout(_ah) \
00437 ((*(_ah)->ah_getCTSTimeout)((_ah)))
00438 #define ath_hal_getcapability(_ah, _cap, _param, _result) \
00439 ((*(_ah)->ah_getCapability)((_ah), (_cap), (_param), (_result)))
00440 #define ath_hal_setcapability(_ah, _cap, _param, _v, _status) \
00441 ((*(_ah)->ah_setCapability)((_ah), (_cap), (_param), (_v), (_status)))
00442 #define ath_hal_ciphersupported(_ah, _cipher) \
00443 (ath_hal_getcapability(_ah, HAL_CAP_CIPHER, _cipher, NULL) == HAL_OK)
00444 #define ath_hal_getregdomain(_ah, _prd) \
00445 ath_hal_getcapability(_ah, HAL_CAP_REG_DMN, 0, (_prd))
00446 #define ath_hal_getcountrycode(_ah, _pcc) \
00447 (*(_pcc) = (_ah)->ah_countryCode)
00448 #define ath_hal_tkipsplit(_ah) \
00449 (ath_hal_getcapability(_ah, HAL_CAP_TKIP_SPLIT, 0, NULL) == HAL_OK)
00450 #define ath_hal_hwphycounters(_ah) \
00451 (ath_hal_getcapability(_ah, HAL_CAP_PHYCOUNTERS, 0, NULL) == HAL_OK)
00452 #define ath_hal_hasdiversity(_ah) \
00453 (ath_hal_getcapability(_ah, HAL_CAP_DIVERSITY, 0, NULL) == HAL_OK)
00454 #define ath_hal_getdiversity(_ah) \
00455 (ath_hal_getcapability(_ah, HAL_CAP_DIVERSITY, 1, NULL) == HAL_OK)
00456 #define ath_hal_setdiversity(_ah, _v) \
00457 ath_hal_setcapability(_ah, HAL_CAP_DIVERSITY, 1, _v, NULL)
00458
00459 #define ath_hal_setuprxdesc(_ah, _ds, _size, _intreq) \
00460 ((*(_ah)->ah_setupRxDesc)((_ah), (_ds), (_size), (_intreq)))
00461 #define ath_hal_rxprocdesc(_ah, _ds, _dspa, _dsnext) \
00462 ((*(_ah)->ah_procRxDesc)((_ah), (_ds), (_dspa), (_dsnext)))
00463 #define ath_hal_setuptxdesc(_ah, _ds, _plen, _hlen, _atype, _txpow, \
00464 _txr0, _txtr0, _keyix, _ant, _flags, \
00465 _rtsrate, _rtsdura) \
00466 ((*(_ah)->ah_setupTxDesc)((_ah), (_ds), (_plen), (_hlen), (_atype), \
00467 (_txpow), (_txr0), (_txtr0), (_keyix), (_ant), \
00468 (_flags), (_rtsrate), (_rtsdura)))
00469 #define ath_hal_setupxtxdesc(_ah, _ds, \
00470 _txr1, _txtr1, _txr2, _txtr2, _txr3, _txtr3) \
00471 ((*(_ah)->ah_setupXTxDesc)((_ah), (_ds), \
00472 (_txr1), (_txtr1), (_txr2), (_txtr2), (_txr3), (_txtr3)))
00473 #define ath_hal_filltxdesc(_ah, _ds, _l, _first, _last, _ds0) \
00474 ((*(_ah)->ah_fillTxDesc)((_ah), (_ds), (_l), (_first), (_last), (_ds0)))
00475 #define ath_hal_txprocdesc(_ah, _ds) \
00476 ((*(_ah)->ah_procTxDesc)((_ah), (_ds)))
00477
00478 #define ath_hal_gpioCfgOutput(_ah, _gpio) \
00479 ((*(_ah)->ah_gpioCfgOutput)((_ah), (_gpio)))
00480 #define ath_hal_gpioset(_ah, _gpio, _b) \
00481 ((*(_ah)->ah_gpioSet)((_ah), (_gpio), (_b)))
00482
00483 #define ath_hal_settxpowerlimit(_ah, _int) \
00484 ((*(_ah)->ah_setTxPowerLimit)((_ah), (_int)))
00485
00486 #endif