Merge from vendor branch OPENSSL:
[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         void    *boot;
37         int     boot_size;
38         void    *ucode;
39         int     ucode_size;
40         void    *main;
41         int     main_size;
42 };
43
44 struct iwi_rx_radiotap_header {
45         struct ieee80211_radiotap_header wr_ihdr;
46         uint8_t         wr_flags;
47         uint8_t         wr_rate;
48         uint16_t        wr_chan_freq;
49         uint16_t        wr_chan_flags;
50         uint8_t         wr_antsignal;
51         uint8_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_ANTENNA))
60
61 struct iwi_tx_radiotap_header {
62         struct ieee80211_radiotap_header wt_ihdr;
63         uint8_t         wt_flags;
64         uint16_t        wt_chan_freq;
65         uint16_t        wt_chan_flags;
66 };
67
68 #define IWI_TX_RADIOTAP_PRESENT                                         \
69         ((1 << IEEE80211_RADIOTAP_FLAGS) |                              \
70          (1 << IEEE80211_RADIOTAP_CHANNEL))
71
72 struct iwi_cmd_ring {
73         bus_dma_tag_t           desc_dmat;
74         bus_dmamap_t            desc_map;
75         bus_addr_t              physaddr;
76         struct iwi_cmd_desc     *desc;
77         int                     count;
78         int                     queued;
79         int                     cur;
80         int                     next;
81 };
82
83 struct iwi_tx_data {
84         bus_dmamap_t            map;
85         struct mbuf             *m;
86         struct ieee80211_node   *ni;
87 };
88
89 struct iwi_tx_ring {
90         bus_dma_tag_t           desc_dmat;
91         bus_dma_tag_t           data_dmat;
92         bus_dmamap_t            desc_map;
93         bus_addr_t              physaddr;
94         bus_addr_t              csr_ridx;
95         bus_addr_t              csr_widx;
96         struct iwi_tx_desc      *desc;
97         struct iwi_tx_data      *data;
98         int                     count;
99         int                     queued;
100         int                     cur;
101         int                     next;
102 };
103
104 struct iwi_rx_data {
105         bus_dmamap_t    map;
106         bus_addr_t      physaddr;
107         uint32_t        reg;
108         struct mbuf     *m;
109 };
110
111 struct iwi_rx_ring {
112         bus_dma_tag_t           data_dmat;
113         struct iwi_rx_data      *data;
114         int                     count;
115         int                     cur;
116 };
117
118 struct iwi_node {
119         struct ieee80211_node   in_node;
120         int                     in_station;
121 #define IWI_MAX_IBSSNODE_NBYTE  4
122 #define IWI_MAX_IBSSNODE        (IWI_MAX_IBSSNODE_NBYTE * NBBY)
123 };
124
125 struct iwi_softc {
126         struct ieee80211com     sc_ic;
127         int                     (*sc_newstate)(struct ieee80211com *,
128                                     enum ieee80211_state, int);
129         void                    (*sc_node_free)(struct ieee80211_node *);
130         device_t                sc_dev;
131
132         struct iwi_firmware     fw;
133         uint32_t                flags;
134 #define IWI_FLAG_FW_CACHED      0x01
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 SIOCSLOADFW      _IOW('i', 137, struct ifreq)
184 #define SIOCSKILLFW      _IOW('i', 138, struct ifreq)
185
186 #define IWI_FW_INITIALIZED(sc)  (sc + 1)
187 #define IWI_FW_CMD_ACKED(sc)    (sc + 2)
188 #define IWI_FW_WAKE_MONITOR(sc) (sc + 3)
189 #define IWI_FW_EXIT_MONITOR(sc) (sc + 4)