Merge from vendor branch CVS:
[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  * $DragonFly: src/sys/dev/netif/ipw/Attic/if_ipwvar.h,v 1.5 2005/11/29 17:15:56 dillon Exp $
29  */
30
31 struct ipw_firmware {
32         void    *main;
33         int     main_size;
34         void    *ucode;
35         int     ucode_size;
36 };
37
38 struct ipw_soft_bd {
39         struct ipw_bd   *bd;
40         int             type;
41 #define IPW_SBD_TYPE_NOASSOC    0
42 #define IPW_SBD_TYPE_COMMAND    1
43 #define IPW_SBD_TYPE_HEADER     2
44 #define IPW_SBD_TYPE_DATA       3
45         void            *priv;
46 };
47
48 struct ipw_soft_hdr {
49         struct ipw_hdr                  hdr;
50         bus_dmamap_t                    map;
51         SLIST_ENTRY(ipw_soft_hdr)       next;
52 };
53
54 struct ipw_soft_buf {
55         struct mbuf                     *m;
56         struct ieee80211_node           *ni;
57         bus_dmamap_t                    map;
58         SLIST_ENTRY(ipw_soft_buf)       next;
59 };
60
61 #define IPW_MAX_NSEG    6
62 struct ipw_dma_mapping {
63         bus_dma_segment_t segs[IPW_MAX_NSEG];
64         int nseg;
65         bus_size_t mapsize;
66 };
67
68 struct ipw_rx_radiotap_header {
69         struct ieee80211_radiotap_header wr_ihdr;
70         u_int8_t        wr_flags;
71         u_int16_t       wr_chan_freq;
72         u_int16_t       wr_chan_flags;
73         u_int8_t        wr_antsignal;
74 };
75
76 #define IPW_RX_RADIOTAP_PRESENT                                         \
77         ((1 << IEEE80211_RADIOTAP_FLAGS) |                              \
78          (1 << IEEE80211_RADIOTAP_CHANNEL) |                            \
79          (1 << IEEE80211_RADIOTAP_DB_ANTSIGNAL))
80
81 struct ipw_tx_radiotap_header {
82         struct ieee80211_radiotap_header wt_ihdr;
83         u_int8_t        wt_flags;
84         u_int16_t       wt_chan_freq;
85         u_int16_t       wt_chan_flags;
86 };
87
88 #define IPW_TX_RADIOTAP_PRESENT                                         \
89         ((1 << IEEE80211_RADIOTAP_FLAGS) |                              \
90          (1 << IEEE80211_RADIOTAP_CHANNEL))
91
92 struct ipw_softc {
93         struct ieee80211com             sc_ic;
94         int                             (*sc_newstate)(struct ieee80211com *,
95                                             enum ieee80211_state, int);
96         struct ipw_firmware             fw;
97         u_int32_t                       flags;
98 #define IPW_FLAG_FW_CACHED          (1 << 0)
99 #define IPW_FLAG_FW_INITED          (1 << 1)
100 #define IPW_FLAG_HAS_RADIO_SWITCH   (1 << 2)
101
102         struct resource                 *irq;
103         struct resource                 *mem;
104         bus_space_tag_t                 sc_st;
105         bus_space_handle_t              sc_sh;
106         void                            *sc_ih;
107
108         int                             authmode;
109         int                             sc_tx_timer;
110
111         bus_dma_tag_t                   tbd_dmat;
112         bus_dma_tag_t                   rbd_dmat;
113         bus_dma_tag_t                   status_dmat;
114         bus_dma_tag_t                   cmd_dmat;
115         bus_dma_tag_t                   hdr_dmat;
116         bus_dma_tag_t                   txbuf_dmat;
117         bus_dma_tag_t                   rxbuf_dmat;
118
119         bus_dmamap_t                    tbd_map;
120         bus_dmamap_t                    rbd_map;
121         bus_dmamap_t                    status_map;
122         bus_dmamap_t                    cmd_map;
123
124         bus_addr_t                      tbd_phys;
125         bus_addr_t                      rbd_phys;
126         bus_addr_t                      status_phys;
127
128         struct ipw_bd                   *tbd_list;
129         struct ipw_bd                   *rbd_list;
130         struct ipw_status               *status_list;
131
132         struct ipw_cmd                  cmd;
133         struct ipw_soft_bd              stbd_list[IPW_NTBD];
134         struct ipw_soft_buf             tx_sbuf_list[IPW_NDATA];
135         struct ipw_soft_hdr             shdr_list[IPW_NDATA];
136         struct ipw_soft_bd              srbd_list[IPW_NRBD];
137         struct ipw_soft_buf             rx_sbuf_list[IPW_NRBD];
138
139         SLIST_HEAD(, ipw_soft_hdr)      free_shdr;
140         SLIST_HEAD(, ipw_soft_buf)      free_sbuf;
141
142         u_int32_t                       table1_base;
143         u_int32_t                       table2_base;
144
145         u_int32_t                       txcur;
146         u_int32_t                       txold;
147         int                             txfree;
148         u_int32_t                       rxcur;
149
150         struct bpf_if                   *sc_drvbpf;
151
152         union {
153                 struct ipw_rx_radiotap_header th;
154                 u_int8_t        pad[64];
155         } sc_rxtapu;
156 #define sc_rxtap        sc_rxtapu.th
157         int                             sc_rxtap_len;
158
159         union {
160                 struct ipw_tx_radiotap_header th;
161                 u_int8_t        pad[64];
162         } sc_txtapu;
163 #define sc_txtap        sc_txtapu.th
164         int                             sc_txtap_len;
165         struct sysctl_ctx_list          sysctl_ctx;
166 };
167
168 #define SIOCSLOADFW      _IOW('i', 137, struct ifreq)
169 #define SIOCSKILLFW      _IOW('i', 138, struct ifreq)
170