Initial import of ath(4) from FreeBSD.
This commit is contained in:
parent
25ce730b93
commit
38004be968
File diff suppressed because it is too large
Load Diff
|
@ -0,0 +1,129 @@
|
|||
/*-
|
||||
* Copyright (c) 2002, 2003 Sam Leffler, Errno Consulting
|
||||
* All rights reserved.
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without
|
||||
* modification, are permitted provided that the following conditions
|
||||
* are met:
|
||||
* 1. Redistributions of source code must retain the above copyright
|
||||
* notice, this list of conditions and the following disclaimer,
|
||||
* without modification.
|
||||
* 2. Redistributions in binary form must reproduce at minimum a disclaimer
|
||||
* similar to the "NO WARRANTY" disclaimer below ("Disclaimer") and any
|
||||
* redistribution must be conditioned upon including a substantially
|
||||
* similar Disclaimer requirement for further binary redistribution.
|
||||
* 3. Neither the names of the above-listed copyright holders nor the names
|
||||
* of any contributors may be used to endorse or promote products derived
|
||||
* from this software without specific prior written permission.
|
||||
*
|
||||
* Alternatively, this software may be distributed under the terms of the
|
||||
* GNU General Public License ("GPL") version 2 as published by the Free
|
||||
* Software Foundation.
|
||||
*
|
||||
* NO WARRANTY
|
||||
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
|
||||
* ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
|
||||
* LIMITED TO, THE IMPLIED WARRANTIES OF NONINFRINGEMENT, MERCHANTIBILITY
|
||||
* AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL
|
||||
* THE COPYRIGHT HOLDERS OR CONTRIBUTORS BE LIABLE FOR SPECIAL, EXEMPLARY,
|
||||
* OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
|
||||
* SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
|
||||
* INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER
|
||||
* IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
|
||||
* ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF
|
||||
* THE POSSIBILITY OF SUCH DAMAGES.
|
||||
*
|
||||
* $FreeBSD: src/sys/dev/ath/if_athioctl.h,v 1.3 2003/09/05 22:22:49 sam Exp $
|
||||
*/
|
||||
|
||||
/*
|
||||
* Ioctl-related defintions for the Atheros Wireless LAN controller driver.
|
||||
*/
|
||||
#ifndef _DEV_ATH_ATHIOCTL_H
|
||||
#define _DEV_ATH_ATHIOCTL_H
|
||||
|
||||
struct ath_stats {
|
||||
u_int32_t ast_watchdog; /* device reset by watchdog */
|
||||
u_int32_t ast_hardware; /* fatal hardware error interrupts */
|
||||
u_int32_t ast_bmiss; /* beacon miss interrupts */
|
||||
u_int32_t ast_rxorn; /* rx overrun interrupts */
|
||||
u_int32_t ast_rxeol; /* rx eol interrupts */
|
||||
u_int32_t ast_txurn; /* tx underrun interrupts */
|
||||
u_int32_t ast_intrcoal; /* interrupts coalesced */
|
||||
u_int32_t ast_tx_mgmt; /* management frames transmitted */
|
||||
u_int32_t ast_tx_discard; /* frames discarded prior to assoc */
|
||||
u_int32_t ast_tx_qstop; /* output stopped 'cuz no buffer */
|
||||
u_int32_t ast_tx_encap; /* tx encapsulation failed */
|
||||
u_int32_t ast_tx_nonode; /* tx failed 'cuz no node */
|
||||
u_int32_t ast_tx_nombuf; /* tx failed 'cuz no mbuf */
|
||||
u_int32_t ast_tx_nomcl; /* tx failed 'cuz no cluster */
|
||||
u_int32_t ast_tx_linear; /* tx linearized to cluster */
|
||||
u_int32_t ast_tx_nodata; /* tx discarded empty frame */
|
||||
u_int32_t ast_tx_busdma; /* tx failed for dma resrcs */
|
||||
u_int32_t ast_tx_xretries;/* tx failed 'cuz too many retries */
|
||||
u_int32_t ast_tx_fifoerr; /* tx failed 'cuz FIFO underrun */
|
||||
u_int32_t ast_tx_filtered;/* tx failed 'cuz xmit filtered */
|
||||
u_int32_t ast_tx_shortretry;/* tx on-chip retries (short) */
|
||||
u_int32_t ast_tx_longretry;/* tx on-chip retries (long) */
|
||||
u_int32_t ast_tx_badrate; /* tx failed 'cuz bogus xmit rate */
|
||||
u_int32_t ast_tx_noack; /* tx frames with no ack marked */
|
||||
u_int32_t ast_tx_rts; /* tx frames with rts enabled */
|
||||
u_int32_t ast_tx_cts; /* tx frames with cts enabled */
|
||||
u_int32_t ast_tx_shortpre;/* tx frames with short preamble */
|
||||
u_int32_t ast_rx_nombuf; /* rx setup failed 'cuz no mbuf */
|
||||
u_int32_t ast_rx_busdma; /* rx setup failed for dma resrcs */
|
||||
u_int32_t ast_rx_orn; /* rx failed 'cuz of desc overrun */
|
||||
u_int32_t ast_rx_crcerr; /* rx failed 'cuz of bad CRC */
|
||||
u_int32_t ast_rx_fifoerr; /* rx failed 'cuz of FIFO overrun */
|
||||
u_int32_t ast_rx_badcrypt;/* rx failed 'cuz decryption */
|
||||
u_int32_t ast_rx_phyerr; /* rx failed 'cuz of PHY err */
|
||||
u_int32_t ast_rx_phy[32]; /* rx PHY error per-code counts */
|
||||
u_int32_t ast_rx_tooshort;/* rx discarded 'cuz frame too short */
|
||||
u_int32_t ast_rx_ctl; /* rx discarded 'cuz ctl frame */
|
||||
u_int32_t ast_be_nombuf; /* beacon setup failed 'cuz no mbuf */
|
||||
u_int32_t ast_per_cal; /* periodic calibration calls */
|
||||
u_int32_t ast_per_calfail;/* periodic calibration failed */
|
||||
u_int32_t ast_per_rfgain; /* periodic calibration rfgain reset */
|
||||
u_int32_t ast_rate_calls; /* rate control checks */
|
||||
u_int32_t ast_rate_raise; /* rate control raised xmit rate */
|
||||
u_int32_t ast_rate_drop; /* rate control dropped xmit rate */
|
||||
};
|
||||
|
||||
#define SIOCGATHSTATS _IOWR('i', 137, struct ifreq)
|
||||
|
||||
/*
|
||||
* Radio capture format.
|
||||
*/
|
||||
#define ATH_RX_RADIOTAP_PRESENT ( \
|
||||
(1 << IEEE80211_RADIOTAP_FLAGS) | \
|
||||
(1 << IEEE80211_RADIOTAP_RATE) | \
|
||||
(1 << IEEE80211_RADIOTAP_CHANNEL) | \
|
||||
(1 << IEEE80211_RADIOTAP_DB_ANTSIGNAL) | \
|
||||
(1 << IEEE80211_RADIOTAP_ANTENNA) | \
|
||||
0)
|
||||
|
||||
struct ath_rx_radiotap_header {
|
||||
struct ieee80211_radiotap_header wr_ihdr;
|
||||
u_int8_t wr_flags; /* XXX for padding */
|
||||
u_int8_t wr_rate;
|
||||
u_int16_t wr_chan_freq;
|
||||
u_int16_t wr_chan_flags;
|
||||
u_int8_t wr_antsignal;
|
||||
u_int8_t wr_antenna;
|
||||
};
|
||||
|
||||
#define ATH_TX_RADIOTAP_PRESENT ( \
|
||||
(1 << IEEE80211_RADIOTAP_FLAGS) | \
|
||||
(1 << IEEE80211_RADIOTAP_RATE) | \
|
||||
(1 << IEEE80211_RADIOTAP_CHANNEL) | \
|
||||
0)
|
||||
|
||||
struct ath_tx_radiotap_header {
|
||||
struct ieee80211_radiotap_header wt_ihdr;
|
||||
u_int8_t wt_flags; /* XXX for padding */
|
||||
u_int8_t wt_rate;
|
||||
u_int16_t wt_chan_freq;
|
||||
u_int16_t wt_chan_flags;
|
||||
};
|
||||
|
||||
#endif /* _DEV_ATH_ATHIOCTL_H */
|
|
@ -0,0 +1,285 @@
|
|||
/*-
|
||||
* Copyright (c) 2002, 2003 Sam Leffler, Errno Consulting
|
||||
* All rights reserved.
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without
|
||||
* modification, are permitted provided that the following conditions
|
||||
* are met:
|
||||
* 1. Redistributions of source code must retain the above copyright
|
||||
* notice, this list of conditions and the following disclaimer,
|
||||
* without modification.
|
||||
* 2. Redistributions in binary form must reproduce at minimum a disclaimer
|
||||
* similar to the "NO WARRANTY" disclaimer below ("Disclaimer") and any
|
||||
* redistribution must be conditioned upon including a substantially
|
||||
* similar Disclaimer requirement for further binary redistribution.
|
||||
* 3. Neither the names of the above-listed copyright holders nor the names
|
||||
* of any contributors may be used to endorse or promote products derived
|
||||
* from this software without specific prior written permission.
|
||||
*
|
||||
* Alternatively, this software may be distributed under the terms of the
|
||||
* GNU General Public License ("GPL") version 2 as published by the Free
|
||||
* Software Foundation.
|
||||
*
|
||||
* NO WARRANTY
|
||||
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
|
||||
* ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
|
||||
* LIMITED TO, THE IMPLIED WARRANTIES OF NONINFRINGEMENT, MERCHANTIBILITY
|
||||
* AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL
|
||||
* THE COPYRIGHT HOLDERS OR CONTRIBUTORS BE LIABLE FOR SPECIAL, EXEMPLARY,
|
||||
* OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
|
||||
* SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
|
||||
* INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER
|
||||
* IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
|
||||
* ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF
|
||||
* THE POSSIBILITY OF SUCH DAMAGES.
|
||||
*
|
||||
* $FreeBSD: src/sys/dev/ath/if_athvar.h,v 1.6 2003/09/05 22:22:49 sam Exp $
|
||||
*/
|
||||
|
||||
/*
|
||||
* Defintions for the Atheros Wireless LAN controller driver.
|
||||
*/
|
||||
#ifndef _DEV_ATH_ATHVAR_H
|
||||
#define _DEV_ATH_ATHVAR_H
|
||||
|
||||
#include <sys/taskqueue.h>
|
||||
|
||||
#include <contrib/dev/ath/ah.h>
|
||||
#include <net80211/ieee80211_radiotap.h>
|
||||
#include <dev/ath/if_athioctl.h>
|
||||
|
||||
#define ATH_TIMEOUT 1000
|
||||
|
||||
#define ATH_RXBUF 40 /* number of RX buffers */
|
||||
#define ATH_TXBUF 60 /* number of TX buffers */
|
||||
#define ATH_TXDESC 8 /* number of descriptors per buffer */
|
||||
|
||||
/* driver-specific node */
|
||||
struct ath_node {
|
||||
struct ieee80211_node an_node; /* base class */
|
||||
u_int an_tx_ok; /* tx ok pkt */
|
||||
u_int an_tx_err; /* tx !ok pkt */
|
||||
u_int an_tx_retr; /* tx retry count */
|
||||
int an_tx_upper; /* tx upper rate req cnt */
|
||||
u_int an_tx_antenna; /* antenna for last good frame */
|
||||
u_int an_rx_antenna; /* antenna for last rcvd frame */
|
||||
};
|
||||
#define ATH_NODE(_n) ((struct ath_node *)(_n))
|
||||
|
||||
struct ath_buf {
|
||||
TAILQ_ENTRY(ath_buf) bf_list;
|
||||
int bf_nseg;
|
||||
bus_dmamap_t bf_dmamap; /* DMA map of the buffer */
|
||||
struct ath_desc *bf_desc; /* virtual addr of desc */
|
||||
bus_addr_t bf_daddr; /* physical addr of desc */
|
||||
struct mbuf *bf_m; /* mbuf for buf */
|
||||
struct ieee80211_node *bf_node; /* pointer to the node */
|
||||
bus_size_t bf_mapsize;
|
||||
#define ATH_MAX_SCATTER 64
|
||||
bus_dma_segment_t bf_segs[ATH_MAX_SCATTER];
|
||||
};
|
||||
|
||||
struct ath_softc {
|
||||
struct ieee80211com sc_ic; /* IEEE 802.11 common */
|
||||
int (*sc_newstate)(struct ieee80211com *,
|
||||
enum ieee80211_state, int);
|
||||
device_t sc_dev;
|
||||
bus_space_tag_t sc_st; /* bus space tag */
|
||||
bus_space_handle_t sc_sh; /* bus space handle */
|
||||
bus_dma_tag_t sc_dmat; /* bus DMA tag */
|
||||
struct mtx sc_mtx; /* master lock (recursive) */
|
||||
struct ath_hal *sc_ah; /* Atheros HAL */
|
||||
unsigned int sc_invalid : 1,/* disable hardware accesses */
|
||||
sc_have11g : 1,/* have 11g support */
|
||||
sc_doani : 1,/* dynamic noise immunity */
|
||||
sc_probing : 1;/* probing AP on beacon miss */
|
||||
/* rate tables */
|
||||
const HAL_RATE_TABLE *sc_rates[IEEE80211_MODE_MAX];
|
||||
const HAL_RATE_TABLE *sc_currates; /* current rate table */
|
||||
enum ieee80211_phymode sc_curmode; /* current phy mode */
|
||||
u_int8_t sc_rixmap[256]; /* IEEE to h/w rate table ix */
|
||||
u_int8_t sc_hwmap[32]; /* h/w rate ix to IEEE table */
|
||||
HAL_INT sc_imask; /* interrupt mask copy */
|
||||
|
||||
struct bpf_if *sc_drvbpf;
|
||||
union {
|
||||
struct ath_tx_radiotap_header th;
|
||||
u_int8_t pad[64];
|
||||
} u_tx_rt;
|
||||
union {
|
||||
struct ath_rx_radiotap_header th;
|
||||
u_int8_t pad[64];
|
||||
} u_rx_rt;
|
||||
|
||||
struct ath_desc *sc_desc; /* TX/RX descriptors */
|
||||
bus_dma_segment_t sc_dseg;
|
||||
bus_dmamap_t sc_ddmamap; /* DMA map for descriptors */
|
||||
bus_addr_t sc_desc_paddr; /* physical addr of sc_desc */
|
||||
bus_addr_t sc_desc_len; /* size of sc_desc */
|
||||
|
||||
struct task sc_fataltask; /* fatal int processing */
|
||||
struct task sc_rxorntask; /* rxorn int processing */
|
||||
|
||||
TAILQ_HEAD(, ath_buf) sc_rxbuf; /* receive buffer */
|
||||
u_int32_t *sc_rxlink; /* link ptr in last RX desc */
|
||||
struct task sc_rxtask; /* rx int processing */
|
||||
|
||||
u_int sc_txhalq; /* HAL q for outgoing frames */
|
||||
u_int32_t *sc_txlink; /* link ptr in last TX desc */
|
||||
int sc_tx_timer; /* transmit timeout */
|
||||
TAILQ_HEAD(, ath_buf) sc_txbuf; /* transmit buffer */
|
||||
struct mtx sc_txbuflock; /* txbuf lock */
|
||||
TAILQ_HEAD(, ath_buf) sc_txq; /* transmitting queue */
|
||||
struct mtx sc_txqlock; /* lock on txq and txlink */
|
||||
struct task sc_txtask; /* tx int processing */
|
||||
|
||||
u_int sc_bhalq; /* HAL q for outgoing beacons */
|
||||
struct ath_buf *sc_bcbuf; /* beacon buffer */
|
||||
struct ath_buf *sc_bufptr; /* allocated buffer ptr */
|
||||
struct task sc_swbatask; /* swba int processing */
|
||||
struct task sc_bmisstask; /* bmiss int processing */
|
||||
|
||||
struct callout sc_cal_ch; /* callout handle for cals */
|
||||
struct callout sc_scan_ch; /* callout handle for scan */
|
||||
struct ath_stats sc_stats; /* interface statistics */
|
||||
};
|
||||
#define sc_tx_th u_tx_rt.th
|
||||
#define sc_rx_th u_rx_rt.th
|
||||
|
||||
int ath_attach(u_int16_t, struct ath_softc *);
|
||||
int ath_detach(struct ath_softc *);
|
||||
void ath_resume(struct ath_softc *);
|
||||
void ath_suspend(struct ath_softc *);
|
||||
void ath_shutdown(struct ath_softc *);
|
||||
void ath_intr(void *);
|
||||
|
||||
/*
|
||||
* HAL definitions to comply with local coding convention.
|
||||
*/
|
||||
#define ath_hal_reset(_ah, _opmode, _chan, _outdoor, _pstatus) \
|
||||
((*(_ah)->ah_reset)((_ah), (_opmode), (_chan), (_outdoor), (_pstatus)))
|
||||
#define ath_hal_getratetable(_ah, _mode) \
|
||||
((*(_ah)->ah_getRateTable)((_ah), (_mode)))
|
||||
#define ath_hal_getregdomain(_ah) \
|
||||
((*(_ah)->ah_getRegDomain)((_ah)))
|
||||
#define ath_hal_getcountrycode(_ah) (_ah)->ah_countryCode
|
||||
#define ath_hal_getmac(_ah, _mac) \
|
||||
((*(_ah)->ah_getMacAddress)((_ah), (_mac)))
|
||||
#define ath_hal_detach(_ah) \
|
||||
((*(_ah)->ah_detach)((_ah)))
|
||||
#define ath_hal_intrset(_ah, _mask) \
|
||||
((*(_ah)->ah_setInterrupts)((_ah), (_mask)))
|
||||
#define ath_hal_intrget(_ah) \
|
||||
((*(_ah)->ah_getInterrupts)((_ah)))
|
||||
#define ath_hal_intrpend(_ah) \
|
||||
((*(_ah)->ah_isInterruptPending)((_ah)))
|
||||
#define ath_hal_getisr(_ah, _pmask) \
|
||||
((*(_ah)->ah_getPendingInterrupts)((_ah), (_pmask)))
|
||||
#define ath_hal_updatetxtriglevel(_ah, _inc) \
|
||||
((*(_ah)->ah_updateTxTrigLevel)((_ah), (_inc)))
|
||||
#define ath_hal_setpower(_ah, _mode, _sleepduration) \
|
||||
((*(_ah)->ah_setPowerMode)((_ah), (_mode), AH_TRUE, (_sleepduration)))
|
||||
#define ath_hal_keyreset(_ah, _ix) \
|
||||
((*(_ah)->ah_resetKeyCacheEntry)((_ah), (_ix)))
|
||||
#define ath_hal_keyset(_ah, _ix, _pk) \
|
||||
((*(_ah)->ah_setKeyCacheEntry)((_ah), (_ix), (_pk), NULL, AH_FALSE))
|
||||
#define ath_hal_keyisvalid(_ah, _ix) \
|
||||
(((*(_ah)->ah_isKeyCacheEntryValid)((_ah), (_ix))))
|
||||
#define ath_hal_keysetmac(_ah, _ix, _mac) \
|
||||
((*(_ah)->ah_setKeyCacheEntryMac)((_ah), (_ix), (_mac)))
|
||||
#define ath_hal_getrxfilter(_ah) \
|
||||
((*(_ah)->ah_getRxFilter)((_ah)))
|
||||
#define ath_hal_setrxfilter(_ah, _filter) \
|
||||
((*(_ah)->ah_setRxFilter)((_ah), (_filter)))
|
||||
#define ath_hal_setmcastfilter(_ah, _mfilt0, _mfilt1) \
|
||||
((*(_ah)->ah_setMulticastFilter)((_ah), (_mfilt0), (_mfilt1)))
|
||||
#define ath_hal_waitforbeacon(_ah, _bf) \
|
||||
((*(_ah)->ah_waitForBeaconDone)((_ah), (_bf)->bf_daddr))
|
||||
#define ath_hal_putrxbuf(_ah, _bufaddr) \
|
||||
((*(_ah)->ah_setRxDP)((_ah), (_bufaddr)))
|
||||
#define ath_hal_gettsf32(_ah) \
|
||||
((*(_ah)->ah_getTsf32)((_ah)))
|
||||
#define ath_hal_gettsf64(_ah) \
|
||||
((*(_ah)->ah_getTsf64)((_ah)))
|
||||
#define ath_hal_resettsf(_ah) \
|
||||
((*(_ah)->ah_resetTsf)((_ah)))
|
||||
#define ath_hal_rxena(_ah) \
|
||||
((*(_ah)->ah_enableReceive)((_ah)))
|
||||
#define ath_hal_puttxbuf(_ah, _q, _bufaddr) \
|
||||
((*(_ah)->ah_setTxDP)((_ah), (_q), (_bufaddr)))
|
||||
#define ath_hal_gettxbuf(_ah, _q) \
|
||||
((*(_ah)->ah_getTxDP)((_ah), (_q)))
|
||||
#define ath_hal_getrxbuf(_ah) \
|
||||
((*(_ah)->ah_getRxDP)((_ah)))
|
||||
#define ath_hal_txstart(_ah, _q) \
|
||||
((*(_ah)->ah_startTxDma)((_ah), (_q)))
|
||||
#define ath_hal_setchannel(_ah, _chan) \
|
||||
((*(_ah)->ah_setChannel)((_ah), (_chan)))
|
||||
#define ath_hal_calibrate(_ah, _chan) \
|
||||
((*(_ah)->ah_perCalibration)((_ah), (_chan)))
|
||||
#define ath_hal_setledstate(_ah, _state) \
|
||||
((*(_ah)->ah_setLedState)((_ah), (_state)))
|
||||
#define ath_hal_beaconinit(_ah, _opmode, _nextb, _bperiod) \
|
||||
((*(_ah)->ah_beaconInit)((_ah), (_opmode), (_nextb), (_bperiod)))
|
||||
#define ath_hal_beaconreset(_ah) \
|
||||
((*(_ah)->ah_resetStationBeaconTimers)((_ah)))
|
||||
#define ath_hal_beacontimers(_ah, _bs, _tsf, _dc, _cc) \
|
||||
((*(_ah)->ah_setStationBeaconTimers)((_ah), (_bs), (_tsf), \
|
||||
(_dc), (_cc)))
|
||||
#define ath_hal_setassocid(_ah, _bss, _associd) \
|
||||
((*(_ah)->ah_writeAssocid)((_ah), (_bss), (_associd), 0))
|
||||
#define ath_hal_setopmode(_ah, _opmode) \
|
||||
((*(_ah)->ah_setPCUConfig)((_ah), (_opmode)))
|
||||
#define ath_hal_stoptxdma(_ah, _qnum) \
|
||||
((*(_ah)->ah_stopTxDma)((_ah), (_qnum)))
|
||||
#define ath_hal_stoppcurecv(_ah) \
|
||||
((*(_ah)->ah_stopPcuReceive)((_ah)))
|
||||
#define ath_hal_startpcurecv(_ah) \
|
||||
((*(_ah)->ah_startPcuReceive)((_ah)))
|
||||
#define ath_hal_stopdmarecv(_ah) \
|
||||
((*(_ah)->ah_stopDmaReceive)((_ah)))
|
||||
#define ath_hal_dumpstate(_ah) \
|
||||
((*(_ah)->ah_dumpState)((_ah)))
|
||||
#define ath_hal_dumpeeprom(_ah) \
|
||||
((*(_ah)->ah_dumpEeprom)((_ah)))
|
||||
#define ath_hal_dumprfgain(_ah) \
|
||||
((*(_ah)->ah_dumpRfGain)((_ah)))
|
||||
#define ath_hal_dumpani(_ah) \
|
||||
((*(_ah)->ah_dumpAni)((_ah)))
|
||||
#define ath_hal_setuptxqueue(_ah, _type, _irq) \
|
||||
((*(_ah)->ah_setupTxQueue)((_ah), (_type), (_irq)))
|
||||
#define ath_hal_resettxqueue(_ah, _q) \
|
||||
((*(_ah)->ah_resetTxQueue)((_ah), (_q)))
|
||||
#define ath_hal_releasetxqueue(_ah, _q) \
|
||||
((*(_ah)->ah_releaseTxQueue)((_ah), (_q)))
|
||||
#define ath_hal_hasveol(_ah) \
|
||||
((*(_ah)->ah_hasVEOL)((_ah)))
|
||||
#define ath_hal_getrfgain(_ah) \
|
||||
((*(_ah)->ah_getRfGain)((_ah)))
|
||||
#define ath_hal_rxmonitor(_ah) \
|
||||
((*(_ah)->ah_rxMonitor)((_ah)))
|
||||
|
||||
#define ath_hal_setupbeacondesc(_ah, _ds, _opmode, _flen, _hlen, \
|
||||
_rate, _antmode) \
|
||||
((*(_ah)->ah_setupBeaconDesc)((_ah), (_ds), (_opmode), \
|
||||
(_flen), (_hlen), (_rate), (_antmode)))
|
||||
#define ath_hal_setuprxdesc(_ah, _ds, _size, _intreq) \
|
||||
((*(_ah)->ah_setupRxDesc)((_ah), (_ds), (_size), (_intreq)))
|
||||
#define ath_hal_rxprocdesc(_ah, _ds) \
|
||||
((*(_ah)->ah_procRxDesc)((_ah), (_ds)))
|
||||
#define ath_hal_setuptxdesc(_ah, _ds, _plen, _hlen, _atype, _txpow, \
|
||||
_txr0, _txtr0, _keyix, _ant, _flags, \
|
||||
_rtsrate, _rtsdura) \
|
||||
((*(_ah)->ah_setupTxDesc)((_ah), (_ds), (_plen), (_hlen), (_atype), \
|
||||
(_txpow), (_txr0), (_txtr0), (_keyix), (_ant), \
|
||||
(_flags), (_rtsrate), (_rtsdura)))
|
||||
#define ath_hal_setupxtxdesc(_ah, _ds, _short, \
|
||||
_txr1, _txtr1, _txr2, _txtr2, _txr3, _txtr3) \
|
||||
((*(_ah)->ah_setupXTxDesc)((_ah), (_ds), (_short), \
|
||||
(_txr1), (_txtr1), (_txr2), (_txtr2), (_txr3), (_txtr3)))
|
||||
#define ath_hal_filltxdesc(_ah, _ds, _l, _first, _last) \
|
||||
((*(_ah)->ah_fillTxDesc)((_ah), (_ds), (_l), (_first), (_last)))
|
||||
#define ath_hal_txprocdesc(_ah, _ds) \
|
||||
((*(_ah)->ah_procTxDesc)((_ah), (_ds)))
|
||||
|
||||
#endif /* _DEV_ATH_ATHVAR_H */
|
|
@ -0,0 +1,303 @@
|
|||
/*-
|
||||
* Copyright (c) 2002, 2003 Sam Leffler, Errno Consulting
|
||||
* All rights reserved.
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without
|
||||
* modification, are permitted provided that the following conditions
|
||||
* are met:
|
||||
* 1. Redistributions of source code must retain the above copyright
|
||||
* notice, this list of conditions and the following disclaimer,
|
||||
* without modification.
|
||||
* 2. Redistributions in binary form must reproduce at minimum a disclaimer
|
||||
* similar to the "NO WARRANTY" disclaimer below ("Disclaimer") and any
|
||||
* redistribution must be conditioned upon including a substantially
|
||||
* similar Disclaimer requirement for further binary redistribution.
|
||||
* 3. Neither the names of the above-listed copyright holders nor the names
|
||||
* of any contributors may be used to endorse or promote products derived
|
||||
* from this software without specific prior written permission.
|
||||
*
|
||||
* Alternatively, this software may be distributed under the terms of the
|
||||
* GNU General Public License ("GPL") version 2 as published by the Free
|
||||
* Software Foundation.
|
||||
*
|
||||
* NO WARRANTY
|
||||
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
|
||||
* ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
|
||||
* LIMITED TO, THE IMPLIED WARRANTIES OF NONINFRINGEMENT, MERCHANTIBILITY
|
||||
* AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL
|
||||
* THE COPYRIGHT HOLDERS OR CONTRIBUTORS BE LIABLE FOR SPECIAL, EXEMPLARY,
|
||||
* OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
|
||||
* SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
|
||||
* INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER
|
||||
* IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
|
||||
* ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF
|
||||
* THE POSSIBILITY OF SUCH DAMAGES.
|
||||
*/
|
||||
|
||||
#include <sys/cdefs.h>
|
||||
__FBSDID("$FreeBSD: src/sys/dev/ath/if_ath_pci.c,v 1.3 2003/08/13 21:29:35 sam Exp $");
|
||||
|
||||
/*
|
||||
* PCI/Cardbus front-end for the Atheros Wireless LAN controller driver.
|
||||
*/
|
||||
|
||||
#include "opt_inet.h"
|
||||
|
||||
#include <sys/param.h>
|
||||
#include <sys/systm.h>
|
||||
#include <sys/mbuf.h>
|
||||
#include <sys/malloc.h>
|
||||
#include <sys/module.h>
|
||||
#include <sys/kernel.h>
|
||||
#include <sys/lock.h>
|
||||
#include <sys/mutex.h>
|
||||
#include <sys/socket.h>
|
||||
#include <sys/sockio.h>
|
||||
#include <sys/errno.h>
|
||||
|
||||
#include <machine/bus.h>
|
||||
#include <machine/resource.h>
|
||||
#include <sys/bus.h>
|
||||
#include <sys/rman.h>
|
||||
|
||||
#include <net/if.h>
|
||||
#include <net/if_dl.h>
|
||||
#include <net/if_media.h>
|
||||
#include <net/ethernet.h>
|
||||
#include <net/if_llc.h>
|
||||
#include <net/if_arp.h>
|
||||
|
||||
#include <net80211/ieee80211.h>
|
||||
#include <net80211/ieee80211_crypto.h>
|
||||
#include <net80211/ieee80211_node.h>
|
||||
#include <net80211/ieee80211_proto.h>
|
||||
#include <net80211/ieee80211_var.h>
|
||||
|
||||
#ifdef INET
|
||||
#include <netinet/in.h>
|
||||
#include <netinet/if_ether.h>
|
||||
#endif
|
||||
|
||||
#include <dev/ath/if_athvar.h>
|
||||
#include <contrib/dev/ath/ah.h>
|
||||
|
||||
#include <dev/pci/pcivar.h>
|
||||
#include <dev/pci/pcireg.h>
|
||||
|
||||
/*
|
||||
* PCI glue.
|
||||
*/
|
||||
|
||||
struct ath_pci_softc {
|
||||
struct ath_softc sc_sc;
|
||||
struct resource *sc_sr; /* memory resource */
|
||||
struct resource *sc_irq; /* irq resource */
|
||||
void *sc_ih; /* intererupt handler */
|
||||
u_int8_t sc_saved_intline;
|
||||
u_int8_t sc_saved_cachelinesz;
|
||||
u_int8_t sc_saved_lattimer;
|
||||
};
|
||||
|
||||
#define BS_BAR 0x10
|
||||
|
||||
static int
|
||||
ath_pci_probe(device_t dev)
|
||||
{
|
||||
const char* devname;
|
||||
|
||||
devname = ath_hal_probe(pci_get_vendor(dev), pci_get_device(dev));
|
||||
if (devname) {
|
||||
device_set_desc(dev, devname);
|
||||
return 0;
|
||||
}
|
||||
return ENXIO;
|
||||
}
|
||||
|
||||
static int
|
||||
ath_pci_attach(device_t dev)
|
||||
{
|
||||
struct ath_pci_softc *psc = device_get_softc(dev);
|
||||
struct ath_softc *sc = &psc->sc_sc;
|
||||
u_int32_t cmd;
|
||||
int error = ENXIO;
|
||||
int rid;
|
||||
|
||||
bzero(psc, sizeof (*psc));
|
||||
sc->sc_dev = dev;
|
||||
|
||||
cmd = pci_read_config(dev, PCIR_COMMAND, 4);
|
||||
cmd |= PCIM_CMD_MEMEN | PCIM_CMD_BUSMASTEREN;
|
||||
pci_write_config(dev, PCIR_COMMAND, cmd, 4);
|
||||
cmd = pci_read_config(dev, PCIR_COMMAND, 4);
|
||||
|
||||
if ((cmd & PCIM_CMD_MEMEN) == 0) {
|
||||
device_printf(dev, "failed to enable memory mapping\n");
|
||||
goto bad;
|
||||
}
|
||||
|
||||
if ((cmd & PCIM_CMD_BUSMASTEREN) == 0) {
|
||||
device_printf(dev, "failed to enable bus mastering\n");
|
||||
goto bad;
|
||||
}
|
||||
|
||||
/*
|
||||
* Setup memory-mapping of PCI registers.
|
||||
*/
|
||||
rid = BS_BAR;
|
||||
psc->sc_sr = bus_alloc_resource(dev, SYS_RES_MEMORY, &rid,
|
||||
0, ~0, 1, RF_ACTIVE);
|
||||
if (psc->sc_sr == NULL) {
|
||||
device_printf(dev, "cannot map register space\n");
|
||||
goto bad;
|
||||
}
|
||||
sc->sc_st = rman_get_bustag(psc->sc_sr);
|
||||
sc->sc_sh = rman_get_bushandle(psc->sc_sr);
|
||||
/*
|
||||
* Mark device invalid so any interrupts (shared or otherwise)
|
||||
* that arrive before the HAL is setup are discarded.
|
||||
*/
|
||||
sc->sc_invalid = 1;
|
||||
|
||||
/*
|
||||
* Arrange interrupt line.
|
||||
*/
|
||||
rid = 0;
|
||||
psc->sc_irq = bus_alloc_resource(dev, SYS_RES_IRQ, &rid,
|
||||
0, ~0, 1, RF_SHAREABLE|RF_ACTIVE);
|
||||
if (psc->sc_irq == NULL) {
|
||||
device_printf(dev, "could not map interrupt\n");
|
||||
goto bad1;
|
||||
}
|
||||
if (bus_setup_intr(dev, psc->sc_irq,
|
||||
INTR_TYPE_NET | INTR_MPSAFE,
|
||||
ath_intr, sc, &psc->sc_ih)) {
|
||||
device_printf(dev, "could not establish interrupt\n");
|
||||
goto bad2;
|
||||
}
|
||||
|
||||
/*
|
||||
* Setup DMA descriptor area.
|
||||
*/
|
||||
if (bus_dma_tag_create(NULL, /* parent */
|
||||
1, 0, /* alignment, bounds */
|
||||
BUS_SPACE_MAXADDR_32BIT, /* lowaddr */
|
||||
BUS_SPACE_MAXADDR, /* highaddr */
|
||||
NULL, NULL, /* filter, filterarg */
|
||||
0x3ffff, /* maxsize XXX */
|
||||
ATH_MAX_SCATTER, /* nsegments */
|
||||
0xffff, /* maxsegsize XXX */
|
||||
BUS_DMA_ALLOCNOW, /* flags */
|
||||
NULL, /* lockfunc */
|
||||
NULL, /* lockarg */
|
||||
&sc->sc_dmat)) {
|
||||
device_printf(dev, "cannot allocate DMA tag\n");
|
||||
goto bad3;
|
||||
}
|
||||
|
||||
mtx_init(&sc->sc_mtx, device_get_nameunit(dev),
|
||||
MTX_NETWORK_LOCK, MTX_DEF | MTX_RECURSE);
|
||||
|
||||
error = ath_attach(pci_get_device(dev), sc);
|
||||
if (error == 0)
|
||||
return error;
|
||||
|
||||
mtx_destroy(&sc->sc_mtx);
|
||||
bus_dma_tag_destroy(sc->sc_dmat);
|
||||
bad3:
|
||||
bus_teardown_intr(dev, psc->sc_irq, psc->sc_ih);
|
||||
bad2:
|
||||
bus_release_resource(dev, SYS_RES_IRQ, 0, psc->sc_irq);
|
||||
bad1:
|
||||
bus_release_resource(dev, SYS_RES_MEMORY, BS_BAR, psc->sc_sr);
|
||||
bad:
|
||||
return (error);
|
||||
}
|
||||
|
||||
static int
|
||||
ath_pci_detach(device_t dev)
|
||||
{
|
||||
struct ath_pci_softc *psc = device_get_softc(dev);
|
||||
struct ath_softc *sc = &psc->sc_sc;
|
||||
|
||||
/* check if device was removed */
|
||||
sc->sc_invalid = !bus_child_present(dev);
|
||||
|
||||
ath_detach(sc);
|
||||
|
||||
bus_generic_detach(dev);
|
||||
bus_teardown_intr(dev, psc->sc_irq, psc->sc_ih);
|
||||
bus_release_resource(dev, SYS_RES_IRQ, 0, psc->sc_irq);
|
||||
|
||||
bus_dma_tag_destroy(sc->sc_dmat);
|
||||
bus_release_resource(dev, SYS_RES_MEMORY, BS_BAR, psc->sc_sr);
|
||||
|
||||
mtx_destroy(&sc->sc_mtx);
|
||||
|
||||
return (0);
|
||||
}
|
||||
|
||||
static int
|
||||
ath_pci_shutdown(device_t dev)
|
||||
{
|
||||
struct ath_pci_softc *psc = device_get_softc(dev);
|
||||
|
||||
ath_shutdown(&psc->sc_sc);
|
||||
return (0);
|
||||
}
|
||||
|
||||
static int
|
||||
ath_pci_suspend(device_t dev)
|
||||
{
|
||||
struct ath_pci_softc *psc = device_get_softc(dev);
|
||||
|
||||
ath_suspend(&psc->sc_sc);
|
||||
|
||||
psc->sc_saved_intline = pci_read_config(dev, PCIR_INTLINE, 1);
|
||||
psc->sc_saved_cachelinesz= pci_read_config(dev, PCIR_CACHELNSZ, 1);
|
||||
psc->sc_saved_lattimer = pci_read_config(dev, PCIR_LATTIMER, 1);
|
||||
|
||||
return (0);
|
||||
}
|
||||
|
||||
static int
|
||||
ath_pci_resume(device_t dev)
|
||||
{
|
||||
struct ath_pci_softc *psc = device_get_softc(dev);
|
||||
u_int16_t cmd;
|
||||
|
||||
pci_write_config(dev, PCIR_INTLINE, psc->sc_saved_intline, 1);
|
||||
pci_write_config(dev, PCIR_CACHELNSZ, psc->sc_saved_cachelinesz, 1);
|
||||
pci_write_config(dev, PCIR_LATTIMER, psc->sc_saved_lattimer, 1);
|
||||
|
||||
/* re-enable mem-map and busmastering */
|
||||
cmd = pci_read_config(dev, PCIR_COMMAND, 2);
|
||||
cmd |= PCIM_CMD_MEMEN | PCIM_CMD_BUSMASTEREN;
|
||||
pci_write_config(dev, PCIR_COMMAND, cmd, 2);
|
||||
|
||||
ath_resume(&psc->sc_sc);
|
||||
|
||||
return (0);
|
||||
}
|
||||
|
||||
static device_method_t ath_pci_methods[] = {
|
||||
/* Device interface */
|
||||
DEVMETHOD(device_probe, ath_pci_probe),
|
||||
DEVMETHOD(device_attach, ath_pci_attach),
|
||||
DEVMETHOD(device_detach, ath_pci_detach),
|
||||
DEVMETHOD(device_shutdown, ath_pci_shutdown),
|
||||
DEVMETHOD(device_suspend, ath_pci_suspend),
|
||||
DEVMETHOD(device_resume, ath_pci_resume),
|
||||
|
||||
{ 0,0 }
|
||||
};
|
||||
static driver_t ath_pci_driver = {
|
||||
"ath",
|
||||
ath_pci_methods,
|
||||
sizeof (struct ath_pci_softc)
|
||||
};
|
||||
static devclass_t ath_devclass;
|
||||
DRIVER_MODULE(if_ath, pci, ath_pci_driver, ath_devclass, 0, 0);
|
||||
DRIVER_MODULE(if_ath, cardbus, ath_pci_driver, ath_devclass, 0, 0);
|
||||
MODULE_VERSION(if_ath, 1);
|
||||
MODULE_DEPEND(if_ath, ath_hal, 1, 1, 1); /* Atheros HAL */
|
||||
MODULE_DEPEND(if_ath, wlan, 1, 1, 1); /* 802.11 media layer */
|
Loading…
Reference in New Issue