]> CyberLeo.Net >> Repos - FreeBSD/FreeBSD.git/blob - sys/dev/usb/if_rumvar.h
Add basic support for RTL8168C, RTL8168CP, RTL8111C and RTL8111CP.
[FreeBSD/FreeBSD.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       8
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_node {
73         struct ieee80211_node   ni;
74         struct ieee80211_amrr_node amn;
75 };
76 #define RUM_NODE(ni)    ((struct rum_node *)(ni))
77
78 struct rum_vap {
79         struct ieee80211vap             vap;
80         struct ieee80211_beacon_offsets bo;
81         struct ieee80211_amrr           amrr;
82         struct callout                  amrr_ch;
83
84         int                             (*newstate)(struct ieee80211vap *,
85                                             enum ieee80211_state, int);
86 };
87 #define RUM_VAP(vap)    ((struct rum_vap *)(vap))
88
89 struct rum_softc {
90         struct ifnet                    *sc_ifp;
91         const struct ieee80211_rate_table *sc_rates;
92
93         device_t                        sc_dev;
94         usbd_device_handle              sc_udev;
95         usbd_interface_handle           sc_iface;
96
97         int                             sc_rx_no;
98         int                             sc_tx_no;
99
100         uint8_t                         rf_rev;
101         uint8_t                         rffreq;
102
103         usbd_xfer_handle                amrr_xfer;
104
105         usbd_pipe_handle                sc_rx_pipeh;
106         usbd_pipe_handle                sc_tx_pipeh;
107
108         enum ieee80211_state            sc_state;
109         int                             sc_arg;
110         struct usb_task                 sc_task;
111
112         struct usb_task                 sc_scantask;
113         int                             sc_scan_action;
114 #define RUM_SCAN_START  0
115 #define RUM_SCAN_END    1
116 #define RUM_SET_CHANNEL 2
117
118         struct rum_rx_data              rx_data[RUM_RX_LIST_COUNT];
119         struct rum_tx_data              tx_data[RUM_TX_LIST_COUNT];
120         int                             tx_queued;
121         int                             tx_cur;
122
123         struct mtx                      sc_mtx;
124
125         struct callout                  watchdog_ch;
126
127         int                             sc_tx_timer;
128
129         uint32_t                        sta[6];
130         uint32_t                        rf_regs[4];
131         uint8_t                         txpow[44];
132
133         struct {
134                 uint8_t val;
135                 uint8_t reg;
136         } __packed                      bbp_prom[16];
137
138         int                             hw_radio;
139         int                             rx_ant;
140         int                             tx_ant;
141         int                             nb_ant;
142         int                             ext_2ghz_lna;
143         int                             ext_5ghz_lna;
144         int                             rssi_2ghz_corr;
145         int                             rssi_5ghz_corr;
146         uint8_t                         bbp17;
147
148         struct rum_rx_radiotap_header   sc_rxtap;
149         int                             sc_rxtap_len;
150
151         struct rum_tx_radiotap_header   sc_txtap;
152         int                             sc_txtap_len;
153 };
154
155 #if 0
156 #define RUM_LOCK(sc)    mtx_lock(&(sc)->sc_mtx)
157 #define RUM_UNLOCK(sc)  mtx_unlock(&(sc)->sc_mtx)
158 #else
159 #define RUM_LOCK(sc)    do { ((sc) = (sc)); mtx_lock(&Giant); } while (0)
160 #define RUM_UNLOCK(sc)  mtx_unlock(&Giant)
161 #endif