Merge from vendor branch HOSTAPD:
[dragonfly.git] / sys / dev / netif / ipw / if_ipwvar.h
1 /*-
2  * Copyright (c) 2004, 2005
3  *      Damien Bergamini <damien.bergamini@free.fr>. All rights reserved.
4  *
5  * Redistribution and use in source and binary forms, with or without
6  * modification, are permitted provided that the following conditions
7  * are met:
8  * 1. Redistributions of source code must retain the above copyright
9  *    notice unmodified, this list of conditions, and the following
10  *    disclaimer.
11  * 2. Redistributions in binary form must reproduce the above copyright
12  *    notice, this list of conditions and the following disclaimer in the
13  *    documentation and/or other materials provided with the distribution.
14  *
15  * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
16  * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
17  * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
18  * ARE DISCLAIMED.  IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
19  * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
20  * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
21  * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
22  * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
23  * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
24  * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
25  * SUCH DAMAGE.
26  *
27  * $Id: if_ipwvar.h,v 1.2.2.1 2005/01/13 20:01:04 damien Exp $
28  * $FreeBSD: src/sys/dev/ipw/if_ipwvar.h,v 1.3 2005/06/10 16:49:11 brooks Exp $
29  * $DragonFly: src/sys/dev/netif/ipw/Attic/if_ipwvar.h,v 1.6 2006/05/18 13:51:45 sephe Exp $
30  */
31
32 struct ipw_firmware {
33         void    *main;
34         int     main_size;
35         void    *ucode;
36         int     ucode_size;
37 };
38
39 struct ipw_soft_bd {
40         struct ipw_bd   *bd;
41         int             type;
42 #define IPW_SBD_TYPE_NOASSOC    0
43 #define IPW_SBD_TYPE_COMMAND    1
44 #define IPW_SBD_TYPE_HEADER     2
45 #define IPW_SBD_TYPE_DATA       3
46         void            *priv;
47 };
48
49 struct ipw_soft_hdr {
50         struct ipw_hdr                  hdr;
51         bus_dmamap_t                    map;
52         SLIST_ENTRY(ipw_soft_hdr)       next;
53 };
54
55 struct ipw_soft_buf {
56         struct mbuf                     *m;
57         struct ieee80211_node           *ni;
58         bus_dmamap_t                    map;
59         SLIST_ENTRY(ipw_soft_buf)       next;
60 };
61
62 #define IPW_MAX_NSEG    6
63 struct ipw_dma_mapping {
64         bus_dma_segment_t segs[IPW_MAX_NSEG];
65         int nseg;
66         bus_size_t mapsize;
67 };
68
69 struct ipw_rx_radiotap_header {
70         struct ieee80211_radiotap_header wr_ihdr;
71         u_int8_t        wr_flags;
72         u_int16_t       wr_chan_freq;
73         u_int16_t       wr_chan_flags;
74         u_int8_t        wr_antsignal;
75 };
76
77 #define IPW_RX_RADIOTAP_PRESENT                                         \
78         ((1 << IEEE80211_RADIOTAP_FLAGS) |                              \
79          (1 << IEEE80211_RADIOTAP_CHANNEL) |                            \
80          (1 << IEEE80211_RADIOTAP_DB_ANTSIGNAL))
81
82 struct ipw_tx_radiotap_header {
83         struct ieee80211_radiotap_header wt_ihdr;
84         u_int8_t        wt_flags;
85         u_int16_t       wt_chan_freq;
86         u_int16_t       wt_chan_flags;
87 };
88
89 #define IPW_TX_RADIOTAP_PRESENT                                         \
90         ((1 << IEEE80211_RADIOTAP_FLAGS) |                              \
91          (1 << IEEE80211_RADIOTAP_CHANNEL))
92
93 struct ipw_softc {
94         struct ieee80211com             sc_ic;
95         int                             (*sc_newstate)(struct ieee80211com *,
96                                             enum ieee80211_state, int);
97         struct ipw_firmware             fw;
98         u_int32_t                       flags;
99 #define IPW_FLAG_FW_CACHED          (1 << 0)
100 #define IPW_FLAG_FW_INITED          (1 << 1)
101 #define IPW_FLAG_HAS_RADIO_SWITCH   (1 << 2)
102 #define IPW_FLAG_FW_WARNED          (1 << 3)
103
104         int                             irq_rid;
105         int                             mem_rid;
106         struct resource                 *irq;
107         struct resource                 *mem;
108         bus_space_tag_t                 sc_st;
109         bus_space_handle_t              sc_sh;
110         void                            *sc_ih;
111
112         int                             sc_tx_timer;
113
114         bus_dma_tag_t                   tbd_dmat;
115         bus_dma_tag_t                   rbd_dmat;
116         bus_dma_tag_t                   status_dmat;
117         bus_dma_tag_t                   cmd_dmat;
118         bus_dma_tag_t                   hdr_dmat;
119         bus_dma_tag_t                   txbuf_dmat;
120         bus_dma_tag_t                   rxbuf_dmat;
121
122         bus_dmamap_t                    tbd_map;
123         bus_dmamap_t                    rbd_map;
124         bus_dmamap_t                    status_map;
125         bus_dmamap_t                    cmd_map;
126
127         bus_addr_t                      tbd_phys;
128         bus_addr_t                      rbd_phys;
129         bus_addr_t                      status_phys;
130
131         struct ipw_bd                   *tbd_list;
132         struct ipw_bd                   *rbd_list;
133         struct ipw_status               *status_list;
134
135         struct ipw_cmd                  cmd;
136         struct ipw_soft_bd              stbd_list[IPW_NTBD];
137         struct ipw_soft_buf             tx_sbuf_list[IPW_NDATA];
138         struct ipw_soft_hdr             shdr_list[IPW_NDATA];
139         struct ipw_soft_bd              srbd_list[IPW_NRBD];
140         struct ipw_soft_buf             rx_sbuf_list[IPW_NRBD];
141
142         SLIST_HEAD(, ipw_soft_hdr)      free_shdr;
143         SLIST_HEAD(, ipw_soft_buf)      free_sbuf;
144
145         u_int32_t                       table1_base;
146         u_int32_t                       table2_base;
147
148         u_int32_t                       txcur;
149         u_int32_t                       txold;
150         int                             txfree;
151         u_int32_t                       rxcur;
152
153         int                             dwelltime;
154
155         struct bpf_if                   *sc_drvbpf;
156
157         union {
158                 struct ipw_rx_radiotap_header th;
159                 u_int8_t        pad[64];
160         } sc_rxtapu;
161 #define sc_rxtap        sc_rxtapu.th
162         int                             sc_rxtap_len;
163
164         union {
165                 struct ipw_tx_radiotap_header th;
166                 u_int8_t        pad[64];
167         } sc_txtapu;
168 #define sc_txtap        sc_txtapu.th
169         int                             sc_txtap_len;
170         struct sysctl_ctx_list          sysctl_ctx;
171 };
172
173 #define SIOCSLOADFW      _IOW('i', 137, struct ifreq)
174 #define SIOCSKILLFW      _IOW('i', 138, struct ifreq)
175