if_wpivar.h revision 1.13 1 1.13 joerg /* $NetBSD: if_wpivar.h,v 1.13 2008/11/12 18:23:08 joerg Exp $ */
2 1.1 simonb
3 1.1 simonb /*-
4 1.1 simonb * Copyright (c) 2006
5 1.1 simonb * Damien Bergamini <damien.bergamini (at) free.fr>
6 1.1 simonb *
7 1.1 simonb * Permission to use, copy, modify, and distribute this software for any
8 1.1 simonb * purpose with or without fee is hereby granted, provided that the above
9 1.1 simonb * copyright notice and this permission notice appear in all copies.
10 1.1 simonb *
11 1.1 simonb * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
12 1.1 simonb * WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
13 1.1 simonb * MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
14 1.1 simonb * ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
15 1.1 simonb * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
16 1.1 simonb * ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
17 1.1 simonb * OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
18 1.1 simonb */
19 1.1 simonb
20 1.1 simonb struct wpi_rx_radiotap_header {
21 1.1 simonb struct ieee80211_radiotap_header wr_ihdr;
22 1.1 simonb uint64_t wr_tsft;
23 1.1 simonb uint8_t wr_flags;
24 1.1 simonb uint8_t wr_rate;
25 1.1 simonb uint16_t wr_chan_freq;
26 1.1 simonb uint16_t wr_chan_flags;
27 1.1 simonb int8_t wr_dbm_antsignal;
28 1.1 simonb int8_t wr_dbm_antnoise;
29 1.1 simonb uint8_t wr_antenna;
30 1.1 simonb };
31 1.1 simonb
32 1.1 simonb #define WPI_RX_RADIOTAP_PRESENT \
33 1.1 simonb ((1 << IEEE80211_RADIOTAP_TSFT) | \
34 1.1 simonb (1 << IEEE80211_RADIOTAP_FLAGS) | \
35 1.1 simonb (1 << IEEE80211_RADIOTAP_RATE) | \
36 1.1 simonb (1 << IEEE80211_RADIOTAP_CHANNEL) | \
37 1.1 simonb (1 << IEEE80211_RADIOTAP_DBM_ANTSIGNAL) | \
38 1.1 simonb (1 << IEEE80211_RADIOTAP_DBM_ANTNOISE) | \
39 1.1 simonb (1 << IEEE80211_RADIOTAP_ANTENNA))
40 1.1 simonb
41 1.1 simonb struct wpi_tx_radiotap_header {
42 1.1 simonb struct ieee80211_radiotap_header wt_ihdr;
43 1.1 simonb uint8_t wt_flags;
44 1.1 simonb uint8_t wt_rate;
45 1.1 simonb uint16_t wt_chan_freq;
46 1.1 simonb uint16_t wt_chan_flags;
47 1.1 simonb uint8_t wt_hwqueue;
48 1.1 simonb };
49 1.1 simonb
50 1.1 simonb #define WPI_TX_RADIOTAP_PRESENT \
51 1.1 simonb ((1 << IEEE80211_RADIOTAP_FLAGS) | \
52 1.1 simonb (1 << IEEE80211_RADIOTAP_RATE) | \
53 1.1 simonb (1 << IEEE80211_RADIOTAP_CHANNEL))
54 1.1 simonb
55 1.1 simonb struct wpi_dma_info {
56 1.3 degroote bus_dma_tag_t tag;
57 1.1 simonb bus_dmamap_t map;
58 1.1 simonb bus_dma_segment_t seg;
59 1.1 simonb bus_addr_t paddr;
60 1.4 christos void * vaddr;
61 1.1 simonb bus_size_t size;
62 1.1 simonb };
63 1.1 simonb
64 1.1 simonb struct wpi_tx_data {
65 1.1 simonb bus_dmamap_t map;
66 1.1 simonb struct mbuf *m;
67 1.1 simonb struct ieee80211_node *ni;
68 1.1 simonb };
69 1.1 simonb
70 1.1 simonb struct wpi_tx_ring {
71 1.1 simonb struct wpi_dma_info desc_dma;
72 1.1 simonb struct wpi_dma_info cmd_dma;
73 1.1 simonb struct wpi_tx_desc *desc;
74 1.1 simonb struct wpi_tx_cmd *cmd;
75 1.1 simonb struct wpi_tx_data *data;
76 1.1 simonb int qid;
77 1.1 simonb int count;
78 1.1 simonb int queued;
79 1.1 simonb int cur;
80 1.1 simonb };
81 1.1 simonb
82 1.3 degroote #define WPI_RBUF_COUNT (WPI_RX_RING_COUNT + 16)
83 1.5 degroote #define WPI_RBUF_LOW_LIMIT 8
84 1.3 degroote
85 1.3 degroote struct wpi_softc;
86 1.3 degroote
87 1.3 degroote struct wpi_rbuf {
88 1.3 degroote struct wpi_softc *sc;
89 1.4 christos void * vaddr;
90 1.3 degroote bus_addr_t paddr;
91 1.3 degroote SLIST_ENTRY(wpi_rbuf) next;
92 1.3 degroote };
93 1.3 degroote
94 1.1 simonb struct wpi_rx_data {
95 1.1 simonb struct mbuf *m;
96 1.1 simonb };
97 1.1 simonb
98 1.1 simonb struct wpi_rx_ring {
99 1.1 simonb struct wpi_dma_info desc_dma;
100 1.3 degroote struct wpi_dma_info buf_dma;
101 1.1 simonb uint32_t *desc;
102 1.1 simonb struct wpi_rx_data data[WPI_RX_RING_COUNT];
103 1.3 degroote struct wpi_rbuf rbuf[WPI_RBUF_COUNT];
104 1.3 degroote SLIST_HEAD(, wpi_rbuf) freelist;
105 1.12 cube kmutex_t freelist_mtx;
106 1.5 degroote int nb_free_entries;
107 1.1 simonb int cur;
108 1.1 simonb };
109 1.1 simonb
110 1.2 joerg struct wpi_node {
111 1.1 simonb struct ieee80211_node ni; /* must be the first */
112 1.2 joerg struct ieee80211_amrr_node amn;
113 1.1 simonb };
114 1.1 simonb
115 1.6 degroote struct wpi_power_sample {
116 1.6 degroote uint8_t index;
117 1.6 degroote int8_t power;
118 1.6 degroote };
119 1.6 degroote
120 1.6 degroote struct wpi_power_group {
121 1.6 degroote #define WPI_SAMPLES_COUNT 5
122 1.6 degroote struct wpi_power_sample samples[WPI_SAMPLES_COUNT];
123 1.6 degroote uint8_t chan;
124 1.6 degroote int8_t maxpwr;
125 1.6 degroote int16_t temp;
126 1.6 degroote };
127 1.6 degroote
128 1.1 simonb struct wpi_softc {
129 1.9 degroote device_t sc_dev;
130 1.3 degroote struct ethercom sc_ec;
131 1.1 simonb struct ieee80211com sc_ic;
132 1.1 simonb int (*sc_newstate)(struct ieee80211com *,
133 1.1 simonb enum ieee80211_state, int);
134 1.3 degroote
135 1.2 joerg struct ieee80211_amrr amrr;
136 1.1 simonb
137 1.1 simonb bus_dma_tag_t sc_dmat;
138 1.1 simonb
139 1.1 simonb /* shared area */
140 1.1 simonb struct wpi_dma_info shared_dma;
141 1.1 simonb struct wpi_shared *shared;
142 1.1 simonb
143 1.6 degroote /* firmware DMA transfer */
144 1.6 degroote struct wpi_dma_info fw_dma;
145 1.13 joerg bool fw_used;
146 1.6 degroote
147 1.1 simonb struct wpi_tx_ring txq[4];
148 1.1 simonb struct wpi_tx_ring cmdq;
149 1.1 simonb struct wpi_rx_ring rxq;
150 1.1 simonb
151 1.1 simonb bus_space_tag_t sc_st;
152 1.1 simonb bus_space_handle_t sc_sh;
153 1.1 simonb void *sc_ih;
154 1.1 simonb pci_chipset_tag_t sc_pct;
155 1.1 simonb pcitag_t sc_pcitag;
156 1.1 simonb bus_size_t sc_sz;
157 1.1 simonb
158 1.6 degroote struct callout calib_to;
159 1.6 degroote int calib_cnt;
160 1.1 simonb
161 1.1 simonb struct wpi_config config;
162 1.6 degroote int temp;
163 1.6 degroote
164 1.6 degroote uint8_t cap;
165 1.6 degroote uint16_t rev;
166 1.6 degroote uint8_t type;
167 1.6 degroote struct wpi_power_group groups[WPI_POWER_GROUPS_COUNT];
168 1.6 degroote int8_t maxpwr[IEEE80211_CHAN_MAX];
169 1.1 simonb
170 1.1 simonb int sc_tx_timer;
171 1.1 simonb
172 1.1 simonb #if NBPFILTER > 0
173 1.4 christos void * sc_drvbpf;
174 1.1 simonb
175 1.1 simonb union {
176 1.1 simonb struct wpi_rx_radiotap_header th;
177 1.1 simonb uint8_t pad[IEEE80211_RADIOTAP_HDRLEN];
178 1.1 simonb } sc_rxtapu;
179 1.1 simonb #define sc_rxtap sc_rxtapu.th
180 1.1 simonb int sc_rxtap_len;
181 1.1 simonb
182 1.1 simonb union {
183 1.1 simonb struct wpi_tx_radiotap_header th;
184 1.1 simonb uint8_t pad[IEEE80211_RADIOTAP_HDRLEN];
185 1.1 simonb } sc_txtapu;
186 1.1 simonb #define sc_txtap sc_txtapu.th
187 1.1 simonb int sc_txtap_len;
188 1.1 simonb #endif
189 1.7 degroote
190 1.7 degroote bool is_scanning;
191 1.11 degroote
192 1.11 degroote struct sysctllog *sc_sysctllog;
193 1.1 simonb };
194