if_wpivar.h revision 1.16 1 /* $NetBSD: if_wpivar.h,v 1.16 2014/08/05 21:54:39 jmcneill Exp $ */
2
3 /*-
4 * Copyright (c) 2006
5 * Damien Bergamini <damien.bergamini (at) free.fr>
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 struct wpi_rx_radiotap_header {
21 struct ieee80211_radiotap_header wr_ihdr;
22 uint64_t wr_tsft;
23 uint8_t wr_flags;
24 uint8_t wr_rate;
25 uint16_t wr_chan_freq;
26 uint16_t wr_chan_flags;
27 int8_t wr_dbm_antsignal;
28 int8_t wr_dbm_antnoise;
29 uint8_t wr_antenna;
30 };
31
32 #define WPI_RX_RADIOTAP_PRESENT \
33 ((1 << IEEE80211_RADIOTAP_TSFT) | \
34 (1 << IEEE80211_RADIOTAP_FLAGS) | \
35 (1 << IEEE80211_RADIOTAP_RATE) | \
36 (1 << IEEE80211_RADIOTAP_CHANNEL) | \
37 (1 << IEEE80211_RADIOTAP_DBM_ANTSIGNAL) | \
38 (1 << IEEE80211_RADIOTAP_DBM_ANTNOISE) | \
39 (1 << IEEE80211_RADIOTAP_ANTENNA))
40
41 struct wpi_tx_radiotap_header {
42 struct ieee80211_radiotap_header wt_ihdr;
43 uint8_t wt_flags;
44 uint8_t wt_rate;
45 uint16_t wt_chan_freq;
46 uint16_t wt_chan_flags;
47 uint8_t wt_hwqueue;
48 };
49
50 #define WPI_TX_RADIOTAP_PRESENT \
51 ((1 << IEEE80211_RADIOTAP_FLAGS) | \
52 (1 << IEEE80211_RADIOTAP_RATE) | \
53 (1 << IEEE80211_RADIOTAP_CHANNEL))
54
55 struct wpi_dma_info {
56 bus_dma_tag_t tag;
57 bus_dmamap_t map;
58 bus_dma_segment_t seg;
59 bus_addr_t paddr;
60 void * vaddr;
61 bus_size_t size;
62 };
63
64 struct wpi_tx_data {
65 bus_dmamap_t map;
66 struct mbuf *m;
67 struct ieee80211_node *ni;
68 };
69
70 struct wpi_tx_ring {
71 struct wpi_dma_info desc_dma;
72 struct wpi_dma_info cmd_dma;
73 struct wpi_tx_desc *desc;
74 struct wpi_tx_cmd *cmd;
75 struct wpi_tx_data *data;
76 int qid;
77 int count;
78 int queued;
79 int cur;
80 };
81
82 #define WPI_RBUF_COUNT (WPI_RX_RING_COUNT + 16)
83 #define WPI_RBUF_LOW_LIMIT 8
84
85 struct wpi_softc;
86
87 struct wpi_rbuf {
88 struct wpi_softc *sc;
89 void * vaddr;
90 bus_addr_t paddr;
91 SLIST_ENTRY(wpi_rbuf) next;
92 };
93
94 struct wpi_rx_data {
95 bus_dmamap_t map;
96 struct mbuf *m;
97 };
98
99 struct wpi_rx_ring {
100 struct wpi_dma_info desc_dma;
101 struct wpi_dma_info buf_dma;
102 uint32_t *desc;
103 struct wpi_rx_data data[WPI_RX_RING_COUNT];
104 struct wpi_rbuf rbuf[WPI_RBUF_COUNT];
105 SLIST_HEAD(, wpi_rbuf) freelist;
106 kmutex_t freelist_mtx;
107 int nb_free_entries;
108 int cur;
109 };
110
111 struct wpi_node {
112 struct ieee80211_node ni; /* must be the first */
113 struct ieee80211_amrr_node amn;
114 };
115
116 struct wpi_power_sample {
117 uint8_t index;
118 int8_t power;
119 };
120
121 struct wpi_power_group {
122 #define WPI_SAMPLES_COUNT 5
123 struct wpi_power_sample samples[WPI_SAMPLES_COUNT];
124 uint8_t chan;
125 int8_t maxpwr;
126 int16_t temp;
127 };
128
129 struct wpi_softc {
130 device_t sc_dev;
131 struct ethercom sc_ec;
132 struct ieee80211com sc_ic;
133 int (*sc_newstate)(struct ieee80211com *,
134 enum ieee80211_state, int);
135
136 struct ieee80211_amrr amrr;
137
138 bus_dma_tag_t sc_dmat;
139
140 /* shared area */
141 struct wpi_dma_info shared_dma;
142 struct wpi_shared *shared;
143
144 /* firmware DMA transfer */
145 struct wpi_dma_info fw_dma;
146 bool fw_used;
147
148 struct wpi_tx_ring txq[4];
149 struct wpi_tx_ring cmdq;
150 struct wpi_rx_ring rxq;
151
152 bus_space_tag_t sc_st;
153 bus_space_handle_t sc_sh;
154 void *sc_ih;
155 pci_chipset_tag_t sc_pct;
156 pcitag_t sc_pcitag;
157 bus_size_t sc_sz;
158
159 struct callout calib_to;
160 int calib_cnt;
161
162 struct wpi_config config;
163 int temp;
164
165 uint8_t cap;
166 uint16_t rev;
167 uint8_t type;
168 struct wpi_power_group groups[WPI_POWER_GROUPS_COUNT];
169 int8_t maxpwr[IEEE80211_CHAN_MAX];
170
171 int sc_tx_timer;
172
173 struct bpf_if * sc_drvbpf;
174
175 union {
176 struct wpi_rx_radiotap_header th;
177 uint8_t pad[IEEE80211_RADIOTAP_HDRLEN];
178 } sc_rxtapu;
179 #define sc_rxtap sc_rxtapu.th
180 int sc_rxtap_len;
181
182 union {
183 struct wpi_tx_radiotap_header th;
184 uint8_t pad[IEEE80211_RADIOTAP_HDRLEN];
185 } sc_txtapu;
186 #define sc_txtap sc_txtapu.th
187 int sc_txtap_len;
188
189 bool is_scanning;
190
191 struct sysctllog *sc_sysctllog;
192 };
193