Merge branch 'vendor/LESS'
[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  * $FreeBSD: src/sys/dev/iwi/if_iwivar.h,v 1.4.2.1 2005/09/26 17:31:36 damien Exp $
32  * $DragonFly: src/sys/dev/netif/iwi/if_iwivar.h,v 1.6 2006/08/12 13:43:21 sephe Exp $
33  */
34
35 struct iwi_firmware {
36         struct fw_image *fw_image;
37         int8_t  *boot;
38         int     boot_size;
39         uint8_t *ucode;
40         int     ucode_size;
41         uint8_t *main;
42         int     main_size;
43 };
44
45 struct iwi_rx_radiotap_header {
46         struct ieee80211_radiotap_header wr_ihdr;
47         uint8_t         wr_flags;
48         uint8_t         wr_rate;
49         uint16_t        wr_chan_freq;
50         uint16_t        wr_chan_flags;
51         uint8_t         wr_antsignal;
52         uint8_t         wr_antenna;
53 };
54
55 #define IWI_RX_RADIOTAP_PRESENT                                         \
56         ((1 << IEEE80211_RADIOTAP_FLAGS) |                              \
57          (1 << IEEE80211_RADIOTAP_RATE) |                               \
58          (1 << IEEE80211_RADIOTAP_CHANNEL) |                            \
59          (1 << IEEE80211_RADIOTAP_DB_ANTSIGNAL) |                       \
60          (1 << IEEE80211_RADIOTAP_ANTENNA))
61
62 struct iwi_tx_radiotap_header {
63         struct ieee80211_radiotap_header wt_ihdr;
64         uint8_t         wt_flags;
65         uint16_t        wt_chan_freq;
66         uint16_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_cmd_ring {
74         bus_dma_tag_t           desc_dmat;
75         bus_dmamap_t            desc_map;
76         bus_addr_t              physaddr;
77         struct iwi_cmd_desc     *desc;
78         int                     count;
79         int                     queued;
80         int                     cur;
81         int                     next;
82 };
83
84 struct iwi_tx_data {
85         bus_dmamap_t            map;
86         struct mbuf             *m;
87         struct ieee80211_node   *ni;
88 };
89
90 struct iwi_tx_ring {
91         bus_dma_tag_t           desc_dmat;
92         bus_dma_tag_t           data_dmat;
93         bus_dmamap_t            desc_map;
94         bus_addr_t              physaddr;
95         bus_addr_t              csr_ridx;
96         bus_addr_t              csr_widx;
97         struct iwi_tx_desc      *desc;
98         struct iwi_tx_data      *data;
99         int                     count;
100         int                     queued;
101         int                     cur;
102         int                     next;
103 };
104
105 struct iwi_rx_data {
106         bus_dmamap_t    map;
107         bus_addr_t      physaddr;
108         uint32_t        reg;
109         struct mbuf     *m;
110 };
111
112 struct iwi_rx_ring {
113         bus_dma_tag_t           data_dmat;
114         struct iwi_rx_data      *data;
115         int                     count;
116         int                     cur;
117 };
118
119 struct iwi_node {
120         struct ieee80211_node   in_node;
121         int                     in_station;
122 #define IWI_MAX_IBSSNODE_NBYTE  4
123 #define IWI_MAX_IBSSNODE        (IWI_MAX_IBSSNODE_NBYTE * NBBY)
124 };
125
126 struct iwi_softc {
127         struct ieee80211com     sc_ic;
128         int                     (*sc_newstate)(struct ieee80211com *,
129                                     enum ieee80211_state, int);
130         void                    (*sc_node_free)(struct ieee80211_node *);
131         device_t                sc_dev;
132
133         struct iwi_firmware     fw;
134         uint32_t                flags;
135 #define IWI_FLAG_FW_INITED      0x02
136 #define IWI_FLAG_FW_WARNED      0x04
137 #define IWI_FLAG_SCANNING       0x08
138 #define IWI_FLAG_EXIT           0x10    /* detaching */
139 #define IWI_FLAG_RESET          0x20    /* need to reset firmware */
140 #define IWI_FLAG_MONITOR        0x40    /* monitor thread was created */
141
142         struct iwi_cmd_ring     cmdq;
143         struct iwi_tx_ring      txq[WME_NUM_AC];
144         struct iwi_rx_ring      rxq;
145
146         struct resource         *irq;
147         struct resource         *mem;
148         bus_space_tag_t         sc_st;
149         bus_space_handle_t      sc_sh;
150         void                    *sc_ih;
151         int                     mem_rid;
152         int                     irq_rid;
153
154         int                     antenna;
155         int                     dwelltime;
156         int                     bluetooth;
157
158         int                     sc_tx_timer;
159
160         struct bpf_if           *sc_drvbpf;
161
162         union {
163                 struct iwi_rx_radiotap_header th;
164                 uint8_t pad[64];
165         }                       sc_rxtapu;
166 #define sc_rxtap        sc_rxtapu.th
167         int                     sc_rxtap_len;
168
169         union {
170                 struct iwi_tx_radiotap_header th;
171                 uint8_t pad[64];
172         }                       sc_txtapu;
173 #define sc_txtap        sc_txtapu.th
174         int                     sc_txtap_len;
175
176         uint8_t                 sc_ibss_node[IWI_MAX_IBSSNODE_NBYTE];
177
178         struct sysctl_ctx_list  sysctl_ctx;
179         struct sysctl_oid       *sysctl_tree;
180         struct thread           *sc_fw_monitor;
181 };
182
183 #define IWI_FW_PATH     "iwi/2200/3.0/ipw2200-%s.fw"
184
185 #define IWI_FW_INITIALIZED(sc)  (sc + 1)
186 #define IWI_FW_CMD_ACKED(sc)    (sc + 2)
187 #define IWI_FW_WAKE_MONITOR(sc) (sc + 3)
188 #define IWI_FW_EXIT_MONITOR(sc) (sc + 4)