Home | History | Annotate | Line # | Download | only in pci
if_iwnvar.h revision 1.3.16.4
      1  1.3.16.4  yamt /*	$NetBSD: if_iwnvar.h,v 1.3.16.4 2010/08/11 22:53:47 yamt Exp $	*/
      2  1.3.16.4  yamt /*	$OpenBSD: if_iwnvar.h,v 1.19 2010/05/05 19:47:43 damien Exp $	*/
      3       1.1  ober 
      4       1.1  ober /*-
      5  1.3.16.2  yamt  * 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.3.16.4  yamt /* XXX Added for NetBSD */
     22  1.3.16.2  yamt #define IEEE80211_NO_HT
     23  1.3.16.2  yamt 
     24       1.1  ober struct iwn_rx_radiotap_header {
     25       1.1  ober 	struct ieee80211_radiotap_header wr_ihdr;
     26       1.1  ober 	uint64_t	wr_tsft;
     27       1.1  ober 	uint8_t		wr_flags;
     28       1.1  ober 	uint8_t		wr_rate;
     29       1.1  ober 	uint16_t	wr_chan_freq;
     30       1.1  ober 	uint16_t	wr_chan_flags;
     31       1.1  ober 	int8_t		wr_dbm_antsignal;
     32       1.1  ober 	int8_t		wr_dbm_antnoise;
     33       1.1  ober } __packed;
     34       1.1  ober 
     35       1.1  ober #define IWN_RX_RADIOTAP_PRESENT						\
     36       1.1  ober 	((1 << IEEE80211_RADIOTAP_TSFT) |				\
     37  1.3.16.2  yamt 	 (1 << IEEE80211_RADIOTAP_FLAGS) |				\
     38  1.3.16.2  yamt 	 (1 << IEEE80211_RADIOTAP_RATE) |				\
     39  1.3.16.2  yamt 	 (1 << IEEE80211_RADIOTAP_CHANNEL) |				\
     40  1.3.16.2  yamt 	 (1 << IEEE80211_RADIOTAP_DBM_ANTSIGNAL) |			\
     41  1.3.16.2  yamt 	 (1 << IEEE80211_RADIOTAP_DBM_ANTNOISE))
     42       1.1  ober 
     43       1.1  ober struct iwn_tx_radiotap_header {
     44       1.1  ober 	struct ieee80211_radiotap_header wt_ihdr;
     45       1.1  ober 	uint8_t		wt_flags;
     46       1.1  ober 	uint8_t		wt_rate;
     47       1.1  ober 	uint16_t	wt_chan_freq;
     48       1.1  ober 	uint16_t	wt_chan_flags;
     49       1.1  ober 	uint8_t		wt_hwqueue;
     50       1.1  ober } __packed;
     51       1.1  ober 
     52  1.3.16.4  yamt #define IWN_TX_RADIOTAP_PRESENT						\
     53  1.3.16.4  yamt 	((1 << IEEE80211_RADIOTAP_FLAGS) |				\
     54  1.3.16.4  yamt 	 (1 << IEEE80211_RADIOTAP_RATE) |				\
     55  1.3.16.2  yamt 	 (1 << IEEE80211_RADIOTAP_CHANNEL))
     56  1.3.16.4  yamt /* XXX OpenBSD also includes IEEE80211_RADIOTAP_HWQUEUE */
     57       1.1  ober 
     58       1.1  ober struct iwn_dma_info {
     59       1.1  ober 	bus_dma_tag_t		tag;
     60       1.1  ober 	bus_dmamap_t		map;
     61       1.1  ober 	bus_dma_segment_t	seg;
     62       1.1  ober 	bus_addr_t		paddr;
     63       1.1  ober 	void *			vaddr;
     64       1.1  ober 	bus_size_t		size;
     65       1.1  ober };
     66       1.1  ober 
     67       1.1  ober struct iwn_tx_data {
     68       1.1  ober 	bus_dmamap_t		map;
     69  1.3.16.2  yamt 	bus_addr_t		cmd_paddr;
     70  1.3.16.2  yamt 	bus_addr_t		scratch_paddr;
     71       1.1  ober 	struct mbuf		*m;
     72       1.1  ober 	struct ieee80211_node	*ni;
     73       1.1  ober };
     74       1.1  ober 
     75       1.1  ober struct iwn_tx_ring {
     76       1.1  ober 	struct iwn_dma_info	desc_dma;
     77       1.1  ober 	struct iwn_dma_info	cmd_dma;
     78       1.1  ober 	struct iwn_tx_desc	*desc;
     79       1.1  ober 	struct iwn_tx_cmd	*cmd;
     80  1.3.16.2  yamt 	struct iwn_tx_data	data[IWN_TX_RING_COUNT];
     81       1.1  ober 	int			qid;
     82       1.1  ober 	int			queued;
     83       1.1  ober 	int			cur;
     84       1.1  ober };
     85       1.1  ober 
     86  1.3.16.4  yamt #define	IWN_RBUF_COUNT	(IWN_RX_RING_COUNT + 32)
     87       1.1  ober 
     88       1.1  ober struct iwn_softc;
     89       1.1  ober 
     90       1.1  ober struct iwn_rbuf {
     91       1.1  ober 	struct iwn_softc	*sc;
     92       1.1  ober 	void *			vaddr;
     93       1.1  ober 	bus_addr_t		paddr;
     94       1.1  ober 	SLIST_ENTRY(iwn_rbuf)	next;
     95       1.1  ober };
     96       1.1  ober 
     97       1.1  ober struct iwn_rx_data {
     98       1.1  ober 	struct mbuf	*m;
     99  1.3.16.2  yamt 	bus_dmamap_t	map;
    100       1.1  ober };
    101       1.1  ober 
    102       1.1  ober struct iwn_rx_ring {
    103       1.1  ober 	struct iwn_dma_info	desc_dma;
    104  1.3.16.2  yamt 	struct iwn_dma_info	stat_dma;
    105       1.1  ober 	struct iwn_dma_info	buf_dma;
    106       1.1  ober 	uint32_t		*desc;
    107  1.3.16.2  yamt 	struct iwn_rx_status	*stat;
    108       1.1  ober 	struct iwn_rx_data	data[IWN_RX_RING_COUNT];
    109       1.1  ober 	struct iwn_rbuf		rbuf[IWN_RBUF_COUNT];
    110  1.3.16.2  yamt 	kmutex_t                freelist_mtx;
    111       1.1  ober 	SLIST_HEAD(, iwn_rbuf)	freelist;
    112       1.1  ober 	int			nb_free_entries;
    113       1.1  ober 	int			cur;
    114       1.1  ober };
    115       1.1  ober 
    116       1.1  ober struct iwn_node {
    117       1.1  ober 	struct	ieee80211_node		ni;	/* must be the first */
    118       1.1  ober 	struct	ieee80211_amrr_node	amn;
    119  1.3.16.2  yamt 	uint16_t			disable_tid;
    120  1.3.16.2  yamt 	uint8_t				id;
    121  1.3.16.2  yamt 	uint8_t				ridx[IEEE80211_RATE_MAXSIZE];
    122       1.1  ober };
    123       1.1  ober 
    124       1.1  ober struct iwn_calib_state {
    125       1.1  ober 	uint8_t		state;
    126       1.1  ober #define IWN_CALIB_STATE_INIT	0
    127       1.1  ober #define IWN_CALIB_STATE_ASSOC	1
    128       1.1  ober #define IWN_CALIB_STATE_RUN	2
    129       1.1  ober 
    130       1.1  ober 	u_int		nbeacons;
    131       1.1  ober 	uint32_t	noise[3];
    132       1.1  ober 	uint32_t	rssi[3];
    133  1.3.16.2  yamt 	uint32_t	ofdm_x1;
    134  1.3.16.2  yamt 	uint32_t	ofdm_mrc_x1;
    135  1.3.16.2  yamt 	uint32_t	ofdm_x4;
    136  1.3.16.2  yamt 	uint32_t	ofdm_mrc_x4;
    137  1.3.16.2  yamt 	uint32_t	cck_x4;
    138  1.3.16.2  yamt 	uint32_t	cck_mrc_x4;
    139       1.1  ober 	uint32_t	bad_plcp_ofdm;
    140       1.1  ober 	uint32_t	fa_ofdm;
    141       1.1  ober 	uint32_t	bad_plcp_cck;
    142       1.1  ober 	uint32_t	fa_cck;
    143       1.1  ober 	uint32_t	low_fa;
    144       1.1  ober 	uint8_t		cck_state;
    145       1.1  ober #define IWN_CCK_STATE_INIT	0
    146       1.1  ober #define IWN_CCK_STATE_LOFA	1
    147       1.1  ober #define IWN_CCK_STATE_HIFA	2
    148       1.1  ober 
    149       1.1  ober 	uint8_t		noise_samples[20];
    150       1.1  ober 	u_int		cur_noise_sample;
    151       1.1  ober 	uint8_t		noise_ref;
    152       1.1  ober 	uint32_t	energy_samples[10];
    153       1.1  ober 	u_int		cur_energy_sample;
    154       1.1  ober 	uint32_t	energy_cck;
    155       1.1  ober };
    156       1.1  ober 
    157  1.3.16.2  yamt struct iwn_calib_info {
    158  1.3.16.2  yamt 	uint8_t		*buf;
    159  1.3.16.2  yamt 	u_int		len;
    160  1.3.16.2  yamt };
    161  1.3.16.2  yamt 
    162  1.3.16.2  yamt struct iwn_fw_part {
    163  1.3.16.2  yamt 	const uint8_t	*text;
    164  1.3.16.2  yamt 	uint32_t	textsz;
    165  1.3.16.2  yamt 	const uint8_t	*data;
    166  1.3.16.2  yamt 	uint32_t	datasz;
    167  1.3.16.2  yamt };
    168  1.3.16.2  yamt 
    169  1.3.16.2  yamt struct iwn_fw_info {
    170  1.3.16.2  yamt 	u_char			*data;
    171  1.3.16.4  yamt 	size_t			size;
    172  1.3.16.2  yamt 	struct iwn_fw_part	init;
    173  1.3.16.2  yamt 	struct iwn_fw_part	main;
    174  1.3.16.2  yamt 	struct iwn_fw_part	boot;
    175  1.3.16.2  yamt };
    176  1.3.16.2  yamt 
    177  1.3.16.2  yamt struct iwn_hal {
    178  1.3.16.2  yamt 	int		(*load_firmware)(struct iwn_softc *);
    179  1.3.16.2  yamt 	void		(*read_eeprom)(struct iwn_softc *);
    180  1.3.16.2  yamt 	int		(*post_alive)(struct iwn_softc *);
    181  1.3.16.2  yamt 	int		(*nic_config)(struct iwn_softc *);
    182  1.3.16.2  yamt 	void		(*update_sched)(struct iwn_softc *, int, int, uint8_t,
    183  1.3.16.2  yamt 			    uint16_t);
    184  1.3.16.2  yamt 	int		(*get_temperature)(struct iwn_softc *);
    185  1.3.16.2  yamt 	int		(*get_rssi)(const struct iwn_rx_stat *);
    186  1.3.16.2  yamt 	int		(*set_txpower)(struct iwn_softc *, int);
    187  1.3.16.2  yamt 	int		(*init_gains)(struct iwn_softc *);
    188  1.3.16.2  yamt 	int		(*set_gains)(struct iwn_softc *);
    189  1.3.16.2  yamt 	int		(*add_node)(struct iwn_softc *, struct iwn_node_info *,
    190  1.3.16.2  yamt 			    int);
    191  1.3.16.2  yamt 	void		(*tx_done)(struct iwn_softc *, struct iwn_rx_desc *,
    192  1.3.16.2  yamt 			    struct iwn_rx_data *);
    193  1.3.16.2  yamt #ifndef IEEE80211_NO_HT
    194  1.3.16.2  yamt 	void		(*ampdu_tx_start)(struct iwn_softc *,
    195  1.3.16.2  yamt 			    struct ieee80211_node *, uint8_t, uint16_t);
    196  1.3.16.2  yamt 	void		(*ampdu_tx_stop)(struct iwn_softc *, uint8_t,
    197  1.3.16.2  yamt 			    uint16_t);
    198  1.3.16.2  yamt #endif
    199  1.3.16.2  yamt 	int		ntxqs;
    200  1.3.16.4  yamt 	int		ndmachnls;
    201  1.3.16.2  yamt 	uint8_t		broadcast_id;
    202  1.3.16.2  yamt 	int		rxonsz;
    203  1.3.16.2  yamt 	int		schedsz;
    204  1.3.16.2  yamt 	uint32_t	fw_text_maxsz;
    205  1.3.16.2  yamt 	uint32_t	fw_data_maxsz;
    206  1.3.16.2  yamt 	uint32_t	fwsz;
    207  1.3.16.2  yamt 	bus_size_t	sched_txfact_addr;
    208  1.3.16.2  yamt };
    209  1.3.16.2  yamt 
    210       1.1  ober struct iwn_softc {
    211  1.3.16.2  yamt 	device_t		sc_dev;
    212  1.3.16.2  yamt 
    213  1.3.16.2  yamt 	struct ethercom		sc_ec;
    214       1.1  ober 	struct ieee80211com	sc_ic;
    215       1.1  ober 	int			(*sc_newstate)(struct ieee80211com *,
    216  1.3.16.2  yamt 				    enum ieee80211_state, int);
    217       1.1  ober 
    218       1.1  ober 	struct ieee80211_amrr	amrr;
    219  1.3.16.2  yamt 	uint8_t			fixed_ridx;
    220       1.1  ober 
    221       1.1  ober 	bus_dma_tag_t		sc_dmat;
    222       1.1  ober 
    223  1.3.16.2  yamt 	u_int			sc_flags;
    224  1.3.16.2  yamt #define IWN_FLAG_HAS_5GHZ	(1 << 0)
    225  1.3.16.4  yamt #define IWN_FLAG_HAS_OTPROM	(1 << 1)
    226  1.3.16.4  yamt #define IWN_FLAG_CALIB_DONE	(1 << 2)
    227  1.3.16.4  yamt #define IWN_FLAG_USE_ICT	(1 << 3)
    228  1.3.16.4  yamt #define IWN_FLAG_INTERNAL_PA	(1 << 4)
    229  1.3.16.4  yamt /* Added for NetBSD */
    230  1.3.16.4  yamt #define IWN_FLAG_SCANNING	(1 << 8)
    231  1.3.16.4  yamt #define IWN_FLAG_HW_INITED	(1 << 9)
    232  1.3.16.2  yamt 
    233  1.3.16.2  yamt 	uint8_t 		hw_type;
    234  1.3.16.2  yamt 	const struct iwn_hal	*sc_hal;
    235  1.3.16.2  yamt 	const char		*fwname;
    236  1.3.16.4  yamt 	const struct iwn_sensitivity_limits
    237  1.3.16.4  yamt 				*limits;
    238  1.3.16.2  yamt 
    239  1.3.16.2  yamt 	/* TX scheduler rings. */
    240  1.3.16.2  yamt 	struct iwn_dma_info	sched_dma;
    241  1.3.16.2  yamt 	uint16_t		*sched;
    242  1.3.16.2  yamt 	uint32_t		sched_base;
    243       1.1  ober 
    244  1.3.16.2  yamt 	/* "Keep Warm" page. */
    245       1.1  ober 	struct iwn_dma_info	kw_dma;
    246       1.1  ober 
    247  1.3.16.2  yamt 	/* Firmware DMA transfer. */
    248       1.1  ober 	struct iwn_dma_info	fw_dma;
    249       1.1  ober 
    250  1.3.16.4  yamt 	/* ICT table. */
    251  1.3.16.4  yamt 	struct iwn_dma_info	ict_dma;
    252  1.3.16.4  yamt 	uint32_t		*ict;
    253  1.3.16.4  yamt 	int			ict_cur;
    254  1.3.16.4  yamt 
    255  1.3.16.2  yamt 	/* TX/RX rings. */
    256  1.3.16.2  yamt 	struct iwn_tx_ring	txq[IWN5000_NTXQUEUES];
    257       1.1  ober 	struct iwn_rx_ring	rxq;
    258       1.1  ober 
    259       1.1  ober 	bus_space_tag_t		sc_st;
    260       1.1  ober 	bus_space_handle_t	sc_sh;
    261       1.1  ober 	void 			*sc_ih;
    262       1.1  ober 	pci_chipset_tag_t	sc_pct;
    263       1.1  ober 	pcitag_t		sc_pcitag;
    264       1.1  ober 	bus_size_t		sc_sz;
    265  1.3.16.2  yamt 	int			sc_cap_off;	/* PCIe Capabilities. */
    266  1.3.16.4  yamt 	struct sysmon_envsys	*sc_sme;
    267  1.3.16.4  yamt 	envsys_data_t		sc_sensor;
    268  1.3.16.2  yamt 	callout_t		calib_to;
    269       1.1  ober 	int			calib_cnt;
    270       1.1  ober 	struct iwn_calib_state	calib;
    271       1.1  ober 
    272  1.3.16.2  yamt 	struct iwn_fw_info	fw;
    273  1.3.16.2  yamt 	struct iwn_calib_info	calibcmd[5];
    274  1.3.16.2  yamt 	uint32_t		errptr;
    275  1.3.16.2  yamt 
    276       1.1  ober 	struct iwn_rx_stat	last_rx_stat;
    277       1.1  ober 	int			last_rx_valid;
    278       1.1  ober 	struct iwn_ucode_info	ucode_info;
    279  1.3.16.2  yamt 	struct iwn_rxon		rxon;
    280       1.1  ober 	uint32_t		rawtemp;
    281       1.1  ober 	int			temp;
    282       1.1  ober 	int			noise;
    283  1.3.16.2  yamt 	uint32_t		qfullmsk;
    284       1.1  ober 
    285  1.3.16.4  yamt 	uint32_t		prom_base;
    286  1.3.16.2  yamt 	struct iwn4965_eeprom_band
    287  1.3.16.2  yamt 				bands[IWN_NBANDS];
    288  1.3.16.2  yamt 	uint16_t		rfcfg;
    289  1.3.16.4  yamt 	uint8_t			calib_ver;
    290  1.3.16.2  yamt 	char			eeprom_domain[4];
    291  1.3.16.2  yamt 	uint32_t		eeprom_crystal;
    292       1.1  ober 	int16_t			eeprom_voltage;
    293       1.1  ober 	int8_t			maxpwr2GHz;
    294       1.1  ober 	int8_t			maxpwr5GHz;
    295       1.1  ober 	int8_t			maxpwr[IEEE80211_CHAN_MAX];
    296  1.3.16.4  yamt 	int8_t			enh_maxpwr[35];
    297       1.1  ober 
    298  1.3.16.4  yamt 	int32_t			temp_off;
    299  1.3.16.4  yamt 	uint32_t		int_mask;
    300  1.3.16.2  yamt 	uint8_t			ntxchains;
    301  1.3.16.2  yamt 	uint8_t			nrxchains;
    302  1.3.16.4  yamt 	uint8_t			txchainmask;
    303  1.3.16.4  yamt 	uint8_t			rxchainmask;
    304  1.3.16.4  yamt 	uint8_t			chainmask;
    305  1.3.16.2  yamt 
    306       1.1  ober 	int			sc_tx_timer;
    307  1.3.16.2  yamt 	void			*powerhook;
    308       1.1  ober 
    309  1.3.16.3  yamt 	struct bpf_if *		sc_drvbpf;
    310       1.1  ober 
    311       1.1  ober 	union {
    312       1.1  ober 		struct iwn_rx_radiotap_header th;
    313       1.1  ober 		uint8_t	pad[IEEE80211_RADIOTAP_HDRLEN];
    314       1.1  ober 	} sc_rxtapu;
    315       1.1  ober #define sc_rxtap	sc_rxtapu.th
    316       1.1  ober 	int			sc_rxtap_len;
    317       1.1  ober 
    318       1.1  ober 	union {
    319       1.1  ober 		struct iwn_tx_radiotap_header th;
    320       1.1  ober 		uint8_t	pad[IEEE80211_RADIOTAP_HDRLEN];
    321       1.1  ober 	} sc_txtapu;
    322       1.1  ober #define sc_txtap	sc_txtapu.th
    323       1.1  ober 	int			sc_txtap_len;
    324  1.3.16.4  yamt 
    325  1.3.16.4  yamt 	kmutex_t		sc_mtx;         /* mutex for init/stop */
    326  1.3.16.4  yamt 
    327       1.1  ober };
    328  1.3.16.4  yamt 
    329