Line data Source code
1 : /* $OpenBSD: pgtvar.h,v 1.17 2015/12/11 16:07:01 mpi Exp $ */
2 :
3 : /*
4 : * Copyright (c) 2006 Claudio Jeker <claudio@openbsd.org>
5 : * Copyright (c) 2006 Marcus Glocker <mglocker@openbsd.org>
6 : *
7 : * Permission to use, copy, modify, and distribute this software for any
8 : * purpose with or without fee is hereby granted, provided that the above
9 : * copyright notice and this permission notice appear in all copies.
10 : *
11 : * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
12 : * WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
13 : * MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
14 : * ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
15 : * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
16 : * ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
17 : * OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
18 : */
19 :
20 : /*
21 : * Copyright (c) 2004 Fujitsu Laboratories of America, Inc.
22 : * Copyright (c) 2004 Brian Fundakowski Feldman
23 : * All rights reserved.
24 : *
25 : * Redistribution and use in source and binary forms, with or without
26 : * modification, are permitted provided that the following conditions
27 : * are met:
28 : * 1. Redistributions of source code must retain the above copyright
29 : * notice, this list of conditions and the following disclaimer.
30 : * 2. Redistributions in binary form must reproduce the above copyright
31 : * notice, this list of conditions and the following disclaimer in the
32 : * documentation and/or other materials provided with the distribution.
33 : *
34 : * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
35 : * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
36 : * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
37 : * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
38 : * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
39 : * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
40 : * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
41 : * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
42 : * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
43 : * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
44 : * SUCH DAMAGE.
45 : */
46 :
47 : #ifndef __PGTVAR_H__
48 : #define __PGTVAR_H__
49 :
50 : #define PGT_RX_RADIOTAP_PRESENT \
51 : ((1 << IEEE80211_RADIOTAP_FLAGS) | \
52 : (1 << IEEE80211_RADIOTAP_CHANNEL) | \
53 : (1 << IEEE80211_RADIOTAP_RSSI))
54 :
55 : struct pgt_rx_radiotap_hdr {
56 : struct ieee80211_radiotap_header wr_ihdr;
57 : uint8_t wr_flags;
58 : uint16_t wr_chan_freq;
59 : uint16_t wr_chan_flags;
60 : uint8_t wr_rssi;
61 : uint8_t wr_max_rssi;
62 : } __packed;
63 :
64 : #define PGT_TX_RADIOTAP_PRESENT \
65 : ((1 << IEEE80211_RADIOTAP_FLAGS) | \
66 : (1 << IEEE80211_RADIOTAP_RATE) | \
67 : (1 << IEEE80211_RADIOTAP_CHANNEL))
68 :
69 : struct pgt_tx_radiotap_hdr {
70 : struct ieee80211_radiotap_header wt_ihdr;
71 : uint8_t wt_flags;
72 : uint8_t wt_rate;
73 : uint16_t wt_chan_freq;
74 : uint16_t wt_chan_flags;
75 : } __packed;
76 :
77 : /*
78 : * The struct pgt_desc is used to either enqueue or dequeue pgt_frags
79 : * (packets) when either free or in flight.
80 : */
81 : struct pgt_desc {
82 : TAILQ_ENTRY(pgt_desc) pd_link;
83 : caddr_t pd_mem;
84 : bus_addr_t pd_dmaaddr;
85 : bus_dmamap_t pd_dmam;
86 : bus_dma_segment_t pd_dmas;
87 : struct pgt_frag *pd_fragp;
88 : unsigned int pd_fragnum;
89 : };
90 : TAILQ_HEAD(pgt_descq, pgt_desc);
91 :
92 : /*
93 : * The struct pgt_mgmt_desc is used to enqueue a management request
94 : * and await response.
95 : */
96 : struct pgt_mgmt_desc {
97 : TAILQ_ENTRY(pgt_mgmt_desc) pmd_link;
98 : const void *pmd_sendbuf; /* NULL = get op */
99 : void *pmd_recvbuf; /* NULL = set op */
100 : size_t pmd_len;
101 : uint32_t pmd_oid;
102 : int pmd_error;
103 : };
104 : TAILQ_HEAD(pgt_mgmt_descq, pgt_mgmt_desc);
105 :
106 : /*
107 : * These events are put on the per-device kthread to be
108 : * able to trigger actions from inside the interrupt; as most
109 : * operations require waiting for another interrupt for response
110 : * (that is, management packets), this is common.
111 : */
112 : struct pgt_async_trap {
113 : TAILQ_ENTRY(pgt_async_trap) pa_link;
114 : struct mbuf *pa_mbuf;
115 : /* followed by the rest of the mbuf data */
116 : };
117 :
118 : struct pgt_ieee80211_node {
119 : struct ieee80211_node pin_node;
120 : enum pin_dot1x_authorization {
121 : PIN_DOT1X_UNAUTHORIZED,
122 : PIN_DOT1X_AUTHORIZED
123 : } pin_dot1x_auth_desired, pin_dot1x_auth;
124 : uint16_t pin_mlme_state;
125 : };
126 :
127 : struct pgt_softc {
128 : struct device sc_dev;
129 : struct ieee80211com sc_ic;
130 : unsigned int sc_flags;
131 : #define SC_NEEDS_FIRMWARE 0x00000001 /* do firmware upload on reset */
132 : #define SC_UNINITIALIZED 0x00000002 /* still awaiting initial intr */
133 : #define SC_DYING 0x00000004 /* going away */
134 : #define SC_NEEDS_RESET 0x00000008 /* going to reset when refcnt = 1 */
135 : #define SC_INTR_RESET 0x00000020 /* interrupt resets at end */
136 : #define SC_POWERSAVE 0x00000040 /* device is asleep */
137 : #define SC_NOFREE_ALLNODES 0x00000100 /* do not free assoc w/reinit */
138 : #define SC_START_DESIRED 0x00000200 /* tried to start during mgmt-crit */
139 : #define SC_KTHREAD 0x00000400 /* has a kthread around */
140 : #define SC_ISL3877 0x00000800 /* chipset */
141 : struct timeout sc_chanscan_timer;
142 : /* configuration sysctls */
143 : int sc_dot1x;
144 : int sc_wds;
145 : /* cached values */
146 : int sc_if_flags;
147 : int16_t sc_80211_ioc_wep;
148 : int16_t sc_80211_ioc_auth;
149 : uint32_t sc_noise;
150 : unsigned int sc_debug;
151 : #define SC_DEBUG_QUEUES 0x00000001
152 : #define SC_DEBUG_MGMT 0x00000002
153 : #define SC_DEBUG_UNEXPECTED 0x00000004
154 : #define SC_DEBUG_TRIGGER 0x00000008
155 : #define SC_DEBUG_EVENTS 0x00000010
156 : #define SC_DEBUG_POWER 0x00000020
157 : #define SC_DEBUG_TRAP 0x00000040
158 : #define SC_DEBUG_LINK 0x00000080
159 : #define SC_DEBUG_RXANNEX 0x00000100
160 : #define SC_DEBUG_RXFRAG 0x00000200
161 : #define SC_DEBUG_RXETHER 0x00000400
162 : bus_space_tag_t sc_iotag;
163 : bus_space_handle_t sc_iohandle;
164 : bus_dma_tag_t sc_dmat;
165 :
166 : bus_dmamap_t sc_cbdmam;
167 : bus_dma_segment_t sc_cbdmas;
168 : struct pgt_control_block *sc_cb; /* DMA-mapped control block */
169 :
170 : bus_dmamap_t sc_psmdmam;
171 : bus_dma_segment_t sc_psmdmas;
172 : void *sc_psmbuf; /* DMA-mapped psm frame area */
173 :
174 : int (*sc_newstate)
175 : (struct ieee80211com *,
176 : enum ieee80211_state, int);
177 :
178 : int (*sc_enable)(struct pgt_softc *);
179 : void (*sc_disable)(struct pgt_softc *);
180 : void (*sc_power)(struct pgt_softc *, int);
181 :
182 : struct pgt_mgmt_descq sc_mgmtinprog;
183 : struct pgt_descq sc_freeq[PGT_QUEUE_COUNT];
184 : size_t sc_freeq_count[PGT_QUEUE_COUNT];
185 : struct pgt_descq sc_dirtyq[PGT_QUEUE_COUNT];
186 : size_t sc_dirtyq_count[PGT_QUEUE_COUNT];
187 : int sc_txtimer;
188 : struct pgt_softc_kthread {
189 : struct proc *sck_proc;
190 : int sck_exit, sck_reset, sck_update;
191 : TAILQ_HEAD(, pgt_async_trap) sck_traps;
192 : } sc_kthread;
193 :
194 : #if NBPFILTER > 0
195 : caddr_t sc_drvbpf;
196 :
197 : union {
198 : struct pgt_rx_radiotap_hdr th;
199 : uint8_t pad[64];
200 : } sc_rxtapu;
201 : #define sc_rxtap sc_rxtapu.th
202 : int sc_rxtap_len;
203 :
204 : union {
205 : struct pgt_tx_radiotap_hdr th;
206 : uint8_t pad[64];
207 : } sc_txtapu;
208 : #define sc_txtap sc_txtapu.th
209 : int sc_txtap_len;
210 : #endif
211 : };
212 :
213 : int pgt_intr(void *);
214 : void pgt_attach(struct device *);
215 : int pgt_detach(struct pgt_softc *);
216 : int pgt_activate(struct device *, int);
217 :
218 : static __inline int
219 0 : pgt_queue_is_rx(enum pgt_queue pq)
220 : {
221 0 : return (pq == PGT_QUEUE_DATA_LOW_RX ||
222 0 : pq == PGT_QUEUE_DATA_HIGH_RX ||
223 0 : pq == PGT_QUEUE_MGMT_RX);
224 : }
225 :
226 : static __inline int
227 0 : pgt_queue_is_tx(enum pgt_queue pq)
228 : {
229 0 : return (pq == PGT_QUEUE_DATA_LOW_TX ||
230 0 : pq == PGT_QUEUE_DATA_HIGH_TX ||
231 0 : pq == PGT_QUEUE_MGMT_TX);
232 : }
233 :
234 : static __inline int
235 0 : pgt_queue_is_data(enum pgt_queue pq)
236 : {
237 0 : return (pq == PGT_QUEUE_DATA_LOW_RX ||
238 0 : pq == PGT_QUEUE_DATA_HIGH_RX ||
239 0 : pq == PGT_QUEUE_DATA_LOW_TX ||
240 0 : pq == PGT_QUEUE_DATA_HIGH_TX);
241 : }
242 :
243 : static __inline int
244 0 : pgt_queue_is_mgmt(enum pgt_queue pq)
245 : {
246 0 : return (pq == PGT_QUEUE_MGMT_RX ||
247 0 : pq == PGT_QUEUE_MGMT_TX);
248 : }
249 :
250 : #endif
|