]> CyberLeo.Net >> Repos - FreeBSD/FreeBSD.git/blob - sys/dev/usb/if_uralvar.h
This commit was generated by cvs2svn to compensate for changes in r154178,
[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       1
22
23 struct ural_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 RAL_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 ural_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 RAL_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 ural_softc;
56
57 struct ural_tx_data {
58         struct ural_softc       *sc;
59         usbd_xfer_handle        xfer;
60         uint8_t                 *buf;
61         struct mbuf             *m;
62         struct ieee80211_node   *ni;
63 };
64
65 struct ural_rx_data {
66         struct ural_softc       *sc;
67         usbd_xfer_handle        xfer;
68         uint8_t                 *buf;
69         struct mbuf             *m;
70 };
71
72 struct ural_amrr {
73         int     txcnt;
74         int     retrycnt;
75         int     success;
76         int     success_threshold;
77         int     recovery;
78 };
79
80 struct ural_softc {
81         struct ifnet                    *sc_ifp;
82         struct ieee80211com             sc_ic;
83         int                             (*sc_newstate)(struct ieee80211com *,
84                                             enum ieee80211_state, int);
85         USBBASEDEVICE                   sc_dev;
86         usbd_device_handle              sc_udev;
87         usbd_interface_handle           sc_iface;
88
89         int                             sc_rx_no;
90         int                             sc_tx_no;
91
92         uint32_t                        asic_rev;
93         uint8_t                         rf_rev;
94
95         usbd_xfer_handle                amrr_xfer;
96
97         usbd_pipe_handle                sc_rx_pipeh;
98         usbd_pipe_handle                sc_tx_pipeh;
99
100         enum ieee80211_state            sc_state;
101         struct usb_task                 sc_task;
102
103         struct ural_amrr                amrr;
104
105         struct ural_rx_data             rx_data[RAL_RX_LIST_COUNT];
106         struct ural_tx_data             tx_data[RAL_TX_LIST_COUNT];
107         int                             tx_queued;
108
109         struct ieee80211_beacon_offsets sc_bo;
110
111         struct mtx                      sc_mtx;
112
113         struct callout                  scan_ch;
114         struct callout                  amrr_ch;
115
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