Rework rt2661 TX interrupts processing
[dragonfly.git] / sys / dev / netif / ral / rt2661var.h
1 /*
2  * Copyright (c) 2005
3  *      Damien Bergamini <damien.bergamini@free.fr>
4  *
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.
8  *
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.
16  *
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.3 2006/11/20 15:03:26 sephe Exp $
19  */
20
21 struct rt2661_rx_radiotap_header {
22         struct ieee80211_radiotap_header wr_ihdr;
23         uint64_t        wr_tsf;
24         uint8_t         wr_flags;
25         uint8_t         wr_rate;
26         uint16_t        wr_chan_freq;
27         uint16_t        wr_chan_flags;
28         uint8_t         wr_antsignal;
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) |                            \
36          (1 << IEEE80211_RADIOTAP_DB_ANTSIGNAL))
37
38 struct rt2661_tx_radiotap_header {
39         struct ieee80211_radiotap_header wt_ihdr;
40         uint8_t         wt_flags;
41         uint8_t         wt_rate;
42         uint16_t        wt_chan_freq;
43         uint16_t        wt_chan_flags;
44 } __packed;
45
46 #define RT2661_TX_RADIOTAP_PRESENT                                      \
47         ((1 << IEEE80211_RADIOTAP_FLAGS) |                              \
48          (1 << IEEE80211_RADIOTAP_RATE) |                               \
49          (1 << IEEE80211_RADIOTAP_CHANNEL))
50
51 struct rt2661_tx_ratectl {
52         struct ieee80211_node   *ni;
53         struct ral_rssdesc      id;
54         STAILQ_ENTRY(rt2661_tx_ratectl) link;
55 };
56
57 struct rt2661_data {
58         bus_dmamap_t    map;
59         struct mbuf     *m;
60 };
61
62 struct rt2661_tx_ring {
63         bus_dma_tag_t           desc_dmat;
64         bus_dma_tag_t           data_dmat;
65         bus_dmamap_t            desc_map;
66         bus_addr_t              physaddr;
67         struct rt2661_tx_desc   *desc;
68         struct rt2661_data      *data;
69         int                     count;
70         int                     queued;
71         int                     cur;
72         int                     next;
73 };
74
75 struct rt2661_rx_ring {
76         bus_dma_tag_t           desc_dmat;
77         bus_dma_tag_t           data_dmat;
78         bus_dmamap_t            desc_map;
79         bus_addr_t              physaddr;
80         struct rt2661_rx_desc   *desc;
81         struct rt2661_data      *data;
82         int                     count;
83         int                     cur;
84         int                     next;
85 };
86
87 struct rt2661_node {
88         struct ieee80211_node   ni;
89         struct ral_rssadapt     rssadapt;
90 };
91
92 struct rt2661_softc {
93         struct ieee80211com             sc_ic;
94         bus_space_tag_t                 sc_st;
95         bus_space_handle_t              sc_sh;
96         device_t                        sc_dev;
97
98         int                             sc_irq_rid;
99         struct resource                 *sc_irq;
100         void                            *sc_ih;
101
102         int                             (*sc_newstate)(struct ieee80211com *,
103                                             enum ieee80211_state, int);
104
105         struct callout                  scan_ch;
106         struct callout                  rssadapt_ch;
107
108         int                             sc_tx_timer;
109
110         struct ieee80211_channel        *sc_curchan;
111
112         uint8_t                         rf_rev;
113
114         uint8_t                         rfprog;
115         uint8_t                         rffreq;
116
117         struct rt2661_tx_ring           txq[4];
118         struct rt2661_tx_ring           mgtq;
119         struct rt2661_rx_ring           rxq;
120
121         uint32_t                        rf_regs[4];
122         int8_t                          txpow[38];
123
124         struct {
125                 uint8_t reg;
126                 uint8_t val;
127         }                               bbp_prom[16];
128
129         int                             hw_radio;
130         int                             rx_ant;
131         int                             tx_ant;
132         int                             nb_ant;
133         int                             ext_2ghz_lna;
134         int                             ext_5ghz_lna;
135         int                             rssi_2ghz_corr;
136         int                             rssi_5ghz_corr;
137
138         uint8_t                         bbp18;
139         uint8_t                         bbp21;
140         uint8_t                         bbp22;
141         uint8_t                         bbp16;
142         uint8_t                         bbp17;
143         uint8_t                         bbp64;
144         uint16_t                        mcu_led;
145
146         STAILQ_HEAD(, rt2661_tx_ratectl) tx_ratectl;
147
148         int                             dwelltime;
149
150         struct bpf_if                   *sc_drvbpf;
151
152         union {
153                 struct rt2661_rx_radiotap_header th;
154                 uint8_t pad[64];
155         }                               sc_rxtapu;
156 #define sc_rxtap        sc_rxtapu.th
157         int                             sc_rxtap_len;
158
159         union {
160                 struct rt2661_tx_radiotap_header th;
161                 uint8_t pad[64];
162         }                               sc_txtapu;
163 #define sc_txtap        sc_txtapu.th
164         int                             sc_txtap_len;
165
166         struct sysctl_ctx_list          sysctl_ctx;
167         struct sysctl_oid               *sysctl_tree;
168 };
169
170 int     rt2661_attach(device_t, int);
171 int     rt2661_detach(void *);
172 void    rt2661_shutdown(void *);
173 void    rt2661_suspend(void *);
174 void    rt2661_resume(void *);