Add support for RT2500USB devices.
[dragonfly.git] / sys / dev / netif / ural / if_uralvar.h
1 /*      $FreeBSD: src/sys/dev/usb/if_uralvar.h,v 1.3.2.3 2006/01/29 14:16:36 damien Exp $       */
2 /*      $DragonFly: src/sys/dev/netif/ural/if_uralvar.h,v 1.1 2006/12/10 02:53:34 sephe Exp $   */
3
4 /*-
5  * Copyright (c) 2005, 2006
6  *      Damien Bergamini <damien.bergamini@free.fr>
7  *
8  * Permission to use, copy, modify, and distribute this software for any
9  * purpose with or without fee is hereby granted, provided that the above
10  * copyright notice and this permission notice appear in all copies.
11  *
12  * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
13  * WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
14  * MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
15  * ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
16  * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
17  * ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
18  * OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
19  */
20
21 #define RAL_RX_LIST_COUNT       1
22 #define RAL_TX_LIST_COUNT       1
23
24 struct ural_rx_radiotap_header {
25         struct ieee80211_radiotap_header wr_ihdr;
26         uint8_t         wr_flags;
27         uint8_t         wr_rate;
28         uint16_t        wr_chan_freq;
29         uint16_t        wr_chan_flags;
30         uint8_t         wr_antenna;
31         uint8_t         wr_antsignal;
32 };
33
34 #define RAL_RX_RADIOTAP_PRESENT                                         \
35         ((1 << IEEE80211_RADIOTAP_FLAGS) |                              \
36          (1 << IEEE80211_RADIOTAP_RATE) |                               \
37          (1 << IEEE80211_RADIOTAP_CHANNEL) |                            \
38          (1 << IEEE80211_RADIOTAP_ANTENNA) |                            \
39          (1 << IEEE80211_RADIOTAP_DB_ANTSIGNAL))
40
41 struct ural_tx_radiotap_header {
42         struct ieee80211_radiotap_header wt_ihdr;
43         uint8_t         wt_flags;
44         uint8_t         wt_rate;
45         uint16_t        wt_chan_freq;
46         uint16_t        wt_chan_flags;
47         uint8_t         wt_antenna;
48 };
49
50 #define RAL_TX_RADIOTAP_PRESENT                                         \
51         ((1 << IEEE80211_RADIOTAP_FLAGS) |                              \
52          (1 << IEEE80211_RADIOTAP_RATE) |                               \
53          (1 << IEEE80211_RADIOTAP_CHANNEL) |                            \
54          (1 << IEEE80211_RADIOTAP_ANTENNA))
55
56 struct ural_softc;
57
58 struct ural_tx_data {
59         struct ural_softc       *sc;
60         usbd_xfer_handle        xfer;
61         uint8_t                 *buf;
62         struct mbuf             *m;
63         struct ieee80211_node   *ni;
64 };
65
66 struct ural_rx_data {
67         struct ural_softc       *sc;
68         usbd_xfer_handle        xfer;
69         uint8_t                 *buf;
70         struct mbuf             *m;
71 };
72
73 struct ural_softc {
74         struct ieee80211com             sc_ic;
75         uint32_t                        sc_flags;
76 #define URAL_FLAG_SYNCTASK      0x1
77
78         int                             (*sc_newstate)(struct ieee80211com *,
79                                             enum ieee80211_state, int);
80         USBBASEDEVICE                   sc_dev;
81         usbd_device_handle              sc_udev;
82         usbd_interface_handle           sc_iface;
83
84         int                             sc_rx_no;
85         int                             sc_tx_no;
86
87         uint32_t                        asic_rev;
88         uint8_t                         rf_rev;
89
90         usbd_xfer_handle                stats_xfer;
91
92         usbd_pipe_handle                sc_rx_pipeh;
93         usbd_pipe_handle                sc_tx_pipeh;
94
95         enum ieee80211_state            sc_state;
96         struct usb_task                 sc_task;
97
98         struct ural_rx_data             rx_data[RAL_RX_LIST_COUNT];
99         struct ural_tx_data             tx_data[RAL_TX_LIST_COUNT];
100         int                             tx_queued;
101
102         struct ieee80211_beacon_offsets sc_bo;
103
104         struct ieee80211_ratectl_stats  sc_stats;
105         int                             sc_tx_retries;
106
107 #if 0
108         struct mtx                      sc_mtx;
109 #endif
110
111         struct callout                  scan_ch;
112         struct callout                  stats_ch;
113
114         int                             sc_tx_timer;
115
116         uint16_t                        sta[11];
117         uint32_t                        rf_regs[4];
118         uint8_t                         txpow[14];
119
120         struct {
121                 uint8_t                 val;
122                 uint8_t                 reg;
123         } __packed                      bbp_prom[16];
124
125         int                             led_mode;
126         int                             hw_radio;
127         int                             rx_ant;
128         int                             tx_ant;
129         int                             nb_ant;
130
131         struct bpf_if                   *sc_drvbpf;
132
133         union {
134                 struct ural_rx_radiotap_header th;
135                 uint8_t pad[64];
136         }                               sc_rxtapu;
137 #define sc_rxtap        sc_rxtapu.th
138         int                             sc_rxtap_len;
139
140         union {
141                 struct ural_tx_radiotap_header th;
142                 uint8_t pad[64];
143         }                               sc_txtapu;
144 #define sc_txtap        sc_txtapu.th
145         int                             sc_txtap_len;
146 };
147
148 /*
149  * Offsets into ural_softc.stap[]
150  */
151 /*
152  * Counters located at RAL_TX_PKT_ are the numbers of packets successfully
153  * or unsuccessfully transmitted.  Though you can calculate the number of
154  * transmissions from certain counter (e.g. NO_RETRY, ONE_RETRY and FAIL),
155  * the counters are NOT the number of transmissions (e.g. MULTI_RETRY).
156  */
157 #define RAL_TX_PKT_NO_RETRY     6
158 #define RAL_TX_PKT_ONE_RETRY    7
159 #define RAL_TX_PKT_MULTI_RETRY  8
160 #define RAL_TX_PKT_FAIL         9