Use per softc debug level instead of a global one.
[dfdiff.git] / sys / dev / netif / ral / rt2661var.h
blob4dcc924de06ca754c0cb6a34d4cdbe3d86d7b65a
1 /*
2 * Copyright (c) 2005
3 * Damien Bergamini <damien.bergamini@free.fr>
5 * Permission to use, copy, modify, and distribute this software for any
6 * purpose with or without fee is hereby granted, provided that the above
7 * copyright notice and this permission notice appear in all copies.
9 * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
10 * WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
11 * MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
12 * ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
13 * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
14 * ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
15 * OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
17 * $FreeBSD: src/sys/dev/ral/rt2661var.h,v 1.1 2006/03/05 20:36:56 damien Exp $
18 * $DragonFly: src/sys/dev/netif/ral/rt2661var.h,v 1.12 2008/02/08 09:42:30 sephe Exp $
21 #define RT2661_TSSI_LIMSZ 4
22 #define RT2661_NCHAN_MAX 38
23 #define RT2661_KEY_MAX 64
25 struct rt2661_rx_radiotap_header {
26 struct ieee80211_radiotap_header wr_ihdr;
27 uint64_t wr_tsf;
28 uint8_t wr_flags;
29 uint8_t wr_rate;
30 uint16_t wr_chan_freq;
31 uint16_t wr_chan_flags;
32 uint8_t wr_antsignal;
33 } __packed;
35 #define RT2661_RX_RADIOTAP_PRESENT \
36 ((1 << IEEE80211_RADIOTAP_TSFT) | \
37 (1 << IEEE80211_RADIOTAP_FLAGS) | \
38 (1 << IEEE80211_RADIOTAP_RATE) | \
39 (1 << IEEE80211_RADIOTAP_CHANNEL) | \
40 (1 << IEEE80211_RADIOTAP_DB_ANTSIGNAL))
42 struct rt2661_tx_radiotap_header {
43 struct ieee80211_radiotap_header wt_ihdr;
44 uint8_t wt_flags;
45 uint8_t wt_rate;
46 uint16_t wt_chan_freq;
47 uint16_t wt_chan_flags;
48 } __packed;
50 #define RT2661_TX_RADIOTAP_PRESENT \
51 ((1 << IEEE80211_RADIOTAP_FLAGS) | \
52 (1 << IEEE80211_RADIOTAP_RATE) | \
53 (1 << IEEE80211_RADIOTAP_CHANNEL))
55 struct rt2661_tx_ratectl {
56 struct ieee80211_node *ni;
57 int len;
58 int rateidx;
59 STAILQ_ENTRY(rt2661_tx_ratectl) link;
62 struct rt2661_data {
63 bus_dmamap_t map;
64 struct mbuf *m;
67 struct rt2661_tx_ring {
68 bus_dma_tag_t desc_dmat;
69 bus_dma_tag_t data_dmat;
70 bus_dmamap_t desc_map;
71 bus_addr_t physaddr;
72 struct rt2661_tx_desc *desc;
73 struct rt2661_data *data;
74 int count;
75 int queued;
76 int cur;
77 int next;
80 struct rt2661_rx_ring {
81 bus_dma_tag_t desc_dmat;
82 bus_dma_tag_t data_dmat;
83 bus_dmamap_t desc_map;
84 bus_addr_t physaddr;
85 struct rt2661_rx_desc *desc;
86 struct rt2661_data *data;
87 int count;
88 int cur;
89 int next;
92 struct rt2661_rfprog {
93 uint8_t chan;
94 uint32_t r1, r2, r3, r4;
97 struct rt2661_softc {
98 struct ieee80211com sc_ic;
99 bus_space_tag_t sc_st;
100 bus_space_handle_t sc_sh;
101 device_t sc_dev;
103 int sc_irq_rid;
104 struct resource *sc_irq;
105 void *sc_ih;
107 int (*sc_newstate)
108 (struct ieee80211com *,
109 enum ieee80211_state, int);
111 int (*sc_key_alloc)
112 (struct ieee80211com *,
113 const struct ieee80211_key *,
114 ieee80211_keyix *, ieee80211_keyix *);
116 int (*sc_key_delete)
117 (struct ieee80211com *,
118 const struct ieee80211_key *);
120 int (*sc_key_set)
121 (struct ieee80211com *,
122 const struct ieee80211_key *,
123 const uint8_t[IEEE80211_ADDR_LEN]);
125 struct callout scan_ch;
126 struct callout calib_ch;
128 int sc_tx_timer;
129 int sc_sifs;
131 struct ieee80211_channel *sc_curchan;
132 int sc_curchan_idx;
133 int sc_txpwr_cnt;
134 int8_t sc_txpwr;
136 uint8_t rf_rev;
138 const struct rt2661_rfprog *rfprog;
139 uint8_t rffreq;
141 struct rt2661_tx_ring txq[4];
142 struct rt2661_tx_ring mgtq;
143 struct rt2661_rx_ring rxq;
145 uint32_t rf_regs[4];
146 int8_t txpow[RT2661_NCHAN_MAX];
148 struct {
149 uint8_t reg;
150 uint8_t val;
151 } bbp_prom[16];
153 int hw_radio;
154 int auto_txagc;
155 int rx_ant;
156 int tx_ant;
157 int nb_ant;
159 int ext_2ghz_lna;
160 int rssi_2ghz_corr[2];
161 int avg_rssi[2];
162 uint8_t bbp17_2ghz_min;
163 uint8_t bbp17_2ghz_max;
165 uint8_t tssi_2ghz_up[RT2661_TSSI_LIMSZ];
166 uint8_t tssi_2ghz_down[RT2661_TSSI_LIMSZ];
167 uint8_t tssi_2ghz_ref;
168 int8_t tssi_2ghz_step;
169 int8_t tssi_2ghz_comp;
171 int ext_5ghz_lna;
172 int rssi_5ghz_corr;
174 uint8_t bbp18;
175 uint8_t bbp21;
176 uint8_t bbp22;
177 uint8_t bbp16;
178 uint8_t bbp17;
179 uint8_t bbp64;
180 uint16_t mcu_led;
182 STAILQ_HEAD(, rt2661_tx_ratectl) tx_ratectl;
184 struct bpf_if *sc_drvbpf;
186 union {
187 struct rt2661_rx_radiotap_header th;
188 uint8_t pad[64];
189 } sc_rxtapu;
190 #define sc_rxtap sc_rxtapu.th
191 int sc_rxtap_len;
193 union {
194 struct rt2661_tx_radiotap_header th;
195 uint8_t pad[64];
196 } sc_txtapu;
197 #define sc_txtap sc_txtapu.th
198 int sc_txtap_len;
200 struct sysctl_ctx_list sysctl_ctx;
201 struct sysctl_oid *sysctl_tree;
203 int sc_txpwr_corr;
204 int sc_calib_txpwr;
205 int sc_calib_rxsns;
206 int sc_dwelltime;
207 int sc_debug;
209 struct ieee80211_onoe_param sc_onoe_param;
210 struct ieee80211_sample_param sc_sample_param;
212 uint32_t sc_keymap[2];
215 #define RT2661_KEY_ASSERT(keyix) \
216 KASSERT((keyix) < RT2661_KEY_MAX, ("invalid keyix %d\n", (keyix)))
218 #define RT2661_KEY_SET(sc, keyix) \
219 do { \
220 RT2661_KEY_ASSERT((keyix)); \
221 (sc)->sc_keymap[(keyix) / 32] |= (1 << ((keyix) % 32)); \
222 } while (0)
224 #define RT2661_KEY_CLR(sc, keyix) \
225 do { \
226 RT2661_KEY_ASSERT((keyix)); \
227 (sc)->sc_keymap[(keyix) / 32] &= ~(1 << ((keyix) % 32)); \
228 } while (0)
230 #define RT2661_KEY_ISSET(sc, keyix) \
231 ((sc)->sc_keymap[(keyix) / 32] & (1 << ((keyix) % 32)))
233 #define RT2661_RESET_AVG_RSSI(sc) \
234 do { \
235 (sc)->avg_rssi[0] = -1; \
236 (sc)->avg_rssi[1] = -1; \
237 } while (0)
239 int rt2661_attach(device_t, int);
240 int rt2661_detach(void *);
241 void rt2661_shutdown(void *);
242 void rt2661_suspend(void *);
243 void rt2661_resume(void *);