Merge from vendor branch CVS:
[dragonfly.git] / sys / dev / netif / iwi / if_iwivar.h
1 /*
2  * Copyright (c) 2004, 2005
3  *      Damien Bergamini <damien.bergamini@free.fr>.
4  * Copyright (c) 2004, 2005
5  *      Andrew Atrens <atrens@nortelnetworks.com>.
6  *
7  * All rights reserved.
8  *
9  * Redistribution and use in source and binary forms, with or without
10  * modification, are permitted provided that the following conditions
11  * are met:
12  * 1. Redistributions of source code must retain the above copyright
13  *    notice unmodified, this list of conditions, and the following
14  *    disclaimer.
15  * 2. Redistributions in binary form must reproduce the above copyright
16  *    notice, this list of conditions and the following disclaimer in the
17  *    documentation and/or other materials provided with the distribution.
18  *
19  * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
20  * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
21  * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
22  * ARE DISCLAIMED.  IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
23  * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
24  * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
25  * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
26  * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
27  * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
28  * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
29  * SUCH DAMAGE.
30  *
31  * $DragonFly: src/sys/dev/netif/iwi/if_iwivar.h,v 1.3 2005/06/27 11:28:54 corecode Exp $
32  */
33
34 struct iwi_firmware {
35         void    *boot;
36         int     boot_size;
37         void    *ucode;
38         int     ucode_size;
39         void    *main;
40         int     main_size;
41 };
42
43 struct iwi_rx_radiotap_header {
44         struct ieee80211_radiotap_header wr_ihdr;
45         u_int8_t        wr_flags;
46         u_int8_t        wr_rate;
47         u_int16_t       wr_chan_freq;
48         u_int16_t       wr_chan_flags;
49         u_int8_t        wr_antsignal;
50         u_int8_t        wr_antnoise;
51         u_int8_t        wr_antenna;
52 };
53
54 #define IWI_RX_RADIOTAP_PRESENT                                         \
55         ((1 << IEEE80211_RADIOTAP_FLAGS) |                              \
56          (1 << IEEE80211_RADIOTAP_RATE) |                               \
57          (1 << IEEE80211_RADIOTAP_CHANNEL) |                            \
58          (1 << IEEE80211_RADIOTAP_DB_ANTSIGNAL) |                       \
59          (1 << IEEE80211_RADIOTAP_DB_ANTNOISE) |                        \
60          (1 << IEEE80211_RADIOTAP_ANTENNA))
61
62 struct iwi_tx_radiotap_header {
63         struct ieee80211_radiotap_header wt_ihdr;
64         u_int8_t        wt_flags;
65         u_int16_t       wt_chan_freq;
66         u_int16_t       wt_chan_flags;
67 };
68
69 #define IWI_TX_RADIOTAP_PRESENT                                         \
70         ((1 << IEEE80211_RADIOTAP_FLAGS) |                              \
71          (1 << IEEE80211_RADIOTAP_CHANNEL))
72
73 struct iwi_softc {
74         struct ieee80211com     sc_ic;
75         int                     (*sc_newstate)(struct ieee80211com *,
76                                     enum ieee80211_state, int);
77         device_t                sc_dev;
78
79
80         struct iwi_firmware     fw;
81         u_int32_t               flags;
82 #define IWI_FLAG_FW_CACHED      (1 << 0)
83 #define IWI_FLAG_FW_IBSS        (1 << 1)
84 #define IWI_FLAG_FW_INITED      (1 << 2)
85 #define IWI_FLAG_SCANNING       (1 << 3)
86 #define IWI_FLAG_SCAN_COMPLETE  (1 << 4)
87 #define IWI_FLAG_SCAN_ABORT     (1 << 5)
88 #define IWI_FLAG_ASSOCIATED     (1 << 6)
89 #define IWI_FLAG_RF_DISABLED    (1 << 7)
90 #define IWI_FLAG_RESET          (1 << 8)
91 #define IWI_FLAG_EXIT           (1 << 9)
92
93         struct iwi_tx_desc      *tx_desc;
94         bus_dma_tag_t           iwi_parent_tag;
95         bus_dma_tag_t           tx_ring_dmat;
96         bus_dmamap_t            tx_ring_map;
97         bus_addr_t              tx_ring_pa;
98         bus_dma_tag_t           tx_buf_dmat;
99
100         struct iwi_tx_buf {
101                 bus_dmamap_t            map;
102                 struct mbuf             *m;
103                 struct ieee80211_node   *ni;
104         } tx_buf[IWI_TX_RING_SIZE];
105
106         int                     tx_cur;
107         int                     tx_old;
108         int                     tx_queued;
109
110         struct iwi_cmd_desc     *cmd_desc;
111         bus_dma_tag_t           cmd_ring_dmat;
112         bus_dmamap_t            cmd_ring_map;
113         bus_addr_t              cmd_ring_pa;
114         int                     cmd_cur;
115
116         bus_dma_tag_t           rx_buf_dmat;
117
118         struct iwi_rx_buf {
119                 bus_dmamap_t    map;
120                 bus_addr_t      physaddr;
121                 struct mbuf     *m;
122         } rx_buf[IWI_RX_RING_SIZE];
123
124         int                     rx_cur;
125
126         struct resource         *irq;
127         struct resource         *mem;
128         bus_space_tag_t         sc_st;
129         bus_space_handle_t      sc_sh;
130         void                    *sc_ih;
131
132         int                     authmode;
133
134         int                     sc_tx_timer;
135
136         struct bpf_if           *sc_drvbpf;
137
138         union {
139                 struct iwi_rx_radiotap_header th;
140                 u_int8_t        pad[64];
141         } sc_rxtapu;
142 #define sc_rxtap        sc_rxtapu.th
143         int                     sc_rxtap_len;
144
145         union {
146                 struct iwi_tx_radiotap_header th;
147                 u_int8_t        pad[64];
148         } sc_txtapu;
149 #define sc_txtap        sc_txtapu.th
150         int                     sc_txtap_len;
151         int                     num_stations;
152         u_int8_t                stations[IWI_FW_MAX_STATIONS][ETHER_ADDR_LEN];
153
154         struct lwkt_token       sc_lock;
155         struct lwkt_token       sc_intrlock;
156
157         struct sysctl_ctx_list  sysctl_ctx;
158         struct sysctl_oid       *sysctl_tree;
159
160         int                     debug_level;
161
162         int                     enable_bg_autodetect;
163         int                     enable_bt_coexist;
164         int                     enable_cts_to_self;
165         int                     antenna_diversity; /* 1 = A, 3 = B, 0 = A + B */
166         int                     enable_neg_best_first;
167         int                     disable_unicast_decryption;
168         int                     disable_multicast_decryption;
169
170         struct thread           *event_thread;
171
172         struct iwi_associate    assoc;
173
174         int                     scan_counter;
175
176 };
177
178 #define SIOCSLOADFW      _IOW('i', 137, struct ifreq)
179 #define SIOCSLOADIBSSFW  _IOW('i', 138, struct ifreq)
180 #define SIOCSKILLFW      _IOW('i', 139, struct ifreq)
181
182 #define IWI_LOCK_INIT(tok)     lwkt_token_init(tok)
183 #define IWI_LOCK_DESTROY(tok)  lwkt_token_uninit(tok)
184
185 #define IWI_LOCK_INFO          struct lwkt_tokref tokinfo
186 #define IWI_INTRLOCK_INFO      struct lwkt_tokref intrtokinfo
187 #define IWI_INTRLOCK(_sc)      lwkt_gettoken(&intrtokinfo,(&(_sc)->sc_intrlock))
188 #define IWI_INTRUNLOCK(SC)     lwkt_reltoken(&intrtokinfo)
189 #define IWI_LOCK(_sc)          lwkt_gettoken(&tokinfo,&((_sc)->sc_lock))
190 #define IWI_UNLOCK(SC)         lwkt_reltoken(&tokinfo)
191
192 /*
193  * Holding a token is not enough for iwi_tx_start() the DMA send
194  * routine. Revert back to the old ipl mechanism for now.
195  */
196
197 #define IWI_IPLLOCK_INFO
198 #define IWI_IPLLOCK(_sc)        crit_enter()
199 #define IWI_IPLUNLOCK(_sc)      crit_exit()
200
201 /* tsleepable events */
202 #define IWI_FW_WAKE_MONITOR(sc)      (sc + 1)
203 #define IWI_FW_INITIALIZED(sc)       (sc + 2)
204 #define IWI_FW_CMD_ACKED(sc)         (sc + 3)
205 #define IWI_FW_SCAN_COMPLETED(sc)    (sc + 4)
206 #define IWI_FW_DEASSOCIATED(sc)      (sc + 5)
207 #define IWI_FW_MON_EXIT(sc)          (sc + 6)
208