Commit | Line | Data |
---|---|---|
91b30d50 | 1 | /* $FreeBSD$ */ |
feb94d24 RP |
2 | |
3 | /*- | |
5fdff524 SZ |
4 | * Copyright (c) 2005 |
5 | * Damien Bergamini <damien.bergamini@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. | |
5fdff524 SZ |
18 | */ |
19 | ||
20 | struct rt2661_rx_radiotap_header { | |
21 | struct ieee80211_radiotap_header wr_ihdr; | |
22 | uint64_t wr_tsf; | |
23 | uint8_t wr_flags; | |
24 | uint8_t wr_rate; | |
25 | uint16_t wr_chan_freq; | |
26 | uint16_t wr_chan_flags; | |
feb94d24 RP |
27 | int8_t wr_antsignal; |
28 | int8_t wr_antnoise; | |
5fdff524 SZ |
29 | } __packed; |
30 | ||
31 | #define RT2661_RX_RADIOTAP_PRESENT \ | |
32 | ((1 << IEEE80211_RADIOTAP_TSFT) | \ | |
33 | (1 << IEEE80211_RADIOTAP_FLAGS) | \ | |
34 | (1 << IEEE80211_RADIOTAP_RATE) | \ | |
35 | (1 << IEEE80211_RADIOTAP_CHANNEL) | \ | |
feb94d24 RP |
36 | (1 << IEEE80211_RADIOTAP_DBM_ANTSIGNAL) | \ |
37 | (1 << IEEE80211_RADIOTAP_DBM_ANTNOISE)) | |
5fdff524 SZ |
38 | |
39 | struct rt2661_tx_radiotap_header { | |
40 | struct ieee80211_radiotap_header wt_ihdr; | |
41 | uint8_t wt_flags; | |
42 | uint8_t wt_rate; | |
43 | uint16_t wt_chan_freq; | |
44 | uint16_t wt_chan_flags; | |
45 | } __packed; | |
46 | ||
47 | #define RT2661_TX_RADIOTAP_PRESENT \ | |
48 | ((1 << IEEE80211_RADIOTAP_FLAGS) | \ | |
49 | (1 << IEEE80211_RADIOTAP_RATE) | \ | |
50 | (1 << IEEE80211_RADIOTAP_CHANNEL)) | |
51 | ||
feb94d24 RP |
52 | struct rt2661_tx_data { |
53 | bus_dmamap_t map; | |
54 | struct mbuf *m; | |
5fdff524 | 55 | struct ieee80211_node *ni; |
feb94d24 RP |
56 | uint8_t rix; |
57 | int8_t rssi; | |
5fdff524 SZ |
58 | }; |
59 | ||
60 | struct rt2661_tx_ring { | |
61 | bus_dma_tag_t desc_dmat; | |
62 | bus_dma_tag_t data_dmat; | |
63 | bus_dmamap_t desc_map; | |
64 | bus_addr_t physaddr; | |
65 | struct rt2661_tx_desc *desc; | |
feb94d24 | 66 | struct rt2661_tx_data *data; |
5fdff524 SZ |
67 | int count; |
68 | int queued; | |
69 | int cur; | |
70 | int next; | |
feb94d24 RP |
71 | int stat; |
72 | }; | |
73 | ||
74 | struct rt2661_rx_data { | |
75 | bus_dmamap_t map; | |
76 | struct mbuf *m; | |
5fdff524 SZ |
77 | }; |
78 | ||
79 | struct rt2661_rx_ring { | |
80 | bus_dma_tag_t desc_dmat; | |
81 | bus_dma_tag_t data_dmat; | |
82 | bus_dmamap_t desc_map; | |
83 | bus_addr_t physaddr; | |
84 | struct rt2661_rx_desc *desc; | |
feb94d24 | 85 | struct rt2661_rx_data *data; |
5fdff524 SZ |
86 | int count; |
87 | int cur; | |
88 | int next; | |
89 | }; | |
90 | ||
feb94d24 RP |
91 | struct rt2661_vap { |
92 | struct ieee80211vap ral_vap; | |
93 | ||
94 | int (*ral_newstate)(struct ieee80211vap *, | |
95 | enum ieee80211_state, int); | |
99fda2c4 | 96 | }; |
feb94d24 | 97 | #define RT2661_VAP(vap) ((struct rt2661_vap *)(vap)) |
99fda2c4 | 98 | |
5fdff524 | 99 | struct rt2661_softc { |
91b30d50 | 100 | struct ieee80211com sc_ic; |
93d249f7 MD |
101 | #if defined(__DragonFly__) |
102 | struct lock sc_mtx; | |
103 | #else | |
91b30d50 | 104 | struct mtx sc_mtx; |
93d249f7 | 105 | #endif |
91b30d50 | 106 | struct mbufq sc_snd; |
feb94d24 | 107 | device_t sc_dev; |
5fdff524 SZ |
108 | bus_space_tag_t sc_st; |
109 | bus_space_handle_t sc_sh; | |
5717dc1a | 110 | |
feb94d24 | 111 | struct callout watchdog_ch; |
5fdff524 SZ |
112 | |
113 | int sc_tx_timer; | |
feb94d24 RP |
114 | int sc_invalid; |
115 | int sc_debug; | |
116 | /* | |
117 | * The same in both up to here | |
118 | * ------------------------------------------------ | |
119 | */ | |
120 | ||
121 | int sc_flags; | |
122 | #define RAL_FW_LOADED 0x1 | |
123 | #define RAL_INPUT_RUNNING 0x2 | |
91b30d50 | 124 | #define RAL_RUNNING 0x4 |
feb94d24 | 125 | int sc_id; |
5fdff524 SZ |
126 | struct ieee80211_channel *sc_curchan; |
127 | ||
128 | uint8_t rf_rev; | |
129 | ||
feb94d24 | 130 | uint8_t rfprog; |
5fdff524 SZ |
131 | uint8_t rffreq; |
132 | ||
133 | struct rt2661_tx_ring txq[4]; | |
134 | struct rt2661_tx_ring mgtq; | |
135 | struct rt2661_rx_ring rxq; | |
136 | ||
137 | uint32_t rf_regs[4]; | |
feb94d24 | 138 | int8_t txpow[38]; |
5fdff524 SZ |
139 | |
140 | struct { | |
141 | uint8_t reg; | |
142 | uint8_t val; | |
143 | } bbp_prom[16]; | |
144 | ||
145 | int hw_radio; | |
146 | int rx_ant; | |
147 | int tx_ant; | |
148 | int nb_ant; | |
149 | int ext_2ghz_lna; | |
150 | int ext_5ghz_lna; | |
feb94d24 | 151 | int rssi_2ghz_corr; |
5fdff524 SZ |
152 | int rssi_5ghz_corr; |
153 | ||
154 | uint8_t bbp18; | |
155 | uint8_t bbp21; | |
156 | uint8_t bbp22; | |
157 | uint8_t bbp16; | |
158 | uint8_t bbp17; | |
159 | uint8_t bbp64; | |
9dd87f8a | 160 | |
feb94d24 | 161 | int dwelltime; |
5fdff524 | 162 | |
feb94d24 | 163 | struct rt2661_rx_radiotap_header sc_rxtap; |
feb94d24 | 164 | struct rt2661_tx_radiotap_header sc_txtap; |
5fdff524 SZ |
165 | }; |
166 | ||
167 | int rt2661_attach(device_t, int); | |
168 | int rt2661_detach(void *); | |
169 | void rt2661_shutdown(void *); | |
170 | void rt2661_suspend(void *); | |
171 | void rt2661_resume(void *); | |
feb94d24 | 172 | void rt2661_intr(void *); |
91b30d50 | 173 | |
93d249f7 MD |
174 | #if defined(__DragonFly__) |
175 | ||
176 | #define RAL_LOCK(sc) lockmgr(&(sc)->sc_mtx, LK_EXCLUSIVE) | |
177 | #define RAL_LOCK_ASSERT(sc) KKASSERT(lockstatus(&(sc)->sc_mtx, curthread) == LK_EXCLUSIVE) | |
178 | #define RAL_UNLOCK(sc) lockmgr(&(sc)->sc_mtx, LK_RELEASE) | |
179 | ||
180 | #else | |
181 | ||
91b30d50 MD |
182 | #define RAL_LOCK(sc) mtx_lock(&(sc)->sc_mtx) |
183 | #define RAL_LOCK_ASSERT(sc) mtx_assert(&(sc)->sc_mtx, MA_OWNED) | |
184 | #define RAL_UNLOCK(sc) mtx_unlock(&(sc)->sc_mtx) | |
93d249f7 MD |
185 | |
186 | #endif |