Home | History | Annotate | Line # | Download | only in pci
if_iwnvar.h revision 1.1
      1 /*	$OpenBSD: if_iwnvar.h,v 1.2 2007/11/19 19:34:25 damien Exp $	*/
      2 
      3 /*-
      4  * Copyright (c) 2007
      5  *	Damien Bergamini <damien.bergamini (at) free.fr>
      6  *
      7  * Permission to use, copy, modify, and distribute this software for any
      8  * purpose with or without fee is hereby granted, provided that the above
      9  * copyright notice and this permission notice appear in all copies.
     10  *
     11  * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
     12  * WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
     13  * MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
     14  * ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
     15  * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
     16  * ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
     17  * OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
     18  */
     19 
     20 struct iwn_rx_radiotap_header {
     21 	struct ieee80211_radiotap_header wr_ihdr;
     22 	uint64_t	wr_tsft;
     23 	uint8_t		wr_flags;
     24 	uint8_t		wr_rate;
     25 	uint16_t	wr_chan_freq;
     26 	uint16_t	wr_chan_flags;
     27 	int8_t		wr_dbm_antsignal;
     28 	int8_t		wr_dbm_antnoise;
     29 } __packed;
     30 
     31 #define IWN_RX_RADIOTAP_PRESENT						\
     32 	((1 << IEEE80211_RADIOTAP_TSFT) |				\
     33 	 (1 << IEEE80211_RADIOTAP_FLAGS) |				\
     34 	 (1 << IEEE80211_RADIOTAP_RATE) |				\
     35 	 (1 << IEEE80211_RADIOTAP_CHANNEL) |				\
     36 	 (1 << IEEE80211_RADIOTAP_DBM_ANTSIGNAL) |			\
     37 	 (1 << IEEE80211_RADIOTAP_DBM_ANTNOISE))
     38 
     39 struct iwn_tx_radiotap_header {
     40 	struct ieee80211_radiotap_header wt_ihdr;
     41 	uint8_t		wt_flags;
     42 	uint8_t		wt_rate;
     43 	uint16_t	wt_chan_freq;
     44 	uint16_t	wt_chan_flags;
     45 	uint8_t		wt_hwqueue;
     46 } __packed;
     47 
     48 #define IWN_TX_RADIOTAP_PRESENT						\
     49 	((1 << IEEE80211_RADIOTAP_FLAGS) |				\
     50 	 (1 << IEEE80211_RADIOTAP_RATE) |				\
     51 	 (1 << IEEE80211_RADIOTAP_CHANNEL))
     52 
     53 struct iwn_dma_info {
     54 	bus_dma_tag_t		tag;
     55 	bus_dmamap_t		map;
     56 	bus_dma_segment_t	seg;
     57 	bus_addr_t		paddr;
     58 	void *			vaddr;
     59 	bus_size_t		size;
     60 };
     61 
     62 struct iwn_tx_data {
     63 	bus_dmamap_t		map;
     64 	struct mbuf		*m;
     65 	struct ieee80211_node	*ni;
     66 };
     67 
     68 struct iwn_tx_ring {
     69 	struct iwn_dma_info	desc_dma;
     70 	struct iwn_dma_info	cmd_dma;
     71 	struct iwn_tx_desc	*desc;
     72 	struct iwn_tx_cmd	*cmd;
     73 	struct iwn_tx_data	*data;
     74 	int			qid;
     75 	int			queued;
     76 	int			count;
     77 	int			cur;
     78 };
     79 
     80 #define IWN_RBUF_COUNT	(IWN_RX_RING_COUNT + 32)
     81 
     82 struct iwn_softc;
     83 
     84 struct iwn_rbuf {
     85 	struct iwn_softc	*sc;
     86 	void *			vaddr;
     87 	bus_addr_t		paddr;
     88 	SLIST_ENTRY(iwn_rbuf)	next;
     89 };
     90 
     91 struct iwn_rx_data {
     92 	struct mbuf	*m;
     93 };
     94 
     95 struct iwn_rx_ring {
     96 	struct iwn_dma_info	desc_dma;
     97 	struct iwn_dma_info	buf_dma;
     98 	uint32_t		*desc;
     99 	struct iwn_rx_data	data[IWN_RX_RING_COUNT];
    100 	struct iwn_rbuf		rbuf[IWN_RBUF_COUNT];
    101 	SLIST_HEAD(, iwn_rbuf)	freelist;
    102 	int			nb_free_entries;
    103 	int			cur;
    104 };
    105 
    106 struct iwn_node {
    107 	struct	ieee80211_node		ni;	/* must be the first */
    108 	struct	ieee80211_amrr_node	amn;
    109 };
    110 
    111 struct iwn_calib_state {
    112 	uint8_t		state;
    113 #define IWN_CALIB_STATE_INIT	0
    114 #define IWN_CALIB_STATE_ASSOC	1
    115 #define IWN_CALIB_STATE_RUN	2
    116 
    117 	u_int		nbeacons;
    118 	uint32_t	noise[3];
    119 	uint32_t	rssi[3];
    120 	uint32_t	corr_ofdm_x1;
    121 	uint32_t	corr_ofdm_mrc_x1;
    122 	uint32_t	corr_ofdm_x4;
    123 	uint32_t	corr_ofdm_mrc_x4;
    124 	uint32_t	corr_cck_x4;
    125 	uint32_t	corr_cck_mrc_x4;
    126 	uint32_t	bad_plcp_ofdm;
    127 	uint32_t	fa_ofdm;
    128 	uint32_t	bad_plcp_cck;
    129 	uint32_t	fa_cck;
    130 	uint32_t	low_fa;
    131 	uint8_t		cck_state;
    132 #define IWN_CCK_STATE_INIT	0
    133 #define IWN_CCK_STATE_LOFA	1
    134 #define IWN_CCK_STATE_HIFA	2
    135 
    136 	uint8_t		noise_samples[20];
    137 	u_int		cur_noise_sample;
    138 	uint8_t		noise_ref;
    139 	uint32_t	energy_samples[10];
    140 	u_int		cur_energy_sample;
    141 	uint32_t	energy_cck;
    142 };
    143 
    144 struct iwn_softc {
    145 	device_t			sc_dev;
    146 	struct ethercom	 	sc_ec;
    147 	struct ieee80211com	sc_ic;
    148 	int			(*sc_newstate)(struct ieee80211com *,
    149 			enum ieee80211_state, int);
    150 
    151 	struct ieee80211_amrr	amrr;
    152 
    153 	bus_dma_tag_t		sc_dmat;
    154 
    155 	/* shared area */
    156 	struct iwn_dma_info	shared_dma;
    157 	struct iwn_shared	*shared;
    158 
    159 	/* "keep warm" page */
    160 	struct iwn_dma_info	kw_dma;
    161 
    162 	/* firmware DMA transfer */
    163 	struct iwn_dma_info	fw_dma;
    164 
    165 	/* rings */
    166 	struct iwn_tx_ring	txq[IWN_NTXQUEUES];
    167 	struct iwn_rx_ring	rxq;
    168 
    169 	bus_space_tag_t		sc_st;
    170 	bus_space_handle_t	sc_sh;
    171 	void 			*sc_ih;
    172 	pci_chipset_tag_t	sc_pct;
    173 	pcitag_t		sc_pcitag;
    174 	bus_size_t		sc_sz;
    175 
    176 	struct callout calib_to;
    177 	int			calib_cnt;
    178 	struct iwn_calib_state	calib;
    179 
    180 	struct iwn_rx_stat	last_rx_stat;
    181 	int			last_rx_valid;
    182 	struct iwn_ucode_info	ucode_info;
    183 	struct iwn_config	config;
    184 	uint32_t		rawtemp;
    185 	int			temp;
    186 	int			noise;
    187 	uint8_t			antmsk;
    188 
    189 	struct iwn_eeprom_band	bands[IWN_NBANDS];
    190 	int16_t			eeprom_voltage;
    191 	int8_t			maxpwr2GHz;
    192 	int8_t			maxpwr5GHz;
    193 	int8_t			maxpwr[IEEE80211_CHAN_MAX];
    194 
    195 	int			sc_tx_timer;
    196 
    197 #if NBPFILTER > 0
    198 	void *			sc_drvbpf;
    199 
    200 	union {
    201 		struct iwn_rx_radiotap_header th;
    202 		uint8_t	pad[IEEE80211_RADIOTAP_HDRLEN];
    203 	} sc_rxtapu;
    204 #define sc_rxtap	sc_rxtapu.th
    205 	int			sc_rxtap_len;
    206 
    207 	union {
    208 		struct iwn_tx_radiotap_header th;
    209 		uint8_t	pad[IEEE80211_RADIOTAP_HDRLEN];
    210 	} sc_txtapu;
    211 #define sc_txtap	sc_txtapu.th
    212 	int			sc_txtap_len;
    213 #endif
    214 
    215 	bool		is_scanning;
    216 };
    217