]> CyberLeo.Net >> Repos - FreeBSD/releng/7.2.git/blob - sys/dev/usb/if_uralvar.h
Create releng/7.2 from stable/7 in preparation for 7.2-RELEASE.
[FreeBSD/releng/7.2.git] / sys / dev / usb / if_uralvar.h
1 /*      $FreeBSD$       */
2
3 /*-
4  * Copyright (c) 2005
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 #define RAL_RX_LIST_COUNT       1
21 #define RAL_TX_LIST_COUNT       1
22
23 #define URAL_SCAN_START         1
24 #define URAL_SCAN_END           2
25 #define URAL_SET_CHANNEL        3
26
27
28 struct ural_rx_radiotap_header {
29         struct ieee80211_radiotap_header wr_ihdr;
30         uint8_t         wr_flags;
31         uint8_t         wr_rate;
32         uint16_t        wr_chan_freq;
33         uint16_t        wr_chan_flags;
34         uint8_t         wr_antenna;
35         uint8_t         wr_antsignal;
36 };
37
38 #define RAL_RX_RADIOTAP_PRESENT                                         \
39         ((1 << IEEE80211_RADIOTAP_FLAGS) |                              \
40          (1 << IEEE80211_RADIOTAP_RATE) |                               \
41          (1 << IEEE80211_RADIOTAP_CHANNEL) |                            \
42          (1 << IEEE80211_RADIOTAP_ANTENNA) |                            \
43          (1 << IEEE80211_RADIOTAP_DB_ANTSIGNAL))
44
45 struct ural_tx_radiotap_header {
46         struct ieee80211_radiotap_header wt_ihdr;
47         uint8_t         wt_flags;
48         uint8_t         wt_rate;
49         uint16_t        wt_chan_freq;
50         uint16_t        wt_chan_flags;
51         uint8_t         wt_antenna;
52 };
53
54 #define RAL_TX_RADIOTAP_PRESENT                                         \
55         ((1 << IEEE80211_RADIOTAP_FLAGS) |                              \
56          (1 << IEEE80211_RADIOTAP_RATE) |                               \
57          (1 << IEEE80211_RADIOTAP_CHANNEL) |                            \
58          (1 << IEEE80211_RADIOTAP_ANTENNA))
59
60 struct ural_softc;
61
62 struct ural_tx_data {
63         struct ural_softc       *sc;
64         usbd_xfer_handle        xfer;
65         uint8_t                 *buf;
66         struct mbuf             *m;
67         struct ieee80211_node   *ni;
68 };
69
70 struct ural_rx_data {
71         struct ural_softc       *sc;
72         usbd_xfer_handle        xfer;
73         uint8_t                 *buf;
74         struct mbuf             *m;
75 };
76
77 struct ural_softc {
78         struct ifnet                    *sc_ifp;
79         struct ieee80211com             sc_ic;
80         int                             (*sc_newstate)(struct ieee80211com *,
81                                             enum ieee80211_state, int);
82         device_t                        sc_dev;
83         usbd_device_handle              sc_udev;
84         usbd_interface_handle           sc_iface;
85
86         int                             sc_rx_no;
87         int                             sc_tx_no;
88
89         uint32_t                        asic_rev;
90         uint8_t                         rf_rev;
91
92         usbd_xfer_handle                amrr_xfer;
93
94         usbd_pipe_handle                sc_rx_pipeh;
95         usbd_pipe_handle                sc_tx_pipeh;
96
97         enum ieee80211_state            sc_state;
98         int                             sc_arg;
99         int                             sc_scan_action; /* should be an enum */
100         struct usb_task                 sc_task;
101         struct usb_task                 sc_scantask;
102
103         struct ieee80211_amrr           amrr;
104         struct ieee80211_amrr_node      amn;
105
106         struct ural_rx_data             rx_data[RAL_RX_LIST_COUNT];
107         struct ural_tx_data             tx_data[RAL_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         int                             sc_tx_timer;
117
118         uint16_t                        sta[11];
119         uint32_t                        rf_regs[4];
120         uint8_t                         txpow[14];
121
122         struct {
123                 uint8_t                 val;
124                 uint8_t                 reg;
125         } __packed                      bbp_prom[16];
126
127         int                             led_mode;
128         int                             hw_radio;
129         int                             rx_ant;
130         int                             tx_ant;
131         int                             nb_ant;
132
133         struct bpf_if                   *sc_drvbpf;
134
135         union {
136                 struct ural_rx_radiotap_header th;
137                 uint8_t pad[64];
138         }                               sc_rxtapu;
139 #define sc_rxtap        sc_rxtapu.th
140         int                             sc_rxtap_len;
141
142         union {
143                 struct ural_tx_radiotap_header th;
144                 uint8_t pad[64];
145         }                               sc_txtapu;
146 #define sc_txtap        sc_txtapu.th
147         int                             sc_txtap_len;
148 };
149
150 #if 0
151 #define RAL_LOCK(sc)    mtx_lock(&(sc)->sc_mtx)
152 #define RAL_UNLOCK(sc)  mtx_unlock(&(sc)->sc_mtx)
153 #else
154 #define RAL_LOCK(sc)    do { ((sc) = (sc)); mtx_lock(&Giant); } while (0)
155 #define RAL_UNLOCK(sc)  mtx_unlock(&Giant)
156 #endif