Merge from vendor branch FILE:
[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.1 2005/03/06 05:02:02 dillon 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 #if NBPFILTER > 0
137         struct bpf_if           *sc_drvbpf;
138
139         union {
140                 struct iwi_rx_radiotap_header th;
141                 u_int8_t        pad[64];
142         } sc_rxtapu;
143 #define sc_rxtap        sc_rxtapu.th
144         int                     sc_rxtap_len;
145
146         union {
147                 struct iwi_tx_radiotap_header th;
148                 u_int8_t        pad[64];
149         } sc_txtapu;
150 #define sc_txtap        sc_txtapu.th
151         int                     sc_txtap_len;
152 #endif
153         int                     num_stations;
154         u_int8_t                stations[IWI_FW_MAX_STATIONS][ETHER_ADDR_LEN];
155
156         struct lwkt_token       sc_lock;
157         struct lwkt_token       sc_intrlock;
158
159         struct sysctl_ctx_list  sysctl_ctx;
160         struct sysctl_oid       *sysctl_tree;
161
162         int                     debug_level;
163
164         int                     enable_bg_autodetect;
165         int                     enable_bt_coexist;
166         int                     enable_cts_to_self;
167         int                     antenna_diversity; /* 1 = A, 3 = B, 0 = A + B */
168         int                     enable_neg_best_first;
169         int                     disable_unicast_decryption;
170         int                     disable_multicast_decryption;
171
172         struct thread           *event_thread;
173
174         struct iwi_associate    assoc;
175
176         int                     scan_counter;
177
178 };
179
180 #define SIOCSLOADFW      _IOW('i', 137, struct ifreq)
181 #define SIOCSLOADIBSSFW  _IOW('i', 138, struct ifreq)
182 #define SIOCSKILLFW      _IOW('i', 139, struct ifreq)
183
184 #define IWI_LOCK_INIT(tok)     lwkt_token_init(tok)
185 #define IWI_LOCK_DESTROY(tok)  lwkt_token_uninit(tok)
186
187 #define IWI_LOCK_INFO          struct lwkt_tokref tokinfo
188 #define IWI_INTRLOCK_INFO      struct lwkt_tokref intrtokinfo
189 #define IWI_INTRLOCK(_sc)      lwkt_gettoken(&intrtokinfo,(&(_sc)->sc_intrlock))
190 #define IWI_INTRUNLOCK(SC)     lwkt_reltoken(&intrtokinfo)
191 #define IWI_LOCK(_sc)          lwkt_gettoken(&tokinfo,&((_sc)->sc_lock))
192 #define IWI_UNLOCK(SC)         lwkt_reltoken(&tokinfo)
193
194 /*
195  * Holding a token is not enough for iwi_tx_start() the DMA send
196  * routine. Revert back to the old ipl mechanism for now.
197  */
198
199 #define IWI_IPLLOCK_INFO       int saved_ipl_level
200 #define IWI_IPLLOCK(_sc)       saved_ipl_level =  splimp()
201 #define IWI_IPLUNLOCK(_sc)     splx(saved_ipl_level)
202
203 /* tsleepable events */
204 #define IWI_FW_WAKE_MONITOR(sc)      (sc + 1)
205 #define IWI_FW_INITIALIZED(sc)       (sc + 2)
206 #define IWI_FW_CMD_ACKED(sc)         (sc + 3)
207 #define IWI_FW_SCAN_COMPLETED(sc)    (sc + 4)
208 #define IWI_FW_DEASSOCIATED(sc)      (sc + 5)
209 #define IWI_FW_MON_EXIT(sc)          (sc + 6)
210