Sync 802.11 support with FreeBSD6:
[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.5 2006/05/18 13:51:45 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 ifnet            *sc_ifp;
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_CACHED      (1 << 0)
136 #define IWI_FLAG_FW_INITED      (1 << 1)
137 #define IWI_FLAG_FW_WARNED      (1 << 2)
138 #define IWI_FLAG_SCANNING       (1 << 3)
139
140         struct iwi_cmd_ring     cmdq;
141         struct iwi_tx_ring      txq[WME_NUM_AC];
142         struct iwi_rx_ring      rxq;
143
144         struct resource         *irq;
145         struct resource         *mem;
146         bus_space_tag_t         sc_st;
147         bus_space_handle_t      sc_sh;
148         void                    *sc_ih;
149         int                     mem_rid;
150         int                     irq_rid;
151
152         int                     antenna;
153         int                     dwelltime;
154         int                     bluetooth;
155
156         int                     sc_tx_timer;
157
158         struct bpf_if           *sc_drvbpf;
159
160         union {
161                 struct iwi_rx_radiotap_header th;
162                 uint8_t pad[64];
163         }                       sc_rxtapu;
164 #define sc_rxtap        sc_rxtapu.th
165         int                     sc_rxtap_len;
166
167         union {
168                 struct iwi_tx_radiotap_header th;
169                 uint8_t pad[64];
170         }                       sc_txtapu;
171 #define sc_txtap        sc_txtapu.th
172         int                     sc_txtap_len;
173
174         uint8_t                 sc_ibss_node[IWI_MAX_IBSSNODE_NBYTE];
175
176         struct sysctl_ctx_list  sysctl_ctx;
177         struct sysctl_oid       *sysctl_tree;
178 };
179
180 #define SIOCSLOADFW      _IOW('i', 137, struct ifreq)
181 #define SIOCSKILLFW      _IOW('i', 138, struct ifreq)
182
183 #define IWI_FW_INITIALIZED(sc)  (sc + 1)
184 #define IWI_FW_CMD_ACKED(sc)    (sc + 2)