]> CyberLeo.Net >> Repos - FreeBSD/FreeBSD.git/blob - sys/dev/usb/if_uralvar.h
add -n option to suppress clearing the build tree and add -DNO_CLEAN
[FreeBSD/FreeBSD.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       8
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_node {
78         struct ieee80211_node           ni;
79         struct ieee80211_amrr_node      amn;
80 };
81 #define URAL_NODE(ni)   ((struct ural_node *)(ni))
82
83 struct ural_vap {
84         struct ieee80211vap             vap;
85         struct ieee80211_beacon_offsets bo;
86         struct ieee80211_amrr           amrr;
87         struct callout                  amrr_ch;
88
89         int                             (*newstate)(struct ieee80211vap *,
90                                             enum ieee80211_state, int);
91 };
92 #define URAL_VAP(vap)   ((struct ural_vap *)(vap))
93
94 struct ural_softc {
95         struct ifnet                    *sc_ifp;
96         device_t                        sc_dev;
97         usbd_device_handle              sc_udev;
98         usbd_interface_handle           sc_iface;
99
100         const struct ieee80211_rate_table *sc_rates;
101
102         int                             sc_rx_no;
103         int                             sc_tx_no;
104
105         uint32_t                        asic_rev;
106         uint8_t                         rf_rev;
107
108         usbd_xfer_handle                amrr_xfer;
109
110         usbd_pipe_handle                sc_rx_pipeh;
111         usbd_pipe_handle                sc_tx_pipeh;
112
113         enum ieee80211_state            sc_state;
114         int                             sc_arg;
115         int                             sc_scan_action; /* should be an enum */
116         struct usb_task                 sc_task;
117         struct usb_task                 sc_scantask;
118
119         struct ural_rx_data             rx_data[RAL_RX_LIST_COUNT];
120         struct ural_tx_data             tx_data[RAL_TX_LIST_COUNT];
121         int                             tx_queued;
122         int                             tx_cur;
123
124         struct mtx                      sc_mtx;
125
126         struct callout                  watchdog_ch;
127         int                             sc_tx_timer;
128
129         uint16_t                        sta[11];
130         uint32_t                        rf_regs[4];
131         uint8_t                         txpow[14];
132
133         struct {
134                 uint8_t                 val;
135                 uint8_t                 reg;
136         } __packed                      bbp_prom[16];
137
138         int                             led_mode;
139         int                             hw_radio;
140         int                             rx_ant;
141         int                             tx_ant;
142         int                             nb_ant;
143
144         struct ural_rx_radiotap_header  sc_rxtap;
145         int                             sc_rxtap_len;
146
147         struct ural_tx_radiotap_header  sc_txtap;
148         int                             sc_txtap_len;
149 };
150
151 #if 0
152 #define RAL_LOCK(sc)    mtx_lock(&(sc)->sc_mtx)
153 #define RAL_UNLOCK(sc)  mtx_unlock(&(sc)->sc_mtx)
154 #else
155 #define RAL_LOCK(sc)    do { ((sc) = (sc)); mtx_lock(&Giant); } while (0)
156 #define RAL_UNLOCK(sc)  mtx_unlock(&Giant)
157 #endif