if_urtwnvar.h revision 1.4 1 /* $NetBSD: if_urtwnvar.h,v 1.4 2013/01/20 20:21:57 christos Exp $ */
2 /* $OpenBSD: if_urtwnreg.h,v 1.3 2010/11/16 18:02:59 damien Exp $ */
3
4 /*-
5 * Copyright (c) 2010 Damien Bergamini <damien.bergamini (at) 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 #ifndef _IF_URTWNVAR_H_
20 #define _IF_URTWNVAR_H_
21
22 /*
23 * Driver definitions.
24 */
25 #define URTWN_RX_LIST_COUNT 1
26 #define URTWN_TX_LIST_COUNT 8
27 #define URTWN_HOST_CMD_RING_COUNT 32
28
29 #define URTWN_RXBUFSZ (16 * 1024)
30 #define URTWN_TXBUFSZ (sizeof(struct r92c_tx_desc) + IEEE80211_MAX_LEN + 8)
31
32 #define URTWN_RIDX_COUNT 28
33
34 #define URTWN_TX_TIMEOUT 5000 /* ms */
35
36 #define URTWN_LED_LINK 0
37 #define URTWN_LED_DATA 1
38
39 struct urtwn_rx_radiotap_header {
40 struct ieee80211_radiotap_header wr_ihdr;
41 uint8_t wr_flags;
42 uint8_t wr_rate;
43 uint16_t wr_chan_freq;
44 uint16_t wr_chan_flags;
45 uint8_t wr_dbm_antsignal;
46 } __packed;
47
48 #define URTWN_RX_RADIOTAP_PRESENT \
49 (1 << IEEE80211_RADIOTAP_FLAGS | \
50 1 << IEEE80211_RADIOTAP_RATE | \
51 1 << IEEE80211_RADIOTAP_CHANNEL | \
52 1 << IEEE80211_RADIOTAP_DBM_ANTSIGNAL)
53
54 struct urtwn_tx_radiotap_header {
55 struct ieee80211_radiotap_header wt_ihdr;
56 uint8_t wt_flags;
57 uint16_t wt_chan_freq;
58 uint16_t wt_chan_flags;
59 } __packed;
60
61 #define URTWN_TX_RADIOTAP_PRESENT \
62 (1 << IEEE80211_RADIOTAP_FLAGS | \
63 1 << IEEE80211_RADIOTAP_CHANNEL)
64
65 struct urtwn_softc;
66
67 struct urtwn_rx_data {
68 struct urtwn_softc *sc;
69 usbd_xfer_handle xfer;
70 uint8_t *buf;
71 };
72
73 struct urtwn_tx_data {
74 struct urtwn_softc *sc;
75 usbd_pipe_handle pipe;
76 usbd_xfer_handle xfer;
77 uint8_t *buf;
78 TAILQ_ENTRY(urtwn_tx_data) next;
79 };
80
81 struct urtwn_host_cmd {
82 void (*cb)(struct urtwn_softc *, void *);
83 uint8_t data[256];
84 };
85
86 struct urtwn_cmd_newstate {
87 enum ieee80211_state state;
88 int arg;
89 };
90
91 struct urtwn_host_cmd_ring {
92 struct urtwn_host_cmd cmd[URTWN_HOST_CMD_RING_COUNT];
93 int cur;
94 int next;
95 int queued;
96 };
97
98 #if 1 /* XXX: sys/net80211/ieee80211.h */
99
100 #define IEEE80211_HTINFO_2NDCHAN 0x03 /* secondary/ext chan offset */
101 #define IEEE80211_HTINFO_2NDCHAN_S 0
102 #define IEEE80211_HTINFO_2NDCHAN_NONE 0x00 /* no secondary/ext channel */
103 #define IEEE80211_HTINFO_2NDCHAN_ABOVE 0x01 /* above private channel */
104 /* NB: 2 is reserved */
105 #define IEEE80211_HTINFO_2NDCHAN_BELOW 0x03 /* below primary channel */
106 #endif /* XXX: 1 */
107
108 struct urtwn_softc {
109 device_t sc_dev;
110 struct ieee80211com sc_ic;
111 struct ethercom sc_ec;
112 #define sc_if sc_ec.ec_if
113 int (*sc_newstate)(struct ieee80211com *,
114 enum ieee80211_state, int);
115
116 usbd_device_handle sc_udev;
117 usbd_interface_handle sc_iface;
118 u_int sc_flags;
119 #define URTWN_FLAG_CCK_HIPWR __BIT(0)
120 #define URTWN_FLAG_ATTACHED __BIT(1)
121 #define URTWN_FLAG_FWREADY __BIT(2)
122 int sc_dying;
123
124 struct usb_task sc_task;
125 callout_t sc_scan_to;
126 callout_t sc_calib_to;
127
128 kmutex_t sc_task_mtx;
129 kmutex_t sc_fwcmd_mtx;
130 kmutex_t sc_tx_mtx;
131 kmutex_t sc_write_mtx;
132
133 usbd_pipe_handle rx_pipe;
134 int rx_npipe;
135 usbd_pipe_handle tx_pipe[R92C_MAX_EPOUT];
136 int tx_npipe;
137 int ac2idx[WME_NUM_AC];
138
139 u_int chip;
140 #define URTWN_CHIP_92C 0x01
141 #define URTWN_CHIP_92C_1T2R 0x02
142 #define URTWN_CHIP_UMC 0x04
143 #define URTWN_CHIP_UMC_A_CUT 0x08
144
145 uint8_t board_type;
146 uint8_t regulatory;
147 uint8_t pa_setting;
148 int avg_pwdb;
149 int thcal_state;
150 int thcal_lctemp;
151 int ntxchains;
152 int nrxchains;
153 int ledlink;
154 bool iqk_inited;
155
156 int tx_timer;
157
158 struct urtwn_host_cmd_ring cmdq;
159 int fwcur;
160 struct urtwn_rx_data rx_data[URTWN_RX_LIST_COUNT];
161 struct urtwn_tx_data tx_data[URTWN_TX_LIST_COUNT];
162 TAILQ_HEAD(, urtwn_tx_data) tx_free_list;
163
164 struct r92c_rom rom;
165
166 uint32_t rf_chnlbw[R92C_MAX_CHAINS];
167
168 struct bpf_if * sc_drvbpf;
169 union {
170 struct urtwn_rx_radiotap_header th;
171 uint8_t pad[64];
172 } sc_rxtapu;
173 #define sc_rxtap sc_rxtapu.th
174 int sc_rxtap_len;
175 union {
176 struct urtwn_tx_radiotap_header th;
177 uint8_t pad[64];
178 } sc_txtapu;
179 #define sc_txtap sc_txtapu.th
180 int sc_txtap_len;
181 };
182
183 #endif /* _IF_URTWNVAR_H_ */
184
185