kernel/usb4bsd: Bring in urtwn(4) and firmware.
[dragonfly.git] / sys / bus / u4b / wlan / if_rumvar.h
1 /*      $FreeBSD: src/sys/dev/usb/wlan/if_rumvar.h,v 1.10 2013/02/11 00:34:54 svnexp Exp $      */
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_TX_LIST_COUNT       8
21 #define RUM_TX_MINFREE          2
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         int8_t          wr_antsignal;
30         int8_t          wr_antnoise;
31         uint8_t         wr_antenna;
32 };
33
34 #define RT2573_RX_RADIOTAP_PRESENT                                      \
35         ((1 << IEEE80211_RADIOTAP_FLAGS) |                              \
36          (1 << IEEE80211_RADIOTAP_RATE) |                               \
37          (1 << IEEE80211_RADIOTAP_CHANNEL) |                            \
38          (1 << IEEE80211_RADIOTAP_DBM_ANTSIGNAL) |                      \
39          (1 << IEEE80211_RADIOTAP_DBM_ANTNOISE) |                       \
40          (1 << IEEE80211_RADIOTAP_ANTENNA) |                            \
41          0)
42
43 struct rum_tx_radiotap_header {
44         struct ieee80211_radiotap_header wt_ihdr;
45         uint8_t         wt_flags;
46         uint8_t         wt_rate;
47         uint16_t        wt_chan_freq;
48         uint16_t        wt_chan_flags;
49         uint8_t         wt_antenna;
50 };
51
52 #define RT2573_TX_RADIOTAP_PRESENT                                      \
53         ((1 << IEEE80211_RADIOTAP_FLAGS) |                              \
54          (1 << IEEE80211_RADIOTAP_RATE) |                               \
55          (1 << IEEE80211_RADIOTAP_CHANNEL) |                            \
56          (1 << IEEE80211_RADIOTAP_ANTENNA))
57
58 struct rum_softc;
59
60 struct rum_tx_data {
61         STAILQ_ENTRY(rum_tx_data)       next;
62         struct rum_softc                *sc;
63         struct rum_tx_desc              desc;
64         struct mbuf                     *m;
65         struct ieee80211_node           *ni;
66         int                             rate;
67 };
68 typedef STAILQ_HEAD(, rum_tx_data) rum_txdhead;
69
70 struct rum_vap {
71         struct ieee80211vap             vap;
72         struct ieee80211_beacon_offsets bo;
73         struct usb_callout              ratectl_ch;
74         struct task                     ratectl_task;
75
76         int                             (*newstate)(struct ieee80211vap *,
77                                             enum ieee80211_state, int);
78 };
79 #define RUM_VAP(vap)    ((struct rum_vap *)(vap))
80
81 enum {
82         RUM_BULK_WR,
83         RUM_BULK_RD,
84         RUM_N_TRANSFER = 2,
85 };
86
87 struct rum_softc {
88         struct ifnet                    *sc_ifp;
89         device_t                        sc_dev;
90         struct usb_device               *sc_udev;
91
92         struct usb_xfer         *sc_xfer[RUM_N_TRANSFER];
93
94         uint8_t                         rf_rev;
95         uint8_t                         rffreq;
96
97         struct rum_tx_data              tx_data[RUM_TX_LIST_COUNT];
98         rum_txdhead                     tx_q;
99         rum_txdhead                     tx_free;
100         int                             tx_nfree;
101         struct rum_rx_desc              sc_rx_desc;
102
103         struct lock                     sc_lock;
104
105         uint32_t                        sta[6];
106         uint32_t                        rf_regs[4];
107         uint8_t                         txpow[44];
108         uint8_t                         sc_bssid[6];
109         uint8_t                         sc_detached;
110
111         struct {
112                 uint8_t val;
113                 uint8_t reg;
114         } __packed                      bbp_prom[16];
115
116         int                             hw_radio;
117         int                             rx_ant;
118         int                             tx_ant;
119         int                             nb_ant;
120         int                             ext_2ghz_lna;
121         int                             ext_5ghz_lna;
122         int                             rssi_2ghz_corr;
123         int                             rssi_5ghz_corr;
124         uint8_t                         bbp17;
125
126         struct rum_rx_radiotap_header   sc_rxtap;
127         int                             sc_rxtap_len;
128
129         struct rum_tx_radiotap_header   sc_txtap;
130         int                             sc_txtap_len;
131 };
132
133 #define RUM_LOCK(sc)            lockmgr(&(sc)->sc_lock, LK_EXCLUSIVE)
134 #define RUM_UNLOCK(sc)          lockmgr(&(sc)->sc_lock, LK_RELEASE)
135 #define RUM_LOCK_ASSERT(sc, t)  KKASSERT(lockstatus(&(sc)->sc_lock, curthread) != 0)