1 /* $OpenBSD: if_iwivar.h,v 1.18 2006/08/19 12:03:05 damien Exp $ */
2
3 /*-
4 * Copyright (c) 2004-2006
5 * Damien Bergamini <damien.bergamini@free.fr>. All rights reserved.
6 *
7 * Redistribution and use in source and binary forms, with or without
8 * modification, are permitted provided that the following conditions
9 * are met:
10 * 1. Redistributions of source code must retain the above copyright
11 * notice unmodified, this list of conditions, and the following
12 * disclaimer.
13 * 2. Redistributions in binary form must reproduce the above copyright
14 * notice, this list of conditions and the following disclaimer in the
15 * documentation and/or other materials provided with the distribution.
16 *
17 * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
18 * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
19 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
20 * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
21 * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
22 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
23 * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
24 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
25 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
26 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
27 * SUCH DAMAGE.
28 */
29
30 struct iwi_rx_radiotap_header {
31 struct ieee80211_radiotap_header wr_ihdr;
32 uint8_t wr_flags;
33 uint8_t wr_rate;
34 uint16_t wr_chan_freq;
35 uint16_t wr_chan_flags;
36 uint8_t wr_antsignal;
37 uint8_t wr_antenna;
38 } __packed;
39
40 #define IWI_RX_RADIOTAP_PRESENT \
41 ((1 << IEEE80211_RADIOTAP_FLAGS) | \
42 (1 << IEEE80211_RADIOTAP_RATE) | \
43 (1 << IEEE80211_RADIOTAP_CHANNEL) | \
44 (1 << IEEE80211_RADIOTAP_DB_ANTSIGNAL) | \
45 (1 << IEEE80211_RADIOTAP_ANTENNA))
46
47 struct iwi_tx_radiotap_header {
48 struct ieee80211_radiotap_header wt_ihdr;
49 uint8_t wt_flags;
50 uint16_t wt_chan_freq;
51 uint16_t wt_chan_flags;
52 } __packed;
53
54 #define IWI_TX_RADIOTAP_PRESENT \
55 ((1 << IEEE80211_RADIOTAP_FLAGS) | \
56 (1 << IEEE80211_RADIOTAP_CHANNEL))
57
58
59 struct iwi_cmd_ring {
60 bus_dmamap_t map;
61 bus_dma_segment_t seg;
62 struct iwi_cmd_desc desc[IWI_CMD_RING_COUNT];
63 int queued;
64 int cur;
65 int next;
66 };
67
68 struct iwi_tx_data {
69 bus_dmamap_t map;
70 struct mbuf *m;
71 struct ieee80211_node *ni;
72 };
73
74 struct iwi_tx_ring {
75 bus_dmamap_t map;
76 bus_dma_segment_t seg;
77 bus_size_t csr_ridx;
78 bus_size_t csr_widx;
79 struct iwi_tx_desc *desc;
80 struct iwi_tx_data data[IWI_TX_RING_COUNT];
81 int queued;
82 int cur;
83 int next;
84 };
85
86 struct iwi_rx_data {
87 bus_dmamap_t map;
88 struct mbuf *m;
89 uint32_t reg;
90 };
91
92 struct iwi_rx_ring {
93 struct iwi_rx_data data[IWI_RX_RING_COUNT];
94 int cur;
95 };
96
97 struct iwi_softc {
98 struct device sc_dev;
99
100 struct ieee80211com sc_ic;
101 int (*sc_newstate)(struct ieee80211com *,
102 enum ieee80211_state, int);
103
104 uint32_t flags;
105 #define IWI_FLAG_FW_INITED (1 << 0)
106
107 bus_dma_tag_t sc_dmat;
108
109 struct iwi_cmd_ring cmdq;
110 struct iwi_tx_ring txq[4];
111 struct iwi_rx_ring rxq;
112
113 #define IWI_MAX_NODE 32
114 uint8_t sta[IWI_MAX_NODE][IEEE80211_ADDR_LEN];
115 uint8_t nsta;
116
117 bus_space_tag_t sc_st;
118 bus_space_handle_t sc_sh;
119 void *sc_ih;
120 pci_chipset_tag_t sc_pct;
121 pcitag_t sc_pcitag;
122 bus_size_t sc_sz;
123
124 int sc_tx_timer;
125
126 void *powerhook;
127
128 #if NBPFILTER > 0
129 caddr_t sc_drvbpf;
130
131 union {
132 struct iwi_rx_radiotap_header th;
133 uint8_t pad[64];
134 } sc_rxtapu;
135 #define sc_rxtap sc_rxtapu.th
136 int sc_rxtap_len;
137
138 union {
139 struct iwi_tx_radiotap_header th;
140 uint8_t pad[64];
141 } sc_txtapu;
142 #define sc_txtap sc_txtapu.th
143 int sc_txtap_len;
144 #endif
145 };