mac80211: move TX info into skb->cb
[deliverable/linux.git] / drivers / net / wireless / rt2x00 / rt2x00usb.h
1 /*
2 Copyright (C) 2004 - 2008 rt2x00 SourceForge Project
3 <http://rt2x00.serialmonkey.com>
4
5 This program is free software; you can redistribute it and/or modify
6 it under the terms of the GNU General Public License as published by
7 the Free Software Foundation; either version 2 of the License, or
8 (at your option) any later version.
9
10 This program is distributed in the hope that it will be useful,
11 but WITHOUT ANY WARRANTY; without even the implied warranty of
12 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 GNU General Public License for more details.
14
15 You should have received a copy of the GNU General Public License
16 along with this program; if not, write to the
17 Free Software Foundation, Inc.,
18 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
19 */
20
21 /*
22 Module: rt2x00usb
23 Abstract: Data structures for the rt2x00usb module.
24 */
25
26 #ifndef RT2X00USB_H
27 #define RT2X00USB_H
28
29 /*
30 * This variable should be used with the
31 * usb_driver structure initialization.
32 */
33 #define USB_DEVICE_DATA(__ops) .driver_info = (kernel_ulong_t)(__ops)
34
35 /*
36 * Register defines.
37 * Some registers require multiple attempts before success,
38 * in those cases REGISTER_BUSY_COUNT attempts should be
39 * taken with a REGISTER_BUSY_DELAY interval.
40 * For USB vendor requests we need to pass a timeout
41 * time in ms, for this we use the REGISTER_TIMEOUT,
42 * however when loading firmware a higher value is
43 * required. In that case we use the REGISTER_TIMEOUT_FIRMWARE.
44 */
45 #define REGISTER_BUSY_COUNT 5
46 #define REGISTER_BUSY_DELAY 100
47 #define REGISTER_TIMEOUT 500
48 #define REGISTER_TIMEOUT_FIRMWARE 1000
49
50 /**
51 * REGISTER_TIMEOUT16 - Determine the timeout for 16bit register access
52 * @__datalen: Data length
53 */
54 #define REGISTER_TIMEOUT16(__datalen) \
55 ( REGISTER_TIMEOUT * ((__datalen) / sizeof(u16)) )
56
57 /**
58 * REGISTER_TIMEOUT32 - Determine the timeout for 32bit register access
59 * @__datalen: Data length
60 */
61 #define REGISTER_TIMEOUT32(__datalen) \
62 ( REGISTER_TIMEOUT * ((__datalen) / sizeof(u32)) )
63
64 /*
65 * Cache size
66 */
67 #define CSR_CACHE_SIZE 8
68 #define CSR_CACHE_SIZE_FIRMWARE 64
69
70 /*
71 * USB request types.
72 */
73 #define USB_VENDOR_REQUEST ( USB_TYPE_VENDOR | USB_RECIP_DEVICE )
74 #define USB_VENDOR_REQUEST_IN ( USB_DIR_IN | USB_VENDOR_REQUEST )
75 #define USB_VENDOR_REQUEST_OUT ( USB_DIR_OUT | USB_VENDOR_REQUEST )
76
77 /**
78 * enum rt2x00usb_vendor_request: USB vendor commands.
79 */
80 enum rt2x00usb_vendor_request {
81 USB_DEVICE_MODE = 1,
82 USB_SINGLE_WRITE = 2,
83 USB_SINGLE_READ = 3,
84 USB_MULTI_WRITE = 6,
85 USB_MULTI_READ = 7,
86 USB_EEPROM_WRITE = 8,
87 USB_EEPROM_READ = 9,
88 USB_LED_CONTROL = 10, /* RT73USB */
89 USB_RX_CONTROL = 12,
90 };
91
92 /**
93 * enum rt2x00usb_mode_offset: Device modes offset.
94 */
95 enum rt2x00usb_mode_offset {
96 USB_MODE_RESET = 1,
97 USB_MODE_UNPLUG = 2,
98 USB_MODE_FUNCTION = 3,
99 USB_MODE_TEST = 4,
100 USB_MODE_SLEEP = 7, /* RT73USB */
101 USB_MODE_FIRMWARE = 8, /* RT73USB */
102 USB_MODE_WAKEUP = 9, /* RT73USB */
103 };
104
105 /**
106 * rt2x00usb_vendor_request - Send register command to device
107 * @rt2x00dev: Pointer to &struct rt2x00_dev
108 * @request: USB vendor command (See &enum rt2x00usb_vendor_request)
109 * @requesttype: Request type &USB_VENDOR_REQUEST_*
110 * @offset: Register offset to perform action on
111 * @value: Value to write to device
112 * @buffer: Buffer where information will be read/written to by device
113 * @buffer_length: Size of &buffer
114 * @timeout: Operation timeout
115 *
116 * This is the main function to communicate with the device,
117 * the &buffer argument _must_ either be NULL or point to
118 * a buffer allocated by kmalloc. Failure to do so can lead
119 * to unexpected behavior depending on the architecture.
120 */
121 int rt2x00usb_vendor_request(struct rt2x00_dev *rt2x00dev,
122 const u8 request, const u8 requesttype,
123 const u16 offset, const u16 value,
124 void *buffer, const u16 buffer_length,
125 const int timeout);
126
127 /**
128 * rt2x00usb_vendor_request_buff - Send register command to device (buffered)
129 * @rt2x00dev: Pointer to &struct rt2x00_dev
130 * @request: USB vendor command (See &enum rt2x00usb_vendor_request)
131 * @requesttype: Request type &USB_VENDOR_REQUEST_*
132 * @offset: Register offset to perform action on
133 * @buffer: Buffer where information will be read/written to by device
134 * @buffer_length: Size of &buffer
135 * @timeout: Operation timeout
136 *
137 * This function will use a previously with kmalloc allocated cache
138 * to communicate with the device. The contents of the buffer pointer
139 * will be copied to this cache when writing, or read from the cache
140 * when reading.
141 * Buffers send to &rt2x00usb_vendor_request _must_ be allocated with
142 * kmalloc. Hence the reason for using a previously allocated cache
143 * which has been allocated properly.
144 */
145 int rt2x00usb_vendor_request_buff(struct rt2x00_dev *rt2x00dev,
146 const u8 request, const u8 requesttype,
147 const u16 offset, void *buffer,
148 const u16 buffer_length, const int timeout);
149
150 /**
151 * rt2x00usb_vendor_request_buff - Send register command to device (buffered)
152 * @rt2x00dev: Pointer to &struct rt2x00_dev
153 * @request: USB vendor command (See &enum rt2x00usb_vendor_request)
154 * @requesttype: Request type &USB_VENDOR_REQUEST_*
155 * @offset: Register offset to perform action on
156 * @buffer: Buffer where information will be read/written to by device
157 * @buffer_length: Size of &buffer
158 * @timeout: Operation timeout
159 *
160 * A version of &rt2x00usb_vendor_request_buff which must be called
161 * if the usb_cache_mutex is already held.
162 */
163 int rt2x00usb_vendor_req_buff_lock(struct rt2x00_dev *rt2x00dev,
164 const u8 request, const u8 requesttype,
165 const u16 offset, void *buffer,
166 const u16 buffer_length, const int timeout);
167
168 /**
169 * rt2x00usb_vendor_request_sw - Send single register command to device
170 * @rt2x00dev: Pointer to &struct rt2x00_dev
171 * @request: USB vendor command (See &enum rt2x00usb_vendor_request)
172 * @offset: Register offset to perform action on
173 * @value: Value to write to device
174 * @timeout: Operation timeout
175 *
176 * Simple wrapper around rt2x00usb_vendor_request to write a single
177 * command to the device. Since we don't use the buffer argument we
178 * don't have to worry about kmalloc here.
179 */
180 static inline int rt2x00usb_vendor_request_sw(struct rt2x00_dev *rt2x00dev,
181 const u8 request,
182 const u16 offset,
183 const u16 value,
184 const int timeout)
185 {
186 return rt2x00usb_vendor_request(rt2x00dev, request,
187 USB_VENDOR_REQUEST_OUT, offset,
188 value, NULL, 0, timeout);
189 }
190
191 /**
192 * rt2x00usb_eeprom_read - Read eeprom from device
193 * @rt2x00dev: Pointer to &struct rt2x00_dev
194 * @eeprom: Pointer to eeprom array to store the information in
195 * @length: Number of bytes to read from the eeprom
196 *
197 * Simple wrapper around rt2x00usb_vendor_request to read the eeprom
198 * from the device. Note that the eeprom argument _must_ be allocated using
199 * kmalloc for correct handling inside the kernel USB layer.
200 */
201 static inline int rt2x00usb_eeprom_read(struct rt2x00_dev *rt2x00dev,
202 __le16 *eeprom, const u16 length)
203 {
204 return rt2x00usb_vendor_request(rt2x00dev, USB_EEPROM_READ,
205 USB_VENDOR_REQUEST_IN, 0, 0,
206 eeprom, length,
207 REGISTER_TIMEOUT16(length));
208 }
209
210 /*
211 * Radio handlers
212 */
213 void rt2x00usb_disable_radio(struct rt2x00_dev *rt2x00dev);
214
215 /*
216 * TX data handlers.
217 */
218 int rt2x00usb_write_tx_data(struct rt2x00_dev *rt2x00dev,
219 struct data_queue *queue, struct sk_buff *skb);
220
221 /**
222 * struct queue_entry_priv_usb: Per entry USB specific information
223 *
224 * @urb: Urb structure used for device communication.
225 */
226 struct queue_entry_priv_usb {
227 struct urb *urb;
228 };
229
230 /**
231 * struct queue_entry_priv_usb_bcn: Per TX entry USB specific information
232 *
233 * The first section should match &struct queue_entry_priv_usb exactly.
234 * rt2500usb can use this structure to send a guardian byte when working
235 * with beacons.
236 *
237 * @urb: Urb structure used for device communication.
238 * @guardian_data: Set to 0, used for sending the guardian data.
239 * @guardian_urb: Urb structure used to send the guardian data.
240 */
241 struct queue_entry_priv_usb_bcn {
242 struct urb *urb;
243
244 unsigned int guardian_data;
245 struct urb *guardian_urb;
246 };
247
248 /*
249 * Device initialization handlers.
250 */
251 void rt2x00usb_init_rxentry(struct rt2x00_dev *rt2x00dev,
252 struct queue_entry *entry);
253 void rt2x00usb_init_txentry(struct rt2x00_dev *rt2x00dev,
254 struct queue_entry *entry);
255 int rt2x00usb_initialize(struct rt2x00_dev *rt2x00dev);
256 void rt2x00usb_uninitialize(struct rt2x00_dev *rt2x00dev);
257
258 /*
259 * USB driver handlers.
260 */
261 int rt2x00usb_probe(struct usb_interface *usb_intf,
262 const struct usb_device_id *id);
263 void rt2x00usb_disconnect(struct usb_interface *usb_intf);
264 #ifdef CONFIG_PM
265 int rt2x00usb_suspend(struct usb_interface *usb_intf, pm_message_t state);
266 int rt2x00usb_resume(struct usb_interface *usb_intf);
267 #else
268 #define rt2x00usb_suspend NULL
269 #define rt2x00usb_resume NULL
270 #endif /* CONFIG_PM */
271
272 #endif /* RT2X00USB_H */
This page took 0.074769 seconds and 5 git commands to generate.