nexmon – Blame information for rev 1

Subversion Repositories:
Rev:
Rev Author Line No. Line
1 office 1 diff -Naur rtl8187_orig/beta-8187/ieee80211_crypt.h rtl8187_rawtx/beta-8187/ieee80211_crypt.h
2 --- rtl8187_orig/beta-8187/ieee80211_crypt.h 2007-03-13 23:45:09.000000000 +0100
3 +++ rtl8187_rawtx/beta-8187/ieee80211_crypt.h 2007-07-13 01:46:27.000000000 +0200
4 @@ -75,12 +75,12 @@
5 atomic_t refcnt;
6 };
7  
8 -int ieee80211_register_crypto_ops(struct ieee80211_crypto_ops *ops);
9 -int ieee80211_unregister_crypto_ops(struct ieee80211_crypto_ops *ops);
10 -struct ieee80211_crypto_ops * ieee80211_get_crypto_ops(const char *name);
11 -void ieee80211_crypt_deinit_entries(struct ieee80211_device *, int);
12 -void ieee80211_crypt_deinit_handler(unsigned long);
13 -void ieee80211_crypt_delayed_deinit(struct ieee80211_device *ieee,
14 +int ieee80211_register_crypto_ops_rtl7(struct ieee80211_crypto_ops *ops);
15 +int ieee80211_unregister_crypto_ops_rtl7(struct ieee80211_crypto_ops *ops);
16 +struct ieee80211_crypto_ops * ieee80211_get_crypto_ops_rtl7(const char *name);
17 +void ieee80211_crypt_deinit_entries_rtl7(struct ieee80211_device *, int);
18 +void ieee80211_crypt_deinit_handler_rtl7(unsigned long);
19 +void ieee80211_crypt_delayed_deinit_rtl7(struct ieee80211_device *ieee,
20 struct ieee80211_crypt_data **crypt);
21  
22 #endif
23 diff -Naur rtl8187_orig/beta-8187/ieee80211.h rtl8187_rawtx/beta-8187/ieee80211.h
24 --- rtl8187_orig/beta-8187/ieee80211.h 2007-03-13 23:45:09.000000000 +0100
25 +++ rtl8187_rawtx/beta-8187/ieee80211.h 2007-07-13 01:46:27.000000000 +0200
26 @@ -120,7 +120,7 @@
27 static inline unsigned long msleep_interruptible_rtl(unsigned int msecs)
28 {
29 unsigned long timeout = MSECS(msecs) + 1;
30 -
31 +
32 while (timeout) {
33 set_current_state(TASK_UNINTERRUPTIBLE);
34 timeout = schedule_timeout(timeout);
35 @@ -156,6 +156,22 @@
36 struct list_head list;
37 };
38  
39 +#define LWNG_CAP_DID_BASE (4 | (1 << 6)) /* section 4, group 1 */
40 +/* ARPHRD_IEEE80211_PRISM uses a bloated version of Prism2 RX frame header
41 + * (from linux-wlan-ng) */
42 +struct linux_wlan_ng_val {
43 + u32 did;
44 + u16 status, len;
45 + u32 data;
46 +} __attribute__ ((packed));
47 +
48 +struct linux_wlan_ng_prism_hdr {
49 + u32 msgcode, msglen;
50 + char devname[16];
51 + struct linux_wlan_ng_val hosttime, mactime, channel, rssi, sq, signal,
52 + noise, rate, istx, frmlen;
53 +} __attribute__ ((packed));
54 +
55 struct ieee80211_hdr {
56 u16 frame_ctl;
57 u16 duration_id;
58 @@ -798,7 +814,7 @@
59  
60 /* the card is not linked at all */
61 IEEE80211_NOLINK = 0,
62 -
63 +
64 /* IEEE80211_ASSOCIATING* are for BSS client mode
65 * the driver shall not perform RX filtering unless
66 * the state is LINKED.
67 @@ -806,31 +822,31 @@
68 * defaults to NOLINK for ALL the other states (including
69 * LINKED_SCANNING)
70 */
71 -
72 +
73 /* the association procedure will start (wq scheduling)*/
74 IEEE80211_ASSOCIATING,
75 IEEE80211_ASSOCIATING_RETRY,
76 -
77 +
78 /* the association procedure is sending AUTH request*/
79 IEEE80211_ASSOCIATING_AUTHENTICATING,
80 -
81 +
82 /* the association procedure has successfully authentcated
83 * and is sending association request
84 */
85 IEEE80211_ASSOCIATING_AUTHENTICATED,
86 -
87 +
88 /* the link is ok. the card associated to a BSS or linked
89 * to a ibss cell or acting as an AP and creating the bss
90 */
91 IEEE80211_LINKED,
92 -
93 +
94 /* same as LINKED, but the driver shall apply RX filter
95 * rules as we are in NO_LINK mode. As the card is still
96 * logically linked, but it is doing a syncro site survey
97 * then it will be back to LINKED state.
98 */
99 IEEE80211_LINKED_SCANNING,
100 -
101 +
102 };
103  
104 #define DEFAULT_MAX_SCAN_AGE (15 * HZ)
105 @@ -840,14 +856,14 @@
106  
107  
108 #if (LINUX_VERSION_CODE <= KERNEL_VERSION(2,6,11))
109 -extern inline int is_multicast_ether_addr(const u8 *addr)
110 +extern inline int is_multicast_ether_addr_rtl7(const u8 *addr)
111 {
112 return ((addr[0] != 0xff) && (0x01 & addr[0]));
113 }
114 #endif
115  
116 #if (LINUX_VERSION_CODE <= KERNEL_VERSION(2,6,13))
117 -extern inline int is_broadcast_ether_addr(const u8 *addr)
118 +extern inline int is_broadcast_ether_addr_rtl7(const u8 *addr)
119 {
120 return ((addr[0] == 0xff) && (addr[1] == 0xff) && (addr[2] == 0xff) && \
121 (addr[3] == 0xff) && (addr[4] == 0xff) && (addr[5] == 0xff));
122 @@ -870,7 +886,7 @@
123 struct net_device_stats stats;
124 struct ieee80211_stats ieee_stats;
125 struct ieee80211_softmac_stats softmac_stats;
126 -
127 +
128 /* Probe / Beacon management */
129 struct list_head network_free_list;
130 struct list_head network_list;
131 @@ -881,7 +897,7 @@
132 int iw_mode; /* operating mode (IW_MODE_*) */
133  
134 spinlock_t lock;
135 -
136 +
137 int tx_headroom; /* Set to size of any additional room needed at front
138 * of allocated Tx SKBs */
139 u32 config;
140 @@ -924,11 +940,11 @@
141 * ad-hoc is a mixture ;-).
142 * Note that in infrastructure mode, even when not associated,
143 * fields bssid and essid may be valid (if wpa_set and essid_set
144 - * are true) as thy carry the value set by the user via iwconfig
145 + * are true) as thy carry the value set by the user via iwconfig
146 */
147 struct ieee80211_network current_network;
148  
149 -
150 +
151 enum ieee80211_state state;
152  
153 int short_slot;
154 @@ -936,33 +952,33 @@
155 int modulation; /* CCK, OFDM */
156 int freq_band; /* 2.4Ghz, 5.2Ghz, Mixed */
157 int abg_true; /* ABG flag */
158 -
159 - /* used for forcing the ibss workqueue to terminate
160 +
161 + /* used for forcing the ibss workqueue to terminate
162 * without wait for the syncro scan to terminate
163 */
164 - short sync_scan_hurryup;
165 -
166 + short sync_scan_hurryup;
167 +
168 /* map of allowed channels. 0 is dummy */
169 // FIXME: remeber to default to a basic channel plan depending of the PHY type
170 int channel_map[MAX_CHANNEL_NUMBER+1];
171 -
172 +
173 int rate; /* current rate */
174 int basic_rate;
175 //FIXME: pleace callback, see if redundant with softmac_features
176 short active_scan;
177 -
178 +
179 /* this contains flags for selectively enable softmac support */
180 u16 softmac_features;
181 -
182 +
183 /* if the sequence control field is not filled by HW */
184 u16 seq_ctrl;
185 -
186 +
187 /* association procedure transaction sequence number */
188 u16 associate_seq;
189 -
190 +
191 /* AID for RTXed association responses */
192 u16 assoc_id;
193 -
194 +
195 /* power save mode related*/
196 short ps;
197 short sta_sleep;
198 @@ -970,147 +986,153 @@
199 struct tasklet_struct ps_task;
200 u32 ps_th;
201 u32 ps_tl;
202 -
203 +
204 short raw_tx;
205 /* used if IEEE_SOFTMAC_TX_QUEUE is set */
206 short queue_stop;
207 short scanning;
208 short proto_started;
209 -
210 +
211 struct semaphore wx_sem;
212 struct semaphore scan_sem;
213 -
214 - spinlock_t mgmt_tx_lock;
215 +
216 + spinlock_t mgmt_tx_lock;
217 spinlock_t beacon_lock;
218  
219 short beacon_txing;
220  
221 short wap_set;
222 short ssid_set;
223 -
224 +
225 /* for discarding duplicated packets in IBSS */
226 struct list_head ibss_mac_hash[IEEE_IBSS_MAC_HASH_SIZE];
227 -
228 +
229 /* for discarding duplicated packets in BSS */
230 u16 last_seq_num;
231 u16 last_frag_num;
232 unsigned long last_packet_time;
233 -
234 +
235 /* for PS mode */
236 unsigned long last_rx_ps_time;
237 -
238 +
239 /* used if IEEE_SOFTMAC_SINGLE_QUEUE is set */
240 struct sk_buff *mgmt_queue_ring[MGMT_QUEUE_NUM];
241 int mgmt_queue_head;
242 int mgmt_queue_tail;
243 -
244 -
245 +
246 +
247 /* used if IEEE_SOFTMAC_TX_QUEUE is set */
248 struct tx_pending_t tx_pending;
249 -
250 +
251 /* used if IEEE_SOFTMAC_ASSOCIATE is set */
252 struct timer_list associate_timer;
253  
254 /* used if IEEE_SOFTMAC_BEACONS is set */
255 struct timer_list beacon_timer;
256 -
257 +
258 struct work_struct associate_complete_wq;
259 +
260 +# if (LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,20))
261 + struct delayed_work associate_retry_wq;
262 + struct delayed_work softmac_scan_wq;
263 +#else
264 struct work_struct associate_retry_wq;
265 + struct work_struct softmac_scan_wq;
266 +#endif
267 struct work_struct start_ibss_wq;
268 struct work_struct associate_procedure_wq;
269 - struct work_struct softmac_scan_wq;
270 struct work_struct wx_sync_scan_wq;
271 -
272 +
273 struct workqueue_struct *wq;
274 /* Callback functions */
275 void (*set_security)(struct net_device *dev,
276 struct ieee80211_security *sec);
277 -
278 +
279 /* Used to TX data frame by using txb structs.
280 * this is not used if in the softmac_features
281 * is set the flag IEEE_SOFTMAC_TX_QUEUE
282 */
283 int (*hard_start_xmit)(struct ieee80211_txb *txb,
284 struct net_device *dev);
285 -
286 +
287 int (*reset_port)(struct net_device *dev);
288  
289 - /* Softmac-generated frames (mamagement) are TXed via this
290 - * callback if the flag IEEE_SOFTMAC_SINGLE_QUEUE is
291 - * not set. As some cards may have different HW queues that
292 + /* Softmac-generated frames (mamagement) are TXed via this
293 + * callback if the flag IEEE_SOFTMAC_SINGLE_QUEUE is
294 + * not set. As some cards may have different HW queues that
295 * one might want to use for data and management frames
296 * the option to have two callbacks might be useful.
297 * This fucntion can't sleep.
298 */
299 int (*softmac_hard_start_xmit)(struct sk_buff *skb,
300 struct net_device *dev);
301 -
302 +
303 /* used instead of hard_start_xmit (not softmac_hard_start_xmit)
304 * if the IEEE_SOFTMAC_TX_QUEUE feature is used to TX data
305 * frames. I the option IEEE_SOFTMAC_SINGLE_QUEUE is also set
306 * then also management frames are sent via this callback.
307 * This function can't sleep.
308 - */
309 + */
310 void (*softmac_data_hard_start_xmit)(struct sk_buff *skb,
311 struct net_device *dev,int rate);
312  
313 /* stops the HW queue for DATA frames. Useful to avoid
314 * waste time to TX data frame when we are reassociating
315 * This function can sleep.
316 - */
317 + */
318 void (*data_hard_stop)(struct net_device *dev);
319 -
320 +
321 /* OK this is complementar to data_poll_hard_stop */
322 void (*data_hard_resume)(struct net_device *dev);
323 -
324 +
325 /* ask to the driver to retune the radio .
326 * This function can sleep. the driver should ensure
327 * the radio has been swithced before return.
328 */
329 void (*set_chan)(struct net_device *dev,short ch);
330 -
331 +
332 /* These are not used if the ieee stack takes care of
333 - * scanning (IEEE_SOFTMAC_SCAN feature set).
334 + * scanning (IEEE_SOFTMAC_SCAN feature set).
335 * In this case only the set_chan is used.
336 *
337 * The syncro version is similar to the start_scan but
338 * does not return until all channels has been scanned.
339 - * this is called in user context and should sleep,
340 + * this is called in user context and should sleep,
341 * it is called in a work_queue when swithcing to ad-hoc mode
342 - * or in behalf of iwlist scan when the card is associated
343 - * and root user ask for a scan.
344 + * or in behalf of iwlist scan when the card is associated
345 + * and root user ask for a scan.
346 * the fucntion stop_scan should stop both the syncro and
347 * background scanning and can sleep.
348 - * The fucntion start_scan should initiate the background
349 + * The fucntion start_scan should initiate the background
350 * scanning and can't sleep.
351 - */
352 + */
353 void (*scan_syncro)(struct net_device *dev);
354 void (*start_scan)(struct net_device *dev);
355 void (*stop_scan)(struct net_device *dev);
356 -
357 +
358 /* indicate the driver that the link state is changed
359 * for example it may indicate the card is associated now.
360 - * Driver might be interested in this to apply RX filter
361 - * rules or simply light the LINK led
362 + * Driver might be interested in this to apply RX filter
363 + * rules or simply light the LINK led
364 */
365 void (*link_change)(struct net_device *dev);
366 -
367 +
368 /* these two function indicates to the HW when to start
369 - * and stop to send beacons. This is used when the
370 + * and stop to send beacons. This is used when the
371 * IEEE_SOFTMAC_BEACONS is not set. For now the
372 * stop_send_bacons is NOT guaranteed to be called only
373 * after start_send_beacons.
374 */
375 void (*start_send_beacons) (struct net_device *dev);
376 void (*stop_send_beacons) (struct net_device *dev);
377 -
378 +
379 /* power save mode related */
380 void (*sta_wake_up) (struct net_device *dev);
381 void (*ps_request_tx_ack) (struct net_device *dev);
382 void (*enter_sleep_state) (struct net_device *dev, u32 th, u32 tl);
383 short (*ps_is_queue_empty) (struct net_device *dev);
384 -
385 -
386 +
387 +
388 /* This must be the last item so that it points to the data
389 * allocated beyond this structure by alloc_ieee80211 */
390 u8 priv[0];
391 @@ -1148,18 +1170,18 @@
392 #define IEEE_SOFTMAC_SINGLE_QUEUE (1<<8)
393  
394 /* Generate beacons. The stack will enqueue beacons
395 - * to the card
396 - */
397 + * to the card
398 + */
399 #define IEEE_SOFTMAC_BEACONS (1<<6)
400  
401  
402  
403 -extern inline void *ieee80211_priv(struct net_device *dev)
404 +extern inline void *ieee80211_priv_rtl7(struct net_device *dev)
405 {
406 return ((struct ieee80211_device *)netdev_priv(dev))->priv;
407 }
408  
409 -extern inline int ieee80211_is_empty_essid(const char *essid, int essid_len)
410 +extern inline int ieee80211_is_empty_essid_rtl7(const char *essid, int essid_len)
411 {
412 /* Single white space is for Linksys APs */
413 if (essid_len == 1 && essid[0] == ' ')
414 @@ -1175,7 +1197,7 @@
415 return 1;
416 }
417  
418 -extern inline int ieee80211_is_valid_mode(struct ieee80211_device *ieee, int mode)
419 +extern inline int ieee80211_is_valid_mode_rtl7(struct ieee80211_device *ieee, int mode)
420 {
421 /*
422 * It is possible for both access points and our device to support
423 @@ -1201,7 +1223,7 @@
424 return 0;
425 }
426  
427 -extern inline int ieee80211_get_hdrlen(u16 fc)
428 +extern inline int ieee80211_get_hdrlen_rtl7(u16 fc)
429 {
430 int hdrlen = 24;
431  
432 @@ -1229,140 +1251,144 @@
433  
434  
435 /* ieee80211.c */
436 -extern void free_ieee80211(struct net_device *dev);
437 -extern struct net_device *alloc_ieee80211(int sizeof_priv);
438 +extern void free_ieee80211_rtl7(struct net_device *dev);
439 +extern struct net_device *alloc_ieee80211_rtl7(int sizeof_priv);
440  
441 -extern int ieee80211_set_encryption(struct ieee80211_device *ieee);
442 +extern int ieee80211_set_encryption_rtl7(struct ieee80211_device *ieee);
443  
444 /* ieee80211_tx.c */
445  
446 -extern int ieee80211_encrypt_fragment(
447 +extern int ieee80211_encrypt_fragment_rtl7(
448 struct ieee80211_device *ieee,
449 struct sk_buff *frag,
450 int hdr_len);
451 -
452 -extern int ieee80211_xmit(struct sk_buff *skb,
453 +
454 +extern int ieee80211_xmit_rtl7(struct sk_buff *skb,
455 struct net_device *dev);
456 -extern void ieee80211_txb_free(struct ieee80211_txb *);
457 +extern void ieee80211_txb_free_rtl7(struct ieee80211_txb *);
458  
459  
460 /* ieee80211_rx.c */
461 -extern int ieee80211_rx(struct ieee80211_device *ieee, struct sk_buff *skb,
462 +extern int ieee80211_rx_rtl7(struct ieee80211_device *ieee, struct sk_buff *skb,
463 struct ieee80211_rx_stats *rx_stats);
464 -extern void ieee80211_rx_mgt(struct ieee80211_device *ieee,
465 +extern void ieee80211_rx_mgt_rtl7(struct ieee80211_device *ieee,
466 struct ieee80211_hdr *header,
467 struct ieee80211_rx_stats *stats);
468  
469 /* ieee80211_wx.c */
470 -extern int ieee80211_wx_get_scan(struct ieee80211_device *ieee,
471 +extern int ieee80211_wx_get_scan_rtl7(struct ieee80211_device *ieee,
472 struct iw_request_info *info,
473 union iwreq_data *wrqu, char *key);
474 -extern int ieee80211_wx_set_encode(struct ieee80211_device *ieee,
475 +extern int ieee80211_wx_set_encode_rtl7(struct ieee80211_device *ieee,
476 struct iw_request_info *info,
477 union iwreq_data *wrqu, char *key);
478 -extern int ieee80211_wx_get_encode(struct ieee80211_device *ieee,
479 +extern int ieee80211_wx_get_encode_rtl7(struct ieee80211_device *ieee,
480 struct iw_request_info *info,
481 union iwreq_data *wrqu, char *key);
482 /* ieee80211_softmac.c */
483 -extern short ieee80211_is_54g(struct ieee80211_network net);
484 -extern short ieee80211_is_shortslot(struct ieee80211_network net);
485 -extern int ieee80211_rx_frame_softmac(struct ieee80211_device *ieee, struct sk_buff *skb,
486 +extern short ieee80211_is_54g_rtl7(struct ieee80211_network net);
487 +extern short ieee80211_is_shortslot_rtl7(struct ieee80211_network net);
488 +extern int ieee80211_rx_frame_softmac_rtl7(struct ieee80211_device *ieee, struct sk_buff *skb,
489 struct ieee80211_rx_stats *rx_stats, u16 type,
490 u16 stype);
491 -extern void ieee80211_softmac_new_net(struct ieee80211_device *ieee, struct ieee80211_network *net);
492 +extern void ieee80211_softmac_new_net_rtl7(struct ieee80211_device *ieee, struct ieee80211_network *net);
493  
494 -extern void ieee80211_softmac_xmit(struct ieee80211_txb *txb, struct ieee80211_device *ieee);
495 -extern void ieee80211_softmac_check_all_nets(struct ieee80211_device *ieee);
496 -extern void ieee80211_start_bss(struct ieee80211_device *ieee);
497 -extern void ieee80211_start_master_bss(struct ieee80211_device *ieee);
498 -extern void ieee80211_start_ibss(struct ieee80211_device *ieee);
499 -extern void ieee80211_softmac_init(struct ieee80211_device *ieee);
500 -extern void ieee80211_softmac_free(struct ieee80211_device *ieee);
501 -extern void ieee80211_associate_abort(struct ieee80211_device *ieee);
502 -extern void ieee80211_disassociate(struct ieee80211_device *ieee);
503 -extern void ieee80211_stop_scan(struct ieee80211_device *ieee);
504 -extern void ieee80211_start_scan_syncro(struct ieee80211_device *ieee);
505 -extern void ieee80211_check_all_nets(struct ieee80211_device *ieee);
506 -extern void ieee80211_start_protocol(struct ieee80211_device *ieee);
507 -extern void ieee80211_stop_protocol(struct ieee80211_device *ieee);
508 -extern void ieee80211_softmac_start_protocol(struct ieee80211_device *ieee);
509 -extern void ieee80211_softmac_stop_protocol(struct ieee80211_device *ieee);
510 -extern void ieee80211_reset_queue(struct ieee80211_device *ieee);
511 -extern void ieee80211_wake_queue(struct ieee80211_device *ieee);
512 -extern void ieee80211_stop_queue(struct ieee80211_device *ieee);
513 -extern struct sk_buff *ieee80211_get_beacon(struct ieee80211_device *ieee);
514 -extern void ieee80211_start_send_beacons(struct ieee80211_device *ieee);
515 -extern void ieee80211_stop_send_beacons(struct ieee80211_device *ieee);
516 -extern int ieee80211_wpa_supplicant_ioctl(struct ieee80211_device *ieee, struct iw_point *p);
517 -extern void notify_wx_assoc_event(struct ieee80211_device *ieee);
518 -extern void ieee80211_ps_tx_ack(struct ieee80211_device *ieee, short success);
519 +extern void ieee80211_softmac_xmit_rtl7(struct ieee80211_txb *txb, struct ieee80211_device *ieee);
520 +extern void ieee80211_softmac_check_all_nets_rtl7(struct ieee80211_device *ieee);
521 +extern void ieee80211_start_bss_rtl7(struct ieee80211_device *ieee);
522 +extern void ieee80211_start_master_bss_rtl7(struct ieee80211_device *ieee);
523 +extern void ieee80211_start_ibss_rtl7(struct ieee80211_device *ieee);
524 +extern void ieee80211_softmac_init_rtl7(struct ieee80211_device *ieee);
525 +extern void ieee80211_softmac_free_rtl7(struct ieee80211_device *ieee);
526 +extern void ieee80211_associate_abort_rtl7(struct ieee80211_device *ieee);
527 +extern void ieee80211_disassociate_rtl7(struct ieee80211_device *ieee);
528 +extern void ieee80211_stop_scan_rtl7(struct ieee80211_device *ieee);
529 +extern void ieee80211_start_scan_syncro_rtl7(struct ieee80211_device *ieee);
530 +extern void ieee80211_check_all_nets_rtl7(struct ieee80211_device *ieee);
531 +extern void ieee80211_start_protocol_rtl7(struct ieee80211_device *ieee);
532 +extern void ieee80211_stop_protocol_rtl7(struct ieee80211_device *ieee);
533 +extern void ieee80211_softmac_start_protocol_rtl7(struct ieee80211_device *ieee);
534 +extern void ieee80211_softmac_stop_protocol_rtl7(struct ieee80211_device *ieee);
535 +extern void ieee80211_reset_queue_rtl7(struct ieee80211_device *ieee);
536 +extern void ieee80211_wake_queue_rtl7(struct ieee80211_device *ieee);
537 +extern void ieee80211_stop_queue_rtl7(struct ieee80211_device *ieee);
538 +extern struct sk_buff *ieee80211_get_beacon_rtl7(struct ieee80211_device *ieee);
539 +extern void ieee80211_start_send_beacons_rtl7(struct ieee80211_device *ieee);
540 +extern void ieee80211_stop_send_beacons_rtl7(struct ieee80211_device *ieee);
541 +extern int ieee80211_wpa_supplicant_ioctl_rtl7(struct ieee80211_device *ieee, struct iw_point *p);
542 +extern void notify_wx_assoc_event_rtl7(struct ieee80211_device *ieee);
543 +extern void ieee80211_ps_tx_ack_rtl7(struct ieee80211_device *ieee, short success);
544  
545 /* ieee80211_softmac_wx.c */
546  
547 -extern int ieee80211_wx_get_wap(struct ieee80211_device *ieee,
548 - struct iw_request_info *info,
549 +extern int ieee80211_wx_get_wap_rtl7(struct ieee80211_device *ieee,
550 + struct iw_request_info *info,
551 union iwreq_data *wrqu, char *ext);
552 -
553 -extern int ieee80211_wx_set_wap(struct ieee80211_device *ieee,
554 +
555 +extern int ieee80211_wx_set_wap_rtl7(struct ieee80211_device *ieee,
556 struct iw_request_info *info,
557 union iwreq_data *awrq,
558 char *extra);
559 -
560 -extern int ieee80211_wx_get_essid(struct ieee80211_device *ieee, struct iw_request_info *a,union iwreq_data *wrqu,char *b);
561  
562 -extern int ieee80211_wx_set_rate(struct ieee80211_device *ieee,
563 +extern int ieee80211_wx_get_essid_rtl7(struct ieee80211_device *ieee, struct iw_request_info *a,union iwreq_data *wrqu,char *b);
564 +
565 +extern int ieee80211_wx_set_rate_rtl7(struct ieee80211_device *ieee,
566 struct iw_request_info *info,
567 union iwreq_data *wrqu, char *extra);
568 -
569 -extern int ieee80211_wx_get_rate(struct ieee80211_device *ieee,
570 - struct iw_request_info *info,
571 +
572 +extern int ieee80211_wx_get_rate_rtl7(struct ieee80211_device *ieee,
573 + struct iw_request_info *info,
574 union iwreq_data *wrqu, char *extra);
575 -
576 -extern int ieee80211_wx_set_mode(struct ieee80211_device *ieee, struct iw_request_info *a,
577 +
578 +extern int ieee80211_wx_set_mode_rtl7(struct ieee80211_device *ieee, struct iw_request_info *a,
579 union iwreq_data *wrqu, char *b);
580 -
581 -extern int ieee80211_wx_set_scan(struct ieee80211_device *ieee, struct iw_request_info *a,
582 +
583 +extern int ieee80211_wx_set_scan_rtl7(struct ieee80211_device *ieee, struct iw_request_info *a,
584 union iwreq_data *wrqu, char *b);
585 -
586 -extern int ieee80211_wx_set_essid(struct ieee80211_device *ieee,
587 +
588 +extern int ieee80211_wx_set_essid_rtl7(struct ieee80211_device *ieee,
589 struct iw_request_info *a,
590 union iwreq_data *wrqu, char *extra);
591 -
592 -extern int ieee80211_wx_get_mode(struct ieee80211_device *ieee, struct iw_request_info *a,
593 +
594 +extern int ieee80211_wx_get_mode_rtl7(struct ieee80211_device *ieee, struct iw_request_info *a,
595 union iwreq_data *wrqu, char *b);
596  
597 -extern int ieee80211_wx_set_freq(struct ieee80211_device *ieee, struct iw_request_info *a,
598 +extern int ieee80211_wx_set_freq_rtl7(struct ieee80211_device *ieee, struct iw_request_info *a,
599 union iwreq_data *wrqu, char *b);
600  
601 -extern int ieee80211_wx_get_freq(struct ieee80211_device *ieee, struct iw_request_info *a,
602 +extern int ieee80211_wx_get_freq_rtl7(struct ieee80211_device *ieee, struct iw_request_info *a,
603 union iwreq_data *wrqu, char *b);
604  
605 -extern void ieee80211_wx_sync_scan_wq(struct ieee80211_device *ieee);
606 +# if (LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,20))
607 +extern void ieee80211_wx_sync_scan_wq_rtl7(struct work_struct *work);
608 +#else
609 +extern void ieee80211_wx_sync_scan_wq_rtl7(struct ieee80211_device *ieee);
610 +#endif
611  
612 -extern int ieee80211_wx_set_rawtx(struct ieee80211_device *ieee,
613 - struct iw_request_info *info,
614 +extern int ieee80211_wx_set_rawtx_rtl7(struct ieee80211_device *ieee,
615 + struct iw_request_info *info,
616 union iwreq_data *wrqu, char *extra);
617 -
618 -extern int ieee80211_wx_get_name(struct ieee80211_device *ieee,
619 - struct iw_request_info *info,
620 +
621 +extern int ieee80211_wx_get_name_rtl7(struct ieee80211_device *ieee,
622 + struct iw_request_info *info,
623 union iwreq_data *wrqu, char *extra);
624  
625 -extern int ieee80211_wx_set_power(struct ieee80211_device *ieee,
626 +extern int ieee80211_wx_set_power_rtl7(struct ieee80211_device *ieee,
627 struct iw_request_info *info,
628 union iwreq_data *wrqu, char *extra);
629  
630 -extern int ieee80211_wx_get_power(struct ieee80211_device *ieee,
631 +extern int ieee80211_wx_get_power_rtl7(struct ieee80211_device *ieee,
632 struct iw_request_info *info,
633 union iwreq_data *wrqu, char *extra);
634 -
635 -extern const long ieee80211_wlan_frequencies[];
636  
637 -extern inline void ieee80211_increment_scans(struct ieee80211_device *ieee)
638 +extern const long ieee80211_wlan_frequencies_rtl7[];
639 +
640 +extern inline void ieee80211_increment_scans_rtl7(struct ieee80211_device *ieee)
641 {
642 ieee->scans++;
643 }
644  
645 -extern inline int ieee80211_get_scans(struct ieee80211_device *ieee)
646 +extern inline int ieee80211_get_scans_rtl7(struct ieee80211_device *ieee)
647 {
648 return ieee->scans;
649 }
650 @@ -1372,7 +1398,7 @@
651 const char *s = essid;
652 char *d = escaped;
653  
654 - if (ieee80211_is_empty_essid(essid, essid_len)) {
655 + if (ieee80211_is_empty_essid_rtl7(essid, essid_len)) {
656 memcpy(escaped, "<hidden>", sizeof("<hidden>"));
657 return escaped;
658 }
659 @@ -1390,4 +1416,5 @@
660 *d = '\0';
661 return escaped;
662 }
663 +
664 #endif /* IEEE80211_H */
665 diff -Naur rtl8187_orig/beta-8187/Makefile rtl8187_rawtx/beta-8187/Makefile
666 --- rtl8187_orig/beta-8187/Makefile 2007-03-13 23:45:09.000000000 +0100
667 +++ rtl8187_rawtx/beta-8187/Makefile 2007-05-27 10:47:14.000000000 +0200
668 @@ -18,6 +18,8 @@
669 KVER := $(shell uname -r)
670 KSRC := /lib/modules/$(KVER)/build
671 INSTALL_PREFIX :=
672 +PWD = $(shell pwd)
673 +
674 all: modules
675  
676 clean:
677 diff -Naur rtl8187_orig/beta-8187/r8180_93cx6.c rtl8187_rawtx/beta-8187/r8180_93cx6.c
678 --- rtl8187_orig/beta-8187/r8180_93cx6.c 2007-03-13 23:45:09.000000000 +0100
679 +++ rtl8187_rawtx/beta-8187/r8180_93cx6.c 2007-07-13 01:46:24.000000000 +0200
680 @@ -87,7 +87,7 @@
681  
682 u32 eprom_read(struct net_device *dev, u32 addr)
683 {
684 - struct r8180_priv *priv = ieee80211_priv(dev);
685 + struct r8180_priv *priv = ieee80211_priv_rtl7(dev);
686 short read_cmd[]={1,1,0};
687 short addr_str[8];
688 int i;
689 diff -Naur rtl8187_orig/beta-8187/r8180_hw.h rtl8187_rawtx/beta-8187/r8180_hw.h
690 --- rtl8187_orig/beta-8187/r8180_hw.h 2007-03-13 23:45:09.000000000 +0100
691 +++ rtl8187_rawtx/beta-8187/r8180_hw.h 2007-07-13 01:46:27.000000000 +0200
692 @@ -646,6 +646,7 @@
693 #define FFER_INTR ((1<<15))
694 #define FFER_GWAKE ((1<< 4))
695  
696 -
697 +#define MAX_TX_POWER 27
698 +#define MIN_TX_POWER 20
699  
700 #endif
701 diff -Naur rtl8187_orig/beta-8187/r8180_rtl8225.c rtl8187_rawtx/beta-8187/r8180_rtl8225.c
702 --- rtl8187_orig/beta-8187/r8180_rtl8225.c 2007-03-13 23:45:09.000000000 +0100
703 +++ rtl8187_rawtx/beta-8187/r8180_rtl8225.c 2007-07-13 01:46:24.000000000 +0200
704 @@ -173,7 +173,7 @@
705  
706 void rtl8225_set_gain(struct net_device *dev, short gain)
707 {
708 - struct r8180_priv *priv = ieee80211_priv(dev);
709 + struct r8180_priv *priv = ieee80211_priv_rtl7(dev);
710  
711 rtl8180_set_anaparam(dev, RTL8225_ANAPARAM_ON);
712  
713 @@ -208,7 +208,7 @@
714 {
715 #ifdef USE_8051_3WIRE
716  
717 - struct r8180_priv *priv = (struct r8180_priv *)ieee80211_priv(dev);
718 + struct r8180_priv *priv = (struct r8180_priv *)ieee80211_priv_rtl7(dev);
719 struct usb_device *udev = priv->udev;
720 //u8 bit;
721 u16 wReg80, wReg82, wReg84;
722 @@ -255,7 +255,7 @@
723 u16 out,select;
724 u8 bit;
725 u32 bangdata = (data << 4) | (adr & 0xf);
726 - struct r8180_priv *priv = ieee80211_priv(dev);
727 + struct r8180_priv *priv = ieee80211_priv_rtl7(dev);
728  
729 out = read_nic_word(dev, RFPinsOutput) & 0xfff3;
730  
731 @@ -349,7 +349,7 @@
732  
733 void rtl8225_SetTXPowerLevel(struct net_device *dev, short ch)
734 {
735 - struct r8180_priv *priv = ieee80211_priv(dev);
736 + struct r8180_priv *priv = ieee80211_priv_rtl7(dev);
737  
738 int GainIdx;
739 int GainSetting;
740 @@ -454,9 +454,9 @@
741  
742 void rtl8225_rf_set_chan(struct net_device *dev, short ch)
743 {
744 - struct r8180_priv *priv = ieee80211_priv(dev);
745 + struct r8180_priv *priv = ieee80211_priv_rtl7(dev);
746 short gset = (priv->ieee80211->state == IEEE80211_LINKED &&
747 - ieee80211_is_54g(priv->ieee80211->current_network)) ||
748 + ieee80211_is_54g_rtl7(priv->ieee80211->current_network)) ||
749 priv->ieee80211->iw_mode == IW_MODE_MONITOR;
750  
751 rtl8225_SetTXPowerLevel(dev, ch);
752 @@ -474,7 +474,7 @@
753 write_nic_byte(dev,DIFS,0x24); //DIFS: 36
754  
755 if(priv->ieee80211->state == IEEE80211_LINKED &&
756 - ieee80211_is_shortslot(priv->ieee80211->current_network))
757 + ieee80211_is_shortslot_rtl7(priv->ieee80211->current_network))
758 write_nic_byte(dev,SLOT,0x9); //SLOT: 9
759  
760 else
761 @@ -546,7 +546,7 @@
762  
763 void rtl8225_rf_init(struct net_device *dev)
764 {
765 - struct r8180_priv *priv = ieee80211_priv(dev);
766 + struct r8180_priv *priv = ieee80211_priv_rtl7(dev);
767 int i;
768 short channel = 1;
769 u16 brsr;
770 diff -Naur rtl8187_orig/beta-8187/r8180_rtl8225.h rtl8187_rawtx/beta-8187/r8180_rtl8225.h
771 --- rtl8187_orig/beta-8187/r8180_rtl8225.h 2007-03-13 23:45:09.000000000 +0100
772 +++ rtl8187_rawtx/beta-8187/r8180_rtl8225.h 2007-07-13 01:46:27.000000000 +0200
773 @@ -44,3 +44,5 @@
774 extern u32 rtl8225_chan[];
775  
776 #endif
777 +
778 +void rtl8225z2_SetTXPowerLevel(struct net_device *dev, short ch);
779 diff -Naur rtl8187_orig/beta-8187/r8180_rtl8225z2.c rtl8187_rawtx/beta-8187/r8180_rtl8225z2.c
780 --- rtl8187_orig/beta-8187/r8180_rtl8225z2.c 2007-03-13 23:45:09.000000000 +0100
781 +++ rtl8187_rawtx/beta-8187/r8180_rtl8225z2.c 2007-07-13 01:46:24.000000000 +0200
782 @@ -2,12 +2,12 @@
783 This is part of the rtl8180-sa2400 driver
784 released under the GPL (See file COPYING for details).
785 Copyright (c) 2005 Andrea Merello <andreamrl@tiscali.it>
786 -
787 - This files contains programming code for the rtl8225
788 +
789 + This files contains programming code for the rtl8225
790 radio frontend.
791 -
792 +
793 *Many* thanks to Realtek Corp. for their great support!
794 -
795 +
796 */
797  
798  
799 @@ -32,51 +32,68 @@
800 };
801  
802 u8 rtl8225z2_gain_a[]={
803 - 0x13,0x27,0x5a,//,0x37,// -82dbm
804 - 0x23,0x23,0x58,//,0x37,// -82dbm
805 - 0x33,0x1f,0x56,//,0x37,// -82dbm
806 - 0x43,0x1b,0x54,//,0x37,// -78dbm
807 - 0x53,0x17,0x51,//,0x37,// -74dbm
808 - 0x63,0x24,0x4f,//,0x37,// -70dbm
809 - 0x73,0x0f,0x4c,//,0x37,// -66dbm
810 + 0x13,0x27,0x5a,//,0x37,// -82dbm
811 + 0x23,0x23,0x58,//,0x37,// -82dbm
812 + 0x33,0x1f,0x56,//,0x37,// -82dbm
813 + 0x43,0x1b,0x54,//,0x37,// -78dbm
814 + 0x53,0x17,0x51,//,0x37,// -74dbm
815 + 0x63,0x24,0x4f,//,0x37,// -70dbm
816 + 0x73,0x0f,0x4c,//,0x37,// -66dbm
817 };
818 #if 0
819 u32 rtl8225_chan[] = {
820 0, //dummy channel 0
821 - 0x085c, //1
822 - 0x08dc, //2
823 - 0x095c, //3
824 - 0x09dc, //4
825 - 0x0a5c, //5
826 - 0x0adc, //6
827 - 0x0b5c, //7
828 - 0x0bdc, //8
829 - 0x0c5c, //9
830 - 0x0cdc, //10
831 - 0x0d5c, //11
832 - 0x0ddc, //12
833 - 0x0e5c, //13
834 + 0x085c, //1
835 + 0x08dc, //2
836 + 0x095c, //3
837 + 0x09dc, //4
838 + 0x0a5c, //5
839 + 0x0adc, //6
840 + 0x0b5c, //7
841 + 0x0bdc, //8
842 + 0x0c5c, //9
843 + 0x0cdc, //10
844 + 0x0d5c, //11
845 + 0x0ddc, //12
846 + 0x0e5c, //13
847 //0x0f5c, //14
848 - 0x0f72, // 14
849 + 0x0f72, // 14
850 };
851 #endif
852  
853 +#if 1
854 //-
855 -u16 rtl8225z2_rxgain[]={
856 +u16 rtl8225z2_rxgain[]={
857 0x0400, 0x0401, 0x0402, 0x0403, 0x0404, 0x0405, 0x0408, 0x0409,
858 - 0x040a, 0x040b, 0x0502, 0x0503, 0x0504, 0x0505, 0x0540, 0x0541,
859 + 0x040a, 0x040b, 0x0502, 0x0503, 0x0504, 0x0505, 0x0540, 0x0541,
860 0x0542, 0x0543, 0x0544, 0x0545, 0x0580, 0x0581, 0x0582, 0x0583,
861 - 0x0584, 0x0585, 0x0588, 0x0589, 0x058a, 0x058b, 0x0643, 0x0644,
862 + 0x0584, 0x0585, 0x0588, 0x0589, 0x058a, 0x058b, 0x0643, 0x0644,
863 0x0645, 0x0680, 0x0681, 0x0682, 0x0683, 0x0684, 0x0685, 0x0688,
864 0x0689, 0x068a, 0x068b, 0x068c, 0x0742, 0x0743, 0x0744, 0x0745,
865 0x0780, 0x0781, 0x0782, 0x0783, 0x0784, 0x0785, 0x0788, 0x0789,
866 0x078a, 0x078b, 0x078c, 0x078d, 0x0790, 0x0791, 0x0792, 0x0793,
867 - 0x0794, 0x0795, 0x0798, 0x0799, 0x079a, 0x079b, 0x079c, 0x079d,
868 - 0x07a0, 0x07a1, 0x07a2, 0x07a3, 0x07a4, 0x07a5, 0x07a8, 0x07a9,
869 - 0x03aa, 0x03ab, 0x03ac, 0x03ad, 0x03b0, 0x03b1, 0x03b2, 0x03b3,
870 + 0x0794, 0x0795, 0x0798, 0x0799, 0x079a, 0x079b, 0x079c, 0x079d,
871 + 0x07a0, 0x07a1, 0x07a2, 0x07a3, 0x07a4, 0x07a5, 0x07a8, 0x07a9,
872 + 0x03aa, 0x03ab, 0x03ac, 0x03ad, 0x03b0, 0x03b1, 0x03b2, 0x03b3,
873 0x03b4, 0x03b5, 0x03b8, 0x03b9, 0x03ba, 0x03bb, 0x03bb
874  
875 };
876 +#else
877 +u16 rtl8225z2_rxgain[]={
878 + 0x0000, 0x0001, 0x0002, 0x0003, 0x0004, 0x0005, 0x0008, 0x0009,
879 + 0x000a, 0x000b, 0x0102, 0x0103, 0x0104, 0x0105, 0x0140, 0x0141,
880 + 0x0142, 0x0143, 0x0144, 0x0145, 0x0180, 0x0181, 0x0182, 0x0183,
881 + 0x0184, 0x0185, 0x0188, 0x0189, 0x018a, 0x018b, 0x0243, 0x0244,
882 + 0x0245, 0x0280, 0x0281, 0x0282, 0x0283, 0x0284, 0x0285, 0x0288,
883 + 0x0289, 0x028a, 0x028b, 0x028c, 0x0342, 0x0343, 0x0344, 0x0345,
884 + 0x0380, 0x0381, 0x0382, 0x0383, 0x0384, 0x0385, 0x0388, 0x0389,
885 + 0x038a, 0x038b, 0x038c, 0x038d, 0x0390, 0x0391, 0x0392, 0x0393,
886 + 0x0394, 0x0395, 0x0398, 0x0399, 0x039a, 0x039b, 0x039c, 0x039d,
887 + 0x03a0, 0x03a1, 0x03a2, 0x03a3, 0x03a4, 0x03a5, 0x03a8, 0x03a9,
888 + 0x03aa, 0x03ab, 0x03ac, 0x03ad, 0x03b0, 0x03b1, 0x03b2, 0x03b3,
889 + 0x03b4, 0x03b5, 0x03b8, 0x03b9, 0x03ba, 0x03bb, 0x03bb
890 +};
891 +#endif
892  
893 //2005.11.16,
894 u8 ZEBRA2_CCK_OFDM_GAIN_SETTING[]={
895 @@ -129,23 +146,30 @@
896 void rtl8225z2_set_gain(struct net_device *dev, short gain)
897 {
898 u8* rtl8225_gain;
899 - struct r8180_priv *priv = ieee80211_priv(dev);
900 -
901 + struct r8180_priv *priv = ieee80211_priv_rtl7(dev);
902 +
903 u8 mode = priv->ieee80211->mode;
904 -
905 - if(mode == IEEE_B || mode == IEEE_G)
906 +
907 + if((mode&IEEE_B) == IEEE_B || (mode&IEEE_G) == IEEE_G) {
908 + //printk(KERN_WARNING "mode ag!\n");
909 rtl8225_gain = rtl8225z2_gain_bg;
910 - else
911 + } else {
912 rtl8225_gain = rtl8225z2_gain_a;
913 -
914 + //printk(KERN_WARNING "mode a!\n");
915 + }
916 +
917 //write_phy_ofdm(dev, 0x0d, rtl8225_gain[gain * 3]);
918 //write_phy_ofdm(dev, 0x19, rtl8225_gain[gain * 3 + 1]);
919 //write_phy_ofdm(dev, 0x1b, rtl8225_gain[gain * 3 + 2]);
920 //2005.11.17, by ch-hsu
921 write_phy_ofdm(dev, 0x0b, rtl8225_gain[gain * 3]);
922 + mdelay(1);
923 write_phy_ofdm(dev, 0x1b, rtl8225_gain[gain * 3 + 1]);
924 + mdelay(1);
925 write_phy_ofdm(dev, 0x1d, rtl8225_gain[gain * 3 + 2]);
926 - write_phy_ofdm(dev, 0x21, 0x37);
927 + mdelay(1);
928 + write_phy_ofdm(dev, 0x21, 0x17);
929 + mdelay(1);
930  
931 }
932  
933 @@ -153,33 +177,33 @@
934  
935 void rtl8225_set_gain(struct net_device *dev, short gain)
936 {
937 - struct r8180_priv *priv = ieee80211_priv(dev);
938 -
939 + struct r8180_priv *priv = ieee80211_priv_rtl7(dev);
940 +
941 rtl8180_set_anaparam(dev, RTL8225_ANAPARAM_ON);
942 -
943 +
944 if(priv->card_8185 == 2)
945 write_phy_ofdm(dev, 0x21, 0x27);
946 else
947 write_phy_ofdm(dev, 0x21, 0x37);
948 -
949 +
950 write_phy_ofdm(dev, 0x25, 0x20);
951 write_phy_ofdm(dev, 0x11, 0x6);
952 -
953 +
954 if(priv->card_8185 == 1 && priv->card_8185_Bversion)
955 write_phy_ofdm(dev, 0x27, 0x8);
956 else
957 write_phy_ofdm(dev, 0x27, 0x88);
958 -
959 +
960 write_phy_ofdm(dev, 0x14, 0);
961 write_phy_ofdm(dev, 0x16, 0);
962 write_phy_ofdm(dev, 0x15, 0x40);
963 write_phy_ofdm(dev, 0x17, 0x40);
964 -
965 +
966 write_phy_ofdm(dev, 0x0d, rtl8225_gain[gain * 4]);
967 write_phy_ofdm(dev, 0x23, rtl8225_gain[gain * 4 + 1]);
968 write_phy_ofdm(dev, 0x1b, rtl8225_gain[gain * 4 + 2]);
969 write_phy_ofdm(dev, 0x1d, rtl8225_gain[gain * 4 + 3]);
970 - //rtl8225_set_gain_usb(dev, gain);
971 + //rtl8225_set_gain_usb(dev, gain);
972 }
973 #endif
974  
975 @@ -193,7 +217,7 @@
976 // ThreeWireReg tdata;
977 int i;
978 short bit, rw;
979 -
980 +
981 u8 wLength = 6;
982 u8 rLength = 12;
983 u8 low2high = 0;
984 @@ -207,20 +231,20 @@
985  
986 dataRead = 0;
987  
988 - oval &= ~0xf;
989 + oval &= ~0xf;
990  
991 write_nic_word(dev, RFPinsOutput, oval | BB_HOST_BANG_EN ); udelay(4);
992  
993 write_nic_word(dev, RFPinsOutput, oval ); udelay(5);
994 -
995 +
996 rw = 0;
997 -
998 +
999 mask = (low2high) ? 0x01 : (((u32)0x01)<<(32-1));
1000 for(i = 0; i < wLength/2; i++)
1001 {
1002 bit = ((data2Write&mask) != 0) ? 1 : 0;
1003 write_nic_word(dev, RFPinsOutput, bit|oval | rw); udelay(1);
1004 -
1005 +
1006 write_nic_word(dev, RFPinsOutput, bit|oval | BB_HOST_BANG_CLK | rw); udelay(2);
1007 write_nic_word(dev, RFPinsOutput, bit|oval | BB_HOST_BANG_CLK | rw); udelay(2);
1008  
1009 @@ -233,9 +257,9 @@
1010 write_nic_word(dev, RFPinsOutput, bit|oval | rw); udelay(2);
1011 break;
1012 }
1013 -
1014 +
1015 bit = ((data2Write&mask) != 0) ? 1: 0;
1016 -
1017 +
1018 write_nic_word(dev, RFPinsOutput, oval|bit|rw| BB_HOST_BANG_CLK); udelay(2);
1019 write_nic_word(dev, RFPinsOutput, oval|bit|rw| BB_HOST_BANG_CLK); udelay(2);
1020  
1021 @@ -252,22 +276,22 @@
1022 for(i = 0; i < rLength; i++)
1023 {
1024 write_nic_word(dev, RFPinsOutput, rw|oval); udelay(1);
1025 -
1026 +
1027 write_nic_word(dev, RFPinsOutput, rw|oval|BB_HOST_BANG_CLK); udelay(2);
1028 write_nic_word(dev, RFPinsOutput, rw|oval|BB_HOST_BANG_CLK); udelay(2);
1029 write_nic_word(dev, RFPinsOutput, rw|oval|BB_HOST_BANG_CLK); udelay(2);
1030 tmp = read_nic_word(dev, RFPinsInput);
1031 -
1032 +
1033 dataRead |= (tmp & BB_HOST_BANG_CLK ? mask : 0);
1034  
1035 write_nic_word(dev, RFPinsOutput, (rw|oval)); udelay(2);
1036  
1037 mask = (low2high) ? (mask<<1) : (mask>>1);
1038 }
1039 -
1040 +
1041 write_nic_word(dev, RFPinsOutput, BB_HOST_BANG_EN|BB_HOST_BANG_RW|oval); udelay(2);
1042  
1043 - write_nic_word(dev, RFPinsEnable, oval2);
1044 + write_nic_word(dev, RFPinsEnable, oval2);
1045 write_nic_word(dev, RFPinsSelect, oval3); // Set To SW Switch
1046 write_nic_word(dev, RFPinsOutput, 0x3a0);
1047  
1048 @@ -280,61 +304,61 @@
1049 u16 out,select;
1050 u8 bit;
1051 u32 bangdata = (data << 4) | (adr & 0xf);
1052 - struct r8180_priv *priv = ieee80211_priv(dev);
1053 -
1054 + struct r8180_priv *priv = ieee80211_priv_rtl7(dev);
1055 +
1056 out = read_nic_word(dev, RFPinsOutput) & 0xfff3;
1057 -
1058 +
1059 write_nic_word(dev,RFPinsEnable,
1060 (read_nic_word(dev,RFPinsEnable) | 0x7));
1061 -
1062 +
1063 select = read_nic_word(dev, RFPinsSelect);
1064 -
1065 - write_nic_word(dev, RFPinsSelect, select | 0x7 |
1066 +
1067 + write_nic_word(dev, RFPinsSelect, select | 0x7 |
1068 ((priv->card_type == USB) ? 0 : SW_CONTROL_GPIO));
1069 -
1070 +
1071 force_pci_posting(dev);
1072 udelay(10);
1073 -
1074 +
1075 write_nic_word(dev, RFPinsOutput, out | BB_HOST_BANG_EN );//| 0x1fff);
1076 -
1077 +
1078 force_pci_posting(dev);
1079 udelay(2);
1080 -
1081 +
1082 write_nic_word(dev, RFPinsOutput, out);
1083 -
1084 +
1085 force_pci_posting(dev);
1086 udelay(10);
1087 -
1088 -
1089 +
1090 +
1091 for(i=15; i>=0;i--){
1092 -
1093 +
1094 bit = (bangdata & (1<<i)) >> i;
1095 -
1096 +
1097 write_nic_word(dev, RFPinsOutput, bit | out);
1098 -
1099 +
1100 write_nic_word(dev, RFPinsOutput, bit | out | BB_HOST_BANG_CLK);
1101 write_nic_word(dev, RFPinsOutput, bit | out | BB_HOST_BANG_CLK);
1102  
1103 i--;
1104 bit = (bangdata & (1<<i)) >> i;
1105 -
1106 +
1107 write_nic_word(dev, RFPinsOutput, bit | out | BB_HOST_BANG_CLK);
1108 write_nic_word(dev, RFPinsOutput, bit | out | BB_HOST_BANG_CLK);
1109  
1110 write_nic_word(dev, RFPinsOutput, bit | out);
1111  
1112 }
1113 -
1114 +
1115 write_nic_word(dev, RFPinsOutput, out | BB_HOST_BANG_EN);
1116 -
1117 +
1118 force_pci_posting(dev);
1119 udelay(10);
1120  
1121 - write_nic_word(dev, RFPinsOutput, out |
1122 + write_nic_word(dev, RFPinsOutput, out |
1123 ((priv->card_type == USB) ? 4 : BB_HOST_BANG_EN));
1124  
1125 - write_nic_word(dev, RFPinsSelect, select |
1126 - ((priv->card_type == USB) ? 0 : SW_CONTROL_GPIO));
1127 + write_nic_word(dev, RFPinsSelect, select |
1128 + ((priv->card_type == USB) ? 0 : SW_CONTROL_GPIO));
1129  
1130 if(priv->card_type == USB)
1131 mdelay(2);
1132 @@ -348,30 +372,30 @@
1133 short vz2 = 1;
1134 /* sw to reg pg 1 */
1135 write_rtl8225(dev, 0, 0x1b7);
1136 -
1137 +
1138 /* reg 8 pg 1 = 23*/
1139 if( read_rtl8225(dev, 8) != 0x588)
1140 vz2 = 0;
1141 -
1142 - else /* reg 9 pg 1 = 24 */
1143 +
1144 + else /* reg 9 pg 1 = 24 */
1145 if( read_rtl8225(dev, 9) != 0x700)
1146 vz2 = 0;
1147 -
1148 - /* sw back to pg 0 */
1149 +
1150 + /* sw back to pg 0 */
1151 write_rtl8225(dev, 0, 0xb7);
1152  
1153 return vz2;
1154 -
1155 +
1156 }
1157  
1158 #if 0
1159 void rtl8225_rf_close(struct net_device *dev)
1160 {
1161 - write_rtl8225(dev, 0x4, 0x1f);
1162 -
1163 + write_rtl8225(dev, 0x4, 0x1f);
1164 +
1165 force_pci_posting(dev);
1166 mdelay(1);
1167 -
1168 +
1169 rtl8180_set_anaparam(dev, RTL8225_ANAPARAM_OFF);
1170 rtl8185_set_anaparam2(dev, RTL8225_ANAPARAM2_OFF);
1171 }
1172 @@ -380,24 +404,24 @@
1173 short rtl8225_rf_set_sens(struct net_device *dev, short sens)
1174 {
1175 if (sens <0 || sens > 6) return -1;
1176 -
1177 +
1178 if(sens > 4)
1179 write_rtl8225(dev, 0x0c, 0x850);
1180 - else
1181 + else
1182 write_rtl8225(dev, 0x0c, 0x50);
1183  
1184 sens= 6-sens;
1185 rtl8225_set_gain(dev, sens);
1186 -
1187 +
1188 write_phy_cck(dev, 0x41, rtl8225_threshold[sens]);
1189 return 0;
1190 -
1191 +
1192 }
1193 #endif
1194 void rtl8225z2_SetTXPowerLevel(struct net_device *dev, short ch)
1195 {
1196 - struct r8180_priv *priv = ieee80211_priv(dev);
1197 -
1198 + struct r8180_priv *priv = ieee80211_priv_rtl7(dev);
1199 +
1200 // int GainIdx;
1201 // int GainSetting;
1202 int i;
1203 @@ -406,44 +430,47 @@
1204 u8 max_cck_power_level;
1205 //u8 min_cck_power_level;
1206 u8 max_ofdm_power_level;
1207 - u8 min_ofdm_power_level;
1208 + u8 min_ofdm_power_level;
1209 u8 cck_power_level = 0xff & priv->chtxpwr[ch];
1210 u8 ofdm_power_level = 0xff & priv->chtxpwr_ofdm[ch];
1211 -
1212 -
1213 +
1214 +
1215 max_cck_power_level = 15;
1216 //min_cck_power_level = 0;
1217 max_ofdm_power_level = 25; // 12 -> 25
1218 min_ofdm_power_level = 10;
1219 -
1220 +
1221 /* CCK power setting */
1222 if(cck_power_level > max_cck_power_level)
1223 + {
1224 cck_power_level = max_cck_power_level;
1225 -
1226 + priv->chtxpwr[ch] = max_cck_power_level;
1227 + }
1228 +
1229 cck_power_level += priv->cck_txpwr_base;
1230 -
1231 +
1232 if(cck_power_level > 35)
1233 cck_power_level = 35;
1234 -
1235 - if(ch == 14)
1236 +
1237 + if(ch == 14)
1238 cck_power_table = rtl8225z2_tx_power_cck_ch14;
1239 - else
1240 + else
1241 cck_power_table = rtl8225z2_tx_power_cck;
1242 -
1243 -
1244 +
1245 +
1246 for(i=0;i<8;i++){
1247 -
1248 +
1249 power = cck_power_table[i];
1250 write_phy_cck(dev, 0x44 + i, power);
1251 }
1252 -
1253 +
1254 //write_nic_byte(dev, TX_GAIN_CCK, power);
1255 //2005.11.17,
1256 write_nic_byte(dev, TX_GAIN_CCK, ZEBRA2_CCK_OFDM_GAIN_SETTING[cck_power_level]);
1257 -
1258 +
1259 force_pci_posting(dev);
1260 mdelay(1);
1261 -
1262 +
1263 /* OFDM power setting */
1264 // Old:
1265 // if(ofdm_power_level > max_ofdm_power_level)
1266 @@ -454,26 +481,26 @@
1267 ofdm_power_level = max_ofdm_power_level;
1268 else
1269 ofdm_power_level += min_ofdm_power_level;
1270 -
1271 +
1272 ofdm_power_level += priv->ofdm_txpwr_base;
1273 -
1274 +
1275 if(ofdm_power_level > 35)
1276 ofdm_power_level = 35;
1277 -
1278 +
1279 rtl8185_set_anaparam2(dev,RTL8225_ANAPARAM2_ON);
1280 -
1281 +
1282 write_phy_ofdm(dev,2,0x42);
1283 write_phy_ofdm(dev,5,0);
1284 write_phy_ofdm(dev,6,0x40);
1285 write_phy_ofdm(dev,7,0);
1286 - write_phy_ofdm(dev,8,0x40);
1287 -
1288 + write_phy_ofdm(dev,8,0x40);
1289 +
1290  
1291 //write_nic_byte(dev, TX_GAIN_OFDM, ofdm_power_level);
1292 //2005.11.17,
1293 write_nic_byte(dev, TX_GAIN_OFDM, ZEBRA2_CCK_OFDM_GAIN_SETTING[ofdm_power_level]);
1294  
1295 -
1296 +
1297 force_pci_posting(dev);
1298 mdelay(1);
1299 //write_nic_byte(dev, TX_AGC_CONTROL,4);
1300 @@ -483,39 +510,39 @@
1301 void rtl8225_set_mode(struct net_device *dev, short modeb)
1302 {
1303 write_phy_ofdm(dev, 0x15, (modeb ? 0x0 : 0x40));
1304 - write_phy_ofdm(dev, 0x17, (modeb ? 0x0 : 0x40));
1305 + write_phy_ofdm(dev, 0x17, (modeb ? 0x0 : 0x40));
1306 }
1307 #endif
1308  
1309 void rtl8225z2_rf_set_chan(struct net_device *dev, short ch)
1310 {
1311 - struct r8180_priv *priv = ieee80211_priv(dev);
1312 + struct r8180_priv *priv = ieee80211_priv_rtl7(dev);
1313 short gset = (priv->ieee80211->state == IEEE80211_LINKED &&
1314 - ieee80211_is_54g(priv->ieee80211->current_network)) ||
1315 + ieee80211_is_54g_rtl7(priv->ieee80211->current_network)) ||
1316 priv->ieee80211->iw_mode == IW_MODE_MONITOR;
1317 -
1318 +
1319 rtl8225z2_SetTXPowerLevel(dev, ch);
1320 -
1321 +
1322 write_rtl8225(dev, 0x7, rtl8225_chan[ch]);
1323 -
1324 +
1325 force_pci_posting(dev);
1326 mdelay(10);
1327 -
1328 +
1329 write_nic_byte(dev,SIFS,0x22);// SIFS: 0x22
1330 -
1331 +
1332 if(gset)
1333 - write_nic_byte(dev,DIFS,20); //DIFS: 20
1334 + write_nic_byte(dev,DIFS,20); //DIFS: 20
1335 else
1336 - write_nic_byte(dev,DIFS,0x24); //DIFS: 36
1337 -
1338 + write_nic_byte(dev,DIFS,0x24); //DIFS: 36
1339 +
1340 if(priv->ieee80211->state == IEEE80211_LINKED &&
1341 - ieee80211_is_shortslot(priv->ieee80211->current_network))
1342 + ieee80211_is_shortslot_rtl7(priv->ieee80211->current_network))
1343 write_nic_byte(dev,SLOT,0x9); //SLOT: 9
1344 -
1345 +
1346 else
1347 write_nic_byte(dev,SLOT,0x14); //SLOT: 20 (0x14)
1348 -
1349 -
1350 +
1351 +
1352 if(gset){
1353 write_nic_byte(dev,EIFS,91 - 20); // EIFS: 91 (0x5B)
1354 write_nic_byte(dev,CW_VAL,0x73); //CW VALUE: 0x37
1355 @@ -529,68 +556,68 @@
1356  
1357 }
1358 #if 0
1359 -void rtl8225_host_pci_init(struct net_device *dev)
1360 +void rtl8225_host_pci_init(struct net_device *dev)
1361 {
1362 write_nic_word(dev, RFPinsOutput, 0x480);
1363 -
1364 +
1365 rtl8185_rf_pins_enable(dev);
1366 -
1367 +
1368 //if(priv->card_8185 == 2 && priv->enable_gpio0 ) /* version D */
1369 //write_nic_word(dev, RFPinsSelect, 0x88);
1370 //else
1371 write_nic_word(dev, RFPinsSelect, 0x88 | SW_CONTROL_GPIO); /* 0x488 | SW_CONTROL_GPIO */
1372 -
1373 +
1374 write_nic_byte(dev, GP_ENABLE, 0);
1375 -
1376 +
1377 force_pci_posting(dev);
1378 mdelay(200);
1379 -
1380 +
1381 write_nic_word(dev, GP_ENABLE, 0xff & (~(1<<6))); /* bit 6 is for RF on/off detection */
1382  
1383 -
1384 +
1385 }
1386  
1387 -void rtl8225_host_usb_init(struct net_device *dev)
1388 +void rtl8225_host_usb_init(struct net_device *dev)
1389 {
1390 write_nic_byte(dev,RFPinsSelect+1,0);
1391  
1392 write_nic_byte(dev,GPIO,0);
1393 -
1394 +
1395 write_nic_byte_E(dev,0x53,read_nic_byte_E(dev,0x53) | (1<<7));
1396 -
1397 +
1398 write_nic_byte(dev,RFPinsSelect+1,4);
1399  
1400 write_nic_byte(dev,GPIO,0x20);
1401  
1402 write_nic_byte(dev,GP_ENABLE,0);
1403  
1404 -
1405 - /* Config BB & RF */
1406 +
1407 + /* Config BB & RF */
1408 write_nic_word(dev, RFPinsOutput, 0x80);
1409  
1410 write_nic_word(dev, RFPinsSelect, 0x80);
1411  
1412 write_nic_word(dev, RFPinsEnable, 0x80);
1413  
1414 -
1415 +
1416 mdelay(100);
1417  
1418 - mdelay(1000);
1419 + mdelay(1000);
1420  
1421 }
1422 #endif
1423 -void rtl8225z2_rf_init(struct net_device *dev)
1424 +void rtl8225z2_rf_init(struct net_device *dev)
1425 {
1426 - struct r8180_priv *priv = ieee80211_priv(dev);
1427 + struct r8180_priv *priv = ieee80211_priv_rtl7(dev);
1428 int i;
1429 short channel = 1;
1430 u16 brsr;
1431 u32 data,addr;
1432 -
1433 +
1434 priv->chan = channel;
1435  
1436 rtl8180_set_anaparam(dev, RTL8225_ANAPARAM_ON);
1437 -
1438 +
1439  
1440 if(priv->card_type == USB)
1441 rtl8225_host_usb_init(dev);
1442 @@ -598,42 +625,42 @@
1443 rtl8225_host_pci_init(dev);
1444  
1445 write_nic_dword(dev, RF_TIMING, 0x000a8008);
1446 -
1447 +
1448 brsr = read_nic_word(dev, BRSR);
1449 -
1450 - write_nic_word(dev, BRSR, 0xffff);
1451 +
1452 + write_nic_word(dev, BRSR, 0xffff);
1453  
1454  
1455 write_nic_dword(dev, RF_PARA, 0x100044);
1456 -
1457 +
1458 #if 1 //0->1
1459 rtl8180_set_mode(dev, EPROM_CMD_CONFIG);
1460 write_nic_byte(dev, CONFIG3, 0x44);
1461 rtl8180_set_mode(dev, EPROM_CMD_NORMAL);
1462 #endif
1463 -
1464 -
1465 +
1466 +
1467 rtl8185_rf_pins_enable(dev);
1468  
1469 // mdelay(1000);
1470  
1471 write_rtl8225(dev, 0x0, 0x2bf); mdelay(1);
1472 -
1473 -
1474 +
1475 +
1476 write_rtl8225(dev, 0x1, 0xee0); mdelay(1);
1477  
1478 write_rtl8225(dev, 0x2, 0x44d); mdelay(1);
1479  
1480 write_rtl8225(dev, 0x3, 0x441); mdelay(1);
1481  
1482 -
1483 +
1484 write_rtl8225(dev, 0x4, 0x8c3);mdelay(1);
1485 -
1486 -
1487 -
1488 +
1489 +
1490 +
1491 write_rtl8225(dev, 0x5, 0xc72);mdelay(1);
1492 // }
1493 -
1494 +
1495 write_rtl8225(dev, 0x6, 0xe6); mdelay(1);
1496  
1497 write_rtl8225(dev, 0x7, ((priv->card_type == USB)? 0x82a : rtl8225_chan[channel])); mdelay(1);
1498 @@ -653,28 +680,28 @@
1499  
1500 write_rtl8225(dev, 0xe, 0x2b); mdelay(1);
1501  
1502 - write_rtl8225(dev, 0xf, 0x114);
1503 -
1504 -
1505 + write_rtl8225(dev, 0xf, 0x114);
1506 +
1507 +
1508 mdelay(100);
1509 -
1510 -
1511 +
1512 +
1513 //if(priv->card_type != USB) /* maybe not needed even for 8185 */
1514 -// write_rtl8225(dev, 0x7, rtl8225_chan[channel]);
1515 -
1516 +// write_rtl8225(dev, 0x7, rtl8225_chan[channel]);
1517 +
1518 write_rtl8225(dev, 0x0, 0x1b7);
1519 -
1520 +
1521 for(i=0;i<95;i++){
1522 write_rtl8225(dev, 0x1, (u8)(i+1));
1523 -
1524 +
1525 #if 0
1526 - if(priv->phy_ver == 1)
1527 + if(priv->phy_ver == 1)
1528 /* version A */
1529 write_rtl8225(dev, 0x2, rtl8225a_rxgain[i]);
1530 else
1531 #endif
1532 /* version B & C & D*/
1533 -
1534 +
1535 write_rtl8225(dev, 0x2, rtl8225z2_rxgain[i]);
1536 }
1537 write_rtl8225(dev, 0x3, 0x80);
1538 @@ -683,16 +710,16 @@
1539 write_rtl8225(dev, 0x0, 0xb7);
1540  
1541 write_rtl8225(dev, 0x2, 0xc4d);
1542 -
1543 +
1544 if(priv->card_type == USB){
1545 // force_pci_posting(dev);
1546 mdelay(200);
1547 -
1548 +
1549 write_rtl8225(dev, 0x2, 0x44d);
1550 -
1551 +
1552 // force_pci_posting(dev);
1553 mdelay(100);
1554 -
1555 +
1556 }//End of if(priv->card_type == USB)
1557 /* FIXME!! rtl8187 we have to check if calibrarion
1558 * is successful and eventually cal. again (repeat
1559 @@ -713,23 +740,23 @@
1560 }
1561 }
1562 //force_pci_posting(dev);
1563 -
1564 - mdelay(200); //200 for 8187
1565 -
1566 -
1567 +
1568 + mdelay(200); //200 for 8187
1569 +
1570 +
1571 // //if(priv->card_type != USB){
1572 // write_rtl8225(dev, 0x2, 0x44d);
1573 // write_rtl8225(dev, 0x7, rtl8225_chan[channel]);
1574 // write_rtl8225(dev, 0x2, 0x47d);
1575 -//
1576 +//
1577 // force_pci_posting(dev);
1578 // mdelay(100);
1579 -//
1580 +//
1581 // write_rtl8225(dev, 0x2, 0x44d);
1582 // //}
1583 -
1584 - write_rtl8225(dev, 0x0, 0x2bf);
1585 -
1586 +
1587 + write_rtl8225(dev, 0x0, 0x2bf);
1588 +
1589 if(priv->card_type != USB)
1590 rtl8185_rf_pins_enable(dev);
1591 //set up ZEBRA AGC table, 2005.11.17,
1592 @@ -744,20 +771,20 @@
1593  
1594 mdelay(1);
1595 }
1596 -#if 0
1597 +#if 0
1598 for(i=0;i<128;i++){
1599 write_phy_ofdm(dev, 0xb, rtl8225_agc[i]);
1600 -
1601 - mdelay(1);
1602 +
1603 + mdelay(1);
1604 write_phy_ofdm(dev, 0xa, (u8)i+ 0x80);
1605 -
1606 - mdelay(1);
1607 +
1608 + mdelay(1);
1609 }
1610 #endif
1611 -
1612 +
1613 force_pci_posting(dev);
1614 mdelay(1);
1615 -
1616 +
1617 write_phy_ofdm(dev, 0x0, 0x1); mdelay(1);
1618 write_phy_ofdm(dev, 0x1, 0x2); mdelay(1);
1619 write_phy_ofdm(dev, 0x2, ((priv->card_type == USB)? 0x42 : 0x62)); mdelay(1);
1620 @@ -771,20 +798,20 @@
1621  
1622 write_phy_ofdm(dev, 0xa, 0x8); mdelay(1);
1623  
1624 - //write_phy_ofdm(dev, 0x18, 0xef);
1625 + //write_phy_ofdm(dev, 0x18, 0xef);
1626 // }
1627 //}
1628 write_phy_ofdm(dev, 0xb, 0x80); mdelay(1);
1629  
1630 write_phy_ofdm(dev, 0xc, 0x1);mdelay(1);
1631  
1632 -
1633 +
1634 //if(priv->card_type != USB)
1635 - write_phy_ofdm(dev, 0xd, 0x43);
1636 -
1637 + write_phy_ofdm(dev, 0xd, 0x43);
1638 +
1639 write_phy_ofdm(dev, 0xe, 0xd3);mdelay(1);
1640  
1641 -
1642 +
1643 #if 0
1644 if(priv->card_8185 == 1){
1645 if(priv->card_8185_Bversion)
1646 @@ -796,17 +823,17 @@
1647 write_phy_ofdm(dev, 0xf, 0x38);mdelay(1);
1648 /*ver D & 8187*/
1649 // }
1650 -
1651 +
1652 // if(priv->card_8185 == 1 && priv->card_8185_Bversion)
1653 // write_phy_ofdm(dev, 0x10, 0x04);/*ver B*/
1654 // else
1655 write_phy_ofdm(dev, 0x10, 0x84);mdelay(1);
1656 /*ver C & D & 8187*/
1657 -
1658 +
1659 write_phy_ofdm(dev, 0x11, 0x07);mdelay(1);
1660 /*agc resp time 700*/
1661  
1662 -
1663 +
1664 // if(priv->card_8185 == 2){
1665 /* Ver D & 8187*/
1666 write_phy_ofdm(dev, 0x12, 0x20);mdelay(1);
1667 @@ -824,47 +851,46 @@
1668 write_phy_ofdm(dev, 0x15, 0x40); mdelay(1);
1669 write_phy_ofdm(dev, 0x16, 0x0); mdelay(1);
1670 write_phy_ofdm(dev, 0x17, 0x40); mdelay(1);
1671 -
1672 +
1673 // if (priv->card_type == USB)
1674 // write_phy_ofdm(dev, 0x18, 0xef);
1675 -
1676 +
1677 write_phy_ofdm(dev, 0x18, 0xef);mdelay(1);
1678 -
1679 +
1680  
1681 write_phy_ofdm(dev, 0x19, 0x19); mdelay(1);
1682 write_phy_ofdm(dev, 0x1a, 0x20); mdelay(1);
1683 write_phy_ofdm(dev, 0x1b, 0x15);mdelay(1);
1684 -
1685 +
1686 write_phy_ofdm(dev, 0x1c, 0x4);mdelay(1);
1687  
1688 write_phy_ofdm(dev, 0x1d, 0xc5);mdelay(1); //2005.11.17,
1689 -
1690 +
1691 write_phy_ofdm(dev, 0x1e, 0x95);mdelay(1);
1692  
1693 write_phy_ofdm(dev, 0x1f, 0x75); mdelay(1);
1694  
1695 // }
1696 -
1697 +
1698 write_phy_ofdm(dev, 0x20, 0x1f);mdelay(1);
1699  
1700 write_phy_ofdm(dev, 0x21, 0x17);mdelay(1);
1701 -
1702 +
1703 write_phy_ofdm(dev, 0x22, 0x16);mdelay(1);
1704  
1705 // if(priv->card_type != USB)
1706 write_phy_ofdm(dev, 0x23, 0x80);mdelay(1); //FIXME maybe not needed // <>
1707 -
1708 +
1709 write_phy_ofdm(dev, 0x24, 0x46); mdelay(1);
1710 write_phy_ofdm(dev, 0x25, 0x00); mdelay(1);
1711 write_phy_ofdm(dev, 0x26, 0x90); mdelay(1);
1712  
1713 write_phy_ofdm(dev, 0x27, 0x88); mdelay(1);
1714  
1715 -
1716 +
1717 // <> Set init. gain to m74dBm.
1718 -
1719 rtl8225z2_set_gain(dev,4);
1720 -
1721 +
1722 write_phy_cck(dev, 0x0, 0x98); mdelay(1);
1723 write_phy_cck(dev, 0x3, 0x20); mdelay(1);
1724 write_phy_cck(dev, 0x4, 0x7e); mdelay(1);
1725 @@ -875,6 +901,9 @@
1726 /* Ver C & D & 8187*/
1727  
1728 write_phy_cck(dev, 0x8, 0x2e);mdelay(1);
1729 + write_phy_cck(dev, 0x9, 0x11);mdelay(1);
1730 + write_phy_cck(dev, 0xa, 0x17);mdelay(1);
1731 + write_phy_cck(dev, 0xb, 0x11);mdelay(1);
1732  
1733 write_phy_cck(dev, 0x10, ((priv->card_type == USB) ? 0x9b: 0x93)); mdelay(1);
1734 write_phy_cck(dev, 0x11, 0x88); mdelay(1);
1735 @@ -885,52 +914,59 @@
1736 else
1737 #endif
1738 write_phy_cck(dev, 0x13, 0xd0); /* Ver C & D & 8187*/
1739 -
1740 - write_phy_cck(dev, 0x19, 0x0);
1741 - write_phy_cck(dev, 0x1a, 0xa0);
1742 - write_phy_cck(dev, 0x1b, 0x8);
1743 - write_phy_cck(dev, 0x40, 0x86); /* CCK Carrier Sense Threshold */
1744 -
1745 - write_phy_cck(dev, 0x41, 0x8d);mdelay(1);
1746  
1747 -
1748 +// write_phy_cck(dev, 0x19, 0x0);
1749 +// write_phy_cck(dev, 0x1a, 0xa0);
1750 +// write_phy_cck(dev, 0x1b, 0x8);
1751 +// write_phy_cck(dev, 0x40, 0x86); /* CCK Carrier Sense Threshold */
1752 + write_phy_cck(dev, 0x19, 0x0); mdelay(1);
1753 + write_phy_cck(dev, 0x1a, 0xa0); mdelay(1);
1754 + write_phy_cck(dev, 0x1b, 0x8); mdelay(1);
1755 + write_phy_cck(dev, 0x1d, 0x0); mdelay(1);
1756 + write_phy_cck(dev, 0x40, 0x86); /* CCK Carrier Sense Threshold */ mdelay(1);
1757 + write_phy_cck(dev, 0x41, 0x86); mdelay(1);
1758 +
1759 +
1760 +// write_phy_cck(dev, 0x41, 0x8d);mdelay(1);
1761 +
1762 +
1763 write_phy_cck(dev, 0x42, 0x15); mdelay(1);
1764 write_phy_cck(dev, 0x43, 0x18); mdelay(1);
1765 -
1766 -
1767 +
1768 +
1769 write_phy_cck(dev, 0x44, 0x36); mdelay(1);
1770 write_phy_cck(dev, 0x45, 0x35); mdelay(1);
1771 write_phy_cck(dev, 0x46, 0x2e); mdelay(1);
1772 write_phy_cck(dev, 0x47, 0x25); mdelay(1);
1773 write_phy_cck(dev, 0x48, 0x1c); mdelay(1);
1774 write_phy_cck(dev, 0x49, 0x12); mdelay(1);
1775 - write_phy_cck(dev, 0x4a, 0x9); mdelay(1);
1776 - write_phy_cck(dev, 0x4b, 0x4); mdelay(1);
1777 + write_phy_cck(dev, 0x4a, 0x09); mdelay(1);
1778 + write_phy_cck(dev, 0x4b, 0x04); mdelay(1);
1779 write_phy_cck(dev, 0x4c, 0x5);mdelay(1);
1780  
1781  
1782 write_nic_byte(dev, 0x5b, 0x0d); mdelay(1);
1783  
1784 -
1785 +
1786  
1787 // <>
1788 // // TESTR 0xb 8187
1789 // write_phy_cck(dev, 0x10, 0x93);// & 0xfb);
1790 -//
1791 +//
1792 // //if(priv->card_type != USB){
1793 // write_phy_ofdm(dev, 0x2, 0x62);
1794 // write_phy_ofdm(dev, 0x6, 0x0);
1795 // write_phy_ofdm(dev, 0x8, 0x0);
1796 // //}
1797 -
1798 +
1799 rtl8225z2_SetTXPowerLevel(dev, channel);
1800 -
1801 +
1802 write_phy_cck(dev, 0x10, 0x9b); mdelay(1); /* Rx ant A, 0xdb for B */
1803 write_phy_ofdm(dev, 0x26, 0x90); mdelay(1); /* Rx ant A, 0x10 for B */
1804 -
1805 +
1806 rtl8185_tx_antenna(dev, 0x3); /* TX ant A, 0x0 for B */
1807 -
1808 - /* switch to high-speed 3-wire
1809 +
1810 + /* switch to high-speed 3-wire
1811 * last digit. 2 for both cck and ofdm
1812 */
1813 if(priv->card_type == USB)
1814 @@ -943,23 +979,23 @@
1815 // if(priv->card_type != USB)
1816 // rtl8225_set_gain(dev, 4); /* FIXME this '1' is random */ // <>
1817 // rtl8225_set_mode(dev, 1); /* FIXME start in B mode */ // <>
1818 -//
1819 +//
1820 // /* make sure is waken up! */
1821 // write_rtl8225(dev,0x4, 0x9ff);
1822 -// rtl8180_set_anaparam(dev, RTL8225_ANAPARAM_ON);
1823 +// rtl8180_set_anaparam(dev, RTL8225_ANAPARAM_ON);
1824 // rtl8185_set_anaparam2(dev, RTL8225_ANAPARAM2_ON);
1825 -
1826 +
1827 rtl8225_rf_set_chan(dev, priv->chan);
1828  
1829 //write_nic_word(dev,BRSR,brsr);
1830 -
1831 +
1832 //rtl8225z2_rf_set_mode(dev);
1833 }
1834  
1835 -void rtl8225z2_rf_set_mode(struct net_device *dev)
1836 +void rtl8225z2_rf_set_mode(struct net_device *dev)
1837 {
1838 - struct r8180_priv *priv = ieee80211_priv(dev);
1839 -
1840 + struct r8180_priv *priv = ieee80211_priv_rtl7(dev);
1841 +
1842 if(priv->ieee80211->mode == IEEE_A)
1843 {
1844 write_rtl8225(dev, 0x5, 0x1865);
1845 @@ -970,15 +1006,15 @@
1846 write_phy_ofdm(dev, 0xb, 0x99);
1847 write_phy_ofdm(dev, 0xf, 0x20);
1848 write_phy_ofdm(dev, 0x11, 0x7);
1849 -
1850 +
1851 rtl8225z2_set_gain(dev,4);
1852 -
1853 +
1854 write_phy_ofdm(dev,0x15, 0x40);
1855 write_phy_ofdm(dev,0x17, 0x40);
1856 -
1857 +
1858 write_nic_dword(dev, 0x94,0x10000000);
1859 }else{
1860 -
1861 +
1862 write_rtl8225(dev, 0x5, 0x1864);
1863 write_nic_dword(dev, RF_PARA, 0x10044);
1864 write_nic_dword(dev, RF_TIMING, 0xa8008);
1865 @@ -987,12 +1023,12 @@
1866 write_phy_ofdm(dev, 0xb, 0x99);
1867 write_phy_ofdm(dev, 0xf, 0x20);
1868 write_phy_ofdm(dev, 0x11, 0x7);
1869 -
1870 +
1871 rtl8225z2_set_gain(dev,4);
1872 -
1873 +
1874 write_phy_ofdm(dev,0x15, 0x40);
1875 write_phy_ofdm(dev,0x17, 0x40);
1876 -
1877 +
1878 write_nic_dword(dev, 0x94,0x04000002);
1879 }
1880 }
1881 diff -Naur rtl8187_orig/beta-8187/r8180_wx.c rtl8187_rawtx/beta-8187/r8180_wx.c
1882 --- rtl8187_orig/beta-8187/r8180_wx.c 2007-03-13 23:45:09.000000000 +0100
1883 +++ rtl8187_rawtx/beta-8187/r8180_wx.c 2007-07-13 01:46:24.000000000 +0200
1884 @@ -1,19 +1,19 @@
1885 -/*
1886 +/*
1887 This file contains wireless extension handlers.
1888  
1889 This is part of rtl8180 OpenSource driver.
1890 - Copyright (C) Andrea Merello 2004-2005 <andreamrl@tiscali.it>
1891 + Copyright (C) Andrea Merello 2004-2005 <andreamrl@tiscali.it>
1892 Released under the terms of GPL (General Public Licence)
1893 -
1894 - Parts of this driver are based on the GPL part
1895 +
1896 + Parts of this driver are based on the GPL part
1897 of the official realtek driver.
1898 -
1899 - Parts of this driver are based on the rtl8180 driver skeleton
1900 +
1901 + Parts of this driver are based on the rtl8180 driver skeleton
1902 from Patric Schenke & Andres Salomon.
1903  
1904 Parts of this driver are based on the Intel Pro Wireless 2100 GPL driver.
1905 -
1906 - We want to tanks the Authors of those projects and the Ndiswrapper
1907 +
1908 + We want to tanks the Authors of those projects and the Ndiswrapper
1909 project Authors.
1910 */
1911  
1912 @@ -21,20 +21,21 @@
1913  
1914 #include "r8187.h"
1915 #include "r8180_hw.h"
1916 +#include "r8180_rtl8225.h"
1917  
1918  
1919 #define RATE_COUNT 4
1920 u32 rtl8180_rates[] = {1000000,2000000,5500000,11000000,
1921 6000000,9000000,12000000,18000000,24000000,36000000,48000000,54000000};
1922 -
1923 +
1924  
1925 static int r8180_wx_get_freq(struct net_device *dev,
1926 struct iw_request_info *a,
1927 union iwreq_data *wrqu, char *b)
1928 {
1929 - struct r8180_priv *priv = ieee80211_priv(dev);
1930 -
1931 - return ieee80211_wx_get_freq(priv->ieee80211,a,wrqu,b);
1932 + struct r8180_priv *priv = ieee80211_priv_rtl7(dev);
1933 +
1934 + return ieee80211_wx_get_freq_rtl7(priv->ieee80211,a,wrqu,b);
1935 }
1936  
1937  
1938 @@ -45,28 +46,28 @@
1939 {
1940 int *parms = (int *)b;
1941 int bi = parms[0];
1942 -
1943 - struct r8180_priv *priv = ieee80211_priv(dev);
1944 -
1945 +
1946 + struct r8180_priv *priv = ieee80211_priv_rtl7(dev);
1947 +
1948 down(&priv->wx_sem);
1949 DMESG("setting beacon interval to %x",bi);
1950 -
1951 +
1952 priv->ieee80211->beacon_interval=bi;
1953 rtl8180_commit(dev);
1954 up(&priv->wx_sem);
1955 -
1956 - return 0;
1957 +
1958 + return 0;
1959 }
1960  
1961  
1962 static int r8180_wx_set_forceassociate(struct net_device *dev, struct iw_request_info *aa,
1963 union iwreq_data *wrqu, char *extra)
1964 {
1965 - struct r8180_priv *priv=ieee80211_priv(dev);
1966 + struct r8180_priv *priv=ieee80211_priv_rtl7(dev);
1967 int *parms = (int *)extra;
1968 -
1969 +
1970 priv->ieee80211->force_associate = (parms[0] > 0);
1971 -
1972 +
1973  
1974 return 0;
1975 }
1976 @@ -75,108 +76,186 @@
1977 static int r8180_wx_get_mode(struct net_device *dev, struct iw_request_info *a,
1978 union iwreq_data *wrqu, char *b)
1979 {
1980 - struct r8180_priv *priv=ieee80211_priv(dev);
1981 + struct r8180_priv *priv=ieee80211_priv_rtl7(dev);
1982  
1983 - return ieee80211_wx_get_mode(priv->ieee80211,a,wrqu,b);
1984 + return ieee80211_wx_get_mode_rtl7(priv->ieee80211,a,wrqu,b);
1985 }
1986  
1987  
1988  
1989 -static int r8180_wx_get_rate(struct net_device *dev,
1990 - struct iw_request_info *info,
1991 +static int r8180_wx_get_rate(struct net_device *dev,
1992 + struct iw_request_info *info,
1993 union iwreq_data *wrqu, char *extra)
1994 {
1995 - struct r8180_priv *priv = ieee80211_priv(dev);
1996 - return ieee80211_wx_get_rate(priv->ieee80211,info,wrqu,extra);
1997 + struct r8180_priv *priv = ieee80211_priv_rtl7(dev);
1998 + return ieee80211_wx_get_rate_rtl7(priv->ieee80211,info,wrqu,extra);
1999 }
2000  
2001  
2002  
2003 -static int r8180_wx_set_rate(struct net_device *dev,
2004 - struct iw_request_info *info,
2005 +static int r8180_wx_set_rate(struct net_device *dev,
2006 + struct iw_request_info *info,
2007 union iwreq_data *wrqu, char *extra)
2008 {
2009 int ret;
2010 - struct r8180_priv *priv = ieee80211_priv(dev);
2011 -
2012 + struct r8180_priv *priv = ieee80211_priv_rtl7(dev);
2013 +
2014 down(&priv->wx_sem);
2015 + ret = ieee80211_wx_set_rate_rtl7(priv->ieee80211,info,wrqu,extra);
2016  
2017 - ret = ieee80211_wx_set_rate(priv->ieee80211,info,wrqu,extra);
2018 -
2019 up(&priv->wx_sem);
2020 -
2021 +
2022 return ret;
2023 }
2024  
2025 -static int r8180_wx_set_rawtx(struct net_device *dev,
2026 - struct iw_request_info *info,
2027 - union iwreq_data *wrqu, char *extra)
2028 +static int r8180_wx_get_txpow(struct net_device *dev,
2029 + struct iw_request_info *info,
2030 + union iwreq_data *wrqu, char *extra)
2031 {
2032 - struct r8180_priv *priv = ieee80211_priv(dev);
2033 - int ret;
2034 -
2035 + struct r8180_priv *priv = ieee80211_priv_rtl7(dev);
2036 + int i=0;
2037 down(&priv->wx_sem);
2038 -
2039 - ret = ieee80211_wx_set_rawtx(priv->ieee80211, info, wrqu, extra);
2040 -
2041 + wrqu->power.value = 0;
2042 + for(i=0; i<15; i++)
2043 + {
2044 + if(priv->chtxpwr[i] > wrqu->power.value) wrqu->power.value = priv->chtxpwr[i];
2045 + if(priv->chtxpwr_ofdm[i] > wrqu->power.value) wrqu->power.value = priv->chtxpwr_ofdm[i];
2046 + }
2047 + wrqu->power.fixed = 1;
2048 + wrqu->power.flags = IW_TXPOW_DBM;
2049 + wrqu->power.disabled = 0;
2050 up(&priv->wx_sem);
2051 -
2052 +
2053 + return 0;
2054 +}
2055 +
2056 +#if 1
2057 +static int r8180_wx_set_txpow(struct net_device *dev,
2058 + struct iw_request_info *info,
2059 + union iwreq_data *wrqu, char *extra)
2060 +{
2061 + int ret = 0, i=0;
2062 + struct r8180_priv *priv = ieee80211_priv_rtl7(dev);
2063 +
2064 + down(&priv->wx_sem);
2065 +
2066 + if (wrqu->power.flags != IW_TXPOW_DBM)
2067 + {
2068 + ret = -EINVAL;
2069 + goto out;
2070 + }
2071 +
2072 + if(wrqu->power.value > priv->txpwr_max)
2073 + {
2074 + ret = -EINVAL;
2075 + goto out;
2076 + }
2077 +
2078 + if(wrqu->power.value < 0)
2079 + {
2080 + ret = -EINVAL;
2081 + goto out;
2082 + }
2083 +
2084 + for(i=1;i<15;i++)
2085 + {
2086 + priv->chtxpwr[i] = priv->chtxpwr_orig[i] - (priv->txpwr_max - wrqu->power.value);
2087 + if(priv->chtxpwr[i] > priv->chtxpwr_orig[i]) priv->chtxpwr[i] = 0;
2088 +
2089 + priv->chtxpwr_ofdm[i] = priv->chtxpwr_ofdm_orig[i] - (priv->txpwr_max - wrqu->power.value);
2090 + if(priv->chtxpwr_ofdm[i] > priv->chtxpwr_ofdm_orig[i]) priv->chtxpwr_ofdm[i] = 0;
2091 + }
2092 + rtl8225z2_SetTXPowerLevel(dev, 1);
2093 +
2094 + out:
2095 + up(&priv->wx_sem);
2096 +
2097 return ret;
2098 -
2099 +
2100 }
2101 +#endif
2102  
2103 -static int r8180_wx_set_crcmon(struct net_device *dev,
2104 - struct iw_request_info *info,
2105 +static int r8180_wx_set_crcmon(struct net_device *dev,
2106 + struct iw_request_info *info,
2107 union iwreq_data *wrqu, char *extra)
2108 {
2109 - struct r8180_priv *priv = ieee80211_priv(dev);
2110 + struct r8180_priv *priv = ieee80211_priv_rtl7(dev);
2111 int *parms = (int *)extra;
2112 int enable = (parms[0] > 0);
2113 short prev = priv->crcmon;
2114  
2115 down(&priv->wx_sem);
2116 -
2117 - if(enable)
2118 +
2119 + if(enable)
2120 priv->crcmon=1;
2121 - else
2122 + else
2123 priv->crcmon=0;
2124  
2125 - DMESG("bad CRC in monitor mode are %s",
2126 + DMESG("bad CRC in monitor mode are %s",
2127 priv->crcmon ? "accepted" : "rejected");
2128  
2129 if(prev != priv->crcmon && priv->up){
2130 rtl8180_down(dev);
2131 rtl8180_up(dev);
2132 }
2133 -
2134 +
2135 up(&priv->wx_sem);
2136 -
2137 +
2138 + return 0;
2139 +}
2140 +
2141 +static int r8180_wx_set_fasttx(struct net_device *dev,
2142 + struct iw_request_info *info,
2143 + union iwreq_data *wrqu, char *extra)
2144 +{
2145 + struct r8180_priv *priv = ieee80211_priv_rtl7(dev);
2146 + int *parms = (int *)extra;
2147 + int enable = (parms[0] > 0);
2148 + short prev = priv->fasttx;
2149 +
2150 + down(&priv->wx_sem);
2151 +
2152 + if(enable)
2153 + priv->fasttx=1;
2154 + else
2155 + priv->fasttx=0;
2156 +
2157 + DMESG("Transmission method (regarding speed) set to: %s",
2158 + priv->fasttx ? "fast" : "normal");
2159 +
2160 + if(prev != priv->fasttx && priv->up){
2161 + rtl8180_down(dev);
2162 + rtl8180_up(dev);
2163 + }
2164 +
2165 + up(&priv->wx_sem);
2166 +
2167 return 0;
2168 }
2169  
2170 static int r8180_wx_set_mode(struct net_device *dev, struct iw_request_info *a,
2171 union iwreq_data *wrqu, char *b)
2172 {
2173 - struct r8180_priv *priv = ieee80211_priv(dev);
2174 + struct r8180_priv *priv = ieee80211_priv_rtl7(dev);
2175 int ret;
2176 -
2177 +
2178 down(&priv->wx_sem);
2179 -
2180 - ret = ieee80211_wx_set_mode(priv->ieee80211,a,wrqu,b);
2181 -
2182 +
2183 + ret = ieee80211_wx_set_mode_rtl7(priv->ieee80211,a,wrqu,b);
2184 +
2185 rtl8187_set_rxconf(dev);
2186 -
2187 +
2188 up(&priv->wx_sem);
2189 return ret;
2190 }
2191  
2192  
2193 -static int rtl8180_wx_get_range(struct net_device *dev,
2194 - struct iw_request_info *info,
2195 +static int rtl8180_wx_get_range(struct net_device *dev,
2196 + struct iw_request_info *info,
2197 union iwreq_data *wrqu, char *extra)
2198 {
2199 struct iw_range *range = (struct iw_range *)extra;
2200 - struct r8180_priv *priv = ieee80211_priv(dev);
2201 + struct r8180_priv *priv = ieee80211_priv_rtl7(dev);
2202 u16 val;
2203 int i;
2204  
2205 @@ -186,26 +265,26 @@
2206 /* Let's try to keep this struct in the same order as in
2207 * linux/include/wireless.h
2208 */
2209 -
2210 +
2211 /* TODO: See what values we can set, and remove the ones we can't
2212 * set, or fill them with some default data.
2213 */
2214  
2215 /* ~5 Mb/s real (802.11b) */
2216 - range->throughput = 5 * 1000 * 1000;
2217 + range->throughput = 5 * 1000 * 1000;
2218  
2219 // TODO: Not used in 802.11b?
2220 // range->min_nwid; /* Minimal NWID we are able to set */
2221 // TODO: Not used in 802.11b?
2222 // range->max_nwid; /* Maximal NWID we are able to set */
2223 -
2224 +
2225 /* Old Frequency (backward compat - moved lower ) */
2226 -// range->old_num_channels;
2227 +// range->old_num_channels;
2228 // range->old_num_frequency;
2229 // range->old_freq[6]; /* Filler to keep "version" at the same offset */
2230 if(priv->rf_set_sens != NULL)
2231 range->sensitivity = priv->max_sens; /* signal level threshold range */
2232 -
2233 +
2234 range->max_qual.qual = 100;
2235 /* TODO: Find real max RSSI and stick here */
2236 range->max_qual.level = 0;
2237 @@ -219,14 +298,14 @@
2238 range->avg_qual.updated = 7; /* Updated all three */
2239  
2240 range->num_bitrates = RATE_COUNT;
2241 -
2242 +
2243 for (i = 0; i < RATE_COUNT && i < IW_MAX_BITRATES; i++) {
2244 range->bitrate[i] = rtl8180_rates[i];
2245 }
2246 -
2247 +
2248 range->min_frag = MIN_FRAG_THRESHOLD;
2249 range->max_frag = MAX_FRAG_THRESHOLD;
2250 -
2251 +
2252 range->pm_capa = 0;
2253  
2254 range->we_version_compiled = WIRELESS_EXT;
2255 @@ -243,18 +322,18 @@
2256 range->num_channels = 14;
2257  
2258 for (i = 0, val = 0; i < 14; i++) {
2259 -
2260 +
2261 // Include only legal frequencies for some countries
2262 if ((priv->challow)[i+1]) {
2263 range->freq[val].i = i + 1;
2264 - range->freq[val].m = ieee80211_wlan_frequencies[i] * 100000;
2265 + range->freq[val].m = ieee80211_wlan_frequencies_rtl7[i] * 100000;
2266 range->freq[val].e = 1;
2267 val++;
2268 } else {
2269 // FIXME: do we need to set anything for channels
2270 // we don't use ?
2271 }
2272 -
2273 +
2274 if (val == IW_MAX_FREQUENCIES)
2275 break;
2276 }
2277 @@ -267,15 +346,15 @@
2278 static int r8180_wx_set_scan(struct net_device *dev, struct iw_request_info *a,
2279 union iwreq_data *wrqu, char *b)
2280 {
2281 - struct r8180_priv *priv = ieee80211_priv(dev);
2282 + struct r8180_priv *priv = ieee80211_priv_rtl7(dev);
2283 int ret;
2284 -
2285 +
2286 if(!priv->up) return -1;
2287 -
2288 +
2289 down(&priv->wx_sem);
2290 -
2291 - ret = ieee80211_wx_set_scan(priv->ieee80211,a,wrqu,b);
2292 -
2293 +
2294 + ret = ieee80211_wx_set_scan_rtl7(priv->ieee80211,a,wrqu,b);
2295 +
2296 up(&priv->wx_sem);
2297 return ret;
2298 }
2299 @@ -286,50 +365,50 @@
2300 {
2301  
2302 int ret;
2303 - struct r8180_priv *priv = ieee80211_priv(dev);
2304 -
2305 + struct r8180_priv *priv = ieee80211_priv_rtl7(dev);
2306 +
2307 if(!priv->up) return -1;
2308 -
2309 +
2310 down(&priv->wx_sem);
2311  
2312 - ret = ieee80211_wx_get_scan(priv->ieee80211,a,wrqu,b);
2313 -
2314 + ret = ieee80211_wx_get_scan_rtl7(priv->ieee80211,a,wrqu,b);
2315 +
2316 up(&priv->wx_sem);
2317 -
2318 +
2319 return ret;
2320 }
2321  
2322  
2323 -static int r8180_wx_set_essid(struct net_device *dev,
2324 +static int r8180_wx_set_essid(struct net_device *dev,
2325 struct iw_request_info *a,
2326 union iwreq_data *wrqu, char *b)
2327 {
2328 - struct r8180_priv *priv = ieee80211_priv(dev);
2329 -
2330 + struct r8180_priv *priv = ieee80211_priv_rtl7(dev);
2331 +
2332 int ret;
2333 -
2334 +
2335 down(&priv->wx_sem);
2336 -
2337 - ret = ieee80211_wx_set_essid(priv->ieee80211,a,wrqu,b);
2338 -
2339 +
2340 + ret = ieee80211_wx_set_essid_rtl7(priv->ieee80211,a,wrqu,b);
2341 +
2342 up(&priv->wx_sem);
2343 return ret;
2344 }
2345  
2346  
2347 -static int r8180_wx_get_essid(struct net_device *dev,
2348 +static int r8180_wx_get_essid(struct net_device *dev,
2349 struct iw_request_info *a,
2350 union iwreq_data *wrqu, char *b)
2351 {
2352 int ret;
2353 - struct r8180_priv *priv = ieee80211_priv(dev);
2354 -
2355 + struct r8180_priv *priv = ieee80211_priv_rtl7(dev);
2356 +
2357 down(&priv->wx_sem);
2358 -
2359 - ret = ieee80211_wx_get_essid(priv->ieee80211, a, wrqu, b);
2360 +
2361 + ret = ieee80211_wx_get_essid_rtl7(priv->ieee80211, a, wrqu, b);
2362  
2363 up(&priv->wx_sem);
2364 -
2365 +
2366 return ret;
2367 }
2368  
2369 @@ -338,30 +417,30 @@
2370 union iwreq_data *wrqu, char *b)
2371 {
2372 int ret;
2373 - struct r8180_priv *priv = ieee80211_priv(dev);
2374 -
2375 + struct r8180_priv *priv = ieee80211_priv_rtl7(dev);
2376 +
2377 down(&priv->wx_sem);
2378 -
2379 - ret = ieee80211_wx_set_freq(priv->ieee80211, a, wrqu, b);
2380 -
2381 +
2382 + ret = ieee80211_wx_set_freq_rtl7(priv->ieee80211, a, wrqu, b);
2383 +
2384 up(&priv->wx_sem);
2385 return ret;
2386 }
2387  
2388 -static int r8180_wx_get_name(struct net_device *dev,
2389 - struct iw_request_info *info,
2390 +static int r8180_wx_get_name(struct net_device *dev,
2391 + struct iw_request_info *info,
2392 union iwreq_data *wrqu, char *extra)
2393 {
2394 - struct r8180_priv *priv = ieee80211_priv(dev);
2395 - return ieee80211_wx_get_name(priv->ieee80211, info, wrqu, extra);
2396 + struct r8180_priv *priv = ieee80211_priv_rtl7(dev);
2397 + return ieee80211_wx_get_name_rtl7(priv->ieee80211, info, wrqu, extra);
2398 }
2399  
2400  
2401 -static int r8180_wx_set_frag(struct net_device *dev,
2402 - struct iw_request_info *info,
2403 +static int r8180_wx_set_frag(struct net_device *dev,
2404 + struct iw_request_info *info,
2405 union iwreq_data *wrqu, char *extra)
2406 {
2407 - struct r8180_priv *priv = ieee80211_priv(dev);
2408 + struct r8180_priv *priv = ieee80211_priv_rtl7(dev);
2409  
2410 if (wrqu->frag.disabled)
2411 priv->ieee80211->fts = DEFAULT_FRAG_THRESHOLD;
2412 @@ -369,7 +448,7 @@
2413 if (wrqu->frag.value < MIN_FRAG_THRESHOLD ||
2414 wrqu->frag.value > MAX_FRAG_THRESHOLD)
2415 return -EINVAL;
2416 -
2417 +
2418 priv->ieee80211->fts = wrqu->frag.value & ~0x1;
2419 }
2420  
2421 @@ -377,11 +456,11 @@
2422 }
2423  
2424  
2425 -static int r8180_wx_get_frag(struct net_device *dev,
2426 - struct iw_request_info *info,
2427 +static int r8180_wx_get_frag(struct net_device *dev,
2428 + struct iw_request_info *info,
2429 union iwreq_data *wrqu, char *extra)
2430 {
2431 - struct r8180_priv *priv = ieee80211_priv(dev);
2432 + struct r8180_priv *priv = ieee80211_priv_rtl7(dev);
2433  
2434 wrqu->frag.value = priv->ieee80211->fts;
2435 wrqu->frag.fixed = 0; /* no auto select */
2436 @@ -397,49 +476,49 @@
2437 char *extra)
2438 {
2439 int ret;
2440 - struct r8180_priv *priv = ieee80211_priv(dev);
2441 -
2442 + struct r8180_priv *priv = ieee80211_priv_rtl7(dev);
2443 +
2444 down(&priv->wx_sem);
2445 -
2446 - ret = ieee80211_wx_set_wap(priv->ieee80211,info,awrq,extra);
2447 -
2448 +
2449 + ret = ieee80211_wx_set_wap_rtl7(priv->ieee80211,info,awrq,extra);
2450 +
2451 up(&priv->wx_sem);
2452 return ret;
2453 -
2454 +
2455 }
2456 -
2457  
2458 -static int r8180_wx_get_wap(struct net_device *dev,
2459 - struct iw_request_info *info,
2460 +
2461 +static int r8180_wx_get_wap(struct net_device *dev,
2462 + struct iw_request_info *info,
2463 union iwreq_data *wrqu, char *extra)
2464 {
2465 - struct r8180_priv *priv = ieee80211_priv(dev);
2466 -
2467 - return ieee80211_wx_get_wap(priv->ieee80211,info,wrqu,extra);
2468 + struct r8180_priv *priv = ieee80211_priv_rtl7(dev);
2469 +
2470 + return ieee80211_wx_get_wap_rtl7(priv->ieee80211,info,wrqu,extra);
2471 }
2472  
2473  
2474 -static int r8180_wx_get_enc(struct net_device *dev,
2475 - struct iw_request_info *info,
2476 +static int r8180_wx_get_enc(struct net_device *dev,
2477 + struct iw_request_info *info,
2478 union iwreq_data *wrqu, char *key)
2479 {
2480 - struct r8180_priv *priv = ieee80211_priv(dev);
2481 -
2482 - return ieee80211_wx_get_encode(priv->ieee80211, info, wrqu, key);
2483 + struct r8180_priv *priv = ieee80211_priv_rtl7(dev);
2484 +
2485 + return ieee80211_wx_get_encode_rtl7(priv->ieee80211, info, wrqu, key);
2486 }
2487  
2488 -static int r8180_wx_set_enc(struct net_device *dev,
2489 - struct iw_request_info *info,
2490 +static int r8180_wx_set_enc(struct net_device *dev,
2491 + struct iw_request_info *info,
2492 union iwreq_data *wrqu, char *key)
2493 {
2494 - struct r8180_priv *priv = ieee80211_priv(dev);
2495 + struct r8180_priv *priv = ieee80211_priv_rtl7(dev);
2496 int ret;
2497 -
2498 +
2499 down(&priv->wx_sem);
2500 -
2501 +
2502 DMESG("Setting SW wep key");
2503 - ret = ieee80211_wx_set_encode(priv->ieee80211,info,wrqu,key);
2504 -
2505 + ret = ieee80211_wx_set_encode_rtl7(priv->ieee80211,info,wrqu,key);
2506 +
2507 up(&priv->wx_sem);
2508 return ret;
2509 }
2510 @@ -447,28 +526,28 @@
2511  
2512 static int r8180_wx_set_scan_type(struct net_device *dev, struct iw_request_info *aa, union
2513 iwreq_data *wrqu, char *p){
2514 -
2515 - struct r8180_priv *priv = ieee80211_priv(dev);
2516 +
2517 + struct r8180_priv *priv = ieee80211_priv_rtl7(dev);
2518 int *parms=(int*)p;
2519 int mode=parms[0];
2520 -
2521 +
2522 priv->ieee80211->active_scan = mode;
2523 -
2524 +
2525 return 1;
2526 }
2527  
2528  
2529  
2530 -static int r8180_wx_set_retry(struct net_device *dev,
2531 - struct iw_request_info *info,
2532 +static int r8180_wx_set_retry(struct net_device *dev,
2533 + struct iw_request_info *info,
2534 union iwreq_data *wrqu, char *extra)
2535 {
2536 - struct r8180_priv *priv = ieee80211_priv(dev);
2537 + struct r8180_priv *priv = ieee80211_priv_rtl7(dev);
2538 int err = 0;
2539 -
2540 +
2541 down(&priv->wx_sem);
2542 -
2543 - if (wrqu->retry.flags & IW_RETRY_LIFETIME ||
2544 +
2545 + if (wrqu->retry.flags & IW_RETRY_LIFETIME ||
2546 wrqu->retry.disabled){
2547 err = -EINVAL;
2548 goto exit;
2549 @@ -485,13 +564,13 @@
2550 if (wrqu->retry.flags & IW_RETRY_MAX) {
2551 priv->retry_rts = wrqu->retry.value;
2552 DMESG("Setting retry for RTS/CTS data to %d", wrqu->retry.value);
2553 -
2554 +
2555 }else {
2556 priv->retry_data = wrqu->retry.value;
2557 DMESG("Setting retry for non RTS/CTS data to %d", wrqu->retry.value);
2558 }
2559 -
2560 - /* FIXME !
2561 +
2562 + /* FIXME !
2563 * We might try to write directly the TX config register
2564 * or to restart just the (R)TX process.
2565 * I'm unsure if whole reset is really needed
2566 @@ -503,28 +582,28 @@
2567 rtl8180_rtx_disable(dev);
2568 rtl8180_rx_enable(dev);
2569 rtl8180_tx_enable(dev);
2570 -
2571 +
2572 }
2573 */
2574 exit:
2575 up(&priv->wx_sem);
2576 -
2577 +
2578 return err;
2579 }
2580  
2581 -static int r8180_wx_get_retry(struct net_device *dev,
2582 - struct iw_request_info *info,
2583 +static int r8180_wx_get_retry(struct net_device *dev,
2584 + struct iw_request_info *info,
2585 union iwreq_data *wrqu, char *extra)
2586 {
2587 - struct r8180_priv *priv = ieee80211_priv(dev);
2588 -
2589 + struct r8180_priv *priv = ieee80211_priv_rtl7(dev);
2590 +
2591  
2592 wrqu->retry.disabled = 0; /* can't be disabled */
2593  
2594 - if ((wrqu->retry.flags & IW_RETRY_TYPE) ==
2595 - IW_RETRY_LIFETIME)
2596 + if ((wrqu->retry.flags & IW_RETRY_TYPE) ==
2597 + IW_RETRY_LIFETIME)
2598 return -EINVAL;
2599 -
2600 +
2601 if (wrqu->retry.flags & IW_RETRY_MAX) {
2602 wrqu->retry.flags = IW_RETRY_LIMIT & IW_RETRY_MAX;
2603 wrqu->retry.value = priv->retry_rts;
2604 @@ -533,30 +612,30 @@
2605 wrqu->retry.value = priv->retry_data;
2606 }
2607 //DMESG("returning %d",wrqu->retry.value);
2608 -
2609 +
2610  
2611 return 0;
2612 }
2613  
2614 -static int r8180_wx_get_sens(struct net_device *dev,
2615 - struct iw_request_info *info,
2616 +static int r8180_wx_get_sens(struct net_device *dev,
2617 + struct iw_request_info *info,
2618 union iwreq_data *wrqu, char *extra)
2619 {
2620 - struct r8180_priv *priv = ieee80211_priv(dev);
2621 - if(priv->rf_set_sens == NULL)
2622 + struct r8180_priv *priv = ieee80211_priv_rtl7(dev);
2623 + if(priv->rf_set_sens == NULL)
2624 return -1; /* we have not this support for this radio */
2625 wrqu->sens.value = priv->sens;
2626 return 0;
2627 }
2628  
2629  
2630 -static int r8180_wx_set_sens(struct net_device *dev,
2631 - struct iw_request_info *info,
2632 +static int r8180_wx_set_sens(struct net_device *dev,
2633 + struct iw_request_info *info,
2634 union iwreq_data *wrqu, char *extra)
2635 {
2636 -
2637 - struct r8180_priv *priv = ieee80211_priv(dev);
2638 -
2639 +
2640 + struct r8180_priv *priv = ieee80211_priv_rtl7(dev);
2641 +
2642 short err = 0;
2643 down(&priv->wx_sem);
2644 //DMESG("attempt to set sensivity to %ddb",wrqu->sens.value);
2645 @@ -571,7 +650,7 @@
2646  
2647 exit:
2648 up(&priv->wx_sem);
2649 -
2650 +
2651 return err;
2652 }
2653  
2654 @@ -623,50 +702,49 @@
2655 dummy, /* SIOCGIWRTS */
2656 r8180_wx_set_frag, /* SIOCSIWFRAG */
2657 r8180_wx_get_frag, /* SIOCGIWFRAG */
2658 - dummy, /* SIOCSIWTXPOW */
2659 - dummy, /* SIOCGIWTXPOW */
2660 + r8180_wx_set_txpow, /* SIOCSIWTXPOW */
2661 + r8180_wx_get_txpow, /* SIOCGIWTXPOW */
2662 r8180_wx_set_retry, /* SIOCSIWRETRY */
2663 r8180_wx_get_retry, /* SIOCGIWRETRY */
2664 r8180_wx_set_enc, /* SIOCSIWENCODE */
2665 r8180_wx_get_enc, /* SIOCGIWENCODE */
2666 dummy, /* SIOCSIWPOWER */
2667 dummy, /* SIOCGIWPOWER */
2668 -};
2669 +};
2670  
2671  
2672 -static const struct iw_priv_args r8180_private_args[] = {
2673 -
2674 +static const struct iw_priv_args r8180_private_args[] = {
2675 {
2676 - SIOCIWFIRSTPRIV + 0x0,
2677 - IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1, 0, "badcrc"
2678 - },
2679 -
2680 + SIOCIWFIRSTPRIV + 0x0,
2681 + IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1, 0, "fasttx"
2682 + },
2683 +
2684 {
2685 SIOCIWFIRSTPRIV + 0x1,
2686 - IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1, 0, "activescan"
2687 -
2688 + IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1, 0, "badcrc"
2689 },
2690 +
2691 {
2692 - SIOCIWFIRSTPRIV + 0x2,
2693 - IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1, 0, "rawtx"
2694 + SIOCIWFIRSTPRIV + 0x2,
2695 + IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1, 0, "activescan"
2696 +
2697 }
2698 };
2699  
2700  
2701 static iw_handler r8180_private_handler[] = {
2702 -// r8180_wx_set_monitor, /* SIOCIWFIRSTPRIV */
2703 + r8180_wx_set_fasttx, /* SIOCIWFIRSTPRIV */
2704 r8180_wx_set_crcmon, /*SIOCIWSECONDPRIV*/
2705 // r8180_wx_set_forceassociate,
2706 // r8180_wx_set_beaconinterval,
2707 // r8180_wx_set_monitor_type,
2708 r8180_wx_set_scan_type,
2709 - r8180_wx_set_rawtx,
2710 };
2711  
2712 -#if WIRELESS_EXT >= 17
2713 +#if WIRELESS_EXT >= 17
2714 static struct iw_statistics *r8180_get_wireless_stats(struct net_device *dev)
2715 {
2716 - struct r8180_priv *priv = ieee80211_priv(dev);
2717 + struct r8180_priv *priv = ieee80211_priv_rtl7(dev);
2718  
2719 return &priv->wstats;
2720 }
2721 @@ -679,8 +757,8 @@
2722 .private = r8180_private_handler,
2723 .num_private = sizeof(r8180_private_handler) / sizeof(iw_handler),
2724 .num_private_args = sizeof(r8180_private_args) / sizeof(struct iw_priv_args),
2725 -#if WIRELESS_EXT >= 17
2726 +#if WIRELESS_EXT >= 17
2727 .get_wireless_stats = r8180_get_wireless_stats,
2728 #endif
2729 - .private_args = (struct iw_priv_args *)r8180_private_args,
2730 + .private_args = (struct iw_priv_args *)r8180_private_args,
2731 };
2732 diff -Naur rtl8187_orig/beta-8187/r8187_core.c rtl8187_rawtx/beta-8187/r8187_core.c
2733 --- rtl8187_orig/beta-8187/r8187_core.c 2007-03-13 23:45:09.000000000 +0100
2734 +++ rtl8187_rawtx/beta-8187/r8187_core.c 2007-07-13 01:46:24.000000000 +0200
2735 @@ -1,27 +1,27 @@
2736 /*
2737 This is part of rtl8187 OpenSource driver - v 0.1
2738 - Copyright (C) Andrea Merello 2005 <andreamrl@tiscali.it>
2739 + Copyright (C) Andrea Merello 2005 <andreamrl@tiscali.it>
2740 Released under the terms of GPL (General Public License)
2741 -
2742 -
2743 - Parts of this driver are based on the rtl8180 driver skeleton
2744 +
2745 +
2746 + Parts of this driver are based on the rtl8180 driver skeleton
2747 from Patric Schenke & Andres Salomon.
2748  
2749 Parts of this driver are based on the Intel Pro Wireless 2*00 GPL drivers.
2750 -
2751 +
2752 some ideas might be derived from David Young rtl8180 netbsd driver.
2753 -
2754 +
2755 Parts of the usb code are from the r8150.c driver in linux kernel
2756 -
2757 +
2758 Some ideas borrowed from the 8139too.c driver included in linux kernel.
2759 -
2760 - We (I?) want to thanks the Authors of those projecs and also the
2761 +
2762 + We (I?) want to thanks the Authors of those projecs and also the
2763 Ndiswrapper's project Authors.
2764 -
2765 - A special big thanks goes also to Realtek corp. for their help in my
2766 - attempt to add RTL8187 and RTL8225 support, and to David Young also.
2767  
2768 - - Please note that this file is a modified version from rtl8180-sa2400
2769 + A special big thanks goes also to Realtek corp. for their help in my
2770 + attempt to add RTL8187 and RTL8225 support, and to David Young also.
2771 +
2772 + - Please note that this file is a modified version from rtl8180-sa2400
2773 drv. So some other people have contributed to this project, and they are
2774 thanked in the rtl8180-sa2400 CHANGELOG.
2775 */
2776 @@ -57,6 +57,7 @@
2777 #undef DEBUG_IRQ_TASKLET
2778 #undef DEBUG_TX_ALLOC
2779 #undef DEBUG_TX_DESC
2780 +#undef DEBUG_TX_POWER
2781  
2782 //#define CONFIG_RTL8180_IO_MAP
2783  
2784 @@ -66,6 +67,9 @@
2785 #include "r8180_93cx6.h" /* Card EEPROM */
2786 #include "r8180_wx.h"
2787  
2788 +#if !(defined(CONFIG_USB_EHCI_HCD) || defined (CONFIG_USB_EHCI_HCD_MODULE))
2789 + #error Build your kernel with ehci_hcd support!
2790 +#endif
2791  
2792 // FIXME: check if 2.6.7 is ok
2793 #if (LINUX_VERSION_CODE < KERNEL_VERSION(2,6,7))
2794 @@ -98,6 +102,10 @@
2795 #endif
2796 static int channels = 0x3fff;
2797  
2798 +// #define DEBUG_EPROM
2799 +// #define DEBUG_REGISTERS
2800 +// #define DEBUG_TX_POWER
2801 +
2802 MODULE_LICENSE("GPL");
2803 MODULE_VERSION("V 1.1");
2804 MODULE_DEVICE_TABLE(usb, rtl8187_usb_id_tbl);
2805 @@ -137,7 +145,7 @@
2806  
2807 static int __devinit rtl8187_usb_probe(struct usb_interface *intf,
2808 const struct usb_device_id *id);
2809 -
2810 +
2811 static void __devexit rtl8187_usb_disconnect(struct usb_interface *intf);
2812  
2813 static struct usb_driver rtl8187_usb_driver = {
2814 @@ -158,13 +166,12 @@
2815 #endif
2816 };
2817  
2818 -
2819 void write_nic_byte_E(struct net_device *dev, int indx, u8 data)
2820 {
2821 -
2822 - struct r8180_priv *priv = (struct r8180_priv *)ieee80211_priv(dev);
2823 +
2824 + struct r8180_priv *priv = (struct r8180_priv *)ieee80211_priv_rtl7(dev);
2825 struct usb_device *udev = priv->udev;
2826 -
2827 +
2828 usb_control_msg(udev, usb_sndctrlpipe(udev, 0),
2829 RTL8187_REQ_SET_REGS, RTL8187_REQT_WRITE,
2830 indx|0xfe00, 0, &data, 1, HZ / 2);
2831 @@ -173,10 +180,10 @@
2832  
2833 void write_nic_byte(struct net_device *dev, int indx, u8 data)
2834 {
2835 -
2836 - struct r8180_priv *priv = (struct r8180_priv *)ieee80211_priv(dev);
2837 +
2838 + struct r8180_priv *priv = (struct r8180_priv *)ieee80211_priv_rtl7(dev);
2839 struct usb_device *udev = priv->udev;
2840 -
2841 +
2842 usb_control_msg(udev, usb_sndctrlpipe(udev, 0),
2843 RTL8187_REQ_SET_REGS, RTL8187_REQT_WRITE,
2844 indx|0xff00, 0, &data, 1, HZ / 2);
2845 @@ -185,10 +192,10 @@
2846  
2847 void write_nic_word(struct net_device *dev, int indx, u16 data)
2848 {
2849 -
2850 - struct r8180_priv *priv = (struct r8180_priv *)ieee80211_priv(dev);
2851 +
2852 + struct r8180_priv *priv = (struct r8180_priv *)ieee80211_priv_rtl7(dev);
2853 struct usb_device *udev = priv->udev;
2854 -
2855 +
2856 usb_control_msg(udev, usb_sndctrlpipe(udev, 0),
2857 RTL8187_REQ_SET_REGS, RTL8187_REQT_WRITE,
2858 indx|0xff00, 0, &data, 2, HZ / 2);
2859 @@ -197,23 +204,23 @@
2860  
2861 void write_nic_dword(struct net_device *dev, int indx, u32 data)
2862 {
2863 -
2864 - struct r8180_priv *priv = (struct r8180_priv *)ieee80211_priv(dev);
2865 +
2866 + struct r8180_priv *priv = (struct r8180_priv *)ieee80211_priv_rtl7(dev);
2867 struct usb_device *udev = priv->udev;
2868 -
2869 +
2870 usb_control_msg(udev, usb_sndctrlpipe(udev, 0),
2871 RTL8187_REQ_SET_REGS, RTL8187_REQT_WRITE,
2872 indx|0xff00, 0, &data, 4, HZ / 2);
2873 }
2874 -
2875 -
2876 -
2877 +
2878 +
2879 +
2880 u8 read_nic_byte(struct net_device *dev, int indx)
2881 {
2882 u8 data;
2883 - struct r8180_priv *priv = (struct r8180_priv *)ieee80211_priv(dev);
2884 + struct r8180_priv *priv = (struct r8180_priv *)ieee80211_priv_rtl7(dev);
2885 struct usb_device *udev = priv->udev;
2886 -
2887 +
2888 usb_control_msg(udev, usb_rcvctrlpipe(udev, 0),
2889 RTL8187_REQ_GET_REGS, RTL8187_REQT_READ,
2890 indx|0xff00, 0, &data, 1, HZ / 2);
2891 @@ -223,22 +230,22 @@
2892 u8 read_nic_byte_E(struct net_device *dev, int indx)
2893 {
2894 u8 data;
2895 - struct r8180_priv *priv = (struct r8180_priv *)ieee80211_priv(dev);
2896 + struct r8180_priv *priv = (struct r8180_priv *)ieee80211_priv_rtl7(dev);
2897 struct usb_device *udev = priv->udev;
2898 -
2899 +
2900 usb_control_msg(udev, usb_rcvctrlpipe(udev, 0),
2901 RTL8187_REQ_GET_REGS, RTL8187_REQT_READ,
2902 indx|0xfe00, 0, &data, 1, HZ / 2);
2903 return data;
2904 }
2905  
2906 -
2907 +
2908 u16 read_nic_word(struct net_device *dev, int indx)
2909 {
2910 u16 data;
2911 - struct r8180_priv *priv = (struct r8180_priv *)ieee80211_priv(dev);
2912 + struct r8180_priv *priv = (struct r8180_priv *)ieee80211_priv_rtl7(dev);
2913 struct usb_device *udev = priv->udev;
2914 -
2915 +
2916 usb_control_msg(udev, usb_rcvctrlpipe(udev, 0),
2917 RTL8187_REQ_GET_REGS, RTL8187_REQT_READ,
2918 indx|0xff00, 0, &data, 2, HZ / 2);
2919 @@ -249,16 +256,16 @@
2920 u32 read_nic_dword(struct net_device *dev, int indx)
2921 {
2922 u32 data;
2923 - struct r8180_priv *priv = (struct r8180_priv *)ieee80211_priv(dev);
2924 + struct r8180_priv *priv = (struct r8180_priv *)ieee80211_priv_rtl7(dev);
2925 struct usb_device *udev = priv->udev;
2926 -
2927 +
2928 usb_control_msg(udev, usb_rcvctrlpipe(udev, 0),
2929 RTL8187_REQ_GET_REGS, RTL8187_REQT_READ,
2930 indx|0xff00, 0, &data, 4, HZ / 2);
2931 return data;
2932 }
2933  
2934 -/* this might still called in what was the PHY rtl8185/rtl8187 common code
2935 +/* this might still called in what was the PHY rtl8185/rtl8187 common code
2936 * plans are to possibilty turn it again in one common code...
2937 */
2938 inline void force_pci_posting(struct net_device *dev)
2939 @@ -271,7 +278,12 @@
2940 //void set_nic_txring(struct net_device *dev);
2941 static struct net_device_stats *rtl8180_stats(struct net_device *dev);
2942 void rtl8180_commit(struct net_device *dev);
2943 +
2944 +# if (LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,20))
2945 +void rtl8180_restart(struct work_struct *work);
2946 +#else
2947 void rtl8180_restart(struct net_device *dev);
2948 +#endif
2949  
2950 /****************************************************************************
2951 -----------------------------PROCFS STUFF-------------------------
2952 @@ -284,13 +296,13 @@
2953 int *eof, void *data)
2954 {
2955 struct net_device *dev = data;
2956 -// struct r8180_priv *priv = (struct r8180_priv *)ieee80211_priv(dev);
2957 -
2958 +// struct r8180_priv *priv = (struct r8180_priv *)ieee80211_priv_rtl7(dev);
2959 +
2960 int len = 0;
2961 int i,n;
2962 -
2963 +
2964 int max=0xff;
2965 -
2966 +
2967 /* This dump the current register page */
2968 for(n=0;n<=max;)
2969 {
2970 @@ -307,7 +319,7 @@
2971 len += snprintf(page + len, count - len,"\n");
2972  
2973  
2974 -
2975 +
2976 *eof = 1;
2977 return len;
2978  
2979 @@ -319,16 +331,16 @@
2980 int *eof, void *data)
2981 {
2982 struct net_device *dev = data;
2983 - struct r8180_priv *priv = (struct r8180_priv *)ieee80211_priv(dev);
2984 -
2985 + struct r8180_priv *priv = (struct r8180_priv *)ieee80211_priv_rtl7(dev);
2986 +
2987 int len = 0;
2988 -
2989 +
2990 len += snprintf(page + len, count - len,
2991 "NIC int: %lu\n"
2992 "Total int: %lu\n",
2993 priv->stats.ints,
2994 priv->stats.shints);
2995 -
2996 +
2997 *eof = 1;
2998 return len;
2999 }
3000 @@ -339,10 +351,10 @@
3001 int *eof, void *data)
3002 {
3003 struct net_device *dev = data;
3004 - struct r8180_priv *priv = (struct r8180_priv *)ieee80211_priv(dev);
3005 -
3006 + struct r8180_priv *priv = (struct r8180_priv *)ieee80211_priv_rtl7(dev);
3007 +
3008 int len = 0;
3009 -
3010 +
3011 len += snprintf(page + len, count - len,
3012 "TX normal priority ok int: %lu\n"
3013 "TX normal priority error int: %lu\n"
3014 @@ -359,7 +371,7 @@
3015 "TX HW queue: %d\n"
3016 "TX lp dropped: %lu\n"
3017 "TX np dropped: %lu\n"
3018 - "TX total data packets %lu\n",
3019 + "TX total data packets %lu\n",
3020 // "TX beacon aborted: %lu\n",
3021 priv->stats.txnpokint,
3022 priv->stats.txnperr,
3023 @@ -379,10 +391,10 @@
3024 priv->stats.txdatapkt
3025 // priv->stats.txbeaconerr
3026 );
3027 -
3028 +
3029 *eof = 1;
3030 return len;
3031 -}
3032 +}
3033  
3034  
3035  
3036 @@ -391,10 +403,10 @@
3037 int *eof, void *data)
3038 {
3039 struct net_device *dev = data;
3040 - struct r8180_priv *priv = (struct r8180_priv *)ieee80211_priv(dev);
3041 -
3042 + struct r8180_priv *priv = (struct r8180_priv *)ieee80211_priv_rtl7(dev);
3043 +
3044 int len = 0;
3045 -
3046 +
3047 len += snprintf(page + len, count - len,
3048 "RX packets: %lu\n"
3049 "RX urb status error: %lu\n"
3050 @@ -402,21 +414,22 @@
3051 priv->stats.rxok,
3052 priv->stats.rxstaterr,
3053 priv->stats.rxurberr);
3054 -
3055 +
3056 *eof = 1;
3057 return len;
3058 -}
3059 -
3060 +}
3061  
3062 +#if WIRELESS_EXT < 17
3063 static struct iw_statistics *r8180_get_wireless_stats(struct net_device *dev)
3064 {
3065 - struct r8180_priv *priv = ieee80211_priv(dev);
3066 + struct r8180_priv *priv = ieee80211_priv_rtl7(dev);
3067  
3068 return &priv->wstats;
3069 }
3070 +#endif
3071  
3072 void rtl8180_proc_module_init(void)
3073 -{
3074 +{
3075 DMESG("Initializing proc filesystem");
3076 rtl8180_proc=create_proc_entry(RTL8187_MODULE_NAME, S_IFDIR, proc_net);
3077 }
3078 @@ -430,7 +443,7 @@
3079  
3080 void rtl8180_proc_remove_one(struct net_device *dev)
3081 {
3082 - struct r8180_priv *priv = (struct r8180_priv *)ieee80211_priv(dev);
3083 + struct r8180_priv *priv = (struct r8180_priv *)ieee80211_priv_rtl7(dev);
3084 if (priv->dir_dev) {
3085 // remove_proc_entry("stats-hw", priv->dir_dev);
3086 remove_proc_entry("stats-tx", priv->dir_dev);
3087 @@ -447,9 +460,9 @@
3088 void rtl8180_proc_init_one(struct net_device *dev)
3089 {
3090 struct proc_dir_entry *e;
3091 - struct r8180_priv *priv = (struct r8180_priv *)ieee80211_priv(dev);
3092 - priv->dir_dev = create_proc_entry(dev->name,
3093 - S_IFDIR | S_IRUGO | S_IXUGO,
3094 + struct r8180_priv *priv = (struct r8180_priv *)ieee80211_priv_rtl7(dev);
3095 + priv->dir_dev = create_proc_entry(dev->name,
3096 + S_IFDIR | S_IRUGO | S_IXUGO,
3097 rtl8180_proc);
3098 if (!priv->dir_dev) {
3099 DMESGE("Unable to initialize /proc/net/rtl8187/%s\n",
3100 @@ -459,7 +472,7 @@
3101 #if 0
3102 e = create_proc_read_entry("stats-hw", S_IFREG | S_IRUGO,
3103 priv->dir_dev, proc_get_stats_hw, dev);
3104 -
3105 +
3106 if (!e) {
3107 DMESGE("Unable to initialize "
3108 "/proc/net/rtl8187/%s/stats-hw\n",
3109 @@ -468,17 +481,17 @@
3110 #endif
3111 e = create_proc_read_entry("stats-rx", S_IFREG | S_IRUGO,
3112 priv->dir_dev, proc_get_stats_rx, dev);
3113 -
3114 +
3115 if (!e) {
3116 DMESGE("Unable to initialize "
3117 "/proc/net/rtl8187/%s/stats-rx\n",
3118 dev->name);
3119 }
3120 -
3121 -
3122 +
3123 +
3124 e = create_proc_read_entry("stats-tx", S_IFREG | S_IRUGO,
3125 priv->dir_dev, proc_get_stats_tx, dev);
3126 -
3127 +
3128 if (!e) {
3129 DMESGE("Unable to initialize "
3130 "/proc/net/rtl8187/%s/stats-tx\n",
3131 @@ -487,27 +500,27 @@
3132 #if 0
3133 e = create_proc_read_entry("stats-ieee", S_IFREG | S_IRUGO,
3134 priv->dir_dev, proc_get_stats_ieee, dev);
3135 -
3136 +
3137 if (!e) {
3138 DMESGE("Unable to initialize "
3139 "/proc/net/rtl8187/%s/stats-ieee\n",
3140 dev->name);
3141 }
3142 -
3143 -
3144 +
3145 +
3146 e = create_proc_read_entry("stats-ap", S_IFREG | S_IRUGO,
3147 priv->dir_dev, proc_get_stats_ap, dev);
3148 -
3149 +
3150 if (!e) {
3151 DMESGE("Unable to initialize "
3152 "/proc/net/rtl8187/%s/stats-ap\n",
3153 dev->name);
3154 }
3155 #endif
3156 -
3157 +
3158 e = create_proc_read_entry("registers", S_IFREG | S_IRUGO,
3159 priv->dir_dev, proc_get_registers, dev);
3160 -
3161 +
3162 if (!e) {
3163 DMESGE("Unable to initialize "
3164 "/proc/net/rtl8187/%s/registers\n",
3165 @@ -523,14 +536,14 @@
3166 {
3167 int i;
3168 u8 *buf =(u8*)buffer;
3169 -
3170 +
3171 printk("ASCII BUFFER DUMP (len: %x):\n",len);
3172 -
3173 +
3174 for(i=0;i<len;i++)
3175 printk("%c",buf[i]);
3176 -
3177 +
3178 printk("\nBINARY BUFFER DUMP (len: %x):\n",len);
3179 -
3180 +
3181 for(i=0;i<len;i++)
3182 printk("%x",buf[i]);
3183  
3184 @@ -539,17 +552,17 @@
3185  
3186 short check_nic_enought_desc(struct net_device *dev, priority_t priority)
3187 {
3188 - struct r8180_priv *priv = ieee80211_priv(dev);
3189 -
3190 - int used = atomic_read((priority == NORM_PRIORITY) ?
3191 + struct r8180_priv *priv = ieee80211_priv_rtl7(dev);
3192 +
3193 + int used = atomic_read((priority == NORM_PRIORITY) ?
3194 &priv->tx_np_pending : &priv->tx_lp_pending);
3195 -
3196 +
3197 return (used < MAX_TX_URB);
3198 }
3199  
3200 void tx_timeout(struct net_device *dev)
3201 {
3202 - struct r8180_priv *priv = ieee80211_priv(dev);
3203 + struct r8180_priv *priv = ieee80211_priv_rtl7(dev);
3204 //rtl8180_commit(dev);
3205 schedule_work(&priv->reset_wq);
3206 //DMESG("TXTIMEOUT");
3207 @@ -561,7 +574,20 @@
3208 {
3209 int i;
3210 for(i=0; i<63; i++)
3211 - DMESG("EEPROM addr %x : %x", i, eprom_read(dev,i));
3212 + DMESG("EEPROM addr %02X : %04X", i, eprom_read(dev,i));
3213 +}
3214 +
3215 +/* this is only for debug */
3216 +void dump_tx_power(struct net_device *dev)
3217 +{
3218 + struct r8180_priv *priv = ieee80211_priv_rtl7(dev);
3219 + int i;
3220 + DMESG("CCK TX-Power (b-mode):");
3221 + for(i=1; i<=14; i++)
3222 + DMESG("Channel %d: %d", i, priv->chtxpwr[i]);
3223 + DMESG("OFDM TX-Power (g-mode):");
3224 + for(i=1; i<=14; i++)
3225 + DMESG("Channel %d: %d", i, priv->chtxpwr_ofdm[i]);
3226 }
3227  
3228 /* this is only for debug */
3229 @@ -570,14 +596,14 @@
3230 int i;
3231 int n;
3232 int max=0xff;
3233 -
3234 - DMESG("Dumping NIC register map");
3235 -
3236 +
3237 + DMESG("Dumping NIC register map");
3238 +
3239 for(n=0;n<=max;)
3240 {
3241 - printk( "\nD: %2x> ", n);
3242 + printk( "\nD: %02X> ", n);
3243 for(i=0;i<16 && n<=max;i++,n++)
3244 - printk("%2x ",read_nic_byte(dev,n));
3245 + printk("%02X ",read_nic_byte(dev,n));
3246 }
3247 printk("\n");
3248 }
3249 @@ -589,11 +615,11 @@
3250  
3251 void rtl8180_irq_enable(struct net_device *dev)
3252 {
3253 - struct r8180_priv *priv = (struct r8180_priv *)ieee80211_priv(dev);
3254 + struct r8180_priv *priv = (struct r8180_priv *)ieee80211_priv_rtl7(dev);
3255 //priv->irq_enabled = 1;
3256 /*
3257 - write_nic_word(dev,INTA_MASK,INTA_RXOK | INTA_RXDESCERR | INTA_RXOVERFLOW |\
3258 - INTA_TXOVERFLOW | INTA_HIPRIORITYDESCERR | INTA_HIPRIORITYDESCOK |\
3259 + write_nic_word(dev,INTA_MASK,INTA_RXOK | INTA_RXDESCERR | INTA_RXOVERFLOW |\
3260 + INTA_TXOVERFLOW | INTA_HIPRIORITYDESCERR | INTA_HIPRIORITYDESCOK |\
3261 INTA_NORMPRIORITYDESCERR | INTA_NORMPRIORITYDESCOK |\
3262 INTA_LOWPRIORITYDESCERR | INTA_LOWPRIORITYDESCOK | INTA_TIMEOUT);
3263 */
3264 @@ -603,7 +629,7 @@
3265  
3266 void rtl8180_irq_disable(struct net_device *dev)
3267 {
3268 -// struct r8180_priv *priv = (struct r8180_priv *)ieee80211_priv(dev);
3269 +// struct r8180_priv *priv = (struct r8180_priv *)ieee80211_priv_rtl7(dev);
3270  
3271 write_nic_word(dev,INTA_MASK,0);
3272 force_pci_posting(dev);
3273 @@ -625,115 +651,119 @@
3274  
3275 void rtl8180_update_msr(struct net_device *dev)
3276 {
3277 - struct r8180_priv *priv = ieee80211_priv(dev);
3278 + struct r8180_priv *priv = ieee80211_priv_rtl7(dev);
3279 u8 msr;
3280 -
3281 +
3282 msr = read_nic_byte(dev, MSR);
3283 msr &= ~ MSR_LINK_MASK;
3284 -
3285 +
3286 /* do not change in link_state != WLAN_LINK_ASSOCIATED.
3287 - * msr must be updated if the state is ASSOCIATING.
3288 + * msr must be updated if the state is ASSOCIATING.
3289 * this is intentional and make sense for ad-hoc and
3290 * master (see the create BSS/IBSS func)
3291 */
3292 - if (priv->ieee80211->state == IEEE80211_LINKED){
3293 -
3294 + if (priv->ieee80211->state == IEEE80211_LINKED){
3295 +
3296 if (priv->ieee80211->iw_mode == IW_MODE_INFRA)
3297 msr |= (MSR_LINK_MANAGED<<MSR_LINK_SHIFT);
3298 else if (priv->ieee80211->iw_mode == IW_MODE_ADHOC)
3299 msr |= (MSR_LINK_ADHOC<<MSR_LINK_SHIFT);
3300 else if (priv->ieee80211->iw_mode == IW_MODE_MASTER)
3301 msr |= (MSR_LINK_MASTER<<MSR_LINK_SHIFT);
3302 -
3303 +
3304 }else
3305 msr |= (MSR_LINK_NONE<<MSR_LINK_SHIFT);
3306 -
3307 +
3308 write_nic_byte(dev, MSR, msr);
3309 }
3310  
3311 void rtl8180_set_chan(struct net_device *dev,short ch)
3312 {
3313 - struct r8180_priv *priv = (struct r8180_priv *)ieee80211_priv(dev);
3314 + struct r8180_priv *priv = (struct r8180_priv *)ieee80211_priv_rtl7(dev);
3315 u32 tx;
3316 priv->chan=ch;
3317 #if 0
3318 - if(priv->ieee80211->iw_mode == IW_MODE_ADHOC ||
3319 + if(priv->ieee80211->iw_mode == IW_MODE_ADHOC ||
3320 priv->ieee80211->iw_mode == IW_MODE_MASTER){
3321 -
3322 - priv->ieee80211->link_state = WLAN_LINK_ASSOCIATED;
3323 +
3324 + priv->ieee80211->link_state = WLAN_LINK_ASSOCIATED;
3325 priv->ieee80211->master_chan = ch;
3326 - rtl8180_update_beacon_ch(dev);
3327 + rtl8180_update_beacon_ch(dev);
3328 }
3329 #endif
3330 -
3331 +
3332 /* this hack should avoid frame TX during channel setting*/
3333 tx = read_nic_dword(dev,TX_CONF);
3334 tx &= ~TX_LOOPBACK_MASK;
3335  
3336 -#ifndef LOOP_TEST
3337 +#ifndef LOOP_TEST
3338 write_nic_dword(dev,TX_CONF, tx |( TX_LOOPBACK_MAC<<TX_LOOPBACK_SHIFT));
3339 -
3340 priv->rf_set_chan(dev,priv->chan);
3341 mdelay(10);
3342 - write_nic_dword(dev,TX_CONF,tx | (TX_LOOPBACK_NONE<<TX_LOOPBACK_SHIFT));
3343 + write_nic_dword(dev,TX_CONF,tx | (TX_LOOPBACK_NONE<<TX_LOOPBACK_SHIFT));
3344 #endif
3345 }
3346 +
3347 +#if (LINUX_VERSION_CODE < KERNEL_VERSION(2,6,19))
3348 void rtl8187_rx_isr(struct urb *rx_urb, struct pt_regs *regs);
3349 +#else
3350 +void rtl8187_rx_isr(struct urb *rx_urb);
3351 +#endif
3352  
3353  
3354 void rtl8187_rx_urbsubmit(struct net_device *dev, struct urb* rx_urb)
3355 {
3356 - struct r8180_priv *priv = (struct r8180_priv *)ieee80211_priv(dev);
3357 + struct r8180_priv *priv = (struct r8180_priv *)ieee80211_priv_rtl7(dev);
3358 int err;
3359 -
3360 +
3361 // u8 *rx;
3362 -
3363 +
3364 //DMESG("starting RX");
3365 /*rx = kmalloc(RX_URB_SIZE*sizeof(u8),GFP_ATOMIC);
3366 - if(!rx){
3367 + if(!rx){
3368 DMESGE("unable to allocate RX buffer");
3369 return;
3370 }*/
3371 -
3372 +
3373 usb_fill_bulk_urb(rx_urb,priv->udev,
3374 usb_rcvbulkpipe(priv->udev,0x81), rx_urb->transfer_buffer,
3375 RX_URB_SIZE,rtl8187_rx_isr,dev);
3376 - err = usb_submit_urb(rx_urb, GFP_ATOMIC);
3377 + err = usb_submit_urb(rx_urb, GFP_ATOMIC);
3378 if(err && err != -EPERM){
3379 DMESGE("cannot submit RX command. URB_STATUS %x",rx_urb->status);
3380 -
3381 +
3382 }
3383 -
3384 +
3385 }
3386  
3387  
3388 void rtl8187_rx_initiate(struct net_device *dev)
3389 {
3390 int i;
3391 - struct r8180_priv *priv = (struct r8180_priv *)ieee80211_priv(dev);
3392 -
3393 + struct r8180_priv *priv = (struct r8180_priv *)ieee80211_priv_rtl7(dev);
3394 +
3395 if(!priv->rx_urb)
3396 DMESGE("Cannot intiate RX urb mechanism");
3397 - for(i=0;i<MAX_RX_URB;i++) // RX_MAX_URB is 1
3398 + for(i=0;i<MAX_RX_URB;i++) // RX_MAX_URB is 1
3399 rtl8187_rx_urbsubmit(dev,priv->rx_urb[i]);
3400 -
3401 +
3402 }
3403  
3404 void rtl8187_set_rxconf(struct net_device *dev)
3405 {
3406 - struct r8180_priv *priv = (struct r8180_priv *)ieee80211_priv(dev);
3407 + struct r8180_priv *priv = (struct r8180_priv *)ieee80211_priv_rtl7(dev);
3408 u32 rxconf;
3409 -
3410 +
3411 rxconf=read_nic_dword(dev,RX_CONF);
3412 rxconf = rxconf &~ MAC_FILTER_MASK;
3413 rxconf = rxconf | (1<<ACCEPT_MNG_FRAME_SHIFT);
3414 rxconf = rxconf | (1<<ACCEPT_DATA_FRAME_SHIFT);
3415 rxconf = rxconf | (1<<ACCEPT_BCAST_FRAME_SHIFT);
3416 rxconf = rxconf | (1<<ACCEPT_MCAST_FRAME_SHIFT);
3417 - rxconf = rxconf | (1<<ACCEPT_CTL_FRAME_SHIFT);
3418 + rxconf = rxconf | (1<<ACCEPT_CTL_FRAME_SHIFT);
3419  
3420 if (dev->flags & IFF_PROMISC) DMESG ("NIC in promisc mode");
3421 -
3422 +
3423 if(priv->ieee80211->iw_mode == IW_MODE_MONITOR || \
3424 dev->flags & IFF_PROMISC){
3425 rxconf = rxconf | (1<<ACCEPT_ALLMAC_FRAME_SHIFT);
3426 @@ -741,40 +771,40 @@
3427 rxconf = rxconf | (1<<ACCEPT_NICMAC_FRAME_SHIFT);
3428 rxconf = rxconf | (1<<RX_CHECK_BSSID_SHIFT);
3429 }
3430 -
3431 +
3432 /*if(priv->ieee80211->iw_mode == IW_MODE_MASTER){
3433 rxconf = rxconf | (1<<ACCEPT_ALLMAC_FRAME_SHIFT);
3434 rxconf = rxconf | (1<<RX_CHECK_BSSID_SHIFT);
3435 }*/
3436 -
3437 +
3438 if(priv->ieee80211->iw_mode == IW_MODE_MONITOR){
3439 rxconf = rxconf | (1<<ACCEPT_ICVERR_FRAME_SHIFT);
3440 rxconf = rxconf | (1<<ACCEPT_PWR_FRAME_SHIFT);
3441 }
3442 -
3443 +
3444 if( priv->crcmon == 1 && priv->ieee80211->iw_mode == IW_MODE_MONITOR)
3445 rxconf = rxconf | (1<<ACCEPT_CRCERR_FRAME_SHIFT);
3446 -
3447 -
3448 +
3449 +
3450 rxconf = rxconf &~ RX_FIFO_THRESHOLD_MASK;
3451 rxconf = rxconf | (RX_FIFO_THRESHOLD_NONE<<RX_FIFO_THRESHOLD_SHIFT);
3452 -
3453 -
3454 +
3455 +
3456 rxconf = rxconf | (1<<RX_AUTORESETPHY_SHIFT);
3457 -
3458 +
3459 rxconf = rxconf &~ MAX_RX_DMA_MASK;
3460 rxconf = rxconf | (MAX_RX_DMA_2048<<MAX_RX_DMA_SHIFT);
3461 -
3462 +
3463 rxconf = rxconf | RCR_ONLYERLPKT;
3464 -
3465 +
3466 // rxconf = rxconf &~ RCR_CS_MASK;
3467 // rxconf = rxconf | (1<<RCR_CS_SHIFT);
3468  
3469 - write_nic_dword(dev, RX_CONF, rxconf);
3470 -
3471 + write_nic_dword(dev, RX_CONF, rxconf);
3472 +
3473 // V rtl suggested V //
3474 // write_nic_dword(dev, RX_CONF, 0x901ce70e);
3475 -
3476 +
3477 //fix_rx_fifo(dev);
3478 // //set_nic_rxring(dev);
3479 #ifdef DEBUG_RX
3480 @@ -785,23 +815,23 @@
3481 void rtl8180_rx_enable(struct net_device *dev)
3482 {
3483 u8 cmd;
3484 -
3485 -
3486 +
3487 +
3488 rtl8187_rx_initiate(dev);
3489  
3490 - rtl8187_set_rxconf(dev);
3491 + rtl8187_set_rxconf(dev);
3492  
3493 cmd=read_nic_byte(dev,CMD);
3494 write_nic_byte(dev,CMD,cmd | (1<<CMD_RX_ENABLE_SHIFT));
3495 #if 0
3496 - /* In rtl8139 driver seems that DMA threshold has to be written
3497 - * after enabling RX, so we rewrite RX_CONFIG register
3498 + /* In rtl8139 driver seems that DMA threshold has to be written
3499 + * after enabling RX, so we rewrite RX_CONFIG register
3500 */
3501 //mdelay(100);
3502 - write_nic_dword(dev, RX_CONF, rxconf);
3503 -
3504 + write_nic_dword(dev, RX_CONF, rxconf);
3505 +
3506 #endif
3507 -
3508 +
3509 }
3510  
3511  
3512 @@ -810,37 +840,37 @@
3513 u8 cmd;
3514 u8 byte;
3515 u32 txconf;
3516 - struct r8180_priv *priv = (struct r8180_priv *)ieee80211_priv(dev);
3517 -
3518 + struct r8180_priv *priv = (struct r8180_priv *)ieee80211_priv_rtl7(dev);
3519 +
3520 byte = read_nic_byte(dev,CW_CONF);
3521 byte &= ~(1<<CW_CONF_PERPACKET_CW_SHIFT);
3522 byte &= ~(1<<CW_CONF_PERPACKET_RETRY_SHIFT);
3523 write_nic_byte(dev, CW_CONF, byte);
3524 -
3525 +
3526 byte = read_nic_byte(dev, TX_AGC_CTL);
3527 byte &= ~(1<<TX_AGC_CTL_PERPACKET_GAIN_SHIFT);
3528 byte &= ~(1<<TX_AGC_CTL_PERPACKET_ANTSEL_SHIFT);
3529 byte &= ~(1<<TX_AGC_CTL_FEEDBACK_ANT);
3530 write_nic_byte(dev, TX_AGC_CTL, byte);
3531 -
3532 +
3533 txconf= read_nic_dword(dev,TX_CONF);
3534 -
3535 +
3536 #if 0
3537 if(priv->card_8185){
3538 -
3539 +
3540 txconf = txconf &~ (1<<TCR_PROBE_NOTIMESTAMP_SHIFT);
3541 -
3542 +
3543 }else{
3544 -
3545 - if(priv->ieee80211->hw_seq)
3546 +
3547 + if(priv->ieee80211->hw_seq)
3548 txconf= txconf &~ (1<<TX_CONF_HEADER_AUTOICREMENT_SHIFT);
3549 - else
3550 + else
3551 txconf= txconf | (1<<TX_CONF_HEADER_AUTOICREMENT_SHIFT);
3552 }
3553 #endif
3554  
3555 txconf = txconf &~ TX_LOOPBACK_MASK;
3556 -
3557 +
3558 #ifndef LOOP_TEST
3559 txconf = txconf | (TX_LOOPBACK_NONE<<TX_LOOPBACK_SHIFT);
3560 #else
3561 @@ -848,23 +878,26 @@
3562 #endif
3563 txconf = txconf &~ TCR_DPRETRY_MASK;
3564 txconf = txconf &~ TCR_RTSRETRY_MASK;
3565 -
3566 - txconf = txconf | (priv->retry_data<<TX_DPRETRY_SHIFT); // long
3567 - txconf = txconf | (priv->retry_rts<<TX_RTSRETRY_SHIFT); // short
3568 -
3569 +
3570 + if(priv->ieee80211->iw_mode != IW_MODE_MONITOR)
3571 + {
3572 + txconf = txconf | (priv->retry_data<<TX_DPRETRY_SHIFT); // long
3573 + txconf = txconf | (priv->retry_rts<<TX_RTSRETRY_SHIFT); // short
3574 + }
3575 +
3576 txconf = txconf &~ (1<<TX_NOCRC_SHIFT);
3577 -
3578 +
3579 txconf = txconf &~ TCR_MXDMA_MASK;
3580 txconf = txconf | (TCR_MXDMA_2048<<TCR_MXDMA_SHIFT);
3581 -
3582 +
3583 txconf = txconf | TCR_CWMIN;
3584 txconf = txconf | TCR_DISCW;
3585 txconf = txconf &~ TCR_SWPLCPLEN;
3586 -
3587 +
3588 txconf=txconf | (1<<TX_NOICV_SHIFT);
3589 -
3590 +
3591 write_nic_dword(dev,TX_CONF,txconf);
3592 -
3593 +
3594 // V RTL suggested V //
3595 // write_nic_dword(dev,TX_CONF,0x00e00707);
3596  
3597 @@ -872,9 +905,9 @@
3598 #ifdef DEBUG_TX
3599 DMESG("txconf: %x %x",txconf,read_nic_dword(dev,TX_CONF));
3600 #endif
3601 -
3602 +
3603 cmd=read_nic_byte(dev,CMD);
3604 - write_nic_byte(dev,CMD,cmd | (1<<CMD_TX_ENABLE_SHIFT));
3605 + write_nic_byte(dev,CMD,cmd | (1<<CMD_TX_ENABLE_SHIFT));
3606  
3607 // mdelay(100);
3608 //write_nic_dword(dev,TX_CONF,txconf);
3609 @@ -889,18 +922,18 @@
3610 #if 0
3611 void rtl8180_beacon_tx_enable(struct net_device *dev)
3612 {
3613 - struct r8180_priv *priv = (struct r8180_priv *)ieee80211_priv(dev);
3614 + struct r8180_priv *priv = (struct r8180_priv *)ieee80211_priv_rtl7(dev);
3615 priv->dma_poll_mask &=~(1<<TX_DMA_STOP_BEACON_SHIFT);
3616 rtl8180_set_mode(dev,EPROM_CMD_CONFIG);
3617 - write_nic_byte(dev,TX_DMA_POLLING,priv->dma_poll_mask);
3618 + write_nic_byte(dev,TX_DMA_POLLING,priv->dma_poll_mask);
3619 rtl8180_set_mode(dev,EPROM_CMD_NORMAL);
3620 }
3621  
3622  
3623 void rtl8180_
3624 -_disable(struct net_device *dev)
3625 +_disable(struct net_device *dev)
3626 {
3627 - struct r8180_priv *priv = (struct r8180_priv *)ieee80211_priv(dev);
3628 + struct r8180_priv *priv = (struct r8180_priv *)ieee80211_priv_rtl7(dev);
3629 priv->dma_poll_mask |= (1<<TX_DMA_STOP_BEACON_SHIFT);
3630 rtl8180_set_mode(dev,EPROM_CMD_CONFIG);
3631 write_nic_byte(dev,TX_DMA_POLLING,priv->dma_poll_mask);
3632 @@ -914,8 +947,8 @@
3633 {
3634 u8 cmd;
3635 int i;
3636 - struct r8180_priv *priv = ieee80211_priv(dev);
3637 -
3638 + struct r8180_priv *priv = ieee80211_priv_rtl7(dev);
3639 +
3640 cmd=read_nic_byte(dev,CMD);
3641 write_nic_byte(dev, CMD, cmd &~ \
3642 ((1<<CMD_RX_ENABLE_SHIFT)|(1<<CMD_TX_ENABLE_SHIFT)));
3643 @@ -926,9 +959,9 @@
3644 usb_kill_urb(priv->rx_urb[i]);
3645 }
3646 /*while (read_nic_byte(dev,CMD) & (1<<CMD_RX_ENABLE_SHIFT))
3647 - udelay(10);
3648 + udelay(10);
3649 */
3650 -
3651 +
3652 // if(!priv->rx_skb_complete)
3653 // dev_kfree_skb_any(priv->rx_skb);
3654 }
3655 @@ -939,14 +972,14 @@
3656 #if 0
3657 int i;
3658 u32 *tmp;
3659 - struct r8180_priv *priv = (struct r8180_priv *)ieee80211_priv(dev);
3660 -
3661 + struct r8180_priv *priv = (struct r8180_priv *)ieee80211_priv_rtl7(dev);
3662 +
3663 priv->txbeaconring = (u32*)pci_alloc_consistent(priv->pdev,
3664 - sizeof(u32)*8*count,
3665 + sizeof(u32)*8*count,
3666 &priv->txbeaconringdma);
3667 if (!priv->txbeaconring) return -1;
3668 for (tmp=priv->txbeaconring,i=0;i<count;i++){
3669 - *tmp = *tmp &~ (1<<31); // descriptor empty, owned by the drv
3670 + *tmp = *tmp &~ (1<<31); // descriptor empty, owned by the drv
3671 /*
3672 *(tmp+2) = (u32)dma_tmp;
3673 *(tmp+3) = bufsize;
3674 @@ -955,7 +988,7 @@
3675 *(tmp+4) = (u32)priv->txbeaconringdma+((i+1)*8*4);
3676 else
3677 *(tmp+4) = (u32)priv->txbeaconringdma;
3678 -
3679 +
3680 tmp=tmp+8;
3681 }
3682 #endif
3683 @@ -965,15 +998,15 @@
3684  
3685 void rtl8180_reset(struct net_device *dev)
3686 {
3687 -
3688 +
3689 u8 cr;
3690 -
3691 +
3692 /* make sure the analog power is on before
3693 * reset, otherwise reset may fail
3694 */
3695 rtl8180_set_anaparam(dev, RTL8225_ANAPARAM_ON);
3696 rtl8185_set_anaparam2(dev, RTL8225_ANAPARAM2_ON);
3697 -
3698 +
3699 rtl8180_irq_disable(dev);
3700  
3701 mdelay(200);
3702 @@ -981,19 +1014,19 @@
3703 write_nic_byte_E(dev,0x18,0x11);
3704 write_nic_byte_E(dev,0x18,0x00);
3705 mdelay(200);
3706 -
3707 +
3708 cr=read_nic_byte(dev,CMD);
3709 cr = cr & 2;
3710 cr = cr | (1<<CMD_RST_SHIFT);
3711 write_nic_byte(dev,CMD,cr);
3712 -
3713 +
3714 force_pci_posting(dev);
3715 -
3716 +
3717 mdelay(200);
3718 -
3719 - if(read_nic_byte(dev,CMD) & (1<<CMD_RST_SHIFT))
3720 +
3721 + if(read_nic_byte(dev,CMD) & (1<<CMD_RST_SHIFT))
3722 DMESGW("Card reset timeout!");
3723 - else
3724 + else
3725 DMESG("Card successfully reset");
3726  
3727 rtl8180_set_mode(dev,EPROM_CMD_LOAD);
3728 @@ -1005,13 +1038,13 @@
3729 */
3730 rtl8180_set_anaparam(dev, RTL8225_ANAPARAM_ON);
3731 rtl8185_set_anaparam2(dev, RTL8225_ANAPARAM2_ON);
3732 -
3733 +
3734 }
3735  
3736 inline u16 ieeerate2rtlrate(int rate)
3737 {
3738 switch(rate){
3739 - case 10:
3740 + case 10:
3741 return 0;
3742 case 20:
3743 return 1;
3744 @@ -1037,32 +1070,42 @@
3745 return 11;
3746 default:
3747 return 3;
3748 -
3749 +
3750 }
3751 }
3752 static u16 rtl_rate[] = {10,20,55,110,60,90,120,180,240,360,480,540};
3753 inline u16 rtl8180_rate2rate(short rate)
3754 {
3755 if (rate >11) return 0;
3756 - return rtl_rate[rate];
3757 + return rtl_rate[rate];
3758 +}
3759 +
3760 +inline u8 rtl8180_IsWirelessBMode(u16 rate)
3761 +{
3762 + if( ((rate <= 110) && (rate != 60) && (rate != 90)) || (rate == 220) )
3763 + return 1;
3764 + else return 0;
3765 }
3766 -
3767  
3768 +#if (LINUX_VERSION_CODE < KERNEL_VERSION(2,6,19))
3769 void rtl8187_rx_isr(struct urb *rx_urb, struct pt_regs *regs)
3770 +#else
3771 +void rtl8187_rx_isr(struct urb *rx_urb)
3772 +#endif
3773 {
3774 struct net_device *dev = (struct net_device*)rx_urb->context;
3775 - struct r8180_priv *priv = ieee80211_priv(dev);
3776 + struct r8180_priv *priv = ieee80211_priv_rtl7(dev);
3777  
3778 priv->rxurb_task = rx_urb;
3779 // DMESGW("David: Rx tasklet start!");
3780 - tasklet_schedule(&priv->irq_rx_tasklet);
3781 + tasklet_schedule(&priv->irq_rx_tasklet);
3782 // DMESGW("=David: Rx tasklet finish!");
3783 }
3784  
3785 #if 0
3786 void rtl8180_tx_queues_stop(struct net_device *dev)
3787 {
3788 - //struct r8180_priv *priv = (struct r8180_priv *)ieee80211_priv(dev);
3789 + //struct r8180_priv *priv = (struct r8180_priv *)ieee80211_priv_rtl7(dev);
3790 u8 dma_poll_mask = (1<<TX_DMA_STOP_LOWPRIORITY_SHIFT);
3791 dma_poll_mask |= (1<<TX_DMA_STOP_HIPRIORITY_SHIFT);
3792 dma_poll_mask |= (1<<TX_DMA_STOP_NORMPRIORITY_SHIFT);
3793 @@ -1078,7 +1121,7 @@
3794 {
3795 //FIXME !!
3796 #if 0
3797 - struct r8180_priv *priv = (struct r8180_priv *)ieee80211_priv(dev);
3798 + struct r8180_priv *priv = (struct r8180_priv *)ieee80211_priv_rtl7(dev);
3799 priv->dma_poll_mask |= (1<<TX_DMA_STOP_LOWPRIORITY_SHIFT);
3800 rtl8180_set_mode(dev,EPROM_CMD_CONFIG);
3801 write_nic_byte(dev,TX_DMA_POLLING,priv->dma_poll_mask);
3802 @@ -1091,7 +1134,7 @@
3803 {
3804 // FIXME !!
3805 #if 0
3806 - struct r8180_priv *priv = (struct r8180_priv *)ieee80211_priv(dev);
3807 + struct r8180_priv *priv = (struct r8180_priv *)ieee80211_priv_rtl7(dev);
3808 priv->dma_poll_mask &= ~(1<<TX_DMA_STOP_LOWPRIORITY_SHIFT);
3809 rtl8180_set_mode(dev,EPROM_CMD_CONFIG);
3810 write_nic_byte(dev,TX_DMA_POLLING,priv->dma_poll_mask);
3811 @@ -1105,14 +1148,19 @@
3812 */
3813 void rtl8180_hard_data_xmit(struct sk_buff *skb, struct net_device *dev, int rate)
3814 {
3815 - struct r8180_priv *priv = (struct r8180_priv *)ieee80211_priv(dev);
3816 -
3817 - short morefrag = 0;
3818 + struct r8180_priv *priv = (struct r8180_priv *)ieee80211_priv_rtl7(dev);
3819 +
3820 + short morefrag = 0;
3821 unsigned long flags;
3822 struct ieee80211_hdr *h = (struct ieee80211_hdr *) skb->data;
3823  
3824 - if (le16_to_cpu(h->frame_ctl) & IEEE80211_FCTL_MOREFRAGS)
3825 - morefrag = 1;
3826 + if(priv->ieee80211->iw_mode != IW_MODE_MONITOR || priv->ieee80211->raw_tx != 1)
3827 + {
3828 + if (le16_to_cpu(h->frame_ctl) & IEEE80211_FCTL_MOREFRAGS)
3829 + {
3830 + morefrag = 1;
3831 + }
3832 + }
3833 // DMESG("%x %x", h->frame_ctl, h->seq_ctl);
3834 /*
3835 * This function doesn't require lock because we make
3836 @@ -1121,24 +1169,29 @@
3837 * the ieee stack, or from the try_wake_queue (again trought
3838 * the ieee stack.
3839 */
3840 - spin_lock_irqsave(&priv->tx_lock,flags);
3841 -
3842 - //DMESG("TX");
3843 - if (!check_nic_enought_desc(dev, LOW_PRIORITY)){
3844 - DMESG("Error: no TX slot ");
3845 - ieee80211_stop_queue(priv->ieee80211);
3846 - }
3847 -
3848 - rtl8180_tx(dev, (u32*)skb->data, skb->len, LOW_PRIORITY, morefrag,
3849 - ieeerate2rtlrate(rate));
3850 -
3851 - priv->stats.txdatapkt++;
3852 -
3853 - if (!check_nic_enought_desc(dev, LOW_PRIORITY))
3854 - ieee80211_stop_queue(priv->ieee80211);
3855 -
3856 - spin_unlock_irqrestore(&priv->tx_lock,flags);
3857 -
3858 +
3859 + if(priv->ieee80211->iw_mode != IW_MODE_MONITOR || priv->fasttx == 0)
3860 + {
3861 + spin_lock_irqsave(&priv->tx_lock,flags);
3862 + //DMESG("TX");
3863 + if (!check_nic_enought_desc(dev, LOW_PRIORITY)){
3864 + DMESG("Error: no TX slot ");
3865 + ieee80211_stop_queue_rtl7(priv->ieee80211);
3866 + }
3867 + rtl8180_tx(dev, (u32*)skb->data, skb->len, LOW_PRIORITY, morefrag,
3868 + ieeerate2rtlrate(rate));
3869 +
3870 + priv->stats.txdatapkt++;
3871 +
3872 + if (!check_nic_enought_desc(dev, LOW_PRIORITY))
3873 + ieee80211_stop_queue_rtl7(priv->ieee80211);
3874 + spin_unlock_irqrestore(&priv->tx_lock,flags);
3875 + }
3876 + else
3877 + {
3878 + rtl8180_tx_fast(dev, (u32*)skb->data, skb->len, ieeerate2rtlrate(rate));
3879 + }
3880 +
3881 }
3882 #if 0
3883 /* This is a rough attempt to TX a frame
3884 @@ -1148,12 +1201,12 @@
3885 */
3886 int rtl8180_hard_start_xmit(struct sk_buff *skb,struct net_device *dev)
3887 {
3888 - struct r8180_priv *priv = (struct r8180_priv *)ieee80211_priv(dev);
3889 + struct r8180_priv *priv = (struct r8180_priv *)ieee80211_priv_rtl7(dev);
3890 int ret;
3891 unsigned long flags;
3892 -
3893 +
3894 spin_lock_irqsave(&priv->tx_lock,flags);
3895 -
3896 +
3897 ret = rtl8180_tx(dev, (u32*)skb->data, skb->len, NORM_PRIORITY, 0,DEFAULT_BASICRATE);
3898 /*
3899 int i;
3900 @@ -1163,9 +1216,9 @@
3901 */
3902 priv->ieee80211->stats.tx_bytes+=skb->len;
3903 priv->ieee80211->stats.tx_packets++;
3904 -
3905 - spin_unlock_irqrestore(&priv->tx_lock,flags);
3906 -
3907 +
3908 + spin_unlock_irqrestore(&priv->tx_lock,flags);
3909 +
3910 dev_kfree_skb_any(skb);
3911 return ret;
3912 }
3913 @@ -1178,7 +1231,7 @@
3914 u16 duration;
3915 u16 drift;
3916 *ext=0;
3917 -
3918 +
3919 switch(rate){
3920 case 0://1mbps
3921 *ext=0;
3922 @@ -1187,7 +1240,7 @@
3923 if(drift ==0 ) break;
3924 duration++;
3925 break;
3926 -
3927 +
3928 case 1://2mbps
3929 *ext=0;
3930 duration = ((len+4)<<4) /0x4;
3931 @@ -1195,40 +1248,44 @@
3932 if(drift ==0 ) break;
3933 duration++;
3934 break;
3935 -
3936 +
3937 case 2: //5.5mbps
3938 *ext=0;
3939 duration = ((len+4)<<4) /0xb;
3940 drift = ((len+4)<<4) % 0xb;
3941 - if(drift ==0 )
3942 + if(drift ==0 )
3943 break;
3944 duration++;
3945 break;
3946 -
3947 +
3948 default:
3949 - case 3://11mbps
3950 + case 3://11mbps
3951 *ext=0;
3952 duration = ((len+4)<<4) /0x16;
3953 drift = ((len+4)<<4) % 0x16;
3954 - if(drift ==0 )
3955 + if(drift ==0 )
3956 break;
3957 duration++;
3958 - if(drift > 6)
3959 + if(drift > 6)
3960 break;
3961 *ext=1;
3962 break;
3963 }
3964 -
3965 +
3966 return duration;
3967 }
3968 #endif
3969  
3970 void rtl8180_try_wake_queue(struct net_device *dev, int pri);
3971  
3972 +#if (LINUX_VERSION_CODE < KERNEL_VERSION(2,6,19))
3973 void rtl8187_lptx_isr(struct urb *tx_urb, struct pt_regs *regs)
3974 +#else
3975 +void rtl8187_lptx_isr(struct urb *tx_urb)
3976 +#endif
3977 {
3978 struct net_device *dev = (struct net_device*)tx_urb->context;
3979 - struct r8180_priv *priv = ieee80211_priv(dev);
3980 + struct r8180_priv *priv = ieee80211_priv_rtl7(dev);
3981 if(tx_urb->status == 0)
3982 priv->stats.txlpokint++;
3983 else
3984 @@ -1239,6 +1296,15 @@
3985 rtl8180_try_wake_queue(dev,LOW_PRIORITY);
3986 }
3987  
3988 +#if (LINUX_VERSION_CODE < KERNEL_VERSION(2,6,19))
3989 +void rtl8187_lptx_isr_fast(struct urb *tx_urb, struct pt_regs *regs)
3990 +#else
3991 +void rtl8187_lptx_isr_fast(struct urb *tx_urb)
3992 +#endif
3993 +{
3994 + kfree(tx_urb->transfer_buffer);
3995 + usb_free_urb(tx_urb);
3996 +}
3997  
3998 void rtl8187_beacon_stop(struct net_device *dev)
3999 {
4000 @@ -1249,55 +1315,55 @@
4001 if ((msrm == (MSR_LINK_ADHOC<<MSR_LINK_SHIFT) ||
4002 (msrm == (MSR_LINK_MASTER<<MSR_LINK_SHIFT)))){
4003 write_nic_byte(dev, MSR, msr2 | MSR_LINK_NONE);
4004 - write_nic_byte(dev, MSR, msr);
4005 + write_nic_byte(dev, MSR, msr);
4006 }
4007 -
4008 -
4009 +
4010 +
4011 }
4012  
4013  
4014 void rtl8187_net_update(struct net_device *dev)
4015 {
4016  
4017 - struct r8180_priv *priv = ieee80211_priv(dev);
4018 + struct r8180_priv *priv = ieee80211_priv_rtl7(dev);
4019 struct ieee80211_network *net;
4020 net = & priv->ieee80211->current_network;
4021 -
4022 -
4023 +
4024 +
4025 write_nic_dword(dev,BSSID,((u32*)net->bssid)[0]);
4026 write_nic_word(dev,BSSID+4,((u16*)net->bssid)[2]);
4027 //for(i=0;i<ETH_ALEN;i++)
4028 // write_nic_byte(dev,BSSID+i,net->bssid[i]);
4029  
4030 rtl8180_update_msr(dev);
4031 -
4032 +
4033 // rtl8180_set_mode(dev,EPROM_CMD_CONFIG);
4034 write_nic_word(dev, AtimWnd, 2);
4035 - write_nic_word(dev, AtimtrItv, 100);
4036 + write_nic_word(dev, AtimtrItv, 100);
4037 write_nic_word(dev, BEACON_INTERVAL, net->beacon_interval);
4038 write_nic_word(dev, BcnIntTime, 100);
4039 -
4040 +
4041  
4042 }
4043  
4044 void rtl8187_beacon_tx(struct net_device *dev)
4045 {
4046  
4047 - struct r8180_priv *priv = ieee80211_priv(dev);
4048 + struct r8180_priv *priv = ieee80211_priv_rtl7(dev);
4049 struct sk_buff *skb;
4050 int i = 0;
4051 -
4052 +
4053 rtl8187_net_update(dev);
4054 -
4055 - skb = ieee80211_get_beacon(priv->ieee80211);
4056 -
4057 -
4058 - if(!skb){
4059 +
4060 + skb = ieee80211_get_beacon_rtl7(priv->ieee80211);
4061 +
4062 +
4063 + if(!skb){
4064 DMESG("not enought memory for allocating beacon");
4065 return;
4066 }
4067 -
4068 -#if 0
4069 +
4070 +#if 0
4071 while(MAX_TX_URB!=atomic_read(&priv->tx_np_pending)){
4072 msleep_interruptible_rtl(HZ/2);
4073 if(i++ > 20){
4074 @@ -1307,7 +1373,7 @@
4075 }
4076 #endif
4077 write_nic_byte(dev, BQREQ, read_nic_byte(dev, BQREQ) | (1<<7));
4078 -
4079 +
4080 i=0;
4081 //while(!read_nic_byte(dev,BQREQ & (1<<7)))
4082 while( (read_nic_byte(dev, BQREQ) & (1<<7)) == 0 )
4083 @@ -1318,16 +1384,20 @@
4084 return ;
4085 }
4086 }
4087 -
4088 +
4089 rtl8180_tx(dev, (u32*)skb->data, skb->len, NORM_PRIORITY,
4090 0, priv->ieee80211->basic_rate);
4091 -
4092 +
4093 }
4094  
4095 +#if (LINUX_VERSION_CODE < KERNEL_VERSION(2,6,19))
4096 void rtl8187_nptx_isr(struct urb *tx_urb, struct pt_regs *regs)
4097 +#else
4098 +void rtl8187_nptx_isr(struct urb *tx_urb)
4099 +#endif
4100 {
4101 struct net_device *dev = (struct net_device*)tx_urb->context;
4102 - struct r8180_priv *priv = ieee80211_priv(dev);
4103 + struct r8180_priv *priv = ieee80211_priv_rtl7(dev);
4104 if(tx_urb->status == 0)
4105 priv->stats.txnpokint++;
4106 else
4107 @@ -1339,10 +1409,10 @@
4108 }
4109  
4110  
4111 -/* This function do the real dirty work: it sends a TX command
4112 - * descriptor plus data URB
4113 +/* This function do the real dirty work: it sends a TX command
4114 + * descriptor plus data URB
4115 */
4116 -
4117 +
4118 short rtl8180_tx(struct net_device *dev, u32* txbuf, int len, priority_t priority,
4119 short morefrag, short rate)
4120 {
4121 @@ -1352,12 +1422,12 @@
4122 int pend ;
4123 int status;
4124 struct urb *tx_urb;
4125 - int urb_len;
4126 - struct r8180_priv *priv = ieee80211_priv(dev);
4127 + int urb_len;
4128 + struct r8180_priv *priv = ieee80211_priv_rtl7(dev);
4129 // int rate = ieeerate2rtlrate(priv->ieee80211->rate);
4130  
4131 - pend = atomic_read((priority == NORM_PRIORITY)? &priv->tx_np_pending : &priv->tx_lp_pending);
4132 - /* we are locked here so the two atomic_read and inc are executed without interleaves */
4133 + pend = atomic_read((priority == NORM_PRIORITY)? &priv->tx_np_pending : &priv->tx_lp_pending);
4134 + /* we are locked here so the two atomic_read and inc are executed without interleaves */
4135 if( pend > MAX_TX_URB){
4136 if(priority == NORM_PRIORITY)
4137 priv->stats.txnpdrop++;
4138 @@ -1365,52 +1435,38 @@
4139 priv->stats.txlpdrop++;
4140 return -1;
4141 }
4142 -
4143 -
4144 +
4145 //tx = kmalloc((len + 4*3), GFP_ATOMIC);
4146 urb_len = len + 4*3;
4147 if((0 == urb_len%64)||(0 == urb_len%512)) {
4148 - urb_len += 1;
4149 + urb_len += 1;
4150 }
4151 tx = kmalloc(urb_len, GFP_ATOMIC);
4152 if(!tx) return -ENOMEM;
4153 - //printk(KERN_WARNING "urb_len = %d\n", urb_len);
4154 + //printk(KERN_WARNING "urb_len = %d\n", urb_len);
4155 tx_urb = usb_alloc_urb(0,GFP_ATOMIC);
4156 -
4157 +
4158 if(!tx_urb){
4159 -
4160 +
4161 kfree(tx);
4162 return -ENOMEM;
4163 }
4164 -
4165 +
4166 memcpy(tx+3,txbuf,len);
4167 tx[0] = 0;
4168 tx[0] |= len & 0xfff;
4169 tx[0] |= (1<<15);
4170 -
4171 -// if(priv->shortpre)
4172 -// tx[0] |= (1<<16);
4173 -
4174 - //if(len > priv->rts_threshold){
4175 -// tx[0] |= (1<<23); //ENABLE RTS
4176 -// tx[0] |= (1<<18); //ENABLE CTS
4177 - //}
4178 +
4179 if(morefrag) tx[0] |= (1<<17);
4180 tx[0] |= (ieeerate2rtlrate(priv->ieee80211->basic_rate) << 19); /* RTS RATE - should be basic rate */
4181 tx[0] |= (rate << 24);
4182 tx[1] = 0;
4183 -
4184 -// duration = rtl8180_len2duration(len,
4185 -// rate,&ext);
4186 -// tx[1] |= (duration & 0x7fff) <<16;
4187 -// if(ext) tx[1] |= (1<<31);
4188  
4189 -
4190 // tx[2] = 0x303020;
4191 tx[2] = 3; // CW min
4192 tx[2] |= (7<<4); //CW max
4193 tx[2] |= (11<<8);//(priv->retry_data<<8); //retry lim
4194 -
4195 +
4196 // printk("%x\n%x\n",tx[0],tx[1]);
4197  
4198 #ifdef DUMP_TX
4199 @@ -1421,7 +1477,7 @@
4200 printk("---------------\n");
4201 #endif
4202  
4203 -
4204 +
4205 /* FIXME check what EP is for low/norm PRI */
4206 usb_fill_bulk_urb(tx_urb,priv->udev,
4207 usb_sndbulkpipe(priv->udev,(priority == LOW_PRIORITY) ? 2:3), tx,
4208 @@ -1438,54 +1494,97 @@
4209 }
4210 }
4211  
4212 -
4213 +/* This function do the real dirty work: it sends a TX command
4214 + * descriptor plus data URB (fast)
4215 + */
4216 +
4217 +short rtl8180_tx_fast(struct net_device *dev, u32* txbuf, int len, short rate)
4218 +{
4219 + u32 *tx;
4220 + int status;
4221 + struct urb *tx_urb;
4222 + int urb_len;
4223 + struct r8180_priv *priv = ieee80211_priv_rtl7(dev);
4224 +
4225 + urb_len = len + 4*3;
4226 + if((0 == urb_len%64)||(0 == urb_len%512)) {
4227 + urb_len += 1;
4228 + }
4229 + tx = kmalloc(urb_len, GFP_ATOMIC);
4230 + if(!tx) return -ENOMEM;
4231 +
4232 + tx_urb = usb_alloc_urb(0,GFP_ATOMIC);
4233 +
4234 + if(!tx_urb){
4235 + kfree(tx);
4236 + return -ENOMEM;
4237 + }
4238 +
4239 + memcpy(tx+3,txbuf,len);
4240 + tx[0] = (len & 0xfff) + 0x8000;
4241 + tx[0] |= (ieeerate2rtlrate(priv->ieee80211->basic_rate) << 19); /* RTS RATE - should be basic rate */
4242 + tx[0] |= (rate << 24);
4243 + tx[1] = 0;
4244 + tx[2] = 2931;
4245 +
4246 + /* FIXME check what EP is for low/norm PRI */
4247 + usb_fill_bulk_urb(tx_urb,priv->udev,
4248 + usb_sndbulkpipe(priv->udev, 2), tx, urb_len, rtl8187_lptx_isr_fast, dev);
4249 + status = usb_submit_urb(tx_urb, GFP_ATOMIC);
4250 + if (!status){
4251 + return 0;
4252 + }else{
4253 + return -1;
4254 + }
4255 +}
4256 +
4257  
4258 void rtl8180_irq_rx_tasklet(struct r8180_priv * priv);
4259  
4260  
4261 short rtl8187_usb_initendpoints(struct net_device *dev)
4262 {
4263 - struct r8180_priv *priv = ieee80211_priv(dev);
4264 + struct r8180_priv *priv = ieee80211_priv_rtl7(dev);
4265 int i;
4266 -
4267 +
4268 priv->rx_urb = (struct urb**) kmalloc (sizeof(struct urb*) * MAX_RX_URB, GFP_KERNEL);
4269 -
4270 +
4271 for(i=0;i<MAX_RX_URB;i++){
4272 priv->rx_urb[i] = usb_alloc_urb(0,GFP_KERNEL);
4273 - if(!priv->rx_urb[i])
4274 + if(!priv->rx_urb[i])
4275 goto destroy;
4276 -
4277 +
4278 priv->rx_urb[i]->transfer_buffer = kmalloc(RX_URB_SIZE, GFP_KERNEL);
4279 - if(!priv->rx_urb[i]->transfer_buffer)
4280 + if(!priv->rx_urb[i]->transfer_buffer)
4281 goto destroy1;
4282 -
4283 +
4284 priv->rx_urb[i]->transfer_buffer_length = RX_URB_SIZE;
4285 }
4286 -
4287 +
4288 return 0;
4289 -
4290 +
4291 destroy1:
4292 usb_free_urb(priv->rx_urb[i]);
4293 -
4294 +
4295 destroy:
4296 while (--i >= 0){
4297 kfree(priv->rx_urb[i]->transfer_buffer);
4298 usb_free_urb(priv->rx_urb[i]);
4299 }
4300 -
4301 +
4302 kfree(priv->rx_urb);
4303 -
4304 +
4305 priv->rx_urb = NULL;
4306 DMESGE("Endpoint Alloc Failure");
4307 return -ENOMEM;
4308 -
4309 +
4310 }
4311  
4312 void rtl8187_usb_deleteendpoints(struct net_device *dev)
4313 {
4314 - struct r8180_priv *priv = ieee80211_priv(dev);
4315 + struct r8180_priv *priv = ieee80211_priv_rtl7(dev);
4316 int i;
4317 -
4318 +
4319 if(priv->rx_urb){
4320 for(i=0;i<MAX_RX_URB;i++){
4321 usb_kill_urb(priv->rx_urb[i]);
4322 @@ -1494,9 +1593,9 @@
4323 }
4324 kfree(priv->rx_urb);
4325 priv->rx_urb = NULL;
4326 -
4327 +
4328 }
4329 -
4330 +
4331 }
4332  
4333  
4334 @@ -1505,16 +1604,16 @@
4335 int i;
4336 u16 word;
4337 int basic_rate,min_rr_rate,max_rr_rate;
4338 -
4339 -// struct r8180_priv *priv = ieee80211_priv(dev);
4340 -
4341 - //if (ieee80211_is_54g(priv->ieee80211->current_network) &&
4342 +
4343 +// struct r8180_priv *priv = ieee80211_priv_rtl7(dev);
4344 +
4345 + //if (ieee80211_is_54g_rtl7(priv->ieee80211->current_network) &&
4346 // priv->ieee80211->state == IEEE80211_LINKED){
4347 basic_rate = ieeerate2rtlrate(240);
4348 min_rr_rate = ieeerate2rtlrate(60);
4349 max_rr_rate = ieeerate2rtlrate(240);
4350 -
4351 -//
4352 +
4353 +//
4354 // }else{
4355 // basic_rate = ieeerate2rtlrate(20);
4356 // min_rr_rate = ieeerate2rtlrate(10);
4357 @@ -1526,21 +1625,21 @@
4358  
4359 word = read_nic_word(dev, BRSR);
4360 word &= ~BRSR_MBR_8185;
4361 -
4362 +
4363  
4364 for(i=0;i<=basic_rate;i++)
4365 word |= (1<<i);
4366  
4367 write_nic_word(dev, BRSR, word);
4368 - //DMESG("RR:%x BRSR: %x", read_nic_byte(dev,RESP_RATE), read_nic_word(dev,BRSR));
4369 + DMESG("RR:%x BRSR: %x", read_nic_byte(dev,RESP_RATE), read_nic_word(dev,BRSR));
4370 }
4371  
4372  
4373 void rtl8187_link_change(struct net_device *dev)
4374 {
4375 // int i;
4376 -
4377 - struct r8180_priv *priv = ieee80211_priv(dev);
4378 +
4379 + struct r8180_priv *priv = ieee80211_priv_rtl7(dev);
4380 //write_nic_word(dev, BintrItv, net->beacon_interval);
4381 rtl8187_net_update(dev);
4382 /*update timing params*/
4383 @@ -1553,24 +1652,24 @@
4384  
4385 short rtl8180_init(struct net_device *dev)
4386 {
4387 -
4388 - struct r8180_priv *priv = ieee80211_priv(dev);
4389 +
4390 + struct r8180_priv *priv = ieee80211_priv_rtl7(dev);
4391 int i, j;
4392 u16 word;
4393 - int ch;
4394 + int ch, chans;
4395 //u16 version;
4396 - //u8 hw_version;
4397 - //u8 config3;
4398 -
4399 + u8 hw_version;
4400 + u8 config3;
4401 +
4402 //FIXME: these constants are placed in a bad pleace.
4403  
4404 // priv->txbuffsize = 1024;
4405 // priv->txringcount = 32;
4406 // priv->rxbuffersize = 1024;
4407 -// priv->rxringcount = 32;
4408 +// priv->rxringcount = 32;
4409 // priv->txbeaconcount = 3;
4410 // priv->rx_skb_complete = 1;
4411 - //priv->txnp_pending.ispending=0;
4412 + //priv->txnp_pending.ispending=0;
4413 /* ^^ the SKB does not containt a partial RXed
4414 * packet (is empty)
4415 */
4416 @@ -1580,15 +1679,24 @@
4417 return -1;
4418 }
4419 ch=channels;
4420 + chans=0;
4421 + for (i=1; i<=14; i++) {
4422 + if( (u8)(ch & 0x01) ) chans++;
4423 + ch >>= 1;
4424 + }
4425 + DMESG("Enabling %d channels.", chans);
4426 + ch=channels;
4427 // set channels 1..14 allowed in given locale
4428 for (i=1; i<=14; i++) {
4429 (priv->ieee80211->channel_map)[i] = (u8)(ch & 0x01);
4430 ch >>= 1;
4431 }
4432 //memcpy(priv->stats,0,sizeof(struct Stats));
4433 -
4434 +
4435 //priv->irq_enabled=0;
4436 -
4437 +
4438 + priv->dev = dev;
4439 +
4440 // priv->stats.rxdmafail=0;
4441 priv->stats.txrdu=0;
4442 // priv->stats.rxrdu=0;
4443 @@ -1612,33 +1720,37 @@
4444 // priv->stats.txbeaconerr=0;
4445 priv->stats.txlperr=0;
4446 priv->stats.txlpokint=0;
4447 -
4448 +
4449 priv->ieee80211->iw_mode = IW_MODE_INFRA;
4450 -
4451 +
4452 priv->retry_rts = DEFAULT_RETRY_RTS;
4453 priv->retry_data = DEFAULT_RETRY_DATA;
4454 priv->ieee80211->rate = 110; //11 mbps
4455 priv->ieee80211->short_slot = 1;
4456 - priv->ieee80211->mode = IEEE_G;
4457 + priv->ieee80211->mode = IEEE_G|IEEE_B;
4458 priv->promisc = (dev->flags & IFF_PROMISC) ? 1:0;
4459 spin_lock_init(&priv->tx_lock);
4460 +#if LINUX_VERSION_CODE < KERNEL_VERSION(2,6,20)
4461 INIT_WORK(&priv->reset_wq,(void(*)(void*)) rtl8180_restart,dev);
4462 +#else
4463 + INIT_WORK(&priv->reset_wq, rtl8180_restart);
4464 +#endif
4465 sema_init(&priv->wx_sem,1);
4466 tasklet_init(&priv->irq_rx_tasklet,
4467 (void(*)(unsigned long))rtl8180_irq_rx_tasklet,
4468 (unsigned long)priv);
4469  
4470 - //priv->ieee80211->func =
4471 + //priv->ieee80211->func =
4472 // kmalloc(sizeof(struct ieee80211_helper_functions),GFP_KERNEL);
4473 //memset(priv->ieee80211->func, 0,
4474 // sizeof(struct ieee80211_helper_functions));
4475 - priv->ieee80211->current_network.beacon_interval = DEFAULT_BEACONINTERVAL;
4476 + priv->ieee80211->current_network.beacon_interval = DEFAULT_BEACONINTERVAL;
4477 priv->ieee80211->iw_mode = IW_MODE_INFRA;
4478 - priv->ieee80211->softmac_features = IEEE_SOFTMAC_SCAN |
4479 - IEEE_SOFTMAC_ASSOCIATE | IEEE_SOFTMAC_PROBERQ |
4480 + priv->ieee80211->softmac_features = IEEE_SOFTMAC_SCAN |
4481 + IEEE_SOFTMAC_ASSOCIATE | IEEE_SOFTMAC_PROBERQ |
4482 IEEE_SOFTMAC_PROBERS | IEEE_SOFTMAC_TX_QUEUE |
4483 /*IEEE_SOFTMAC_BEACONS | */IEEE_SOFTMAC_SINGLE_QUEUE;
4484 -
4485 +
4486 priv->ieee80211->active_scan = 1;
4487 priv->ieee80211->rate = 110; //11 mbps
4488 priv->ieee80211->modulation = IEEE80211_CCK_MODULATION | IEEE80211_OFDM_MODULATION;
4489 @@ -1655,51 +1767,51 @@
4490 priv->ieee80211->data_hard_resume = rtl8180_data_hard_resume;
4491 //priv->ieee80211->start_send_beacons = NULL;
4492 //priv->ieee80211->stop_send_beacons = NULL;
4493 -
4494 +
4495 priv->ieee80211->fts = DEFAULT_FRAG_THRESHOLD;
4496 -
4497 +
4498 priv->card_8185 = 2;
4499 priv->phy_ver = 2;
4500 priv->card_type = USB;
4501 -
4502 +
4503 #if 0
4504 hw_version =( read_nic_dword(dev, TCR) & TCR_HWVERID_MASK)>>TCR_HWVERID_SHIFT;
4505 -
4506 +
4507 switch (hw_version){
4508 case HW_VERID_R8185_ABC:
4509 - DMESG("MAC controller is a RTL8185 b/g");
4510 + DMESG("MAC controller is a RTL8185 b/g");
4511 priv->card_8185 = 1;
4512 /* you should not find a card with 8225 PHY ver < C*/
4513 priv->phy_ver = 2;
4514 break;
4515 -
4516 +
4517 case HW_VERID_R8185_D:
4518 - DMESG("MAC controller is a RTL8185 b/g (V. D)");
4519 + DMESG("MAC controller is a RTL8185 b/g (V. D)");
4520 priv->card_8185 = 2;
4521 /* you should not find a card with 8225 PHY ver < C*/
4522 priv->phy_ver = 2;
4523 break;
4524 -
4525 +
4526 case HW_VERID_R8180_ABCD:
4527 DMESG("MAC controller is a RTL8180");
4528 priv->card_8185 = 0;
4529 break;
4530 -
4531 +
4532 case HW_VERID_R8180_F:
4533 DMESG("MAC controller is a RTL8180 (v. F)");
4534 priv->card_8185 = 0;
4535 break;
4536 -
4537 +
4538 default:
4539 DMESGW("MAC chip not recognized: version %x. Assuming RTL8180",hw_version);
4540 priv->card_8185 = 0;
4541 break;
4542 }
4543 -
4544 -
4545 +
4546 +
4547 /* you should not found any 8185 Ver B Card */
4548 priv->card_8185_Bversion = 0;
4549 -
4550 +
4551 config3 = read_nic_byte(dev, CONFIG3);
4552 if(config3 & 0x8){
4553 priv->card_type = CARDBUS;
4554 @@ -1715,13 +1827,19 @@
4555 #endif
4556 priv->enable_gpio0 = 0;
4557  
4558 -
4559 +
4560 + hw_version =( read_nic_dword(dev, TCR) & TCR_HWVERID_MASK)>>TCR_HWVERID_SHIFT;
4561 + config3 = read_nic_byte(dev, CONFIG3);
4562 +
4563 + DMESG("MAC chip version: %02X", hw_version);
4564 + DMESG("Card type: %02X", config3);
4565 +
4566 /* commented out just because we already do
4567 this when resetting the card
4568 andrea 20050924
4569 */
4570 #if 0
4571 -
4572 +
4573 u8 txcr, txreg50;
4574 u32 txreg54, txreg60;
4575  
4576 @@ -1757,8 +1875,8 @@
4577 // DMESG("<<txcr:%x>>", txcr);
4578  
4579 #endif
4580 -
4581 - /*the eeprom type is stored in RCR register bit #6 */
4582 +
4583 + /*the eeprom type is stored in RCR register bit #6 */
4584 if (RCR_9356SEL & read_nic_dword(dev, RCR)){
4585 priv->epromtype=EPROM_93c56;
4586 DMESG("Reported EEPROM chip is a 93c56 (2Kbit)");
4587 @@ -1766,58 +1884,73 @@
4588 priv->epromtype=EPROM_93c46;
4589 DMESG("Reported EEPROM chip is a 93c46 (1Kbit)");
4590 }
4591 -
4592 +
4593 dev->get_stats = rtl8180_stats;
4594 -
4595 +
4596 dev->dev_addr[0]=eprom_read(dev,MAC_ADR) & 0xff;
4597 dev->dev_addr[1]=(eprom_read(dev,MAC_ADR) & 0xff00)>>8;
4598 dev->dev_addr[2]=eprom_read(dev,MAC_ADR+1) & 0xff;
4599 dev->dev_addr[3]=(eprom_read(dev,MAC_ADR+1) & 0xff00)>>8;
4600 dev->dev_addr[4]=eprom_read(dev,MAC_ADR+2) & 0xff;
4601 dev->dev_addr[5]=(eprom_read(dev,MAC_ADR+2) & 0xff00)>>8;
4602 -
4603 +
4604 DMESG("Card MAC address is "MAC_FMT, MAC_ARG(dev->dev_addr));
4605 -
4606 +
4607 for(i=1,j=0; i<6; i+=2,j++){
4608 -
4609 +
4610 word = eprom_read(dev,EPROM_TXPW0 + j);
4611 priv->chtxpwr[i]=word & 0xf;
4612 priv->chtxpwr_ofdm[i]=(word & 0xf0)>>4;
4613 priv->chtxpwr[i+1]=(word & 0xf00)>>8;
4614 priv->chtxpwr_ofdm[i+1]=(word & 0xf000)>>12;
4615 }
4616 -
4617 +
4618 for(i=1,j=0; i<4; i+=2,j++){
4619 -
4620 +
4621 word = eprom_read(dev,EPROM_TXPW1 + j);
4622 priv->chtxpwr[i+6]=word & 0xf;
4623 priv->chtxpwr_ofdm[i+6]=(word & 0xf0)>>4;
4624 priv->chtxpwr[i+6+1]=(word & 0xf00)>>8;
4625 priv->chtxpwr_ofdm[i+6+1]=(word & 0xf000)>>12;
4626 }
4627 -
4628 +
4629 for(i=1,j=0; i<4; i+=2,j++){
4630 -
4631 +
4632 word = eprom_read(dev,EPROM_TXPW2 + j);
4633 priv->chtxpwr[i+6+4]=word & 0xf;
4634 priv->chtxpwr_ofdm[i+6+4]=(word & 0xf0)>>4;
4635 priv->chtxpwr[i+6+4+1]=(word & 0xf00)>>8;
4636 priv->chtxpwr_ofdm[i+6+4+1]=(word & 0xf000)>>12;
4637 }
4638 -
4639 -
4640 +
4641 +
4642 priv->rf_chip = 0xff & eprom_read(dev,EPROM_RFCHIPID);
4643 -
4644 +
4645 +#ifdef DEBUG_TX_POWER
4646 + dump_tx_power(dev);
4647 +#endif
4648 +
4649 + DMESG("RF Chip ID: %02X", priv->rf_chip);
4650 +
4651 word = eprom_read(dev,EPROM_TXPW_BASE);
4652 priv->cck_txpwr_base = word & 0xf;
4653 priv->ofdm_txpwr_base = (word>>4) & 0xf;
4654 -
4655 +
4656 + priv->txpwr_max = 0;
4657 + for(i=1; i<15; i++)
4658 + {
4659 + if(priv->chtxpwr[i] > priv->txpwr_max) priv->txpwr_max = priv->chtxpwr[i];
4660 + if(priv->chtxpwr_ofdm[i] > priv->txpwr_max) priv->txpwr_max = priv->chtxpwr_ofdm[i];
4661 + priv->chtxpwr_orig[i] = priv->chtxpwr[i];
4662 + priv->chtxpwr_ofdm_orig[i] = priv->chtxpwr_ofdm[i];
4663 + }
4664 +
4665 /* check RF frontend chipset */
4666 -
4667 +
4668 switch (priv->rf_chip) {
4669 -
4670 +
4671 case EPROM_RFCHIPID_RTL8225U:
4672 -
4673 +
4674 DMESG("Card reports RF frontend Realtek 8225");
4675 DMESGW("This driver has EXPERIMENTAL support for this chipset.");
4676 DMESGW("use it with care and at your own risk and");
4677 @@ -1834,28 +1967,28 @@
4678 DMESG("This seems a legacy 1st version radio");
4679 }
4680 priv->rf_close = rtl8225_rf_close;
4681 -
4682 +
4683 priv->max_sens = RTL8225_RF_MAX_SENS;
4684 priv->sens = RTL8225_RF_DEF_SENS;
4685 break;
4686 -
4687 +
4688 default:
4689 DMESGW("Unknown RF module %x",priv->rf_chip);
4690 DMESGW("Exiting...");
4691 return -1;
4692 -
4693 +
4694 }
4695 -
4696 +
4697 // DMESG("Energy threshold: %x",priv->cs_treshold);
4698 DMESG("PAPE from CONFIG2: %x",read_nic_byte(dev,CONFIG2)&0x7);
4699 //DMESG("CONFIG2: %x ECONFIG2: %x",read_nic_byte(dev,CONFIG2),eprom_read(dev,EPROM_CONFIG2));
4700 -
4701 - if(rtl8187_usb_initendpoints(dev)!=0){
4702 +
4703 + if(rtl8187_usb_initendpoints(dev)!=0){
4704 DMESG("Endopoints initialization failed");
4705 return -ENOMEM;
4706 }
4707 -#if 0
4708 - if (0!=alloc_rx_desc_ring(dev, priv->rxbuffersize, priv->rxringcount))
4709 +#if 0
4710 + if (0!=alloc_rx_desc_ring(dev, priv->rxbuffersize, priv->rxringcount))
4711 return -ENOMEM;
4712  
4713 if (0!=alloc_tx_desc_ring(dev, priv->txbuffsize, priv->txringcount,
4714 @@ -1869,16 +2002,16 @@
4715 if (0!=alloc_tx_desc_ring(dev, priv->txbuffsize, priv->txringcount,
4716 TX_LOWPRIORITY_RING_ADDR))
4717 return -ENOMEM;
4718 -
4719 -
4720 +
4721 +
4722 if (0!=alloc_tx_beacon_desc_ring(dev, priv->txbeaconcount))
4723 return -ENOMEM;
4724 #endif
4725 -
4726 +
4727  
4728 #ifdef DEBUG_EPROM
4729 dump_eprom(dev);
4730 -#endif
4731 +#endif
4732 return 0;
4733  
4734 }
4735 @@ -1898,7 +2031,7 @@
4736 rtl8180_set_mode(dev, EPROM_CMD_CONFIG);
4737  
4738 conf3 = read_nic_byte(dev, CONFIG3);
4739 - write_nic_byte(dev, CONFIG3, conf3 | (1<<CONFIG3_ANAPARAM_W_SHIFT));
4740 + write_nic_byte(dev, CONFIG3, conf3 | (1<<CONFIG3_ANAPARAM_W_SHIFT));
4741  
4742 write_nic_dword(dev, ANAPARAM2, a);
4743  
4744 @@ -1918,23 +2051,23 @@
4745  
4746 conf3 = read_nic_byte(dev, CONFIG3);
4747 write_nic_byte(dev, CONFIG3, conf3 | (1<<CONFIG3_ANAPARAM_W_SHIFT));
4748 -
4749 +
4750 write_nic_dword(dev, ANAPARAM, a);
4751  
4752 conf3 = read_nic_byte(dev, CONFIG3);
4753 write_nic_byte(dev, CONFIG3, conf3 &~(1<<CONFIG3_ANAPARAM_W_SHIFT));
4754  
4755 rtl8180_set_mode(dev, EPROM_CMD_NORMAL);
4756 -
4757 +
4758 }
4759  
4760  
4761 void rtl8185_tx_antenna(struct net_device *dev, u8 ant)
4762 {
4763 - write_nic_byte(dev, TX_ANTENNA, ant);
4764 + write_nic_byte(dev, TX_ANTENNA, ant);
4765 force_pci_posting(dev);
4766 mdelay(1);
4767 -}
4768 +}
4769  
4770  
4771 void rtl8187_write_phy(struct net_device *dev, u8 adr, u32 data)
4772 @@ -1942,26 +2075,26 @@
4773 //u8 phyr;
4774 u32 phyw;
4775 // int i;
4776 -
4777 +
4778 adr |= 0x80;
4779 -
4780 +
4781 phyw= ((data<<8) | adr);
4782 -
4783 -
4784 -
4785 - // Note that, we must write 0xff7c after 0x7d-0x7f to write BB register.
4786 +
4787 +
4788 +
4789 + // Note that, we must write 0xff7c after 0x7d-0x7f to write BB register.
4790 write_nic_byte(dev, 0x7f, ((phyw & 0xff000000) >> 24));
4791 write_nic_byte(dev, 0x7e, ((phyw & 0x00ff0000) >> 16));
4792 write_nic_byte(dev, 0x7d, ((phyw & 0x0000ff00) >> 8));
4793 write_nic_byte(dev, 0x7c, ((phyw & 0x000000ff) ));
4794  
4795 //read_nic_dword(dev, PHY_ADR);
4796 -#if 0
4797 +#if 0
4798 for(i=0;i<10;i++){
4799 write_nic_dword(dev, PHY_ADR, 0xffffff7f & phyw);
4800 phyr = read_nic_byte(dev, PHY_READ);
4801 if(phyr == (data&0xff)) break;
4802 -
4803 +
4804 }
4805 #endif
4806 /* this is ok to fail when we write AGC table. check for AGC table might be
4807 @@ -1988,60 +2121,60 @@
4808  
4809 void rtl8180_adapter_start(struct net_device *dev)
4810 {
4811 - struct r8180_priv *priv = ieee80211_priv(dev);
4812 + struct r8180_priv *priv = ieee80211_priv_rtl7(dev);
4813 //u32 anaparam;
4814 //u8 config3;
4815 -
4816 +
4817 //rtl8180_rtx_disable(dev);
4818 rtl8180_reset(dev);
4819  
4820 write_nic_byte(dev,0x85,0);
4821 write_nic_byte(dev,0x91,0);
4822 -
4823 +
4824 /* light blink! */
4825 write_nic_byte(dev,0x85,4);
4826 write_nic_byte(dev,0x91,1);
4827 write_nic_byte(dev,0x90,0);
4828 -
4829 +
4830 priv->irq_mask = 0xffff;
4831 /*
4832 priv->dma_poll_mask = 0;
4833 priv->dma_poll_mask|= (1<<TX_DMA_STOP_BEACON_SHIFT);
4834 -*/
4835 +*/
4836 // rtl8180_beacon_tx_disable(dev);
4837 -
4838 +
4839 rtl8180_set_mode(dev, EPROM_CMD_CONFIG);
4840 write_nic_dword(dev, MAC0, ((u32*)dev->dev_addr)[0]);
4841 write_nic_word(dev, MAC4, ((u32*)dev->dev_addr)[1] & 0xffff );
4842  
4843 rtl8180_set_mode(dev, EPROM_CMD_NORMAL);
4844 rtl8180_update_msr(dev);
4845 -
4846 +
4847 rtl8180_set_mode(dev, EPROM_CMD_CONFIG);
4848 -
4849 +
4850 write_nic_word(dev,0xf4,0xffff);
4851 write_nic_byte(dev,
4852 - CONFIG1, (read_nic_byte(dev,CONFIG1) & 0x3f) | 0x80);
4853 + CONFIG1, (read_nic_byte(dev,CONFIG1) & 0x3f) | 0x80);
4854  
4855 rtl8180_set_mode(dev,EPROM_CMD_NORMAL);
4856 -
4857 - write_nic_dword(dev,INT_TIMEOUT,0);
4858 +
4859 + write_nic_dword(dev,INT_TIMEOUT,0);
4860  
4861 #ifdef DEBUG_REGISTERS
4862 - rtl8180_dump_reg(dev);
4863 + rtl8180_dump_reg(dev);
4864 #endif
4865 -
4866 -
4867 - write_nic_byte(dev, WPA_CONFIG, 0);
4868 +
4869 +
4870 + write_nic_byte(dev, WPA_CONFIG, 0);
4871  
4872 write_nic_byte(dev, RATE_FALLBACK, 0x81);
4873 rtl8187_set_rate(dev);
4874 -
4875 - priv->rf_init(dev);
4876 +
4877 + priv->rf_init(dev);
4878  
4879 if(priv->rf_set_sens != NULL)
4880 - priv->rf_set_sens(dev,priv->sens);
4881 -
4882 + priv->rf_set_sens(dev,priv->sens);
4883 +
4884 write_nic_word(dev,0x5e,1);
4885  
4886 #if 1
4887 @@ -2054,13 +2187,13 @@
4888 write_nic_byte(dev, 0xff, 0x60);
4889  
4890 write_nic_word(dev,0x5e,0);
4891 -
4892 -
4893 +
4894 +
4895 rtl8180_irq_enable(dev);
4896 /*DMESG ("lfree %d",get_curr_tx_free_desc(dev,LOW_PRIORITY));
4897 -
4898 +
4899 DMESG ("nfree %d",get_curr_tx_free_desc(dev,NORM_PRIORITY));
4900 -
4901 +
4902 DMESG ("hfree %d",get_curr_tx_free_desc(dev,HI_PRIORITY));
4903 if(check_nic_enought_desc(dev,NORM_PRIORITY)) DMESG("NORM OK");
4904 if(check_nic_enought_desc(dev,HI_PRIORITY)) DMESG("HI OK");
4905 @@ -2077,8 +2210,8 @@
4906 void rtl8180_start_tx_beacon(struct net_device *dev)
4907 {
4908 int i;
4909 - struct r8180_priv *priv = (struct r8180_priv *)ieee80211_priv(dev);
4910 - u16 word;
4911 + struct r8180_priv *priv = (struct r8180_priv *)ieee80211_priv_rtl7(dev);
4912 + u16 word;
4913 DMESG("Enabling beacon TX");
4914 //write_nic_byte(dev, 0x42,0xe6);// TCR
4915 //rtl8180_init_beacon(dev);
4916 @@ -2091,41 +2224,41 @@
4917 //write_nic_word(dev,0x7a,0);
4918 //write_nic_word(dev,0x7a,0x8000);
4919  
4920 -
4921 +
4922 word = read_nic_word(dev, BcnItv);
4923 word &= ~BcnItv_BcnItv; // clear Bcn_Itv
4924 write_nic_word(dev, BcnItv, word);
4925  
4926 - write_nic_word(dev, AtimWnd,
4927 + write_nic_word(dev, AtimWnd,
4928 read_nic_word(dev, AtimWnd) &~ AtimWnd_AtimWnd);
4929 -
4930 +
4931 word = read_nic_word(dev, BintrItv);
4932 word &= ~BintrItv_BintrItv;
4933 -
4934 - //word |= priv->ieee80211->beacon_interval *
4935 +
4936 + //word |= priv->ieee80211->beacon_interval *
4937 // ((priv->txbeaconcount > 1)?(priv->txbeaconcount-1):1);
4938 // FIXME:FIXME check if correct ^^ worked with 0x3e8;
4939 -
4940 +
4941 write_nic_word(dev, BintrItv, word);
4942 -
4943 +
4944 //write_nic_word(dev,0x2e,0xe002);
4945 //write_nic_dword(dev,0x30,0xb8c7832e);
4946 for(i=0; i<ETH_ALEN; i++)
4947 write_nic_byte(dev, BSSID+i, priv->ieee80211->beacon_cell_ssid[i]);
4948 -
4949 +
4950 // rtl8180_update_msr(dev);
4951  
4952 -
4953 +
4954 //write_nic_byte(dev,CONFIG4,3); /* !!!!!!!!!! */
4955 -
4956 +
4957 rtl8180_set_mode(dev, EPROM_CMD_NORMAL);
4958 -
4959 +
4960 rtl8180_irq_enable(dev);
4961 -
4962 +
4963 /* VV !!!!!!!!!! VV*/
4964 /*
4965 rtl8180_set_mode(dev,EPROM_CMD_CONFIG);
4966 - write_nic_byte(dev,0x9d,0x00);
4967 + write_nic_byte(dev,0x9d,0x00);
4968 rtl8180_set_mode(dev,EPROM_CMD_NORMAL);
4969 */
4970 }
4971 @@ -2135,137 +2268,138 @@
4972 ***************************************************************************/
4973 static struct net_device_stats *rtl8180_stats(struct net_device *dev)
4974 {
4975 - struct r8180_priv *priv = ieee80211_priv(dev);
4976 -
4977 + struct r8180_priv *priv = ieee80211_priv_rtl7(dev);
4978 +
4979 return &priv->ieee80211->stats;
4980 }
4981  
4982  
4983 int _rtl8180_up(struct net_device *dev)
4984 {
4985 - struct r8180_priv *priv = ieee80211_priv(dev);
4986 + struct r8180_priv *priv = ieee80211_priv_rtl7(dev);
4987  
4988 priv->up=1;
4989 -
4990 - //DMESG("Bringing up iface");
4991 +
4992 +// DMESG("Bringing up iface");
4993  
4994 rtl8180_adapter_start(dev);
4995 -
4996 rtl8180_rx_enable(dev);
4997 -
4998 rtl8180_tx_enable(dev);
4999 -
5000 - ieee80211_softmac_start_protocol(priv->ieee80211);
5001 -
5002 - ieee80211_reset_queue(priv->ieee80211);
5003 + ieee80211_softmac_start_protocol_rtl7(priv->ieee80211);
5004 + ieee80211_reset_queue_rtl7(priv->ieee80211);
5005 if(!netif_queue_stopped(dev))
5006 netif_start_queue(dev);
5007 else
5008 netif_wake_queue(dev);
5009 -
5010 return 0;
5011 }
5012  
5013  
5014 int rtl8180_open(struct net_device *dev)
5015 {
5016 - struct r8180_priv *priv = ieee80211_priv(dev);
5017 + struct r8180_priv *priv = ieee80211_priv_rtl7(dev);
5018 int ret;
5019 -
5020 +
5021 down(&priv->wx_sem);
5022 +
5023 ret = rtl8180_up(dev);
5024 up(&priv->wx_sem);
5025 return ret;
5026 -
5027 +
5028 }
5029  
5030  
5031 int rtl8180_up(struct net_device *dev)
5032 {
5033 - struct r8180_priv *priv = ieee80211_priv(dev);
5034 + struct r8180_priv *priv = ieee80211_priv_rtl7(dev);
5035  
5036 if (priv->up == 1) return -1;
5037 -
5038 +
5039 return _rtl8180_up(dev);
5040 }
5041  
5042  
5043 int rtl8180_close(struct net_device *dev)
5044 {
5045 - struct r8180_priv *priv = ieee80211_priv(dev);
5046 + struct r8180_priv *priv = ieee80211_priv_rtl7(dev);
5047 int ret;
5048 -
5049 +
5050 down(&priv->wx_sem);
5051 -
5052 +
5053 ret = rtl8180_down(dev);
5054 -
5055 +
5056 up(&priv->wx_sem);
5057 -
5058 +
5059 return ret;
5060  
5061 }
5062  
5063 int rtl8180_down(struct net_device *dev)
5064 {
5065 - struct r8180_priv *priv = ieee80211_priv(dev);
5066 + struct r8180_priv *priv = ieee80211_priv_rtl7(dev);
5067  
5068 if (priv->up == 0) return -1;
5069 -
5070 +
5071 priv->up=0;
5072  
5073 /* FIXME */
5074 if (!netif_queue_stopped(dev))
5075 netif_stop_queue(dev);
5076 -
5077 +
5078 rtl8180_rtx_disable(dev);
5079 rtl8180_irq_disable(dev);
5080  
5081 - ieee80211_softmac_stop_protocol(priv->ieee80211);
5082 -
5083 + ieee80211_softmac_stop_protocol_rtl7(priv->ieee80211);
5084 +
5085 return 0;
5086 }
5087  
5088  
5089 void rtl8180_commit(struct net_device *dev)
5090 {
5091 - struct r8180_priv *priv = ieee80211_priv(dev);
5092 + struct r8180_priv *priv = ieee80211_priv_rtl7(dev);
5093  
5094 if (priv->up == 0) return ;
5095 -
5096 - ieee80211_softmac_stop_protocol(priv->ieee80211);
5097 -
5098 +
5099 + ieee80211_softmac_stop_protocol_rtl7(priv->ieee80211);
5100 +
5101 rtl8180_irq_disable(dev);
5102 rtl8180_rtx_disable(dev);
5103 _rtl8180_up(dev);
5104 }
5105  
5106 +# if (LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,20))
5107 +void rtl8180_restart(struct work_struct *work)
5108 +{
5109 + struct r8180_priv *priv = container_of(work, struct r8180_priv, reset_wq);
5110 + struct net_device *dev = priv->dev;
5111 +#else
5112 void rtl8180_restart(struct net_device *dev)
5113 {
5114 - struct r8180_priv *priv = ieee80211_priv(dev);
5115 -
5116 + struct r8180_priv *priv = ieee80211_priv_rtl7(dev);
5117 +#endif
5118 down(&priv->wx_sem);
5119 -
5120 rtl8180_commit(dev);
5121 -
5122 +
5123 up(&priv->wx_sem);
5124 }
5125  
5126 static void r8180_set_multicast(struct net_device *dev)
5127 {
5128 - struct r8180_priv *priv = ieee80211_priv(dev);
5129 + struct r8180_priv *priv = ieee80211_priv_rtl7(dev);
5130 short promisc;
5131  
5132 //down(&priv->wx_sem);
5133 -
5134 +
5135 /* FIXME FIXME */
5136 -
5137 +
5138 promisc = (dev->flags & IFF_PROMISC) ? 1:0;
5139 -
5140 +
5141 if (promisc != priv->promisc)
5142 // rtl8180_commit(dev);
5143 -
5144 +
5145 priv->promisc = promisc;
5146 -
5147 +
5148 //schedule_work(&priv->reset_wq);
5149 //up(&priv->wx_sem);
5150 }
5151 @@ -2273,17 +2407,17 @@
5152  
5153 int r8180_set_mac_adr(struct net_device *dev, void *mac)
5154 {
5155 - struct r8180_priv *priv = ieee80211_priv(dev);
5156 + struct r8180_priv *priv = ieee80211_priv_rtl7(dev);
5157 struct sockaddr *addr = mac;
5158 -
5159 +
5160 down(&priv->wx_sem);
5161 -
5162 +
5163 memcpy(dev->dev_addr, addr->sa_data, ETH_ALEN);
5164 -
5165 +
5166 schedule_work(&priv->reset_wq);
5167 -
5168 +
5169 up(&priv->wx_sem);
5170 -
5171 +
5172 return 0;
5173 }
5174  
5175 @@ -2291,16 +2425,18 @@
5176 /* based on ipw2200 driver */
5177 int rtl8180_ioctl(struct net_device *dev, struct ifreq *rq, int cmd)
5178 {
5179 - struct r8180_priv *priv = (struct r8180_priv *)ieee80211_priv(dev);
5180 -
5181 + struct r8180_priv *priv = (struct r8180_priv *)ieee80211_priv_rtl7(dev);
5182 + struct iwreq *wrq;
5183 + int ret;
5184 +
5185 down(&priv->wx_sem);
5186 -
5187 - struct iwreq *wrq = (struct iwreq *)rq;
5188 -
5189 - int ret=-1;
5190 +
5191 + wrq = (struct iwreq *)rq;
5192 +
5193 + ret=-1;
5194 switch (cmd) {
5195 case RTL_IOCTL_WPA_SUPPLICANT:
5196 - ret = ieee80211_wpa_supplicant_ioctl(priv->ieee80211, &wrq->u.data);
5197 + ret = ieee80211_wpa_supplicant_ioctl_rtl7(priv->ieee80211, &wrq->u.data);
5198 break;
5199  
5200 default:
5201 @@ -2309,7 +2445,7 @@
5202 }
5203  
5204 up(&priv->wx_sem);
5205 -
5206 +
5207 return ret;
5208 }
5209  
5210 @@ -2320,10 +2456,11 @@
5211 struct net_device *dev = (struct net_device*)rx_urb->context;
5212 int status,len,flen;
5213 struct sk_buff *skb;
5214 - u32 *desc;
5215 -
5216 + u8 *desc;
5217 + u8 signal,quality,rate;
5218 +
5219 //DMESG("rtl8187_rx_isr");
5220 -
5221 +
5222 struct ieee80211_rx_stats stats = {
5223 .signal = 0,
5224 .noise = -98,
5225 @@ -2332,43 +2469,109 @@
5226 .freq = IEEE80211_24GHZ_BAND,
5227 };
5228  
5229 +
5230 //DMESG("RX %d ",rx_urb->status);
5231 status = rx_urb->status;
5232 if(status == 0){
5233 -
5234 +
5235 len = rx_urb->actual_length;
5236 - // len = len - 4 - 15 - 1; /* CRC, DESC, SEPARATOR*/
5237 + // len = len - 4 - 15 - 1; /* CRC, DESC, SEPARATOR*/
5238 len -= 4*4;/* 4 dword and 4 byte CRC */
5239 -
5240 +#if 0
5241 desc = (u32*)(rx_urb->transfer_buffer + len);
5242 -
5243 +
5244 flen = desc[0] & 0xfff;
5245 -
5246 +
5247 if( flen <= rx_urb->actual_length){
5248 -
5249 - stats.signal = (desc[1] & 0x7f00)>>8;
5250 - stats.noise = desc[1] &0xff;
5251 - stats.rate = desc[0] >> 20 & 0xf;
5252 +
5253 + //stats.signal = (desc[1] & 0x7f00)>>8;
5254 + //stats.noise = desc[1] &0xff;
5255 + signal=(desc[1]& (0xff0000))>>16;
5256 + signal=(signal&0xfe)>>1; // Modify by hikaru 6.6
5257 +
5258 + quality=(desc[1] & (0xff));
5259 +
5260 + rate=(desc[0] &((1<<23)|(1<<22)|(1<<21)|(1<<20)))>>20;
5261 + // printk(KERN_INFO "rate is %d!\n",rate);
5262 + stats.rate = rtl8180_rate2rate(rate);
5263 + // printk(KERN_INFO "stats.rate is %d!\n",stats.rate);
5264 + //stats.rate = desc[0] >> 20 & 0xf;
5265 stats.mac_time[0] = desc[2];
5266 stats.mac_time[1] = desc[3];
5267 +#endif
5268 +
5269 + desc = rx_urb->transfer_buffer + len;
5270 +
5271 + flen = ((desc[1] & 0x0f) << 8) + (desc[0] & 0xff);
5272 +
5273 + if( flen <= rx_urb->actual_length){
5274 + //stats.signal = (desc[1] & 0x7f00)>>8;
5275 + //stats.noise = desc[1] &0xff;
5276 + signal=(desc[6]& 0xfe)>>1;
5277 + //signal=(signal&0xfe)>>1; // Modify by hikaru 6.6
5278 +
5279 + quality=desc[4] & 0xff;
5280 +
5281 + //rate=(desc[2] &((1<<7)|(1<<6)|(1<<5)|(1<<4)))>>4;
5282 + rate=(desc[2] & 0xf0)>>4;
5283 + // printk(KERN_INFO "rate is %d!\n",rate);
5284 + stats.rate = rtl8180_rate2rate(rate);
5285 + // printk(KERN_INFO "stats.rate is %d!\n",stats.rate);
5286 + //stats.rate = desc[0] >> 20 & 0xf;
5287 + stats.mac_time[0] = desc[8] + (desc[9]<<8) + (desc[10]<<16) + (desc[11]<<24);
5288 + stats.mac_time[1] = desc[12] + (desc[13]<<8) + (desc[14]<<16) + (desc[15]<<24);
5289 +
5290 +
5291 + //calculate link quality begin
5292 + if(!rtl8180_IsWirelessBMode(stats.rate) )
5293 + { // OFDM rate.
5294 + if(signal>90)
5295 + signal=90;
5296 + else if(signal<25)
5297 + signal=25;
5298 + signal = (90-signal)*100/65;
5299 + }
5300 + else
5301 + { // CCK rate.
5302 + if(signal>95)
5303 + signal = 95;
5304 + else if(signal<30)
5305 + signal = 30;
5306 + signal =(95-signal )*100/65;
5307 + }
5308 + priv->wstats.qual.level = signal;
5309 + // printk(KERN_INFO "signal is %d!\n",signal);
5310 + if(quality > 64)
5311 + priv ->wstats.qual.qual = 0;
5312 + else
5313 + priv ->wstats.qual.qual = ((64-quality) * 100) / 64; // SQ value is the SIGNAL_QUALITY returned to IORequest,
5314 + //and this value only appear when STA is associated to AP or
5315 + // STA is in IBSS mode
5316 + // printk(KERN_INFO "quality is %d!\n",priv->wstats.qual.qual);
5317 + priv->wstats.qual.noise = 100 - priv ->wstats.qual.qual;
5318 + priv->wstats.qual.updated = 7;
5319 + if(priv->ieee80211->iw_mode == IW_MODE_MONITOR)
5320 + {
5321 + stats.signal = priv->wstats.qual.level;
5322 + stats.noise = priv->wstats.qual.noise;
5323 + }
5324 + //calculate link quality end
5325 skb = dev_alloc_skb(flen-4);
5326 - //skb_reserve(skb,2);
5327 - if(skb){
5328 + if(skb){
5329 memcpy(skb_put(skb,flen-4),
5330 rx_urb->transfer_buffer,flen -4);
5331 -
5332 +
5333 #ifdef DUMP_RX
5334 int i;
5335 for(i=0;i<flen-4;i++)
5336 printk("%2x ",((u8*)(rx_urb->transfer_buffer))[i]);
5337 printk("------RATE %x:w---------------\n",stats.rate);
5338 -
5339 +
5340 #endif
5341 priv->stats.rxok++;
5342 // priv->rxskb = skb;
5343 // priv->tempstats = &stats;
5344 -
5345 - if(!ieee80211_rx(priv->ieee80211,
5346 + if(!ieee80211_rx_rtl7(priv->ieee80211,
5347 skb, &stats))
5348 dev_kfree_skb_any(skb);
5349 }
5350 @@ -2376,9 +2579,8 @@
5351 }else{
5352 priv->stats.rxstaterr++;
5353 priv->ieee80211->stats.rx_errors++;
5354 -
5355 }
5356 -
5357 +
5358 if(status != -ENOENT)rtl8187_rx_urbsubmit(dev,rx_urb);
5359 else DMESG("RX process aborted due to explicit shutdown");
5360 }
5361 @@ -2396,20 +2598,20 @@
5362 struct r8180_priv *priv= NULL;
5363 struct usb_device *udev = interface_to_usbdev(intf);
5364  
5365 -//printk("===> rtl8187_usb_probe()\n");
5366 -
5367 - dev = alloc_ieee80211(sizeof(struct r8180_priv));
5368 -
5369 +//printk("===> rtl8187_usb_probe()\n");
5370 +
5371 + dev = alloc_ieee80211_rtl7(sizeof(struct r8180_priv));
5372 +
5373 SET_MODULE_OWNER(dev);
5374 - usb_set_intfdata(intf, dev);
5375 -
5376 + usb_set_intfdata(intf, dev);
5377 +
5378 SET_NETDEV_DEV(dev, &intf->dev);
5379  
5380 - priv = ieee80211_priv(dev);
5381 + priv = ieee80211_priv_rtl7(dev);
5382 priv->ieee80211 = netdev_priv(dev);
5383 -
5384 +
5385 priv->udev=udev;
5386 -
5387 +
5388 dev->open = rtl8180_open;
5389 dev->stop = rtl8180_close;
5390 //dev->hard_start_xmit = rtl8180_8023_hard_start_xmit;
5391 @@ -2418,41 +2620,46 @@
5392 dev->do_ioctl = rtl8180_ioctl;
5393 dev->set_multicast_list = r8180_set_multicast;
5394 dev->set_mac_address = r8180_set_mac_adr;
5395 +#if WIRELESS_EXT >= 12
5396 +#if WIRELESS_EXT < 17
5397 dev->get_wireless_stats = r8180_get_wireless_stats;
5398 +#endif
5399 + dev->wireless_handlers = (struct iw_handler_def *) &r8180_wx_handlers_def;
5400 +#endif
5401 dev->type=ARPHRD_ETHER;
5402 -
5403 +
5404 if (dev_alloc_name(dev, ifname) < 0){
5405 DMESG("Oops: devname already taken! Trying wlan%%d...\n");
5406 ifname = "wlan%d";
5407 dev_alloc_name(dev, ifname);
5408 }
5409 -
5410 +
5411 // dev->open=rtl8180_init;
5412 -
5413 - if(rtl8180_init(dev)!=0){
5414 +
5415 + if(rtl8180_init(dev)!=0){
5416 DMESG("Initialization failed");
5417 goto fail;
5418 }
5419 -
5420 +
5421 netif_carrier_off(dev);
5422 netif_stop_queue(dev);
5423 -
5424 +
5425 register_netdev(dev);
5426 -
5427 +
5428 rtl8180_proc_init_one(dev);
5429 -
5430 -
5431 +
5432 +
5433 DMESG("Driver probe completed\n");
5434 - return 0;
5435 + return 0;
5436 +
5437  
5438 -
5439 fail:
5440 - free_ieee80211(dev);
5441 -
5442 + free_ieee80211_rtl7(dev);
5443 +
5444 DMESG("wlan driver load failed\n");
5445 -
5446 +
5447 return -ENODEV;
5448 -
5449 +
5450 }
5451  
5452  
5453 @@ -2461,13 +2668,13 @@
5454 struct r8180_priv *priv;
5455 struct net_device *dev = usb_get_intfdata(intf);
5456 if(dev){
5457 -
5458 +
5459 unregister_netdev(dev);
5460 -
5461 - priv=ieee80211_priv(dev);
5462 -
5463 +
5464 + priv=ieee80211_priv_rtl7(dev);
5465 +
5466 rtl8180_proc_remove_one(dev);
5467 -
5468 +
5469 rtl8180_down(dev);
5470 priv->rf_close(dev);
5471 //rtl8180_rtx_disable(dev);
5472 @@ -2478,12 +2685,12 @@
5473  
5474 }
5475 // pci_disable_device(pdev);
5476 - free_ieee80211(dev);
5477 + free_ieee80211_rtl7(dev);
5478 DMESG("wlan driver removed\n");
5479 }
5480  
5481  
5482 -static int __init rtl8187_usb_module_init(void)
5483 +static int __init rtl8187_usb_module_init_rtl7(void)
5484 {
5485 printk(KERN_INFO "\nLinux kernel driver for RTL8187 \
5486 based WLAN cards\n");
5487 @@ -2495,7 +2702,7 @@
5488 }
5489  
5490  
5491 -static void __exit rtl8187_usb_module_exit(void)
5492 +static void __exit rtl8187_usb_module_exit_rtl7(void)
5493 {
5494 usb_deregister(&rtl8187_usb_driver);
5495  
5496 @@ -2508,14 +2715,14 @@
5497 {
5498 unsigned long flags;
5499 short enough_desc;
5500 - struct r8180_priv *priv = (struct r8180_priv *)ieee80211_priv(dev);
5501 -
5502 + struct r8180_priv *priv = (struct r8180_priv *)ieee80211_priv_rtl7(dev);
5503 +
5504 spin_lock_irqsave(&priv->tx_lock,flags);
5505 enough_desc = check_nic_enought_desc(dev,pri);
5506 - spin_unlock_irqrestore(&priv->tx_lock,flags);
5507 -
5508 + spin_unlock_irqrestore(&priv->tx_lock,flags);
5509 +
5510 if(enough_desc)
5511 - ieee80211_wake_queue(priv->ieee80211);
5512 + ieee80211_wake_queue_rtl7(priv->ieee80211);
5513 }
5514  
5515  
5516 @@ -2523,5 +2730,5 @@
5517 /***************************************************************************
5518 ------------------- module init / exit stubs ----------------
5519 ****************************************************************************/
5520 -module_init(rtl8187_usb_module_init);
5521 -module_exit(rtl8187_usb_module_exit);
5522 +module_init(rtl8187_usb_module_init_rtl7);
5523 +module_exit(rtl8187_usb_module_exit_rtl7);
5524 diff -Naur rtl8187_orig/beta-8187/r8187.h rtl8187_rawtx/beta-8187/r8187.h
5525 --- rtl8187_orig/beta-8187/r8187.h 2007-03-13 23:45:09.000000000 +0100
5526 +++ rtl8187_rawtx/beta-8187/r8187.h 2007-07-13 01:46:27.000000000 +0200
5527 @@ -1,17 +1,17 @@
5528 -/*
5529 +/*
5530 This is part of rtl8187 OpenSource driver.
5531 - Copyright (C) Andrea Merello 2004-2005 <andreamrl@tiscali.it>
5532 + Copyright (C) Andrea Merello 2004-2005 <andreamrl@tiscali.it>
5533 Released under the terms of GPL (General Public Licence)
5534 -
5535 - Parts of this driver are based on the GPL part of the
5536 +
5537 + Parts of this driver are based on the GPL part of the
5538 official realtek driver
5539 -
5540 - Parts of this driver are based on the rtl8180 driver skeleton
5541 +
5542 + Parts of this driver are based on the rtl8180 driver skeleton
5543 from Patric Schenke & Andres Salomon
5544 -
5545 +
5546 Parts of this driver are based on the Intel Pro Wireless 2100 GPL driver
5547 -
5548 - We want to tanks the Authors of those projects and the Ndiswrapper
5549 +
5550 + We want to tanks the Authors of those projects and the Ndiswrapper
5551 project Authors.
5552 */
5553  
5554 @@ -26,7 +26,6 @@
5555  
5556 #include <linux/module.h>
5557 #include <linux/kernel.h>
5558 -#include <linux/config.h>
5559 #include <linux/init.h>
5560 #include <linux/ioport.h>
5561 #include <linux/sched.h>
5562 @@ -47,6 +46,12 @@
5563 #include <asm/io.h>
5564 #include <asm/semaphore.h>
5565  
5566 +#if (LINUX_VERSION_CODE < KERNEL_VERSION(2,6,19))
5567 +#include <linux/config.h>
5568 +#else
5569 +#include <linux/autoconf.h>
5570 +#endif
5571 +
5572 #include "ieee80211.h"
5573  
5574 #define EPROM_93c46 0
5575 @@ -68,7 +73,7 @@
5576 {
5577 struct buffer *next;
5578 u32 *buf;
5579 -
5580 +
5581 } buffer;
5582  
5583 #if 0
5584 @@ -123,18 +128,18 @@
5585 short epromtype;
5586 int irq;
5587 struct ieee80211_device *ieee80211;
5588 -
5589 +
5590 short card_8185; /* O: rtl8180, 1:rtl8185 V B/C, 2:rtl8185 V D */
5591 short card_8185_Bversion; /* if TCR reports card V B/C this discriminates */
5592 short phy_ver; /* meaningful for rtl8225 1:A 2:B 3:C */
5593 short enable_gpio0;
5594 enum card_type {PCI,MINIPCI,CARDBUS,USB/*rtl8187*/}card_type;
5595 short hw_plcp_len;
5596 -
5597 +
5598 // spinlock_t irq_lock;
5599 // spinlock_t irq_th_lock;
5600 spinlock_t tx_lock;
5601 -
5602 +
5603 u16 irq_mask;
5604 // short irq_enabled;
5605 struct net_device *dev;
5606 @@ -143,13 +148,17 @@
5607 short max_sens;
5608 u8 chtxpwr[15]; //channels from 1 to 14, 0 not used
5609 u8 chtxpwr_ofdm[15]; //channels from 1 to 14, 0 not used
5610 + u8 chtxpwr_orig[15]; //channels from 1 to 14, 0 not used
5611 + u8 chtxpwr_ofdm_orig[15]; //channels from 1 to 14, 0 not used
5612 u8 cck_txpwr_base;
5613 u8 ofdm_txpwr_base;
5614 + u8 txpwr_max;
5615 u8 challow[15]; //channels from 1 to 14, 0 not used
5616 short up;
5617 short crcmon; //if 1 allow bad crc frame reception in monitor mode
5618 -// short prism_hdr;
5619 -
5620 + short prism_hdr;
5621 + short fasttx;
5622 +
5623 // struct timer_list scan_timer;
5624 /*short scanpending;
5625 short stopscan;*/
5626 @@ -158,7 +167,7 @@
5627 //u8 active_scan_num;
5628 struct semaphore wx_sem;
5629 // short hw_wep;
5630 -
5631 +
5632 // short digphy;
5633 // short antb;
5634 // short diversity;
5635 @@ -171,31 +180,31 @@
5636 void (*rf_close)(struct net_device *dev);
5637 void (*rf_init)(struct net_device *dev);
5638 //short rate;
5639 - short promisc;
5640 + short promisc;
5641 /*stats*/
5642 struct Stats stats;
5643 struct iw_statistics wstats;
5644 struct proc_dir_entry *dir_dev;
5645 -
5646 +
5647 /*RX stuff*/
5648 // u32 *rxring;
5649 // u32 *rxringtail;
5650 // dma_addr_t rxringdma;
5651 struct urb **rx_urb;
5652 -
5653 +
5654 //struct buffer *rxbuffer;
5655 //struct buffer *rxbufferhead;
5656 //int rxringcount;
5657 //u16 rxbuffersize;
5658 -
5659 - //struct sk_buff *rx_skb;
5660 +
5661 + //struct sk_buff *rx_skb;
5662  
5663 //short rx_skb_complete;
5664  
5665 //u32 rx_prevlen;
5666 atomic_t tx_lp_pending;
5667 atomic_t tx_np_pending;
5668 -#if 0
5669 +#if 0
5670 /*TX stuff*/
5671 u32 *txlpring;
5672 u32 *txhpring;
5673 @@ -225,7 +234,7 @@
5674 struct urb *rxurb_task;
5675 // u8 dma_poll_mask;
5676 //short tx_suspend;
5677 -
5678 +
5679 /* adhoc/master mode stuff */
5680 #if 0
5681 u32 *txbeacontail;
5682 @@ -239,22 +248,23 @@
5683 //u16 master_beaconinterval;
5684 // u32 master_beaconsize;
5685 //u16 beacon_interval;
5686 -
5687 +
5688 u8 retry_data;
5689 u8 retry_rts;
5690 -
5691 +
5692 struct work_struct reset_wq;
5693 -
5694 +
5695 }r8180_priv;
5696  
5697  
5698 -typedef enum{
5699 +typedef enum{
5700 LOW_PRIORITY ,
5701 - NORM_PRIORITY
5702 + NORM_PRIORITY
5703 } priority_t;
5704  
5705  
5706 short rtl8180_tx(struct net_device *dev,u32* skbuf, int len,priority_t priority,short morefrag,short rate);
5707 +short rtl8180_tx_fast(struct net_device *dev,u32* skbuf, int len, short rate);
5708  
5709 u8 read_nic_byte(struct net_device *dev, int x);
5710 u8 read_nic_byte_E(struct net_device *dev, int x);
5711 diff -Naur rtl8187_orig/ieee80211/ieee80211_crypt.c rtl8187_rawtx/ieee80211/ieee80211_crypt.c
5712 --- rtl8187_orig/ieee80211/ieee80211_crypt.c 2007-03-13 23:45:09.000000000 +0100
5713 +++ rtl8187_rawtx/ieee80211/ieee80211_crypt.c 2007-07-13 01:46:05.000000000 +0200
5714 @@ -11,7 +11,6 @@
5715 *
5716 */
5717  
5718 -#include <linux/config.h>
5719 #include <linux/version.h>
5720 #include <linux/module.h>
5721 #include <linux/init.h>
5722 @@ -19,6 +18,12 @@
5723 #include <asm/string.h>
5724 #include <asm/errno.h>
5725  
5726 +#if (LINUX_VERSION_CODE < KERNEL_VERSION(2,6,19))
5727 +#include <linux/config.h>
5728 +#else
5729 +#include <linux/autoconf.h>
5730 +#endif
5731 +
5732 #include "ieee80211.h"
5733  
5734 MODULE_AUTHOR("Jouni Malinen");
5735 @@ -38,7 +43,7 @@
5736  
5737 static struct ieee80211_crypto *hcrypt;
5738  
5739 -void ieee80211_crypt_deinit_entries(struct ieee80211_device *ieee,
5740 +void ieee80211_crypt_deinit_entries_rtl7(struct ieee80211_device *ieee,
5741 int force)
5742 {
5743 struct list_head *ptr, *n;
5744 @@ -61,13 +66,13 @@
5745 }
5746 }
5747  
5748 -void ieee80211_crypt_deinit_handler(unsigned long data)
5749 +void ieee80211_crypt_deinit_handler_rtl7(unsigned long data)
5750 {
5751 struct ieee80211_device *ieee = (struct ieee80211_device *)data;
5752 unsigned long flags;
5753  
5754 spin_lock_irqsave(&ieee->lock, flags);
5755 - ieee80211_crypt_deinit_entries(ieee, 0);
5756 + ieee80211_crypt_deinit_entries_rtl7(ieee, 0);
5757 if (!list_empty(&ieee->crypt_deinit_list)) {
5758 printk(KERN_DEBUG "%s: entries remaining in delayed crypt "
5759 "deletion list\n", ieee->dev->name);
5760 @@ -78,7 +83,7 @@
5761  
5762 }
5763  
5764 -void ieee80211_crypt_delayed_deinit(struct ieee80211_device *ieee,
5765 +void ieee80211_crypt_delayed_deinit_rtl7(struct ieee80211_device *ieee,
5766 struct ieee80211_crypt_data **crypt)
5767 {
5768 struct ieee80211_crypt_data *tmp;
5769 @@ -103,7 +108,7 @@
5770 spin_unlock_irqrestore(&ieee->lock, flags);
5771 }
5772  
5773 -int ieee80211_register_crypto_ops(struct ieee80211_crypto_ops *ops)
5774 +int ieee80211_register_crypto_ops_rtl7(struct ieee80211_crypto_ops *ops)
5775 {
5776 unsigned long flags;
5777 struct ieee80211_crypto_alg *alg;
5778 @@ -128,7 +133,7 @@
5779 return 0;
5780 }
5781  
5782 -int ieee80211_unregister_crypto_ops(struct ieee80211_crypto_ops *ops)
5783 +int ieee80211_unregister_crypto_ops_rtl7(struct ieee80211_crypto_ops *ops)
5784 {
5785 unsigned long flags;
5786 struct list_head *ptr;
5787 @@ -159,7 +164,7 @@
5788 }
5789  
5790  
5791 -struct ieee80211_crypto_ops * ieee80211_get_crypto_ops(const char *name)
5792 +struct ieee80211_crypto_ops * ieee80211_get_crypto_ops_rtl7(const char *name)
5793 {
5794 unsigned long flags;
5795 struct list_head *ptr;
5796 @@ -186,13 +191,13 @@
5797 }
5798  
5799  
5800 -static void * ieee80211_crypt_null_init(int keyidx) { return (void *) 1; }
5801 -static void ieee80211_crypt_null_deinit(void *priv) {}
5802 +static void * ieee80211_crypt_null_init_rtl7(int keyidx) { return (void *) 1; }
5803 +static void ieee80211_crypt_null_deinit_rtl7(void *priv) {}
5804  
5805 static struct ieee80211_crypto_ops ieee80211_crypt_null = {
5806 .name = "NULL",
5807 - .init = ieee80211_crypt_null_init,
5808 - .deinit = ieee80211_crypt_null_deinit,
5809 + .init = ieee80211_crypt_null_init_rtl7,
5810 + .deinit = ieee80211_crypt_null_deinit_rtl7,
5811 .encrypt_mpdu = NULL,
5812 .decrypt_mpdu = NULL,
5813 .encrypt_msdu = NULL,
5814 @@ -205,7 +210,7 @@
5815 };
5816  
5817  
5818 -static int __init ieee80211_crypto_init(void)
5819 +static int __init ieee80211_crypto_init_rtl7(void)
5820 {
5821 int ret = -ENOMEM;
5822  
5823 @@ -217,7 +222,7 @@
5824 INIT_LIST_HEAD(&hcrypt->algs);
5825 spin_lock_init(&hcrypt->lock);
5826  
5827 - ret = ieee80211_register_crypto_ops(&ieee80211_crypt_null);
5828 + ret = ieee80211_register_crypto_ops_rtl7(&ieee80211_crypt_null);
5829 if (ret < 0) {
5830 kfree(hcrypt);
5831 hcrypt = NULL;
5832 @@ -227,7 +232,7 @@
5833 }
5834  
5835  
5836 -static void __exit ieee80211_crypto_deinit(void)
5837 +static void __exit ieee80211_crypto_deinit_rtl7(void)
5838 {
5839 struct list_head *ptr, *n;
5840  
5841 @@ -247,13 +252,13 @@
5842 kfree(hcrypt);
5843 }
5844  
5845 -EXPORT_SYMBOL(ieee80211_crypt_deinit_entries);
5846 -EXPORT_SYMBOL(ieee80211_crypt_deinit_handler);
5847 -EXPORT_SYMBOL(ieee80211_crypt_delayed_deinit);
5848 -
5849 -EXPORT_SYMBOL(ieee80211_register_crypto_ops);
5850 -EXPORT_SYMBOL(ieee80211_unregister_crypto_ops);
5851 -EXPORT_SYMBOL(ieee80211_get_crypto_ops);
5852 +EXPORT_SYMBOL(ieee80211_crypt_deinit_entries_rtl7);
5853 +EXPORT_SYMBOL(ieee80211_crypt_deinit_handler_rtl7);
5854 +EXPORT_SYMBOL(ieee80211_crypt_delayed_deinit_rtl7);
5855 +
5856 +EXPORT_SYMBOL(ieee80211_register_crypto_ops_rtl7);
5857 +EXPORT_SYMBOL(ieee80211_unregister_crypto_ops_rtl7);
5858 +EXPORT_SYMBOL(ieee80211_get_crypto_ops_rtl7);
5859  
5860 -module_init(ieee80211_crypto_init);
5861 -module_exit(ieee80211_crypto_deinit);
5862 +module_init(ieee80211_crypto_init_rtl7);
5863 +module_exit(ieee80211_crypto_deinit_rtl7);
5864 diff -Naur rtl8187_orig/ieee80211/ieee80211_crypt_ccmp.c rtl8187_rawtx/ieee80211/ieee80211_crypt_ccmp.c
5865 --- rtl8187_orig/ieee80211/ieee80211_crypt_ccmp.c 2007-03-13 23:45:09.000000000 +0100
5866 +++ rtl8187_rawtx/ieee80211/ieee80211_crypt_ccmp.c 2007-07-13 01:46:05.000000000 +0200
5867 @@ -9,7 +9,6 @@
5868 * more details.
5869 */
5870  
5871 -#include <linux/config.h>
5872 #include <linux/version.h>
5873 #include <linux/module.h>
5874 #include <linux/init.h>
5875 @@ -22,11 +21,22 @@
5876 #include <asm/string.h>
5877 #include <linux/wireless.h>
5878  
5879 +#if (LINUX_VERSION_CODE < KERNEL_VERSION(2,6,19))
5880 +#include <linux/config.h>
5881 +#else
5882 +#include <linux/autoconf.h>
5883 +#endif
5884 +
5885 #include "ieee80211.h"
5886  
5887  
5888 #include <linux/crypto.h>
5889 -#include <asm/scatterlist.h>
5890 +
5891 +#if LINUX_VERSION_CODE < KERNEL_VERSION(2,6,20)
5892 + #include <asm/scatterlist.h>
5893 +#else
5894 + #include <linux/scatterlist.h>
5895 +#endif
5896  
5897 MODULE_AUTHOR("Jouni Malinen");
5898 MODULE_DESCRIPTION("Host AP crypt: CCMP");
5899 @@ -51,7 +61,11 @@
5900  
5901 int key_idx;
5902  
5903 +#if (LINUX_VERSION_CODE < KERNEL_VERSION(2,6,19))
5904 struct crypto_tfm *tfm;
5905 +#else
5906 + struct crypto_cipher *tfm;
5907 +#endif
5908  
5909 /* scratch buffers for virt_to_page() (crypto API) */
5910 u8 tx_b0[AES_BLOCK_LEN], tx_b[AES_BLOCK_LEN],
5911 @@ -59,7 +73,8 @@
5912 u8 rx_b0[AES_BLOCK_LEN], rx_b[AES_BLOCK_LEN], rx_a[AES_BLOCK_LEN];
5913 };
5914  
5915 -void ieee80211_ccmp_aes_encrypt(struct crypto_tfm *tfm,
5916 +#if (LINUX_VERSION_CODE < KERNEL_VERSION(2,6,19))
5917 +void ieee80211_ccmp_aes_encrypt_rtl7(struct crypto_tfm *tfm,
5918 const u8 pt[16], u8 ct[16])
5919 {
5920 struct scatterlist src, dst;
5921 @@ -74,8 +89,15 @@
5922  
5923 crypto_cipher_encrypt(tfm, &dst, &src, AES_BLOCK_LEN);
5924 }
5925 +#else
5926 +static inline void ieee80211_ccmp_aes_encrypt_rtl7(struct crypto_cipher *tfm,
5927 + const u8 pt[16], u8 ct[16])
5928 +{
5929 + crypto_cipher_encrypt_one(tfm, ct, pt);
5930 +}
5931 +#endif
5932  
5933 -static void * ieee80211_ccmp_init(int key_idx)
5934 +static void * ieee80211_ccmp_init_rtl7(int key_idx)
5935 {
5936 struct ieee80211_ccmp_data *priv;
5937  
5938 @@ -85,19 +107,33 @@
5939 memset(priv, 0, sizeof(*priv));
5940 priv->key_idx = key_idx;
5941  
5942 +#if (LINUX_VERSION_CODE < KERNEL_VERSION(2,6,19))
5943 priv->tfm = crypto_alloc_tfm("aes", 0);
5944 if (priv->tfm == NULL) {
5945 printk(KERN_DEBUG "ieee80211_crypt_ccmp: could not allocate "
5946 "crypto API aes\n");
5947 goto fail;
5948 }
5949 +#else
5950 + priv->tfm = crypto_alloc_cipher("aes", 0, CRYPTO_ALG_ASYNC);
5951 + if (IS_ERR(priv->tfm)) {
5952 + printk(KERN_DEBUG "ieee80211_crypt_ccmp: could not allocate "
5953 + "crypto API aes\n");
5954 + priv->tfm = NULL;
5955 + goto fail;
5956 + }
5957 +#endif
5958  
5959 return priv;
5960  
5961 fail:
5962 if (priv) {
5963 if (priv->tfm)
5964 +#if (LINUX_VERSION_CODE < KERNEL_VERSION(2,6,19))
5965 crypto_free_tfm(priv->tfm);
5966 +#else
5967 + crypto_free_cipher(priv->tfm);
5968 +#endif
5969 kfree(priv);
5970 }
5971  
5972 @@ -105,16 +141,20 @@
5973 }
5974  
5975  
5976 -static void ieee80211_ccmp_deinit(void *priv)
5977 +static void ieee80211_ccmp_deinit_rtl7(void *priv)
5978 {
5979 struct ieee80211_ccmp_data *_priv = priv;
5980 if (_priv && _priv->tfm)
5981 +#if (LINUX_VERSION_CODE < KERNEL_VERSION(2,6,19))
5982 crypto_free_tfm(_priv->tfm);
5983 +#else
5984 + crypto_free_cipher(_priv->tfm);
5985 +#endif
5986 kfree(priv);
5987 }
5988  
5989  
5990 -static inline void xor_block(u8 *b, u8 *a, size_t len)
5991 +static inline void xor_block_rtl7(u8 *b, u8 *a, size_t len)
5992 {
5993 int i;
5994 for (i = 0; i < len; i++)
5995 @@ -122,7 +162,11 @@
5996 }
5997  
5998  
5999 -static void ccmp_init_blocks(struct crypto_tfm *tfm,
6000 +#if (LINUX_VERSION_CODE < KERNEL_VERSION(2,6,19))
6001 +static void ccmp_init_blocks_rtl7(struct crypto_tfm *tfm,
6002 +#else
6003 +static void ccmp_init_blocks_rtl7(struct crypto_cipher *tfm,
6004 +#endif
6005 struct ieee80211_hdr *hdr,
6006 u8 *pn, size_t dlen, u8 *b0, u8 *auth,
6007 u8 *s0)
6008 @@ -186,18 +230,18 @@
6009 }
6010  
6011 /* Start with the first block and AAD */
6012 - ieee80211_ccmp_aes_encrypt(tfm, b0, auth);
6013 - xor_block(auth, aad, AES_BLOCK_LEN);
6014 - ieee80211_ccmp_aes_encrypt(tfm, auth, auth);
6015 - xor_block(auth, &aad[AES_BLOCK_LEN], AES_BLOCK_LEN);
6016 - ieee80211_ccmp_aes_encrypt(tfm, auth, auth);
6017 + ieee80211_ccmp_aes_encrypt_rtl7(tfm, b0, auth);
6018 + xor_block_rtl7(auth, aad, AES_BLOCK_LEN);
6019 + ieee80211_ccmp_aes_encrypt_rtl7(tfm, auth, auth);
6020 + xor_block_rtl7(auth, &aad[AES_BLOCK_LEN], AES_BLOCK_LEN);
6021 + ieee80211_ccmp_aes_encrypt_rtl7(tfm, auth, auth);
6022 b0[0] &= 0x07;
6023 b0[14] = b0[15] = 0;
6024 - ieee80211_ccmp_aes_encrypt(tfm, b0, s0);
6025 + ieee80211_ccmp_aes_encrypt_rtl7(tfm, b0, s0);
6026 }
6027  
6028  
6029 -static int ieee80211_ccmp_encrypt(struct sk_buff *skb, int hdr_len, void *priv)
6030 +static int ieee80211_ccmp_encrypt_rtl7(struct sk_buff *skb, int hdr_len, void *priv)
6031 {
6032 struct ieee80211_ccmp_data *key = priv;
6033 int data_len, i, blocks, last, len;
6034 @@ -237,7 +281,7 @@
6035 *pos++ = key->tx_pn[0];
6036  
6037 hdr = (struct ieee80211_hdr *) skb->data;
6038 - ccmp_init_blocks(key->tfm, hdr, key->tx_pn, data_len, b0, b, s0);
6039 + ccmp_init_blocks_rtl7(key->tfm, hdr, key->tx_pn, data_len, b0, b, s0);
6040  
6041 blocks = (data_len + AES_BLOCK_LEN - 1) / AES_BLOCK_LEN;
6042 last = data_len % AES_BLOCK_LEN;
6043 @@ -245,13 +289,13 @@
6044 for (i = 1; i <= blocks; i++) {
6045 len = (i == blocks && last) ? last : AES_BLOCK_LEN;
6046 /* Authentication */
6047 - xor_block(b, pos, len);
6048 - ieee80211_ccmp_aes_encrypt(key->tfm, b, b);
6049 + xor_block_rtl7(b, pos, len);
6050 + ieee80211_ccmp_aes_encrypt_rtl7(key->tfm, b, b);
6051 /* Encryption, with counter */
6052 b0[14] = (i >> 8) & 0xff;
6053 b0[15] = i & 0xff;
6054 - ieee80211_ccmp_aes_encrypt(key->tfm, b0, e);
6055 - xor_block(pos, e, len);
6056 + ieee80211_ccmp_aes_encrypt_rtl7(key->tfm, b0, e);
6057 + xor_block_rtl7(pos, e, len);
6058 pos += len;
6059 }
6060  
6061 @@ -262,7 +306,7 @@
6062 }
6063  
6064  
6065 -static int ieee80211_ccmp_decrypt(struct sk_buff *skb, int hdr_len, void *priv)
6066 +static int ieee80211_ccmp_decrypt_rtl7(struct sk_buff *skb, int hdr_len, void *priv)
6067 {
6068 struct ieee80211_ccmp_data *key = priv;
6069 u8 keyidx, *pos;
6070 @@ -326,8 +370,8 @@
6071 return -4;
6072 }
6073  
6074 - ccmp_init_blocks(key->tfm, hdr, pn, data_len, b0, a, b);
6075 - xor_block(mic, b, CCMP_MIC_LEN);
6076 + ccmp_init_blocks_rtl7(key->tfm, hdr, pn, data_len, b0, a, b);
6077 + xor_block_rtl7(mic, b, CCMP_MIC_LEN);
6078  
6079 blocks = (data_len + AES_BLOCK_LEN - 1) / AES_BLOCK_LEN;
6080 last = data_len % AES_BLOCK_LEN;
6081 @@ -337,11 +381,11 @@
6082 /* Decrypt, with counter */
6083 b0[14] = (i >> 8) & 0xff;
6084 b0[15] = i & 0xff;
6085 - ieee80211_ccmp_aes_encrypt(key->tfm, b0, b);
6086 - xor_block(pos, b, len);
6087 + ieee80211_ccmp_aes_encrypt_rtl7(key->tfm, b0, b);
6088 + xor_block_rtl7(pos, b, len);
6089 /* Authentication */
6090 - xor_block(a, pos, len);
6091 - ieee80211_ccmp_aes_encrypt(key->tfm, a, a);
6092 + xor_block_rtl7(a, pos, len);
6093 + ieee80211_ccmp_aes_encrypt_rtl7(key->tfm, a, a);
6094 pos += len;
6095 }
6096  
6097 @@ -365,11 +409,15 @@
6098 }
6099  
6100  
6101 -static int ieee80211_ccmp_set_key(void *key, int len, u8 *seq, void *priv)
6102 +static int ieee80211_ccmp_set_key_rtl7(void *key, int len, u8 *seq, void *priv)
6103 {
6104 struct ieee80211_ccmp_data *data = priv;
6105 int keyidx;
6106 +#if (LINUX_VERSION_CODE < KERNEL_VERSION(2,6,19))
6107 struct crypto_tfm *tfm = data->tfm;
6108 +#else
6109 + struct crypto_cipher *tfm = data->tfm;
6110 +#endif
6111  
6112 keyidx = data->key_idx;
6113 memset(data, 0, sizeof(*data));
6114 @@ -396,7 +444,7 @@
6115 }
6116  
6117  
6118 -static int ieee80211_ccmp_get_key(void *key, int len, u8 *seq, void *priv)
6119 +static int ieee80211_ccmp_get_key_rtl7(void *key, int len, u8 *seq, void *priv)
6120 {
6121 struct ieee80211_ccmp_data *data = priv;
6122  
6123 @@ -420,7 +468,7 @@
6124 }
6125  
6126  
6127 -static char * ieee80211_ccmp_print_stats(char *p, void *priv)
6128 +static char * ieee80211_ccmp_print_stats_rtl7(char *p, void *priv)
6129 {
6130 struct ieee80211_ccmp_data *ccmp = priv;
6131 p += sprintf(p, "key[%d] alg=CCMP key_set=%d "
6132 @@ -437,34 +485,34 @@
6133 }
6134  
6135  
6136 -static struct ieee80211_crypto_ops ieee80211_crypt_ccmp = {
6137 +static struct ieee80211_crypto_ops ieee80211_crypt_ccmp_rtl7 = {
6138 .name = "CCMP",
6139 - .init = ieee80211_ccmp_init,
6140 - .deinit = ieee80211_ccmp_deinit,
6141 - .encrypt_mpdu = ieee80211_ccmp_encrypt,
6142 - .decrypt_mpdu = ieee80211_ccmp_decrypt,
6143 + .init = ieee80211_ccmp_init_rtl7,
6144 + .deinit = ieee80211_ccmp_deinit_rtl7,
6145 + .encrypt_mpdu = ieee80211_ccmp_encrypt_rtl7,
6146 + .decrypt_mpdu = ieee80211_ccmp_decrypt_rtl7,
6147 .encrypt_msdu = NULL,
6148 .decrypt_msdu = NULL,
6149 - .set_key = ieee80211_ccmp_set_key,
6150 - .get_key = ieee80211_ccmp_get_key,
6151 - .print_stats = ieee80211_ccmp_print_stats,
6152 + .set_key = ieee80211_ccmp_set_key_rtl7,
6153 + .get_key = ieee80211_ccmp_get_key_rtl7,
6154 + .print_stats = ieee80211_ccmp_print_stats_rtl7,
6155 .extra_prefix_len = CCMP_HDR_LEN,
6156 .extra_postfix_len = CCMP_MIC_LEN,
6157 .owner = THIS_MODULE,
6158 };
6159  
6160  
6161 -static int __init ieee80211_crypto_ccmp_init(void)
6162 +static int __init ieee80211_crypto_ccmp_init_rtl7(void)
6163 {
6164 - return ieee80211_register_crypto_ops(&ieee80211_crypt_ccmp);
6165 + return ieee80211_register_crypto_ops_rtl7(&ieee80211_crypt_ccmp_rtl7);
6166 }
6167  
6168  
6169 -static void __exit ieee80211_crypto_ccmp_exit(void)
6170 +static void __exit ieee80211_crypto_ccmp_exit_rtl7(void)
6171 {
6172 - ieee80211_unregister_crypto_ops(&ieee80211_crypt_ccmp);
6173 + ieee80211_unregister_crypto_ops_rtl7(&ieee80211_crypt_ccmp_rtl7);
6174 }
6175  
6176  
6177 -module_init(ieee80211_crypto_ccmp_init);
6178 -module_exit(ieee80211_crypto_ccmp_exit);
6179 +module_init(ieee80211_crypto_ccmp_init_rtl7);
6180 +module_exit(ieee80211_crypto_ccmp_exit_rtl7);
6181 diff -Naur rtl8187_orig/ieee80211/ieee80211_crypt.h rtl8187_rawtx/ieee80211/ieee80211_crypt.h
6182 --- rtl8187_orig/ieee80211/ieee80211_crypt.h 2007-03-13 23:45:09.000000000 +0100
6183 +++ rtl8187_rawtx/ieee80211/ieee80211_crypt.h 2007-07-13 01:46:10.000000000 +0200
6184 @@ -75,12 +75,12 @@
6185 atomic_t refcnt;
6186 };
6187  
6188 -int ieee80211_register_crypto_ops(struct ieee80211_crypto_ops *ops);
6189 -int ieee80211_unregister_crypto_ops(struct ieee80211_crypto_ops *ops);
6190 -struct ieee80211_crypto_ops * ieee80211_get_crypto_ops(const char *name);
6191 -void ieee80211_crypt_deinit_entries(struct ieee80211_device *, int);
6192 -void ieee80211_crypt_deinit_handler(unsigned long);
6193 -void ieee80211_crypt_delayed_deinit(struct ieee80211_device *ieee,
6194 +int ieee80211_register_crypto_ops_rtl7(struct ieee80211_crypto_ops *ops);
6195 +int ieee80211_unregister_crypto_ops_rtl7(struct ieee80211_crypto_ops *ops);
6196 +struct ieee80211_crypto_ops * ieee80211_get_crypto_ops_rtl7(const char *name);
6197 +void ieee80211_crypt_deinit_entries_rtl7(struct ieee80211_device *, int);
6198 +void ieee80211_crypt_deinit_handler_rtl7(unsigned long);
6199 +void ieee80211_crypt_delayed_deinit_rtl7(struct ieee80211_device *ieee,
6200 struct ieee80211_crypt_data **crypt);
6201  
6202 #endif
6203 diff -Naur rtl8187_orig/ieee80211/ieee80211_crypt_tkip.c rtl8187_rawtx/ieee80211/ieee80211_crypt_tkip.c
6204 --- rtl8187_orig/ieee80211/ieee80211_crypt_tkip.c 2007-03-13 23:45:09.000000000 +0100
6205 +++ rtl8187_rawtx/ieee80211/ieee80211_crypt_tkip.c 2007-07-13 01:46:05.000000000 +0200
6206 @@ -9,7 +9,6 @@
6207 * more details.
6208 */
6209  
6210 -#include <linux/config.h>
6211 #include <linux/version.h>
6212 #include <linux/module.h>
6213 #include <linux/init.h>
6214 @@ -21,13 +20,24 @@
6215 #include <linux/if_arp.h>
6216 #include <asm/string.h>
6217  
6218 +#if (LINUX_VERSION_CODE < KERNEL_VERSION(2,6,19))
6219 +#include <linux/config.h>
6220 +#else
6221 +#include <linux/autoconf.h>
6222 +#endif
6223 +
6224 #include "ieee80211.h"
6225  
6226 +#if LINUX_VERSION_CODE < KERNEL_VERSION(2,6,20)
6227 + #include <asm/scatterlist.h>
6228 +#else
6229 + #include <linux/scatterlist.h>
6230 +#endif
6231  
6232 #include <linux/crypto.h>
6233 -#include <asm/scatterlist.h>
6234 #include <linux/crc32.h>
6235  
6236 +
6237 MODULE_AUTHOR("Jouni Malinen");
6238 MODULE_DESCRIPTION("Host AP crypt: TKIP");
6239 MODULE_LICENSE("GPL");
6240 @@ -55,14 +65,21 @@
6241  
6242 int key_idx;
6243  
6244 +#if LINUX_VERSION_CODE < KERNEL_VERSION(2,6,19)
6245 struct crypto_tfm *tfm_arc4;
6246 struct crypto_tfm *tfm_michael;
6247 +#else
6248 + struct crypto_blkcipher *rx_tfm_arc4;
6249 + struct crypto_blkcipher *tx_tfm_arc4;
6250 + struct crypto_hash *rx_tfm_michael;
6251 + struct crypto_hash *tx_tfm_michael;
6252 +#endif
6253  
6254 /* scratch buffers for virt_to_page() (crypto API) */
6255 u8 rx_hdr[16], tx_hdr[16];
6256 };
6257  
6258 -static void * ieee80211_tkip_init(int key_idx)
6259 +static void * ieee80211_tkip_init_rtl7(int key_idx)
6260 {
6261 struct ieee80211_tkip_data *priv;
6262  
6263 @@ -72,28 +89,74 @@
6264 memset(priv, 0, sizeof(*priv));
6265 priv->key_idx = key_idx;
6266  
6267 +#if LINUX_VERSION_CODE < KERNEL_VERSION(2,6,19)
6268 priv->tfm_arc4 = crypto_alloc_tfm("arc4", 0);
6269 if (priv->tfm_arc4 == NULL) {
6270 printk(KERN_DEBUG "ieee80211_crypt_tkip: could not allocate "
6271 "crypto API arc4\n");
6272 goto fail;
6273 }
6274 -
6275 priv->tfm_michael = crypto_alloc_tfm("michael_mic", 0);
6276 if (priv->tfm_michael == NULL) {
6277 printk(KERN_DEBUG "ieee80211_crypt_tkip: could not allocate "
6278 "crypto API michael_mic\n");
6279 goto fail;
6280 }
6281 +#else
6282 + priv->tx_tfm_arc4 = crypto_alloc_blkcipher("ecb(arc4)", 0, CRYPTO_ALG_ASYNC);
6283 + if (IS_ERR(priv->tx_tfm_arc4)) {
6284 + printk(KERN_DEBUG "ieee80211_crypt_wep: could not allocate "
6285 + "crypto API arc4\n");
6286 + priv->tx_tfm_arc4 = NULL;
6287 + goto fail;
6288 + }
6289 +
6290 + priv->tx_tfm_michael = crypto_alloc_hash("michael_mic", 0,
6291 + CRYPTO_ALG_ASYNC);
6292 + if (IS_ERR(priv->tx_tfm_michael)) {
6293 + printk(KERN_DEBUG "ieee80211_crypt_tkip: could not allocate "
6294 + "crypto API michael_mic\n");
6295 + priv->tx_tfm_michael = NULL;
6296 + goto fail;
6297 + }
6298 +
6299 + priv->rx_tfm_arc4 = crypto_alloc_blkcipher("ecb(arc4)", 0, CRYPTO_ALG_ASYNC);
6300 + if (IS_ERR(priv->rx_tfm_arc4)) {
6301 + printk(KERN_DEBUG "ieee80211_crypt_wep: could not allocate "
6302 + "crypto API arc4\n");
6303 + priv->rx_tfm_arc4 = NULL;
6304 + goto fail;
6305 + }
6306 +
6307 + priv->rx_tfm_michael = crypto_alloc_hash("michael_mic", 0,
6308 + CRYPTO_ALG_ASYNC);
6309 + if (IS_ERR(priv->rx_tfm_michael)) {
6310 + printk(KERN_DEBUG "ieee80211_crypt_tkip: could not allocate "
6311 + "crypto API michael_mic\n");
6312 + priv->rx_tfm_michael = NULL;
6313 + goto fail;
6314 + }
6315 +#endif
6316  
6317 return priv;
6318  
6319 fail:
6320 if (priv) {
6321 +#if LINUX_VERSION_CODE < KERNEL_VERSION(2,6,19)
6322 if (priv->tfm_michael)
6323 crypto_free_tfm(priv->tfm_michael);
6324 if (priv->tfm_arc4)
6325 crypto_free_tfm(priv->tfm_arc4);
6326 +#else
6327 + if (priv->tx_tfm_michael)
6328 + crypto_free_hash(priv->tx_tfm_michael);
6329 + if (priv->tx_tfm_arc4)
6330 + crypto_free_blkcipher(priv->tx_tfm_arc4);
6331 + if (priv->rx_tfm_michael)
6332 + crypto_free_hash(priv->rx_tfm_michael);
6333 + if (priv->rx_tfm_arc4)
6334 + crypto_free_blkcipher(priv->rx_tfm_arc4);
6335 +#endif
6336 kfree(priv);
6337 }
6338  
6339 @@ -101,13 +164,26 @@
6340 }
6341  
6342  
6343 -static void ieee80211_tkip_deinit(void *priv)
6344 +static void ieee80211_tkip_deinit_rtl7(void *priv)
6345 {
6346 struct ieee80211_tkip_data *_priv = priv;
6347 +#if LINUX_VERSION_CODE < KERNEL_VERSION(2,6,19)
6348 if (_priv && _priv->tfm_michael)
6349 crypto_free_tfm(_priv->tfm_michael);
6350 if (_priv && _priv->tfm_arc4)
6351 crypto_free_tfm(_priv->tfm_arc4);
6352 +#else
6353 + if (_priv) {
6354 + if (_priv->tx_tfm_michael)
6355 + crypto_free_hash(_priv->tx_tfm_michael);
6356 + if (_priv->tx_tfm_arc4)
6357 + crypto_free_blkcipher(_priv->tx_tfm_arc4);
6358 + if (_priv->rx_tfm_michael)
6359 + crypto_free_hash(_priv->rx_tfm_michael);
6360 + if (_priv->rx_tfm_arc4)
6361 + crypto_free_blkcipher(_priv->rx_tfm_arc4);
6362 + }
6363 +#endif
6364 kfree(priv);
6365 }
6366  
6367 @@ -200,7 +276,7 @@
6368  
6369 #define PHASE1_LOOP_COUNT 8
6370  
6371 -static void tkip_mixing_phase1(u16 *TTAK, const u8 *TK, const u8 *TA, u32 IV32)
6372 +static void tkip_mixing_phase1_rtl7(u16 *TTAK, const u8 *TK, const u8 *TA, u32 IV32)
6373 {
6374 int i, j;
6375  
6376 @@ -222,7 +298,7 @@
6377 }
6378  
6379  
6380 -static void tkip_mixing_phase2(u8 *WEPSeed, const u8 *TK, const u16 *TTAK,
6381 +static void tkip_mixing_phase2_rtl7(u8 *WEPSeed, const u8 *TK, const u16 *TTAK,
6382 u16 IV16)
6383 {
6384 /* Make temporary area overlap WEP seed so that the final copy can be
6385 @@ -268,7 +344,7 @@
6386 #endif
6387 }
6388  
6389 -static int ieee80211_tkip_encrypt(struct sk_buff *skb, int hdr_len, void *priv)
6390 +static int ieee80211_tkip_encrypt_rtl7(struct sk_buff *skb, int hdr_len, void *priv)
6391 {
6392 struct ieee80211_tkip_data *tkey = priv;
6393 int len;
6394 @@ -276,6 +352,9 @@
6395 struct ieee80211_hdr *hdr;
6396 u32 crc;
6397 struct scatterlist sg;
6398 +#if (LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,19))
6399 + struct blkcipher_desc desc = { .tfm = tkey->tx_tfm_arc4 };
6400 +#endif
6401  
6402 if (skb_headroom(skb) < 8 || skb_tailroom(skb) < 4 ||
6403 skb->len < hdr_len)
6404 @@ -283,11 +362,11 @@
6405  
6406 hdr = (struct ieee80211_hdr *) skb->data;
6407 if (!tkey->tx_phase1_done) {
6408 - tkip_mixing_phase1(tkey->tx_ttak, tkey->key, hdr->addr2,
6409 + tkip_mixing_phase1_rtl7(tkey->tx_ttak, tkey->key, hdr->addr2,
6410 tkey->tx_iv32);
6411 tkey->tx_phase1_done = 1;
6412 }
6413 - tkip_mixing_phase2(rc4key, tkey->key, tkey->tx_ttak, tkey->tx_iv16);
6414 + tkip_mixing_phase2_rtl7(rc4key, tkey->key, tkey->tx_ttak, tkey->tx_iv16);
6415  
6416 len = skb->len - hdr_len;
6417 pos = skb_push(skb, 8);
6418 @@ -310,11 +389,19 @@
6419 icv[2] = crc >> 16;
6420 icv[3] = crc >> 24;
6421  
6422 +#if (LINUX_VERSION_CODE < KERNEL_VERSION(2,6,19))
6423 crypto_cipher_setkey(tkey->tfm_arc4, rc4key, 16);
6424 +#else
6425 + crypto_blkcipher_setkey(tkey->tx_tfm_arc4, rc4key, 16);
6426 +#endif
6427 sg.page = virt_to_page(pos);
6428 sg.offset = offset_in_page(pos);
6429 sg.length = len + 4;
6430 +#if (LINUX_VERSION_CODE < KERNEL_VERSION(2,6,19))
6431 crypto_cipher_encrypt(tkey->tfm_arc4, &sg, &sg, len + 4);
6432 +#else
6433 + crypto_blkcipher_encrypt(&desc, &sg, &sg, len + 4);
6434 +#endif
6435  
6436 tkey->tx_iv16++;
6437 if (tkey->tx_iv16 == 0) {
6438 @@ -325,7 +412,7 @@
6439 return 0;
6440 }
6441  
6442 -static int ieee80211_tkip_decrypt(struct sk_buff *skb, int hdr_len, void *priv)
6443 +static int ieee80211_tkip_decrypt_rtl7(struct sk_buff *skb, int hdr_len, void *priv)
6444 {
6445 struct ieee80211_tkip_data *tkey = priv;
6446 u8 rc4key[16];
6447 @@ -337,6 +424,9 @@
6448 u32 crc;
6449 struct scatterlist sg;
6450 int plen;
6451 +#if (LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,19))
6452 + struct blkcipher_desc desc = { .tfm = tkey->rx_tfm_arc4 };
6453 +#endif
6454  
6455 if (skb->len < hdr_len + 8 + 4)
6456 return -1;
6457 @@ -382,18 +472,26 @@
6458 }
6459  
6460 if (iv32 != tkey->rx_iv32 || !tkey->rx_phase1_done) {
6461 - tkip_mixing_phase1(tkey->rx_ttak, tkey->key, hdr->addr2, iv32);
6462 + tkip_mixing_phase1_rtl7(tkey->rx_ttak, tkey->key, hdr->addr2, iv32);
6463 tkey->rx_phase1_done = 1;
6464 }
6465 - tkip_mixing_phase2(rc4key, tkey->key, tkey->rx_ttak, iv16);
6466 + tkip_mixing_phase2_rtl7(rc4key, tkey->key, tkey->rx_ttak, iv16);
6467  
6468 plen = skb->len - hdr_len - 12;
6469  
6470 +#if (LINUX_VERSION_CODE < KERNEL_VERSION(2,6,19))
6471 crypto_cipher_setkey(tkey->tfm_arc4, rc4key, 16);
6472 +#else
6473 + crypto_blkcipher_setkey(tkey->rx_tfm_arc4, rc4key, 16);
6474 +#endif
6475 sg.page = virt_to_page(pos);
6476 sg.offset = offset_in_page(pos);
6477 sg.length = plen + 4;
6478 +#if (LINUX_VERSION_CODE < KERNEL_VERSION(2,6,19))
6479 crypto_cipher_decrypt(tkey->tfm_arc4, &sg, &sg, plen + 4);
6480 +#else
6481 + crypto_blkcipher_decrypt(&desc, &sg, &sg, plen + 4);
6482 +#endif
6483  
6484 crc = ~crc32_le(~0, pos, plen);
6485 icv[0] = crc;
6486 @@ -427,13 +525,22 @@
6487 return keyidx;
6488 }
6489  
6490 -
6491 -static int michael_mic(struct ieee80211_tkip_data *tkey, u8 *key, u8 *hdr,
6492 +#if LINUX_VERSION_CODE < KERNEL_VERSION(2,6,19)
6493 +static int michael_mic_rtl7(struct ieee80211_tkip_data *tkey, u8 *key, u8 *hdr,
6494 u8 *data, size_t data_len, u8 *mic)
6495 {
6496 struct scatterlist sg[2];
6497  
6498 if (tkey->tfm_michael == NULL) {
6499 +#else
6500 +static int michael_mic_rtl7(struct crypto_hash *tfm_michael, u8 *key, u8 *hdr,
6501 + u8 *data, size_t data_len, u8 *mic)
6502 +{
6503 + struct hash_desc desc;
6504 + struct scatterlist sg[2];
6505 +
6506 + if (tfm_michael == NULL) {
6507 +#endif
6508 printk(KERN_WARNING "michael_mic: tfm_michael == NULL\n");
6509 return -1;
6510 }
6511 @@ -445,15 +552,24 @@
6512 sg[1].offset = offset_in_page(data);
6513 sg[1].length = data_len;
6514  
6515 +#if LINUX_VERSION_CODE < KERNEL_VERSION(2,6,19)
6516 crypto_digest_init(tkey->tfm_michael);
6517 crypto_digest_setkey(tkey->tfm_michael, key, 8);
6518 crypto_digest_update(tkey->tfm_michael, sg, 2);
6519 crypto_digest_final(tkey->tfm_michael, mic);
6520  
6521 return 0;
6522 +#else
6523 + if (crypto_hash_setkey(tfm_michael, key, 8))
6524 + return -1;
6525 +
6526 + desc.tfm = tfm_michael;
6527 + desc.flags = 0;
6528 + return crypto_hash_digest(&desc, sg, data_len + 16, mic);
6529 +#endif
6530 }
6531  
6532 -static void michael_mic_hdr(struct sk_buff *skb, u8 *hdr)
6533 +static void michael_mic_hdr_rtl7(struct sk_buff *skb, u8 *hdr)
6534 {
6535 struct ieee80211_hdr *hdr11;
6536  
6537 @@ -483,7 +599,7 @@
6538 }
6539  
6540  
6541 -static int ieee80211_michael_mic_add(struct sk_buff *skb, int hdr_len, void *priv)
6542 +static int ieee80211_michael_mic_add_rtl7(struct sk_buff *skb, int hdr_len, void *priv)
6543 {
6544 struct ieee80211_tkip_data *tkey = priv;
6545 u8 *pos;
6546 @@ -495,18 +611,24 @@
6547 return -1;
6548 }
6549  
6550 - michael_mic_hdr(skb, tkey->tx_hdr);
6551 + michael_mic_hdr_rtl7(skb, tkey->tx_hdr);
6552 pos = skb_put(skb, 8);
6553 - if (michael_mic(tkey, &tkey->key[16], tkey->tx_hdr,
6554 +#if LINUX_VERSION_CODE < KERNEL_VERSION(2,6,19)
6555 + if (michael_mic_rtl7(tkey, &tkey->key[16], tkey->tx_hdr,
6556 skb->data + hdr_len, skb->len - 8 - hdr_len, pos))
6557 return -1;
6558 +#else
6559 + if (michael_mic_rtl7(tkey->tx_tfm_michael, &tkey->key[16], tkey->tx_hdr,
6560 + skb->data + hdr_len, skb->len - 8 - hdr_len, pos))
6561 + return -1;
6562 +#endif
6563  
6564 return 0;
6565 }
6566  
6567  
6568 #if WIRELESS_EXT >= 18
6569 -static void ieee80211_michael_mic_failure(struct net_device *dev,
6570 +static void ieee80211_michael_mic_failure_rtl7(struct net_device *dev,
6571 struct ieee80211_hdr *hdr,
6572 int keyidx)
6573 {
6574 @@ -527,7 +649,7 @@
6575 wireless_send_event(dev, IWEVMICHAELMICFAILURE, &wrqu, (char *) &ev);
6576 }
6577 #elif WIRELESS_EXT >= 15
6578 -static void ieee80211_michael_mic_failure(struct net_device *dev,
6579 +static void ieee80211_michael_mic_failure_rtl7(struct net_device *dev,
6580 struct ieee80211_hdr *hdr,
6581 int keyidx)
6582 {
6583 @@ -543,7 +665,7 @@
6584 wireless_send_event(dev, IWEVCUSTOM, &wrqu, buf);
6585 }
6586 #else /* WIRELESS_EXT >= 15 */
6587 -static inline void ieee80211_michael_mic_failure(struct net_device *dev,
6588 +static inline void ieee80211_michael_mic_failure_rtl7(struct net_device *dev,
6589 struct ieee80211_hdr *hdr,
6590 int keyidx)
6591 {
6592 @@ -551,7 +673,7 @@
6593 #endif /* WIRELESS_EXT >= 15 */
6594  
6595  
6596 -static int ieee80211_michael_mic_verify(struct sk_buff *skb, int keyidx,
6597 +static int ieee80211_michael_mic_verify_rtl7(struct sk_buff *skb, int keyidx,
6598 int hdr_len, void *priv)
6599 {
6600 struct ieee80211_tkip_data *tkey = priv;
6601 @@ -560,10 +682,16 @@
6602 if (!tkey->key_set)
6603 return -1;
6604  
6605 - michael_mic_hdr(skb, tkey->rx_hdr);
6606 - if (michael_mic(tkey, &tkey->key[24], tkey->rx_hdr,
6607 + michael_mic_hdr_rtl7(skb, tkey->rx_hdr);
6608 +#if LINUX_VERSION_CODE < KERNEL_VERSION(2,6,19)
6609 + if (michael_mic_rtl7(tkey, &tkey->key[24], tkey->rx_hdr,
6610 skb->data + hdr_len, skb->len - 8 - hdr_len, mic))
6611 return -1;
6612 +#else
6613 + if (michael_mic_rtl7(tkey->rx_tfm_michael, &tkey->key[24], tkey->rx_hdr,
6614 + skb->data + hdr_len, skb->len - 8 - hdr_len, mic))
6615 + return -1;
6616 +#endif
6617 if (memcmp(mic, skb->data + skb->len - 8, 8) != 0) {
6618 struct ieee80211_hdr *hdr;
6619 hdr = (struct ieee80211_hdr *) skb->data;
6620 @@ -572,7 +700,7 @@
6621 skb->dev ? skb->dev->name : "N/A", MAC_ARG(hdr->addr2),
6622 keyidx);
6623 if (skb->dev)
6624 - ieee80211_michael_mic_failure(skb->dev, hdr, keyidx);
6625 + ieee80211_michael_mic_failure_rtl7(skb->dev, hdr, keyidx);
6626 tkey->dot11RSNAStatsTKIPLocalMICFailures++;
6627 return -1;
6628 }
6629 @@ -588,18 +716,33 @@
6630 }
6631  
6632  
6633 -static int ieee80211_tkip_set_key(void *key, int len, u8 *seq, void *priv)
6634 +static int ieee80211_tkip_set_key_rtl7(void *key, int len, u8 *seq, void *priv)
6635 {
6636 struct ieee80211_tkip_data *tkey = priv;
6637 int keyidx;
6638 +#if (LINUX_VERSION_CODE < KERNEL_VERSION(2,6,19))
6639 struct crypto_tfm *tfm = tkey->tfm_michael;
6640 struct crypto_tfm *tfm2 = tkey->tfm_arc4;
6641 +#else
6642 + struct crypto_hash *tfm = tkey->tx_tfm_michael;
6643 + struct crypto_blkcipher *tfm2 = tkey->tx_tfm_arc4;
6644 + struct crypto_hash *tfm3 = tkey->rx_tfm_michael;
6645 + struct crypto_blkcipher *tfm4 = tkey->rx_tfm_arc4;
6646 +#endif
6647  
6648 keyidx = tkey->key_idx;
6649 memset(tkey, 0, sizeof(*tkey));
6650 tkey->key_idx = keyidx;
6651 +#if (LINUX_VERSION_CODE < KERNEL_VERSION(2,6,19))
6652 tkey->tfm_michael = tfm;
6653 tkey->tfm_arc4 = tfm2;
6654 +#else
6655 + tkey->tx_tfm_michael = tfm;
6656 + tkey->tx_tfm_arc4 = tfm2;
6657 + tkey->rx_tfm_michael = tfm3;
6658 + tkey->rx_tfm_arc4 = tfm4;
6659 +#endif
6660 +
6661 if (len == TKIP_KEY_LEN) {
6662 memcpy(tkey->key, key, TKIP_KEY_LEN);
6663 tkey->key_set = 1;
6664 @@ -618,7 +761,7 @@
6665 }
6666  
6667  
6668 -static int ieee80211_tkip_get_key(void *key, int len, u8 *seq, void *priv)
6669 +static int ieee80211_tkip_get_key_rtl7(void *key, int len, u8 *seq, void *priv)
6670 {
6671 struct ieee80211_tkip_data *tkey = priv;
6672  
6673 @@ -648,7 +791,7 @@
6674 }
6675  
6676  
6677 -static char * ieee80211_tkip_print_stats(char *p, void *priv)
6678 +static char * ieee80211_tkip_print_stats_rtl7(char *p, void *priv)
6679 {
6680 struct ieee80211_tkip_data *tkip = priv;
6681 p += sprintf(p, "key[%d] alg=TKIP key_set=%d "
6682 @@ -675,34 +818,34 @@
6683 }
6684  
6685  
6686 -static struct ieee80211_crypto_ops ieee80211_crypt_tkip = {
6687 +static struct ieee80211_crypto_ops ieee80211_crypt_tkip_rtl7 = {
6688 .name = "TKIP",
6689 - .init = ieee80211_tkip_init,
6690 - .deinit = ieee80211_tkip_deinit,
6691 - .encrypt_mpdu = ieee80211_tkip_encrypt,
6692 - .decrypt_mpdu = ieee80211_tkip_decrypt,
6693 - .encrypt_msdu = ieee80211_michael_mic_add,
6694 - .decrypt_msdu = ieee80211_michael_mic_verify,
6695 - .set_key = ieee80211_tkip_set_key,
6696 - .get_key = ieee80211_tkip_get_key,
6697 - .print_stats = ieee80211_tkip_print_stats,
6698 + .init = ieee80211_tkip_init_rtl7,
6699 + .deinit = ieee80211_tkip_deinit_rtl7,
6700 + .encrypt_mpdu = ieee80211_tkip_encrypt_rtl7,
6701 + .decrypt_mpdu = ieee80211_tkip_decrypt_rtl7,
6702 + .encrypt_msdu = ieee80211_michael_mic_add_rtl7,
6703 + .decrypt_msdu = ieee80211_michael_mic_verify_rtl7,
6704 + .set_key = ieee80211_tkip_set_key_rtl7,
6705 + .get_key = ieee80211_tkip_get_key_rtl7,
6706 + .print_stats = ieee80211_tkip_print_stats_rtl7,
6707 .extra_prefix_len = 4 + 4, /* IV + ExtIV */
6708 .extra_postfix_len = 8 + 4, /* MIC + ICV */
6709 .owner = THIS_MODULE,
6710 };
6711  
6712  
6713 -static int __init ieee80211_crypto_tkip_init(void)
6714 +static int __init ieee80211_crypto_tkip_init_rtl7(void)
6715 {
6716 - return ieee80211_register_crypto_ops(&ieee80211_crypt_tkip);
6717 + return ieee80211_register_crypto_ops_rtl7(&ieee80211_crypt_tkip_rtl7);
6718 }
6719  
6720  
6721 -static void __exit ieee80211_crypto_tkip_exit(void)
6722 +static void __exit ieee80211_crypto_tkip_exit_rtl7(void)
6723 {
6724 - ieee80211_unregister_crypto_ops(&ieee80211_crypt_tkip);
6725 + ieee80211_unregister_crypto_ops_rtl7(&ieee80211_crypt_tkip_rtl7);
6726 }
6727  
6728  
6729 -module_init(ieee80211_crypto_tkip_init);
6730 -module_exit(ieee80211_crypto_tkip_exit);
6731 +module_init(ieee80211_crypto_tkip_init_rtl7);
6732 +module_exit(ieee80211_crypto_tkip_exit_rtl7);
6733 diff -Naur rtl8187_orig/ieee80211/ieee80211_crypt_wep.c rtl8187_rawtx/ieee80211/ieee80211_crypt_wep.c
6734 --- rtl8187_orig/ieee80211/ieee80211_crypt_wep.c 2007-03-13 23:45:09.000000000 +0100
6735 +++ rtl8187_rawtx/ieee80211/ieee80211_crypt_wep.c 2007-07-13 01:46:05.000000000 +0200
6736 @@ -9,7 +9,6 @@
6737 * more details.
6738 */
6739  
6740 -#include <linux/config.h>
6741 #include <linux/version.h>
6742 #include <linux/module.h>
6743 #include <linux/init.h>
6744 @@ -18,13 +17,24 @@
6745 #include <linux/skbuff.h>
6746 #include <asm/string.h>
6747  
6748 +#if (LINUX_VERSION_CODE < KERNEL_VERSION(2,6,19))
6749 +#include <linux/config.h>
6750 +#else
6751 +#include <linux/autoconf.h>
6752 +#endif
6753 +
6754 #include "ieee80211.h"
6755  
6756  
6757 #include <linux/crypto.h>
6758 -#include <asm/scatterlist.h>
6759 #include <linux/crc32.h>
6760  
6761 +#if LINUX_VERSION_CODE < KERNEL_VERSION(2,6,20)
6762 + #include <asm/scatterlist.h>
6763 +#else
6764 + #include <linux/scatterlist.h>
6765 +#endif
6766 +
6767 MODULE_AUTHOR("Jouni Malinen");
6768 MODULE_DESCRIPTION("Host AP crypt: WEP");
6769 MODULE_LICENSE("GPL");
6770 @@ -36,11 +46,16 @@
6771 u8 key[WEP_KEY_LEN + 1];
6772 u8 key_len;
6773 u8 key_idx;
6774 +#if LINUX_VERSION_CODE < KERNEL_VERSION(2,6,19)
6775 struct crypto_tfm *tfm;
6776 +#else
6777 + struct crypto_blkcipher *rx_tfm;
6778 + struct crypto_blkcipher *tx_tfm;
6779 +#endif
6780 };
6781  
6782  
6783 -static void * prism2_wep_init(int keyidx)
6784 +static void * prism2_wep_init_rtl7(int keyidx)
6785 {
6786 struct prism2_wep_data *priv;
6787  
6788 @@ -50,13 +65,30 @@
6789 memset(priv, 0, sizeof(*priv));
6790 priv->key_idx = keyidx;
6791  
6792 +#if LINUX_VERSION_CODE < KERNEL_VERSION(2,6,19)
6793 priv->tfm = crypto_alloc_tfm("arc4", 0);
6794 if (priv->tfm == NULL) {
6795 printk(KERN_DEBUG "ieee80211_crypt_wep: could not allocate "
6796 "crypto API arc4\n");
6797 goto fail;
6798 }
6799 +#else
6800 + priv->tx_tfm = crypto_alloc_blkcipher("ecb(arc4)", 0, CRYPTO_ALG_ASYNC);
6801 + if (IS_ERR(priv->tx_tfm)) {
6802 + printk(KERN_DEBUG "ieee80211_crypt_wep: could not allocate "
6803 + "crypto API arc4\n");
6804 + priv->tx_tfm = NULL;
6805 + goto fail;
6806 + }
6807  
6808 + priv->rx_tfm = crypto_alloc_blkcipher("ecb(arc4)", 0, CRYPTO_ALG_ASYNC);
6809 + if (IS_ERR(priv->rx_tfm)) {
6810 + printk(KERN_DEBUG "ieee80211_crypt_wep: could not allocate "
6811 + "crypto API arc4\n");
6812 + priv->rx_tfm = NULL;
6813 + goto fail;
6814 + }
6815 +#endif
6816 /* start WEP IV from a random value */
6817 get_random_bytes(&priv->iv, 4);
6818  
6819 @@ -64,19 +96,35 @@
6820  
6821 fail:
6822 if (priv) {
6823 +#if LINUX_VERSION_CODE < KERNEL_VERSION(2,6,19)
6824 if (priv->tfm)
6825 crypto_free_tfm(priv->tfm);
6826 +#else
6827 + if (priv->tx_tfm)
6828 + crypto_free_blkcipher(priv->tx_tfm);
6829 + if (priv->rx_tfm)
6830 + crypto_free_blkcipher(priv->rx_tfm);
6831 +#endif
6832 kfree(priv);
6833 }
6834 return NULL;
6835 }
6836  
6837  
6838 -static void prism2_wep_deinit(void *priv)
6839 +static void prism2_wep_deinit_rtl7(void *priv)
6840 {
6841 struct prism2_wep_data *_priv = priv;
6842 +#if LINUX_VERSION_CODE < KERNEL_VERSION(2,6,19)
6843 if (_priv && _priv->tfm)
6844 crypto_free_tfm(_priv->tfm);
6845 +#else
6846 + if (_priv) {
6847 + if (_priv->tx_tfm)
6848 + crypto_free_blkcipher(_priv->tx_tfm);
6849 + if (_priv->rx_tfm)
6850 + crypto_free_blkcipher(_priv->rx_tfm);
6851 + }
6852 +#endif
6853 kfree(priv);
6854 }
6855  
6856 @@ -87,13 +135,16 @@
6857 *
6858 * WEP frame payload: IV + TX key idx, RC4(data), ICV = RC4(CRC32(data))
6859 */
6860 -static int prism2_wep_encrypt(struct sk_buff *skb, int hdr_len, void *priv)
6861 +static int prism2_wep_encrypt_rtl7(struct sk_buff *skb, int hdr_len, void *priv)
6862 {
6863 struct prism2_wep_data *wep = priv;
6864 u32 crc, klen, len;
6865 u8 key[WEP_KEY_LEN + 3];
6866 u8 *pos, *icv;
6867 struct scatterlist sg;
6868 +#if (LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,19))
6869 + struct blkcipher_desc desc = { .tfm = wep->tx_tfm };
6870 +#endif
6871  
6872 if (skb_headroom(skb) < 4 || skb_tailroom(skb) < 4 ||
6873 skb->len < hdr_len)
6874 @@ -134,13 +185,21 @@
6875 icv[2] = crc >> 16;
6876 icv[3] = crc >> 24;
6877  
6878 +#if (LINUX_VERSION_CODE < KERNEL_VERSION(2,6,19))
6879 crypto_cipher_setkey(wep->tfm, key, klen);
6880 +#else
6881 + crypto_blkcipher_setkey(wep->tx_tfm, key, klen);
6882 +#endif
6883 sg.page = virt_to_page(pos);
6884 sg.offset = offset_in_page(pos);
6885 sg.length = len + 4;
6886 - crypto_cipher_encrypt(wep->tfm, &sg, &sg, len + 4);
6887  
6888 +#if (LINUX_VERSION_CODE < KERNEL_VERSION(2,6,19))
6889 + crypto_cipher_encrypt(wep->tfm, &sg, &sg, len + 4);
6890 return 0;
6891 +#else
6892 + return crypto_blkcipher_encrypt(&desc, &sg, &sg, len + 4);
6893 +#endif
6894 }
6895  
6896  
6897 @@ -151,13 +210,16 @@
6898 * Returns 0 if frame was decrypted successfully and ICV was correct and -1 on
6899 * failure. If frame is OK, IV and ICV will be removed.
6900 */
6901 -static int prism2_wep_decrypt(struct sk_buff *skb, int hdr_len, void *priv)
6902 +static int prism2_wep_decrypt_rtl7(struct sk_buff *skb, int hdr_len, void *priv)
6903 {
6904 struct prism2_wep_data *wep = priv;
6905 u32 crc, klen, plen;
6906 u8 key[WEP_KEY_LEN + 3];
6907 u8 keyidx, *pos, icv[4];
6908 struct scatterlist sg;
6909 +#if (LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,19))
6910 + struct blkcipher_desc desc = { .tfm = wep->rx_tfm };
6911 +#endif
6912  
6913 if (skb->len < hdr_len + 8)
6914 return -1;
6915 @@ -178,11 +240,22 @@
6916 /* Apply RC4 to data and compute CRC32 over decrypted data */
6917 plen = skb->len - hdr_len - 8;
6918  
6919 +#if (LINUX_VERSION_CODE < KERNEL_VERSION(2,6,19))
6920 crypto_cipher_setkey(wep->tfm, key, klen);
6921 +#else
6922 + crypto_blkcipher_setkey(wep->rx_tfm, key, klen);
6923 +#endif
6924 +
6925 sg.page = virt_to_page(pos);
6926 sg.offset = offset_in_page(pos);
6927 sg.length = plen + 4;
6928 +
6929 +#if (LINUX_VERSION_CODE < KERNEL_VERSION(2,6,19))
6930 crypto_cipher_decrypt(wep->tfm, &sg, &sg, plen + 4);
6931 +#else
6932 + if(crypto_blkcipher_decrypt(&desc, &sg, &sg, plen + 4))
6933 + return -7;
6934 +#endif
6935  
6936 crc = ~crc32_le(~0, pos, plen);
6937 icv[0] = crc;
6938 @@ -203,7 +276,7 @@
6939 }
6940  
6941  
6942 -static int prism2_wep_set_key(void *key, int len, u8 *seq, void *priv)
6943 +static int prism2_wep_set_key_rtl7(void *key, int len, u8 *seq, void *priv)
6944 {
6945 struct prism2_wep_data *wep = priv;
6946  
6947 @@ -217,7 +290,7 @@
6948 }
6949  
6950  
6951 -static int prism2_wep_get_key(void *key, int len, u8 *seq, void *priv)
6952 +static int prism2_wep_get_key_rtl7(void *key, int len, u8 *seq, void *priv)
6953 {
6954 struct prism2_wep_data *wep = priv;
6955  
6956 @@ -230,7 +303,7 @@
6957 }
6958  
6959  
6960 -static char * prism2_wep_print_stats(char *p, void *priv)
6961 +static char * prism2_wep_print_stats_rtl7(char *p, void *priv)
6962 {
6963 struct prism2_wep_data *wep = priv;
6964 p += sprintf(p, "key[%d] alg=WEP len=%d\n",
6965 @@ -239,34 +312,34 @@
6966 }
6967  
6968  
6969 -static struct ieee80211_crypto_ops ieee80211_crypt_wep = {
6970 +static struct ieee80211_crypto_ops ieee80211_crypt_wep_rtl7 = {
6971 .name = "WEP",
6972 - .init = prism2_wep_init,
6973 - .deinit = prism2_wep_deinit,
6974 - .encrypt_mpdu = prism2_wep_encrypt,
6975 - .decrypt_mpdu = prism2_wep_decrypt,
6976 + .init = prism2_wep_init_rtl7,
6977 + .deinit = prism2_wep_deinit_rtl7,
6978 + .encrypt_mpdu = prism2_wep_encrypt_rtl7,
6979 + .decrypt_mpdu = prism2_wep_decrypt_rtl7,
6980 .encrypt_msdu = NULL,
6981 .decrypt_msdu = NULL,
6982 - .set_key = prism2_wep_set_key,
6983 - .get_key = prism2_wep_get_key,
6984 - .print_stats = prism2_wep_print_stats,
6985 + .set_key = prism2_wep_set_key_rtl7,
6986 + .get_key = prism2_wep_get_key_rtl7,
6987 + .print_stats = prism2_wep_print_stats_rtl7,
6988 .extra_prefix_len = 4, /* IV */
6989 .extra_postfix_len = 4, /* ICV */
6990 .owner = THIS_MODULE,
6991 };
6992  
6993  
6994 -static int __init ieee80211_crypto_wep_init(void)
6995 +static int __init ieee80211_crypto_wep_init_rtl7(void)
6996 {
6997 - return ieee80211_register_crypto_ops(&ieee80211_crypt_wep);
6998 + return ieee80211_register_crypto_ops_rtl7(&ieee80211_crypt_wep_rtl7);
6999 }
7000  
7001  
7002 -static void __exit ieee80211_crypto_wep_exit(void)
7003 +static void __exit ieee80211_crypto_wep_exit_rtl7(void)
7004 {
7005 - ieee80211_unregister_crypto_ops(&ieee80211_crypt_wep);
7006 + ieee80211_unregister_crypto_ops_rtl7(&ieee80211_crypt_wep_rtl7);
7007 }
7008  
7009  
7010 -module_init(ieee80211_crypto_wep_init);
7011 -module_exit(ieee80211_crypto_wep_exit);
7012 +module_init(ieee80211_crypto_wep_init_rtl7);
7013 +module_exit(ieee80211_crypto_wep_exit_rtl7);
7014 diff -Naur rtl8187_orig/ieee80211/ieee80211.h rtl8187_rawtx/ieee80211/ieee80211.h
7015 --- rtl8187_orig/ieee80211/ieee80211.h 2007-03-13 23:45:09.000000000 +0100
7016 +++ rtl8187_rawtx/ieee80211/ieee80211.h 2007-07-13 01:46:10.000000000 +0200
7017 @@ -120,7 +120,7 @@
7018 static inline unsigned long msleep_interruptible_rtl(unsigned int msecs)
7019 {
7020 unsigned long timeout = MSECS(msecs) + 1;
7021 -
7022 +
7023 while (timeout) {
7024 set_current_state(TASK_UNINTERRUPTIBLE);
7025 timeout = schedule_timeout(timeout);
7026 @@ -156,6 +156,22 @@
7027 struct list_head list;
7028 };
7029  
7030 +#define LWNG_CAP_DID_BASE (4 | (1 << 6)) /* section 4, group 1 */
7031 +/* ARPHRD_IEEE80211_PRISM uses a bloated version of Prism2 RX frame header
7032 + * (from linux-wlan-ng) */
7033 +struct linux_wlan_ng_val {
7034 + u32 did;
7035 + u16 status, len;
7036 + u32 data;
7037 +} __attribute__ ((packed));
7038 +
7039 +struct linux_wlan_ng_prism_hdr {
7040 + u32 msgcode, msglen;
7041 + char devname[16];
7042 + struct linux_wlan_ng_val hosttime, mactime, channel, rssi, sq, signal,
7043 + noise, rate, istx, frmlen;
7044 +} __attribute__ ((packed));
7045 +
7046 struct ieee80211_hdr {
7047 u16 frame_ctl;
7048 u16 duration_id;
7049 @@ -798,7 +814,7 @@
7050  
7051 /* the card is not linked at all */
7052 IEEE80211_NOLINK = 0,
7053 -
7054 +
7055 /* IEEE80211_ASSOCIATING* are for BSS client mode
7056 * the driver shall not perform RX filtering unless
7057 * the state is LINKED.
7058 @@ -806,31 +822,31 @@
7059 * defaults to NOLINK for ALL the other states (including
7060 * LINKED_SCANNING)
7061 */
7062 -
7063 +
7064 /* the association procedure will start (wq scheduling)*/
7065 IEEE80211_ASSOCIATING,
7066 IEEE80211_ASSOCIATING_RETRY,
7067 -
7068 +
7069 /* the association procedure is sending AUTH request*/
7070 IEEE80211_ASSOCIATING_AUTHENTICATING,
7071 -
7072 +
7073 /* the association procedure has successfully authentcated
7074 * and is sending association request
7075 */
7076 IEEE80211_ASSOCIATING_AUTHENTICATED,
7077 -
7078 +
7079 /* the link is ok. the card associated to a BSS or linked
7080 * to a ibss cell or acting as an AP and creating the bss
7081 */
7082 IEEE80211_LINKED,
7083 -
7084 +
7085 /* same as LINKED, but the driver shall apply RX filter
7086 * rules as we are in NO_LINK mode. As the card is still
7087 * logically linked, but it is doing a syncro site survey
7088 * then it will be back to LINKED state.
7089 */
7090 IEEE80211_LINKED_SCANNING,
7091 -
7092 +
7093 };
7094  
7095 #define DEFAULT_MAX_SCAN_AGE (15 * HZ)
7096 @@ -840,14 +856,14 @@
7097  
7098  
7099 #if (LINUX_VERSION_CODE <= KERNEL_VERSION(2,6,11))
7100 -extern inline int is_multicast_ether_addr(const u8 *addr)
7101 +extern inline int is_multicast_ether_addr_rtl7(const u8 *addr)
7102 {
7103 return ((addr[0] != 0xff) && (0x01 & addr[0]));
7104 }
7105 #endif
7106  
7107 #if (LINUX_VERSION_CODE <= KERNEL_VERSION(2,6,13))
7108 -extern inline int is_broadcast_ether_addr(const u8 *addr)
7109 +extern inline int is_broadcast_ether_addr_rtl7(const u8 *addr)
7110 {
7111 return ((addr[0] == 0xff) && (addr[1] == 0xff) && (addr[2] == 0xff) && \
7112 (addr[3] == 0xff) && (addr[4] == 0xff) && (addr[5] == 0xff));
7113 @@ -870,7 +886,7 @@
7114 struct net_device_stats stats;
7115 struct ieee80211_stats ieee_stats;
7116 struct ieee80211_softmac_stats softmac_stats;
7117 -
7118 +
7119 /* Probe / Beacon management */
7120 struct list_head network_free_list;
7121 struct list_head network_list;
7122 @@ -881,7 +897,7 @@
7123 int iw_mode; /* operating mode (IW_MODE_*) */
7124  
7125 spinlock_t lock;
7126 -
7127 +
7128 int tx_headroom; /* Set to size of any additional room needed at front
7129 * of allocated Tx SKBs */
7130 u32 config;
7131 @@ -924,11 +940,11 @@
7132 * ad-hoc is a mixture ;-).
7133 * Note that in infrastructure mode, even when not associated,
7134 * fields bssid and essid may be valid (if wpa_set and essid_set
7135 - * are true) as thy carry the value set by the user via iwconfig
7136 + * are true) as thy carry the value set by the user via iwconfig
7137 */
7138 struct ieee80211_network current_network;
7139  
7140 -
7141 +
7142 enum ieee80211_state state;
7143  
7144 int short_slot;
7145 @@ -936,33 +952,33 @@
7146 int modulation; /* CCK, OFDM */
7147 int freq_band; /* 2.4Ghz, 5.2Ghz, Mixed */
7148 int abg_true; /* ABG flag */
7149 -
7150 - /* used for forcing the ibss workqueue to terminate
7151 +
7152 + /* used for forcing the ibss workqueue to terminate
7153 * without wait for the syncro scan to terminate
7154 */
7155 - short sync_scan_hurryup;
7156 -
7157 + short sync_scan_hurryup;
7158 +
7159 /* map of allowed channels. 0 is dummy */
7160 // FIXME: remeber to default to a basic channel plan depending of the PHY type
7161 int channel_map[MAX_CHANNEL_NUMBER+1];
7162 -
7163 +
7164 int rate; /* current rate */
7165 int basic_rate;
7166 //FIXME: pleace callback, see if redundant with softmac_features
7167 short active_scan;
7168 -
7169 +
7170 /* this contains flags for selectively enable softmac support */
7171 u16 softmac_features;
7172 -
7173 +
7174 /* if the sequence control field is not filled by HW */
7175 u16 seq_ctrl;
7176 -
7177 +
7178 /* association procedure transaction sequence number */
7179 u16 associate_seq;
7180 -
7181 +
7182 /* AID for RTXed association responses */
7183 u16 assoc_id;
7184 -
7185 +
7186 /* power save mode related*/
7187 short ps;
7188 short sta_sleep;
7189 @@ -970,147 +986,153 @@
7190 struct tasklet_struct ps_task;
7191 u32 ps_th;
7192 u32 ps_tl;
7193 -
7194 +
7195 short raw_tx;
7196 /* used if IEEE_SOFTMAC_TX_QUEUE is set */
7197 short queue_stop;
7198 short scanning;
7199 short proto_started;
7200 -
7201 +
7202 struct semaphore wx_sem;
7203 struct semaphore scan_sem;
7204 -
7205 - spinlock_t mgmt_tx_lock;
7206 +
7207 + spinlock_t mgmt_tx_lock;
7208 spinlock_t beacon_lock;
7209  
7210 short beacon_txing;
7211  
7212 short wap_set;
7213 short ssid_set;
7214 -
7215 +
7216 /* for discarding duplicated packets in IBSS */
7217 struct list_head ibss_mac_hash[IEEE_IBSS_MAC_HASH_SIZE];
7218 -
7219 +
7220 /* for discarding duplicated packets in BSS */
7221 u16 last_seq_num;
7222 u16 last_frag_num;
7223 unsigned long last_packet_time;
7224 -
7225 +
7226 /* for PS mode */
7227 unsigned long last_rx_ps_time;
7228 -
7229 +
7230 /* used if IEEE_SOFTMAC_SINGLE_QUEUE is set */
7231 struct sk_buff *mgmt_queue_ring[MGMT_QUEUE_NUM];
7232 int mgmt_queue_head;
7233 int mgmt_queue_tail;
7234 -
7235 -
7236 +
7237 +
7238 /* used if IEEE_SOFTMAC_TX_QUEUE is set */
7239 struct tx_pending_t tx_pending;
7240 -
7241 +
7242 /* used if IEEE_SOFTMAC_ASSOCIATE is set */
7243 struct timer_list associate_timer;
7244  
7245 /* used if IEEE_SOFTMAC_BEACONS is set */
7246 struct timer_list beacon_timer;
7247 -
7248 +
7249 struct work_struct associate_complete_wq;
7250 +
7251 +# if (LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,20))
7252 + struct delayed_work associate_retry_wq;
7253 + struct delayed_work softmac_scan_wq;
7254 +#else
7255 struct work_struct associate_retry_wq;
7256 + struct work_struct softmac_scan_wq;
7257 +#endif
7258 struct work_struct start_ibss_wq;
7259 struct work_struct associate_procedure_wq;
7260 - struct work_struct softmac_scan_wq;
7261 struct work_struct wx_sync_scan_wq;
7262 -
7263 +
7264 struct workqueue_struct *wq;
7265 /* Callback functions */
7266 void (*set_security)(struct net_device *dev,
7267 struct ieee80211_security *sec);
7268 -
7269 +
7270 /* Used to TX data frame by using txb structs.
7271 * this is not used if in the softmac_features
7272 * is set the flag IEEE_SOFTMAC_TX_QUEUE
7273 */
7274 int (*hard_start_xmit)(struct ieee80211_txb *txb,
7275 struct net_device *dev);
7276 -
7277 +
7278 int (*reset_port)(struct net_device *dev);
7279  
7280 - /* Softmac-generated frames (mamagement) are TXed via this
7281 - * callback if the flag IEEE_SOFTMAC_SINGLE_QUEUE is
7282 - * not set. As some cards may have different HW queues that
7283 + /* Softmac-generated frames (mamagement) are TXed via this
7284 + * callback if the flag IEEE_SOFTMAC_SINGLE_QUEUE is
7285 + * not set. As some cards may have different HW queues that
7286 * one might want to use for data and management frames
7287 * the option to have two callbacks might be useful.
7288 * This fucntion can't sleep.
7289 */
7290 int (*softmac_hard_start_xmit)(struct sk_buff *skb,
7291 struct net_device *dev);
7292 -
7293 +
7294 /* used instead of hard_start_xmit (not softmac_hard_start_xmit)
7295 * if the IEEE_SOFTMAC_TX_QUEUE feature is used to TX data
7296 * frames. I the option IEEE_SOFTMAC_SINGLE_QUEUE is also set
7297 * then also management frames are sent via this callback.
7298 * This function can't sleep.
7299 - */
7300 + */
7301 void (*softmac_data_hard_start_xmit)(struct sk_buff *skb,
7302 struct net_device *dev,int rate);
7303  
7304 /* stops the HW queue for DATA frames. Useful to avoid
7305 * waste time to TX data frame when we are reassociating
7306 * This function can sleep.
7307 - */
7308 + */
7309 void (*data_hard_stop)(struct net_device *dev);
7310 -
7311 +
7312 /* OK this is complementar to data_poll_hard_stop */
7313 void (*data_hard_resume)(struct net_device *dev);
7314 -
7315 +
7316 /* ask to the driver to retune the radio .
7317 * This function can sleep. the driver should ensure
7318 * the radio has been swithced before return.
7319 */
7320 void (*set_chan)(struct net_device *dev,short ch);
7321 -
7322 +
7323 /* These are not used if the ieee stack takes care of
7324 - * scanning (IEEE_SOFTMAC_SCAN feature set).
7325 + * scanning (IEEE_SOFTMAC_SCAN feature set).
7326 * In this case only the set_chan is used.
7327 *
7328 * The syncro version is similar to the start_scan but
7329 * does not return until all channels has been scanned.
7330 - * this is called in user context and should sleep,
7331 + * this is called in user context and should sleep,
7332 * it is called in a work_queue when swithcing to ad-hoc mode
7333 - * or in behalf of iwlist scan when the card is associated
7334 - * and root user ask for a scan.
7335 + * or in behalf of iwlist scan when the card is associated
7336 + * and root user ask for a scan.
7337 * the fucntion stop_scan should stop both the syncro and
7338 * background scanning and can sleep.
7339 - * The fucntion start_scan should initiate the background
7340 + * The fucntion start_scan should initiate the background
7341 * scanning and can't sleep.
7342 - */
7343 + */
7344 void (*scan_syncro)(struct net_device *dev);
7345 void (*start_scan)(struct net_device *dev);
7346 void (*stop_scan)(struct net_device *dev);
7347 -
7348 +
7349 /* indicate the driver that the link state is changed
7350 * for example it may indicate the card is associated now.
7351 - * Driver might be interested in this to apply RX filter
7352 - * rules or simply light the LINK led
7353 + * Driver might be interested in this to apply RX filter
7354 + * rules or simply light the LINK led
7355 */
7356 void (*link_change)(struct net_device *dev);
7357 -
7358 +
7359 /* these two function indicates to the HW when to start
7360 - * and stop to send beacons. This is used when the
7361 + * and stop to send beacons. This is used when the
7362 * IEEE_SOFTMAC_BEACONS is not set. For now the
7363 * stop_send_bacons is NOT guaranteed to be called only
7364 * after start_send_beacons.
7365 */
7366 void (*start_send_beacons) (struct net_device *dev);
7367 void (*stop_send_beacons) (struct net_device *dev);
7368 -
7369 +
7370 /* power save mode related */
7371 void (*sta_wake_up) (struct net_device *dev);
7372 void (*ps_request_tx_ack) (struct net_device *dev);
7373 void (*enter_sleep_state) (struct net_device *dev, u32 th, u32 tl);
7374 short (*ps_is_queue_empty) (struct net_device *dev);
7375 -
7376 -
7377 +
7378 +
7379 /* This must be the last item so that it points to the data
7380 * allocated beyond this structure by alloc_ieee80211 */
7381 u8 priv[0];
7382 @@ -1148,18 +1170,18 @@
7383 #define IEEE_SOFTMAC_SINGLE_QUEUE (1<<8)
7384  
7385 /* Generate beacons. The stack will enqueue beacons
7386 - * to the card
7387 - */
7388 + * to the card
7389 + */
7390 #define IEEE_SOFTMAC_BEACONS (1<<6)
7391  
7392  
7393  
7394 -extern inline void *ieee80211_priv(struct net_device *dev)
7395 +extern inline void *ieee80211_priv_rtl7(struct net_device *dev)
7396 {
7397 return ((struct ieee80211_device *)netdev_priv(dev))->priv;
7398 }
7399  
7400 -extern inline int ieee80211_is_empty_essid(const char *essid, int essid_len)
7401 +extern inline int ieee80211_is_empty_essid_rtl7(const char *essid, int essid_len)
7402 {
7403 /* Single white space is for Linksys APs */
7404 if (essid_len == 1 && essid[0] == ' ')
7405 @@ -1175,7 +1197,7 @@
7406 return 1;
7407 }
7408  
7409 -extern inline int ieee80211_is_valid_mode(struct ieee80211_device *ieee, int mode)
7410 +extern inline int ieee80211_is_valid_mode_rtl7(struct ieee80211_device *ieee, int mode)
7411 {
7412 /*
7413 * It is possible for both access points and our device to support
7414 @@ -1201,7 +1223,7 @@
7415 return 0;
7416 }
7417  
7418 -extern inline int ieee80211_get_hdrlen(u16 fc)
7419 +extern inline int ieee80211_get_hdrlen_rtl7(u16 fc)
7420 {
7421 int hdrlen = 24;
7422  
7423 @@ -1229,140 +1251,144 @@
7424  
7425  
7426 /* ieee80211.c */
7427 -extern void free_ieee80211(struct net_device *dev);
7428 -extern struct net_device *alloc_ieee80211(int sizeof_priv);
7429 +extern void free_ieee80211_rtl7(struct net_device *dev);
7430 +extern struct net_device *alloc_ieee80211_rtl7(int sizeof_priv);
7431  
7432 -extern int ieee80211_set_encryption(struct ieee80211_device *ieee);
7433 +extern int ieee80211_set_encryption_rtl7(struct ieee80211_device *ieee);
7434  
7435 /* ieee80211_tx.c */
7436  
7437 -extern int ieee80211_encrypt_fragment(
7438 +extern int ieee80211_encrypt_fragment_rtl7(
7439 struct ieee80211_device *ieee,
7440 struct sk_buff *frag,
7441 int hdr_len);
7442 -
7443 -extern int ieee80211_xmit(struct sk_buff *skb,
7444 +
7445 +extern int ieee80211_xmit_rtl7(struct sk_buff *skb,
7446 struct net_device *dev);
7447 -extern void ieee80211_txb_free(struct ieee80211_txb *);
7448 +extern void ieee80211_txb_free_rtl7(struct ieee80211_txb *);
7449  
7450  
7451 /* ieee80211_rx.c */
7452 -extern int ieee80211_rx(struct ieee80211_device *ieee, struct sk_buff *skb,
7453 +extern int ieee80211_rx_rtl7(struct ieee80211_device *ieee, struct sk_buff *skb,
7454 struct ieee80211_rx_stats *rx_stats);
7455 -extern void ieee80211_rx_mgt(struct ieee80211_device *ieee,
7456 +extern void ieee80211_rx_mgt_rtl7(struct ieee80211_device *ieee,
7457 struct ieee80211_hdr *header,
7458 struct ieee80211_rx_stats *stats);
7459  
7460 /* ieee80211_wx.c */
7461 -extern int ieee80211_wx_get_scan(struct ieee80211_device *ieee,
7462 +extern int ieee80211_wx_get_scan_rtl7(struct ieee80211_device *ieee,
7463 struct iw_request_info *info,
7464 union iwreq_data *wrqu, char *key);
7465 -extern int ieee80211_wx_set_encode(struct ieee80211_device *ieee,
7466 +extern int ieee80211_wx_set_encode_rtl7(struct ieee80211_device *ieee,
7467 struct iw_request_info *info,
7468 union iwreq_data *wrqu, char *key);
7469 -extern int ieee80211_wx_get_encode(struct ieee80211_device *ieee,
7470 +extern int ieee80211_wx_get_encode_rtl7(struct ieee80211_device *ieee,
7471 struct iw_request_info *info,
7472 union iwreq_data *wrqu, char *key);
7473 /* ieee80211_softmac.c */
7474 -extern short ieee80211_is_54g(struct ieee80211_network net);
7475 -extern short ieee80211_is_shortslot(struct ieee80211_network net);
7476 -extern int ieee80211_rx_frame_softmac(struct ieee80211_device *ieee, struct sk_buff *skb,
7477 +extern short ieee80211_is_54g_rtl7(struct ieee80211_network net);
7478 +extern short ieee80211_is_shortslot_rtl7(struct ieee80211_network net);
7479 +extern int ieee80211_rx_frame_softmac_rtl7(struct ieee80211_device *ieee, struct sk_buff *skb,
7480 struct ieee80211_rx_stats *rx_stats, u16 type,
7481 u16 stype);
7482 -extern void ieee80211_softmac_new_net(struct ieee80211_device *ieee, struct ieee80211_network *net);
7483 +extern void ieee80211_softmac_new_net_rtl7(struct ieee80211_device *ieee, struct ieee80211_network *net);
7484  
7485 -extern void ieee80211_softmac_xmit(struct ieee80211_txb *txb, struct ieee80211_device *ieee);
7486 -extern void ieee80211_softmac_check_all_nets(struct ieee80211_device *ieee);
7487 -extern void ieee80211_start_bss(struct ieee80211_device *ieee);
7488 -extern void ieee80211_start_master_bss(struct ieee80211_device *ieee);
7489 -extern void ieee80211_start_ibss(struct ieee80211_device *ieee);
7490 -extern void ieee80211_softmac_init(struct ieee80211_device *ieee);
7491 -extern void ieee80211_softmac_free(struct ieee80211_device *ieee);
7492 -extern void ieee80211_associate_abort(struct ieee80211_device *ieee);
7493 -extern void ieee80211_disassociate(struct ieee80211_device *ieee);
7494 -extern void ieee80211_stop_scan(struct ieee80211_device *ieee);
7495 -extern void ieee80211_start_scan_syncro(struct ieee80211_device *ieee);
7496 -extern void ieee80211_check_all_nets(struct ieee80211_device *ieee);
7497 -extern void ieee80211_start_protocol(struct ieee80211_device *ieee);
7498 -extern void ieee80211_stop_protocol(struct ieee80211_device *ieee);
7499 -extern void ieee80211_softmac_start_protocol(struct ieee80211_device *ieee);
7500 -extern void ieee80211_softmac_stop_protocol(struct ieee80211_device *ieee);
7501 -extern void ieee80211_reset_queue(struct ieee80211_device *ieee);
7502 -extern void ieee80211_wake_queue(struct ieee80211_device *ieee);
7503 -extern void ieee80211_stop_queue(struct ieee80211_device *ieee);
7504 -extern struct sk_buff *ieee80211_get_beacon(struct ieee80211_device *ieee);
7505 -extern void ieee80211_start_send_beacons(struct ieee80211_device *ieee);
7506 -extern void ieee80211_stop_send_beacons(struct ieee80211_device *ieee);
7507 -extern int ieee80211_wpa_supplicant_ioctl(struct ieee80211_device *ieee, struct iw_point *p);
7508 -extern void notify_wx_assoc_event(struct ieee80211_device *ieee);
7509 -extern void ieee80211_ps_tx_ack(struct ieee80211_device *ieee, short success);
7510 +extern void ieee80211_softmac_xmit_rtl7(struct ieee80211_txb *txb, struct ieee80211_device *ieee);
7511 +extern void ieee80211_softmac_check_all_nets_rtl7(struct ieee80211_device *ieee);
7512 +extern void ieee80211_start_bss_rtl7(struct ieee80211_device *ieee);
7513 +extern void ieee80211_start_master_bss_rtl7(struct ieee80211_device *ieee);
7514 +extern void ieee80211_start_ibss_rtl7(struct ieee80211_device *ieee);
7515 +extern void ieee80211_softmac_init_rtl7(struct ieee80211_device *ieee);
7516 +extern void ieee80211_softmac_free_rtl7(struct ieee80211_device *ieee);
7517 +extern void ieee80211_associate_abort_rtl7(struct ieee80211_device *ieee);
7518 +extern void ieee80211_disassociate_rtl7(struct ieee80211_device *ieee);
7519 +extern void ieee80211_stop_scan_rtl7(struct ieee80211_device *ieee);
7520 +extern void ieee80211_start_scan_syncro_rtl7(struct ieee80211_device *ieee);
7521 +extern void ieee80211_check_all_nets_rtl7(struct ieee80211_device *ieee);
7522 +extern void ieee80211_start_protocol_rtl7(struct ieee80211_device *ieee);
7523 +extern void ieee80211_stop_protocol_rtl7(struct ieee80211_device *ieee);
7524 +extern void ieee80211_softmac_start_protocol_rtl7(struct ieee80211_device *ieee);
7525 +extern void ieee80211_softmac_stop_protocol_rtl7(struct ieee80211_device *ieee);
7526 +extern void ieee80211_reset_queue_rtl7(struct ieee80211_device *ieee);
7527 +extern void ieee80211_wake_queue_rtl7(struct ieee80211_device *ieee);
7528 +extern void ieee80211_stop_queue_rtl7(struct ieee80211_device *ieee);
7529 +extern struct sk_buff *ieee80211_get_beacon_rtl7(struct ieee80211_device *ieee);
7530 +extern void ieee80211_start_send_beacons_rtl7(struct ieee80211_device *ieee);
7531 +extern void ieee80211_stop_send_beacons_rtl7(struct ieee80211_device *ieee);
7532 +extern int ieee80211_wpa_supplicant_ioctl_rtl7(struct ieee80211_device *ieee, struct iw_point *p);
7533 +extern void notify_wx_assoc_event_rtl7(struct ieee80211_device *ieee);
7534 +extern void ieee80211_ps_tx_ack_rtl7(struct ieee80211_device *ieee, short success);
7535  
7536 /* ieee80211_softmac_wx.c */
7537  
7538 -extern int ieee80211_wx_get_wap(struct ieee80211_device *ieee,
7539 - struct iw_request_info *info,
7540 +extern int ieee80211_wx_get_wap_rtl7(struct ieee80211_device *ieee,
7541 + struct iw_request_info *info,
7542 union iwreq_data *wrqu, char *ext);
7543 -
7544 -extern int ieee80211_wx_set_wap(struct ieee80211_device *ieee,
7545 +
7546 +extern int ieee80211_wx_set_wap_rtl7(struct ieee80211_device *ieee,
7547 struct iw_request_info *info,
7548 union iwreq_data *awrq,
7549 char *extra);
7550 -
7551 -extern int ieee80211_wx_get_essid(struct ieee80211_device *ieee, struct iw_request_info *a,union iwreq_data *wrqu,char *b);
7552  
7553 -extern int ieee80211_wx_set_rate(struct ieee80211_device *ieee,
7554 +extern int ieee80211_wx_get_essid_rtl7(struct ieee80211_device *ieee, struct iw_request_info *a,union iwreq_data *wrqu,char *b);
7555 +
7556 +extern int ieee80211_wx_set_rate_rtl7(struct ieee80211_device *ieee,
7557 struct iw_request_info *info,
7558 union iwreq_data *wrqu, char *extra);
7559 -
7560 -extern int ieee80211_wx_get_rate(struct ieee80211_device *ieee,
7561 - struct iw_request_info *info,
7562 +
7563 +extern int ieee80211_wx_get_rate_rtl7(struct ieee80211_device *ieee,
7564 + struct iw_request_info *info,
7565 union iwreq_data *wrqu, char *extra);
7566 -
7567 -extern int ieee80211_wx_set_mode(struct ieee80211_device *ieee, struct iw_request_info *a,
7568 +
7569 +extern int ieee80211_wx_set_mode_rtl7(struct ieee80211_device *ieee, struct iw_request_info *a,
7570 union iwreq_data *wrqu, char *b);
7571 -
7572 -extern int ieee80211_wx_set_scan(struct ieee80211_device *ieee, struct iw_request_info *a,
7573 +
7574 +extern int ieee80211_wx_set_scan_rtl7(struct ieee80211_device *ieee, struct iw_request_info *a,
7575 union iwreq_data *wrqu, char *b);
7576 -
7577 -extern int ieee80211_wx_set_essid(struct ieee80211_device *ieee,
7578 +
7579 +extern int ieee80211_wx_set_essid_rtl7(struct ieee80211_device *ieee,
7580 struct iw_request_info *a,
7581 union iwreq_data *wrqu, char *extra);
7582 -
7583 -extern int ieee80211_wx_get_mode(struct ieee80211_device *ieee, struct iw_request_info *a,
7584 +
7585 +extern int ieee80211_wx_get_mode_rtl7(struct ieee80211_device *ieee, struct iw_request_info *a,
7586 union iwreq_data *wrqu, char *b);
7587  
7588 -extern int ieee80211_wx_set_freq(struct ieee80211_device *ieee, struct iw_request_info *a,
7589 +extern int ieee80211_wx_set_freq_rtl7(struct ieee80211_device *ieee, struct iw_request_info *a,
7590 union iwreq_data *wrqu, char *b);
7591  
7592 -extern int ieee80211_wx_get_freq(struct ieee80211_device *ieee, struct iw_request_info *a,
7593 +extern int ieee80211_wx_get_freq_rtl7(struct ieee80211_device *ieee, struct iw_request_info *a,
7594 union iwreq_data *wrqu, char *b);
7595  
7596 -extern void ieee80211_wx_sync_scan_wq(struct ieee80211_device *ieee);
7597 +# if (LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,20))
7598 +extern void ieee80211_wx_sync_scan_wq_rtl7(struct work_struct *work);
7599 +#else
7600 +extern void ieee80211_wx_sync_scan_wq_rtl7(struct ieee80211_device *ieee);
7601 +#endif
7602  
7603 -extern int ieee80211_wx_set_rawtx(struct ieee80211_device *ieee,
7604 - struct iw_request_info *info,
7605 +extern int ieee80211_wx_set_rawtx_rtl7(struct ieee80211_device *ieee,
7606 + struct iw_request_info *info,
7607 union iwreq_data *wrqu, char *extra);
7608 -
7609 -extern int ieee80211_wx_get_name(struct ieee80211_device *ieee,
7610 - struct iw_request_info *info,
7611 +
7612 +extern int ieee80211_wx_get_name_rtl7(struct ieee80211_device *ieee,
7613 + struct iw_request_info *info,
7614 union iwreq_data *wrqu, char *extra);
7615  
7616 -extern int ieee80211_wx_set_power(struct ieee80211_device *ieee,
7617 +extern int ieee80211_wx_set_power_rtl7(struct ieee80211_device *ieee,
7618 struct iw_request_info *info,
7619 union iwreq_data *wrqu, char *extra);
7620  
7621 -extern int ieee80211_wx_get_power(struct ieee80211_device *ieee,
7622 +extern int ieee80211_wx_get_power_rtl7(struct ieee80211_device *ieee,
7623 struct iw_request_info *info,
7624 union iwreq_data *wrqu, char *extra);
7625 -
7626 -extern const long ieee80211_wlan_frequencies[];
7627  
7628 -extern inline void ieee80211_increment_scans(struct ieee80211_device *ieee)
7629 +extern const long ieee80211_wlan_frequencies_rtl7[];
7630 +
7631 +extern inline void ieee80211_increment_scans_rtl7(struct ieee80211_device *ieee)
7632 {
7633 ieee->scans++;
7634 }
7635  
7636 -extern inline int ieee80211_get_scans(struct ieee80211_device *ieee)
7637 +extern inline int ieee80211_get_scans_rtl7(struct ieee80211_device *ieee)
7638 {
7639 return ieee->scans;
7640 }
7641 @@ -1372,7 +1398,7 @@
7642 const char *s = essid;
7643 char *d = escaped;
7644  
7645 - if (ieee80211_is_empty_essid(essid, essid_len)) {
7646 + if (ieee80211_is_empty_essid_rtl7(essid, essid_len)) {
7647 memcpy(escaped, "<hidden>", sizeof("<hidden>"));
7648 return escaped;
7649 }
7650 @@ -1390,4 +1416,5 @@
7651 *d = '\0';
7652 return escaped;
7653 }
7654 +
7655 #endif /* IEEE80211_H */
7656 diff -Naur rtl8187_orig/ieee80211/ieee80211_module.c rtl8187_rawtx/ieee80211/ieee80211_module.c
7657 --- rtl8187_orig/ieee80211/ieee80211_module.c 2007-03-13 23:45:09.000000000 +0100
7658 +++ rtl8187_rawtx/ieee80211/ieee80211_module.c 2007-07-13 01:46:05.000000000 +0200
7659 @@ -31,7 +31,6 @@
7660 *******************************************************************************/
7661  
7662 #include <linux/compiler.h>
7663 -#include <linux/config.h>
7664 #include <linux/errno.h>
7665 #include <linux/if_arp.h>
7666 #include <linux/in6.h>
7667 @@ -52,6 +51,12 @@
7668 #include <asm/uaccess.h>
7669 #include <net/arp.h>
7670  
7671 +#if (LINUX_VERSION_CODE < KERNEL_VERSION(2,6,19))
7672 +#include <linux/config.h>
7673 +#else
7674 +#include <linux/autoconf.h>
7675 +#endif
7676 +
7677 #include "ieee80211.h"
7678  
7679 MODULE_DESCRIPTION("802.11 data/management/control stack");
7680 @@ -60,7 +65,7 @@
7681  
7682 #define DRV_NAME "ieee80211"
7683  
7684 -static inline int ieee80211_networks_allocate(struct ieee80211_device *ieee)
7685 +static inline int ieee80211_networks_allocate_rtl7(struct ieee80211_device *ieee)
7686 {
7687 if (ieee->networks)
7688 return 0;
7689 @@ -80,7 +85,7 @@
7690 return 0;
7691 }
7692  
7693 -static inline void ieee80211_networks_free(struct ieee80211_device *ieee)
7694 +static inline void ieee80211_networks_free_rtl7(struct ieee80211_device *ieee)
7695 {
7696 if (!ieee->networks)
7697 return;
7698 @@ -88,7 +93,7 @@
7699 ieee->networks = NULL;
7700 }
7701  
7702 -static inline void ieee80211_networks_initialize(struct ieee80211_device *ieee)
7703 +static inline void ieee80211_networks_initialize_rtl7(struct ieee80211_device *ieee)
7704 {
7705 int i;
7706  
7707 @@ -99,7 +104,7 @@
7708 }
7709  
7710  
7711 -struct net_device *alloc_ieee80211(int sizeof_priv)
7712 +struct net_device *alloc_ieee80211_rtl7(int sizeof_priv)
7713 {
7714 struct ieee80211_device *ieee;
7715 struct net_device *dev;
7716 @@ -113,17 +118,17 @@
7717 goto failed;
7718 }
7719 ieee = netdev_priv(dev);
7720 - dev->hard_start_xmit = ieee80211_xmit;
7721 + dev->hard_start_xmit = ieee80211_xmit_rtl7;
7722  
7723 ieee->dev = dev;
7724  
7725 - err = ieee80211_networks_allocate(ieee);
7726 + err = ieee80211_networks_allocate_rtl7(ieee);
7727 if (err) {
7728 IEEE80211_ERROR("Unable to allocate beacon storage: %d\n",
7729 err);
7730 goto failed;
7731 }
7732 - ieee80211_networks_initialize(ieee);
7733 + ieee80211_networks_initialize_rtl7(ieee);
7734  
7735 /* Default fragmentation threshold is maximum payload size */
7736 ieee->fts = DEFAULT_FTS;
7737 @@ -138,7 +143,7 @@
7738 INIT_LIST_HEAD(&ieee->crypt_deinit_list);
7739 init_timer(&ieee->crypt_deinit_timer);
7740 ieee->crypt_deinit_timer.data = (unsigned long)ieee;
7741 - ieee->crypt_deinit_timer.function = ieee80211_crypt_deinit_handler;
7742 + ieee->crypt_deinit_timer.function = ieee80211_crypt_deinit_handler_rtl7;
7743  
7744 spin_lock_init(&ieee->lock);
7745  
7746 @@ -149,7 +154,7 @@
7747 ieee->ieee802_1x = 1;
7748 ieee->raw_tx = 0;
7749  
7750 - ieee80211_softmac_init(ieee);
7751 + ieee80211_softmac_init_rtl7(ieee);
7752  
7753 for (i = 0; i < IEEE_IBSS_MAC_HASH_SIZE; i++)
7754 INIT_LIST_HEAD(&ieee->ibss_mac_hash[i]);
7755 @@ -167,7 +172,7 @@
7756 }
7757  
7758  
7759 -void free_ieee80211(struct net_device *dev)
7760 +void free_ieee80211_rtl7(struct net_device *dev)
7761 {
7762 struct ieee80211_device *ieee = netdev_priv(dev);
7763  
7764 @@ -175,9 +180,9 @@
7765 struct list_head *p, *q;
7766  
7767  
7768 - ieee80211_softmac_free(ieee);
7769 + ieee80211_softmac_free_rtl7(ieee);
7770 del_timer_sync(&ieee->crypt_deinit_timer);
7771 - ieee80211_crypt_deinit_entries(ieee, 1);
7772 + ieee80211_crypt_deinit_entries_rtl7(ieee, 1);
7773  
7774 for (i = 0; i < WEP_KEYS; i++) {
7775 struct ieee80211_crypt_data *crypt = ieee->crypt[i];
7776 @@ -191,7 +196,7 @@
7777 }
7778 }
7779  
7780 - ieee80211_networks_free(ieee);
7781 + ieee80211_networks_free_rtl7(ieee);
7782  
7783 for (i = 0; i < IEEE_IBSS_MAC_HASH_SIZE; i++) {
7784 list_for_each_safe(p, q, &ieee->ibss_mac_hash[i]) {
7785 @@ -210,13 +215,13 @@
7786 u32 ieee80211_debug_level = 0;
7787 struct proc_dir_entry *ieee80211_proc = NULL;
7788  
7789 -static int show_debug_level(char *page, char **start, off_t offset,
7790 +static int show_debug_level_rtl7(char *page, char **start, off_t offset,
7791 int count, int *eof, void *data)
7792 {
7793 return snprintf(page, count, "0x%08X\n", ieee80211_debug_level);
7794 }
7795  
7796 -static int store_debug_level(struct file *file, const char *buffer,
7797 +static int store_debug_level_rtl7(struct file *file, const char *buffer,
7798 unsigned long count, void *data)
7799 {
7800 char buf[] = "0x00000000";
7801 @@ -243,7 +248,7 @@
7802 return strnlen(buf, count);
7803 }
7804  
7805 -static int __init ieee80211_init(void)
7806 +static int __init ieee80211_init_rtl7(void)
7807 {
7808 struct proc_dir_entry *e;
7809  
7810 @@ -268,7 +273,7 @@
7811 return 0;
7812 }
7813  
7814 -static void __exit ieee80211_exit(void)
7815 +static void __exit ieee80211_exit_rtl7(void)
7816 {
7817 if (ieee80211_proc) {
7818 remove_proc_entry("debug_level", ieee80211_proc);
7819 @@ -282,9 +287,9 @@
7820 MODULE_PARM_DESC(debug, "debug output mask");
7821  
7822  
7823 -module_exit(ieee80211_exit);
7824 -module_init(ieee80211_init);
7825 +module_exit(ieee80211_exit_rtl7);
7826 +module_init(ieee80211_init_rtl7);
7827 #endif
7828  
7829 -EXPORT_SYMBOL(alloc_ieee80211);
7830 -EXPORT_SYMBOL(free_ieee80211);
7831 +EXPORT_SYMBOL(alloc_ieee80211_rtl7);
7832 +EXPORT_SYMBOL(free_ieee80211_rtl7);
7833 diff -Naur rtl8187_orig/ieee80211/ieee80211_rx.c rtl8187_rawtx/ieee80211/ieee80211_rx.c
7834 --- rtl8187_orig/ieee80211/ieee80211_rx.c 2007-03-13 23:45:09.000000000 +0100
7835 +++ rtl8187_rawtx/ieee80211/ieee80211_rx.c 2007-07-29 10:28:57.000000000 +0200
7836 @@ -13,16 +13,15 @@
7837 * more details.
7838 ******************************************************************************
7839  
7840 - Few modifications for Realtek's Wi-Fi drivers by
7841 + Few modifications for Realtek's Wi-Fi drivers by
7842 Andrea Merello <andreamrl@tiscali.it>
7843 -
7844 - A special thanks goes to Realtek for their support !
7845 +
7846 + A special thanks goes to Realtek for their support !
7847  
7848 ******************************************************************************/
7849 -
7850 +
7851  
7852 #include <linux/compiler.h>
7853 -#include <linux/config.h>
7854 #include <linux/errno.h>
7855 #include <linux/if_arp.h>
7856 #include <linux/in6.h>
7857 @@ -43,18 +42,89 @@
7858 #include <asm/uaccess.h>
7859 #include <linux/ctype.h>
7860  
7861 +#if (LINUX_VERSION_CODE < KERNEL_VERSION(2,6,19))
7862 +#include <linux/config.h>
7863 +#else
7864 +#include <linux/autoconf.h>
7865 +#endif
7866 +
7867 +
7868 #include "ieee80211.h"
7869  
7870 -static inline void ieee80211_monitor_rx(struct ieee80211_device *ieee,
7871 +static inline void ieee80211_monitor_rx_rtl7(struct ieee80211_device *ieee,
7872 struct sk_buff *skb,
7873 struct ieee80211_rx_stats *rx_stats)
7874 {
7875 - struct ieee80211_hdr *hdr = (struct ieee80211_hdr *)skb->data;
7876 - u16 fc = le16_to_cpu(hdr->frame_ctl);
7877 + struct ieee80211_hdr *hdr1 = (struct ieee80211_hdr *)skb->data;
7878 + u16 fc = le16_to_cpu(hdr1->frame_ctl);
7879 + int prism_header;
7880 + int hdrlen, phdrlen, head_need, tail_need;
7881 +
7882 + if (ieee->dev->type == ARPHRD_IEEE80211_PRISM) {
7883 + prism_header = 1;
7884 + phdrlen = sizeof(struct linux_wlan_ng_prism_hdr);
7885 + } else {
7886 + prism_header = 0;
7887 + phdrlen = 0;
7888 + }
7889 +
7890 + hdrlen = ieee80211_get_hdrlen_rtl7(fc);
7891 +
7892 + /* check if there is enough room for extra data; if not, expand skb
7893 + * buffer to be large enough for the changes */
7894 + head_need = phdrlen;
7895 + tail_need = 0;
7896 +#ifdef PRISM2_ADD_BOGUS_CRC
7897 + tail_need += 4;
7898 +#endif /* PRISM2_ADD_BOGUS_CRC */
7899 +
7900 + head_need -= skb_headroom(skb);
7901 + tail_need -= skb_tailroom(skb);
7902 +
7903 + if (head_need > 0 || tail_need > 0) {
7904 + if (pskb_expand_head(skb, head_need > 0 ? head_need : 0,
7905 + tail_need > 0 ? tail_need : 0,
7906 + GFP_ATOMIC)) {
7907 + printk(KERN_DEBUG "%s: ieee80211_rx failed to "
7908 + "reallocate skb buffer\n", ieee->dev->name);
7909 + dev_kfree_skb_any(skb);
7910 + return;
7911 + }
7912 + }
7913 +
7914 + if (prism_header == 1) {
7915 + struct linux_wlan_ng_prism_hdr *hdr;
7916 + hdr = (struct linux_wlan_ng_prism_hdr *)
7917 + skb_push(skb, phdrlen);
7918 + memset(hdr, 0, phdrlen);
7919 + hdr->msgcode = LWNG_CAP_DID_BASE;
7920 + hdr->msglen = sizeof(*hdr);
7921 + memcpy(hdr->devname, ieee->dev->name, sizeof(hdr->devname));
7922 +#define LWNG_SETVAL(f,i,s,l,d) \
7923 +hdr->f.did = LWNG_CAP_DID_BASE | (i << 12); \
7924 +hdr->f.status = s; hdr->f.len = l; hdr->f.data = d
7925 + LWNG_SETVAL(hosttime, 1, 0, 4, jiffies);
7926 + LWNG_SETVAL(mactime, 2, 0, 4, ((u32)rx_stats->mac_time));
7927 + LWNG_SETVAL(channel, 3, 1 /* no value */, 4, 0);
7928 + LWNG_SETVAL(rssi, 4, 1 /* no value */, 4, 0);
7929 + LWNG_SETVAL(sq, 5, 1 /* no value */, 4, 0);
7930 + LWNG_SETVAL(signal, 6, 0, 4, rx_stats->signal);
7931 + LWNG_SETVAL(noise, 7, 0, 4, rx_stats->noise);
7932 + LWNG_SETVAL(rate, 8, 0, 4, rx_stats->rate / 5);
7933 + LWNG_SETVAL(istx, 9, 0, 4, 0);
7934 + LWNG_SETVAL(frmlen, 10, 0, 4, skb->len - phdrlen);
7935 +#undef LWNG_SETVAL
7936 + }
7937  
7938 skb->dev = ieee->dev;
7939 +#if (LINUX_VERSION_CODE < KERNEL_VERSION(2,6,22))
7940 skb->mac.raw = skb->data;
7941 - skb_pull(skb, ieee80211_get_hdrlen(fc));
7942 +#else
7943 + skb_reset_mac_header(skb);
7944 +#endif
7945 + skb_pull(skb, hdrlen);
7946 + if (prism_header)
7947 + skb_pull(skb, phdrlen);
7948 skb->pkt_type = PACKET_OTHERHOST;
7949 skb->protocol = __constant_htons(ETH_P_80211_RAW);
7950 memset(skb->cb, 0, sizeof(skb->cb));
7951 @@ -64,7 +134,7 @@
7952  
7953 /* Called only as a tasklet (software IRQ) */
7954 static struct ieee80211_frag_entry *
7955 -ieee80211_frag_cache_find(struct ieee80211_device *ieee, unsigned int seq,
7956 +ieee80211_frag_cache_find_rtl7(struct ieee80211_device *ieee, unsigned int seq,
7957 unsigned int frag, u8 *src, u8 *dst)
7958 {
7959 struct ieee80211_frag_entry *entry;
7960 @@ -94,7 +164,7 @@
7961  
7962 /* Called only as a tasklet (software IRQ) */
7963 static struct sk_buff *
7964 -ieee80211_frag_cache_get(struct ieee80211_device *ieee,
7965 +ieee80211_frag_cache_get_rtl7(struct ieee80211_device *ieee,
7966 struct ieee80211_hdr *hdr)
7967 {
7968 struct sk_buff *skb = NULL;
7969 @@ -133,7 +203,7 @@
7970 } else {
7971 /* received a fragment of a frame for which the head fragment
7972 * should have already been received */
7973 - entry = ieee80211_frag_cache_find(ieee, seq, frag, hdr->addr2,
7974 + entry = ieee80211_frag_cache_find_rtl7(ieee, seq, frag, hdr->addr2,
7975 hdr->addr1);
7976 if (entry != NULL) {
7977 entry->last_frag = frag;
7978 @@ -146,7 +216,7 @@
7979  
7980  
7981 /* Called only as a tasklet (software IRQ) */
7982 -static int ieee80211_frag_cache_invalidate(struct ieee80211_device *ieee,
7983 +static int ieee80211_frag_cache_invalidate_rtl7(struct ieee80211_device *ieee,
7984 struct ieee80211_hdr *hdr)
7985 {
7986 u16 sc;
7987 @@ -156,7 +226,7 @@
7988 sc = le16_to_cpu(hdr->seq_ctl);
7989 seq = WLAN_GET_SEQ_SEQ(sc);
7990  
7991 - entry = ieee80211_frag_cache_find(ieee, seq, -1, hdr->addr2,
7992 + entry = ieee80211_frag_cache_find_rtl7(ieee, seq, -1, hdr->addr2,
7993 hdr->addr1);
7994  
7995 if (entry == NULL) {
7996 @@ -178,7 +248,7 @@
7997 *
7998 * Called by ieee80211_rx */
7999 static inline int
8000 -ieee80211_rx_frame_mgmt(struct ieee80211_device *ieee, struct sk_buff *skb,
8001 +ieee80211_rx_frame_mgmt_rtl7(struct ieee80211_device *ieee, struct sk_buff *skb,
8002 struct ieee80211_rx_stats *rx_stats, u16 type,
8003 u16 stype)
8004 {
8005 @@ -187,13 +257,13 @@
8006 * response parser uses it
8007 */
8008 rx_stats->len = skb->len;
8009 - ieee80211_rx_mgt(ieee,(struct ieee80211_hdr *)skb->data,rx_stats);
8010 - ieee80211_rx_frame_softmac(ieee, skb, rx_stats, type, stype);
8011 + ieee80211_rx_mgt_rtl7(ieee,(struct ieee80211_hdr *)skb->data,rx_stats);
8012 + ieee80211_rx_frame_softmac_rtl7(ieee, skb, rx_stats, type, stype);
8013  
8014 dev_kfree_skb_any(skb);
8015 -
8016 +
8017 return 0;
8018 -
8019 +
8020 #ifdef NOT_YET
8021 if (ieee->iw_mode == IW_MODE_MASTER) {
8022 printk(KERN_DEBUG "%s: Master mode not yet suppported.\n",
8023 @@ -253,7 +323,7 @@
8024 /* No encapsulation header if EtherType < 0x600 (=length) */
8025  
8026 /* Called by ieee80211_rx_frame_decrypt */
8027 -static int ieee80211_is_eapol_frame(struct ieee80211_device *ieee,
8028 +static int ieee80211_is_eapol_frame_rtl7(struct ieee80211_device *ieee,
8029 struct sk_buff *skb)
8030 {
8031 struct net_device *dev = ieee->dev;
8032 @@ -294,7 +364,7 @@
8033  
8034 /* Called only as a tasklet (software IRQ), by ieee80211_rx */
8035 static inline int
8036 -ieee80211_rx_frame_decrypt(struct ieee80211_device* ieee, struct sk_buff *skb,
8037 +ieee80211_rx_frame_decrypt_rtl7(struct ieee80211_device* ieee, struct sk_buff *skb,
8038 struct ieee80211_crypt_data *crypt)
8039 {
8040 struct ieee80211_hdr *hdr;
8041 @@ -304,7 +374,7 @@
8042 return 0;
8043  
8044 hdr = (struct ieee80211_hdr *) skb->data;
8045 - hdrlen = ieee80211_get_hdrlen(le16_to_cpu(hdr->frame_ctl));
8046 + hdrlen = ieee80211_get_hdrlen_rtl7(le16_to_cpu(hdr->frame_ctl));
8047  
8048 #ifdef CONFIG_IEEE80211_CRYPT_TKIP
8049 if (ieee->tkip_countermeasures &&
8050 @@ -339,7 +409,7 @@
8051  
8052 /* Called only as a tasklet (software IRQ), by ieee80211_rx */
8053 static inline int
8054 -ieee80211_rx_frame_decrypt_msdu(struct ieee80211_device* ieee, struct sk_buff *skb,
8055 +ieee80211_rx_frame_decrypt_msdu_rtl7(struct ieee80211_device* ieee, struct sk_buff *skb,
8056 int keyidx, struct ieee80211_crypt_data *crypt)
8057 {
8058 struct ieee80211_hdr *hdr;
8059 @@ -349,7 +419,7 @@
8060 return 0;
8061  
8062 hdr = (struct ieee80211_hdr *) skb->data;
8063 - hdrlen = ieee80211_get_hdrlen(le16_to_cpu(hdr->frame_ctl));
8064 + hdrlen = ieee80211_get_hdrlen_rtl7(le16_to_cpu(hdr->frame_ctl));
8065  
8066 atomic_inc(&crypt->refcnt);
8067 res = crypt->ops->decrypt_msdu(skb, keyidx, hdrlen, crypt->priv);
8068 @@ -367,7 +437,7 @@
8069  
8070 /* this function is stolen from ipw2200 driver*/
8071 #define IEEE_PACKET_RETRY_TIME (5*HZ)
8072 -static int is_duplicate_packet(struct ieee80211_device *ieee,
8073 +static int is_duplicate_packet_rtl7(struct ieee80211_device *ieee,
8074 struct ieee80211_hdr *header)
8075 {
8076 // u16 fc = le16_to_cpu(header->frame_ctl);
8077 @@ -413,7 +483,7 @@
8078 last_seq = &ieee->last_seq_num;
8079 last_frag = &ieee->last_frag_num;
8080 last_time = &ieee->last_packet_time;
8081 -
8082 +
8083 break;
8084 default:
8085 return 0;
8086 @@ -436,7 +506,7 @@
8087 drop:
8088 // BUG_ON(!(fc & IEEE80211_FCTL_RETRY));
8089 // printk("DUP\n");
8090 -
8091 +
8092 return 1;
8093 }
8094  
8095 @@ -444,7 +514,7 @@
8096 /* All received frames are sent to this function. @skb contains the frame in
8097 * IEEE 802.11 format, i.e., in the format it was sent over air.
8098 * This function is called only as a tasklet (software IRQ). */
8099 -int ieee80211_rx(struct ieee80211_device *ieee, struct sk_buff *skb,
8100 +int ieee80211_rx_rtl7(struct ieee80211_device *ieee, struct sk_buff *skb,
8101 struct ieee80211_rx_stats *rx_stats)
8102 {
8103 struct net_device *dev = ieee->dev;
8104 @@ -481,9 +551,9 @@
8105 type = WLAN_FC_GET_TYPE(fc);
8106 stype = WLAN_FC_GET_STYPE(fc);
8107 sc = le16_to_cpu(hdr->seq_ctl);
8108 -
8109 +
8110 frag = WLAN_GET_SEQ_FRAG(sc);
8111 - hdrlen = ieee80211_get_hdrlen(fc);
8112 + hdrlen = ieee80211_get_hdrlen_rtl7(fc);
8113  
8114 #ifdef NOT_YET
8115 #if WIRELESS_EXT > 15
8116 @@ -501,12 +571,12 @@
8117 }
8118 #endif /* IW_WIRELESS_SPY */
8119 #endif /* WIRELESS_EXT > 15 */
8120 - hostap_update_rx_stats(local->ap, hdr, rx_stats);
8121 + hostap_update_rx_stats_rtl7(local->ap, hdr, rx_stats);
8122 #endif
8123  
8124 #if WIRELESS_EXT > 15
8125 if (ieee->iw_mode == IW_MODE_MONITOR) {
8126 - ieee80211_monitor_rx(ieee, skb, rx_stats);
8127 + ieee80211_monitor_rx_rtl7(ieee, skb, rx_stats);
8128 stats->rx_packets++;
8129 stats->rx_bytes += skb->len;
8130 return 1;
8131 @@ -529,7 +599,7 @@
8132 * stations that do not support WEP key mapping). */
8133  
8134 if (!(hdr->addr1[0] & 0x01) || local->bcrx_sta_key)
8135 - (void) hostap_handle_sta_crypto(local, hdr, &crypt,
8136 + (void) hostap_handle_sta_crypto_rtl7(local, hdr, &crypt,
8137 &sta);
8138 #endif
8139  
8140 @@ -555,7 +625,7 @@
8141 if (skb->len < IEEE80211_DATA_HDR3_LEN)
8142 goto rx_dropped;
8143  
8144 - if (is_duplicate_packet(ieee, hdr))
8145 + if (is_duplicate_packet_rtl7(ieee, hdr))
8146 goto rx_dropped;
8147  
8148  
8149 @@ -573,9 +643,9 @@
8150 goto rx_dropped;
8151 }
8152 #endif
8153 -
8154 -
8155 - if (ieee80211_rx_frame_mgmt(ieee, skb, rx_stats, type, stype))
8156 +
8157 +
8158 + if (ieee80211_rx_frame_mgmt_rtl7(ieee, skb, rx_stats, type, stype))
8159 goto rx_dropped;
8160 else
8161 goto rx_exit;
8162 @@ -583,7 +653,7 @@
8163  
8164  
8165 /* Data frame - extract src/dst addresses */
8166 -
8167 +
8168 switch (fc & (IEEE80211_FCTL_FROMDS | IEEE80211_FCTL_TODS)) {
8169 case IEEE80211_FCTL_FROMDS:
8170 memcpy(dst, hdr->addr1, ETH_ALEN);
8171 @@ -606,7 +676,7 @@
8172 }
8173  
8174 #ifdef NOT_YET
8175 - if (hostap_rx_frame_wds(ieee, hdr, fc, &wds))
8176 + if (hostap_rx_frame_wds_rtl7(ieee, hdr, fc, &wds))
8177 goto rx_dropped;
8178 if (wds) {
8179 skb->dev = dev = wds;
8180 @@ -619,7 +689,7 @@
8181 memcmp(hdr->addr2, ieee->assoc_ap_addr, ETH_ALEN) == 0) {
8182 /* Frame from BSSID of the AP for which we are a client */
8183 skb->dev = dev = ieee->stadev;
8184 - stats = hostap_get_stats(dev);
8185 + stats = hostap_get_stats_rtl7(dev);
8186 from_assoc_ap = 1;
8187 }
8188 #endif
8189 @@ -630,7 +700,7 @@
8190 if ((ieee->iw_mode == IW_MODE_MASTER ||
8191 ieee->iw_mode == IW_MODE_REPEAT) &&
8192 !from_assoc_ap) {
8193 - switch (hostap_handle_sta_rx(ieee, dev, skb, rx_stats,
8194 + switch (hostap_handle_sta_rx_rtl7(ieee, dev, skb, rx_stats,
8195 wds != NULL)) {
8196 case AP_RX_CONTINUE_NOT_AUTHORIZED:
8197 frame_authorized = 0;
8198 @@ -664,7 +734,7 @@
8199 /* skb: hdr + (possibly fragmented, possibly encrypted) payload */
8200  
8201 if (ieee->host_decrypt && (fc & IEEE80211_FCTL_WEP) &&
8202 - (keyidx = ieee80211_rx_frame_decrypt(ieee, skb, crypt)) < 0)
8203 + (keyidx = ieee80211_rx_frame_decrypt_rtl7(ieee, skb, crypt)) < 0)
8204 goto rx_dropped;
8205  
8206 hdr = (struct ieee80211_hdr *) skb->data;
8207 @@ -674,7 +744,7 @@
8208 // ieee->host_decrypt && (fc & IEEE80211_FCTL_WEP) &&
8209 if ((frag != 0 || (fc & IEEE80211_FCTL_MOREFRAGS))) {
8210 int flen;
8211 - struct sk_buff *frag_skb = ieee80211_frag_cache_get(ieee, hdr);
8212 + struct sk_buff *frag_skb = ieee80211_frag_cache_get_rtl7(ieee, hdr);
8213 IEEE80211_DEBUG_FRAG("Rx Fragment received (%u)\n", frag);
8214  
8215 if (!frag_skb) {
8216 @@ -694,7 +764,7 @@
8217 printk(KERN_WARNING "%s: host decrypted and "
8218 "reassembled frame did not fit skb\n",
8219 dev->name);
8220 - ieee80211_frag_cache_invalidate(ieee, hdr);
8221 + ieee80211_frag_cache_invalidate_rtl7(ieee, hdr);
8222 goto rx_dropped;
8223 }
8224  
8225 @@ -722,19 +792,19 @@
8226 * delivered, so remove skb from fragment cache */
8227 skb = frag_skb;
8228 hdr = (struct ieee80211_hdr *) skb->data;
8229 - ieee80211_frag_cache_invalidate(ieee, hdr);
8230 + ieee80211_frag_cache_invalidate_rtl7(ieee, hdr);
8231 }
8232  
8233 /* skb: hdr + (possible reassembled) full MSDU payload; possibly still
8234 * encrypted/authenticated */
8235 if (ieee->host_decrypt && (fc & IEEE80211_FCTL_WEP) &&
8236 - ieee80211_rx_frame_decrypt_msdu(ieee, skb, keyidx, crypt))
8237 + ieee80211_rx_frame_decrypt_msdu_rtl7(ieee, skb, keyidx, crypt))
8238 goto rx_dropped;
8239  
8240 hdr = (struct ieee80211_hdr *) skb->data;
8241 if (crypt && !(fc & IEEE80211_FCTL_WEP) && !ieee->open_wep) {
8242 if (/*ieee->ieee802_1x &&*/
8243 - ieee80211_is_eapol_frame(ieee, skb)) {
8244 + ieee80211_is_eapol_frame_rtl7(ieee, skb)) {
8245 #ifdef CONFIG_IEEE80211_DEBUG
8246 /* pass unencrypted EAPOL frames even if encryption is
8247 * configured */
8248 @@ -763,7 +833,7 @@
8249 #endif
8250  
8251 if (crypt && !(fc & IEEE80211_FCTL_WEP) && !ieee->open_wep &&
8252 - !ieee80211_is_eapol_frame(ieee, skb)) {
8253 + !ieee80211_is_eapol_frame_rtl7(ieee, skb)) {
8254 IEEE80211_DEBUG_DROP(
8255 "dropped unencrypted RX data "
8256 "frame from " MAC_FMT
8257 @@ -861,7 +931,12 @@
8258 if (skb2 != NULL) {
8259 /* send to wireless media */
8260 skb2->protocol = __constant_htons(ETH_P_802_3);
8261 +#if (LINUX_VERSION_CODE < KERNEL_VERSION(2,6,22))
8262 skb2->mac.raw = skb2->nh.raw = skb2->data;
8263 +#else
8264 + skb_reset_mac_header(skb2);
8265 + skb_reset_network_header(skb2);
8266 +#endif
8267 /* skb2->nh.raw = skb2->data + ETH_HLEN; */
8268 skb2->dev = dev;
8269 dev_queue_xmit(skb2);
8270 @@ -896,7 +971,7 @@
8271  
8272 #define MGMT_FRAME_FIXED_PART_LENGTH 0x24
8273  
8274 -static inline int ieee80211_is_ofdm_rate(u8 rate)
8275 +static inline int ieee80211_is_ofdm_rate_rtl7(u8 rate)
8276 {
8277 switch (rate & ~IEEE80211_BASIC_RATE_MASK) {
8278 case IEEE80211_OFDM_RATE_6MB:
8279 @@ -913,7 +988,7 @@
8280 }
8281  
8282  
8283 -static inline int ieee80211_network_init(
8284 +static inline int ieee80211_network_init_rtl7(
8285 struct ieee80211_device *ieee,
8286 struct ieee80211_probe_response *beacon,
8287 struct ieee80211_network *network,
8288 @@ -964,7 +1039,7 @@
8289  
8290 switch (info_element->id) {
8291 case MFIE_TYPE_SSID:
8292 - if (ieee80211_is_empty_essid(info_element->data,
8293 + if (ieee80211_is_empty_essid_rtl7(info_element->data,
8294 info_element->len)) {
8295 network->flags |= NETWORK_EMPTY_ESSID;
8296 break;
8297 @@ -991,7 +1066,7 @@
8298 #ifdef CONFIG_IEEE80211_DEBUG
8299 p += snprintf(p, sizeof(rates_str) - (p - rates_str), "%02X ", network->rates[i]);
8300 #endif
8301 - if (ieee80211_is_ofdm_rate(info_element->data[i])) {
8302 + if (ieee80211_is_ofdm_rate_rtl7(info_element->data[i])) {
8303 network->flags |= NETWORK_HAS_OFDM;
8304 if (info_element->data[i] &
8305 IEEE80211_BASIC_RATE_MASK)
8306 @@ -1014,7 +1089,7 @@
8307 #ifdef CONFIG_IEEE80211_DEBUG
8308 p += snprintf(p, sizeof(rates_str) - (p - rates_str), "%02X ", network->rates[i]);
8309 #endif
8310 - if (ieee80211_is_ofdm_rate(info_element->data[i])) {
8311 + if (ieee80211_is_ofdm_rate_rtl7(info_element->data[i])) {
8312 network->flags |= NETWORK_HAS_OFDM;
8313 if (info_element->data[i] &
8314 IEEE80211_BASIC_RATE_MASK)
8315 @@ -1043,47 +1118,47 @@
8316 break;
8317  
8318 case MFIE_TYPE_TIM:
8319 -
8320 - if(info_element->len < 4)
8321 +
8322 + if(info_element->len < 4)
8323 break;
8324 -
8325 +
8326 network->dtim_period = info_element->data[1];
8327 -
8328 +
8329 if(ieee->state != IEEE80211_LINKED)
8330 break;
8331 -
8332 - network->last_dtim_sta_time[0] = stats->mac_time[0];
8333 +
8334 + network->last_dtim_sta_time[0] = stats->mac_time[0];
8335 network->last_dtim_sta_time[1] = stats->mac_time[1];
8336 -
8337 +
8338 network->dtim_data = IEEE80211_DTIM_VALID;
8339 -
8340 - if(info_element->data[0] != 0)
8341 +
8342 + if(info_element->data[0] != 0)
8343 break;
8344 -
8345 +
8346 if(info_element->data[2] & 1)
8347 network->dtim_data |= IEEE80211_DTIM_MBCAST;
8348 -
8349 +
8350 offset = (info_element->data[2] >> 1)*2;
8351 -
8352 - //printk("offset1:%x aid:%x\n",offset, ieee->assoc_id);
8353 -
8354 - if(ieee->assoc_id < offset ||
8355 +
8356 + //printk("offset1:%x aid:%x\n",offset, ieee->assoc_id);
8357 +
8358 + if(ieee->assoc_id < offset ||
8359 ieee->assoc_id > 8*(offset + info_element->len -3))
8360 -
8361 +
8362 break;
8363 -
8364 -
8365 +
8366 +
8367 offset = offset + ieee->assoc_id / 8;// + ((aid % 8)? 0 : 1) ;
8368 -
8369 - // printk("offset:%x data:%x, ucast:%d\n", offset,
8370 +
8371 + // printk("offset:%x data:%x, ucast:%d\n", offset,
8372 // info_element->data[3+offset] ,
8373 // info_element->data[3+offset] & (1<<(ieee->assoc_id%8)));
8374 -
8375 +
8376 if(info_element->data[3+offset] & (1<<(ieee->assoc_id%8)))
8377 network->dtim_data |= IEEE80211_DTIM_UCAST;
8378 -
8379 +
8380 break;
8381 -
8382 +
8383 case MFIE_TYPE_IBSS_SET:
8384 IEEE80211_DEBUG_SCAN("MFIE_TYPE_IBSS_SET: ignored\n");
8385 break;
8386 @@ -1115,7 +1190,7 @@
8387 memcpy(network->rsn_ie, info_element,
8388 network->rsn_ie_len);
8389 break;
8390 -
8391 +
8392 default:
8393 IEEE80211_DEBUG_SCAN("unsupported IE %d\n",
8394 info_element->id);
8395 @@ -1147,7 +1222,7 @@
8396 return 1;
8397 }
8398  
8399 - if (ieee80211_is_empty_essid(network->ssid, network->ssid_len))
8400 + if (ieee80211_is_empty_essid_rtl7(network->ssid, network->ssid_len))
8401 network->flags |= NETWORK_EMPTY_ESSID;
8402  
8403 memcpy(&network->stats, stats, sizeof(network->stats));
8404 @@ -1155,24 +1230,24 @@
8405 return 0;
8406 }
8407  
8408 -static inline int is_same_network(struct ieee80211_network *src,
8409 +static inline int is_same_network_rtl7(struct ieee80211_network *src,
8410 struct ieee80211_network *dst)
8411 {
8412 /* A network is only a duplicate if the channel, BSSID, ESSID
8413 - * and the capability field (in particular IBSS and BSS) all match.
8414 + * and the capability field (in particular IBSS and BSS) all match.
8415 * We treat all <hidden> with the same BSSID and channel
8416 * as one network */
8417 return ((src->ssid_len == dst->ssid_len) &&
8418 (src->channel == dst->channel) &&
8419 !memcmp(src->bssid, dst->bssid, ETH_ALEN) &&
8420 !memcmp(src->ssid, dst->ssid, src->ssid_len) &&
8421 - ((src->capability & WLAN_CAPABILITY_IBSS) ==
8422 + ((src->capability & WLAN_CAPABILITY_IBSS) ==
8423 (dst->capability & WLAN_CAPABILITY_IBSS)) &&
8424 - ((src->capability & WLAN_CAPABILITY_BSS) ==
8425 + ((src->capability & WLAN_CAPABILITY_BSS) ==
8426 (dst->capability & WLAN_CAPABILITY_BSS)));
8427 }
8428  
8429 -static inline void update_network(struct ieee80211_network *dst,
8430 +static inline void update_network_rtl7(struct ieee80211_network *dst,
8431 struct ieee80211_network *src)
8432 {
8433 memcpy(&dst->stats, &src->stats, sizeof(struct ieee80211_rx_stats));
8434 @@ -1194,7 +1269,7 @@
8435 dst->dtim_data = src->dtim_data;
8436 dst->last_dtim_sta_time[0] = src->last_dtim_sta_time[0];
8437 dst->last_dtim_sta_time[1] = src->last_dtim_sta_time[1];
8438 -
8439 +
8440 memcpy(dst->wpa_ie, src->wpa_ie, src->wpa_ie_len);
8441 dst->wpa_ie_len = src->wpa_ie_len;
8442 memcpy(dst->rsn_ie, src->rsn_ie, src->rsn_ie_len);
8443 @@ -1204,7 +1279,7 @@
8444 /* dst->last_associate is not overwritten */
8445 }
8446  
8447 -static inline void ieee80211_process_probe_response(
8448 +static inline void ieee80211_process_probe_response_rtl7(
8449 struct ieee80211_device *ieee,
8450 struct ieee80211_probe_response *beacon,
8451 struct ieee80211_rx_stats *stats)
8452 @@ -1239,7 +1314,7 @@
8453 (beacon->capability & (1<<0x1)) ? '1' : '0',
8454 (beacon->capability & (1<<0x0)) ? '1' : '0');
8455  
8456 - if (ieee80211_network_init(ieee, beacon, &network, stats)) {
8457 + if (ieee80211_network_init_rtl7(ieee, beacon, &network, stats)) {
8458 IEEE80211_DEBUG_SCAN("Dropped '%s' (" MAC_FMT ") via %s.\n",
8459 escape_essid(info_element->data,
8460 info_element->len),
8461 @@ -1261,12 +1336,12 @@
8462 * already there. */
8463  
8464 spin_lock_irqsave(&ieee->lock, flags);
8465 -
8466 - if(is_same_network(&ieee->current_network, &network))
8467 - update_network(&ieee->current_network, &network);
8468 -
8469 +
8470 + if(is_same_network_rtl7(&ieee->current_network, &network))
8471 + update_network_rtl7(&ieee->current_network, &network);
8472 +
8473 list_for_each_entry(target, &ieee->network_list, list) {
8474 - if (is_same_network(target, &network))
8475 + if (is_same_network_rtl7(target, &network))
8476 break;
8477  
8478 if ((oldest == NULL) ||
8479 @@ -1306,7 +1381,7 @@
8480 memcpy(target, &network, sizeof(*target));
8481 list_add_tail(&target->list, &ieee->network_list);
8482 if(ieee->softmac_features & IEEE_SOFTMAC_ASSOCIATE)
8483 - ieee80211_softmac_new_net(ieee,&network);
8484 + ieee80211_softmac_new_net_rtl7(ieee,&network);
8485 } else {
8486 IEEE80211_DEBUG_SCAN("Updating '%s' (" MAC_FMT ") via %s.\n",
8487 escape_essid(target->ssid,
8488 @@ -1315,39 +1390,39 @@
8489 WLAN_FC_GET_STYPE(beacon->header.frame_ctl) ==
8490 IEEE80211_STYPE_PROBE_RESP ?
8491 "PROBE RESPONSE" : "BEACON");
8492 -
8493 +
8494 /* we have an entry and we are going to update it. But this entry may
8495 - * be already expired. In this case we do the same as we found a new
8496 + * be already expired. In this case we do the same as we found a new
8497 * net and call the new_net handler
8498 */
8499 renew = !time_after(target->last_scanned + ieee->scan_age, jiffies);
8500 - update_network(target, &network);
8501 + update_network_rtl7(target, &network);
8502 if(renew && (ieee->softmac_features & IEEE_SOFTMAC_ASSOCIATE))
8503 - ieee80211_softmac_new_net(ieee,&network);
8504 + ieee80211_softmac_new_net_rtl7(ieee,&network);
8505 }
8506  
8507 spin_unlock_irqrestore(&ieee->lock, flags);
8508 }
8509  
8510 -void ieee80211_rx_mgt(struct ieee80211_device *ieee,
8511 +void ieee80211_rx_mgt_rtl7(struct ieee80211_device *ieee,
8512 struct ieee80211_hdr *header,
8513 struct ieee80211_rx_stats *stats)
8514 {
8515 switch (WLAN_FC_GET_STYPE(header->frame_ctl)) {
8516 -
8517 +
8518 case IEEE80211_STYPE_BEACON:
8519 IEEE80211_DEBUG_MGMT("received BEACON (%d)\n",
8520 WLAN_FC_GET_STYPE(header->frame_ctl));
8521 IEEE80211_DEBUG_SCAN("Beacon\n");
8522 - ieee80211_process_probe_response(
8523 + ieee80211_process_probe_response_rtl7(
8524 ieee, (struct ieee80211_probe_response *)header, stats);
8525 break;
8526 -
8527 +
8528 case IEEE80211_STYPE_PROBE_RESP:
8529 IEEE80211_DEBUG_MGMT("received PROBE RESPONSE (%d)\n",
8530 WLAN_FC_GET_STYPE(header->frame_ctl));
8531 IEEE80211_DEBUG_SCAN("Probe response\n");
8532 - ieee80211_process_probe_response(
8533 + ieee80211_process_probe_response_rtl7(
8534 ieee, (struct ieee80211_probe_response *)header, stats);
8535 break;
8536  
8537 @@ -1355,5 +1430,5 @@
8538 }
8539  
8540  
8541 -EXPORT_SYMBOL(ieee80211_rx_mgt);
8542 -EXPORT_SYMBOL(ieee80211_rx);
8543 +EXPORT_SYMBOL(ieee80211_rx_mgt_rtl7);
8544 +EXPORT_SYMBOL(ieee80211_rx_rtl7);
8545 diff -Naur rtl8187_orig/ieee80211/ieee80211_softmac.c rtl8187_rawtx/ieee80211/ieee80211_softmac.c
8546 --- rtl8187_orig/ieee80211/ieee80211_softmac.c 2007-03-13 23:45:09.000000000 +0100
8547 +++ rtl8187_rawtx/ieee80211/ieee80211_softmac.c 2007-07-13 01:46:05.000000000 +0200
8548 @@ -1,14 +1,14 @@
8549 /* IEEE 802.11 SoftMAC layer
8550 * Copyright (c) 2005 Andrea Merello <andreamrl@tiscali.it>
8551 *
8552 - * Mostly extracted from the rtl8180-sa2400 driver for the
8553 + * Mostly extracted from the rtl8180-sa2400 driver for the
8554 * in-kernel generic ieee802.11 stack.
8555 *
8556 * Few lines might be stolen from other part of the ieee80211
8557 * stack. Copyright who own it's copyright
8558 *
8559 * WPA code stolen from the ipw2200 driver.
8560 - * Copyright who own it's copyright.
8561 + * Copyright who own it's copyright.
8562 *
8563 * released under the GPL
8564 */
8565 @@ -20,12 +20,12 @@
8566 #include <linux/delay.h>
8567 #include <linux/version.h>
8568  
8569 -short ieee80211_is_54g(struct ieee80211_network net)
8570 +short ieee80211_is_54g_rtl7(struct ieee80211_network net)
8571 {
8572 return ((net.rates_ex_len > 0) || (net.rates_len > 4));
8573 }
8574  
8575 -short ieee80211_is_shortslot(struct ieee80211_network net)
8576 +short ieee80211_is_shortslot_rtl7(struct ieee80211_network net)
8577 {
8578 return (net.capability & WLAN_CAPABILITY_SHORT_SLOT);
8579 }
8580 @@ -34,28 +34,28 @@
8581 * tag and the EXTENDED RATE MFIE tag if needed.
8582 * It encludes two bytes per tag for the tag itself and its len
8583 */
8584 -unsigned int ieee80211_MFIE_rate_len(struct ieee80211_device *ieee)
8585 +unsigned int ieee80211_MFIE_rate_len_rtl7(struct ieee80211_device *ieee)
8586 {
8587 unsigned int rate_len = 0;
8588 -
8589 +
8590 if (ieee->modulation & IEEE80211_CCK_MODULATION)
8591 rate_len = IEEE80211_CCK_RATE_LEN + 2;
8592 -
8593 +
8594 if (ieee->modulation & IEEE80211_OFDM_MODULATION)
8595 -
8596 +
8597 rate_len += IEEE80211_OFDM_RATE_LEN + 2;
8598 -
8599 +
8600 return rate_len;
8601 }
8602  
8603 -/* pleace the MFIE rate, tag to the memory (double) poined.
8604 +/* pleace the MFIE rate, tag to the memory (double) poined.
8605 * Then it updates the pointer so that
8606 * it points after the new MFIE tag added.
8607 - */
8608 -void ieee80211_MFIE_Brate(struct ieee80211_device *ieee, u8 **tag_p)
8609 + */
8610 +void ieee80211_MFIE_Brate_rtl7(struct ieee80211_device *ieee, u8 **tag_p)
8611 {
8612 - u8 *tag = *tag_p;
8613 -
8614 + u8 *tag = *tag_p;
8615 +
8616 if (ieee->modulation & IEEE80211_CCK_MODULATION){
8617 *tag++ = MFIE_TYPE_RATES;
8618 *tag++ = 4;
8619 @@ -64,17 +64,17 @@
8620 *tag++ = IEEE80211_BASIC_RATE_MASK | IEEE80211_CCK_RATE_5MB;
8621 *tag++ = IEEE80211_BASIC_RATE_MASK | IEEE80211_CCK_RATE_11MB;
8622 }
8623 -
8624 +
8625 /* We may add an option for custom rates that specific HW might support */
8626 *tag_p = tag;
8627 }
8628  
8629 -void ieee80211_MFIE_Grate(struct ieee80211_device *ieee, u8 **tag_p)
8630 -{
8631 - u8 *tag = *tag_p;
8632 -
8633 +void ieee80211_MFIE_Grate_rtl7(struct ieee80211_device *ieee, u8 **tag_p)
8634 +{
8635 + u8 *tag = *tag_p;
8636 +
8637 if (ieee->modulation & IEEE80211_OFDM_MODULATION){
8638 -
8639 +
8640 *tag++ = MFIE_TYPE_RATES_EX;
8641 *tag++ = 8;
8642 *tag++ = IEEE80211_BASIC_RATE_MASK | IEEE80211_OFDM_RATE_6MB;
8643 @@ -85,73 +85,73 @@
8644 *tag++ = IEEE80211_BASIC_RATE_MASK | IEEE80211_OFDM_RATE_36MB;
8645 *tag++ = IEEE80211_BASIC_RATE_MASK | IEEE80211_OFDM_RATE_48MB;
8646 *tag++ = IEEE80211_BASIC_RATE_MASK | IEEE80211_OFDM_RATE_54MB;
8647 -
8648 +
8649 }
8650 -
8651 +
8652 /* We may add an option for custom rates that specific HW might support */
8653 *tag_p = tag;
8654 }
8655  
8656 -void enqueue_mgmt(struct ieee80211_device *ieee, struct sk_buff *skb)
8657 +void enqueue_mgmt_rtl7(struct ieee80211_device *ieee, struct sk_buff *skb)
8658 {
8659 int nh;
8660 nh = (ieee->mgmt_queue_head +1) % MGMT_QUEUE_NUM;
8661 -
8662 +
8663 /*
8664 * if the queue is full but we have newer frames then
8665 * just overwrites the oldest.
8666 - *
8667 + *
8668 * if (nh == ieee->mgmt_queue_tail)
8669 * return -1;
8670 - */
8671 + */
8672 ieee->mgmt_queue_head = nh;
8673 ieee->mgmt_queue_ring[nh] = skb;
8674 -
8675 +
8676 //return 0;
8677 }
8678  
8679 -struct sk_buff *dequeue_mgmt(struct ieee80211_device *ieee)
8680 +struct sk_buff *dequeue_mgmt_rtl7(struct ieee80211_device *ieee)
8681 {
8682 struct sk_buff *ret;
8683 -
8684 +
8685 if(ieee->mgmt_queue_tail == ieee->mgmt_queue_head)
8686 return NULL;
8687 -
8688 +
8689 ret = ieee->mgmt_queue_ring[ieee->mgmt_queue_tail];
8690 -
8691 - ieee->mgmt_queue_tail =
8692 +
8693 + ieee->mgmt_queue_tail =
8694 (ieee->mgmt_queue_tail+1) % MGMT_QUEUE_NUM;
8695 -
8696 +
8697 return ret;
8698 }
8699  
8700 -void init_mgmt_queue(struct ieee80211_device *ieee)
8701 +void init_mgmt_queue_rtl7(struct ieee80211_device *ieee)
8702 {
8703 ieee->mgmt_queue_tail = ieee->mgmt_queue_head = 0;
8704 }
8705  
8706  
8707 -void ieee80211_sta_wakeup(struct ieee80211_device *ieee, short nl);
8708 +void ieee80211_sta_wakeup_rtl7(struct ieee80211_device *ieee, short nl);
8709  
8710 -inline void softmac_mgmt_xmit(struct sk_buff *skb, struct ieee80211_device *ieee)
8711 +inline void softmac_mgmt_xmit_rtl7(struct sk_buff *skb, struct ieee80211_device *ieee)
8712 {
8713 unsigned long flags;
8714 short single = ieee->softmac_features & IEEE_SOFTMAC_SINGLE_QUEUE;
8715 struct ieee80211_hdr_3addr *header=
8716 (struct ieee80211_hdr_3addr *) skb->data;
8717 -
8718 -
8719 +
8720 +
8721 spin_lock_irqsave(&ieee->lock, flags);
8722 -
8723 +
8724 /* called with 2nd param 0, no mgmt lock required */
8725 - ieee80211_sta_wakeup(ieee,0);
8726 -
8727 + ieee80211_sta_wakeup_rtl7(ieee,0);
8728 +
8729 if(single){
8730 -
8731 +
8732 if(ieee->queue_stop){
8733 -
8734 - enqueue_mgmt(ieee,skb);
8735 -
8736 +
8737 + enqueue_mgmt_rtl7(ieee,skb);
8738 +
8739 }else{
8740 header->seq_ctl = cpu_to_le16(ieee->seq_ctrl << 4);
8741  
8742 @@ -159,119 +159,119 @@
8743 ieee->seq_ctrl = 0;
8744 else
8745 ieee->seq_ctrl++;
8746 -
8747 +
8748 /* avoid watchdog triggers */
8749 ieee->dev->trans_start = jiffies;
8750 ieee->softmac_data_hard_start_xmit(skb,ieee->dev,ieee->basic_rate);
8751 }
8752 -
8753 +
8754 spin_unlock_irqrestore(&ieee->lock, flags);
8755 }else{
8756 spin_unlock_irqrestore(&ieee->lock, flags);
8757 spin_lock_irqsave(&ieee->mgmt_tx_lock, flags);
8758 -
8759 +
8760 header->seq_ctl = cpu_to_le16(ieee->seq_ctrl << 4);
8761 -
8762 +
8763 if (ieee->seq_ctrl == 0xFFF)
8764 ieee->seq_ctrl = 0;
8765 else
8766 ieee->seq_ctrl++;
8767 -
8768 +
8769 ieee->softmac_hard_start_xmit(skb,ieee->dev);
8770 -
8771 +
8772 spin_unlock_irqrestore(&ieee->mgmt_tx_lock, flags);
8773 }
8774 }
8775  
8776  
8777 -inline void softmac_ps_mgmt_xmit(struct sk_buff *skb, struct ieee80211_device *ieee)
8778 +inline void softmac_ps_mgmt_xmit_rtl7(struct sk_buff *skb, struct ieee80211_device *ieee)
8779 {
8780 -
8781 +
8782 short single = ieee->softmac_features & IEEE_SOFTMAC_SINGLE_QUEUE;
8783 struct ieee80211_hdr_3addr *header =
8784 (struct ieee80211_hdr_3addr *) skb->data;
8785 -
8786 -
8787 +
8788 +
8789 if(single){
8790 -
8791 +
8792 header->seq_ctl = cpu_to_le16(ieee->seq_ctrl << 4);
8793  
8794 if (ieee->seq_ctrl == 0xFFF)
8795 ieee->seq_ctrl = 0;
8796 else
8797 ieee->seq_ctrl++;
8798 -
8799 +
8800 /* avoid watchdog triggers */
8801 ieee->dev->trans_start = jiffies;
8802 ieee->softmac_data_hard_start_xmit(skb,ieee->dev,ieee->basic_rate);
8803 -
8804 +
8805 }else{
8806 -
8807 +
8808 header->seq_ctl = cpu_to_le16(ieee->seq_ctrl << 4);
8809 -
8810 +
8811 if (ieee->seq_ctrl == 0xFFF)
8812 ieee->seq_ctrl = 0;
8813 else
8814 ieee->seq_ctrl++;
8815  
8816 ieee->softmac_hard_start_xmit(skb,ieee->dev);
8817 -
8818 +
8819 }
8820 }
8821  
8822 -inline struct sk_buff *ieee80211_probe_req(struct ieee80211_device *ieee)
8823 +inline struct sk_buff *ieee80211_probe_req_rtl7(struct ieee80211_device *ieee)
8824 {
8825 unsigned int len,rate_len;
8826 u8 *tag;
8827 struct sk_buff *skb;
8828 struct ieee80211_probe_request *req;
8829 -
8830 +
8831 len = ieee->current_network.ssid_len;
8832 -
8833 - rate_len = ieee80211_MFIE_rate_len(ieee);
8834 -
8835 +
8836 + rate_len = ieee80211_MFIE_rate_len_rtl7(ieee);
8837 +
8838 skb = dev_alloc_skb(sizeof(struct ieee80211_probe_request) +
8839 2 + len + rate_len);
8840 -
8841 - if (!skb)
8842 +
8843 + if (!skb)
8844 return NULL;
8845 -
8846 +
8847 req = (struct ieee80211_probe_request *) skb_put(skb,sizeof(struct ieee80211_probe_request));
8848 req->header.frame_ctl = cpu_to_le16(IEEE80211_STYPE_PROBE_REQ);
8849 - req->header.duration_id = 0; //FIXME: is this OK ?
8850 -
8851 + req->header.duration_id = 0; //FIXME: is this OK ?
8852 +
8853 memset(req->header.addr1, 0xff, ETH_ALEN);
8854 memcpy(req->header.addr2, ieee->dev->dev_addr, ETH_ALEN);
8855 memset(req->header.addr3, 0xff, ETH_ALEN);
8856 -
8857 +
8858 tag = (u8 *) skb_put(skb,len+2+rate_len);
8859 -
8860 +
8861 *tag++ = MFIE_TYPE_SSID;
8862 *tag++ = len;
8863 memcpy(tag, ieee->current_network.ssid, len);
8864 tag += len;
8865 -
8866 - ieee80211_MFIE_Brate(ieee,&tag);
8867 - ieee80211_MFIE_Grate(ieee,&tag);
8868 +
8869 + ieee80211_MFIE_Brate_rtl7(ieee,&tag);
8870 + ieee80211_MFIE_Grate_rtl7(ieee,&tag);
8871 return skb;
8872 }
8873  
8874 -struct sk_buff *ieee80211_get_beacon_(struct ieee80211_device *ieee);
8875 -void ieee80211_send_beacon(struct ieee80211_device *ieee)
8876 +struct sk_buff *ieee80211_get_beacon__rtl7(struct ieee80211_device *ieee);
8877 +void ieee80211_send_beacon_rtl7(struct ieee80211_device *ieee)
8878 {
8879 struct sk_buff *skb;
8880 -
8881 - unsigned long flags;
8882 -
8883 - skb = ieee80211_get_beacon_(ieee);
8884 +
8885 + unsigned long flags;
8886 +
8887 + skb = ieee80211_get_beacon__rtl7(ieee);
8888 if (skb){
8889 - softmac_mgmt_xmit(skb, ieee);
8890 + softmac_mgmt_xmit_rtl7(skb, ieee);
8891 ieee->softmac_stats.tx_beacons++;
8892 }
8893  
8894 - ieee->beacon_timer.expires = jiffies +
8895 + ieee->beacon_timer.expires = jiffies +
8896 (MSECS( ieee->current_network.beacon_interval -5));
8897 -
8898 +
8899 spin_lock_irqsave(&ieee->beacon_lock,flags);
8900 if(ieee->beacon_txing)
8901 add_timer(&ieee->beacon_timer);
8902 @@ -279,57 +279,57 @@
8903 }
8904  
8905  
8906 -void ieee80211_send_beacon_cb(unsigned long _ieee)
8907 +void ieee80211_send_beacon_cb_rtl7(unsigned long _ieee)
8908 {
8909 struct ieee80211_device *ieee =
8910 (struct ieee80211_device *) _ieee;
8911 - ieee80211_send_beacon(ieee);
8912 + ieee80211_send_beacon_rtl7(ieee);
8913 }
8914  
8915  
8916 -void ieee80211_send_probe(struct ieee80211_device *ieee)
8917 +void ieee80211_send_probe_rtl7(struct ieee80211_device *ieee)
8918 {
8919 struct sk_buff *skb;
8920 -
8921 - skb = ieee80211_probe_req(ieee);
8922 +
8923 + skb = ieee80211_probe_req_rtl7(ieee);
8924 if (skb){
8925 - softmac_mgmt_xmit(skb, ieee);
8926 + softmac_mgmt_xmit_rtl7(skb, ieee);
8927 ieee->softmac_stats.tx_probe_rq++;
8928 }
8929 }
8930  
8931 -void ieee80211_send_probe_requests(struct ieee80211_device *ieee)
8932 +void ieee80211_send_probe_requests_rtl7(struct ieee80211_device *ieee)
8933 {
8934 if (ieee->active_scan && (ieee->softmac_features & IEEE_SOFTMAC_PROBERQ)){
8935 - ieee80211_send_probe(ieee);
8936 - ieee80211_send_probe(ieee);
8937 + ieee80211_send_probe_rtl7(ieee);
8938 + ieee80211_send_probe_rtl7(ieee);
8939 }
8940 }
8941  
8942 /* this performs syncro scan blocking the caller until all channels
8943 - * in the allowed channel map has been checked.
8944 + * in the allowed channel map has been checked.
8945 */
8946 -void ieee80211_softmac_scan_syncro(struct ieee80211_device *ieee)
8947 +void ieee80211_softmac_scan_syncro_rtl7(struct ieee80211_device *ieee)
8948 {
8949 short ch = 0;
8950 -
8951 +
8952 down(&ieee->scan_sem);
8953 -
8954 +
8955 while(1)
8956 {
8957 -
8958 +
8959 do{
8960 ch++;
8961 - if (ch > MAX_CHANNEL_NUMBER)
8962 + if (ch > MAX_CHANNEL_NUMBER)
8963 goto out; /* scan completed */
8964 -
8965 +
8966 }while(!ieee->channel_map[ch]);
8967 -
8968 +
8969 /* this fuction can be called in two situations
8970 * 1- We have switched to ad-hoc mode and we are
8971 * performing a complete syncro scan before conclude
8972 - * there are no interesting cell and to create a
8973 - * new one. In this case the link state is
8974 + * there are no interesting cell and to create a
8975 + * new one. In this case the link state is
8976 * IEEE80211_NOLINK until we found an interesting cell.
8977 * If so the ieee8021_new_net, called by the RX path
8978 * will set the state to IEEE80211_LINKED, so we stop
8979 @@ -342,24 +342,24 @@
8980 * not filter RX frames and the channel is changing.
8981 * So the only situation in witch are interested is to check
8982 * if the state become LINKED because of the #1 situation
8983 - */
8984 -
8985 + */
8986 +
8987 if (ieee->state == IEEE80211_LINKED)
8988 goto out;
8989 -
8990 +
8991 ieee->set_chan(ieee->dev, ch);
8992 -
8993 - ieee80211_send_probe_requests(ieee);
8994 -
8995 +
8996 + ieee80211_send_probe_requests_rtl7(ieee);
8997 +
8998 /* this prevent excessive time wait when we
8999 * need to wait for a syncro scan to end..
9000 - */
9001 + */
9002 if (ieee->sync_scan_hurryup)
9003 goto out;
9004  
9005  
9006 msleep_interruptible_rtl(IEEE80211_SOFTMAC_SCAN_TIME);
9007 -
9008 +
9009 }
9010 out:
9011 ieee->sync_scan_hurryup = 0;
9012 @@ -370,43 +370,49 @@
9013 void ieee80211_softmac_scan(struct ieee80211_device *ieee)
9014 {
9015 short watchdog = 0;
9016 -
9017 +
9018 do{
9019 - ieee->current_network.channel =
9020 + ieee->current_network.channel =
9021 (ieee->current_network.channel + 1) % MAX_CHANNEL_NUMBER;
9022 - if (watchdog++ > MAX_CHANNEL_NUMBER)
9023 + if (watchdog++ > MAX_CHANNEL_NUMBER)
9024 return; /* no good chans */
9025 -
9026 +
9027 }while(!ieee->channel_map[ieee->current_network.channel]);
9028 -
9029 +
9030  
9031 schedule_work(&ieee->softmac_scan_wq);
9032 }
9033 #endif
9034  
9035 -void ieee80211_softmac_scan_wq(struct ieee80211_device *ieee)
9036 -{
9037 - down(&ieee->scan_sem);
9038 -
9039 +# if (LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,20))
9040 +void ieee80211_softmac_scan_wq_rtl7(struct work_struct *work)
9041 +{
9042 + struct delayed_work *dwork = container_of(work, struct delayed_work, work);
9043 + struct ieee80211_device *ieee = container_of(dwork, struct ieee80211_device, softmac_scan_wq);
9044 +#else
9045 +void ieee80211_softmac_scan_wq_rtl7(struct ieee80211_device *ieee)
9046 +{
9047 +#endif
9048 short watchdog = 0;
9049 -
9050 + down(&ieee->scan_sem);
9051 +
9052 do{
9053 - ieee->current_network.channel =
9054 + ieee->current_network.channel =
9055 (ieee->current_network.channel + 1) % MAX_CHANNEL_NUMBER;
9056 - if (watchdog++ > MAX_CHANNEL_NUMBER)
9057 + if (watchdog++ > MAX_CHANNEL_NUMBER)
9058 goto out; /* no good chans */
9059 -
9060 +
9061 }while(!ieee->channel_map[ieee->current_network.channel]);
9062 -
9063 +
9064 if (ieee->scanning == 0 )
9065 goto out;
9066 -
9067 +
9068 ieee->set_chan(ieee->dev, ieee->current_network.channel);
9069 - ieee80211_send_probe_requests(ieee);
9070 + ieee80211_send_probe_requests_rtl7(ieee);
9071  
9072 -#if 0
9073 +#if 0
9074 ieee->.expires = jiffies + (IEEE80211_SOFTMAC_SCAN_TIME);
9075 - if (ieee->scanning == 1)
9076 + if (ieee->scanning == 1)
9077 add_timer(&ieee->scan_timer);
9078 #endif
9079 queue_delayed_work(ieee->wq, &ieee->softmac_scan_wq, IEEE80211_SOFTMAC_SCAN_TIME);
9080 @@ -419,7 +425,7 @@
9081 {
9082 unsigned long flags;
9083 struct ieee80211_device *ieee = (struct ieee80211_device *)_dev;
9084 -
9085 +
9086 spin_lock_irqsave(&ieee->lock, flags);
9087 ieee80211_softmac_scan(ieee);
9088 spin_unlock_irqrestore(&ieee->lock, flags);
9089 @@ -427,19 +433,19 @@
9090 #endif
9091  
9092  
9093 -void ieee80211_beacons_start(struct ieee80211_device *ieee)
9094 +void ieee80211_beacons_start_rtl7(struct ieee80211_device *ieee)
9095 {
9096 - unsigned long flags;
9097 + unsigned long flags;
9098  
9099 spin_lock_irqsave(&ieee->beacon_lock,flags);
9100  
9101 ieee->beacon_txing = 1;
9102 - ieee80211_send_beacon(ieee);
9103 -
9104 + ieee80211_send_beacon_rtl7(ieee);
9105 +
9106 spin_unlock_irqrestore(&ieee->beacon_lock,flags);
9107 }
9108  
9109 -void ieee80211_beacons_stop(struct ieee80211_device *ieee)
9110 +void ieee80211_beacons_stop_rtl7(struct ieee80211_device *ieee)
9111 {
9112 unsigned long flags;
9113  
9114 @@ -453,111 +459,111 @@
9115 }
9116  
9117  
9118 -void ieee80211_stop_send_beacons(struct ieee80211_device *ieee)
9119 +void ieee80211_stop_send_beacons_rtl7(struct ieee80211_device *ieee)
9120 {
9121 if(ieee->stop_send_beacons)
9122 ieee->stop_send_beacons(ieee->dev);
9123 if (ieee->softmac_features & IEEE_SOFTMAC_BEACONS)
9124 - ieee80211_beacons_stop(ieee);
9125 + ieee80211_beacons_stop_rtl7(ieee);
9126 }
9127  
9128  
9129 -void ieee80211_start_send_beacons(struct ieee80211_device *ieee)
9130 +void ieee80211_start_send_beacons_rtl7(struct ieee80211_device *ieee)
9131 {
9132 if(ieee->start_send_beacons)
9133 ieee->start_send_beacons(ieee->dev);
9134 if(ieee->softmac_features & IEEE_SOFTMAC_BEACONS)
9135 - ieee80211_beacons_start(ieee);
9136 + ieee80211_beacons_start_rtl7(ieee);
9137 }
9138  
9139  
9140 -void ieee80211_softmac_stop_scan(struct ieee80211_device *ieee)
9141 +void ieee80211_softmac_stop_scan_rtl7(struct ieee80211_device *ieee)
9142 {
9143 -// unsigned long flags;
9144 -
9145 +// unsigned long flags;
9146 +
9147 //ieee->sync_scan_hurryup = 1;
9148 -
9149 +
9150 down(&ieee->scan_sem);
9151 // spin_lock_irqsave(&ieee->lock, flags);
9152 -
9153 +
9154 if (ieee->scanning == 1){
9155 ieee->scanning = 0;
9156 //del_timer_sync(&ieee->scan_timer);
9157 cancel_delayed_work(&ieee->softmac_scan_wq);
9158 }
9159 -
9160 +
9161 // spin_unlock_irqrestore(&ieee->lock, flags);
9162 up(&ieee->scan_sem);
9163 }
9164  
9165 -void ieee80211_stop_scan(struct ieee80211_device *ieee)
9166 +void ieee80211_stop_scan_rtl7(struct ieee80211_device *ieee)
9167 {
9168 if (ieee->softmac_features & IEEE_SOFTMAC_SCAN)
9169 - ieee80211_softmac_stop_scan(ieee);
9170 + ieee80211_softmac_stop_scan_rtl7(ieee);
9171 else
9172 ieee->stop_scan(ieee->dev);
9173 }
9174  
9175 /* called with ieee->lock held */
9176 -void ieee80211_start_scan(struct ieee80211_device *ieee)
9177 +void ieee80211_start_scan_rtl7(struct ieee80211_device *ieee)
9178 {
9179 - if (ieee->softmac_features & IEEE_SOFTMAC_SCAN){
9180 + if (ieee->softmac_features & IEEE_SOFTMAC_SCAN){
9181 if (ieee->scanning == 0){
9182 ieee->scanning = 1;
9183 //ieee80211_softmac_scan(ieee);
9184 - queue_work(ieee->wq, &ieee->softmac_scan_wq);
9185 + queue_delayed_work(ieee->wq, &ieee->softmac_scan_wq, 0);
9186 }
9187 }else
9188 ieee->start_scan(ieee->dev);
9189 -
9190 +
9191 }
9192  
9193 /* called with wx_sem held */
9194 -void ieee80211_start_scan_syncro(struct ieee80211_device *ieee)
9195 +void ieee80211_start_scan_syncro_rtl7(struct ieee80211_device *ieee)
9196 {
9197 ieee->sync_scan_hurryup = 0;
9198 -
9199 +
9200 if (ieee->softmac_features & IEEE_SOFTMAC_SCAN)
9201 - ieee80211_softmac_scan_syncro(ieee);
9202 + ieee80211_softmac_scan_syncro_rtl7(ieee);
9203 else
9204 ieee->scan_syncro(ieee->dev);
9205 -
9206 +
9207 }
9208  
9209 -inline struct sk_buff *ieee80211_authentication_req(struct ieee80211_network *beacon,
9210 +inline struct sk_buff *ieee80211_authentication_req_rtl7(struct ieee80211_network *beacon,
9211 struct ieee80211_device *ieee, int challengelen)
9212 {
9213 - struct sk_buff *skb;
9214 + struct sk_buff *skb;
9215 struct ieee80211_authentication *auth;
9216 -
9217 - skb = dev_alloc_skb(sizeof(struct ieee80211_authentication) + challengelen);
9218 -
9219 +
9220 + skb = dev_alloc_skb(sizeof(struct ieee80211_authentication) + challengelen);
9221 +
9222 if (!skb) return NULL;
9223 -
9224 +
9225 auth = (struct ieee80211_authentication *)
9226 skb_put(skb, sizeof(struct ieee80211_authentication));
9227 -
9228 +
9229 auth->header.frame_ctl = IEEE80211_STYPE_AUTH;
9230 if (challengelen) auth->header.frame_ctl |= IEEE80211_FCTL_WEP;
9231 -
9232 +
9233 auth->header.duration_id = 0x013a; //FIXME
9234 -
9235 +
9236 memcpy(auth->header.addr1, beacon->bssid, ETH_ALEN);
9237 memcpy(auth->header.addr2, ieee->dev->dev_addr, ETH_ALEN);
9238 memcpy(auth->header.addr3, beacon->bssid, ETH_ALEN);
9239 -
9240 +
9241 auth->algorithm = ieee->open_wep ? WLAN_AUTH_OPEN : WLAN_AUTH_SHARED_KEY;
9242 -
9243 +
9244 auth->transaction = cpu_to_le16(ieee->associate_seq);
9245 ieee->associate_seq++;
9246 -
9247 +
9248 auth->status = cpu_to_le16(WLAN_STATUS_SUCCESS);
9249 -
9250 +
9251 return skb;
9252 -
9253 +
9254 }
9255  
9256 -static struct sk_buff* ieee80211_probe_resp(struct ieee80211_device *ieee, u8 *dest)
9257 +static struct sk_buff* ieee80211_probe_resp_rtl7(struct ieee80211_device *ieee, u8 *dest)
9258 {
9259 u8 *tag;
9260 int beacon_size;
9261 @@ -566,23 +572,23 @@
9262 int encrypt;
9263 int atim_len,erp_len;
9264 struct ieee80211_crypt_data* crypt;
9265 -
9266 +
9267 char *ssid = ieee->current_network.ssid;
9268 int ssid_len = ieee->current_network.ssid_len;
9269 int rate_len = ieee->current_network.rates_len+2;
9270 int rate_ex_len = ieee->current_network.rates_ex_len;
9271 if(rate_ex_len > 0) rate_ex_len+=2;
9272 -
9273 +
9274 if(ieee->current_network.capability & WLAN_CAPABILITY_IBSS)
9275 atim_len = 4;
9276 else
9277 atim_len = 0;
9278 -
9279 - if(ieee80211_is_54g(ieee->current_network))
9280 +
9281 + if(ieee80211_is_54g_rtl7(ieee->current_network))
9282 erp_len = 3;
9283 else
9284 erp_len = 0;
9285 -
9286 +
9287 beacon_size = sizeof(struct ieee80211_probe_response)+
9288 ssid_len
9289 +3 //channel
9290 @@ -590,72 +596,72 @@
9291 +rate_ex_len
9292 +atim_len
9293 +erp_len;
9294 -
9295 +
9296 skb = dev_alloc_skb(beacon_size);
9297 -
9298 - if (!skb)
9299 +
9300 + if (!skb)
9301 return NULL;
9302 -
9303 +
9304 beacon_buf = (struct ieee80211_probe_response*) skb_put(skb, beacon_size);
9305 -
9306 +
9307 memcpy (beacon_buf->header.addr1, dest,ETH_ALEN);
9308 memcpy (beacon_buf->header.addr2, ieee->dev->dev_addr, ETH_ALEN);
9309 memcpy (beacon_buf->header.addr3, ieee->current_network.bssid, ETH_ALEN);
9310  
9311 beacon_buf->header.duration_id = 0; //FIXME
9312 - beacon_buf->beacon_interval =
9313 + beacon_buf->beacon_interval =
9314 cpu_to_le16(ieee->current_network.beacon_interval);
9315 - beacon_buf->capability =
9316 + beacon_buf->capability =
9317 cpu_to_le16(ieee->current_network.capability & WLAN_CAPABILITY_IBSS);
9318 -
9319 +
9320 if(ieee->short_slot && (ieee->current_network.capability & WLAN_CAPABILITY_SHORT_SLOT))
9321 - cpu_to_le16((beacon_buf->capability |= WLAN_CAPABILITY_SHORT_SLOT));
9322 -
9323 + cpu_to_le16((beacon_buf->capability |= WLAN_CAPABILITY_SHORT_SLOT));
9324 +
9325 crypt = ieee->crypt[ieee->tx_keyidx];
9326  
9327 - encrypt = ieee->host_encrypt && crypt && crypt->ops &&
9328 + encrypt = ieee->host_encrypt && crypt && crypt->ops &&
9329 (0 == strcmp(crypt->ops->name, "WEP"));
9330  
9331 - if (encrypt)
9332 + if (encrypt)
9333 beacon_buf->capability |= cpu_to_le16(WLAN_CAPABILITY_PRIVACY);
9334 -
9335 -
9336 +
9337 +
9338 beacon_buf->header.frame_ctl = cpu_to_le16(IEEE80211_STYPE_PROBE_RESP);
9339 -
9340 - beacon_buf->info_element.id = MFIE_TYPE_SSID;
9341 +
9342 + beacon_buf->info_element.id = MFIE_TYPE_SSID;
9343 beacon_buf->info_element.len = ssid_len;
9344 -
9345 +
9346 tag = (u8*) beacon_buf->info_element.data;
9347 -
9348 +
9349 memcpy(tag, ssid, ssid_len);
9350 -
9351 +
9352 tag += ssid_len;
9353 -
9354 +
9355 *(tag++) = MFIE_TYPE_RATES;
9356 - *(tag++) = rate_len-2;
9357 + *(tag++) = rate_len-2;
9358 memcpy(tag,ieee->current_network.rates,rate_len-2);
9359 tag+=rate_len-2;
9360 -
9361 +
9362 *(tag++) = MFIE_TYPE_DS_SET;
9363 *(tag++) = 1;
9364 *(tag++) = ieee->current_network.channel;
9365 -
9366 +
9367 if(atim_len){
9368 *(tag++) = MFIE_TYPE_IBSS_SET;
9369 *(tag++) = 2;
9370 *((u16*)(tag)) = cpu_to_le16(ieee->current_network.atim_window);
9371 tag+=2;
9372 }
9373 -
9374 +
9375 if(erp_len){
9376 *(tag++) = MFIE_TYPE_ERP;
9377 *(tag++) = 1;
9378 - *(tag++) = 0;
9379 + *(tag++) = 0;
9380 }
9381 -
9382 +
9383 if(rate_ex_len){
9384 *(tag++) = MFIE_TYPE_RATES_EX;
9385 - *(tag++) = rate_ex_len-2;
9386 + *(tag++) = rate_ex_len-2;
9387 memcpy(tag,ieee->current_network.rates_ex,rate_ex_len-2);
9388 tag+=rate_ex_len-2;
9389 }
9390 @@ -664,208 +670,211 @@
9391 }
9392  
9393  
9394 -struct sk_buff* ieee80211_assoc_resp(struct ieee80211_device *ieee, u8 *dest)
9395 +struct sk_buff* ieee80211_assoc_resp_rtl7(struct ieee80211_device *ieee, u8 *dest)
9396 {
9397 struct sk_buff *skb;
9398 u8* tag;
9399 -
9400 +
9401 struct ieee80211_crypt_data* crypt;
9402 struct ieee80211_assoc_response_frame *assoc;
9403 short encrypt;
9404 -
9405 - unsigned int rate_len = ieee80211_MFIE_rate_len(ieee);
9406 +
9407 + unsigned int rate_len = ieee80211_MFIE_rate_len_rtl7(ieee);
9408 int len = sizeof(struct ieee80211_assoc_response_frame) + rate_len;
9409 -
9410 - skb = dev_alloc_skb(len);
9411 -
9412 - if (!skb)
9413 +
9414 + skb = dev_alloc_skb(len);
9415 +
9416 + if (!skb)
9417 return NULL;
9418 -
9419 +
9420 assoc = (struct ieee80211_assoc_response_frame *)
9421 skb_put(skb,sizeof(struct ieee80211_assoc_response_frame));
9422 -
9423 +
9424 assoc->header.frame_ctl = cpu_to_le16(IEEE80211_STYPE_ASSOC_RESP);
9425 memcpy(assoc->header.addr1, dest,ETH_ALEN);
9426 memcpy(assoc->header.addr3, ieee->dev->dev_addr, ETH_ALEN);
9427 memcpy(assoc->header.addr2, ieee->dev->dev_addr, ETH_ALEN);
9428 - assoc->capability = cpu_to_le16(ieee->iw_mode == IW_MODE_MASTER ?
9429 + assoc->capability = cpu_to_le16(ieee->iw_mode == IW_MODE_MASTER ?
9430 WLAN_CAPABILITY_BSS : WLAN_CAPABILITY_IBSS);
9431 -
9432 -
9433 +
9434 +
9435 if(ieee->short_slot)
9436 assoc->capability |= cpu_to_le16(WLAN_CAPABILITY_SHORT_SLOT);
9437 -
9438 +
9439 if (ieee->host_encrypt)
9440 crypt = ieee->crypt[ieee->tx_keyidx];
9441 else crypt = NULL;
9442 -
9443 +
9444 encrypt = ( crypt && crypt->ops);
9445 -
9446 +
9447 if (encrypt)
9448 assoc->capability |= cpu_to_le16(WLAN_CAPABILITY_PRIVACY);
9449 -
9450 +
9451 assoc->status = 0;
9452 assoc->aid = cpu_to_le16(ieee->assoc_id);
9453 if (ieee->assoc_id == 0x2007) ieee->assoc_id=0;
9454 else ieee->assoc_id++;
9455 -
9456 +
9457 tag = (u8*) skb_put(skb, rate_len);
9458 -
9459 - ieee80211_MFIE_Brate(ieee, &tag);
9460 - ieee80211_MFIE_Grate(ieee, &tag);
9461 -
9462 +
9463 + ieee80211_MFIE_Brate_rtl7(ieee, &tag);
9464 + ieee80211_MFIE_Grate_rtl7(ieee, &tag);
9465 +
9466 return skb;
9467 }
9468  
9469 -struct sk_buff* ieee80211_auth_resp(struct ieee80211_device *ieee,int status, u8 *dest)
9470 +struct sk_buff* ieee80211_auth_resp_rtl7(struct ieee80211_device *ieee,int status, u8 *dest)
9471 {
9472 struct sk_buff *skb;
9473 struct ieee80211_authentication *auth;
9474 -
9475 - skb = dev_alloc_skb(sizeof(struct ieee80211_authentication)+1);
9476 -
9477 - if (!skb)
9478 +
9479 + skb = dev_alloc_skb(sizeof(struct ieee80211_authentication)+1);
9480 +
9481 + if (!skb)
9482 return NULL;
9483 -
9484 +
9485 skb->len = sizeof(struct ieee80211_authentication);
9486 -
9487 +
9488 auth = (struct ieee80211_authentication *)skb->data;
9489 -
9490 +
9491 auth->status = cpu_to_le16(status);
9492 auth->transaction = cpu_to_le16(2);
9493 auth->algorithm = cpu_to_le16(WLAN_AUTH_OPEN);
9494 -
9495 +
9496 memcpy(auth->header.addr3, ieee->dev->dev_addr, ETH_ALEN);
9497 memcpy(auth->header.addr2, ieee->dev->dev_addr, ETH_ALEN);
9498 memcpy(auth->header.addr1, dest, ETH_ALEN);
9499 - auth->header.frame_ctl = cpu_to_le16(IEEE80211_STYPE_AUTH);
9500 + auth->header.frame_ctl = cpu_to_le16(IEEE80211_STYPE_AUTH);
9501 return skb;
9502 -
9503 -
9504 +
9505 +
9506 }
9507  
9508 -struct sk_buff* ieee80211_null_func(struct ieee80211_device *ieee,short pwr)
9509 +struct sk_buff* ieee80211_null_func_rtl7(struct ieee80211_device *ieee,short pwr)
9510 {
9511 struct sk_buff *skb;
9512 struct ieee80211_hdr_3addr* hdr;
9513 -
9514 - skb = dev_alloc_skb(sizeof(struct ieee80211_hdr_3addr));
9515 -
9516 - if (!skb)
9517 +
9518 + skb = dev_alloc_skb(sizeof(struct ieee80211_hdr_3addr));
9519 +
9520 + if (!skb)
9521 return NULL;
9522 -
9523 +
9524 hdr = (struct ieee80211_hdr_3addr*)skb_put(skb,sizeof(struct ieee80211_hdr_3addr));
9525 -
9526 +
9527 memcpy(hdr->addr1, ieee->current_network.bssid, ETH_ALEN);
9528 memcpy(hdr->addr2, ieee->dev->dev_addr, ETH_ALEN);
9529 memcpy(hdr->addr3, ieee->current_network.bssid, ETH_ALEN);
9530 -
9531 - hdr->frame_ctl = cpu_to_le16(IEEE80211_FTYPE_DATA |
9532 - IEEE80211_STYPE_NULLFUNC | IEEE80211_FCTL_TODS |
9533 - (pwr ? IEEE80211_FCTL_PM:0));
9534 -
9535 +
9536 + hdr->frame_ctl = cpu_to_le16(IEEE80211_FTYPE_DATA |
9537 + IEEE80211_STYPE_NULLFUNC | IEEE80211_FCTL_TODS |
9538 + (pwr ? IEEE80211_FCTL_PM:0));
9539 +
9540 return skb;
9541 -
9542 -
9543 +
9544 +
9545 }
9546  
9547  
9548 -void ieee80211_resp_to_assoc_rq(struct ieee80211_device *ieee, u8* dest)
9549 +void ieee80211_resp_to_assoc_rq_rtl7(struct ieee80211_device *ieee, u8* dest)
9550 {
9551 - struct sk_buff *buf = ieee80211_assoc_resp(ieee, dest);
9552 -
9553 + struct sk_buff *buf = ieee80211_assoc_resp_rtl7(ieee, dest);
9554 +
9555 if (buf)
9556 - softmac_mgmt_xmit(buf, ieee);
9557 + softmac_mgmt_xmit_rtl7(buf, ieee);
9558 }
9559  
9560  
9561 -void ieee80211_resp_to_auth(struct ieee80211_device *ieee, int s, u8* dest)
9562 +void ieee80211_resp_to_auth_rtl7(struct ieee80211_device *ieee, int s, u8* dest)
9563 {
9564 - struct sk_buff *buf = ieee80211_auth_resp(ieee, s, dest);
9565 -
9566 + struct sk_buff *buf = ieee80211_auth_resp_rtl7(ieee, s, dest);
9567 +
9568 if (buf)
9569 - softmac_mgmt_xmit(buf, ieee);
9570 + softmac_mgmt_xmit_rtl7(buf, ieee);
9571 }
9572  
9573  
9574 -void ieee80211_resp_to_probe(struct ieee80211_device *ieee, u8 *dest)
9575 +void ieee80211_resp_to_probe_rtl7(struct ieee80211_device *ieee, u8 *dest)
9576 {
9577 -
9578 - struct sk_buff *buf = ieee80211_probe_resp(ieee, dest);
9579 -
9580 - if (buf)
9581 - softmac_mgmt_xmit(buf, ieee);
9582 +
9583 + struct sk_buff *buf = ieee80211_probe_resp_rtl7(ieee, dest);
9584 +
9585 + if (buf)
9586 + softmac_mgmt_xmit_rtl7(buf, ieee);
9587 }
9588  
9589  
9590 -inline struct sk_buff *ieee80211_association_req(struct ieee80211_network *beacon,struct ieee80211_device *ieee)
9591 +inline struct sk_buff *ieee80211_association_req_rtl7(struct ieee80211_network *beacon,struct ieee80211_device *ieee)
9592 {
9593 struct sk_buff *skb;
9594 -
9595 +
9596 struct ieee80211_assoc_request_frame *hdr;
9597 u8 *tag;
9598 -
9599 +
9600 unsigned int wpa_len = beacon->wpa_ie_len;
9601 -
9602 - unsigned int rate_len = ieee80211_MFIE_rate_len(ieee);
9603 -
9604 -
9605 -
9606 +
9607 + unsigned int rate_len = ieee80211_MFIE_rate_len_rtl7(ieee);
9608 +
9609 +
9610 +
9611 int len=sizeof(struct ieee80211_assoc_request_frame)+
9612 + beacon->ssid_len//essid tagged val
9613 + rate_len//rates tagged val
9614 + wpa_len;
9615 -
9616 +
9617 skb = dev_alloc_skb(len);
9618 -
9619 - if (!skb)
9620 +
9621 + if (!skb)
9622 return NULL;
9623 -
9624 +
9625 hdr = (struct ieee80211_assoc_request_frame *)
9626 skb_put(skb, sizeof(struct ieee80211_assoc_request_frame));
9627 -
9628 -
9629 +
9630 +
9631 hdr->header.frame_ctl = IEEE80211_STYPE_ASSOC_REQ;
9632 hdr->header.duration_id= 37; //FIXME
9633 memcpy(hdr->header.addr1, beacon->bssid, ETH_ALEN);
9634 memcpy(hdr->header.addr2, ieee->dev->dev_addr, ETH_ALEN);
9635 memcpy(hdr->header.addr3, beacon->bssid, ETH_ALEN);
9636 -
9637 +
9638 hdr->capability = cpu_to_le16(WLAN_CAPABILITY_BSS);
9639 - if (beacon->capability & WLAN_CAPABILITY_PRIVACY )
9640 + if (beacon->capability & WLAN_CAPABILITY_PRIVACY )
9641 hdr->capability |= cpu_to_le16(WLAN_CAPABILITY_PRIVACY);
9642 -
9643 +
9644 if(ieee->short_slot)
9645 hdr->capability |= cpu_to_le16(WLAN_CAPABILITY_SHORT_SLOT);
9646 -
9647 +
9648 + if(beacon->capability & WLAN_CAPABILITY_SHORT_PREAMBLE)
9649 + hdr->capability |= cpu_to_le16(WLAN_CAPABILITY_SHORT_PREAMBLE);
9650 +
9651 hdr->listen_interval = 0xa; //FIXME
9652 -
9653 +
9654 hdr->info_element.id = MFIE_TYPE_SSID;
9655  
9656 hdr->info_element.len = beacon->ssid_len;
9657 tag = skb_put(skb, beacon->ssid_len);
9658 memcpy(tag, beacon->ssid, beacon->ssid_len);
9659 -
9660 - tag = skb_put(skb, rate_len);
9661 -
9662 - ieee80211_MFIE_Brate(ieee, &tag);
9663 - ieee80211_MFIE_Grate(ieee, &tag);
9664 -
9665 +
9666 + tag = skb_put(skb, rate_len);
9667 +
9668 + ieee80211_MFIE_Brate_rtl7(ieee, &tag);
9669 + ieee80211_MFIE_Grate_rtl7(ieee, &tag);
9670 +
9671 tag = skb_put(skb,wpa_len);
9672 -
9673 +
9674 memcpy(tag,beacon->wpa_ie,wpa_len);
9675 -
9676 +
9677 return skb;
9678 }
9679  
9680 -void ieee80211_associate_abort(struct ieee80211_device *ieee)
9681 +void ieee80211_associate_abort_rtl7(struct ieee80211_device *ieee)
9682 {
9683 -
9684 +
9685 unsigned long flags;
9686 spin_lock_irqsave(&ieee->lock, flags);
9687 -
9688 +
9689 ieee->associate_seq++;
9690 -
9691 +
9692 /* don't scan, and avoid to have the RX path possibily
9693 * try again to associate. Even do not react to AUTH or
9694 * ASSOC response. Just wait for the retry wq to be scheduled.
9695 @@ -873,166 +882,181 @@
9696 * with, so we retry or just get back to NO_LINK and scanning
9697 */
9698 if (ieee->state == IEEE80211_ASSOCIATING_AUTHENTICATING){
9699 - IEEE80211_DEBUG_MGMT("Authentication failed\n");
9700 + IEEE80211_DEBUG_MGMT("Authentication failed\n");
9701 ieee->softmac_stats.no_auth_rs++;
9702 }else{
9703 - IEEE80211_DEBUG_MGMT("Association failed\n");
9704 + IEEE80211_DEBUG_MGMT("Association failed\n");
9705 ieee->softmac_stats.no_ass_rs++;
9706 }
9707 -
9708 +
9709 ieee->state = IEEE80211_ASSOCIATING_RETRY;
9710 -
9711 +
9712 queue_delayed_work(ieee->wq, &ieee->associate_retry_wq, IEEE80211_SOFTMAC_ASSOC_RETRY_TIME);
9713 -
9714 +
9715 spin_unlock_irqrestore(&ieee->lock, flags);
9716 }
9717  
9718 -void ieee80211_associate_abort_cb(unsigned long dev)
9719 +void ieee80211_associate_abort_cb_rtl7(unsigned long dev)
9720 {
9721 - ieee80211_associate_abort((struct ieee80211_device *) dev);
9722 + ieee80211_associate_abort_rtl7((struct ieee80211_device *) dev);
9723 }
9724  
9725  
9726 -void ieee80211_associate_step1(struct ieee80211_device *ieee)
9727 +void ieee80211_associate_step1_rtl7(struct ieee80211_device *ieee)
9728 {
9729 struct ieee80211_network *beacon = &ieee->current_network;
9730 struct sk_buff *skb;
9731 -
9732 +
9733 IEEE80211_DEBUG_MGMT("Stopping scan\n");
9734 -
9735 +
9736 ieee->softmac_stats.tx_auth_rq++;
9737 - skb=ieee80211_authentication_req(beacon, ieee, 0);
9738 -
9739 - if (!skb)
9740 - ieee80211_associate_abort(ieee);
9741 - else{
9742 + skb=ieee80211_authentication_req_rtl7(beacon, ieee, 0);
9743 +
9744 + if (!skb)
9745 + ieee80211_associate_abort_rtl7(ieee);
9746 + else{
9747 ieee->state = IEEE80211_ASSOCIATING_AUTHENTICATING ;
9748 IEEE80211_DEBUG_MGMT("Sending authentication request\n");
9749 - softmac_mgmt_xmit(skb, ieee);
9750 + softmac_mgmt_xmit_rtl7(skb, ieee);
9751 ieee->associate_timer.expires = jiffies + (HZ / 2);
9752 add_timer(&ieee->associate_timer);
9753 - }
9754 + }
9755 }
9756  
9757 -void ieee80211_auth_challenge(struct ieee80211_device *ieee, u8 *challenge, int chlen)
9758 +void ieee80211_auth_challenge_rtl7(struct ieee80211_device *ieee, u8 *challenge, int chlen)
9759 {
9760 - u8 *c;
9761 + u8 *c;
9762 struct sk_buff *skb;
9763 struct ieee80211_network *beacon = &ieee->current_network;
9764 // int hlen = sizeof(struct ieee80211_authentication);
9765 -
9766 +
9767 ieee->associate_seq++;
9768 ieee->softmac_stats.tx_auth_rq++;
9769 -
9770 - skb = ieee80211_authentication_req(beacon, ieee, chlen+2);
9771 - if (!skb)
9772 - ieee80211_associate_abort(ieee);
9773 +
9774 + skb = ieee80211_authentication_req_rtl7(beacon, ieee, chlen+2);
9775 + if (!skb)
9776 + ieee80211_associate_abort_rtl7(ieee);
9777 else{
9778 c = skb_put(skb, chlen+2);
9779 *(c++) = MFIE_TYPE_CHALLENGE;
9780 *(c++) = chlen;
9781 memcpy(c, challenge, chlen);
9782 -
9783 +
9784 IEEE80211_DEBUG_MGMT("Sending authentication challenge response\n");
9785 -
9786 - ieee80211_encrypt_fragment(ieee, skb, sizeof(struct ieee80211_hdr_3addr ));
9787 -
9788 - softmac_mgmt_xmit(skb, ieee);
9789 +
9790 + ieee80211_encrypt_fragment_rtl7(ieee, skb, sizeof(struct ieee80211_hdr_3addr ));
9791 +
9792 + softmac_mgmt_xmit_rtl7(skb, ieee);
9793 ieee->associate_timer.expires = jiffies + (HZ / 2);
9794 add_timer(&ieee->associate_timer);
9795 - }
9796 + }
9797 kfree(challenge);
9798 }
9799  
9800 -void ieee80211_associate_step2(struct ieee80211_device *ieee)
9801 +void ieee80211_associate_step2_rtl7(struct ieee80211_device *ieee)
9802 {
9803 struct sk_buff* skb;
9804 struct ieee80211_network *beacon = &ieee->current_network;
9805 -
9806 +
9807 del_timer_sync(&ieee->associate_timer);
9808 -
9809 +
9810 IEEE80211_DEBUG_MGMT("Sending association request\n");
9811 -
9812 +
9813 ieee->softmac_stats.tx_ass_rq++;
9814 - skb=ieee80211_association_req(beacon, ieee);
9815 - if (!skb)
9816 - ieee80211_associate_abort(ieee);
9817 + skb=ieee80211_association_req_rtl7(beacon, ieee);
9818 + if (!skb)
9819 + ieee80211_associate_abort_rtl7(ieee);
9820 else{
9821 - softmac_mgmt_xmit(skb, ieee);
9822 + softmac_mgmt_xmit_rtl7(skb, ieee);
9823 ieee->associate_timer.expires = jiffies + (HZ / 2);
9824 add_timer(&ieee->associate_timer);
9825 - }
9826 + }
9827 }
9828  
9829 -void ieee80211_associate_complete_wq(struct ieee80211_device *ieee)
9830 +# if (LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,20))
9831 +void ieee80211_associate_complete_wq_rtl7(struct work_struct *work)
9832 +{
9833 + struct ieee80211_device *ieee = container_of(work, struct ieee80211_device, associate_complete_wq);
9834 +#else
9835 +void ieee80211_associate_complete_wq_rtl7(struct ieee80211_device *ieee)
9836 {
9837 +#endif
9838 printk(KERN_INFO "Associated successfully\n");
9839 - if(ieee80211_is_54g(ieee->current_network) &&
9840 +#if 0
9841 + if(ieee80211_is_54g_rtl7(ieee->current_network) &&
9842 (ieee->modulation & IEEE80211_OFDM_MODULATION)){
9843 -
9844 +
9845 ieee->rate = 540;
9846 printk(KERN_INFO"Using G rates\n");
9847 }else{
9848 ieee->rate = 110;
9849 printk(KERN_INFO"Using B rates\n");
9850 }
9851 +#else
9852 + printk(KERN_INFO"Using %d MBit\n", (ieee->rate/10) );
9853 +#endif
9854 ieee->link_change(ieee->dev);
9855 - notify_wx_assoc_event(ieee);
9856 + notify_wx_assoc_event_rtl7(ieee);
9857 if (ieee->data_hard_resume)
9858 ieee->data_hard_resume(ieee->dev);
9859 netif_carrier_on(ieee->dev);
9860 }
9861  
9862 -void ieee80211_associate_complete(struct ieee80211_device *ieee)
9863 +void ieee80211_associate_complete_rtl7(struct ieee80211_device *ieee)
9864 {
9865  
9866 del_timer_sync(&ieee->associate_timer);
9867 -
9868 +
9869 ieee->seq_ctrl = 0;
9870 ieee->state = IEEE80211_LINKED;
9871 IEEE80211_DEBUG_MGMT("Successfully associated\n");
9872 -
9873 +
9874 queue_work(ieee->wq, &ieee->associate_complete_wq);
9875 }
9876  
9877 -void ieee80211_associate_procedure_wq(struct ieee80211_device *ieee)
9878 +# if (LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,20))
9879 +void ieee80211_associate_procedure_wq_rtl7(struct work_struct *work)
9880 {
9881 + struct ieee80211_device *ieee = container_of(work, struct ieee80211_device, associate_procedure_wq);
9882 +#else
9883 +void ieee80211_associate_procedure_wq_rtl7(struct ieee80211_device *ieee)
9884 +{
9885 +#endif
9886 ieee->sync_scan_hurryup = 1;
9887 down(&ieee->wx_sem);
9888 -
9889 if (ieee->data_hard_stop)
9890 ieee->data_hard_stop(ieee->dev);
9891 -
9892 - ieee80211_stop_scan(ieee);
9893 +
9894 + ieee80211_stop_scan_rtl7(ieee);
9895 ieee->set_chan(ieee->dev, ieee->current_network.channel);
9896 -
9897 +
9898 ieee->associate_seq = 1;
9899 - ieee80211_associate_step1(ieee);
9900 -
9901 + ieee80211_associate_step1_rtl7(ieee);
9902 +
9903 up(&ieee->wx_sem);
9904 }
9905  
9906 -inline void ieee80211_softmac_new_net(struct ieee80211_device *ieee, struct ieee80211_network *net)
9907 +inline void ieee80211_softmac_new_net_rtl7(struct ieee80211_device *ieee, struct ieee80211_network *net)
9908 {
9909 -
9910 +
9911 u8 tmp_ssid[IW_ESSID_MAX_SIZE+1];
9912 int tmp_ssid_len = 0;
9913 -
9914 +
9915 short apset,ssidset,ssidbroad,apmatch,ssidmatch;
9916 -
9917 - /* we are interested in new new only if we are not associated
9918 +
9919 + /* we are interested in new new only if we are not associated
9920 * and we are not associating / authenticating
9921 */
9922 if (ieee->state != IEEE80211_NOLINK)
9923 - return;
9924 -
9925 + return;
9926 +
9927 if ((ieee->iw_mode == IW_MODE_INFRA) && !(net->capability & WLAN_CAPABILITY_BSS))
9928 return;
9929 -
9930 +
9931 if ((ieee->iw_mode == IW_MODE_ADHOC) && !(net->capability & WLAN_CAPABILITY_IBSS))
9932 return;
9933  
9934 -
9935 +
9936 if (ieee->iw_mode == IW_MODE_INFRA || ieee->iw_mode == IW_MODE_ADHOC){
9937 /* if the user specified the AP MAC, we need also the essid
9938 * This could be obtained by beacons or, if the network does not
9939 @@ -1043,23 +1067,23 @@
9940 ssidbroad = !(net->ssid_len == 0 || net->ssid[0]== '\0');
9941 apmatch = (memcmp(ieee->current_network.bssid, net->bssid, ETH_ALEN)==0);
9942 ssidmatch = (0==strncmp(ieee->current_network.ssid, net->ssid, net->ssid_len));
9943 -
9944 -
9945 -
9946 +
9947 +
9948 +
9949 if ( /* if the user set the AP check if match.
9950 * if the network does not broadcast essid we check the user supplyed ANY essid
9951 * if the network does broadcast and the user does not set essid it is OK
9952 * if the network does broadcast and the user did set essid chech if essid match
9953 */
9954 - ( apset && apmatch &&
9955 - ((ssidset && ssidbroad && ssidmatch) || (ssidbroad && !ssidset) || (!ssidbroad && ssidset)) ) ||
9956 + ( apset && apmatch &&
9957 + ((ssidset && ssidbroad && ssidmatch) || (ssidbroad && !ssidset) || (!ssidbroad && ssidset)) ) ||
9958 /* if the ap is not set, check that the user set the bssid
9959 * and the network does bradcast and that those two bssid matches
9960 - */
9961 - (!apset && ssidset && ssidbroad && ssidmatch)
9962 + */
9963 + (!apset && ssidset && ssidbroad && ssidmatch)
9964 ){
9965 -
9966 -
9967 +
9968 +
9969 /* if the essid is hidden replace it with the
9970 * essid provided by the user.
9971 */
9972 @@ -1068,18 +1092,19 @@
9973 tmp_ssid_len = ieee->current_network.ssid_len;
9974 }
9975 memcpy(&ieee->current_network, net, sizeof(struct ieee80211_network));
9976 -
9977 +
9978 if (!ssidbroad){
9979 strncpy(ieee->current_network.ssid, tmp_ssid, IW_ESSID_MAX_SIZE);
9980 ieee->current_network.ssid_len = tmp_ssid_len;
9981 }
9982 - printk(KERN_INFO"Linking with %s\n",ieee->current_network.ssid);
9983 -
9984 + printk(KERN_INFO"Linking with \"%s\" rate: %d MBit\n",ieee->current_network.ssid, (ieee->rate/10));
9985 +
9986 if (ieee->iw_mode == IW_MODE_INFRA){
9987 ieee->state = IEEE80211_ASSOCIATING;
9988 queue_work(ieee->wq, &ieee->associate_procedure_wq);
9989 }else{
9990 - if(ieee80211_is_54g(ieee->current_network) &&
9991 +#if 0
9992 + if(ieee80211_is_54g_rtl7(ieee->current_network) &&
9993 (ieee->modulation & IEEE80211_OFDM_MODULATION)){
9994 ieee->rate = 540;
9995 printk(KERN_INFO"Using G rates\n");
9996 @@ -1087,44 +1112,45 @@
9997 ieee->rate = 110;
9998 printk(KERN_INFO"Using B rates\n");
9999 }
10000 +#else
10001 + printk(KERN_INFO"Using %d MBit\n", (ieee->rate/10) );
10002 +#endif
10003 ieee->state = IEEE80211_LINKED;
10004 }
10005 -
10006 +
10007 }
10008 }
10009 -
10010 }
10011  
10012 -void ieee80211_softmac_check_all_nets(struct ieee80211_device *ieee)
10013 +void ieee80211_softmac_check_all_nets_rtl7(struct ieee80211_device *ieee)
10014 {
10015 -
10016 +
10017 unsigned long flags;
10018 struct ieee80211_network *target;
10019 -
10020 +
10021 spin_lock_irqsave(&ieee->lock, flags);
10022 -
10023 list_for_each_entry(target, &ieee->network_list, list) {
10024 -
10025 +
10026 /* if the state become different that NOLINK means
10027 * we had found what we are searching for
10028 */
10029 - if (ieee->state != IEEE80211_NOLINK)
10030 + if (ieee->state != IEEE80211_NOLINK)
10031 break;
10032 -
10033 +
10034 //if (ieee->scan_age == 0 || time_after(target->last_scanned + ieee->scan_age, jiffies))
10035 - ieee80211_softmac_new_net(ieee, target);
10036 + ieee80211_softmac_new_net_rtl7(ieee, target);
10037 }
10038 -
10039 +
10040 spin_unlock_irqrestore(&ieee->lock, flags);
10041 -
10042 +
10043 }
10044  
10045  
10046 -static inline u16 auth_parse(struct sk_buff *skb, u8** challenge, int *chlen)
10047 +static inline u16 auth_parse_rtl7(struct sk_buff *skb, u8** challenge, int *chlen)
10048 {
10049 struct ieee80211_authentication *a;
10050 u8 *t;
10051 - if (skb->len < (sizeof(struct ieee80211_authentication)-sizeof(struct ieee80211_info_element))){
10052 + if (skb->len < (sizeof(struct ieee80211_authentication)-sizeof(struct ieee80211_info_element))){
10053 IEEE80211_DEBUG_MGMT("invalid len in auth resp: %d\n",skb->len);
10054 return 0xcafe;
10055 }
10056 @@ -1132,58 +1158,58 @@
10057 a = (struct ieee80211_authentication*) skb->data;
10058 if(skb->len > (sizeof(struct ieee80211_authentication) +3)){
10059 t = skb->data + sizeof(struct ieee80211_authentication);
10060 -
10061 +
10062 if(*(t++) == MFIE_TYPE_CHALLENGE){
10063 *chlen = *(t++);
10064 *challenge = (u8*)kmalloc(*chlen, GFP_ATOMIC);
10065 memcpy(*challenge, t, *chlen);
10066 }
10067 }
10068 -
10069 +
10070 return cpu_to_le16(a->status);
10071 -
10072 +
10073 }
10074  
10075  
10076 -int auth_rq_parse(struct sk_buff *skb,u8* dest)
10077 +int auth_rq_parse_rtl7(struct sk_buff *skb,u8* dest)
10078 {
10079 struct ieee80211_authentication *a;
10080 -
10081 - if (skb->len < (sizeof(struct ieee80211_authentication)-sizeof(struct ieee80211_info_element))){
10082 - IEEE80211_DEBUG_MGMT("invalid len in auth request: %d\n",skb->len);
10083 +
10084 + if (skb->len < (sizeof(struct ieee80211_authentication)-sizeof(struct ieee80211_info_element))){
10085 + IEEE80211_DEBUG_MGMT("invalid len in auth request: %d\n",skb->len);
10086 return -1;
10087 }
10088 a = (struct ieee80211_authentication*) skb->data;
10089 -
10090 +
10091 memcpy(dest,a->header.addr2, ETH_ALEN);
10092 -
10093 - if (le16_to_cpu(a->algorithm) != WLAN_AUTH_OPEN)
10094 +
10095 + if (le16_to_cpu(a->algorithm) != WLAN_AUTH_OPEN)
10096 return WLAN_STATUS_NOT_SUPPORTED_AUTH_ALG;
10097 -
10098 +
10099 return WLAN_STATUS_SUCCESS;
10100 }
10101  
10102 -static short probe_rq_parse(struct ieee80211_device *ieee, struct sk_buff *skb, u8 *src)
10103 +static short probe_rq_parse_rtl7(struct ieee80211_device *ieee, struct sk_buff *skb, u8 *src)
10104 {
10105 u8 *tag;
10106 u8 *skbend;
10107 u8 *ssid=NULL;
10108 u8 ssidlen = 0;
10109 -
10110 +
10111 struct ieee80211_hdr_3addr *header =
10112 (struct ieee80211_hdr_3addr *) skb->data;
10113 -
10114 - if (skb->len < sizeof (struct ieee80211_hdr_3addr ))
10115 +
10116 + if (skb->len < sizeof (struct ieee80211_hdr_3addr ))
10117 return -1; /* corrupted */
10118 -
10119 +
10120 memcpy(src,header->addr2, ETH_ALEN);
10121 -
10122 +
10123 skbend = (u8*)skb->data + skb->len;
10124 -
10125 +
10126 tag = skb->data + sizeof (struct ieee80211_hdr_3addr );
10127 -
10128 +
10129 while (tag+1 < skbend){
10130 - if (*tag == 0){
10131 + if (*tag == 0){
10132 ssid = tag+2;
10133 ssidlen = *(tag+1);
10134 break;
10135 @@ -1192,88 +1218,88 @@
10136 tag = tag + *(tag); /* point to the last data byte of the tag */
10137 tag++; /* point to the next tag */
10138 }
10139 -
10140 +
10141 //IEEE80211DMESG("Card MAC address is "MACSTR, MAC2STR(src));
10142 if (ssidlen == 0) return 1;
10143 -
10144 +
10145 if (!ssid) return 1; /* ssid not found in tagged param */
10146 return (!strncmp(ssid, ieee->current_network.ssid, ssidlen));
10147 -
10148 +
10149 }
10150  
10151 -int assoc_rq_parse(struct sk_buff *skb,u8* dest)
10152 +int assoc_rq_parse_rtl7(struct sk_buff *skb,u8* dest)
10153 {
10154 struct ieee80211_assoc_request_frame *a;
10155 -
10156 - if (skb->len < (sizeof(struct ieee80211_assoc_request_frame) -
10157 - sizeof(struct ieee80211_info_element))) {
10158 -
10159 +
10160 + if (skb->len < (sizeof(struct ieee80211_assoc_request_frame) -
10161 + sizeof(struct ieee80211_info_element))) {
10162 +
10163 IEEE80211_DEBUG_MGMT("invalid len in auth request:%d \n", skb->len);
10164 return -1;
10165 }
10166 -
10167 +
10168 a = (struct ieee80211_assoc_request_frame*) skb->data;
10169 -
10170 +
10171 memcpy(dest,a->header.addr2,ETH_ALEN);
10172 -
10173 +
10174 return 0;
10175 }
10176  
10177 -static inline u16 assoc_parse(struct sk_buff *skb, int *aid)
10178 +static inline u16 assoc_parse_rtl7(struct sk_buff *skb, int *aid)
10179 {
10180 struct ieee80211_assoc_response_frame *a;
10181 - if (skb->len < sizeof(struct ieee80211_assoc_response_frame)){
10182 + if (skb->len < sizeof(struct ieee80211_assoc_response_frame)){
10183 IEEE80211_DEBUG_MGMT("invalid len in auth resp: %d\n", skb->len);
10184 return 0xcafe;
10185 }
10186 -
10187 +
10188 a = (struct ieee80211_assoc_response_frame*) skb->data;
10189 *aid = le16_to_cpu(a->aid) & 0x3fff;
10190 return le16_to_cpu(a->status);
10191 }
10192  
10193 static inline void
10194 -ieee80211_rx_probe_rq(struct ieee80211_device *ieee, struct sk_buff *skb)
10195 +ieee80211_rx_probe_rq_rtl7(struct ieee80211_device *ieee, struct sk_buff *skb)
10196 {
10197 u8 dest[ETH_ALEN];
10198 -
10199 +
10200 //IEEE80211DMESG("Rx probe");
10201 ieee->softmac_stats.rx_probe_rq++;
10202 //DMESG("Dest is "MACSTR, MAC2STR(dest));
10203 - if (probe_rq_parse(ieee, skb, dest)){
10204 + if (probe_rq_parse_rtl7(ieee, skb, dest)){
10205 //IEEE80211DMESG("Was for me!");
10206 ieee->softmac_stats.tx_probe_rs++;
10207 - ieee80211_resp_to_probe(ieee, dest);
10208 + ieee80211_resp_to_probe_rtl7(ieee, dest);
10209 }
10210 }
10211  
10212 static inline void
10213 -ieee80211_rx_auth_rq(struct ieee80211_device *ieee, struct sk_buff *skb)
10214 +ieee80211_rx_auth_rq_rtl7(struct ieee80211_device *ieee, struct sk_buff *skb)
10215 {
10216 u8 dest[ETH_ALEN];
10217 int status;
10218 //IEEE80211DMESG("Rx probe");
10219 ieee->softmac_stats.rx_auth_rq++;
10220 -
10221 - if ((status = auth_rq_parse(skb, dest))!= -1){
10222 - ieee80211_resp_to_auth(ieee, status, dest);
10223 +
10224 + if ((status = auth_rq_parse_rtl7(skb, dest))!= -1){
10225 + ieee80211_resp_to_auth_rtl7(ieee, status, dest);
10226 }
10227 //DMESG("Dest is "MACSTR, MAC2STR(dest));
10228 -
10229 +
10230 }
10231  
10232 static inline void
10233 -ieee80211_rx_assoc_rq(struct ieee80211_device *ieee, struct sk_buff *skb)
10234 +ieee80211_rx_assoc_rq_rtl7(struct ieee80211_device *ieee, struct sk_buff *skb)
10235 {
10236 -
10237 +
10238 u8 dest[ETH_ALEN];
10239 //unsigned long flags;
10240 -
10241 +
10242 ieee->softmac_stats.rx_ass_rq++;
10243 - if (assoc_rq_parse(skb,dest) != -1){
10244 - ieee80211_resp_to_assoc_rq(ieee, dest);
10245 + if (assoc_rq_parse_rtl7(skb,dest) != -1){
10246 + ieee80211_resp_to_assoc_rq_rtl7(ieee, dest);
10247 }
10248 -
10249 +
10250 printk(KERN_INFO"New client associated: "MAC_FMT"\n", MAC_ARG(dest));
10251 //FIXME
10252 #if 0
10253 @@ -1285,25 +1311,25 @@
10254  
10255  
10256  
10257 -void ieee80211_sta_ps_send_null_frame(struct ieee80211_device *ieee, short pwr)
10258 +void ieee80211_sta_ps_send_null_frame_rtl7(struct ieee80211_device *ieee, short pwr)
10259 {
10260 -
10261 - struct sk_buff *buf = ieee80211_null_func(ieee, pwr);
10262 -
10263 +
10264 + struct sk_buff *buf = ieee80211_null_func_rtl7(ieee, pwr);
10265 +
10266 if (buf)
10267 - softmac_ps_mgmt_xmit(buf, ieee);
10268 + softmac_ps_mgmt_xmit_rtl7(buf, ieee);
10269  
10270 -}
10271 +}
10272  
10273  
10274 -short ieee80211_sta_ps_sleep(struct ieee80211_device *ieee, u32 *time_h, u32 *time_l)
10275 -{
10276 +short ieee80211_sta_ps_sleep_rtl7(struct ieee80211_device *ieee, u32 *time_h, u32 *time_l)
10277 +{
10278 int timeout = ieee->ps_timeout;
10279 u8 dtim;
10280 /*if(ieee->ps == IEEE80211_PS_DISABLED ||
10281 - ieee->iw_mode != IW_MODE_INFRA ||
10282 + ieee->iw_mode != IW_MODE_INFRA ||
10283 ieee->state != IEEE80211_LINKED)
10284 -
10285 +
10286 return 0;
10287 */
10288 dtim = ieee->current_network.dtim_data;
10289 @@ -1312,133 +1338,133 @@
10290 return 0;
10291 //printk("VALID\n");
10292 ieee->current_network.dtim_data = IEEE80211_DTIM_INVALID;
10293 -
10294 +
10295 if(dtim & ((IEEE80211_DTIM_UCAST | IEEE80211_DTIM_MBCAST)& ieee->ps))
10296 return 2;
10297 -
10298 +
10299 if(!time_after(jiffies, ieee->dev->trans_start + MSECS(timeout)))
10300 return 0;
10301 -
10302 +
10303 if(!time_after(jiffies, ieee->last_rx_ps_time + MSECS(timeout)))
10304 return 0;
10305 -
10306 +
10307 if((ieee->softmac_features & IEEE_SOFTMAC_SINGLE_QUEUE ) &&
10308 (ieee->mgmt_queue_tail != ieee->mgmt_queue_head))
10309 return 0;
10310 -
10311 +
10312 if(time_l){
10313 - *time_l = ieee->current_network.last_dtim_sta_time[0]
10314 - + (ieee->current_network.beacon_interval
10315 + *time_l = ieee->current_network.last_dtim_sta_time[0]
10316 + + (ieee->current_network.beacon_interval
10317 * ieee->current_network.dtim_period) * 1000;
10318 }
10319 -
10320 +
10321 if(time_h){
10322 *time_h = ieee->current_network.last_dtim_sta_time[1];
10323 if(time_l && *time_l < ieee->current_network.last_dtim_sta_time[0])
10324 *time_h += 1;
10325 }
10326 -
10327 +
10328 return 1;
10329 -
10330 -
10331 +
10332 +
10333 }
10334  
10335 -inline void ieee80211_sta_ps(struct ieee80211_device *ieee)
10336 +inline void ieee80211_sta_ps_rtl7(struct ieee80211_device *ieee)
10337 {
10338  
10339 u32 th,tl;
10340 short sleep;
10341 -
10342 +
10343 unsigned long flags,flags2;
10344 -
10345 +
10346 spin_lock_irqsave(&ieee->lock, flags);
10347 -
10348 +
10349 if((ieee->ps == IEEE80211_PS_DISABLED ||
10350 - ieee->iw_mode != IW_MODE_INFRA ||
10351 + ieee->iw_mode != IW_MODE_INFRA ||
10352 ieee->state != IEEE80211_LINKED)){
10353 -
10354 - #warning CHECK_LOCK_HERE
10355 +
10356 +// #warning CHECK_LOCK_HERE
10357 spin_lock_irqsave(&ieee->mgmt_tx_lock, flags2);
10358 -
10359 - ieee80211_sta_wakeup(ieee, 1);
10360 -
10361 +
10362 + ieee80211_sta_wakeup_rtl7(ieee, 1);
10363 + printk(KERN_WARNING "wakeup 1!\n" );
10364 spin_unlock_irqrestore(&ieee->mgmt_tx_lock, flags2);
10365 }
10366 -
10367 - sleep = ieee80211_sta_ps_sleep(ieee,&th, &tl);
10368 +
10369 + sleep = ieee80211_sta_ps_sleep_rtl7(ieee,&th, &tl);
10370 /* 2 wake, 1 sleep, 0 do nothing */
10371 if(sleep == 0)
10372 goto out;
10373 -
10374 +
10375 if(sleep == 1){
10376 -
10377 +
10378 if(ieee->sta_sleep == 1)
10379 ieee->enter_sleep_state(ieee->dev,th,tl);
10380 -
10381 +
10382 else if(ieee->sta_sleep == 0){
10383 // printk("send null 1\n");
10384 spin_lock_irqsave(&ieee->mgmt_tx_lock, flags2);
10385 -
10386 +
10387 if(ieee->ps_is_queue_empty(ieee->dev)){
10388 -
10389 -
10390 +
10391 +
10392 ieee->sta_sleep = 2;
10393 -
10394 +
10395 ieee->ps_request_tx_ack(ieee->dev);
10396 -
10397 - ieee80211_sta_ps_send_null_frame(ieee,1);
10398 -
10399 +
10400 + ieee80211_sta_ps_send_null_frame_rtl7(ieee,1);
10401 +
10402 ieee->ps_th = th;
10403 ieee->ps_tl = tl;
10404 - }
10405 + }
10406 spin_unlock_irqrestore(&ieee->mgmt_tx_lock, flags2);
10407 -
10408 +
10409 }
10410 -
10411 -
10412 +
10413 +
10414 }else if(sleep == 2){
10415 -#warning CHECK_LOCK_HERE
10416 +// #warning CHECK_LOCK_HERE
10417 spin_lock_irqsave(&ieee->mgmt_tx_lock, flags2);
10418 -
10419 - ieee80211_sta_wakeup(ieee,1);
10420 -
10421 +
10422 + ieee80211_sta_wakeup_rtl7(ieee,1);
10423 + printk(KERN_WARNING "wakeup 2!\n" );
10424 spin_unlock_irqrestore(&ieee->mgmt_tx_lock, flags2);
10425 }
10426  
10427 -out:
10428 +out:
10429 spin_unlock_irqrestore(&ieee->lock, flags);
10430 -
10431 +
10432 }
10433  
10434 -void ieee80211_sta_wakeup(struct ieee80211_device *ieee, short nl)
10435 +void ieee80211_sta_wakeup_rtl7(struct ieee80211_device *ieee, short nl)
10436 {
10437 if(ieee->sta_sleep == 0){
10438 if(nl){
10439 printk("Warning: driver is probably failing to report TX ps error\n");
10440 ieee->ps_request_tx_ack(ieee->dev);
10441 - ieee80211_sta_ps_send_null_frame(ieee, 0);
10442 + ieee80211_sta_ps_send_null_frame_rtl7(ieee, 0);
10443 }
10444 return;
10445 -
10446 +
10447 }
10448 -
10449 - if(ieee->sta_sleep == 1)
10450 +
10451 + if(ieee->sta_sleep == 1)
10452 ieee->sta_wake_up(ieee->dev);
10453 -
10454 +
10455 ieee->sta_sleep = 0;
10456 -
10457 +
10458 if(nl){
10459 ieee->ps_request_tx_ack(ieee->dev);
10460 - ieee80211_sta_ps_send_null_frame(ieee, 0);
10461 + ieee80211_sta_ps_send_null_frame_rtl7(ieee, 0);
10462 }
10463 }
10464  
10465 -void ieee80211_ps_tx_ack(struct ieee80211_device *ieee, short success)
10466 +void ieee80211_ps_tx_ack_rtl7(struct ieee80211_device *ieee, short success)
10467 {
10468 unsigned long flags,flags2;
10469 -
10470 +
10471 spin_lock_irqsave(&ieee->lock, flags);
10472 -
10473 +
10474 if(ieee->sta_sleep == 2){
10475 /* Null frame with PS bit set */
10476 if(success){
10477 @@ -1451,10 +1477,10 @@
10478 }
10479 /* 21112005 - tx again null without PS bit if lost */
10480 else {
10481 -
10482 +
10483 if((ieee->sta_sleep == 0) && !success){
10484 spin_lock_irqsave(&ieee->mgmt_tx_lock, flags2);
10485 - ieee80211_sta_ps_send_null_frame(ieee, 0);
10486 + ieee80211_sta_ps_send_null_frame_rtl7(ieee, 0);
10487 spin_unlock_irqrestore(&ieee->mgmt_tx_lock, flags2);
10488 }
10489 }
10490 @@ -1462,129 +1488,132 @@
10491 }
10492  
10493 inline int
10494 -ieee80211_rx_frame_softmac(struct ieee80211_device *ieee, struct sk_buff *skb,
10495 +ieee80211_rx_frame_softmac_rtl7(struct ieee80211_device *ieee, struct sk_buff *skb,
10496 struct ieee80211_rx_stats *rx_stats, u16 type,
10497 u16 stype)
10498 {
10499 struct ieee80211_hdr_3addr *header;
10500 - header = (struct ieee80211_hdr_3addr *) skb->data;
10501 u16 errcode;
10502 u8* challenge;
10503 int chlen;
10504 int aid;
10505 -
10506 +
10507 + chlen = 0;
10508 +
10509 + header = (struct ieee80211_hdr_3addr *) skb->data;
10510 +
10511 if(!ieee->proto_started)
10512 return 0;
10513 -
10514 +
10515 if(ieee->sta_sleep || (ieee->ps != IEEE80211_PS_DISABLED &&
10516 - ieee->iw_mode == IW_MODE_INFRA &&
10517 + ieee->iw_mode == IW_MODE_INFRA &&
10518 ieee->state == IEEE80211_LINKED))
10519 -
10520 +
10521 tasklet_schedule(&ieee->ps_task);
10522 -
10523 +
10524 if(WLAN_FC_GET_STYPE(header->frame_ctl) != IEEE80211_STYPE_PROBE_RESP &&
10525 WLAN_FC_GET_STYPE(header->frame_ctl) != IEEE80211_STYPE_BEACON)
10526 ieee->last_rx_ps_time = jiffies;
10527 -
10528 +
10529 switch (WLAN_FC_GET_STYPE(header->frame_ctl)) {
10530 -
10531 +
10532 case IEEE80211_STYPE_ASSOC_RESP:
10533 case IEEE80211_STYPE_REASSOC_RESP:
10534 -
10535 +
10536 IEEE80211_DEBUG_MGMT("received [RE]ASSOCIATION RESPONSE (%d)\n",
10537 WLAN_FC_GET_STYPE(header->frame_ctl));
10538 if ((ieee->softmac_features & IEEE_SOFTMAC_ASSOCIATE) &&
10539 - ieee->state == IEEE80211_ASSOCIATING_AUTHENTICATED &&
10540 + ieee->state == IEEE80211_ASSOCIATING_AUTHENTICATED &&
10541 ieee->iw_mode == IW_MODE_INFRA){
10542 - if (0 == (errcode=assoc_parse(skb, &aid))){
10543 -
10544 + if (0 == (errcode=assoc_parse_rtl7(skb, &aid))){
10545 +
10546 ieee->state=IEEE80211_LINKED;
10547 ieee->assoc_id = aid;
10548 ieee->softmac_stats.rx_ass_ok++;
10549 -
10550 - ieee80211_associate_complete(ieee);
10551 +
10552 + ieee80211_associate_complete_rtl7(ieee);
10553 }else{
10554 ieee->softmac_stats.rx_ass_err++;
10555 IEEE80211_DEBUG_MGMT(
10556 "Association response status code 0x%x\n",
10557 errcode);
10558 - ieee80211_associate_abort(ieee);
10559 + ieee80211_associate_abort_rtl7(ieee);
10560 }
10561 }
10562 break;
10563 -
10564 +
10565 case IEEE80211_STYPE_ASSOC_REQ:
10566 case IEEE80211_STYPE_REASSOC_REQ:
10567 -
10568 +
10569 if ((ieee->softmac_features & IEEE_SOFTMAC_ASSOCIATE) &&
10570 ieee->iw_mode == IW_MODE_MASTER)
10571 -
10572 - ieee80211_rx_assoc_rq(ieee, skb);
10573 +
10574 + ieee80211_rx_assoc_rq_rtl7(ieee, skb);
10575 break;
10576 -
10577 +
10578 case IEEE80211_STYPE_AUTH:
10579 -
10580 +
10581 if (ieee->softmac_features & IEEE_SOFTMAC_ASSOCIATE){
10582 - if (ieee->state == IEEE80211_ASSOCIATING_AUTHENTICATING &&
10583 + if (ieee->state == IEEE80211_ASSOCIATING_AUTHENTICATING &&
10584 ieee->iw_mode == IW_MODE_INFRA){
10585 -
10586 +
10587 IEEE80211_DEBUG_MGMT("Received authentication response");
10588 -
10589 - if (0 == (errcode=auth_parse(skb, &challenge, &chlen))){
10590 +
10591 + if (0 == (errcode=auth_parse_rtl7(skb, &challenge, &chlen))){
10592 if(ieee->open_wep || !challenge){
10593 ieee->state = IEEE80211_ASSOCIATING_AUTHENTICATED;
10594 ieee->softmac_stats.rx_auth_rs_ok++;
10595 -
10596 - ieee80211_associate_step2(ieee);
10597 +
10598 + ieee80211_associate_step2_rtl7(ieee);
10599 }else{
10600 - ieee80211_auth_challenge(ieee, challenge, chlen);
10601 + ieee80211_auth_challenge_rtl7(ieee, challenge, chlen);
10602 }
10603 }else{
10604 ieee->softmac_stats.rx_auth_rs_err++;
10605 IEEE80211_DEBUG_MGMT("Authentication respose status code 0x%x",errcode);
10606 - ieee80211_associate_abort(ieee);
10607 + ieee80211_associate_abort_rtl7(ieee);
10608 }
10609 -
10610 +
10611 }else if (ieee->iw_mode == IW_MODE_MASTER){
10612 - ieee80211_rx_auth_rq(ieee, skb);
10613 + ieee80211_rx_auth_rq_rtl7(ieee, skb);
10614 }
10615 }
10616 break;
10617 -
10618 +
10619 case IEEE80211_STYPE_PROBE_REQ:
10620 -
10621 - if ((ieee->softmac_features & IEEE_SOFTMAC_PROBERS) &&
10622 - ((ieee->iw_mode == IW_MODE_ADHOC ||
10623 +
10624 + if ((ieee->softmac_features & IEEE_SOFTMAC_PROBERS) &&
10625 + ((ieee->iw_mode == IW_MODE_ADHOC ||
10626 ieee->iw_mode == IW_MODE_MASTER) &&
10627 ieee->state == IEEE80211_LINKED))
10628 -
10629 - ieee80211_rx_probe_rq(ieee, skb);
10630 +
10631 + ieee80211_rx_probe_rq_rtl7(ieee, skb);
10632 break;
10633 -
10634 +
10635 case IEEE80211_STYPE_DISASSOC:
10636 case IEEE80211_STYPE_DEAUTH:
10637 - /* FIXME for now repeat all the association procedure
10638 + /* FIXME for now repeat all the association procedure
10639 * both for disassociation and deauthentication
10640 */
10641 if ((ieee->softmac_features & IEEE_SOFTMAC_ASSOCIATE) &&
10642 - ieee->state == IEEE80211_LINKED &&
10643 + ieee->state == IEEE80211_LINKED &&
10644 ieee->iw_mode == IW_MODE_INFRA){
10645 -
10646 +
10647 ieee->state = IEEE80211_ASSOCIATING;
10648 ieee->softmac_stats.reassoc++;
10649 -
10650 - notify_wx_assoc_event(ieee);
10651 -
10652 +
10653 + notify_wx_assoc_event_rtl7(ieee);
10654 +
10655 queue_work(ieee->wq, &ieee->associate_procedure_wq);
10656 }
10657 -
10658 +
10659 break;
10660 -
10661 - default:
10662 +
10663 + default:
10664 return -1;
10665 break;
10666 }
10667 -
10668 +
10669 //dev_kfree_skb_any(skb);
10670 return 0;
10671 }
10672 @@ -1602,21 +1631,21 @@
10673 * This might be useful if each fragment need it's own
10674 * descriptor, thus just keep a total free memory > than
10675 * the max fragmentation treshold is not enought.. If the
10676 - * ieee802.11 stack passed a TXB struct then you needed
10677 - * to keep N free descriptors where
10678 + * ieee802.11 stack passed a TXB struct then you needed
10679 + * to keep N free descriptors where
10680 * N = MAX_PACKET_SIZE / MIN_FRAG_TRESHOLD
10681 * In this way you need just one and the 802.11 stack
10682 - * will take care of buffering fragments and pass them to
10683 + * will take care of buffering fragments and pass them to
10684 * to the driver later, when it wakes the queue.
10685 - */
10686 -
10687 -void ieee80211_softmac_xmit(struct ieee80211_txb *txb, struct ieee80211_device *ieee)
10688 + */
10689 +
10690 +void ieee80211_softmac_xmit_rtl7(struct ieee80211_txb *txb, struct ieee80211_device *ieee)
10691 {
10692 -
10693 -
10694 +
10695 +
10696 unsigned long flags;
10697 int i;
10698 -
10699 +
10700 spin_lock_irqsave(&ieee->lock,flags);
10701 #if 0
10702 if(ieee->queue_stop){
10703 @@ -1627,13 +1656,13 @@
10704 err = 1;
10705 goto exit;
10706 }
10707 -
10708 +
10709 ieee->stats.tx_bytes+=skb->len;
10710 -
10711 -
10712 +
10713 +
10714 txb=ieee80211_skb_to_txb(ieee,skb);
10715 -
10716 -
10717 +
10718 +
10719 if(txb==NULL){
10720 IEEE80211DMESG("WW: IEEE stack failed to provide txb");
10721 //dev_kfree_skb_any(skb);
10722 @@ -1641,12 +1670,12 @@
10723 goto exit;
10724 }
10725 #endif
10726 -
10727 +
10728 /* called with 2nd parm 0, no tx mgmt lock required */
10729 - ieee80211_sta_wakeup(ieee,0);
10730 + ieee80211_sta_wakeup_rtl7(ieee,0);
10731  
10732 for(i = 0; i < txb->nr_frags; i++) {
10733 -
10734 +
10735 if (ieee->queue_stop){
10736 ieee->tx_pending.txb = txb;
10737 ieee->tx_pending.frag = i;
10738 @@ -1658,29 +1687,29 @@
10739 //(i+1)<txb->nr_frags);
10740 ieee->stats.tx_packets++;
10741 ieee->stats.tx_bytes += txb->fragments[i]->len;
10742 - ieee->dev->trans_start = jiffies;
10743 + ieee->dev->trans_start = jiffies;
10744 }
10745 - }
10746 -
10747 - ieee80211_txb_free(txb);
10748 -
10749 + }
10750 +
10751 + ieee80211_txb_free_rtl7(txb);
10752 +
10753 exit:
10754 spin_unlock_irqrestore(&ieee->lock,flags);
10755 -
10756 +
10757 }
10758  
10759 /* called with ieee->lock acquired */
10760 -void ieee80211_resume_tx(struct ieee80211_device *ieee)
10761 +void ieee80211_resume_tx_rtl7(struct ieee80211_device *ieee)
10762 {
10763 int i;
10764 for(i = ieee->tx_pending.frag; i < ieee->tx_pending.txb->nr_frags; i++) {
10765 -
10766 +
10767 if (ieee->queue_stop){
10768 ieee->tx_pending.frag = i;
10769 return;
10770 }else{
10771 -
10772 - ieee->softmac_data_hard_start_xmit(
10773 +
10774 + ieee->softmac_data_hard_start_xmit(
10775 ieee->tx_pending.txb->fragments[i],
10776 ieee->dev,ieee->rate);
10777 //(i+1)<ieee->tx_pending.txb->nr_frags);
10778 @@ -1688,21 +1717,21 @@
10779 ieee->dev->trans_start = jiffies;
10780 }
10781 }
10782 -
10783 -
10784 - ieee80211_txb_free(ieee->tx_pending.txb);
10785 +
10786 +
10787 + ieee80211_txb_free_rtl7(ieee->tx_pending.txb);
10788 ieee->tx_pending.txb = NULL;
10789 }
10790  
10791  
10792 -void ieee80211_reset_queue(struct ieee80211_device *ieee)
10793 +void ieee80211_reset_queue_rtl7(struct ieee80211_device *ieee)
10794 {
10795 unsigned long flags;
10796 -
10797 +
10798 spin_lock_irqsave(&ieee->lock,flags);
10799 - init_mgmt_queue(ieee);
10800 + init_mgmt_queue_rtl7(ieee);
10801 if (ieee->tx_pending.txb){
10802 - ieee80211_txb_free(ieee->tx_pending.txb);
10803 + ieee80211_txb_free_rtl7(ieee->tx_pending.txb);
10804 ieee->tx_pending.txb = NULL;
10805 }
10806 ieee->queue_stop = 0;
10807 @@ -1710,23 +1739,23 @@
10808  
10809 }
10810  
10811 -void ieee80211_wake_queue(struct ieee80211_device *ieee)
10812 +void ieee80211_wake_queue_rtl7(struct ieee80211_device *ieee)
10813 {
10814  
10815 unsigned long flags;
10816 struct sk_buff *skb;
10817 struct ieee80211_hdr_3addr *header;
10818 -
10819 +
10820 spin_lock_irqsave(&ieee->lock,flags);
10821 if (! ieee->queue_stop) goto exit;
10822 -
10823 +
10824 ieee->queue_stop = 0;
10825 -
10826 +
10827 if(ieee->softmac_features & IEEE_SOFTMAC_SINGLE_QUEUE){
10828 - while (!ieee->queue_stop && (skb = dequeue_mgmt(ieee))){
10829 -
10830 + while (!ieee->queue_stop && (skb = dequeue_mgmt_rtl7(ieee))){
10831 +
10832 header = (struct ieee80211_hdr_3addr *) skb->data;
10833 -
10834 +
10835 header->seq_ctl = cpu_to_le16(ieee->seq_ctrl << 4);
10836  
10837 if (ieee->seq_ctrl == 0xFFF)
10838 @@ -1738,19 +1767,19 @@
10839 }
10840 }
10841 if (!ieee->queue_stop && ieee->tx_pending.txb)
10842 - ieee80211_resume_tx(ieee);
10843 -
10844 + ieee80211_resume_tx_rtl7(ieee);
10845 +
10846 if (!ieee->queue_stop && netif_queue_stopped(ieee->dev)){
10847 ieee->softmac_stats.swtxawake++;
10848 netif_wake_queue(ieee->dev);
10849 }
10850 -
10851 +
10852 exit :
10853 spin_unlock_irqrestore(&ieee->lock,flags);
10854 }
10855  
10856  
10857 -void ieee80211_stop_queue(struct ieee80211_device *ieee)
10858 +void ieee80211_stop_queue_rtl7(struct ieee80211_device *ieee)
10859 {
10860 //unsigned long flags;
10861 //spin_lock_irqsave(&ieee->lock,flags);
10862 @@ -1761,81 +1790,88 @@
10863 }
10864 ieee->queue_stop = 1;
10865 //spin_unlock_irqrestore(&ieee->lock,flags);
10866 -
10867 +
10868 }
10869  
10870  
10871 -inline void ieee80211_randomize_cell(struct ieee80211_device *ieee)
10872 +inline void ieee80211_randomize_cell_rtl7(struct ieee80211_device *ieee)
10873 {
10874 -
10875 +
10876 get_random_bytes(ieee->current_network.bssid, ETH_ALEN);
10877 -
10878 +
10879 /* an IBSS cell address must have the two less significant
10880 - * bits of the first byte = 2
10881 + * bits of the first byte = 2
10882 */
10883 ieee->current_network.bssid[0] &= ~0x01;
10884 ieee->current_network.bssid[0] |= 0x02;
10885 }
10886  
10887 /* called in user context only */
10888 -void ieee80211_start_master_bss(struct ieee80211_device *ieee)
10889 +void ieee80211_start_master_bss_rtl7(struct ieee80211_device *ieee)
10890 {
10891 ieee->assoc_id = 1;
10892 -
10893 +
10894 if (ieee->current_network.ssid_len == 0){
10895 - strncpy(ieee->current_network.ssid,
10896 + strncpy(ieee->current_network.ssid,
10897 IEEE80211_DEFAULT_TX_ESSID,
10898 IW_ESSID_MAX_SIZE);
10899 -
10900 +
10901 ieee->current_network.ssid_len = strlen(IEEE80211_DEFAULT_TX_ESSID);
10902 ieee->ssid_set = 1;
10903 }
10904 -
10905 +
10906 memcpy(ieee->current_network.bssid, ieee->dev->dev_addr, ETH_ALEN);
10907 -
10908 +
10909 ieee->set_chan(ieee->dev, ieee->current_network.channel);
10910 ieee->state = IEEE80211_LINKED;
10911 ieee->link_change(ieee->dev);
10912 - notify_wx_assoc_event(ieee);
10913 -
10914 + notify_wx_assoc_event_rtl7(ieee);
10915 +
10916 if (ieee->data_hard_resume)
10917 ieee->data_hard_resume(ieee->dev);
10918 -
10919 +
10920 netif_carrier_on(ieee->dev);
10921 }
10922  
10923 -void ieee80211_start_monitor_mode(struct ieee80211_device *ieee)
10924 +void ieee80211_start_monitor_mode_rtl7(struct ieee80211_device *ieee)
10925 {
10926 if(ieee->raw_tx){
10927 -
10928 +
10929 if (ieee->data_hard_resume)
10930 ieee->data_hard_resume(ieee->dev);
10931 -
10932 +
10933 netif_carrier_on(ieee->dev);
10934 }
10935 }
10936 -void ieee80211_start_ibss_wq(struct ieee80211_device *ieee)
10937 +
10938 +# if (LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,20))
10939 +void ieee80211_start_ibss_wq_rtl7(struct work_struct *work)
10940 +{
10941 + struct ieee80211_device *ieee = container_of(work, struct ieee80211_device, start_ibss_wq);
10942 +#else
10943 +void ieee80211_start_ibss_wq_rtl7(struct ieee80211_device *ieee)
10944 {
10945 -
10946 +#endif
10947 +
10948 /* iwconfig mode ad-hoc will schedule this and return
10949 * on the other hand this will block further iwconfig SET
10950 * operations because of the wx_sem hold.
10951 * Anyway some most set operations set a flag to speed-up
10952 - * (abort) this wq (when syncro scanning) before sleeping
10953 + * (abort) this wq (when syncro scanning) before sleeping
10954 * on the semaphore
10955 */
10956 -
10957 +
10958 down(&ieee->wx_sem);
10959 -
10960 +
10961 if (ieee->current_network.ssid_len == 0){
10962 strcpy(ieee->current_network.ssid,IEEE80211_DEFAULT_TX_ESSID);
10963 ieee->current_network.ssid_len = strlen(IEEE80211_DEFAULT_TX_ESSID);
10964 ieee->ssid_set = 1;
10965 - }
10966 -
10967 + }
10968 +
10969 /* check if we have this cell in our network list */
10970 - ieee80211_softmac_check_all_nets(ieee);
10971 -
10972 + ieee80211_softmac_check_all_nets_rtl7(ieee);
10973 +
10974 /* if not then the state is not linked. Maybe the user swithced to
10975 * ad-hoc mode just after being in monitor mode, or just after
10976 * being very few time in managed mode (so the card have had no
10977 @@ -1851,29 +1887,29 @@
10978 * associated.
10979 */
10980 if (ieee->state == IEEE80211_NOLINK)
10981 - ieee80211_start_scan_syncro(ieee);
10982 + ieee80211_start_scan_syncro_rtl7(ieee);
10983  
10984 /* the network definitively is not here.. create a new cell */
10985 if (ieee->state == IEEE80211_NOLINK){
10986 - printk("creating new IBSS cell\n");
10987 + printk("creating new IBSS cell\n");
10988 if(!ieee->wap_set)
10989 - ieee80211_randomize_cell(ieee);
10990 -
10991 + ieee80211_randomize_cell_rtl7(ieee);
10992 +
10993 if(ieee->modulation & IEEE80211_CCK_MODULATION){
10994 -
10995 +
10996 ieee->current_network.rates_len = 4;
10997 -
10998 +
10999 ieee->current_network.rates[0] = IEEE80211_BASIC_RATE_MASK | IEEE80211_CCK_RATE_1MB;
11000 ieee->current_network.rates[1] = IEEE80211_BASIC_RATE_MASK | IEEE80211_CCK_RATE_2MB;
11001 ieee->current_network.rates[2] = IEEE80211_BASIC_RATE_MASK | IEEE80211_CCK_RATE_5MB;
11002 ieee->current_network.rates[3] = IEEE80211_BASIC_RATE_MASK | IEEE80211_CCK_RATE_11MB;
11003 -
11004 +
11005 }else
11006 ieee->current_network.rates_len = 0;
11007 -
11008 +
11009 if(ieee->modulation & IEEE80211_OFDM_MODULATION){
11010 ieee->current_network.rates_ex_len = 8;
11011 -
11012 +
11013 ieee->current_network.rates_ex[0] = IEEE80211_BASIC_RATE_MASK | IEEE80211_OFDM_RATE_6MB;
11014 ieee->current_network.rates_ex[1] = IEEE80211_BASIC_RATE_MASK | IEEE80211_OFDM_RATE_9MB;
11015 ieee->current_network.rates_ex[2] = IEEE80211_BASIC_RATE_MASK | IEEE80211_OFDM_RATE_12MB;
11016 @@ -1882,44 +1918,44 @@
11017 ieee->current_network.rates_ex[5] = IEEE80211_BASIC_RATE_MASK | IEEE80211_OFDM_RATE_36MB;
11018 ieee->current_network.rates_ex[6] = IEEE80211_BASIC_RATE_MASK | IEEE80211_OFDM_RATE_48MB;
11019 ieee->current_network.rates_ex[7] = IEEE80211_BASIC_RATE_MASK | IEEE80211_OFDM_RATE_54MB;
11020 -
11021 - ieee->rate = 540;
11022 +
11023 +// ieee->rate = 540;
11024 }else{
11025 ieee->current_network.rates_ex_len = 0;
11026 - ieee->rate = 110;
11027 +// ieee->rate = 110;
11028 }
11029 -
11030 +
11031 ieee->current_network.atim_window = 0;
11032 ieee->current_network.capability = WLAN_CAPABILITY_IBSS;
11033 if(ieee->short_slot)
11034 ieee->current_network.capability |= WLAN_CAPABILITY_SHORT_SLOT;
11035 -
11036 +
11037 }
11038 -
11039 +
11040 ieee->state = IEEE80211_LINKED;
11041 -
11042 +
11043 ieee->set_chan(ieee->dev, ieee->current_network.channel);
11044 ieee->link_change(ieee->dev);
11045 -
11046 - notify_wx_assoc_event(ieee);
11047 -
11048 - ieee80211_start_send_beacons(ieee);
11049 -
11050 +
11051 + notify_wx_assoc_event_rtl7(ieee);
11052 +
11053 + ieee80211_start_send_beacons_rtl7(ieee);
11054 +
11055 if (ieee->data_hard_resume)
11056 ieee->data_hard_resume(ieee->dev);
11057 -
11058 +
11059 netif_carrier_on(ieee->dev);
11060 -
11061 +
11062 up(&ieee->wx_sem);
11063 }
11064  
11065 -inline void ieee80211_start_ibss(struct ieee80211_device *ieee)
11066 +inline void ieee80211_start_ibss_rtl7(struct ieee80211_device *ieee)
11067 {
11068 queue_work(ieee->wq, &ieee->start_ibss_wq);
11069 }
11070  
11071 /* this is called only in user context, with wx_sem held */
11072 -void ieee80211_start_bss(struct ieee80211_device *ieee)
11073 +void ieee80211_start_bss_rtl7(struct ieee80211_device *ieee)
11074 {
11075 unsigned long flags;
11076 /* check if we have already found the net we
11077 @@ -1927,8 +1963,8 @@
11078 * if not (we are disassociated and we are not
11079 * in associating / authenticating phase) start the background scanning.
11080 */
11081 - ieee80211_softmac_check_all_nets(ieee);
11082 -
11083 + ieee80211_softmac_check_all_nets_rtl7(ieee);
11084 +
11085 /* ensure no-one start an associating process (thus setting
11086 * the ieee->state to ieee80211_ASSOCIATING) while we
11087 * have just cheked it and we are going to enable scan.
11088 @@ -1937,41 +1973,49 @@
11089 * the rx path), so we cannot be in the middle of such function
11090 */
11091 spin_lock_irqsave(&ieee->lock, flags);
11092 -
11093 if (ieee->state == IEEE80211_NOLINK)
11094 - ieee80211_start_scan(ieee);
11095 -
11096 + ieee80211_start_scan_rtl7(ieee);
11097 +
11098 spin_unlock_irqrestore(&ieee->lock, flags);
11099 }
11100  
11101 /* called only in userspace context */
11102 -void ieee80211_disassociate(struct ieee80211_device *ieee)
11103 +void ieee80211_disassociate_rtl7(struct ieee80211_device *ieee)
11104 {
11105 netif_carrier_off(ieee->dev);
11106 -
11107 +
11108 if (ieee->softmac_features & IEEE_SOFTMAC_TX_QUEUE)
11109 - ieee80211_reset_queue(ieee);
11110 -
11111 + ieee80211_reset_queue_rtl7(ieee);
11112 +
11113 if (ieee->data_hard_stop)
11114 ieee->data_hard_stop(ieee->dev);
11115 -
11116 +
11117 ieee->state = IEEE80211_NOLINK;
11118 ieee->link_change(ieee->dev);
11119 - notify_wx_assoc_event(ieee);
11120 -
11121 + notify_wx_assoc_event_rtl7(ieee);
11122 +
11123 }
11124 -void ieee80211_associate_retry_wq(struct ieee80211_device *ieee)
11125 +
11126 +# if (LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,20))
11127 +void ieee80211_associate_retry_wq_rtl7(struct work_struct *work)
11128 +{
11129 + struct delayed_work *dwork = container_of(work, struct delayed_work, work);
11130 + struct ieee80211_device *ieee = container_of(dwork, struct ieee80211_device, associate_retry_wq);
11131 +#else
11132 +void ieee80211_associate_retry_wq_rtl7(struct ieee80211_device *ieee)
11133 {
11134 +#endif
11135 unsigned long flags;
11136 -
11137 +
11138 down(&ieee->wx_sem);
11139 +
11140 if(!ieee->proto_started)
11141 goto exit;
11142 -
11143 +
11144 if(ieee->state != IEEE80211_ASSOCIATING_RETRY)
11145 goto exit;
11146 -
11147 - /* until we do not set the state to IEEE80211_NOLINK
11148 +
11149 + /* until we do not set the state to IEEE80211_NOLINK
11150 * there are no possibility to have someone else trying
11151 * to start an association procdure (we get here with
11152 * ieee->state = IEEE80211_ASSOCIATING).
11153 @@ -1981,122 +2025,120 @@
11154 * RX path works with ieee->lock held so there are no
11155 * problems. If we are still disassociated then start a scan.
11156 * the lock here is necessary to ensure no one try to start
11157 - * an association procedure when we have just checked the
11158 + * an association procedure when we have just checked the
11159 * state and we are going to start the scan.
11160 */
11161 ieee->state = IEEE80211_NOLINK;
11162  
11163 - ieee80211_softmac_check_all_nets(ieee);
11164 -
11165 + ieee80211_softmac_check_all_nets_rtl7(ieee);
11166 +
11167 spin_lock_irqsave(&ieee->lock, flags);
11168 -
11169 +
11170 if(ieee->state == IEEE80211_NOLINK)
11171 - ieee80211_start_scan(ieee);
11172 -
11173 + ieee80211_start_scan_rtl7(ieee);
11174 +
11175 spin_unlock_irqrestore(&ieee->lock, flags);
11176  
11177 exit:
11178 up(&ieee->wx_sem);
11179 }
11180  
11181 -struct sk_buff *ieee80211_get_beacon_(struct ieee80211_device *ieee)
11182 +struct sk_buff *ieee80211_get_beacon__rtl7(struct ieee80211_device *ieee)
11183 {
11184 u8 broadcast_addr[] = {0xff,0xff,0xff,0xff,0xff,0xff};
11185 -
11186 +
11187 struct sk_buff *skb;
11188 struct ieee80211_probe_response *b;
11189 -
11190 - skb = ieee80211_probe_resp(ieee, broadcast_addr);
11191 -
11192 - if (!skb)
11193 +
11194 + skb = ieee80211_probe_resp_rtl7(ieee, broadcast_addr);
11195 +
11196 + if (!skb)
11197 return NULL;
11198 -
11199 +
11200 b = (struct ieee80211_probe_response *) skb->data;
11201 b->header.frame_ctl = cpu_to_le16(IEEE80211_STYPE_BEACON);
11202 -
11203 +
11204 return skb;
11205 -
11206 +
11207 }
11208  
11209 -struct sk_buff *ieee80211_get_beacon(struct ieee80211_device *ieee)
11210 +struct sk_buff *ieee80211_get_beacon_rtl7(struct ieee80211_device *ieee)
11211 {
11212 struct sk_buff *skb;
11213 struct ieee80211_probe_response *b;
11214 -
11215 - skb = ieee80211_get_beacon_(ieee);
11216 - if(!skb)
11217 +
11218 + skb = ieee80211_get_beacon__rtl7(ieee);
11219 + if(!skb)
11220 return NULL;
11221 -
11222 - b = (struct ieee80211_probe_response *) skb->data;
11223 +
11224 + b = (struct ieee80211_probe_response *) skb->data;
11225 b->header.seq_ctrl = cpu_to_le16(ieee->seq_ctrl << 4);
11226 -
11227 +
11228 if (ieee->seq_ctrl == 0xFFF)
11229 ieee->seq_ctrl = 0;
11230 else
11231 ieee->seq_ctrl++;
11232 -
11233 +
11234 return skb;
11235 }
11236  
11237 -void ieee80211_softmac_stop_protocol(struct ieee80211_device *ieee)
11238 +void ieee80211_softmac_stop_protocol_rtl7(struct ieee80211_device *ieee)
11239 {
11240 ieee->sync_scan_hurryup = 1;
11241 down(&ieee->wx_sem);
11242 - ieee80211_stop_protocol(ieee);
11243 +
11244 + ieee80211_stop_protocol_rtl7(ieee);
11245 up(&ieee->wx_sem);
11246 }
11247  
11248  
11249 -void ieee80211_stop_protocol(struct ieee80211_device *ieee)
11250 +void ieee80211_stop_protocol_rtl7(struct ieee80211_device *ieee)
11251 {
11252 if (!ieee->proto_started)
11253 return;
11254 -
11255 +
11256 ieee->proto_started = 0;
11257 -
11258 - ieee80211_stop_send_beacons(ieee);
11259 -
11260 +
11261 + ieee80211_stop_send_beacons_rtl7(ieee);
11262 +
11263 del_timer_sync(&ieee->associate_timer);
11264 - cancel_delayed_work(&ieee->associate_retry_wq);
11265 -
11266 - ieee80211_stop_scan(ieee);
11267 + cancel_delayed_work(&ieee->associate_retry_wq);
11268 +
11269 + ieee80211_stop_scan_rtl7(ieee);
11270  
11271 - ieee80211_disassociate(ieee);
11272 + ieee80211_disassociate_rtl7(ieee);
11273 }
11274  
11275 -void ieee80211_softmac_start_protocol(struct ieee80211_device *ieee)
11276 +void ieee80211_softmac_start_protocol_rtl7(struct ieee80211_device *ieee)
11277 {
11278 ieee->sync_scan_hurryup = 0;
11279 down(&ieee->wx_sem);
11280 - ieee80211_start_protocol(ieee);
11281 + ieee80211_start_protocol_rtl7(ieee);
11282 up(&ieee->wx_sem);
11283 }
11284  
11285 -void ieee80211_start_protocol(struct ieee80211_device *ieee)
11286 +void ieee80211_start_protocol_rtl7(struct ieee80211_device *ieee)
11287 {
11288 short ch = 0;
11289 -
11290 if (ieee->proto_started)
11291 return;
11292 -
11293 +
11294 ieee->proto_started = 1;
11295 -
11296 +
11297 if (ieee->current_network.channel == 0){
11298 do{
11299 ch++;
11300 - if (ch > MAX_CHANNEL_NUMBER)
11301 + if (ch > MAX_CHANNEL_NUMBER)
11302 return; /* no channel found */
11303 -
11304 +
11305 }while(!ieee->channel_map[ch]);
11306 -
11307 +
11308 ieee->current_network.channel = ch;
11309 }
11310 -
11311 +
11312 if (ieee->current_network.beacon_interval == 0)
11313 ieee->current_network.beacon_interval = 100;
11314 -
11315 ieee->set_chan(ieee->dev,ieee->current_network.channel);
11316 -
11317 ieee->last_seq_num = -1;
11318 ieee->last_frag_num = -1;
11319 ieee->last_packet_time = 0;
11320 @@ -2107,30 +2149,27 @@
11321 * attempts does not fail just because the user provide the essid
11322 * and the nic is still checking for the AP MAC ??
11323 */
11324 -
11325 +
11326 if (ieee->iw_mode == IW_MODE_INFRA)
11327 - ieee80211_start_bss(ieee);
11328 -
11329 + ieee80211_start_bss_rtl7(ieee);
11330 else if (ieee->iw_mode == IW_MODE_ADHOC)
11331 - ieee80211_start_ibss(ieee);
11332 -
11333 + ieee80211_start_ibss_rtl7(ieee);
11334 else if (ieee->iw_mode == IW_MODE_MASTER)
11335 - ieee80211_start_master_bss(ieee);
11336 -
11337 + ieee80211_start_master_bss_rtl7(ieee);
11338 else if(ieee->iw_mode == IW_MODE_MONITOR)
11339 - ieee80211_start_monitor_mode(ieee);
11340 + ieee80211_start_monitor_mode_rtl7(ieee);
11341 }
11342  
11343  
11344 #define DRV_NAME "Ieee80211"
11345 -void ieee80211_softmac_init(struct ieee80211_device *ieee)
11346 +void ieee80211_softmac_init_rtl7(struct ieee80211_device *ieee)
11347 {
11348 memset(&ieee->current_network, 0, sizeof(struct ieee80211_network));
11349 -
11350 +
11351 ieee->state = IEEE80211_NOLINK;
11352 ieee->sync_scan_hurryup = 0;
11353 ieee->seq_ctrl = 0;
11354 -
11355 +
11356 ieee->assoc_id = 0;
11357 ieee->queue_stop = 0;
11358 ieee->scanning = 0;
11359 @@ -2142,66 +2181,75 @@
11360 ieee->rate = 3;
11361 ieee->ps = IEEE80211_PS_DISABLED;
11362 ieee->sta_sleep = 0;
11363 -
11364 - init_mgmt_queue(ieee);
11365 +
11366 + init_mgmt_queue_rtl7(ieee);
11367 #if 0
11368 init_timer(&ieee->scan_timer);
11369 ieee->scan_timer.data = (unsigned long)ieee;
11370 ieee->scan_timer.function = ieee80211_softmac_scan_cb;
11371 #endif
11372 ieee->tx_pending.txb = NULL;
11373 -
11374 +
11375 init_timer(&ieee->associate_timer);
11376 ieee->associate_timer.data = (unsigned long)ieee;
11377 - ieee->associate_timer.function = ieee80211_associate_abort_cb;
11378 + ieee->associate_timer.function = ieee80211_associate_abort_cb_rtl7;
11379  
11380 init_timer(&ieee->beacon_timer);
11381 ieee->beacon_timer.data = (unsigned long) ieee;
11382 - ieee->beacon_timer.function = ieee80211_send_beacon_cb;
11383 -
11384 + ieee->beacon_timer.function = ieee80211_send_beacon_cb_rtl7;
11385 +
11386 #ifdef PF_SYNCTHREAD
11387 ieee->wq = create_workqueue(DRV_NAME,0);
11388 -#else
11389 +#else
11390 ieee->wq = create_workqueue(DRV_NAME);
11391 #endif
11392 -
11393 - INIT_WORK(&ieee->start_ibss_wq,(void(*)(void*)) ieee80211_start_ibss_wq,ieee);
11394 - INIT_WORK(&ieee->associate_retry_wq,(void(*)(void*)) ieee80211_associate_retry_wq,ieee);
11395 - INIT_WORK(&ieee->associate_complete_wq,(void(*)(void*)) ieee80211_associate_complete_wq,ieee);
11396 - INIT_WORK(&ieee->associate_procedure_wq,(void(*)(void*)) ieee80211_associate_procedure_wq,ieee);
11397 - INIT_WORK(&ieee->softmac_scan_wq,(void(*)(void*)) ieee80211_softmac_scan_wq,ieee);
11398 - INIT_WORK(&ieee->wx_sync_scan_wq,(void(*)(void*)) ieee80211_wx_sync_scan_wq,ieee);
11399 -
11400 +
11401 +#if LINUX_VERSION_CODE < KERNEL_VERSION(2,6,20)
11402 + INIT_WORK(&ieee->start_ibss_wq,(void(*)(void*)) ieee80211_start_ibss_wq_rtl7,ieee);
11403 + INIT_WORK(&ieee->associate_retry_wq,(void(*)(void*)) ieee80211_associate_retry_wq_rtl7,ieee);
11404 + INIT_WORK(&ieee->associate_complete_wq,(void(*)(void*)) ieee80211_associate_complete_wq_rtl7,ieee);
11405 + INIT_WORK(&ieee->associate_procedure_wq,(void(*)(void*)) ieee80211_associate_procedure_wq_rtl7,ieee);
11406 + INIT_WORK(&ieee->softmac_scan_wq,(void(*)(void*)) ieee80211_softmac_scan_wq_rtl7,ieee);
11407 + INIT_WORK(&ieee->wx_sync_scan_wq,(void(*)(void*)) ieee80211_wx_sync_scan_wq_rtl7,ieee);
11408 +#else
11409 + INIT_WORK(&ieee->start_ibss_wq, ieee80211_start_ibss_wq_rtl7);
11410 + INIT_DELAYED_WORK(&ieee->associate_retry_wq, ieee80211_associate_retry_wq_rtl7);
11411 + INIT_WORK(&ieee->associate_complete_wq, ieee80211_associate_complete_wq_rtl7);
11412 + INIT_WORK(&ieee->associate_procedure_wq, ieee80211_associate_procedure_wq_rtl7);
11413 + INIT_DELAYED_WORK(&ieee->softmac_scan_wq, ieee80211_softmac_scan_wq_rtl7);
11414 + INIT_WORK(&ieee->wx_sync_scan_wq, ieee80211_wx_sync_scan_wq_rtl7);
11415 +#endif
11416 +
11417 sema_init(&ieee->wx_sem, 1);
11418 sema_init(&ieee->scan_sem, 1);
11419 -
11420 +
11421 spin_lock_init(&ieee->mgmt_tx_lock);
11422 spin_lock_init(&ieee->beacon_lock);
11423 -
11424 +
11425 tasklet_init(&ieee->ps_task,
11426 - (void(*)(unsigned long)) ieee80211_sta_ps,
11427 + (void(*)(unsigned long)) ieee80211_sta_ps_rtl7,
11428 (unsigned long)ieee);
11429  
11430 }
11431  
11432 -void ieee80211_softmac_free(struct ieee80211_device *ieee)
11433 +void ieee80211_softmac_free_rtl7(struct ieee80211_device *ieee)
11434 {
11435 down(&ieee->wx_sem);
11436 -
11437 +
11438 del_timer_sync(&ieee->associate_timer);
11439 cancel_delayed_work(&ieee->associate_retry_wq);
11440 destroy_workqueue(ieee->wq);
11441 -
11442 +
11443 up(&ieee->wx_sem);
11444 }
11445  
11446 -/********************************************************
11447 +/********************************************************
11448 * Start of WPA code. *
11449 * this is stolen from the ipw2200 driver *
11450 ********************************************************/
11451  
11452 -
11453 -static int ieee80211_wpa_enable(struct ieee80211_device *ieee, int value)
11454 +
11455 +static int ieee80211_wpa_enable_rtl7(struct ieee80211_device *ieee, int value)
11456 {
11457 /* This is called when wpa_supplicant loads and closes the driver
11458 * interface. */
11459 @@ -2210,19 +2258,19 @@
11460 return 0;
11461 }
11462  
11463 -
11464 -void ieee80211_wpa_assoc_frame(struct ieee80211_device *ieee, char *wpa_ie, int wpa_ie_len)
11465 +
11466 +void ieee80211_wpa_assoc_frame_rtl7(struct ieee80211_device *ieee, char *wpa_ie, int wpa_ie_len)
11467 {
11468 /* make sure WPA is enabled */
11469 - ieee80211_wpa_enable(ieee, 1);
11470 + ieee80211_wpa_enable_rtl7(ieee, 1);
11471  
11472 - ieee80211_disassociate(ieee);
11473 + ieee80211_disassociate_rtl7(ieee);
11474 }
11475  
11476  
11477 -static int ieee80211_wpa_mlme(struct ieee80211_device *ieee, int command, int reason)
11478 +static int ieee80211_wpa_mlme_rtl7(struct ieee80211_device *ieee, int command, int reason)
11479 {
11480 -
11481 +
11482 int ret = 0;
11483  
11484 switch (command) {
11485 @@ -2231,7 +2279,7 @@
11486 break;
11487  
11488 case IEEE_MLME_STA_DISASSOC:
11489 - ieee80211_disassociate(ieee);
11490 + ieee80211_disassociate_rtl7(ieee);
11491 break;
11492  
11493 default:
11494 @@ -2243,7 +2291,7 @@
11495 }
11496  
11497  
11498 -static int ieee80211_wpa_set_wpa_ie(struct ieee80211_device *ieee,
11499 +static int ieee80211_wpa_set_wpa_ie_rtl7(struct ieee80211_device *ieee,
11500 struct ieee_param *param, int plen)
11501 {
11502 u8 *buf;
11503 @@ -2267,16 +2315,16 @@
11504 ieee->wpa_ie_len = 0;
11505 }
11506  
11507 - ieee80211_wpa_assoc_frame(ieee, ieee->wpa_ie, ieee->wpa_ie_len);
11508 + ieee80211_wpa_assoc_frame_rtl7(ieee, ieee->wpa_ie, ieee->wpa_ie_len);
11509 return 0;
11510 }
11511  
11512 #define AUTH_ALG_OPEN_SYSTEM 0x1
11513 #define AUTH_ALG_SHARED_KEY 0x2
11514  
11515 -static int ieee80211_wpa_set_auth_algs(struct ieee80211_device *ieee, int value)
11516 +static int ieee80211_wpa_set_auth_algs_rtl7(struct ieee80211_device *ieee, int value)
11517 {
11518 -
11519 +
11520 struct ieee80211_security sec = {
11521 .flags = SEC_AUTH_MODE,
11522 };
11523 @@ -2300,13 +2348,13 @@
11524  
11525  
11526  
11527 -static int ieee80211_wpa_set_param(struct ieee80211_device *ieee, u8 name, u32 value)
11528 +static int ieee80211_wpa_set_param_rtl7(struct ieee80211_device *ieee, u8 name, u32 value)
11529 {
11530 int ret=0;
11531  
11532 switch (name) {
11533 case IEEE_PARAM_WPA_ENABLED:
11534 - ret = ieee80211_wpa_enable(ieee, value);
11535 + ret = ieee80211_wpa_enable_rtl7(ieee, value);
11536 break;
11537  
11538 case IEEE_PARAM_TKIP_COUNTERMEASURES:
11539 @@ -2351,7 +2399,7 @@
11540 break;
11541  
11542 case IEEE_PARAM_AUTH_ALGS:
11543 - ret = ieee80211_wpa_set_auth_algs(ieee, value);
11544 + ret = ieee80211_wpa_set_auth_algs_rtl7(ieee, value);
11545 break;
11546  
11547 case IEEE_PARAM_IEEE_802_1X:
11548 @@ -2368,11 +2416,11 @@
11549  
11550 /* implementation borrowed from hostap driver */
11551  
11552 -static int ieee80211_wpa_set_encryption(struct ieee80211_device *ieee,
11553 +static int ieee80211_wpa_set_encryption_rtl7(struct ieee80211_device *ieee,
11554 struct ieee_param *param, int param_len)
11555 {
11556 int ret = 0;
11557 -
11558 +
11559 struct ieee80211_crypto_ops *ops;
11560 struct ieee80211_crypt_data **crypt;
11561  
11562 @@ -2407,7 +2455,7 @@
11563 //sec.encrypt = 0;
11564 sec.level = SEC_LEVEL_0;
11565 sec.flags |= SEC_ENABLED | SEC_LEVEL;
11566 - ieee80211_crypt_delayed_deinit(ieee, crypt);
11567 + ieee80211_crypt_delayed_deinit_rtl7(ieee, crypt);
11568 }
11569 goto done;
11570 }
11571 @@ -2421,16 +2469,16 @@
11572 strcmp(param->u.crypt.alg, "TKIP"))
11573 goto skip_host_crypt;
11574  
11575 - ops = ieee80211_get_crypto_ops(param->u.crypt.alg);
11576 + ops = ieee80211_get_crypto_ops_rtl7(param->u.crypt.alg);
11577 if (ops == NULL && strcmp(param->u.crypt.alg, "WEP") == 0) {
11578 - request_module("ieee80211_crypt_wep");
11579 - ops = ieee80211_get_crypto_ops(param->u.crypt.alg);
11580 + request_module("ieee80211_crypt_wep_rtl");
11581 + ops = ieee80211_get_crypto_ops_rtl7(param->u.crypt.alg);
11582 } else if (ops == NULL && strcmp(param->u.crypt.alg, "TKIP") == 0) {
11583 - request_module("ieee80211_crypt_tkip");
11584 - ops = ieee80211_get_crypto_ops(param->u.crypt.alg);
11585 + request_module("ieee80211_crypt_tkip_rtl");
11586 + ops = ieee80211_get_crypto_ops_rtl7(param->u.crypt.alg);
11587 } else if (ops == NULL && strcmp(param->u.crypt.alg, "CCMP") == 0) {
11588 - request_module("ieee80211_crypt_ccmp");
11589 - ops = ieee80211_get_crypto_ops(param->u.crypt.alg);
11590 + request_module("ieee80211_crypt_ccmp_rtl");
11591 + ops = ieee80211_get_crypto_ops_rtl7(param->u.crypt.alg);
11592 }
11593 if (ops == NULL) {
11594 printk("unknown crypto alg '%s'\n", param->u.crypt.alg);
11595 @@ -2442,7 +2490,7 @@
11596 if (*crypt == NULL || (*crypt)->ops != ops) {
11597 struct ieee80211_crypt_data *new_crypt;
11598  
11599 - ieee80211_crypt_delayed_deinit(ieee, crypt);
11600 + ieee80211_crypt_delayed_deinit_rtl7(ieee, crypt);
11601  
11602 new_crypt = (struct ieee80211_crypt_data *)
11603 kmalloc(sizeof(*new_crypt), GFP_KERNEL);
11604 @@ -2525,7 +2573,7 @@
11605  
11606  
11607  
11608 -int ieee80211_wpa_supplicant_ioctl(struct ieee80211_device *ieee, struct iw_point *p)
11609 +int ieee80211_wpa_supplicant_ioctl_rtl7(struct ieee80211_device *ieee, struct iw_point *p)
11610 {
11611 struct ieee_param *param;
11612 int ret=0;
11613 @@ -2537,7 +2585,7 @@
11614 ret = -EINVAL;
11615 goto out;
11616 }
11617 -
11618 +
11619 param = (struct ieee_param *)kmalloc(p->length, GFP_KERNEL);
11620 if (param == NULL){
11621 ret = -ENOMEM;
11622 @@ -2552,20 +2600,20 @@
11623 switch (param->cmd) {
11624  
11625 case IEEE_CMD_SET_WPA_PARAM:
11626 - ret = ieee80211_wpa_set_param(ieee, param->u.wpa_param.name,
11627 + ret = ieee80211_wpa_set_param_rtl7(ieee, param->u.wpa_param.name,
11628 param->u.wpa_param.value);
11629 break;
11630  
11631 case IEEE_CMD_SET_WPA_IE:
11632 - ret = ieee80211_wpa_set_wpa_ie(ieee, param, p->length);
11633 + ret = ieee80211_wpa_set_wpa_ie_rtl7(ieee, param, p->length);
11634 break;
11635  
11636 case IEEE_CMD_SET_ENCRYPTION:
11637 - ret = ieee80211_wpa_set_encryption(ieee, param, p->length);
11638 + ret = ieee80211_wpa_set_encryption_rtl7(ieee, param, p->length);
11639 break;
11640  
11641 case IEEE_CMD_MLME:
11642 - ret = ieee80211_wpa_mlme(ieee, param->u.mlme.command,
11643 + ret = ieee80211_wpa_mlme_rtl7(ieee, param->u.mlme.command,
11644 param->u.mlme.reason_code);
11645 break;
11646  
11647 @@ -2581,11 +2629,11 @@
11648 kfree(param);
11649 out:
11650 up(&ieee->wx_sem);
11651 -
11652 +
11653 return ret;
11654 }
11655  
11656 -void notify_wx_assoc_event(struct ieee80211_device *ieee)
11657 +void notify_wx_assoc_event_rtl7(struct ieee80211_device *ieee)
11658 {
11659 union iwreq_data wrqu;
11660 wrqu.ap_addr.sa_family = ARPHRD_ETHER;
11661 @@ -2597,14 +2645,14 @@
11662 }
11663  
11664  
11665 -EXPORT_SYMBOL(ieee80211_get_beacon);
11666 -EXPORT_SYMBOL(ieee80211_wake_queue);
11667 -EXPORT_SYMBOL(ieee80211_stop_queue);
11668 -EXPORT_SYMBOL(ieee80211_reset_queue);
11669 -EXPORT_SYMBOL(ieee80211_softmac_stop_protocol);
11670 -EXPORT_SYMBOL(ieee80211_softmac_start_protocol);
11671 -EXPORT_SYMBOL(ieee80211_is_shortslot);
11672 -EXPORT_SYMBOL(ieee80211_is_54g);
11673 -EXPORT_SYMBOL(ieee80211_wpa_supplicant_ioctl);
11674 -EXPORT_SYMBOL(ieee80211_ps_tx_ack);
11675 -//EXPORT_SYMBOL(ieee80211_sta_ps_send_null_frame);
11676 +EXPORT_SYMBOL(ieee80211_get_beacon_rtl7);
11677 +EXPORT_SYMBOL(ieee80211_wake_queue_rtl7);
11678 +EXPORT_SYMBOL(ieee80211_stop_queue_rtl7);
11679 +EXPORT_SYMBOL(ieee80211_reset_queue_rtl7);
11680 +EXPORT_SYMBOL(ieee80211_softmac_stop_protocol_rtl7);
11681 +EXPORT_SYMBOL(ieee80211_softmac_start_protocol_rtl7);
11682 +EXPORT_SYMBOL(ieee80211_is_shortslot_rtl7);
11683 +EXPORT_SYMBOL(ieee80211_is_54g_rtl7);
11684 +EXPORT_SYMBOL(ieee80211_wpa_supplicant_ioctl_rtl7);
11685 +EXPORT_SYMBOL(ieee80211_ps_tx_ack_rtl7);
11686 +//EXPORT_SYMBOL(ieee80211_sta_ps_send_null_frame_rtl7);
11687 diff -Naur rtl8187_orig/ieee80211/ieee80211_softmac_wx.c rtl8187_rawtx/ieee80211/ieee80211_softmac_wx.c
11688 --- rtl8187_orig/ieee80211/ieee80211_softmac_wx.c 2007-03-13 23:45:09.000000000 +0100
11689 +++ rtl8187_rawtx/ieee80211/ieee80211_softmac_wx.c 2007-07-13 01:46:05.000000000 +0200
11690 @@ -1,7 +1,7 @@
11691 /* IEEE 802.11 SoftMAC layer
11692 * Copyright (c) 2005 Andrea Merello <andreamrl@tiscali.it>
11693 *
11694 - * Mostly extracted from the rtl8180-sa2400 driver for the
11695 + * Mostly extracted from the rtl8180-sa2400 driver for the
11696 * in-kernel generic ieee802.11 stack.
11697 *
11698 * Some pieces of code might be stolen from ipw2100 driver
11699 @@ -18,23 +18,23 @@
11700  
11701 /* FIXME: add A freqs */
11702  
11703 -const long ieee80211_wlan_frequencies[] = {
11704 - 2412, 2417, 2422, 2427,
11705 - 2432, 2437, 2442, 2447,
11706 - 2452, 2457, 2462, 2467,
11707 - 2472, 2484
11708 +const long ieee80211_wlan_frequencies_rtl7[] = {
11709 + 2412, 2417, 2422, 2427,
11710 + 2432, 2437, 2442, 2447,
11711 + 2452, 2457, 2462, 2467,
11712 + 2472, 2484
11713 };
11714  
11715  
11716 -int ieee80211_wx_set_freq(struct ieee80211_device *ieee, struct iw_request_info *a,
11717 +int ieee80211_wx_set_freq_rtl7(struct ieee80211_device *ieee, struct iw_request_info *a,
11718 union iwreq_data *wrqu, char *b)
11719 {
11720 int ret;
11721 struct iw_freq *fwrq = & wrqu->freq;
11722  
11723 down(&ieee->wx_sem);
11724 -
11725 - if(ieee->iw_mode == IW_MODE_INFRA){
11726 +
11727 + if(ieee->iw_mode == IW_MODE_INFRA){
11728 ret = -EOPNOTSUPP;
11729 goto out;
11730 }
11731 @@ -45,31 +45,31 @@
11732 fwrq->m <= (int) 2.487e8)) {
11733 int f = fwrq->m / 100000;
11734 int c = 0;
11735 -
11736 - while ((c < 14) && (f != ieee80211_wlan_frequencies[c]))
11737 +
11738 + while ((c < 14) && (f != ieee80211_wlan_frequencies_rtl7[c]))
11739 c++;
11740 -
11741 +
11742 /* hack to fall through */
11743 fwrq->e = 0;
11744 fwrq->m = c + 1;
11745 }
11746 }
11747 -
11748 - if (fwrq->e > 0 || fwrq->m > 14 || fwrq->m < 1 ){
11749 +
11750 + if (fwrq->e > 0 || fwrq->m > 14 || fwrq->m < 1 ){
11751 ret = -EOPNOTSUPP;
11752 goto out;
11753 -
11754 +
11755 }else { /* Set the channel */
11756 -
11757 -
11758 +
11759 +
11760 ieee->current_network.channel = fwrq->m;
11761 ieee->set_chan(ieee->dev, ieee->current_network.channel);
11762 -
11763 +
11764 if(ieee->iw_mode == IW_MODE_ADHOC || ieee->iw_mode == IW_MODE_MASTER)
11765 if(ieee->state == IEEE80211_LINKED){
11766 -
11767 - ieee80211_stop_send_beacons(ieee);
11768 - ieee80211_start_send_beacons(ieee);
11769 +
11770 + ieee80211_stop_send_beacons_rtl7(ieee);
11771 + ieee80211_start_send_beacons_rtl7(ieee);
11772 }
11773 }
11774  
11775 @@ -80,7 +80,7 @@
11776 }
11777  
11778  
11779 -int ieee80211_wx_get_freq(struct ieee80211_device *ieee,
11780 +int ieee80211_wx_get_freq_rtl7(struct ieee80211_device *ieee,
11781 struct iw_request_info *a,
11782 union iwreq_data *wrqu, char *b)
11783 {
11784 @@ -88,110 +88,110 @@
11785  
11786 if (ieee->current_network.channel == 0)
11787 return -1;
11788 -
11789 +
11790 fwrq->m = ieee->current_network.channel;
11791 fwrq->e = 0;
11792 -
11793 +
11794 return 0;
11795 }
11796  
11797 -int ieee80211_wx_get_wap(struct ieee80211_device *ieee,
11798 - struct iw_request_info *info,
11799 +int ieee80211_wx_get_wap_rtl7(struct ieee80211_device *ieee,
11800 + struct iw_request_info *info,
11801 union iwreq_data *wrqu, char *extra)
11802 {
11803 - unsigned long flags;
11804 -
11805 + unsigned long flags;
11806 +
11807 wrqu->ap_addr.sa_family = ARPHRD_ETHER;
11808 -
11809 +
11810 if (ieee->iw_mode == IW_MODE_MONITOR)
11811 return -1;
11812 -
11813 +
11814 /* We want avoid to give to the user inconsistent infos*/
11815 spin_lock_irqsave(&ieee->lock, flags);
11816 -
11817 - if (ieee->state != IEEE80211_LINKED &&
11818 +
11819 + if (ieee->state != IEEE80211_LINKED &&
11820 ieee->state != IEEE80211_LINKED_SCANNING &&
11821 ieee->wap_set == 0)
11822 -
11823 +
11824 memset(wrqu->ap_addr.sa_data, 0, ETH_ALEN);
11825 else
11826 - memcpy(wrqu->ap_addr.sa_data,
11827 + memcpy(wrqu->ap_addr.sa_data,
11828 ieee->current_network.bssid, ETH_ALEN);
11829 -
11830 +
11831 spin_unlock_irqrestore(&ieee->lock, flags);
11832 -
11833 +
11834 return 0;
11835 }
11836  
11837  
11838 -int ieee80211_wx_set_wap(struct ieee80211_device *ieee,
11839 +int ieee80211_wx_set_wap_rtl7(struct ieee80211_device *ieee,
11840 struct iw_request_info *info,
11841 union iwreq_data *awrq,
11842 char *extra)
11843 {
11844 -
11845 +
11846 int ret = 0;
11847 u8 zero[] = {0,0,0,0,0,0};
11848 unsigned long flags;
11849 -
11850 +
11851 + struct sockaddr *temp = NULL;
11852 short ifup = ieee->proto_started;//dev->flags & IFF_UP;
11853 -
11854 +
11855 ieee->sync_scan_hurryup = 1;
11856 -
11857 +
11858 down(&ieee->wx_sem);
11859 -
11860 - struct sockaddr *temp = (struct sockaddr *)awrq;
11861 -
11862 +
11863 + temp = (struct sockaddr *)awrq;
11864 /* use ifconfig hw ether */
11865 if (ieee->iw_mode == IW_MODE_MASTER){
11866 ret = -1;
11867 goto out;
11868 }
11869 -
11870 +
11871 if (temp->sa_family != ARPHRD_ETHER){
11872 ret = -EINVAL;
11873 goto out;
11874 }
11875 -
11876 +
11877 if (ifup)
11878 - ieee80211_stop_protocol(ieee);
11879 -
11880 + ieee80211_stop_protocol_rtl7(ieee);
11881 +
11882 /* just to avoid to give inconsistent infos in the
11883 - * get wx method. not really needed otherwise
11884 + * get wx method. not really needed otherwise
11885 */
11886 spin_lock_irqsave(&ieee->lock, flags);
11887 -
11888 - memcpy(ieee->current_network.bssid, temp->sa_data, ETH_ALEN);
11889 +
11890 + memcpy(ieee->current_network.bssid, temp->sa_data, ETH_ALEN);
11891 ieee->wap_set = memcmp(temp->sa_data, zero,ETH_ALEN)!=0;
11892 -
11893 +
11894 spin_unlock_irqrestore(&ieee->lock, flags);
11895 -
11896 +
11897 if (ifup)
11898 - ieee80211_start_protocol(ieee);
11899 -
11900 + ieee80211_start_protocol_rtl7(ieee);
11901 +
11902 out:
11903 up(&ieee->wx_sem);
11904 return ret;
11905 }
11906 -
11907 - int ieee80211_wx_get_essid(struct ieee80211_device *ieee, struct iw_request_info *a,union iwreq_data *wrqu,char *b)
11908 +
11909 + int ieee80211_wx_get_essid_rtl7(struct ieee80211_device *ieee, struct iw_request_info *a,union iwreq_data *wrqu,char *b)
11910 {
11911 int len,ret = 0;
11912 unsigned long flags;
11913 -
11914 +
11915 if (ieee->iw_mode == IW_MODE_MONITOR)
11916 return -1;
11917 -
11918 - /* We want avoid to give to the user inconsistent infos*/
11919 +
11920 + /* We want avoid to give to the user inconsistent infos*/
11921 spin_lock_irqsave(&ieee->lock, flags);
11922 -
11923 +
11924 if (ieee->current_network.ssid[0] == '\0' ||
11925 - ieee->current_network.ssid_len == 0){
11926 + ieee->current_network.ssid_len == 0){
11927 ret = -1;
11928 goto out;
11929 }
11930 -
11931 - if (ieee->state != IEEE80211_LINKED &&
11932 +
11933 + if (ieee->state != IEEE80211_LINKED &&
11934 ieee->state != IEEE80211_LINKED_SCANNING &&
11935 ieee->ssid_set == 0){
11936 ret = -1;
11937 @@ -204,59 +204,76 @@
11938  
11939 out:
11940 spin_unlock_irqrestore(&ieee->lock, flags);
11941 -
11942 +
11943 return ret;
11944 -
11945 +
11946 }
11947  
11948 -int ieee80211_wx_set_rate(struct ieee80211_device *ieee,
11949 +int ieee80211_wx_set_rate_rtl7(struct ieee80211_device *ieee,
11950 struct iw_request_info *info,
11951 union iwreq_data *wrqu, char *extra)
11952 {
11953  
11954 u32 target_rate = wrqu->bitrate.value;
11955 -
11956 +
11957 ieee->rate = target_rate/100000;
11958 //FIXME: we might want to limit rate also in management protocols.
11959 - return 0;
11960 + return 0;
11961 }
11962  
11963  
11964  
11965 -int ieee80211_wx_get_rate(struct ieee80211_device *ieee,
11966 - struct iw_request_info *info,
11967 +int ieee80211_wx_get_rate_rtl7(struct ieee80211_device *ieee,
11968 + struct iw_request_info *info,
11969 union iwreq_data *wrqu, char *extra)
11970 {
11971 -
11972 +
11973 wrqu->bitrate.value = ieee->rate * 100000;
11974 -
11975 +
11976 return 0;
11977 }
11978  
11979 -int ieee80211_wx_set_mode(struct ieee80211_device *ieee, struct iw_request_info *a,
11980 +int ieee80211_wx_set_mode_rtl7(struct ieee80211_device *ieee, struct iw_request_info *a,
11981 union iwreq_data *wrqu, char *b)
11982 {
11983 -
11984 + short prev = ieee->raw_tx;
11985 +
11986 ieee->sync_scan_hurryup = 1;
11987 -
11988 +
11989 down(&ieee->wx_sem);
11990 -
11991 +
11992 if (wrqu->mode == ieee->iw_mode)
11993 goto out;
11994 -
11995 +
11996 if (wrqu->mode == IW_MODE_MONITOR){
11997 -
11998 - ieee->dev->type = ARPHRD_IEEE80211;
11999 + ieee->dev->type = ARPHRD_IEEE80211_PRISM;
12000 }else{
12001 ieee->dev->type = ARPHRD_ETHER;
12002 }
12003 -
12004 +
12005 if (!ieee->proto_started){
12006 ieee->iw_mode = wrqu->mode;
12007 }else{
12008 - ieee80211_stop_protocol(ieee);
12009 + ieee80211_stop_protocol_rtl7(ieee);
12010 ieee->iw_mode = wrqu->mode;
12011 - ieee80211_start_protocol(ieee);
12012 + ieee80211_start_protocol_rtl7(ieee);
12013 + }
12014 +
12015 + if(ieee->iw_mode == IW_MODE_MONITOR)
12016 + {
12017 + ieee->raw_tx = 1;
12018 + if(prev == 0 && ieee->raw_tx){
12019 + if (ieee->data_hard_resume)
12020 + ieee->data_hard_resume(ieee->dev);
12021 +
12022 + netif_carrier_on(ieee->dev);
12023 + }
12024 +
12025 + netif_carrier_on(ieee->dev);
12026 + }
12027 + else
12028 + {
12029 + ieee->raw_tx = 0;
12030 }
12031  
12032 out:
12033 @@ -264,120 +281,132 @@
12034 return 0;
12035 }
12036  
12037 -void ieee80211_wx_sync_scan_wq(struct ieee80211_device *ieee)
12038 +# if (LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,20))
12039 +void ieee80211_wx_sync_scan_wq_rtl7(struct work_struct *work)
12040 {
12041 + struct ieee80211_device *ieee = container_of(work, struct ieee80211_device, wx_sync_scan_wq);
12042 +#else
12043 +void ieee80211_wx_sync_scan_wq_rtl7(struct ieee80211_device *ieee)
12044 +{
12045 +#endif
12046 short chan;
12047  
12048 chan = ieee->current_network.channel;
12049 -
12050 +
12051 netif_carrier_off(ieee->dev);
12052 -
12053 +
12054 if (ieee->data_hard_stop)
12055 ieee->data_hard_stop(ieee->dev);
12056 -
12057 - ieee80211_stop_send_beacons(ieee);
12058 -
12059 +
12060 + ieee80211_stop_send_beacons_rtl7(ieee);
12061 +
12062 ieee->state = IEEE80211_LINKED_SCANNING;
12063 ieee->link_change(ieee->dev);
12064 -
12065 - ieee80211_start_scan_syncro(ieee);
12066 -
12067 +
12068 + ieee80211_start_scan_syncro_rtl7(ieee);
12069 +
12070 ieee->set_chan(ieee->dev, chan);
12071 -
12072 +
12073 ieee->state = IEEE80211_LINKED;
12074 ieee->link_change(ieee->dev);
12075 -
12076 +
12077 if (ieee->data_hard_resume)
12078 ieee->data_hard_resume(ieee->dev);
12079 -
12080 +
12081 if(ieee->iw_mode == IW_MODE_ADHOC || ieee->iw_mode == IW_MODE_MASTER)
12082 - ieee80211_start_send_beacons(ieee);
12083 -
12084 + ieee80211_start_send_beacons_rtl7(ieee);
12085 +
12086 netif_carrier_on(ieee->dev);
12087 -
12088 +
12089 up(&ieee->wx_sem);
12090 -
12091 +
12092 }
12093  
12094 -int ieee80211_wx_set_scan(struct ieee80211_device *ieee, struct iw_request_info *a,
12095 +int ieee80211_wx_set_scan_rtl7(struct ieee80211_device *ieee, struct iw_request_info *a,
12096 union iwreq_data *wrqu, char *b)
12097 {
12098 int ret = 0;
12099 -
12100 +
12101 down(&ieee->wx_sem);
12102 -
12103 - if (ieee->iw_mode == IW_MODE_MONITOR || !(ieee->proto_started)){
12104 +
12105 + if (ieee->iw_mode == IW_MODE_MONITOR || !(ieee->proto_started)){
12106 ret = -1;
12107 goto out;
12108 }
12109 -
12110 +
12111 if ( ieee->state == IEEE80211_LINKED){
12112 queue_work(ieee->wq, &ieee->wx_sync_scan_wq);
12113 /* intentionally forget to up sem */
12114 return 0;
12115 }
12116 -
12117 +
12118 out:
12119 up(&ieee->wx_sem);
12120 return ret;
12121 }
12122  
12123 -int ieee80211_wx_set_essid(struct ieee80211_device *ieee,
12124 +int ieee80211_wx_set_essid_rtl7(struct ieee80211_device *ieee,
12125 struct iw_request_info *a,
12126 union iwreq_data *wrqu, char *extra)
12127 {
12128 -
12129 +
12130 int ret=0,len;
12131 short proto_started;
12132 unsigned long flags;
12133 -
12134 +
12135 ieee->sync_scan_hurryup = 1;
12136 -
12137 +
12138 down(&ieee->wx_sem);
12139 -
12140 +
12141 proto_started = ieee->proto_started;
12142 -
12143 +
12144 if (wrqu->essid.length > IW_ESSID_MAX_SIZE){
12145 ret= -E2BIG;
12146 goto out;
12147 }
12148 -
12149 +
12150 if (ieee->iw_mode == IW_MODE_MONITOR){
12151 ret= -1;
12152 goto out;
12153 }
12154 -
12155 +
12156 if(proto_started)
12157 - ieee80211_stop_protocol(ieee);
12158 -
12159 + ieee80211_stop_protocol_rtl7(ieee);
12160 +
12161 /* this is just to be sure that the GET wx callback
12162 * has consisten infos. not needed otherwise
12163 */
12164 spin_lock_irqsave(&ieee->lock, flags);
12165 -
12166 +
12167 if (wrqu->essid.flags && wrqu->essid.length) {
12168 +#if WIRELESS_EXT > 20
12169 + len = min((int)wrqu->essid.length, IW_ESSID_MAX_SIZE);
12170 +#else
12171 len = ((wrqu->essid.length-1) < IW_ESSID_MAX_SIZE) ? (wrqu->essid.length-1) : IW_ESSID_MAX_SIZE;
12172 -
12173 +#endif
12174 +
12175 strncpy(ieee->current_network.ssid, extra, len);
12176 ieee->current_network.ssid_len = len;
12177 ieee->ssid_set = 1;
12178 }
12179 - else{
12180 + else{
12181 ieee->ssid_set = 0;
12182 ieee->current_network.ssid[0] = '\0';
12183 ieee->current_network.ssid_len = 0;
12184 }
12185 -
12186 +
12187 spin_unlock_irqrestore(&ieee->lock, flags);
12188 -
12189 +
12190 if (proto_started)
12191 - ieee80211_start_protocol(ieee);
12192 + ieee80211_start_protocol_rtl7(ieee);
12193 out:
12194 up(&ieee->wx_sem);
12195 +
12196 +
12197 return ret;
12198 }
12199  
12200 - int ieee80211_wx_get_mode(struct ieee80211_device *ieee, struct iw_request_info *a,
12201 + int ieee80211_wx_get_mode_rtl7(struct ieee80211_device *ieee, struct iw_request_info *a,
12202 union iwreq_data *wrqu, char *b)
12203 {
12204  
12205 @@ -385,23 +414,23 @@
12206 return 0;
12207 }
12208  
12209 - int ieee80211_wx_set_rawtx(struct ieee80211_device *ieee,
12210 - struct iw_request_info *info,
12211 + int ieee80211_wx_set_rawtx_rtl7(struct ieee80211_device *ieee,
12212 + struct iw_request_info *info,
12213 union iwreq_data *wrqu, char *extra)
12214 {
12215 -
12216 +
12217 int *parms = (int *)extra;
12218 int enable = (parms[0] > 0);
12219 short prev = ieee->raw_tx;
12220  
12221 down(&ieee->wx_sem);
12222 -
12223 - if(enable)
12224 +
12225 + if(enable)
12226 ieee->raw_tx = 1;
12227 - else
12228 + else
12229 ieee->raw_tx = 0;
12230  
12231 - printk(KERN_INFO"raw TX is %s\n",
12232 + printk(KERN_INFO"raw TX is %s\n",
12233 ieee->raw_tx ? "enabled" : "disabled");
12234  
12235 if(ieee->iw_mode == IW_MODE_MONITOR)
12236 @@ -409,21 +438,21 @@
12237 if(prev == 0 && ieee->raw_tx){
12238 if (ieee->data_hard_resume)
12239 ieee->data_hard_resume(ieee->dev);
12240 -
12241 - netif_carrier_on(ieee->dev);
12242 +
12243 + netif_carrier_on(ieee->dev);
12244 }
12245 -
12246 +
12247 if(prev && ieee->raw_tx == 1)
12248 - netif_carrier_off(ieee->dev);
12249 + netif_carrier_off(ieee->dev);
12250 }
12251 -
12252 +
12253 up(&ieee->wx_sem);
12254 -
12255 +
12256 return 0;
12257 }
12258 -
12259 -int ieee80211_wx_get_name(struct ieee80211_device *ieee,
12260 - struct iw_request_info *info,
12261 +
12262 +int ieee80211_wx_get_name_rtl7(struct ieee80211_device *ieee,
12263 + struct iw_request_info *info,
12264 union iwreq_data *wrqu, char *extra)
12265 {
12266 strcpy(wrqu->name, "802.11");
12267 @@ -433,20 +462,20 @@
12268 strcat(wrqu->name, "/g");
12269 }else if(ieee->modulation & IEEE80211_OFDM_MODULATION)
12270 strcat(wrqu->name, "g");
12271 -
12272 - if((ieee->state == IEEE80211_LINKED) ||
12273 +
12274 + if((ieee->state == IEEE80211_LINKED) ||
12275 (ieee->state == IEEE80211_LINKED_SCANNING))
12276 strcat(wrqu->name," linked");
12277 else if(ieee->state != IEEE80211_NOLINK)
12278 strcat(wrqu->name," link..");
12279 -
12280 -
12281 +
12282 +
12283 return 0;
12284 }
12285  
12286  
12287 /* this is mostly stolen from hostap */
12288 -int ieee80211_wx_set_power(struct ieee80211_device *ieee,
12289 +int ieee80211_wx_set_power_rtl7(struct ieee80211_device *ieee,
12290 struct iw_request_info *info,
12291 union iwreq_data *wrqu, char *extra)
12292 {
12293 @@ -457,50 +486,50 @@
12294 (!ieee->ps_request_tx_ack) ||
12295 (!ieee->enter_sleep_state) ||
12296 (!ieee->ps_is_queue_empty)){
12297 -
12298 +
12299 printk("ERROR. PS mode is tryied to be use but\
12300 -driver missed a callback\n\n");
12301 -
12302 +driver missed a callback\n\n");
12303 +
12304 return -1;
12305 }
12306 -
12307 +
12308 down(&ieee->wx_sem);
12309 -
12310 +
12311 if (wrqu->power.disabled){
12312 ieee->ps = IEEE80211_PS_DISABLED;
12313 -
12314 +
12315 goto exit;
12316 }
12317 switch (wrqu->power.flags & IW_POWER_MODE) {
12318 case IW_POWER_UNICAST_R:
12319 ieee->ps = IEEE80211_PS_UNICAST;
12320 -
12321 +
12322 break;
12323 case IW_POWER_ALL_R:
12324 - ieee->ps = IEEE80211_PS_UNICAST | IEEE80211_PS_MBCAST;
12325 + ieee->ps = IEEE80211_PS_UNICAST | IEEE80211_PS_MBCAST;
12326 break;
12327 -
12328 +
12329 case IW_POWER_ON:
12330 ieee->ps = IEEE80211_PS_DISABLED;
12331 break;
12332 -
12333 +
12334 default:
12335 ret = -EINVAL;
12336 goto exit;
12337 }
12338  
12339 if (wrqu->power.flags & IW_POWER_TIMEOUT) {
12340 -
12341 +
12342 ieee->ps_timeout = wrqu->power.value / 1000;
12343 printk("Timeout %d\n",ieee->ps_timeout);
12344 }
12345 -
12346 +
12347 if (wrqu->power.flags & IW_POWER_PERIOD) {
12348 -
12349 +
12350 ret = -EOPNOTSUPP;
12351 goto exit;
12352 //wrq->value / 1024;
12353 -
12354 +
12355 }
12356 exit:
12357 up(&ieee->wx_sem);
12358 @@ -509,15 +538,15 @@
12359 }
12360  
12361 /* this is stolen from hostap */
12362 -int ieee80211_wx_get_power(struct ieee80211_device *ieee,
12363 +int ieee80211_wx_get_power_rtl7(struct ieee80211_device *ieee,
12364 struct iw_request_info *info,
12365 union iwreq_data *wrqu, char *extra)
12366 {
12367 int ret =0;
12368 -
12369 +
12370 down(&ieee->wx_sem);
12371 -
12372 - if(ieee->ps == IEEE80211_PS_DISABLED){
12373 +
12374 + if(ieee->ps == IEEE80211_PS_DISABLED){
12375 wrqu->power.disabled = 1;
12376 goto exit;
12377 }
12378 @@ -547,19 +576,19 @@
12379  
12380 }
12381  
12382 -EXPORT_SYMBOL(ieee80211_wx_get_essid);
12383 -EXPORT_SYMBOL(ieee80211_wx_set_essid);
12384 -EXPORT_SYMBOL(ieee80211_wx_set_rate);
12385 -EXPORT_SYMBOL(ieee80211_wx_get_rate);
12386 -EXPORT_SYMBOL(ieee80211_wx_set_wap);
12387 -EXPORT_SYMBOL(ieee80211_wx_get_wap);
12388 -EXPORT_SYMBOL(ieee80211_wx_set_mode);
12389 -EXPORT_SYMBOL(ieee80211_wx_get_mode);
12390 -EXPORT_SYMBOL(ieee80211_wx_set_scan);
12391 -EXPORT_SYMBOL(ieee80211_wx_get_freq);
12392 -EXPORT_SYMBOL(ieee80211_wx_set_freq);
12393 -EXPORT_SYMBOL(ieee80211_wx_set_rawtx);
12394 -EXPORT_SYMBOL(ieee80211_wx_get_name);
12395 -EXPORT_SYMBOL(ieee80211_wx_set_power);
12396 -EXPORT_SYMBOL(ieee80211_wx_get_power);
12397 -EXPORT_SYMBOL(ieee80211_wlan_frequencies);
12398 +EXPORT_SYMBOL(ieee80211_wx_get_essid_rtl7);
12399 +EXPORT_SYMBOL(ieee80211_wx_set_essid_rtl7);
12400 +EXPORT_SYMBOL(ieee80211_wx_set_rate_rtl7);
12401 +EXPORT_SYMBOL(ieee80211_wx_get_rate_rtl7);
12402 +EXPORT_SYMBOL(ieee80211_wx_set_wap_rtl7);
12403 +EXPORT_SYMBOL(ieee80211_wx_get_wap_rtl7);
12404 +EXPORT_SYMBOL(ieee80211_wx_set_mode_rtl7);
12405 +EXPORT_SYMBOL(ieee80211_wx_get_mode_rtl7);
12406 +EXPORT_SYMBOL(ieee80211_wx_set_scan_rtl7);
12407 +EXPORT_SYMBOL(ieee80211_wx_get_freq_rtl7);
12408 +EXPORT_SYMBOL(ieee80211_wx_set_freq_rtl7);
12409 +EXPORT_SYMBOL(ieee80211_wx_set_rawtx_rtl7);
12410 +EXPORT_SYMBOL(ieee80211_wx_get_name_rtl7);
12411 +EXPORT_SYMBOL(ieee80211_wx_set_power_rtl7);
12412 +EXPORT_SYMBOL(ieee80211_wx_get_power_rtl7);
12413 +EXPORT_SYMBOL(ieee80211_wlan_frequencies_rtl7);
12414 diff -Naur rtl8187_orig/ieee80211/ieee80211_tx.c rtl8187_rawtx/ieee80211/ieee80211_tx.c
12415 --- rtl8187_orig/ieee80211/ieee80211_tx.c 2007-03-13 23:45:09.000000000 +0100
12416 +++ rtl8187_rawtx/ieee80211/ieee80211_tx.c 2007-07-13 01:46:05.000000000 +0200
12417 @@ -24,15 +24,14 @@
12418  
12419 ******************************************************************************
12420  
12421 - Few modifications for Realtek's Wi-Fi drivers by
12422 + Few modifications for Realtek's Wi-Fi drivers by
12423 Andrea Merello <andreamrl@tiscali.it>
12424 -
12425 - A special thanks goes to Realtek for their support !
12426 +
12427 + A special thanks goes to Realtek for their support !
12428  
12429 ******************************************************************************/
12430  
12431 #include <linux/compiler.h>
12432 -#include <linux/config.h>
12433 #include <linux/errno.h>
12434 #include <linux/if_arp.h>
12435 #include <linux/in6.h>
12436 @@ -52,6 +51,12 @@
12437 #include <linux/etherdevice.h>
12438 #include <asm/uaccess.h>
12439  
12440 +#if (LINUX_VERSION_CODE < KERNEL_VERSION(2,6,19))
12441 +#include <linux/config.h>
12442 +#else
12443 +#include <linux/autoconf.h>
12444 +#endif
12445 +
12446 #include "ieee80211.h"
12447  
12448  
12449 @@ -155,7 +160,7 @@
12450 static u8 P802_1H_OUI[P80211_OUI_LEN] = { 0x00, 0x00, 0xf8 };
12451 static u8 RFC1042_OUI[P80211_OUI_LEN] = { 0x00, 0x00, 0x00 };
12452  
12453 -static inline int ieee80211_put_snap(u8 *data, u16 h_proto)
12454 +static inline int ieee80211_put_snap_rtl7(u8 *data, u16 h_proto)
12455 {
12456 struct ieee80211_snap_hdr *snap;
12457 u8 *oui;
12458 @@ -178,7 +183,7 @@
12459 return SNAP_SIZE + sizeof(u16);
12460 }
12461  
12462 -int ieee80211_encrypt_fragment(
12463 +int ieee80211_encrypt_fragment_rtl7(
12464 struct ieee80211_device *ieee,
12465 struct sk_buff *frag,
12466 int hdr_len)
12467 @@ -225,7 +230,7 @@
12468 }
12469  
12470  
12471 -void ieee80211_txb_free(struct ieee80211_txb *txb) {
12472 +void ieee80211_txb_free_rtl7(struct ieee80211_txb *txb) {
12473 int i;
12474 if (unlikely(!txb))
12475 return;
12476 @@ -235,7 +240,7 @@
12477 kfree(txb);
12478 }
12479  
12480 -struct ieee80211_txb *ieee80211_alloc_txb(int nr_frags, int txb_size,
12481 +struct ieee80211_txb *ieee80211_alloc_txb_rtl7(int nr_frags, int txb_size,
12482 int gfp_mask)
12483 {
12484 struct ieee80211_txb *txb;
12485 @@ -267,7 +272,7 @@
12486 }
12487  
12488 /* SKBs are added to the ieee->tx_queue. */
12489 -int ieee80211_xmit(struct sk_buff *skb,
12490 +int ieee80211_xmit_rtl7(struct sk_buff *skb,
12491 struct net_device *dev)
12492 {
12493 struct ieee80211_device *ieee = netdev_priv(dev);
12494 @@ -299,27 +304,27 @@
12495 }
12496  
12497 if(likely(ieee->raw_tx == 0)){
12498 -
12499 +
12500 if (unlikely(skb->len < SNAP_SIZE + sizeof(u16))) {
12501 printk(KERN_WARNING "%s: skb too small (%d).\n",
12502 ieee->dev->name, skb->len);
12503 goto success;
12504 }
12505 -
12506 -
12507 +
12508 +
12509 ether_type = ntohs(((struct ethhdr *)skb->data)->h_proto);
12510 -
12511 +
12512 crypt = ieee->crypt[ieee->tx_keyidx];
12513 -
12514 +
12515 encrypt = !(ether_type == ETH_P_PAE && ieee->ieee802_1x) &&
12516 ieee->host_encrypt && crypt && crypt->ops;
12517 -
12518 +
12519 if (!encrypt && ieee->ieee802_1x &&
12520 ieee->drop_unencrypted && ether_type != ETH_P_PAE) {
12521 stats->tx_dropped++;
12522 goto success;
12523 }
12524 -
12525 +
12526 #ifdef CONFIG_IEEE80211_DEBUG
12527 if (crypt && !encrypt && ether_type == ETH_P_PAE) {
12528 struct eapol *eap = (struct eapol *)(skb->data +
12529 @@ -328,23 +333,23 @@
12530 eap_get_type(eap->type));
12531 }
12532 #endif
12533 -
12534 +
12535 /* Save source and destination addresses */
12536 memcpy(&dest, skb->data, ETH_ALEN);
12537 memcpy(&src, skb->data+ETH_ALEN, ETH_ALEN);
12538 -
12539 +
12540 /* Advance the SKB to the start of the payload */
12541 skb_pull(skb, sizeof(struct ethhdr));
12542 -
12543 +
12544 /* Determine total amount of storage required for TXB packets */
12545 bytes = skb->len + SNAP_SIZE + sizeof(u16);
12546 -
12547 +
12548 if (encrypt)
12549 fc = IEEE80211_FTYPE_DATA | IEEE80211_STYPE_DATA |
12550 IEEE80211_FCTL_WEP;
12551 else
12552 fc = IEEE80211_FTYPE_DATA | IEEE80211_STYPE_DATA;
12553 -
12554 +
12555 if (ieee->iw_mode == IW_MODE_INFRA) {
12556 fc |= IEEE80211_FCTL_TODS;
12557 /* To DS: Addr1 = BSSID, Addr2 = SA,
12558 @@ -360,9 +365,9 @@
12559 memcpy(&header.addr3, ieee->current_network.bssid, ETH_ALEN);
12560 }
12561 header.frame_ctl = cpu_to_le16(fc);
12562 -
12563 +
12564 hdr_len = IEEE80211_3ADDR_LEN;
12565 -
12566 +
12567 /* Determine fragmentation size based on destination (multicast
12568 * and broadcast are not fragmented) */
12569 if (is_multicast_ether_addr(dest) ||
12570 @@ -370,7 +375,7 @@
12571 frag_size = MAX_FRAG_THRESHOLD;
12572 else
12573 frag_size = ieee->fts;
12574 -
12575 +
12576 /* Determine amount of payload per fragment. Regardless of if
12577 * this stack is providing the full 802.11 header, one will
12578 * eventually be affixed to this fragment -- so we must account for
12579 @@ -379,12 +384,12 @@
12580 if (ieee->config &
12581 (CFG_IEEE80211_COMPUTE_FCS | CFG_IEEE80211_RESERVE_FCS))
12582 bytes_per_frag -= IEEE80211_FCS_LEN;
12583 -
12584 +
12585 /* Each fragment may need to have room for encryptiong pre/postfix */
12586 if (encrypt)
12587 bytes_per_frag -= crypt->ops->extra_prefix_len +
12588 crypt->ops->extra_postfix_len;
12589 -
12590 +
12591 /* Number of fragments is the total bytes_per_frag /
12592 * payload_per_fragment */
12593 nr_frags = bytes / bytes_per_frag;
12594 @@ -393,11 +398,11 @@
12595 nr_frags++;
12596 else
12597 bytes_last_frag = bytes_per_frag;
12598 -
12599 +
12600 /* When we allocate the TXB we allocate enough space for the reserve
12601 * and full fragment bytes (bytes_per_frag doesn't include prefix,
12602 * postfix, header, FCS, etc.) */
12603 - txb = ieee80211_alloc_txb(nr_frags, frag_size, GFP_ATOMIC);
12604 + txb = ieee80211_alloc_txb_rtl7(nr_frags, frag_size, GFP_ATOMIC);
12605 if (unlikely(!txb)) {
12606 printk(KERN_WARNING "%s: Could not allocate TXB\n",
12607 ieee->dev->name);
12608 @@ -405,93 +410,94 @@
12609 }
12610 txb->encrypted = encrypt;
12611 txb->payload_size = bytes;
12612 -
12613 +
12614 for (i = 0; i < nr_frags; i++) {
12615 skb_frag = txb->fragments[i];
12616 -
12617 +
12618 if (encrypt)
12619 skb_reserve(skb_frag, crypt->ops->extra_prefix_len);
12620 -
12621 +
12622 frag_hdr = (struct ieee80211_hdr *)skb_put(skb_frag, hdr_len);
12623 memcpy(frag_hdr, &header, hdr_len);
12624 -
12625 +
12626 /* If this is not the last fragment, then add the MOREFRAGS
12627 * bit to the frame control */
12628 if (i != nr_frags - 1) {
12629 frag_hdr->frame_ctl = cpu_to_le16(
12630 fc | IEEE80211_FCTL_MOREFRAGS);
12631 bytes = bytes_per_frag;
12632 -
12633 +
12634 } else {
12635 /* The last fragment takes the remaining length */
12636 bytes = bytes_last_frag;
12637 }
12638 -
12639 +
12640 frag_hdr->seq_ctl = cpu_to_le16(ieee->seq_ctrl<<4 | i);
12641 -
12642 -
12643 +
12644 +
12645 /* Put a SNAP header on the first fragment */
12646 if (i == 0) {
12647 - ieee80211_put_snap(
12648 + ieee80211_put_snap_rtl7(
12649 skb_put(skb_frag, SNAP_SIZE + sizeof(u16)),
12650 ether_type);
12651 bytes -= SNAP_SIZE + sizeof(u16);
12652 }
12653 -
12654 +
12655 memcpy(skb_put(skb_frag, bytes), skb->data, bytes);
12656 -
12657 +
12658 /* Advance the SKB... */
12659 skb_pull(skb, bytes);
12660 -
12661 +
12662 /* Encryption routine will move the header forward in order
12663 * to insert the IV between the header and the payload */
12664 if (encrypt)
12665 - ieee80211_encrypt_fragment(ieee, skb_frag, hdr_len);
12666 + ieee80211_encrypt_fragment_rtl7(ieee, skb_frag, hdr_len);
12667 if (ieee->config &
12668 (CFG_IEEE80211_COMPUTE_FCS | CFG_IEEE80211_RESERVE_FCS))
12669 skb_put(skb_frag, 4);
12670 }
12671 - // Advance sequence number in data frame.
12672 + // Advance sequence number in data frame.
12673 if (ieee->seq_ctrl == 0xFFF)
12674 ieee->seq_ctrl = 0;
12675 else
12676 ieee->seq_ctrl++;
12677 //---
12678 }else{
12679 - if (unlikely(skb->len < sizeof(struct ieee80211_hdr_3addr))) {
12680 +// if (unlikely(skb->len < sizeof(struct ieee80211_hdr_3addr))) {
12681 + if (unlikely(skb->len < 14)) {
12682 printk(KERN_WARNING "%s: skb too small (%d).\n",
12683 ieee->dev->name, skb->len);
12684 goto success;
12685 }
12686 -
12687 - txb = ieee80211_alloc_txb(1, skb->len, GFP_ATOMIC);
12688 +
12689 + txb = ieee80211_alloc_txb_rtl7(1, skb->len, GFP_ATOMIC);
12690 if(!txb){
12691 printk(KERN_WARNING "%s: Could not allocate TXB\n",
12692 ieee->dev->name);
12693 goto failed;
12694 }
12695 -
12696 +
12697 txb->encrypted = 0;
12698 txb->payload_size = skb->len;
12699 memcpy(skb_put(txb->fragments[0],skb->len), skb->data, skb->len);
12700 - }
12701 + }
12702  
12703 success:
12704 spin_unlock_irqrestore(&ieee->lock, flags);
12705 dev_kfree_skb_any(skb);
12706 if (txb) {
12707 if (ieee->softmac_features & IEEE_SOFTMAC_TX_QUEUE){
12708 - ieee80211_softmac_xmit(txb, ieee);
12709 + ieee80211_softmac_xmit_rtl7(txb, ieee);
12710 }else{
12711 if ((*ieee->hard_start_xmit)(txb, dev) == 0) {
12712 stats->tx_packets++;
12713 stats->tx_bytes += txb->payload_size;
12714 return 0;
12715 }
12716 - ieee80211_txb_free(txb);
12717 + ieee80211_txb_free_rtl7(txb);
12718 }
12719 -
12720 -
12721 +
12722 +
12723 }
12724  
12725 return 0;
12726 @@ -504,4 +510,4 @@
12727  
12728 }
12729  
12730 -EXPORT_SYMBOL(ieee80211_txb_free);
12731 +EXPORT_SYMBOL(ieee80211_txb_free_rtl7);
12732 diff -Naur rtl8187_orig/ieee80211/ieee80211_wx.c rtl8187_rawtx/ieee80211/ieee80211_wx.c
12733 --- rtl8187_orig/ieee80211/ieee80211_wx.c 2007-03-13 23:45:09.000000000 +0100
12734 +++ rtl8187_rawtx/ieee80211/ieee80211_wx.c 2007-07-13 01:46:05.000000000 +0200
12735 @@ -40,7 +40,7 @@
12736 };
12737  
12738 #define MAX_CUSTOM_LEN 64
12739 -static inline char *ipw2100_translate_scan(struct ieee80211_device *ieee,
12740 +static inline char *ipw2100_translate_scan_rtl7(struct ieee80211_device *ieee,
12741 char *start, char *stop,
12742 struct ieee80211_network *network)
12743 {
12744 @@ -207,7 +207,7 @@
12745 return start;
12746 }
12747  
12748 -int ieee80211_wx_get_scan(struct ieee80211_device *ieee,
12749 +int ieee80211_wx_get_scan_rtl7(struct ieee80211_device *ieee,
12750 struct iw_request_info *info,
12751 union iwreq_data *wrqu, char *extra)
12752 {
12753 @@ -220,13 +220,14 @@
12754  
12755 IEEE80211_DEBUG_WX("Getting scan\n");
12756 down(&ieee->wx_sem);
12757 + printk("GOT WX GET SCAN WX_SEM LOCK");
12758 spin_lock_irqsave(&ieee->lock, flags);
12759  
12760 list_for_each_entry(network, &ieee->network_list, list) {
12761 i++;
12762 if (ieee->scan_age == 0 ||
12763 time_after(network->last_scanned + ieee->scan_age, jiffies))
12764 - ev = ipw2100_translate_scan(ieee, ev, stop, network);
12765 + ev = ipw2100_translate_scan_rtl7(ieee, ev, stop, network);
12766 else
12767 IEEE80211_DEBUG_SCAN(
12768 "Not showing network '%s ("
12769 @@ -247,7 +248,7 @@
12770 return 0;
12771 }
12772  
12773 -int ieee80211_wx_set_encode(struct ieee80211_device *ieee,
12774 +int ieee80211_wx_set_encode_rtl7(struct ieee80211_device *ieee,
12775 struct iw_request_info *info,
12776 union iwreq_data *wrqu, char *keybuf)
12777 {
12778 @@ -259,6 +260,9 @@
12779 int i, key, key_provided, len;
12780 struct ieee80211_crypt_data **crypt;
12781  
12782 + if (erq->flags & IW_ENCODE_RESTRICTED)
12783 + return -EINVAL;
12784 +
12785 IEEE80211_DEBUG_WX("SET_ENCODE\n");
12786  
12787 key = erq->flags & IW_ENCODE_INDEX;
12788 @@ -281,7 +285,7 @@
12789 if (key_provided && *crypt) {
12790 IEEE80211_DEBUG_WX("Disabling encryption on key %d.\n",
12791 key);
12792 - ieee80211_crypt_delayed_deinit(ieee, crypt);
12793 + ieee80211_crypt_delayed_deinit_rtl7(ieee, crypt);
12794 } else
12795 IEEE80211_DEBUG_WX("Disabling encryption.\n");
12796  
12797 @@ -291,7 +295,7 @@
12798 if (ieee->crypt[i] != NULL) {
12799 if (key_provided)
12800 break;
12801 - ieee80211_crypt_delayed_deinit(
12802 + ieee80211_crypt_delayed_deinit_rtl7(
12803 ieee, &ieee->crypt[i]);
12804 }
12805 }
12806 @@ -314,7 +318,7 @@
12807 strcmp((*crypt)->ops->name, "WEP") != 0) {
12808 /* changing to use WEP; deinit previously used algorithm
12809 * on this key */
12810 - ieee80211_crypt_delayed_deinit(ieee, crypt);
12811 + ieee80211_crypt_delayed_deinit_rtl7(ieee, crypt);
12812 }
12813  
12814 if (*crypt == NULL) {
12815 @@ -326,10 +330,10 @@
12816 if (new_crypt == NULL)
12817 return -ENOMEM;
12818 memset(new_crypt, 0, sizeof(struct ieee80211_crypt_data));
12819 - new_crypt->ops = ieee80211_get_crypto_ops("WEP");
12820 + new_crypt->ops = ieee80211_get_crypto_ops_rtl7("WEP");
12821 if (!new_crypt->ops) {
12822 - request_module("ieee80211_crypt_wep");
12823 - new_crypt->ops = ieee80211_get_crypto_ops("WEP");
12824 + request_module("ieee80211_crypt_wep_rtl");
12825 + new_crypt->ops = ieee80211_get_crypto_ops_rtl7("WEP");
12826 }
12827  
12828 if (new_crypt->ops && try_module_get(new_crypt->ops->owner))
12829 @@ -340,7 +344,7 @@
12830 new_crypt = NULL;
12831  
12832 printk(KERN_WARNING "%s: could not initialize WEP: "
12833 - "load module ieee80211_crypt_wep\n",
12834 + "load module ieee80211_crypt_wep_rtl\n",
12835 dev->name);
12836 return -EOPNOTSUPP;
12837 }
12838 @@ -418,7 +422,7 @@
12839 return 0;
12840 }
12841  
12842 -int ieee80211_wx_get_encode(struct ieee80211_device *ieee,
12843 +int ieee80211_wx_get_encode_rtl7(struct ieee80211_device *ieee,
12844 struct iw_request_info *info,
12845 union iwreq_data *wrqu, char *keybuf)
12846 {
12847 @@ -430,7 +434,7 @@
12848  
12849 if(ieee->iw_mode == IW_MODE_MONITOR)
12850 return -1;
12851 -
12852 +
12853 key = erq->flags & IW_ENCODE_INDEX;
12854 if (key) {
12855 if (key > WEP_KEYS)
12856 @@ -470,6 +474,6 @@
12857 }
12858  
12859  
12860 -EXPORT_SYMBOL(ieee80211_wx_get_scan);
12861 -EXPORT_SYMBOL(ieee80211_wx_set_encode);
12862 -EXPORT_SYMBOL(ieee80211_wx_get_encode);
12863 +EXPORT_SYMBOL(ieee80211_wx_get_scan_rtl7);
12864 +EXPORT_SYMBOL(ieee80211_wx_set_encode_rtl7);
12865 +EXPORT_SYMBOL(ieee80211_wx_get_encode_rtl7);
12866 diff -Naur rtl8187_orig/ieee80211/Makefile rtl8187_rawtx/ieee80211/Makefile
12867 --- rtl8187_orig/ieee80211/Makefile 2007-03-13 23:45:09.000000000 +0100
12868 +++ rtl8187_rawtx/ieee80211/Makefile 2007-05-27 10:47:26.000000000 +0200
12869 @@ -17,6 +17,7 @@
12870 KVER := $(shell uname -r)
12871 KSRC := /lib/modules/$(KVER)/build
12872 INSTALL_PREFIX :=
12873 +PWD = $(shell pwd)
12874  
12875 all: modules
12876  
12877 diff -Naur rtl8187_orig/ieee80211/Modules.symvers rtl8187_rawtx/ieee80211/Modules.symvers
12878 --- rtl8187_orig/ieee80211/Modules.symvers 2007-03-13 23:45:09.000000000 +0100
12879 +++ rtl8187_rawtx/ieee80211/Modules.symvers 1970-01-01 01:00:00.000000000 +0100
12880 @@ -1,43 +0,0 @@
12881 -0x232e7944 ieee80211_wlan_frequencies /home/woo/rtl8187_linuxdrv_FC2_V1.1_Src/ieee80211/ieee80211-rtl
12882 -0xaeae102f free_ieee80211_rtl /usr/rtl8187_linux_2.6_05312006/ieee80211/ieee80211-rtl
12883 -0x279e265f ieee80211_crypt_deinit_handler net/ieee80211/ieee80211_crypt
12884 -0xc2411d91 ieee80211_stop_queue /home/woo/rtl8187_linuxdrv_FC2_V1.1_Src/ieee80211/ieee80211-rtl
12885 -0x6ece20e1 ieee80211_wx_get_name_rtl /usr/rtl8187_linux_2.6_05312006/ieee80211/ieee80211-rtl
12886 -0x5d3847ff ieee80211_rx_rtl /home/woo/rtl8187_linuxdrv_FC2_V1.1_Src/ieee80211/ieee80211-rtl
12887 -0x18612027 ieee80211_wx_get_scan_rtl /home/woo/rtl8187_linuxdrv_FC2_V1.1_Src/ieee80211/ieee80211-rtl
12888 -0xa0e03ce1 ieee80211_wx_get_name /home/woo/rtl8187_linuxdrv_FC2_V1.1_Src/ieee80211/ieee80211-rtl
12889 -0xee25f349 ieee80211_wx_get_mode /home/woo/rtl8187_linuxdrv_FC2_V1.1_Src/ieee80211/ieee80211-rtl
12890 -0x86013c3d ieee80211_wx_set_mode /home/woo/rtl8187_linuxdrv_FC2_V1.1_Src/ieee80211/ieee80211-rtl
12891 -0x04493cc0 ieee80211_wx_get_rate /home/woo/rtl8187_linuxdrv_FC2_V1.1_Src/ieee80211/ieee80211-rtl
12892 -0x6c6df3b4 ieee80211_wx_set_rate /home/woo/rtl8187_linuxdrv_FC2_V1.1_Src/ieee80211/ieee80211-rtl
12893 -0x82caec02 ieee80211_crypt_deinit_entries net/ieee80211/ieee80211_crypt
12894 -0x347945bf ieee80211_wx_get_power /home/woo/rtl8187_linuxdrv_FC2_V1.1_Src/ieee80211/ieee80211-rtl
12895 -0x6379d455 ieee80211_wx_set_power /home/woo/rtl8187_linuxdrv_FC2_V1.1_Src/ieee80211/ieee80211-rtl
12896 -0xae62ed59 ieee80211_wx_set_scan /home/woo/rtl8187_linuxdrv_FC2_V1.1_Src/ieee80211/ieee80211-rtl
12897 -0x6621e172 ieee80211_wx_set_freq /home/woo/rtl8187_linuxdrv_FC2_V1.1_Src/ieee80211/ieee80211-rtl
12898 -0x0e052e06 ieee80211_wx_get_freq /home/woo/rtl8187_linuxdrv_FC2_V1.1_Src/ieee80211/ieee80211-rtl
12899 -0x283f9f5d ieee80211_unregister_crypto_ops net/ieee80211/ieee80211_crypt
12900 -0x9da79aac ieee80211_is_shortslot /home/woo/rtl8187_linuxdrv_FC2_V1.1_Src/ieee80211/ieee80211-rtl
12901 -0x666032dc ieee80211_wx_get_wap /home/woo/rtl8187_linuxdrv_FC2_V1.1_Src/ieee80211/ieee80211-rtl
12902 -0x9f1cbe0e ieee80211_wx_set_wap /home/woo/rtl8187_linuxdrv_FC2_V1.1_Src/ieee80211/ieee80211-rtl
12903 -0x73d1d341 ieee80211_wx_set_rawtx /home/woo/rtl8187_linuxdrv_FC2_V1.1_Src/ieee80211/ieee80211-rtl
12904 -0x2c714184 ieee80211_is_54g /home/woo/rtl8187_linuxdrv_FC2_V1.1_Src/ieee80211/ieee80211-rtl
12905 -0x6892d598 ieee80211_wpa_supplicant_ioctl /home/woo/rtl8187_linuxdrv_FC2_V1.1_Src/ieee80211/ieee80211-rtl
12906 -0xc062f1f5 ieee80211_ps_tx_ack /home/woo/rtl8187_linuxdrv_FC2_V1.1_Src/ieee80211/ieee80211-rtl
12907 -0x55534906 ieee80211_get_beacon /home/woo/rtl8187_linuxdrv_FC2_V1.1_Src/ieee80211/ieee80211-rtl
12908 -0xe2679638 ieee80211_crypt_delayed_deinit net/ieee80211/ieee80211_crypt
12909 -0x3a0456bc free_ieee80211 net/ieee80211/ieee80211
12910 -0x7e1ef2c8 ieee80211_wake_queue /home/woo/rtl8187_linuxdrv_FC2_V1.1_Src/ieee80211/ieee80211-rtl
12911 -0xc1b81e9f ieee80211_register_crypto_ops net/ieee80211/ieee80211_crypt
12912 -0x3f795a39 alloc_ieee80211 net/ieee80211/ieee80211
12913 -0x89803c23 ieee80211_get_crypto_ops net/ieee80211/ieee80211_crypt
12914 -0xc6caf2a4 ieee80211_txb_free net/ieee80211/ieee80211
12915 -0x49c1422c ieee80211_rx_mgt net/ieee80211/ieee80211
12916 -0xbf2b4ebd alloc_ieee80211_rtl /usr/rtl8187_linux_2.6_05312006/ieee80211/ieee80211-rtl
12917 -0xd155f7b8 ieee80211_softmac_stop_protocol /home/woo/rtl8187_linuxdrv_FC2_V1.1_Src/ieee80211/ieee80211-rtl
12918 -0x9ce2dcde ieee80211_softmac_start_protocol /home/woo/rtl8187_linuxdrv_FC2_V1.1_Src/ieee80211/ieee80211-rtl
12919 -0x00d74bba ieee80211_wx_get_encode_rtl /home/woo/rtl8187_linuxdrv_FC2_V1.1_Src/ieee80211/ieee80211-rtl
12920 -0x92b5d996 ieee80211_wx_set_encode_rtl /home/woo/rtl8187_linuxdrv_FC2_V1.1_Src/ieee80211/ieee80211-rtl
12921 -0x2ac9bf95 ieee80211_wx_set_essid /home/woo/rtl8187_linuxdrv_FC2_V1.1_Src/ieee80211/ieee80211-rtl
12922 -0x7dc92e7f ieee80211_wx_get_essid /home/woo/rtl8187_linuxdrv_FC2_V1.1_Src/ieee80211/ieee80211-rtl
12923 -0xd04740ca ieee80211_reset_queue /home/woo/rtl8187_linuxdrv_FC2_V1.1_Src/ieee80211/ieee80211-rtl
12924 diff -Naur rtl8187_orig/Makefile rtl8187_rawtx/Makefile
12925 --- rtl8187_orig/Makefile 1970-01-01 01:00:00.000000000 +0100
12926 +++ rtl8187_rawtx/Makefile 2007-06-21 23:43:15.000000000 +0200
12927 @@ -0,0 +1,39 @@
12928 +prefix = /lib/modules/$(shell uname -r)/kernel/drivers/net/wireless
12929 +r8187dir = $(prefix)/rtl8187
12930 +ieeedir = $(prefix)/rtl_ieee80211
12931 +
12932 +default: all
12933 +
12934 +all:
12935 + -rm -f ieee80211/Module.symvers 2>/dev/null
12936 + -rm -f ieee80211/Modules.symvers 2>/dev/null
12937 + $(MAKE) -C ieee80211 $(@)
12938 + -chmod +x symvers
12939 + -./symvers
12940 + $(MAKE) -C beta-8187 $(@)
12941 +
12942 +install:
12943 + install -d $(ieeedir)
12944 + install -d $(r8187dir)
12945 + install -m 644 ./ieee80211/*.ko $(ieeedir)
12946 + install -m 644 ./beta-8187/*.ko $(r8187dir)
12947 + -find /lib/modules/$(shell uname -r) -name rtl8187.ko -exec mv -v {} ~/ \;
12948 + -depmod -ae
12949 +
12950 +uninstall:
12951 + -rm -f $(ieeedir)/ieee80211-rtl.ko
12952 + -rm -f $(ieeedir)/ieee80211_crypt-rtl.ko
12953 + -rm -f $(ieeedir)/ieee80211_crypt_ccmp-rtl.ko
12954 + -rm -f $(ieeedir)/ieee80211_crypt_tkip-rtl.ko
12955 + -rm -f $(ieeedir)/ieee80211_crypt_wep-rtl.ko
12956 + -rm -f $(r8187dir)/r8187.ko
12957 + -rm -fr $(ieeedir)
12958 + -rm -fr $(r8187dir)
12959 + -depmod -ae
12960 +
12961 +clean:
12962 + $(MAKE) -C ieee80211 $(@)
12963 + $(MAKE) -C beta-8187 $(@)
12964 +
12965 +distclean: clean
12966 +
12967 diff -Naur rtl8187_orig/symvers rtl8187_rawtx/symvers
12968 --- rtl8187_orig/symvers 1970-01-01 01:00:00.000000000 +0100
12969 +++ rtl8187_rawtx/symvers 2007-05-26 10:39:22.000000000 +0200
12970 @@ -0,0 +1,25 @@
12971 +#!/bin/sh
12972 +
12973 +cd beta-8187
12974 +
12975 +if [ -e Module.symvers ]
12976 +then
12977 + rm Module.symvers
12978 +fi
12979 +
12980 +if [ -e Modules.symvers ]
12981 +then
12982 + rm Modules.symvers
12983 +fi
12984 +
12985 +if [ -e ../ieee80211/Module.symvers ]
12986 +then
12987 + ln -sf ../ieee80211/Module.symvers ./
12988 +fi
12989 +
12990 +if [ -e ../ieee80211/Modules.symvers ]
12991 +then
12992 + ln -sf ../ieee80211/Modules.symvers ./
12993 +fi
12994 +
12995 +cd ..
12996 diff -Naur rtl8187_orig/wlan0rmv rtl8187_rawtx/wlan0rmv
12997 --- rtl8187_orig/wlan0rmv 2007-03-13 23:45:09.000000000 +0100
12998 +++ rtl8187_rawtx/wlan0rmv 2007-06-26 16:32:43.000000000 +0200
12999 @@ -1,5 +1,9 @@
13000 #!/bin/bash
13001  
13002 -rmmod r8180
13003 -rmmod ieee80211_r8180
13004 -rmmod ieee80211_crypt_r8180
13005 +rmmod rtl8187 2>/dev/null
13006 +rmmod r8187 2>/dev/null
13007 +rmmod ieee80211_rtl 2>/dev/null
13008 +rmmod ieee80211_crypt_ccmp_rtl 2>/dev/null
13009 +rmmod ieee80211_crypt_tkip_rtl 2>/dev/null
13010 +rmmod ieee80211_crypt_wep_rtl 2>/dev/null
13011 +rmmod ieee80211_crypt_rtl 2>/dev/null