Add hardware crypto support for 2x61 part of ral(4). This kind of hardware
[dragonfly/vkernel-mp.git] / sys / dev / netif / ral / rt2661var.h
blob60c0476efa3095c03cfe8e35ed71e7b191301905
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.7 2007/05/07 14:14:21 sephe Exp $
21 #define RT2661_NCHAN_MAX 38
22 #define RT2661_KEY_MAX 64
24 struct rt2661_rx_radiotap_header {
25 struct ieee80211_radiotap_header wr_ihdr;
26 uint64_t wr_tsf;
27 uint8_t wr_flags;
28 uint8_t wr_rate;
29 uint16_t wr_chan_freq;
30 uint16_t wr_chan_flags;
31 uint8_t wr_antsignal;
32 } __packed;
34 #define RT2661_RX_RADIOTAP_PRESENT \
35 ((1 << IEEE80211_RADIOTAP_TSFT) | \
36 (1 << IEEE80211_RADIOTAP_FLAGS) | \
37 (1 << IEEE80211_RADIOTAP_RATE) | \
38 (1 << IEEE80211_RADIOTAP_CHANNEL) | \
39 (1 << IEEE80211_RADIOTAP_DB_ANTSIGNAL))
41 struct rt2661_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 } __packed;
49 #define RT2661_TX_RADIOTAP_PRESENT \
50 ((1 << IEEE80211_RADIOTAP_FLAGS) | \
51 (1 << IEEE80211_RADIOTAP_RATE) | \
52 (1 << IEEE80211_RADIOTAP_CHANNEL))
54 struct rt2661_tx_ratectl {
55 struct ieee80211_node *ni;
56 int len;
57 int rateidx;
58 STAILQ_ENTRY(rt2661_tx_ratectl) link;
61 struct rt2661_data {
62 bus_dmamap_t map;
63 struct mbuf *m;
66 struct rt2661_tx_ring {
67 bus_dma_tag_t desc_dmat;
68 bus_dma_tag_t data_dmat;
69 bus_dmamap_t desc_map;
70 bus_addr_t physaddr;
71 struct rt2661_tx_desc *desc;
72 struct rt2661_data *data;
73 int count;
74 int queued;
75 int cur;
76 int next;
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;
85 struct rt2661_data *data;
86 int count;
87 int cur;
88 int next;
91 struct rt2661_softc {
92 struct ieee80211com sc_ic;
93 bus_space_tag_t sc_st;
94 bus_space_handle_t sc_sh;
95 device_t sc_dev;
97 int sc_irq_rid;
98 struct resource *sc_irq;
99 void *sc_ih;
101 int (*sc_newstate)
102 (struct ieee80211com *,
103 enum ieee80211_state, int);
105 int (*sc_key_alloc)
106 (struct ieee80211com *,
107 const struct ieee80211_key *,
108 ieee80211_keyix *, ieee80211_keyix *);
110 int (*sc_key_delete)
111 (struct ieee80211com *,
112 const struct ieee80211_key *);
114 int (*sc_key_set)
115 (struct ieee80211com *,
116 const struct ieee80211_key *,
117 const uint8_t[IEEE80211_ADDR_LEN]);
119 struct callout scan_ch;
121 int sc_tx_timer;
122 int sc_sifs;
124 struct ieee80211_channel *sc_curchan;
126 uint8_t rf_rev;
128 uint8_t rfprog;
129 uint8_t rffreq;
131 struct rt2661_tx_ring txq[4];
132 struct rt2661_tx_ring mgtq;
133 struct rt2661_rx_ring rxq;
135 uint32_t rf_regs[4];
136 int8_t txpow[RT2661_NCHAN_MAX];
138 struct {
139 uint8_t reg;
140 uint8_t val;
141 } bbp_prom[16];
143 int hw_radio;
144 int rx_ant;
145 int tx_ant;
146 int nb_ant;
147 int ext_2ghz_lna;
148 int ext_5ghz_lna;
149 int rssi_2ghz_corr;
150 int rssi_5ghz_corr;
152 uint8_t bbp18;
153 uint8_t bbp21;
154 uint8_t bbp22;
155 uint8_t bbp16;
156 uint8_t bbp17;
157 uint8_t bbp64;
158 uint16_t mcu_led;
160 STAILQ_HEAD(, rt2661_tx_ratectl) tx_ratectl;
162 int dwelltime;
164 struct bpf_if *sc_drvbpf;
166 union {
167 struct rt2661_rx_radiotap_header th;
168 uint8_t pad[64];
169 } sc_rxtapu;
170 #define sc_rxtap sc_rxtapu.th
171 int sc_rxtap_len;
173 union {
174 struct rt2661_tx_radiotap_header th;
175 uint8_t pad[64];
176 } sc_txtapu;
177 #define sc_txtap sc_txtapu.th
178 int sc_txtap_len;
180 struct sysctl_ctx_list sysctl_ctx;
181 struct sysctl_oid *sysctl_tree;
183 uint32_t sc_keymap[2];
186 #define RT2661_KEY_ASSERT(keyix) \
187 KASSERT((keyix) < RT2661_KEY_MAX, ("invalid keyix %d\n", (keyix)))
189 #define RT2661_KEY_SET(sc, keyix) \
190 do { \
191 RT2661_KEY_ASSERT((keyix)); \
192 (sc)->sc_keymap[(keyix) / 32] |= (1 << ((keyix) % 32)); \
193 } while (0)
195 #define RT2661_KEY_CLR(sc, keyix) \
196 do { \
197 RT2661_KEY_ASSERT((keyix)); \
198 (sc)->sc_keymap[(keyix) / 32] &= ~(1 << ((keyix) % 32)); \
199 } while (0)
201 #define RT2661_KEY_ISSET(sc, keyix) \
202 ((sc)->sc_keymap[(keyix) / 32] & (1 << ((keyix) % 32)))
204 int rt2661_attach(device_t, int);
205 int rt2661_detach(void *);
206 void rt2661_shutdown(void *);
207 void rt2661_suspend(void *);
208 void rt2661_resume(void *);