Home | History | Annotate | Line # | Download | only in pci
if_iwnvar.h revision 1.6
      1  1.6  christos /*	$OpenBSD: if_iwnvar.h,v 1.8 2008/12/03 17:17:08 damien Exp $	*/
      2  1.6  christos /*	$NetBSD: if_iwnvar.h,v 1.6 2009/09/11 01:28:20 christos Exp $	*/
      3  1.1      ober 
      4  1.1      ober /*-
      5  1.6  christos  * Copyright (c) 2007, 2008
      6  1.1      ober  *	Damien Bergamini <damien.bergamini (at) free.fr>
      7  1.1      ober  *
      8  1.1      ober  * Permission to use, copy, modify, and distribute this software for any
      9  1.1      ober  * purpose with or without fee is hereby granted, provided that the above
     10  1.1      ober  * copyright notice and this permission notice appear in all copies.
     11  1.1      ober  *
     12  1.1      ober  * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
     13  1.1      ober  * WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
     14  1.1      ober  * MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
     15  1.1      ober  * ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
     16  1.1      ober  * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
     17  1.1      ober  * ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
     18  1.1      ober  * OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
     19  1.1      ober  */
     20  1.1      ober 
     21  1.6  christos #define IEEE80211_NO_HT
     22  1.6  christos 
     23  1.1      ober struct iwn_rx_radiotap_header {
     24  1.1      ober 	struct ieee80211_radiotap_header wr_ihdr;
     25  1.1      ober 	uint64_t	wr_tsft;
     26  1.1      ober 	uint8_t		wr_flags;
     27  1.1      ober 	uint8_t		wr_rate;
     28  1.1      ober 	uint16_t	wr_chan_freq;
     29  1.1      ober 	uint16_t	wr_chan_flags;
     30  1.1      ober 	int8_t		wr_dbm_antsignal;
     31  1.1      ober 	int8_t		wr_dbm_antnoise;
     32  1.1      ober } __packed;
     33  1.1      ober 
     34  1.1      ober #define IWN_RX_RADIOTAP_PRESENT						\
     35  1.1      ober 	((1 << IEEE80211_RADIOTAP_TSFT) |				\
     36  1.6  christos 	 (1 << IEEE80211_RADIOTAP_FLAGS) |				\
     37  1.6  christos 	 (1 << IEEE80211_RADIOTAP_RATE) |				\
     38  1.6  christos 	 (1 << IEEE80211_RADIOTAP_CHANNEL) |				\
     39  1.6  christos 	 (1 << IEEE80211_RADIOTAP_DBM_ANTSIGNAL) |			\
     40  1.6  christos 	 (1 << IEEE80211_RADIOTAP_DBM_ANTNOISE))
     41  1.1      ober 
     42  1.1      ober struct iwn_tx_radiotap_header {
     43  1.1      ober 	struct ieee80211_radiotap_header wt_ihdr;
     44  1.1      ober 	uint8_t		wt_flags;
     45  1.1      ober 	uint8_t		wt_rate;
     46  1.1      ober 	uint16_t	wt_chan_freq;
     47  1.1      ober 	uint16_t	wt_chan_flags;
     48  1.1      ober 	uint8_t		wt_hwqueue;
     49  1.1      ober } __packed;
     50  1.1      ober 
     51  1.6  christos #define IWN_TX_RADIOTAP_PRESENT                                      \
     52  1.6  christos         ((1 << IEEE80211_RADIOTAP_FLAGS) |                           \
     53  1.6  christos 	 (1 << IEEE80211_RADIOTAP_RATE) |                            \
     54  1.6  christos 	 (1 << IEEE80211_RADIOTAP_CHANNEL))
     55  1.1      ober 
     56  1.1      ober struct iwn_dma_info {
     57  1.1      ober 	bus_dma_tag_t		tag;
     58  1.1      ober 	bus_dmamap_t		map;
     59  1.1      ober 	bus_dma_segment_t	seg;
     60  1.1      ober 	bus_addr_t		paddr;
     61  1.1      ober 	void *			vaddr;
     62  1.1      ober 	bus_size_t		size;
     63  1.1      ober };
     64  1.1      ober 
     65  1.1      ober struct iwn_tx_data {
     66  1.1      ober 	bus_dmamap_t		map;
     67  1.6  christos 	bus_addr_t		cmd_paddr;
     68  1.6  christos 	bus_addr_t		scratch_paddr;
     69  1.1      ober 	struct mbuf		*m;
     70  1.1      ober 	struct ieee80211_node	*ni;
     71  1.1      ober };
     72  1.1      ober 
     73  1.1      ober struct iwn_tx_ring {
     74  1.1      ober 	struct iwn_dma_info	desc_dma;
     75  1.1      ober 	struct iwn_dma_info	cmd_dma;
     76  1.1      ober 	struct iwn_tx_desc	*desc;
     77  1.1      ober 	struct iwn_tx_cmd	*cmd;
     78  1.6  christos 	struct iwn_tx_data	data[IWN_TX_RING_COUNT];
     79  1.1      ober 	int			qid;
     80  1.1      ober 	int			queued;
     81  1.1      ober 	int			count;
     82  1.1      ober 	int			cur;
     83  1.1      ober };
     84  1.1      ober 
     85  1.1      ober #define IWN_RBUF_COUNT	(IWN_RX_RING_COUNT + 32)
     86  1.1      ober 
     87  1.1      ober struct iwn_softc;
     88  1.1      ober 
     89  1.1      ober struct iwn_rbuf {
     90  1.1      ober 	struct iwn_softc	*sc;
     91  1.1      ober 	void *			vaddr;
     92  1.1      ober 	bus_addr_t		paddr;
     93  1.1      ober 	SLIST_ENTRY(iwn_rbuf)	next;
     94  1.1      ober };
     95  1.1      ober 
     96  1.1      ober struct iwn_rx_data {
     97  1.1      ober 	struct mbuf	*m;
     98  1.6  christos 	bus_dmamap_t	map;
     99  1.1      ober };
    100  1.1      ober 
    101  1.1      ober struct iwn_rx_ring {
    102  1.1      ober 	struct iwn_dma_info	desc_dma;
    103  1.6  christos 	struct iwn_dma_info	stat_dma;
    104  1.1      ober 	struct iwn_dma_info	buf_dma;
    105  1.1      ober 	uint32_t		*desc;
    106  1.6  christos 	struct iwn_rx_status	*stat;
    107  1.1      ober 	struct iwn_rx_data	data[IWN_RX_RING_COUNT];
    108  1.1      ober 	struct iwn_rbuf		rbuf[IWN_RBUF_COUNT];
    109  1.6  christos 	kmutex_t                freelist_mtx;
    110  1.1      ober 	SLIST_HEAD(, iwn_rbuf)	freelist;
    111  1.1      ober 	int			nb_free_entries;
    112  1.1      ober 	int			cur;
    113  1.1      ober };
    114  1.1      ober 
    115  1.1      ober struct iwn_node {
    116  1.1      ober 	struct	ieee80211_node		ni;	/* must be the first */
    117  1.1      ober 	struct	ieee80211_amrr_node	amn;
    118  1.6  christos 	uint16_t			disable_tid;
    119  1.6  christos 	uint8_t				id;
    120  1.6  christos 	uint8_t				ridx[IEEE80211_RATE_MAXSIZE];
    121  1.1      ober };
    122  1.1      ober 
    123  1.1      ober struct iwn_calib_state {
    124  1.1      ober 	uint8_t		state;
    125  1.1      ober #define IWN_CALIB_STATE_INIT	0
    126  1.1      ober #define IWN_CALIB_STATE_ASSOC	1
    127  1.1      ober #define IWN_CALIB_STATE_RUN	2
    128  1.1      ober 
    129  1.1      ober 	u_int		nbeacons;
    130  1.1      ober 	uint32_t	noise[3];
    131  1.1      ober 	uint32_t	rssi[3];
    132  1.6  christos 	uint32_t	ofdm_x1;
    133  1.6  christos 	uint32_t	ofdm_mrc_x1;
    134  1.6  christos 	uint32_t	ofdm_x4;
    135  1.6  christos 	uint32_t	ofdm_mrc_x4;
    136  1.6  christos 	uint32_t	cck_x4;
    137  1.6  christos 	uint32_t	cck_mrc_x4;
    138  1.1      ober 	uint32_t	bad_plcp_ofdm;
    139  1.1      ober 	uint32_t	fa_ofdm;
    140  1.1      ober 	uint32_t	bad_plcp_cck;
    141  1.1      ober 	uint32_t	fa_cck;
    142  1.1      ober 	uint32_t	low_fa;
    143  1.1      ober 	uint8_t		cck_state;
    144  1.1      ober #define IWN_CCK_STATE_INIT	0
    145  1.1      ober #define IWN_CCK_STATE_LOFA	1
    146  1.1      ober #define IWN_CCK_STATE_HIFA	2
    147  1.1      ober 
    148  1.1      ober 	uint8_t		noise_samples[20];
    149  1.1      ober 	u_int		cur_noise_sample;
    150  1.1      ober 	uint8_t		noise_ref;
    151  1.1      ober 	uint32_t	energy_samples[10];
    152  1.1      ober 	u_int		cur_energy_sample;
    153  1.1      ober 	uint32_t	energy_cck;
    154  1.1      ober };
    155  1.1      ober 
    156  1.6  christos struct iwn_calib_info {
    157  1.6  christos 	uint8_t		*buf;
    158  1.6  christos 	u_int		len;
    159  1.6  christos };
    160  1.6  christos 
    161  1.6  christos struct iwn_fw_part {
    162  1.6  christos 	const uint8_t	*text;
    163  1.6  christos 	uint32_t	textsz;
    164  1.6  christos 	const uint8_t	*data;
    165  1.6  christos 	uint32_t	datasz;
    166  1.6  christos };
    167  1.6  christos 
    168  1.6  christos struct iwn_fw_info {
    169  1.6  christos 	u_char			*data;
    170  1.6  christos 	struct iwn_fw_part	init;
    171  1.6  christos 	struct iwn_fw_part	main;
    172  1.6  christos 	struct iwn_fw_part	boot;
    173  1.6  christos };
    174  1.6  christos 
    175  1.6  christos struct iwn_hal {
    176  1.6  christos 	int		(*load_firmware)(struct iwn_softc *);
    177  1.6  christos 	void		(*read_eeprom)(struct iwn_softc *);
    178  1.6  christos 	int		(*post_alive)(struct iwn_softc *);
    179  1.6  christos 	int		(*apm_init)(struct iwn_softc *);
    180  1.6  christos 	int		(*nic_config)(struct iwn_softc *);
    181  1.6  christos 	void		(*update_sched)(struct iwn_softc *, int, int, uint8_t,
    182  1.6  christos 			    uint16_t);
    183  1.6  christos 	int		(*get_temperature)(struct iwn_softc *);
    184  1.6  christos 	int		(*get_rssi)(const struct iwn_rx_stat *);
    185  1.6  christos 	int		(*set_txpower)(struct iwn_softc *, int);
    186  1.6  christos 	int		(*init_gains)(struct iwn_softc *);
    187  1.6  christos 	int		(*set_gains)(struct iwn_softc *);
    188  1.6  christos 	int		(*add_node)(struct iwn_softc *, struct iwn_node_info *,
    189  1.6  christos 			    int);
    190  1.6  christos 	void		(*tx_done)(struct iwn_softc *, struct iwn_rx_desc *,
    191  1.6  christos 			    struct iwn_rx_data *);
    192  1.6  christos #ifndef IEEE80211_NO_HT
    193  1.6  christos 	void		(*ampdu_tx_start)(struct iwn_softc *,
    194  1.6  christos 			    struct ieee80211_node *, uint8_t, uint16_t);
    195  1.6  christos 	void		(*ampdu_tx_stop)(struct iwn_softc *, uint8_t,
    196  1.6  christos 			    uint16_t);
    197  1.6  christos #endif
    198  1.6  christos 	const struct	iwn_sensitivity_limits *limits;
    199  1.6  christos 	int		ntxqs;
    200  1.6  christos 	uint8_t		broadcast_id;
    201  1.6  christos 	int		rxonsz;
    202  1.6  christos 	int		schedsz;
    203  1.6  christos 	uint32_t	fw_text_maxsz;
    204  1.6  christos 	uint32_t	fw_data_maxsz;
    205  1.6  christos 	uint32_t	fwsz;
    206  1.6  christos 	bus_size_t	sched_txfact_addr;
    207  1.6  christos };
    208  1.6  christos 
    209  1.1      ober struct iwn_softc {
    210  1.6  christos 	device_t		sc_dev;
    211  1.6  christos 
    212  1.6  christos 	struct ethercom		sc_ec;
    213  1.1      ober 	struct ieee80211com	sc_ic;
    214  1.1      ober 	int			(*sc_newstate)(struct ieee80211com *,
    215  1.6  christos 				    enum ieee80211_state, int);
    216  1.1      ober 
    217  1.1      ober 	struct ieee80211_amrr	amrr;
    218  1.6  christos 	uint8_t			fixed_ridx;
    219  1.1      ober 
    220  1.1      ober 	bus_dma_tag_t		sc_dmat;
    221  1.1      ober 
    222  1.6  christos 	u_int			sc_flags;
    223  1.6  christos #define IWN_FLAG_HAS_5GHZ	(1 << 0)
    224  1.6  christos #define IWN_FLAG_FIRST_BOOT	(1 << 1)
    225  1.6  christos 
    226  1.6  christos 	uint8_t 		hw_type;
    227  1.6  christos 	const struct iwn_hal	*sc_hal;
    228  1.6  christos 	const char		*fwname;
    229  1.6  christos 
    230  1.6  christos 	/* TX scheduler rings. */
    231  1.6  christos 	struct iwn_dma_info	sched_dma;
    232  1.6  christos 	uint16_t		*sched;
    233  1.6  christos 	uint32_t		sched_base;
    234  1.1      ober 
    235  1.6  christos 	/* "Keep Warm" page. */
    236  1.1      ober 	struct iwn_dma_info	kw_dma;
    237  1.1      ober 
    238  1.6  christos 	/* Firmware DMA transfer. */
    239  1.1      ober 	struct iwn_dma_info	fw_dma;
    240  1.1      ober 
    241  1.6  christos 	/* TX/RX rings. */
    242  1.6  christos 	struct iwn_tx_ring	txq[IWN5000_NTXQUEUES];
    243  1.1      ober 	struct iwn_rx_ring	rxq;
    244  1.1      ober 
    245  1.1      ober 	bus_space_tag_t		sc_st;
    246  1.1      ober 	bus_space_handle_t	sc_sh;
    247  1.1      ober 	void 			*sc_ih;
    248  1.1      ober 	pci_chipset_tag_t	sc_pct;
    249  1.1      ober 	pcitag_t		sc_pcitag;
    250  1.1      ober 	bus_size_t		sc_sz;
    251  1.6  christos 	int			sc_cap_off;	/* PCIe Capabilities. */
    252  1.1      ober 
    253  1.6  christos 	callout_t		calib_to;
    254  1.1      ober 	int			calib_cnt;
    255  1.1      ober 	struct iwn_calib_state	calib;
    256  1.1      ober 
    257  1.6  christos 	struct iwn_fw_info	fw;
    258  1.6  christos 	struct iwn_calib_info	calibcmd[5];
    259  1.6  christos 	uint32_t		errptr;
    260  1.6  christos 
    261  1.1      ober 	struct iwn_rx_stat	last_rx_stat;
    262  1.1      ober 	int			last_rx_valid;
    263  1.1      ober 	struct iwn_ucode_info	ucode_info;
    264  1.6  christos 	struct iwn_rxon		rxon;
    265  1.1      ober 	uint32_t		rawtemp;
    266  1.1      ober 	int			temp;
    267  1.1      ober 	int			noise;
    268  1.6  christos 	uint32_t		qfullmsk;
    269  1.1      ober 
    270  1.6  christos 	struct iwn4965_eeprom_band
    271  1.6  christos 				bands[IWN_NBANDS];
    272  1.6  christos 	uint16_t		rfcfg;
    273  1.6  christos 	char			eeprom_domain[4];
    274  1.6  christos 	uint32_t		eeprom_crystal;
    275  1.1      ober 	int16_t			eeprom_voltage;
    276  1.1      ober 	int8_t			maxpwr2GHz;
    277  1.1      ober 	int8_t			maxpwr5GHz;
    278  1.1      ober 	int8_t			maxpwr[IEEE80211_CHAN_MAX];
    279  1.1      ober 
    280  1.6  christos 	uint32_t		critical_temp;
    281  1.6  christos 	uint8_t			ntxchains;
    282  1.6  christos 	uint8_t			nrxchains;
    283  1.6  christos 	uint8_t			txantmsk;
    284  1.6  christos 	uint8_t			rxantmsk;
    285  1.6  christos 	uint8_t			antmsk;
    286  1.6  christos 
    287  1.1      ober 	int			sc_tx_timer;
    288  1.6  christos 	void			*powerhook;
    289  1.1      ober 
    290  1.1      ober #if NBPFILTER > 0
    291  1.1      ober 	void *			sc_drvbpf;
    292  1.1      ober 
    293  1.1      ober 	union {
    294  1.1      ober 		struct iwn_rx_radiotap_header th;
    295  1.1      ober 		uint8_t	pad[IEEE80211_RADIOTAP_HDRLEN];
    296  1.1      ober 	} sc_rxtapu;
    297  1.1      ober #define sc_rxtap	sc_rxtapu.th
    298  1.1      ober 	int			sc_rxtap_len;
    299  1.1      ober 
    300  1.1      ober 	union {
    301  1.1      ober 		struct iwn_tx_radiotap_header th;
    302  1.1      ober 		uint8_t	pad[IEEE80211_RADIOTAP_HDRLEN];
    303  1.1      ober 	} sc_txtapu;
    304  1.1      ober #define sc_txtap	sc_txtapu.th
    305  1.1      ober 	int			sc_txtap_len;
    306  1.1      ober #endif
    307  1.1      ober 	bool		is_scanning;
    308  1.5     blymn 	bool		sc_radio;
    309  1.1      ober };
    310