Merge from vendor branch OPENSSH:
[dragonfly.git] / sys / dev / netif / ral / rt2560var.h
1 /*
2  * Copyright (c) 2005, 2006
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/rt2560var.h,v 1.1 2006/03/05 20:36:56 damien Exp $
18  * $DragonFly: src/sys/dev/netif/ral/rt2560var.h,v 1.2 2007/02/05 15:19:04 sephe Exp $
19  */
20
21 struct rt2560_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_antenna;
29         uint8_t         wr_antsignal;
30 };
31
32 #define RT2560_RX_RADIOTAP_PRESENT                                      \
33         ((1 << IEEE80211_RADIOTAP_TSFT) |                               \
34          (1 << IEEE80211_RADIOTAP_FLAGS) |                              \
35          (1 << IEEE80211_RADIOTAP_RATE) |                               \
36          (1 << IEEE80211_RADIOTAP_CHANNEL) |                            \
37          (1 << IEEE80211_RADIOTAP_ANTENNA) |                            \
38          (1 << IEEE80211_RADIOTAP_DB_ANTSIGNAL))
39
40 struct rt2560_tx_radiotap_header {
41         struct ieee80211_radiotap_header wt_ihdr;
42         uint8_t         wt_flags;
43         uint8_t         wt_rate;
44         uint16_t        wt_chan_freq;
45         uint16_t        wt_chan_flags;
46         uint8_t         wt_antenna;
47 };
48
49 #define RT2560_TX_RADIOTAP_PRESENT                                      \
50         ((1 << IEEE80211_RADIOTAP_FLAGS) |                              \
51          (1 << IEEE80211_RADIOTAP_RATE) |                               \
52          (1 << IEEE80211_RADIOTAP_CHANNEL) |                            \
53          (1 << IEEE80211_RADIOTAP_ANTENNA))
54
55 struct rt2560_tx_data {
56         bus_dmamap_t                    map;
57         struct mbuf                     *m;
58         struct ieee80211_node           *ni;
59         struct ral_rssdesc              id;
60 };
61
62 struct rt2560_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 rt2560_tx_desc   *desc;
68         struct rt2560_tx_data   *data;
69         int                     count;
70         int                     queued;
71         int                     cur;
72         int                     next;
73         int                     cur_encrypt;
74         int                     next_encrypt;
75 };
76
77 struct rt2560_rx_data {
78         bus_dmamap_t    map;
79         struct mbuf     *m;
80         int             drop;
81 };
82
83 struct rt2560_rx_ring {
84         bus_dma_tag_t           desc_dmat;
85         bus_dma_tag_t           data_dmat;
86         bus_dmamap_t            desc_map;
87         bus_addr_t              physaddr;
88         struct rt2560_rx_desc   *desc;
89         struct rt2560_rx_data   *data;
90         int                     count;
91         int                     cur;
92         int                     next;
93         int                     cur_decrypt;
94 };
95
96 struct rt2560_node {
97         struct ieee80211_node   ni;
98         struct ral_rssadapt     rssadapt;
99 };
100
101 struct rt2560_softc {
102         /*
103          * NOTE: following four fields MUST be in the
104          * same order as in rt2661_softc
105          */
106         struct ieee80211com     sc_ic;
107         bus_space_tag_t         sc_st;
108         bus_space_handle_t      sc_sh;
109         device_t                sc_dev;
110
111         int                     sc_irq_rid;
112         struct resource         *sc_irq;
113         void                    *sc_ih;
114
115         int                     (*sc_newstate)(struct ieee80211com *,
116                                     enum ieee80211_state, int);
117
118         struct callout          scan_ch;
119         struct callout          rssadapt_ch;
120
121         int                     sc_tx_timer;
122
123         uint32_t                asic_rev;
124         uint32_t                eeprom_rev;
125         uint8_t                 rf_rev;
126         uint8_t                 rssi_corr;
127
128         struct rt2560_tx_ring   txq;
129         struct rt2560_tx_ring   prioq;
130         struct rt2560_tx_ring   atimq;
131         struct rt2560_tx_ring   bcnq;
132         struct rt2560_rx_ring   rxq;
133
134         struct ieee80211_beacon_offsets sc_bo;
135
136         uint32_t                rf_regs[4];
137         uint8_t                 txpow[14];
138
139         struct {
140                 uint8_t reg;
141                 uint8_t val;
142         }                       bbp_prom[16];
143
144         int                     led_mode;
145         int                     hw_radio;
146         int                     rx_ant;
147         int                     tx_ant;
148         int                     nb_ant;
149
150         int                     dwelltime;
151
152         struct bpf_if           *sc_drvbpf;
153
154         union {
155                 struct rt2560_rx_radiotap_header th;
156                 uint8_t pad[64];
157         }                       sc_rxtapu;
158 #define sc_rxtap        sc_rxtapu.th
159         int                     sc_rxtap_len;
160
161         union {
162                 struct rt2560_tx_radiotap_header th;
163                 uint8_t pad[64];
164         }                       sc_txtapu;
165 #define sc_txtap        sc_txtapu.th
166         int                     sc_txtap_len;
167
168         struct sysctl_ctx_list  sysctl_ctx;
169         struct sysctl_oid       *sysctl_tree;
170 };
171
172 int     rt2560_attach(device_t, int);
173 int     rt2560_detach(void *);
174 void    rt2560_shutdown(void *);
175 void    rt2560_suspend(void *);
176 void    rt2560_resume(void *);