Debian Codegraph @

patches/old/rtl8187_2.6.21.patch

raw
1 diff -Naur rtl8187_orig/beta-8187/ieee80211.h rtl8187_rawtx/beta-8187/ieee80211.h
2 --- rtl8187_orig/beta-8187/ieee80211.h 2007-03-13 23:45:09.000000000 +0100
3 +++ rtl8187_rawtx/beta-8187/ieee80211.h 2007-06-05 14:00:05.000000000 +0200
4 @@ -156,6 +156,22 @@
5 struct list_head list;
6 };
7
8 +#define LWNG_CAP_DID_BASE (4 | (1 << 6)) /* section 4, group 1 */
9 +/* ARPHRD_IEEE80211_PRISM uses a bloated version of Prism2 RX frame header
10 + * (from linux-wlan-ng) */
11 +struct linux_wlan_ng_val {
12 + u32 did;
13 + u16 status, len;
14 + u32 data;
15 +} __attribute__ ((packed));
16 +
17 +struct linux_wlan_ng_prism_hdr {
18 + u32 msgcode, msglen;
19 + char devname[16];
20 + struct linux_wlan_ng_val hosttime, mactime, channel, rssi, sq, signal,
21 + noise, rate, istx, frmlen;
22 +} __attribute__ ((packed));
23 +
24 struct ieee80211_hdr {
25 u16 frame_ctl;
26 u16 duration_id;
27 @@ -840,14 +856,14 @@
28
29
30 #if (LINUX_VERSION_CODE <= KERNEL_VERSION(2,6,11))
31 -extern inline int is_multicast_ether_addr(const u8 *addr)
32 +extern inline int is_multicast_ether_addr_rtl7(const u8 *addr)
33 {
34 return ((addr[0] != 0xff) && (0x01 & addr[0]));
35 }
36 #endif
37
38 #if (LINUX_VERSION_CODE <= KERNEL_VERSION(2,6,13))
39 -extern inline int is_broadcast_ether_addr(const u8 *addr)
40 +extern inline int is_broadcast_ether_addr_rtl7(const u8 *addr)
41 {
42 return ((addr[0] == 0xff) && (addr[1] == 0xff) && (addr[2] == 0xff) && \
43 (addr[3] == 0xff) && (addr[4] == 0xff) && (addr[5] == 0xff));
44 @@ -1015,10 +1031,16 @@
45 struct timer_list beacon_timer;
46
47 struct work_struct associate_complete_wq;
48 +
49 +# if (LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,20))
50 + struct delayed_work associate_retry_wq;
51 + struct delayed_work softmac_scan_wq;
52 +#else
53 struct work_struct associate_retry_wq;
54 + struct work_struct softmac_scan_wq;
55 +#endif
56 struct work_struct start_ibss_wq;
57 struct work_struct associate_procedure_wq;
58 - struct work_struct softmac_scan_wq;
59 struct work_struct wx_sync_scan_wq;
60
61 struct workqueue_struct *wq;
62 @@ -1154,12 +1176,12 @@
63
64
65
66 -extern inline void *ieee80211_priv(struct net_device *dev)
67 +extern inline void *ieee80211_priv_rtl7(struct net_device *dev)
68 {
69 return ((struct ieee80211_device *)netdev_priv(dev))->priv;
70 }
71
72 -extern inline int ieee80211_is_empty_essid(const char *essid, int essid_len)
73 +extern inline int ieee80211_is_empty_essid_rtl7(const char *essid, int essid_len)
74 {
75 /* Single white space is for Linksys APs */
76 if (essid_len == 1 && essid[0] == ' ')
77 @@ -1175,7 +1197,7 @@
78 return 1;
79 }
80
81 -extern inline int ieee80211_is_valid_mode(struct ieee80211_device *ieee, int mode)
82 +extern inline int ieee80211_is_valid_mode_rtl7(struct ieee80211_device *ieee, int mode)
83 {
84 /*
85 * It is possible for both access points and our device to support
86 @@ -1201,7 +1223,7 @@
87 return 0;
88 }
89
90 -extern inline int ieee80211_get_hdrlen(u16 fc)
91 +extern inline int ieee80211_get_hdrlen_rtl7(u16 fc)
92 {
93 int hdrlen = 24;
94
95 @@ -1229,140 +1251,144 @@
96
97
98 /* ieee80211.c */
99 -extern void free_ieee80211(struct net_device *dev);
100 -extern struct net_device *alloc_ieee80211(int sizeof_priv);
101 +extern void free_ieee80211_rtl7(struct net_device *dev);
102 +extern struct net_device *alloc_ieee80211_rtl7(int sizeof_priv);
103
104 -extern int ieee80211_set_encryption(struct ieee80211_device *ieee);
105 +extern int ieee80211_set_encryption_rtl7(struct ieee80211_device *ieee);
106
107 /* ieee80211_tx.c */
108
109 -extern int ieee80211_encrypt_fragment(
110 +extern int ieee80211_encrypt_fragment_rtl7(
111 struct ieee80211_device *ieee,
112 struct sk_buff *frag,
113 int hdr_len);
114
115 -extern int ieee80211_xmit(struct sk_buff *skb,
116 +extern int ieee80211_xmit_rtl7(struct sk_buff *skb,
117 struct net_device *dev);
118 -extern void ieee80211_txb_free(struct ieee80211_txb *);
119 +extern void ieee80211_txb_free_rtl7(struct ieee80211_txb *);
120
121
122 /* ieee80211_rx.c */
123 -extern int ieee80211_rx(struct ieee80211_device *ieee, struct sk_buff *skb,
124 +extern int ieee80211_rx_rtl7(struct ieee80211_device *ieee, struct sk_buff *skb,
125 struct ieee80211_rx_stats *rx_stats);
126 -extern void ieee80211_rx_mgt(struct ieee80211_device *ieee,
127 +extern void ieee80211_rx_mgt_rtl7(struct ieee80211_device *ieee,
128 struct ieee80211_hdr *header,
129 struct ieee80211_rx_stats *stats);
130
131 /* ieee80211_wx.c */
132 -extern int ieee80211_wx_get_scan(struct ieee80211_device *ieee,
133 +extern int ieee80211_wx_get_scan_rtl7(struct ieee80211_device *ieee,
134 struct iw_request_info *info,
135 union iwreq_data *wrqu, char *key);
136 -extern int ieee80211_wx_set_encode(struct ieee80211_device *ieee,
137 +extern int ieee80211_wx_set_encode_rtl7(struct ieee80211_device *ieee,
138 struct iw_request_info *info,
139 union iwreq_data *wrqu, char *key);
140 -extern int ieee80211_wx_get_encode(struct ieee80211_device *ieee,
141 +extern int ieee80211_wx_get_encode_rtl7(struct ieee80211_device *ieee,
142 struct iw_request_info *info,
143 union iwreq_data *wrqu, char *key);
144 /* ieee80211_softmac.c */
145 -extern short ieee80211_is_54g(struct ieee80211_network net);
146 -extern short ieee80211_is_shortslot(struct ieee80211_network net);
147 -extern int ieee80211_rx_frame_softmac(struct ieee80211_device *ieee, struct sk_buff *skb,
148 +extern short ieee80211_is_54g_rtl7(struct ieee80211_network net);
149 +extern short ieee80211_is_shortslot_rtl7(struct ieee80211_network net);
150 +extern int ieee80211_rx_frame_softmac_rtl7(struct ieee80211_device *ieee, struct sk_buff *skb,
151 struct ieee80211_rx_stats *rx_stats, u16 type,
152 u16 stype);
153 -extern void ieee80211_softmac_new_net(struct ieee80211_device *ieee, struct ieee80211_network *net);
154 +extern void ieee80211_softmac_new_net_rtl7(struct ieee80211_device *ieee, struct ieee80211_network *net);
155
156 -extern void ieee80211_softmac_xmit(struct ieee80211_txb *txb, struct ieee80211_device *ieee);
157 -extern void ieee80211_softmac_check_all_nets(struct ieee80211_device *ieee);
158 -extern void ieee80211_start_bss(struct ieee80211_device *ieee);
159 -extern void ieee80211_start_master_bss(struct ieee80211_device *ieee);
160 -extern void ieee80211_start_ibss(struct ieee80211_device *ieee);
161 -extern void ieee80211_softmac_init(struct ieee80211_device *ieee);
162 -extern void ieee80211_softmac_free(struct ieee80211_device *ieee);
163 -extern void ieee80211_associate_abort(struct ieee80211_device *ieee);
164 -extern void ieee80211_disassociate(struct ieee80211_device *ieee);
165 -extern void ieee80211_stop_scan(struct ieee80211_device *ieee);
166 -extern void ieee80211_start_scan_syncro(struct ieee80211_device *ieee);
167 -extern void ieee80211_check_all_nets(struct ieee80211_device *ieee);
168 -extern void ieee80211_start_protocol(struct ieee80211_device *ieee);
169 -extern void ieee80211_stop_protocol(struct ieee80211_device *ieee);
170 -extern void ieee80211_softmac_start_protocol(struct ieee80211_device *ieee);
171 -extern void ieee80211_softmac_stop_protocol(struct ieee80211_device *ieee);
172 -extern void ieee80211_reset_queue(struct ieee80211_device *ieee);
173 -extern void ieee80211_wake_queue(struct ieee80211_device *ieee);
174 -extern void ieee80211_stop_queue(struct ieee80211_device *ieee);
175 -extern struct sk_buff *ieee80211_get_beacon(struct ieee80211_device *ieee);
176 -extern void ieee80211_start_send_beacons(struct ieee80211_device *ieee);
177 -extern void ieee80211_stop_send_beacons(struct ieee80211_device *ieee);
178 -extern int ieee80211_wpa_supplicant_ioctl(struct ieee80211_device *ieee, struct iw_point *p);
179 -extern void notify_wx_assoc_event(struct ieee80211_device *ieee);
180 -extern void ieee80211_ps_tx_ack(struct ieee80211_device *ieee, short success);
181 +extern void ieee80211_softmac_xmit_rtl7(struct ieee80211_txb *txb, struct ieee80211_device *ieee);
182 +extern void ieee80211_softmac_check_all_nets_rtl7(struct ieee80211_device *ieee);
183 +extern void ieee80211_start_bss_rtl7(struct ieee80211_device *ieee);
184 +extern void ieee80211_start_master_bss_rtl7(struct ieee80211_device *ieee);
185 +extern void ieee80211_start_ibss_rtl7(struct ieee80211_device *ieee);
186 +extern void ieee80211_softmac_init_rtl7(struct ieee80211_device *ieee);
187 +extern void ieee80211_softmac_free_rtl7(struct ieee80211_device *ieee);
188 +extern void ieee80211_associate_abort_rtl7(struct ieee80211_device *ieee);
189 +extern void ieee80211_disassociate_rtl7(struct ieee80211_device *ieee);
190 +extern void ieee80211_stop_scan_rtl7(struct ieee80211_device *ieee);
191 +extern void ieee80211_start_scan_syncro_rtl7(struct ieee80211_device *ieee);
192 +extern void ieee80211_check_all_nets_rtl7(struct ieee80211_device *ieee);
193 +extern void ieee80211_start_protocol_rtl7(struct ieee80211_device *ieee);
194 +extern void ieee80211_stop_protocol_rtl7(struct ieee80211_device *ieee);
195 +extern void ieee80211_softmac_start_protocol_rtl7(struct ieee80211_device *ieee);
196 +extern void ieee80211_softmac_stop_protocol_rtl7(struct ieee80211_device *ieee);
197 +extern void ieee80211_reset_queue_rtl7(struct ieee80211_device *ieee);
198 +extern void ieee80211_wake_queue_rtl7(struct ieee80211_device *ieee);
199 +extern void ieee80211_stop_queue_rtl7(struct ieee80211_device *ieee);
200 +extern struct sk_buff *ieee80211_get_beacon_rtl7(struct ieee80211_device *ieee);
201 +extern void ieee80211_start_send_beacons_rtl7(struct ieee80211_device *ieee);
202 +extern void ieee80211_stop_send_beacons_rtl7(struct ieee80211_device *ieee);
203 +extern int ieee80211_wpa_supplicant_ioctl_rtl7(struct ieee80211_device *ieee, struct iw_point *p);
204 +extern void notify_wx_assoc_event_rtl7(struct ieee80211_device *ieee);
205 +extern void ieee80211_ps_tx_ack_rtl7(struct ieee80211_device *ieee, short success);
206
207 /* ieee80211_softmac_wx.c */
208
209 -extern int ieee80211_wx_get_wap(struct ieee80211_device *ieee,
210 +extern int ieee80211_wx_get_wap_rtl7(struct ieee80211_device *ieee,
211 struct iw_request_info *info,
212 union iwreq_data *wrqu, char *ext);
213
214 -extern int ieee80211_wx_set_wap(struct ieee80211_device *ieee,
215 +extern int ieee80211_wx_set_wap_rtl7(struct ieee80211_device *ieee,
216 struct iw_request_info *info,
217 union iwreq_data *awrq,
218 char *extra);
219
220 -extern int ieee80211_wx_get_essid(struct ieee80211_device *ieee, struct iw_request_info *a,union iwreq_data *wrqu,char *b);
221 +extern int ieee80211_wx_get_essid_rtl7(struct ieee80211_device *ieee, struct iw_request_info *a,union iwreq_data *wrqu,char *b);
222
223 -extern int ieee80211_wx_set_rate(struct ieee80211_device *ieee,
224 +extern int ieee80211_wx_set_rate_rtl7(struct ieee80211_device *ieee,
225 struct iw_request_info *info,
226 union iwreq_data *wrqu, char *extra);
227
228 -extern int ieee80211_wx_get_rate(struct ieee80211_device *ieee,
229 +extern int ieee80211_wx_get_rate_rtl7(struct ieee80211_device *ieee,
230 struct iw_request_info *info,
231 union iwreq_data *wrqu, char *extra);
232
233 -extern int ieee80211_wx_set_mode(struct ieee80211_device *ieee, struct iw_request_info *a,
234 +extern int ieee80211_wx_set_mode_rtl7(struct ieee80211_device *ieee, struct iw_request_info *a,
235 union iwreq_data *wrqu, char *b);
236
237 -extern int ieee80211_wx_set_scan(struct ieee80211_device *ieee, struct iw_request_info *a,
238 +extern int ieee80211_wx_set_scan_rtl7(struct ieee80211_device *ieee, struct iw_request_info *a,
239 union iwreq_data *wrqu, char *b);
240
241 -extern int ieee80211_wx_set_essid(struct ieee80211_device *ieee,
242 +extern int ieee80211_wx_set_essid_rtl7(struct ieee80211_device *ieee,
243 struct iw_request_info *a,
244 union iwreq_data *wrqu, char *extra);
245
246 -extern int ieee80211_wx_get_mode(struct ieee80211_device *ieee, struct iw_request_info *a,
247 +extern int ieee80211_wx_get_mode_rtl7(struct ieee80211_device *ieee, struct iw_request_info *a,
248 union iwreq_data *wrqu, char *b);
249
250 -extern int ieee80211_wx_set_freq(struct ieee80211_device *ieee, struct iw_request_info *a,
251 +extern int ieee80211_wx_set_freq_rtl7(struct ieee80211_device *ieee, struct iw_request_info *a,
252 union iwreq_data *wrqu, char *b);
253
254 -extern int ieee80211_wx_get_freq(struct ieee80211_device *ieee, struct iw_request_info *a,
255 +extern int ieee80211_wx_get_freq_rtl7(struct ieee80211_device *ieee, struct iw_request_info *a,
256 union iwreq_data *wrqu, char *b);
257
258 -extern void ieee80211_wx_sync_scan_wq(struct ieee80211_device *ieee);
259 +# if (LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,20))
260 +extern void ieee80211_wx_sync_scan_wq_rtl7(struct work_struct *work);
261 +#else
262 +extern void ieee80211_wx_sync_scan_wq_rtl7(struct ieee80211_device *ieee);
263 +#endif
264
265 -extern int ieee80211_wx_set_rawtx(struct ieee80211_device *ieee,
266 +extern int ieee80211_wx_set_rawtx_rtl7(struct ieee80211_device *ieee,
267 struct iw_request_info *info,
268 union iwreq_data *wrqu, char *extra);
269
270 -extern int ieee80211_wx_get_name(struct ieee80211_device *ieee,
271 +extern int ieee80211_wx_get_name_rtl7(struct ieee80211_device *ieee,
272 struct iw_request_info *info,
273 union iwreq_data *wrqu, char *extra);
274
275 -extern int ieee80211_wx_set_power(struct ieee80211_device *ieee,
276 +extern int ieee80211_wx_set_power_rtl7(struct ieee80211_device *ieee,
277 struct iw_request_info *info,
278 union iwreq_data *wrqu, char *extra);
279
280 -extern int ieee80211_wx_get_power(struct ieee80211_device *ieee,
281 +extern int ieee80211_wx_get_power_rtl7(struct ieee80211_device *ieee,
282 struct iw_request_info *info,
283 union iwreq_data *wrqu, char *extra);
284
285 -extern const long ieee80211_wlan_frequencies[];
286 +extern const long ieee80211_wlan_frequencies_rtl7[];
287
288 -extern inline void ieee80211_increment_scans(struct ieee80211_device *ieee)
289 +extern inline void ieee80211_increment_scans_rtl7(struct ieee80211_device *ieee)
290 {
291 ieee->scans++;
292 }
293
294 -extern inline int ieee80211_get_scans(struct ieee80211_device *ieee)
295 +extern inline int ieee80211_get_scans_rtl7(struct ieee80211_device *ieee)
296 {
297 return ieee->scans;
298 }
299 @@ -1372,7 +1398,7 @@
300 const char *s = essid;
301 char *d = escaped;
302
303 - if (ieee80211_is_empty_essid(essid, essid_len)) {
304 + if (ieee80211_is_empty_essid_rtl7(essid, essid_len)) {
305 memcpy(escaped, "<hidden>", sizeof("<hidden>"));
306 return escaped;
307 }
308 diff -Naur rtl8187_orig/beta-8187/Makefile rtl8187_rawtx/beta-8187/Makefile
309 --- rtl8187_orig/beta-8187/Makefile 2007-03-13 23:45:09.000000000 +0100
310 +++ rtl8187_rawtx/beta-8187/Makefile 2007-05-27 10:47:14.000000000 +0200
311 @@ -18,6 +18,8 @@
312 KVER := $(shell uname -r)
313 KSRC := /lib/modules/$(KVER)/build
314 INSTALL_PREFIX :=
315 +PWD = $(shell pwd)
316 +
317 all: modules
318
319 clean:
320 diff -Naur rtl8187_orig/beta-8187/r8180_93cx6.c rtl8187_rawtx/beta-8187/r8180_93cx6.c
321 --- rtl8187_orig/beta-8187/r8180_93cx6.c 2007-03-13 23:45:09.000000000 +0100
322 +++ rtl8187_rawtx/beta-8187/r8180_93cx6.c 2007-06-05 14:00:01.000000000 +0200
323 @@ -87,7 +87,7 @@
324
325 u32 eprom_read(struct net_device *dev, u32 addr)
326 {
327 - struct r8180_priv *priv = ieee80211_priv(dev);
328 + struct r8180_priv *priv = ieee80211_priv_rtl7(dev);
329 short read_cmd[]={1,1,0};
330 short addr_str[8];
331 int i;
332 diff -Naur rtl8187_orig/beta-8187/r8180_hw.h rtl8187_rawtx/beta-8187/r8180_hw.h
333 --- rtl8187_orig/beta-8187/r8180_hw.h 2007-03-13 23:45:09.000000000 +0100
334 +++ rtl8187_rawtx/beta-8187/r8180_hw.h 2007-06-05 14:00:05.000000000 +0200
335 @@ -646,6 +646,7 @@
336 #define FFER_INTR ((1<<15))
337 #define FFER_GWAKE ((1<< 4))
338
339 -
340 +#define MAX_TX_POWER 27
341 +#define MIN_TX_POWER 20
342
343 #endif
344 diff -Naur rtl8187_orig/beta-8187/r8180_rtl8225.c rtl8187_rawtx/beta-8187/r8180_rtl8225.c
345 --- rtl8187_orig/beta-8187/r8180_rtl8225.c 2007-03-13 23:45:09.000000000 +0100
346 +++ rtl8187_rawtx/beta-8187/r8180_rtl8225.c 2007-06-05 14:00:01.000000000 +0200
347 @@ -173,7 +173,7 @@
348
349 void rtl8225_set_gain(struct net_device *dev, short gain)
350 {
351 - struct r8180_priv *priv = ieee80211_priv(dev);
352 + struct r8180_priv *priv = ieee80211_priv_rtl7(dev);
353
354 rtl8180_set_anaparam(dev, RTL8225_ANAPARAM_ON);
355
356 @@ -208,7 +208,7 @@
357 {
358 #ifdef USE_8051_3WIRE
359
360 - struct r8180_priv *priv = (struct r8180_priv *)ieee80211_priv(dev);
361 + struct r8180_priv *priv = (struct r8180_priv *)ieee80211_priv_rtl7(dev);
362 struct usb_device *udev = priv->udev;
363 //u8 bit;
364 u16 wReg80, wReg82, wReg84;
365 @@ -255,7 +255,7 @@
366 u16 out,select;
367 u8 bit;
368 u32 bangdata = (data << 4) | (adr & 0xf);
369 - struct r8180_priv *priv = ieee80211_priv(dev);
370 + struct r8180_priv *priv = ieee80211_priv_rtl7(dev);
371
372 out = read_nic_word(dev, RFPinsOutput) & 0xfff3;
373
374 @@ -349,7 +349,7 @@
375
376 void rtl8225_SetTXPowerLevel(struct net_device *dev, short ch)
377 {
378 - struct r8180_priv *priv = ieee80211_priv(dev);
379 + struct r8180_priv *priv = ieee80211_priv_rtl7(dev);
380
381 int GainIdx;
382 int GainSetting;
383 @@ -454,9 +454,9 @@
384
385 void rtl8225_rf_set_chan(struct net_device *dev, short ch)
386 {
387 - struct r8180_priv *priv = ieee80211_priv(dev);
388 + struct r8180_priv *priv = ieee80211_priv_rtl7(dev);
389 short gset = (priv->ieee80211->state == IEEE80211_LINKED &&
390 - ieee80211_is_54g(priv->ieee80211->current_network)) ||
391 + ieee80211_is_54g_rtl7(priv->ieee80211->current_network)) ||
392 priv->ieee80211->iw_mode == IW_MODE_MONITOR;
393
394 rtl8225_SetTXPowerLevel(dev, ch);
395 @@ -474,7 +474,7 @@
396 write_nic_byte(dev,DIFS,0x24); //DIFS: 36
397
398 if(priv->ieee80211->state == IEEE80211_LINKED &&
399 - ieee80211_is_shortslot(priv->ieee80211->current_network))
400 + ieee80211_is_shortslot_rtl7(priv->ieee80211->current_network))
401 write_nic_byte(dev,SLOT,0x9); //SLOT: 9
402
403 else
404 @@ -546,7 +546,7 @@
405
406 void rtl8225_rf_init(struct net_device *dev)
407 {
408 - struct r8180_priv *priv = ieee80211_priv(dev);
409 + struct r8180_priv *priv = ieee80211_priv_rtl7(dev);
410 int i;
411 short channel = 1;
412 u16 brsr;
413 diff -Naur rtl8187_orig/beta-8187/r8180_rtl8225.h rtl8187_rawtx/beta-8187/r8180_rtl8225.h
414 --- rtl8187_orig/beta-8187/r8180_rtl8225.h 2007-03-13 23:45:09.000000000 +0100
415 +++ rtl8187_rawtx/beta-8187/r8180_rtl8225.h 2007-06-05 14:00:05.000000000 +0200
416 @@ -44,3 +44,5 @@
417 extern u32 rtl8225_chan[];
418
419 #endif
420 +
421 +void rtl8225z2_SetTXPowerLevel(struct net_device *dev, short ch);
422 diff -Naur rtl8187_orig/beta-8187/r8180_rtl8225z2.c rtl8187_rawtx/beta-8187/r8180_rtl8225z2.c
423 --- rtl8187_orig/beta-8187/r8180_rtl8225z2.c 2007-03-13 23:45:09.000000000 +0100
424 +++ rtl8187_rawtx/beta-8187/r8180_rtl8225z2.c 2007-06-05 14:00:01.000000000 +0200
425 @@ -2,12 +2,12 @@
426 This is part of the rtl8180-sa2400 driver
427 released under the GPL (See file COPYING for details).
428 Copyright (c) 2005 Andrea Merello <[email protected]>
429 -
430 - This files contains programming code for the rtl8225
431 +
432 + This files contains programming code for the rtl8225
433 radio frontend.
434 -
435 +
436 *Many* thanks to Realtek Corp. for their great support!
437 -
438 +
439 */
440
441
442 @@ -32,51 +32,68 @@
443 };
444
445 u8 rtl8225z2_gain_a[]={
446 - 0x13,0x27,0x5a,//,0x37,// -82dbm
447 - 0x23,0x23,0x58,//,0x37,// -82dbm
448 - 0x33,0x1f,0x56,//,0x37,// -82dbm
449 - 0x43,0x1b,0x54,//,0x37,// -78dbm
450 - 0x53,0x17,0x51,//,0x37,// -74dbm
451 - 0x63,0x24,0x4f,//,0x37,// -70dbm
452 - 0x73,0x0f,0x4c,//,0x37,// -66dbm
453 + 0x13,0x27,0x5a,//,0x37,// -82dbm
454 + 0x23,0x23,0x58,//,0x37,// -82dbm
455 + 0x33,0x1f,0x56,//,0x37,// -82dbm
456 + 0x43,0x1b,0x54,//,0x37,// -78dbm
457 + 0x53,0x17,0x51,//,0x37,// -74dbm
458 + 0x63,0x24,0x4f,//,0x37,// -70dbm
459 + 0x73,0x0f,0x4c,//,0x37,// -66dbm
460 };
461 #if 0
462 u32 rtl8225_chan[] = {
463 0, //dummy channel 0
464 - 0x085c, //1
465 - 0x08dc, //2
466 - 0x095c, //3
467 - 0x09dc, //4
468 - 0x0a5c, //5
469 - 0x0adc, //6
470 - 0x0b5c, //7
471 - 0x0bdc, //8
472 - 0x0c5c, //9
473 - 0x0cdc, //10
474 - 0x0d5c, //11
475 - 0x0ddc, //12
476 - 0x0e5c, //13
477 + 0x085c, //1
478 + 0x08dc, //2
479 + 0x095c, //3
480 + 0x09dc, //4
481 + 0x0a5c, //5
482 + 0x0adc, //6
483 + 0x0b5c, //7
484 + 0x0bdc, //8
485 + 0x0c5c, //9
486 + 0x0cdc, //10
487 + 0x0d5c, //11
488 + 0x0ddc, //12
489 + 0x0e5c, //13
490 //0x0f5c, //14
491 - 0x0f72, // 14
492 + 0x0f72, // 14
493 };
494 #endif
495
496 +#if 0
497 //-
498 -u16 rtl8225z2_rxgain[]={
499 +u16 rtl8225z2_rxgain[]={
500 0x0400, 0x0401, 0x0402, 0x0403, 0x0404, 0x0405, 0x0408, 0x0409,
501 - 0x040a, 0x040b, 0x0502, 0x0503, 0x0504, 0x0505, 0x0540, 0x0541,
502 + 0x040a, 0x040b, 0x0502, 0x0503, 0x0504, 0x0505, 0x0540, 0x0541,
503 0x0542, 0x0543, 0x0544, 0x0545, 0x0580, 0x0581, 0x0582, 0x0583,
504 - 0x0584, 0x0585, 0x0588, 0x0589, 0x058a, 0x058b, 0x0643, 0x0644,
505 + 0x0584, 0x0585, 0x0588, 0x0589, 0x058a, 0x058b, 0x0643, 0x0644,
506 0x0645, 0x0680, 0x0681, 0x0682, 0x0683, 0x0684, 0x0685, 0x0688,
507 0x0689, 0x068a, 0x068b, 0x068c, 0x0742, 0x0743, 0x0744, 0x0745,
508 0x0780, 0x0781, 0x0782, 0x0783, 0x0784, 0x0785, 0x0788, 0x0789,
509 0x078a, 0x078b, 0x078c, 0x078d, 0x0790, 0x0791, 0x0792, 0x0793,
510 - 0x0794, 0x0795, 0x0798, 0x0799, 0x079a, 0x079b, 0x079c, 0x079d,
511 - 0x07a0, 0x07a1, 0x07a2, 0x07a3, 0x07a4, 0x07a5, 0x07a8, 0x07a9,
512 - 0x03aa, 0x03ab, 0x03ac, 0x03ad, 0x03b0, 0x03b1, 0x03b2, 0x03b3,
513 + 0x0794, 0x0795, 0x0798, 0x0799, 0x079a, 0x079b, 0x079c, 0x079d,
514 + 0x07a0, 0x07a1, 0x07a2, 0x07a3, 0x07a4, 0x07a5, 0x07a8, 0x07a9,
515 + 0x03aa, 0x03ab, 0x03ac, 0x03ad, 0x03b0, 0x03b1, 0x03b2, 0x03b3,
516 0x03b4, 0x03b5, 0x03b8, 0x03b9, 0x03ba, 0x03bb, 0x03bb
517
518 };
519 +#else
520 +u16 rtl8225z2_rxgain[]={
521 + 0x0000, 0x0001, 0x0002, 0x0003, 0x0004, 0x0005, 0x0008, 0x0009,
522 + 0x000a, 0x000b, 0x0102, 0x0103, 0x0104, 0x0105, 0x0140, 0x0141,
523 + 0x0142, 0x0143, 0x0144, 0x0145, 0x0180, 0x0181, 0x0182, 0x0183,
524 + 0x0184, 0x0185, 0x0188, 0x0189, 0x018a, 0x018b, 0x0243, 0x0244,
525 + 0x0245, 0x0280, 0x0281, 0x0282, 0x0283, 0x0284, 0x0285, 0x0288,
526 + 0x0289, 0x028a, 0x028b, 0x028c, 0x0342, 0x0343, 0x0344, 0x0345,
527 + 0x0380, 0x0381, 0x0382, 0x0383, 0x0384, 0x0385, 0x0388, 0x0389,
528 + 0x038a, 0x038b, 0x038c, 0x038d, 0x0390, 0x0391, 0x0392, 0x0393,
529 + 0x0394, 0x0395, 0x0398, 0x0399, 0x039a, 0x039b, 0x039c, 0x039d,
530 + 0x03a0, 0x03a1, 0x03a2, 0x03a3, 0x03a4, 0x03a5, 0x03a8, 0x03a9,
531 + 0x03aa, 0x03ab, 0x03ac, 0x03ad, 0x03b0, 0x03b1, 0x03b2, 0x03b3,
532 + 0x03b4, 0x03b5, 0x03b8, 0x03b9, 0x03ba, 0x03bb, 0x03bb
533 +};
534 +#endif
535
536 //2005.11.16,
537 u8 ZEBRA2_CCK_OFDM_GAIN_SETTING[]={
538 @@ -129,23 +146,30 @@
539 void rtl8225z2_set_gain(struct net_device *dev, short gain)
540 {
541 u8* rtl8225_gain;
542 - struct r8180_priv *priv = ieee80211_priv(dev);
543 -
544 + struct r8180_priv *priv = ieee80211_priv_rtl7(dev);
545 +
546 u8 mode = priv->ieee80211->mode;
547 -
548 - if(mode == IEEE_B || mode == IEEE_G)
549 +
550 + if((mode&IEEE_B) == IEEE_B || (mode&IEEE_G) == IEEE_G) {
551 + //printk(KERN_WARNING "mode ag!\n");
552 rtl8225_gain = rtl8225z2_gain_bg;
553 - else
554 + } else {
555 rtl8225_gain = rtl8225z2_gain_a;
556 -
557 + //printk(KERN_WARNING "mode a!\n");
558 + }
559 +
560 //write_phy_ofdm(dev, 0x0d, rtl8225_gain[gain * 3]);
561 //write_phy_ofdm(dev, 0x19, rtl8225_gain[gain * 3 + 1]);
562 //write_phy_ofdm(dev, 0x1b, rtl8225_gain[gain * 3 + 2]);
563 //2005.11.17, by ch-hsu
564 write_phy_ofdm(dev, 0x0b, rtl8225_gain[gain * 3]);
565 + mdelay(1);
566 write_phy_ofdm(dev, 0x1b, rtl8225_gain[gain * 3 + 1]);
567 + mdelay(1);
568 write_phy_ofdm(dev, 0x1d, rtl8225_gain[gain * 3 + 2]);
569 - write_phy_ofdm(dev, 0x21, 0x37);
570 + mdelay(1);
571 + write_phy_ofdm(dev, 0x21, 0x17);
572 + mdelay(1);
573
574 }
575
576 @@ -153,33 +177,33 @@
577
578 void rtl8225_set_gain(struct net_device *dev, short gain)
579 {
580 - struct r8180_priv *priv = ieee80211_priv(dev);
581 -
582 + struct r8180_priv *priv = ieee80211_priv_rtl7(dev);
583 +
584 rtl8180_set_anaparam(dev, RTL8225_ANAPARAM_ON);
585 -
586 +
587 if(priv->card_8185 == 2)
588 write_phy_ofdm(dev, 0x21, 0x27);
589 else
590 write_phy_ofdm(dev, 0x21, 0x37);
591 -
592 +
593 write_phy_ofdm(dev, 0x25, 0x20);
594 write_phy_ofdm(dev, 0x11, 0x6);
595 -
596 +
597 if(priv->card_8185 == 1 && priv->card_8185_Bversion)
598 write_phy_ofdm(dev, 0x27, 0x8);
599 else
600 write_phy_ofdm(dev, 0x27, 0x88);
601 -
602 +
603 write_phy_ofdm(dev, 0x14, 0);
604 write_phy_ofdm(dev, 0x16, 0);
605 write_phy_ofdm(dev, 0x15, 0x40);
606 write_phy_ofdm(dev, 0x17, 0x40);
607 -
608 +
609 write_phy_ofdm(dev, 0x0d, rtl8225_gain[gain * 4]);
610 write_phy_ofdm(dev, 0x23, rtl8225_gain[gain * 4 + 1]);
611 write_phy_ofdm(dev, 0x1b, rtl8225_gain[gain * 4 + 2]);
612 write_phy_ofdm(dev, 0x1d, rtl8225_gain[gain * 4 + 3]);
613 - //rtl8225_set_gain_usb(dev, gain);
614 + //rtl8225_set_gain_usb(dev, gain);
615 }
616 #endif
617
618 @@ -193,7 +217,7 @@
619 // ThreeWireReg tdata;
620 int i;
621 short bit, rw;
622 -
623 +
624 u8 wLength = 6;
625 u8 rLength = 12;
626 u8 low2high = 0;
627 @@ -207,20 +231,20 @@
628
629 dataRead = 0;
630
631 - oval &= ~0xf;
632 + oval &= ~0xf;
633
634 write_nic_word(dev, RFPinsOutput, oval | BB_HOST_BANG_EN ); udelay(4);
635
636 write_nic_word(dev, RFPinsOutput, oval ); udelay(5);
637 -
638 +
639 rw = 0;
640 -
641 +
642 mask = (low2high) ? 0x01 : (((u32)0x01)<<(32-1));
643 for(i = 0; i < wLength/2; i++)
644 {
645 bit = ((data2Write&mask) != 0) ? 1 : 0;
646 write_nic_word(dev, RFPinsOutput, bit|oval | rw); udelay(1);
647 -
648 +
649 write_nic_word(dev, RFPinsOutput, bit|oval | BB_HOST_BANG_CLK | rw); udelay(2);
650 write_nic_word(dev, RFPinsOutput, bit|oval | BB_HOST_BANG_CLK | rw); udelay(2);
651
652 @@ -233,9 +257,9 @@
653 write_nic_word(dev, RFPinsOutput, bit|oval | rw); udelay(2);
654 break;
655 }
656 -
657 +
658 bit = ((data2Write&mask) != 0) ? 1: 0;
659 -
660 +
661 write_nic_word(dev, RFPinsOutput, oval|bit|rw| BB_HOST_BANG_CLK); udelay(2);
662 write_nic_word(dev, RFPinsOutput, oval|bit|rw| BB_HOST_BANG_CLK); udelay(2);
663
664 @@ -252,22 +276,22 @@
665 for(i = 0; i < rLength; i++)
666 {
667 write_nic_word(dev, RFPinsOutput, rw|oval); udelay(1);
668 -
669 +
670 write_nic_word(dev, RFPinsOutput, rw|oval|BB_HOST_BANG_CLK); udelay(2);
671 write_nic_word(dev, RFPinsOutput, rw|oval|BB_HOST_BANG_CLK); udelay(2);
672 write_nic_word(dev, RFPinsOutput, rw|oval|BB_HOST_BANG_CLK); udelay(2);
673 tmp = read_nic_word(dev, RFPinsInput);
674 -
675 +
676 dataRead |= (tmp & BB_HOST_BANG_CLK ? mask : 0);
677
678 write_nic_word(dev, RFPinsOutput, (rw|oval)); udelay(2);
679
680 mask = (low2high) ? (mask<<1) : (mask>>1);
681 }
682 -
683 +
684 write_nic_word(dev, RFPinsOutput, BB_HOST_BANG_EN|BB_HOST_BANG_RW|oval); udelay(2);
685
686 - write_nic_word(dev, RFPinsEnable, oval2);
687 + write_nic_word(dev, RFPinsEnable, oval2);
688 write_nic_word(dev, RFPinsSelect, oval3); // Set To SW Switch
689 write_nic_word(dev, RFPinsOutput, 0x3a0);
690
691 @@ -280,61 +304,61 @@
692 u16 out,select;
693 u8 bit;
694 u32 bangdata = (data << 4) | (adr & 0xf);
695 - struct r8180_priv *priv = ieee80211_priv(dev);
696 -
697 + struct r8180_priv *priv = ieee80211_priv_rtl7(dev);
698 +
699 out = read_nic_word(dev, RFPinsOutput) & 0xfff3;
700 -
701 +
702 write_nic_word(dev,RFPinsEnable,
703 (read_nic_word(dev,RFPinsEnable) | 0x7));
704 -
705 +
706 select = read_nic_word(dev, RFPinsSelect);
707 -
708 - write_nic_word(dev, RFPinsSelect, select | 0x7 |
709 +
710 + write_nic_word(dev, RFPinsSelect, select | 0x7 |
711 ((priv->card_type == USB) ? 0 : SW_CONTROL_GPIO));
712 -
713 +
714 force_pci_posting(dev);
715 udelay(10);
716 -
717 +
718 write_nic_word(dev, RFPinsOutput, out | BB_HOST_BANG_EN );//| 0x1fff);
719 -
720 +
721 force_pci_posting(dev);
722 udelay(2);
723 -
724 +
725 write_nic_word(dev, RFPinsOutput, out);
726 -
727 +
728 force_pci_posting(dev);
729 udelay(10);
730 -
731 -
732 +
733 +
734 for(i=15; i>=0;i--){
735 -
736 +
737 bit = (bangdata & (1<<i)) >> i;
738 -
739 +
740 write_nic_word(dev, RFPinsOutput, bit | out);
741 -
742 +
743 write_nic_word(dev, RFPinsOutput, bit | out | BB_HOST_BANG_CLK);
744 write_nic_word(dev, RFPinsOutput, bit | out | BB_HOST_BANG_CLK);
745
746 i--;
747 bit = (bangdata & (1<<i)) >> i;
748 -
749 +
750 write_nic_word(dev, RFPinsOutput, bit | out | BB_HOST_BANG_CLK);
751 write_nic_word(dev, RFPinsOutput, bit | out | BB_HOST_BANG_CLK);
752
753 write_nic_word(dev, RFPinsOutput, bit | out);
754
755 }
756 -
757 +
758 write_nic_word(dev, RFPinsOutput, out | BB_HOST_BANG_EN);
759 -
760 +
761 force_pci_posting(dev);
762 udelay(10);
763
764 - write_nic_word(dev, RFPinsOutput, out |
765 + write_nic_word(dev, RFPinsOutput, out |
766 ((priv->card_type == USB) ? 4 : BB_HOST_BANG_EN));
767
768 - write_nic_word(dev, RFPinsSelect, select |
769 - ((priv->card_type == USB) ? 0 : SW_CONTROL_GPIO));
770 + write_nic_word(dev, RFPinsSelect, select |
771 + ((priv->card_type == USB) ? 0 : SW_CONTROL_GPIO));
772
773 if(priv->card_type == USB)
774 mdelay(2);
775 @@ -348,30 +372,30 @@
776 short vz2 = 1;
777 /* sw to reg pg 1 */
778 write_rtl8225(dev, 0, 0x1b7);
779 -
780 +
781 /* reg 8 pg 1 = 23*/
782 if( read_rtl8225(dev, 8) != 0x588)
783 vz2 = 0;
784 -
785 - else /* reg 9 pg 1 = 24 */
786 +
787 + else /* reg 9 pg 1 = 24 */
788 if( read_rtl8225(dev, 9) != 0x700)
789 vz2 = 0;
790 -
791 - /* sw back to pg 0 */
792 +
793 + /* sw back to pg 0 */
794 write_rtl8225(dev, 0, 0xb7);
795
796 return vz2;
797 -
798 +
799 }
800
801 #if 0
802 void rtl8225_rf_close(struct net_device *dev)
803 {
804 - write_rtl8225(dev, 0x4, 0x1f);
805 -
806 + write_rtl8225(dev, 0x4, 0x1f);
807 +
808 force_pci_posting(dev);
809 mdelay(1);
810 -
811 +
812 rtl8180_set_anaparam(dev, RTL8225_ANAPARAM_OFF);
813 rtl8185_set_anaparam2(dev, RTL8225_ANAPARAM2_OFF);
814 }
815 @@ -380,24 +404,24 @@
816 short rtl8225_rf_set_sens(struct net_device *dev, short sens)
817 {
818 if (sens <0 || sens > 6) return -1;
819 -
820 +
821 if(sens > 4)
822 write_rtl8225(dev, 0x0c, 0x850);
823 - else
824 + else
825 write_rtl8225(dev, 0x0c, 0x50);
826
827 sens= 6-sens;
828 rtl8225_set_gain(dev, sens);
829 -
830 +
831 write_phy_cck(dev, 0x41, rtl8225_threshold[sens]);
832 return 0;
833 -
834 +
835 }
836 #endif
837 void rtl8225z2_SetTXPowerLevel(struct net_device *dev, short ch)
838 {
839 - struct r8180_priv *priv = ieee80211_priv(dev);
840 -
841 + struct r8180_priv *priv = ieee80211_priv_rtl7(dev);
842 +
843 // int GainIdx;
844 // int GainSetting;
845 int i;
846 @@ -406,44 +430,47 @@
847 u8 max_cck_power_level;
848 //u8 min_cck_power_level;
849 u8 max_ofdm_power_level;
850 - u8 min_ofdm_power_level;
851 + u8 min_ofdm_power_level;
852 u8 cck_power_level = 0xff & priv->chtxpwr[ch];
853 u8 ofdm_power_level = 0xff & priv->chtxpwr_ofdm[ch];
854 -
855 -
856 +
857 +
858 max_cck_power_level = 15;
859 //min_cck_power_level = 0;
860 max_ofdm_power_level = 25; // 12 -> 25
861 min_ofdm_power_level = 10;
862 -
863 +
864 /* CCK power setting */
865 if(cck_power_level > max_cck_power_level)
866 + {
867 cck_power_level = max_cck_power_level;
868 -
869 + priv->chtxpwr[ch] = max_cck_power_level;
870 + }
871 +
872 cck_power_level += priv->cck_txpwr_base;
873 -
874 +
875 if(cck_power_level > 35)
876 cck_power_level = 35;
877 -
878 - if(ch == 14)
879 +
880 + if(ch == 14)
881 cck_power_table = rtl8225z2_tx_power_cck_ch14;
882 - else
883 + else
884 cck_power_table = rtl8225z2_tx_power_cck;
885 -
886 -
887 +
888 +
889 for(i=0;i<8;i++){
890 -
891 +
892 power = cck_power_table[i];
893 write_phy_cck(dev, 0x44 + i, power);
894 }
895 -
896 +
897 //write_nic_byte(dev, TX_GAIN_CCK, power);
898 //2005.11.17,
899 write_nic_byte(dev, TX_GAIN_CCK, ZEBRA2_CCK_OFDM_GAIN_SETTING[cck_power_level]);
900 -
901 +
902 force_pci_posting(dev);
903 mdelay(1);
904 -
905 +
906 /* OFDM power setting */
907 // Old:
908 // if(ofdm_power_level > max_ofdm_power_level)
909 @@ -454,26 +481,26 @@
910 ofdm_power_level = max_ofdm_power_level;
911 else
912 ofdm_power_level += min_ofdm_power_level;
913 -
914 +
915 ofdm_power_level += priv->ofdm_txpwr_base;
916 -
917 +
918 if(ofdm_power_level > 35)
919 ofdm_power_level = 35;
920 -
921 +
922 rtl8185_set_anaparam2(dev,RTL8225_ANAPARAM2_ON);
923 -
924 +
925 write_phy_ofdm(dev,2,0x42);
926 write_phy_ofdm(dev,5,0);
927 write_phy_ofdm(dev,6,0x40);
928 write_phy_ofdm(dev,7,0);
929 - write_phy_ofdm(dev,8,0x40);
930 -
931 + write_phy_ofdm(dev,8,0x40);
932 +
933
934 //write_nic_byte(dev, TX_GAIN_OFDM, ofdm_power_level);
935 //2005.11.17,
936 write_nic_byte(dev, TX_GAIN_OFDM, ZEBRA2_CCK_OFDM_GAIN_SETTING[ofdm_power_level]);
937
938 -
939 +
940 force_pci_posting(dev);
941 mdelay(1);
942 //write_nic_byte(dev, TX_AGC_CONTROL,4);
943 @@ -483,39 +510,39 @@
944 void rtl8225_set_mode(struct net_device *dev, short modeb)
945 {
946 write_phy_ofdm(dev, 0x15, (modeb ? 0x0 : 0x40));
947 - write_phy_ofdm(dev, 0x17, (modeb ? 0x0 : 0x40));
948 + write_phy_ofdm(dev, 0x17, (modeb ? 0x0 : 0x40));
949 }
950 #endif
951
952 void rtl8225z2_rf_set_chan(struct net_device *dev, short ch)
953 {
954 - struct r8180_priv *priv = ieee80211_priv(dev);
955 + struct r8180_priv *priv = ieee80211_priv_rtl7(dev);
956 short gset = (priv->ieee80211->state == IEEE80211_LINKED &&
957 - ieee80211_is_54g(priv->ieee80211->current_network)) ||
958 + ieee80211_is_54g_rtl7(priv->ieee80211->current_network)) ||
959 priv->ieee80211->iw_mode == IW_MODE_MONITOR;
960 -
961 +
962 rtl8225z2_SetTXPowerLevel(dev, ch);
963 -
964 +
965 write_rtl8225(dev, 0x7, rtl8225_chan[ch]);
966 -
967 +
968 force_pci_posting(dev);
969 mdelay(10);
970 -
971 +
972 write_nic_byte(dev,SIFS,0x22);// SIFS: 0x22
973 -
974 +
975 if(gset)
976 - write_nic_byte(dev,DIFS,20); //DIFS: 20
977 + write_nic_byte(dev,DIFS,20); //DIFS: 20
978 else
979 - write_nic_byte(dev,DIFS,0x24); //DIFS: 36
980 -
981 + write_nic_byte(dev,DIFS,0x24); //DIFS: 36
982 +
983 if(priv->ieee80211->state == IEEE80211_LINKED &&
984 - ieee80211_is_shortslot(priv->ieee80211->current_network))
985 + ieee80211_is_shortslot_rtl7(priv->ieee80211->current_network))
986 write_nic_byte(dev,SLOT,0x9); //SLOT: 9
987 -
988 +
989 else
990 write_nic_byte(dev,SLOT,0x14); //SLOT: 20 (0x14)
991 -
992 -
993 +
994 +
995 if(gset){
996 write_nic_byte(dev,EIFS,91 - 20); // EIFS: 91 (0x5B)
997 write_nic_byte(dev,CW_VAL,0x73); //CW VALUE: 0x37
998 @@ -529,68 +556,68 @@
999
1000 }
1001 #if 0
1002 -void rtl8225_host_pci_init(struct net_device *dev)
1003 +void rtl8225_host_pci_init(struct net_device *dev)
1004 {
1005 write_nic_word(dev, RFPinsOutput, 0x480);
1006 -
1007 +
1008 rtl8185_rf_pins_enable(dev);
1009 -
1010 +
1011 //if(priv->card_8185 == 2 && priv->enable_gpio0 ) /* version D */
1012 //write_nic_word(dev, RFPinsSelect, 0x88);
1013 //else
1014 write_nic_word(dev, RFPinsSelect, 0x88 | SW_CONTROL_GPIO); /* 0x488 | SW_CONTROL_GPIO */
1015 -
1016 +
1017 write_nic_byte(dev, GP_ENABLE, 0);
1018 -
1019 +
1020 force_pci_posting(dev);
1021 mdelay(200);
1022 -
1023 +
1024 write_nic_word(dev, GP_ENABLE, 0xff & (~(1<<6))); /* bit 6 is for RF on/off detection */
1025
1026 -
1027 +
1028 }
1029
1030 -void rtl8225_host_usb_init(struct net_device *dev)
1031 +void rtl8225_host_usb_init(struct net_device *dev)
1032 {
1033 write_nic_byte(dev,RFPinsSelect+1,0);
1034
1035 write_nic_byte(dev,GPIO,0);
1036 -
1037 +
1038 write_nic_byte_E(dev,0x53,read_nic_byte_E(dev,0x53) | (1<<7));
1039 -
1040 +
1041 write_nic_byte(dev,RFPinsSelect+1,4);
1042
1043 write_nic_byte(dev,GPIO,0x20);
1044
1045 write_nic_byte(dev,GP_ENABLE,0);
1046
1047 -
1048 - /* Config BB & RF */
1049 +
1050 + /* Config BB & RF */
1051 write_nic_word(dev, RFPinsOutput, 0x80);
1052
1053 write_nic_word(dev, RFPinsSelect, 0x80);
1054
1055 write_nic_word(dev, RFPinsEnable, 0x80);
1056
1057 -
1058 +
1059 mdelay(100);
1060
1061 - mdelay(1000);
1062 + mdelay(1000);
1063
1064 }
1065 #endif
1066 -void rtl8225z2_rf_init(struct net_device *dev)
1067 +void rtl8225z2_rf_init(struct net_device *dev)
1068 {
1069 - struct r8180_priv *priv = ieee80211_priv(dev);
1070 + struct r8180_priv *priv = ieee80211_priv_rtl7(dev);
1071 int i;
1072 short channel = 1;
1073 u16 brsr;
1074 u32 data,addr;
1075 -
1076 +
1077 priv->chan = channel;
1078
1079 rtl8180_set_anaparam(dev, RTL8225_ANAPARAM_ON);
1080 -
1081 +
1082
1083 if(priv->card_type == USB)
1084 rtl8225_host_usb_init(dev);
1085 @@ -598,42 +625,42 @@
1086 rtl8225_host_pci_init(dev);
1087
1088 write_nic_dword(dev, RF_TIMING, 0x000a8008);
1089 -
1090 +
1091 brsr = read_nic_word(dev, BRSR);
1092 -
1093 - write_nic_word(dev, BRSR, 0xffff);
1094 +
1095 + write_nic_word(dev, BRSR, 0xffff);
1096
1097
1098 write_nic_dword(dev, RF_PARA, 0x100044);
1099 -
1100 +
1101 #if 1 //0->1
1102 rtl8180_set_mode(dev, EPROM_CMD_CONFIG);
1103 write_nic_byte(dev, CONFIG3, 0x44);
1104 rtl8180_set_mode(dev, EPROM_CMD_NORMAL);
1105 #endif
1106 -
1107 -
1108 +
1109 +
1110 rtl8185_rf_pins_enable(dev);
1111
1112 // mdelay(1000);
1113
1114 write_rtl8225(dev, 0x0, 0x2bf); mdelay(1);
1115 -
1116 -
1117 +
1118 +
1119 write_rtl8225(dev, 0x1, 0xee0); mdelay(1);
1120
1121 write_rtl8225(dev, 0x2, 0x44d); mdelay(1);
1122
1123 write_rtl8225(dev, 0x3, 0x441); mdelay(1);
1124
1125 -
1126 +
1127 write_rtl8225(dev, 0x4, 0x8c3);mdelay(1);
1128 -
1129 -
1130 -
1131 +
1132 +
1133 +
1134 write_rtl8225(dev, 0x5, 0xc72);mdelay(1);
1135 // }
1136 -
1137 +
1138 write_rtl8225(dev, 0x6, 0xe6); mdelay(1);
1139
1140 write_rtl8225(dev, 0x7, ((priv->card_type == USB)? 0x82a : rtl8225_chan[channel])); mdelay(1);
1141 @@ -653,28 +680,28 @@
1142
1143 write_rtl8225(dev, 0xe, 0x2b); mdelay(1);
1144
1145 - write_rtl8225(dev, 0xf, 0x114);
1146 -
1147 -
1148 + write_rtl8225(dev, 0xf, 0x114);
1149 +
1150 +
1151 mdelay(100);
1152 -
1153 -
1154 +
1155 +
1156 //if(priv->card_type != USB) /* maybe not needed even for 8185 */
1157 -// write_rtl8225(dev, 0x7, rtl8225_chan[channel]);
1158 -
1159 +// write_rtl8225(dev, 0x7, rtl8225_chan[channel]);
1160 +
1161 write_rtl8225(dev, 0x0, 0x1b7);
1162 -
1163 +
1164 for(i=0;i<95;i++){
1165 write_rtl8225(dev, 0x1, (u8)(i+1));
1166 -
1167 +
1168 #if 0
1169 - if(priv->phy_ver == 1)
1170 + if(priv->phy_ver == 1)
1171 /* version A */
1172 write_rtl8225(dev, 0x2, rtl8225a_rxgain[i]);
1173 else
1174 #endif
1175 /* version B & C & D*/
1176 -
1177 +
1178 write_rtl8225(dev, 0x2, rtl8225z2_rxgain[i]);
1179 }
1180 write_rtl8225(dev, 0x3, 0x80);
1181 @@ -683,16 +710,16 @@
1182 write_rtl8225(dev, 0x0, 0xb7);
1183
1184 write_rtl8225(dev, 0x2, 0xc4d);
1185 -
1186 +
1187 if(priv->card_type == USB){
1188 // force_pci_posting(dev);
1189 mdelay(200);
1190 -
1191 +
1192 write_rtl8225(dev, 0x2, 0x44d);
1193 -
1194 +
1195 // force_pci_posting(dev);
1196 mdelay(100);
1197 -
1198 +
1199 }//End of if(priv->card_type == USB)
1200 /* FIXME!! rtl8187 we have to check if calibrarion
1201 * is successful and eventually cal. again (repeat
1202 @@ -713,23 +740,23 @@
1203 }
1204 }
1205 //force_pci_posting(dev);
1206 -
1207 - mdelay(200); //200 for 8187
1208 -
1209 -
1210 +
1211 + mdelay(200); //200 for 8187
1212 +
1213 +
1214 // //if(priv->card_type != USB){
1215 // write_rtl8225(dev, 0x2, 0x44d);
1216 // write_rtl8225(dev, 0x7, rtl8225_chan[channel]);
1217 // write_rtl8225(dev, 0x2, 0x47d);
1218 -//
1219 +//
1220 // force_pci_posting(dev);
1221 // mdelay(100);
1222 -//
1223 +//
1224 // write_rtl8225(dev, 0x2, 0x44d);
1225 // //}
1226 -
1227 - write_rtl8225(dev, 0x0, 0x2bf);
1228 -
1229 +
1230 + write_rtl8225(dev, 0x0, 0x2bf);
1231 +
1232 if(priv->card_type != USB)
1233 rtl8185_rf_pins_enable(dev);
1234 //set up ZEBRA AGC table, 2005.11.17,
1235 @@ -744,20 +771,20 @@
1236
1237 mdelay(1);
1238 }
1239 -#if 0
1240 +#if 0
1241 for(i=0;i<128;i++){
1242 write_phy_ofdm(dev, 0xb, rtl8225_agc[i]);
1243 -
1244 - mdelay(1);
1245 +
1246 + mdelay(1);
1247 write_phy_ofdm(dev, 0xa, (u8)i+ 0x80);
1248 -
1249 - mdelay(1);
1250 +
1251 + mdelay(1);
1252 }
1253 #endif
1254 -
1255 +
1256 force_pci_posting(dev);
1257 mdelay(1);
1258 -
1259 +
1260 write_phy_ofdm(dev, 0x0, 0x1); mdelay(1);
1261 write_phy_ofdm(dev, 0x1, 0x2); mdelay(1);
1262 write_phy_ofdm(dev, 0x2, ((priv->card_type == USB)? 0x42 : 0x62)); mdelay(1);
1263 @@ -771,20 +798,20 @@
1264
1265 write_phy_ofdm(dev, 0xa, 0x8); mdelay(1);
1266
1267 - //write_phy_ofdm(dev, 0x18, 0xef);
1268 + //write_phy_ofdm(dev, 0x18, 0xef);
1269 // }
1270 //}
1271 write_phy_ofdm(dev, 0xb, 0x80); mdelay(1);
1272
1273 write_phy_ofdm(dev, 0xc, 0x1);mdelay(1);
1274
1275 -
1276 +
1277 //if(priv->card_type != USB)
1278 - write_phy_ofdm(dev, 0xd, 0x43);
1279 -
1280 + write_phy_ofdm(dev, 0xd, 0x43);
1281 +
1282 write_phy_ofdm(dev, 0xe, 0xd3);mdelay(1);
1283
1284 -
1285 +
1286 #if 0
1287 if(priv->card_8185 == 1){
1288 if(priv->card_8185_Bversion)
1289 @@ -796,17 +823,17 @@
1290 write_phy_ofdm(dev, 0xf, 0x38);mdelay(1);
1291 /*ver D & 8187*/
1292 // }
1293 -
1294 +
1295 // if(priv->card_8185 == 1 && priv->card_8185_Bversion)
1296 // write_phy_ofdm(dev, 0x10, 0x04);/*ver B*/
1297 // else
1298 write_phy_ofdm(dev, 0x10, 0x84);mdelay(1);
1299 /*ver C & D & 8187*/
1300 -
1301 +
1302 write_phy_ofdm(dev, 0x11, 0x07);mdelay(1);
1303 /*agc resp time 700*/
1304
1305 -
1306 +
1307 // if(priv->card_8185 == 2){
1308 /* Ver D & 8187*/
1309 write_phy_ofdm(dev, 0x12, 0x20);mdelay(1);
1310 @@ -824,47 +851,46 @@
1311 write_phy_ofdm(dev, 0x15, 0x40); mdelay(1);
1312 write_phy_ofdm(dev, 0x16, 0x0); mdelay(1);
1313 write_phy_ofdm(dev, 0x17, 0x40); mdelay(1);
1314 -
1315 +
1316 // if (priv->card_type == USB)
1317 // write_phy_ofdm(dev, 0x18, 0xef);
1318 -
1319 +
1320 write_phy_ofdm(dev, 0x18, 0xef);mdelay(1);
1321 -
1322 +
1323
1324 write_phy_ofdm(dev, 0x19, 0x19); mdelay(1);
1325 write_phy_ofdm(dev, 0x1a, 0x20); mdelay(1);
1326 write_phy_ofdm(dev, 0x1b, 0x15);mdelay(1);
1327 -
1328 +
1329 write_phy_ofdm(dev, 0x1c, 0x4);mdelay(1);
1330
1331 write_phy_ofdm(dev, 0x1d, 0xc5);mdelay(1); //2005.11.17,
1332 -
1333 +
1334 write_phy_ofdm(dev, 0x1e, 0x95);mdelay(1);
1335
1336 write_phy_ofdm(dev, 0x1f, 0x75); mdelay(1);
1337
1338 // }
1339 -
1340 +
1341 write_phy_ofdm(dev, 0x20, 0x1f);mdelay(1);
1342
1343 write_phy_ofdm(dev, 0x21, 0x17);mdelay(1);
1344 -
1345 +
1346 write_phy_ofdm(dev, 0x22, 0x16);mdelay(1);
1347
1348 // if(priv->card_type != USB)
1349 write_phy_ofdm(dev, 0x23, 0x80);mdelay(1); //FIXME maybe not needed // <>
1350 -
1351 +
1352 write_phy_ofdm(dev, 0x24, 0x46); mdelay(1);
1353 write_phy_ofdm(dev, 0x25, 0x00); mdelay(1);
1354 write_phy_ofdm(dev, 0x26, 0x90); mdelay(1);
1355
1356 write_phy_ofdm(dev, 0x27, 0x88); mdelay(1);
1357
1358 -
1359 +
1360 // <> Set init. gain to m74dBm.
1361 -
1362 rtl8225z2_set_gain(dev,4);
1363 -
1364 +
1365 write_phy_cck(dev, 0x0, 0x98); mdelay(1);
1366 write_phy_cck(dev, 0x3, 0x20); mdelay(1);
1367 write_phy_cck(dev, 0x4, 0x7e); mdelay(1);
1368 @@ -875,6 +901,9 @@
1369 /* Ver C & D & 8187*/
1370
1371 write_phy_cck(dev, 0x8, 0x2e);mdelay(1);
1372 + write_phy_cck(dev, 0x9, 0x11);mdelay(1);
1373 + write_phy_cck(dev, 0xa, 0x17);mdelay(1);
1374 + write_phy_cck(dev, 0xb, 0x11);mdelay(1);
1375
1376 write_phy_cck(dev, 0x10, ((priv->card_type == USB) ? 0x9b: 0x93)); mdelay(1);
1377 write_phy_cck(dev, 0x11, 0x88); mdelay(1);
1378 @@ -885,52 +914,59 @@
1379 else
1380 #endif
1381 write_phy_cck(dev, 0x13, 0xd0); /* Ver C & D & 8187*/
1382 -
1383 - write_phy_cck(dev, 0x19, 0x0);
1384 - write_phy_cck(dev, 0x1a, 0xa0);
1385 - write_phy_cck(dev, 0x1b, 0x8);
1386 - write_phy_cck(dev, 0x40, 0x86); /* CCK Carrier Sense Threshold */
1387 -
1388 - write_phy_cck(dev, 0x41, 0x8d);mdelay(1);
1389
1390 -
1391 +// write_phy_cck(dev, 0x19, 0x0);
1392 +// write_phy_cck(dev, 0x1a, 0xa0);
1393 +// write_phy_cck(dev, 0x1b, 0x8);
1394 +// write_phy_cck(dev, 0x40, 0x86); /* CCK Carrier Sense Threshold */
1395 + write_phy_cck(dev, 0x19, 0x0); mdelay(1);
1396 + write_phy_cck(dev, 0x1a, 0xa0); mdelay(1);
1397 + write_phy_cck(dev, 0x1b, 0x8); mdelay(1);
1398 + write_phy_cck(dev, 0x1d, 0x0); mdelay(1);
1399 + write_phy_cck(dev, 0x40, 0x86); /* CCK Carrier Sense Threshold */ mdelay(1);
1400 + write_phy_cck(dev, 0x41, 0x9d); mdelay(1);
1401 +
1402 +
1403 +// write_phy_cck(dev, 0x41, 0x8d);mdelay(1);
1404 +
1405 +
1406 write_phy_cck(dev, 0x42, 0x15); mdelay(1);
1407 write_phy_cck(dev, 0x43, 0x18); mdelay(1);
1408 -
1409 -
1410 +
1411 +
1412 write_phy_cck(dev, 0x44, 0x36); mdelay(1);
1413 write_phy_cck(dev, 0x45, 0x35); mdelay(1);
1414 write_phy_cck(dev, 0x46, 0x2e); mdelay(1);
1415 write_phy_cck(dev, 0x47, 0x25); mdelay(1);
1416 write_phy_cck(dev, 0x48, 0x1c); mdelay(1);
1417 write_phy_cck(dev, 0x49, 0x12); mdelay(1);
1418 - write_phy_cck(dev, 0x4a, 0x9); mdelay(1);
1419 - write_phy_cck(dev, 0x4b, 0x4); mdelay(1);
1420 + write_phy_cck(dev, 0x4a, 0x09); mdelay(1);
1421 + write_phy_cck(dev, 0x4b, 0x04); mdelay(1);
1422 write_phy_cck(dev, 0x4c, 0x5);mdelay(1);
1423
1424
1425 write_nic_byte(dev, 0x5b, 0x0d); mdelay(1);
1426
1427 -
1428 +
1429
1430 // <>
1431 // // TESTR 0xb 8187
1432 // write_phy_cck(dev, 0x10, 0x93);// & 0xfb);
1433 -//
1434 +//
1435 // //if(priv->card_type != USB){
1436 // write_phy_ofdm(dev, 0x2, 0x62);
1437 // write_phy_ofdm(dev, 0x6, 0x0);
1438 // write_phy_ofdm(dev, 0x8, 0x0);
1439 // //}
1440 -
1441 +
1442 rtl8225z2_SetTXPowerLevel(dev, channel);
1443 -
1444 +
1445 write_phy_cck(dev, 0x10, 0x9b); mdelay(1); /* Rx ant A, 0xdb for B */
1446 write_phy_ofdm(dev, 0x26, 0x90); mdelay(1); /* Rx ant A, 0x10 for B */
1447 -
1448 +
1449 rtl8185_tx_antenna(dev, 0x3); /* TX ant A, 0x0 for B */
1450 -
1451 - /* switch to high-speed 3-wire
1452 +
1453 + /* switch to high-speed 3-wire
1454 * last digit. 2 for both cck and ofdm
1455 */
1456 if(priv->card_type == USB)
1457 @@ -943,23 +979,23 @@
1458 // if(priv->card_type != USB)
1459 // rtl8225_set_gain(dev, 4); /* FIXME this '1' is random */ // <>
1460 // rtl8225_set_mode(dev, 1); /* FIXME start in B mode */ // <>
1461 -//
1462 +//
1463 // /* make sure is waken up! */
1464 // write_rtl8225(dev,0x4, 0x9ff);
1465 -// rtl8180_set_anaparam(dev, RTL8225_ANAPARAM_ON);
1466 +// rtl8180_set_anaparam(dev, RTL8225_ANAPARAM_ON);
1467 // rtl8185_set_anaparam2(dev, RTL8225_ANAPARAM2_ON);
1468 -
1469 +
1470 rtl8225_rf_set_chan(dev, priv->chan);
1471
1472 //write_nic_word(dev,BRSR,brsr);
1473 -
1474 +
1475 //rtl8225z2_rf_set_mode(dev);
1476 }
1477
1478 -void rtl8225z2_rf_set_mode(struct net_device *dev)
1479 +void rtl8225z2_rf_set_mode(struct net_device *dev)
1480 {
1481 - struct r8180_priv *priv = ieee80211_priv(dev);
1482 -
1483 + struct r8180_priv *priv = ieee80211_priv_rtl7(dev);
1484 +
1485 if(priv->ieee80211->mode == IEEE_A)
1486 {
1487 write_rtl8225(dev, 0x5, 0x1865);
1488 @@ -970,15 +1006,15 @@
1489 write_phy_ofdm(dev, 0xb, 0x99);
1490 write_phy_ofdm(dev, 0xf, 0x20);
1491 write_phy_ofdm(dev, 0x11, 0x7);
1492 -
1493 +
1494 rtl8225z2_set_gain(dev,4);
1495 -
1496 +
1497 write_phy_ofdm(dev,0x15, 0x40);
1498 write_phy_ofdm(dev,0x17, 0x40);
1499 -
1500 +
1501 write_nic_dword(dev, 0x94,0x10000000);
1502 }else{
1503 -
1504 +
1505 write_rtl8225(dev, 0x5, 0x1864);
1506 write_nic_dword(dev, RF_PARA, 0x10044);
1507 write_nic_dword(dev, RF_TIMING, 0xa8008);
1508 @@ -987,12 +1023,12 @@
1509 write_phy_ofdm(dev, 0xb, 0x99);
1510 write_phy_ofdm(dev, 0xf, 0x20);
1511 write_phy_ofdm(dev, 0x11, 0x7);
1512 -
1513 +
1514 rtl8225z2_set_gain(dev,4);
1515 -
1516 +
1517 write_phy_ofdm(dev,0x15, 0x40);
1518 write_phy_ofdm(dev,0x17, 0x40);
1519 -
1520 +
1521 write_nic_dword(dev, 0x94,0x04000002);
1522 }
1523 }
1524 diff -Naur rtl8187_orig/beta-8187/r8180_wx.c rtl8187_rawtx/beta-8187/r8180_wx.c
1525 --- rtl8187_orig/beta-8187/r8180_wx.c 2007-03-13 23:45:09.000000000 +0100
1526 +++ rtl8187_rawtx/beta-8187/r8180_wx.c 2007-06-05 14:00:01.000000000 +0200
1527 @@ -1,19 +1,19 @@
1528 -/*
1529 +/*
1530 This file contains wireless extension handlers.
1531
1532 This is part of rtl8180 OpenSource driver.
1533 - Copyright (C) Andrea Merello 2004-2005 <[email protected]>
1534 + Copyright (C) Andrea Merello 2004-2005 <[email protected]>
1535 Released under the terms of GPL (General Public Licence)
1536 -
1537 - Parts of this driver are based on the GPL part
1538 +
1539 + Parts of this driver are based on the GPL part
1540 of the official realtek driver.
1541 -
1542 - Parts of this driver are based on the rtl8180 driver skeleton
1543 +
1544 + Parts of this driver are based on the rtl8180 driver skeleton
1545 from Patric Schenke & Andres Salomon.
1546
1547 Parts of this driver are based on the Intel Pro Wireless 2100 GPL driver.
1548 -
1549 - We want to tanks the Authors of those projects and the Ndiswrapper
1550 +
1551 + We want to tanks the Authors of those projects and the Ndiswrapper
1552 project Authors.
1553 */
1554
1555 @@ -21,20 +21,21 @@
1556
1557 #include "r8187.h"
1558 #include "r8180_hw.h"
1559 +#include "r8180_rtl8225.h"
1560
1561
1562 #define RATE_COUNT 4
1563 u32 rtl8180_rates[] = {1000000,2000000,5500000,11000000,
1564 6000000,9000000,12000000,18000000,24000000,36000000,48000000,54000000};
1565 -
1566 +
1567
1568 static int r8180_wx_get_freq(struct net_device *dev,
1569 struct iw_request_info *a,
1570 union iwreq_data *wrqu, char *b)
1571 {
1572 - struct r8180_priv *priv = ieee80211_priv(dev);
1573 -
1574 - return ieee80211_wx_get_freq(priv->ieee80211,a,wrqu,b);
1575 + struct r8180_priv *priv = ieee80211_priv_rtl7(dev);
1576 +
1577 + return ieee80211_wx_get_freq_rtl7(priv->ieee80211,a,wrqu,b);
1578 }
1579
1580
1581 @@ -45,28 +46,28 @@
1582 {
1583 int *parms = (int *)b;
1584 int bi = parms[0];
1585 -
1586 - struct r8180_priv *priv = ieee80211_priv(dev);
1587 -
1588 +
1589 + struct r8180_priv *priv = ieee80211_priv_rtl7(dev);
1590 +
1591 down(&priv->wx_sem);
1592 DMESG("setting beacon interval to %x",bi);
1593 -
1594 +
1595 priv->ieee80211->beacon_interval=bi;
1596 rtl8180_commit(dev);
1597 up(&priv->wx_sem);
1598 -
1599 - return 0;
1600 +
1601 + return 0;
1602 }
1603
1604
1605 static int r8180_wx_set_forceassociate(struct net_device *dev, struct iw_request_info *aa,
1606 union iwreq_data *wrqu, char *extra)
1607 {
1608 - struct r8180_priv *priv=ieee80211_priv(dev);
1609 + struct r8180_priv *priv=ieee80211_priv_rtl7(dev);
1610 int *parms = (int *)extra;
1611 -
1612 +
1613 priv->ieee80211->force_associate = (parms[0] > 0);
1614 -
1615 +
1616
1617 return 0;
1618 }
1619 @@ -75,108 +76,157 @@
1620 static int r8180_wx_get_mode(struct net_device *dev, struct iw_request_info *a,
1621 union iwreq_data *wrqu, char *b)
1622 {
1623 - struct r8180_priv *priv=ieee80211_priv(dev);
1624 + struct r8180_priv *priv=ieee80211_priv_rtl7(dev);
1625
1626 - return ieee80211_wx_get_mode(priv->ieee80211,a,wrqu,b);
1627 + return ieee80211_wx_get_mode_rtl7(priv->ieee80211,a,wrqu,b);
1628 }
1629
1630
1631
1632 -static int r8180_wx_get_rate(struct net_device *dev,
1633 - struct iw_request_info *info,
1634 +static int r8180_wx_get_rate(struct net_device *dev,
1635 + struct iw_request_info *info,
1636 union iwreq_data *wrqu, char *extra)
1637 {
1638 - struct r8180_priv *priv = ieee80211_priv(dev);
1639 - return ieee80211_wx_get_rate(priv->ieee80211,info,wrqu,extra);
1640 + struct r8180_priv *priv = ieee80211_priv_rtl7(dev);
1641 + return ieee80211_wx_get_rate_rtl7(priv->ieee80211,info,wrqu,extra);
1642 }
1643
1644
1645
1646 -static int r8180_wx_set_rate(struct net_device *dev,
1647 - struct iw_request_info *info,
1648 +static int r8180_wx_set_rate(struct net_device *dev,
1649 + struct iw_request_info *info,
1650 union iwreq_data *wrqu, char *extra)
1651 {
1652 int ret;
1653 - struct r8180_priv *priv = ieee80211_priv(dev);
1654 -
1655 + struct r8180_priv *priv = ieee80211_priv_rtl7(dev);
1656 +
1657 down(&priv->wx_sem);
1658 + ret = ieee80211_wx_set_rate_rtl7(priv->ieee80211,info,wrqu,extra);
1659
1660 - ret = ieee80211_wx_set_rate(priv->ieee80211,info,wrqu,extra);
1661 -
1662 up(&priv->wx_sem);
1663 -
1664 +
1665 return ret;
1666 }
1667
1668 -static int r8180_wx_set_rawtx(struct net_device *dev,
1669 - struct iw_request_info *info,
1670 - union iwreq_data *wrqu, char *extra)
1671 +static int r8180_wx_get_txpow(struct net_device *dev,
1672 + struct iw_request_info *info,
1673 + union iwreq_data *wrqu, char *extra)
1674 {
1675 - struct r8180_priv *priv = ieee80211_priv(dev);
1676 - int ret;
1677 -
1678 + struct r8180_priv *priv = ieee80211_priv_rtl7(dev);
1679 + int i=0;
1680 down(&priv->wx_sem);
1681 -
1682 - ret = ieee80211_wx_set_rawtx(priv->ieee80211, info, wrqu, extra);
1683 -
1684 + wrqu->power.value = 0;
1685 + for(i=0; i<15; i++)
1686 + {
1687 + if(priv->chtxpwr[i] > wrqu->power.value) wrqu->power.value = priv->chtxpwr[i];
1688 + if(priv->chtxpwr_ofdm[i] > wrqu->power.value) wrqu->power.value = priv->chtxpwr_ofdm[i];
1689 + }
1690 + wrqu->power.fixed = 1;
1691 + wrqu->power.flags = IW_TXPOW_DBM;
1692 + wrqu->power.disabled = 0;
1693 up(&priv->wx_sem);
1694 -
1695 +
1696 + return 0;
1697 +}
1698 +
1699 +#if 1
1700 +static int r8180_wx_set_txpow(struct net_device *dev,
1701 + struct iw_request_info *info,
1702 + union iwreq_data *wrqu, char *extra)
1703 +{
1704 + int ret = 0, i=0;
1705 + struct r8180_priv *priv = ieee80211_priv_rtl7(dev);
1706 +
1707 + down(&priv->wx_sem);
1708 +
1709 + if (wrqu->power.flags != IW_TXPOW_DBM)
1710 + {
1711 + ret = -EINVAL;
1712 + goto out;
1713 + }
1714 +
1715 + if(wrqu->power.value > priv->txpwr_max)
1716 + {
1717 + ret = -EINVAL;
1718 + goto out;
1719 + }
1720 +
1721 + if(wrqu->power.value < 0)
1722 + {
1723 + ret = -EINVAL;
1724 + goto out;
1725 + }
1726 +
1727 + for(i=1;i<15;i++)
1728 + {
1729 + priv->chtxpwr[i] = priv->chtxpwr_orig[i] - (priv->txpwr_max - wrqu->power.value);
1730 + if(priv->chtxpwr[i] > priv->chtxpwr_orig[i]) priv->chtxpwr[i] = 0;
1731 +
1732 + priv->chtxpwr_ofdm[i] = priv->chtxpwr_ofdm_orig[i] - (priv->txpwr_max - wrqu->power.value);
1733 + if(priv->chtxpwr_ofdm[i] > priv->chtxpwr_ofdm_orig[i]) priv->chtxpwr_ofdm[i] = 0;
1734 + }
1735 + rtl8225z2_SetTXPowerLevel(dev, 1);
1736 +
1737 + out:
1738 + up(&priv->wx_sem);
1739 +
1740 return ret;
1741 -
1742 +
1743 }
1744 +#endif
1745
1746 -static int r8180_wx_set_crcmon(struct net_device *dev,
1747 - struct iw_request_info *info,
1748 +static int r8180_wx_set_crcmon(struct net_device *dev,
1749 + struct iw_request_info *info,
1750 union iwreq_data *wrqu, char *extra)
1751 {
1752 - struct r8180_priv *priv = ieee80211_priv(dev);
1753 + struct r8180_priv *priv = ieee80211_priv_rtl7(dev);
1754 int *parms = (int *)extra;
1755 int enable = (parms[0] > 0);
1756 short prev = priv->crcmon;
1757
1758 down(&priv->wx_sem);
1759 -
1760 - if(enable)
1761 +
1762 + if(enable)
1763 priv->crcmon=1;
1764 - else
1765 + else
1766 priv->crcmon=0;
1767
1768 - DMESG("bad CRC in monitor mode are %s",
1769 + DMESG("bad CRC in monitor mode are %s",
1770 priv->crcmon ? "accepted" : "rejected");
1771
1772 if(prev != priv->crcmon && priv->up){
1773 rtl8180_down(dev);
1774 rtl8180_up(dev);
1775 }
1776 -
1777 +
1778 up(&priv->wx_sem);
1779 -
1780 +
1781 return 0;
1782 }
1783
1784 static int r8180_wx_set_mode(struct net_device *dev, struct iw_request_info *a,
1785 union iwreq_data *wrqu, char *b)
1786 {
1787 - struct r8180_priv *priv = ieee80211_priv(dev);
1788 + struct r8180_priv *priv = ieee80211_priv_rtl7(dev);
1789 int ret;
1790 -
1791 +
1792 down(&priv->wx_sem);
1793 -
1794 - ret = ieee80211_wx_set_mode(priv->ieee80211,a,wrqu,b);
1795 -
1796 +
1797 + ret = ieee80211_wx_set_mode_rtl7(priv->ieee80211,a,wrqu,b);
1798 +
1799 rtl8187_set_rxconf(dev);
1800 -
1801 +
1802 up(&priv->wx_sem);
1803 return ret;
1804 }
1805
1806
1807 -static int rtl8180_wx_get_range(struct net_device *dev,
1808 - struct iw_request_info *info,
1809 +static int rtl8180_wx_get_range(struct net_device *dev,
1810 + struct iw_request_info *info,
1811 union iwreq_data *wrqu, char *extra)
1812 {
1813 struct iw_range *range = (struct iw_range *)extra;
1814 - struct r8180_priv *priv = ieee80211_priv(dev);
1815 + struct r8180_priv *priv = ieee80211_priv_rtl7(dev);
1816 u16 val;
1817 int i;
1818
1819 @@ -186,26 +236,26 @@
1820 /* Let's try to keep this struct in the same order as in
1821 * linux/include/wireless.h
1822 */
1823 -
1824 +
1825 /* TODO: See what values we can set, and remove the ones we can't
1826 * set, or fill them with some default data.
1827 */
1828
1829 /* ~5 Mb/s real (802.11b) */
1830 - range->throughput = 5 * 1000 * 1000;
1831 + range->throughput = 5 * 1000 * 1000;
1832
1833 // TODO: Not used in 802.11b?
1834 // range->min_nwid; /* Minimal NWID we are able to set */
1835 // TODO: Not used in 802.11b?
1836 // range->max_nwid; /* Maximal NWID we are able to set */
1837 -
1838 +
1839 /* Old Frequency (backward compat - moved lower ) */
1840 -// range->old_num_channels;
1841 +// range->old_num_channels;
1842 // range->old_num_frequency;
1843 // range->old_freq[6]; /* Filler to keep "version" at the same offset */
1844 if(priv->rf_set_sens != NULL)
1845 range->sensitivity = priv->max_sens; /* signal level threshold range */
1846 -
1847 +
1848 range->max_qual.qual = 100;
1849 /* TODO: Find real max RSSI and stick here */
1850 range->max_qual.level = 0;
1851 @@ -219,14 +269,14 @@
1852 range->avg_qual.updated = 7; /* Updated all three */
1853
1854 range->num_bitrates = RATE_COUNT;
1855 -
1856 +
1857 for (i = 0; i < RATE_COUNT && i < IW_MAX_BITRATES; i++) {
1858 range->bitrate[i] = rtl8180_rates[i];
1859 }
1860 -
1861 +
1862 range->min_frag = MIN_FRAG_THRESHOLD;
1863 range->max_frag = MAX_FRAG_THRESHOLD;
1864 -
1865 +
1866 range->pm_capa = 0;
1867
1868 range->we_version_compiled = WIRELESS_EXT;
1869 @@ -243,18 +293,18 @@
1870 range->num_channels = 14;
1871
1872 for (i = 0, val = 0; i < 14; i++) {
1873 -
1874 +
1875 // Include only legal frequencies for some countries
1876 if ((priv->challow)[i+1]) {
1877 range->freq[val].i = i + 1;
1878 - range->freq[val].m = ieee80211_wlan_frequencies[i] * 100000;
1879 + range->freq[val].m = ieee80211_wlan_frequencies_rtl7[i] * 100000;
1880 range->freq[val].e = 1;
1881 val++;
1882 } else {
1883 // FIXME: do we need to set anything for channels
1884 // we don't use ?
1885 }
1886 -
1887 +
1888 if (val == IW_MAX_FREQUENCIES)
1889 break;
1890 }
1891 @@ -267,15 +317,15 @@
1892 static int r8180_wx_set_scan(struct net_device *dev, struct iw_request_info *a,
1893 union iwreq_data *wrqu, char *b)
1894 {
1895 - struct r8180_priv *priv = ieee80211_priv(dev);
1896 + struct r8180_priv *priv = ieee80211_priv_rtl7(dev);
1897 int ret;
1898 -
1899 +
1900 if(!priv->up) return -1;
1901 -
1902 +
1903 down(&priv->wx_sem);
1904 -
1905 - ret = ieee80211_wx_set_scan(priv->ieee80211,a,wrqu,b);
1906 -
1907 +
1908 + ret = ieee80211_wx_set_scan_rtl7(priv->ieee80211,a,wrqu,b);
1909 +
1910 up(&priv->wx_sem);
1911 return ret;
1912 }
1913 @@ -286,50 +336,50 @@
1914 {
1915
1916 int ret;
1917 - struct r8180_priv *priv = ieee80211_priv(dev);
1918 -
1919 + struct r8180_priv *priv = ieee80211_priv_rtl7(dev);
1920 +
1921 if(!priv->up) return -1;
1922 -
1923 +
1924 down(&priv->wx_sem);
1925
1926 - ret = ieee80211_wx_get_scan(priv->ieee80211,a,wrqu,b);
1927 -
1928 + ret = ieee80211_wx_get_scan_rtl7(priv->ieee80211,a,wrqu,b);
1929 +
1930 up(&priv->wx_sem);
1931 -
1932 +
1933 return ret;
1934 }
1935
1936
1937 -static int r8180_wx_set_essid(struct net_device *dev,
1938 +static int r8180_wx_set_essid(struct net_device *dev,
1939 struct iw_request_info *a,
1940 union iwreq_data *wrqu, char *b)
1941 {
1942 - struct r8180_priv *priv = ieee80211_priv(dev);
1943 -
1944 + struct r8180_priv *priv = ieee80211_priv_rtl7(dev);
1945 +
1946 int ret;
1947 -
1948 +
1949 down(&priv->wx_sem);
1950 -
1951 - ret = ieee80211_wx_set_essid(priv->ieee80211,a,wrqu,b);
1952 -
1953 +
1954 + ret = ieee80211_wx_set_essid_rtl7(priv->ieee80211,a,wrqu,b);
1955 +
1956 up(&priv->wx_sem);
1957 return ret;
1958 }
1959
1960
1961 -static int r8180_wx_get_essid(struct net_device *dev,
1962 +static int r8180_wx_get_essid(struct net_device *dev,
1963 struct iw_request_info *a,
1964 union iwreq_data *wrqu, char *b)
1965 {
1966 int ret;
1967 - struct r8180_priv *priv = ieee80211_priv(dev);
1968 -
1969 + struct r8180_priv *priv = ieee80211_priv_rtl7(dev);
1970 +
1971 down(&priv->wx_sem);
1972 -
1973 - ret = ieee80211_wx_get_essid(priv->ieee80211, a, wrqu, b);
1974 +
1975 + ret = ieee80211_wx_get_essid_rtl7(priv->ieee80211, a, wrqu, b);
1976
1977 up(&priv->wx_sem);
1978 -
1979 +
1980 return ret;
1981 }
1982
1983 @@ -338,30 +388,30 @@
1984 union iwreq_data *wrqu, char *b)
1985 {
1986 int ret;
1987 - struct r8180_priv *priv = ieee80211_priv(dev);
1988 -
1989 + struct r8180_priv *priv = ieee80211_priv_rtl7(dev);
1990 +
1991 down(&priv->wx_sem);
1992 -
1993 - ret = ieee80211_wx_set_freq(priv->ieee80211, a, wrqu, b);
1994 -
1995 +
1996 + ret = ieee80211_wx_set_freq_rtl7(priv->ieee80211, a, wrqu, b);
1997 +
1998 up(&priv->wx_sem);
1999 return ret;
2000 }
2001
2002 -static int r8180_wx_get_name(struct net_device *dev,
2003 - struct iw_request_info *info,
2004 +static int r8180_wx_get_name(struct net_device *dev,
2005 + struct iw_request_info *info,
2006 union iwreq_data *wrqu, char *extra)
2007 {
2008 - struct r8180_priv *priv = ieee80211_priv(dev);
2009 - return ieee80211_wx_get_name(priv->ieee80211, info, wrqu, extra);
2010 + struct r8180_priv *priv = ieee80211_priv_rtl7(dev);
2011 + return ieee80211_wx_get_name_rtl7(priv->ieee80211, info, wrqu, extra);
2012 }
2013
2014
2015 -static int r8180_wx_set_frag(struct net_device *dev,
2016 - struct iw_request_info *info,
2017 +static int r8180_wx_set_frag(struct net_device *dev,
2018 + struct iw_request_info *info,
2019 union iwreq_data *wrqu, char *extra)
2020 {
2021 - struct r8180_priv *priv = ieee80211_priv(dev);
2022 + struct r8180_priv *priv = ieee80211_priv_rtl7(dev);
2023
2024 if (wrqu->frag.disabled)
2025 priv->ieee80211->fts = DEFAULT_FRAG_THRESHOLD;
2026 @@ -369,7 +419,7 @@
2027 if (wrqu->frag.value < MIN_FRAG_THRESHOLD ||
2028 wrqu->frag.value > MAX_FRAG_THRESHOLD)
2029 return -EINVAL;
2030 -
2031 +
2032 priv->ieee80211->fts = wrqu->frag.value & ~0x1;
2033 }
2034
2035 @@ -377,11 +427,11 @@
2036 }
2037
2038
2039 -static int r8180_wx_get_frag(struct net_device *dev,
2040 - struct iw_request_info *info,
2041 +static int r8180_wx_get_frag(struct net_device *dev,
2042 + struct iw_request_info *info,
2043 union iwreq_data *wrqu, char *extra)
2044 {
2045 - struct r8180_priv *priv = ieee80211_priv(dev);
2046 + struct r8180_priv *priv = ieee80211_priv_rtl7(dev);
2047
2048 wrqu->frag.value = priv->ieee80211->fts;
2049 wrqu->frag.fixed = 0; /* no auto select */
2050 @@ -397,49 +447,49 @@
2051 char *extra)
2052 {
2053 int ret;
2054 - struct r8180_priv *priv = ieee80211_priv(dev);
2055 -
2056 + struct r8180_priv *priv = ieee80211_priv_rtl7(dev);
2057 +
2058 down(&priv->wx_sem);
2059 -
2060 - ret = ieee80211_wx_set_wap(priv->ieee80211,info,awrq,extra);
2061 -
2062 +
2063 + ret = ieee80211_wx_set_wap_rtl7(priv->ieee80211,info,awrq,extra);
2064 +
2065 up(&priv->wx_sem);
2066 return ret;
2067 -
2068 +
2069 }
2070 -
2071
2072 -static int r8180_wx_get_wap(struct net_device *dev,
2073 - struct iw_request_info *info,
2074 +
2075 +static int r8180_wx_get_wap(struct net_device *dev,
2076 + struct iw_request_info *info,
2077 union iwreq_data *wrqu, char *extra)
2078 {
2079 - struct r8180_priv *priv = ieee80211_priv(dev);
2080 -
2081 - return ieee80211_wx_get_wap(priv->ieee80211,info,wrqu,extra);
2082 + struct r8180_priv *priv = ieee80211_priv_rtl7(dev);
2083 +
2084 + return ieee80211_wx_get_wap_rtl7(priv->ieee80211,info,wrqu,extra);
2085 }
2086
2087
2088 -static int r8180_wx_get_enc(struct net_device *dev,
2089 - struct iw_request_info *info,
2090 +static int r8180_wx_get_enc(struct net_device *dev,
2091 + struct iw_request_info *info,
2092 union iwreq_data *wrqu, char *key)
2093 {
2094 - struct r8180_priv *priv = ieee80211_priv(dev);
2095 -
2096 - return ieee80211_wx_get_encode(priv->ieee80211, info, wrqu, key);
2097 + struct r8180_priv *priv = ieee80211_priv_rtl7(dev);
2098 +
2099 + return ieee80211_wx_get_encode_rtl7(priv->ieee80211, info, wrqu, key);
2100 }
2101
2102 -static int r8180_wx_set_enc(struct net_device *dev,
2103 - struct iw_request_info *info,
2104 +static int r8180_wx_set_enc(struct net_device *dev,
2105 + struct iw_request_info *info,
2106 union iwreq_data *wrqu, char *key)
2107 {
2108 - struct r8180_priv *priv = ieee80211_priv(dev);
2109 + struct r8180_priv *priv = ieee80211_priv_rtl7(dev);
2110 int ret;
2111 -
2112 +
2113 down(&priv->wx_sem);
2114 -
2115 +
2116 DMESG("Setting SW wep key");
2117 - ret = ieee80211_wx_set_encode(priv->ieee80211,info,wrqu,key);
2118 -
2119 + ret = ieee80211_wx_set_encode_rtl7(priv->ieee80211,info,wrqu,key);
2120 +
2121 up(&priv->wx_sem);
2122 return ret;
2123 }
2124 @@ -447,28 +497,28 @@
2125
2126 static int r8180_wx_set_scan_type(struct net_device *dev, struct iw_request_info *aa, union
2127 iwreq_data *wrqu, char *p){
2128 -
2129 - struct r8180_priv *priv = ieee80211_priv(dev);
2130 +
2131 + struct r8180_priv *priv = ieee80211_priv_rtl7(dev);
2132 int *parms=(int*)p;
2133 int mode=parms[0];
2134 -
2135 +
2136 priv->ieee80211->active_scan = mode;
2137 -
2138 +
2139 return 1;
2140 }
2141
2142
2143
2144 -static int r8180_wx_set_retry(struct net_device *dev,
2145 - struct iw_request_info *info,
2146 +static int r8180_wx_set_retry(struct net_device *dev,
2147 + struct iw_request_info *info,
2148 union iwreq_data *wrqu, char *extra)
2149 {
2150 - struct r8180_priv *priv = ieee80211_priv(dev);
2151 + struct r8180_priv *priv = ieee80211_priv_rtl7(dev);
2152 int err = 0;
2153 -
2154 +
2155 down(&priv->wx_sem);
2156 -
2157 - if (wrqu->retry.flags & IW_RETRY_LIFETIME ||
2158 +
2159 + if (wrqu->retry.flags & IW_RETRY_LIFETIME ||
2160 wrqu->retry.disabled){
2161 err = -EINVAL;
2162 goto exit;
2163 @@ -485,13 +535,13 @@
2164 if (wrqu->retry.flags & IW_RETRY_MAX) {
2165 priv->retry_rts = wrqu->retry.value;
2166 DMESG("Setting retry for RTS/CTS data to %d", wrqu->retry.value);
2167 -
2168 +
2169 }else {
2170 priv->retry_data = wrqu->retry.value;
2171 DMESG("Setting retry for non RTS/CTS data to %d", wrqu->retry.value);
2172 }
2173 -
2174 - /* FIXME !
2175 +
2176 + /* FIXME !
2177 * We might try to write directly the TX config register
2178 * or to restart just the (R)TX process.
2179 * I'm unsure if whole reset is really needed
2180 @@ -503,28 +553,28 @@
2181 rtl8180_rtx_disable(dev);
2182 rtl8180_rx_enable(dev);
2183 rtl8180_tx_enable(dev);
2184 -
2185 +
2186 }
2187 */
2188 exit:
2189 up(&priv->wx_sem);
2190 -
2191 +
2192 return err;
2193 }
2194
2195 -static int r8180_wx_get_retry(struct net_device *dev,
2196 - struct iw_request_info *info,
2197 +static int r8180_wx_get_retry(struct net_device *dev,
2198 + struct iw_request_info *info,
2199 union iwreq_data *wrqu, char *extra)
2200 {
2201 - struct r8180_priv *priv = ieee80211_priv(dev);
2202 -
2203 + struct r8180_priv *priv = ieee80211_priv_rtl7(dev);
2204 +
2205
2206 wrqu->retry.disabled = 0; /* can't be disabled */
2207
2208 - if ((wrqu->retry.flags & IW_RETRY_TYPE) ==
2209 - IW_RETRY_LIFETIME)
2210 + if ((wrqu->retry.flags & IW_RETRY_TYPE) ==
2211 + IW_RETRY_LIFETIME)
2212 return -EINVAL;
2213 -
2214 +
2215 if (wrqu->retry.flags & IW_RETRY_MAX) {
2216 wrqu->retry.flags = IW_RETRY_LIMIT & IW_RETRY_MAX;
2217 wrqu->retry.value = priv->retry_rts;
2218 @@ -533,30 +583,30 @@
2219 wrqu->retry.value = priv->retry_data;
2220 }
2221 //DMESG("returning %d",wrqu->retry.value);
2222 -
2223 +
2224
2225 return 0;
2226 }
2227
2228 -static int r8180_wx_get_sens(struct net_device *dev,
2229 - struct iw_request_info *info,
2230 +static int r8180_wx_get_sens(struct net_device *dev,
2231 + struct iw_request_info *info,
2232 union iwreq_data *wrqu, char *extra)
2233 {
2234 - struct r8180_priv *priv = ieee80211_priv(dev);
2235 - if(priv->rf_set_sens == NULL)
2236 + struct r8180_priv *priv = ieee80211_priv_rtl7(dev);
2237 + if(priv->rf_set_sens == NULL)
2238 return -1; /* we have not this support for this radio */
2239 wrqu->sens.value = priv->sens;
2240 return 0;
2241 }
2242
2243
2244 -static int r8180_wx_set_sens(struct net_device *dev,
2245 - struct iw_request_info *info,
2246 +static int r8180_wx_set_sens(struct net_device *dev,
2247 + struct iw_request_info *info,
2248 union iwreq_data *wrqu, char *extra)
2249 {
2250 -
2251 - struct r8180_priv *priv = ieee80211_priv(dev);
2252 -
2253 +
2254 + struct r8180_priv *priv = ieee80211_priv_rtl7(dev);
2255 +
2256 short err = 0;
2257 down(&priv->wx_sem);
2258 //DMESG("attempt to set sensivity to %ddb",wrqu->sens.value);
2259 @@ -571,7 +621,7 @@
2260
2261 exit:
2262 up(&priv->wx_sem);
2263 -
2264 +
2265 return err;
2266 }
2267
2268 @@ -623,32 +673,28 @@
2269 dummy, /* SIOCGIWRTS */
2270 r8180_wx_set_frag, /* SIOCSIWFRAG */
2271 r8180_wx_get_frag, /* SIOCGIWFRAG */
2272 - dummy, /* SIOCSIWTXPOW */
2273 - dummy, /* SIOCGIWTXPOW */
2274 + r8180_wx_set_txpow, /* SIOCSIWTXPOW */
2275 + r8180_wx_get_txpow, /* SIOCGIWTXPOW */
2276 r8180_wx_set_retry, /* SIOCSIWRETRY */
2277 r8180_wx_get_retry, /* SIOCGIWRETRY */
2278 r8180_wx_set_enc, /* SIOCSIWENCODE */
2279 r8180_wx_get_enc, /* SIOCGIWENCODE */
2280 dummy, /* SIOCSIWPOWER */
2281 dummy, /* SIOCGIWPOWER */
2282 -};
2283 +};
2284
2285
2286 -static const struct iw_priv_args r8180_private_args[] = {
2287 -
2288 +static const struct iw_priv_args r8180_private_args[] = {
2289 +
2290 {
2291 - SIOCIWFIRSTPRIV + 0x0,
2292 - IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1, 0, "badcrc"
2293 - },
2294 -
2295 + SIOCIWFIRSTPRIV + 0x0,
2296 + IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1, 0, "badcrc"
2297 + },
2298 +
2299 {
2300 SIOCIWFIRSTPRIV + 0x1,
2301 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1, 0, "activescan"
2302 -
2303 - },
2304 - {
2305 - SIOCIWFIRSTPRIV + 0x2,
2306 - IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1, 0, "rawtx"
2307 +
2308 }
2309 };
2310
2311 @@ -660,13 +706,12 @@
2312 // r8180_wx_set_beaconinterval,
2313 // r8180_wx_set_monitor_type,
2314 r8180_wx_set_scan_type,
2315 - r8180_wx_set_rawtx,
2316 };
2317
2318 -#if WIRELESS_EXT >= 17
2319 +#if WIRELESS_EXT >= 17
2320 static struct iw_statistics *r8180_get_wireless_stats(struct net_device *dev)
2321 {
2322 - struct r8180_priv *priv = ieee80211_priv(dev);
2323 + struct r8180_priv *priv = ieee80211_priv_rtl7(dev);
2324
2325 return &priv->wstats;
2326 }
2327 @@ -679,8 +724,8 @@
2328 .private = r8180_private_handler,
2329 .num_private = sizeof(r8180_private_handler) / sizeof(iw_handler),
2330 .num_private_args = sizeof(r8180_private_args) / sizeof(struct iw_priv_args),
2331 -#if WIRELESS_EXT >= 17
2332 +#if WIRELESS_EXT >= 17
2333 .get_wireless_stats = r8180_get_wireless_stats,
2334 #endif
2335 - .private_args = (struct iw_priv_args *)r8180_private_args,
2336 + .private_args = (struct iw_priv_args *)r8180_private_args,
2337 };
2338 diff -Naur rtl8187_orig/beta-8187/r8187_core.c rtl8187_rawtx/beta-8187/r8187_core.c
2339 --- rtl8187_orig/beta-8187/r8187_core.c 2007-03-13 23:45:09.000000000 +0100
2340 +++ rtl8187_rawtx/beta-8187/r8187_core.c 2007-06-05 14:00:01.000000000 +0200
2341 @@ -1,27 +1,27 @@
2342 /*
2343 This is part of rtl8187 OpenSource driver - v 0.1
2344 - Copyright (C) Andrea Merello 2005 <[email protected]>
2345 + Copyright (C) Andrea Merello 2005 <[email protected]>
2346 Released under the terms of GPL (General Public License)
2347 -
2348 -
2349 - Parts of this driver are based on the rtl8180 driver skeleton
2350 +
2351 +
2352 + Parts of this driver are based on the rtl8180 driver skeleton
2353 from Patric Schenke & Andres Salomon.
2354
2355 Parts of this driver are based on the Intel Pro Wireless 2*00 GPL drivers.
2356 -
2357 +
2358 some ideas might be derived from David Young rtl8180 netbsd driver.
2359 -
2360 +
2361 Parts of the usb code are from the r8150.c driver in linux kernel
2362 -
2363 +
2364 Some ideas borrowed from the 8139too.c driver included in linux kernel.
2365 -
2366 - We (I?) want to thanks the Authors of those projecs and also the
2367 +
2368 + We (I?) want to thanks the Authors of those projecs and also the
2369 Ndiswrapper's project Authors.
2370 -
2371 - A special big thanks goes also to Realtek corp. for their help in my
2372 - attempt to add RTL8187 and RTL8225 support, and to David Young also.
2373
2374 - - Please note that this file is a modified version from rtl8180-sa2400
2375 + A special big thanks goes also to Realtek corp. for their help in my
2376 + attempt to add RTL8187 and RTL8225 support, and to David Young also.
2377 +
2378 + - Please note that this file is a modified version from rtl8180-sa2400
2379 drv. So some other people have contributed to this project, and they are
2380 thanked in the rtl8180-sa2400 CHANGELOG.
2381 */
2382 @@ -57,6 +57,7 @@
2383 #undef DEBUG_IRQ_TASKLET
2384 #undef DEBUG_TX_ALLOC
2385 #undef DEBUG_TX_DESC
2386 +#undef DEBUG_TX_POWER
2387
2388 //#define CONFIG_RTL8180_IO_MAP
2389
2390 @@ -66,6 +67,9 @@
2391 #include "r8180_93cx6.h" /* Card EEPROM */
2392 #include "r8180_wx.h"
2393
2394 +#if !(defined(CONFIG_USB_EHCI_HCD) || defined (CONFIG_USB_EHCI_HCD_MODULE))
2395 + #error Build your kernel with ehci_hcd support!
2396 +#endif
2397
2398 // FIXME: check if 2.6.7 is ok
2399 #if (LINUX_VERSION_CODE < KERNEL_VERSION(2,6,7))
2400 @@ -98,6 +102,10 @@
2401 #endif
2402 static int channels = 0x3fff;
2403
2404 +// #define DEBUG_EPROM
2405 +// #define DEBUG_REGISTERS
2406 +// #define DEBUG_TX_POWER
2407 +
2408 MODULE_LICENSE("GPL");
2409 MODULE_VERSION("V 1.1");
2410 MODULE_DEVICE_TABLE(usb, rtl8187_usb_id_tbl);
2411 @@ -137,7 +145,7 @@
2412
2413 static int __devinit rtl8187_usb_probe(struct usb_interface *intf,
2414 const struct usb_device_id *id);
2415 -
2416 +
2417 static void __devexit rtl8187_usb_disconnect(struct usb_interface *intf);
2418
2419 static struct usb_driver rtl8187_usb_driver = {
2420 @@ -158,13 +166,12 @@
2421 #endif
2422 };
2423
2424 -
2425 void write_nic_byte_E(struct net_device *dev, int indx, u8 data)
2426 {
2427 -
2428 - struct r8180_priv *priv = (struct r8180_priv *)ieee80211_priv(dev);
2429 +
2430 + struct r8180_priv *priv = (struct r8180_priv *)ieee80211_priv_rtl7(dev);
2431 struct usb_device *udev = priv->udev;
2432 -
2433 +
2434 usb_control_msg(udev, usb_sndctrlpipe(udev, 0),
2435 RTL8187_REQ_SET_REGS, RTL8187_REQT_WRITE,
2436 indx|0xfe00, 0, &data, 1, HZ / 2);
2437 @@ -173,10 +180,10 @@
2438
2439 void write_nic_byte(struct net_device *dev, int indx, u8 data)
2440 {
2441 -
2442 - struct r8180_priv *priv = (struct r8180_priv *)ieee80211_priv(dev);
2443 +
2444 + struct r8180_priv *priv = (struct r8180_priv *)ieee80211_priv_rtl7(dev);
2445 struct usb_device *udev = priv->udev;
2446 -
2447 +
2448 usb_control_msg(udev, usb_sndctrlpipe(udev, 0),
2449 RTL8187_REQ_SET_REGS, RTL8187_REQT_WRITE,
2450 indx|0xff00, 0, &data, 1, HZ / 2);
2451 @@ -185,10 +192,10 @@
2452
2453 void write_nic_word(struct net_device *dev, int indx, u16 data)
2454 {
2455 -
2456 - struct r8180_priv *priv = (struct r8180_priv *)ieee80211_priv(dev);
2457 +
2458 + struct r8180_priv *priv = (struct r8180_priv *)ieee80211_priv_rtl7(dev);
2459 struct usb_device *udev = priv->udev;
2460 -
2461 +
2462 usb_control_msg(udev, usb_sndctrlpipe(udev, 0),
2463 RTL8187_REQ_SET_REGS, RTL8187_REQT_WRITE,
2464 indx|0xff00, 0, &data, 2, HZ / 2);
2465 @@ -197,23 +204,23 @@
2466
2467 void write_nic_dword(struct net_device *dev, int indx, u32 data)
2468 {
2469 -
2470 - struct r8180_priv *priv = (struct r8180_priv *)ieee80211_priv(dev);
2471 +
2472 + struct r8180_priv *priv = (struct r8180_priv *)ieee80211_priv_rtl7(dev);
2473 struct usb_device *udev = priv->udev;
2474 -
2475 +
2476 usb_control_msg(udev, usb_sndctrlpipe(udev, 0),
2477 RTL8187_REQ_SET_REGS, RTL8187_REQT_WRITE,
2478 indx|0xff00, 0, &data, 4, HZ / 2);
2479 }
2480 -
2481 -
2482 -
2483 +
2484 +
2485 +
2486 u8 read_nic_byte(struct net_device *dev, int indx)
2487 {
2488 u8 data;
2489 - struct r8180_priv *priv = (struct r8180_priv *)ieee80211_priv(dev);
2490 + struct r8180_priv *priv = (struct r8180_priv *)ieee80211_priv_rtl7(dev);
2491 struct usb_device *udev = priv->udev;
2492 -
2493 +
2494 usb_control_msg(udev, usb_rcvctrlpipe(udev, 0),
2495 RTL8187_REQ_GET_REGS, RTL8187_REQT_READ,
2496 indx|0xff00, 0, &data, 1, HZ / 2);
2497 @@ -223,22 +230,22 @@
2498 u8 read_nic_byte_E(struct net_device *dev, int indx)
2499 {
2500 u8 data;
2501 - struct r8180_priv *priv = (struct r8180_priv *)ieee80211_priv(dev);
2502 + struct r8180_priv *priv = (struct r8180_priv *)ieee80211_priv_rtl7(dev);
2503 struct usb_device *udev = priv->udev;
2504 -
2505 +
2506 usb_control_msg(udev, usb_rcvctrlpipe(udev, 0),
2507 RTL8187_REQ_GET_REGS, RTL8187_REQT_READ,
2508 indx|0xfe00, 0, &data, 1, HZ / 2);
2509 return data;
2510 }
2511
2512 -
2513 +
2514 u16 read_nic_word(struct net_device *dev, int indx)
2515 {
2516 u16 data;
2517 - struct r8180_priv *priv = (struct r8180_priv *)ieee80211_priv(dev);
2518 + struct r8180_priv *priv = (struct r8180_priv *)ieee80211_priv_rtl7(dev);
2519 struct usb_device *udev = priv->udev;
2520 -
2521 +
2522 usb_control_msg(udev, usb_rcvctrlpipe(udev, 0),
2523 RTL8187_REQ_GET_REGS, RTL8187_REQT_READ,
2524 indx|0xff00, 0, &data, 2, HZ / 2);
2525 @@ -249,16 +256,16 @@
2526 u32 read_nic_dword(struct net_device *dev, int indx)
2527 {
2528 u32 data;
2529 - struct r8180_priv *priv = (struct r8180_priv *)ieee80211_priv(dev);
2530 + struct r8180_priv *priv = (struct r8180_priv *)ieee80211_priv_rtl7(dev);
2531 struct usb_device *udev = priv->udev;
2532 -
2533 +
2534 usb_control_msg(udev, usb_rcvctrlpipe(udev, 0),
2535 RTL8187_REQ_GET_REGS, RTL8187_REQT_READ,
2536 indx|0xff00, 0, &data, 4, HZ / 2);
2537 return data;
2538 }
2539
2540 -/* this might still called in what was the PHY rtl8185/rtl8187 common code
2541 +/* this might still called in what was the PHY rtl8185/rtl8187 common code
2542 * plans are to possibilty turn it again in one common code...
2543 */
2544 inline void force_pci_posting(struct net_device *dev)
2545 @@ -271,7 +278,12 @@
2546 //void set_nic_txring(struct net_device *dev);
2547 static struct net_device_stats *rtl8180_stats(struct net_device *dev);
2548 void rtl8180_commit(struct net_device *dev);
2549 +
2550 +# if (LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,20))
2551 +void rtl8180_restart(struct work_struct *work);
2552 +#else
2553 void rtl8180_restart(struct net_device *dev);
2554 +#endif
2555
2556 /****************************************************************************
2557 -----------------------------PROCFS STUFF-------------------------
2558 @@ -284,13 +296,13 @@
2559 int *eof, void *data)
2560 {
2561 struct net_device *dev = data;
2562 -// struct r8180_priv *priv = (struct r8180_priv *)ieee80211_priv(dev);
2563 -
2564 +// struct r8180_priv *priv = (struct r8180_priv *)ieee80211_priv_rtl7(dev);
2565 +
2566 int len = 0;
2567 int i,n;
2568 -
2569 +
2570 int max=0xff;
2571 -
2572 +
2573 /* This dump the current register page */
2574 for(n=0;n<=max;)
2575 {
2576 @@ -307,7 +319,7 @@
2577 len += snprintf(page + len, count - len,"\n");
2578
2579
2580 -
2581 +
2582 *eof = 1;
2583 return len;
2584
2585 @@ -319,16 +331,16 @@
2586 int *eof, void *data)
2587 {
2588 struct net_device *dev = data;
2589 - struct r8180_priv *priv = (struct r8180_priv *)ieee80211_priv(dev);
2590 -
2591 + struct r8180_priv *priv = (struct r8180_priv *)ieee80211_priv_rtl7(dev);
2592 +
2593 int len = 0;
2594 -
2595 +
2596 len += snprintf(page + len, count - len,
2597 "NIC int: %lu\n"
2598 "Total int: %lu\n",
2599 priv->stats.ints,
2600 priv->stats.shints);
2601 -
2602 +
2603 *eof = 1;
2604 return len;
2605 }
2606 @@ -339,10 +351,10 @@
2607 int *eof, void *data)
2608 {
2609 struct net_device *dev = data;
2610 - struct r8180_priv *priv = (struct r8180_priv *)ieee80211_priv(dev);
2611 -
2612 + struct r8180_priv *priv = (struct r8180_priv *)ieee80211_priv_rtl7(dev);
2613 +
2614 int len = 0;
2615 -
2616 +
2617 len += snprintf(page + len, count - len,
2618 "TX normal priority ok int: %lu\n"
2619 "TX normal priority error int: %lu\n"
2620 @@ -359,7 +371,7 @@
2621 "TX HW queue: %d\n"
2622 "TX lp dropped: %lu\n"
2623 "TX np dropped: %lu\n"
2624 - "TX total data packets %lu\n",
2625 + "TX total data packets %lu\n",
2626 // "TX beacon aborted: %lu\n",
2627 priv->stats.txnpokint,
2628 priv->stats.txnperr,
2629 @@ -379,10 +391,10 @@
2630 priv->stats.txdatapkt
2631 // priv->stats.txbeaconerr
2632 );
2633 -
2634 +
2635 *eof = 1;
2636 return len;
2637 -}
2638 +}
2639
2640
2641
2642 @@ -391,10 +403,10 @@
2643 int *eof, void *data)
2644 {
2645 struct net_device *dev = data;
2646 - struct r8180_priv *priv = (struct r8180_priv *)ieee80211_priv(dev);
2647 -
2648 + struct r8180_priv *priv = (struct r8180_priv *)ieee80211_priv_rtl7(dev);
2649 +
2650 int len = 0;
2651 -
2652 +
2653 len += snprintf(page + len, count - len,
2654 "RX packets: %lu\n"
2655 "RX urb status error: %lu\n"
2656 @@ -402,21 +414,22 @@
2657 priv->stats.rxok,
2658 priv->stats.rxstaterr,
2659 priv->stats.rxurberr);
2660 -
2661 +
2662 *eof = 1;
2663 return len;
2664 -}
2665 -
2666 +}
2667
2668 +#if WIRELESS_EXT < 17
2669 static struct iw_statistics *r8180_get_wireless_stats(struct net_device *dev)
2670 {
2671 - struct r8180_priv *priv = ieee80211_priv(dev);
2672 + struct r8180_priv *priv = ieee80211_priv_rtl7(dev);
2673
2674 return &priv->wstats;
2675 }
2676 +#endif
2677
2678 void rtl8180_proc_module_init(void)
2679 -{
2680 +{
2681 DMESG("Initializing proc filesystem");
2682 rtl8180_proc=create_proc_entry(RTL8187_MODULE_NAME, S_IFDIR, proc_net);
2683 }
2684 @@ -430,7 +443,7 @@
2685
2686 void rtl8180_proc_remove_one(struct net_device *dev)
2687 {
2688 - struct r8180_priv *priv = (struct r8180_priv *)ieee80211_priv(dev);
2689 + struct r8180_priv *priv = (struct r8180_priv *)ieee80211_priv_rtl7(dev);
2690 if (priv->dir_dev) {
2691 // remove_proc_entry("stats-hw", priv->dir_dev);
2692 remove_proc_entry("stats-tx", priv->dir_dev);
2693 @@ -447,9 +460,9 @@
2694 void rtl8180_proc_init_one(struct net_device *dev)
2695 {
2696 struct proc_dir_entry *e;
2697 - struct r8180_priv *priv = (struct r8180_priv *)ieee80211_priv(dev);
2698 - priv->dir_dev = create_proc_entry(dev->name,
2699 - S_IFDIR | S_IRUGO | S_IXUGO,
2700 + struct r8180_priv *priv = (struct r8180_priv *)ieee80211_priv_rtl7(dev);
2701 + priv->dir_dev = create_proc_entry(dev->name,
2702 + S_IFDIR | S_IRUGO | S_IXUGO,
2703 rtl8180_proc);
2704 if (!priv->dir_dev) {
2705 DMESGE("Unable to initialize /proc/net/rtl8187/%s\n",
2706 @@ -459,7 +472,7 @@
2707 #if 0
2708 e = create_proc_read_entry("stats-hw", S_IFREG | S_IRUGO,
2709 priv->dir_dev, proc_get_stats_hw, dev);
2710 -
2711 +
2712 if (!e) {
2713 DMESGE("Unable to initialize "
2714 "/proc/net/rtl8187/%s/stats-hw\n",
2715 @@ -468,17 +481,17 @@
2716 #endif
2717 e = create_proc_read_entry("stats-rx", S_IFREG | S_IRUGO,
2718 priv->dir_dev, proc_get_stats_rx, dev);
2719 -
2720 +
2721 if (!e) {
2722 DMESGE("Unable to initialize "
2723 "/proc/net/rtl8187/%s/stats-rx\n",
2724 dev->name);
2725 }
2726 -
2727 -
2728 +
2729 +
2730 e = create_proc_read_entry("stats-tx", S_IFREG | S_IRUGO,
2731 priv->dir_dev, proc_get_stats_tx, dev);
2732 -
2733 +
2734 if (!e) {
2735 DMESGE("Unable to initialize "
2736 "/proc/net/rtl8187/%s/stats-tx\n",
2737 @@ -487,27 +500,27 @@
2738 #if 0
2739 e = create_proc_read_entry("stats-ieee", S_IFREG | S_IRUGO,
2740 priv->dir_dev, proc_get_stats_ieee, dev);
2741 -
2742 +
2743 if (!e) {
2744 DMESGE("Unable to initialize "
2745 "/proc/net/rtl8187/%s/stats-ieee\n",
2746 dev->name);
2747 }
2748 -
2749 -
2750 +
2751 +
2752 e = create_proc_read_entry("stats-ap", S_IFREG | S_IRUGO,
2753 priv->dir_dev, proc_get_stats_ap, dev);
2754 -
2755 +
2756 if (!e) {
2757 DMESGE("Unable to initialize "
2758 "/proc/net/rtl8187/%s/stats-ap\n",
2759 dev->name);
2760 }
2761 #endif
2762 -
2763 +
2764 e = create_proc_read_entry("registers", S_IFREG | S_IRUGO,
2765 priv->dir_dev, proc_get_registers, dev);
2766 -
2767 +
2768 if (!e) {
2769 DMESGE("Unable to initialize "
2770 "/proc/net/rtl8187/%s/registers\n",
2771 @@ -523,14 +536,14 @@
2772 {
2773 int i;
2774 u8 *buf =(u8*)buffer;
2775 -
2776 +
2777 printk("ASCII BUFFER DUMP (len: %x):\n",len);
2778 -
2779 +
2780 for(i=0;i<len;i++)
2781 printk("%c",buf[i]);
2782 -
2783 +
2784 printk("\nBINARY BUFFER DUMP (len: %x):\n",len);
2785 -
2786 +
2787 for(i=0;i<len;i++)
2788 printk("%x",buf[i]);
2789
2790 @@ -539,17 +552,17 @@
2791
2792 short check_nic_enought_desc(struct net_device *dev, priority_t priority)
2793 {
2794 - struct r8180_priv *priv = ieee80211_priv(dev);
2795 -
2796 - int used = atomic_read((priority == NORM_PRIORITY) ?
2797 + struct r8180_priv *priv = ieee80211_priv_rtl7(dev);
2798 +
2799 + int used = atomic_read((priority == NORM_PRIORITY) ?
2800 &priv->tx_np_pending : &priv->tx_lp_pending);
2801 -
2802 +
2803 return (used < MAX_TX_URB);
2804 }
2805
2806 void tx_timeout(struct net_device *dev)
2807 {
2808 - struct r8180_priv *priv = ieee80211_priv(dev);
2809 + struct r8180_priv *priv = ieee80211_priv_rtl7(dev);
2810 //rtl8180_commit(dev);
2811 schedule_work(&priv->reset_wq);
2812 //DMESG("TXTIMEOUT");
2813 @@ -561,7 +574,20 @@
2814 {
2815 int i;
2816 for(i=0; i<63; i++)
2817 - DMESG("EEPROM addr %x : %x", i, eprom_read(dev,i));
2818 + DMESG("EEPROM addr %02X : %04X", i, eprom_read(dev,i));
2819 +}
2820 +
2821 +/* this is only for debug */
2822 +void dump_tx_power(struct net_device *dev)
2823 +{
2824 + struct r8180_priv *priv = ieee80211_priv_rtl7(dev);
2825 + int i;
2826 + DMESG("CCK TX-Power (b-mode):");
2827 + for(i=1; i<=14; i++)
2828 + DMESG("Channel %d: %d", i, priv->chtxpwr[i]);
2829 + DMESG("OFDM TX-Power (g-mode):");
2830 + for(i=1; i<=14; i++)
2831 + DMESG("Channel %d: %d", i, priv->chtxpwr_ofdm[i]);
2832 }
2833
2834 /* this is only for debug */
2835 @@ -570,14 +596,14 @@
2836 int i;
2837 int n;
2838 int max=0xff;
2839 -
2840 - DMESG("Dumping NIC register map");
2841 -
2842 +
2843 + DMESG("Dumping NIC register map");
2844 +
2845 for(n=0;n<=max;)
2846 {
2847 - printk( "\nD: %2x> ", n);
2848 + printk( "\nD: %02X> ", n);
2849 for(i=0;i<16 && n<=max;i++,n++)
2850 - printk("%2x ",read_nic_byte(dev,n));
2851 + printk("%02X ",read_nic_byte(dev,n));
2852 }
2853 printk("\n");
2854 }
2855 @@ -589,11 +615,11 @@
2856
2857 void rtl8180_irq_enable(struct net_device *dev)
2858 {
2859 - struct r8180_priv *priv = (struct r8180_priv *)ieee80211_priv(dev);
2860 + struct r8180_priv *priv = (struct r8180_priv *)ieee80211_priv_rtl7(dev);
2861 //priv->irq_enabled = 1;
2862 /*
2863 - write_nic_word(dev,INTA_MASK,INTA_RXOK | INTA_RXDESCERR | INTA_RXOVERFLOW |\
2864 - INTA_TXOVERFLOW | INTA_HIPRIORITYDESCERR | INTA_HIPRIORITYDESCOK |\
2865 + write_nic_word(dev,INTA_MASK,INTA_RXOK | INTA_RXDESCERR | INTA_RXOVERFLOW |\
2866 + INTA_TXOVERFLOW | INTA_HIPRIORITYDESCERR | INTA_HIPRIORITYDESCOK |\
2867 INTA_NORMPRIORITYDESCERR | INTA_NORMPRIORITYDESCOK |\
2868 INTA_LOWPRIORITYDESCERR | INTA_LOWPRIORITYDESCOK | INTA_TIMEOUT);
2869 */
2870 @@ -603,7 +629,7 @@
2871
2872 void rtl8180_irq_disable(struct net_device *dev)
2873 {
2874 -// struct r8180_priv *priv = (struct r8180_priv *)ieee80211_priv(dev);
2875 +// struct r8180_priv *priv = (struct r8180_priv *)ieee80211_priv_rtl7(dev);
2876
2877 write_nic_word(dev,INTA_MASK,0);
2878 force_pci_posting(dev);
2879 @@ -625,115 +651,119 @@
2880
2881 void rtl8180_update_msr(struct net_device *dev)
2882 {
2883 - struct r8180_priv *priv = ieee80211_priv(dev);
2884 + struct r8180_priv *priv = ieee80211_priv_rtl7(dev);
2885 u8 msr;
2886 -
2887 +
2888 msr = read_nic_byte(dev, MSR);
2889 msr &= ~ MSR_LINK_MASK;
2890 -
2891 +
2892 /* do not change in link_state != WLAN_LINK_ASSOCIATED.
2893 - * msr must be updated if the state is ASSOCIATING.
2894 + * msr must be updated if the state is ASSOCIATING.
2895 * this is intentional and make sense for ad-hoc and
2896 * master (see the create BSS/IBSS func)
2897 */
2898 - if (priv->ieee80211->state == IEEE80211_LINKED){
2899 -
2900 + if (priv->ieee80211->state == IEEE80211_LINKED){
2901 +
2902 if (priv->ieee80211->iw_mode == IW_MODE_INFRA)
2903 msr |= (MSR_LINK_MANAGED<<MSR_LINK_SHIFT);
2904 else if (priv->ieee80211->iw_mode == IW_MODE_ADHOC)
2905 msr |= (MSR_LINK_ADHOC<<MSR_LINK_SHIFT);
2906 else if (priv->ieee80211->iw_mode == IW_MODE_MASTER)
2907 msr |= (MSR_LINK_MASTER<<MSR_LINK_SHIFT);
2908 -
2909 +
2910 }else
2911 msr |= (MSR_LINK_NONE<<MSR_LINK_SHIFT);
2912 -
2913 +
2914 write_nic_byte(dev, MSR, msr);
2915 }
2916
2917 void rtl8180_set_chan(struct net_device *dev,short ch)
2918 {
2919 - struct r8180_priv *priv = (struct r8180_priv *)ieee80211_priv(dev);
2920 + struct r8180_priv *priv = (struct r8180_priv *)ieee80211_priv_rtl7(dev);
2921 u32 tx;
2922 priv->chan=ch;
2923 #if 0
2924 - if(priv->ieee80211->iw_mode == IW_MODE_ADHOC ||
2925 + if(priv->ieee80211->iw_mode == IW_MODE_ADHOC ||
2926 priv->ieee80211->iw_mode == IW_MODE_MASTER){
2927 -
2928 - priv->ieee80211->link_state = WLAN_LINK_ASSOCIATED;
2929 +
2930 + priv->ieee80211->link_state = WLAN_LINK_ASSOCIATED;
2931 priv->ieee80211->master_chan = ch;
2932 - rtl8180_update_beacon_ch(dev);
2933 + rtl8180_update_beacon_ch(dev);
2934 }
2935 #endif
2936 -
2937 +
2938 /* this hack should avoid frame TX during channel setting*/
2939 tx = read_nic_dword(dev,TX_CONF);
2940 tx &= ~TX_LOOPBACK_MASK;
2941
2942 -#ifndef LOOP_TEST
2943 +#ifndef LOOP_TEST
2944 write_nic_dword(dev,TX_CONF, tx |( TX_LOOPBACK_MAC<<TX_LOOPBACK_SHIFT));
2945 -
2946 priv->rf_set_chan(dev,priv->chan);
2947 mdelay(10);
2948 - write_nic_dword(dev,TX_CONF,tx | (TX_LOOPBACK_NONE<<TX_LOOPBACK_SHIFT));
2949 + write_nic_dword(dev,TX_CONF,tx | (TX_LOOPBACK_NONE<<TX_LOOPBACK_SHIFT));
2950 #endif
2951 }
2952 +
2953 +#if (LINUX_VERSION_CODE < KERNEL_VERSION(2,6,19))
2954 void rtl8187_rx_isr(struct urb *rx_urb, struct pt_regs *regs);
2955 +#else
2956 +void rtl8187_rx_isr(struct urb *rx_urb);
2957 +#endif
2958
2959
2960 void rtl8187_rx_urbsubmit(struct net_device *dev, struct urb* rx_urb)
2961 {
2962 - struct r8180_priv *priv = (struct r8180_priv *)ieee80211_priv(dev);
2963 + struct r8180_priv *priv = (struct r8180_priv *)ieee80211_priv_rtl7(dev);
2964 int err;
2965 -
2966 +
2967 // u8 *rx;
2968 -
2969 +
2970 //DMESG("starting RX");
2971 /*rx = kmalloc(RX_URB_SIZE*sizeof(u8),GFP_ATOMIC);
2972 - if(!rx){
2973 + if(!rx){
2974 DMESGE("unable to allocate RX buffer");
2975 return;
2976 }*/
2977 -
2978 +
2979 usb_fill_bulk_urb(rx_urb,priv->udev,
2980 usb_rcvbulkpipe(priv->udev,0x81), rx_urb->transfer_buffer,
2981 RX_URB_SIZE,rtl8187_rx_isr,dev);
2982 - err = usb_submit_urb(rx_urb, GFP_ATOMIC);
2983 + err = usb_submit_urb(rx_urb, GFP_ATOMIC);
2984 if(err && err != -EPERM){
2985 DMESGE("cannot submit RX command. URB_STATUS %x",rx_urb->status);
2986 -
2987 +
2988 }
2989 -
2990 +
2991 }
2992
2993
2994 void rtl8187_rx_initiate(struct net_device *dev)
2995 {
2996 int i;
2997 - struct r8180_priv *priv = (struct r8180_priv *)ieee80211_priv(dev);
2998 -
2999 + struct r8180_priv *priv = (struct r8180_priv *)ieee80211_priv_rtl7(dev);
3000 +
3001 if(!priv->rx_urb)
3002 DMESGE("Cannot intiate RX urb mechanism");
3003 - for(i=0;i<MAX_RX_URB;i++) // RX_MAX_URB is 1
3004 + for(i=0;i<MAX_RX_URB;i++) // RX_MAX_URB is 1
3005 rtl8187_rx_urbsubmit(dev,priv->rx_urb[i]);
3006 -
3007 +
3008 }
3009
3010 void rtl8187_set_rxconf(struct net_device *dev)
3011 {
3012 - struct r8180_priv *priv = (struct r8180_priv *)ieee80211_priv(dev);
3013 + struct r8180_priv *priv = (struct r8180_priv *)ieee80211_priv_rtl7(dev);
3014 u32 rxconf;
3015 -
3016 +
3017 rxconf=read_nic_dword(dev,RX_CONF);
3018 rxconf = rxconf &~ MAC_FILTER_MASK;
3019 rxconf = rxconf | (1<<ACCEPT_MNG_FRAME_SHIFT);
3020 rxconf = rxconf | (1<<ACCEPT_DATA_FRAME_SHIFT);
3021 rxconf = rxconf | (1<<ACCEPT_BCAST_FRAME_SHIFT);
3022 rxconf = rxconf | (1<<ACCEPT_MCAST_FRAME_SHIFT);
3023 - rxconf = rxconf | (1<<ACCEPT_CTL_FRAME_SHIFT);
3024 + rxconf = rxconf | (1<<ACCEPT_CTL_FRAME_SHIFT);
3025
3026 if (dev->flags & IFF_PROMISC) DMESG ("NIC in promisc mode");
3027 -
3028 +
3029 if(priv->ieee80211->iw_mode == IW_MODE_MONITOR || \
3030 dev->flags & IFF_PROMISC){
3031 rxconf = rxconf | (1<<ACCEPT_ALLMAC_FRAME_SHIFT);
3032 @@ -741,40 +771,40 @@
3033 rxconf = rxconf | (1<<ACCEPT_NICMAC_FRAME_SHIFT);
3034 rxconf = rxconf | (1<<RX_CHECK_BSSID_SHIFT);
3035 }
3036 -
3037 +
3038 /*if(priv->ieee80211->iw_mode == IW_MODE_MASTER){
3039 rxconf = rxconf | (1<<ACCEPT_ALLMAC_FRAME_SHIFT);
3040 rxconf = rxconf | (1<<RX_CHECK_BSSID_SHIFT);
3041 }*/
3042 -
3043 +
3044 if(priv->ieee80211->iw_mode == IW_MODE_MONITOR){
3045 rxconf = rxconf | (1<<ACCEPT_ICVERR_FRAME_SHIFT);
3046 rxconf = rxconf | (1<<ACCEPT_PWR_FRAME_SHIFT);
3047 }
3048 -
3049 +
3050 if( priv->crcmon == 1 && priv->ieee80211->iw_mode == IW_MODE_MONITOR)
3051 rxconf = rxconf | (1<<ACCEPT_CRCERR_FRAME_SHIFT);
3052 -
3053 -
3054 +
3055 +
3056 rxconf = rxconf &~ RX_FIFO_THRESHOLD_MASK;
3057 rxconf = rxconf | (RX_FIFO_THRESHOLD_NONE<<RX_FIFO_THRESHOLD_SHIFT);
3058 -
3059 -
3060 +
3061 +
3062 rxconf = rxconf | (1<<RX_AUTORESETPHY_SHIFT);
3063 -
3064 +
3065 rxconf = rxconf &~ MAX_RX_DMA_MASK;
3066 rxconf = rxconf | (MAX_RX_DMA_2048<<MAX_RX_DMA_SHIFT);
3067 -
3068 +
3069 rxconf = rxconf | RCR_ONLYERLPKT;
3070 -
3071 +
3072 // rxconf = rxconf &~ RCR_CS_MASK;
3073 // rxconf = rxconf | (1<<RCR_CS_SHIFT);
3074
3075 - write_nic_dword(dev, RX_CONF, rxconf);
3076 -
3077 + write_nic_dword(dev, RX_CONF, rxconf);
3078 +
3079 // V rtl suggested V //
3080 // write_nic_dword(dev, RX_CONF, 0x901ce70e);
3081 -
3082 +
3083 //fix_rx_fifo(dev);
3084 // //set_nic_rxring(dev);
3085 #ifdef DEBUG_RX
3086 @@ -785,23 +815,23 @@
3087 void rtl8180_rx_enable(struct net_device *dev)
3088 {
3089 u8 cmd;
3090 -
3091 -
3092 +
3093 +
3094 rtl8187_rx_initiate(dev);
3095
3096 - rtl8187_set_rxconf(dev);
3097 + rtl8187_set_rxconf(dev);
3098
3099 cmd=read_nic_byte(dev,CMD);
3100 write_nic_byte(dev,CMD,cmd | (1<<CMD_RX_ENABLE_SHIFT));
3101 #if 0
3102 - /* In rtl8139 driver seems that DMA threshold has to be written
3103 - * after enabling RX, so we rewrite RX_CONFIG register
3104 + /* In rtl8139 driver seems that DMA threshold has to be written
3105 + * after enabling RX, so we rewrite RX_CONFIG register
3106 */
3107 //mdelay(100);
3108 - write_nic_dword(dev, RX_CONF, rxconf);
3109 -
3110 + write_nic_dword(dev, RX_CONF, rxconf);
3111 +
3112 #endif
3113 -
3114 +
3115 }
3116
3117
3118 @@ -810,37 +840,37 @@
3119 u8 cmd;
3120 u8 byte;
3121 u32 txconf;
3122 - struct r8180_priv *priv = (struct r8180_priv *)ieee80211_priv(dev);
3123 -
3124 + struct r8180_priv *priv = (struct r8180_priv *)ieee80211_priv_rtl7(dev);
3125 +
3126 byte = read_nic_byte(dev,CW_CONF);
3127 byte &= ~(1<<CW_CONF_PERPACKET_CW_SHIFT);
3128 byte &= ~(1<<CW_CONF_PERPACKET_RETRY_SHIFT);
3129 write_nic_byte(dev, CW_CONF, byte);
3130 -
3131 +
3132 byte = read_nic_byte(dev, TX_AGC_CTL);
3133 byte &= ~(1<<TX_AGC_CTL_PERPACKET_GAIN_SHIFT);
3134 byte &= ~(1<<TX_AGC_CTL_PERPACKET_ANTSEL_SHIFT);
3135 byte &= ~(1<<TX_AGC_CTL_FEEDBACK_ANT);
3136 write_nic_byte(dev, TX_AGC_CTL, byte);
3137 -
3138 +
3139 txconf= read_nic_dword(dev,TX_CONF);
3140 -
3141 +
3142 #if 0
3143 if(priv->card_8185){
3144 -
3145 +
3146 txconf = txconf &~ (1<<TCR_PROBE_NOTIMESTAMP_SHIFT);
3147 -
3148 +
3149 }else{
3150 -
3151 - if(priv->ieee80211->hw_seq)
3152 +
3153 + if(priv->ieee80211->hw_seq)
3154 txconf= txconf &~ (1<<TX_CONF_HEADER_AUTOICREMENT_SHIFT);
3155 - else
3156 + else
3157 txconf= txconf | (1<<TX_CONF_HEADER_AUTOICREMENT_SHIFT);
3158 }
3159 #endif
3160
3161 txconf = txconf &~ TX_LOOPBACK_MASK;
3162 -
3163 +
3164 #ifndef LOOP_TEST
3165 txconf = txconf | (TX_LOOPBACK_NONE<<TX_LOOPBACK_SHIFT);
3166 #else
3167 @@ -848,23 +878,26 @@
3168 #endif
3169 txconf = txconf &~ TCR_DPRETRY_MASK;
3170 txconf = txconf &~ TCR_RTSRETRY_MASK;
3171 -
3172 - txconf = txconf | (priv->retry_data<<TX_DPRETRY_SHIFT); // long
3173 - txconf = txconf | (priv->retry_rts<<TX_RTSRETRY_SHIFT); // short
3174 -
3175 +
3176 + if(priv->ieee80211->iw_mode != IW_MODE_MONITOR)
3177 + {
3178 + txconf = txconf | (priv->retry_data<<TX_DPRETRY_SHIFT); // long
3179 + txconf = txconf | (priv->retry_rts<<TX_RTSRETRY_SHIFT); // short
3180 + }
3181 +
3182 txconf = txconf &~ (1<<TX_NOCRC_SHIFT);
3183 -
3184 +
3185 txconf = txconf &~ TCR_MXDMA_MASK;
3186 txconf = txconf | (TCR_MXDMA_2048<<TCR_MXDMA_SHIFT);
3187 -
3188 +
3189 txconf = txconf | TCR_CWMIN;
3190 txconf = txconf | TCR_DISCW;
3191 txconf = txconf &~ TCR_SWPLCPLEN;
3192 -
3193 +
3194 txconf=txconf | (1<<TX_NOICV_SHIFT);
3195 -
3196 +
3197 write_nic_dword(dev,TX_CONF,txconf);
3198 -
3199 +
3200 // V RTL suggested V //
3201 // write_nic_dword(dev,TX_CONF,0x00e00707);
3202
3203 @@ -872,9 +905,9 @@
3204 #ifdef DEBUG_TX
3205 DMESG("txconf: %x %x",txconf,read_nic_dword(dev,TX_CONF));
3206 #endif
3207 -
3208 +
3209 cmd=read_nic_byte(dev,CMD);
3210 - write_nic_byte(dev,CMD,cmd | (1<<CMD_TX_ENABLE_SHIFT));
3211 + write_nic_byte(dev,CMD,cmd | (1<<CMD_TX_ENABLE_SHIFT));
3212
3213 // mdelay(100);
3214 //write_nic_dword(dev,TX_CONF,txconf);
3215 @@ -889,18 +922,18 @@
3216 #if 0
3217 void rtl8180_beacon_tx_enable(struct net_device *dev)
3218 {
3219 - struct r8180_priv *priv = (struct r8180_priv *)ieee80211_priv(dev);
3220 + struct r8180_priv *priv = (struct r8180_priv *)ieee80211_priv_rtl7(dev);
3221 priv->dma_poll_mask &=~(1<<TX_DMA_STOP_BEACON_SHIFT);
3222 rtl8180_set_mode(dev,EPROM_CMD_CONFIG);
3223 - write_nic_byte(dev,TX_DMA_POLLING,priv->dma_poll_mask);
3224 + write_nic_byte(dev,TX_DMA_POLLING,priv->dma_poll_mask);
3225 rtl8180_set_mode(dev,EPROM_CMD_NORMAL);
3226 }
3227
3228
3229 void rtl8180_
3230 -_disable(struct net_device *dev)
3231 +_disable(struct net_device *dev)
3232 {
3233 - struct r8180_priv *priv = (struct r8180_priv *)ieee80211_priv(dev);
3234 + struct r8180_priv *priv = (struct r8180_priv *)ieee80211_priv_rtl7(dev);
3235 priv->dma_poll_mask |= (1<<TX_DMA_STOP_BEACON_SHIFT);
3236 rtl8180_set_mode(dev,EPROM_CMD_CONFIG);
3237 write_nic_byte(dev,TX_DMA_POLLING,priv->dma_poll_mask);
3238 @@ -914,8 +947,8 @@
3239 {
3240 u8 cmd;
3241 int i;
3242 - struct r8180_priv *priv = ieee80211_priv(dev);
3243 -
3244 + struct r8180_priv *priv = ieee80211_priv_rtl7(dev);
3245 +
3246 cmd=read_nic_byte(dev,CMD);
3247 write_nic_byte(dev, CMD, cmd &~ \
3248 ((1<<CMD_RX_ENABLE_SHIFT)|(1<<CMD_TX_ENABLE_SHIFT)));
3249 @@ -926,9 +959,9 @@
3250 usb_kill_urb(priv->rx_urb[i]);
3251 }
3252 /*while (read_nic_byte(dev,CMD) & (1<<CMD_RX_ENABLE_SHIFT))
3253 - udelay(10);
3254 + udelay(10);
3255 */
3256 -
3257 +
3258 // if(!priv->rx_skb_complete)
3259 // dev_kfree_skb_any(priv->rx_skb);
3260 }
3261 @@ -939,14 +972,14 @@
3262 #if 0
3263 int i;
3264 u32 *tmp;
3265 - struct r8180_priv *priv = (struct r8180_priv *)ieee80211_priv(dev);
3266 -
3267 + struct r8180_priv *priv = (struct r8180_priv *)ieee80211_priv_rtl7(dev);
3268 +
3269 priv->txbeaconring = (u32*)pci_alloc_consistent(priv->pdev,
3270 - sizeof(u32)*8*count,
3271 + sizeof(u32)*8*count,
3272 &priv->txbeaconringdma);
3273 if (!priv->txbeaconring) return -1;
3274 for (tmp=priv->txbeaconring,i=0;i<count;i++){
3275 - *tmp = *tmp &~ (1<<31); // descriptor empty, owned by the drv
3276 + *tmp = *tmp &~ (1<<31); // descriptor empty, owned by the drv
3277 /*
3278 *(tmp+2) = (u32)dma_tmp;
3279 *(tmp+3) = bufsize;
3280 @@ -955,7 +988,7 @@
3281 *(tmp+4) = (u32)priv->txbeaconringdma+((i+1)*8*4);
3282 else
3283 *(tmp+4) = (u32)priv->txbeaconringdma;
3284 -
3285 +
3286 tmp=tmp+8;
3287 }
3288 #endif
3289 @@ -965,15 +998,15 @@
3290
3291 void rtl8180_reset(struct net_device *dev)
3292 {
3293 -
3294 +
3295 u8 cr;
3296 -
3297 +
3298 /* make sure the analog power is on before
3299 * reset, otherwise reset may fail
3300 */
3301 rtl8180_set_anaparam(dev, RTL8225_ANAPARAM_ON);
3302 rtl8185_set_anaparam2(dev, RTL8225_ANAPARAM2_ON);
3303 -
3304 +
3305 rtl8180_irq_disable(dev);
3306
3307 mdelay(200);
3308 @@ -981,19 +1014,19 @@
3309 write_nic_byte_E(dev,0x18,0x11);
3310 write_nic_byte_E(dev,0x18,0x00);
3311 mdelay(200);
3312 -
3313 +
3314 cr=read_nic_byte(dev,CMD);
3315 cr = cr & 2;
3316 cr = cr | (1<<CMD_RST_SHIFT);
3317 write_nic_byte(dev,CMD,cr);
3318 -
3319 +
3320 force_pci_posting(dev);
3321 -
3322 +
3323 mdelay(200);
3324 -
3325 - if(read_nic_byte(dev,CMD) & (1<<CMD_RST_SHIFT))
3326 +
3327 + if(read_nic_byte(dev,CMD) & (1<<CMD_RST_SHIFT))
3328 DMESGW("Card reset timeout!");
3329 - else
3330 + else
3331 DMESG("Card successfully reset");
3332
3333 rtl8180_set_mode(dev,EPROM_CMD_LOAD);
3334 @@ -1005,13 +1038,13 @@
3335 */
3336 rtl8180_set_anaparam(dev, RTL8225_ANAPARAM_ON);
3337 rtl8185_set_anaparam2(dev, RTL8225_ANAPARAM2_ON);
3338 -
3339 +
3340 }
3341
3342 inline u16 ieeerate2rtlrate(int rate)
3343 {
3344 switch(rate){
3345 - case 10:
3346 + case 10:
3347 return 0;
3348 case 20:
3349 return 1;
3350 @@ -1037,32 +1070,42 @@
3351 return 11;
3352 default:
3353 return 3;
3354 -
3355 +
3356 }
3357 }
3358 static u16 rtl_rate[] = {10,20,55,110,60,90,120,180,240,360,480,540};
3359 inline u16 rtl8180_rate2rate(short rate)
3360 {
3361 if (rate >11) return 0;
3362 - return rtl_rate[rate];
3363 + return rtl_rate[rate];
3364 +}
3365 +
3366 +inline u8 rtl8180_IsWirelessBMode(u16 rate)
3367 +{
3368 + if( ((rate <= 110) && (rate != 60) && (rate != 90)) || (rate == 220) )
3369 + return 1;
3370 + else return 0;
3371 }
3372 -
3373
3374 +#if (LINUX_VERSION_CODE < KERNEL_VERSION(2,6,19))
3375 void rtl8187_rx_isr(struct urb *rx_urb, struct pt_regs *regs)
3376 +#else
3377 +void rtl8187_rx_isr(struct urb *rx_urb)
3378 +#endif
3379 {
3380 struct net_device *dev = (struct net_device*)rx_urb->context;
3381 - struct r8180_priv *priv = ieee80211_priv(dev);
3382 + struct r8180_priv *priv = ieee80211_priv_rtl7(dev);
3383
3384 priv->rxurb_task = rx_urb;
3385 // DMESGW("David: Rx tasklet start!");
3386 - tasklet_schedule(&priv->irq_rx_tasklet);
3387 + tasklet_schedule(&priv->irq_rx_tasklet);
3388 // DMESGW("=David: Rx tasklet finish!");
3389 }
3390
3391 #if 0
3392 void rtl8180_tx_queues_stop(struct net_device *dev)
3393 {
3394 - //struct r8180_priv *priv = (struct r8180_priv *)ieee80211_priv(dev);
3395 + //struct r8180_priv *priv = (struct r8180_priv *)ieee80211_priv_rtl7(dev);
3396 u8 dma_poll_mask = (1<<TX_DMA_STOP_LOWPRIORITY_SHIFT);
3397 dma_poll_mask |= (1<<TX_DMA_STOP_HIPRIORITY_SHIFT);
3398 dma_poll_mask |= (1<<TX_DMA_STOP_NORMPRIORITY_SHIFT);
3399 @@ -1078,7 +1121,7 @@
3400 {
3401 //FIXME !!
3402 #if 0
3403 - struct r8180_priv *priv = (struct r8180_priv *)ieee80211_priv(dev);
3404 + struct r8180_priv *priv = (struct r8180_priv *)ieee80211_priv_rtl7(dev);
3405 priv->dma_poll_mask |= (1<<TX_DMA_STOP_LOWPRIORITY_SHIFT);
3406 rtl8180_set_mode(dev,EPROM_CMD_CONFIG);
3407 write_nic_byte(dev,TX_DMA_POLLING,priv->dma_poll_mask);
3408 @@ -1091,7 +1134,7 @@
3409 {
3410 // FIXME !!
3411 #if 0
3412 - struct r8180_priv *priv = (struct r8180_priv *)ieee80211_priv(dev);
3413 + struct r8180_priv *priv = (struct r8180_priv *)ieee80211_priv_rtl7(dev);
3414 priv->dma_poll_mask &= ~(1<<TX_DMA_STOP_LOWPRIORITY_SHIFT);
3415 rtl8180_set_mode(dev,EPROM_CMD_CONFIG);
3416 write_nic_byte(dev,TX_DMA_POLLING,priv->dma_poll_mask);
3417 @@ -1105,14 +1148,19 @@
3418 */
3419 void rtl8180_hard_data_xmit(struct sk_buff *skb, struct net_device *dev, int rate)
3420 {
3421 - struct r8180_priv *priv = (struct r8180_priv *)ieee80211_priv(dev);
3422 -
3423 - short morefrag = 0;
3424 + struct r8180_priv *priv = (struct r8180_priv *)ieee80211_priv_rtl7(dev);
3425 +
3426 + short morefrag = 0;
3427 unsigned long flags;
3428 struct ieee80211_hdr *h = (struct ieee80211_hdr *) skb->data;
3429
3430 - if (le16_to_cpu(h->frame_ctl) & IEEE80211_FCTL_MOREFRAGS)
3431 - morefrag = 1;
3432 + if(priv->ieee80211->iw_mode != IW_MODE_MONITOR || priv->ieee80211->raw_tx != 1)
3433 + {
3434 + if (le16_to_cpu(h->frame_ctl) & IEEE80211_FCTL_MOREFRAGS)
3435 + {
3436 + morefrag = 1;
3437 + }
3438 + }
3439 // DMESG("%x %x", h->frame_ctl, h->seq_ctl);
3440 /*
3441 * This function doesn't require lock because we make
3442 @@ -1121,24 +1169,30 @@
3443 * the ieee stack, or from the try_wake_queue (again trought
3444 * the ieee stack.
3445 */
3446 - spin_lock_irqsave(&priv->tx_lock,flags);
3447 -
3448 - //DMESG("TX");
3449 - if (!check_nic_enought_desc(dev, LOW_PRIORITY)){
3450 - DMESG("Error: no TX slot ");
3451 - ieee80211_stop_queue(priv->ieee80211);
3452 + spin_lock_irqsave(&priv->tx_lock,flags);
3453 +
3454 + if(priv->ieee80211->iw_mode != IW_MODE_MONITOR)
3455 + {
3456 + //DMESG("TX");
3457 + if (!check_nic_enought_desc(dev, LOW_PRIORITY)){
3458 + DMESG("Error: no TX slot ");
3459 + ieee80211_stop_queue_rtl7(priv->ieee80211);
3460 + }
3461 }
3462 -
3463 +
3464 rtl8180_tx(dev, (u32*)skb->data, skb->len, LOW_PRIORITY, morefrag,
3465 ieeerate2rtlrate(rate));
3466
3467 - priv->stats.txdatapkt++;
3468 -
3469 - if (!check_nic_enought_desc(dev, LOW_PRIORITY))
3470 - ieee80211_stop_queue(priv->ieee80211);
3471 -
3472 - spin_unlock_irqrestore(&priv->tx_lock,flags);
3473 -
3474 + if(priv->ieee80211->iw_mode != IW_MODE_MONITOR)
3475 + {
3476 + priv->stats.txdatapkt++;
3477 +
3478 + if (!check_nic_enought_desc(dev, LOW_PRIORITY))
3479 + ieee80211_stop_queue_rtl7(priv->ieee80211);
3480 + }
3481 +
3482 + spin_unlock_irqrestore(&priv->tx_lock,flags);
3483 +
3484 }
3485 #if 0
3486 /* This is a rough attempt to TX a frame
3487 @@ -1148,12 +1202,12 @@
3488 */
3489 int rtl8180_hard_start_xmit(struct sk_buff *skb,struct net_device *dev)
3490 {
3491 - struct r8180_priv *priv = (struct r8180_priv *)ieee80211_priv(dev);
3492 + struct r8180_priv *priv = (struct r8180_priv *)ieee80211_priv_rtl7(dev);
3493 int ret;
3494 unsigned long flags;
3495 -
3496 +
3497 spin_lock_irqsave(&priv->tx_lock,flags);
3498 -
3499 +
3500 ret = rtl8180_tx(dev, (u32*)skb->data, skb->len, NORM_PRIORITY, 0,DEFAULT_BASICRATE);
3501 /*
3502 int i;
3503 @@ -1163,9 +1217,9 @@
3504 */
3505 priv->ieee80211->stats.tx_bytes+=skb->len;
3506 priv->ieee80211->stats.tx_packets++;
3507 -
3508 - spin_unlock_irqrestore(&priv->tx_lock,flags);
3509 -
3510 +
3511 + spin_unlock_irqrestore(&priv->tx_lock,flags);
3512 +
3513 dev_kfree_skb_any(skb);
3514 return ret;
3515 }
3516 @@ -1178,7 +1232,7 @@
3517 u16 duration;
3518 u16 drift;
3519 *ext=0;
3520 -
3521 +
3522 switch(rate){
3523 case 0://1mbps
3524 *ext=0;
3525 @@ -1187,7 +1241,7 @@
3526 if(drift ==0 ) break;
3527 duration++;
3528 break;
3529 -
3530 +
3531 case 1://2mbps
3532 *ext=0;
3533 duration = ((len+4)<<4) /0x4;
3534 @@ -1195,40 +1249,44 @@
3535 if(drift ==0 ) break;
3536 duration++;
3537 break;
3538 -
3539 +
3540 case 2: //5.5mbps
3541 *ext=0;
3542 duration = ((len+4)<<4) /0xb;
3543 drift = ((len+4)<<4) % 0xb;
3544 - if(drift ==0 )
3545 + if(drift ==0 )
3546 break;
3547 duration++;
3548 break;
3549 -
3550 +
3551 default:
3552 - case 3://11mbps
3553 + case 3://11mbps
3554 *ext=0;
3555 duration = ((len+4)<<4) /0x16;
3556 drift = ((len+4)<<4) % 0x16;
3557 - if(drift ==0 )
3558 + if(drift ==0 )
3559 break;
3560 duration++;
3561 - if(drift > 6)
3562 + if(drift > 6)
3563 break;
3564 *ext=1;
3565 break;
3566 }
3567 -
3568 +
3569 return duration;
3570 }
3571 #endif
3572
3573 void rtl8180_try_wake_queue(struct net_device *dev, int pri);
3574
3575 +#if (LINUX_VERSION_CODE < KERNEL_VERSION(2,6,19))
3576 void rtl8187_lptx_isr(struct urb *tx_urb, struct pt_regs *regs)
3577 +#else
3578 +void rtl8187_lptx_isr(struct urb *tx_urb)
3579 +#endif
3580 {
3581 struct net_device *dev = (struct net_device*)tx_urb->context;
3582 - struct r8180_priv *priv = ieee80211_priv(dev);
3583 + struct r8180_priv *priv = ieee80211_priv_rtl7(dev);
3584 if(tx_urb->status == 0)
3585 priv->stats.txlpokint++;
3586 else
3587 @@ -1249,55 +1307,55 @@
3588 if ((msrm == (MSR_LINK_ADHOC<<MSR_LINK_SHIFT) ||
3589 (msrm == (MSR_LINK_MASTER<<MSR_LINK_SHIFT)))){
3590 write_nic_byte(dev, MSR, msr2 | MSR_LINK_NONE);
3591 - write_nic_byte(dev, MSR, msr);
3592 + write_nic_byte(dev, MSR, msr);
3593 }
3594 -
3595 -
3596 +
3597 +
3598 }
3599
3600
3601 void rtl8187_net_update(struct net_device *dev)
3602 {
3603
3604 - struct r8180_priv *priv = ieee80211_priv(dev);
3605 + struct r8180_priv *priv = ieee80211_priv_rtl7(dev);
3606 struct ieee80211_network *net;
3607 net = & priv->ieee80211->current_network;
3608 -
3609 -
3610 +
3611 +
3612 write_nic_dword(dev,BSSID,((u32*)net->bssid)[0]);
3613 write_nic_word(dev,BSSID+4,((u16*)net->bssid)[2]);
3614 //for(i=0;i<ETH_ALEN;i++)
3615 // write_nic_byte(dev,BSSID+i,net->bssid[i]);
3616
3617 rtl8180_update_msr(dev);
3618 -
3619 +
3620 // rtl8180_set_mode(dev,EPROM_CMD_CONFIG);
3621 write_nic_word(dev, AtimWnd, 2);
3622 - write_nic_word(dev, AtimtrItv, 100);
3623 + write_nic_word(dev, AtimtrItv, 100);
3624 write_nic_word(dev, BEACON_INTERVAL, net->beacon_interval);
3625 write_nic_word(dev, BcnIntTime, 100);
3626 -
3627 +
3628
3629 }
3630
3631 void rtl8187_beacon_tx(struct net_device *dev)
3632 {
3633
3634 - struct r8180_priv *priv = ieee80211_priv(dev);
3635 + struct r8180_priv *priv = ieee80211_priv_rtl7(dev);
3636 struct sk_buff *skb;
3637 int i = 0;
3638 -
3639 +
3640 rtl8187_net_update(dev);
3641 -
3642 - skb = ieee80211_get_beacon(priv->ieee80211);
3643 -
3644 -
3645 - if(!skb){
3646 +
3647 + skb = ieee80211_get_beacon_rtl7(priv->ieee80211);
3648 +
3649 +
3650 + if(!skb){
3651 DMESG("not enought memory for allocating beacon");
3652 return;
3653 }
3654 -
3655 -#if 0
3656 +
3657 +#if 0
3658 while(MAX_TX_URB!=atomic_read(&priv->tx_np_pending)){
3659 msleep_interruptible_rtl(HZ/2);
3660 if(i++ > 20){
3661 @@ -1307,7 +1365,7 @@
3662 }
3663 #endif
3664 write_nic_byte(dev, BQREQ, read_nic_byte(dev, BQREQ) | (1<<7));
3665 -
3666 +
3667 i=0;
3668 //while(!read_nic_byte(dev,BQREQ & (1<<7)))
3669 while( (read_nic_byte(dev, BQREQ) & (1<<7)) == 0 )
3670 @@ -1318,31 +1376,38 @@
3671 return ;
3672 }
3673 }
3674 -
3675 +
3676 rtl8180_tx(dev, (u32*)skb->data, skb->len, NORM_PRIORITY,
3677 0, priv->ieee80211->basic_rate);
3678 -
3679 +
3680 }
3681
3682 +#if (LINUX_VERSION_CODE < KERNEL_VERSION(2,6,19))
3683 void rtl8187_nptx_isr(struct urb *tx_urb, struct pt_regs *regs)
3684 +#else
3685 +void rtl8187_nptx_isr(struct urb *tx_urb)
3686 +#endif
3687 {
3688 struct net_device *dev = (struct net_device*)tx_urb->context;
3689 - struct r8180_priv *priv = ieee80211_priv(dev);
3690 + struct r8180_priv *priv = ieee80211_priv_rtl7(dev);
3691 if(tx_urb->status == 0)
3692 priv->stats.txnpokint++;
3693 else
3694 priv->stats.txnperr++;
3695 kfree(tx_urb->transfer_buffer);
3696 usb_free_urb(tx_urb);
3697 - atomic_dec(&priv->tx_np_pending);
3698 + if(priv->ieee80211->iw_mode != IW_MODE_MONITOR)
3699 + {
3700 + atomic_dec(&priv->tx_np_pending);
3701 + }
3702 //rtl8180_try_wake_queue(dev,NORM_PRIORITY);
3703 }
3704
3705
3706 -/* This function do the real dirty work: it sends a TX command
3707 - * descriptor plus data URB
3708 +/* This function do the real dirty work: it sends a TX command
3709 + * descriptor plus data URB
3710 */
3711 -
3712 +
3713 short rtl8180_tx(struct net_device *dev, u32* txbuf, int len, priority_t priority,
3714 short morefrag, short rate)
3715 {
3716 @@ -1352,45 +1417,47 @@
3717 int pend ;
3718 int status;
3719 struct urb *tx_urb;
3720 - int urb_len;
3721 - struct r8180_priv *priv = ieee80211_priv(dev);
3722 + int urb_len;
3723 + struct r8180_priv *priv = ieee80211_priv_rtl7(dev);
3724 // int rate = ieeerate2rtlrate(priv->ieee80211->rate);
3725
3726 - pend = atomic_read((priority == NORM_PRIORITY)? &priv->tx_np_pending : &priv->tx_lp_pending);
3727 - /* we are locked here so the two atomic_read and inc are executed without interleaves */
3728 - if( pend > MAX_TX_URB){
3729 - if(priority == NORM_PRIORITY)
3730 - priv->stats.txnpdrop++;
3731 - else
3732 - priv->stats.txlpdrop++;
3733 - return -1;
3734 + if(priv->ieee80211->iw_mode != IW_MODE_MONITOR)
3735 + {
3736 + pend = atomic_read((priority == NORM_PRIORITY)? &priv->tx_np_pending : &priv->tx_lp_pending);
3737 + /* we are locked here so the two atomic_read and inc are executed without interleaves */
3738 + if( pend > MAX_TX_URB){
3739 + if(priority == NORM_PRIORITY)
3740 + priv->stats.txnpdrop++;
3741 + else
3742 + priv->stats.txlpdrop++;
3743 + return -1;
3744 + }
3745 }
3746 -
3747 -
3748 +
3749 //tx = kmalloc((len + 4*3), GFP_ATOMIC);
3750 urb_len = len + 4*3;
3751 if((0 == urb_len%64)||(0 == urb_len%512)) {
3752 - urb_len += 1;
3753 + urb_len += 1;
3754 }
3755 tx = kmalloc(urb_len, GFP_ATOMIC);
3756 if(!tx) return -ENOMEM;
3757 - //printk(KERN_WARNING "urb_len = %d\n", urb_len);
3758 + //printk(KERN_WARNING "urb_len = %d\n", urb_len);
3759 tx_urb = usb_alloc_urb(0,GFP_ATOMIC);
3760 -
3761 +
3762 if(!tx_urb){
3763 -
3764 +
3765 kfree(tx);
3766 return -ENOMEM;
3767 }
3768 -
3769 +
3770 memcpy(tx+3,txbuf,len);
3771 tx[0] = 0;
3772 tx[0] |= len & 0xfff;
3773 tx[0] |= (1<<15);
3774 -
3775 +
3776 // if(priv->shortpre)
3777 // tx[0] |= (1<<16);
3778 -
3779 +
3780 //if(len > priv->rts_threshold){
3781 // tx[0] |= (1<<23); //ENABLE RTS
3782 // tx[0] |= (1<<18); //ENABLE CTS
3783 @@ -1399,18 +1466,18 @@
3784 tx[0] |= (ieeerate2rtlrate(priv->ieee80211->basic_rate) << 19); /* RTS RATE - should be basic rate */
3785 tx[0] |= (rate << 24);
3786 tx[1] = 0;
3787 -
3788 +
3789 // duration = rtl8180_len2duration(len,
3790 -// rate,&ext);
3791 +// rate,&ext);
3792 // tx[1] |= (duration & 0x7fff) <<16;
3793 // if(ext) tx[1] |= (1<<31);
3794
3795 -
3796 +
3797 // tx[2] = 0x303020;
3798 tx[2] = 3; // CW min
3799 tx[2] |= (7<<4); //CW max
3800 tx[2] |= (11<<8);//(priv->retry_data<<8); //retry lim
3801 -
3802 +
3803 // printk("%x\n%x\n",tx[0],tx[1]);
3804
3805 #ifdef DUMP_TX
3806 @@ -1421,71 +1488,77 @@
3807 printk("---------------\n");
3808 #endif
3809
3810 -
3811 +
3812 /* FIXME check what EP is for low/norm PRI */
3813 usb_fill_bulk_urb(tx_urb,priv->udev,
3814 usb_sndbulkpipe(priv->udev,(priority == LOW_PRIORITY) ? 2:3), tx,
3815 urb_len, (priority == LOW_PRIORITY)?rtl8187_lptx_isr:rtl8187_nptx_isr, dev);
3816 status = usb_submit_urb(tx_urb, GFP_ATOMIC);
3817 if (!status){
3818 - atomic_inc((priority == NORM_PRIORITY)? &priv->tx_np_pending : &priv->tx_lp_pending);
3819 + if(priv->ieee80211->iw_mode != IW_MODE_MONITOR)
3820 + {
3821 + atomic_inc((priority == NORM_PRIORITY)? &priv->tx_np_pending : &priv->tx_lp_pending);
3822 + }
3823 return 0;
3824 }else{
3825 - DMESGE("Error TX URB %d, error %d",
3826 - atomic_read((priority == NORM_PRIORITY)? &priv->tx_np_pending : &priv->tx_lp_pending),
3827 - status);
3828 + if(priv->ieee80211->iw_mode != IW_MODE_MONITOR)
3829 + {
3830 + DMESGE("Error TX URB %d, error %d",
3831 + atomic_read((priority == NORM_PRIORITY)? &priv->tx_np_pending : &priv->tx_lp_pending),
3832 + status);
3833 + }
3834 return -1;
3835 }
3836 }
3837
3838 -
3839 +
3840
3841 void rtl8180_irq_rx_tasklet(struct r8180_priv * priv);
3842
3843
3844 short rtl8187_usb_initendpoints(struct net_device *dev)
3845 {
3846 - struct r8180_priv *priv = ieee80211_priv(dev);
3847 + struct r8180_priv *priv = ieee80211_priv_rtl7(dev);
3848 int i;
3849 -
3850 +
3851 priv->rx_urb = (struct urb**) kmalloc (sizeof(struct urb*) * MAX_RX_URB, GFP_KERNEL);
3852 -
3853 +
3854 for(i=0;i<MAX_RX_URB;i++){
3855 priv->rx_urb[i] = usb_alloc_urb(0,GFP_KERNEL);
3856 - if(!priv->rx_urb[i])
3857 + if(!priv->rx_urb[i])
3858 goto destroy;
3859 -
3860 +
3861 priv->rx_urb[i]->transfer_buffer = kmalloc(RX_URB_SIZE, GFP_KERNEL);
3862 - if(!priv->rx_urb[i]->transfer_buffer)
3863 + if(!priv->rx_urb[i]->transfer_buffer)
3864 goto destroy1;
3865 -
3866 +
3867 priv->rx_urb[i]->transfer_buffer_length = RX_URB_SIZE;
3868 }
3869 -
3870 +
3871 return 0;
3872 -
3873 +
3874 destroy1:
3875 usb_free_urb(priv->rx_urb[i]);
3876 -
3877 +
3878 destroy:
3879 while (--i >= 0){
3880 kfree(priv->rx_urb[i]->transfer_buffer);
3881 usb_free_urb(priv->rx_urb[i]);
3882 }
3883 -
3884 +
3885 kfree(priv->rx_urb);
3886 -
3887 +
3888 priv->rx_urb = NULL;
3889 DMESGE("Endpoint Alloc Failure");
3890 return -ENOMEM;
3891 -
3892 +
3893 }
3894
3895 void rtl8187_usb_deleteendpoints(struct net_device *dev)
3896 {
3897 - struct r8180_priv *priv = ieee80211_priv(dev);
3898 + struct r8180_priv *priv = ieee80211_priv_rtl7(dev);
3899 int i;
3900 -
3901 +
3902 if(priv->rx_urb){
3903 for(i=0;i<MAX_RX_URB;i++){
3904 usb_kill_urb(priv->rx_urb[i]);
3905 @@ -1494,9 +1567,9 @@
3906 }
3907 kfree(priv->rx_urb);
3908 priv->rx_urb = NULL;
3909 -
3910 +
3911 }
3912 -
3913 +
3914 }
3915
3916
3917 @@ -1505,16 +1578,16 @@
3918 int i;
3919 u16 word;
3920 int basic_rate,min_rr_rate,max_rr_rate;
3921 -
3922 -// struct r8180_priv *priv = ieee80211_priv(dev);
3923 -
3924 - //if (ieee80211_is_54g(priv->ieee80211->current_network) &&
3925 +
3926 +// struct r8180_priv *priv = ieee80211_priv_rtl7(dev);
3927 +
3928 + //if (ieee80211_is_54g_rtl7(priv->ieee80211->current_network) &&
3929 // priv->ieee80211->state == IEEE80211_LINKED){
3930 basic_rate = ieeerate2rtlrate(240);
3931 min_rr_rate = ieeerate2rtlrate(60);
3932 max_rr_rate = ieeerate2rtlrate(240);
3933 -
3934 -//
3935 +
3936 +//
3937 // }else{
3938 // basic_rate = ieeerate2rtlrate(20);
3939 // min_rr_rate = ieeerate2rtlrate(10);
3940 @@ -1526,21 +1599,21 @@
3941
3942 word = read_nic_word(dev, BRSR);
3943 word &= ~BRSR_MBR_8185;
3944 -
3945 +
3946
3947 for(i=0;i<=basic_rate;i++)
3948 word |= (1<<i);
3949
3950 write_nic_word(dev, BRSR, word);
3951 - //DMESG("RR:%x BRSR: %x", read_nic_byte(dev,RESP_RATE), read_nic_word(dev,BRSR));
3952 + DMESG("RR:%x BRSR: %x", read_nic_byte(dev,RESP_RATE), read_nic_word(dev,BRSR));
3953 }
3954
3955
3956 void rtl8187_link_change(struct net_device *dev)
3957 {
3958 // int i;
3959 -
3960 - struct r8180_priv *priv = ieee80211_priv(dev);
3961 +
3962 + struct r8180_priv *priv = ieee80211_priv_rtl7(dev);
3963 //write_nic_word(dev, BintrItv, net->beacon_interval);
3964 rtl8187_net_update(dev);
3965 /*update timing params*/
3966 @@ -1553,24 +1626,24 @@
3967
3968 short rtl8180_init(struct net_device *dev)
3969 {
3970 -
3971 - struct r8180_priv *priv = ieee80211_priv(dev);
3972 +
3973 + struct r8180_priv *priv = ieee80211_priv_rtl7(dev);
3974 int i, j;
3975 u16 word;
3976 - int ch;
3977 + int ch, chans;
3978 //u16 version;
3979 - //u8 hw_version;
3980 - //u8 config3;
3981 -
3982 + u8 hw_version;
3983 + u8 config3;
3984 +
3985 //FIXME: these constants are placed in a bad pleace.
3986
3987 // priv->txbuffsize = 1024;
3988 // priv->txringcount = 32;
3989 // priv->rxbuffersize = 1024;
3990 -// priv->rxringcount = 32;
3991 +// priv->rxringcount = 32;
3992 // priv->txbeaconcount = 3;
3993 // priv->rx_skb_complete = 1;
3994 - //priv->txnp_pending.ispending=0;
3995 + //priv->txnp_pending.ispending=0;
3996 /* ^^ the SKB does not containt a partial RXed
3997 * packet (is empty)
3998 */
3999 @@ -1580,15 +1653,24 @@
4000 return -1;
4001 }
4002 ch=channels;
4003 + chans=0;
4004 + for (i=1; i<=14; i++) {
4005 + if( (u8)(ch & 0x01) ) chans++;
4006 + ch >>= 1;
4007 + }
4008 + DMESG("Enabling %d channels.", chans);
4009 + ch=channels;
4010 // set channels 1..14 allowed in given locale
4011 for (i=1; i<=14; i++) {
4012 (priv->ieee80211->channel_map)[i] = (u8)(ch & 0x01);
4013 ch >>= 1;
4014 }
4015 //memcpy(priv->stats,0,sizeof(struct Stats));
4016 -
4017 +
4018 //priv->irq_enabled=0;
4019 -
4020 +
4021 + priv->dev = dev;
4022 +
4023 // priv->stats.rxdmafail=0;
4024 priv->stats.txrdu=0;
4025 // priv->stats.rxrdu=0;
4026 @@ -1612,33 +1694,37 @@
4027 // priv->stats.txbeaconerr=0;
4028 priv->stats.txlperr=0;
4029 priv->stats.txlpokint=0;
4030 -
4031 +
4032 priv->ieee80211->iw_mode = IW_MODE_INFRA;
4033 -
4034 +
4035 priv->retry_rts = DEFAULT_RETRY_RTS;
4036 priv->retry_data = DEFAULT_RETRY_DATA;
4037 priv->ieee80211->rate = 110; //11 mbps
4038 priv->ieee80211->short_slot = 1;
4039 - priv->ieee80211->mode = IEEE_G;
4040 + priv->ieee80211->mode = IEEE_G|IEEE_B;
4041 priv->promisc = (dev->flags & IFF_PROMISC) ? 1:0;
4042 spin_lock_init(&priv->tx_lock);
4043 +#if LINUX_VERSION_CODE < KERNEL_VERSION(2,6,20)
4044 INIT_WORK(&priv->reset_wq,(void(*)(void*)) rtl8180_restart,dev);
4045 +#else
4046 + INIT_WORK(&priv->reset_wq, rtl8180_restart);
4047 +#endif
4048 sema_init(&priv->wx_sem,1);
4049 tasklet_init(&priv->irq_rx_tasklet,
4050 (void(*)(unsigned long))rtl8180_irq_rx_tasklet,
4051 (unsigned long)priv);
4052
4053 - //priv->ieee80211->func =
4054 + //priv->ieee80211->func =
4055 // kmalloc(sizeof(struct ieee80211_helper_functions),GFP_KERNEL);
4056 //memset(priv->ieee80211->func, 0,
4057 // sizeof(struct ieee80211_helper_functions));
4058 - priv->ieee80211->current_network.beacon_interval = DEFAULT_BEACONINTERVAL;
4059 + priv->ieee80211->current_network.beacon_interval = DEFAULT_BEACONINTERVAL;
4060 priv->ieee80211->iw_mode = IW_MODE_INFRA;
4061 - priv->ieee80211->softmac_features = IEEE_SOFTMAC_SCAN |
4062 - IEEE_SOFTMAC_ASSOCIATE | IEEE_SOFTMAC_PROBERQ |
4063 + priv->ieee80211->softmac_features = IEEE_SOFTMAC_SCAN |
4064 + IEEE_SOFTMAC_ASSOCIATE | IEEE_SOFTMAC_PROBERQ |
4065 IEEE_SOFTMAC_PROBERS | IEEE_SOFTMAC_TX_QUEUE |
4066 /*IEEE_SOFTMAC_BEACONS | */IEEE_SOFTMAC_SINGLE_QUEUE;
4067 -
4068 +
4069 priv->ieee80211->active_scan = 1;
4070 priv->ieee80211->rate = 110; //11 mbps
4071 priv->ieee80211->modulation = IEEE80211_CCK_MODULATION | IEEE80211_OFDM_MODULATION;
4072 @@ -1655,51 +1741,51 @@
4073 priv->ieee80211->data_hard_resume = rtl8180_data_hard_resume;
4074 //priv->ieee80211->start_send_beacons = NULL;
4075 //priv->ieee80211->stop_send_beacons = NULL;
4076 -
4077 +
4078 priv->ieee80211->fts = DEFAULT_FRAG_THRESHOLD;
4079 -
4080 +
4081 priv->card_8185 = 2;
4082 priv->phy_ver = 2;
4083 priv->card_type = USB;
4084 -
4085 +
4086 #if 0
4087 hw_version =( read_nic_dword(dev, TCR) & TCR_HWVERID_MASK)>>TCR_HWVERID_SHIFT;
4088 -
4089 +
4090 switch (hw_version){
4091 case HW_VERID_R8185_ABC:
4092 - DMESG("MAC controller is a RTL8185 b/g");
4093 + DMESG("MAC controller is a RTL8185 b/g");
4094 priv->card_8185 = 1;
4095 /* you should not find a card with 8225 PHY ver < C*/
4096 priv->phy_ver = 2;
4097 break;
4098 -
4099 +
4100 case HW_VERID_R8185_D:
4101 - DMESG("MAC controller is a RTL8185 b/g (V. D)");
4102 + DMESG("MAC controller is a RTL8185 b/g (V. D)");
4103 priv->card_8185 = 2;
4104 /* you should not find a card with 8225 PHY ver < C*/
4105 priv->phy_ver = 2;
4106 break;
4107 -
4108 +
4109 case HW_VERID_R8180_ABCD:
4110 DMESG("MAC controller is a RTL8180");
4111 priv->card_8185 = 0;
4112 break;
4113 -
4114 +
4115 case HW_VERID_R8180_F:
4116 DMESG("MAC controller is a RTL8180 (v. F)");
4117 priv->card_8185 = 0;
4118 break;
4119 -
4120 +
4121 default:
4122 DMESGW("MAC chip not recognized: version %x. Assuming RTL8180",hw_version);
4123 priv->card_8185 = 0;
4124 break;
4125 }
4126 -
4127 -
4128 +
4129 +
4130 /* you should not found any 8185 Ver B Card */
4131 priv->card_8185_Bversion = 0;
4132 -
4133 +
4134 config3 = read_nic_byte(dev, CONFIG3);
4135 if(config3 & 0x8){
4136 priv->card_type = CARDBUS;
4137 @@ -1715,13 +1801,19 @@
4138 #endif
4139 priv->enable_gpio0 = 0;
4140
4141 -
4142 +
4143 + hw_version =( read_nic_dword(dev, TCR) & TCR_HWVERID_MASK)>>TCR_HWVERID_SHIFT;
4144 + config3 = read_nic_byte(dev, CONFIG3);
4145 +
4146 + DMESG("MAC chip version: %02X", hw_version);
4147 + DMESG("Card type: %02X", config3);
4148 +
4149 /* commented out just because we already do
4150 this when resetting the card
4151 andrea 20050924
4152 */
4153 #if 0
4154 -
4155 +
4156 u8 txcr, txreg50;
4157 u32 txreg54, txreg60;
4158
4159 @@ -1757,8 +1849,8 @@
4160 // DMESG("<<txcr:%x>>", txcr);
4161
4162 #endif
4163 -
4164 - /*the eeprom type is stored in RCR register bit #6 */
4165 +
4166 + /*the eeprom type is stored in RCR register bit #6 */
4167 if (RCR_9356SEL & read_nic_dword(dev, RCR)){
4168 priv->epromtype=EPROM_93c56;
4169 DMESG("Reported EEPROM chip is a 93c56 (2Kbit)");
4170 @@ -1766,58 +1858,73 @@
4171 priv->epromtype=EPROM_93c46;
4172 DMESG("Reported EEPROM chip is a 93c46 (1Kbit)");
4173 }
4174 -
4175 +
4176 dev->get_stats = rtl8180_stats;
4177 -
4178 +
4179 dev->dev_addr[0]=eprom_read(dev,MAC_ADR) & 0xff;
4180 dev->dev_addr[1]=(eprom_read(dev,MAC_ADR) & 0xff00)>>8;
4181 dev->dev_addr[2]=eprom_read(dev,MAC_ADR+1) & 0xff;
4182 dev->dev_addr[3]=(eprom_read(dev,MAC_ADR+1) & 0xff00)>>8;
4183 dev->dev_addr[4]=eprom_read(dev,MAC_ADR+2) & 0xff;
4184 dev->dev_addr[5]=(eprom_read(dev,MAC_ADR+2) & 0xff00)>>8;
4185 -
4186 +
4187 DMESG("Card MAC address is "MAC_FMT, MAC_ARG(dev->dev_addr));
4188 -
4189 +
4190 for(i=1,j=0; i<6; i+=2,j++){
4191 -
4192 +
4193 word = eprom_read(dev,EPROM_TXPW0 + j);
4194 priv->chtxpwr[i]=word & 0xf;
4195 priv->chtxpwr_ofdm[i]=(word & 0xf0)>>4;
4196 priv->chtxpwr[i+1]=(word & 0xf00)>>8;
4197 priv->chtxpwr_ofdm[i+1]=(word & 0xf000)>>12;
4198 }
4199 -
4200 +
4201 for(i=1,j=0; i<4; i+=2,j++){
4202 -
4203 +
4204 word = eprom_read(dev,EPROM_TXPW1 + j);
4205 priv->chtxpwr[i+6]=word & 0xf;
4206 priv->chtxpwr_ofdm[i+6]=(word & 0xf0)>>4;
4207 priv->chtxpwr[i+6+1]=(word & 0xf00)>>8;
4208 priv->chtxpwr_ofdm[i+6+1]=(word & 0xf000)>>12;
4209 }
4210 -
4211 +
4212 for(i=1,j=0; i<4; i+=2,j++){
4213 -
4214 +
4215 word = eprom_read(dev,EPROM_TXPW2 + j);
4216 priv->chtxpwr[i+6+4]=word & 0xf;
4217 priv->chtxpwr_ofdm[i+6+4]=(word & 0xf0)>>4;
4218 priv->chtxpwr[i+6+4+1]=(word & 0xf00)>>8;
4219 priv->chtxpwr_ofdm[i+6+4+1]=(word & 0xf000)>>12;
4220 }
4221 -
4222 -
4223 +
4224 +
4225 priv->rf_chip = 0xff & eprom_read(dev,EPROM_RFCHIPID);
4226 -
4227 +
4228 +#ifdef DEBUG_TX_POWER
4229 + dump_tx_power(dev);
4230 +#endif
4231 +
4232 + DMESG("RF Chip ID: %02X", priv->rf_chip);
4233 +
4234 word = eprom_read(dev,EPROM_TXPW_BASE);
4235 priv->cck_txpwr_base = word & 0xf;
4236 priv->ofdm_txpwr_base = (word>>4) & 0xf;
4237 -
4238 +
4239 + priv->txpwr_max = 0;
4240 + for(i=1; i<15; i++)
4241 + {
4242 + if(priv->chtxpwr[i] > priv->txpwr_max) priv->txpwr_max = priv->chtxpwr[i];
4243 + if(priv->chtxpwr_ofdm[i] > priv->txpwr_max) priv->txpwr_max = priv->chtxpwr_ofdm[i];
4244 + priv->chtxpwr_orig[i] = priv->chtxpwr[i];
4245 + priv->chtxpwr_ofdm_orig[i] = priv->chtxpwr_ofdm[i];
4246 + }
4247 +
4248 /* check RF frontend chipset */
4249 -
4250 +
4251 switch (priv->rf_chip) {
4252 -
4253 +
4254 case EPROM_RFCHIPID_RTL8225U:
4255 -
4256 +
4257 DMESG("Card reports RF frontend Realtek 8225");
4258 DMESGW("This driver has EXPERIMENTAL support for this chipset.");
4259 DMESGW("use it with care and at your own risk and");
4260 @@ -1834,28 +1941,28 @@
4261 DMESG("This seems a legacy 1st version radio");
4262 }
4263 priv->rf_close = rtl8225_rf_close;
4264 -
4265 +
4266 priv->max_sens = RTL8225_RF_MAX_SENS;
4267 priv->sens = RTL8225_RF_DEF_SENS;
4268 break;
4269 -
4270 +
4271 default:
4272 DMESGW("Unknown RF module %x",priv->rf_chip);
4273 DMESGW("Exiting...");
4274 return -1;
4275 -
4276 +
4277 }
4278 -
4279 +
4280 // DMESG("Energy threshold: %x",priv->cs_treshold);
4281 DMESG("PAPE from CONFIG2: %x",read_nic_byte(dev,CONFIG2)&0x7);
4282 //DMESG("CONFIG2: %x ECONFIG2: %x",read_nic_byte(dev,CONFIG2),eprom_read(dev,EPROM_CONFIG2));
4283 -
4284 - if(rtl8187_usb_initendpoints(dev)!=0){
4285 +
4286 + if(rtl8187_usb_initendpoints(dev)!=0){
4287 DMESG("Endopoints initialization failed");
4288 return -ENOMEM;
4289 }
4290 -#if 0
4291 - if (0!=alloc_rx_desc_ring(dev, priv->rxbuffersize, priv->rxringcount))
4292 +#if 0
4293 + if (0!=alloc_rx_desc_ring(dev, priv->rxbuffersize, priv->rxringcount))
4294 return -ENOMEM;
4295
4296 if (0!=alloc_tx_desc_ring(dev, priv->txbuffsize, priv->txringcount,
4297 @@ -1869,16 +1976,16 @@
4298 if (0!=alloc_tx_desc_ring(dev, priv->txbuffsize, priv->txringcount,
4299 TX_LOWPRIORITY_RING_ADDR))
4300 return -ENOMEM;
4301 -
4302 -
4303 +
4304 +
4305 if (0!=alloc_tx_beacon_desc_ring(dev, priv->txbeaconcount))
4306 return -ENOMEM;
4307 #endif
4308 -
4309 +
4310
4311 #ifdef DEBUG_EPROM
4312 dump_eprom(dev);
4313 -#endif
4314 +#endif
4315 return 0;
4316
4317 }
4318 @@ -1898,7 +2005,7 @@
4319 rtl8180_set_mode(dev, EPROM_CMD_CONFIG);
4320
4321 conf3 = read_nic_byte(dev, CONFIG3);
4322 - write_nic_byte(dev, CONFIG3, conf3 | (1<<CONFIG3_ANAPARAM_W_SHIFT));
4323 + write_nic_byte(dev, CONFIG3, conf3 | (1<<CONFIG3_ANAPARAM_W_SHIFT));
4324
4325 write_nic_dword(dev, ANAPARAM2, a);
4326
4327 @@ -1918,23 +2025,23 @@
4328
4329 conf3 = read_nic_byte(dev, CONFIG3);
4330 write_nic_byte(dev, CONFIG3, conf3 | (1<<CONFIG3_ANAPARAM_W_SHIFT));
4331 -
4332 +
4333 write_nic_dword(dev, ANAPARAM, a);
4334
4335 conf3 = read_nic_byte(dev, CONFIG3);
4336 write_nic_byte(dev, CONFIG3, conf3 &~(1<<CONFIG3_ANAPARAM_W_SHIFT));
4337
4338 rtl8180_set_mode(dev, EPROM_CMD_NORMAL);
4339 -
4340 +
4341 }
4342
4343
4344 void rtl8185_tx_antenna(struct net_device *dev, u8 ant)
4345 {
4346 - write_nic_byte(dev, TX_ANTENNA, ant);
4347 + write_nic_byte(dev, TX_ANTENNA, ant);
4348 force_pci_posting(dev);
4349 mdelay(1);
4350 -}
4351 +}
4352
4353
4354 void rtl8187_write_phy(struct net_device *dev, u8 adr, u32 data)
4355 @@ -1942,26 +2049,26 @@
4356 //u8 phyr;
4357 u32 phyw;
4358 // int i;
4359 -
4360 +
4361 adr |= 0x80;
4362 -
4363 +
4364 phyw= ((data<<8) | adr);
4365 -
4366 -
4367 -
4368 - // Note that, we must write 0xff7c after 0x7d-0x7f to write BB register.
4369 +
4370 +
4371 +
4372 + // Note that, we must write 0xff7c after 0x7d-0x7f to write BB register.
4373 write_nic_byte(dev, 0x7f, ((phyw & 0xff000000) >> 24));
4374 write_nic_byte(dev, 0x7e, ((phyw & 0x00ff0000) >> 16));
4375 write_nic_byte(dev, 0x7d, ((phyw & 0x0000ff00) >> 8));
4376 write_nic_byte(dev, 0x7c, ((phyw & 0x000000ff) ));
4377
4378 //read_nic_dword(dev, PHY_ADR);
4379 -#if 0
4380 +#if 0
4381 for(i=0;i<10;i++){
4382 write_nic_dword(dev, PHY_ADR, 0xffffff7f & phyw);
4383 phyr = read_nic_byte(dev, PHY_READ);
4384 if(phyr == (data&0xff)) break;
4385 -
4386 +
4387 }
4388 #endif
4389 /* this is ok to fail when we write AGC table. check for AGC table might be
4390 @@ -1988,60 +2095,60 @@
4391
4392 void rtl8180_adapter_start(struct net_device *dev)
4393 {
4394 - struct r8180_priv *priv = ieee80211_priv(dev);
4395 + struct r8180_priv *priv = ieee80211_priv_rtl7(dev);
4396 //u32 anaparam;
4397 //u8 config3;
4398 -
4399 +
4400 //rtl8180_rtx_disable(dev);
4401 rtl8180_reset(dev);
4402
4403 write_nic_byte(dev,0x85,0);
4404 write_nic_byte(dev,0x91,0);
4405 -
4406 +
4407 /* light blink! */
4408 write_nic_byte(dev,0x85,4);
4409 write_nic_byte(dev,0x91,1);
4410 write_nic_byte(dev,0x90,0);
4411 -
4412 +
4413 priv->irq_mask = 0xffff;
4414 /*
4415 priv->dma_poll_mask = 0;
4416 priv->dma_poll_mask|= (1<<TX_DMA_STOP_BEACON_SHIFT);
4417 -*/
4418 +*/
4419 // rtl8180_beacon_tx_disable(dev);
4420 -
4421 +
4422 rtl8180_set_mode(dev, EPROM_CMD_CONFIG);
4423 write_nic_dword(dev, MAC0, ((u32*)dev->dev_addr)[0]);
4424 write_nic_word(dev, MAC4, ((u32*)dev->dev_addr)[1] & 0xffff );
4425
4426 rtl8180_set_mode(dev, EPROM_CMD_NORMAL);
4427 rtl8180_update_msr(dev);
4428 -
4429 +
4430 rtl8180_set_mode(dev, EPROM_CMD_CONFIG);
4431 -
4432 +
4433 write_nic_word(dev,0xf4,0xffff);
4434 write_nic_byte(dev,
4435 - CONFIG1, (read_nic_byte(dev,CONFIG1) & 0x3f) | 0x80);
4436 + CONFIG1, (read_nic_byte(dev,CONFIG1) & 0x3f) | 0x80);
4437
4438 rtl8180_set_mode(dev,EPROM_CMD_NORMAL);
4439 -
4440 - write_nic_dword(dev,INT_TIMEOUT,0);
4441 +
4442 + write_nic_dword(dev,INT_TIMEOUT,0);
4443
4444 #ifdef DEBUG_REGISTERS
4445 - rtl8180_dump_reg(dev);
4446 + rtl8180_dump_reg(dev);
4447 #endif
4448 -
4449 -
4450 - write_nic_byte(dev, WPA_CONFIG, 0);
4451 +
4452 +
4453 + write_nic_byte(dev, WPA_CONFIG, 0);
4454
4455 write_nic_byte(dev, RATE_FALLBACK, 0x81);
4456 rtl8187_set_rate(dev);
4457 -
4458 - priv->rf_init(dev);
4459 +
4460 + priv->rf_init(dev);
4461
4462 if(priv->rf_set_sens != NULL)
4463 - priv->rf_set_sens(dev,priv->sens);
4464 -
4465 + priv->rf_set_sens(dev,priv->sens);
4466 +
4467 write_nic_word(dev,0x5e,1);
4468
4469 #if 1
4470 @@ -2054,13 +2161,13 @@
4471 write_nic_byte(dev, 0xff, 0x60);
4472
4473 write_nic_word(dev,0x5e,0);
4474 -
4475 -
4476 +
4477 +
4478 rtl8180_irq_enable(dev);
4479 /*DMESG ("lfree %d",get_curr_tx_free_desc(dev,LOW_PRIORITY));
4480 -
4481 +
4482 DMESG ("nfree %d",get_curr_tx_free_desc(dev,NORM_PRIORITY));
4483 -
4484 +
4485 DMESG ("hfree %d",get_curr_tx_free_desc(dev,HI_PRIORITY));
4486 if(check_nic_enought_desc(dev,NORM_PRIORITY)) DMESG("NORM OK");
4487 if(check_nic_enought_desc(dev,HI_PRIORITY)) DMESG("HI OK");
4488 @@ -2077,8 +2184,8 @@
4489 void rtl8180_start_tx_beacon(struct net_device *dev)
4490 {
4491 int i;
4492 - struct r8180_priv *priv = (struct r8180_priv *)ieee80211_priv(dev);
4493 - u16 word;
4494 + struct r8180_priv *priv = (struct r8180_priv *)ieee80211_priv_rtl7(dev);
4495 + u16 word;
4496 DMESG("Enabling beacon TX");
4497 //write_nic_byte(dev, 0x42,0xe6);// TCR
4498 //rtl8180_init_beacon(dev);
4499 @@ -2091,41 +2198,41 @@
4500 //write_nic_word(dev,0x7a,0);
4501 //write_nic_word(dev,0x7a,0x8000);
4502
4503 -
4504 +
4505 word = read_nic_word(dev, BcnItv);
4506 word &= ~BcnItv_BcnItv; // clear Bcn_Itv
4507 write_nic_word(dev, BcnItv, word);
4508
4509 - write_nic_word(dev, AtimWnd,
4510 + write_nic_word(dev, AtimWnd,
4511 read_nic_word(dev, AtimWnd) &~ AtimWnd_AtimWnd);
4512 -
4513 +
4514 word = read_nic_word(dev, BintrItv);
4515 word &= ~BintrItv_BintrItv;
4516 -
4517 - //word |= priv->ieee80211->beacon_interval *
4518 +
4519 + //word |= priv->ieee80211->beacon_interval *
4520 // ((priv->txbeaconcount > 1)?(priv->txbeaconcount-1):1);
4521 // FIXME:FIXME check if correct ^^ worked with 0x3e8;
4522 -
4523 +
4524 write_nic_word(dev, BintrItv, word);
4525 -
4526 +
4527 //write_nic_word(dev,0x2e,0xe002);
4528 //write_nic_dword(dev,0x30,0xb8c7832e);
4529 for(i=0; i<ETH_ALEN; i++)
4530 write_nic_byte(dev, BSSID+i, priv->ieee80211->beacon_cell_ssid[i]);
4531 -
4532 +
4533 // rtl8180_update_msr(dev);
4534
4535 -
4536 +
4537 //write_nic_byte(dev,CONFIG4,3); /* !!!!!!!!!! */
4538 -
4539 +
4540 rtl8180_set_mode(dev, EPROM_CMD_NORMAL);
4541 -
4542 +
4543 rtl8180_irq_enable(dev);
4544 -
4545 +
4546 /* VV !!!!!!!!!! VV*/
4547 /*
4548 rtl8180_set_mode(dev,EPROM_CMD_CONFIG);
4549 - write_nic_byte(dev,0x9d,0x00);
4550 + write_nic_byte(dev,0x9d,0x00);
4551 rtl8180_set_mode(dev,EPROM_CMD_NORMAL);
4552 */
4553 }
4554 @@ -2135,137 +2242,138 @@
4555 ***************************************************************************/
4556 static struct net_device_stats *rtl8180_stats(struct net_device *dev)
4557 {
4558 - struct r8180_priv *priv = ieee80211_priv(dev);
4559 -
4560 + struct r8180_priv *priv = ieee80211_priv_rtl7(dev);
4561 +
4562 return &priv->ieee80211->stats;
4563 }
4564
4565
4566 int _rtl8180_up(struct net_device *dev)
4567 {
4568 - struct r8180_priv *priv = ieee80211_priv(dev);
4569 + struct r8180_priv *priv = ieee80211_priv_rtl7(dev);
4570
4571 priv->up=1;
4572 -
4573 - //DMESG("Bringing up iface");
4574 +
4575 +// DMESG("Bringing up iface");
4576
4577 rtl8180_adapter_start(dev);
4578 -
4579 rtl8180_rx_enable(dev);
4580 -
4581 rtl8180_tx_enable(dev);
4582 -
4583 - ieee80211_softmac_start_protocol(priv->ieee80211);
4584 -
4585 - ieee80211_reset_queue(priv->ieee80211);
4586 + ieee80211_softmac_start_protocol_rtl7(priv->ieee80211);
4587 + ieee80211_reset_queue_rtl7(priv->ieee80211);
4588 if(!netif_queue_stopped(dev))
4589 netif_start_queue(dev);
4590 else
4591 netif_wake_queue(dev);
4592 -
4593 return 0;
4594 }
4595
4596
4597 int rtl8180_open(struct net_device *dev)
4598 {
4599 - struct r8180_priv *priv = ieee80211_priv(dev);
4600 + struct r8180_priv *priv = ieee80211_priv_rtl7(dev);
4601 int ret;
4602 -
4603 +
4604 down(&priv->wx_sem);
4605 +
4606 ret = rtl8180_up(dev);
4607 up(&priv->wx_sem);
4608 return ret;
4609 -
4610 +
4611 }
4612
4613
4614 int rtl8180_up(struct net_device *dev)
4615 {
4616 - struct r8180_priv *priv = ieee80211_priv(dev);
4617 + struct r8180_priv *priv = ieee80211_priv_rtl7(dev);
4618
4619 if (priv->up == 1) return -1;
4620 -
4621 +
4622 return _rtl8180_up(dev);
4623 }
4624
4625
4626 int rtl8180_close(struct net_device *dev)
4627 {
4628 - struct r8180_priv *priv = ieee80211_priv(dev);
4629 + struct r8180_priv *priv = ieee80211_priv_rtl7(dev);
4630 int ret;
4631 -
4632 +
4633 down(&priv->wx_sem);
4634 -
4635 +
4636 ret = rtl8180_down(dev);
4637 -
4638 +
4639 up(&priv->wx_sem);
4640 -
4641 +
4642 return ret;
4643
4644 }
4645
4646 int rtl8180_down(struct net_device *dev)
4647 {
4648 - struct r8180_priv *priv = ieee80211_priv(dev);
4649 + struct r8180_priv *priv = ieee80211_priv_rtl7(dev);
4650
4651 if (priv->up == 0) return -1;
4652 -
4653 +
4654 priv->up=0;
4655
4656 /* FIXME */
4657 if (!netif_queue_stopped(dev))
4658 netif_stop_queue(dev);
4659 -
4660 +
4661 rtl8180_rtx_disable(dev);
4662 rtl8180_irq_disable(dev);
4663
4664 - ieee80211_softmac_stop_protocol(priv->ieee80211);
4665 -
4666 + ieee80211_softmac_stop_protocol_rtl7(priv->ieee80211);
4667 +
4668 return 0;
4669 }
4670
4671
4672 void rtl8180_commit(struct net_device *dev)
4673 {
4674 - struct r8180_priv *priv = ieee80211_priv(dev);
4675 + struct r8180_priv *priv = ieee80211_priv_rtl7(dev);
4676
4677 if (priv->up == 0) return ;
4678 -
4679 - ieee80211_softmac_stop_protocol(priv->ieee80211);
4680 -
4681 +
4682 + ieee80211_softmac_stop_protocol_rtl7(priv->ieee80211);
4683 +
4684 rtl8180_irq_disable(dev);
4685 rtl8180_rtx_disable(dev);
4686 _rtl8180_up(dev);
4687 }
4688
4689 +# if (LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,20))
4690 +void rtl8180_restart(struct work_struct *work)
4691 +{
4692 + struct r8180_priv *priv = container_of(work, struct r8180_priv, reset_wq);
4693 + struct net_device *dev = priv->dev;
4694 +#else
4695 void rtl8180_restart(struct net_device *dev)
4696 {
4697 - struct r8180_priv *priv = ieee80211_priv(dev);
4698 -
4699 + struct r8180_priv *priv = ieee80211_priv_rtl7(dev);
4700 +#endif
4701 down(&priv->wx_sem);
4702 -
4703 rtl8180_commit(dev);
4704 -
4705 +
4706 up(&priv->wx_sem);
4707 }
4708
4709 static void r8180_set_multicast(struct net_device *dev)
4710 {
4711 - struct r8180_priv *priv = ieee80211_priv(dev);
4712 + struct r8180_priv *priv = ieee80211_priv_rtl7(dev);
4713 short promisc;
4714
4715 //down(&priv->wx_sem);
4716 -
4717 +
4718 /* FIXME FIXME */
4719 -
4720 +
4721 promisc = (dev->flags & IFF_PROMISC) ? 1:0;
4722 -
4723 +
4724 if (promisc != priv->promisc)
4725 // rtl8180_commit(dev);
4726 -
4727 +
4728 priv->promisc = promisc;
4729 -
4730 +
4731 //schedule_work(&priv->reset_wq);
4732 //up(&priv->wx_sem);
4733 }
4734 @@ -2273,17 +2381,17 @@
4735
4736 int r8180_set_mac_adr(struct net_device *dev, void *mac)
4737 {
4738 - struct r8180_priv *priv = ieee80211_priv(dev);
4739 + struct r8180_priv *priv = ieee80211_priv_rtl7(dev);
4740 struct sockaddr *addr = mac;
4741 -
4742 +
4743 down(&priv->wx_sem);
4744 -
4745 +
4746 memcpy(dev->dev_addr, addr->sa_data, ETH_ALEN);
4747 -
4748 +
4749 schedule_work(&priv->reset_wq);
4750 -
4751 +
4752 up(&priv->wx_sem);
4753 -
4754 +
4755 return 0;
4756 }
4757
4758 @@ -2291,16 +2399,18 @@
4759 /* based on ipw2200 driver */
4760 int rtl8180_ioctl(struct net_device *dev, struct ifreq *rq, int cmd)
4761 {
4762 - struct r8180_priv *priv = (struct r8180_priv *)ieee80211_priv(dev);
4763 -
4764 + struct r8180_priv *priv = (struct r8180_priv *)ieee80211_priv_rtl7(dev);
4765 + struct iwreq *wrq;
4766 + int ret;
4767 +
4768 down(&priv->wx_sem);
4769 -
4770 - struct iwreq *wrq = (struct iwreq *)rq;
4771 -
4772 - int ret=-1;
4773 +
4774 + wrq = (struct iwreq *)rq;
4775 +
4776 + ret=-1;
4777 switch (cmd) {
4778 case RTL_IOCTL_WPA_SUPPLICANT:
4779 - ret = ieee80211_wpa_supplicant_ioctl(priv->ieee80211, &wrq->u.data);
4780 + ret = ieee80211_wpa_supplicant_ioctl_rtl7(priv->ieee80211, &wrq->u.data);
4781 break;
4782
4783 default:
4784 @@ -2309,7 +2419,7 @@
4785 }
4786
4787 up(&priv->wx_sem);
4788 -
4789 +
4790 return ret;
4791 }
4792
4793 @@ -2320,10 +2430,11 @@
4794 struct net_device *dev = (struct net_device*)rx_urb->context;
4795 int status,len,flen;
4796 struct sk_buff *skb;
4797 - u32 *desc;
4798 -
4799 + u8 *desc;
4800 + u8 signal,quality,rate;
4801 +
4802 //DMESG("rtl8187_rx_isr");
4803 -
4804 +
4805 struct ieee80211_rx_stats stats = {
4806 .signal = 0,
4807 .noise = -98,
4808 @@ -2332,43 +2443,109 @@
4809 .freq = IEEE80211_24GHZ_BAND,
4810 };
4811
4812 +
4813 //DMESG("RX %d ",rx_urb->status);
4814 status = rx_urb->status;
4815 if(status == 0){
4816 -
4817 +
4818 len = rx_urb->actual_length;
4819 - // len = len - 4 - 15 - 1; /* CRC, DESC, SEPARATOR*/
4820 + // len = len - 4 - 15 - 1; /* CRC, DESC, SEPARATOR*/
4821 len -= 4*4;/* 4 dword and 4 byte CRC */
4822 -
4823 +#if 0
4824 desc = (u32*)(rx_urb->transfer_buffer + len);
4825 -
4826 +
4827 flen = desc[0] & 0xfff;
4828 -
4829 +
4830 if( flen <= rx_urb->actual_length){
4831 -
4832 - stats.signal = (desc[1] & 0x7f00)>>8;
4833 - stats.noise = desc[1] &0xff;
4834 - stats.rate = desc[0] >> 20 & 0xf;
4835 +
4836 + //stats.signal = (desc[1] & 0x7f00)>>8;
4837 + //stats.noise = desc[1] &0xff;
4838 + signal=(desc[1]& (0xff0000))>>16;
4839 + signal=(signal&0xfe)>>1; // Modify by hikaru 6.6
4840 +
4841 + quality=(desc[1] & (0xff));
4842 +
4843 + rate=(desc[0] &((1<<23)|(1<<22)|(1<<21)|(1<<20)))>>20;
4844 + // printk(KERN_INFO "rate is %d!\n",rate);
4845 + stats.rate = rtl8180_rate2rate(rate);
4846 + // printk(KERN_INFO "stats.rate is %d!\n",stats.rate);
4847 + //stats.rate = desc[0] >> 20 & 0xf;
4848 stats.mac_time[0] = desc[2];
4849 stats.mac_time[1] = desc[3];
4850 +#endif
4851 +
4852 + desc = rx_urb->transfer_buffer + len;
4853 +
4854 + flen = ((desc[1] & 0x0f) << 8) + (desc[0] & 0xff);
4855 +
4856 + if( flen <= rx_urb->actual_length){
4857 + //stats.signal = (desc[1] & 0x7f00)>>8;
4858 + //stats.noise = desc[1] &0xff;
4859 + signal=(desc[6]& 0xfe)>>1;
4860 + //signal=(signal&0xfe)>>1; // Modify by hikaru 6.6
4861 +
4862 + quality=desc[4] & 0xff;
4863 +
4864 + //rate=(desc[2] &((1<<7)|(1<<6)|(1<<5)|(1<<4)))>>4;
4865 + rate=(desc[2] & 0xf0)>>4;
4866 + // printk(KERN_INFO "rate is %d!\n",rate);
4867 + stats.rate = rtl8180_rate2rate(rate);
4868 + // printk(KERN_INFO "stats.rate is %d!\n",stats.rate);
4869 + //stats.rate = desc[0] >> 20 & 0xf;
4870 + stats.mac_time[0] = desc[8] + (desc[9]<<8) + (desc[10]<<16) + (desc[11]<<24);
4871 + stats.mac_time[1] = desc[12] + (desc[13]<<8) + (desc[14]<<16) + (desc[15]<<24);
4872 +
4873 +
4874 + //calculate link quality begin
4875 + if(!rtl8180_IsWirelessBMode(stats.rate) )
4876 + { // OFDM rate.
4877 + if(signal>90)
4878 + signal=90;
4879 + else if(signal<25)
4880 + signal=25;
4881 + signal = (90-signal)*100/65;
4882 + }
4883 + else
4884 + { // CCK rate.
4885 + if(signal>95)
4886 + signal = 95;
4887 + else if(signal<30)
4888 + signal = 30;
4889 + signal =(95-signal )*100/65;
4890 + }
4891 + priv->wstats.qual.level = signal;
4892 + // printk(KERN_INFO "signal is %d!\n",signal);
4893 + if(quality > 64)
4894 + priv ->wstats.qual.qual = 0;
4895 + else
4896 + priv ->wstats.qual.qual = ((64-quality) * 100) / 64; // SQ value is the SIGNAL_QUALITY returned to IORequest,
4897 + //and this value only appear when STA is associated to AP or
4898 + // STA is in IBSS mode
4899 + // printk(KERN_INFO "quality is %d!\n",priv->wstats.qual.qual);
4900 + priv->wstats.qual.noise = 100 - priv ->wstats.qual.qual;
4901 + priv->wstats.qual.updated = 7;
4902 + if(priv->ieee80211->iw_mode == IW_MODE_MONITOR)
4903 + {
4904 + stats.signal = priv->wstats.qual.level;
4905 + stats.noise = priv->wstats.qual.noise;
4906 + }
4907 + //calculate link quality end
4908 skb = dev_alloc_skb(flen-4);
4909 - //skb_reserve(skb,2);
4910 - if(skb){
4911 + if(skb){
4912 memcpy(skb_put(skb,flen-4),
4913 rx_urb->transfer_buffer,flen -4);
4914 -
4915 +
4916 #ifdef DUMP_RX
4917 int i;
4918 for(i=0;i<flen-4;i++)
4919 printk("%2x ",((u8*)(rx_urb->transfer_buffer))[i]);
4920 printk("------RATE %x:w---------------\n",stats.rate);
4921 -
4922 +
4923 #endif
4924 priv->stats.rxok++;
4925 // priv->rxskb = skb;
4926 // priv->tempstats = &stats;
4927 -
4928 - if(!ieee80211_rx(priv->ieee80211,
4929 + if(!ieee80211_rx_rtl7(priv->ieee80211,
4930 skb, &stats))
4931 dev_kfree_skb_any(skb);
4932 }
4933 @@ -2376,9 +2553,8 @@
4934 }else{
4935 priv->stats.rxstaterr++;
4936 priv->ieee80211->stats.rx_errors++;
4937 -
4938 }
4939 -
4940 +
4941 if(status != -ENOENT)rtl8187_rx_urbsubmit(dev,rx_urb);
4942 else DMESG("RX process aborted due to explicit shutdown");
4943 }
4944 @@ -2396,20 +2572,20 @@
4945 struct r8180_priv *priv= NULL;
4946 struct usb_device *udev = interface_to_usbdev(intf);
4947
4948 -//printk("===> rtl8187_usb_probe()\n");
4949 -
4950 - dev = alloc_ieee80211(sizeof(struct r8180_priv));
4951 -
4952 +//printk("===> rtl8187_usb_probe()\n");
4953 +
4954 + dev = alloc_ieee80211_rtl7(sizeof(struct r8180_priv));
4955 +
4956 SET_MODULE_OWNER(dev);
4957 - usb_set_intfdata(intf, dev);
4958 -
4959 + usb_set_intfdata(intf, dev);
4960 +
4961 SET_NETDEV_DEV(dev, &intf->dev);
4962
4963 - priv = ieee80211_priv(dev);
4964 + priv = ieee80211_priv_rtl7(dev);
4965 priv->ieee80211 = netdev_priv(dev);
4966 -
4967 +
4968 priv->udev=udev;
4969 -
4970 +
4971 dev->open = rtl8180_open;
4972 dev->stop = rtl8180_close;
4973 //dev->hard_start_xmit = rtl8180_8023_hard_start_xmit;
4974 @@ -2418,41 +2594,46 @@
4975 dev->do_ioctl = rtl8180_ioctl;
4976 dev->set_multicast_list = r8180_set_multicast;
4977 dev->set_mac_address = r8180_set_mac_adr;
4978 +#if WIRELESS_EXT >= 12
4979 +#if WIRELESS_EXT < 17
4980 dev->get_wireless_stats = r8180_get_wireless_stats;
4981 +#endif
4982 + dev->wireless_handlers = (struct iw_handler_def *) &r8180_wx_handlers_def;
4983 +#endif
4984 dev->type=ARPHRD_ETHER;
4985 -
4986 +
4987 if (dev_alloc_name(dev, ifname) < 0){
4988 DMESG("Oops: devname already taken! Trying wlan%%d...\n");
4989 ifname = "wlan%d";
4990 dev_alloc_name(dev, ifname);
4991 }
4992 -
4993 +
4994 // dev->open=rtl8180_init;
4995 -
4996 - if(rtl8180_init(dev)!=0){
4997 +
4998 + if(rtl8180_init(dev)!=0){
4999 DMESG("Initialization failed");
5000 goto fail;
5001 }
5002 -
5003 +
5004 netif_carrier_off(dev);
5005 netif_stop_queue(dev);
5006 -
5007 +
5008 register_netdev(dev);
5009 -
5010 +
5011 rtl8180_proc_init_one(dev);
5012 -
5013 -
5014 +
5015 +
5016 DMESG("Driver probe completed\n");
5017 - return 0;
5018 + return 0;
5019 +
5020
5021 -
5022 fail:
5023 - free_ieee80211(dev);
5024 -
5025 + free_ieee80211_rtl7(dev);
5026 +
5027 DMESG("wlan driver load failed\n");
5028 -
5029 +
5030 return -ENODEV;
5031 -
5032 +
5033 }
5034
5035
5036 @@ -2461,13 +2642,13 @@
5037 struct r8180_priv *priv;
5038 struct net_device *dev = usb_get_intfdata(intf);
5039 if(dev){
5040 -
5041 +
5042 unregister_netdev(dev);
5043 -
5044 - priv=ieee80211_priv(dev);
5045 -
5046 +
5047 + priv=ieee80211_priv_rtl7(dev);
5048 +
5049 rtl8180_proc_remove_one(dev);
5050 -
5051 +
5052 rtl8180_down(dev);
5053 priv->rf_close(dev);
5054 //rtl8180_rtx_disable(dev);
5055 @@ -2478,12 +2659,12 @@
5056
5057 }
5058 // pci_disable_device(pdev);
5059 - free_ieee80211(dev);
5060 + free_ieee80211_rtl7(dev);
5061 DMESG("wlan driver removed\n");
5062 }
5063
5064
5065 -static int __init rtl8187_usb_module_init(void)
5066 +static int __init rtl8187_usb_module_init_rtl7(void)
5067 {
5068 printk(KERN_INFO "\nLinux kernel driver for RTL8187 \
5069 based WLAN cards\n");
5070 @@ -2495,7 +2676,7 @@
5071 }
5072
5073
5074 -static void __exit rtl8187_usb_module_exit(void)
5075 +static void __exit rtl8187_usb_module_exit_rtl7(void)
5076 {
5077 usb_deregister(&rtl8187_usb_driver);
5078
5079 @@ -2508,14 +2689,14 @@
5080 {
5081 unsigned long flags;
5082 short enough_desc;
5083 - struct r8180_priv *priv = (struct r8180_priv *)ieee80211_priv(dev);
5084 -
5085 + struct r8180_priv *priv = (struct r8180_priv *)ieee80211_priv_rtl7(dev);
5086 +
5087 spin_lock_irqsave(&priv->tx_lock,flags);
5088 enough_desc = check_nic_enought_desc(dev,pri);
5089 - spin_unlock_irqrestore(&priv->tx_lock,flags);
5090 -
5091 + spin_unlock_irqrestore(&priv->tx_lock,flags);
5092 +
5093 if(enough_desc)
5094 - ieee80211_wake_queue(priv->ieee80211);
5095 + ieee80211_wake_queue_rtl7(priv->ieee80211);
5096 }
5097
5098
5099 @@ -2523,5 +2704,5 @@
5100 /***************************************************************************
5101 ------------------- module init / exit stubs ----------------
5102 ****************************************************************************/
5103 -module_init(rtl8187_usb_module_init);
5104 -module_exit(rtl8187_usb_module_exit);
5105 +module_init(rtl8187_usb_module_init_rtl7);
5106 +module_exit(rtl8187_usb_module_exit_rtl7);
5107 diff -Naur rtl8187_orig/beta-8187/r8187.h rtl8187_rawtx/beta-8187/r8187.h
5108 --- rtl8187_orig/beta-8187/r8187.h 2007-03-13 23:45:09.000000000 +0100
5109 +++ rtl8187_rawtx/beta-8187/r8187.h 2007-06-05 14:00:05.000000000 +0200
5110 @@ -1,17 +1,17 @@
5111 -/*
5112 +/*
5113 This is part of rtl8187 OpenSource driver.
5114 - Copyright (C) Andrea Merello 2004-2005 <[email protected]>
5115 + Copyright (C) Andrea Merello 2004-2005 <[email protected]>
5116 Released under the terms of GPL (General Public Licence)
5117 -
5118 - Parts of this driver are based on the GPL part of the
5119 +
5120 + Parts of this driver are based on the GPL part of the
5121 official realtek driver
5122 -
5123 - Parts of this driver are based on the rtl8180 driver skeleton
5124 +
5125 + Parts of this driver are based on the rtl8180 driver skeleton
5126 from Patric Schenke & Andres Salomon
5127 -
5128 +
5129 Parts of this driver are based on the Intel Pro Wireless 2100 GPL driver
5130 -
5131 - We want to tanks the Authors of those projects and the Ndiswrapper
5132 +
5133 + We want to tanks the Authors of those projects and the Ndiswrapper
5134 project Authors.
5135 */
5136
5137 @@ -26,7 +26,6 @@
5138
5139 #include <linux/module.h>
5140 #include <linux/kernel.h>
5141 -#include <linux/config.h>
5142 #include <linux/init.h>
5143 #include <linux/ioport.h>
5144 #include <linux/sched.h>
5145 @@ -47,6 +46,12 @@
5146 #include <asm/io.h>
5147 #include <asm/semaphore.h>
5148
5149 +#if (LINUX_VERSION_CODE < KERNEL_VERSION(2,6,19))
5150 +#include <linux/config.h>
5151 +#else
5152 +#include <linux/autoconf.h>
5153 +#endif
5154 +
5155 #include "ieee80211.h"
5156
5157 #define EPROM_93c46 0
5158 @@ -68,7 +73,7 @@
5159 {
5160 struct buffer *next;
5161 u32 *buf;
5162 -
5163 +
5164 } buffer;
5165
5166 #if 0
5167 @@ -123,18 +128,18 @@
5168 short epromtype;
5169 int irq;
5170 struct ieee80211_device *ieee80211;
5171 -
5172 +
5173 short card_8185; /* O: rtl8180, 1:rtl8185 V B/C, 2:rtl8185 V D */
5174 short card_8185_Bversion; /* if TCR reports card V B/C this discriminates */
5175 short phy_ver; /* meaningful for rtl8225 1:A 2:B 3:C */
5176 short enable_gpio0;
5177 enum card_type {PCI,MINIPCI,CARDBUS,USB/*rtl8187*/}card_type;
5178 short hw_plcp_len;
5179 -
5180 +
5181 // spinlock_t irq_lock;
5182 // spinlock_t irq_th_lock;
5183 spinlock_t tx_lock;
5184 -
5185 +
5186 u16 irq_mask;
5187 // short irq_enabled;
5188 struct net_device *dev;
5189 @@ -143,13 +148,16 @@
5190 short max_sens;
5191 u8 chtxpwr[15]; //channels from 1 to 14, 0 not used
5192 u8 chtxpwr_ofdm[15]; //channels from 1 to 14, 0 not used
5193 + u8 chtxpwr_orig[15]; //channels from 1 to 14, 0 not used
5194 + u8 chtxpwr_ofdm_orig[15]; //channels from 1 to 14, 0 not used
5195 u8 cck_txpwr_base;
5196 u8 ofdm_txpwr_base;
5197 + u8 txpwr_max;
5198 u8 challow[15]; //channels from 1 to 14, 0 not used
5199 short up;
5200 short crcmon; //if 1 allow bad crc frame reception in monitor mode
5201 -// short prism_hdr;
5202 -
5203 + short prism_hdr;
5204 +
5205 // struct timer_list scan_timer;
5206 /*short scanpending;
5207 short stopscan;*/
5208 @@ -158,7 +166,7 @@
5209 //u8 active_scan_num;
5210 struct semaphore wx_sem;
5211 // short hw_wep;
5212 -
5213 +
5214 // short digphy;
5215 // short antb;
5216 // short diversity;
5217 @@ -171,31 +179,31 @@
5218 void (*rf_close)(struct net_device *dev);
5219 void (*rf_init)(struct net_device *dev);
5220 //short rate;
5221 - short promisc;
5222 + short promisc;
5223 /*stats*/
5224 struct Stats stats;
5225 struct iw_statistics wstats;
5226 struct proc_dir_entry *dir_dev;
5227 -
5228 +
5229 /*RX stuff*/
5230 // u32 *rxring;
5231 // u32 *rxringtail;
5232 // dma_addr_t rxringdma;
5233 struct urb **rx_urb;
5234 -
5235 +
5236 //struct buffer *rxbuffer;
5237 //struct buffer *rxbufferhead;
5238 //int rxringcount;
5239 //u16 rxbuffersize;
5240 -
5241 - //struct sk_buff *rx_skb;
5242 +
5243 + //struct sk_buff *rx_skb;
5244
5245 //short rx_skb_complete;
5246
5247 //u32 rx_prevlen;
5248 atomic_t tx_lp_pending;
5249 atomic_t tx_np_pending;
5250 -#if 0
5251 +#if 0
5252 /*TX stuff*/
5253 u32 *txlpring;
5254 u32 *txhpring;
5255 @@ -225,7 +233,7 @@
5256 struct urb *rxurb_task;
5257 // u8 dma_poll_mask;
5258 //short tx_suspend;
5259 -
5260 +
5261 /* adhoc/master mode stuff */
5262 #if 0
5263 u32 *txbeacontail;
5264 @@ -239,18 +247,18 @@
5265 //u16 master_beaconinterval;
5266 // u32 master_beaconsize;
5267 //u16 beacon_interval;
5268 -
5269 +
5270 u8 retry_data;
5271 u8 retry_rts;
5272 -
5273 +
5274 struct work_struct reset_wq;
5275 -
5276 +
5277 }r8180_priv;
5278
5279
5280 -typedef enum{
5281 +typedef enum{
5282 LOW_PRIORITY ,
5283 - NORM_PRIORITY
5284 + NORM_PRIORITY
5285 } priority_t;
5286
5287
5288 diff -Naur rtl8187_orig/ieee80211/ieee80211_crypt.c rtl8187_rawtx/ieee80211/ieee80211_crypt.c
5289 --- rtl8187_orig/ieee80211/ieee80211_crypt.c 2007-03-13 23:45:09.000000000 +0100
5290 +++ rtl8187_rawtx/ieee80211/ieee80211_crypt.c 2007-06-05 14:00:28.000000000 +0200
5291 @@ -11,7 +11,6 @@
5292 *
5293 */
5294
5295 -#include <linux/config.h>
5296 #include <linux/version.h>
5297 #include <linux/module.h>
5298 #include <linux/init.h>
5299 @@ -19,6 +18,12 @@
5300 #include <asm/string.h>
5301 #include <asm/errno.h>
5302
5303 +#if (LINUX_VERSION_CODE < KERNEL_VERSION(2,6,19))
5304 +#include <linux/config.h>
5305 +#else
5306 +#include <linux/autoconf.h>
5307 +#endif
5308 +
5309 #include "ieee80211.h"
5310
5311 MODULE_AUTHOR("Jouni Malinen");
5312 @@ -38,7 +43,7 @@
5313
5314 static struct ieee80211_crypto *hcrypt;
5315
5316 -void ieee80211_crypt_deinit_entries(struct ieee80211_device *ieee,
5317 +void ieee80211_crypt_deinit_entries_rtl7(struct ieee80211_device *ieee,
5318 int force)
5319 {
5320 struct list_head *ptr, *n;
5321 @@ -61,13 +66,13 @@
5322 }
5323 }
5324
5325 -void ieee80211_crypt_deinit_handler(unsigned long data)
5326 +void ieee80211_crypt_deinit_handler_rtl7(unsigned long data)
5327 {
5328 struct ieee80211_device *ieee = (struct ieee80211_device *)data;
5329 unsigned long flags;
5330
5331 spin_lock_irqsave(&ieee->lock, flags);
5332 - ieee80211_crypt_deinit_entries(ieee, 0);
5333 + ieee80211_crypt_deinit_entries_rtl7(ieee, 0);
5334 if (!list_empty(&ieee->crypt_deinit_list)) {
5335 printk(KERN_DEBUG "%s: entries remaining in delayed crypt "
5336 "deletion list\n", ieee->dev->name);
5337 @@ -78,7 +83,7 @@
5338
5339 }
5340
5341 -void ieee80211_crypt_delayed_deinit(struct ieee80211_device *ieee,
5342 +void ieee80211_crypt_delayed_deinit_rtl7(struct ieee80211_device *ieee,
5343 struct ieee80211_crypt_data **crypt)
5344 {
5345 struct ieee80211_crypt_data *tmp;
5346 @@ -103,7 +108,7 @@
5347 spin_unlock_irqrestore(&ieee->lock, flags);
5348 }
5349
5350 -int ieee80211_register_crypto_ops(struct ieee80211_crypto_ops *ops)
5351 +int ieee80211_register_crypto_ops_rtl7(struct ieee80211_crypto_ops *ops)
5352 {
5353 unsigned long flags;
5354 struct ieee80211_crypto_alg *alg;
5355 @@ -128,7 +133,7 @@
5356 return 0;
5357 }
5358
5359 -int ieee80211_unregister_crypto_ops(struct ieee80211_crypto_ops *ops)
5360 +int ieee80211_unregister_crypto_ops_rtl7(struct ieee80211_crypto_ops *ops)
5361 {
5362 unsigned long flags;
5363 struct list_head *ptr;
5364 @@ -159,7 +164,7 @@
5365 }
5366
5367
5368 -struct ieee80211_crypto_ops * ieee80211_get_crypto_ops(const char *name)
5369 +struct ieee80211_crypto_ops * ieee80211_get_crypto_ops_rtl7(const char *name)
5370 {
5371 unsigned long flags;
5372 struct list_head *ptr;
5373 @@ -186,13 +191,13 @@
5374 }
5375
5376
5377 -static void * ieee80211_crypt_null_init(int keyidx) { return (void *) 1; }
5378 -static void ieee80211_crypt_null_deinit(void *priv) {}
5379 +static void * ieee80211_crypt_null_init_rtl7(int keyidx) { return (void *) 1; }
5380 +static void ieee80211_crypt_null_deinit_rtl7(void *priv) {}
5381
5382 static struct ieee80211_crypto_ops ieee80211_crypt_null = {
5383 .name = "NULL",
5384 - .init = ieee80211_crypt_null_init,
5385 - .deinit = ieee80211_crypt_null_deinit,
5386 + .init = ieee80211_crypt_null_init_rtl7,
5387 + .deinit = ieee80211_crypt_null_deinit_rtl7,
5388 .encrypt_mpdu = NULL,
5389 .decrypt_mpdu = NULL,
5390 .encrypt_msdu = NULL,
5391 @@ -205,7 +210,7 @@
5392 };
5393
5394
5395 -static int __init ieee80211_crypto_init(void)
5396 +static int __init ieee80211_crypto_init_rtl7(void)
5397 {
5398 int ret = -ENOMEM;
5399
5400 @@ -217,7 +222,7 @@
5401 INIT_LIST_HEAD(&hcrypt->algs);
5402 spin_lock_init(&hcrypt->lock);
5403
5404 - ret = ieee80211_register_crypto_ops(&ieee80211_crypt_null);
5405 + ret = ieee80211_register_crypto_ops_rtl7(&ieee80211_crypt_null);
5406 if (ret < 0) {
5407 kfree(hcrypt);
5408 hcrypt = NULL;
5409 @@ -227,7 +232,7 @@
5410 }
5411
5412
5413 -static void __exit ieee80211_crypto_deinit(void)
5414 +static void __exit ieee80211_crypto_deinit_rtl7(void)
5415 {
5416 struct list_head *ptr, *n;
5417
5418 @@ -247,13 +252,13 @@
5419 kfree(hcrypt);
5420 }
5421
5422 -EXPORT_SYMBOL(ieee80211_crypt_deinit_entries);
5423 -EXPORT_SYMBOL(ieee80211_crypt_deinit_handler);
5424 -EXPORT_SYMBOL(ieee80211_crypt_delayed_deinit);
5425 -
5426 -EXPORT_SYMBOL(ieee80211_register_crypto_ops);
5427 -EXPORT_SYMBOL(ieee80211_unregister_crypto_ops);
5428 -EXPORT_SYMBOL(ieee80211_get_crypto_ops);
5429 +EXPORT_SYMBOL(ieee80211_crypt_deinit_entries_rtl7);
5430 +EXPORT_SYMBOL(ieee80211_crypt_deinit_handler_rtl7);
5431 +EXPORT_SYMBOL(ieee80211_crypt_delayed_deinit_rtl7);
5432 +
5433 +EXPORT_SYMBOL(ieee80211_register_crypto_ops_rtl7);
5434 +EXPORT_SYMBOL(ieee80211_unregister_crypto_ops_rtl7);
5435 +EXPORT_SYMBOL(ieee80211_get_crypto_ops_rtl7);
5436
5437 -module_init(ieee80211_crypto_init);
5438 -module_exit(ieee80211_crypto_deinit);
5439 +module_init(ieee80211_crypto_init_rtl7);
5440 +module_exit(ieee80211_crypto_deinit_rtl7);
5441 diff -Naur rtl8187_orig/ieee80211/ieee80211_crypt_ccmp.c rtl8187_rawtx/ieee80211/ieee80211_crypt_ccmp.c
5442 --- rtl8187_orig/ieee80211/ieee80211_crypt_ccmp.c 2007-03-13 23:45:09.000000000 +0100
5443 +++ rtl8187_rawtx/ieee80211/ieee80211_crypt_ccmp.c 2007-06-05 14:00:28.000000000 +0200
5444 @@ -9,7 +9,6 @@
5445 * more details.
5446 */
5447
5448 -#include <linux/config.h>
5449 #include <linux/version.h>
5450 #include <linux/module.h>
5451 #include <linux/init.h>
5452 @@ -22,11 +21,22 @@
5453 #include <asm/string.h>
5454 #include <linux/wireless.h>
5455
5456 +#if (LINUX_VERSION_CODE < KERNEL_VERSION(2,6,19))
5457 +#include <linux/config.h>
5458 +#else
5459 +#include <linux/autoconf.h>
5460 +#endif
5461 +
5462 #include "ieee80211.h"
5463
5464
5465 #include <linux/crypto.h>
5466 -#include <asm/scatterlist.h>
5467 +
5468 +#if LINUX_VERSION_CODE < KERNEL_VERSION(2,6,20)
5469 + #include <asm/scatterlist.h>
5470 +#else
5471 + #include <linux/scatterlist.h>
5472 +#endif
5473
5474 MODULE_AUTHOR("Jouni Malinen");
5475 MODULE_DESCRIPTION("Host AP crypt: CCMP");
5476 @@ -51,7 +61,11 @@
5477
5478 int key_idx;
5479
5480 +#if (LINUX_VERSION_CODE < KERNEL_VERSION(2,6,19))
5481 struct crypto_tfm *tfm;
5482 +#else
5483 + struct crypto_cipher *tfm;
5484 +#endif
5485
5486 /* scratch buffers for virt_to_page() (crypto API) */
5487 u8 tx_b0[AES_BLOCK_LEN], tx_b[AES_BLOCK_LEN],
5488 @@ -59,7 +73,8 @@
5489 u8 rx_b0[AES_BLOCK_LEN], rx_b[AES_BLOCK_LEN], rx_a[AES_BLOCK_LEN];
5490 };
5491
5492 -void ieee80211_ccmp_aes_encrypt(struct crypto_tfm *tfm,
5493 +#if (LINUX_VERSION_CODE < KERNEL_VERSION(2,6,19))
5494 +void ieee80211_ccmp_aes_encrypt_rtl7(struct crypto_tfm *tfm,
5495 const u8 pt[16], u8 ct[16])
5496 {
5497 struct scatterlist src, dst;
5498 @@ -74,8 +89,15 @@
5499
5500 crypto_cipher_encrypt(tfm, &dst, &src, AES_BLOCK_LEN);
5501 }
5502 +#else
5503 +static inline void ieee80211_ccmp_aes_encrypt_rtl7(struct crypto_cipher *tfm,
5504 + const u8 pt[16], u8 ct[16])
5505 +{
5506 + crypto_cipher_encrypt_one(tfm, ct, pt);
5507 +}
5508 +#endif
5509
5510 -static void * ieee80211_ccmp_init(int key_idx)
5511 +static void * ieee80211_ccmp_init_rtl7(int key_idx)
5512 {
5513 struct ieee80211_ccmp_data *priv;
5514
5515 @@ -85,19 +107,33 @@
5516 memset(priv, 0, sizeof(*priv));
5517 priv->key_idx = key_idx;
5518
5519 +#if (LINUX_VERSION_CODE < KERNEL_VERSION(2,6,19))
5520 priv->tfm = crypto_alloc_tfm("aes", 0);
5521 if (priv->tfm == NULL) {
5522 printk(KERN_DEBUG "ieee80211_crypt_ccmp: could not allocate "
5523 "crypto API aes\n");
5524 goto fail;
5525 }
5526 +#else
5527 + priv->tfm = crypto_alloc_cipher("aes", 0, CRYPTO_ALG_ASYNC);
5528 + if (IS_ERR(priv->tfm)) {
5529 + printk(KERN_DEBUG "ieee80211_crypt_ccmp: could not allocate "
5530 + "crypto API aes\n");
5531 + priv->tfm = NULL;
5532 + goto fail;
5533 + }
5534 +#endif
5535
5536 return priv;
5537
5538 fail:
5539 if (priv) {
5540 if (priv->tfm)
5541 +#if (LINUX_VERSION_CODE < KERNEL_VERSION(2,6,19))
5542 crypto_free_tfm(priv->tfm);
5543 +#else
5544 + crypto_free_cipher(priv->tfm);
5545 +#endif
5546 kfree(priv);
5547 }
5548
5549 @@ -105,16 +141,20 @@
5550 }
5551
5552
5553 -static void ieee80211_ccmp_deinit(void *priv)
5554 +static void ieee80211_ccmp_deinit_rtl7(void *priv)
5555 {
5556 struct ieee80211_ccmp_data *_priv = priv;
5557 if (_priv && _priv->tfm)
5558 +#if (LINUX_VERSION_CODE < KERNEL_VERSION(2,6,19))
5559 crypto_free_tfm(_priv->tfm);
5560 +#else
5561 + crypto_free_cipher(_priv->tfm);
5562 +#endif
5563 kfree(priv);
5564 }
5565
5566
5567 -static inline void xor_block(u8 *b, u8 *a, size_t len)
5568 +static inline void xor_block_rtl7(u8 *b, u8 *a, size_t len)
5569 {
5570 int i;
5571 for (i = 0; i < len; i++)
5572 @@ -122,7 +162,11 @@
5573 }
5574
5575
5576 -static void ccmp_init_blocks(struct crypto_tfm *tfm,
5577 +#if (LINUX_VERSION_CODE < KERNEL_VERSION(2,6,19))
5578 +static void ccmp_init_blocks_rtl7(struct crypto_tfm *tfm,
5579 +#else
5580 +static void ccmp_init_blocks_rtl7(struct crypto_cipher *tfm,
5581 +#endif
5582 struct ieee80211_hdr *hdr,
5583 u8 *pn, size_t dlen, u8 *b0, u8 *auth,
5584 u8 *s0)
5585 @@ -186,18 +230,18 @@
5586 }
5587
5588 /* Start with the first block and AAD */
5589 - ieee80211_ccmp_aes_encrypt(tfm, b0, auth);
5590 - xor_block(auth, aad, AES_BLOCK_LEN);
5591 - ieee80211_ccmp_aes_encrypt(tfm, auth, auth);
5592 - xor_block(auth, &aad[AES_BLOCK_LEN], AES_BLOCK_LEN);
5593 - ieee80211_ccmp_aes_encrypt(tfm, auth, auth);
5594 + ieee80211_ccmp_aes_encrypt_rtl7(tfm, b0, auth);
5595 + xor_block_rtl7(auth, aad, AES_BLOCK_LEN);
5596 + ieee80211_ccmp_aes_encrypt_rtl7(tfm, auth, auth);
5597 + xor_block_rtl7(auth, &aad[AES_BLOCK_LEN], AES_BLOCK_LEN);
5598 + ieee80211_ccmp_aes_encrypt_rtl7(tfm, auth, auth);
5599 b0[0] &= 0x07;
5600 b0[14] = b0[15] = 0;
5601 - ieee80211_ccmp_aes_encrypt(tfm, b0, s0);
5602 + ieee80211_ccmp_aes_encrypt_rtl7(tfm, b0, s0);
5603 }
5604
5605
5606 -static int ieee80211_ccmp_encrypt(struct sk_buff *skb, int hdr_len, void *priv)
5607 +static int ieee80211_ccmp_encrypt_rtl7(struct sk_buff *skb, int hdr_len, void *priv)
5608 {
5609 struct ieee80211_ccmp_data *key = priv;
5610 int data_len, i, blocks, last, len;
5611 @@ -237,7 +281,7 @@
5612 *pos++ = key->tx_pn[0];
5613
5614 hdr = (struct ieee80211_hdr *) skb->data;
5615 - ccmp_init_blocks(key->tfm, hdr, key->tx_pn, data_len, b0, b, s0);
5616 + ccmp_init_blocks_rtl7(key->tfm, hdr, key->tx_pn, data_len, b0, b, s0);
5617
5618 blocks = (data_len + AES_BLOCK_LEN - 1) / AES_BLOCK_LEN;
5619 last = data_len % AES_BLOCK_LEN;
5620 @@ -245,13 +289,13 @@
5621 for (i = 1; i <= blocks; i++) {
5622 len = (i == blocks && last) ? last : AES_BLOCK_LEN;
5623 /* Authentication */
5624 - xor_block(b, pos, len);
5625 - ieee80211_ccmp_aes_encrypt(key->tfm, b, b);
5626 + xor_block_rtl7(b, pos, len);
5627 + ieee80211_ccmp_aes_encrypt_rtl7(key->tfm, b, b);
5628 /* Encryption, with counter */
5629 b0[14] = (i >> 8) & 0xff;
5630 b0[15] = i & 0xff;
5631 - ieee80211_ccmp_aes_encrypt(key->tfm, b0, e);
5632 - xor_block(pos, e, len);
5633 + ieee80211_ccmp_aes_encrypt_rtl7(key->tfm, b0, e);
5634 + xor_block_rtl7(pos, e, len);
5635 pos += len;
5636 }
5637
5638 @@ -262,7 +306,7 @@
5639 }
5640
5641
5642 -static int ieee80211_ccmp_decrypt(struct sk_buff *skb, int hdr_len, void *priv)
5643 +static int ieee80211_ccmp_decrypt_rtl7(struct sk_buff *skb, int hdr_len, void *priv)
5644 {
5645 struct ieee80211_ccmp_data *key = priv;
5646 u8 keyidx, *pos;
5647 @@ -326,8 +370,8 @@
5648 return -4;
5649 }
5650
5651 - ccmp_init_blocks(key->tfm, hdr, pn, data_len, b0, a, b);
5652 - xor_block(mic, b, CCMP_MIC_LEN);
5653 + ccmp_init_blocks_rtl7(key->tfm, hdr, pn, data_len, b0, a, b);
5654 + xor_block_rtl7(mic, b, CCMP_MIC_LEN);
5655
5656 blocks = (data_len + AES_BLOCK_LEN - 1) / AES_BLOCK_LEN;
5657 last = data_len % AES_BLOCK_LEN;
5658 @@ -337,11 +381,11 @@
5659 /* Decrypt, with counter */
5660 b0[14] = (i >> 8) & 0xff;
5661 b0[15] = i & 0xff;
5662 - ieee80211_ccmp_aes_encrypt(key->tfm, b0, b);
5663 - xor_block(pos, b, len);
5664 + ieee80211_ccmp_aes_encrypt_rtl7(key->tfm, b0, b);
5665 + xor_block_rtl7(pos, b, len);
5666 /* Authentication */
5667 - xor_block(a, pos, len);
5668 - ieee80211_ccmp_aes_encrypt(key->tfm, a, a);
5669 + xor_block_rtl7(a, pos, len);
5670 + ieee80211_ccmp_aes_encrypt_rtl7(key->tfm, a, a);
5671 pos += len;
5672 }
5673
5674 @@ -365,11 +409,15 @@
5675 }
5676
5677
5678 -static int ieee80211_ccmp_set_key(void *key, int len, u8 *seq, void *priv)
5679 +static int ieee80211_ccmp_set_key_rtl7(void *key, int len, u8 *seq, void *priv)
5680 {
5681 struct ieee80211_ccmp_data *data = priv;
5682 int keyidx;
5683 +#if (LINUX_VERSION_CODE < KERNEL_VERSION(2,6,19))
5684 struct crypto_tfm *tfm = data->tfm;
5685 +#else
5686 + struct crypto_cipher *tfm = data->tfm;
5687 +#endif
5688
5689 keyidx = data->key_idx;
5690 memset(data, 0, sizeof(*data));
5691 @@ -396,7 +444,7 @@
5692 }
5693
5694
5695 -static int ieee80211_ccmp_get_key(void *key, int len, u8 *seq, void *priv)
5696 +static int ieee80211_ccmp_get_key_rtl7(void *key, int len, u8 *seq, void *priv)
5697 {
5698 struct ieee80211_ccmp_data *data = priv;
5699
5700 @@ -420,7 +468,7 @@
5701 }
5702
5703
5704 -static char * ieee80211_ccmp_print_stats(char *p, void *priv)
5705 +static char * ieee80211_ccmp_print_stats_rtl7(char *p, void *priv)
5706 {
5707 struct ieee80211_ccmp_data *ccmp = priv;
5708 p += sprintf(p, "key[%d] alg=CCMP key_set=%d "
5709 @@ -437,34 +485,34 @@
5710 }
5711
5712
5713 -static struct ieee80211_crypto_ops ieee80211_crypt_ccmp = {
5714 +static struct ieee80211_crypto_ops ieee80211_crypt_ccmp_rtl7 = {
5715 .name = "CCMP",
5716 - .init = ieee80211_ccmp_init,
5717 - .deinit = ieee80211_ccmp_deinit,
5718 - .encrypt_mpdu = ieee80211_ccmp_encrypt,
5719 - .decrypt_mpdu = ieee80211_ccmp_decrypt,
5720 + .init = ieee80211_ccmp_init_rtl7,
5721 + .deinit = ieee80211_ccmp_deinit_rtl7,
5722 + .encrypt_mpdu = ieee80211_ccmp_encrypt_rtl7,
5723 + .decrypt_mpdu = ieee80211_ccmp_decrypt_rtl7,
5724 .encrypt_msdu = NULL,
5725 .decrypt_msdu = NULL,
5726 - .set_key = ieee80211_ccmp_set_key,
5727 - .get_key = ieee80211_ccmp_get_key,
5728 - .print_stats = ieee80211_ccmp_print_stats,
5729 + .set_key = ieee80211_ccmp_set_key_rtl7,
5730 + .get_key = ieee80211_ccmp_get_key_rtl7,
5731 + .print_stats = ieee80211_ccmp_print_stats_rtl7,
5732 .extra_prefix_len = CCMP_HDR_LEN,
5733 .extra_postfix_len = CCMP_MIC_LEN,
5734 .owner = THIS_MODULE,
5735 };
5736
5737
5738 -static int __init ieee80211_crypto_ccmp_init(void)
5739 +static int __init ieee80211_crypto_ccmp_init_rtl7(void)
5740 {
5741 - return ieee80211_register_crypto_ops(&ieee80211_crypt_ccmp);
5742 + return ieee80211_register_crypto_ops_rtl7(&ieee80211_crypt_ccmp_rtl7);
5743 }
5744
5745
5746 -static void __exit ieee80211_crypto_ccmp_exit(void)
5747 +static void __exit ieee80211_crypto_ccmp_exit_rtl7(void)
5748 {
5749 - ieee80211_unregister_crypto_ops(&ieee80211_crypt_ccmp);
5750 + ieee80211_unregister_crypto_ops_rtl7(&ieee80211_crypt_ccmp_rtl7);
5751 }
5752
5753
5754 -module_init(ieee80211_crypto_ccmp_init);
5755 -module_exit(ieee80211_crypto_ccmp_exit);
5756 +module_init(ieee80211_crypto_ccmp_init_rtl7);
5757 +module_exit(ieee80211_crypto_ccmp_exit_rtl7);
5758 diff -Naur rtl8187_orig/ieee80211/ieee80211_crypt.h rtl8187_rawtx/ieee80211/ieee80211_crypt.h
5759 --- rtl8187_orig/ieee80211/ieee80211_crypt.h 2007-03-13 23:45:09.000000000 +0100
5760 +++ rtl8187_rawtx/ieee80211/ieee80211_crypt.h 2007-06-05 14:00:34.000000000 +0200
5761 @@ -75,12 +75,12 @@
5762 atomic_t refcnt;
5763 };
5764
5765 -int ieee80211_register_crypto_ops(struct ieee80211_crypto_ops *ops);
5766 -int ieee80211_unregister_crypto_ops(struct ieee80211_crypto_ops *ops);
5767 -struct ieee80211_crypto_ops * ieee80211_get_crypto_ops(const char *name);
5768 -void ieee80211_crypt_deinit_entries(struct ieee80211_device *, int);
5769 -void ieee80211_crypt_deinit_handler(unsigned long);
5770 -void ieee80211_crypt_delayed_deinit(struct ieee80211_device *ieee,
5771 +int ieee80211_register_crypto_ops_rtl7(struct ieee80211_crypto_ops *ops);
5772 +int ieee80211_unregister_crypto_ops_rtl7(struct ieee80211_crypto_ops *ops);
5773 +struct ieee80211_crypto_ops * ieee80211_get_crypto_ops_rtl7(const char *name);
5774 +void ieee80211_crypt_deinit_entries_rtl7(struct ieee80211_device *, int);
5775 +void ieee80211_crypt_deinit_handler_rtl7(unsigned long);
5776 +void ieee80211_crypt_delayed_deinit_rtl7(struct ieee80211_device *ieee,
5777 struct ieee80211_crypt_data **crypt);
5778
5779 #endif
5780 diff -Naur rtl8187_orig/ieee80211/ieee80211_crypt_tkip.c rtl8187_rawtx/ieee80211/ieee80211_crypt_tkip.c
5781 --- rtl8187_orig/ieee80211/ieee80211_crypt_tkip.c 2007-03-13 23:45:09.000000000 +0100
5782 +++ rtl8187_rawtx/ieee80211/ieee80211_crypt_tkip.c 2007-06-05 14:00:28.000000000 +0200
5783 @@ -9,7 +9,6 @@
5784 * more details.
5785 */
5786
5787 -#include <linux/config.h>
5788 #include <linux/version.h>
5789 #include <linux/module.h>
5790 #include <linux/init.h>
5791 @@ -21,13 +20,24 @@
5792 #include <linux/if_arp.h>
5793 #include <asm/string.h>
5794
5795 +#if (LINUX_VERSION_CODE < KERNEL_VERSION(2,6,19))
5796 +#include <linux/config.h>
5797 +#else
5798 +#include <linux/autoconf.h>
5799 +#endif
5800 +
5801 #include "ieee80211.h"
5802
5803 +#if LINUX_VERSION_CODE < KERNEL_VERSION(2,6,20)
5804 + #include <asm/scatterlist.h>
5805 +#else
5806 + #include <linux/scatterlist.h>
5807 +#endif
5808
5809 #include <linux/crypto.h>
5810 -#include <asm/scatterlist.h>
5811 #include <linux/crc32.h>
5812
5813 +
5814 MODULE_AUTHOR("Jouni Malinen");
5815 MODULE_DESCRIPTION("Host AP crypt: TKIP");
5816 MODULE_LICENSE("GPL");
5817 @@ -55,14 +65,21 @@
5818
5819 int key_idx;
5820
5821 +#if LINUX_VERSION_CODE < KERNEL_VERSION(2,6,19)
5822 struct crypto_tfm *tfm_arc4;
5823 struct crypto_tfm *tfm_michael;
5824 +#else
5825 + struct crypto_blkcipher *rx_tfm_arc4;
5826 + struct crypto_blkcipher *tx_tfm_arc4;
5827 + struct crypto_hash *rx_tfm_michael;
5828 + struct crypto_hash *tx_tfm_michael;
5829 +#endif
5830
5831 /* scratch buffers for virt_to_page() (crypto API) */
5832 u8 rx_hdr[16], tx_hdr[16];
5833 };
5834
5835 -static void * ieee80211_tkip_init(int key_idx)
5836 +static void * ieee80211_tkip_init_rtl7(int key_idx)
5837 {
5838 struct ieee80211_tkip_data *priv;
5839
5840 @@ -72,28 +89,74 @@
5841 memset(priv, 0, sizeof(*priv));
5842 priv->key_idx = key_idx;
5843
5844 +#if LINUX_VERSION_CODE < KERNEL_VERSION(2,6,19)
5845 priv->tfm_arc4 = crypto_alloc_tfm("arc4", 0);
5846 if (priv->tfm_arc4 == NULL) {
5847 printk(KERN_DEBUG "ieee80211_crypt_tkip: could not allocate "
5848 "crypto API arc4\n");
5849 goto fail;
5850 }
5851 -
5852 priv->tfm_michael = crypto_alloc_tfm("michael_mic", 0);
5853 if (priv->tfm_michael == NULL) {
5854 printk(KERN_DEBUG "ieee80211_crypt_tkip: could not allocate "
5855 "crypto API michael_mic\n");
5856 goto fail;
5857 }
5858 +#else
5859 + priv->tx_tfm_arc4 = crypto_alloc_blkcipher("ecb(arc4)", 0, CRYPTO_ALG_ASYNC);
5860 + if (IS_ERR(priv->tx_tfm_arc4)) {
5861 + printk(KERN_DEBUG "ieee80211_crypt_wep: could not allocate "
5862 + "crypto API arc4\n");
5863 + priv->tx_tfm_arc4 = NULL;
5864 + goto fail;
5865 + }
5866 +
5867 + priv->tx_tfm_michael = crypto_alloc_hash("michael_mic", 0,
5868 + CRYPTO_ALG_ASYNC);
5869 + if (IS_ERR(priv->tx_tfm_michael)) {
5870 + printk(KERN_DEBUG "ieee80211_crypt_tkip: could not allocate "
5871 + "crypto API michael_mic\n");
5872 + priv->tx_tfm_michael = NULL;
5873 + goto fail;
5874 + }
5875 +
5876 + priv->rx_tfm_arc4 = crypto_alloc_blkcipher("ecb(arc4)", 0, CRYPTO_ALG_ASYNC);
5877 + if (IS_ERR(priv->rx_tfm_arc4)) {
5878 + printk(KERN_DEBUG "ieee80211_crypt_wep: could not allocate "
5879 + "crypto API arc4\n");
5880 + priv->rx_tfm_arc4 = NULL;
5881 + goto fail;
5882 + }
5883 +
5884 + priv->rx_tfm_michael = crypto_alloc_hash("michael_mic", 0,
5885 + CRYPTO_ALG_ASYNC);
5886 + if (IS_ERR(priv->rx_tfm_michael)) {
5887 + printk(KERN_DEBUG "ieee80211_crypt_tkip: could not allocate "
5888 + "crypto API michael_mic\n");
5889 + priv->rx_tfm_michael = NULL;
5890 + goto fail;
5891 + }
5892 +#endif
5893
5894 return priv;
5895
5896 fail:
5897 if (priv) {
5898 +#if LINUX_VERSION_CODE < KERNEL_VERSION(2,6,19)
5899 if (priv->tfm_michael)
5900 crypto_free_tfm(priv->tfm_michael);
5901 if (priv->tfm_arc4)
5902 crypto_free_tfm(priv->tfm_arc4);
5903 +#else
5904 + if (priv->tx_tfm_michael)
5905 + crypto_free_hash(priv->tx_tfm_michael);
5906 + if (priv->tx_tfm_arc4)
5907 + crypto_free_blkcipher(priv->tx_tfm_arc4);
5908 + if (priv->rx_tfm_michael)
5909 + crypto_free_hash(priv->rx_tfm_michael);
5910 + if (priv->rx_tfm_arc4)
5911 + crypto_free_blkcipher(priv->rx_tfm_arc4);
5912 +#endif
5913 kfree(priv);
5914 }
5915
5916 @@ -101,13 +164,26 @@
5917 }
5918
5919
5920 -static void ieee80211_tkip_deinit(void *priv)
5921 +static void ieee80211_tkip_deinit_rtl7(void *priv)
5922 {
5923 struct ieee80211_tkip_data *_priv = priv;
5924 +#if LINUX_VERSION_CODE < KERNEL_VERSION(2,6,19)
5925 if (_priv && _priv->tfm_michael)
5926 crypto_free_tfm(_priv->tfm_michael);
5927 if (_priv && _priv->tfm_arc4)
5928 crypto_free_tfm(_priv->tfm_arc4);
5929 +#else
5930 + if (_priv) {
5931 + if (_priv->tx_tfm_michael)
5932 + crypto_free_hash(_priv->tx_tfm_michael);
5933 + if (_priv->tx_tfm_arc4)
5934 + crypto_free_blkcipher(_priv->tx_tfm_arc4);
5935 + if (_priv->rx_tfm_michael)
5936 + crypto_free_hash(_priv->rx_tfm_michael);
5937 + if (_priv->rx_tfm_arc4)
5938 + crypto_free_blkcipher(_priv->rx_tfm_arc4);
5939 + }
5940 +#endif
5941 kfree(priv);
5942 }
5943
5944 @@ -200,7 +276,7 @@
5945
5946 #define PHASE1_LOOP_COUNT 8
5947
5948 -static void tkip_mixing_phase1(u16 *TTAK, const u8 *TK, const u8 *TA, u32 IV32)
5949 +static void tkip_mixing_phase1_rtl7(u16 *TTAK, const u8 *TK, const u8 *TA, u32 IV32)
5950 {
5951 int i, j;
5952
5953 @@ -222,7 +298,7 @@
5954 }
5955
5956
5957 -static void tkip_mixing_phase2(u8 *WEPSeed, const u8 *TK, const u16 *TTAK,
5958 +static void tkip_mixing_phase2_rtl7(u8 *WEPSeed, const u8 *TK, const u16 *TTAK,
5959 u16 IV16)
5960 {
5961 /* Make temporary area overlap WEP seed so that the final copy can be
5962 @@ -268,7 +344,7 @@
5963 #endif
5964 }
5965
5966 -static int ieee80211_tkip_encrypt(struct sk_buff *skb, int hdr_len, void *priv)
5967 +static int ieee80211_tkip_encrypt_rtl7(struct sk_buff *skb, int hdr_len, void *priv)
5968 {
5969 struct ieee80211_tkip_data *tkey = priv;
5970 int len;
5971 @@ -276,6 +352,9 @@
5972 struct ieee80211_hdr *hdr;
5973 u32 crc;
5974 struct scatterlist sg;
5975 +#if (LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,19))
5976 + struct blkcipher_desc desc = { .tfm = tkey->tx_tfm_arc4 };
5977 +#endif
5978
5979 if (skb_headroom(skb) < 8 || skb_tailroom(skb) < 4 ||
5980 skb->len < hdr_len)
5981 @@ -283,11 +362,11 @@
5982
5983 hdr = (struct ieee80211_hdr *) skb->data;
5984 if (!tkey->tx_phase1_done) {
5985 - tkip_mixing_phase1(tkey->tx_ttak, tkey->key, hdr->addr2,
5986 + tkip_mixing_phase1_rtl7(tkey->tx_ttak, tkey->key, hdr->addr2,
5987 tkey->tx_iv32);
5988 tkey->tx_phase1_done = 1;
5989 }
5990 - tkip_mixing_phase2(rc4key, tkey->key, tkey->tx_ttak, tkey->tx_iv16);
5991 + tkip_mixing_phase2_rtl7(rc4key, tkey->key, tkey->tx_ttak, tkey->tx_iv16);
5992
5993 len = skb->len - hdr_len;
5994 pos = skb_push(skb, 8);
5995 @@ -310,11 +389,19 @@
5996 icv[2] = crc >> 16;
5997 icv[3] = crc >> 24;
5998
5999 +#if (LINUX_VERSION_CODE < KERNEL_VERSION(2,6,19))
6000 crypto_cipher_setkey(tkey->tfm_arc4, rc4key, 16);
6001 +#else
6002 + crypto_blkcipher_setkey(tkey->tx_tfm_arc4, rc4key, 16);
6003 +#endif
6004 sg.page = virt_to_page(pos);
6005 sg.offset = offset_in_page(pos);
6006 sg.length = len + 4;
6007 +#if (LINUX_VERSION_CODE < KERNEL_VERSION(2,6,19))
6008 crypto_cipher_encrypt(tkey->tfm_arc4, &sg, &sg, len + 4);
6009 +#else
6010 + crypto_blkcipher_encrypt(&desc, &sg, &sg, len + 4);
6011 +#endif
6012
6013 tkey->tx_iv16++;
6014 if (tkey->tx_iv16 == 0) {
6015 @@ -325,7 +412,7 @@
6016 return 0;
6017 }
6018
6019 -static int ieee80211_tkip_decrypt(struct sk_buff *skb, int hdr_len, void *priv)
6020 +static int ieee80211_tkip_decrypt_rtl7(struct sk_buff *skb, int hdr_len, void *priv)
6021 {
6022 struct ieee80211_tkip_data *tkey = priv;
6023 u8 rc4key[16];
6024 @@ -337,6 +424,9 @@
6025 u32 crc;
6026 struct scatterlist sg;
6027 int plen;
6028 +#if (LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,19))
6029 + struct blkcipher_desc desc = { .tfm = tkey->rx_tfm_arc4 };
6030 +#endif
6031
6032 if (skb->len < hdr_len + 8 + 4)
6033 return -1;
6034 @@ -382,18 +472,26 @@
6035 }
6036
6037 if (iv32 != tkey->rx_iv32 || !tkey->rx_phase1_done) {
6038 - tkip_mixing_phase1(tkey->rx_ttak, tkey->key, hdr->addr2, iv32);
6039 + tkip_mixing_phase1_rtl7(tkey->rx_ttak, tkey->key, hdr->addr2, iv32);
6040 tkey->rx_phase1_done = 1;
6041 }
6042 - tkip_mixing_phase2(rc4key, tkey->key, tkey->rx_ttak, iv16);
6043 + tkip_mixing_phase2_rtl7(rc4key, tkey->key, tkey->rx_ttak, iv16);
6044
6045 plen = skb->len - hdr_len - 12;
6046
6047 +#if (LINUX_VERSION_CODE < KERNEL_VERSION(2,6,19))
6048 crypto_cipher_setkey(tkey->tfm_arc4, rc4key, 16);
6049 +#else
6050 + crypto_blkcipher_setkey(tkey->rx_tfm_arc4, rc4key, 16);
6051 +#endif
6052 sg.page = virt_to_page(pos);
6053 sg.offset = offset_in_page(pos);
6054 sg.length = plen + 4;
6055 +#if (LINUX_VERSION_CODE < KERNEL_VERSION(2,6,19))
6056 crypto_cipher_decrypt(tkey->tfm_arc4, &sg, &sg, plen + 4);
6057 +#else
6058 + crypto_blkcipher_decrypt(&desc, &sg, &sg, plen + 4);
6059 +#endif
6060
6061 crc = ~crc32_le(~0, pos, plen);
6062 icv[0] = crc;
6063 @@ -427,13 +525,22 @@
6064 return keyidx;
6065 }
6066
6067 -
6068 -static int michael_mic(struct ieee80211_tkip_data *tkey, u8 *key, u8 *hdr,
6069 +#if LINUX_VERSION_CODE < KERNEL_VERSION(2,6,19)
6070 +static int michael_mic_rtl7(struct ieee80211_tkip_data *tkey, u8 *key, u8 *hdr,
6071 u8 *data, size_t data_len, u8 *mic)
6072 {
6073 struct scatterlist sg[2];
6074
6075 if (tkey->tfm_michael == NULL) {
6076 +#else
6077 +static int michael_mic_rtl7(struct crypto_hash *tfm_michael, u8 *key, u8 *hdr,
6078 + u8 *data, size_t data_len, u8 *mic)
6079 +{
6080 + struct hash_desc desc;
6081 + struct scatterlist sg[2];
6082 +
6083 + if (tfm_michael == NULL) {
6084 +#endif
6085 printk(KERN_WARNING "michael_mic: tfm_michael == NULL\n");
6086 return -1;
6087 }
6088 @@ -445,15 +552,24 @@
6089 sg[1].offset = offset_in_page(data);
6090 sg[1].length = data_len;
6091
6092 +#if LINUX_VERSION_CODE < KERNEL_VERSION(2,6,19)
6093 crypto_digest_init(tkey->tfm_michael);
6094 crypto_digest_setkey(tkey->tfm_michael, key, 8);
6095 crypto_digest_update(tkey->tfm_michael, sg, 2);
6096 crypto_digest_final(tkey->tfm_michael, mic);
6097
6098 return 0;
6099 +#else
6100 + if (crypto_hash_setkey(tfm_michael, key, 8))
6101 + return -1;
6102 +
6103 + desc.tfm = tfm_michael;
6104 + desc.flags = 0;
6105 + return crypto_hash_digest(&desc, sg, data_len + 16, mic);
6106 +#endif
6107 }
6108
6109 -static void michael_mic_hdr(struct sk_buff *skb, u8 *hdr)
6110 +static void michael_mic_hdr_rtl7(struct sk_buff *skb, u8 *hdr)
6111 {
6112 struct ieee80211_hdr *hdr11;
6113
6114 @@ -483,7 +599,7 @@
6115 }
6116
6117
6118 -static int ieee80211_michael_mic_add(struct sk_buff *skb, int hdr_len, void *priv)
6119 +static int ieee80211_michael_mic_add_rtl7(struct sk_buff *skb, int hdr_len, void *priv)
6120 {
6121 struct ieee80211_tkip_data *tkey = priv;
6122 u8 *pos;
6123 @@ -495,18 +611,24 @@
6124 return -1;
6125 }
6126
6127 - michael_mic_hdr(skb, tkey->tx_hdr);
6128 + michael_mic_hdr_rtl7(skb, tkey->tx_hdr);
6129 pos = skb_put(skb, 8);
6130 - if (michael_mic(tkey, &tkey->key[16], tkey->tx_hdr,
6131 +#if LINUX_VERSION_CODE < KERNEL_VERSION(2,6,19)
6132 + if (michael_mic_rtl7(tkey, &tkey->key[16], tkey->tx_hdr,
6133 skb->data + hdr_len, skb->len - 8 - hdr_len, pos))
6134 return -1;
6135 +#else
6136 + if (michael_mic_rtl7(tkey->tx_tfm_michael, &tkey->key[16], tkey->tx_hdr,
6137 + skb->data + hdr_len, skb->len - 8 - hdr_len, pos))
6138 + return -1;
6139 +#endif
6140
6141 return 0;
6142 }
6143
6144
6145 #if WIRELESS_EXT >= 18
6146 -static void ieee80211_michael_mic_failure(struct net_device *dev,
6147 +static void ieee80211_michael_mic_failure_rtl7(struct net_device *dev,
6148 struct ieee80211_hdr *hdr,
6149 int keyidx)
6150 {
6151 @@ -527,7 +649,7 @@
6152 wireless_send_event(dev, IWEVMICHAELMICFAILURE, &wrqu, (char *) &ev);
6153 }
6154 #elif WIRELESS_EXT >= 15
6155 -static void ieee80211_michael_mic_failure(struct net_device *dev,
6156 +static void ieee80211_michael_mic_failure_rtl7(struct net_device *dev,
6157 struct ieee80211_hdr *hdr,
6158 int keyidx)
6159 {
6160 @@ -543,7 +665,7 @@
6161 wireless_send_event(dev, IWEVCUSTOM, &wrqu, buf);
6162 }
6163 #else /* WIRELESS_EXT >= 15 */
6164 -static inline void ieee80211_michael_mic_failure(struct net_device *dev,
6165 +static inline void ieee80211_michael_mic_failure_rtl7(struct net_device *dev,
6166 struct ieee80211_hdr *hdr,
6167 int keyidx)
6168 {
6169 @@ -551,7 +673,7 @@
6170 #endif /* WIRELESS_EXT >= 15 */
6171
6172
6173 -static int ieee80211_michael_mic_verify(struct sk_buff *skb, int keyidx,
6174 +static int ieee80211_michael_mic_verify_rtl7(struct sk_buff *skb, int keyidx,
6175 int hdr_len, void *priv)
6176 {
6177 struct ieee80211_tkip_data *tkey = priv;
6178 @@ -560,10 +682,16 @@
6179 if (!tkey->key_set)
6180 return -1;
6181
6182 - michael_mic_hdr(skb, tkey->rx_hdr);
6183 - if (michael_mic(tkey, &tkey->key[24], tkey->rx_hdr,
6184 + michael_mic_hdr_rtl7(skb, tkey->rx_hdr);
6185 +#if LINUX_VERSION_CODE < KERNEL_VERSION(2,6,19)
6186 + if (michael_mic_rtl7(tkey, &tkey->key[24], tkey->rx_hdr,
6187 skb->data + hdr_len, skb->len - 8 - hdr_len, mic))
6188 return -1;
6189 +#else
6190 + if (michael_mic_rtl7(tkey->rx_tfm_michael, &tkey->key[24], tkey->rx_hdr,
6191 + skb->data + hdr_len, skb->len - 8 - hdr_len, mic))
6192 + return -1;
6193 +#endif
6194 if (memcmp(mic, skb->data + skb->len - 8, 8) != 0) {
6195 struct ieee80211_hdr *hdr;
6196 hdr = (struct ieee80211_hdr *) skb->data;
6197 @@ -572,7 +700,7 @@
6198 skb->dev ? skb->dev->name : "N/A", MAC_ARG(hdr->addr2),
6199 keyidx);
6200 if (skb->dev)
6201 - ieee80211_michael_mic_failure(skb->dev, hdr, keyidx);
6202 + ieee80211_michael_mic_failure_rtl7(skb->dev, hdr, keyidx);
6203 tkey->dot11RSNAStatsTKIPLocalMICFailures++;
6204 return -1;
6205 }
6206 @@ -588,18 +716,33 @@
6207 }
6208
6209
6210 -static int ieee80211_tkip_set_key(void *key, int len, u8 *seq, void *priv)
6211 +static int ieee80211_tkip_set_key_rtl7(void *key, int len, u8 *seq, void *priv)
6212 {
6213 struct ieee80211_tkip_data *tkey = priv;
6214 int keyidx;
6215 +#if (LINUX_VERSION_CODE < KERNEL_VERSION(2,6,19))
6216 struct crypto_tfm *tfm = tkey->tfm_michael;
6217 struct crypto_tfm *tfm2 = tkey->tfm_arc4;
6218 +#else
6219 + struct crypto_hash *tfm = tkey->tx_tfm_michael;
6220 + struct crypto_blkcipher *tfm2 = tkey->tx_tfm_arc4;
6221 + struct crypto_hash *tfm3 = tkey->rx_tfm_michael;
6222 + struct crypto_blkcipher *tfm4 = tkey->rx_tfm_arc4;
6223 +#endif
6224
6225 keyidx = tkey->key_idx;
6226 memset(tkey, 0, sizeof(*tkey));
6227 tkey->key_idx = keyidx;
6228 +#if (LINUX_VERSION_CODE < KERNEL_VERSION(2,6,19))
6229 tkey->tfm_michael = tfm;
6230 tkey->tfm_arc4 = tfm2;
6231 +#else
6232 + tkey->tx_tfm_michael = tfm;
6233 + tkey->tx_tfm_arc4 = tfm2;
6234 + tkey->rx_tfm_michael = tfm3;
6235 + tkey->rx_tfm_arc4 = tfm4;
6236 +#endif
6237 +
6238 if (len == TKIP_KEY_LEN) {
6239 memcpy(tkey->key, key, TKIP_KEY_LEN);
6240 tkey->key_set = 1;
6241 @@ -618,7 +761,7 @@
6242 }
6243
6244
6245 -static int ieee80211_tkip_get_key(void *key, int len, u8 *seq, void *priv)
6246 +static int ieee80211_tkip_get_key_rtl7(void *key, int len, u8 *seq, void *priv)
6247 {
6248 struct ieee80211_tkip_data *tkey = priv;
6249
6250 @@ -648,7 +791,7 @@
6251 }
6252
6253
6254 -static char * ieee80211_tkip_print_stats(char *p, void *priv)
6255 +static char * ieee80211_tkip_print_stats_rtl7(char *p, void *priv)
6256 {
6257 struct ieee80211_tkip_data *tkip = priv;
6258 p += sprintf(p, "key[%d] alg=TKIP key_set=%d "
6259 @@ -675,34 +818,34 @@
6260 }
6261
6262
6263 -static struct ieee80211_crypto_ops ieee80211_crypt_tkip = {
6264 +static struct ieee80211_crypto_ops ieee80211_crypt_tkip_rtl7 = {
6265 .name = "TKIP",
6266 - .init = ieee80211_tkip_init,
6267 - .deinit = ieee80211_tkip_deinit,
6268 - .encrypt_mpdu = ieee80211_tkip_encrypt,
6269 - .decrypt_mpdu = ieee80211_tkip_decrypt,
6270 - .encrypt_msdu = ieee80211_michael_mic_add,
6271 - .decrypt_msdu = ieee80211_michael_mic_verify,
6272 - .set_key = ieee80211_tkip_set_key,
6273 - .get_key = ieee80211_tkip_get_key,
6274 - .print_stats = ieee80211_tkip_print_stats,
6275 + .init = ieee80211_tkip_init_rtl7,
6276 + .deinit = ieee80211_tkip_deinit_rtl7,
6277 + .encrypt_mpdu = ieee80211_tkip_encrypt_rtl7,
6278 + .decrypt_mpdu = ieee80211_tkip_decrypt_rtl7,
6279 + .encrypt_msdu = ieee80211_michael_mic_add_rtl7,
6280 + .decrypt_msdu = ieee80211_michael_mic_verify_rtl7,
6281 + .set_key = ieee80211_tkip_set_key_rtl7,
6282 + .get_key = ieee80211_tkip_get_key_rtl7,
6283 + .print_stats = ieee80211_tkip_print_stats_rtl7,
6284 .extra_prefix_len = 4 + 4, /* IV + ExtIV */
6285 .extra_postfix_len = 8 + 4, /* MIC + ICV */
6286 .owner = THIS_MODULE,
6287 };
6288
6289
6290 -static int __init ieee80211_crypto_tkip_init(void)
6291 +static int __init ieee80211_crypto_tkip_init_rtl7(void)
6292 {
6293 - return ieee80211_register_crypto_ops(&ieee80211_crypt_tkip);
6294 + return ieee80211_register_crypto_ops_rtl7(&ieee80211_crypt_tkip_rtl7);
6295 }
6296
6297
6298 -static void __exit ieee80211_crypto_tkip_exit(void)
6299 +static void __exit ieee80211_crypto_tkip_exit_rtl7(void)
6300 {
6301 - ieee80211_unregister_crypto_ops(&ieee80211_crypt_tkip);
6302 + ieee80211_unregister_crypto_ops_rtl7(&ieee80211_crypt_tkip_rtl7);
6303 }
6304
6305
6306 -module_init(ieee80211_crypto_tkip_init);
6307 -module_exit(ieee80211_crypto_tkip_exit);
6308 +module_init(ieee80211_crypto_tkip_init_rtl7);
6309 +module_exit(ieee80211_crypto_tkip_exit_rtl7);
6310 diff -Naur rtl8187_orig/ieee80211/ieee80211_crypt_wep.c rtl8187_rawtx/ieee80211/ieee80211_crypt_wep.c
6311 --- rtl8187_orig/ieee80211/ieee80211_crypt_wep.c 2007-03-13 23:45:09.000000000 +0100
6312 +++ rtl8187_rawtx/ieee80211/ieee80211_crypt_wep.c 2007-06-05 14:00:28.000000000 +0200
6313 @@ -9,7 +9,6 @@
6314 * more details.
6315 */
6316
6317 -#include <linux/config.h>
6318 #include <linux/version.h>
6319 #include <linux/module.h>
6320 #include <linux/init.h>
6321 @@ -18,13 +17,24 @@
6322 #include <linux/skbuff.h>
6323 #include <asm/string.h>
6324
6325 +#if (LINUX_VERSION_CODE < KERNEL_VERSION(2,6,19))
6326 +#include <linux/config.h>
6327 +#else
6328 +#include <linux/autoconf.h>
6329 +#endif
6330 +
6331 #include "ieee80211.h"
6332
6333
6334 #include <linux/crypto.h>
6335 -#include <asm/scatterlist.h>
6336 #include <linux/crc32.h>
6337
6338 +#if LINUX_VERSION_CODE < KERNEL_VERSION(2,6,20)
6339 + #include <asm/scatterlist.h>
6340 +#else
6341 + #include <linux/scatterlist.h>
6342 +#endif
6343 +
6344 MODULE_AUTHOR("Jouni Malinen");
6345 MODULE_DESCRIPTION("Host AP crypt: WEP");
6346 MODULE_LICENSE("GPL");
6347 @@ -36,11 +46,16 @@
6348 u8 key[WEP_KEY_LEN + 1];
6349 u8 key_len;
6350 u8 key_idx;
6351 +#if LINUX_VERSION_CODE < KERNEL_VERSION(2,6,19)
6352 struct crypto_tfm *tfm;
6353 +#else
6354 + struct crypto_blkcipher *rx_tfm;
6355 + struct crypto_blkcipher *tx_tfm;
6356 +#endif
6357 };
6358
6359
6360 -static void * prism2_wep_init(int keyidx)
6361 +static void * prism2_wep_init_rtl7(int keyidx)
6362 {
6363 struct prism2_wep_data *priv;
6364
6365 @@ -50,13 +65,30 @@
6366 memset(priv, 0, sizeof(*priv));
6367 priv->key_idx = keyidx;
6368
6369 +#if LINUX_VERSION_CODE < KERNEL_VERSION(2,6,19)
6370 priv->tfm = crypto_alloc_tfm("arc4", 0);
6371 if (priv->tfm == NULL) {
6372 printk(KERN_DEBUG "ieee80211_crypt_wep: could not allocate "
6373 "crypto API arc4\n");
6374 goto fail;
6375 }
6376 +#else
6377 + priv->tx_tfm = crypto_alloc_blkcipher("ecb(arc4)", 0, CRYPTO_ALG_ASYNC);
6378 + if (IS_ERR(priv->tx_tfm)) {
6379 + printk(KERN_DEBUG "ieee80211_crypt_wep: could not allocate "
6380 + "crypto API arc4\n");
6381 + priv->tx_tfm = NULL;
6382 + goto fail;
6383 + }
6384
6385 + priv->rx_tfm = crypto_alloc_blkcipher("ecb(arc4)", 0, CRYPTO_ALG_ASYNC);
6386 + if (IS_ERR(priv->rx_tfm)) {
6387 + printk(KERN_DEBUG "ieee80211_crypt_wep: could not allocate "
6388 + "crypto API arc4\n");
6389 + priv->rx_tfm = NULL;
6390 + goto fail;
6391 + }
6392 +#endif
6393 /* start WEP IV from a random value */
6394 get_random_bytes(&priv->iv, 4);
6395
6396 @@ -64,19 +96,35 @@
6397
6398 fail:
6399 if (priv) {
6400 +#if LINUX_VERSION_CODE < KERNEL_VERSION(2,6,19)
6401 if (priv->tfm)
6402 crypto_free_tfm(priv->tfm);
6403 +#else
6404 + if (priv->tx_tfm)
6405 + crypto_free_blkcipher(priv->tx_tfm);
6406 + if (priv->rx_tfm)
6407 + crypto_free_blkcipher(priv->rx_tfm);
6408 +#endif
6409 kfree(priv);
6410 }
6411 return NULL;
6412 }
6413
6414
6415 -static void prism2_wep_deinit(void *priv)
6416 +static void prism2_wep_deinit_rtl7(void *priv)
6417 {
6418 struct prism2_wep_data *_priv = priv;
6419 +#if LINUX_VERSION_CODE < KERNEL_VERSION(2,6,19)
6420 if (_priv && _priv->tfm)
6421 crypto_free_tfm(_priv->tfm);
6422 +#else
6423 + if (_priv) {
6424 + if (_priv->tx_tfm)
6425 + crypto_free_blkcipher(_priv->tx_tfm);
6426 + if (_priv->rx_tfm)
6427 + crypto_free_blkcipher(_priv->rx_tfm);
6428 + }
6429 +#endif
6430 kfree(priv);
6431 }
6432
6433 @@ -87,13 +135,16 @@
6434 *
6435 * WEP frame payload: IV + TX key idx, RC4(data), ICV = RC4(CRC32(data))
6436 */
6437 -static int prism2_wep_encrypt(struct sk_buff *skb, int hdr_len, void *priv)
6438 +static int prism2_wep_encrypt_rtl7(struct sk_buff *skb, int hdr_len, void *priv)
6439 {
6440 struct prism2_wep_data *wep = priv;
6441 u32 crc, klen, len;
6442 u8 key[WEP_KEY_LEN + 3];
6443 u8 *pos, *icv;
6444 struct scatterlist sg;
6445 +#if (LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,19))
6446 + struct blkcipher_desc desc = { .tfm = wep->tx_tfm };
6447 +#endif
6448
6449 if (skb_headroom(skb) < 4 || skb_tailroom(skb) < 4 ||
6450 skb->len < hdr_len)
6451 @@ -134,13 +185,21 @@
6452 icv[2] = crc >> 16;
6453 icv[3] = crc >> 24;
6454
6455 +#if (LINUX_VERSION_CODE < KERNEL_VERSION(2,6,19))
6456 crypto_cipher_setkey(wep->tfm, key, klen);
6457 +#else
6458 + crypto_blkcipher_setkey(wep->tx_tfm, key, klen);
6459 +#endif
6460 sg.page = virt_to_page(pos);
6461 sg.offset = offset_in_page(pos);
6462 sg.length = len + 4;
6463 - crypto_cipher_encrypt(wep->tfm, &sg, &sg, len + 4);
6464
6465 +#if (LINUX_VERSION_CODE < KERNEL_VERSION(2,6,19))
6466 + crypto_cipher_encrypt(wep->tfm, &sg, &sg, len + 4);
6467 return 0;
6468 +#else
6469 + return crypto_blkcipher_encrypt(&desc, &sg, &sg, len + 4);
6470 +#endif
6471 }
6472
6473
6474 @@ -151,13 +210,16 @@
6475 * Returns 0 if frame was decrypted successfully and ICV was correct and -1 on
6476 * failure. If frame is OK, IV and ICV will be removed.
6477 */
6478 -static int prism2_wep_decrypt(struct sk_buff *skb, int hdr_len, void *priv)
6479 +static int prism2_wep_decrypt_rtl7(struct sk_buff *skb, int hdr_len, void *priv)
6480 {
6481 struct prism2_wep_data *wep = priv;
6482 u32 crc, klen, plen;
6483 u8 key[WEP_KEY_LEN + 3];
6484 u8 keyidx, *pos, icv[4];
6485 struct scatterlist sg;
6486 +#if (LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,19))
6487 + struct blkcipher_desc desc = { .tfm = wep->rx_tfm };
6488 +#endif
6489
6490 if (skb->len < hdr_len + 8)
6491 return -1;
6492 @@ -178,11 +240,22 @@
6493 /* Apply RC4 to data and compute CRC32 over decrypted data */
6494 plen = skb->len - hdr_len - 8;
6495
6496 +#if (LINUX_VERSION_CODE < KERNEL_VERSION(2,6,19))
6497 crypto_cipher_setkey(wep->tfm, key, klen);
6498 +#else
6499 + crypto_blkcipher_setkey(wep->rx_tfm, key, klen);
6500 +#endif
6501 +
6502 sg.page = virt_to_page(pos);
6503 sg.offset = offset_in_page(pos);
6504 sg.length = plen + 4;
6505 +
6506 +#if (LINUX_VERSION_CODE < KERNEL_VERSION(2,6,19))
6507 crypto_cipher_decrypt(wep->tfm, &sg, &sg, plen + 4);
6508 +#else
6509 + if(crypto_blkcipher_decrypt(&desc, &sg, &sg, plen + 4))
6510 + return -7;
6511 +#endif
6512
6513 crc = ~crc32_le(~0, pos, plen);
6514 icv[0] = crc;
6515 @@ -203,7 +276,7 @@
6516 }
6517
6518
6519 -static int prism2_wep_set_key(void *key, int len, u8 *seq, void *priv)
6520 +static int prism2_wep_set_key_rtl7(void *key, int len, u8 *seq, void *priv)
6521 {
6522 struct prism2_wep_data *wep = priv;
6523
6524 @@ -217,7 +290,7 @@
6525 }
6526
6527
6528 -static int prism2_wep_get_key(void *key, int len, u8 *seq, void *priv)
6529 +static int prism2_wep_get_key_rtl7(void *key, int len, u8 *seq, void *priv)
6530 {
6531 struct prism2_wep_data *wep = priv;
6532
6533 @@ -230,7 +303,7 @@
6534 }
6535
6536
6537 -static char * prism2_wep_print_stats(char *p, void *priv)
6538 +static char * prism2_wep_print_stats_rtl7(char *p, void *priv)
6539 {
6540 struct prism2_wep_data *wep = priv;
6541 p += sprintf(p, "key[%d] alg=WEP len=%d\n",
6542 @@ -239,34 +312,34 @@
6543 }
6544
6545
6546 -static struct ieee80211_crypto_ops ieee80211_crypt_wep = {
6547 +static struct ieee80211_crypto_ops ieee80211_crypt_wep_rtl7 = {
6548 .name = "WEP",
6549 - .init = prism2_wep_init,
6550 - .deinit = prism2_wep_deinit,
6551 - .encrypt_mpdu = prism2_wep_encrypt,
6552 - .decrypt_mpdu = prism2_wep_decrypt,
6553 + .init = prism2_wep_init_rtl7,
6554 + .deinit = prism2_wep_deinit_rtl7,
6555 + .encrypt_mpdu = prism2_wep_encrypt_rtl7,
6556 + .decrypt_mpdu = prism2_wep_decrypt_rtl7,
6557 .encrypt_msdu = NULL,
6558 .decrypt_msdu = NULL,
6559 - .set_key = prism2_wep_set_key,
6560 - .get_key = prism2_wep_get_key,
6561 - .print_stats = prism2_wep_print_stats,
6562 + .set_key = prism2_wep_set_key_rtl7,
6563 + .get_key = prism2_wep_get_key_rtl7,
6564 + .print_stats = prism2_wep_print_stats_rtl7,
6565 .extra_prefix_len = 4, /* IV */
6566 .extra_postfix_len = 4, /* ICV */
6567 .owner = THIS_MODULE,
6568 };
6569
6570
6571 -static int __init ieee80211_crypto_wep_init(void)
6572 +static int __init ieee80211_crypto_wep_init_rtl7(void)
6573 {
6574 - return ieee80211_register_crypto_ops(&ieee80211_crypt_wep);
6575 + return ieee80211_register_crypto_ops_rtl7(&ieee80211_crypt_wep_rtl7);
6576 }
6577
6578
6579 -static void __exit ieee80211_crypto_wep_exit(void)
6580 +static void __exit ieee80211_crypto_wep_exit_rtl7(void)
6581 {
6582 - ieee80211_unregister_crypto_ops(&ieee80211_crypt_wep);
6583 + ieee80211_unregister_crypto_ops_rtl7(&ieee80211_crypt_wep_rtl7);
6584 }
6585
6586
6587 -module_init(ieee80211_crypto_wep_init);
6588 -module_exit(ieee80211_crypto_wep_exit);
6589 +module_init(ieee80211_crypto_wep_init_rtl7);
6590 +module_exit(ieee80211_crypto_wep_exit_rtl7);
6591 diff -Naur rtl8187_orig/ieee80211/ieee80211.h rtl8187_rawtx/ieee80211/ieee80211.h
6592 --- rtl8187_orig/ieee80211/ieee80211.h 2007-03-13 23:45:09.000000000 +0100
6593 +++ rtl8187_rawtx/ieee80211/ieee80211.h 2007-06-05 14:00:34.000000000 +0200
6594 @@ -156,6 +156,22 @@
6595 struct list_head list;
6596 };
6597
6598 +#define LWNG_CAP_DID_BASE (4 | (1 << 6)) /* section 4, group 1 */
6599 +/* ARPHRD_IEEE80211_PRISM uses a bloated version of Prism2 RX frame header
6600 + * (from linux-wlan-ng) */
6601 +struct linux_wlan_ng_val {
6602 + u32 did;
6603 + u16 status, len;
6604 + u32 data;
6605 +} __attribute__ ((packed));
6606 +
6607 +struct linux_wlan_ng_prism_hdr {
6608 + u32 msgcode, msglen;
6609 + char devname[16];
6610 + struct linux_wlan_ng_val hosttime, mactime, channel, rssi, sq, signal,
6611 + noise, rate, istx, frmlen;
6612 +} __attribute__ ((packed));
6613 +
6614 struct ieee80211_hdr {
6615 u16 frame_ctl;
6616 u16 duration_id;
6617 @@ -840,14 +856,14 @@
6618
6619
6620 #if (LINUX_VERSION_CODE <= KERNEL_VERSION(2,6,11))
6621 -extern inline int is_multicast_ether_addr(const u8 *addr)
6622 +extern inline int is_multicast_ether_addr_rtl7(const u8 *addr)
6623 {
6624 return ((addr[0] != 0xff) && (0x01 & addr[0]));
6625 }
6626 #endif
6627
6628 #if (LINUX_VERSION_CODE <= KERNEL_VERSION(2,6,13))
6629 -extern inline int is_broadcast_ether_addr(const u8 *addr)
6630 +extern inline int is_broadcast_ether_addr_rtl7(const u8 *addr)
6631 {
6632 return ((addr[0] == 0xff) && (addr[1] == 0xff) && (addr[2] == 0xff) && \
6633 (addr[3] == 0xff) && (addr[4] == 0xff) && (addr[5] == 0xff));
6634 @@ -1015,10 +1031,16 @@
6635 struct timer_list beacon_timer;
6636
6637 struct work_struct associate_complete_wq;
6638 +
6639 +# if (LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,20))
6640 + struct delayed_work associate_retry_wq;
6641 + struct delayed_work softmac_scan_wq;
6642 +#else
6643 struct work_struct associate_retry_wq;
6644 + struct work_struct softmac_scan_wq;
6645 +#endif
6646 struct work_struct start_ibss_wq;
6647 struct work_struct associate_procedure_wq;
6648 - struct work_struct softmac_scan_wq;
6649 struct work_struct wx_sync_scan_wq;
6650
6651 struct workqueue_struct *wq;
6652 @@ -1154,12 +1176,12 @@
6653
6654
6655
6656 -extern inline void *ieee80211_priv(struct net_device *dev)
6657 +extern inline void *ieee80211_priv_rtl7(struct net_device *dev)
6658 {
6659 return ((struct ieee80211_device *)netdev_priv(dev))->priv;
6660 }
6661
6662 -extern inline int ieee80211_is_empty_essid(const char *essid, int essid_len)
6663 +extern inline int ieee80211_is_empty_essid_rtl7(const char *essid, int essid_len)
6664 {
6665 /* Single white space is for Linksys APs */
6666 if (essid_len == 1 && essid[0] == ' ')
6667 @@ -1175,7 +1197,7 @@
6668 return 1;
6669 }
6670
6671 -extern inline int ieee80211_is_valid_mode(struct ieee80211_device *ieee, int mode)
6672 +extern inline int ieee80211_is_valid_mode_rtl7(struct ieee80211_device *ieee, int mode)
6673 {
6674 /*
6675 * It is possible for both access points and our device to support
6676 @@ -1201,7 +1223,7 @@
6677 return 0;
6678 }
6679
6680 -extern inline int ieee80211_get_hdrlen(u16 fc)
6681 +extern inline int ieee80211_get_hdrlen_rtl7(u16 fc)
6682 {
6683 int hdrlen = 24;
6684
6685 @@ -1229,140 +1251,144 @@
6686
6687
6688 /* ieee80211.c */
6689 -extern void free_ieee80211(struct net_device *dev);
6690 -extern struct net_device *alloc_ieee80211(int sizeof_priv);
6691 +extern void free_ieee80211_rtl7(struct net_device *dev);
6692 +extern struct net_device *alloc_ieee80211_rtl7(int sizeof_priv);
6693
6694 -extern int ieee80211_set_encryption(struct ieee80211_device *ieee);
6695 +extern int ieee80211_set_encryption_rtl7(struct ieee80211_device *ieee);
6696
6697 /* ieee80211_tx.c */
6698
6699 -extern int ieee80211_encrypt_fragment(
6700 +extern int ieee80211_encrypt_fragment_rtl7(
6701 struct ieee80211_device *ieee,
6702 struct sk_buff *frag,
6703 int hdr_len);
6704
6705 -extern int ieee80211_xmit(struct sk_buff *skb,
6706 +extern int ieee80211_xmit_rtl7(struct sk_buff *skb,
6707 struct net_device *dev);
6708 -extern void ieee80211_txb_free(struct ieee80211_txb *);
6709 +extern void ieee80211_txb_free_rtl7(struct ieee80211_txb *);
6710
6711
6712 /* ieee80211_rx.c */
6713 -extern int ieee80211_rx(struct ieee80211_device *ieee, struct sk_buff *skb,
6714 +extern int ieee80211_rx_rtl7(struct ieee80211_device *ieee, struct sk_buff *skb,
6715 struct ieee80211_rx_stats *rx_stats);
6716 -extern void ieee80211_rx_mgt(struct ieee80211_device *ieee,
6717 +extern void ieee80211_rx_mgt_rtl7(struct ieee80211_device *ieee,
6718 struct ieee80211_hdr *header,
6719 struct ieee80211_rx_stats *stats);
6720
6721 /* ieee80211_wx.c */
6722 -extern int ieee80211_wx_get_scan(struct ieee80211_device *ieee,
6723 +extern int ieee80211_wx_get_scan_rtl7(struct ieee80211_device *ieee,
6724 struct iw_request_info *info,
6725 union iwreq_data *wrqu, char *key);
6726 -extern int ieee80211_wx_set_encode(struct ieee80211_device *ieee,
6727 +extern int ieee80211_wx_set_encode_rtl7(struct ieee80211_device *ieee,
6728 struct iw_request_info *info,
6729 union iwreq_data *wrqu, char *key);
6730 -extern int ieee80211_wx_get_encode(struct ieee80211_device *ieee,
6731 +extern int ieee80211_wx_get_encode_rtl7(struct ieee80211_device *ieee,
6732 struct iw_request_info *info,
6733 union iwreq_data *wrqu, char *key);
6734 /* ieee80211_softmac.c */
6735 -extern short ieee80211_is_54g(struct ieee80211_network net);
6736 -extern short ieee80211_is_shortslot(struct ieee80211_network net);
6737 -extern int ieee80211_rx_frame_softmac(struct ieee80211_device *ieee, struct sk_buff *skb,
6738 +extern short ieee80211_is_54g_rtl7(struct ieee80211_network net);
6739 +extern short ieee80211_is_shortslot_rtl7(struct ieee80211_network net);
6740 +extern int ieee80211_rx_frame_softmac_rtl7(struct ieee80211_device *ieee, struct sk_buff *skb,
6741 struct ieee80211_rx_stats *rx_stats, u16 type,
6742 u16 stype);
6743 -extern void ieee80211_softmac_new_net(struct ieee80211_device *ieee, struct ieee80211_network *net);
6744 +extern void ieee80211_softmac_new_net_rtl7(struct ieee80211_device *ieee, struct ieee80211_network *net);
6745
6746 -extern void ieee80211_softmac_xmit(struct ieee80211_txb *txb, struct ieee80211_device *ieee);
6747 -extern void ieee80211_softmac_check_all_nets(struct ieee80211_device *ieee);
6748 -extern void ieee80211_start_bss(struct ieee80211_device *ieee);
6749 -extern void ieee80211_start_master_bss(struct ieee80211_device *ieee);
6750 -extern void ieee80211_start_ibss(struct ieee80211_device *ieee);
6751 -extern void ieee80211_softmac_init(struct ieee80211_device *ieee);
6752 -extern void ieee80211_softmac_free(struct ieee80211_device *ieee);
6753 -extern void ieee80211_associate_abort(struct ieee80211_device *ieee);
6754 -extern void ieee80211_disassociate(struct ieee80211_device *ieee);
6755 -extern void ieee80211_stop_scan(struct ieee80211_device *ieee);
6756 -extern void ieee80211_start_scan_syncro(struct ieee80211_device *ieee);
6757 -extern void ieee80211_check_all_nets(struct ieee80211_device *ieee);
6758 -extern void ieee80211_start_protocol(struct ieee80211_device *ieee);
6759 -extern void ieee80211_stop_protocol(struct ieee80211_device *ieee);
6760 -extern void ieee80211_softmac_start_protocol(struct ieee80211_device *ieee);
6761 -extern void ieee80211_softmac_stop_protocol(struct ieee80211_device *ieee);
6762 -extern void ieee80211_reset_queue(struct ieee80211_device *ieee);
6763 -extern void ieee80211_wake_queue(struct ieee80211_device *ieee);
6764 -extern void ieee80211_stop_queue(struct ieee80211_device *ieee);
6765 -extern struct sk_buff *ieee80211_get_beacon(struct ieee80211_device *ieee);
6766 -extern void ieee80211_start_send_beacons(struct ieee80211_device *ieee);
6767 -extern void ieee80211_stop_send_beacons(struct ieee80211_device *ieee);
6768 -extern int ieee80211_wpa_supplicant_ioctl(struct ieee80211_device *ieee, struct iw_point *p);
6769 -extern void notify_wx_assoc_event(struct ieee80211_device *ieee);
6770 -extern void ieee80211_ps_tx_ack(struct ieee80211_device *ieee, short success);
6771 +extern void ieee80211_softmac_xmit_rtl7(struct ieee80211_txb *txb, struct ieee80211_device *ieee);
6772 +extern void ieee80211_softmac_check_all_nets_rtl7(struct ieee80211_device *ieee);
6773 +extern void ieee80211_start_bss_rtl7(struct ieee80211_device *ieee);
6774 +extern void ieee80211_start_master_bss_rtl7(struct ieee80211_device *ieee);
6775 +extern void ieee80211_start_ibss_rtl7(struct ieee80211_device *ieee);
6776 +extern void ieee80211_softmac_init_rtl7(struct ieee80211_device *ieee);
6777 +extern void ieee80211_softmac_free_rtl7(struct ieee80211_device *ieee);
6778 +extern void ieee80211_associate_abort_rtl7(struct ieee80211_device *ieee);
6779 +extern void ieee80211_disassociate_rtl7(struct ieee80211_device *ieee);
6780 +extern void ieee80211_stop_scan_rtl7(struct ieee80211_device *ieee);
6781 +extern void ieee80211_start_scan_syncro_rtl7(struct ieee80211_device *ieee);
6782 +extern void ieee80211_check_all_nets_rtl7(struct ieee80211_device *ieee);
6783 +extern void ieee80211_start_protocol_rtl7(struct ieee80211_device *ieee);
6784 +extern void ieee80211_stop_protocol_rtl7(struct ieee80211_device *ieee);
6785 +extern void ieee80211_softmac_start_protocol_rtl7(struct ieee80211_device *ieee);
6786 +extern void ieee80211_softmac_stop_protocol_rtl7(struct ieee80211_device *ieee);
6787 +extern void ieee80211_reset_queue_rtl7(struct ieee80211_device *ieee);
6788 +extern void ieee80211_wake_queue_rtl7(struct ieee80211_device *ieee);
6789 +extern void ieee80211_stop_queue_rtl7(struct ieee80211_device *ieee);
6790 +extern struct sk_buff *ieee80211_get_beacon_rtl7(struct ieee80211_device *ieee);
6791 +extern void ieee80211_start_send_beacons_rtl7(struct ieee80211_device *ieee);
6792 +extern void ieee80211_stop_send_beacons_rtl7(struct ieee80211_device *ieee);
6793 +extern int ieee80211_wpa_supplicant_ioctl_rtl7(struct ieee80211_device *ieee, struct iw_point *p);
6794 +extern void notify_wx_assoc_event_rtl7(struct ieee80211_device *ieee);
6795 +extern void ieee80211_ps_tx_ack_rtl7(struct ieee80211_device *ieee, short success);
6796
6797 /* ieee80211_softmac_wx.c */
6798
6799 -extern int ieee80211_wx_get_wap(struct ieee80211_device *ieee,
6800 +extern int ieee80211_wx_get_wap_rtl7(struct ieee80211_device *ieee,
6801 struct iw_request_info *info,
6802 union iwreq_data *wrqu, char *ext);
6803
6804 -extern int ieee80211_wx_set_wap(struct ieee80211_device *ieee,
6805 +extern int ieee80211_wx_set_wap_rtl7(struct ieee80211_device *ieee,
6806 struct iw_request_info *info,
6807 union iwreq_data *awrq,
6808 char *extra);
6809
6810 -extern int ieee80211_wx_get_essid(struct ieee80211_device *ieee, struct iw_request_info *a,union iwreq_data *wrqu,char *b);
6811 +extern int ieee80211_wx_get_essid_rtl7(struct ieee80211_device *ieee, struct iw_request_info *a,union iwreq_data *wrqu,char *b);
6812
6813 -extern int ieee80211_wx_set_rate(struct ieee80211_device *ieee,
6814 +extern int ieee80211_wx_set_rate_rtl7(struct ieee80211_device *ieee,
6815 struct iw_request_info *info,
6816 union iwreq_data *wrqu, char *extra);
6817
6818 -extern int ieee80211_wx_get_rate(struct ieee80211_device *ieee,
6819 +extern int ieee80211_wx_get_rate_rtl7(struct ieee80211_device *ieee,
6820 struct iw_request_info *info,
6821 union iwreq_data *wrqu, char *extra);
6822
6823 -extern int ieee80211_wx_set_mode(struct ieee80211_device *ieee, struct iw_request_info *a,
6824 +extern int ieee80211_wx_set_mode_rtl7(struct ieee80211_device *ieee, struct iw_request_info *a,
6825 union iwreq_data *wrqu, char *b);
6826
6827 -extern int ieee80211_wx_set_scan(struct ieee80211_device *ieee, struct iw_request_info *a,
6828 +extern int ieee80211_wx_set_scan_rtl7(struct ieee80211_device *ieee, struct iw_request_info *a,
6829 union iwreq_data *wrqu, char *b);
6830
6831 -extern int ieee80211_wx_set_essid(struct ieee80211_device *ieee,
6832 +extern int ieee80211_wx_set_essid_rtl7(struct ieee80211_device *ieee,
6833 struct iw_request_info *a,
6834 union iwreq_data *wrqu, char *extra);
6835
6836 -extern int ieee80211_wx_get_mode(struct ieee80211_device *ieee, struct iw_request_info *a,
6837 +extern int ieee80211_wx_get_mode_rtl7(struct ieee80211_device *ieee, struct iw_request_info *a,
6838 union iwreq_data *wrqu, char *b);
6839
6840 -extern int ieee80211_wx_set_freq(struct ieee80211_device *ieee, struct iw_request_info *a,
6841 +extern int ieee80211_wx_set_freq_rtl7(struct ieee80211_device *ieee, struct iw_request_info *a,
6842 union iwreq_data *wrqu, char *b);
6843
6844 -extern int ieee80211_wx_get_freq(struct ieee80211_device *ieee, struct iw_request_info *a,
6845 +extern int ieee80211_wx_get_freq_rtl7(struct ieee80211_device *ieee, struct iw_request_info *a,
6846 union iwreq_data *wrqu, char *b);
6847
6848 -extern void ieee80211_wx_sync_scan_wq(struct ieee80211_device *ieee);
6849 +# if (LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,20))
6850 +extern void ieee80211_wx_sync_scan_wq_rtl7(struct work_struct *work);
6851 +#else
6852 +extern void ieee80211_wx_sync_scan_wq_rtl7(struct ieee80211_device *ieee);
6853 +#endif
6854
6855 -extern int ieee80211_wx_set_rawtx(struct ieee80211_device *ieee,
6856 +extern int ieee80211_wx_set_rawtx_rtl7(struct ieee80211_device *ieee,
6857 struct iw_request_info *info,
6858 union iwreq_data *wrqu, char *extra);
6859
6860 -extern int ieee80211_wx_get_name(struct ieee80211_device *ieee,
6861 +extern int ieee80211_wx_get_name_rtl7(struct ieee80211_device *ieee,
6862 struct iw_request_info *info,
6863 union iwreq_data *wrqu, char *extra);
6864
6865 -extern int ieee80211_wx_set_power(struct ieee80211_device *ieee,
6866 +extern int ieee80211_wx_set_power_rtl7(struct ieee80211_device *ieee,
6867 struct iw_request_info *info,
6868 union iwreq_data *wrqu, char *extra);
6869
6870 -extern int ieee80211_wx_get_power(struct ieee80211_device *ieee,
6871 +extern int ieee80211_wx_get_power_rtl7(struct ieee80211_device *ieee,
6872 struct iw_request_info *info,
6873 union iwreq_data *wrqu, char *extra);
6874
6875 -extern const long ieee80211_wlan_frequencies[];
6876 +extern const long ieee80211_wlan_frequencies_rtl7[];
6877
6878 -extern inline void ieee80211_increment_scans(struct ieee80211_device *ieee)
6879 +extern inline void ieee80211_increment_scans_rtl7(struct ieee80211_device *ieee)
6880 {
6881 ieee->scans++;
6882 }
6883
6884 -extern inline int ieee80211_get_scans(struct ieee80211_device *ieee)
6885 +extern inline int ieee80211_get_scans_rtl7(struct ieee80211_device *ieee)
6886 {
6887 return ieee->scans;
6888 }
6889 @@ -1372,7 +1398,7 @@
6890 const char *s = essid;
6891 char *d = escaped;
6892
6893 - if (ieee80211_is_empty_essid(essid, essid_len)) {
6894 + if (ieee80211_is_empty_essid_rtl7(essid, essid_len)) {
6895 memcpy(escaped, "<hidden>", sizeof("<hidden>"));
6896 return escaped;
6897 }
6898 diff -Naur rtl8187_orig/ieee80211/ieee80211_module.c rtl8187_rawtx/ieee80211/ieee80211_module.c
6899 --- rtl8187_orig/ieee80211/ieee80211_module.c 2007-03-13 23:45:09.000000000 +0100
6900 +++ rtl8187_rawtx/ieee80211/ieee80211_module.c 2007-06-05 14:00:28.000000000 +0200
6901 @@ -31,7 +31,6 @@
6902 *******************************************************************************/
6903
6904 #include <linux/compiler.h>
6905 -#include <linux/config.h>
6906 #include <linux/errno.h>
6907 #include <linux/if_arp.h>
6908 #include <linux/in6.h>
6909 @@ -52,6 +51,12 @@
6910 #include <asm/uaccess.h>
6911 #include <net/arp.h>
6912
6913 +#if (LINUX_VERSION_CODE < KERNEL_VERSION(2,6,19))
6914 +#include <linux/config.h>
6915 +#else
6916 +#include <linux/autoconf.h>
6917 +#endif
6918 +
6919 #include "ieee80211.h"
6920
6921 MODULE_DESCRIPTION("802.11 data/management/control stack");
6922 @@ -60,7 +65,7 @@
6923
6924 #define DRV_NAME "ieee80211"
6925
6926 -static inline int ieee80211_networks_allocate(struct ieee80211_device *ieee)
6927 +static inline int ieee80211_networks_allocate_rtl7(struct ieee80211_device *ieee)
6928 {
6929 if (ieee->networks)
6930 return 0;
6931 @@ -80,7 +85,7 @@
6932 return 0;
6933 }
6934
6935 -static inline void ieee80211_networks_free(struct ieee80211_device *ieee)
6936 +static inline void ieee80211_networks_free_rtl7(struct ieee80211_device *ieee)
6937 {
6938 if (!ieee->networks)
6939 return;
6940 @@ -88,7 +93,7 @@
6941 ieee->networks = NULL;
6942 }
6943
6944 -static inline void ieee80211_networks_initialize(struct ieee80211_device *ieee)
6945 +static inline void ieee80211_networks_initialize_rtl7(struct ieee80211_device *ieee)
6946 {
6947 int i;
6948
6949 @@ -99,7 +104,7 @@
6950 }
6951
6952
6953 -struct net_device *alloc_ieee80211(int sizeof_priv)
6954 +struct net_device *alloc_ieee80211_rtl7(int sizeof_priv)
6955 {
6956 struct ieee80211_device *ieee;
6957 struct net_device *dev;
6958 @@ -113,17 +118,17 @@
6959 goto failed;
6960 }
6961 ieee = netdev_priv(dev);
6962 - dev->hard_start_xmit = ieee80211_xmit;
6963 + dev->hard_start_xmit = ieee80211_xmit_rtl7;
6964
6965 ieee->dev = dev;
6966
6967 - err = ieee80211_networks_allocate(ieee);
6968 + err = ieee80211_networks_allocate_rtl7(ieee);
6969 if (err) {
6970 IEEE80211_ERROR("Unable to allocate beacon storage: %d\n",
6971 err);
6972 goto failed;
6973 }
6974 - ieee80211_networks_initialize(ieee);
6975 + ieee80211_networks_initialize_rtl7(ieee);
6976
6977 /* Default fragmentation threshold is maximum payload size */
6978 ieee->fts = DEFAULT_FTS;
6979 @@ -138,7 +143,7 @@
6980 INIT_LIST_HEAD(&ieee->crypt_deinit_list);
6981 init_timer(&ieee->crypt_deinit_timer);
6982 ieee->crypt_deinit_timer.data = (unsigned long)ieee;
6983 - ieee->crypt_deinit_timer.function = ieee80211_crypt_deinit_handler;
6984 + ieee->crypt_deinit_timer.function = ieee80211_crypt_deinit_handler_rtl7;
6985
6986 spin_lock_init(&ieee->lock);
6987
6988 @@ -149,7 +154,7 @@
6989 ieee->ieee802_1x = 1;
6990 ieee->raw_tx = 0;
6991
6992 - ieee80211_softmac_init(ieee);
6993 + ieee80211_softmac_init_rtl7(ieee);
6994
6995 for (i = 0; i < IEEE_IBSS_MAC_HASH_SIZE; i++)
6996 INIT_LIST_HEAD(&ieee->ibss_mac_hash[i]);
6997 @@ -167,7 +172,7 @@
6998 }
6999
7000
7001 -void free_ieee80211(struct net_device *dev)
7002 +void free_ieee80211_rtl7(struct net_device *dev)
7003 {
7004 struct ieee80211_device *ieee = netdev_priv(dev);
7005
7006 @@ -175,9 +180,9 @@
7007 struct list_head *p, *q;
7008
7009
7010 - ieee80211_softmac_free(ieee);
7011 + ieee80211_softmac_free_rtl7(ieee);
7012 del_timer_sync(&ieee->crypt_deinit_timer);
7013 - ieee80211_crypt_deinit_entries(ieee, 1);
7014 + ieee80211_crypt_deinit_entries_rtl7(ieee, 1);
7015
7016 for (i = 0; i < WEP_KEYS; i++) {
7017 struct ieee80211_crypt_data *crypt = ieee->crypt[i];
7018 @@ -191,7 +196,7 @@
7019 }
7020 }
7021
7022 - ieee80211_networks_free(ieee);
7023 + ieee80211_networks_free_rtl7(ieee);
7024
7025 for (i = 0; i < IEEE_IBSS_MAC_HASH_SIZE; i++) {
7026 list_for_each_safe(p, q, &ieee->ibss_mac_hash[i]) {
7027 @@ -210,13 +215,13 @@
7028 u32 ieee80211_debug_level = 0;
7029 struct proc_dir_entry *ieee80211_proc = NULL;
7030
7031 -static int show_debug_level(char *page, char **start, off_t offset,
7032 +static int show_debug_level_rtl7(char *page, char **start, off_t offset,
7033 int count, int *eof, void *data)
7034 {
7035 return snprintf(page, count, "0x%08X\n", ieee80211_debug_level);
7036 }
7037
7038 -static int store_debug_level(struct file *file, const char *buffer,
7039 +static int store_debug_level_rtl7(struct file *file, const char *buffer,
7040 unsigned long count, void *data)
7041 {
7042 char buf[] = "0x00000000";
7043 @@ -243,7 +248,7 @@
7044 return strnlen(buf, count);
7045 }
7046
7047 -static int __init ieee80211_init(void)
7048 +static int __init ieee80211_init_rtl7(void)
7049 {
7050 struct proc_dir_entry *e;
7051
7052 @@ -268,7 +273,7 @@
7053 return 0;
7054 }
7055
7056 -static void __exit ieee80211_exit(void)
7057 +static void __exit ieee80211_exit_rtl7(void)
7058 {
7059 if (ieee80211_proc) {
7060 remove_proc_entry("debug_level", ieee80211_proc);
7061 @@ -282,9 +287,9 @@
7062 MODULE_PARM_DESC(debug, "debug output mask");
7063
7064
7065 -module_exit(ieee80211_exit);
7066 -module_init(ieee80211_init);
7067 +module_exit(ieee80211_exit_rtl7);
7068 +module_init(ieee80211_init_rtl7);
7069 #endif
7070
7071 -EXPORT_SYMBOL(alloc_ieee80211);
7072 -EXPORT_SYMBOL(free_ieee80211);
7073 +EXPORT_SYMBOL(alloc_ieee80211_rtl7);
7074 +EXPORT_SYMBOL(free_ieee80211_rtl7);
7075 diff -Naur rtl8187_orig/ieee80211/ieee80211_rx.c rtl8187_rawtx/ieee80211/ieee80211_rx.c
7076 --- rtl8187_orig/ieee80211/ieee80211_rx.c 2007-03-13 23:45:09.000000000 +0100
7077 +++ rtl8187_rawtx/ieee80211/ieee80211_rx.c 2007-06-05 14:00:28.000000000 +0200
7078 @@ -22,7 +22,6 @@
7079
7080
7081 #include <linux/compiler.h>
7082 -#include <linux/config.h>
7083 #include <linux/errno.h>
7084 #include <linux/if_arp.h>
7085 #include <linux/in6.h>
7086 @@ -43,18 +42,85 @@
7087 #include <asm/uaccess.h>
7088 #include <linux/ctype.h>
7089
7090 +#if (LINUX_VERSION_CODE < KERNEL_VERSION(2,6,19))
7091 +#include <linux/config.h>
7092 +#else
7093 +#include <linux/autoconf.h>
7094 +#endif
7095 +
7096 +
7097 #include "ieee80211.h"
7098
7099 -static inline void ieee80211_monitor_rx(struct ieee80211_device *ieee,
7100 +static inline void ieee80211_monitor_rx_rtl7(struct ieee80211_device *ieee,
7101 struct sk_buff *skb,
7102 struct ieee80211_rx_stats *rx_stats)
7103 {
7104 - struct ieee80211_hdr *hdr = (struct ieee80211_hdr *)skb->data;
7105 - u16 fc = le16_to_cpu(hdr->frame_ctl);
7106 + struct ieee80211_hdr *hdr1 = (struct ieee80211_hdr *)skb->data;
7107 + u16 fc = le16_to_cpu(hdr1->frame_ctl);
7108 + int prism_header;
7109 + int hdrlen, phdrlen, head_need, tail_need;
7110 +
7111 + if (ieee->dev->type == ARPHRD_IEEE80211_PRISM) {
7112 + prism_header = 1;
7113 + phdrlen = sizeof(struct linux_wlan_ng_prism_hdr);
7114 + } else {
7115 + prism_header = 0;
7116 + phdrlen = 0;
7117 + }
7118 +
7119 + hdrlen = ieee80211_get_hdrlen_rtl7(fc);
7120 +
7121 + /* check if there is enough room for extra data; if not, expand skb
7122 + * buffer to be large enough for the changes */
7123 + head_need = phdrlen;
7124 + tail_need = 0;
7125 +#ifdef PRISM2_ADD_BOGUS_CRC
7126 + tail_need += 4;
7127 +#endif /* PRISM2_ADD_BOGUS_CRC */
7128 +
7129 + head_need -= skb_headroom(skb);
7130 + tail_need -= skb_tailroom(skb);
7131 +
7132 + if (head_need > 0 || tail_need > 0) {
7133 + if (pskb_expand_head(skb, head_need > 0 ? head_need : 0,
7134 + tail_need > 0 ? tail_need : 0,
7135 + GFP_ATOMIC)) {
7136 + printk(KERN_DEBUG "%s: ieee80211_rx failed to "
7137 + "reallocate skb buffer\n", ieee->dev->name);
7138 + dev_kfree_skb_any(skb);
7139 + return;
7140 + }
7141 + }
7142 +
7143 + if (prism_header == 1) {
7144 + struct linux_wlan_ng_prism_hdr *hdr;
7145 + hdr = (struct linux_wlan_ng_prism_hdr *)
7146 + skb_push(skb, phdrlen);
7147 + memset(hdr, 0, phdrlen);
7148 + hdr->msgcode = LWNG_CAP_DID_BASE;
7149 + hdr->msglen = sizeof(*hdr);
7150 + memcpy(hdr->devname, ieee->dev->name, sizeof(hdr->devname));
7151 +#define LWNG_SETVAL(f,i,s,l,d) \
7152 +hdr->f.did = LWNG_CAP_DID_BASE | (i << 12); \
7153 +hdr->f.status = s; hdr->f.len = l; hdr->f.data = d
7154 + LWNG_SETVAL(hosttime, 1, 0, 4, jiffies);
7155 + LWNG_SETVAL(mactime, 2, 0, 4, ((u32)rx_stats->mac_time));
7156 + LWNG_SETVAL(channel, 3, 1 /* no value */, 4, 0);
7157 + LWNG_SETVAL(rssi, 4, 1 /* no value */, 4, 0);
7158 + LWNG_SETVAL(sq, 5, 1 /* no value */, 4, 0);
7159 + LWNG_SETVAL(signal, 6, 0, 4, rx_stats->signal);
7160 + LWNG_SETVAL(noise, 7, 0, 4, rx_stats->noise);
7161 + LWNG_SETVAL(rate, 8, 0, 4, rx_stats->rate / 5);
7162 + LWNG_SETVAL(istx, 9, 0, 4, 0);
7163 + LWNG_SETVAL(frmlen, 10, 0, 4, skb->len - phdrlen);
7164 +#undef LWNG_SETVAL
7165 + }
7166
7167 skb->dev = ieee->dev;
7168 skb->mac.raw = skb->data;
7169 - skb_pull(skb, ieee80211_get_hdrlen(fc));
7170 + skb_pull(skb, hdrlen);
7171 + if (prism_header)
7172 + skb_pull(skb, phdrlen);
7173 skb->pkt_type = PACKET_OTHERHOST;
7174 skb->protocol = __constant_htons(ETH_P_80211_RAW);
7175 memset(skb->cb, 0, sizeof(skb->cb));
7176 @@ -64,7 +130,7 @@
7177
7178 /* Called only as a tasklet (software IRQ) */
7179 static struct ieee80211_frag_entry *
7180 -ieee80211_frag_cache_find(struct ieee80211_device *ieee, unsigned int seq,
7181 +ieee80211_frag_cache_find_rtl7(struct ieee80211_device *ieee, unsigned int seq,
7182 unsigned int frag, u8 *src, u8 *dst)
7183 {
7184 struct ieee80211_frag_entry *entry;
7185 @@ -94,7 +160,7 @@
7186
7187 /* Called only as a tasklet (software IRQ) */
7188 static struct sk_buff *
7189 -ieee80211_frag_cache_get(struct ieee80211_device *ieee,
7190 +ieee80211_frag_cache_get_rtl7(struct ieee80211_device *ieee,
7191 struct ieee80211_hdr *hdr)
7192 {
7193 struct sk_buff *skb = NULL;
7194 @@ -133,7 +199,7 @@
7195 } else {
7196 /* received a fragment of a frame for which the head fragment
7197 * should have already been received */
7198 - entry = ieee80211_frag_cache_find(ieee, seq, frag, hdr->addr2,
7199 + entry = ieee80211_frag_cache_find_rtl7(ieee, seq, frag, hdr->addr2,
7200 hdr->addr1);
7201 if (entry != NULL) {
7202 entry->last_frag = frag;
7203 @@ -146,7 +212,7 @@
7204
7205
7206 /* Called only as a tasklet (software IRQ) */
7207 -static int ieee80211_frag_cache_invalidate(struct ieee80211_device *ieee,
7208 +static int ieee80211_frag_cache_invalidate_rtl7(struct ieee80211_device *ieee,
7209 struct ieee80211_hdr *hdr)
7210 {
7211 u16 sc;
7212 @@ -156,7 +222,7 @@
7213 sc = le16_to_cpu(hdr->seq_ctl);
7214 seq = WLAN_GET_SEQ_SEQ(sc);
7215
7216 - entry = ieee80211_frag_cache_find(ieee, seq, -1, hdr->addr2,
7217 + entry = ieee80211_frag_cache_find_rtl7(ieee, seq, -1, hdr->addr2,
7218 hdr->addr1);
7219
7220 if (entry == NULL) {
7221 @@ -178,7 +244,7 @@
7222 *
7223 * Called by ieee80211_rx */
7224 static inline int
7225 -ieee80211_rx_frame_mgmt(struct ieee80211_device *ieee, struct sk_buff *skb,
7226 +ieee80211_rx_frame_mgmt_rtl7(struct ieee80211_device *ieee, struct sk_buff *skb,
7227 struct ieee80211_rx_stats *rx_stats, u16 type,
7228 u16 stype)
7229 {
7230 @@ -187,8 +253,8 @@
7231 * response parser uses it
7232 */
7233 rx_stats->len = skb->len;
7234 - ieee80211_rx_mgt(ieee,(struct ieee80211_hdr *)skb->data,rx_stats);
7235 - ieee80211_rx_frame_softmac(ieee, skb, rx_stats, type, stype);
7236 + ieee80211_rx_mgt_rtl7(ieee,(struct ieee80211_hdr *)skb->data,rx_stats);
7237 + ieee80211_rx_frame_softmac_rtl7(ieee, skb, rx_stats, type, stype);
7238
7239 dev_kfree_skb_any(skb);
7240
7241 @@ -253,7 +319,7 @@
7242 /* No encapsulation header if EtherType < 0x600 (=length) */
7243
7244 /* Called by ieee80211_rx_frame_decrypt */
7245 -static int ieee80211_is_eapol_frame(struct ieee80211_device *ieee,
7246 +static int ieee80211_is_eapol_frame_rtl7(struct ieee80211_device *ieee,
7247 struct sk_buff *skb)
7248 {
7249 struct net_device *dev = ieee->dev;
7250 @@ -294,7 +360,7 @@
7251
7252 /* Called only as a tasklet (software IRQ), by ieee80211_rx */
7253 static inline int
7254 -ieee80211_rx_frame_decrypt(struct ieee80211_device* ieee, struct sk_buff *skb,
7255 +ieee80211_rx_frame_decrypt_rtl7(struct ieee80211_device* ieee, struct sk_buff *skb,
7256 struct ieee80211_crypt_data *crypt)
7257 {
7258 struct ieee80211_hdr *hdr;
7259 @@ -304,7 +370,7 @@
7260 return 0;
7261
7262 hdr = (struct ieee80211_hdr *) skb->data;
7263 - hdrlen = ieee80211_get_hdrlen(le16_to_cpu(hdr->frame_ctl));
7264 + hdrlen = ieee80211_get_hdrlen_rtl7(le16_to_cpu(hdr->frame_ctl));
7265
7266 #ifdef CONFIG_IEEE80211_CRYPT_TKIP
7267 if (ieee->tkip_countermeasures &&
7268 @@ -339,7 +405,7 @@
7269
7270 /* Called only as a tasklet (software IRQ), by ieee80211_rx */
7271 static inline int
7272 -ieee80211_rx_frame_decrypt_msdu(struct ieee80211_device* ieee, struct sk_buff *skb,
7273 +ieee80211_rx_frame_decrypt_msdu_rtl7(struct ieee80211_device* ieee, struct sk_buff *skb,
7274 int keyidx, struct ieee80211_crypt_data *crypt)
7275 {
7276 struct ieee80211_hdr *hdr;
7277 @@ -349,7 +415,7 @@
7278 return 0;
7279
7280 hdr = (struct ieee80211_hdr *) skb->data;
7281 - hdrlen = ieee80211_get_hdrlen(le16_to_cpu(hdr->frame_ctl));
7282 + hdrlen = ieee80211_get_hdrlen_rtl7(le16_to_cpu(hdr->frame_ctl));
7283
7284 atomic_inc(&crypt->refcnt);
7285 res = crypt->ops->decrypt_msdu(skb, keyidx, hdrlen, crypt->priv);
7286 @@ -367,7 +433,7 @@
7287
7288 /* this function is stolen from ipw2200 driver*/
7289 #define IEEE_PACKET_RETRY_TIME (5*HZ)
7290 -static int is_duplicate_packet(struct ieee80211_device *ieee,
7291 +static int is_duplicate_packet_rtl7(struct ieee80211_device *ieee,
7292 struct ieee80211_hdr *header)
7293 {
7294 // u16 fc = le16_to_cpu(header->frame_ctl);
7295 @@ -444,7 +510,7 @@
7296 /* All received frames are sent to this function. @skb contains the frame in
7297 * IEEE 802.11 format, i.e., in the format it was sent over air.
7298 * This function is called only as a tasklet (software IRQ). */
7299 -int ieee80211_rx(struct ieee80211_device *ieee, struct sk_buff *skb,
7300 +int ieee80211_rx_rtl7(struct ieee80211_device *ieee, struct sk_buff *skb,
7301 struct ieee80211_rx_stats *rx_stats)
7302 {
7303 struct net_device *dev = ieee->dev;
7304 @@ -483,7 +549,7 @@
7305 sc = le16_to_cpu(hdr->seq_ctl);
7306
7307 frag = WLAN_GET_SEQ_FRAG(sc);
7308 - hdrlen = ieee80211_get_hdrlen(fc);
7309 + hdrlen = ieee80211_get_hdrlen_rtl7(fc);
7310
7311 #ifdef NOT_YET
7312 #if WIRELESS_EXT > 15
7313 @@ -501,12 +567,12 @@
7314 }
7315 #endif /* IW_WIRELESS_SPY */
7316 #endif /* WIRELESS_EXT > 15 */
7317 - hostap_update_rx_stats(local->ap, hdr, rx_stats);
7318 + hostap_update_rx_stats_rtl7(local->ap, hdr, rx_stats);
7319 #endif
7320
7321 #if WIRELESS_EXT > 15
7322 if (ieee->iw_mode == IW_MODE_MONITOR) {
7323 - ieee80211_monitor_rx(ieee, skb, rx_stats);
7324 + ieee80211_monitor_rx_rtl7(ieee, skb, rx_stats);
7325 stats->rx_packets++;
7326 stats->rx_bytes += skb->len;
7327 return 1;
7328 @@ -529,7 +595,7 @@
7329 * stations that do not support WEP key mapping). */
7330
7331 if (!(hdr->addr1[0] & 0x01) || local->bcrx_sta_key)
7332 - (void) hostap_handle_sta_crypto(local, hdr, &crypt,
7333 + (void) hostap_handle_sta_crypto_rtl7(local, hdr, &crypt,
7334 &sta);
7335 #endif
7336
7337 @@ -555,7 +621,7 @@
7338 if (skb->len < IEEE80211_DATA_HDR3_LEN)
7339 goto rx_dropped;
7340
7341 - if (is_duplicate_packet(ieee, hdr))
7342 + if (is_duplicate_packet_rtl7(ieee, hdr))
7343 goto rx_dropped;
7344
7345
7346 @@ -575,7 +641,7 @@
7347 #endif
7348
7349
7350 - if (ieee80211_rx_frame_mgmt(ieee, skb, rx_stats, type, stype))
7351 + if (ieee80211_rx_frame_mgmt_rtl7(ieee, skb, rx_stats, type, stype))
7352 goto rx_dropped;
7353 else
7354 goto rx_exit;
7355 @@ -606,7 +672,7 @@
7356 }
7357
7358 #ifdef NOT_YET
7359 - if (hostap_rx_frame_wds(ieee, hdr, fc, &wds))
7360 + if (hostap_rx_frame_wds_rtl7(ieee, hdr, fc, &wds))
7361 goto rx_dropped;
7362 if (wds) {
7363 skb->dev = dev = wds;
7364 @@ -619,7 +685,7 @@
7365 memcmp(hdr->addr2, ieee->assoc_ap_addr, ETH_ALEN) == 0) {
7366 /* Frame from BSSID of the AP for which we are a client */
7367 skb->dev = dev = ieee->stadev;
7368 - stats = hostap_get_stats(dev);
7369 + stats = hostap_get_stats_rtl7(dev);
7370 from_assoc_ap = 1;
7371 }
7372 #endif
7373 @@ -630,7 +696,7 @@
7374 if ((ieee->iw_mode == IW_MODE_MASTER ||
7375 ieee->iw_mode == IW_MODE_REPEAT) &&
7376 !from_assoc_ap) {
7377 - switch (hostap_handle_sta_rx(ieee, dev, skb, rx_stats,
7378 + switch (hostap_handle_sta_rx_rtl7(ieee, dev, skb, rx_stats,
7379 wds != NULL)) {
7380 case AP_RX_CONTINUE_NOT_AUTHORIZED:
7381 frame_authorized = 0;
7382 @@ -664,7 +730,7 @@
7383 /* skb: hdr + (possibly fragmented, possibly encrypted) payload */
7384
7385 if (ieee->host_decrypt && (fc & IEEE80211_FCTL_WEP) &&
7386 - (keyidx = ieee80211_rx_frame_decrypt(ieee, skb, crypt)) < 0)
7387 + (keyidx = ieee80211_rx_frame_decrypt_rtl7(ieee, skb, crypt)) < 0)
7388 goto rx_dropped;
7389
7390 hdr = (struct ieee80211_hdr *) skb->data;
7391 @@ -674,7 +740,7 @@
7392 // ieee->host_decrypt && (fc & IEEE80211_FCTL_WEP) &&
7393 if ((frag != 0 || (fc & IEEE80211_FCTL_MOREFRAGS))) {
7394 int flen;
7395 - struct sk_buff *frag_skb = ieee80211_frag_cache_get(ieee, hdr);
7396 + struct sk_buff *frag_skb = ieee80211_frag_cache_get_rtl7(ieee, hdr);
7397 IEEE80211_DEBUG_FRAG("Rx Fragment received (%u)\n", frag);
7398
7399 if (!frag_skb) {
7400 @@ -694,7 +760,7 @@
7401 printk(KERN_WARNING "%s: host decrypted and "
7402 "reassembled frame did not fit skb\n",
7403 dev->name);
7404 - ieee80211_frag_cache_invalidate(ieee, hdr);
7405 + ieee80211_frag_cache_invalidate_rtl7(ieee, hdr);
7406 goto rx_dropped;
7407 }
7408
7409 @@ -722,19 +788,19 @@
7410 * delivered, so remove skb from fragment cache */
7411 skb = frag_skb;
7412 hdr = (struct ieee80211_hdr *) skb->data;
7413 - ieee80211_frag_cache_invalidate(ieee, hdr);
7414 + ieee80211_frag_cache_invalidate_rtl7(ieee, hdr);
7415 }
7416
7417 /* skb: hdr + (possible reassembled) full MSDU payload; possibly still
7418 * encrypted/authenticated */
7419 if (ieee->host_decrypt && (fc & IEEE80211_FCTL_WEP) &&
7420 - ieee80211_rx_frame_decrypt_msdu(ieee, skb, keyidx, crypt))
7421 + ieee80211_rx_frame_decrypt_msdu_rtl7(ieee, skb, keyidx, crypt))
7422 goto rx_dropped;
7423
7424 hdr = (struct ieee80211_hdr *) skb->data;
7425 if (crypt && !(fc & IEEE80211_FCTL_WEP) && !ieee->open_wep) {
7426 if (/*ieee->ieee802_1x &&*/
7427 - ieee80211_is_eapol_frame(ieee, skb)) {
7428 + ieee80211_is_eapol_frame_rtl7(ieee, skb)) {
7429 #ifdef CONFIG_IEEE80211_DEBUG
7430 /* pass unencrypted EAPOL frames even if encryption is
7431 * configured */
7432 @@ -763,7 +829,7 @@
7433 #endif
7434
7435 if (crypt && !(fc & IEEE80211_FCTL_WEP) && !ieee->open_wep &&
7436 - !ieee80211_is_eapol_frame(ieee, skb)) {
7437 + !ieee80211_is_eapol_frame_rtl7(ieee, skb)) {
7438 IEEE80211_DEBUG_DROP(
7439 "dropped unencrypted RX data "
7440 "frame from " MAC_FMT
7441 @@ -896,7 +962,7 @@
7442
7443 #define MGMT_FRAME_FIXED_PART_LENGTH 0x24
7444
7445 -static inline int ieee80211_is_ofdm_rate(u8 rate)
7446 +static inline int ieee80211_is_ofdm_rate_rtl7(u8 rate)
7447 {
7448 switch (rate & ~IEEE80211_BASIC_RATE_MASK) {
7449 case IEEE80211_OFDM_RATE_6MB:
7450 @@ -913,7 +979,7 @@
7451 }
7452
7453
7454 -static inline int ieee80211_network_init(
7455 +static inline int ieee80211_network_init_rtl7(
7456 struct ieee80211_device *ieee,
7457 struct ieee80211_probe_response *beacon,
7458 struct ieee80211_network *network,
7459 @@ -964,7 +1030,7 @@
7460
7461 switch (info_element->id) {
7462 case MFIE_TYPE_SSID:
7463 - if (ieee80211_is_empty_essid(info_element->data,
7464 + if (ieee80211_is_empty_essid_rtl7(info_element->data,
7465 info_element->len)) {
7466 network->flags |= NETWORK_EMPTY_ESSID;
7467 break;
7468 @@ -991,7 +1057,7 @@
7469 #ifdef CONFIG_IEEE80211_DEBUG
7470 p += snprintf(p, sizeof(rates_str) - (p - rates_str), "%02X ", network->rates[i]);
7471 #endif
7472 - if (ieee80211_is_ofdm_rate(info_element->data[i])) {
7473 + if (ieee80211_is_ofdm_rate_rtl7(info_element->data[i])) {
7474 network->flags |= NETWORK_HAS_OFDM;
7475 if (info_element->data[i] &
7476 IEEE80211_BASIC_RATE_MASK)
7477 @@ -1014,7 +1080,7 @@
7478 #ifdef CONFIG_IEEE80211_DEBUG
7479 p += snprintf(p, sizeof(rates_str) - (p - rates_str), "%02X ", network->rates[i]);
7480 #endif
7481 - if (ieee80211_is_ofdm_rate(info_element->data[i])) {
7482 + if (ieee80211_is_ofdm_rate_rtl7(info_element->data[i])) {
7483 network->flags |= NETWORK_HAS_OFDM;
7484 if (info_element->data[i] &
7485 IEEE80211_BASIC_RATE_MASK)
7486 @@ -1147,7 +1213,7 @@
7487 return 1;
7488 }
7489
7490 - if (ieee80211_is_empty_essid(network->ssid, network->ssid_len))
7491 + if (ieee80211_is_empty_essid_rtl7(network->ssid, network->ssid_len))
7492 network->flags |= NETWORK_EMPTY_ESSID;
7493
7494 memcpy(&network->stats, stats, sizeof(network->stats));
7495 @@ -1155,7 +1221,7 @@
7496 return 0;
7497 }
7498
7499 -static inline int is_same_network(struct ieee80211_network *src,
7500 +static inline int is_same_network_rtl7(struct ieee80211_network *src,
7501 struct ieee80211_network *dst)
7502 {
7503 /* A network is only a duplicate if the channel, BSSID, ESSID
7504 @@ -1172,7 +1238,7 @@
7505 (dst->capability & WLAN_CAPABILITY_BSS)));
7506 }
7507
7508 -static inline void update_network(struct ieee80211_network *dst,
7509 +static inline void update_network_rtl7(struct ieee80211_network *dst,
7510 struct ieee80211_network *src)
7511 {
7512 memcpy(&dst->stats, &src->stats, sizeof(struct ieee80211_rx_stats));
7513 @@ -1204,7 +1270,7 @@
7514 /* dst->last_associate is not overwritten */
7515 }
7516
7517 -static inline void ieee80211_process_probe_response(
7518 +static inline void ieee80211_process_probe_response_rtl7(
7519 struct ieee80211_device *ieee,
7520 struct ieee80211_probe_response *beacon,
7521 struct ieee80211_rx_stats *stats)
7522 @@ -1239,7 +1305,7 @@
7523 (beacon->capability & (1<<0x1)) ? '1' : '0',
7524 (beacon->capability & (1<<0x0)) ? '1' : '0');
7525
7526 - if (ieee80211_network_init(ieee, beacon, &network, stats)) {
7527 + if (ieee80211_network_init_rtl7(ieee, beacon, &network, stats)) {
7528 IEEE80211_DEBUG_SCAN("Dropped '%s' (" MAC_FMT ") via %s.\n",
7529 escape_essid(info_element->data,
7530 info_element->len),
7531 @@ -1262,11 +1328,11 @@
7532
7533 spin_lock_irqsave(&ieee->lock, flags);
7534
7535 - if(is_same_network(&ieee->current_network, &network))
7536 - update_network(&ieee->current_network, &network);
7537 + if(is_same_network_rtl7(&ieee->current_network, &network))
7538 + update_network_rtl7(&ieee->current_network, &network);
7539
7540 list_for_each_entry(target, &ieee->network_list, list) {
7541 - if (is_same_network(target, &network))
7542 + if (is_same_network_rtl7(target, &network))
7543 break;
7544
7545 if ((oldest == NULL) ||
7546 @@ -1306,7 +1372,7 @@
7547 memcpy(target, &network, sizeof(*target));
7548 list_add_tail(&target->list, &ieee->network_list);
7549 if(ieee->softmac_features & IEEE_SOFTMAC_ASSOCIATE)
7550 - ieee80211_softmac_new_net(ieee,&network);
7551 + ieee80211_softmac_new_net_rtl7(ieee,&network);
7552 } else {
7553 IEEE80211_DEBUG_SCAN("Updating '%s' (" MAC_FMT ") via %s.\n",
7554 escape_essid(target->ssid,
7555 @@ -1321,15 +1387,15 @@
7556 * net and call the new_net handler
7557 */
7558 renew = !time_after(target->last_scanned + ieee->scan_age, jiffies);
7559 - update_network(target, &network);
7560 + update_network_rtl7(target, &network);
7561 if(renew && (ieee->softmac_features & IEEE_SOFTMAC_ASSOCIATE))
7562 - ieee80211_softmac_new_net(ieee,&network);
7563 + ieee80211_softmac_new_net_rtl7(ieee,&network);
7564 }
7565
7566 spin_unlock_irqrestore(&ieee->lock, flags);
7567 }
7568
7569 -void ieee80211_rx_mgt(struct ieee80211_device *ieee,
7570 +void ieee80211_rx_mgt_rtl7(struct ieee80211_device *ieee,
7571 struct ieee80211_hdr *header,
7572 struct ieee80211_rx_stats *stats)
7573 {
7574 @@ -1339,7 +1405,7 @@
7575 IEEE80211_DEBUG_MGMT("received BEACON (%d)\n",
7576 WLAN_FC_GET_STYPE(header->frame_ctl));
7577 IEEE80211_DEBUG_SCAN("Beacon\n");
7578 - ieee80211_process_probe_response(
7579 + ieee80211_process_probe_response_rtl7(
7580 ieee, (struct ieee80211_probe_response *)header, stats);
7581 break;
7582
7583 @@ -1347,7 +1413,7 @@
7584 IEEE80211_DEBUG_MGMT("received PROBE RESPONSE (%d)\n",
7585 WLAN_FC_GET_STYPE(header->frame_ctl));
7586 IEEE80211_DEBUG_SCAN("Probe response\n");
7587 - ieee80211_process_probe_response(
7588 + ieee80211_process_probe_response_rtl7(
7589 ieee, (struct ieee80211_probe_response *)header, stats);
7590 break;
7591
7592 @@ -1355,5 +1421,5 @@
7593 }
7594
7595
7596 -EXPORT_SYMBOL(ieee80211_rx_mgt);
7597 -EXPORT_SYMBOL(ieee80211_rx);
7598 +EXPORT_SYMBOL(ieee80211_rx_mgt_rtl7);
7599 +EXPORT_SYMBOL(ieee80211_rx_rtl7);
7600 diff -Naur rtl8187_orig/ieee80211/ieee80211_softmac.c rtl8187_rawtx/ieee80211/ieee80211_softmac.c
7601 --- rtl8187_orig/ieee80211/ieee80211_softmac.c 2007-03-13 23:45:09.000000000 +0100
7602 +++ rtl8187_rawtx/ieee80211/ieee80211_softmac.c 2007-06-05 14:00:29.000000000 +0200
7603 @@ -1,14 +1,14 @@
7604 /* IEEE 802.11 SoftMAC layer
7605 * Copyright (c) 2005 Andrea Merello <[email protected]>
7606 *
7607 - * Mostly extracted from the rtl8180-sa2400 driver for the
7608 + * Mostly extracted from the rtl8180-sa2400 driver for the
7609 * in-kernel generic ieee802.11 stack.
7610 *
7611 * Few lines might be stolen from other part of the ieee80211
7612 * stack. Copyright who own it's copyright
7613 *
7614 * WPA code stolen from the ipw2200 driver.
7615 - * Copyright who own it's copyright.
7616 + * Copyright who own it's copyright.
7617 *
7618 * released under the GPL
7619 */
7620 @@ -20,12 +20,12 @@
7621 #include <linux/delay.h>
7622 #include <linux/version.h>
7623
7624 -short ieee80211_is_54g(struct ieee80211_network net)
7625 +short ieee80211_is_54g_rtl7(struct ieee80211_network net)
7626 {
7627 return ((net.rates_ex_len > 0) || (net.rates_len > 4));
7628 }
7629
7630 -short ieee80211_is_shortslot(struct ieee80211_network net)
7631 +short ieee80211_is_shortslot_rtl7(struct ieee80211_network net)
7632 {
7633 return (net.capability & WLAN_CAPABILITY_SHORT_SLOT);
7634 }
7635 @@ -34,28 +34,28 @@
7636 * tag and the EXTENDED RATE MFIE tag if needed.
7637 * It encludes two bytes per tag for the tag itself and its len
7638 */
7639 -unsigned int ieee80211_MFIE_rate_len(struct ieee80211_device *ieee)
7640 +unsigned int ieee80211_MFIE_rate_len_rtl7(struct ieee80211_device *ieee)
7641 {
7642 unsigned int rate_len = 0;
7643 -
7644 +
7645 if (ieee->modulation & IEEE80211_CCK_MODULATION)
7646 rate_len = IEEE80211_CCK_RATE_LEN + 2;
7647 -
7648 +
7649 if (ieee->modulation & IEEE80211_OFDM_MODULATION)
7650 -
7651 +
7652 rate_len += IEEE80211_OFDM_RATE_LEN + 2;
7653 -
7654 +
7655 return rate_len;
7656 }
7657
7658 -/* pleace the MFIE rate, tag to the memory (double) poined.
7659 +/* pleace the MFIE rate, tag to the memory (double) poined.
7660 * Then it updates the pointer so that
7661 * it points after the new MFIE tag added.
7662 - */
7663 -void ieee80211_MFIE_Brate(struct ieee80211_device *ieee, u8 **tag_p)
7664 + */
7665 +void ieee80211_MFIE_Brate_rtl7(struct ieee80211_device *ieee, u8 **tag_p)
7666 {
7667 - u8 *tag = *tag_p;
7668 -
7669 + u8 *tag = *tag_p;
7670 +
7671 if (ieee->modulation & IEEE80211_CCK_MODULATION){
7672 *tag++ = MFIE_TYPE_RATES;
7673 *tag++ = 4;
7674 @@ -64,17 +64,17 @@
7675 *tag++ = IEEE80211_BASIC_RATE_MASK | IEEE80211_CCK_RATE_5MB;
7676 *tag++ = IEEE80211_BASIC_RATE_MASK | IEEE80211_CCK_RATE_11MB;
7677 }
7678 -
7679 +
7680 /* We may add an option for custom rates that specific HW might support */
7681 *tag_p = tag;
7682 }
7683
7684 -void ieee80211_MFIE_Grate(struct ieee80211_device *ieee, u8 **tag_p)
7685 -{
7686 - u8 *tag = *tag_p;
7687 -
7688 +void ieee80211_MFIE_Grate_rtl7(struct ieee80211_device *ieee, u8 **tag_p)
7689 +{
7690 + u8 *tag = *tag_p;
7691 +
7692 if (ieee->modulation & IEEE80211_OFDM_MODULATION){
7693 -
7694 +
7695 *tag++ = MFIE_TYPE_RATES_EX;
7696 *tag++ = 8;
7697 *tag++ = IEEE80211_BASIC_RATE_MASK | IEEE80211_OFDM_RATE_6MB;
7698 @@ -85,73 +85,73 @@
7699 *tag++ = IEEE80211_BASIC_RATE_MASK | IEEE80211_OFDM_RATE_36MB;
7700 *tag++ = IEEE80211_BASIC_RATE_MASK | IEEE80211_OFDM_RATE_48MB;
7701 *tag++ = IEEE80211_BASIC_RATE_MASK | IEEE80211_OFDM_RATE_54MB;
7702 -
7703 +
7704 }
7705 -
7706 +
7707 /* We may add an option for custom rates that specific HW might support */
7708 *tag_p = tag;
7709 }
7710
7711 -void enqueue_mgmt(struct ieee80211_device *ieee, struct sk_buff *skb)
7712 +void enqueue_mgmt_rtl7(struct ieee80211_device *ieee, struct sk_buff *skb)
7713 {
7714 int nh;
7715 nh = (ieee->mgmt_queue_head +1) % MGMT_QUEUE_NUM;
7716 -
7717 +
7718 /*
7719 * if the queue is full but we have newer frames then
7720 * just overwrites the oldest.
7721 - *
7722 + *
7723 * if (nh == ieee->mgmt_queue_tail)
7724 * return -1;
7725 - */
7726 + */
7727 ieee->mgmt_queue_head = nh;
7728 ieee->mgmt_queue_ring[nh] = skb;
7729 -
7730 +
7731 //return 0;
7732 }
7733
7734 -struct sk_buff *dequeue_mgmt(struct ieee80211_device *ieee)
7735 +struct sk_buff *dequeue_mgmt_rtl7(struct ieee80211_device *ieee)
7736 {
7737 struct sk_buff *ret;
7738 -
7739 +
7740 if(ieee->mgmt_queue_tail == ieee->mgmt_queue_head)
7741 return NULL;
7742 -
7743 +
7744 ret = ieee->mgmt_queue_ring[ieee->mgmt_queue_tail];
7745 -
7746 - ieee->mgmt_queue_tail =
7747 +
7748 + ieee->mgmt_queue_tail =
7749 (ieee->mgmt_queue_tail+1) % MGMT_QUEUE_NUM;
7750 -
7751 +
7752 return ret;
7753 }
7754
7755 -void init_mgmt_queue(struct ieee80211_device *ieee)
7756 +void init_mgmt_queue_rtl7(struct ieee80211_device *ieee)
7757 {
7758 ieee->mgmt_queue_tail = ieee->mgmt_queue_head = 0;
7759 }
7760
7761
7762 -void ieee80211_sta_wakeup(struct ieee80211_device *ieee, short nl);
7763 +void ieee80211_sta_wakeup_rtl7(struct ieee80211_device *ieee, short nl);
7764
7765 -inline void softmac_mgmt_xmit(struct sk_buff *skb, struct ieee80211_device *ieee)
7766 +inline void softmac_mgmt_xmit_rtl7(struct sk_buff *skb, struct ieee80211_device *ieee)
7767 {
7768 unsigned long flags;
7769 short single = ieee->softmac_features & IEEE_SOFTMAC_SINGLE_QUEUE;
7770 struct ieee80211_hdr_3addr *header=
7771 (struct ieee80211_hdr_3addr *) skb->data;
7772 -
7773 -
7774 +
7775 +
7776 spin_lock_irqsave(&ieee->lock, flags);
7777 -
7778 +
7779 /* called with 2nd param 0, no mgmt lock required */
7780 - ieee80211_sta_wakeup(ieee,0);
7781 -
7782 + ieee80211_sta_wakeup_rtl7(ieee,0);
7783 +
7784 if(single){
7785 -
7786 +
7787 if(ieee->queue_stop){
7788 -
7789 - enqueue_mgmt(ieee,skb);
7790 -
7791 +
7792 + enqueue_mgmt_rtl7(ieee,skb);
7793 +
7794 }else{
7795 header->seq_ctl = cpu_to_le16(ieee->seq_ctrl << 4);
7796
7797 @@ -159,119 +159,119 @@
7798 ieee->seq_ctrl = 0;
7799 else
7800 ieee->seq_ctrl++;
7801 -
7802 +
7803 /* avoid watchdog triggers */
7804 ieee->dev->trans_start = jiffies;
7805 ieee->softmac_data_hard_start_xmit(skb,ieee->dev,ieee->basic_rate);
7806 }
7807 -
7808 +
7809 spin_unlock_irqrestore(&ieee->lock, flags);
7810 }else{
7811 spin_unlock_irqrestore(&ieee->lock, flags);
7812 spin_lock_irqsave(&ieee->mgmt_tx_lock, flags);
7813 -
7814 +
7815 header->seq_ctl = cpu_to_le16(ieee->seq_ctrl << 4);
7816 -
7817 +
7818 if (ieee->seq_ctrl == 0xFFF)
7819 ieee->seq_ctrl = 0;
7820 else
7821 ieee->seq_ctrl++;
7822 -
7823 +
7824 ieee->softmac_hard_start_xmit(skb,ieee->dev);
7825 -
7826 +
7827 spin_unlock_irqrestore(&ieee->mgmt_tx_lock, flags);
7828 }
7829 }
7830
7831
7832 -inline void softmac_ps_mgmt_xmit(struct sk_buff *skb, struct ieee80211_device *ieee)
7833 +inline void softmac_ps_mgmt_xmit_rtl7(struct sk_buff *skb, struct ieee80211_device *ieee)
7834 {
7835 -
7836 +
7837 short single = ieee->softmac_features & IEEE_SOFTMAC_SINGLE_QUEUE;
7838 struct ieee80211_hdr_3addr *header =
7839 (struct ieee80211_hdr_3addr *) skb->data;
7840 -
7841 -
7842 +
7843 +
7844 if(single){
7845 -
7846 +
7847 header->seq_ctl = cpu_to_le16(ieee->seq_ctrl << 4);
7848
7849 if (ieee->seq_ctrl == 0xFFF)
7850 ieee->seq_ctrl = 0;
7851 else
7852 ieee->seq_ctrl++;
7853 -
7854 +
7855 /* avoid watchdog triggers */
7856 ieee->dev->trans_start = jiffies;
7857 ieee->softmac_data_hard_start_xmit(skb,ieee->dev,ieee->basic_rate);
7858 -
7859 +
7860 }else{
7861 -
7862 +
7863 header->seq_ctl = cpu_to_le16(ieee->seq_ctrl << 4);
7864 -
7865 +
7866 if (ieee->seq_ctrl == 0xFFF)
7867 ieee->seq_ctrl = 0;
7868 else
7869 ieee->seq_ctrl++;
7870
7871 ieee->softmac_hard_start_xmit(skb,ieee->dev);
7872 -
7873 +
7874 }
7875 }
7876
7877 -inline struct sk_buff *ieee80211_probe_req(struct ieee80211_device *ieee)
7878 +inline struct sk_buff *ieee80211_probe_req_rtl7(struct ieee80211_device *ieee)
7879 {
7880 unsigned int len,rate_len;
7881 u8 *tag;
7882 struct sk_buff *skb;
7883 struct ieee80211_probe_request *req;
7884 -
7885 +
7886 len = ieee->current_network.ssid_len;
7887 -
7888 - rate_len = ieee80211_MFIE_rate_len(ieee);
7889 -
7890 +
7891 + rate_len = ieee80211_MFIE_rate_len_rtl7(ieee);
7892 +
7893 skb = dev_alloc_skb(sizeof(struct ieee80211_probe_request) +
7894 2 + len + rate_len);
7895 -
7896 - if (!skb)
7897 +
7898 + if (!skb)
7899 return NULL;
7900 -
7901 +
7902 req = (struct ieee80211_probe_request *) skb_put(skb,sizeof(struct ieee80211_probe_request));
7903 req->header.frame_ctl = cpu_to_le16(IEEE80211_STYPE_PROBE_REQ);
7904 - req->header.duration_id = 0; //FIXME: is this OK ?
7905 -
7906 + req->header.duration_id = 0; //FIXME: is this OK ?
7907 +
7908 memset(req->header.addr1, 0xff, ETH_ALEN);
7909 memcpy(req->header.addr2, ieee->dev->dev_addr, ETH_ALEN);
7910 memset(req->header.addr3, 0xff, ETH_ALEN);
7911 -
7912 +
7913 tag = (u8 *) skb_put(skb,len+2+rate_len);
7914 -
7915 +
7916 *tag++ = MFIE_TYPE_SSID;
7917 *tag++ = len;
7918 memcpy(tag, ieee->current_network.ssid, len);
7919 tag += len;
7920 -
7921 - ieee80211_MFIE_Brate(ieee,&tag);
7922 - ieee80211_MFIE_Grate(ieee,&tag);
7923 +
7924 + ieee80211_MFIE_Brate_rtl7(ieee,&tag);
7925 + ieee80211_MFIE_Grate_rtl7(ieee,&tag);
7926 return skb;
7927 }
7928
7929 -struct sk_buff *ieee80211_get_beacon_(struct ieee80211_device *ieee);
7930 -void ieee80211_send_beacon(struct ieee80211_device *ieee)
7931 +struct sk_buff *ieee80211_get_beacon__rtl7(struct ieee80211_device *ieee);
7932 +void ieee80211_send_beacon_rtl7(struct ieee80211_device *ieee)
7933 {
7934 struct sk_buff *skb;
7935 -
7936 - unsigned long flags;
7937 -
7938 - skb = ieee80211_get_beacon_(ieee);
7939 +
7940 + unsigned long flags;
7941 +
7942 + skb = ieee80211_get_beacon__rtl7(ieee);
7943 if (skb){
7944 - softmac_mgmt_xmit(skb, ieee);
7945 + softmac_mgmt_xmit_rtl7(skb, ieee);
7946 ieee->softmac_stats.tx_beacons++;
7947 }
7948
7949 - ieee->beacon_timer.expires = jiffies +
7950 + ieee->beacon_timer.expires = jiffies +
7951 (MSECS( ieee->current_network.beacon_interval -5));
7952 -
7953 +
7954 spin_lock_irqsave(&ieee->beacon_lock,flags);
7955 if(ieee->beacon_txing)
7956 add_timer(&ieee->beacon_timer);
7957 @@ -279,57 +279,57 @@
7958 }
7959
7960
7961 -void ieee80211_send_beacon_cb(unsigned long _ieee)
7962 +void ieee80211_send_beacon_cb_rtl7(unsigned long _ieee)
7963 {
7964 struct ieee80211_device *ieee =
7965 (struct ieee80211_device *) _ieee;
7966 - ieee80211_send_beacon(ieee);
7967 + ieee80211_send_beacon_rtl7(ieee);
7968 }
7969
7970
7971 -void ieee80211_send_probe(struct ieee80211_device *ieee)
7972 +void ieee80211_send_probe_rtl7(struct ieee80211_device *ieee)
7973 {
7974 struct sk_buff *skb;
7975 -
7976 - skb = ieee80211_probe_req(ieee);
7977 +
7978 + skb = ieee80211_probe_req_rtl7(ieee);
7979 if (skb){
7980 - softmac_mgmt_xmit(skb, ieee);
7981 + softmac_mgmt_xmit_rtl7(skb, ieee);
7982 ieee->softmac_stats.tx_probe_rq++;
7983 }
7984 }
7985
7986 -void ieee80211_send_probe_requests(struct ieee80211_device *ieee)
7987 +void ieee80211_send_probe_requests_rtl7(struct ieee80211_device *ieee)
7988 {
7989 if (ieee->active_scan && (ieee->softmac_features & IEEE_SOFTMAC_PROBERQ)){
7990 - ieee80211_send_probe(ieee);
7991 - ieee80211_send_probe(ieee);
7992 + ieee80211_send_probe_rtl7(ieee);
7993 + ieee80211_send_probe_rtl7(ieee);
7994 }
7995 }
7996
7997 /* this performs syncro scan blocking the caller until all channels
7998 - * in the allowed channel map has been checked.
7999 + * in the allowed channel map has been checked.
8000 */
8001 -void ieee80211_softmac_scan_syncro(struct ieee80211_device *ieee)
8002 +void ieee80211_softmac_scan_syncro_rtl7(struct ieee80211_device *ieee)
8003 {
8004 short ch = 0;
8005 -
8006 +
8007 down(&ieee->scan_sem);
8008 -
8009 +
8010 while(1)
8011 {
8012 -
8013 +
8014 do{
8015 ch++;
8016 - if (ch > MAX_CHANNEL_NUMBER)
8017 + if (ch > MAX_CHANNEL_NUMBER)
8018 goto out; /* scan completed */
8019 -
8020 +
8021 }while(!ieee->channel_map[ch]);
8022 -
8023 +
8024 /* this fuction can be called in two situations
8025 * 1- We have switched to ad-hoc mode and we are
8026 * performing a complete syncro scan before conclude
8027 - * there are no interesting cell and to create a
8028 - * new one. In this case the link state is
8029 + * there are no interesting cell and to create a
8030 + * new one. In this case the link state is
8031 * IEEE80211_NOLINK until we found an interesting cell.
8032 * If so the ieee8021_new_net, called by the RX path
8033 * will set the state to IEEE80211_LINKED, so we stop
8034 @@ -342,24 +342,24 @@
8035 * not filter RX frames and the channel is changing.
8036 * So the only situation in witch are interested is to check
8037 * if the state become LINKED because of the #1 situation
8038 - */
8039 -
8040 + */
8041 +
8042 if (ieee->state == IEEE80211_LINKED)
8043 goto out;
8044 -
8045 +
8046 ieee->set_chan(ieee->dev, ch);
8047 -
8048 - ieee80211_send_probe_requests(ieee);
8049 -
8050 +
8051 + ieee80211_send_probe_requests_rtl7(ieee);
8052 +
8053 /* this prevent excessive time wait when we
8054 * need to wait for a syncro scan to end..
8055 - */
8056 + */
8057 if (ieee->sync_scan_hurryup)
8058 goto out;
8059
8060
8061 msleep_interruptible_rtl(IEEE80211_SOFTMAC_SCAN_TIME);
8062 -
8063 +
8064 }
8065 out:
8066 ieee->sync_scan_hurryup = 0;
8067 @@ -370,43 +370,49 @@
8068 void ieee80211_softmac_scan(struct ieee80211_device *ieee)
8069 {
8070 short watchdog = 0;
8071 -
8072 +
8073 do{
8074 - ieee->current_network.channel =
8075 + ieee->current_network.channel =
8076 (ieee->current_network.channel + 1) % MAX_CHANNEL_NUMBER;
8077 - if (watchdog++ > MAX_CHANNEL_NUMBER)
8078 + if (watchdog++ > MAX_CHANNEL_NUMBER)
8079 return; /* no good chans */
8080 -
8081 +
8082 }while(!ieee->channel_map[ieee->current_network.channel]);
8083 -
8084 +
8085
8086 schedule_work(&ieee->softmac_scan_wq);
8087 }
8088 #endif
8089
8090 -void ieee80211_softmac_scan_wq(struct ieee80211_device *ieee)
8091 -{
8092 - down(&ieee->scan_sem);
8093 -
8094 +# if (LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,20))
8095 +void ieee80211_softmac_scan_wq_rtl7(struct work_struct *work)
8096 +{
8097 + struct delayed_work *dwork = container_of(work, struct delayed_work, work);
8098 + struct ieee80211_device *ieee = container_of(dwork, struct ieee80211_device, softmac_scan_wq);
8099 +#else
8100 +void ieee80211_softmac_scan_wq_rtl7(struct ieee80211_device *ieee)
8101 +{
8102 +#endif
8103 short watchdog = 0;
8104 -
8105 + down(&ieee->scan_sem);
8106 +
8107 do{
8108 - ieee->current_network.channel =
8109 + ieee->current_network.channel =
8110 (ieee->current_network.channel + 1) % MAX_CHANNEL_NUMBER;
8111 - if (watchdog++ > MAX_CHANNEL_NUMBER)
8112 + if (watchdog++ > MAX_CHANNEL_NUMBER)
8113 goto out; /* no good chans */
8114 -
8115 +
8116 }while(!ieee->channel_map[ieee->current_network.channel]);
8117 -
8118 +
8119 if (ieee->scanning == 0 )
8120 goto out;
8121 -
8122 +
8123 ieee->set_chan(ieee->dev, ieee->current_network.channel);
8124 - ieee80211_send_probe_requests(ieee);
8125 + ieee80211_send_probe_requests_rtl7(ieee);
8126
8127 -#if 0
8128 +#if 0
8129 ieee->.expires = jiffies + (IEEE80211_SOFTMAC_SCAN_TIME);
8130 - if (ieee->scanning == 1)
8131 + if (ieee->scanning == 1)
8132 add_timer(&ieee->scan_timer);
8133 #endif
8134 queue_delayed_work(ieee->wq, &ieee->softmac_scan_wq, IEEE80211_SOFTMAC_SCAN_TIME);
8135 @@ -419,7 +425,7 @@
8136 {
8137 unsigned long flags;
8138 struct ieee80211_device *ieee = (struct ieee80211_device *)_dev;
8139 -
8140 +
8141 spin_lock_irqsave(&ieee->lock, flags);
8142 ieee80211_softmac_scan(ieee);
8143 spin_unlock_irqrestore(&ieee->lock, flags);
8144 @@ -427,19 +433,19 @@
8145 #endif
8146
8147
8148 -void ieee80211_beacons_start(struct ieee80211_device *ieee)
8149 +void ieee80211_beacons_start_rtl7(struct ieee80211_device *ieee)
8150 {
8151 - unsigned long flags;
8152 + unsigned long flags;
8153
8154 spin_lock_irqsave(&ieee->beacon_lock,flags);
8155
8156 ieee->beacon_txing = 1;
8157 - ieee80211_send_beacon(ieee);
8158 -
8159 + ieee80211_send_beacon_rtl7(ieee);
8160 +
8161 spin_unlock_irqrestore(&ieee->beacon_lock,flags);
8162 }
8163
8164 -void ieee80211_beacons_stop(struct ieee80211_device *ieee)
8165 +void ieee80211_beacons_stop_rtl7(struct ieee80211_device *ieee)
8166 {
8167 unsigned long flags;
8168
8169 @@ -453,111 +459,111 @@
8170 }
8171
8172
8173 -void ieee80211_stop_send_beacons(struct ieee80211_device *ieee)
8174 +void ieee80211_stop_send_beacons_rtl7(struct ieee80211_device *ieee)
8175 {
8176 if(ieee->stop_send_beacons)
8177 ieee->stop_send_beacons(ieee->dev);
8178 if (ieee->softmac_features & IEEE_SOFTMAC_BEACONS)
8179 - ieee80211_beacons_stop(ieee);
8180 + ieee80211_beacons_stop_rtl7(ieee);
8181 }
8182
8183
8184 -void ieee80211_start_send_beacons(struct ieee80211_device *ieee)
8185 +void ieee80211_start_send_beacons_rtl7(struct ieee80211_device *ieee)
8186 {
8187 if(ieee->start_send_beacons)
8188 ieee->start_send_beacons(ieee->dev);
8189 if(ieee->softmac_features & IEEE_SOFTMAC_BEACONS)
8190 - ieee80211_beacons_start(ieee);
8191 + ieee80211_beacons_start_rtl7(ieee);
8192 }
8193
8194
8195 -void ieee80211_softmac_stop_scan(struct ieee80211_device *ieee)
8196 +void ieee80211_softmac_stop_scan_rtl7(struct ieee80211_device *ieee)
8197 {
8198 -// unsigned long flags;
8199 -
8200 +// unsigned long flags;
8201 +
8202 //ieee->sync_scan_hurryup = 1;
8203 -
8204 +
8205 down(&ieee->scan_sem);
8206 // spin_lock_irqsave(&ieee->lock, flags);
8207 -
8208 +
8209 if (ieee->scanning == 1){
8210 ieee->scanning = 0;
8211 //del_timer_sync(&ieee->scan_timer);
8212 cancel_delayed_work(&ieee->softmac_scan_wq);
8213 }
8214 -
8215 +
8216 // spin_unlock_irqrestore(&ieee->lock, flags);
8217 up(&ieee->scan_sem);
8218 }
8219
8220 -void ieee80211_stop_scan(struct ieee80211_device *ieee)
8221 +void ieee80211_stop_scan_rtl7(struct ieee80211_device *ieee)
8222 {
8223 if (ieee->softmac_features & IEEE_SOFTMAC_SCAN)
8224 - ieee80211_softmac_stop_scan(ieee);
8225 + ieee80211_softmac_stop_scan_rtl7(ieee);
8226 else
8227 ieee->stop_scan(ieee->dev);
8228 }
8229
8230 /* called with ieee->lock held */
8231 -void ieee80211_start_scan(struct ieee80211_device *ieee)
8232 +void ieee80211_start_scan_rtl7(struct ieee80211_device *ieee)
8233 {
8234 - if (ieee->softmac_features & IEEE_SOFTMAC_SCAN){
8235 + if (ieee->softmac_features & IEEE_SOFTMAC_SCAN){
8236 if (ieee->scanning == 0){
8237 ieee->scanning = 1;
8238 //ieee80211_softmac_scan(ieee);
8239 - queue_work(ieee->wq, &ieee->softmac_scan_wq);
8240 + queue_delayed_work(ieee->wq, &ieee->softmac_scan_wq, 0);
8241 }
8242 }else
8243 ieee->start_scan(ieee->dev);
8244 -
8245 +
8246 }
8247
8248 /* called with wx_sem held */
8249 -void ieee80211_start_scan_syncro(struct ieee80211_device *ieee)
8250 +void ieee80211_start_scan_syncro_rtl7(struct ieee80211_device *ieee)
8251 {
8252 ieee->sync_scan_hurryup = 0;
8253 -
8254 +
8255 if (ieee->softmac_features & IEEE_SOFTMAC_SCAN)
8256 - ieee80211_softmac_scan_syncro(ieee);
8257 + ieee80211_softmac_scan_syncro_rtl7(ieee);
8258 else
8259 ieee->scan_syncro(ieee->dev);
8260 -
8261 +
8262 }
8263
8264 -inline struct sk_buff *ieee80211_authentication_req(struct ieee80211_network *beacon,
8265 +inline struct sk_buff *ieee80211_authentication_req_rtl7(struct ieee80211_network *beacon,
8266 struct ieee80211_device *ieee, int challengelen)
8267 {
8268 - struct sk_buff *skb;
8269 + struct sk_buff *skb;
8270 struct ieee80211_authentication *auth;
8271 -
8272 - skb = dev_alloc_skb(sizeof(struct ieee80211_authentication) + challengelen);
8273 -
8274 +
8275 + skb = dev_alloc_skb(sizeof(struct ieee80211_authentication) + challengelen);
8276 +
8277 if (!skb) return NULL;
8278 -
8279 +
8280 auth = (struct ieee80211_authentication *)
8281 skb_put(skb, sizeof(struct ieee80211_authentication));
8282 -
8283 +
8284 auth->header.frame_ctl = IEEE80211_STYPE_AUTH;
8285 if (challengelen) auth->header.frame_ctl |= IEEE80211_FCTL_WEP;
8286 -
8287 +
8288 auth->header.duration_id = 0x013a; //FIXME
8289 -
8290 +
8291 memcpy(auth->header.addr1, beacon->bssid, ETH_ALEN);
8292 memcpy(auth->header.addr2, ieee->dev->dev_addr, ETH_ALEN);
8293 memcpy(auth->header.addr3, beacon->bssid, ETH_ALEN);
8294 -
8295 +
8296 auth->algorithm = ieee->open_wep ? WLAN_AUTH_OPEN : WLAN_AUTH_SHARED_KEY;
8297 -
8298 +
8299 auth->transaction = cpu_to_le16(ieee->associate_seq);
8300 ieee->associate_seq++;
8301 -
8302 +
8303 auth->status = cpu_to_le16(WLAN_STATUS_SUCCESS);
8304 -
8305 +
8306 return skb;
8307 -
8308 +
8309 }
8310
8311 -static struct sk_buff* ieee80211_probe_resp(struct ieee80211_device *ieee, u8 *dest)
8312 +static struct sk_buff* ieee80211_probe_resp_rtl7(struct ieee80211_device *ieee, u8 *dest)
8313 {
8314 u8 *tag;
8315 int beacon_size;
8316 @@ -566,23 +572,23 @@
8317 int encrypt;
8318 int atim_len,erp_len;
8319 struct ieee80211_crypt_data* crypt;
8320 -
8321 +
8322 char *ssid = ieee->current_network.ssid;
8323 int ssid_len = ieee->current_network.ssid_len;
8324 int rate_len = ieee->current_network.rates_len+2;
8325 int rate_ex_len = ieee->current_network.rates_ex_len;
8326 if(rate_ex_len > 0) rate_ex_len+=2;
8327 -
8328 +
8329 if(ieee->current_network.capability & WLAN_CAPABILITY_IBSS)
8330 atim_len = 4;
8331 else
8332 atim_len = 0;
8333 -
8334 - if(ieee80211_is_54g(ieee->current_network))
8335 +
8336 + if(ieee80211_is_54g_rtl7(ieee->current_network))
8337 erp_len = 3;
8338 else
8339 erp_len = 0;
8340 -
8341 +
8342 beacon_size = sizeof(struct ieee80211_probe_response)+
8343 ssid_len
8344 +3 //channel
8345 @@ -590,72 +596,72 @@
8346 +rate_ex_len
8347 +atim_len
8348 +erp_len;
8349 -
8350 +
8351 skb = dev_alloc_skb(beacon_size);
8352 -
8353 - if (!skb)
8354 +
8355 + if (!skb)
8356 return NULL;
8357 -
8358 +
8359 beacon_buf = (struct ieee80211_probe_response*) skb_put(skb, beacon_size);
8360 -
8361 +
8362 memcpy (beacon_buf->header.addr1, dest,ETH_ALEN);
8363 memcpy (beacon_buf->header.addr2, ieee->dev->dev_addr, ETH_ALEN);
8364 memcpy (beacon_buf->header.addr3, ieee->current_network.bssid, ETH_ALEN);
8365
8366 beacon_buf->header.duration_id = 0; //FIXME
8367 - beacon_buf->beacon_interval =
8368 + beacon_buf->beacon_interval =
8369 cpu_to_le16(ieee->current_network.beacon_interval);
8370 - beacon_buf->capability =
8371 + beacon_buf->capability =
8372 cpu_to_le16(ieee->current_network.capability & WLAN_CAPABILITY_IBSS);
8373 -
8374 +
8375 if(ieee->short_slot && (ieee->current_network.capability & WLAN_CAPABILITY_SHORT_SLOT))
8376 - cpu_to_le16((beacon_buf->capability |= WLAN_CAPABILITY_SHORT_SLOT));
8377 -
8378 + cpu_to_le16((beacon_buf->capability |= WLAN_CAPABILITY_SHORT_SLOT));
8379 +
8380 crypt = ieee->crypt[ieee->tx_keyidx];
8381
8382 - encrypt = ieee->host_encrypt && crypt && crypt->ops &&
8383 + encrypt = ieee->host_encrypt && crypt && crypt->ops &&
8384 (0 == strcmp(crypt->ops->name, "WEP"));
8385
8386 - if (encrypt)
8387 + if (encrypt)
8388 beacon_buf->capability |= cpu_to_le16(WLAN_CAPABILITY_PRIVACY);
8389 -
8390 -
8391 +
8392 +
8393 beacon_buf->header.frame_ctl = cpu_to_le16(IEEE80211_STYPE_PROBE_RESP);
8394 -
8395 - beacon_buf->info_element.id = MFIE_TYPE_SSID;
8396 +
8397 + beacon_buf->info_element.id = MFIE_TYPE_SSID;
8398 beacon_buf->info_element.len = ssid_len;
8399 -
8400 +
8401 tag = (u8*) beacon_buf->info_element.data;
8402 -
8403 +
8404 memcpy(tag, ssid, ssid_len);
8405 -
8406 +
8407 tag += ssid_len;
8408 -
8409 +
8410 *(tag++) = MFIE_TYPE_RATES;
8411 - *(tag++) = rate_len-2;
8412 + *(tag++) = rate_len-2;
8413 memcpy(tag,ieee->current_network.rates,rate_len-2);
8414 tag+=rate_len-2;
8415 -
8416 +
8417 *(tag++) = MFIE_TYPE_DS_SET;
8418 *(tag++) = 1;
8419 *(tag++) = ieee->current_network.channel;
8420 -
8421 +
8422 if(atim_len){
8423 *(tag++) = MFIE_TYPE_IBSS_SET;
8424 *(tag++) = 2;
8425 *((u16*)(tag)) = cpu_to_le16(ieee->current_network.atim_window);
8426 tag+=2;
8427 }
8428 -
8429 +
8430 if(erp_len){
8431 *(tag++) = MFIE_TYPE_ERP;
8432 *(tag++) = 1;
8433 - *(tag++) = 0;
8434 + *(tag++) = 0;
8435 }
8436 -
8437 +
8438 if(rate_ex_len){
8439 *(tag++) = MFIE_TYPE_RATES_EX;
8440 - *(tag++) = rate_ex_len-2;
8441 + *(tag++) = rate_ex_len-2;
8442 memcpy(tag,ieee->current_network.rates_ex,rate_ex_len-2);
8443 tag+=rate_ex_len-2;
8444 }
8445 @@ -664,208 +670,208 @@
8446 }
8447
8448
8449 -struct sk_buff* ieee80211_assoc_resp(struct ieee80211_device *ieee, u8 *dest)
8450 +struct sk_buff* ieee80211_assoc_resp_rtl7(struct ieee80211_device *ieee, u8 *dest)
8451 {
8452 struct sk_buff *skb;
8453 u8* tag;
8454 -
8455 +
8456 struct ieee80211_crypt_data* crypt;
8457 struct ieee80211_assoc_response_frame *assoc;
8458 short encrypt;
8459 -
8460 - unsigned int rate_len = ieee80211_MFIE_rate_len(ieee);
8461 +
8462 + unsigned int rate_len = ieee80211_MFIE_rate_len_rtl7(ieee);
8463 int len = sizeof(struct ieee80211_assoc_response_frame) + rate_len;
8464 -
8465 - skb = dev_alloc_skb(len);
8466 -
8467 - if (!skb)
8468 +
8469 + skb = dev_alloc_skb(len);
8470 +
8471 + if (!skb)
8472 return NULL;
8473 -
8474 +
8475 assoc = (struct ieee80211_assoc_response_frame *)
8476 skb_put(skb,sizeof(struct ieee80211_assoc_response_frame));
8477 -
8478 +
8479 assoc->header.frame_ctl = cpu_to_le16(IEEE80211_STYPE_ASSOC_RESP);
8480 memcpy(assoc->header.addr1, dest,ETH_ALEN);
8481 memcpy(assoc->header.addr3, ieee->dev->dev_addr, ETH_ALEN);
8482 memcpy(assoc->header.addr2, ieee->dev->dev_addr, ETH_ALEN);
8483 - assoc->capability = cpu_to_le16(ieee->iw_mode == IW_MODE_MASTER ?
8484 + assoc->capability = cpu_to_le16(ieee->iw_mode == IW_MODE_MASTER ?
8485 WLAN_CAPABILITY_BSS : WLAN_CAPABILITY_IBSS);
8486 -
8487 -
8488 +
8489 +
8490 if(ieee->short_slot)
8491 assoc->capability |= cpu_to_le16(WLAN_CAPABILITY_SHORT_SLOT);
8492 -
8493 +
8494 if (ieee->host_encrypt)
8495 crypt = ieee->crypt[ieee->tx_keyidx];
8496 else crypt = NULL;
8497 -
8498 +
8499 encrypt = ( crypt && crypt->ops);
8500 -
8501 +
8502 if (encrypt)
8503 assoc->capability |= cpu_to_le16(WLAN_CAPABILITY_PRIVACY);
8504 -
8505 +
8506 assoc->status = 0;
8507 assoc->aid = cpu_to_le16(ieee->assoc_id);
8508 if (ieee->assoc_id == 0x2007) ieee->assoc_id=0;
8509 else ieee->assoc_id++;
8510 -
8511 +
8512 tag = (u8*) skb_put(skb, rate_len);
8513 -
8514 - ieee80211_MFIE_Brate(ieee, &tag);
8515 - ieee80211_MFIE_Grate(ieee, &tag);
8516 -
8517 +
8518 + ieee80211_MFIE_Brate_rtl7(ieee, &tag);
8519 + ieee80211_MFIE_Grate_rtl7(ieee, &tag);
8520 +
8521 return skb;
8522 }
8523
8524 -struct sk_buff* ieee80211_auth_resp(struct ieee80211_device *ieee,int status, u8 *dest)
8525 +struct sk_buff* ieee80211_auth_resp_rtl7(struct ieee80211_device *ieee,int status, u8 *dest)
8526 {
8527 struct sk_buff *skb;
8528 struct ieee80211_authentication *auth;
8529 -
8530 - skb = dev_alloc_skb(sizeof(struct ieee80211_authentication)+1);
8531 -
8532 - if (!skb)
8533 +
8534 + skb = dev_alloc_skb(sizeof(struct ieee80211_authentication)+1);
8535 +
8536 + if (!skb)
8537 return NULL;
8538 -
8539 +
8540 skb->len = sizeof(struct ieee80211_authentication);
8541 -
8542 +
8543 auth = (struct ieee80211_authentication *)skb->data;
8544 -
8545 +
8546 auth->status = cpu_to_le16(status);
8547 auth->transaction = cpu_to_le16(2);
8548 auth->algorithm = cpu_to_le16(WLAN_AUTH_OPEN);
8549 -
8550 +
8551 memcpy(auth->header.addr3, ieee->dev->dev_addr, ETH_ALEN);
8552 memcpy(auth->header.addr2, ieee->dev->dev_addr, ETH_ALEN);
8553 memcpy(auth->header.addr1, dest, ETH_ALEN);
8554 - auth->header.frame_ctl = cpu_to_le16(IEEE80211_STYPE_AUTH);
8555 + auth->header.frame_ctl = cpu_to_le16(IEEE80211_STYPE_AUTH);
8556 return skb;
8557 -
8558 -
8559 +
8560 +
8561 }
8562
8563 -struct sk_buff* ieee80211_null_func(struct ieee80211_device *ieee,short pwr)
8564 +struct sk_buff* ieee80211_null_func_rtl7(struct ieee80211_device *ieee,short pwr)
8565 {
8566 struct sk_buff *skb;
8567 struct ieee80211_hdr_3addr* hdr;
8568 -
8569 - skb = dev_alloc_skb(sizeof(struct ieee80211_hdr_3addr));
8570 -
8571 - if (!skb)
8572 +
8573 + skb = dev_alloc_skb(sizeof(struct ieee80211_hdr_3addr));
8574 +
8575 + if (!skb)
8576 return NULL;
8577 -
8578 +
8579 hdr = (struct ieee80211_hdr_3addr*)skb_put(skb,sizeof(struct ieee80211_hdr_3addr));
8580 -
8581 +
8582 memcpy(hdr->addr1, ieee->current_network.bssid, ETH_ALEN);
8583 memcpy(hdr->addr2, ieee->dev->dev_addr, ETH_ALEN);
8584 memcpy(hdr->addr3, ieee->current_network.bssid, ETH_ALEN);
8585 -
8586 - hdr->frame_ctl = cpu_to_le16(IEEE80211_FTYPE_DATA |
8587 - IEEE80211_STYPE_NULLFUNC | IEEE80211_FCTL_TODS |
8588 - (pwr ? IEEE80211_FCTL_PM:0));
8589 -
8590 +
8591 + hdr->frame_ctl = cpu_to_le16(IEEE80211_FTYPE_DATA |
8592 + IEEE80211_STYPE_NULLFUNC | IEEE80211_FCTL_TODS |
8593 + (pwr ? IEEE80211_FCTL_PM:0));
8594 +
8595 return skb;
8596 -
8597 -
8598 +
8599 +
8600 }
8601
8602
8603 -void ieee80211_resp_to_assoc_rq(struct ieee80211_device *ieee, u8* dest)
8604 +void ieee80211_resp_to_assoc_rq_rtl7(struct ieee80211_device *ieee, u8* dest)
8605 {
8606 - struct sk_buff *buf = ieee80211_assoc_resp(ieee, dest);
8607 -
8608 + struct sk_buff *buf = ieee80211_assoc_resp_rtl7(ieee, dest);
8609 +
8610 if (buf)
8611 - softmac_mgmt_xmit(buf, ieee);
8612 + softmac_mgmt_xmit_rtl7(buf, ieee);
8613 }
8614
8615
8616 -void ieee80211_resp_to_auth(struct ieee80211_device *ieee, int s, u8* dest)
8617 +void ieee80211_resp_to_auth_rtl7(struct ieee80211_device *ieee, int s, u8* dest)
8618 {
8619 - struct sk_buff *buf = ieee80211_auth_resp(ieee, s, dest);
8620 -
8621 + struct sk_buff *buf = ieee80211_auth_resp_rtl7(ieee, s, dest);
8622 +
8623 if (buf)
8624 - softmac_mgmt_xmit(buf, ieee);
8625 + softmac_mgmt_xmit_rtl7(buf, ieee);
8626 }
8627
8628
8629 -void ieee80211_resp_to_probe(struct ieee80211_device *ieee, u8 *dest)
8630 +void ieee80211_resp_to_probe_rtl7(struct ieee80211_device *ieee, u8 *dest)
8631 {
8632 -
8633 - struct sk_buff *buf = ieee80211_probe_resp(ieee, dest);
8634 -
8635 - if (buf)
8636 - softmac_mgmt_xmit(buf, ieee);
8637 +
8638 + struct sk_buff *buf = ieee80211_probe_resp_rtl7(ieee, dest);
8639 +
8640 + if (buf)
8641 + softmac_mgmt_xmit_rtl7(buf, ieee);
8642 }
8643
8644
8645 -inline struct sk_buff *ieee80211_association_req(struct ieee80211_network *beacon,struct ieee80211_device *ieee)
8646 +inline struct sk_buff *ieee80211_association_req_rtl7(struct ieee80211_network *beacon,struct ieee80211_device *ieee)
8647 {
8648 struct sk_buff *skb;
8649 -
8650 +
8651 struct ieee80211_assoc_request_frame *hdr;
8652 u8 *tag;
8653 -
8654 +
8655 unsigned int wpa_len = beacon->wpa_ie_len;
8656 -
8657 - unsigned int rate_len = ieee80211_MFIE_rate_len(ieee);
8658 -
8659 -
8660 -
8661 +
8662 + unsigned int rate_len = ieee80211_MFIE_rate_len_rtl7(ieee);
8663 +
8664 +
8665 +
8666 int len=sizeof(struct ieee80211_assoc_request_frame)+
8667 + beacon->ssid_len//essid tagged val
8668 + rate_len//rates tagged val
8669 + wpa_len;
8670 -
8671 +
8672 skb = dev_alloc_skb(len);
8673 -
8674 - if (!skb)
8675 +
8676 + if (!skb)
8677 return NULL;
8678 -
8679 +
8680 hdr = (struct ieee80211_assoc_request_frame *)
8681 skb_put(skb, sizeof(struct ieee80211_assoc_request_frame));
8682 -
8683 -
8684 +
8685 +
8686 hdr->header.frame_ctl = IEEE80211_STYPE_ASSOC_REQ;
8687 hdr->header.duration_id= 37; //FIXME
8688 memcpy(hdr->header.addr1, beacon->bssid, ETH_ALEN);
8689 memcpy(hdr->header.addr2, ieee->dev->dev_addr, ETH_ALEN);
8690 memcpy(hdr->header.addr3, beacon->bssid, ETH_ALEN);
8691 -
8692 +
8693 hdr->capability = cpu_to_le16(WLAN_CAPABILITY_BSS);
8694 - if (beacon->capability & WLAN_CAPABILITY_PRIVACY )
8695 + if (beacon->capability & WLAN_CAPABILITY_PRIVACY )
8696 hdr->capability |= cpu_to_le16(WLAN_CAPABILITY_PRIVACY);
8697 -
8698 +
8699 if(ieee->short_slot)
8700 hdr->capability |= cpu_to_le16(WLAN_CAPABILITY_SHORT_SLOT);
8701 -
8702 +
8703 hdr->listen_interval = 0xa; //FIXME
8704 -
8705 +
8706 hdr->info_element.id = MFIE_TYPE_SSID;
8707
8708 hdr->info_element.len = beacon->ssid_len;
8709 tag = skb_put(skb, beacon->ssid_len);
8710 memcpy(tag, beacon->ssid, beacon->ssid_len);
8711 -
8712 - tag = skb_put(skb, rate_len);
8713 -
8714 - ieee80211_MFIE_Brate(ieee, &tag);
8715 - ieee80211_MFIE_Grate(ieee, &tag);
8716 -
8717 +
8718 + tag = skb_put(skb, rate_len);
8719 +
8720 + ieee80211_MFIE_Brate_rtl7(ieee, &tag);
8721 + ieee80211_MFIE_Grate_rtl7(ieee, &tag);
8722 +
8723 tag = skb_put(skb,wpa_len);
8724 -
8725 +
8726 memcpy(tag,beacon->wpa_ie,wpa_len);
8727 -
8728 +
8729 return skb;
8730 }
8731
8732 -void ieee80211_associate_abort(struct ieee80211_device *ieee)
8733 +void ieee80211_associate_abort_rtl7(struct ieee80211_device *ieee)
8734 {
8735 -
8736 +
8737 unsigned long flags;
8738 spin_lock_irqsave(&ieee->lock, flags);
8739 -
8740 +
8741 ieee->associate_seq++;
8742 -
8743 +
8744 /* don't scan, and avoid to have the RX path possibily
8745 * try again to associate. Even do not react to AUTH or
8746 * ASSOC response. Just wait for the retry wq to be scheduled.
8747 @@ -873,103 +879,109 @@
8748 * with, so we retry or just get back to NO_LINK and scanning
8749 */
8750 if (ieee->state == IEEE80211_ASSOCIATING_AUTHENTICATING){
8751 - IEEE80211_DEBUG_MGMT("Authentication failed\n");
8752 + IEEE80211_DEBUG_MGMT("Authentication failed\n");
8753 ieee->softmac_stats.no_auth_rs++;
8754 }else{
8755 - IEEE80211_DEBUG_MGMT("Association failed\n");
8756 + IEEE80211_DEBUG_MGMT("Association failed\n");
8757 ieee->softmac_stats.no_ass_rs++;
8758 }
8759 -
8760 +
8761 ieee->state = IEEE80211_ASSOCIATING_RETRY;
8762 -
8763 +
8764 queue_delayed_work(ieee->wq, &ieee->associate_retry_wq, IEEE80211_SOFTMAC_ASSOC_RETRY_TIME);
8765 -
8766 +
8767 spin_unlock_irqrestore(&ieee->lock, flags);
8768 }
8769
8770 -void ieee80211_associate_abort_cb(unsigned long dev)
8771 +void ieee80211_associate_abort_cb_rtl7(unsigned long dev)
8772 {
8773 - ieee80211_associate_abort((struct ieee80211_device *) dev);
8774 + ieee80211_associate_abort_rtl7((struct ieee80211_device *) dev);
8775 }
8776
8777
8778 -void ieee80211_associate_step1(struct ieee80211_device *ieee)
8779 +void ieee80211_associate_step1_rtl7(struct ieee80211_device *ieee)
8780 {
8781 struct ieee80211_network *beacon = &ieee->current_network;
8782 struct sk_buff *skb;
8783 -
8784 +
8785 IEEE80211_DEBUG_MGMT("Stopping scan\n");
8786 -
8787 +
8788 ieee->softmac_stats.tx_auth_rq++;
8789 - skb=ieee80211_authentication_req(beacon, ieee, 0);
8790 -
8791 - if (!skb)
8792 - ieee80211_associate_abort(ieee);
8793 - else{
8794 + skb=ieee80211_authentication_req_rtl7(beacon, ieee, 0);
8795 +
8796 + if (!skb)
8797 + ieee80211_associate_abort_rtl7(ieee);
8798 + else{
8799 ieee->state = IEEE80211_ASSOCIATING_AUTHENTICATING ;
8800 IEEE80211_DEBUG_MGMT("Sending authentication request\n");
8801 - softmac_mgmt_xmit(skb, ieee);
8802 + softmac_mgmt_xmit_rtl7(skb, ieee);
8803 ieee->associate_timer.expires = jiffies + (HZ / 2);
8804 add_timer(&ieee->associate_timer);
8805 - }
8806 + }
8807 }
8808
8809 -void ieee80211_auth_challenge(struct ieee80211_device *ieee, u8 *challenge, int chlen)
8810 +void ieee80211_auth_challenge_rtl7(struct ieee80211_device *ieee, u8 *challenge, int chlen)
8811 {
8812 - u8 *c;
8813 + u8 *c;
8814 struct sk_buff *skb;
8815 struct ieee80211_network *beacon = &ieee->current_network;
8816 // int hlen = sizeof(struct ieee80211_authentication);
8817 -
8818 +
8819 ieee->associate_seq++;
8820 ieee->softmac_stats.tx_auth_rq++;
8821 -
8822 - skb = ieee80211_authentication_req(beacon, ieee, chlen+2);
8823 - if (!skb)
8824 - ieee80211_associate_abort(ieee);
8825 +
8826 + skb = ieee80211_authentication_req_rtl7(beacon, ieee, chlen+2);
8827 + if (!skb)
8828 + ieee80211_associate_abort_rtl7(ieee);
8829 else{
8830 c = skb_put(skb, chlen+2);
8831 *(c++) = MFIE_TYPE_CHALLENGE;
8832 *(c++) = chlen;
8833 memcpy(c, challenge, chlen);
8834 -
8835 +
8836 IEEE80211_DEBUG_MGMT("Sending authentication challenge response\n");
8837 -
8838 - ieee80211_encrypt_fragment(ieee, skb, sizeof(struct ieee80211_hdr_3addr ));
8839 -
8840 - softmac_mgmt_xmit(skb, ieee);
8841 +
8842 + ieee80211_encrypt_fragment_rtl7(ieee, skb, sizeof(struct ieee80211_hdr_3addr ));
8843 +
8844 + softmac_mgmt_xmit_rtl7(skb, ieee);
8845 ieee->associate_timer.expires = jiffies + (HZ / 2);
8846 add_timer(&ieee->associate_timer);
8847 - }
8848 + }
8849 kfree(challenge);
8850 }
8851
8852 -void ieee80211_associate_step2(struct ieee80211_device *ieee)
8853 +void ieee80211_associate_step2_rtl7(struct ieee80211_device *ieee)
8854 {
8855 struct sk_buff* skb;
8856 struct ieee80211_network *beacon = &ieee->current_network;
8857 -
8858 +
8859 del_timer_sync(&ieee->associate_timer);
8860 -
8861 +
8862 IEEE80211_DEBUG_MGMT("Sending association request\n");
8863 -
8864 +
8865 ieee->softmac_stats.tx_ass_rq++;
8866 - skb=ieee80211_association_req(beacon, ieee);
8867 - if (!skb)
8868 - ieee80211_associate_abort(ieee);
8869 + skb=ieee80211_association_req_rtl7(beacon, ieee);
8870 + if (!skb)
8871 + ieee80211_associate_abort_rtl7(ieee);
8872 else{
8873 - softmac_mgmt_xmit(skb, ieee);
8874 + softmac_mgmt_xmit_rtl7(skb, ieee);
8875 ieee->associate_timer.expires = jiffies + (HZ / 2);
8876 add_timer(&ieee->associate_timer);
8877 - }
8878 + }
8879 }
8880
8881 -void ieee80211_associate_complete_wq(struct ieee80211_device *ieee)
8882 +# if (LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,20))
8883 +void ieee80211_associate_complete_wq_rtl7(struct work_struct *work)
8884 {
8885 + struct ieee80211_device *ieee = container_of(work, struct ieee80211_device, associate_complete_wq);
8886 +#else
8887 +void ieee80211_associate_complete_wq_rtl7(struct ieee80211_device *ieee)
8888 +{
8889 +#endif
8890 printk(KERN_INFO "Associated successfully\n");
8891 - if(ieee80211_is_54g(ieee->current_network) &&
8892 + if(ieee80211_is_54g_rtl7(ieee->current_network) &&
8893 (ieee->modulation & IEEE80211_OFDM_MODULATION)){
8894 -
8895 +
8896 ieee->rate = 540;
8897 printk(KERN_INFO"Using G rates\n");
8898 }else{
8899 @@ -977,62 +989,67 @@
8900 printk(KERN_INFO"Using B rates\n");
8901 }
8902 ieee->link_change(ieee->dev);
8903 - notify_wx_assoc_event(ieee);
8904 + notify_wx_assoc_event_rtl7(ieee);
8905 if (ieee->data_hard_resume)
8906 ieee->data_hard_resume(ieee->dev);
8907 netif_carrier_on(ieee->dev);
8908 }
8909
8910 -void ieee80211_associate_complete(struct ieee80211_device *ieee)
8911 +void ieee80211_associate_complete_rtl7(struct ieee80211_device *ieee)
8912 {
8913
8914 del_timer_sync(&ieee->associate_timer);
8915 -
8916 +
8917 ieee->seq_ctrl = 0;
8918 ieee->state = IEEE80211_LINKED;
8919 IEEE80211_DEBUG_MGMT("Successfully associated\n");
8920 -
8921 +
8922 queue_work(ieee->wq, &ieee->associate_complete_wq);
8923 }
8924
8925 -void ieee80211_associate_procedure_wq(struct ieee80211_device *ieee)
8926 +# if (LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,20))
8927 +void ieee80211_associate_procedure_wq_rtl7(struct work_struct *work)
8928 +{
8929 + struct ieee80211_device *ieee = container_of(work, struct ieee80211_device, associate_procedure_wq);
8930 +#else
8931 +void ieee80211_associate_procedure_wq_rtl7(struct ieee80211_device *ieee)
8932 {
8933 +#endif
8934 ieee->sync_scan_hurryup = 1;
8935 down(&ieee->wx_sem);
8936 -
8937 if (ieee->data_hard_stop)
8938 ieee->data_hard_stop(ieee->dev);
8939 -
8940 - ieee80211_stop_scan(ieee);
8941 +
8942 + ieee80211_stop_scan_rtl7(ieee);
8943 ieee->set_chan(ieee->dev, ieee->current_network.channel);
8944 -
8945 +
8946 ieee->associate_seq = 1;
8947 - ieee80211_associate_step1(ieee);
8948 -
8949 + ieee80211_associate_step1_rtl7(ieee);
8950 +
8951 up(&ieee->wx_sem);
8952 }
8953
8954 -inline void ieee80211_softmac_new_net(struct ieee80211_device *ieee, struct ieee80211_network *net)
8955 +inline void ieee80211_softmac_new_net_rtl7(struct ieee80211_device *ieee, struct ieee80211_network *net)
8956 {
8957 -
8958 +
8959 u8 tmp_ssid[IW_ESSID_MAX_SIZE+1];
8960 int tmp_ssid_len = 0;
8961 -
8962 +
8963 short apset,ssidset,ssidbroad,apmatch,ssidmatch;
8964 -
8965 - /* we are interested in new new only if we are not associated
8966 +
8967 + /* we are interested in new new only if we are not associated
8968 * and we are not associating / authenticating
8969 */
8970 if (ieee->state != IEEE80211_NOLINK)
8971 - return;
8972 -
8973 + return;
8974 +
8975 if ((ieee->iw_mode == IW_MODE_INFRA) && !(net->capability & WLAN_CAPABILITY_BSS))
8976 return;
8977 -
8978 +
8979 if ((ieee->iw_mode == IW_MODE_ADHOC) && !(net->capability & WLAN_CAPABILITY_IBSS))
8980 return;
8981
8982 -
8983 +
8984 if (ieee->iw_mode == IW_MODE_INFRA || ieee->iw_mode == IW_MODE_ADHOC){
8985 /* if the user specified the AP MAC, we need also the essid
8986 * This could be obtained by beacons or, if the network does not
8987 @@ -1043,23 +1060,23 @@
8988 ssidbroad = !(net->ssid_len == 0 || net->ssid[0]== '\0');
8989 apmatch = (memcmp(ieee->current_network.bssid, net->bssid, ETH_ALEN)==0);
8990 ssidmatch = (0==strncmp(ieee->current_network.ssid, net->ssid, net->ssid_len));
8991 -
8992 -
8993 -
8994 +
8995 +
8996 +
8997 if ( /* if the user set the AP check if match.
8998 * if the network does not broadcast essid we check the user supplyed ANY essid
8999 * if the network does broadcast and the user does not set essid it is OK
9000 * if the network does broadcast and the user did set essid chech if essid match
9001 */
9002 - ( apset && apmatch &&
9003 - ((ssidset && ssidbroad && ssidmatch) || (ssidbroad && !ssidset) || (!ssidbroad && ssidset)) ) ||
9004 + ( apset && apmatch &&
9005 + ((ssidset && ssidbroad && ssidmatch) || (ssidbroad && !ssidset) || (!ssidbroad && ssidset)) ) ||
9006 /* if the ap is not set, check that the user set the bssid
9007 * and the network does bradcast and that those two bssid matches
9008 - */
9009 - (!apset && ssidset && ssidbroad && ssidmatch)
9010 + */
9011 + (!apset && ssidset && ssidbroad && ssidmatch)
9012 ){
9013 -
9014 -
9015 +
9016 +
9017 /* if the essid is hidden replace it with the
9018 * essid provided by the user.
9019 */
9020 @@ -1068,18 +1085,18 @@
9021 tmp_ssid_len = ieee->current_network.ssid_len;
9022 }
9023 memcpy(&ieee->current_network, net, sizeof(struct ieee80211_network));
9024 -
9025 +
9026 if (!ssidbroad){
9027 strncpy(ieee->current_network.ssid, tmp_ssid, IW_ESSID_MAX_SIZE);
9028 ieee->current_network.ssid_len = tmp_ssid_len;
9029 }
9030 printk(KERN_INFO"Linking with %s\n",ieee->current_network.ssid);
9031 -
9032 +
9033 if (ieee->iw_mode == IW_MODE_INFRA){
9034 ieee->state = IEEE80211_ASSOCIATING;
9035 queue_work(ieee->wq, &ieee->associate_procedure_wq);
9036 }else{
9037 - if(ieee80211_is_54g(ieee->current_network) &&
9038 + if(ieee80211_is_54g_rtl7(ieee->current_network) &&
9039 (ieee->modulation & IEEE80211_OFDM_MODULATION)){
9040 ieee->rate = 540;
9041 printk(KERN_INFO"Using G rates\n");
9042 @@ -1089,42 +1106,40 @@
9043 }
9044 ieee->state = IEEE80211_LINKED;
9045 }
9046 -
9047 +
9048 }
9049 }
9050 -
9051 }
9052
9053 -void ieee80211_softmac_check_all_nets(struct ieee80211_device *ieee)
9054 +void ieee80211_softmac_check_all_nets_rtl7(struct ieee80211_device *ieee)
9055 {
9056 -
9057 +
9058 unsigned long flags;
9059 struct ieee80211_network *target;
9060 -
9061 +
9062 spin_lock_irqsave(&ieee->lock, flags);
9063 -
9064 list_for_each_entry(target, &ieee->network_list, list) {
9065 -
9066 +
9067 /* if the state become different that NOLINK means
9068 * we had found what we are searching for
9069 */
9070 - if (ieee->state != IEEE80211_NOLINK)
9071 + if (ieee->state != IEEE80211_NOLINK)
9072 break;
9073 -
9074 +
9075 //if (ieee->scan_age == 0 || time_after(target->last_scanned + ieee->scan_age, jiffies))
9076 - ieee80211_softmac_new_net(ieee, target);
9077 + ieee80211_softmac_new_net_rtl7(ieee, target);
9078 }
9079 -
9080 +
9081 spin_unlock_irqrestore(&ieee->lock, flags);
9082 -
9083 +
9084 }
9085
9086
9087 -static inline u16 auth_parse(struct sk_buff *skb, u8** challenge, int *chlen)
9088 +static inline u16 auth_parse_rtl7(struct sk_buff *skb, u8** challenge, int *chlen)
9089 {
9090 struct ieee80211_authentication *a;
9091 u8 *t;
9092 - if (skb->len < (sizeof(struct ieee80211_authentication)-sizeof(struct ieee80211_info_element))){
9093 + if (skb->len < (sizeof(struct ieee80211_authentication)-sizeof(struct ieee80211_info_element))){
9094 IEEE80211_DEBUG_MGMT("invalid len in auth resp: %d\n",skb->len);
9095 return 0xcafe;
9096 }
9097 @@ -1132,58 +1147,58 @@
9098 a = (struct ieee80211_authentication*) skb->data;
9099 if(skb->len > (sizeof(struct ieee80211_authentication) +3)){
9100 t = skb->data + sizeof(struct ieee80211_authentication);
9101 -
9102 +
9103 if(*(t++) == MFIE_TYPE_CHALLENGE){
9104 *chlen = *(t++);
9105 *challenge = (u8*)kmalloc(*chlen, GFP_ATOMIC);
9106 memcpy(*challenge, t, *chlen);
9107 }
9108 }
9109 -
9110 +
9111 return cpu_to_le16(a->status);
9112 -
9113 +
9114 }
9115
9116
9117 -int auth_rq_parse(struct sk_buff *skb,u8* dest)
9118 +int auth_rq_parse_rtl7(struct sk_buff *skb,u8* dest)
9119 {
9120 struct ieee80211_authentication *a;
9121 -
9122 - if (skb->len < (sizeof(struct ieee80211_authentication)-sizeof(struct ieee80211_info_element))){
9123 - IEEE80211_DEBUG_MGMT("invalid len in auth request: %d\n",skb->len);
9124 +
9125 + if (skb->len < (sizeof(struct ieee80211_authentication)-sizeof(struct ieee80211_info_element))){
9126 + IEEE80211_DEBUG_MGMT("invalid len in auth request: %d\n",skb->len);
9127 return -1;
9128 }
9129 a = (struct ieee80211_authentication*) skb->data;
9130 -
9131 +
9132 memcpy(dest,a->header.addr2, ETH_ALEN);
9133 -
9134 - if (le16_to_cpu(a->algorithm) != WLAN_AUTH_OPEN)
9135 +
9136 + if (le16_to_cpu(a->algorithm) != WLAN_AUTH_OPEN)
9137 return WLAN_STATUS_NOT_SUPPORTED_AUTH_ALG;
9138 -
9139 +
9140 return WLAN_STATUS_SUCCESS;
9141 }
9142
9143 -static short probe_rq_parse(struct ieee80211_device *ieee, struct sk_buff *skb, u8 *src)
9144 +static short probe_rq_parse_rtl7(struct ieee80211_device *ieee, struct sk_buff *skb, u8 *src)
9145 {
9146 u8 *tag;
9147 u8 *skbend;
9148 u8 *ssid=NULL;
9149 u8 ssidlen = 0;
9150 -
9151 +
9152 struct ieee80211_hdr_3addr *header =
9153 (struct ieee80211_hdr_3addr *) skb->data;
9154 -
9155 - if (skb->len < sizeof (struct ieee80211_hdr_3addr ))
9156 +
9157 + if (skb->len < sizeof (struct ieee80211_hdr_3addr ))
9158 return -1; /* corrupted */
9159 -
9160 +
9161 memcpy(src,header->addr2, ETH_ALEN);
9162 -
9163 +
9164 skbend = (u8*)skb->data + skb->len;
9165 -
9166 +
9167 tag = skb->data + sizeof (struct ieee80211_hdr_3addr );
9168 -
9169 +
9170 while (tag+1 < skbend){
9171 - if (*tag == 0){
9172 + if (*tag == 0){
9173 ssid = tag+2;
9174 ssidlen = *(tag+1);
9175 break;
9176 @@ -1192,88 +1207,88 @@
9177 tag = tag + *(tag); /* point to the last data byte of the tag */
9178 tag++; /* point to the next tag */
9179 }
9180 -
9181 +
9182 //IEEE80211DMESG("Card MAC address is "MACSTR, MAC2STR(src));
9183 if (ssidlen == 0) return 1;
9184 -
9185 +
9186 if (!ssid) return 1; /* ssid not found in tagged param */
9187 return (!strncmp(ssid, ieee->current_network.ssid, ssidlen));
9188 -
9189 +
9190 }
9191
9192 -int assoc_rq_parse(struct sk_buff *skb,u8* dest)
9193 +int assoc_rq_parse_rtl7(struct sk_buff *skb,u8* dest)
9194 {
9195 struct ieee80211_assoc_request_frame *a;
9196 -
9197 - if (skb->len < (sizeof(struct ieee80211_assoc_request_frame) -
9198 - sizeof(struct ieee80211_info_element))) {
9199 -
9200 +
9201 + if (skb->len < (sizeof(struct ieee80211_assoc_request_frame) -
9202 + sizeof(struct ieee80211_info_element))) {
9203 +
9204 IEEE80211_DEBUG_MGMT("invalid len in auth request:%d \n", skb->len);
9205 return -1;
9206 }
9207 -
9208 +
9209 a = (struct ieee80211_assoc_request_frame*) skb->data;
9210 -
9211 +
9212 memcpy(dest,a->header.addr2,ETH_ALEN);
9213 -
9214 +
9215 return 0;
9216 }
9217
9218 -static inline u16 assoc_parse(struct sk_buff *skb, int *aid)
9219 +static inline u16 assoc_parse_rtl7(struct sk_buff *skb, int *aid)
9220 {
9221 struct ieee80211_assoc_response_frame *a;
9222 - if (skb->len < sizeof(struct ieee80211_assoc_response_frame)){
9223 + if (skb->len < sizeof(struct ieee80211_assoc_response_frame)){
9224 IEEE80211_DEBUG_MGMT("invalid len in auth resp: %d\n", skb->len);
9225 return 0xcafe;
9226 }
9227 -
9228 +
9229 a = (struct ieee80211_assoc_response_frame*) skb->data;
9230 *aid = le16_to_cpu(a->aid) & 0x3fff;
9231 return le16_to_cpu(a->status);
9232 }
9233
9234 static inline void
9235 -ieee80211_rx_probe_rq(struct ieee80211_device *ieee, struct sk_buff *skb)
9236 +ieee80211_rx_probe_rq_rtl7(struct ieee80211_device *ieee, struct sk_buff *skb)
9237 {
9238 u8 dest[ETH_ALEN];
9239 -
9240 +
9241 //IEEE80211DMESG("Rx probe");
9242 ieee->softmac_stats.rx_probe_rq++;
9243 //DMESG("Dest is "MACSTR, MAC2STR(dest));
9244 - if (probe_rq_parse(ieee, skb, dest)){
9245 + if (probe_rq_parse_rtl7(ieee, skb, dest)){
9246 //IEEE80211DMESG("Was for me!");
9247 ieee->softmac_stats.tx_probe_rs++;
9248 - ieee80211_resp_to_probe(ieee, dest);
9249 + ieee80211_resp_to_probe_rtl7(ieee, dest);
9250 }
9251 }
9252
9253 static inline void
9254 -ieee80211_rx_auth_rq(struct ieee80211_device *ieee, struct sk_buff *skb)
9255 +ieee80211_rx_auth_rq_rtl7(struct ieee80211_device *ieee, struct sk_buff *skb)
9256 {
9257 u8 dest[ETH_ALEN];
9258 int status;
9259 //IEEE80211DMESG("Rx probe");
9260 ieee->softmac_stats.rx_auth_rq++;
9261 -
9262 - if ((status = auth_rq_parse(skb, dest))!= -1){
9263 - ieee80211_resp_to_auth(ieee, status, dest);
9264 +
9265 + if ((status = auth_rq_parse_rtl7(skb, dest))!= -1){
9266 + ieee80211_resp_to_auth_rtl7(ieee, status, dest);
9267 }
9268 //DMESG("Dest is "MACSTR, MAC2STR(dest));
9269 -
9270 +
9271 }
9272
9273 static inline void
9274 -ieee80211_rx_assoc_rq(struct ieee80211_device *ieee, struct sk_buff *skb)
9275 +ieee80211_rx_assoc_rq_rtl7(struct ieee80211_device *ieee, struct sk_buff *skb)
9276 {
9277 -
9278 +
9279 u8 dest[ETH_ALEN];
9280 //unsigned long flags;
9281 -
9282 +
9283 ieee->softmac_stats.rx_ass_rq++;
9284 - if (assoc_rq_parse(skb,dest) != -1){
9285 - ieee80211_resp_to_assoc_rq(ieee, dest);
9286 + if (assoc_rq_parse_rtl7(skb,dest) != -1){
9287 + ieee80211_resp_to_assoc_rq_rtl7(ieee, dest);
9288 }
9289 -
9290 +
9291 printk(KERN_INFO"New client associated: "MAC_FMT"\n", MAC_ARG(dest));
9292 //FIXME
9293 #if 0
9294 @@ -1285,25 +1300,25 @@
9295
9296
9297
9298 -void ieee80211_sta_ps_send_null_frame(struct ieee80211_device *ieee, short pwr)
9299 +void ieee80211_sta_ps_send_null_frame_rtl7(struct ieee80211_device *ieee, short pwr)
9300 {
9301 -
9302 - struct sk_buff *buf = ieee80211_null_func(ieee, pwr);
9303 -
9304 +
9305 + struct sk_buff *buf = ieee80211_null_func_rtl7(ieee, pwr);
9306 +
9307 if (buf)
9308 - softmac_ps_mgmt_xmit(buf, ieee);
9309 + softmac_ps_mgmt_xmit_rtl7(buf, ieee);
9310
9311 -}
9312 +}
9313
9314
9315 -short ieee80211_sta_ps_sleep(struct ieee80211_device *ieee, u32 *time_h, u32 *time_l)
9316 -{
9317 +short ieee80211_sta_ps_sleep_rtl7(struct ieee80211_device *ieee, u32 *time_h, u32 *time_l)
9318 +{
9319 int timeout = ieee->ps_timeout;
9320 u8 dtim;
9321 /*if(ieee->ps == IEEE80211_PS_DISABLED ||
9322 - ieee->iw_mode != IW_MODE_INFRA ||
9323 + ieee->iw_mode != IW_MODE_INFRA ||
9324 ieee->state != IEEE80211_LINKED)
9325 -
9326 +
9327 return 0;
9328 */
9329 dtim = ieee->current_network.dtim_data;
9330 @@ -1312,133 +1327,133 @@
9331 return 0;
9332 //printk("VALID\n");
9333 ieee->current_network.dtim_data = IEEE80211_DTIM_INVALID;
9334 -
9335 +
9336 if(dtim & ((IEEE80211_DTIM_UCAST | IEEE80211_DTIM_MBCAST)& ieee->ps))
9337 return 2;
9338 -
9339 +
9340 if(!time_after(jiffies, ieee->dev->trans_start + MSECS(timeout)))
9341 return 0;
9342 -
9343 +
9344 if(!time_after(jiffies, ieee->last_rx_ps_time + MSECS(timeout)))
9345 return 0;
9346 -
9347 +
9348 if((ieee->softmac_features & IEEE_SOFTMAC_SINGLE_QUEUE ) &&
9349 (ieee->mgmt_queue_tail != ieee->mgmt_queue_head))
9350 return 0;
9351 -
9352 +
9353 if(time_l){
9354 - *time_l = ieee->current_network.last_dtim_sta_time[0]
9355 - + (ieee->current_network.beacon_interval
9356 + *time_l = ieee->current_network.last_dtim_sta_time[0]
9357 + + (ieee->current_network.beacon_interval
9358 * ieee->current_network.dtim_period) * 1000;
9359 }
9360 -
9361 +
9362 if(time_h){
9363 *time_h = ieee->current_network.last_dtim_sta_time[1];
9364 if(time_l && *time_l < ieee->current_network.last_dtim_sta_time[0])
9365 *time_h += 1;
9366 }
9367 -
9368 +
9369 return 1;
9370 -
9371 -
9372 +
9373 +
9374 }
9375
9376 -inline void ieee80211_sta_ps(struct ieee80211_device *ieee)
9377 +inline void ieee80211_sta_ps_rtl7(struct ieee80211_device *ieee)
9378 {
9379
9380 u32 th,tl;
9381 short sleep;
9382 -
9383 +
9384 unsigned long flags,flags2;
9385 -
9386 +
9387 spin_lock_irqsave(&ieee->lock, flags);
9388 -
9389 +
9390 if((ieee->ps == IEEE80211_PS_DISABLED ||
9391 - ieee->iw_mode != IW_MODE_INFRA ||
9392 + ieee->iw_mode != IW_MODE_INFRA ||
9393 ieee->state != IEEE80211_LINKED)){
9394 -
9395 - #warning CHECK_LOCK_HERE
9396 +
9397 +// #warning CHECK_LOCK_HERE
9398 spin_lock_irqsave(&ieee->mgmt_tx_lock, flags2);
9399 -
9400 - ieee80211_sta_wakeup(ieee, 1);
9401 -
9402 +
9403 + ieee80211_sta_wakeup_rtl7(ieee, 1);
9404 + printk(KERN_WARNING "wakeup 1!\n" );
9405 spin_unlock_irqrestore(&ieee->mgmt_tx_lock, flags2);
9406 }
9407 -
9408 - sleep = ieee80211_sta_ps_sleep(ieee,&th, &tl);
9409 +
9410 + sleep = ieee80211_sta_ps_sleep_rtl7(ieee,&th, &tl);
9411 /* 2 wake, 1 sleep, 0 do nothing */
9412 if(sleep == 0)
9413 goto out;
9414 -
9415 +
9416 if(sleep == 1){
9417 -
9418 +
9419 if(ieee->sta_sleep == 1)
9420 ieee->enter_sleep_state(ieee->dev,th,tl);
9421 -
9422 +
9423 else if(ieee->sta_sleep == 0){
9424 // printk("send null 1\n");
9425 spin_lock_irqsave(&ieee->mgmt_tx_lock, flags2);
9426 -
9427 +
9428 if(ieee->ps_is_queue_empty(ieee->dev)){
9429 -
9430 -
9431 +
9432 +
9433 ieee->sta_sleep = 2;
9434 -
9435 +
9436 ieee->ps_request_tx_ack(ieee->dev);
9437 -
9438 - ieee80211_sta_ps_send_null_frame(ieee,1);
9439 -
9440 +
9441 + ieee80211_sta_ps_send_null_frame_rtl7(ieee,1);
9442 +
9443 ieee->ps_th = th;
9444 ieee->ps_tl = tl;
9445 - }
9446 + }
9447 spin_unlock_irqrestore(&ieee->mgmt_tx_lock, flags2);
9448 -
9449 +
9450 }
9451 -
9452 -
9453 +
9454 +
9455 }else if(sleep == 2){
9456 -#warning CHECK_LOCK_HERE
9457 +// #warning CHECK_LOCK_HERE
9458 spin_lock_irqsave(&ieee->mgmt_tx_lock, flags2);
9459 -
9460 - ieee80211_sta_wakeup(ieee,1);
9461 -
9462 +
9463 + ieee80211_sta_wakeup_rtl7(ieee,1);
9464 + printk(KERN_WARNING "wakeup 2!\n" );
9465 spin_unlock_irqrestore(&ieee->mgmt_tx_lock, flags2);
9466 }
9467
9468 -out:
9469 +out:
9470 spin_unlock_irqrestore(&ieee->lock, flags);
9471 -
9472 +
9473 }
9474
9475 -void ieee80211_sta_wakeup(struct ieee80211_device *ieee, short nl)
9476 +void ieee80211_sta_wakeup_rtl7(struct ieee80211_device *ieee, short nl)
9477 {
9478 if(ieee->sta_sleep == 0){
9479 if(nl){
9480 printk("Warning: driver is probably failing to report TX ps error\n");
9481 ieee->ps_request_tx_ack(ieee->dev);
9482 - ieee80211_sta_ps_send_null_frame(ieee, 0);
9483 + ieee80211_sta_ps_send_null_frame_rtl7(ieee, 0);
9484 }
9485 return;
9486 -
9487 +
9488 }
9489 -
9490 - if(ieee->sta_sleep == 1)
9491 +
9492 + if(ieee->sta_sleep == 1)
9493 ieee->sta_wake_up(ieee->dev);
9494 -
9495 +
9496 ieee->sta_sleep = 0;
9497 -
9498 +
9499 if(nl){
9500 ieee->ps_request_tx_ack(ieee->dev);
9501 - ieee80211_sta_ps_send_null_frame(ieee, 0);
9502 + ieee80211_sta_ps_send_null_frame_rtl7(ieee, 0);
9503 }
9504 }
9505
9506 -void ieee80211_ps_tx_ack(struct ieee80211_device *ieee, short success)
9507 +void ieee80211_ps_tx_ack_rtl7(struct ieee80211_device *ieee, short success)
9508 {
9509 unsigned long flags,flags2;
9510 -
9511 +
9512 spin_lock_irqsave(&ieee->lock, flags);
9513 -
9514 +
9515 if(ieee->sta_sleep == 2){
9516 /* Null frame with PS bit set */
9517 if(success){
9518 @@ -1451,10 +1466,10 @@
9519 }
9520 /* 21112005 - tx again null without PS bit if lost */
9521 else {
9522 -
9523 +
9524 if((ieee->sta_sleep == 0) && !success){
9525 spin_lock_irqsave(&ieee->mgmt_tx_lock, flags2);
9526 - ieee80211_sta_ps_send_null_frame(ieee, 0);
9527 + ieee80211_sta_ps_send_null_frame_rtl7(ieee, 0);
9528 spin_unlock_irqrestore(&ieee->mgmt_tx_lock, flags2);
9529 }
9530 }
9531 @@ -1462,129 +1477,132 @@
9532 }
9533
9534 inline int
9535 -ieee80211_rx_frame_softmac(struct ieee80211_device *ieee, struct sk_buff *skb,
9536 +ieee80211_rx_frame_softmac_rtl7(struct ieee80211_device *ieee, struct sk_buff *skb,
9537 struct ieee80211_rx_stats *rx_stats, u16 type,
9538 u16 stype)
9539 {
9540 struct ieee80211_hdr_3addr *header;
9541 - header = (struct ieee80211_hdr_3addr *) skb->data;
9542 u16 errcode;
9543 u8* challenge;
9544 int chlen;
9545 int aid;
9546 -
9547 +
9548 + chlen = 0;
9549 +
9550 + header = (struct ieee80211_hdr_3addr *) skb->data;
9551 +
9552 if(!ieee->proto_started)
9553 return 0;
9554 -
9555 +
9556 if(ieee->sta_sleep || (ieee->ps != IEEE80211_PS_DISABLED &&
9557 - ieee->iw_mode == IW_MODE_INFRA &&
9558 + ieee->iw_mode == IW_MODE_INFRA &&
9559 ieee->state == IEEE80211_LINKED))
9560 -
9561 +
9562 tasklet_schedule(&ieee->ps_task);
9563 -
9564 +
9565 if(WLAN_FC_GET_STYPE(header->frame_ctl) != IEEE80211_STYPE_PROBE_RESP &&
9566 WLAN_FC_GET_STYPE(header->frame_ctl) != IEEE80211_STYPE_BEACON)
9567 ieee->last_rx_ps_time = jiffies;
9568 -
9569 +
9570 switch (WLAN_FC_GET_STYPE(header->frame_ctl)) {
9571 -
9572 +
9573 case IEEE80211_STYPE_ASSOC_RESP:
9574 case IEEE80211_STYPE_REASSOC_RESP:
9575 -
9576 +
9577 IEEE80211_DEBUG_MGMT("received [RE]ASSOCIATION RESPONSE (%d)\n",
9578 WLAN_FC_GET_STYPE(header->frame_ctl));
9579 if ((ieee->softmac_features & IEEE_SOFTMAC_ASSOCIATE) &&
9580 - ieee->state == IEEE80211_ASSOCIATING_AUTHENTICATED &&
9581 + ieee->state == IEEE80211_ASSOCIATING_AUTHENTICATED &&
9582 ieee->iw_mode == IW_MODE_INFRA){
9583 - if (0 == (errcode=assoc_parse(skb, &aid))){
9584 -
9585 + if (0 == (errcode=assoc_parse_rtl7(skb, &aid))){
9586 +
9587 ieee->state=IEEE80211_LINKED;
9588 ieee->assoc_id = aid;
9589 ieee->softmac_stats.rx_ass_ok++;
9590 -
9591 - ieee80211_associate_complete(ieee);
9592 +
9593 + ieee80211_associate_complete_rtl7(ieee);
9594 }else{
9595 ieee->softmac_stats.rx_ass_err++;
9596 IEEE80211_DEBUG_MGMT(
9597 "Association response status code 0x%x\n",
9598 errcode);
9599 - ieee80211_associate_abort(ieee);
9600 + ieee80211_associate_abort_rtl7(ieee);
9601 }
9602 }
9603 break;
9604 -
9605 +
9606 case IEEE80211_STYPE_ASSOC_REQ:
9607 case IEEE80211_STYPE_REASSOC_REQ:
9608 -
9609 +
9610 if ((ieee->softmac_features & IEEE_SOFTMAC_ASSOCIATE) &&
9611 ieee->iw_mode == IW_MODE_MASTER)
9612 -
9613 - ieee80211_rx_assoc_rq(ieee, skb);
9614 +
9615 + ieee80211_rx_assoc_rq_rtl7(ieee, skb);
9616 break;
9617 -
9618 +
9619 case IEEE80211_STYPE_AUTH:
9620 -
9621 +
9622 if (ieee->softmac_features & IEEE_SOFTMAC_ASSOCIATE){
9623 - if (ieee->state == IEEE80211_ASSOCIATING_AUTHENTICATING &&
9624 + if (ieee->state == IEEE80211_ASSOCIATING_AUTHENTICATING &&
9625 ieee->iw_mode == IW_MODE_INFRA){
9626 -
9627 +
9628 IEEE80211_DEBUG_MGMT("Received authentication response");
9629 -
9630 - if (0 == (errcode=auth_parse(skb, &challenge, &chlen))){
9631 +
9632 + if (0 == (errcode=auth_parse_rtl7(skb, &challenge, &chlen))){
9633 if(ieee->open_wep || !challenge){
9634 ieee->state = IEEE80211_ASSOCIATING_AUTHENTICATED;
9635 ieee->softmac_stats.rx_auth_rs_ok++;
9636 -
9637 - ieee80211_associate_step2(ieee);
9638 +
9639 + ieee80211_associate_step2_rtl7(ieee);
9640 }else{
9641 - ieee80211_auth_challenge(ieee, challenge, chlen);
9642 + ieee80211_auth_challenge_rtl7(ieee, challenge, chlen);
9643 }
9644 }else{
9645 ieee->softmac_stats.rx_auth_rs_err++;
9646 IEEE80211_DEBUG_MGMT("Authentication respose status code 0x%x",errcode);
9647 - ieee80211_associate_abort(ieee);
9648 + ieee80211_associate_abort_rtl7(ieee);
9649 }
9650 -
9651 +
9652 }else if (ieee->iw_mode == IW_MODE_MASTER){
9653 - ieee80211_rx_auth_rq(ieee, skb);
9654 + ieee80211_rx_auth_rq_rtl7(ieee, skb);
9655 }
9656 }
9657 break;
9658 -
9659 +
9660 case IEEE80211_STYPE_PROBE_REQ:
9661 -
9662 - if ((ieee->softmac_features & IEEE_SOFTMAC_PROBERS) &&
9663 - ((ieee->iw_mode == IW_MODE_ADHOC ||
9664 +
9665 + if ((ieee->softmac_features & IEEE_SOFTMAC_PROBERS) &&
9666 + ((ieee->iw_mode == IW_MODE_ADHOC ||
9667 ieee->iw_mode == IW_MODE_MASTER) &&
9668 ieee->state == IEEE80211_LINKED))
9669 -
9670 - ieee80211_rx_probe_rq(ieee, skb);
9671 +
9672 + ieee80211_rx_probe_rq_rtl7(ieee, skb);
9673 break;
9674 -
9675 +
9676 case IEEE80211_STYPE_DISASSOC:
9677 case IEEE80211_STYPE_DEAUTH:
9678 - /* FIXME for now repeat all the association procedure
9679 + /* FIXME for now repeat all the association procedure
9680 * both for disassociation and deauthentication
9681 */
9682 if ((ieee->softmac_features & IEEE_SOFTMAC_ASSOCIATE) &&
9683 - ieee->state == IEEE80211_LINKED &&
9684 + ieee->state == IEEE80211_LINKED &&
9685 ieee->iw_mode == IW_MODE_INFRA){
9686 -
9687 +
9688 ieee->state = IEEE80211_ASSOCIATING;
9689 ieee->softmac_stats.reassoc++;
9690 -
9691 - notify_wx_assoc_event(ieee);
9692 -
9693 +
9694 + notify_wx_assoc_event_rtl7(ieee);
9695 +
9696 queue_work(ieee->wq, &ieee->associate_procedure_wq);
9697 }
9698 -
9699 +
9700 break;
9701 -
9702 - default:
9703 +
9704 + default:
9705 return -1;
9706 break;
9707 }
9708 -
9709 +
9710 //dev_kfree_skb_any(skb);
9711 return 0;
9712 }
9713 @@ -1602,21 +1620,21 @@
9714 * This might be useful if each fragment need it's own
9715 * descriptor, thus just keep a total free memory > than
9716 * the max fragmentation treshold is not enought.. If the
9717 - * ieee802.11 stack passed a TXB struct then you needed
9718 - * to keep N free descriptors where
9719 + * ieee802.11 stack passed a TXB struct then you needed
9720 + * to keep N free descriptors where
9721 * N = MAX_PACKET_SIZE / MIN_FRAG_TRESHOLD
9722 * In this way you need just one and the 802.11 stack
9723 - * will take care of buffering fragments and pass them to
9724 + * will take care of buffering fragments and pass them to
9725 * to the driver later, when it wakes the queue.
9726 - */
9727 -
9728 -void ieee80211_softmac_xmit(struct ieee80211_txb *txb, struct ieee80211_device *ieee)
9729 + */
9730 +
9731 +void ieee80211_softmac_xmit_rtl7(struct ieee80211_txb *txb, struct ieee80211_device *ieee)
9732 {
9733 -
9734 -
9735 +
9736 +
9737 unsigned long flags;
9738 int i;
9739 -
9740 +
9741 spin_lock_irqsave(&ieee->lock,flags);
9742 #if 0
9743 if(ieee->queue_stop){
9744 @@ -1627,13 +1645,13 @@
9745 err = 1;
9746 goto exit;
9747 }
9748 -
9749 +
9750 ieee->stats.tx_bytes+=skb->len;
9751 -
9752 -
9753 +
9754 +
9755 txb=ieee80211_skb_to_txb(ieee,skb);
9756 -
9757 -
9758 +
9759 +
9760 if(txb==NULL){
9761 IEEE80211DMESG("WW: IEEE stack failed to provide txb");
9762 //dev_kfree_skb_any(skb);
9763 @@ -1641,12 +1659,12 @@
9764 goto exit;
9765 }
9766 #endif
9767 -
9768 +
9769 /* called with 2nd parm 0, no tx mgmt lock required */
9770 - ieee80211_sta_wakeup(ieee,0);
9771 + ieee80211_sta_wakeup_rtl7(ieee,0);
9772
9773 for(i = 0; i < txb->nr_frags; i++) {
9774 -
9775 +
9776 if (ieee->queue_stop){
9777 ieee->tx_pending.txb = txb;
9778 ieee->tx_pending.frag = i;
9779 @@ -1658,29 +1676,29 @@
9780 //(i+1)<txb->nr_frags);
9781 ieee->stats.tx_packets++;
9782 ieee->stats.tx_bytes += txb->fragments[i]->len;
9783 - ieee->dev->trans_start = jiffies;
9784 + ieee->dev->trans_start = jiffies;
9785 }
9786 - }
9787 -
9788 - ieee80211_txb_free(txb);
9789 -
9790 + }
9791 +
9792 + ieee80211_txb_free_rtl7(txb);
9793 +
9794 exit:
9795 spin_unlock_irqrestore(&ieee->lock,flags);
9796 -
9797 +
9798 }
9799
9800 /* called with ieee->lock acquired */
9801 -void ieee80211_resume_tx(struct ieee80211_device *ieee)
9802 +void ieee80211_resume_tx_rtl7(struct ieee80211_device *ieee)
9803 {
9804 int i;
9805 for(i = ieee->tx_pending.frag; i < ieee->tx_pending.txb->nr_frags; i++) {
9806 -
9807 +
9808 if (ieee->queue_stop){
9809 ieee->tx_pending.frag = i;
9810 return;
9811 }else{
9812 -
9813 - ieee->softmac_data_hard_start_xmit(
9814 +
9815 + ieee->softmac_data_hard_start_xmit(
9816 ieee->tx_pending.txb->fragments[i],
9817 ieee->dev,ieee->rate);
9818 //(i+1)<ieee->tx_pending.txb->nr_frags);
9819 @@ -1688,21 +1706,21 @@
9820 ieee->dev->trans_start = jiffies;
9821 }
9822 }
9823 -
9824 -
9825 - ieee80211_txb_free(ieee->tx_pending.txb);
9826 +
9827 +
9828 + ieee80211_txb_free_rtl7(ieee->tx_pending.txb);
9829 ieee->tx_pending.txb = NULL;
9830 }
9831
9832
9833 -void ieee80211_reset_queue(struct ieee80211_device *ieee)
9834 +void ieee80211_reset_queue_rtl7(struct ieee80211_device *ieee)
9835 {
9836 unsigned long flags;
9837 -
9838 +
9839 spin_lock_irqsave(&ieee->lock,flags);
9840 - init_mgmt_queue(ieee);
9841 + init_mgmt_queue_rtl7(ieee);
9842 if (ieee->tx_pending.txb){
9843 - ieee80211_txb_free(ieee->tx_pending.txb);
9844 + ieee80211_txb_free_rtl7(ieee->tx_pending.txb);
9845 ieee->tx_pending.txb = NULL;
9846 }
9847 ieee->queue_stop = 0;
9848 @@ -1710,23 +1728,23 @@
9849
9850 }
9851
9852 -void ieee80211_wake_queue(struct ieee80211_device *ieee)
9853 +void ieee80211_wake_queue_rtl7(struct ieee80211_device *ieee)
9854 {
9855
9856 unsigned long flags;
9857 struct sk_buff *skb;
9858 struct ieee80211_hdr_3addr *header;
9859 -
9860 +
9861 spin_lock_irqsave(&ieee->lock,flags);
9862 if (! ieee->queue_stop) goto exit;
9863 -
9864 +
9865 ieee->queue_stop = 0;
9866 -
9867 +
9868 if(ieee->softmac_features & IEEE_SOFTMAC_SINGLE_QUEUE){
9869 - while (!ieee->queue_stop && (skb = dequeue_mgmt(ieee))){
9870 -
9871 + while (!ieee->queue_stop && (skb = dequeue_mgmt_rtl7(ieee))){
9872 +
9873 header = (struct ieee80211_hdr_3addr *) skb->data;
9874 -
9875 +
9876 header->seq_ctl = cpu_to_le16(ieee->seq_ctrl << 4);
9877
9878 if (ieee->seq_ctrl == 0xFFF)
9879 @@ -1738,19 +1756,19 @@
9880 }
9881 }
9882 if (!ieee->queue_stop && ieee->tx_pending.txb)
9883 - ieee80211_resume_tx(ieee);
9884 -
9885 + ieee80211_resume_tx_rtl7(ieee);
9886 +
9887 if (!ieee->queue_stop && netif_queue_stopped(ieee->dev)){
9888 ieee->softmac_stats.swtxawake++;
9889 netif_wake_queue(ieee->dev);
9890 }
9891 -
9892 +
9893 exit :
9894 spin_unlock_irqrestore(&ieee->lock,flags);
9895 }
9896
9897
9898 -void ieee80211_stop_queue(struct ieee80211_device *ieee)
9899 +void ieee80211_stop_queue_rtl7(struct ieee80211_device *ieee)
9900 {
9901 //unsigned long flags;
9902 //spin_lock_irqsave(&ieee->lock,flags);
9903 @@ -1761,81 +1779,88 @@
9904 }
9905 ieee->queue_stop = 1;
9906 //spin_unlock_irqrestore(&ieee->lock,flags);
9907 -
9908 +
9909 }
9910
9911
9912 -inline void ieee80211_randomize_cell(struct ieee80211_device *ieee)
9913 +inline void ieee80211_randomize_cell_rtl7(struct ieee80211_device *ieee)
9914 {
9915 -
9916 +
9917 get_random_bytes(ieee->current_network.bssid, ETH_ALEN);
9918 -
9919 +
9920 /* an IBSS cell address must have the two less significant
9921 - * bits of the first byte = 2
9922 + * bits of the first byte = 2
9923 */
9924 ieee->current_network.bssid[0] &= ~0x01;
9925 ieee->current_network.bssid[0] |= 0x02;
9926 }
9927
9928 /* called in user context only */
9929 -void ieee80211_start_master_bss(struct ieee80211_device *ieee)
9930 +void ieee80211_start_master_bss_rtl7(struct ieee80211_device *ieee)
9931 {
9932 ieee->assoc_id = 1;
9933 -
9934 +
9935 if (ieee->current_network.ssid_len == 0){
9936 - strncpy(ieee->current_network.ssid,
9937 + strncpy(ieee->current_network.ssid,
9938 IEEE80211_DEFAULT_TX_ESSID,
9939 IW_ESSID_MAX_SIZE);
9940 -
9941 +
9942 ieee->current_network.ssid_len = strlen(IEEE80211_DEFAULT_TX_ESSID);
9943 ieee->ssid_set = 1;
9944 }
9945 -
9946 +
9947 memcpy(ieee->current_network.bssid, ieee->dev->dev_addr, ETH_ALEN);
9948 -
9949 +
9950 ieee->set_chan(ieee->dev, ieee->current_network.channel);
9951 ieee->state = IEEE80211_LINKED;
9952 ieee->link_change(ieee->dev);
9953 - notify_wx_assoc_event(ieee);
9954 -
9955 + notify_wx_assoc_event_rtl7(ieee);
9956 +
9957 if (ieee->data_hard_resume)
9958 ieee->data_hard_resume(ieee->dev);
9959 -
9960 +
9961 netif_carrier_on(ieee->dev);
9962 }
9963
9964 -void ieee80211_start_monitor_mode(struct ieee80211_device *ieee)
9965 +void ieee80211_start_monitor_mode_rtl7(struct ieee80211_device *ieee)
9966 {
9967 if(ieee->raw_tx){
9968 -
9969 +
9970 if (ieee->data_hard_resume)
9971 ieee->data_hard_resume(ieee->dev);
9972 -
9973 +
9974 netif_carrier_on(ieee->dev);
9975 }
9976 }
9977 -void ieee80211_start_ibss_wq(struct ieee80211_device *ieee)
9978 +
9979 +# if (LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,20))
9980 +void ieee80211_start_ibss_wq_rtl7(struct work_struct *work)
9981 {
9982 -
9983 + struct ieee80211_device *ieee = container_of(work, struct ieee80211_device, start_ibss_wq);
9984 +#else
9985 +void ieee80211_start_ibss_wq_rtl7(struct ieee80211_device *ieee)
9986 +{
9987 +#endif
9988 +
9989 /* iwconfig mode ad-hoc will schedule this and return
9990 * on the other hand this will block further iwconfig SET
9991 * operations because of the wx_sem hold.
9992 * Anyway some most set operations set a flag to speed-up
9993 - * (abort) this wq (when syncro scanning) before sleeping
9994 + * (abort) this wq (when syncro scanning) before sleeping
9995 * on the semaphore
9996 */
9997 -
9998 +
9999 down(&ieee->wx_sem);
10000 -
10001 +
10002 if (ieee->current_network.ssid_len == 0){
10003 strcpy(ieee->current_network.ssid,IEEE80211_DEFAULT_TX_ESSID);
10004 ieee->current_network.ssid_len = strlen(IEEE80211_DEFAULT_TX_ESSID);
10005 ieee->ssid_set = 1;
10006 - }
10007 -
10008 + }
10009 +
10010 /* check if we have this cell in our network list */
10011 - ieee80211_softmac_check_all_nets(ieee);
10012 -
10013 + ieee80211_softmac_check_all_nets_rtl7(ieee);
10014 +
10015 /* if not then the state is not linked. Maybe the user swithced to
10016 * ad-hoc mode just after being in monitor mode, or just after
10017 * being very few time in managed mode (so the card have had no
10018 @@ -1851,29 +1876,29 @@
10019 * associated.
10020 */
10021 if (ieee->state == IEEE80211_NOLINK)
10022 - ieee80211_start_scan_syncro(ieee);
10023 + ieee80211_start_scan_syncro_rtl7(ieee);
10024
10025 /* the network definitively is not here.. create a new cell */
10026 if (ieee->state == IEEE80211_NOLINK){
10027 - printk("creating new IBSS cell\n");
10028 + printk("creating new IBSS cell\n");
10029 if(!ieee->wap_set)
10030 - ieee80211_randomize_cell(ieee);
10031 -
10032 + ieee80211_randomize_cell_rtl7(ieee);
10033 +
10034 if(ieee->modulation & IEEE80211_CCK_MODULATION){
10035 -
10036 +
10037 ieee->current_network.rates_len = 4;
10038 -
10039 +
10040 ieee->current_network.rates[0] = IEEE80211_BASIC_RATE_MASK | IEEE80211_CCK_RATE_1MB;
10041 ieee->current_network.rates[1] = IEEE80211_BASIC_RATE_MASK | IEEE80211_CCK_RATE_2MB;
10042 ieee->current_network.rates[2] = IEEE80211_BASIC_RATE_MASK | IEEE80211_CCK_RATE_5MB;
10043 ieee->current_network.rates[3] = IEEE80211_BASIC_RATE_MASK | IEEE80211_CCK_RATE_11MB;
10044 -
10045 +
10046 }else
10047 ieee->current_network.rates_len = 0;
10048 -
10049 +
10050 if(ieee->modulation & IEEE80211_OFDM_MODULATION){
10051 ieee->current_network.rates_ex_len = 8;
10052 -
10053 +
10054 ieee->current_network.rates_ex[0] = IEEE80211_BASIC_RATE_MASK | IEEE80211_OFDM_RATE_6MB;
10055 ieee->current_network.rates_ex[1] = IEEE80211_BASIC_RATE_MASK | IEEE80211_OFDM_RATE_9MB;
10056 ieee->current_network.rates_ex[2] = IEEE80211_BASIC_RATE_MASK | IEEE80211_OFDM_RATE_12MB;
10057 @@ -1882,44 +1907,44 @@
10058 ieee->current_network.rates_ex[5] = IEEE80211_BASIC_RATE_MASK | IEEE80211_OFDM_RATE_36MB;
10059 ieee->current_network.rates_ex[6] = IEEE80211_BASIC_RATE_MASK | IEEE80211_OFDM_RATE_48MB;
10060 ieee->current_network.rates_ex[7] = IEEE80211_BASIC_RATE_MASK | IEEE80211_OFDM_RATE_54MB;
10061 -
10062 +
10063 ieee->rate = 540;
10064 }else{
10065 ieee->current_network.rates_ex_len = 0;
10066 ieee->rate = 110;
10067 }
10068 -
10069 +
10070 ieee->current_network.atim_window = 0;
10071 ieee->current_network.capability = WLAN_CAPABILITY_IBSS;
10072 if(ieee->short_slot)
10073 ieee->current_network.capability |= WLAN_CAPABILITY_SHORT_SLOT;
10074 -
10075 +
10076 }
10077 -
10078 +
10079 ieee->state = IEEE80211_LINKED;
10080 -
10081 +
10082 ieee->set_chan(ieee->dev, ieee->current_network.channel);
10083 ieee->link_change(ieee->dev);
10084 -
10085 - notify_wx_assoc_event(ieee);
10086 -
10087 - ieee80211_start_send_beacons(ieee);
10088 -
10089 +
10090 + notify_wx_assoc_event_rtl7(ieee);
10091 +
10092 + ieee80211_start_send_beacons_rtl7(ieee);
10093 +
10094 if (ieee->data_hard_resume)
10095 ieee->data_hard_resume(ieee->dev);
10096 -
10097 +
10098 netif_carrier_on(ieee->dev);
10099 -
10100 +
10101 up(&ieee->wx_sem);
10102 }
10103
10104 -inline void ieee80211_start_ibss(struct ieee80211_device *ieee)
10105 +inline void ieee80211_start_ibss_rtl7(struct ieee80211_device *ieee)
10106 {
10107 queue_work(ieee->wq, &ieee->start_ibss_wq);
10108 }
10109
10110 /* this is called only in user context, with wx_sem held */
10111 -void ieee80211_start_bss(struct ieee80211_device *ieee)
10112 +void ieee80211_start_bss_rtl7(struct ieee80211_device *ieee)
10113 {
10114 unsigned long flags;
10115 /* check if we have already found the net we
10116 @@ -1927,8 +1952,8 @@
10117 * if not (we are disassociated and we are not
10118 * in associating / authenticating phase) start the background scanning.
10119 */
10120 - ieee80211_softmac_check_all_nets(ieee);
10121 -
10122 + ieee80211_softmac_check_all_nets_rtl7(ieee);
10123 +
10124 /* ensure no-one start an associating process (thus setting
10125 * the ieee->state to ieee80211_ASSOCIATING) while we
10126 * have just cheked it and we are going to enable scan.
10127 @@ -1937,41 +1962,49 @@
10128 * the rx path), so we cannot be in the middle of such function
10129 */
10130 spin_lock_irqsave(&ieee->lock, flags);
10131 -
10132 if (ieee->state == IEEE80211_NOLINK)
10133 - ieee80211_start_scan(ieee);
10134 -
10135 + ieee80211_start_scan_rtl7(ieee);
10136 +
10137 spin_unlock_irqrestore(&ieee->lock, flags);
10138 }
10139
10140 /* called only in userspace context */
10141 -void ieee80211_disassociate(struct ieee80211_device *ieee)
10142 +void ieee80211_disassociate_rtl7(struct ieee80211_device *ieee)
10143 {
10144 netif_carrier_off(ieee->dev);
10145 -
10146 +
10147 if (ieee->softmac_features & IEEE_SOFTMAC_TX_QUEUE)
10148 - ieee80211_reset_queue(ieee);
10149 -
10150 + ieee80211_reset_queue_rtl7(ieee);
10151 +
10152 if (ieee->data_hard_stop)
10153 ieee->data_hard_stop(ieee->dev);
10154 -
10155 +
10156 ieee->state = IEEE80211_NOLINK;
10157 ieee->link_change(ieee->dev);
10158 - notify_wx_assoc_event(ieee);
10159 -
10160 + notify_wx_assoc_event_rtl7(ieee);
10161 +
10162 }
10163 -void ieee80211_associate_retry_wq(struct ieee80211_device *ieee)
10164 +
10165 +# if (LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,20))
10166 +void ieee80211_associate_retry_wq_rtl7(struct work_struct *work)
10167 {
10168 + struct delayed_work *dwork = container_of(work, struct delayed_work, work);
10169 + struct ieee80211_device *ieee = container_of(dwork, struct ieee80211_device, associate_retry_wq);
10170 +#else
10171 +void ieee80211_associate_retry_wq_rtl7(struct ieee80211_device *ieee)
10172 +{
10173 +#endif
10174 unsigned long flags;
10175 -
10176 +
10177 down(&ieee->wx_sem);
10178 +
10179 if(!ieee->proto_started)
10180 goto exit;
10181 -
10182 +
10183 if(ieee->state != IEEE80211_ASSOCIATING_RETRY)
10184 goto exit;
10185 -
10186 - /* until we do not set the state to IEEE80211_NOLINK
10187 +
10188 + /* until we do not set the state to IEEE80211_NOLINK
10189 * there are no possibility to have someone else trying
10190 * to start an association procdure (we get here with
10191 * ieee->state = IEEE80211_ASSOCIATING).
10192 @@ -1981,122 +2014,120 @@
10193 * RX path works with ieee->lock held so there are no
10194 * problems. If we are still disassociated then start a scan.
10195 * the lock here is necessary to ensure no one try to start
10196 - * an association procedure when we have just checked the
10197 + * an association procedure when we have just checked the
10198 * state and we are going to start the scan.
10199 */
10200 ieee->state = IEEE80211_NOLINK;
10201
10202 - ieee80211_softmac_check_all_nets(ieee);
10203 -
10204 + ieee80211_softmac_check_all_nets_rtl7(ieee);
10205 +
10206 spin_lock_irqsave(&ieee->lock, flags);
10207 -
10208 +
10209 if(ieee->state == IEEE80211_NOLINK)
10210 - ieee80211_start_scan(ieee);
10211 -
10212 + ieee80211_start_scan_rtl7(ieee);
10213 +
10214 spin_unlock_irqrestore(&ieee->lock, flags);
10215
10216 exit:
10217 up(&ieee->wx_sem);
10218 }
10219
10220 -struct sk_buff *ieee80211_get_beacon_(struct ieee80211_device *ieee)
10221 +struct sk_buff *ieee80211_get_beacon__rtl7(struct ieee80211_device *ieee)
10222 {
10223 u8 broadcast_addr[] = {0xff,0xff,0xff,0xff,0xff,0xff};
10224 -
10225 +
10226 struct sk_buff *skb;
10227 struct ieee80211_probe_response *b;
10228 -
10229 - skb = ieee80211_probe_resp(ieee, broadcast_addr);
10230 -
10231 - if (!skb)
10232 +
10233 + skb = ieee80211_probe_resp_rtl7(ieee, broadcast_addr);
10234 +
10235 + if (!skb)
10236 return NULL;
10237 -
10238 +
10239 b = (struct ieee80211_probe_response *) skb->data;
10240 b->header.frame_ctl = cpu_to_le16(IEEE80211_STYPE_BEACON);
10241 -
10242 +
10243 return skb;
10244 -
10245 +
10246 }
10247
10248 -struct sk_buff *ieee80211_get_beacon(struct ieee80211_device *ieee)
10249 +struct sk_buff *ieee80211_get_beacon_rtl7(struct ieee80211_device *ieee)
10250 {
10251 struct sk_buff *skb;
10252 struct ieee80211_probe_response *b;
10253 -
10254 - skb = ieee80211_get_beacon_(ieee);
10255 - if(!skb)
10256 +
10257 + skb = ieee80211_get_beacon__rtl7(ieee);
10258 + if(!skb)
10259 return NULL;
10260 -
10261 - b = (struct ieee80211_probe_response *) skb->data;
10262 +
10263 + b = (struct ieee80211_probe_response *) skb->data;
10264 b->header.seq_ctrl = cpu_to_le16(ieee->seq_ctrl << 4);
10265 -
10266 +
10267 if (ieee->seq_ctrl == 0xFFF)
10268 ieee->seq_ctrl = 0;
10269 else
10270 ieee->seq_ctrl++;
10271 -
10272 +
10273 return skb;
10274 }
10275
10276 -void ieee80211_softmac_stop_protocol(struct ieee80211_device *ieee)
10277 +void ieee80211_softmac_stop_protocol_rtl7(struct ieee80211_device *ieee)
10278 {
10279 ieee->sync_scan_hurryup = 1;
10280 down(&ieee->wx_sem);
10281 - ieee80211_stop_protocol(ieee);
10282 +
10283 + ieee80211_stop_protocol_rtl7(ieee);
10284 up(&ieee->wx_sem);
10285 }
10286
10287
10288 -void ieee80211_stop_protocol(struct ieee80211_device *ieee)
10289 +void ieee80211_stop_protocol_rtl7(struct ieee80211_device *ieee)
10290 {
10291 if (!ieee->proto_started)
10292 return;
10293 -
10294 +
10295 ieee->proto_started = 0;
10296 -
10297 - ieee80211_stop_send_beacons(ieee);
10298 -
10299 +
10300 + ieee80211_stop_send_beacons_rtl7(ieee);
10301 +
10302 del_timer_sync(&ieee->associate_timer);
10303 - cancel_delayed_work(&ieee->associate_retry_wq);
10304 -
10305 - ieee80211_stop_scan(ieee);
10306 + cancel_delayed_work(&ieee->associate_retry_wq);
10307
10308 - ieee80211_disassociate(ieee);
10309 + ieee80211_stop_scan_rtl7(ieee);
10310 +
10311 + ieee80211_disassociate_rtl7(ieee);
10312 }
10313
10314 -void ieee80211_softmac_start_protocol(struct ieee80211_device *ieee)
10315 +void ieee80211_softmac_start_protocol_rtl7(struct ieee80211_device *ieee)
10316 {
10317 ieee->sync_scan_hurryup = 0;
10318 down(&ieee->wx_sem);
10319 - ieee80211_start_protocol(ieee);
10320 + ieee80211_start_protocol_rtl7(ieee);
10321 up(&ieee->wx_sem);
10322 }
10323
10324 -void ieee80211_start_protocol(struct ieee80211_device *ieee)
10325 +void ieee80211_start_protocol_rtl7(struct ieee80211_device *ieee)
10326 {
10327 short ch = 0;
10328 -
10329 if (ieee->proto_started)
10330 return;
10331 -
10332 +
10333 ieee->proto_started = 1;
10334 -
10335 +
10336 if (ieee->current_network.channel == 0){
10337 do{
10338 ch++;
10339 - if (ch > MAX_CHANNEL_NUMBER)
10340 + if (ch > MAX_CHANNEL_NUMBER)
10341 return; /* no channel found */
10342 -
10343 +
10344 }while(!ieee->channel_map[ch]);
10345 -
10346 +
10347 ieee->current_network.channel = ch;
10348 }
10349 -
10350 +
10351 if (ieee->current_network.beacon_interval == 0)
10352 ieee->current_network.beacon_interval = 100;
10353 -
10354 ieee->set_chan(ieee->dev,ieee->current_network.channel);
10355 -
10356 ieee->last_seq_num = -1;
10357 ieee->last_frag_num = -1;
10358 ieee->last_packet_time = 0;
10359 @@ -2107,30 +2138,27 @@
10360 * attempts does not fail just because the user provide the essid
10361 * and the nic is still checking for the AP MAC ??
10362 */
10363 -
10364 +
10365 if (ieee->iw_mode == IW_MODE_INFRA)
10366 - ieee80211_start_bss(ieee);
10367 -
10368 + ieee80211_start_bss_rtl7(ieee);
10369 else if (ieee->iw_mode == IW_MODE_ADHOC)
10370 - ieee80211_start_ibss(ieee);
10371 -
10372 + ieee80211_start_ibss_rtl7(ieee);
10373 else if (ieee->iw_mode == IW_MODE_MASTER)
10374 - ieee80211_start_master_bss(ieee);
10375 -
10376 + ieee80211_start_master_bss_rtl7(ieee);
10377 else if(ieee->iw_mode == IW_MODE_MONITOR)
10378 - ieee80211_start_monitor_mode(ieee);
10379 + ieee80211_start_monitor_mode_rtl7(ieee);
10380 }
10381
10382
10383 #define DRV_NAME "Ieee80211"
10384 -void ieee80211_softmac_init(struct ieee80211_device *ieee)
10385 +void ieee80211_softmac_init_rtl7(struct ieee80211_device *ieee)
10386 {
10387 memset(&ieee->current_network, 0, sizeof(struct ieee80211_network));
10388 -
10389 +
10390 ieee->state = IEEE80211_NOLINK;
10391 ieee->sync_scan_hurryup = 0;
10392 ieee->seq_ctrl = 0;
10393 -
10394 +
10395 ieee->assoc_id = 0;
10396 ieee->queue_stop = 0;
10397 ieee->scanning = 0;
10398 @@ -2142,66 +2170,75 @@
10399 ieee->rate = 3;
10400 ieee->ps = IEEE80211_PS_DISABLED;
10401 ieee->sta_sleep = 0;
10402 -
10403 - init_mgmt_queue(ieee);
10404 +
10405 + init_mgmt_queue_rtl7(ieee);
10406 #if 0
10407 init_timer(&ieee->scan_timer);
10408 ieee->scan_timer.data = (unsigned long)ieee;
10409 ieee->scan_timer.function = ieee80211_softmac_scan_cb;
10410 #endif
10411 ieee->tx_pending.txb = NULL;
10412 -
10413 +
10414 init_timer(&ieee->associate_timer);
10415 ieee->associate_timer.data = (unsigned long)ieee;
10416 - ieee->associate_timer.function = ieee80211_associate_abort_cb;
10417 + ieee->associate_timer.function = ieee80211_associate_abort_cb_rtl7;
10418
10419 init_timer(&ieee->beacon_timer);
10420 ieee->beacon_timer.data = (unsigned long) ieee;
10421 - ieee->beacon_timer.function = ieee80211_send_beacon_cb;
10422 -
10423 + ieee->beacon_timer.function = ieee80211_send_beacon_cb_rtl7;
10424 +
10425 #ifdef PF_SYNCTHREAD
10426 ieee->wq = create_workqueue(DRV_NAME,0);
10427 -#else
10428 +#else
10429 ieee->wq = create_workqueue(DRV_NAME);
10430 #endif
10431 -
10432 - INIT_WORK(&ieee->start_ibss_wq,(void(*)(void*)) ieee80211_start_ibss_wq,ieee);
10433 - INIT_WORK(&ieee->associate_retry_wq,(void(*)(void*)) ieee80211_associate_retry_wq,ieee);
10434 - INIT_WORK(&ieee->associate_complete_wq,(void(*)(void*)) ieee80211_associate_complete_wq,ieee);
10435 - INIT_WORK(&ieee->associate_procedure_wq,(void(*)(void*)) ieee80211_associate_procedure_wq,ieee);
10436 - INIT_WORK(&ieee->softmac_scan_wq,(void(*)(void*)) ieee80211_softmac_scan_wq,ieee);
10437 - INIT_WORK(&ieee->wx_sync_scan_wq,(void(*)(void*)) ieee80211_wx_sync_scan_wq,ieee);
10438 -
10439 +
10440 +#if LINUX_VERSION_CODE < KERNEL_VERSION(2,6,20)
10441 + INIT_WORK(&ieee->start_ibss_wq,(void(*)(void*)) ieee80211_start_ibss_wq_rtl7,ieee);
10442 + INIT_WORK(&ieee->associate_retry_wq,(void(*)(void*)) ieee80211_associate_retry_wq_rtl7,ieee);
10443 + INIT_WORK(&ieee->associate_complete_wq,(void(*)(void*)) ieee80211_associate_complete_wq_rtl7,ieee);
10444 + INIT_WORK(&ieee->associate_procedure_wq,(void(*)(void*)) ieee80211_associate_procedure_wq_rtl7,ieee);
10445 + INIT_WORK(&ieee->softmac_scan_wq,(void(*)(void*)) ieee80211_softmac_scan_wq_rtl7,ieee);
10446 + INIT_WORK(&ieee->wx_sync_scan_wq,(void(*)(void*)) ieee80211_wx_sync_scan_wq_rtl7,ieee);
10447 +#else
10448 + INIT_WORK(&ieee->start_ibss_wq, ieee80211_start_ibss_wq_rtl7);
10449 + INIT_DELAYED_WORK(&ieee->associate_retry_wq, ieee80211_associate_retry_wq_rtl7);
10450 + INIT_WORK(&ieee->associate_complete_wq, ieee80211_associate_complete_wq_rtl7);
10451 + INIT_WORK(&ieee->associate_procedure_wq, ieee80211_associate_procedure_wq_rtl7);
10452 + INIT_DELAYED_WORK(&ieee->softmac_scan_wq, ieee80211_softmac_scan_wq_rtl7);
10453 + INIT_WORK(&ieee->wx_sync_scan_wq, ieee80211_wx_sync_scan_wq_rtl7);
10454 +#endif
10455 +
10456 sema_init(&ieee->wx_sem, 1);
10457 sema_init(&ieee->scan_sem, 1);
10458 -
10459 +
10460 spin_lock_init(&ieee->mgmt_tx_lock);
10461 spin_lock_init(&ieee->beacon_lock);
10462 -
10463 +
10464 tasklet_init(&ieee->ps_task,
10465 - (void(*)(unsigned long)) ieee80211_sta_ps,
10466 + (void(*)(unsigned long)) ieee80211_sta_ps_rtl7,
10467 (unsigned long)ieee);
10468
10469 }
10470
10471 -void ieee80211_softmac_free(struct ieee80211_device *ieee)
10472 +void ieee80211_softmac_free_rtl7(struct ieee80211_device *ieee)
10473 {
10474 down(&ieee->wx_sem);
10475 -
10476 +
10477 del_timer_sync(&ieee->associate_timer);
10478 cancel_delayed_work(&ieee->associate_retry_wq);
10479 destroy_workqueue(ieee->wq);
10480 -
10481 +
10482 up(&ieee->wx_sem);
10483 }
10484
10485 -/********************************************************
10486 +/********************************************************
10487 * Start of WPA code. *
10488 * this is stolen from the ipw2200 driver *
10489 ********************************************************/
10490
10491 -
10492 -static int ieee80211_wpa_enable(struct ieee80211_device *ieee, int value)
10493 +
10494 +static int ieee80211_wpa_enable_rtl7(struct ieee80211_device *ieee, int value)
10495 {
10496 /* This is called when wpa_supplicant loads and closes the driver
10497 * interface. */
10498 @@ -2210,19 +2247,19 @@
10499 return 0;
10500 }
10501
10502 -
10503 -void ieee80211_wpa_assoc_frame(struct ieee80211_device *ieee, char *wpa_ie, int wpa_ie_len)
10504 +
10505 +void ieee80211_wpa_assoc_frame_rtl7(struct ieee80211_device *ieee, char *wpa_ie, int wpa_ie_len)
10506 {
10507 /* make sure WPA is enabled */
10508 - ieee80211_wpa_enable(ieee, 1);
10509 + ieee80211_wpa_enable_rtl7(ieee, 1);
10510
10511 - ieee80211_disassociate(ieee);
10512 + ieee80211_disassociate_rtl7(ieee);
10513 }
10514
10515
10516 -static int ieee80211_wpa_mlme(struct ieee80211_device *ieee, int command, int reason)
10517 +static int ieee80211_wpa_mlme_rtl7(struct ieee80211_device *ieee, int command, int reason)
10518 {
10519 -
10520 +
10521 int ret = 0;
10522
10523 switch (command) {
10524 @@ -2231,7 +2268,7 @@
10525 break;
10526
10527 case IEEE_MLME_STA_DISASSOC:
10528 - ieee80211_disassociate(ieee);
10529 + ieee80211_disassociate_rtl7(ieee);
10530 break;
10531
10532 default:
10533 @@ -2243,7 +2280,7 @@
10534 }
10535
10536
10537 -static int ieee80211_wpa_set_wpa_ie(struct ieee80211_device *ieee,
10538 +static int ieee80211_wpa_set_wpa_ie_rtl7(struct ieee80211_device *ieee,
10539 struct ieee_param *param, int plen)
10540 {
10541 u8 *buf;
10542 @@ -2267,16 +2304,16 @@
10543 ieee->wpa_ie_len = 0;
10544 }
10545
10546 - ieee80211_wpa_assoc_frame(ieee, ieee->wpa_ie, ieee->wpa_ie_len);
10547 + ieee80211_wpa_assoc_frame_rtl7(ieee, ieee->wpa_ie, ieee->wpa_ie_len);
10548 return 0;
10549 }
10550
10551 #define AUTH_ALG_OPEN_SYSTEM 0x1
10552 #define AUTH_ALG_SHARED_KEY 0x2
10553
10554 -static int ieee80211_wpa_set_auth_algs(struct ieee80211_device *ieee, int value)
10555 +static int ieee80211_wpa_set_auth_algs_rtl7(struct ieee80211_device *ieee, int value)
10556 {
10557 -
10558 +
10559 struct ieee80211_security sec = {
10560 .flags = SEC_AUTH_MODE,
10561 };
10562 @@ -2300,13 +2337,13 @@
10563
10564
10565
10566 -static int ieee80211_wpa_set_param(struct ieee80211_device *ieee, u8 name, u32 value)
10567 +static int ieee80211_wpa_set_param_rtl7(struct ieee80211_device *ieee, u8 name, u32 value)
10568 {
10569 int ret=0;
10570
10571 switch (name) {
10572 case IEEE_PARAM_WPA_ENABLED:
10573 - ret = ieee80211_wpa_enable(ieee, value);
10574 + ret = ieee80211_wpa_enable_rtl7(ieee, value);
10575 break;
10576
10577 case IEEE_PARAM_TKIP_COUNTERMEASURES:
10578 @@ -2351,7 +2388,7 @@
10579 break;
10580
10581 case IEEE_PARAM_AUTH_ALGS:
10582 - ret = ieee80211_wpa_set_auth_algs(ieee, value);
10583 + ret = ieee80211_wpa_set_auth_algs_rtl7(ieee, value);
10584 break;
10585
10586 case IEEE_PARAM_IEEE_802_1X:
10587 @@ -2368,11 +2405,11 @@
10588
10589 /* implementation borrowed from hostap driver */
10590
10591 -static int ieee80211_wpa_set_encryption(struct ieee80211_device *ieee,
10592 +static int ieee80211_wpa_set_encryption_rtl7(struct ieee80211_device *ieee,
10593 struct ieee_param *param, int param_len)
10594 {
10595 int ret = 0;
10596 -
10597 +
10598 struct ieee80211_crypto_ops *ops;
10599 struct ieee80211_crypt_data **crypt;
10600
10601 @@ -2407,7 +2444,7 @@
10602 //sec.encrypt = 0;
10603 sec.level = SEC_LEVEL_0;
10604 sec.flags |= SEC_ENABLED | SEC_LEVEL;
10605 - ieee80211_crypt_delayed_deinit(ieee, crypt);
10606 + ieee80211_crypt_delayed_deinit_rtl7(ieee, crypt);
10607 }
10608 goto done;
10609 }
10610 @@ -2421,16 +2458,16 @@
10611 strcmp(param->u.crypt.alg, "TKIP"))
10612 goto skip_host_crypt;
10613
10614 - ops = ieee80211_get_crypto_ops(param->u.crypt.alg);
10615 + ops = ieee80211_get_crypto_ops_rtl7(param->u.crypt.alg);
10616 if (ops == NULL && strcmp(param->u.crypt.alg, "WEP") == 0) {
10617 - request_module("ieee80211_crypt_wep");
10618 - ops = ieee80211_get_crypto_ops(param->u.crypt.alg);
10619 + request_module("ieee80211_crypt_wep_rtl7");
10620 + ops = ieee80211_get_crypto_ops_rtl7(param->u.crypt.alg);
10621 } else if (ops == NULL && strcmp(param->u.crypt.alg, "TKIP") == 0) {
10622 - request_module("ieee80211_crypt_tkip");
10623 - ops = ieee80211_get_crypto_ops(param->u.crypt.alg);
10624 + request_module("ieee80211_crypt_tkip_rtl7");
10625 + ops = ieee80211_get_crypto_ops_rtl7(param->u.crypt.alg);
10626 } else if (ops == NULL && strcmp(param->u.crypt.alg, "CCMP") == 0) {
10627 - request_module("ieee80211_crypt_ccmp");
10628 - ops = ieee80211_get_crypto_ops(param->u.crypt.alg);
10629 + request_module("ieee80211_crypt_ccmp_rtl7");
10630 + ops = ieee80211_get_crypto_ops_rtl7(param->u.crypt.alg);
10631 }
10632 if (ops == NULL) {
10633 printk("unknown crypto alg '%s'\n", param->u.crypt.alg);
10634 @@ -2442,7 +2479,7 @@
10635 if (*crypt == NULL || (*crypt)->ops != ops) {
10636 struct ieee80211_crypt_data *new_crypt;
10637
10638 - ieee80211_crypt_delayed_deinit(ieee, crypt);
10639 + ieee80211_crypt_delayed_deinit_rtl7(ieee, crypt);
10640
10641 new_crypt = (struct ieee80211_crypt_data *)
10642 kmalloc(sizeof(*new_crypt), GFP_KERNEL);
10643 @@ -2525,7 +2562,7 @@
10644
10645
10646
10647 -int ieee80211_wpa_supplicant_ioctl(struct ieee80211_device *ieee, struct iw_point *p)
10648 +int ieee80211_wpa_supplicant_ioctl_rtl7(struct ieee80211_device *ieee, struct iw_point *p)
10649 {
10650 struct ieee_param *param;
10651 int ret=0;
10652 @@ -2537,7 +2574,7 @@
10653 ret = -EINVAL;
10654 goto out;
10655 }
10656 -
10657 +
10658 param = (struct ieee_param *)kmalloc(p->length, GFP_KERNEL);
10659 if (param == NULL){
10660 ret = -ENOMEM;
10661 @@ -2552,20 +2589,20 @@
10662 switch (param->cmd) {
10663
10664 case IEEE_CMD_SET_WPA_PARAM:
10665 - ret = ieee80211_wpa_set_param(ieee, param->u.wpa_param.name,
10666 + ret = ieee80211_wpa_set_param_rtl7(ieee, param->u.wpa_param.name,
10667 param->u.wpa_param.value);
10668 break;
10669
10670 case IEEE_CMD_SET_WPA_IE:
10671 - ret = ieee80211_wpa_set_wpa_ie(ieee, param, p->length);
10672 + ret = ieee80211_wpa_set_wpa_ie_rtl7(ieee, param, p->length);
10673 break;
10674
10675 case IEEE_CMD_SET_ENCRYPTION:
10676 - ret = ieee80211_wpa_set_encryption(ieee, param, p->length);
10677 + ret = ieee80211_wpa_set_encryption_rtl7(ieee, param, p->length);
10678 break;
10679
10680 case IEEE_CMD_MLME:
10681 - ret = ieee80211_wpa_mlme(ieee, param->u.mlme.command,
10682 + ret = ieee80211_wpa_mlme_rtl7(ieee, param->u.mlme.command,
10683 param->u.mlme.reason_code);
10684 break;
10685
10686 @@ -2581,11 +2618,11 @@
10687 kfree(param);
10688 out:
10689 up(&ieee->wx_sem);
10690 -
10691 +
10692 return ret;
10693 }
10694
10695 -void notify_wx_assoc_event(struct ieee80211_device *ieee)
10696 +void notify_wx_assoc_event_rtl7(struct ieee80211_device *ieee)
10697 {
10698 union iwreq_data wrqu;
10699 wrqu.ap_addr.sa_family = ARPHRD_ETHER;
10700 @@ -2597,14 +2634,14 @@
10701 }
10702
10703
10704 -EXPORT_SYMBOL(ieee80211_get_beacon);
10705 -EXPORT_SYMBOL(ieee80211_wake_queue);
10706 -EXPORT_SYMBOL(ieee80211_stop_queue);
10707 -EXPORT_SYMBOL(ieee80211_reset_queue);
10708 -EXPORT_SYMBOL(ieee80211_softmac_stop_protocol);
10709 -EXPORT_SYMBOL(ieee80211_softmac_start_protocol);
10710 -EXPORT_SYMBOL(ieee80211_is_shortslot);
10711 -EXPORT_SYMBOL(ieee80211_is_54g);
10712 -EXPORT_SYMBOL(ieee80211_wpa_supplicant_ioctl);
10713 -EXPORT_SYMBOL(ieee80211_ps_tx_ack);
10714 -//EXPORT_SYMBOL(ieee80211_sta_ps_send_null_frame);
10715 +EXPORT_SYMBOL(ieee80211_get_beacon_rtl7);
10716 +EXPORT_SYMBOL(ieee80211_wake_queue_rtl7);
10717 +EXPORT_SYMBOL(ieee80211_stop_queue_rtl7);
10718 +EXPORT_SYMBOL(ieee80211_reset_queue_rtl7);
10719 +EXPORT_SYMBOL(ieee80211_softmac_stop_protocol_rtl7);
10720 +EXPORT_SYMBOL(ieee80211_softmac_start_protocol_rtl7);
10721 +EXPORT_SYMBOL(ieee80211_is_shortslot_rtl7);
10722 +EXPORT_SYMBOL(ieee80211_is_54g_rtl7);
10723 +EXPORT_SYMBOL(ieee80211_wpa_supplicant_ioctl_rtl7);
10724 +EXPORT_SYMBOL(ieee80211_ps_tx_ack_rtl7);
10725 +//EXPORT_SYMBOL(ieee80211_sta_ps_send_null_frame_rtl7);
10726 diff -Naur rtl8187_orig/ieee80211/ieee80211_softmac_wx.c rtl8187_rawtx/ieee80211/ieee80211_softmac_wx.c
10727 --- rtl8187_orig/ieee80211/ieee80211_softmac_wx.c 2007-03-13 23:45:09.000000000 +0100
10728 +++ rtl8187_rawtx/ieee80211/ieee80211_softmac_wx.c 2007-06-05 14:00:29.000000000 +0200
10729 @@ -1,7 +1,7 @@
10730 /* IEEE 802.11 SoftMAC layer
10731 * Copyright (c) 2005 Andrea Merello <[email protected]>
10732 *
10733 - * Mostly extracted from the rtl8180-sa2400 driver for the
10734 + * Mostly extracted from the rtl8180-sa2400 driver for the
10735 * in-kernel generic ieee802.11 stack.
10736 *
10737 * Some pieces of code might be stolen from ipw2100 driver
10738 @@ -18,23 +18,23 @@
10739
10740 /* FIXME: add A freqs */
10741
10742 -const long ieee80211_wlan_frequencies[] = {
10743 - 2412, 2417, 2422, 2427,
10744 - 2432, 2437, 2442, 2447,
10745 - 2452, 2457, 2462, 2467,
10746 - 2472, 2484
10747 +const long ieee80211_wlan_frequencies_rtl7[] = {
10748 + 2412, 2417, 2422, 2427,
10749 + 2432, 2437, 2442, 2447,
10750 + 2452, 2457, 2462, 2467,
10751 + 2472, 2484
10752 };
10753
10754
10755 -int ieee80211_wx_set_freq(struct ieee80211_device *ieee, struct iw_request_info *a,
10756 +int ieee80211_wx_set_freq_rtl7(struct ieee80211_device *ieee, struct iw_request_info *a,
10757 union iwreq_data *wrqu, char *b)
10758 {
10759 int ret;
10760 struct iw_freq *fwrq = & wrqu->freq;
10761
10762 down(&ieee->wx_sem);
10763 -
10764 - if(ieee->iw_mode == IW_MODE_INFRA){
10765 +
10766 + if(ieee->iw_mode == IW_MODE_INFRA){
10767 ret = -EOPNOTSUPP;
10768 goto out;
10769 }
10770 @@ -45,31 +45,31 @@
10771 fwrq->m <= (int) 2.487e8)) {
10772 int f = fwrq->m / 100000;
10773 int c = 0;
10774 -
10775 - while ((c < 14) && (f != ieee80211_wlan_frequencies[c]))
10776 +
10777 + while ((c < 14) && (f != ieee80211_wlan_frequencies_rtl7[c]))
10778 c++;
10779 -
10780 +
10781 /* hack to fall through */
10782 fwrq->e = 0;
10783 fwrq->m = c + 1;
10784 }
10785 }
10786 -
10787 - if (fwrq->e > 0 || fwrq->m > 14 || fwrq->m < 1 ){
10788 +
10789 + if (fwrq->e > 0 || fwrq->m > 14 || fwrq->m < 1 ){
10790 ret = -EOPNOTSUPP;
10791 goto out;
10792 -
10793 +
10794 }else { /* Set the channel */
10795 -
10796 -
10797 +
10798 +
10799 ieee->current_network.channel = fwrq->m;
10800 ieee->set_chan(ieee->dev, ieee->current_network.channel);
10801 -
10802 +
10803 if(ieee->iw_mode == IW_MODE_ADHOC || ieee->iw_mode == IW_MODE_MASTER)
10804 if(ieee->state == IEEE80211_LINKED){
10805 -
10806 - ieee80211_stop_send_beacons(ieee);
10807 - ieee80211_start_send_beacons(ieee);
10808 +
10809 + ieee80211_stop_send_beacons_rtl7(ieee);
10810 + ieee80211_start_send_beacons_rtl7(ieee);
10811 }
10812 }
10813
10814 @@ -80,7 +80,7 @@
10815 }
10816
10817
10818 -int ieee80211_wx_get_freq(struct ieee80211_device *ieee,
10819 +int ieee80211_wx_get_freq_rtl7(struct ieee80211_device *ieee,
10820 struct iw_request_info *a,
10821 union iwreq_data *wrqu, char *b)
10822 {
10823 @@ -88,110 +88,110 @@
10824
10825 if (ieee->current_network.channel == 0)
10826 return -1;
10827 -
10828 +
10829 fwrq->m = ieee->current_network.channel;
10830 fwrq->e = 0;
10831 -
10832 +
10833 return 0;
10834 }
10835
10836 -int ieee80211_wx_get_wap(struct ieee80211_device *ieee,
10837 - struct iw_request_info *info,
10838 +int ieee80211_wx_get_wap_rtl7(struct ieee80211_device *ieee,
10839 + struct iw_request_info *info,
10840 union iwreq_data *wrqu, char *extra)
10841 {
10842 - unsigned long flags;
10843 -
10844 + unsigned long flags;
10845 +
10846 wrqu->ap_addr.sa_family = ARPHRD_ETHER;
10847 -
10848 +
10849 if (ieee->iw_mode == IW_MODE_MONITOR)
10850 return -1;
10851 -
10852 +
10853 /* We want avoid to give to the user inconsistent infos*/
10854 spin_lock_irqsave(&ieee->lock, flags);
10855 -
10856 - if (ieee->state != IEEE80211_LINKED &&
10857 +
10858 + if (ieee->state != IEEE80211_LINKED &&
10859 ieee->state != IEEE80211_LINKED_SCANNING &&
10860 ieee->wap_set == 0)
10861 -
10862 +
10863 memset(wrqu->ap_addr.sa_data, 0, ETH_ALEN);
10864 else
10865 - memcpy(wrqu->ap_addr.sa_data,
10866 + memcpy(wrqu->ap_addr.sa_data,
10867 ieee->current_network.bssid, ETH_ALEN);
10868 -
10869 +
10870 spin_unlock_irqrestore(&ieee->lock, flags);
10871 -
10872 +
10873 return 0;
10874 }
10875
10876
10877 -int ieee80211_wx_set_wap(struct ieee80211_device *ieee,
10878 +int ieee80211_wx_set_wap_rtl7(struct ieee80211_device *ieee,
10879 struct iw_request_info *info,
10880 union iwreq_data *awrq,
10881 char *extra)
10882 {
10883 -
10884 +
10885 int ret = 0;
10886 u8 zero[] = {0,0,0,0,0,0};
10887 unsigned long flags;
10888 -
10889 +
10890 + struct sockaddr *temp = NULL;
10891 short ifup = ieee->proto_started;//dev->flags & IFF_UP;
10892 -
10893 +
10894 ieee->sync_scan_hurryup = 1;
10895 -
10896 +
10897 down(&ieee->wx_sem);
10898 -
10899 - struct sockaddr *temp = (struct sockaddr *)awrq;
10900 -
10901 +
10902 + temp = (struct sockaddr *)awrq;
10903 /* use ifconfig hw ether */
10904 if (ieee->iw_mode == IW_MODE_MASTER){
10905 ret = -1;
10906 goto out;
10907 }
10908 -
10909 +
10910 if (temp->sa_family != ARPHRD_ETHER){
10911 ret = -EINVAL;
10912 goto out;
10913 }
10914 -
10915 +
10916 if (ifup)
10917 - ieee80211_stop_protocol(ieee);
10918 -
10919 + ieee80211_stop_protocol_rtl7(ieee);
10920 +
10921 /* just to avoid to give inconsistent infos in the
10922 - * get wx method. not really needed otherwise
10923 + * get wx method. not really needed otherwise
10924 */
10925 spin_lock_irqsave(&ieee->lock, flags);
10926 -
10927 - memcpy(ieee->current_network.bssid, temp->sa_data, ETH_ALEN);
10928 +
10929 + memcpy(ieee->current_network.bssid, temp->sa_data, ETH_ALEN);
10930 ieee->wap_set = memcmp(temp->sa_data, zero,ETH_ALEN)!=0;
10931 -
10932 +
10933 spin_unlock_irqrestore(&ieee->lock, flags);
10934 -
10935 +
10936 if (ifup)
10937 - ieee80211_start_protocol(ieee);
10938 -
10939 + ieee80211_start_protocol_rtl7(ieee);
10940 +
10941 out:
10942 up(&ieee->wx_sem);
10943 return ret;
10944 }
10945 -
10946 - int ieee80211_wx_get_essid(struct ieee80211_device *ieee, struct iw_request_info *a,union iwreq_data *wrqu,char *b)
10947 +
10948 + int ieee80211_wx_get_essid_rtl7(struct ieee80211_device *ieee, struct iw_request_info *a,union iwreq_data *wrqu,char *b)
10949 {
10950 int len,ret = 0;
10951 unsigned long flags;
10952 -
10953 +
10954 if (ieee->iw_mode == IW_MODE_MONITOR)
10955 return -1;
10956 -
10957 - /* We want avoid to give to the user inconsistent infos*/
10958 +
10959 + /* We want avoid to give to the user inconsistent infos*/
10960 spin_lock_irqsave(&ieee->lock, flags);
10961 -
10962 +
10963 if (ieee->current_network.ssid[0] == '\0' ||
10964 - ieee->current_network.ssid_len == 0){
10965 + ieee->current_network.ssid_len == 0){
10966 ret = -1;
10967 goto out;
10968 }
10969 -
10970 - if (ieee->state != IEEE80211_LINKED &&
10971 +
10972 + if (ieee->state != IEEE80211_LINKED &&
10973 ieee->state != IEEE80211_LINKED_SCANNING &&
10974 ieee->ssid_set == 0){
10975 ret = -1;
10976 @@ -204,59 +204,76 @@
10977
10978 out:
10979 spin_unlock_irqrestore(&ieee->lock, flags);
10980 -
10981 +
10982 return ret;
10983 -
10984 +
10985 }
10986
10987 -int ieee80211_wx_set_rate(struct ieee80211_device *ieee,
10988 +int ieee80211_wx_set_rate_rtl7(struct ieee80211_device *ieee,
10989 struct iw_request_info *info,
10990 union iwreq_data *wrqu, char *extra)
10991 {
10992
10993 u32 target_rate = wrqu->bitrate.value;
10994 -
10995 +
10996 ieee->rate = target_rate/100000;
10997 //FIXME: we might want to limit rate also in management protocols.
10998 - return 0;
10999 + return 0;
11000 }
11001
11002
11003
11004 -int ieee80211_wx_get_rate(struct ieee80211_device *ieee,
11005 - struct iw_request_info *info,
11006 +int ieee80211_wx_get_rate_rtl7(struct ieee80211_device *ieee,
11007 + struct iw_request_info *info,
11008 union iwreq_data *wrqu, char *extra)
11009 {
11010 -
11011 +
11012 wrqu->bitrate.value = ieee->rate * 100000;
11013 -
11014 +
11015 return 0;
11016 }
11017
11018 -int ieee80211_wx_set_mode(struct ieee80211_device *ieee, struct iw_request_info *a,
11019 +int ieee80211_wx_set_mode_rtl7(struct ieee80211_device *ieee, struct iw_request_info *a,
11020 union iwreq_data *wrqu, char *b)
11021 {
11022 -
11023 + short prev = ieee->raw_tx;
11024 +
11025 ieee->sync_scan_hurryup = 1;
11026 -
11027 +
11028 down(&ieee->wx_sem);
11029 -
11030 +
11031 if (wrqu->mode == ieee->iw_mode)
11032 goto out;
11033 -
11034 +
11035 if (wrqu->mode == IW_MODE_MONITOR){
11036 -
11037 - ieee->dev->type = ARPHRD_IEEE80211;
11038 + ieee->dev->type = ARPHRD_IEEE80211_PRISM;
11039 }else{
11040 ieee->dev->type = ARPHRD_ETHER;
11041 }
11042 -
11043 +
11044 if (!ieee->proto_started){
11045 ieee->iw_mode = wrqu->mode;
11046 }else{
11047 - ieee80211_stop_protocol(ieee);
11048 + ieee80211_stop_protocol_rtl7(ieee);
11049 ieee->iw_mode = wrqu->mode;
11050 - ieee80211_start_protocol(ieee);
11051 + ieee80211_start_protocol_rtl7(ieee);
11052 + }
11053 +
11054 + if(ieee->iw_mode == IW_MODE_MONITOR)
11055 + {
11056 + ieee->raw_tx = 1;
11057 + if(prev == 0 && ieee->raw_tx){
11058 + if (ieee->data_hard_resume)
11059 + ieee->data_hard_resume(ieee->dev);
11060 +
11061 + netif_carrier_on(ieee->dev);
11062 + }
11063 +
11064 + netif_carrier_on(ieee->dev);
11065 + }
11066 + else
11067 + {
11068 + ieee->raw_tx = 0;
11069 }
11070
11071 out:
11072 @@ -264,120 +281,132 @@
11073 return 0;
11074 }
11075
11076 -void ieee80211_wx_sync_scan_wq(struct ieee80211_device *ieee)
11077 +# if (LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,20))
11078 +void ieee80211_wx_sync_scan_wq_rtl7(struct work_struct *work)
11079 {
11080 + struct ieee80211_device *ieee = container_of(work, struct ieee80211_device, wx_sync_scan_wq);
11081 +#else
11082 +void ieee80211_wx_sync_scan_wq_rtl7(struct ieee80211_device *ieee)
11083 +{
11084 +#endif
11085 short chan;
11086
11087 chan = ieee->current_network.channel;
11088 -
11089 +
11090 netif_carrier_off(ieee->dev);
11091 -
11092 +
11093 if (ieee->data_hard_stop)
11094 ieee->data_hard_stop(ieee->dev);
11095 -
11096 - ieee80211_stop_send_beacons(ieee);
11097 -
11098 +
11099 + ieee80211_stop_send_beacons_rtl7(ieee);
11100 +
11101 ieee->state = IEEE80211_LINKED_SCANNING;
11102 ieee->link_change(ieee->dev);
11103 -
11104 - ieee80211_start_scan_syncro(ieee);
11105 -
11106 +
11107 + ieee80211_start_scan_syncro_rtl7(ieee);
11108 +
11109 ieee->set_chan(ieee->dev, chan);
11110 -
11111 +
11112 ieee->state = IEEE80211_LINKED;
11113 ieee->link_change(ieee->dev);
11114 -
11115 +
11116 if (ieee->data_hard_resume)
11117 ieee->data_hard_resume(ieee->dev);
11118 -
11119 +
11120 if(ieee->iw_mode == IW_MODE_ADHOC || ieee->iw_mode == IW_MODE_MASTER)
11121 - ieee80211_start_send_beacons(ieee);
11122 -
11123 + ieee80211_start_send_beacons_rtl7(ieee);
11124 +
11125 netif_carrier_on(ieee->dev);
11126 -
11127 +
11128 up(&ieee->wx_sem);
11129 -
11130 +
11131 }
11132
11133 -int ieee80211_wx_set_scan(struct ieee80211_device *ieee, struct iw_request_info *a,
11134 +int ieee80211_wx_set_scan_rtl7(struct ieee80211_device *ieee, struct iw_request_info *a,
11135 union iwreq_data *wrqu, char *b)
11136 {
11137 int ret = 0;
11138 -
11139 +
11140 down(&ieee->wx_sem);
11141 -
11142 - if (ieee->iw_mode == IW_MODE_MONITOR || !(ieee->proto_started)){
11143 +
11144 + if (ieee->iw_mode == IW_MODE_MONITOR || !(ieee->proto_started)){
11145 ret = -1;
11146 goto out;
11147 }
11148 -
11149 +
11150 if ( ieee->state == IEEE80211_LINKED){
11151 queue_work(ieee->wq, &ieee->wx_sync_scan_wq);
11152 /* intentionally forget to up sem */
11153 return 0;
11154 }
11155 -
11156 +
11157 out:
11158 up(&ieee->wx_sem);
11159 return ret;
11160 }
11161
11162 -int ieee80211_wx_set_essid(struct ieee80211_device *ieee,
11163 +int ieee80211_wx_set_essid_rtl7(struct ieee80211_device *ieee,
11164 struct iw_request_info *a,
11165 union iwreq_data *wrqu, char *extra)
11166 {
11167 -
11168 +
11169 int ret=0,len;
11170 short proto_started;
11171 unsigned long flags;
11172 -
11173 +
11174 ieee->sync_scan_hurryup = 1;
11175 -
11176 +
11177 down(&ieee->wx_sem);
11178 -
11179 +
11180 proto_started = ieee->proto_started;
11181 -
11182 +
11183 if (wrqu->essid.length > IW_ESSID_MAX_SIZE){
11184 ret= -E2BIG;
11185 goto out;
11186 }
11187 -
11188 +
11189 if (ieee->iw_mode == IW_MODE_MONITOR){
11190 ret= -1;
11191 goto out;
11192 }
11193 -
11194 +
11195 if(proto_started)
11196 - ieee80211_stop_protocol(ieee);
11197 -
11198 + ieee80211_stop_protocol_rtl7(ieee);
11199 +
11200 /* this is just to be sure that the GET wx callback
11201 * has consisten infos. not needed otherwise
11202 */
11203 spin_lock_irqsave(&ieee->lock, flags);
11204 -
11205 +
11206 if (wrqu->essid.flags && wrqu->essid.length) {
11207 +#if WIRELESS_EXT > 20
11208 + len = min((int)wrqu->essid.length, IW_ESSID_MAX_SIZE);
11209 +#else
11210 len = ((wrqu->essid.length-1) < IW_ESSID_MAX_SIZE) ? (wrqu->essid.length-1) : IW_ESSID_MAX_SIZE;
11211 -
11212 +#endif
11213 +
11214 strncpy(ieee->current_network.ssid, extra, len);
11215 ieee->current_network.ssid_len = len;
11216 ieee->ssid_set = 1;
11217 }
11218 - else{
11219 + else{
11220 ieee->ssid_set = 0;
11221 ieee->current_network.ssid[0] = '\0';
11222 ieee->current_network.ssid_len = 0;
11223 }
11224 -
11225 +
11226 spin_unlock_irqrestore(&ieee->lock, flags);
11227 -
11228 +
11229 if (proto_started)
11230 - ieee80211_start_protocol(ieee);
11231 + ieee80211_start_protocol_rtl7(ieee);
11232 out:
11233 up(&ieee->wx_sem);
11234 +
11235 +
11236 return ret;
11237 }
11238
11239 - int ieee80211_wx_get_mode(struct ieee80211_device *ieee, struct iw_request_info *a,
11240 + int ieee80211_wx_get_mode_rtl7(struct ieee80211_device *ieee, struct iw_request_info *a,
11241 union iwreq_data *wrqu, char *b)
11242 {
11243
11244 @@ -385,23 +414,23 @@
11245 return 0;
11246 }
11247
11248 - int ieee80211_wx_set_rawtx(struct ieee80211_device *ieee,
11249 - struct iw_request_info *info,
11250 + int ieee80211_wx_set_rawtx_rtl7(struct ieee80211_device *ieee,
11251 + struct iw_request_info *info,
11252 union iwreq_data *wrqu, char *extra)
11253 {
11254 -
11255 +
11256 int *parms = (int *)extra;
11257 int enable = (parms[0] > 0);
11258 short prev = ieee->raw_tx;
11259
11260 down(&ieee->wx_sem);
11261 -
11262 - if(enable)
11263 +
11264 + if(enable)
11265 ieee->raw_tx = 1;
11266 - else
11267 + else
11268 ieee->raw_tx = 0;
11269
11270 - printk(KERN_INFO"raw TX is %s\n",
11271 + printk(KERN_INFO"raw TX is %s\n",
11272 ieee->raw_tx ? "enabled" : "disabled");
11273
11274 if(ieee->iw_mode == IW_MODE_MONITOR)
11275 @@ -409,21 +438,21 @@
11276 if(prev == 0 && ieee->raw_tx){
11277 if (ieee->data_hard_resume)
11278 ieee->data_hard_resume(ieee->dev);
11279 -
11280 - netif_carrier_on(ieee->dev);
11281 +
11282 + netif_carrier_on(ieee->dev);
11283 }
11284 -
11285 +
11286 if(prev && ieee->raw_tx == 1)
11287 - netif_carrier_off(ieee->dev);
11288 + netif_carrier_off(ieee->dev);
11289 }
11290 -
11291 +
11292 up(&ieee->wx_sem);
11293 -
11294 +
11295 return 0;
11296 }
11297 -
11298 -int ieee80211_wx_get_name(struct ieee80211_device *ieee,
11299 - struct iw_request_info *info,
11300 +
11301 +int ieee80211_wx_get_name_rtl7(struct ieee80211_device *ieee,
11302 + struct iw_request_info *info,
11303 union iwreq_data *wrqu, char *extra)
11304 {
11305 strcpy(wrqu->name, "802.11");
11306 @@ -433,20 +462,20 @@
11307 strcat(wrqu->name, "/g");
11308 }else if(ieee->modulation & IEEE80211_OFDM_MODULATION)
11309 strcat(wrqu->name, "g");
11310 -
11311 - if((ieee->state == IEEE80211_LINKED) ||
11312 +
11313 + if((ieee->state == IEEE80211_LINKED) ||
11314 (ieee->state == IEEE80211_LINKED_SCANNING))
11315 strcat(wrqu->name," linked");
11316 else if(ieee->state != IEEE80211_NOLINK)
11317 strcat(wrqu->name," link..");
11318 -
11319 -
11320 +
11321 +
11322 return 0;
11323 }
11324
11325
11326 /* this is mostly stolen from hostap */
11327 -int ieee80211_wx_set_power(struct ieee80211_device *ieee,
11328 +int ieee80211_wx_set_power_rtl7(struct ieee80211_device *ieee,
11329 struct iw_request_info *info,
11330 union iwreq_data *wrqu, char *extra)
11331 {
11332 @@ -457,50 +486,50 @@
11333 (!ieee->ps_request_tx_ack) ||
11334 (!ieee->enter_sleep_state) ||
11335 (!ieee->ps_is_queue_empty)){
11336 -
11337 +
11338 printk("ERROR. PS mode is tryied to be use but\
11339 -driver missed a callback\n\n");
11340 -
11341 +driver missed a callback\n\n");
11342 +
11343 return -1;
11344 }
11345 -
11346 +
11347 down(&ieee->wx_sem);
11348 -
11349 +
11350 if (wrqu->power.disabled){
11351 ieee->ps = IEEE80211_PS_DISABLED;
11352 -
11353 +
11354 goto exit;
11355 }
11356 switch (wrqu->power.flags & IW_POWER_MODE) {
11357 case IW_POWER_UNICAST_R:
11358 ieee->ps = IEEE80211_PS_UNICAST;
11359 -
11360 +
11361 break;
11362 case IW_POWER_ALL_R:
11363 - ieee->ps = IEEE80211_PS_UNICAST | IEEE80211_PS_MBCAST;
11364 + ieee->ps = IEEE80211_PS_UNICAST | IEEE80211_PS_MBCAST;
11365 break;
11366 -
11367 +
11368 case IW_POWER_ON:
11369 ieee->ps = IEEE80211_PS_DISABLED;
11370 break;
11371 -
11372 +
11373 default:
11374 ret = -EINVAL;
11375 goto exit;
11376 }
11377
11378 if (wrqu->power.flags & IW_POWER_TIMEOUT) {
11379 -
11380 +
11381 ieee->ps_timeout = wrqu->power.value / 1000;
11382 printk("Timeout %d\n",ieee->ps_timeout);
11383 }
11384 -
11385 +
11386 if (wrqu->power.flags & IW_POWER_PERIOD) {
11387 -
11388 +
11389 ret = -EOPNOTSUPP;
11390 goto exit;
11391 //wrq->value / 1024;
11392 -
11393 +
11394 }
11395 exit:
11396 up(&ieee->wx_sem);
11397 @@ -509,15 +538,15 @@
11398 }
11399
11400 /* this is stolen from hostap */
11401 -int ieee80211_wx_get_power(struct ieee80211_device *ieee,
11402 +int ieee80211_wx_get_power_rtl7(struct ieee80211_device *ieee,
11403 struct iw_request_info *info,
11404 union iwreq_data *wrqu, char *extra)
11405 {
11406 int ret =0;
11407 -
11408 +
11409 down(&ieee->wx_sem);
11410 -
11411 - if(ieee->ps == IEEE80211_PS_DISABLED){
11412 +
11413 + if(ieee->ps == IEEE80211_PS_DISABLED){
11414 wrqu->power.disabled = 1;
11415 goto exit;
11416 }
11417 @@ -547,19 +576,19 @@
11418
11419 }
11420
11421 -EXPORT_SYMBOL(ieee80211_wx_get_essid);
11422 -EXPORT_SYMBOL(ieee80211_wx_set_essid);
11423 -EXPORT_SYMBOL(ieee80211_wx_set_rate);
11424 -EXPORT_SYMBOL(ieee80211_wx_get_rate);
11425 -EXPORT_SYMBOL(ieee80211_wx_set_wap);
11426 -EXPORT_SYMBOL(ieee80211_wx_get_wap);
11427 -EXPORT_SYMBOL(ieee80211_wx_set_mode);
11428 -EXPORT_SYMBOL(ieee80211_wx_get_mode);
11429 -EXPORT_SYMBOL(ieee80211_wx_set_scan);
11430 -EXPORT_SYMBOL(ieee80211_wx_get_freq);
11431 -EXPORT_SYMBOL(ieee80211_wx_set_freq);
11432 -EXPORT_SYMBOL(ieee80211_wx_set_rawtx);
11433 -EXPORT_SYMBOL(ieee80211_wx_get_name);
11434 -EXPORT_SYMBOL(ieee80211_wx_set_power);
11435 -EXPORT_SYMBOL(ieee80211_wx_get_power);
11436 -EXPORT_SYMBOL(ieee80211_wlan_frequencies);
11437 +EXPORT_SYMBOL(ieee80211_wx_get_essid_rtl7);
11438 +EXPORT_SYMBOL(ieee80211_wx_set_essid_rtl7);
11439 +EXPORT_SYMBOL(ieee80211_wx_set_rate_rtl7);
11440 +EXPORT_SYMBOL(ieee80211_wx_get_rate_rtl7);
11441 +EXPORT_SYMBOL(ieee80211_wx_set_wap_rtl7);
11442 +EXPORT_SYMBOL(ieee80211_wx_get_wap_rtl7);
11443 +EXPORT_SYMBOL(ieee80211_wx_set_mode_rtl7);
11444 +EXPORT_SYMBOL(ieee80211_wx_get_mode_rtl7);
11445 +EXPORT_SYMBOL(ieee80211_wx_set_scan_rtl7);
11446 +EXPORT_SYMBOL(ieee80211_wx_get_freq_rtl7);
11447 +EXPORT_SYMBOL(ieee80211_wx_set_freq_rtl7);
11448 +EXPORT_SYMBOL(ieee80211_wx_set_rawtx_rtl7);
11449 +EXPORT_SYMBOL(ieee80211_wx_get_name_rtl7);
11450 +EXPORT_SYMBOL(ieee80211_wx_set_power_rtl7);
11451 +EXPORT_SYMBOL(ieee80211_wx_get_power_rtl7);
11452 +EXPORT_SYMBOL(ieee80211_wlan_frequencies_rtl7);
11453 diff -Naur rtl8187_orig/ieee80211/ieee80211_tx.c rtl8187_rawtx/ieee80211/ieee80211_tx.c
11454 --- rtl8187_orig/ieee80211/ieee80211_tx.c 2007-03-13 23:45:09.000000000 +0100
11455 +++ rtl8187_rawtx/ieee80211/ieee80211_tx.c 2007-06-05 14:00:29.000000000 +0200
11456 @@ -32,7 +32,6 @@
11457 ******************************************************************************/
11458
11459 #include <linux/compiler.h>
11460 -#include <linux/config.h>
11461 #include <linux/errno.h>
11462 #include <linux/if_arp.h>
11463 #include <linux/in6.h>
11464 @@ -52,6 +51,12 @@
11465 #include <linux/etherdevice.h>
11466 #include <asm/uaccess.h>
11467
11468 +#if (LINUX_VERSION_CODE < KERNEL_VERSION(2,6,19))
11469 +#include <linux/config.h>
11470 +#else
11471 +#include <linux/autoconf.h>
11472 +#endif
11473 +
11474 #include "ieee80211.h"
11475
11476
11477 @@ -155,7 +160,7 @@
11478 static u8 P802_1H_OUI[P80211_OUI_LEN] = { 0x00, 0x00, 0xf8 };
11479 static u8 RFC1042_OUI[P80211_OUI_LEN] = { 0x00, 0x00, 0x00 };
11480
11481 -static inline int ieee80211_put_snap(u8 *data, u16 h_proto)
11482 +static inline int ieee80211_put_snap_rtl7(u8 *data, u16 h_proto)
11483 {
11484 struct ieee80211_snap_hdr *snap;
11485 u8 *oui;
11486 @@ -178,7 +183,7 @@
11487 return SNAP_SIZE + sizeof(u16);
11488 }
11489
11490 -int ieee80211_encrypt_fragment(
11491 +int ieee80211_encrypt_fragment_rtl7(
11492 struct ieee80211_device *ieee,
11493 struct sk_buff *frag,
11494 int hdr_len)
11495 @@ -225,7 +230,7 @@
11496 }
11497
11498
11499 -void ieee80211_txb_free(struct ieee80211_txb *txb) {
11500 +void ieee80211_txb_free_rtl7(struct ieee80211_txb *txb) {
11501 int i;
11502 if (unlikely(!txb))
11503 return;
11504 @@ -235,7 +240,7 @@
11505 kfree(txb);
11506 }
11507
11508 -struct ieee80211_txb *ieee80211_alloc_txb(int nr_frags, int txb_size,
11509 +struct ieee80211_txb *ieee80211_alloc_txb_rtl7(int nr_frags, int txb_size,
11510 int gfp_mask)
11511 {
11512 struct ieee80211_txb *txb;
11513 @@ -267,7 +272,7 @@
11514 }
11515
11516 /* SKBs are added to the ieee->tx_queue. */
11517 -int ieee80211_xmit(struct sk_buff *skb,
11518 +int ieee80211_xmit_rtl7(struct sk_buff *skb,
11519 struct net_device *dev)
11520 {
11521 struct ieee80211_device *ieee = netdev_priv(dev);
11522 @@ -397,7 +402,7 @@
11523 /* When we allocate the TXB we allocate enough space for the reserve
11524 * and full fragment bytes (bytes_per_frag doesn't include prefix,
11525 * postfix, header, FCS, etc.) */
11526 - txb = ieee80211_alloc_txb(nr_frags, frag_size, GFP_ATOMIC);
11527 + txb = ieee80211_alloc_txb_rtl7(nr_frags, frag_size, GFP_ATOMIC);
11528 if (unlikely(!txb)) {
11529 printk(KERN_WARNING "%s: Could not allocate TXB\n",
11530 ieee->dev->name);
11531 @@ -432,7 +437,7 @@
11532
11533 /* Put a SNAP header on the first fragment */
11534 if (i == 0) {
11535 - ieee80211_put_snap(
11536 + ieee80211_put_snap_rtl7(
11537 skb_put(skb_frag, SNAP_SIZE + sizeof(u16)),
11538 ether_type);
11539 bytes -= SNAP_SIZE + sizeof(u16);
11540 @@ -446,7 +451,7 @@
11541 /* Encryption routine will move the header forward in order
11542 * to insert the IV between the header and the payload */
11543 if (encrypt)
11544 - ieee80211_encrypt_fragment(ieee, skb_frag, hdr_len);
11545 + ieee80211_encrypt_fragment_rtl7(ieee, skb_frag, hdr_len);
11546 if (ieee->config &
11547 (CFG_IEEE80211_COMPUTE_FCS | CFG_IEEE80211_RESERVE_FCS))
11548 skb_put(skb_frag, 4);
11549 @@ -458,13 +463,14 @@
11550 ieee->seq_ctrl++;
11551 //---
11552 }else{
11553 - if (unlikely(skb->len < sizeof(struct ieee80211_hdr_3addr))) {
11554 +// if (unlikely(skb->len < sizeof(struct ieee80211_hdr_3addr))) {
11555 + if (unlikely(skb->len < 14)) {
11556 printk(KERN_WARNING "%s: skb too small (%d).\n",
11557 ieee->dev->name, skb->len);
11558 goto success;
11559 }
11560
11561 - txb = ieee80211_alloc_txb(1, skb->len, GFP_ATOMIC);
11562 + txb = ieee80211_alloc_txb_rtl7(1, skb->len, GFP_ATOMIC);
11563 if(!txb){
11564 printk(KERN_WARNING "%s: Could not allocate TXB\n",
11565 ieee->dev->name);
11566 @@ -481,14 +487,14 @@
11567 dev_kfree_skb_any(skb);
11568 if (txb) {
11569 if (ieee->softmac_features & IEEE_SOFTMAC_TX_QUEUE){
11570 - ieee80211_softmac_xmit(txb, ieee);
11571 + ieee80211_softmac_xmit_rtl7(txb, ieee);
11572 }else{
11573 if ((*ieee->hard_start_xmit)(txb, dev) == 0) {
11574 stats->tx_packets++;
11575 stats->tx_bytes += txb->payload_size;
11576 return 0;
11577 }
11578 - ieee80211_txb_free(txb);
11579 + ieee80211_txb_free_rtl7(txb);
11580 }
11581
11582
11583 @@ -504,4 +510,4 @@
11584
11585 }
11586
11587 -EXPORT_SYMBOL(ieee80211_txb_free);
11588 +EXPORT_SYMBOL(ieee80211_txb_free_rtl7);
11589 diff -Naur rtl8187_orig/ieee80211/ieee80211_wx.c rtl8187_rawtx/ieee80211/ieee80211_wx.c
11590 --- rtl8187_orig/ieee80211/ieee80211_wx.c 2007-03-13 23:45:09.000000000 +0100
11591 +++ rtl8187_rawtx/ieee80211/ieee80211_wx.c 2007-06-05 14:00:29.000000000 +0200
11592 @@ -40,7 +40,7 @@
11593 };
11594
11595 #define MAX_CUSTOM_LEN 64
11596 -static inline char *ipw2100_translate_scan(struct ieee80211_device *ieee,
11597 +static inline char *ipw2100_translate_scan_rtl7(struct ieee80211_device *ieee,
11598 char *start, char *stop,
11599 struct ieee80211_network *network)
11600 {
11601 @@ -207,7 +207,7 @@
11602 return start;
11603 }
11604
11605 -int ieee80211_wx_get_scan(struct ieee80211_device *ieee,
11606 +int ieee80211_wx_get_scan_rtl7(struct ieee80211_device *ieee,
11607 struct iw_request_info *info,
11608 union iwreq_data *wrqu, char *extra)
11609 {
11610 @@ -220,13 +220,14 @@
11611
11612 IEEE80211_DEBUG_WX("Getting scan\n");
11613 down(&ieee->wx_sem);
11614 + printk("GOT WX GET SCAN WX_SEM LOCK");
11615 spin_lock_irqsave(&ieee->lock, flags);
11616
11617 list_for_each_entry(network, &ieee->network_list, list) {
11618 i++;
11619 if (ieee->scan_age == 0 ||
11620 time_after(network->last_scanned + ieee->scan_age, jiffies))
11621 - ev = ipw2100_translate_scan(ieee, ev, stop, network);
11622 + ev = ipw2100_translate_scan_rtl7(ieee, ev, stop, network);
11623 else
11624 IEEE80211_DEBUG_SCAN(
11625 "Not showing network '%s ("
11626 @@ -247,7 +248,7 @@
11627 return 0;
11628 }
11629
11630 -int ieee80211_wx_set_encode(struct ieee80211_device *ieee,
11631 +int ieee80211_wx_set_encode_rtl7(struct ieee80211_device *ieee,
11632 struct iw_request_info *info,
11633 union iwreq_data *wrqu, char *keybuf)
11634 {
11635 @@ -281,7 +282,7 @@
11636 if (key_provided && *crypt) {
11637 IEEE80211_DEBUG_WX("Disabling encryption on key %d.\n",
11638 key);
11639 - ieee80211_crypt_delayed_deinit(ieee, crypt);
11640 + ieee80211_crypt_delayed_deinit_rtl7(ieee, crypt);
11641 } else
11642 IEEE80211_DEBUG_WX("Disabling encryption.\n");
11643
11644 @@ -291,7 +292,7 @@
11645 if (ieee->crypt[i] != NULL) {
11646 if (key_provided)
11647 break;
11648 - ieee80211_crypt_delayed_deinit(
11649 + ieee80211_crypt_delayed_deinit_rtl7(
11650 ieee, &ieee->crypt[i]);
11651 }
11652 }
11653 @@ -314,7 +315,7 @@
11654 strcmp((*crypt)->ops->name, "WEP") != 0) {
11655 /* changing to use WEP; deinit previously used algorithm
11656 * on this key */
11657 - ieee80211_crypt_delayed_deinit(ieee, crypt);
11658 + ieee80211_crypt_delayed_deinit_rtl7(ieee, crypt);
11659 }
11660
11661 if (*crypt == NULL) {
11662 @@ -326,10 +327,10 @@
11663 if (new_crypt == NULL)
11664 return -ENOMEM;
11665 memset(new_crypt, 0, sizeof(struct ieee80211_crypt_data));
11666 - new_crypt->ops = ieee80211_get_crypto_ops("WEP");
11667 + new_crypt->ops = ieee80211_get_crypto_ops_rtl7("WEP");
11668 if (!new_crypt->ops) {
11669 request_module("ieee80211_crypt_wep");
11670 - new_crypt->ops = ieee80211_get_crypto_ops("WEP");
11671 + new_crypt->ops = ieee80211_get_crypto_ops_rtl7("WEP");
11672 }
11673
11674 if (new_crypt->ops && try_module_get(new_crypt->ops->owner))
11675 @@ -418,7 +419,7 @@
11676 return 0;
11677 }
11678
11679 -int ieee80211_wx_get_encode(struct ieee80211_device *ieee,
11680 +int ieee80211_wx_get_encode_rtl7(struct ieee80211_device *ieee,
11681 struct iw_request_info *info,
11682 union iwreq_data *wrqu, char *keybuf)
11683 {
11684 @@ -470,6 +471,6 @@
11685 }
11686
11687
11688 -EXPORT_SYMBOL(ieee80211_wx_get_scan);
11689 -EXPORT_SYMBOL(ieee80211_wx_set_encode);
11690 -EXPORT_SYMBOL(ieee80211_wx_get_encode);
11691 +EXPORT_SYMBOL(ieee80211_wx_get_scan_rtl7);
11692 +EXPORT_SYMBOL(ieee80211_wx_set_encode_rtl7);
11693 +EXPORT_SYMBOL(ieee80211_wx_get_encode_rtl7);
11694 diff -Naur rtl8187_orig/ieee80211/Makefile rtl8187_rawtx/ieee80211/Makefile
11695 --- rtl8187_orig/ieee80211/Makefile 2007-03-13 23:45:09.000000000 +0100
11696 +++ rtl8187_rawtx/ieee80211/Makefile 2007-05-27 10:47:26.000000000 +0200
11697 @@ -17,6 +17,7 @@
11698 KVER := $(shell uname -r)
11699 KSRC := /lib/modules/$(KVER)/build
11700 INSTALL_PREFIX :=
11701 +PWD = $(shell pwd)
11702
11703 all: modules
11704
11705 diff -Naur rtl8187_orig/Makefile rtl8187_rawtx/Makefile
11706 --- rtl8187_orig/Makefile 1970-01-01 01:00:00.000000000 +0100
11707 +++ rtl8187_rawtx/Makefile 2007-05-26 10:39:10.000000000 +0200
11708 @@ -0,0 +1,36 @@
11709 +prefix = /lib/modules/$(shell uname -r)/kernel/drivers/net/wireless
11710 +r8187dir = $(prefix)/rtl8187
11711 +ieeedir = $(prefix)/rtl_ieee80211
11712 +
11713 +default: all
11714 +
11715 +all:
11716 + $(MAKE) -C ieee80211 $(@)
11717 + -chmod +x symvers
11718 + -./symvers
11719 + $(MAKE) -C beta-8187 $(@)
11720 +
11721 +install:
11722 + install -d $(ieeedir)
11723 + install -d $(r8187dir)
11724 + install -m 644 ./ieee80211/*.ko $(ieeedir)
11725 + install -m 644 ./beta-8187/*.ko $(r8187dir)
11726 + -depmod -ae
11727 +
11728 +uninstall:
11729 + -rm -f $(ieeedir)/ieee80211-rtl.ko
11730 + -rm -f $(ieeedir)/ieee80211_crypt-rtl.ko
11731 + -rm -f $(ieeedir)/ieee80211_crypt_ccmp-rtl.ko
11732 + -rm -f $(ieeedir)/ieee80211_crypt_tkip-rtl.ko
11733 + -rm -f $(ieeedir)/ieee80211_crypt_wep-rtl.ko
11734 + -rm -f $(r8187dir)/r8187.ko
11735 + -rm -fr $(ieeedir)
11736 + -rm -fr $(r8187dir)
11737 + -depmod -ae
11738 +
11739 +clean:
11740 + $(MAKE) -C ieee80211 $(@)
11741 + $(MAKE) -C beta-8187 $(@)
11742 +
11743 +distclean: clean
11744 +
11745 diff -Naur rtl8187_orig/symvers rtl8187_rawtx/symvers
11746 --- rtl8187_orig/symvers 1970-01-01 01:00:00.000000000 +0100
11747 +++ rtl8187_rawtx/symvers 2007-05-26 10:39:22.000000000 +0200
11748 @@ -0,0 +1,25 @@
11749 +#!/bin/sh
11750 +
11751 +cd beta-8187
11752 +
11753 +if [ -e Module.symvers ]
11754 +then
11755 + rm Module.symvers
11756 +fi
11757 +
11758 +if [ -e Modules.symvers ]
11759 +then
11760 + rm Modules.symvers
11761 +fi
11762 +
11763 +if [ -e ../ieee80211/Module.symvers ]
11764 +then
11765 + ln -sf ../ieee80211/Module.symvers ./
11766 +fi
11767 +
11768 +if [ -e ../ieee80211/Modules.symvers ]
11769 +then
11770 + ln -sf ../ieee80211/Modules.symvers ./
11771 +fi
11772 +
11773 +cd ..