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