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-13 01:46:05.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,85 @@
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 skb->mac.raw = skb->data;
7940 - skb_pull(skb, ieee80211_get_hdrlen(fc));
7941 + skb_pull(skb, hdrlen);
7942 + if (prism_header)
7943 + skb_pull(skb, phdrlen);
7944 skb->pkt_type = PACKET_OTHERHOST;
7945 skb->protocol = __constant_htons(ETH_P_80211_RAW);
7946 memset(skb->cb, 0, sizeof(skb->cb));
7947 @@ -64,7 +130,7 @@
7948  
7949 /* Called only as a tasklet (software IRQ) */
7950 static struct ieee80211_frag_entry *
7951 -ieee80211_frag_cache_find(struct ieee80211_device *ieee, unsigned int seq,
7952 +ieee80211_frag_cache_find_rtl7(struct ieee80211_device *ieee, unsigned int seq,
7953 unsigned int frag, u8 *src, u8 *dst)
7954 {
7955 struct ieee80211_frag_entry *entry;
7956 @@ -94,7 +160,7 @@
7957  
7958 /* Called only as a tasklet (software IRQ) */
7959 static struct sk_buff *
7960 -ieee80211_frag_cache_get(struct ieee80211_device *ieee,
7961 +ieee80211_frag_cache_get_rtl7(struct ieee80211_device *ieee,
7962 struct ieee80211_hdr *hdr)
7963 {
7964 struct sk_buff *skb = NULL;
7965 @@ -133,7 +199,7 @@
7966 } else {
7967 /* received a fragment of a frame for which the head fragment
7968 * should have already been received */
7969 - entry = ieee80211_frag_cache_find(ieee, seq, frag, hdr->addr2,
7970 + entry = ieee80211_frag_cache_find_rtl7(ieee, seq, frag, hdr->addr2,
7971 hdr->addr1);
7972 if (entry != NULL) {
7973 entry->last_frag = frag;
7974 @@ -146,7 +212,7 @@
7975  
7976  
7977 /* Called only as a tasklet (software IRQ) */
7978 -static int ieee80211_frag_cache_invalidate(struct ieee80211_device *ieee,
7979 +static int ieee80211_frag_cache_invalidate_rtl7(struct ieee80211_device *ieee,
7980 struct ieee80211_hdr *hdr)
7981 {
7982 u16 sc;
7983 @@ -156,7 +222,7 @@
7984 sc = le16_to_cpu(hdr->seq_ctl);
7985 seq = WLAN_GET_SEQ_SEQ(sc);
7986  
7987 - entry = ieee80211_frag_cache_find(ieee, seq, -1, hdr->addr2,
7988 + entry = ieee80211_frag_cache_find_rtl7(ieee, seq, -1, hdr->addr2,
7989 hdr->addr1);
7990  
7991 if (entry == NULL) {
7992 @@ -178,7 +244,7 @@
7993 *
7994 * Called by ieee80211_rx */
7995 static inline int
7996 -ieee80211_rx_frame_mgmt(struct ieee80211_device *ieee, struct sk_buff *skb,
7997 +ieee80211_rx_frame_mgmt_rtl7(struct ieee80211_device *ieee, struct sk_buff *skb,
7998 struct ieee80211_rx_stats *rx_stats, u16 type,
7999 u16 stype)
8000 {
8001 @@ -187,13 +253,13 @@
8002 * response parser uses it
8003 */
8004 rx_stats->len = skb->len;
8005 - ieee80211_rx_mgt(ieee,(struct ieee80211_hdr *)skb->data,rx_stats);
8006 - ieee80211_rx_frame_softmac(ieee, skb, rx_stats, type, stype);
8007 + ieee80211_rx_mgt_rtl7(ieee,(struct ieee80211_hdr *)skb->data,rx_stats);
8008 + ieee80211_rx_frame_softmac_rtl7(ieee, skb, rx_stats, type, stype);
8009  
8010 dev_kfree_skb_any(skb);
8011 -
8012 +
8013 return 0;
8014 -
8015 +
8016 #ifdef NOT_YET
8017 if (ieee->iw_mode == IW_MODE_MASTER) {
8018 printk(KERN_DEBUG "%s: Master mode not yet suppported.\n",
8019 @@ -253,7 +319,7 @@
8020 /* No encapsulation header if EtherType < 0x600 (=length) */
8021  
8022 /* Called by ieee80211_rx_frame_decrypt */
8023 -static int ieee80211_is_eapol_frame(struct ieee80211_device *ieee,
8024 +static int ieee80211_is_eapol_frame_rtl7(struct ieee80211_device *ieee,
8025 struct sk_buff *skb)
8026 {
8027 struct net_device *dev = ieee->dev;
8028 @@ -294,7 +360,7 @@
8029  
8030 /* Called only as a tasklet (software IRQ), by ieee80211_rx */
8031 static inline int
8032 -ieee80211_rx_frame_decrypt(struct ieee80211_device* ieee, struct sk_buff *skb,
8033 +ieee80211_rx_frame_decrypt_rtl7(struct ieee80211_device* ieee, struct sk_buff *skb,
8034 struct ieee80211_crypt_data *crypt)
8035 {
8036 struct ieee80211_hdr *hdr;
8037 @@ -304,7 +370,7 @@
8038 return 0;
8039  
8040 hdr = (struct ieee80211_hdr *) skb->data;
8041 - hdrlen = ieee80211_get_hdrlen(le16_to_cpu(hdr->frame_ctl));
8042 + hdrlen = ieee80211_get_hdrlen_rtl7(le16_to_cpu(hdr->frame_ctl));
8043  
8044 #ifdef CONFIG_IEEE80211_CRYPT_TKIP
8045 if (ieee->tkip_countermeasures &&
8046 @@ -339,7 +405,7 @@
8047  
8048 /* Called only as a tasklet (software IRQ), by ieee80211_rx */
8049 static inline int
8050 -ieee80211_rx_frame_decrypt_msdu(struct ieee80211_device* ieee, struct sk_buff *skb,
8051 +ieee80211_rx_frame_decrypt_msdu_rtl7(struct ieee80211_device* ieee, struct sk_buff *skb,
8052 int keyidx, struct ieee80211_crypt_data *crypt)
8053 {
8054 struct ieee80211_hdr *hdr;
8055 @@ -349,7 +415,7 @@
8056 return 0;
8057  
8058 hdr = (struct ieee80211_hdr *) skb->data;
8059 - hdrlen = ieee80211_get_hdrlen(le16_to_cpu(hdr->frame_ctl));
8060 + hdrlen = ieee80211_get_hdrlen_rtl7(le16_to_cpu(hdr->frame_ctl));
8061  
8062 atomic_inc(&crypt->refcnt);
8063 res = crypt->ops->decrypt_msdu(skb, keyidx, hdrlen, crypt->priv);
8064 @@ -367,7 +433,7 @@
8065  
8066 /* this function is stolen from ipw2200 driver*/
8067 #define IEEE_PACKET_RETRY_TIME (5*HZ)
8068 -static int is_duplicate_packet(struct ieee80211_device *ieee,
8069 +static int is_duplicate_packet_rtl7(struct ieee80211_device *ieee,
8070 struct ieee80211_hdr *header)
8071 {
8072 // u16 fc = le16_to_cpu(header->frame_ctl);
8073 @@ -413,7 +479,7 @@
8074 last_seq = &ieee->last_seq_num;
8075 last_frag = &ieee->last_frag_num;
8076 last_time = &ieee->last_packet_time;
8077 -
8078 +
8079 break;
8080 default:
8081 return 0;
8082 @@ -436,7 +502,7 @@
8083 drop:
8084 // BUG_ON(!(fc & IEEE80211_FCTL_RETRY));
8085 // printk("DUP\n");
8086 -
8087 +
8088 return 1;
8089 }
8090  
8091 @@ -444,7 +510,7 @@
8092 /* All received frames are sent to this function. @skb contains the frame in
8093 * IEEE 802.11 format, i.e., in the format it was sent over air.
8094 * This function is called only as a tasklet (software IRQ). */
8095 -int ieee80211_rx(struct ieee80211_device *ieee, struct sk_buff *skb,
8096 +int ieee80211_rx_rtl7(struct ieee80211_device *ieee, struct sk_buff *skb,
8097 struct ieee80211_rx_stats *rx_stats)
8098 {
8099 struct net_device *dev = ieee->dev;
8100 @@ -481,9 +547,9 @@
8101 type = WLAN_FC_GET_TYPE(fc);
8102 stype = WLAN_FC_GET_STYPE(fc);
8103 sc = le16_to_cpu(hdr->seq_ctl);
8104 -
8105 +
8106 frag = WLAN_GET_SEQ_FRAG(sc);
8107 - hdrlen = ieee80211_get_hdrlen(fc);
8108 + hdrlen = ieee80211_get_hdrlen_rtl7(fc);
8109  
8110 #ifdef NOT_YET
8111 #if WIRELESS_EXT > 15
8112 @@ -501,12 +567,12 @@
8113 }
8114 #endif /* IW_WIRELESS_SPY */
8115 #endif /* WIRELESS_EXT > 15 */
8116 - hostap_update_rx_stats(local->ap, hdr, rx_stats);
8117 + hostap_update_rx_stats_rtl7(local->ap, hdr, rx_stats);
8118 #endif
8119  
8120 #if WIRELESS_EXT > 15
8121 if (ieee->iw_mode == IW_MODE_MONITOR) {
8122 - ieee80211_monitor_rx(ieee, skb, rx_stats);
8123 + ieee80211_monitor_rx_rtl7(ieee, skb, rx_stats);
8124 stats->rx_packets++;
8125 stats->rx_bytes += skb->len;
8126 return 1;
8127 @@ -529,7 +595,7 @@
8128 * stations that do not support WEP key mapping). */
8129  
8130 if (!(hdr->addr1[0] & 0x01) || local->bcrx_sta_key)
8131 - (void) hostap_handle_sta_crypto(local, hdr, &crypt,
8132 + (void) hostap_handle_sta_crypto_rtl7(local, hdr, &crypt,
8133 &sta);
8134 #endif
8135  
8136 @@ -555,7 +621,7 @@
8137 if (skb->len < IEEE80211_DATA_HDR3_LEN)
8138 goto rx_dropped;
8139  
8140 - if (is_duplicate_packet(ieee, hdr))
8141 + if (is_duplicate_packet_rtl7(ieee, hdr))
8142 goto rx_dropped;
8143  
8144  
8145 @@ -573,9 +639,9 @@
8146 goto rx_dropped;
8147 }
8148 #endif
8149 -
8150 -
8151 - if (ieee80211_rx_frame_mgmt(ieee, skb, rx_stats, type, stype))
8152 +
8153 +
8154 + if (ieee80211_rx_frame_mgmt_rtl7(ieee, skb, rx_stats, type, stype))
8155 goto rx_dropped;
8156 else
8157 goto rx_exit;
8158 @@ -583,7 +649,7 @@
8159  
8160  
8161 /* Data frame - extract src/dst addresses */
8162 -
8163 +
8164 switch (fc & (IEEE80211_FCTL_FROMDS | IEEE80211_FCTL_TODS)) {
8165 case IEEE80211_FCTL_FROMDS:
8166 memcpy(dst, hdr->addr1, ETH_ALEN);
8167 @@ -606,7 +672,7 @@
8168 }
8169  
8170 #ifdef NOT_YET
8171 - if (hostap_rx_frame_wds(ieee, hdr, fc, &wds))
8172 + if (hostap_rx_frame_wds_rtl7(ieee, hdr, fc, &wds))
8173 goto rx_dropped;
8174 if (wds) {
8175 skb->dev = dev = wds;
8176 @@ -619,7 +685,7 @@
8177 memcmp(hdr->addr2, ieee->assoc_ap_addr, ETH_ALEN) == 0) {
8178 /* Frame from BSSID of the AP for which we are a client */
8179 skb->dev = dev = ieee->stadev;
8180 - stats = hostap_get_stats(dev);
8181 + stats = hostap_get_stats_rtl7(dev);
8182 from_assoc_ap = 1;
8183 }
8184 #endif
8185 @@ -630,7 +696,7 @@
8186 if ((ieee->iw_mode == IW_MODE_MASTER ||
8187 ieee->iw_mode == IW_MODE_REPEAT) &&
8188 !from_assoc_ap) {
8189 - switch (hostap_handle_sta_rx(ieee, dev, skb, rx_stats,
8190 + switch (hostap_handle_sta_rx_rtl7(ieee, dev, skb, rx_stats,
8191 wds != NULL)) {
8192 case AP_RX_CONTINUE_NOT_AUTHORIZED:
8193 frame_authorized = 0;
8194 @@ -664,7 +730,7 @@
8195 /* skb: hdr + (possibly fragmented, possibly encrypted) payload */
8196  
8197 if (ieee->host_decrypt && (fc & IEEE80211_FCTL_WEP) &&
8198 - (keyidx = ieee80211_rx_frame_decrypt(ieee, skb, crypt)) < 0)
8199 + (keyidx = ieee80211_rx_frame_decrypt_rtl7(ieee, skb, crypt)) < 0)
8200 goto rx_dropped;
8201  
8202 hdr = (struct ieee80211_hdr *) skb->data;
8203 @@ -674,7 +740,7 @@
8204 // ieee->host_decrypt && (fc & IEEE80211_FCTL_WEP) &&
8205 if ((frag != 0 || (fc & IEEE80211_FCTL_MOREFRAGS))) {
8206 int flen;
8207 - struct sk_buff *frag_skb = ieee80211_frag_cache_get(ieee, hdr);
8208 + struct sk_buff *frag_skb = ieee80211_frag_cache_get_rtl7(ieee, hdr);
8209 IEEE80211_DEBUG_FRAG("Rx Fragment received (%u)\n", frag);
8210  
8211 if (!frag_skb) {
8212 @@ -694,7 +760,7 @@
8213 printk(KERN_WARNING "%s: host decrypted and "
8214 "reassembled frame did not fit skb\n",
8215 dev->name);
8216 - ieee80211_frag_cache_invalidate(ieee, hdr);
8217 + ieee80211_frag_cache_invalidate_rtl7(ieee, hdr);
8218 goto rx_dropped;
8219 }
8220  
8221 @@ -722,19 +788,19 @@
8222 * delivered, so remove skb from fragment cache */
8223 skb = frag_skb;
8224 hdr = (struct ieee80211_hdr *) skb->data;
8225 - ieee80211_frag_cache_invalidate(ieee, hdr);
8226 + ieee80211_frag_cache_invalidate_rtl7(ieee, hdr);
8227 }
8228  
8229 /* skb: hdr + (possible reassembled) full MSDU payload; possibly still
8230 * encrypted/authenticated */
8231 if (ieee->host_decrypt && (fc & IEEE80211_FCTL_WEP) &&
8232 - ieee80211_rx_frame_decrypt_msdu(ieee, skb, keyidx, crypt))
8233 + ieee80211_rx_frame_decrypt_msdu_rtl7(ieee, skb, keyidx, crypt))
8234 goto rx_dropped;
8235  
8236 hdr = (struct ieee80211_hdr *) skb->data;
8237 if (crypt && !(fc & IEEE80211_FCTL_WEP) && !ieee->open_wep) {
8238 if (/*ieee->ieee802_1x &&*/
8239 - ieee80211_is_eapol_frame(ieee, skb)) {
8240 + ieee80211_is_eapol_frame_rtl7(ieee, skb)) {
8241 #ifdef CONFIG_IEEE80211_DEBUG
8242 /* pass unencrypted EAPOL frames even if encryption is
8243 * configured */
8244 @@ -763,7 +829,7 @@
8245 #endif
8246  
8247 if (crypt && !(fc & IEEE80211_FCTL_WEP) && !ieee->open_wep &&
8248 - !ieee80211_is_eapol_frame(ieee, skb)) {
8249 + !ieee80211_is_eapol_frame_rtl7(ieee, skb)) {
8250 IEEE80211_DEBUG_DROP(
8251 "dropped unencrypted RX data "
8252 "frame from " MAC_FMT
8253 @@ -896,7 +962,7 @@
8254  
8255 #define MGMT_FRAME_FIXED_PART_LENGTH 0x24
8256  
8257 -static inline int ieee80211_is_ofdm_rate(u8 rate)
8258 +static inline int ieee80211_is_ofdm_rate_rtl7(u8 rate)
8259 {
8260 switch (rate & ~IEEE80211_BASIC_RATE_MASK) {
8261 case IEEE80211_OFDM_RATE_6MB:
8262 @@ -913,7 +979,7 @@
8263 }
8264  
8265  
8266 -static inline int ieee80211_network_init(
8267 +static inline int ieee80211_network_init_rtl7(
8268 struct ieee80211_device *ieee,
8269 struct ieee80211_probe_response *beacon,
8270 struct ieee80211_network *network,
8271 @@ -964,7 +1030,7 @@
8272  
8273 switch (info_element->id) {
8274 case MFIE_TYPE_SSID:
8275 - if (ieee80211_is_empty_essid(info_element->data,
8276 + if (ieee80211_is_empty_essid_rtl7(info_element->data,
8277 info_element->len)) {
8278 network->flags |= NETWORK_EMPTY_ESSID;
8279 break;
8280 @@ -991,7 +1057,7 @@
8281 #ifdef CONFIG_IEEE80211_DEBUG
8282 p += snprintf(p, sizeof(rates_str) - (p - rates_str), "%02X ", network->rates[i]);
8283 #endif
8284 - if (ieee80211_is_ofdm_rate(info_element->data[i])) {
8285 + if (ieee80211_is_ofdm_rate_rtl7(info_element->data[i])) {
8286 network->flags |= NETWORK_HAS_OFDM;
8287 if (info_element->data[i] &
8288 IEEE80211_BASIC_RATE_MASK)
8289 @@ -1014,7 +1080,7 @@
8290 #ifdef CONFIG_IEEE80211_DEBUG
8291 p += snprintf(p, sizeof(rates_str) - (p - rates_str), "%02X ", network->rates[i]);
8292 #endif
8293 - if (ieee80211_is_ofdm_rate(info_element->data[i])) {
8294 + if (ieee80211_is_ofdm_rate_rtl7(info_element->data[i])) {
8295 network->flags |= NETWORK_HAS_OFDM;
8296 if (info_element->data[i] &
8297 IEEE80211_BASIC_RATE_MASK)
8298 @@ -1043,47 +1109,47 @@
8299 break;
8300  
8301 case MFIE_TYPE_TIM:
8302 -
8303 - if(info_element->len < 4)
8304 +
8305 + if(info_element->len < 4)
8306 break;
8307 -
8308 +
8309 network->dtim_period = info_element->data[1];
8310 -
8311 +
8312 if(ieee->state != IEEE80211_LINKED)
8313 break;
8314 -
8315 - network->last_dtim_sta_time[0] = stats->mac_time[0];
8316 +
8317 + network->last_dtim_sta_time[0] = stats->mac_time[0];
8318 network->last_dtim_sta_time[1] = stats->mac_time[1];
8319 -
8320 +
8321 network->dtim_data = IEEE80211_DTIM_VALID;
8322 -
8323 - if(info_element->data[0] != 0)
8324 +
8325 + if(info_element->data[0] != 0)
8326 break;
8327 -
8328 +
8329 if(info_element->data[2] & 1)
8330 network->dtim_data |= IEEE80211_DTIM_MBCAST;
8331 -
8332 +
8333 offset = (info_element->data[2] >> 1)*2;
8334 -
8335 - //printk("offset1:%x aid:%x\n",offset, ieee->assoc_id);
8336 -
8337 - if(ieee->assoc_id < offset ||
8338 +
8339 + //printk("offset1:%x aid:%x\n",offset, ieee->assoc_id);
8340 +
8341 + if(ieee->assoc_id < offset ||
8342 ieee->assoc_id > 8*(offset + info_element->len -3))
8343 -
8344 +
8345 break;
8346 -
8347 -
8348 +
8349 +
8350 offset = offset + ieee->assoc_id / 8;// + ((aid % 8)? 0 : 1) ;
8351 -
8352 - // printk("offset:%x data:%x, ucast:%d\n", offset,
8353 +
8354 + // printk("offset:%x data:%x, ucast:%d\n", offset,
8355 // info_element->data[3+offset] ,
8356 // info_element->data[3+offset] & (1<<(ieee->assoc_id%8)));
8357 -
8358 +
8359 if(info_element->data[3+offset] & (1<<(ieee->assoc_id%8)))
8360 network->dtim_data |= IEEE80211_DTIM_UCAST;
8361 -
8362 +
8363 break;
8364 -
8365 +
8366 case MFIE_TYPE_IBSS_SET:
8367 IEEE80211_DEBUG_SCAN("MFIE_TYPE_IBSS_SET: ignored\n");
8368 break;
8369 @@ -1115,7 +1181,7 @@
8370 memcpy(network->rsn_ie, info_element,
8371 network->rsn_ie_len);
8372 break;
8373 -
8374 +
8375 default:
8376 IEEE80211_DEBUG_SCAN("unsupported IE %d\n",
8377 info_element->id);
8378 @@ -1147,7 +1213,7 @@
8379 return 1;
8380 }
8381  
8382 - if (ieee80211_is_empty_essid(network->ssid, network->ssid_len))
8383 + if (ieee80211_is_empty_essid_rtl7(network->ssid, network->ssid_len))
8384 network->flags |= NETWORK_EMPTY_ESSID;
8385  
8386 memcpy(&network->stats, stats, sizeof(network->stats));
8387 @@ -1155,24 +1221,24 @@
8388 return 0;
8389 }
8390  
8391 -static inline int is_same_network(struct ieee80211_network *src,
8392 +static inline int is_same_network_rtl7(struct ieee80211_network *src,
8393 struct ieee80211_network *dst)
8394 {
8395 /* A network is only a duplicate if the channel, BSSID, ESSID
8396 - * and the capability field (in particular IBSS and BSS) all match.
8397 + * and the capability field (in particular IBSS and BSS) all match.
8398 * We treat all <hidden> with the same BSSID and channel
8399 * as one network */
8400 return ((src->ssid_len == dst->ssid_len) &&
8401 (src->channel == dst->channel) &&
8402 !memcmp(src->bssid, dst->bssid, ETH_ALEN) &&
8403 !memcmp(src->ssid, dst->ssid, src->ssid_len) &&
8404 - ((src->capability & WLAN_CAPABILITY_IBSS) ==
8405 + ((src->capability & WLAN_CAPABILITY_IBSS) ==
8406 (dst->capability & WLAN_CAPABILITY_IBSS)) &&
8407 - ((src->capability & WLAN_CAPABILITY_BSS) ==
8408 + ((src->capability & WLAN_CAPABILITY_BSS) ==
8409 (dst->capability & WLAN_CAPABILITY_BSS)));
8410 }
8411  
8412 -static inline void update_network(struct ieee80211_network *dst,
8413 +static inline void update_network_rtl7(struct ieee80211_network *dst,
8414 struct ieee80211_network *src)
8415 {
8416 memcpy(&dst->stats, &src->stats, sizeof(struct ieee80211_rx_stats));
8417 @@ -1194,7 +1260,7 @@
8418 dst->dtim_data = src->dtim_data;
8419 dst->last_dtim_sta_time[0] = src->last_dtim_sta_time[0];
8420 dst->last_dtim_sta_time[1] = src->last_dtim_sta_time[1];
8421 -
8422 +
8423 memcpy(dst->wpa_ie, src->wpa_ie, src->wpa_ie_len);
8424 dst->wpa_ie_len = src->wpa_ie_len;
8425 memcpy(dst->rsn_ie, src->rsn_ie, src->rsn_ie_len);
8426 @@ -1204,7 +1270,7 @@
8427 /* dst->last_associate is not overwritten */
8428 }
8429  
8430 -static inline void ieee80211_process_probe_response(
8431 +static inline void ieee80211_process_probe_response_rtl7(
8432 struct ieee80211_device *ieee,
8433 struct ieee80211_probe_response *beacon,
8434 struct ieee80211_rx_stats *stats)
8435 @@ -1239,7 +1305,7 @@
8436 (beacon->capability & (1<<0x1)) ? '1' : '0',
8437 (beacon->capability & (1<<0x0)) ? '1' : '0');
8438  
8439 - if (ieee80211_network_init(ieee, beacon, &network, stats)) {
8440 + if (ieee80211_network_init_rtl7(ieee, beacon, &network, stats)) {
8441 IEEE80211_DEBUG_SCAN("Dropped '%s' (" MAC_FMT ") via %s.\n",
8442 escape_essid(info_element->data,
8443 info_element->len),
8444 @@ -1261,12 +1327,12 @@
8445 * already there. */
8446  
8447 spin_lock_irqsave(&ieee->lock, flags);
8448 -
8449 - if(is_same_network(&ieee->current_network, &network))
8450 - update_network(&ieee->current_network, &network);
8451 -
8452 +
8453 + if(is_same_network_rtl7(&ieee->current_network, &network))
8454 + update_network_rtl7(&ieee->current_network, &network);
8455 +
8456 list_for_each_entry(target, &ieee->network_list, list) {
8457 - if (is_same_network(target, &network))
8458 + if (is_same_network_rtl7(target, &network))
8459 break;
8460  
8461 if ((oldest == NULL) ||
8462 @@ -1306,7 +1372,7 @@
8463 memcpy(target, &network, sizeof(*target));
8464 list_add_tail(&target->list, &ieee->network_list);
8465 if(ieee->softmac_features & IEEE_SOFTMAC_ASSOCIATE)
8466 - ieee80211_softmac_new_net(ieee,&network);
8467 + ieee80211_softmac_new_net_rtl7(ieee,&network);
8468 } else {
8469 IEEE80211_DEBUG_SCAN("Updating '%s' (" MAC_FMT ") via %s.\n",
8470 escape_essid(target->ssid,
8471 @@ -1315,39 +1381,39 @@
8472 WLAN_FC_GET_STYPE(beacon->header.frame_ctl) ==
8473 IEEE80211_STYPE_PROBE_RESP ?
8474 "PROBE RESPONSE" : "BEACON");
8475 -
8476 +
8477 /* we have an entry and we are going to update it. But this entry may
8478 - * be already expired. In this case we do the same as we found a new
8479 + * be already expired. In this case we do the same as we found a new
8480 * net and call the new_net handler
8481 */
8482 renew = !time_after(target->last_scanned + ieee->scan_age, jiffies);
8483 - update_network(target, &network);
8484 + update_network_rtl7(target, &network);
8485 if(renew && (ieee->softmac_features & IEEE_SOFTMAC_ASSOCIATE))
8486 - ieee80211_softmac_new_net(ieee,&network);
8487 + ieee80211_softmac_new_net_rtl7(ieee,&network);
8488 }
8489  
8490 spin_unlock_irqrestore(&ieee->lock, flags);
8491 }
8492  
8493 -void ieee80211_rx_mgt(struct ieee80211_device *ieee,
8494 +void ieee80211_rx_mgt_rtl7(struct ieee80211_device *ieee,
8495 struct ieee80211_hdr *header,
8496 struct ieee80211_rx_stats *stats)
8497 {
8498 switch (WLAN_FC_GET_STYPE(header->frame_ctl)) {
8499 -
8500 +
8501 case IEEE80211_STYPE_BEACON:
8502 IEEE80211_DEBUG_MGMT("received BEACON (%d)\n",
8503 WLAN_FC_GET_STYPE(header->frame_ctl));
8504 IEEE80211_DEBUG_SCAN("Beacon\n");
8505 - ieee80211_process_probe_response(
8506 + ieee80211_process_probe_response_rtl7(
8507 ieee, (struct ieee80211_probe_response *)header, stats);
8508 break;
8509 -
8510 +
8511 case IEEE80211_STYPE_PROBE_RESP:
8512 IEEE80211_DEBUG_MGMT("received PROBE RESPONSE (%d)\n",
8513 WLAN_FC_GET_STYPE(header->frame_ctl));
8514 IEEE80211_DEBUG_SCAN("Probe response\n");
8515 - ieee80211_process_probe_response(
8516 + ieee80211_process_probe_response_rtl7(
8517 ieee, (struct ieee80211_probe_response *)header, stats);
8518 break;
8519  
8520 @@ -1355,5 +1421,5 @@
8521 }
8522  
8523  
8524 -EXPORT_SYMBOL(ieee80211_rx_mgt);
8525 -EXPORT_SYMBOL(ieee80211_rx);
8526 +EXPORT_SYMBOL(ieee80211_rx_mgt_rtl7);
8527 +EXPORT_SYMBOL(ieee80211_rx_rtl7);
8528 diff -Naur rtl8187_orig/ieee80211/ieee80211_softmac.c rtl8187_rawtx/ieee80211/ieee80211_softmac.c
8529 --- rtl8187_orig/ieee80211/ieee80211_softmac.c 2007-03-13 23:45:09.000000000 +0100
8530 +++ rtl8187_rawtx/ieee80211/ieee80211_softmac.c 2007-07-13 01:46:05.000000000 +0200
8531 @@ -1,14 +1,14 @@
8532 /* IEEE 802.11 SoftMAC layer
8533 * Copyright (c) 2005 Andrea Merello <andreamrl@tiscali.it>
8534 *
8535 - * Mostly extracted from the rtl8180-sa2400 driver for the
8536 + * Mostly extracted from the rtl8180-sa2400 driver for the
8537 * in-kernel generic ieee802.11 stack.
8538 *
8539 * Few lines might be stolen from other part of the ieee80211
8540 * stack. Copyright who own it's copyright
8541 *
8542 * WPA code stolen from the ipw2200 driver.
8543 - * Copyright who own it's copyright.
8544 + * Copyright who own it's copyright.
8545 *
8546 * released under the GPL
8547 */
8548 @@ -20,12 +20,12 @@
8549 #include <linux/delay.h>
8550 #include <linux/version.h>
8551  
8552 -short ieee80211_is_54g(struct ieee80211_network net)
8553 +short ieee80211_is_54g_rtl7(struct ieee80211_network net)
8554 {
8555 return ((net.rates_ex_len > 0) || (net.rates_len > 4));
8556 }
8557  
8558 -short ieee80211_is_shortslot(struct ieee80211_network net)
8559 +short ieee80211_is_shortslot_rtl7(struct ieee80211_network net)
8560 {
8561 return (net.capability & WLAN_CAPABILITY_SHORT_SLOT);
8562 }
8563 @@ -34,28 +34,28 @@
8564 * tag and the EXTENDED RATE MFIE tag if needed.
8565 * It encludes two bytes per tag for the tag itself and its len
8566 */
8567 -unsigned int ieee80211_MFIE_rate_len(struct ieee80211_device *ieee)
8568 +unsigned int ieee80211_MFIE_rate_len_rtl7(struct ieee80211_device *ieee)
8569 {
8570 unsigned int rate_len = 0;
8571 -
8572 +
8573 if (ieee->modulation & IEEE80211_CCK_MODULATION)
8574 rate_len = IEEE80211_CCK_RATE_LEN + 2;
8575 -
8576 +
8577 if (ieee->modulation & IEEE80211_OFDM_MODULATION)
8578 -
8579 +
8580 rate_len += IEEE80211_OFDM_RATE_LEN + 2;
8581 -
8582 +
8583 return rate_len;
8584 }
8585  
8586 -/* pleace the MFIE rate, tag to the memory (double) poined.
8587 +/* pleace the MFIE rate, tag to the memory (double) poined.
8588 * Then it updates the pointer so that
8589 * it points after the new MFIE tag added.
8590 - */
8591 -void ieee80211_MFIE_Brate(struct ieee80211_device *ieee, u8 **tag_p)
8592 + */
8593 +void ieee80211_MFIE_Brate_rtl7(struct ieee80211_device *ieee, u8 **tag_p)
8594 {
8595 - u8 *tag = *tag_p;
8596 -
8597 + u8 *tag = *tag_p;
8598 +
8599 if (ieee->modulation & IEEE80211_CCK_MODULATION){
8600 *tag++ = MFIE_TYPE_RATES;
8601 *tag++ = 4;
8602 @@ -64,17 +64,17 @@
8603 *tag++ = IEEE80211_BASIC_RATE_MASK | IEEE80211_CCK_RATE_5MB;
8604 *tag++ = IEEE80211_BASIC_RATE_MASK | IEEE80211_CCK_RATE_11MB;
8605 }
8606 -
8607 +
8608 /* We may add an option for custom rates that specific HW might support */
8609 *tag_p = tag;
8610 }
8611  
8612 -void ieee80211_MFIE_Grate(struct ieee80211_device *ieee, u8 **tag_p)
8613 -{
8614 - u8 *tag = *tag_p;
8615 -
8616 +void ieee80211_MFIE_Grate_rtl7(struct ieee80211_device *ieee, u8 **tag_p)
8617 +{
8618 + u8 *tag = *tag_p;
8619 +
8620 if (ieee->modulation & IEEE80211_OFDM_MODULATION){
8621 -
8622 +
8623 *tag++ = MFIE_TYPE_RATES_EX;
8624 *tag++ = 8;
8625 *tag++ = IEEE80211_BASIC_RATE_MASK | IEEE80211_OFDM_RATE_6MB;
8626 @@ -85,73 +85,73 @@
8627 *tag++ = IEEE80211_BASIC_RATE_MASK | IEEE80211_OFDM_RATE_36MB;
8628 *tag++ = IEEE80211_BASIC_RATE_MASK | IEEE80211_OFDM_RATE_48MB;
8629 *tag++ = IEEE80211_BASIC_RATE_MASK | IEEE80211_OFDM_RATE_54MB;
8630 -
8631 +
8632 }
8633 -
8634 +
8635 /* We may add an option for custom rates that specific HW might support */
8636 *tag_p = tag;
8637 }
8638  
8639 -void enqueue_mgmt(struct ieee80211_device *ieee, struct sk_buff *skb)
8640 +void enqueue_mgmt_rtl7(struct ieee80211_device *ieee, struct sk_buff *skb)
8641 {
8642 int nh;
8643 nh = (ieee->mgmt_queue_head +1) % MGMT_QUEUE_NUM;
8644 -
8645 +
8646 /*
8647 * if the queue is full but we have newer frames then
8648 * just overwrites the oldest.
8649 - *
8650 + *
8651 * if (nh == ieee->mgmt_queue_tail)
8652 * return -1;
8653 - */
8654 + */
8655 ieee->mgmt_queue_head = nh;
8656 ieee->mgmt_queue_ring[nh] = skb;
8657 -
8658 +
8659 //return 0;
8660 }
8661  
8662 -struct sk_buff *dequeue_mgmt(struct ieee80211_device *ieee)
8663 +struct sk_buff *dequeue_mgmt_rtl7(struct ieee80211_device *ieee)
8664 {
8665 struct sk_buff *ret;
8666 -
8667 +
8668 if(ieee->mgmt_queue_tail == ieee->mgmt_queue_head)
8669 return NULL;
8670 -
8671 +
8672 ret = ieee->mgmt_queue_ring[ieee->mgmt_queue_tail];
8673 -
8674 - ieee->mgmt_queue_tail =
8675 +
8676 + ieee->mgmt_queue_tail =
8677 (ieee->mgmt_queue_tail+1) % MGMT_QUEUE_NUM;
8678 -
8679 +
8680 return ret;
8681 }
8682  
8683 -void init_mgmt_queue(struct ieee80211_device *ieee)
8684 +void init_mgmt_queue_rtl7(struct ieee80211_device *ieee)
8685 {
8686 ieee->mgmt_queue_tail = ieee->mgmt_queue_head = 0;
8687 }
8688  
8689  
8690 -void ieee80211_sta_wakeup(struct ieee80211_device *ieee, short nl);
8691 +void ieee80211_sta_wakeup_rtl7(struct ieee80211_device *ieee, short nl);
8692  
8693 -inline void softmac_mgmt_xmit(struct sk_buff *skb, struct ieee80211_device *ieee)
8694 +inline void softmac_mgmt_xmit_rtl7(struct sk_buff *skb, struct ieee80211_device *ieee)
8695 {
8696 unsigned long flags;
8697 short single = ieee->softmac_features & IEEE_SOFTMAC_SINGLE_QUEUE;
8698 struct ieee80211_hdr_3addr *header=
8699 (struct ieee80211_hdr_3addr *) skb->data;
8700 -
8701 -
8702 +
8703 +
8704 spin_lock_irqsave(&ieee->lock, flags);
8705 -
8706 +
8707 /* called with 2nd param 0, no mgmt lock required */
8708 - ieee80211_sta_wakeup(ieee,0);
8709 -
8710 + ieee80211_sta_wakeup_rtl7(ieee,0);
8711 +
8712 if(single){
8713 -
8714 +
8715 if(ieee->queue_stop){
8716 -
8717 - enqueue_mgmt(ieee,skb);
8718 -
8719 +
8720 + enqueue_mgmt_rtl7(ieee,skb);
8721 +
8722 }else{
8723 header->seq_ctl = cpu_to_le16(ieee->seq_ctrl << 4);
8724  
8725 @@ -159,119 +159,119 @@
8726 ieee->seq_ctrl = 0;
8727 else
8728 ieee->seq_ctrl++;
8729 -
8730 +
8731 /* avoid watchdog triggers */
8732 ieee->dev->trans_start = jiffies;
8733 ieee->softmac_data_hard_start_xmit(skb,ieee->dev,ieee->basic_rate);
8734 }
8735 -
8736 +
8737 spin_unlock_irqrestore(&ieee->lock, flags);
8738 }else{
8739 spin_unlock_irqrestore(&ieee->lock, flags);
8740 spin_lock_irqsave(&ieee->mgmt_tx_lock, flags);
8741 -
8742 +
8743 header->seq_ctl = cpu_to_le16(ieee->seq_ctrl << 4);
8744 -
8745 +
8746 if (ieee->seq_ctrl == 0xFFF)
8747 ieee->seq_ctrl = 0;
8748 else
8749 ieee->seq_ctrl++;
8750 -
8751 +
8752 ieee->softmac_hard_start_xmit(skb,ieee->dev);
8753 -
8754 +
8755 spin_unlock_irqrestore(&ieee->mgmt_tx_lock, flags);
8756 }
8757 }
8758  
8759  
8760 -inline void softmac_ps_mgmt_xmit(struct sk_buff *skb, struct ieee80211_device *ieee)
8761 +inline void softmac_ps_mgmt_xmit_rtl7(struct sk_buff *skb, struct ieee80211_device *ieee)
8762 {
8763 -
8764 +
8765 short single = ieee->softmac_features & IEEE_SOFTMAC_SINGLE_QUEUE;
8766 struct ieee80211_hdr_3addr *header =
8767 (struct ieee80211_hdr_3addr *) skb->data;
8768 -
8769 -
8770 +
8771 +
8772 if(single){
8773 -
8774 +
8775 header->seq_ctl = cpu_to_le16(ieee->seq_ctrl << 4);
8776  
8777 if (ieee->seq_ctrl == 0xFFF)
8778 ieee->seq_ctrl = 0;
8779 else
8780 ieee->seq_ctrl++;
8781 -
8782 +
8783 /* avoid watchdog triggers */
8784 ieee->dev->trans_start = jiffies;
8785 ieee->softmac_data_hard_start_xmit(skb,ieee->dev,ieee->basic_rate);
8786 -
8787 +
8788 }else{
8789 -
8790 +
8791 header->seq_ctl = cpu_to_le16(ieee->seq_ctrl << 4);
8792 -
8793 +
8794 if (ieee->seq_ctrl == 0xFFF)
8795 ieee->seq_ctrl = 0;
8796 else
8797 ieee->seq_ctrl++;
8798  
8799 ieee->softmac_hard_start_xmit(skb,ieee->dev);
8800 -
8801 +
8802 }
8803 }
8804  
8805 -inline struct sk_buff *ieee80211_probe_req(struct ieee80211_device *ieee)
8806 +inline struct sk_buff *ieee80211_probe_req_rtl7(struct ieee80211_device *ieee)
8807 {
8808 unsigned int len,rate_len;
8809 u8 *tag;
8810 struct sk_buff *skb;
8811 struct ieee80211_probe_request *req;
8812 -
8813 +
8814 len = ieee->current_network.ssid_len;
8815 -
8816 - rate_len = ieee80211_MFIE_rate_len(ieee);
8817 -
8818 +
8819 + rate_len = ieee80211_MFIE_rate_len_rtl7(ieee);
8820 +
8821 skb = dev_alloc_skb(sizeof(struct ieee80211_probe_request) +
8822 2 + len + rate_len);
8823 -
8824 - if (!skb)
8825 +
8826 + if (!skb)
8827 return NULL;
8828 -
8829 +
8830 req = (struct ieee80211_probe_request *) skb_put(skb,sizeof(struct ieee80211_probe_request));
8831 req->header.frame_ctl = cpu_to_le16(IEEE80211_STYPE_PROBE_REQ);
8832 - req->header.duration_id = 0; //FIXME: is this OK ?
8833 -
8834 + req->header.duration_id = 0; //FIXME: is this OK ?
8835 +
8836 memset(req->header.addr1, 0xff, ETH_ALEN);
8837 memcpy(req->header.addr2, ieee->dev->dev_addr, ETH_ALEN);
8838 memset(req->header.addr3, 0xff, ETH_ALEN);
8839 -
8840 +
8841 tag = (u8 *) skb_put(skb,len+2+rate_len);
8842 -
8843 +
8844 *tag++ = MFIE_TYPE_SSID;
8845 *tag++ = len;
8846 memcpy(tag, ieee->current_network.ssid, len);
8847 tag += len;
8848 -
8849 - ieee80211_MFIE_Brate(ieee,&tag);
8850 - ieee80211_MFIE_Grate(ieee,&tag);
8851 +
8852 + ieee80211_MFIE_Brate_rtl7(ieee,&tag);
8853 + ieee80211_MFIE_Grate_rtl7(ieee,&tag);
8854 return skb;
8855 }
8856  
8857 -struct sk_buff *ieee80211_get_beacon_(struct ieee80211_device *ieee);
8858 -void ieee80211_send_beacon(struct ieee80211_device *ieee)
8859 +struct sk_buff *ieee80211_get_beacon__rtl7(struct ieee80211_device *ieee);
8860 +void ieee80211_send_beacon_rtl7(struct ieee80211_device *ieee)
8861 {
8862 struct sk_buff *skb;
8863 -
8864 - unsigned long flags;
8865 -
8866 - skb = ieee80211_get_beacon_(ieee);
8867 +
8868 + unsigned long flags;
8869 +
8870 + skb = ieee80211_get_beacon__rtl7(ieee);
8871 if (skb){
8872 - softmac_mgmt_xmit(skb, ieee);
8873 + softmac_mgmt_xmit_rtl7(skb, ieee);
8874 ieee->softmac_stats.tx_beacons++;
8875 }
8876  
8877 - ieee->beacon_timer.expires = jiffies +
8878 + ieee->beacon_timer.expires = jiffies +
8879 (MSECS( ieee->current_network.beacon_interval -5));
8880 -
8881 +
8882 spin_lock_irqsave(&ieee->beacon_lock,flags);
8883 if(ieee->beacon_txing)
8884 add_timer(&ieee->beacon_timer);
8885 @@ -279,57 +279,57 @@
8886 }
8887  
8888  
8889 -void ieee80211_send_beacon_cb(unsigned long _ieee)
8890 +void ieee80211_send_beacon_cb_rtl7(unsigned long _ieee)
8891 {
8892 struct ieee80211_device *ieee =
8893 (struct ieee80211_device *) _ieee;
8894 - ieee80211_send_beacon(ieee);
8895 + ieee80211_send_beacon_rtl7(ieee);
8896 }
8897  
8898  
8899 -void ieee80211_send_probe(struct ieee80211_device *ieee)
8900 +void ieee80211_send_probe_rtl7(struct ieee80211_device *ieee)
8901 {
8902 struct sk_buff *skb;
8903 -
8904 - skb = ieee80211_probe_req(ieee);
8905 +
8906 + skb = ieee80211_probe_req_rtl7(ieee);
8907 if (skb){
8908 - softmac_mgmt_xmit(skb, ieee);
8909 + softmac_mgmt_xmit_rtl7(skb, ieee);
8910 ieee->softmac_stats.tx_probe_rq++;
8911 }
8912 }
8913  
8914 -void ieee80211_send_probe_requests(struct ieee80211_device *ieee)
8915 +void ieee80211_send_probe_requests_rtl7(struct ieee80211_device *ieee)
8916 {
8917 if (ieee->active_scan && (ieee->softmac_features & IEEE_SOFTMAC_PROBERQ)){
8918 - ieee80211_send_probe(ieee);
8919 - ieee80211_send_probe(ieee);
8920 + ieee80211_send_probe_rtl7(ieee);
8921 + ieee80211_send_probe_rtl7(ieee);
8922 }
8923 }
8924  
8925 /* this performs syncro scan blocking the caller until all channels
8926 - * in the allowed channel map has been checked.
8927 + * in the allowed channel map has been checked.
8928 */
8929 -void ieee80211_softmac_scan_syncro(struct ieee80211_device *ieee)
8930 +void ieee80211_softmac_scan_syncro_rtl7(struct ieee80211_device *ieee)
8931 {
8932 short ch = 0;
8933 -
8934 +
8935 down(&ieee->scan_sem);
8936 -
8937 +
8938 while(1)
8939 {
8940 -
8941 +
8942 do{
8943 ch++;
8944 - if (ch > MAX_CHANNEL_NUMBER)
8945 + if (ch > MAX_CHANNEL_NUMBER)
8946 goto out; /* scan completed */
8947 -
8948 +
8949 }while(!ieee->channel_map[ch]);
8950 -
8951 +
8952 /* this fuction can be called in two situations
8953 * 1- We have switched to ad-hoc mode and we are
8954 * performing a complete syncro scan before conclude
8955 - * there are no interesting cell and to create a
8956 - * new one. In this case the link state is
8957 + * there are no interesting cell and to create a
8958 + * new one. In this case the link state is
8959 * IEEE80211_NOLINK until we found an interesting cell.
8960 * If so the ieee8021_new_net, called by the RX path
8961 * will set the state to IEEE80211_LINKED, so we stop
8962 @@ -342,24 +342,24 @@
8963 * not filter RX frames and the channel is changing.
8964 * So the only situation in witch are interested is to check
8965 * if the state become LINKED because of the #1 situation
8966 - */
8967 -
8968 + */
8969 +
8970 if (ieee->state == IEEE80211_LINKED)
8971 goto out;
8972 -
8973 +
8974 ieee->set_chan(ieee->dev, ch);
8975 -
8976 - ieee80211_send_probe_requests(ieee);
8977 -
8978 +
8979 + ieee80211_send_probe_requests_rtl7(ieee);
8980 +
8981 /* this prevent excessive time wait when we
8982 * need to wait for a syncro scan to end..
8983 - */
8984 + */
8985 if (ieee->sync_scan_hurryup)
8986 goto out;
8987  
8988  
8989 msleep_interruptible_rtl(IEEE80211_SOFTMAC_SCAN_TIME);
8990 -
8991 +
8992 }
8993 out:
8994 ieee->sync_scan_hurryup = 0;
8995 @@ -370,43 +370,49 @@
8996 void ieee80211_softmac_scan(struct ieee80211_device *ieee)
8997 {
8998 short watchdog = 0;
8999 -
9000 +
9001 do{
9002 - ieee->current_network.channel =
9003 + ieee->current_network.channel =
9004 (ieee->current_network.channel + 1) % MAX_CHANNEL_NUMBER;
9005 - if (watchdog++ > MAX_CHANNEL_NUMBER)
9006 + if (watchdog++ > MAX_CHANNEL_NUMBER)
9007 return; /* no good chans */
9008 -
9009 +
9010 }while(!ieee->channel_map[ieee->current_network.channel]);
9011 -
9012 +
9013  
9014 schedule_work(&ieee->softmac_scan_wq);
9015 }
9016 #endif
9017  
9018 -void ieee80211_softmac_scan_wq(struct ieee80211_device *ieee)
9019 -{
9020 - down(&ieee->scan_sem);
9021 -
9022 +# if (LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,20))
9023 +void ieee80211_softmac_scan_wq_rtl7(struct work_struct *work)
9024 +{
9025 + struct delayed_work *dwork = container_of(work, struct delayed_work, work);
9026 + struct ieee80211_device *ieee = container_of(dwork, struct ieee80211_device, softmac_scan_wq);
9027 +#else
9028 +void ieee80211_softmac_scan_wq_rtl7(struct ieee80211_device *ieee)
9029 +{
9030 +#endif
9031 short watchdog = 0;
9032 -
9033 + down(&ieee->scan_sem);
9034 +
9035 do{
9036 - ieee->current_network.channel =
9037 + ieee->current_network.channel =
9038 (ieee->current_network.channel + 1) % MAX_CHANNEL_NUMBER;
9039 - if (watchdog++ > MAX_CHANNEL_NUMBER)
9040 + if (watchdog++ > MAX_CHANNEL_NUMBER)
9041 goto out; /* no good chans */
9042 -
9043 +
9044 }while(!ieee->channel_map[ieee->current_network.channel]);
9045 -
9046 +
9047 if (ieee->scanning == 0 )
9048 goto out;
9049 -
9050 +
9051 ieee->set_chan(ieee->dev, ieee->current_network.channel);
9052 - ieee80211_send_probe_requests(ieee);
9053 + ieee80211_send_probe_requests_rtl7(ieee);
9054  
9055 -#if 0
9056 +#if 0
9057 ieee->.expires = jiffies + (IEEE80211_SOFTMAC_SCAN_TIME);
9058 - if (ieee->scanning == 1)
9059 + if (ieee->scanning == 1)
9060 add_timer(&ieee->scan_timer);
9061 #endif
9062 queue_delayed_work(ieee->wq, &ieee->softmac_scan_wq, IEEE80211_SOFTMAC_SCAN_TIME);
9063 @@ -419,7 +425,7 @@
9064 {
9065 unsigned long flags;
9066 struct ieee80211_device *ieee = (struct ieee80211_device *)_dev;
9067 -
9068 +
9069 spin_lock_irqsave(&ieee->lock, flags);
9070 ieee80211_softmac_scan(ieee);
9071 spin_unlock_irqrestore(&ieee->lock, flags);
9072 @@ -427,19 +433,19 @@
9073 #endif
9074  
9075  
9076 -void ieee80211_beacons_start(struct ieee80211_device *ieee)
9077 +void ieee80211_beacons_start_rtl7(struct ieee80211_device *ieee)
9078 {
9079 - unsigned long flags;
9080 + unsigned long flags;
9081  
9082 spin_lock_irqsave(&ieee->beacon_lock,flags);
9083  
9084 ieee->beacon_txing = 1;
9085 - ieee80211_send_beacon(ieee);
9086 -
9087 + ieee80211_send_beacon_rtl7(ieee);
9088 +
9089 spin_unlock_irqrestore(&ieee->beacon_lock,flags);
9090 }
9091  
9092 -void ieee80211_beacons_stop(struct ieee80211_device *ieee)
9093 +void ieee80211_beacons_stop_rtl7(struct ieee80211_device *ieee)
9094 {
9095 unsigned long flags;
9096  
9097 @@ -453,111 +459,111 @@
9098 }
9099  
9100  
9101 -void ieee80211_stop_send_beacons(struct ieee80211_device *ieee)
9102 +void ieee80211_stop_send_beacons_rtl7(struct ieee80211_device *ieee)
9103 {
9104 if(ieee->stop_send_beacons)
9105 ieee->stop_send_beacons(ieee->dev);
9106 if (ieee->softmac_features & IEEE_SOFTMAC_BEACONS)
9107 - ieee80211_beacons_stop(ieee);
9108 + ieee80211_beacons_stop_rtl7(ieee);
9109 }
9110  
9111  
9112 -void ieee80211_start_send_beacons(struct ieee80211_device *ieee)
9113 +void ieee80211_start_send_beacons_rtl7(struct ieee80211_device *ieee)
9114 {
9115 if(ieee->start_send_beacons)
9116 ieee->start_send_beacons(ieee->dev);
9117 if(ieee->softmac_features & IEEE_SOFTMAC_BEACONS)
9118 - ieee80211_beacons_start(ieee);
9119 + ieee80211_beacons_start_rtl7(ieee);
9120 }
9121  
9122  
9123 -void ieee80211_softmac_stop_scan(struct ieee80211_device *ieee)
9124 +void ieee80211_softmac_stop_scan_rtl7(struct ieee80211_device *ieee)
9125 {
9126 -// unsigned long flags;
9127 -
9128 +// unsigned long flags;
9129 +
9130 //ieee->sync_scan_hurryup = 1;
9131 -
9132 +
9133 down(&ieee->scan_sem);
9134 // spin_lock_irqsave(&ieee->lock, flags);
9135 -
9136 +
9137 if (ieee->scanning == 1){
9138 ieee->scanning = 0;
9139 //del_timer_sync(&ieee->scan_timer);
9140 cancel_delayed_work(&ieee->softmac_scan_wq);
9141 }
9142 -
9143 +
9144 // spin_unlock_irqrestore(&ieee->lock, flags);
9145 up(&ieee->scan_sem);
9146 }
9147  
9148 -void ieee80211_stop_scan(struct ieee80211_device *ieee)
9149 +void ieee80211_stop_scan_rtl7(struct ieee80211_device *ieee)
9150 {
9151 if (ieee->softmac_features & IEEE_SOFTMAC_SCAN)
9152 - ieee80211_softmac_stop_scan(ieee);
9153 + ieee80211_softmac_stop_scan_rtl7(ieee);
9154 else
9155 ieee->stop_scan(ieee->dev);
9156 }
9157  
9158 /* called with ieee->lock held */
9159 -void ieee80211_start_scan(struct ieee80211_device *ieee)
9160 +void ieee80211_start_scan_rtl7(struct ieee80211_device *ieee)
9161 {
9162 - if (ieee->softmac_features & IEEE_SOFTMAC_SCAN){
9163 + if (ieee->softmac_features & IEEE_SOFTMAC_SCAN){
9164 if (ieee->scanning == 0){
9165 ieee->scanning = 1;
9166 //ieee80211_softmac_scan(ieee);
9167 - queue_work(ieee->wq, &ieee->softmac_scan_wq);
9168 + queue_delayed_work(ieee->wq, &ieee->softmac_scan_wq, 0);
9169 }
9170 }else
9171 ieee->start_scan(ieee->dev);
9172 -
9173 +
9174 }
9175  
9176 /* called with wx_sem held */
9177 -void ieee80211_start_scan_syncro(struct ieee80211_device *ieee)
9178 +void ieee80211_start_scan_syncro_rtl7(struct ieee80211_device *ieee)
9179 {
9180 ieee->sync_scan_hurryup = 0;
9181 -
9182 +
9183 if (ieee->softmac_features & IEEE_SOFTMAC_SCAN)
9184 - ieee80211_softmac_scan_syncro(ieee);
9185 + ieee80211_softmac_scan_syncro_rtl7(ieee);
9186 else
9187 ieee->scan_syncro(ieee->dev);
9188 -
9189 +
9190 }
9191  
9192 -inline struct sk_buff *ieee80211_authentication_req(struct ieee80211_network *beacon,
9193 +inline struct sk_buff *ieee80211_authentication_req_rtl7(struct ieee80211_network *beacon,
9194 struct ieee80211_device *ieee, int challengelen)
9195 {
9196 - struct sk_buff *skb;
9197 + struct sk_buff *skb;
9198 struct ieee80211_authentication *auth;
9199 -
9200 - skb = dev_alloc_skb(sizeof(struct ieee80211_authentication) + challengelen);
9201 -
9202 +
9203 + skb = dev_alloc_skb(sizeof(struct ieee80211_authentication) + challengelen);
9204 +
9205 if (!skb) return NULL;
9206 -
9207 +
9208 auth = (struct ieee80211_authentication *)
9209 skb_put(skb, sizeof(struct ieee80211_authentication));
9210 -
9211 +
9212 auth->header.frame_ctl = IEEE80211_STYPE_AUTH;
9213 if (challengelen) auth->header.frame_ctl |= IEEE80211_FCTL_WEP;
9214 -
9215 +
9216 auth->header.duration_id = 0x013a; //FIXME
9217 -
9218 +
9219 memcpy(auth->header.addr1, beacon->bssid, ETH_ALEN);
9220 memcpy(auth->header.addr2, ieee->dev->dev_addr, ETH_ALEN);
9221 memcpy(auth->header.addr3, beacon->bssid, ETH_ALEN);
9222 -
9223 +
9224 auth->algorithm = ieee->open_wep ? WLAN_AUTH_OPEN : WLAN_AUTH_SHARED_KEY;
9225 -
9226 +
9227 auth->transaction = cpu_to_le16(ieee->associate_seq);
9228 ieee->associate_seq++;
9229 -
9230 +
9231 auth->status = cpu_to_le16(WLAN_STATUS_SUCCESS);
9232 -
9233 +
9234 return skb;
9235 -
9236 +
9237 }
9238  
9239 -static struct sk_buff* ieee80211_probe_resp(struct ieee80211_device *ieee, u8 *dest)
9240 +static struct sk_buff* ieee80211_probe_resp_rtl7(struct ieee80211_device *ieee, u8 *dest)
9241 {
9242 u8 *tag;
9243 int beacon_size;
9244 @@ -566,23 +572,23 @@
9245 int encrypt;
9246 int atim_len,erp_len;
9247 struct ieee80211_crypt_data* crypt;
9248 -
9249 +
9250 char *ssid = ieee->current_network.ssid;
9251 int ssid_len = ieee->current_network.ssid_len;
9252 int rate_len = ieee->current_network.rates_len+2;
9253 int rate_ex_len = ieee->current_network.rates_ex_len;
9254 if(rate_ex_len > 0) rate_ex_len+=2;
9255 -
9256 +
9257 if(ieee->current_network.capability & WLAN_CAPABILITY_IBSS)
9258 atim_len = 4;
9259 else
9260 atim_len = 0;
9261 -
9262 - if(ieee80211_is_54g(ieee->current_network))
9263 +
9264 + if(ieee80211_is_54g_rtl7(ieee->current_network))
9265 erp_len = 3;
9266 else
9267 erp_len = 0;
9268 -
9269 +
9270 beacon_size = sizeof(struct ieee80211_probe_response)+
9271 ssid_len
9272 +3 //channel
9273 @@ -590,72 +596,72 @@
9274 +rate_ex_len
9275 +atim_len
9276 +erp_len;
9277 -
9278 +
9279 skb = dev_alloc_skb(beacon_size);
9280 -
9281 - if (!skb)
9282 +
9283 + if (!skb)
9284 return NULL;
9285 -
9286 +
9287 beacon_buf = (struct ieee80211_probe_response*) skb_put(skb, beacon_size);
9288 -
9289 +
9290 memcpy (beacon_buf->header.addr1, dest,ETH_ALEN);
9291 memcpy (beacon_buf->header.addr2, ieee->dev->dev_addr, ETH_ALEN);
9292 memcpy (beacon_buf->header.addr3, ieee->current_network.bssid, ETH_ALEN);
9293  
9294 beacon_buf->header.duration_id = 0; //FIXME
9295 - beacon_buf->beacon_interval =
9296 + beacon_buf->beacon_interval =
9297 cpu_to_le16(ieee->current_network.beacon_interval);
9298 - beacon_buf->capability =
9299 + beacon_buf->capability =
9300 cpu_to_le16(ieee->current_network.capability & WLAN_CAPABILITY_IBSS);
9301 -
9302 +
9303 if(ieee->short_slot && (ieee->current_network.capability & WLAN_CAPABILITY_SHORT_SLOT))
9304 - cpu_to_le16((beacon_buf->capability |= WLAN_CAPABILITY_SHORT_SLOT));
9305 -
9306 + cpu_to_le16((beacon_buf->capability |= WLAN_CAPABILITY_SHORT_SLOT));
9307 +
9308 crypt = ieee->crypt[ieee->tx_keyidx];
9309  
9310 - encrypt = ieee->host_encrypt && crypt && crypt->ops &&
9311 + encrypt = ieee->host_encrypt && crypt && crypt->ops &&
9312 (0 == strcmp(crypt->ops->name, "WEP"));
9313  
9314 - if (encrypt)
9315 + if (encrypt)
9316 beacon_buf->capability |= cpu_to_le16(WLAN_CAPABILITY_PRIVACY);
9317 -
9318 -
9319 +
9320 +
9321 beacon_buf->header.frame_ctl = cpu_to_le16(IEEE80211_STYPE_PROBE_RESP);
9322 -
9323 - beacon_buf->info_element.id = MFIE_TYPE_SSID;
9324 +
9325 + beacon_buf->info_element.id = MFIE_TYPE_SSID;
9326 beacon_buf->info_element.len = ssid_len;
9327 -
9328 +
9329 tag = (u8*) beacon_buf->info_element.data;
9330 -
9331 +
9332 memcpy(tag, ssid, ssid_len);
9333 -
9334 +
9335 tag += ssid_len;
9336 -
9337 +
9338 *(tag++) = MFIE_TYPE_RATES;
9339 - *(tag++) = rate_len-2;
9340 + *(tag++) = rate_len-2;
9341 memcpy(tag,ieee->current_network.rates,rate_len-2);
9342 tag+=rate_len-2;
9343 -
9344 +
9345 *(tag++) = MFIE_TYPE_DS_SET;
9346 *(tag++) = 1;
9347 *(tag++) = ieee->current_network.channel;
9348 -
9349 +
9350 if(atim_len){
9351 *(tag++) = MFIE_TYPE_IBSS_SET;
9352 *(tag++) = 2;
9353 *((u16*)(tag)) = cpu_to_le16(ieee->current_network.atim_window);
9354 tag+=2;
9355 }
9356 -
9357 +
9358 if(erp_len){
9359 *(tag++) = MFIE_TYPE_ERP;
9360 *(tag++) = 1;
9361 - *(tag++) = 0;
9362 + *(tag++) = 0;
9363 }
9364 -
9365 +
9366 if(rate_ex_len){
9367 *(tag++) = MFIE_TYPE_RATES_EX;
9368 - *(tag++) = rate_ex_len-2;
9369 + *(tag++) = rate_ex_len-2;
9370 memcpy(tag,ieee->current_network.rates_ex,rate_ex_len-2);
9371 tag+=rate_ex_len-2;
9372 }
9373 @@ -664,208 +670,211 @@
9374 }
9375  
9376  
9377 -struct sk_buff* ieee80211_assoc_resp(struct ieee80211_device *ieee, u8 *dest)
9378 +struct sk_buff* ieee80211_assoc_resp_rtl7(struct ieee80211_device *ieee, u8 *dest)
9379 {
9380 struct sk_buff *skb;
9381 u8* tag;
9382 -
9383 +
9384 struct ieee80211_crypt_data* crypt;
9385 struct ieee80211_assoc_response_frame *assoc;
9386 short encrypt;
9387 -
9388 - unsigned int rate_len = ieee80211_MFIE_rate_len(ieee);
9389 +
9390 + unsigned int rate_len = ieee80211_MFIE_rate_len_rtl7(ieee);
9391 int len = sizeof(struct ieee80211_assoc_response_frame) + rate_len;
9392 -
9393 - skb = dev_alloc_skb(len);
9394 -
9395 - if (!skb)
9396 +
9397 + skb = dev_alloc_skb(len);
9398 +
9399 + if (!skb)
9400 return NULL;
9401 -
9402 +
9403 assoc = (struct ieee80211_assoc_response_frame *)
9404 skb_put(skb,sizeof(struct ieee80211_assoc_response_frame));
9405 -
9406 +
9407 assoc->header.frame_ctl = cpu_to_le16(IEEE80211_STYPE_ASSOC_RESP);
9408 memcpy(assoc->header.addr1, dest,ETH_ALEN);
9409 memcpy(assoc->header.addr3, ieee->dev->dev_addr, ETH_ALEN);
9410 memcpy(assoc->header.addr2, ieee->dev->dev_addr, ETH_ALEN);
9411 - assoc->capability = cpu_to_le16(ieee->iw_mode == IW_MODE_MASTER ?
9412 + assoc->capability = cpu_to_le16(ieee->iw_mode == IW_MODE_MASTER ?
9413 WLAN_CAPABILITY_BSS : WLAN_CAPABILITY_IBSS);
9414 -
9415 -
9416 +
9417 +
9418 if(ieee->short_slot)
9419 assoc->capability |= cpu_to_le16(WLAN_CAPABILITY_SHORT_SLOT);
9420 -
9421 +
9422 if (ieee->host_encrypt)
9423 crypt = ieee->crypt[ieee->tx_keyidx];
9424 else crypt = NULL;
9425 -
9426 +
9427 encrypt = ( crypt && crypt->ops);
9428 -
9429 +
9430 if (encrypt)
9431 assoc->capability |= cpu_to_le16(WLAN_CAPABILITY_PRIVACY);
9432 -
9433 +
9434 assoc->status = 0;
9435 assoc->aid = cpu_to_le16(ieee->assoc_id);
9436 if (ieee->assoc_id == 0x2007) ieee->assoc_id=0;
9437 else ieee->assoc_id++;
9438 -
9439 +
9440 tag = (u8*) skb_put(skb, rate_len);
9441 -
9442 - ieee80211_MFIE_Brate(ieee, &tag);
9443 - ieee80211_MFIE_Grate(ieee, &tag);
9444 -
9445 +
9446 + ieee80211_MFIE_Brate_rtl7(ieee, &tag);
9447 + ieee80211_MFIE_Grate_rtl7(ieee, &tag);
9448 +
9449 return skb;
9450 }
9451  
9452 -struct sk_buff* ieee80211_auth_resp(struct ieee80211_device *ieee,int status, u8 *dest)
9453 +struct sk_buff* ieee80211_auth_resp_rtl7(struct ieee80211_device *ieee,int status, u8 *dest)
9454 {
9455 struct sk_buff *skb;
9456 struct ieee80211_authentication *auth;
9457 -
9458 - skb = dev_alloc_skb(sizeof(struct ieee80211_authentication)+1);
9459 -
9460 - if (!skb)
9461 +
9462 + skb = dev_alloc_skb(sizeof(struct ieee80211_authentication)+1);
9463 +
9464 + if (!skb)
9465 return NULL;
9466 -
9467 +
9468 skb->len = sizeof(struct ieee80211_authentication);
9469 -
9470 +
9471 auth = (struct ieee80211_authentication *)skb->data;
9472 -
9473 +
9474 auth->status = cpu_to_le16(status);
9475 auth->transaction = cpu_to_le16(2);
9476 auth->algorithm = cpu_to_le16(WLAN_AUTH_OPEN);
9477 -
9478 +
9479 memcpy(auth->header.addr3, ieee->dev->dev_addr, ETH_ALEN);
9480 memcpy(auth->header.addr2, ieee->dev->dev_addr, ETH_ALEN);
9481 memcpy(auth->header.addr1, dest, ETH_ALEN);
9482 - auth->header.frame_ctl = cpu_to_le16(IEEE80211_STYPE_AUTH);
9483 + auth->header.frame_ctl = cpu_to_le16(IEEE80211_STYPE_AUTH);
9484 return skb;
9485 -
9486 -
9487 +
9488 +
9489 }
9490  
9491 -struct sk_buff* ieee80211_null_func(struct ieee80211_device *ieee,short pwr)
9492 +struct sk_buff* ieee80211_null_func_rtl7(struct ieee80211_device *ieee,short pwr)
9493 {
9494 struct sk_buff *skb;
9495 struct ieee80211_hdr_3addr* hdr;
9496 -
9497 - skb = dev_alloc_skb(sizeof(struct ieee80211_hdr_3addr));
9498 -
9499 - if (!skb)
9500 +
9501 + skb = dev_alloc_skb(sizeof(struct ieee80211_hdr_3addr));
9502 +
9503 + if (!skb)
9504 return NULL;
9505 -
9506 +
9507 hdr = (struct ieee80211_hdr_3addr*)skb_put(skb,sizeof(struct ieee80211_hdr_3addr));
9508 -
9509 +
9510 memcpy(hdr->addr1, ieee->current_network.bssid, ETH_ALEN);
9511 memcpy(hdr->addr2, ieee->dev->dev_addr, ETH_ALEN);
9512 memcpy(hdr->addr3, ieee->current_network.bssid, ETH_ALEN);
9513 -
9514 - hdr->frame_ctl = cpu_to_le16(IEEE80211_FTYPE_DATA |
9515 - IEEE80211_STYPE_NULLFUNC | IEEE80211_FCTL_TODS |
9516 - (pwr ? IEEE80211_FCTL_PM:0));
9517 -
9518 +
9519 + hdr->frame_ctl = cpu_to_le16(IEEE80211_FTYPE_DATA |
9520 + IEEE80211_STYPE_NULLFUNC | IEEE80211_FCTL_TODS |
9521 + (pwr ? IEEE80211_FCTL_PM:0));
9522 +
9523 return skb;
9524 -
9525 -
9526 +
9527 +
9528 }
9529  
9530  
9531 -void ieee80211_resp_to_assoc_rq(struct ieee80211_device *ieee, u8* dest)
9532 +void ieee80211_resp_to_assoc_rq_rtl7(struct ieee80211_device *ieee, u8* dest)
9533 {
9534 - struct sk_buff *buf = ieee80211_assoc_resp(ieee, dest);
9535 -
9536 + struct sk_buff *buf = ieee80211_assoc_resp_rtl7(ieee, dest);
9537 +
9538 if (buf)
9539 - softmac_mgmt_xmit(buf, ieee);
9540 + softmac_mgmt_xmit_rtl7(buf, ieee);
9541 }
9542  
9543  
9544 -void ieee80211_resp_to_auth(struct ieee80211_device *ieee, int s, u8* dest)
9545 +void ieee80211_resp_to_auth_rtl7(struct ieee80211_device *ieee, int s, u8* dest)
9546 {
9547 - struct sk_buff *buf = ieee80211_auth_resp(ieee, s, dest);
9548 -
9549 + struct sk_buff *buf = ieee80211_auth_resp_rtl7(ieee, s, dest);
9550 +
9551 if (buf)
9552 - softmac_mgmt_xmit(buf, ieee);
9553 + softmac_mgmt_xmit_rtl7(buf, ieee);
9554 }
9555  
9556  
9557 -void ieee80211_resp_to_probe(struct ieee80211_device *ieee, u8 *dest)
9558 +void ieee80211_resp_to_probe_rtl7(struct ieee80211_device *ieee, u8 *dest)
9559 {
9560 -
9561 - struct sk_buff *buf = ieee80211_probe_resp(ieee, dest);
9562 -
9563 - if (buf)
9564 - softmac_mgmt_xmit(buf, ieee);
9565 +
9566 + struct sk_buff *buf = ieee80211_probe_resp_rtl7(ieee, dest);
9567 +
9568 + if (buf)
9569 + softmac_mgmt_xmit_rtl7(buf, ieee);
9570 }
9571  
9572  
9573 -inline struct sk_buff *ieee80211_association_req(struct ieee80211_network *beacon,struct ieee80211_device *ieee)
9574 +inline struct sk_buff *ieee80211_association_req_rtl7(struct ieee80211_network *beacon,struct ieee80211_device *ieee)
9575 {
9576 struct sk_buff *skb;
9577 -
9578 +
9579 struct ieee80211_assoc_request_frame *hdr;
9580 u8 *tag;
9581 -
9582 +
9583 unsigned int wpa_len = beacon->wpa_ie_len;
9584 -
9585 - unsigned int rate_len = ieee80211_MFIE_rate_len(ieee);
9586 -
9587 -
9588 -
9589 +
9590 + unsigned int rate_len = ieee80211_MFIE_rate_len_rtl7(ieee);
9591 +
9592 +
9593 +
9594 int len=sizeof(struct ieee80211_assoc_request_frame)+
9595 + beacon->ssid_len//essid tagged val
9596 + rate_len//rates tagged val
9597 + wpa_len;
9598 -
9599 +
9600 skb = dev_alloc_skb(len);
9601 -
9602 - if (!skb)
9603 +
9604 + if (!skb)
9605 return NULL;
9606 -
9607 +
9608 hdr = (struct ieee80211_assoc_request_frame *)
9609 skb_put(skb, sizeof(struct ieee80211_assoc_request_frame));
9610 -
9611 -
9612 +
9613 +
9614 hdr->header.frame_ctl = IEEE80211_STYPE_ASSOC_REQ;
9615 hdr->header.duration_id= 37; //FIXME
9616 memcpy(hdr->header.addr1, beacon->bssid, ETH_ALEN);
9617 memcpy(hdr->header.addr2, ieee->dev->dev_addr, ETH_ALEN);
9618 memcpy(hdr->header.addr3, beacon->bssid, ETH_ALEN);
9619 -
9620 +
9621 hdr->capability = cpu_to_le16(WLAN_CAPABILITY_BSS);
9622 - if (beacon->capability & WLAN_CAPABILITY_PRIVACY )
9623 + if (beacon->capability & WLAN_CAPABILITY_PRIVACY )
9624 hdr->capability |= cpu_to_le16(WLAN_CAPABILITY_PRIVACY);
9625 -
9626 +
9627 if(ieee->short_slot)
9628 hdr->capability |= cpu_to_le16(WLAN_CAPABILITY_SHORT_SLOT);
9629 -
9630 +
9631 + if(beacon->capability & WLAN_CAPABILITY_SHORT_PREAMBLE)
9632 + hdr->capability |= cpu_to_le16(WLAN_CAPABILITY_SHORT_PREAMBLE);
9633 +
9634 hdr->listen_interval = 0xa; //FIXME
9635 -
9636 +
9637 hdr->info_element.id = MFIE_TYPE_SSID;
9638  
9639 hdr->info_element.len = beacon->ssid_len;
9640 tag = skb_put(skb, beacon->ssid_len);
9641 memcpy(tag, beacon->ssid, beacon->ssid_len);
9642 -
9643 - tag = skb_put(skb, rate_len);
9644 -
9645 - ieee80211_MFIE_Brate(ieee, &tag);
9646 - ieee80211_MFIE_Grate(ieee, &tag);
9647 -
9648 +
9649 + tag = skb_put(skb, rate_len);
9650 +
9651 + ieee80211_MFIE_Brate_rtl7(ieee, &tag);
9652 + ieee80211_MFIE_Grate_rtl7(ieee, &tag);
9653 +
9654 tag = skb_put(skb,wpa_len);
9655 -
9656 +
9657 memcpy(tag,beacon->wpa_ie,wpa_len);
9658 -
9659 +
9660 return skb;
9661 }
9662  
9663 -void ieee80211_associate_abort(struct ieee80211_device *ieee)
9664 +void ieee80211_associate_abort_rtl7(struct ieee80211_device *ieee)
9665 {
9666 -
9667 +
9668 unsigned long flags;
9669 spin_lock_irqsave(&ieee->lock, flags);
9670 -
9671 +
9672 ieee->associate_seq++;
9673 -
9674 +
9675 /* don't scan, and avoid to have the RX path possibily
9676 * try again to associate. Even do not react to AUTH or
9677 * ASSOC response. Just wait for the retry wq to be scheduled.
9678 @@ -873,166 +882,181 @@
9679 * with, so we retry or just get back to NO_LINK and scanning
9680 */
9681 if (ieee->state == IEEE80211_ASSOCIATING_AUTHENTICATING){
9682 - IEEE80211_DEBUG_MGMT("Authentication failed\n");
9683 + IEEE80211_DEBUG_MGMT("Authentication failed\n");
9684 ieee->softmac_stats.no_auth_rs++;
9685 }else{
9686 - IEEE80211_DEBUG_MGMT("Association failed\n");
9687 + IEEE80211_DEBUG_MGMT("Association failed\n");
9688 ieee->softmac_stats.no_ass_rs++;
9689 }
9690 -
9691 +
9692 ieee->state = IEEE80211_ASSOCIATING_RETRY;
9693 -
9694 +
9695 queue_delayed_work(ieee->wq, &ieee->associate_retry_wq, IEEE80211_SOFTMAC_ASSOC_RETRY_TIME);
9696 -
9697 +
9698 spin_unlock_irqrestore(&ieee->lock, flags);
9699 }
9700  
9701 -void ieee80211_associate_abort_cb(unsigned long dev)
9702 +void ieee80211_associate_abort_cb_rtl7(unsigned long dev)
9703 {
9704 - ieee80211_associate_abort((struct ieee80211_device *) dev);
9705 + ieee80211_associate_abort_rtl7((struct ieee80211_device *) dev);
9706 }
9707  
9708  
9709 -void ieee80211_associate_step1(struct ieee80211_device *ieee)
9710 +void ieee80211_associate_step1_rtl7(struct ieee80211_device *ieee)
9711 {
9712 struct ieee80211_network *beacon = &ieee->current_network;
9713 struct sk_buff *skb;
9714 -
9715 +
9716 IEEE80211_DEBUG_MGMT("Stopping scan\n");
9717 -
9718 +
9719 ieee->softmac_stats.tx_auth_rq++;
9720 - skb=ieee80211_authentication_req(beacon, ieee, 0);
9721 -
9722 - if (!skb)
9723 - ieee80211_associate_abort(ieee);
9724 - else{
9725 + skb=ieee80211_authentication_req_rtl7(beacon, ieee, 0);
9726 +
9727 + if (!skb)
9728 + ieee80211_associate_abort_rtl7(ieee);
9729 + else{
9730 ieee->state = IEEE80211_ASSOCIATING_AUTHENTICATING ;
9731 IEEE80211_DEBUG_MGMT("Sending authentication request\n");
9732 - softmac_mgmt_xmit(skb, ieee);
9733 + softmac_mgmt_xmit_rtl7(skb, ieee);
9734 ieee->associate_timer.expires = jiffies + (HZ / 2);
9735 add_timer(&ieee->associate_timer);
9736 - }
9737 + }
9738 }
9739  
9740 -void ieee80211_auth_challenge(struct ieee80211_device *ieee, u8 *challenge, int chlen)
9741 +void ieee80211_auth_challenge_rtl7(struct ieee80211_device *ieee, u8 *challenge, int chlen)
9742 {
9743 - u8 *c;
9744 + u8 *c;
9745 struct sk_buff *skb;
9746 struct ieee80211_network *beacon = &ieee->current_network;
9747 // int hlen = sizeof(struct ieee80211_authentication);
9748 -
9749 +
9750 ieee->associate_seq++;
9751 ieee->softmac_stats.tx_auth_rq++;
9752 -
9753 - skb = ieee80211_authentication_req(beacon, ieee, chlen+2);
9754 - if (!skb)
9755 - ieee80211_associate_abort(ieee);
9756 +
9757 + skb = ieee80211_authentication_req_rtl7(beacon, ieee, chlen+2);
9758 + if (!skb)
9759 + ieee80211_associate_abort_rtl7(ieee);
9760 else{
9761 c = skb_put(skb, chlen+2);
9762 *(c++) = MFIE_TYPE_CHALLENGE;
9763 *(c++) = chlen;
9764 memcpy(c, challenge, chlen);
9765 -
9766 +
9767 IEEE80211_DEBUG_MGMT("Sending authentication challenge response\n");
9768 -
9769 - ieee80211_encrypt_fragment(ieee, skb, sizeof(struct ieee80211_hdr_3addr ));
9770 -
9771 - softmac_mgmt_xmit(skb, ieee);
9772 +
9773 + ieee80211_encrypt_fragment_rtl7(ieee, skb, sizeof(struct ieee80211_hdr_3addr ));
9774 +
9775 + softmac_mgmt_xmit_rtl7(skb, ieee);
9776 ieee->associate_timer.expires = jiffies + (HZ / 2);
9777 add_timer(&ieee->associate_timer);
9778 - }
9779 + }
9780 kfree(challenge);
9781 }
9782  
9783 -void ieee80211_associate_step2(struct ieee80211_device *ieee)
9784 +void ieee80211_associate_step2_rtl7(struct ieee80211_device *ieee)
9785 {
9786 struct sk_buff* skb;
9787 struct ieee80211_network *beacon = &ieee->current_network;
9788 -
9789 +
9790 del_timer_sync(&ieee->associate_timer);
9791 -
9792 +
9793 IEEE80211_DEBUG_MGMT("Sending association request\n");
9794 -
9795 +
9796 ieee->softmac_stats.tx_ass_rq++;
9797 - skb=ieee80211_association_req(beacon, ieee);
9798 - if (!skb)
9799 - ieee80211_associate_abort(ieee);
9800 + skb=ieee80211_association_req_rtl7(beacon, ieee);
9801 + if (!skb)
9802 + ieee80211_associate_abort_rtl7(ieee);
9803 else{
9804 - softmac_mgmt_xmit(skb, ieee);
9805 + softmac_mgmt_xmit_rtl7(skb, ieee);
9806 ieee->associate_timer.expires = jiffies + (HZ / 2);
9807 add_timer(&ieee->associate_timer);
9808 - }
9809 + }
9810 }
9811  
9812 -void ieee80211_associate_complete_wq(struct ieee80211_device *ieee)
9813 +# if (LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,20))
9814 +void ieee80211_associate_complete_wq_rtl7(struct work_struct *work)
9815 +{
9816 + struct ieee80211_device *ieee = container_of(work, struct ieee80211_device, associate_complete_wq);
9817 +#else
9818 +void ieee80211_associate_complete_wq_rtl7(struct ieee80211_device *ieee)
9819 {
9820 +#endif
9821 printk(KERN_INFO "Associated successfully\n");
9822 - if(ieee80211_is_54g(ieee->current_network) &&
9823 +#if 0
9824 + if(ieee80211_is_54g_rtl7(ieee->current_network) &&
9825 (ieee->modulation & IEEE80211_OFDM_MODULATION)){
9826 -
9827 +
9828 ieee->rate = 540;
9829 printk(KERN_INFO"Using G rates\n");
9830 }else{
9831 ieee->rate = 110;
9832 printk(KERN_INFO"Using B rates\n");
9833 }
9834 +#else
9835 + printk(KERN_INFO"Using %d MBit\n", (ieee->rate/10) );
9836 +#endif
9837 ieee->link_change(ieee->dev);
9838 - notify_wx_assoc_event(ieee);
9839 + notify_wx_assoc_event_rtl7(ieee);
9840 if (ieee->data_hard_resume)
9841 ieee->data_hard_resume(ieee->dev);
9842 netif_carrier_on(ieee->dev);
9843 }
9844  
9845 -void ieee80211_associate_complete(struct ieee80211_device *ieee)
9846 +void ieee80211_associate_complete_rtl7(struct ieee80211_device *ieee)
9847 {
9848  
9849 del_timer_sync(&ieee->associate_timer);
9850 -
9851 +
9852 ieee->seq_ctrl = 0;
9853 ieee->state = IEEE80211_LINKED;
9854 IEEE80211_DEBUG_MGMT("Successfully associated\n");
9855 -
9856 +
9857 queue_work(ieee->wq, &ieee->associate_complete_wq);
9858 }
9859  
9860 -void ieee80211_associate_procedure_wq(struct ieee80211_device *ieee)
9861 +# if (LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,20))
9862 +void ieee80211_associate_procedure_wq_rtl7(struct work_struct *work)
9863 {
9864 + struct ieee80211_device *ieee = container_of(work, struct ieee80211_device, associate_procedure_wq);
9865 +#else
9866 +void ieee80211_associate_procedure_wq_rtl7(struct ieee80211_device *ieee)
9867 +{
9868 +#endif
9869 ieee->sync_scan_hurryup = 1;
9870 down(&ieee->wx_sem);
9871 -
9872 if (ieee->data_hard_stop)
9873 ieee->data_hard_stop(ieee->dev);
9874 -
9875 - ieee80211_stop_scan(ieee);
9876 +
9877 + ieee80211_stop_scan_rtl7(ieee);
9878 ieee->set_chan(ieee->dev, ieee->current_network.channel);
9879 -
9880 +
9881 ieee->associate_seq = 1;
9882 - ieee80211_associate_step1(ieee);
9883 -
9884 + ieee80211_associate_step1_rtl7(ieee);
9885 +
9886 up(&ieee->wx_sem);
9887 }
9888  
9889 -inline void ieee80211_softmac_new_net(struct ieee80211_device *ieee, struct ieee80211_network *net)
9890 +inline void ieee80211_softmac_new_net_rtl7(struct ieee80211_device *ieee, struct ieee80211_network *net)
9891 {
9892 -
9893 +
9894 u8 tmp_ssid[IW_ESSID_MAX_SIZE+1];
9895 int tmp_ssid_len = 0;
9896 -
9897 +
9898 short apset,ssidset,ssidbroad,apmatch,ssidmatch;
9899 -
9900 - /* we are interested in new new only if we are not associated
9901 +
9902 + /* we are interested in new new only if we are not associated
9903 * and we are not associating / authenticating
9904 */
9905 if (ieee->state != IEEE80211_NOLINK)
9906 - return;
9907 -
9908 + return;
9909 +
9910 if ((ieee->iw_mode == IW_MODE_INFRA) && !(net->capability & WLAN_CAPABILITY_BSS))
9911 return;
9912 -
9913 +
9914 if ((ieee->iw_mode == IW_MODE_ADHOC) && !(net->capability & WLAN_CAPABILITY_IBSS))
9915 return;
9916  
9917 -
9918 +
9919 if (ieee->iw_mode == IW_MODE_INFRA || ieee->iw_mode == IW_MODE_ADHOC){
9920 /* if the user specified the AP MAC, we need also the essid
9921 * This could be obtained by beacons or, if the network does not
9922 @@ -1043,23 +1067,23 @@
9923 ssidbroad = !(net->ssid_len == 0 || net->ssid[0]== '\0');
9924 apmatch = (memcmp(ieee->current_network.bssid, net->bssid, ETH_ALEN)==0);
9925 ssidmatch = (0==strncmp(ieee->current_network.ssid, net->ssid, net->ssid_len));
9926 -
9927 -
9928 -
9929 +
9930 +
9931 +
9932 if ( /* if the user set the AP check if match.
9933 * if the network does not broadcast essid we check the user supplyed ANY essid
9934 * if the network does broadcast and the user does not set essid it is OK
9935 * if the network does broadcast and the user did set essid chech if essid match
9936 */
9937 - ( apset && apmatch &&
9938 - ((ssidset && ssidbroad && ssidmatch) || (ssidbroad && !ssidset) || (!ssidbroad && ssidset)) ) ||
9939 + ( apset && apmatch &&
9940 + ((ssidset && ssidbroad && ssidmatch) || (ssidbroad && !ssidset) || (!ssidbroad && ssidset)) ) ||
9941 /* if the ap is not set, check that the user set the bssid
9942 * and the network does bradcast and that those two bssid matches
9943 - */
9944 - (!apset && ssidset && ssidbroad && ssidmatch)
9945 + */
9946 + (!apset && ssidset && ssidbroad && ssidmatch)
9947 ){
9948 -
9949 -
9950 +
9951 +
9952 /* if the essid is hidden replace it with the
9953 * essid provided by the user.
9954 */
9955 @@ -1068,18 +1092,19 @@
9956 tmp_ssid_len = ieee->current_network.ssid_len;
9957 }
9958 memcpy(&ieee->current_network, net, sizeof(struct ieee80211_network));
9959 -
9960 +
9961 if (!ssidbroad){
9962 strncpy(ieee->current_network.ssid, tmp_ssid, IW_ESSID_MAX_SIZE);
9963 ieee->current_network.ssid_len = tmp_ssid_len;
9964 }
9965 - printk(KERN_INFO"Linking with %s\n",ieee->current_network.ssid);
9966 -
9967 + printk(KERN_INFO"Linking with \"%s\" rate: %d MBit\n",ieee->current_network.ssid, (ieee->rate/10));
9968 +
9969 if (ieee->iw_mode == IW_MODE_INFRA){
9970 ieee->state = IEEE80211_ASSOCIATING;
9971 queue_work(ieee->wq, &ieee->associate_procedure_wq);
9972 }else{
9973 - if(ieee80211_is_54g(ieee->current_network) &&
9974 +#if 0
9975 + if(ieee80211_is_54g_rtl7(ieee->current_network) &&
9976 (ieee->modulation & IEEE80211_OFDM_MODULATION)){
9977 ieee->rate = 540;
9978 printk(KERN_INFO"Using G rates\n");
9979 @@ -1087,44 +1112,45 @@
9980 ieee->rate = 110;
9981 printk(KERN_INFO"Using B rates\n");
9982 }
9983 +#else
9984 + printk(KERN_INFO"Using %d MBit\n", (ieee->rate/10) );
9985 +#endif
9986 ieee->state = IEEE80211_LINKED;
9987 }
9988 -
9989 +
9990 }
9991 }
9992 -
9993 }
9994  
9995 -void ieee80211_softmac_check_all_nets(struct ieee80211_device *ieee)
9996 +void ieee80211_softmac_check_all_nets_rtl7(struct ieee80211_device *ieee)
9997 {
9998 -
9999 +
10000 unsigned long flags;
10001 struct ieee80211_network *target;
10002 -
10003 +
10004 spin_lock_irqsave(&ieee->lock, flags);
10005 -
10006 list_for_each_entry(target, &ieee->network_list, list) {
10007 -
10008 +
10009 /* if the state become different that NOLINK means
10010 * we had found what we are searching for
10011 */
10012 - if (ieee->state != IEEE80211_NOLINK)
10013 + if (ieee->state != IEEE80211_NOLINK)
10014 break;
10015 -
10016 +
10017 //if (ieee->scan_age == 0 || time_after(target->last_scanned + ieee->scan_age, jiffies))
10018 - ieee80211_softmac_new_net(ieee, target);
10019 + ieee80211_softmac_new_net_rtl7(ieee, target);
10020 }
10021 -
10022 +
10023 spin_unlock_irqrestore(&ieee->lock, flags);
10024 -
10025 +
10026 }
10027  
10028  
10029 -static inline u16 auth_parse(struct sk_buff *skb, u8** challenge, int *chlen)
10030 +static inline u16 auth_parse_rtl7(struct sk_buff *skb, u8** challenge, int *chlen)
10031 {
10032 struct ieee80211_authentication *a;
10033 u8 *t;
10034 - if (skb->len < (sizeof(struct ieee80211_authentication)-sizeof(struct ieee80211_info_element))){
10035 + if (skb->len < (sizeof(struct ieee80211_authentication)-sizeof(struct ieee80211_info_element))){
10036 IEEE80211_DEBUG_MGMT("invalid len in auth resp: %d\n",skb->len);
10037 return 0xcafe;
10038 }
10039 @@ -1132,58 +1158,58 @@
10040 a = (struct ieee80211_authentication*) skb->data;
10041 if(skb->len > (sizeof(struct ieee80211_authentication) +3)){
10042 t = skb->data + sizeof(struct ieee80211_authentication);
10043 -
10044 +
10045 if(*(t++) == MFIE_TYPE_CHALLENGE){
10046 *chlen = *(t++);
10047 *challenge = (u8*)kmalloc(*chlen, GFP_ATOMIC);
10048 memcpy(*challenge, t, *chlen);
10049 }
10050 }
10051 -
10052 +
10053 return cpu_to_le16(a->status);
10054 -
10055 +
10056 }
10057  
10058  
10059 -int auth_rq_parse(struct sk_buff *skb,u8* dest)
10060 +int auth_rq_parse_rtl7(struct sk_buff *skb,u8* dest)
10061 {
10062 struct ieee80211_authentication *a;
10063 -
10064 - if (skb->len < (sizeof(struct ieee80211_authentication)-sizeof(struct ieee80211_info_element))){
10065 - IEEE80211_DEBUG_MGMT("invalid len in auth request: %d\n",skb->len);
10066 +
10067 + if (skb->len < (sizeof(struct ieee80211_authentication)-sizeof(struct ieee80211_info_element))){
10068 + IEEE80211_DEBUG_MGMT("invalid len in auth request: %d\n",skb->len);
10069 return -1;
10070 }
10071 a = (struct ieee80211_authentication*) skb->data;
10072 -
10073 +
10074 memcpy(dest,a->header.addr2, ETH_ALEN);
10075 -
10076 - if (le16_to_cpu(a->algorithm) != WLAN_AUTH_OPEN)
10077 +
10078 + if (le16_to_cpu(a->algorithm) != WLAN_AUTH_OPEN)
10079 return WLAN_STATUS_NOT_SUPPORTED_AUTH_ALG;
10080 -
10081 +
10082 return WLAN_STATUS_SUCCESS;
10083 }
10084  
10085 -static short probe_rq_parse(struct ieee80211_device *ieee, struct sk_buff *skb, u8 *src)
10086 +static short probe_rq_parse_rtl7(struct ieee80211_device *ieee, struct sk_buff *skb, u8 *src)
10087 {
10088 u8 *tag;
10089 u8 *skbend;
10090 u8 *ssid=NULL;
10091 u8 ssidlen = 0;
10092 -
10093 +
10094 struct ieee80211_hdr_3addr *header =
10095 (struct ieee80211_hdr_3addr *) skb->data;
10096 -
10097 - if (skb->len < sizeof (struct ieee80211_hdr_3addr ))
10098 +
10099 + if (skb->len < sizeof (struct ieee80211_hdr_3addr ))
10100 return -1; /* corrupted */
10101 -
10102 +
10103 memcpy(src,header->addr2, ETH_ALEN);
10104 -
10105 +
10106 skbend = (u8*)skb->data + skb->len;
10107 -
10108 +
10109 tag = skb->data + sizeof (struct ieee80211_hdr_3addr );
10110 -
10111 +
10112 while (tag+1 < skbend){
10113 - if (*tag == 0){
10114 + if (*tag == 0){
10115 ssid = tag+2;
10116 ssidlen = *(tag+1);
10117 break;
10118 @@ -1192,88 +1218,88 @@
10119 tag = tag + *(tag); /* point to the last data byte of the tag */
10120 tag++; /* point to the next tag */
10121 }
10122 -
10123 +
10124 //IEEE80211DMESG("Card MAC address is "MACSTR, MAC2STR(src));
10125 if (ssidlen == 0) return 1;
10126 -
10127 +
10128 if (!ssid) return 1; /* ssid not found in tagged param */
10129 return (!strncmp(ssid, ieee->current_network.ssid, ssidlen));
10130 -
10131 +
10132 }
10133  
10134 -int assoc_rq_parse(struct sk_buff *skb,u8* dest)
10135 +int assoc_rq_parse_rtl7(struct sk_buff *skb,u8* dest)
10136 {
10137 struct ieee80211_assoc_request_frame *a;
10138 -
10139 - if (skb->len < (sizeof(struct ieee80211_assoc_request_frame) -
10140 - sizeof(struct ieee80211_info_element))) {
10141 -
10142 +
10143 + if (skb->len < (sizeof(struct ieee80211_assoc_request_frame) -
10144 + sizeof(struct ieee80211_info_element))) {
10145 +
10146 IEEE80211_DEBUG_MGMT("invalid len in auth request:%d \n", skb->len);
10147 return -1;
10148 }
10149 -
10150 +
10151 a = (struct ieee80211_assoc_request_frame*) skb->data;
10152 -
10153 +
10154 memcpy(dest,a->header.addr2,ETH_ALEN);
10155 -
10156 +
10157 return 0;
10158 }
10159  
10160 -static inline u16 assoc_parse(struct sk_buff *skb, int *aid)
10161 +static inline u16 assoc_parse_rtl7(struct sk_buff *skb, int *aid)
10162 {
10163 struct ieee80211_assoc_response_frame *a;
10164 - if (skb->len < sizeof(struct ieee80211_assoc_response_frame)){
10165 + if (skb->len < sizeof(struct ieee80211_assoc_response_frame)){
10166 IEEE80211_DEBUG_MGMT("invalid len in auth resp: %d\n", skb->len);
10167 return 0xcafe;
10168 }
10169 -
10170 +
10171 a = (struct ieee80211_assoc_response_frame*) skb->data;
10172 *aid = le16_to_cpu(a->aid) & 0x3fff;
10173 return le16_to_cpu(a->status);
10174 }
10175  
10176 static inline void
10177 -ieee80211_rx_probe_rq(struct ieee80211_device *ieee, struct sk_buff *skb)
10178 +ieee80211_rx_probe_rq_rtl7(struct ieee80211_device *ieee, struct sk_buff *skb)
10179 {
10180 u8 dest[ETH_ALEN];
10181 -
10182 +
10183 //IEEE80211DMESG("Rx probe");
10184 ieee->softmac_stats.rx_probe_rq++;
10185 //DMESG("Dest is "MACSTR, MAC2STR(dest));
10186 - if (probe_rq_parse(ieee, skb, dest)){
10187 + if (probe_rq_parse_rtl7(ieee, skb, dest)){
10188 //IEEE80211DMESG("Was for me!");
10189 ieee->softmac_stats.tx_probe_rs++;
10190 - ieee80211_resp_to_probe(ieee, dest);
10191 + ieee80211_resp_to_probe_rtl7(ieee, dest);
10192 }
10193 }
10194  
10195 static inline void
10196 -ieee80211_rx_auth_rq(struct ieee80211_device *ieee, struct sk_buff *skb)
10197 +ieee80211_rx_auth_rq_rtl7(struct ieee80211_device *ieee, struct sk_buff *skb)
10198 {
10199 u8 dest[ETH_ALEN];
10200 int status;
10201 //IEEE80211DMESG("Rx probe");
10202 ieee->softmac_stats.rx_auth_rq++;
10203 -
10204 - if ((status = auth_rq_parse(skb, dest))!= -1){
10205 - ieee80211_resp_to_auth(ieee, status, dest);
10206 +
10207 + if ((status = auth_rq_parse_rtl7(skb, dest))!= -1){
10208 + ieee80211_resp_to_auth_rtl7(ieee, status, dest);
10209 }
10210 //DMESG("Dest is "MACSTR, MAC2STR(dest));
10211 -
10212 +
10213 }
10214  
10215 static inline void
10216 -ieee80211_rx_assoc_rq(struct ieee80211_device *ieee, struct sk_buff *skb)
10217 +ieee80211_rx_assoc_rq_rtl7(struct ieee80211_device *ieee, struct sk_buff *skb)
10218 {
10219 -
10220 +
10221 u8 dest[ETH_ALEN];
10222 //unsigned long flags;
10223 -
10224 +
10225 ieee->softmac_stats.rx_ass_rq++;
10226 - if (assoc_rq_parse(skb,dest) != -1){
10227 - ieee80211_resp_to_assoc_rq(ieee, dest);
10228 + if (assoc_rq_parse_rtl7(skb,dest) != -1){
10229 + ieee80211_resp_to_assoc_rq_rtl7(ieee, dest);
10230 }
10231 -
10232 +
10233 printk(KERN_INFO"New client associated: "MAC_FMT"\n", MAC_ARG(dest));
10234 //FIXME
10235 #if 0
10236 @@ -1285,25 +1311,25 @@
10237  
10238  
10239  
10240 -void ieee80211_sta_ps_send_null_frame(struct ieee80211_device *ieee, short pwr)
10241 +void ieee80211_sta_ps_send_null_frame_rtl7(struct ieee80211_device *ieee, short pwr)
10242 {
10243 -
10244 - struct sk_buff *buf = ieee80211_null_func(ieee, pwr);
10245 -
10246 +
10247 + struct sk_buff *buf = ieee80211_null_func_rtl7(ieee, pwr);
10248 +
10249 if (buf)
10250 - softmac_ps_mgmt_xmit(buf, ieee);
10251 + softmac_ps_mgmt_xmit_rtl7(buf, ieee);
10252  
10253 -}
10254 +}
10255  
10256  
10257 -short ieee80211_sta_ps_sleep(struct ieee80211_device *ieee, u32 *time_h, u32 *time_l)
10258 -{
10259 +short ieee80211_sta_ps_sleep_rtl7(struct ieee80211_device *ieee, u32 *time_h, u32 *time_l)
10260 +{
10261 int timeout = ieee->ps_timeout;
10262 u8 dtim;
10263 /*if(ieee->ps == IEEE80211_PS_DISABLED ||
10264 - ieee->iw_mode != IW_MODE_INFRA ||
10265 + ieee->iw_mode != IW_MODE_INFRA ||
10266 ieee->state != IEEE80211_LINKED)
10267 -
10268 +
10269 return 0;
10270 */
10271 dtim = ieee->current_network.dtim_data;
10272 @@ -1312,133 +1338,133 @@
10273 return 0;
10274 //printk("VALID\n");
10275 ieee->current_network.dtim_data = IEEE80211_DTIM_INVALID;
10276 -
10277 +
10278 if(dtim & ((IEEE80211_DTIM_UCAST | IEEE80211_DTIM_MBCAST)& ieee->ps))
10279 return 2;
10280 -
10281 +
10282 if(!time_after(jiffies, ieee->dev->trans_start + MSECS(timeout)))
10283 return 0;
10284 -
10285 +
10286 if(!time_after(jiffies, ieee->last_rx_ps_time + MSECS(timeout)))
10287 return 0;
10288 -
10289 +
10290 if((ieee->softmac_features & IEEE_SOFTMAC_SINGLE_QUEUE ) &&
10291 (ieee->mgmt_queue_tail != ieee->mgmt_queue_head))
10292 return 0;
10293 -
10294 +
10295 if(time_l){
10296 - *time_l = ieee->current_network.last_dtim_sta_time[0]
10297 - + (ieee->current_network.beacon_interval
10298 + *time_l = ieee->current_network.last_dtim_sta_time[0]
10299 + + (ieee->current_network.beacon_interval
10300 * ieee->current_network.dtim_period) * 1000;
10301 }
10302 -
10303 +
10304 if(time_h){
10305 *time_h = ieee->current_network.last_dtim_sta_time[1];
10306 if(time_l && *time_l < ieee->current_network.last_dtim_sta_time[0])
10307 *time_h += 1;
10308 }
10309 -
10310 +
10311 return 1;
10312 -
10313 -
10314 +
10315 +
10316 }
10317  
10318 -inline void ieee80211_sta_ps(struct ieee80211_device *ieee)
10319 +inline void ieee80211_sta_ps_rtl7(struct ieee80211_device *ieee)
10320 {
10321  
10322 u32 th,tl;
10323 short sleep;
10324 -
10325 +
10326 unsigned long flags,flags2;
10327 -
10328 +
10329 spin_lock_irqsave(&ieee->lock, flags);
10330 -
10331 +
10332 if((ieee->ps == IEEE80211_PS_DISABLED ||
10333 - ieee->iw_mode != IW_MODE_INFRA ||
10334 + ieee->iw_mode != IW_MODE_INFRA ||
10335 ieee->state != IEEE80211_LINKED)){
10336 -
10337 - #warning CHECK_LOCK_HERE
10338 +
10339 +// #warning CHECK_LOCK_HERE
10340 spin_lock_irqsave(&ieee->mgmt_tx_lock, flags2);
10341 -
10342 - ieee80211_sta_wakeup(ieee, 1);
10343 -
10344 +
10345 + ieee80211_sta_wakeup_rtl7(ieee, 1);
10346 + printk(KERN_WARNING "wakeup 1!\n" );
10347 spin_unlock_irqrestore(&ieee->mgmt_tx_lock, flags2);
10348 }
10349 -
10350 - sleep = ieee80211_sta_ps_sleep(ieee,&th, &tl);
10351 +
10352 + sleep = ieee80211_sta_ps_sleep_rtl7(ieee,&th, &tl);
10353 /* 2 wake, 1 sleep, 0 do nothing */
10354 if(sleep == 0)
10355 goto out;
10356 -
10357 +
10358 if(sleep == 1){
10359 -
10360 +
10361 if(ieee->sta_sleep == 1)
10362 ieee->enter_sleep_state(ieee->dev,th,tl);
10363 -
10364 +
10365 else if(ieee->sta_sleep == 0){
10366 // printk("send null 1\n");
10367 spin_lock_irqsave(&ieee->mgmt_tx_lock, flags2);
10368 -
10369 +
10370 if(ieee->ps_is_queue_empty(ieee->dev)){
10371 -
10372 -
10373 +
10374 +
10375 ieee->sta_sleep = 2;
10376 -
10377 +
10378 ieee->ps_request_tx_ack(ieee->dev);
10379 -
10380 - ieee80211_sta_ps_send_null_frame(ieee,1);
10381 -
10382 +
10383 + ieee80211_sta_ps_send_null_frame_rtl7(ieee,1);
10384 +
10385 ieee->ps_th = th;
10386 ieee->ps_tl = tl;
10387 - }
10388 + }
10389 spin_unlock_irqrestore(&ieee->mgmt_tx_lock, flags2);
10390 -
10391 +
10392 }
10393 -
10394 -
10395 +
10396 +
10397 }else if(sleep == 2){
10398 -#warning CHECK_LOCK_HERE
10399 +// #warning CHECK_LOCK_HERE
10400 spin_lock_irqsave(&ieee->mgmt_tx_lock, flags2);
10401 -
10402 - ieee80211_sta_wakeup(ieee,1);
10403 -
10404 +
10405 + ieee80211_sta_wakeup_rtl7(ieee,1);
10406 + printk(KERN_WARNING "wakeup 2!\n" );
10407 spin_unlock_irqrestore(&ieee->mgmt_tx_lock, flags2);
10408 }
10409  
10410 -out:
10411 +out:
10412 spin_unlock_irqrestore(&ieee->lock, flags);
10413 -
10414 +
10415 }
10416  
10417 -void ieee80211_sta_wakeup(struct ieee80211_device *ieee, short nl)
10418 +void ieee80211_sta_wakeup_rtl7(struct ieee80211_device *ieee, short nl)
10419 {
10420 if(ieee->sta_sleep == 0){
10421 if(nl){
10422 printk("Warning: driver is probably failing to report TX ps error\n");
10423 ieee->ps_request_tx_ack(ieee->dev);
10424 - ieee80211_sta_ps_send_null_frame(ieee, 0);
10425 + ieee80211_sta_ps_send_null_frame_rtl7(ieee, 0);
10426 }
10427 return;
10428 -
10429 +
10430 }
10431 -
10432 - if(ieee->sta_sleep == 1)
10433 +
10434 + if(ieee->sta_sleep == 1)
10435 ieee->sta_wake_up(ieee->dev);
10436 -
10437 +
10438 ieee->sta_sleep = 0;
10439 -
10440 +
10441 if(nl){
10442 ieee->ps_request_tx_ack(ieee->dev);
10443 - ieee80211_sta_ps_send_null_frame(ieee, 0);
10444 + ieee80211_sta_ps_send_null_frame_rtl7(ieee, 0);
10445 }
10446 }
10447  
10448 -void ieee80211_ps_tx_ack(struct ieee80211_device *ieee, short success)
10449 +void ieee80211_ps_tx_ack_rtl7(struct ieee80211_device *ieee, short success)
10450 {
10451 unsigned long flags,flags2;
10452 -
10453 +
10454 spin_lock_irqsave(&ieee->lock, flags);
10455 -
10456 +
10457 if(ieee->sta_sleep == 2){
10458 /* Null frame with PS bit set */
10459 if(success){
10460 @@ -1451,10 +1477,10 @@
10461 }
10462 /* 21112005 - tx again null without PS bit if lost */
10463 else {
10464 -
10465 +
10466 if((ieee->sta_sleep == 0) && !success){
10467 spin_lock_irqsave(&ieee->mgmt_tx_lock, flags2);
10468 - ieee80211_sta_ps_send_null_frame(ieee, 0);
10469 + ieee80211_sta_ps_send_null_frame_rtl7(ieee, 0);
10470 spin_unlock_irqrestore(&ieee->mgmt_tx_lock, flags2);
10471 }
10472 }
10473 @@ -1462,129 +1488,132 @@
10474 }
10475  
10476 inline int
10477 -ieee80211_rx_frame_softmac(struct ieee80211_device *ieee, struct sk_buff *skb,
10478 +ieee80211_rx_frame_softmac_rtl7(struct ieee80211_device *ieee, struct sk_buff *skb,
10479 struct ieee80211_rx_stats *rx_stats, u16 type,
10480 u16 stype)
10481 {
10482 struct ieee80211_hdr_3addr *header;
10483 - header = (struct ieee80211_hdr_3addr *) skb->data;
10484 u16 errcode;
10485 u8* challenge;
10486 int chlen;
10487 int aid;
10488 -
10489 +
10490 + chlen = 0;
10491 +
10492 + header = (struct ieee80211_hdr_3addr *) skb->data;
10493 +
10494 if(!ieee->proto_started)
10495 return 0;
10496 -
10497 +
10498 if(ieee->sta_sleep || (ieee->ps != IEEE80211_PS_DISABLED &&
10499 - ieee->iw_mode == IW_MODE_INFRA &&
10500 + ieee->iw_mode == IW_MODE_INFRA &&
10501 ieee->state == IEEE80211_LINKED))
10502 -
10503 +
10504 tasklet_schedule(&ieee->ps_task);
10505 -
10506 +
10507 if(WLAN_FC_GET_STYPE(header->frame_ctl) != IEEE80211_STYPE_PROBE_RESP &&
10508 WLAN_FC_GET_STYPE(header->frame_ctl) != IEEE80211_STYPE_BEACON)
10509 ieee->last_rx_ps_time = jiffies;
10510 -
10511 +
10512 switch (WLAN_FC_GET_STYPE(header->frame_ctl)) {
10513 -
10514 +
10515 case IEEE80211_STYPE_ASSOC_RESP:
10516 case IEEE80211_STYPE_REASSOC_RESP:
10517 -
10518 +
10519 IEEE80211_DEBUG_MGMT("received [RE]ASSOCIATION RESPONSE (%d)\n",
10520 WLAN_FC_GET_STYPE(header->frame_ctl));
10521 if ((ieee->softmac_features & IEEE_SOFTMAC_ASSOCIATE) &&
10522 - ieee->state == IEEE80211_ASSOCIATING_AUTHENTICATED &&
10523 + ieee->state == IEEE80211_ASSOCIATING_AUTHENTICATED &&
10524 ieee->iw_mode == IW_MODE_INFRA){
10525 - if (0 == (errcode=assoc_parse(skb, &aid))){
10526 -
10527 + if (0 == (errcode=assoc_parse_rtl7(skb, &aid))){
10528 +
10529 ieee->state=IEEE80211_LINKED;
10530 ieee->assoc_id = aid;
10531 ieee->softmac_stats.rx_ass_ok++;
10532 -
10533 - ieee80211_associate_complete(ieee);
10534 +
10535 + ieee80211_associate_complete_rtl7(ieee);
10536 }else{
10537 ieee->softmac_stats.rx_ass_err++;
10538 IEEE80211_DEBUG_MGMT(
10539 "Association response status code 0x%x\n",
10540 errcode);
10541 - ieee80211_associate_abort(ieee);
10542 + ieee80211_associate_abort_rtl7(ieee);
10543 }
10544 }
10545 break;
10546 -
10547 +
10548 case IEEE80211_STYPE_ASSOC_REQ:
10549 case IEEE80211_STYPE_REASSOC_REQ:
10550 -
10551 +
10552 if ((ieee->softmac_features & IEEE_SOFTMAC_ASSOCIATE) &&
10553 ieee->iw_mode == IW_MODE_MASTER)
10554 -
10555 - ieee80211_rx_assoc_rq(ieee, skb);
10556 +
10557 + ieee80211_rx_assoc_rq_rtl7(ieee, skb);
10558 break;
10559 -
10560 +
10561 case IEEE80211_STYPE_AUTH:
10562 -
10563 +
10564 if (ieee->softmac_features & IEEE_SOFTMAC_ASSOCIATE){
10565 - if (ieee->state == IEEE80211_ASSOCIATING_AUTHENTICATING &&
10566 + if (ieee->state == IEEE80211_ASSOCIATING_AUTHENTICATING &&
10567 ieee->iw_mode == IW_MODE_INFRA){
10568 -
10569 +
10570 IEEE80211_DEBUG_MGMT("Received authentication response");
10571 -
10572 - if (0 == (errcode=auth_parse(skb, &challenge, &chlen))){
10573 +
10574 + if (0 == (errcode=auth_parse_rtl7(skb, &challenge, &chlen))){
10575 if(ieee->open_wep || !challenge){
10576 ieee->state = IEEE80211_ASSOCIATING_AUTHENTICATED;
10577 ieee->softmac_stats.rx_auth_rs_ok++;
10578 -
10579 - ieee80211_associate_step2(ieee);
10580 +
10581 + ieee80211_associate_step2_rtl7(ieee);
10582 }else{
10583 - ieee80211_auth_challenge(ieee, challenge, chlen);
10584 + ieee80211_auth_challenge_rtl7(ieee, challenge, chlen);
10585 }
10586 }else{
10587 ieee->softmac_stats.rx_auth_rs_err++;
10588 IEEE80211_DEBUG_MGMT("Authentication respose status code 0x%x",errcode);
10589 - ieee80211_associate_abort(ieee);
10590 + ieee80211_associate_abort_rtl7(ieee);
10591 }
10592 -
10593 +
10594 }else if (ieee->iw_mode == IW_MODE_MASTER){
10595 - ieee80211_rx_auth_rq(ieee, skb);
10596 + ieee80211_rx_auth_rq_rtl7(ieee, skb);
10597 }
10598 }
10599 break;
10600 -
10601 +
10602 case IEEE80211_STYPE_PROBE_REQ:
10603 -
10604 - if ((ieee->softmac_features & IEEE_SOFTMAC_PROBERS) &&
10605 - ((ieee->iw_mode == IW_MODE_ADHOC ||
10606 +
10607 + if ((ieee->softmac_features & IEEE_SOFTMAC_PROBERS) &&
10608 + ((ieee->iw_mode == IW_MODE_ADHOC ||
10609 ieee->iw_mode == IW_MODE_MASTER) &&
10610 ieee->state == IEEE80211_LINKED))
10611 -
10612 - ieee80211_rx_probe_rq(ieee, skb);
10613 +
10614 + ieee80211_rx_probe_rq_rtl7(ieee, skb);
10615 break;
10616 -
10617 +
10618 case IEEE80211_STYPE_DISASSOC:
10619 case IEEE80211_STYPE_DEAUTH:
10620 - /* FIXME for now repeat all the association procedure
10621 + /* FIXME for now repeat all the association procedure
10622 * both for disassociation and deauthentication
10623 */
10624 if ((ieee->softmac_features & IEEE_SOFTMAC_ASSOCIATE) &&
10625 - ieee->state == IEEE80211_LINKED &&
10626 + ieee->state == IEEE80211_LINKED &&
10627 ieee->iw_mode == IW_MODE_INFRA){
10628 -
10629 +
10630 ieee->state = IEEE80211_ASSOCIATING;
10631 ieee->softmac_stats.reassoc++;
10632 -
10633 - notify_wx_assoc_event(ieee);
10634 -
10635 +
10636 + notify_wx_assoc_event_rtl7(ieee);
10637 +
10638 queue_work(ieee->wq, &ieee->associate_procedure_wq);
10639 }
10640 -
10641 +
10642 break;
10643 -
10644 - default:
10645 +
10646 + default:
10647 return -1;
10648 break;
10649 }
10650 -
10651 +
10652 //dev_kfree_skb_any(skb);
10653 return 0;
10654 }
10655 @@ -1602,21 +1631,21 @@
10656 * This might be useful if each fragment need it's own
10657 * descriptor, thus just keep a total free memory > than
10658 * the max fragmentation treshold is not enought.. If the
10659 - * ieee802.11 stack passed a TXB struct then you needed
10660 - * to keep N free descriptors where
10661 + * ieee802.11 stack passed a TXB struct then you needed
10662 + * to keep N free descriptors where
10663 * N = MAX_PACKET_SIZE / MIN_FRAG_TRESHOLD
10664 * In this way you need just one and the 802.11 stack
10665 - * will take care of buffering fragments and pass them to
10666 + * will take care of buffering fragments and pass them to
10667 * to the driver later, when it wakes the queue.
10668 - */
10669 -
10670 -void ieee80211_softmac_xmit(struct ieee80211_txb *txb, struct ieee80211_device *ieee)
10671 + */
10672 +
10673 +void ieee80211_softmac_xmit_rtl7(struct ieee80211_txb *txb, struct ieee80211_device *ieee)
10674 {
10675 -
10676 -
10677 +
10678 +
10679 unsigned long flags;
10680 int i;
10681 -
10682 +
10683 spin_lock_irqsave(&ieee->lock,flags);
10684 #if 0
10685 if(ieee->queue_stop){
10686 @@ -1627,13 +1656,13 @@
10687 err = 1;
10688 goto exit;
10689 }
10690 -
10691 +
10692 ieee->stats.tx_bytes+=skb->len;
10693 -
10694 -
10695 +
10696 +
10697 txb=ieee80211_skb_to_txb(ieee,skb);
10698 -
10699 -
10700 +
10701 +
10702 if(txb==NULL){
10703 IEEE80211DMESG("WW: IEEE stack failed to provide txb");
10704 //dev_kfree_skb_any(skb);
10705 @@ -1641,12 +1670,12 @@
10706 goto exit;
10707 }
10708 #endif
10709 -
10710 +
10711 /* called with 2nd parm 0, no tx mgmt lock required */
10712 - ieee80211_sta_wakeup(ieee,0);
10713 + ieee80211_sta_wakeup_rtl7(ieee,0);
10714  
10715 for(i = 0; i < txb->nr_frags; i++) {
10716 -
10717 +
10718 if (ieee->queue_stop){
10719 ieee->tx_pending.txb = txb;
10720 ieee->tx_pending.frag = i;
10721 @@ -1658,29 +1687,29 @@
10722 //(i+1)<txb->nr_frags);
10723 ieee->stats.tx_packets++;
10724 ieee->stats.tx_bytes += txb->fragments[i]->len;
10725 - ieee->dev->trans_start = jiffies;
10726 + ieee->dev->trans_start = jiffies;
10727 }
10728 - }
10729 -
10730 - ieee80211_txb_free(txb);
10731 -
10732 + }
10733 +
10734 + ieee80211_txb_free_rtl7(txb);
10735 +
10736 exit:
10737 spin_unlock_irqrestore(&ieee->lock,flags);
10738 -
10739 +
10740 }
10741  
10742 /* called with ieee->lock acquired */
10743 -void ieee80211_resume_tx(struct ieee80211_device *ieee)
10744 +void ieee80211_resume_tx_rtl7(struct ieee80211_device *ieee)
10745 {
10746 int i;
10747 for(i = ieee->tx_pending.frag; i < ieee->tx_pending.txb->nr_frags; i++) {
10748 -
10749 +
10750 if (ieee->queue_stop){
10751 ieee->tx_pending.frag = i;
10752 return;
10753 }else{
10754 -
10755 - ieee->softmac_data_hard_start_xmit(
10756 +
10757 + ieee->softmac_data_hard_start_xmit(
10758 ieee->tx_pending.txb->fragments[i],
10759 ieee->dev,ieee->rate);
10760 //(i+1)<ieee->tx_pending.txb->nr_frags);
10761 @@ -1688,21 +1717,21 @@
10762 ieee->dev->trans_start = jiffies;
10763 }
10764 }
10765 -
10766 -
10767 - ieee80211_txb_free(ieee->tx_pending.txb);
10768 +
10769 +
10770 + ieee80211_txb_free_rtl7(ieee->tx_pending.txb);
10771 ieee->tx_pending.txb = NULL;
10772 }
10773  
10774  
10775 -void ieee80211_reset_queue(struct ieee80211_device *ieee)
10776 +void ieee80211_reset_queue_rtl7(struct ieee80211_device *ieee)
10777 {
10778 unsigned long flags;
10779 -
10780 +
10781 spin_lock_irqsave(&ieee->lock,flags);
10782 - init_mgmt_queue(ieee);
10783 + init_mgmt_queue_rtl7(ieee);
10784 if (ieee->tx_pending.txb){
10785 - ieee80211_txb_free(ieee->tx_pending.txb);
10786 + ieee80211_txb_free_rtl7(ieee->tx_pending.txb);
10787 ieee->tx_pending.txb = NULL;
10788 }
10789 ieee->queue_stop = 0;
10790 @@ -1710,23 +1739,23 @@
10791  
10792 }
10793  
10794 -void ieee80211_wake_queue(struct ieee80211_device *ieee)
10795 +void ieee80211_wake_queue_rtl7(struct ieee80211_device *ieee)
10796 {
10797  
10798 unsigned long flags;
10799 struct sk_buff *skb;
10800 struct ieee80211_hdr_3addr *header;
10801 -
10802 +
10803 spin_lock_irqsave(&ieee->lock,flags);
10804 if (! ieee->queue_stop) goto exit;
10805 -
10806 +
10807 ieee->queue_stop = 0;
10808 -
10809 +
10810 if(ieee->softmac_features & IEEE_SOFTMAC_SINGLE_QUEUE){
10811 - while (!ieee->queue_stop && (skb = dequeue_mgmt(ieee))){
10812 -
10813 + while (!ieee->queue_stop && (skb = dequeue_mgmt_rtl7(ieee))){
10814 +
10815 header = (struct ieee80211_hdr_3addr *) skb->data;
10816 -
10817 +
10818 header->seq_ctl = cpu_to_le16(ieee->seq_ctrl << 4);
10819  
10820 if (ieee->seq_ctrl == 0xFFF)
10821 @@ -1738,19 +1767,19 @@
10822 }
10823 }
10824 if (!ieee->queue_stop && ieee->tx_pending.txb)
10825 - ieee80211_resume_tx(ieee);
10826 -
10827 + ieee80211_resume_tx_rtl7(ieee);
10828 +
10829 if (!ieee->queue_stop && netif_queue_stopped(ieee->dev)){
10830 ieee->softmac_stats.swtxawake++;
10831 netif_wake_queue(ieee->dev);
10832 }
10833 -
10834 +
10835 exit :
10836 spin_unlock_irqrestore(&ieee->lock,flags);
10837 }
10838  
10839  
10840 -void ieee80211_stop_queue(struct ieee80211_device *ieee)
10841 +void ieee80211_stop_queue_rtl7(struct ieee80211_device *ieee)
10842 {
10843 //unsigned long flags;
10844 //spin_lock_irqsave(&ieee->lock,flags);
10845 @@ -1761,81 +1790,88 @@
10846 }
10847 ieee->queue_stop = 1;
10848 //spin_unlock_irqrestore(&ieee->lock,flags);
10849 -
10850 +
10851 }
10852  
10853  
10854 -inline void ieee80211_randomize_cell(struct ieee80211_device *ieee)
10855 +inline void ieee80211_randomize_cell_rtl7(struct ieee80211_device *ieee)
10856 {
10857 -
10858 +
10859 get_random_bytes(ieee->current_network.bssid, ETH_ALEN);
10860 -
10861 +
10862 /* an IBSS cell address must have the two less significant
10863 - * bits of the first byte = 2
10864 + * bits of the first byte = 2
10865 */
10866 ieee->current_network.bssid[0] &= ~0x01;
10867 ieee->current_network.bssid[0] |= 0x02;
10868 }
10869  
10870 /* called in user context only */
10871 -void ieee80211_start_master_bss(struct ieee80211_device *ieee)
10872 +void ieee80211_start_master_bss_rtl7(struct ieee80211_device *ieee)
10873 {
10874 ieee->assoc_id = 1;
10875 -
10876 +
10877 if (ieee->current_network.ssid_len == 0){
10878 - strncpy(ieee->current_network.ssid,
10879 + strncpy(ieee->current_network.ssid,
10880 IEEE80211_DEFAULT_TX_ESSID,
10881 IW_ESSID_MAX_SIZE);
10882 -
10883 +
10884 ieee->current_network.ssid_len = strlen(IEEE80211_DEFAULT_TX_ESSID);
10885 ieee->ssid_set = 1;
10886 }
10887 -
10888 +
10889 memcpy(ieee->current_network.bssid, ieee->dev->dev_addr, ETH_ALEN);
10890 -
10891 +
10892 ieee->set_chan(ieee->dev, ieee->current_network.channel);
10893 ieee->state = IEEE80211_LINKED;
10894 ieee->link_change(ieee->dev);
10895 - notify_wx_assoc_event(ieee);
10896 -
10897 + notify_wx_assoc_event_rtl7(ieee);
10898 +
10899 if (ieee->data_hard_resume)
10900 ieee->data_hard_resume(ieee->dev);
10901 -
10902 +
10903 netif_carrier_on(ieee->dev);
10904 }
10905  
10906 -void ieee80211_start_monitor_mode(struct ieee80211_device *ieee)
10907 +void ieee80211_start_monitor_mode_rtl7(struct ieee80211_device *ieee)
10908 {
10909 if(ieee->raw_tx){
10910 -
10911 +
10912 if (ieee->data_hard_resume)
10913 ieee->data_hard_resume(ieee->dev);
10914 -
10915 +
10916 netif_carrier_on(ieee->dev);
10917 }
10918 }
10919 -void ieee80211_start_ibss_wq(struct ieee80211_device *ieee)
10920 +
10921 +# if (LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,20))
10922 +void ieee80211_start_ibss_wq_rtl7(struct work_struct *work)
10923 +{
10924 + struct ieee80211_device *ieee = container_of(work, struct ieee80211_device, start_ibss_wq);
10925 +#else
10926 +void ieee80211_start_ibss_wq_rtl7(struct ieee80211_device *ieee)
10927 {
10928 -
10929 +#endif
10930 +
10931 /* iwconfig mode ad-hoc will schedule this and return
10932 * on the other hand this will block further iwconfig SET
10933 * operations because of the wx_sem hold.
10934 * Anyway some most set operations set a flag to speed-up
10935 - * (abort) this wq (when syncro scanning) before sleeping
10936 + * (abort) this wq (when syncro scanning) before sleeping
10937 * on the semaphore
10938 */
10939 -
10940 +
10941 down(&ieee->wx_sem);
10942 -
10943 +
10944 if (ieee->current_network.ssid_len == 0){
10945 strcpy(ieee->current_network.ssid,IEEE80211_DEFAULT_TX_ESSID);
10946 ieee->current_network.ssid_len = strlen(IEEE80211_DEFAULT_TX_ESSID);
10947 ieee->ssid_set = 1;
10948 - }
10949 -
10950 + }
10951 +
10952 /* check if we have this cell in our network list */
10953 - ieee80211_softmac_check_all_nets(ieee);
10954 -
10955 + ieee80211_softmac_check_all_nets_rtl7(ieee);
10956 +
10957 /* if not then the state is not linked. Maybe the user swithced to
10958 * ad-hoc mode just after being in monitor mode, or just after
10959 * being very few time in managed mode (so the card have had no
10960 @@ -1851,29 +1887,29 @@
10961 * associated.
10962 */
10963 if (ieee->state == IEEE80211_NOLINK)
10964 - ieee80211_start_scan_syncro(ieee);
10965 + ieee80211_start_scan_syncro_rtl7(ieee);
10966  
10967 /* the network definitively is not here.. create a new cell */
10968 if (ieee->state == IEEE80211_NOLINK){
10969 - printk("creating new IBSS cell\n");
10970 + printk("creating new IBSS cell\n");
10971 if(!ieee->wap_set)
10972 - ieee80211_randomize_cell(ieee);
10973 -
10974 + ieee80211_randomize_cell_rtl7(ieee);
10975 +
10976 if(ieee->modulation & IEEE80211_CCK_MODULATION){
10977 -
10978 +
10979 ieee->current_network.rates_len = 4;
10980 -
10981 +
10982 ieee->current_network.rates[0] = IEEE80211_BASIC_RATE_MASK | IEEE80211_CCK_RATE_1MB;
10983 ieee->current_network.rates[1] = IEEE80211_BASIC_RATE_MASK | IEEE80211_CCK_RATE_2MB;
10984 ieee->current_network.rates[2] = IEEE80211_BASIC_RATE_MASK | IEEE80211_CCK_RATE_5MB;
10985 ieee->current_network.rates[3] = IEEE80211_BASIC_RATE_MASK | IEEE80211_CCK_RATE_11MB;
10986 -
10987 +
10988 }else
10989 ieee->current_network.rates_len = 0;
10990 -
10991 +
10992 if(ieee->modulation & IEEE80211_OFDM_MODULATION){
10993 ieee->current_network.rates_ex_len = 8;
10994 -
10995 +
10996 ieee->current_network.rates_ex[0] = IEEE80211_BASIC_RATE_MASK | IEEE80211_OFDM_RATE_6MB;
10997 ieee->current_network.rates_ex[1] = IEEE80211_BASIC_RATE_MASK | IEEE80211_OFDM_RATE_9MB;
10998 ieee->current_network.rates_ex[2] = IEEE80211_BASIC_RATE_MASK | IEEE80211_OFDM_RATE_12MB;
10999 @@ -1882,44 +1918,44 @@
11000 ieee->current_network.rates_ex[5] = IEEE80211_BASIC_RATE_MASK | IEEE80211_OFDM_RATE_36MB;
11001 ieee->current_network.rates_ex[6] = IEEE80211_BASIC_RATE_MASK | IEEE80211_OFDM_RATE_48MB;
11002 ieee->current_network.rates_ex[7] = IEEE80211_BASIC_RATE_MASK | IEEE80211_OFDM_RATE_54MB;
11003 -
11004 - ieee->rate = 540;
11005 +
11006 +// ieee->rate = 540;
11007 }else{
11008 ieee->current_network.rates_ex_len = 0;
11009 - ieee->rate = 110;
11010 +// ieee->rate = 110;
11011 }
11012 -
11013 +
11014 ieee->current_network.atim_window = 0;
11015 ieee->current_network.capability = WLAN_CAPABILITY_IBSS;
11016 if(ieee->short_slot)
11017 ieee->current_network.capability |= WLAN_CAPABILITY_SHORT_SLOT;
11018 -
11019 +
11020 }
11021 -
11022 +
11023 ieee->state = IEEE80211_LINKED;
11024 -
11025 +
11026 ieee->set_chan(ieee->dev, ieee->current_network.channel);
11027 ieee->link_change(ieee->dev);
11028 -
11029 - notify_wx_assoc_event(ieee);
11030 -
11031 - ieee80211_start_send_beacons(ieee);
11032 -
11033 +
11034 + notify_wx_assoc_event_rtl7(ieee);
11035 +
11036 + ieee80211_start_send_beacons_rtl7(ieee);
11037 +
11038 if (ieee->data_hard_resume)
11039 ieee->data_hard_resume(ieee->dev);
11040 -
11041 +
11042 netif_carrier_on(ieee->dev);
11043 -
11044 +
11045 up(&ieee->wx_sem);
11046 }
11047  
11048 -inline void ieee80211_start_ibss(struct ieee80211_device *ieee)
11049 +inline void ieee80211_start_ibss_rtl7(struct ieee80211_device *ieee)
11050 {
11051 queue_work(ieee->wq, &ieee->start_ibss_wq);
11052 }
11053  
11054 /* this is called only in user context, with wx_sem held */
11055 -void ieee80211_start_bss(struct ieee80211_device *ieee)
11056 +void ieee80211_start_bss_rtl7(struct ieee80211_device *ieee)
11057 {
11058 unsigned long flags;
11059 /* check if we have already found the net we
11060 @@ -1927,8 +1963,8 @@
11061 * if not (we are disassociated and we are not
11062 * in associating / authenticating phase) start the background scanning.
11063 */
11064 - ieee80211_softmac_check_all_nets(ieee);
11065 -
11066 + ieee80211_softmac_check_all_nets_rtl7(ieee);
11067 +
11068 /* ensure no-one start an associating process (thus setting
11069 * the ieee->state to ieee80211_ASSOCIATING) while we
11070 * have just cheked it and we are going to enable scan.
11071 @@ -1937,41 +1973,49 @@
11072 * the rx path), so we cannot be in the middle of such function
11073 */
11074 spin_lock_irqsave(&ieee->lock, flags);
11075 -
11076 if (ieee->state == IEEE80211_NOLINK)
11077 - ieee80211_start_scan(ieee);
11078 -
11079 + ieee80211_start_scan_rtl7(ieee);
11080 +
11081 spin_unlock_irqrestore(&ieee->lock, flags);
11082 }
11083  
11084 /* called only in userspace context */
11085 -void ieee80211_disassociate(struct ieee80211_device *ieee)
11086 +void ieee80211_disassociate_rtl7(struct ieee80211_device *ieee)
11087 {
11088 netif_carrier_off(ieee->dev);
11089 -
11090 +
11091 if (ieee->softmac_features & IEEE_SOFTMAC_TX_QUEUE)
11092 - ieee80211_reset_queue(ieee);
11093 -
11094 + ieee80211_reset_queue_rtl7(ieee);
11095 +
11096 if (ieee->data_hard_stop)
11097 ieee->data_hard_stop(ieee->dev);
11098 -
11099 +
11100 ieee->state = IEEE80211_NOLINK;
11101 ieee->link_change(ieee->dev);
11102 - notify_wx_assoc_event(ieee);
11103 -
11104 + notify_wx_assoc_event_rtl7(ieee);
11105 +
11106 }
11107 -void ieee80211_associate_retry_wq(struct ieee80211_device *ieee)
11108 +
11109 +# if (LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,20))
11110 +void ieee80211_associate_retry_wq_rtl7(struct work_struct *work)
11111 +{
11112 + struct delayed_work *dwork = container_of(work, struct delayed_work, work);
11113 + struct ieee80211_device *ieee = container_of(dwork, struct ieee80211_device, associate_retry_wq);
11114 +#else
11115 +void ieee80211_associate_retry_wq_rtl7(struct ieee80211_device *ieee)
11116 {
11117 +#endif
11118 unsigned long flags;
11119 -
11120 +
11121 down(&ieee->wx_sem);
11122 +
11123 if(!ieee->proto_started)
11124 goto exit;
11125 -
11126 +
11127 if(ieee->state != IEEE80211_ASSOCIATING_RETRY)
11128 goto exit;
11129 -
11130 - /* until we do not set the state to IEEE80211_NOLINK
11131 +
11132 + /* until we do not set the state to IEEE80211_NOLINK
11133 * there are no possibility to have someone else trying
11134 * to start an association procdure (we get here with
11135 * ieee->state = IEEE80211_ASSOCIATING).
11136 @@ -1981,122 +2025,120 @@
11137 * RX path works with ieee->lock held so there are no
11138 * problems. If we are still disassociated then start a scan.
11139 * the lock here is necessary to ensure no one try to start
11140 - * an association procedure when we have just checked the
11141 + * an association procedure when we have just checked the
11142 * state and we are going to start the scan.
11143 */
11144 ieee->state = IEEE80211_NOLINK;
11145  
11146 - ieee80211_softmac_check_all_nets(ieee);
11147 -
11148 + ieee80211_softmac_check_all_nets_rtl7(ieee);
11149 +
11150 spin_lock_irqsave(&ieee->lock, flags);
11151 -
11152 +
11153 if(ieee->state == IEEE80211_NOLINK)
11154 - ieee80211_start_scan(ieee);
11155 -
11156 + ieee80211_start_scan_rtl7(ieee);
11157 +
11158 spin_unlock_irqrestore(&ieee->lock, flags);
11159  
11160 exit:
11161 up(&ieee->wx_sem);
11162 }
11163  
11164 -struct sk_buff *ieee80211_get_beacon_(struct ieee80211_device *ieee)
11165 +struct sk_buff *ieee80211_get_beacon__rtl7(struct ieee80211_device *ieee)
11166 {
11167 u8 broadcast_addr[] = {0xff,0xff,0xff,0xff,0xff,0xff};
11168 -
11169 +
11170 struct sk_buff *skb;
11171 struct ieee80211_probe_response *b;
11172 -
11173 - skb = ieee80211_probe_resp(ieee, broadcast_addr);
11174 -
11175 - if (!skb)
11176 +
11177 + skb = ieee80211_probe_resp_rtl7(ieee, broadcast_addr);
11178 +
11179 + if (!skb)
11180 return NULL;
11181 -
11182 +
11183 b = (struct ieee80211_probe_response *) skb->data;
11184 b->header.frame_ctl = cpu_to_le16(IEEE80211_STYPE_BEACON);
11185 -
11186 +
11187 return skb;
11188 -
11189 +
11190 }
11191  
11192 -struct sk_buff *ieee80211_get_beacon(struct ieee80211_device *ieee)
11193 +struct sk_buff *ieee80211_get_beacon_rtl7(struct ieee80211_device *ieee)
11194 {
11195 struct sk_buff *skb;
11196 struct ieee80211_probe_response *b;
11197 -
11198 - skb = ieee80211_get_beacon_(ieee);
11199 - if(!skb)
11200 +
11201 + skb = ieee80211_get_beacon__rtl7(ieee);
11202 + if(!skb)
11203 return NULL;
11204 -
11205 - b = (struct ieee80211_probe_response *) skb->data;
11206 +
11207 + b = (struct ieee80211_probe_response *) skb->data;
11208 b->header.seq_ctrl = cpu_to_le16(ieee->seq_ctrl << 4);
11209 -
11210 +
11211 if (ieee->seq_ctrl == 0xFFF)
11212 ieee->seq_ctrl = 0;
11213 else
11214 ieee->seq_ctrl++;
11215 -
11216 +
11217 return skb;
11218 }
11219  
11220 -void ieee80211_softmac_stop_protocol(struct ieee80211_device *ieee)
11221 +void ieee80211_softmac_stop_protocol_rtl7(struct ieee80211_device *ieee)
11222 {
11223 ieee->sync_scan_hurryup = 1;
11224 down(&ieee->wx_sem);
11225 - ieee80211_stop_protocol(ieee);
11226 +
11227 + ieee80211_stop_protocol_rtl7(ieee);
11228 up(&ieee->wx_sem);
11229 }
11230  
11231  
11232 -void ieee80211_stop_protocol(struct ieee80211_device *ieee)
11233 +void ieee80211_stop_protocol_rtl7(struct ieee80211_device *ieee)
11234 {
11235 if (!ieee->proto_started)
11236 return;
11237 -
11238 +
11239 ieee->proto_started = 0;
11240 -
11241 - ieee80211_stop_send_beacons(ieee);
11242 -
11243 +
11244 + ieee80211_stop_send_beacons_rtl7(ieee);
11245 +
11246 del_timer_sync(&ieee->associate_timer);
11247 - cancel_delayed_work(&ieee->associate_retry_wq);
11248 -
11249 - ieee80211_stop_scan(ieee);
11250 + cancel_delayed_work(&ieee->associate_retry_wq);
11251 +
11252 + ieee80211_stop_scan_rtl7(ieee);
11253  
11254 - ieee80211_disassociate(ieee);
11255 + ieee80211_disassociate_rtl7(ieee);
11256 }
11257  
11258 -void ieee80211_softmac_start_protocol(struct ieee80211_device *ieee)
11259 +void ieee80211_softmac_start_protocol_rtl7(struct ieee80211_device *ieee)
11260 {
11261 ieee->sync_scan_hurryup = 0;
11262 down(&ieee->wx_sem);
11263 - ieee80211_start_protocol(ieee);
11264 + ieee80211_start_protocol_rtl7(ieee);
11265 up(&ieee->wx_sem);
11266 }
11267  
11268 -void ieee80211_start_protocol(struct ieee80211_device *ieee)
11269 +void ieee80211_start_protocol_rtl7(struct ieee80211_device *ieee)
11270 {
11271 short ch = 0;
11272 -
11273 if (ieee->proto_started)
11274 return;
11275 -
11276 +
11277 ieee->proto_started = 1;
11278 -
11279 +
11280 if (ieee->current_network.channel == 0){
11281 do{
11282 ch++;
11283 - if (ch > MAX_CHANNEL_NUMBER)
11284 + if (ch > MAX_CHANNEL_NUMBER)
11285 return; /* no channel found */
11286 -
11287 +
11288 }while(!ieee->channel_map[ch]);
11289 -
11290 +
11291 ieee->current_network.channel = ch;
11292 }
11293 -
11294 +
11295 if (ieee->current_network.beacon_interval == 0)
11296 ieee->current_network.beacon_interval = 100;
11297 -
11298 ieee->set_chan(ieee->dev,ieee->current_network.channel);
11299 -
11300 ieee->last_seq_num = -1;
11301 ieee->last_frag_num = -1;
11302 ieee->last_packet_time = 0;
11303 @@ -2107,30 +2149,27 @@
11304 * attempts does not fail just because the user provide the essid
11305 * and the nic is still checking for the AP MAC ??
11306 */
11307 -
11308 +
11309 if (ieee->iw_mode == IW_MODE_INFRA)
11310 - ieee80211_start_bss(ieee);
11311 -
11312 + ieee80211_start_bss_rtl7(ieee);
11313 else if (ieee->iw_mode == IW_MODE_ADHOC)
11314 - ieee80211_start_ibss(ieee);
11315 -
11316 + ieee80211_start_ibss_rtl7(ieee);
11317 else if (ieee->iw_mode == IW_MODE_MASTER)
11318 - ieee80211_start_master_bss(ieee);
11319 -
11320 + ieee80211_start_master_bss_rtl7(ieee);
11321 else if(ieee->iw_mode == IW_MODE_MONITOR)
11322 - ieee80211_start_monitor_mode(ieee);
11323 + ieee80211_start_monitor_mode_rtl7(ieee);
11324 }
11325  
11326  
11327 #define DRV_NAME "Ieee80211"
11328 -void ieee80211_softmac_init(struct ieee80211_device *ieee)
11329 +void ieee80211_softmac_init_rtl7(struct ieee80211_device *ieee)
11330 {
11331 memset(&ieee->current_network, 0, sizeof(struct ieee80211_network));
11332 -
11333 +
11334 ieee->state = IEEE80211_NOLINK;
11335 ieee->sync_scan_hurryup = 0;
11336 ieee->seq_ctrl = 0;
11337 -
11338 +
11339 ieee->assoc_id = 0;
11340 ieee->queue_stop = 0;
11341 ieee->scanning = 0;
11342 @@ -2142,66 +2181,75 @@
11343 ieee->rate = 3;
11344 ieee->ps = IEEE80211_PS_DISABLED;
11345 ieee->sta_sleep = 0;
11346 -
11347 - init_mgmt_queue(ieee);
11348 +
11349 + init_mgmt_queue_rtl7(ieee);
11350 #if 0
11351 init_timer(&ieee->scan_timer);
11352 ieee->scan_timer.data = (unsigned long)ieee;
11353 ieee->scan_timer.function = ieee80211_softmac_scan_cb;
11354 #endif
11355 ieee->tx_pending.txb = NULL;
11356 -
11357 +
11358 init_timer(&ieee->associate_timer);
11359 ieee->associate_timer.data = (unsigned long)ieee;
11360 - ieee->associate_timer.function = ieee80211_associate_abort_cb;
11361 + ieee->associate_timer.function = ieee80211_associate_abort_cb_rtl7;
11362  
11363 init_timer(&ieee->beacon_timer);
11364 ieee->beacon_timer.data = (unsigned long) ieee;
11365 - ieee->beacon_timer.function = ieee80211_send_beacon_cb;
11366 -
11367 + ieee->beacon_timer.function = ieee80211_send_beacon_cb_rtl7;
11368 +
11369 #ifdef PF_SYNCTHREAD
11370 ieee->wq = create_workqueue(DRV_NAME,0);
11371 -#else
11372 +#else
11373 ieee->wq = create_workqueue(DRV_NAME);
11374 #endif
11375 -
11376 - INIT_WORK(&ieee->start_ibss_wq,(void(*)(void*)) ieee80211_start_ibss_wq,ieee);
11377 - INIT_WORK(&ieee->associate_retry_wq,(void(*)(void*)) ieee80211_associate_retry_wq,ieee);
11378 - INIT_WORK(&ieee->associate_complete_wq,(void(*)(void*)) ieee80211_associate_complete_wq,ieee);
11379 - INIT_WORK(&ieee->associate_procedure_wq,(void(*)(void*)) ieee80211_associate_procedure_wq,ieee);
11380 - INIT_WORK(&ieee->softmac_scan_wq,(void(*)(void*)) ieee80211_softmac_scan_wq,ieee);
11381 - INIT_WORK(&ieee->wx_sync_scan_wq,(void(*)(void*)) ieee80211_wx_sync_scan_wq,ieee);
11382 -
11383 +
11384 +#if LINUX_VERSION_CODE < KERNEL_VERSION(2,6,20)
11385 + INIT_WORK(&ieee->start_ibss_wq,(void(*)(void*)) ieee80211_start_ibss_wq_rtl7,ieee);
11386 + INIT_WORK(&ieee->associate_retry_wq,(void(*)(void*)) ieee80211_associate_retry_wq_rtl7,ieee);
11387 + INIT_WORK(&ieee->associate_complete_wq,(void(*)(void*)) ieee80211_associate_complete_wq_rtl7,ieee);
11388 + INIT_WORK(&ieee->associate_procedure_wq,(void(*)(void*)) ieee80211_associate_procedure_wq_rtl7,ieee);
11389 + INIT_WORK(&ieee->softmac_scan_wq,(void(*)(void*)) ieee80211_softmac_scan_wq_rtl7,ieee);
11390 + INIT_WORK(&ieee->wx_sync_scan_wq,(void(*)(void*)) ieee80211_wx_sync_scan_wq_rtl7,ieee);
11391 +#else
11392 + INIT_WORK(&ieee->start_ibss_wq, ieee80211_start_ibss_wq_rtl7);
11393 + INIT_DELAYED_WORK(&ieee->associate_retry_wq, ieee80211_associate_retry_wq_rtl7);
11394 + INIT_WORK(&ieee->associate_complete_wq, ieee80211_associate_complete_wq_rtl7);
11395 + INIT_WORK(&ieee->associate_procedure_wq, ieee80211_associate_procedure_wq_rtl7);
11396 + INIT_DELAYED_WORK(&ieee->softmac_scan_wq, ieee80211_softmac_scan_wq_rtl7);
11397 + INIT_WORK(&ieee->wx_sync_scan_wq, ieee80211_wx_sync_scan_wq_rtl7);
11398 +#endif
11399 +
11400 sema_init(&ieee->wx_sem, 1);
11401 sema_init(&ieee->scan_sem, 1);
11402 -
11403 +
11404 spin_lock_init(&ieee->mgmt_tx_lock);
11405 spin_lock_init(&ieee->beacon_lock);
11406 -
11407 +
11408 tasklet_init(&ieee->ps_task,
11409 - (void(*)(unsigned long)) ieee80211_sta_ps,
11410 + (void(*)(unsigned long)) ieee80211_sta_ps_rtl7,
11411 (unsigned long)ieee);
11412  
11413 }
11414  
11415 -void ieee80211_softmac_free(struct ieee80211_device *ieee)
11416 +void ieee80211_softmac_free_rtl7(struct ieee80211_device *ieee)
11417 {
11418 down(&ieee->wx_sem);
11419 -
11420 +
11421 del_timer_sync(&ieee->associate_timer);
11422 cancel_delayed_work(&ieee->associate_retry_wq);
11423 destroy_workqueue(ieee->wq);
11424 -
11425 +
11426 up(&ieee->wx_sem);
11427 }
11428  
11429 -/********************************************************
11430 +/********************************************************
11431 * Start of WPA code. *
11432 * this is stolen from the ipw2200 driver *
11433 ********************************************************/
11434  
11435 -
11436 -static int ieee80211_wpa_enable(struct ieee80211_device *ieee, int value)
11437 +
11438 +static int ieee80211_wpa_enable_rtl7(struct ieee80211_device *ieee, int value)
11439 {
11440 /* This is called when wpa_supplicant loads and closes the driver
11441 * interface. */
11442 @@ -2210,19 +2258,19 @@
11443 return 0;
11444 }
11445  
11446 -
11447 -void ieee80211_wpa_assoc_frame(struct ieee80211_device *ieee, char *wpa_ie, int wpa_ie_len)
11448 +
11449 +void ieee80211_wpa_assoc_frame_rtl7(struct ieee80211_device *ieee, char *wpa_ie, int wpa_ie_len)
11450 {
11451 /* make sure WPA is enabled */
11452 - ieee80211_wpa_enable(ieee, 1);
11453 + ieee80211_wpa_enable_rtl7(ieee, 1);
11454  
11455 - ieee80211_disassociate(ieee);
11456 + ieee80211_disassociate_rtl7(ieee);
11457 }
11458  
11459  
11460 -static int ieee80211_wpa_mlme(struct ieee80211_device *ieee, int command, int reason)
11461 +static int ieee80211_wpa_mlme_rtl7(struct ieee80211_device *ieee, int command, int reason)
11462 {
11463 -
11464 +
11465 int ret = 0;
11466  
11467 switch (command) {
11468 @@ -2231,7 +2279,7 @@
11469 break;
11470  
11471 case IEEE_MLME_STA_DISASSOC:
11472 - ieee80211_disassociate(ieee);
11473 + ieee80211_disassociate_rtl7(ieee);
11474 break;
11475  
11476 default:
11477 @@ -2243,7 +2291,7 @@
11478 }
11479  
11480  
11481 -static int ieee80211_wpa_set_wpa_ie(struct ieee80211_device *ieee,
11482 +static int ieee80211_wpa_set_wpa_ie_rtl7(struct ieee80211_device *ieee,
11483 struct ieee_param *param, int plen)
11484 {
11485 u8 *buf;
11486 @@ -2267,16 +2315,16 @@
11487 ieee->wpa_ie_len = 0;
11488 }
11489  
11490 - ieee80211_wpa_assoc_frame(ieee, ieee->wpa_ie, ieee->wpa_ie_len);
11491 + ieee80211_wpa_assoc_frame_rtl7(ieee, ieee->wpa_ie, ieee->wpa_ie_len);
11492 return 0;
11493 }
11494  
11495 #define AUTH_ALG_OPEN_SYSTEM 0x1
11496 #define AUTH_ALG_SHARED_KEY 0x2
11497  
11498 -static int ieee80211_wpa_set_auth_algs(struct ieee80211_device *ieee, int value)
11499 +static int ieee80211_wpa_set_auth_algs_rtl7(struct ieee80211_device *ieee, int value)
11500 {
11501 -
11502 +
11503 struct ieee80211_security sec = {
11504 .flags = SEC_AUTH_MODE,
11505 };
11506 @@ -2300,13 +2348,13 @@
11507  
11508  
11509  
11510 -static int ieee80211_wpa_set_param(struct ieee80211_device *ieee, u8 name, u32 value)
11511 +static int ieee80211_wpa_set_param_rtl7(struct ieee80211_device *ieee, u8 name, u32 value)
11512 {
11513 int ret=0;
11514  
11515 switch (name) {
11516 case IEEE_PARAM_WPA_ENABLED:
11517 - ret = ieee80211_wpa_enable(ieee, value);
11518 + ret = ieee80211_wpa_enable_rtl7(ieee, value);
11519 break;
11520  
11521 case IEEE_PARAM_TKIP_COUNTERMEASURES:
11522 @@ -2351,7 +2399,7 @@
11523 break;
11524  
11525 case IEEE_PARAM_AUTH_ALGS:
11526 - ret = ieee80211_wpa_set_auth_algs(ieee, value);
11527 + ret = ieee80211_wpa_set_auth_algs_rtl7(ieee, value);
11528 break;
11529  
11530 case IEEE_PARAM_IEEE_802_1X:
11531 @@ -2368,11 +2416,11 @@
11532  
11533 /* implementation borrowed from hostap driver */
11534  
11535 -static int ieee80211_wpa_set_encryption(struct ieee80211_device *ieee,
11536 +static int ieee80211_wpa_set_encryption_rtl7(struct ieee80211_device *ieee,
11537 struct ieee_param *param, int param_len)
11538 {
11539 int ret = 0;
11540 -
11541 +
11542 struct ieee80211_crypto_ops *ops;
11543 struct ieee80211_crypt_data **crypt;
11544  
11545 @@ -2407,7 +2455,7 @@
11546 //sec.encrypt = 0;
11547 sec.level = SEC_LEVEL_0;
11548 sec.flags |= SEC_ENABLED | SEC_LEVEL;
11549 - ieee80211_crypt_delayed_deinit(ieee, crypt);
11550 + ieee80211_crypt_delayed_deinit_rtl7(ieee, crypt);
11551 }
11552 goto done;
11553 }
11554 @@ -2421,16 +2469,16 @@
11555 strcmp(param->u.crypt.alg, "TKIP"))
11556 goto skip_host_crypt;
11557  
11558 - ops = ieee80211_get_crypto_ops(param->u.crypt.alg);
11559 + ops = ieee80211_get_crypto_ops_rtl7(param->u.crypt.alg);
11560 if (ops == NULL && strcmp(param->u.crypt.alg, "WEP") == 0) {
11561 - request_module("ieee80211_crypt_wep");
11562 - ops = ieee80211_get_crypto_ops(param->u.crypt.alg);
11563 + request_module("ieee80211_crypt_wep_rtl");
11564 + ops = ieee80211_get_crypto_ops_rtl7(param->u.crypt.alg);
11565 } else if (ops == NULL && strcmp(param->u.crypt.alg, "TKIP") == 0) {
11566 - request_module("ieee80211_crypt_tkip");
11567 - ops = ieee80211_get_crypto_ops(param->u.crypt.alg);
11568 + request_module("ieee80211_crypt_tkip_rtl");
11569 + ops = ieee80211_get_crypto_ops_rtl7(param->u.crypt.alg);
11570 } else if (ops == NULL && strcmp(param->u.crypt.alg, "CCMP") == 0) {
11571 - request_module("ieee80211_crypt_ccmp");
11572 - ops = ieee80211_get_crypto_ops(param->u.crypt.alg);
11573 + request_module("ieee80211_crypt_ccmp_rtl");
11574 + ops = ieee80211_get_crypto_ops_rtl7(param->u.crypt.alg);
11575 }
11576 if (ops == NULL) {
11577 printk("unknown crypto alg '%s'\n", param->u.crypt.alg);
11578 @@ -2442,7 +2490,7 @@
11579 if (*crypt == NULL || (*crypt)->ops != ops) {
11580 struct ieee80211_crypt_data *new_crypt;
11581  
11582 - ieee80211_crypt_delayed_deinit(ieee, crypt);
11583 + ieee80211_crypt_delayed_deinit_rtl7(ieee, crypt);
11584  
11585 new_crypt = (struct ieee80211_crypt_data *)
11586 kmalloc(sizeof(*new_crypt), GFP_KERNEL);
11587 @@ -2525,7 +2573,7 @@
11588  
11589  
11590  
11591 -int ieee80211_wpa_supplicant_ioctl(struct ieee80211_device *ieee, struct iw_point *p)
11592 +int ieee80211_wpa_supplicant_ioctl_rtl7(struct ieee80211_device *ieee, struct iw_point *p)
11593 {
11594 struct ieee_param *param;
11595 int ret=0;
11596 @@ -2537,7 +2585,7 @@
11597 ret = -EINVAL;
11598 goto out;
11599 }
11600 -
11601 +
11602 param = (struct ieee_param *)kmalloc(p->length, GFP_KERNEL);
11603 if (param == NULL){
11604 ret = -ENOMEM;
11605 @@ -2552,20 +2600,20 @@
11606 switch (param->cmd) {
11607  
11608 case IEEE_CMD_SET_WPA_PARAM:
11609 - ret = ieee80211_wpa_set_param(ieee, param->u.wpa_param.name,
11610 + ret = ieee80211_wpa_set_param_rtl7(ieee, param->u.wpa_param.name,
11611 param->u.wpa_param.value);
11612 break;
11613  
11614 case IEEE_CMD_SET_WPA_IE:
11615 - ret = ieee80211_wpa_set_wpa_ie(ieee, param, p->length);
11616 + ret = ieee80211_wpa_set_wpa_ie_rtl7(ieee, param, p->length);
11617 break;
11618  
11619 case IEEE_CMD_SET_ENCRYPTION:
11620 - ret = ieee80211_wpa_set_encryption(ieee, param, p->length);
11621 + ret = ieee80211_wpa_set_encryption_rtl7(ieee, param, p->length);
11622 break;
11623  
11624 case IEEE_CMD_MLME:
11625 - ret = ieee80211_wpa_mlme(ieee, param->u.mlme.command,
11626 + ret = ieee80211_wpa_mlme_rtl7(ieee, param->u.mlme.command,
11627 param->u.mlme.reason_code);
11628 break;
11629  
11630 @@ -2581,11 +2629,11 @@
11631 kfree(param);
11632 out:
11633 up(&ieee->wx_sem);
11634 -
11635 +
11636 return ret;
11637 }
11638  
11639 -void notify_wx_assoc_event(struct ieee80211_device *ieee)
11640 +void notify_wx_assoc_event_rtl7(struct ieee80211_device *ieee)
11641 {
11642 union iwreq_data wrqu;
11643 wrqu.ap_addr.sa_family = ARPHRD_ETHER;
11644 @@ -2597,14 +2645,14 @@
11645 }
11646  
11647  
11648 -EXPORT_SYMBOL(ieee80211_get_beacon);
11649 -EXPORT_SYMBOL(ieee80211_wake_queue);
11650 -EXPORT_SYMBOL(ieee80211_stop_queue);
11651 -EXPORT_SYMBOL(ieee80211_reset_queue);
11652 -EXPORT_SYMBOL(ieee80211_softmac_stop_protocol);
11653 -EXPORT_SYMBOL(ieee80211_softmac_start_protocol);
11654 -EXPORT_SYMBOL(ieee80211_is_shortslot);
11655 -EXPORT_SYMBOL(ieee80211_is_54g);
11656 -EXPORT_SYMBOL(ieee80211_wpa_supplicant_ioctl);
11657 -EXPORT_SYMBOL(ieee80211_ps_tx_ack);
11658 -//EXPORT_SYMBOL(ieee80211_sta_ps_send_null_frame);
11659 +EXPORT_SYMBOL(ieee80211_get_beacon_rtl7);
11660 +EXPORT_SYMBOL(ieee80211_wake_queue_rtl7);
11661 +EXPORT_SYMBOL(ieee80211_stop_queue_rtl7);
11662 +EXPORT_SYMBOL(ieee80211_reset_queue_rtl7);
11663 +EXPORT_SYMBOL(ieee80211_softmac_stop_protocol_rtl7);
11664 +EXPORT_SYMBOL(ieee80211_softmac_start_protocol_rtl7);
11665 +EXPORT_SYMBOL(ieee80211_is_shortslot_rtl7);
11666 +EXPORT_SYMBOL(ieee80211_is_54g_rtl7);
11667 +EXPORT_SYMBOL(ieee80211_wpa_supplicant_ioctl_rtl7);
11668 +EXPORT_SYMBOL(ieee80211_ps_tx_ack_rtl7);
11669 +//EXPORT_SYMBOL(ieee80211_sta_ps_send_null_frame_rtl7);
11670 diff -Naur rtl8187_orig/ieee80211/ieee80211_softmac_wx.c rtl8187_rawtx/ieee80211/ieee80211_softmac_wx.c
11671 --- rtl8187_orig/ieee80211/ieee80211_softmac_wx.c 2007-03-13 23:45:09.000000000 +0100
11672 +++ rtl8187_rawtx/ieee80211/ieee80211_softmac_wx.c 2007-07-13 01:46:05.000000000 +0200
11673 @@ -1,7 +1,7 @@
11674 /* IEEE 802.11 SoftMAC layer
11675 * Copyright (c) 2005 Andrea Merello <andreamrl@tiscali.it>
11676 *
11677 - * Mostly extracted from the rtl8180-sa2400 driver for the
11678 + * Mostly extracted from the rtl8180-sa2400 driver for the
11679 * in-kernel generic ieee802.11 stack.
11680 *
11681 * Some pieces of code might be stolen from ipw2100 driver
11682 @@ -18,23 +18,23 @@
11683  
11684 /* FIXME: add A freqs */
11685  
11686 -const long ieee80211_wlan_frequencies[] = {
11687 - 2412, 2417, 2422, 2427,
11688 - 2432, 2437, 2442, 2447,
11689 - 2452, 2457, 2462, 2467,
11690 - 2472, 2484
11691 +const long ieee80211_wlan_frequencies_rtl7[] = {
11692 + 2412, 2417, 2422, 2427,
11693 + 2432, 2437, 2442, 2447,
11694 + 2452, 2457, 2462, 2467,
11695 + 2472, 2484
11696 };
11697  
11698  
11699 -int ieee80211_wx_set_freq(struct ieee80211_device *ieee, struct iw_request_info *a,
11700 +int ieee80211_wx_set_freq_rtl7(struct ieee80211_device *ieee, struct iw_request_info *a,
11701 union iwreq_data *wrqu, char *b)
11702 {
11703 int ret;
11704 struct iw_freq *fwrq = & wrqu->freq;
11705  
11706 down(&ieee->wx_sem);
11707 -
11708 - if(ieee->iw_mode == IW_MODE_INFRA){
11709 +
11710 + if(ieee->iw_mode == IW_MODE_INFRA){
11711 ret = -EOPNOTSUPP;
11712 goto out;
11713 }
11714 @@ -45,31 +45,31 @@
11715 fwrq->m <= (int) 2.487e8)) {
11716 int f = fwrq->m / 100000;
11717 int c = 0;
11718 -
11719 - while ((c < 14) && (f != ieee80211_wlan_frequencies[c]))
11720 +
11721 + while ((c < 14) && (f != ieee80211_wlan_frequencies_rtl7[c]))
11722 c++;
11723 -
11724 +
11725 /* hack to fall through */
11726 fwrq->e = 0;
11727 fwrq->m = c + 1;
11728 }
11729 }
11730 -
11731 - if (fwrq->e > 0 || fwrq->m > 14 || fwrq->m < 1 ){
11732 +
11733 + if (fwrq->e > 0 || fwrq->m > 14 || fwrq->m < 1 ){
11734 ret = -EOPNOTSUPP;
11735 goto out;
11736 -
11737 +
11738 }else { /* Set the channel */
11739 -
11740 -
11741 +
11742 +
11743 ieee->current_network.channel = fwrq->m;
11744 ieee->set_chan(ieee->dev, ieee->current_network.channel);
11745 -
11746 +
11747 if(ieee->iw_mode == IW_MODE_ADHOC || ieee->iw_mode == IW_MODE_MASTER)
11748 if(ieee->state == IEEE80211_LINKED){
11749 -
11750 - ieee80211_stop_send_beacons(ieee);
11751 - ieee80211_start_send_beacons(ieee);
11752 +
11753 + ieee80211_stop_send_beacons_rtl7(ieee);
11754 + ieee80211_start_send_beacons_rtl7(ieee);
11755 }
11756 }
11757  
11758 @@ -80,7 +80,7 @@
11759 }
11760  
11761  
11762 -int ieee80211_wx_get_freq(struct ieee80211_device *ieee,
11763 +int ieee80211_wx_get_freq_rtl7(struct ieee80211_device *ieee,
11764 struct iw_request_info *a,
11765 union iwreq_data *wrqu, char *b)
11766 {
11767 @@ -88,110 +88,110 @@
11768  
11769 if (ieee->current_network.channel == 0)
11770 return -1;
11771 -
11772 +
11773 fwrq->m = ieee->current_network.channel;
11774 fwrq->e = 0;
11775 -
11776 +
11777 return 0;
11778 }
11779  
11780 -int ieee80211_wx_get_wap(struct ieee80211_device *ieee,
11781 - struct iw_request_info *info,
11782 +int ieee80211_wx_get_wap_rtl7(struct ieee80211_device *ieee,
11783 + struct iw_request_info *info,
11784 union iwreq_data *wrqu, char *extra)
11785 {
11786 - unsigned long flags;
11787 -
11788 + unsigned long flags;
11789 +
11790 wrqu->ap_addr.sa_family = ARPHRD_ETHER;
11791 -
11792 +
11793 if (ieee->iw_mode == IW_MODE_MONITOR)
11794 return -1;
11795 -
11796 +
11797 /* We want avoid to give to the user inconsistent infos*/
11798 spin_lock_irqsave(&ieee->lock, flags);
11799 -
11800 - if (ieee->state != IEEE80211_LINKED &&
11801 +
11802 + if (ieee->state != IEEE80211_LINKED &&
11803 ieee->state != IEEE80211_LINKED_SCANNING &&
11804 ieee->wap_set == 0)
11805 -
11806 +
11807 memset(wrqu->ap_addr.sa_data, 0, ETH_ALEN);
11808 else
11809 - memcpy(wrqu->ap_addr.sa_data,
11810 + memcpy(wrqu->ap_addr.sa_data,
11811 ieee->current_network.bssid, ETH_ALEN);
11812 -
11813 +
11814 spin_unlock_irqrestore(&ieee->lock, flags);
11815 -
11816 +
11817 return 0;
11818 }
11819  
11820  
11821 -int ieee80211_wx_set_wap(struct ieee80211_device *ieee,
11822 +int ieee80211_wx_set_wap_rtl7(struct ieee80211_device *ieee,
11823 struct iw_request_info *info,
11824 union iwreq_data *awrq,
11825 char *extra)
11826 {
11827 -
11828 +
11829 int ret = 0;
11830 u8 zero[] = {0,0,0,0,0,0};
11831 unsigned long flags;
11832 -
11833 +
11834 + struct sockaddr *temp = NULL;
11835 short ifup = ieee->proto_started;//dev->flags & IFF_UP;
11836 -
11837 +
11838 ieee->sync_scan_hurryup = 1;
11839 -
11840 +
11841 down(&ieee->wx_sem);
11842 -
11843 - struct sockaddr *temp = (struct sockaddr *)awrq;
11844 -
11845 +
11846 + temp = (struct sockaddr *)awrq;
11847 /* use ifconfig hw ether */
11848 if (ieee->iw_mode == IW_MODE_MASTER){
11849 ret = -1;
11850 goto out;
11851 }
11852 -
11853 +
11854 if (temp->sa_family != ARPHRD_ETHER){
11855 ret = -EINVAL;
11856 goto out;
11857 }
11858 -
11859 +
11860 if (ifup)
11861 - ieee80211_stop_protocol(ieee);
11862 -
11863 + ieee80211_stop_protocol_rtl7(ieee);
11864 +
11865 /* just to avoid to give inconsistent infos in the
11866 - * get wx method. not really needed otherwise
11867 + * get wx method. not really needed otherwise
11868 */
11869 spin_lock_irqsave(&ieee->lock, flags);
11870 -
11871 - memcpy(ieee->current_network.bssid, temp->sa_data, ETH_ALEN);
11872 +
11873 + memcpy(ieee->current_network.bssid, temp->sa_data, ETH_ALEN);
11874 ieee->wap_set = memcmp(temp->sa_data, zero,ETH_ALEN)!=0;
11875 -
11876 +
11877 spin_unlock_irqrestore(&ieee->lock, flags);
11878 -
11879 +
11880 if (ifup)
11881 - ieee80211_start_protocol(ieee);
11882 -
11883 + ieee80211_start_protocol_rtl7(ieee);
11884 +
11885 out:
11886 up(&ieee->wx_sem);
11887 return ret;
11888 }
11889 -
11890 - int ieee80211_wx_get_essid(struct ieee80211_device *ieee, struct iw_request_info *a,union iwreq_data *wrqu,char *b)
11891 +
11892 + int ieee80211_wx_get_essid_rtl7(struct ieee80211_device *ieee, struct iw_request_info *a,union iwreq_data *wrqu,char *b)
11893 {
11894 int len,ret = 0;
11895 unsigned long flags;
11896 -
11897 +
11898 if (ieee->iw_mode == IW_MODE_MONITOR)
11899 return -1;
11900 -
11901 - /* We want avoid to give to the user inconsistent infos*/
11902 +
11903 + /* We want avoid to give to the user inconsistent infos*/
11904 spin_lock_irqsave(&ieee->lock, flags);
11905 -
11906 +
11907 if (ieee->current_network.ssid[0] == '\0' ||
11908 - ieee->current_network.ssid_len == 0){
11909 + ieee->current_network.ssid_len == 0){
11910 ret = -1;
11911 goto out;
11912 }
11913 -
11914 - if (ieee->state != IEEE80211_LINKED &&
11915 +
11916 + if (ieee->state != IEEE80211_LINKED &&
11917 ieee->state != IEEE80211_LINKED_SCANNING &&
11918 ieee->ssid_set == 0){
11919 ret = -1;
11920 @@ -204,59 +204,76 @@
11921  
11922 out:
11923 spin_unlock_irqrestore(&ieee->lock, flags);
11924 -
11925 +
11926 return ret;
11927 -
11928 +
11929 }
11930  
11931 -int ieee80211_wx_set_rate(struct ieee80211_device *ieee,
11932 +int ieee80211_wx_set_rate_rtl7(struct ieee80211_device *ieee,
11933 struct iw_request_info *info,
11934 union iwreq_data *wrqu, char *extra)
11935 {
11936  
11937 u32 target_rate = wrqu->bitrate.value;
11938 -
11939 +
11940 ieee->rate = target_rate/100000;
11941 //FIXME: we might want to limit rate also in management protocols.
11942 - return 0;
11943 + return 0;
11944 }
11945  
11946  
11947  
11948 -int ieee80211_wx_get_rate(struct ieee80211_device *ieee,
11949 - struct iw_request_info *info,
11950 +int ieee80211_wx_get_rate_rtl7(struct ieee80211_device *ieee,
11951 + struct iw_request_info *info,
11952 union iwreq_data *wrqu, char *extra)
11953 {
11954 -
11955 +
11956 wrqu->bitrate.value = ieee->rate * 100000;
11957 -
11958 +
11959 return 0;
11960 }
11961  
11962 -int ieee80211_wx_set_mode(struct ieee80211_device *ieee, struct iw_request_info *a,
11963 +int ieee80211_wx_set_mode_rtl7(struct ieee80211_device *ieee, struct iw_request_info *a,
11964 union iwreq_data *wrqu, char *b)
11965 {
11966 -
11967 + short prev = ieee->raw_tx;
11968 +
11969 ieee->sync_scan_hurryup = 1;
11970 -
11971 +
11972 down(&ieee->wx_sem);
11973 -
11974 +
11975 if (wrqu->mode == ieee->iw_mode)
11976 goto out;
11977 -
11978 +
11979 if (wrqu->mode == IW_MODE_MONITOR){
11980 -
11981 - ieee->dev->type = ARPHRD_IEEE80211;
11982 + ieee->dev->type = ARPHRD_IEEE80211_PRISM;
11983 }else{
11984 ieee->dev->type = ARPHRD_ETHER;
11985 }
11986 -
11987 +
11988 if (!ieee->proto_started){
11989 ieee->iw_mode = wrqu->mode;
11990 }else{
11991 - ieee80211_stop_protocol(ieee);
11992 + ieee80211_stop_protocol_rtl7(ieee);
11993 ieee->iw_mode = wrqu->mode;
11994 - ieee80211_start_protocol(ieee);
11995 + ieee80211_start_protocol_rtl7(ieee);
11996 + }
11997 +
11998 + if(ieee->iw_mode == IW_MODE_MONITOR)
11999 + {
12000 + ieee->raw_tx = 1;
12001 + if(prev == 0 && ieee->raw_tx){
12002 + if (ieee->data_hard_resume)
12003 + ieee->data_hard_resume(ieee->dev);
12004 +
12005 + netif_carrier_on(ieee->dev);
12006 + }
12007 +
12008 + netif_carrier_on(ieee->dev);
12009 + }
12010 + else
12011 + {
12012 + ieee->raw_tx = 0;
12013 }
12014  
12015 out:
12016 @@ -264,120 +281,132 @@
12017 return 0;
12018 }
12019  
12020 -void ieee80211_wx_sync_scan_wq(struct ieee80211_device *ieee)
12021 +# if (LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,20))
12022 +void ieee80211_wx_sync_scan_wq_rtl7(struct work_struct *work)
12023 {
12024 + struct ieee80211_device *ieee = container_of(work, struct ieee80211_device, wx_sync_scan_wq);
12025 +#else
12026 +void ieee80211_wx_sync_scan_wq_rtl7(struct ieee80211_device *ieee)
12027 +{
12028 +#endif
12029 short chan;
12030  
12031 chan = ieee->current_network.channel;
12032 -
12033 +
12034 netif_carrier_off(ieee->dev);
12035 -
12036 +
12037 if (ieee->data_hard_stop)
12038 ieee->data_hard_stop(ieee->dev);
12039 -
12040 - ieee80211_stop_send_beacons(ieee);
12041 -
12042 +
12043 + ieee80211_stop_send_beacons_rtl7(ieee);
12044 +
12045 ieee->state = IEEE80211_LINKED_SCANNING;
12046 ieee->link_change(ieee->dev);
12047 -
12048 - ieee80211_start_scan_syncro(ieee);
12049 -
12050 +
12051 + ieee80211_start_scan_syncro_rtl7(ieee);
12052 +
12053 ieee->set_chan(ieee->dev, chan);
12054 -
12055 +
12056 ieee->state = IEEE80211_LINKED;
12057 ieee->link_change(ieee->dev);
12058 -
12059 +
12060 if (ieee->data_hard_resume)
12061 ieee->data_hard_resume(ieee->dev);
12062 -
12063 +
12064 if(ieee->iw_mode == IW_MODE_ADHOC || ieee->iw_mode == IW_MODE_MASTER)
12065 - ieee80211_start_send_beacons(ieee);
12066 -
12067 + ieee80211_start_send_beacons_rtl7(ieee);
12068 +
12069 netif_carrier_on(ieee->dev);
12070 -
12071 +
12072 up(&ieee->wx_sem);
12073 -
12074 +
12075 }
12076  
12077 -int ieee80211_wx_set_scan(struct ieee80211_device *ieee, struct iw_request_info *a,
12078 +int ieee80211_wx_set_scan_rtl7(struct ieee80211_device *ieee, struct iw_request_info *a,
12079 union iwreq_data *wrqu, char *b)
12080 {
12081 int ret = 0;
12082 -
12083 +
12084 down(&ieee->wx_sem);
12085 -
12086 - if (ieee->iw_mode == IW_MODE_MONITOR || !(ieee->proto_started)){
12087 +
12088 + if (ieee->iw_mode == IW_MODE_MONITOR || !(ieee->proto_started)){
12089 ret = -1;
12090 goto out;
12091 }
12092 -
12093 +
12094 if ( ieee->state == IEEE80211_LINKED){
12095 queue_work(ieee->wq, &ieee->wx_sync_scan_wq);
12096 /* intentionally forget to up sem */
12097 return 0;
12098 }
12099 -
12100 +
12101 out:
12102 up(&ieee->wx_sem);
12103 return ret;
12104 }
12105  
12106 -int ieee80211_wx_set_essid(struct ieee80211_device *ieee,
12107 +int ieee80211_wx_set_essid_rtl7(struct ieee80211_device *ieee,
12108 struct iw_request_info *a,
12109 union iwreq_data *wrqu, char *extra)
12110 {
12111 -
12112 +
12113 int ret=0,len;
12114 short proto_started;
12115 unsigned long flags;
12116 -
12117 +
12118 ieee->sync_scan_hurryup = 1;
12119 -
12120 +
12121 down(&ieee->wx_sem);
12122 -
12123 +
12124 proto_started = ieee->proto_started;
12125 -
12126 +
12127 if (wrqu->essid.length > IW_ESSID_MAX_SIZE){
12128 ret= -E2BIG;
12129 goto out;
12130 }
12131 -
12132 +
12133 if (ieee->iw_mode == IW_MODE_MONITOR){
12134 ret= -1;
12135 goto out;
12136 }
12137 -
12138 +
12139 if(proto_started)
12140 - ieee80211_stop_protocol(ieee);
12141 -
12142 + ieee80211_stop_protocol_rtl7(ieee);
12143 +
12144 /* this is just to be sure that the GET wx callback
12145 * has consisten infos. not needed otherwise
12146 */
12147 spin_lock_irqsave(&ieee->lock, flags);
12148 -
12149 +
12150 if (wrqu->essid.flags && wrqu->essid.length) {
12151 +#if WIRELESS_EXT > 20
12152 + len = min((int)wrqu->essid.length, IW_ESSID_MAX_SIZE);
12153 +#else
12154 len = ((wrqu->essid.length-1) < IW_ESSID_MAX_SIZE) ? (wrqu->essid.length-1) : IW_ESSID_MAX_SIZE;
12155 -
12156 +#endif
12157 +
12158 strncpy(ieee->current_network.ssid, extra, len);
12159 ieee->current_network.ssid_len = len;
12160 ieee->ssid_set = 1;
12161 }
12162 - else{
12163 + else{
12164 ieee->ssid_set = 0;
12165 ieee->current_network.ssid[0] = '\0';
12166 ieee->current_network.ssid_len = 0;
12167 }
12168 -
12169 +
12170 spin_unlock_irqrestore(&ieee->lock, flags);
12171 -
12172 +
12173 if (proto_started)
12174 - ieee80211_start_protocol(ieee);
12175 + ieee80211_start_protocol_rtl7(ieee);
12176 out:
12177 up(&ieee->wx_sem);
12178 +
12179 +
12180 return ret;
12181 }
12182  
12183 - int ieee80211_wx_get_mode(struct ieee80211_device *ieee, struct iw_request_info *a,
12184 + int ieee80211_wx_get_mode_rtl7(struct ieee80211_device *ieee, struct iw_request_info *a,
12185 union iwreq_data *wrqu, char *b)
12186 {
12187  
12188 @@ -385,23 +414,23 @@
12189 return 0;
12190 }
12191  
12192 - int ieee80211_wx_set_rawtx(struct ieee80211_device *ieee,
12193 - struct iw_request_info *info,
12194 + int ieee80211_wx_set_rawtx_rtl7(struct ieee80211_device *ieee,
12195 + struct iw_request_info *info,
12196 union iwreq_data *wrqu, char *extra)
12197 {
12198 -
12199 +
12200 int *parms = (int *)extra;
12201 int enable = (parms[0] > 0);
12202 short prev = ieee->raw_tx;
12203  
12204 down(&ieee->wx_sem);
12205 -
12206 - if(enable)
12207 +
12208 + if(enable)
12209 ieee->raw_tx = 1;
12210 - else
12211 + else
12212 ieee->raw_tx = 0;
12213  
12214 - printk(KERN_INFO"raw TX is %s\n",
12215 + printk(KERN_INFO"raw TX is %s\n",
12216 ieee->raw_tx ? "enabled" : "disabled");
12217  
12218 if(ieee->iw_mode == IW_MODE_MONITOR)
12219 @@ -409,21 +438,21 @@
12220 if(prev == 0 && ieee->raw_tx){
12221 if (ieee->data_hard_resume)
12222 ieee->data_hard_resume(ieee->dev);
12223 -
12224 - netif_carrier_on(ieee->dev);
12225 +
12226 + netif_carrier_on(ieee->dev);
12227 }
12228 -
12229 +
12230 if(prev && ieee->raw_tx == 1)
12231 - netif_carrier_off(ieee->dev);
12232 + netif_carrier_off(ieee->dev);
12233 }
12234 -
12235 +
12236 up(&ieee->wx_sem);
12237 -
12238 +
12239 return 0;
12240 }
12241 -
12242 -int ieee80211_wx_get_name(struct ieee80211_device *ieee,
12243 - struct iw_request_info *info,
12244 +
12245 +int ieee80211_wx_get_name_rtl7(struct ieee80211_device *ieee,
12246 + struct iw_request_info *info,
12247 union iwreq_data *wrqu, char *extra)
12248 {
12249 strcpy(wrqu->name, "802.11");
12250 @@ -433,20 +462,20 @@
12251 strcat(wrqu->name, "/g");
12252 }else if(ieee->modulation & IEEE80211_OFDM_MODULATION)
12253 strcat(wrqu->name, "g");
12254 -
12255 - if((ieee->state == IEEE80211_LINKED) ||
12256 +
12257 + if((ieee->state == IEEE80211_LINKED) ||
12258 (ieee->state == IEEE80211_LINKED_SCANNING))
12259 strcat(wrqu->name," linked");
12260 else if(ieee->state != IEEE80211_NOLINK)
12261 strcat(wrqu->name," link..");
12262 -
12263 -
12264 +
12265 +
12266 return 0;
12267 }
12268  
12269  
12270 /* this is mostly stolen from hostap */
12271 -int ieee80211_wx_set_power(struct ieee80211_device *ieee,
12272 +int ieee80211_wx_set_power_rtl7(struct ieee80211_device *ieee,
12273 struct iw_request_info *info,
12274 union iwreq_data *wrqu, char *extra)
12275 {
12276 @@ -457,50 +486,50 @@
12277 (!ieee->ps_request_tx_ack) ||
12278 (!ieee->enter_sleep_state) ||
12279 (!ieee->ps_is_queue_empty)){
12280 -
12281 +
12282 printk("ERROR. PS mode is tryied to be use but\
12283 -driver missed a callback\n\n");
12284 -
12285 +driver missed a callback\n\n");
12286 +
12287 return -1;
12288 }
12289 -
12290 +
12291 down(&ieee->wx_sem);
12292 -
12293 +
12294 if (wrqu->power.disabled){
12295 ieee->ps = IEEE80211_PS_DISABLED;
12296 -
12297 +
12298 goto exit;
12299 }
12300 switch (wrqu->power.flags & IW_POWER_MODE) {
12301 case IW_POWER_UNICAST_R:
12302 ieee->ps = IEEE80211_PS_UNICAST;
12303 -
12304 +
12305 break;
12306 case IW_POWER_ALL_R:
12307 - ieee->ps = IEEE80211_PS_UNICAST | IEEE80211_PS_MBCAST;
12308 + ieee->ps = IEEE80211_PS_UNICAST | IEEE80211_PS_MBCAST;
12309 break;
12310 -
12311 +
12312 case IW_POWER_ON:
12313 ieee->ps = IEEE80211_PS_DISABLED;
12314 break;
12315 -
12316 +
12317 default:
12318 ret = -EINVAL;
12319 goto exit;
12320 }
12321  
12322 if (wrqu->power.flags & IW_POWER_TIMEOUT) {
12323 -
12324 +
12325 ieee->ps_timeout = wrqu->power.value / 1000;
12326 printk("Timeout %d\n",ieee->ps_timeout);
12327 }
12328 -
12329 +
12330 if (wrqu->power.flags & IW_POWER_PERIOD) {
12331 -
12332 +
12333 ret = -EOPNOTSUPP;
12334 goto exit;
12335 //wrq->value / 1024;
12336 -
12337 +
12338 }
12339 exit:
12340 up(&ieee->wx_sem);
12341 @@ -509,15 +538,15 @@
12342 }
12343  
12344 /* this is stolen from hostap */
12345 -int ieee80211_wx_get_power(struct ieee80211_device *ieee,
12346 +int ieee80211_wx_get_power_rtl7(struct ieee80211_device *ieee,
12347 struct iw_request_info *info,
12348 union iwreq_data *wrqu, char *extra)
12349 {
12350 int ret =0;
12351 -
12352 +
12353 down(&ieee->wx_sem);
12354 -
12355 - if(ieee->ps == IEEE80211_PS_DISABLED){
12356 +
12357 + if(ieee->ps == IEEE80211_PS_DISABLED){
12358 wrqu->power.disabled = 1;
12359 goto exit;
12360 }
12361 @@ -547,19 +576,19 @@
12362  
12363 }
12364  
12365 -EXPORT_SYMBOL(ieee80211_wx_get_essid);
12366 -EXPORT_SYMBOL(ieee80211_wx_set_essid);
12367 -EXPORT_SYMBOL(ieee80211_wx_set_rate);
12368 -EXPORT_SYMBOL(ieee80211_wx_get_rate);
12369 -EXPORT_SYMBOL(ieee80211_wx_set_wap);
12370 -EXPORT_SYMBOL(ieee80211_wx_get_wap);
12371 -EXPORT_SYMBOL(ieee80211_wx_set_mode);
12372 -EXPORT_SYMBOL(ieee80211_wx_get_mode);
12373 -EXPORT_SYMBOL(ieee80211_wx_set_scan);
12374 -EXPORT_SYMBOL(ieee80211_wx_get_freq);
12375 -EXPORT_SYMBOL(ieee80211_wx_set_freq);
12376 -EXPORT_SYMBOL(ieee80211_wx_set_rawtx);
12377 -EXPORT_SYMBOL(ieee80211_wx_get_name);
12378 -EXPORT_SYMBOL(ieee80211_wx_set_power);
12379 -EXPORT_SYMBOL(ieee80211_wx_get_power);
12380 -EXPORT_SYMBOL(ieee80211_wlan_frequencies);
12381 +EXPORT_SYMBOL(ieee80211_wx_get_essid_rtl7);
12382 +EXPORT_SYMBOL(ieee80211_wx_set_essid_rtl7);
12383 +EXPORT_SYMBOL(ieee80211_wx_set_rate_rtl7);
12384 +EXPORT_SYMBOL(ieee80211_wx_get_rate_rtl7);
12385 +EXPORT_SYMBOL(ieee80211_wx_set_wap_rtl7);
12386 +EXPORT_SYMBOL(ieee80211_wx_get_wap_rtl7);
12387 +EXPORT_SYMBOL(ieee80211_wx_set_mode_rtl7);
12388 +EXPORT_SYMBOL(ieee80211_wx_get_mode_rtl7);
12389 +EXPORT_SYMBOL(ieee80211_wx_set_scan_rtl7);
12390 +EXPORT_SYMBOL(ieee80211_wx_get_freq_rtl7);
12391 +EXPORT_SYMBOL(ieee80211_wx_set_freq_rtl7);
12392 +EXPORT_SYMBOL(ieee80211_wx_set_rawtx_rtl7);
12393 +EXPORT_SYMBOL(ieee80211_wx_get_name_rtl7);
12394 +EXPORT_SYMBOL(ieee80211_wx_set_power_rtl7);
12395 +EXPORT_SYMBOL(ieee80211_wx_get_power_rtl7);
12396 +EXPORT_SYMBOL(ieee80211_wlan_frequencies_rtl7);
12397 diff -Naur rtl8187_orig/ieee80211/ieee80211_tx.c rtl8187_rawtx/ieee80211/ieee80211_tx.c
12398 --- rtl8187_orig/ieee80211/ieee80211_tx.c 2007-03-13 23:45:09.000000000 +0100
12399 +++ rtl8187_rawtx/ieee80211/ieee80211_tx.c 2007-07-13 01:46:05.000000000 +0200
12400 @@ -24,15 +24,14 @@
12401  
12402 ******************************************************************************
12403  
12404 - Few modifications for Realtek's Wi-Fi drivers by
12405 + Few modifications for Realtek's Wi-Fi drivers by
12406 Andrea Merello <andreamrl@tiscali.it>
12407 -
12408 - A special thanks goes to Realtek for their support !
12409 +
12410 + A special thanks goes to Realtek for their support !
12411  
12412 ******************************************************************************/
12413  
12414 #include <linux/compiler.h>
12415 -#include <linux/config.h>
12416 #include <linux/errno.h>
12417 #include <linux/if_arp.h>
12418 #include <linux/in6.h>
12419 @@ -52,6 +51,12 @@
12420 #include <linux/etherdevice.h>
12421 #include <asm/uaccess.h>
12422  
12423 +#if (LINUX_VERSION_CODE < KERNEL_VERSION(2,6,19))
12424 +#include <linux/config.h>
12425 +#else
12426 +#include <linux/autoconf.h>
12427 +#endif
12428 +
12429 #include "ieee80211.h"
12430  
12431  
12432 @@ -155,7 +160,7 @@
12433 static u8 P802_1H_OUI[P80211_OUI_LEN] = { 0x00, 0x00, 0xf8 };
12434 static u8 RFC1042_OUI[P80211_OUI_LEN] = { 0x00, 0x00, 0x00 };
12435  
12436 -static inline int ieee80211_put_snap(u8 *data, u16 h_proto)
12437 +static inline int ieee80211_put_snap_rtl7(u8 *data, u16 h_proto)
12438 {
12439 struct ieee80211_snap_hdr *snap;
12440 u8 *oui;
12441 @@ -178,7 +183,7 @@
12442 return SNAP_SIZE + sizeof(u16);
12443 }
12444  
12445 -int ieee80211_encrypt_fragment(
12446 +int ieee80211_encrypt_fragment_rtl7(
12447 struct ieee80211_device *ieee,
12448 struct sk_buff *frag,
12449 int hdr_len)
12450 @@ -225,7 +230,7 @@
12451 }
12452  
12453  
12454 -void ieee80211_txb_free(struct ieee80211_txb *txb) {
12455 +void ieee80211_txb_free_rtl7(struct ieee80211_txb *txb) {
12456 int i;
12457 if (unlikely(!txb))
12458 return;
12459 @@ -235,7 +240,7 @@
12460 kfree(txb);
12461 }
12462  
12463 -struct ieee80211_txb *ieee80211_alloc_txb(int nr_frags, int txb_size,
12464 +struct ieee80211_txb *ieee80211_alloc_txb_rtl7(int nr_frags, int txb_size,
12465 int gfp_mask)
12466 {
12467 struct ieee80211_txb *txb;
12468 @@ -267,7 +272,7 @@
12469 }
12470  
12471 /* SKBs are added to the ieee->tx_queue. */
12472 -int ieee80211_xmit(struct sk_buff *skb,
12473 +int ieee80211_xmit_rtl7(struct sk_buff *skb,
12474 struct net_device *dev)
12475 {
12476 struct ieee80211_device *ieee = netdev_priv(dev);
12477 @@ -299,27 +304,27 @@
12478 }
12479  
12480 if(likely(ieee->raw_tx == 0)){
12481 -
12482 +
12483 if (unlikely(skb->len < SNAP_SIZE + sizeof(u16))) {
12484 printk(KERN_WARNING "%s: skb too small (%d).\n",
12485 ieee->dev->name, skb->len);
12486 goto success;
12487 }
12488 -
12489 -
12490 +
12491 +
12492 ether_type = ntohs(((struct ethhdr *)skb->data)->h_proto);
12493 -
12494 +
12495 crypt = ieee->crypt[ieee->tx_keyidx];
12496 -
12497 +
12498 encrypt = !(ether_type == ETH_P_PAE && ieee->ieee802_1x) &&
12499 ieee->host_encrypt && crypt && crypt->ops;
12500 -
12501 +
12502 if (!encrypt && ieee->ieee802_1x &&
12503 ieee->drop_unencrypted && ether_type != ETH_P_PAE) {
12504 stats->tx_dropped++;
12505 goto success;
12506 }
12507 -
12508 +
12509 #ifdef CONFIG_IEEE80211_DEBUG
12510 if (crypt && !encrypt && ether_type == ETH_P_PAE) {
12511 struct eapol *eap = (struct eapol *)(skb->data +
12512 @@ -328,23 +333,23 @@
12513 eap_get_type(eap->type));
12514 }
12515 #endif
12516 -
12517 +
12518 /* Save source and destination addresses */
12519 memcpy(&dest, skb->data, ETH_ALEN);
12520 memcpy(&src, skb->data+ETH_ALEN, ETH_ALEN);
12521 -
12522 +
12523 /* Advance the SKB to the start of the payload */
12524 skb_pull(skb, sizeof(struct ethhdr));
12525 -
12526 +
12527 /* Determine total amount of storage required for TXB packets */
12528 bytes = skb->len + SNAP_SIZE + sizeof(u16);
12529 -
12530 +
12531 if (encrypt)
12532 fc = IEEE80211_FTYPE_DATA | IEEE80211_STYPE_DATA |
12533 IEEE80211_FCTL_WEP;
12534 else
12535 fc = IEEE80211_FTYPE_DATA | IEEE80211_STYPE_DATA;
12536 -
12537 +
12538 if (ieee->iw_mode == IW_MODE_INFRA) {
12539 fc |= IEEE80211_FCTL_TODS;
12540 /* To DS: Addr1 = BSSID, Addr2 = SA,
12541 @@ -360,9 +365,9 @@
12542 memcpy(&header.addr3, ieee->current_network.bssid, ETH_ALEN);
12543 }
12544 header.frame_ctl = cpu_to_le16(fc);
12545 -
12546 +
12547 hdr_len = IEEE80211_3ADDR_LEN;
12548 -
12549 +
12550 /* Determine fragmentation size based on destination (multicast
12551 * and broadcast are not fragmented) */
12552 if (is_multicast_ether_addr(dest) ||
12553 @@ -370,7 +375,7 @@
12554 frag_size = MAX_FRAG_THRESHOLD;
12555 else
12556 frag_size = ieee->fts;
12557 -
12558 +
12559 /* Determine amount of payload per fragment. Regardless of if
12560 * this stack is providing the full 802.11 header, one will
12561 * eventually be affixed to this fragment -- so we must account for
12562 @@ -379,12 +384,12 @@
12563 if (ieee->config &
12564 (CFG_IEEE80211_COMPUTE_FCS | CFG_IEEE80211_RESERVE_FCS))
12565 bytes_per_frag -= IEEE80211_FCS_LEN;
12566 -
12567 +
12568 /* Each fragment may need to have room for encryptiong pre/postfix */
12569 if (encrypt)
12570 bytes_per_frag -= crypt->ops->extra_prefix_len +
12571 crypt->ops->extra_postfix_len;
12572 -
12573 +
12574 /* Number of fragments is the total bytes_per_frag /
12575 * payload_per_fragment */
12576 nr_frags = bytes / bytes_per_frag;
12577 @@ -393,11 +398,11 @@
12578 nr_frags++;
12579 else
12580 bytes_last_frag = bytes_per_frag;
12581 -
12582 +
12583 /* When we allocate the TXB we allocate enough space for the reserve
12584 * and full fragment bytes (bytes_per_frag doesn't include prefix,
12585 * postfix, header, FCS, etc.) */
12586 - txb = ieee80211_alloc_txb(nr_frags, frag_size, GFP_ATOMIC);
12587 + txb = ieee80211_alloc_txb_rtl7(nr_frags, frag_size, GFP_ATOMIC);
12588 if (unlikely(!txb)) {
12589 printk(KERN_WARNING "%s: Could not allocate TXB\n",
12590 ieee->dev->name);
12591 @@ -405,93 +410,94 @@
12592 }
12593 txb->encrypted = encrypt;
12594 txb->payload_size = bytes;
12595 -
12596 +
12597 for (i = 0; i < nr_frags; i++) {
12598 skb_frag = txb->fragments[i];
12599 -
12600 +
12601 if (encrypt)
12602 skb_reserve(skb_frag, crypt->ops->extra_prefix_len);
12603 -
12604 +
12605 frag_hdr = (struct ieee80211_hdr *)skb_put(skb_frag, hdr_len);
12606 memcpy(frag_hdr, &header, hdr_len);
12607 -
12608 +
12609 /* If this is not the last fragment, then add the MOREFRAGS
12610 * bit to the frame control */
12611 if (i != nr_frags - 1) {
12612 frag_hdr->frame_ctl = cpu_to_le16(
12613 fc | IEEE80211_FCTL_MOREFRAGS);
12614 bytes = bytes_per_frag;
12615 -
12616 +
12617 } else {
12618 /* The last fragment takes the remaining length */
12619 bytes = bytes_last_frag;
12620 }
12621 -
12622 +
12623 frag_hdr->seq_ctl = cpu_to_le16(ieee->seq_ctrl<<4 | i);
12624 -
12625 -
12626 +
12627 +
12628 /* Put a SNAP header on the first fragment */
12629 if (i == 0) {
12630 - ieee80211_put_snap(
12631 + ieee80211_put_snap_rtl7(
12632 skb_put(skb_frag, SNAP_SIZE + sizeof(u16)),
12633 ether_type);
12634 bytes -= SNAP_SIZE + sizeof(u16);
12635 }
12636 -
12637 +
12638 memcpy(skb_put(skb_frag, bytes), skb->data, bytes);
12639 -
12640 +
12641 /* Advance the SKB... */
12642 skb_pull(skb, bytes);
12643 -
12644 +
12645 /* Encryption routine will move the header forward in order
12646 * to insert the IV between the header and the payload */
12647 if (encrypt)
12648 - ieee80211_encrypt_fragment(ieee, skb_frag, hdr_len);
12649 + ieee80211_encrypt_fragment_rtl7(ieee, skb_frag, hdr_len);
12650 if (ieee->config &
12651 (CFG_IEEE80211_COMPUTE_FCS | CFG_IEEE80211_RESERVE_FCS))
12652 skb_put(skb_frag, 4);
12653 }
12654 - // Advance sequence number in data frame.
12655 + // Advance sequence number in data frame.
12656 if (ieee->seq_ctrl == 0xFFF)
12657 ieee->seq_ctrl = 0;
12658 else
12659 ieee->seq_ctrl++;
12660 //---
12661 }else{
12662 - if (unlikely(skb->len < sizeof(struct ieee80211_hdr_3addr))) {
12663 +// if (unlikely(skb->len < sizeof(struct ieee80211_hdr_3addr))) {
12664 + if (unlikely(skb->len < 14)) {
12665 printk(KERN_WARNING "%s: skb too small (%d).\n",
12666 ieee->dev->name, skb->len);
12667 goto success;
12668 }
12669 -
12670 - txb = ieee80211_alloc_txb(1, skb->len, GFP_ATOMIC);
12671 +
12672 + txb = ieee80211_alloc_txb_rtl7(1, skb->len, GFP_ATOMIC);
12673 if(!txb){
12674 printk(KERN_WARNING "%s: Could not allocate TXB\n",
12675 ieee->dev->name);
12676 goto failed;
12677 }
12678 -
12679 +
12680 txb->encrypted = 0;
12681 txb->payload_size = skb->len;
12682 memcpy(skb_put(txb->fragments[0],skb->len), skb->data, skb->len);
12683 - }
12684 + }
12685  
12686 success:
12687 spin_unlock_irqrestore(&ieee->lock, flags);
12688 dev_kfree_skb_any(skb);
12689 if (txb) {
12690 if (ieee->softmac_features & IEEE_SOFTMAC_TX_QUEUE){
12691 - ieee80211_softmac_xmit(txb, ieee);
12692 + ieee80211_softmac_xmit_rtl7(txb, ieee);
12693 }else{
12694 if ((*ieee->hard_start_xmit)(txb, dev) == 0) {
12695 stats->tx_packets++;
12696 stats->tx_bytes += txb->payload_size;
12697 return 0;
12698 }
12699 - ieee80211_txb_free(txb);
12700 + ieee80211_txb_free_rtl7(txb);
12701 }
12702 -
12703 -
12704 +
12705 +
12706 }
12707  
12708 return 0;
12709 @@ -504,4 +510,4 @@
12710  
12711 }
12712  
12713 -EXPORT_SYMBOL(ieee80211_txb_free);
12714 +EXPORT_SYMBOL(ieee80211_txb_free_rtl7);
12715 diff -Naur rtl8187_orig/ieee80211/ieee80211_wx.c rtl8187_rawtx/ieee80211/ieee80211_wx.c
12716 --- rtl8187_orig/ieee80211/ieee80211_wx.c 2007-03-13 23:45:09.000000000 +0100
12717 +++ rtl8187_rawtx/ieee80211/ieee80211_wx.c 2007-07-13 01:46:05.000000000 +0200
12718 @@ -40,7 +40,7 @@
12719 };
12720  
12721 #define MAX_CUSTOM_LEN 64
12722 -static inline char *ipw2100_translate_scan(struct ieee80211_device *ieee,
12723 +static inline char *ipw2100_translate_scan_rtl7(struct ieee80211_device *ieee,
12724 char *start, char *stop,
12725 struct ieee80211_network *network)
12726 {
12727 @@ -207,7 +207,7 @@
12728 return start;
12729 }
12730  
12731 -int ieee80211_wx_get_scan(struct ieee80211_device *ieee,
12732 +int ieee80211_wx_get_scan_rtl7(struct ieee80211_device *ieee,
12733 struct iw_request_info *info,
12734 union iwreq_data *wrqu, char *extra)
12735 {
12736 @@ -220,13 +220,14 @@
12737  
12738 IEEE80211_DEBUG_WX("Getting scan\n");
12739 down(&ieee->wx_sem);
12740 + printk("GOT WX GET SCAN WX_SEM LOCK");
12741 spin_lock_irqsave(&ieee->lock, flags);
12742  
12743 list_for_each_entry(network, &ieee->network_list, list) {
12744 i++;
12745 if (ieee->scan_age == 0 ||
12746 time_after(network->last_scanned + ieee->scan_age, jiffies))
12747 - ev = ipw2100_translate_scan(ieee, ev, stop, network);
12748 + ev = ipw2100_translate_scan_rtl7(ieee, ev, stop, network);
12749 else
12750 IEEE80211_DEBUG_SCAN(
12751 "Not showing network '%s ("
12752 @@ -247,7 +248,7 @@
12753 return 0;
12754 }
12755  
12756 -int ieee80211_wx_set_encode(struct ieee80211_device *ieee,
12757 +int ieee80211_wx_set_encode_rtl7(struct ieee80211_device *ieee,
12758 struct iw_request_info *info,
12759 union iwreq_data *wrqu, char *keybuf)
12760 {
12761 @@ -259,6 +260,9 @@
12762 int i, key, key_provided, len;
12763 struct ieee80211_crypt_data **crypt;
12764  
12765 + if (erq->flags & IW_ENCODE_RESTRICTED)
12766 + return -EINVAL;
12767 +
12768 IEEE80211_DEBUG_WX("SET_ENCODE\n");
12769  
12770 key = erq->flags & IW_ENCODE_INDEX;
12771 @@ -281,7 +285,7 @@
12772 if (key_provided && *crypt) {
12773 IEEE80211_DEBUG_WX("Disabling encryption on key %d.\n",
12774 key);
12775 - ieee80211_crypt_delayed_deinit(ieee, crypt);
12776 + ieee80211_crypt_delayed_deinit_rtl7(ieee, crypt);
12777 } else
12778 IEEE80211_DEBUG_WX("Disabling encryption.\n");
12779  
12780 @@ -291,7 +295,7 @@
12781 if (ieee->crypt[i] != NULL) {
12782 if (key_provided)
12783 break;
12784 - ieee80211_crypt_delayed_deinit(
12785 + ieee80211_crypt_delayed_deinit_rtl7(
12786 ieee, &ieee->crypt[i]);
12787 }
12788 }
12789 @@ -314,7 +318,7 @@
12790 strcmp((*crypt)->ops->name, "WEP") != 0) {
12791 /* changing to use WEP; deinit previously used algorithm
12792 * on this key */
12793 - ieee80211_crypt_delayed_deinit(ieee, crypt);
12794 + ieee80211_crypt_delayed_deinit_rtl7(ieee, crypt);
12795 }
12796  
12797 if (*crypt == NULL) {
12798 @@ -326,10 +330,10 @@
12799 if (new_crypt == NULL)
12800 return -ENOMEM;
12801 memset(new_crypt, 0, sizeof(struct ieee80211_crypt_data));
12802 - new_crypt->ops = ieee80211_get_crypto_ops("WEP");
12803 + new_crypt->ops = ieee80211_get_crypto_ops_rtl7("WEP");
12804 if (!new_crypt->ops) {
12805 - request_module("ieee80211_crypt_wep");
12806 - new_crypt->ops = ieee80211_get_crypto_ops("WEP");
12807 + request_module("ieee80211_crypt_wep_rtl");
12808 + new_crypt->ops = ieee80211_get_crypto_ops_rtl7("WEP");
12809 }
12810  
12811 if (new_crypt->ops && try_module_get(new_crypt->ops->owner))
12812 @@ -340,7 +344,7 @@
12813 new_crypt = NULL;
12814  
12815 printk(KERN_WARNING "%s: could not initialize WEP: "
12816 - "load module ieee80211_crypt_wep\n",
12817 + "load module ieee80211_crypt_wep_rtl\n",
12818 dev->name);
12819 return -EOPNOTSUPP;
12820 }
12821 @@ -418,7 +422,7 @@
12822 return 0;
12823 }
12824  
12825 -int ieee80211_wx_get_encode(struct ieee80211_device *ieee,
12826 +int ieee80211_wx_get_encode_rtl7(struct ieee80211_device *ieee,
12827 struct iw_request_info *info,
12828 union iwreq_data *wrqu, char *keybuf)
12829 {
12830 @@ -430,7 +434,7 @@
12831  
12832 if(ieee->iw_mode == IW_MODE_MONITOR)
12833 return -1;
12834 -
12835 +
12836 key = erq->flags & IW_ENCODE_INDEX;
12837 if (key) {
12838 if (key > WEP_KEYS)
12839 @@ -470,6 +474,6 @@
12840 }
12841  
12842  
12843 -EXPORT_SYMBOL(ieee80211_wx_get_scan);
12844 -EXPORT_SYMBOL(ieee80211_wx_set_encode);
12845 -EXPORT_SYMBOL(ieee80211_wx_get_encode);
12846 +EXPORT_SYMBOL(ieee80211_wx_get_scan_rtl7);
12847 +EXPORT_SYMBOL(ieee80211_wx_set_encode_rtl7);
12848 +EXPORT_SYMBOL(ieee80211_wx_get_encode_rtl7);
12849 diff -Naur rtl8187_orig/ieee80211/Makefile rtl8187_rawtx/ieee80211/Makefile
12850 --- rtl8187_orig/ieee80211/Makefile 2007-03-13 23:45:09.000000000 +0100
12851 +++ rtl8187_rawtx/ieee80211/Makefile 2007-05-27 10:47:26.000000000 +0200
12852 @@ -17,6 +17,7 @@
12853 KVER := $(shell uname -r)
12854 KSRC := /lib/modules/$(KVER)/build
12855 INSTALL_PREFIX :=
12856 +PWD = $(shell pwd)
12857  
12858 all: modules
12859  
12860 diff -Naur rtl8187_orig/ieee80211/Modules.symvers rtl8187_rawtx/ieee80211/Modules.symvers
12861 --- rtl8187_orig/ieee80211/Modules.symvers 2007-03-13 23:45:09.000000000 +0100
12862 +++ rtl8187_rawtx/ieee80211/Modules.symvers 1970-01-01 01:00:00.000000000 +0100
12863 @@ -1,43 +0,0 @@
12864 -0x232e7944 ieee80211_wlan_frequencies /home/woo/rtl8187_linuxdrv_FC2_V1.1_Src/ieee80211/ieee80211-rtl
12865 -0xaeae102f free_ieee80211_rtl /usr/rtl8187_linux_2.6_05312006/ieee80211/ieee80211-rtl
12866 -0x279e265f ieee80211_crypt_deinit_handler net/ieee80211/ieee80211_crypt
12867 -0xc2411d91 ieee80211_stop_queue /home/woo/rtl8187_linuxdrv_FC2_V1.1_Src/ieee80211/ieee80211-rtl
12868 -0x6ece20e1 ieee80211_wx_get_name_rtl /usr/rtl8187_linux_2.6_05312006/ieee80211/ieee80211-rtl
12869 -0x5d3847ff ieee80211_rx_rtl /home/woo/rtl8187_linuxdrv_FC2_V1.1_Src/ieee80211/ieee80211-rtl
12870 -0x18612027 ieee80211_wx_get_scan_rtl /home/woo/rtl8187_linuxdrv_FC2_V1.1_Src/ieee80211/ieee80211-rtl
12871 -0xa0e03ce1 ieee80211_wx_get_name /home/woo/rtl8187_linuxdrv_FC2_V1.1_Src/ieee80211/ieee80211-rtl
12872 -0xee25f349 ieee80211_wx_get_mode /home/woo/rtl8187_linuxdrv_FC2_V1.1_Src/ieee80211/ieee80211-rtl
12873 -0x86013c3d ieee80211_wx_set_mode /home/woo/rtl8187_linuxdrv_FC2_V1.1_Src/ieee80211/ieee80211-rtl
12874 -0x04493cc0 ieee80211_wx_get_rate /home/woo/rtl8187_linuxdrv_FC2_V1.1_Src/ieee80211/ieee80211-rtl
12875 -0x6c6df3b4 ieee80211_wx_set_rate /home/woo/rtl8187_linuxdrv_FC2_V1.1_Src/ieee80211/ieee80211-rtl
12876 -0x82caec02 ieee80211_crypt_deinit_entries net/ieee80211/ieee80211_crypt
12877 -0x347945bf ieee80211_wx_get_power /home/woo/rtl8187_linuxdrv_FC2_V1.1_Src/ieee80211/ieee80211-rtl
12878 -0x6379d455 ieee80211_wx_set_power /home/woo/rtl8187_linuxdrv_FC2_V1.1_Src/ieee80211/ieee80211-rtl
12879 -0xae62ed59 ieee80211_wx_set_scan /home/woo/rtl8187_linuxdrv_FC2_V1.1_Src/ieee80211/ieee80211-rtl
12880 -0x6621e172 ieee80211_wx_set_freq /home/woo/rtl8187_linuxdrv_FC2_V1.1_Src/ieee80211/ieee80211-rtl
12881 -0x0e052e06 ieee80211_wx_get_freq /home/woo/rtl8187_linuxdrv_FC2_V1.1_Src/ieee80211/ieee80211-rtl
12882 -0x283f9f5d ieee80211_unregister_crypto_ops net/ieee80211/ieee80211_crypt
12883 -0x9da79aac ieee80211_is_shortslot /home/woo/rtl8187_linuxdrv_FC2_V1.1_Src/ieee80211/ieee80211-rtl
12884 -0x666032dc ieee80211_wx_get_wap /home/woo/rtl8187_linuxdrv_FC2_V1.1_Src/ieee80211/ieee80211-rtl
12885 -0x9f1cbe0e ieee80211_wx_set_wap /home/woo/rtl8187_linuxdrv_FC2_V1.1_Src/ieee80211/ieee80211-rtl
12886 -0x73d1d341 ieee80211_wx_set_rawtx /home/woo/rtl8187_linuxdrv_FC2_V1.1_Src/ieee80211/ieee80211-rtl
12887 -0x2c714184 ieee80211_is_54g /home/woo/rtl8187_linuxdrv_FC2_V1.1_Src/ieee80211/ieee80211-rtl
12888 -0x6892d598 ieee80211_wpa_supplicant_ioctl /home/woo/rtl8187_linuxdrv_FC2_V1.1_Src/ieee80211/ieee80211-rtl
12889 -0xc062f1f5 ieee80211_ps_tx_ack /home/woo/rtl8187_linuxdrv_FC2_V1.1_Src/ieee80211/ieee80211-rtl
12890 -0x55534906 ieee80211_get_beacon /home/woo/rtl8187_linuxdrv_FC2_V1.1_Src/ieee80211/ieee80211-rtl
12891 -0xe2679638 ieee80211_crypt_delayed_deinit net/ieee80211/ieee80211_crypt
12892 -0x3a0456bc free_ieee80211 net/ieee80211/ieee80211
12893 -0x7e1ef2c8 ieee80211_wake_queue /home/woo/rtl8187_linuxdrv_FC2_V1.1_Src/ieee80211/ieee80211-rtl
12894 -0xc1b81e9f ieee80211_register_crypto_ops net/ieee80211/ieee80211_crypt
12895 -0x3f795a39 alloc_ieee80211 net/ieee80211/ieee80211
12896 -0x89803c23 ieee80211_get_crypto_ops net/ieee80211/ieee80211_crypt
12897 -0xc6caf2a4 ieee80211_txb_free net/ieee80211/ieee80211
12898 -0x49c1422c ieee80211_rx_mgt net/ieee80211/ieee80211
12899 -0xbf2b4ebd alloc_ieee80211_rtl /usr/rtl8187_linux_2.6_05312006/ieee80211/ieee80211-rtl
12900 -0xd155f7b8 ieee80211_softmac_stop_protocol /home/woo/rtl8187_linuxdrv_FC2_V1.1_Src/ieee80211/ieee80211-rtl
12901 -0x9ce2dcde ieee80211_softmac_start_protocol /home/woo/rtl8187_linuxdrv_FC2_V1.1_Src/ieee80211/ieee80211-rtl
12902 -0x00d74bba ieee80211_wx_get_encode_rtl /home/woo/rtl8187_linuxdrv_FC2_V1.1_Src/ieee80211/ieee80211-rtl
12903 -0x92b5d996 ieee80211_wx_set_encode_rtl /home/woo/rtl8187_linuxdrv_FC2_V1.1_Src/ieee80211/ieee80211-rtl
12904 -0x2ac9bf95 ieee80211_wx_set_essid /home/woo/rtl8187_linuxdrv_FC2_V1.1_Src/ieee80211/ieee80211-rtl
12905 -0x7dc92e7f ieee80211_wx_get_essid /home/woo/rtl8187_linuxdrv_FC2_V1.1_Src/ieee80211/ieee80211-rtl
12906 -0xd04740ca ieee80211_reset_queue /home/woo/rtl8187_linuxdrv_FC2_V1.1_Src/ieee80211/ieee80211-rtl
12907 diff -Naur rtl8187_orig/Makefile rtl8187_rawtx/Makefile
12908 --- rtl8187_orig/Makefile 1970-01-01 01:00:00.000000000 +0100
12909 +++ rtl8187_rawtx/Makefile 2007-06-21 23:43:15.000000000 +0200
12910 @@ -0,0 +1,39 @@
12911 +prefix = /lib/modules/$(shell uname -r)/kernel/drivers/net/wireless
12912 +r8187dir = $(prefix)/rtl8187
12913 +ieeedir = $(prefix)/rtl_ieee80211
12914 +
12915 +default: all
12916 +
12917 +all:
12918 + -rm -f ieee80211/Module.symvers 2>/dev/null
12919 + -rm -f ieee80211/Modules.symvers 2>/dev/null
12920 + $(MAKE) -C ieee80211 $(@)
12921 + -chmod +x symvers
12922 + -./symvers
12923 + $(MAKE) -C beta-8187 $(@)
12924 +
12925 +install:
12926 + install -d $(ieeedir)
12927 + install -d $(r8187dir)
12928 + install -m 644 ./ieee80211/*.ko $(ieeedir)
12929 + install -m 644 ./beta-8187/*.ko $(r8187dir)
12930 + -find /lib/modules/$(shell uname -r) -name rtl8187.ko -exec mv -v {} ~/ \;
12931 + -depmod -ae
12932 +
12933 +uninstall:
12934 + -rm -f $(ieeedir)/ieee80211-rtl.ko
12935 + -rm -f $(ieeedir)/ieee80211_crypt-rtl.ko
12936 + -rm -f $(ieeedir)/ieee80211_crypt_ccmp-rtl.ko
12937 + -rm -f $(ieeedir)/ieee80211_crypt_tkip-rtl.ko
12938 + -rm -f $(ieeedir)/ieee80211_crypt_wep-rtl.ko
12939 + -rm -f $(r8187dir)/r8187.ko
12940 + -rm -fr $(ieeedir)
12941 + -rm -fr $(r8187dir)
12942 + -depmod -ae
12943 +
12944 +clean:
12945 + $(MAKE) -C ieee80211 $(@)
12946 + $(MAKE) -C beta-8187 $(@)
12947 +
12948 +distclean: clean
12949 +
12950 diff -Naur rtl8187_orig/symvers rtl8187_rawtx/symvers
12951 --- rtl8187_orig/symvers 1970-01-01 01:00:00.000000000 +0100
12952 +++ rtl8187_rawtx/symvers 2007-05-26 10:39:22.000000000 +0200
12953 @@ -0,0 +1,25 @@
12954 +#!/bin/sh
12955 +
12956 +cd beta-8187
12957 +
12958 +if [ -e Module.symvers ]
12959 +then
12960 + rm Module.symvers
12961 +fi
12962 +
12963 +if [ -e Modules.symvers ]
12964 +then
12965 + rm Modules.symvers
12966 +fi
12967 +
12968 +if [ -e ../ieee80211/Module.symvers ]
12969 +then
12970 + ln -sf ../ieee80211/Module.symvers ./
12971 +fi
12972 +
12973 +if [ -e ../ieee80211/Modules.symvers ]
12974 +then
12975 + ln -sf ../ieee80211/Modules.symvers ./
12976 +fi
12977 +
12978 +cd ..
12979 diff -Naur rtl8187_orig/wlan0rmv rtl8187_rawtx/wlan0rmv
12980 --- rtl8187_orig/wlan0rmv 2007-03-13 23:45:09.000000000 +0100
12981 +++ rtl8187_rawtx/wlan0rmv 2007-06-26 16:32:43.000000000 +0200
12982 @@ -1,5 +1,9 @@
12983 #!/bin/bash
12984  
12985 -rmmod r8180
12986 -rmmod ieee80211_r8180
12987 -rmmod ieee80211_crypt_r8180
12988 +rmmod rtl8187 2>/dev/null
12989 +rmmod r8187 2>/dev/null
12990 +rmmod ieee80211_rtl 2>/dev/null
12991 +rmmod ieee80211_crypt_ccmp_rtl 2>/dev/null
12992 +rmmod ieee80211_crypt_tkip_rtl 2>/dev/null
12993 +rmmod ieee80211_crypt_wep_rtl 2>/dev/null
12994 +rmmod ieee80211_crypt_rtl 2>/dev/null