]> CyberLeo.Net >> Repos - FreeBSD/releng/7.2.git/blob - sys/dev/usb/if_rumvar.h
Create releng/7.2 from stable/7 in preparation for 7.2-RELEASE.
[FreeBSD/releng/7.2.git] / sys / dev / usb / if_rumvar.h
1 /*      $FreeBSD$       */
2
3 /*-
4  * Copyright (c) 2005, 2006 Damien Bergamini <damien.bergamini@free.fr>
5  * Copyright (c) 2006 Niall O'Higgins <niallo@openbsd.org>
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 #define RUM_RX_LIST_COUNT       1
21 #define RUM_TX_LIST_COUNT       1
22
23 struct rum_rx_radiotap_header {
24         struct ieee80211_radiotap_header wr_ihdr;
25         uint8_t         wr_flags;
26         uint8_t         wr_rate;
27         uint16_t        wr_chan_freq;
28         uint16_t        wr_chan_flags;
29         uint8_t         wr_antenna;
30         uint8_t         wr_antsignal;
31 };
32
33 #define RT2573_RX_RADIOTAP_PRESENT                                      \
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 rum_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 RT2573_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 rum_softc;
56
57 struct rum_tx_data {
58         struct rum_softc        *sc;
59         usbd_xfer_handle        xfer;
60         uint8_t                 *buf;
61         struct mbuf             *m;
62         struct ieee80211_node   *ni;
63 };
64
65 struct rum_rx_data {
66         struct rum_softc        *sc;
67         usbd_xfer_handle        xfer;
68         uint8_t                 *buf;
69         struct mbuf             *m;
70 };
71
72 struct rum_softc {
73         struct ifnet                    *sc_ifp;
74         struct ieee80211com             sc_ic;
75         int                             (*sc_newstate)(struct ieee80211com *,
76                                             enum ieee80211_state, int);
77
78         device_t                        sc_dev;
79         usbd_device_handle              sc_udev;
80         usbd_interface_handle           sc_iface;
81
82         int                             sc_rx_no;
83         int                             sc_tx_no;
84
85         uint8_t                         rf_rev;
86         uint8_t                         rffreq;
87
88         usbd_xfer_handle                amrr_xfer;
89
90         usbd_pipe_handle                sc_rx_pipeh;
91         usbd_pipe_handle                sc_tx_pipeh;
92
93         enum ieee80211_state            sc_state;
94         int                             sc_arg;
95         struct usb_task                 sc_task;
96
97         struct ieee80211_amrr           amrr;
98         struct ieee80211_amrr_node      amn;
99
100         struct usb_task                 sc_scantask;
101         int                             sc_scan_action;
102 #define RUM_SCAN_START  0
103 #define RUM_SCAN_END    1
104 #define RUM_SET_CHANNEL 2
105
106         struct rum_rx_data              rx_data[RUM_RX_LIST_COUNT];
107         struct rum_tx_data              tx_data[RUM_TX_LIST_COUNT];
108         int                             tx_queued;
109
110         struct ieee80211_beacon_offsets sc_bo;
111
112         struct mtx                      sc_mtx;
113
114         struct callout                  watchdog_ch;
115         struct callout                  amrr_ch;
116
117         int                             sc_tx_timer;
118
119         uint32_t                        sta[6];
120         uint32_t                        rf_regs[4];
121         uint8_t                         txpow[44];
122
123         struct {
124                 uint8_t val;
125                 uint8_t reg;
126         } __packed                      bbp_prom[16];
127
128         int                             hw_radio;
129         int                             rx_ant;
130         int                             tx_ant;
131         int                             nb_ant;
132         int                             ext_2ghz_lna;
133         int                             ext_5ghz_lna;
134         int                             rssi_2ghz_corr;
135         int                             rssi_5ghz_corr;
136         int                             sifs;
137         uint8_t                         bbp17;
138
139         struct bpf_if                   *sc_drvbpf;
140
141         union {
142                 struct rum_rx_radiotap_header th;
143                 uint8_t pad[64];
144         }                               sc_rxtapu;
145 #define sc_rxtap        sc_rxtapu.th
146         int                             sc_rxtap_len;
147
148         union {
149                 struct rum_tx_radiotap_header th;
150                 uint8_t pad[64];
151         }                               sc_txtapu;
152 #define sc_txtap        sc_txtapu.th
153         int                             sc_txtap_len;
154 };
155
156 #if 0
157 #define RUM_LOCK(sc)    mtx_lock(&(sc)->sc_mtx)
158 #define RUM_UNLOCK(sc)  mtx_unlock(&(sc)->sc_mtx)
159 #else
160 #define RUM_LOCK(sc)    do { ((sc) = (sc)); mtx_lock(&Giant); } while (0)
161 #define RUM_UNLOCK(sc)  mtx_unlock(&Giant)
162 #endif