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