1 /* $FreeBSD$ */
2
3 /*-
4 * Copyright (c) 2005, 2006
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.
18 */
19
20 struct rt2560_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;
27 uint8_t wr_antenna;
28 uint8_t wr_antsignal;
29 };
30
31 #define RT2560_RX_RADIOTAP_PRESENT \
32 ((1 << IEEE80211_RADIOTAP_TSFT) | \
33 (1 << IEEE80211_RADIOTAP_FLAGS) | \
34 (1 << IEEE80211_RADIOTAP_RATE) | \
35 (1 << IEEE80211_RADIOTAP_CHANNEL) | \
36 (1 << IEEE80211_RADIOTAP_ANTENNA) | \
37 (1 << IEEE80211_RADIOTAP_DB_ANTSIGNAL))
38
39 struct rt2560_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 uint8_t wt_antenna;
46 };
47
48 #define RT2560_TX_RADIOTAP_PRESENT \
49 ((1 << IEEE80211_RADIOTAP_FLAGS) | \
50 (1 << IEEE80211_RADIOTAP_RATE) | \
51 (1 << IEEE80211_RADIOTAP_CHANNEL) | \
52 (1 << IEEE80211_RADIOTAP_ANTENNA))
53
54 struct rt2560_tx_data {
55 bus_dmamap_t map;
56 struct mbuf *m;
57 struct ieee80211_node *ni;
58 struct ral_rssdesc id;
59 };
60
61 struct rt2560_tx_ring {
62 bus_dma_tag_t desc_dmat;
63 bus_dma_tag_t data_dmat;
64 bus_dmamap_t desc_map;
65 bus_addr_t physaddr;
66 struct rt2560_tx_desc *desc;
67 struct rt2560_tx_data *data;
68 int count;
69 int queued;
70 int cur;
71 int next;
72 int cur_encrypt;
73 int next_encrypt;
74 };
75
76 struct rt2560_rx_data {
77 bus_dmamap_t map;
78 struct mbuf *m;
79 int drop;
80 };
81
82 struct rt2560_rx_ring {
83 bus_dma_tag_t desc_dmat;
84 bus_dma_tag_t data_dmat;
85 bus_dmamap_t desc_map;
86 bus_addr_t physaddr;
87 struct rt2560_rx_desc *desc;
88 struct rt2560_rx_data *data;
89 int count;
90 int cur;
91 int next;
92 int cur_decrypt;
93 };
94
95 struct rt2560_node {
96 struct ieee80211_node ni;
97 struct ral_rssadapt rssadapt;
98 };
99
100 struct rt2560_softc {
101 struct ifnet *sc_ifp;
102 struct ieee80211com sc_ic;
103 int (*sc_newstate)(struct ieee80211com *,
104 enum ieee80211_state, int);
105 device_t sc_dev;
106 bus_space_tag_t sc_st;
107 bus_space_handle_t sc_sh;
108
109 struct mtx sc_mtx;
110
111 struct callout scan_ch;
112 struct callout rssadapt_ch;
113
114 int sc_tx_timer;
115
116 uint32_t asic_rev;
117 uint32_t eeprom_rev;
118 uint8_t rf_rev;
119
120 struct rt2560_tx_ring txq;
121 struct rt2560_tx_ring prioq;
122 struct rt2560_tx_ring atimq;
123 struct rt2560_tx_ring bcnq;
124 struct rt2560_rx_ring rxq;
125
126 struct ieee80211_beacon_offsets sc_bo;
127
128 uint32_t rf_regs[4];
129 uint8_t txpow[14];
130
131 struct {
132 uint8_t reg;
133 uint8_t val;
134 } bbp_prom[16];
135
136 int led_mode;
137 int hw_radio;
138 int rx_ant;
139 int tx_ant;
140 int nb_ant;
141
142 int dwelltime;
143
144 struct bpf_if *sc_drvbpf;
145
146 union {
147 struct rt2560_rx_radiotap_header th;
148 uint8_t pad[64];
149 } sc_rxtapu;
150 #define sc_rxtap sc_rxtapu.th
151 int sc_rxtap_len;
152
153 union {
154 struct rt2560_tx_radiotap_header th;
155 uint8_t pad[64];
156 } sc_txtapu;
157 #define sc_txtap sc_txtapu.th
158 int sc_txtap_len;
159 };
160
161 int rt2560_attach(device_t, int);
162 int rt2560_detach(void *);
163 void rt2560_shutdown(void *);
164 void rt2560_suspend(void *);
165 void rt2560_resume(void *);
166 void rt2560_intr(void *);
167
168 #define RAL_LOCK(sc) mtx_lock(&(sc)->sc_mtx)
169 #define RAL_UNLOCK(sc) mtx_unlock(&(sc)->sc_mtx)
Cache object: 7e3b4e99b21c69f2bb6b934d6f1ff071
|